<commit_before><?php
namespace App\Event\Plugin\Search\View;

use Cake\Event\Event;
use Cake\Event\EventListenerInterface;
use Cake\Network\Request;
use Cake\ORM\Entity;
use Search\Event\EventName;

class MenuListener implements EventListenerInterface
{
    /**
     * Menu element name
     */
    const MENU_ELEMENT = 'Menu.menu';

    /**
     * Implemented Events
     *
     * @return array
     */
    public function implementedEvents()
    {
        return [
            (string)EventName::MENU_TOP_DASHBOARD_VIEW() => 'getDashboardsViewMenuTop',
            (string)EventName::MENU_ACTIONS_SEARCH_VIEW() => 'getSearchResultsIndexMenuActions',
        ];
    }

    /**
     * Method that adds elements to Dashboards view View top menu.
     *
     * @param  Cake\Event\Event     $event   Event object
     * @param  Cake\Network\Request $request Request object
     * @param  Cake\ORM\Entity      $entity  Entity object
     * @return void
     */
    public function getDashboardsViewMenuTop(Event $event, Request $request, Entity $entity)
    {
        $urlEdit = [
            'plugin' => $request->plugin,
            'controller' => $request->controller,
            'action' => 'edit',
            $entity->id
        ];
        $btnEdit = ' ' . $event->subject()->Html->link(
            '<i class="fa fa-pencil"></i> ' . __('Edit'),
            $urlEdit,
            ['escape' => false, 'title' => __('Edit'), 'class' => 'btn btn-default']
        );

        $urlDel = [
            'plugin' => $request->plugin,
            'controller' => $request->controller,
            'action' => 'delete',
            $entity->id
        ];
        $btnDel = ' ' . $event->subject()->Form->postLink(
            '<i class="fa fa-trash"></i> ' . __('Delete'),
            $urlDel,
            [
                'confirm' => __('Are you sure you want to delete {0}?', $entity->name),
                'title' => __('Delete'),
                'escape' => false,
                'class' => 'btn btn-default'
            ]
        );

        $menu = [
            [
                'label' => $btnEdit,
                'url' => $urlEdit,
                'capabilities' => 'fromUrl'
            ],
            [
                'label' => $btnDel,
                'url' => $urlDel,
                'capabilities' => 'fromUrl'
            ]<commit_msg>Fixed dashboard buttons<commit_after><?php
namespace App\Event\Plugin\Search\View;

use Cake\Event\Event;
use Cake\Event\EventListenerInterface;
use Cake\Network\Request;
use Cake\ORM\Entity;
use Search\Event\EventName;

class MenuListener implements EventListenerInterface
{
    /**
     * Menu element name
     */
    const MENU_ELEMENT = 'Menu.menu';

    /**
     * Implemented Events
     *
     * @return array
     */
    public function implementedEvents()
    {
        return [
            (string)EventName::MENU_TOP_DASHBOARD_VIEW() => 'getDashboardsViewMenuTop',
            (string)EventName::MENU_ACTIONS_SEARCH_VIEW() => 'getSearchResultsIndexMenuActions',
        ];
    }

    /**
     * Method that adds elements to Dashboards view View top menu.
     *
     * @param  Cake\Event\Event     $event   Event object
     * @param  Cake\Network\Request $request Request object
     * @param  Cake\ORM\Entity      $entity  Entity object
     * @return void
     */
    public function getDashboardsViewMenuTop(Event $event, Request $request, Entity $entity)
    {
        $urlEdit = [
            'plugin' => $request->plugin,
            'controller' => $request->controller,
            'action' => 'edit',
            $entity->id
        ];
        $btnEdit = ' ' . $event->subject()->Html->link(
            '<i class="fa fa-pencil"></i> ' . __('Edit'),
            $urlEdit,
            ['escape' => false, 'title' => __('Edit'), 'class' => 'btn btn-default']
        );

        $urlDel = [
            'plugin' => $request->plugin,
            'controller' => $request->controller,
            'action' => 'delete',
            $entity->id
        ];
        $btnDel = ' ' . $event->subject()->Form->postLink(
            '<i class="fa fa-trash"></i> ' . __('Delete'),
            $urlDel,
            [
                'confirm' => __('Are you sure you want to delete {0}?', $entity->name),
                'title' => __('Delete'),
                'escape' => false,
                'class' => 'btn btn-default'
            ]
        );

        $menu = [
            [
                'label' => $btnEdit,
                'url' => $urlEdit,
                'capabilities' => 'fromUrl',
                'icon' => 'pencil',
                'type' => 'link_button',
            ],
            [
                'label' => $btnDel,
                'url' => $urlDel,
                'capabilities' => 'fromUrl',
                'icon' => 'trash',
                'type' => 'link_button',
            ]
{'fraction_non_alphanumeric': 0.1489841986455982, 'fraction_numerical': 0.0004104247896572953, 'mean_word_length': 1.6474741988049972, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2641859', 'n_tokens_mistral': 1424, 'n_tokens_neox': 1379, 'n_words': 284}