<commit_before><?php

namespace Pagekit\Widget\Event;

use Pagekit\Framework\Event\EventSubscriber;
use Pagekit\Widget\Entity\Widget;

class WidgetListener extends EventSubscriber
{
    /**
     * Handles the widget to position assignment.
     */
    public function onSystemSite()
    {
        $request   = $this['request'];
        $active    = (array) $request->attributes->get('_menu');
        $user      = $this['user'];
        $sections  = $this['view.sections'];

        foreach ($this['widgets']->getWidgetRepository()->where('status = ?', [Widget::STATUS_ENABLED])->orderBy('priority')->get() as $widget) {

            // filter by access
            if (!$widget->hasAccess($user)) {
                continue;
            }

            // filter by menu items and pages
            $items = $widget->getMenuItems();
            $pages = $widget->getPages();

            $itemsMatch = (bool) array_intersect($items, $active);
            $pagesMatch = $this->matchPath($request->getPathInfo(), $pages);

            if (!( ((!$items || $itemsMatch) && (!$pages || $pagesMatch)) || ($items && $itemsMatch) || ($pages && $pagesMatch) )) {
                continue;
            }

            $sections->append($widget->getPosition(), [$widget->getId() => $widget]);
        }
    }

    /**<commit_msg>cleanup<commit_after><?php

namespace Pagekit\Widget\Event;

use Pagekit\Framework\Event\EventSubscriber;
use Pagekit\Widget\Entity\Widget;

class WidgetListener extends EventSubscriber
{
    /**
     * Handles the widget to position assignment.
     */
    public function onSystemSite()
    {
        $request   = $this['request'];
        $active    = (array) $request->attributes->get('_menu');
        $user      = $this['user'];
        $sections  = $this['view.sections'];

        foreach ($this['widgets']->getWidgetRepository()->where('status = ?', [Widget::STATUS_ENABLED])->orderBy('priority')->get() as $widget) {

            // filter by access
            if (!$widget->hasAccess($user)) {
                continue;
            }

            // filter by menu items and pages
            $items = $widget->getMenuItems();
            $pages = $widget->getPages();

            $itemsMatch = (bool) array_intersect($items, $active);
            $pagesMatch = $this->matchPath($request->getPathInfo(), $pages);

            if (!( ((!$items || $itemsMatch) && (!$pages || $pagesMatch)) || ($items && $itemsMatch) || ($pages && $pagesMatch) )) {
                continue;
            }

            $sections->append($widget->getPosition(), $widget);
        }
    }

    /**
{'fraction_non_alphanumeric': 0.17152724481964696, 'fraction_numerical': 0.0, 'mean_word_length': 2.283375314861461, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '3310007', 'n_tokens_mistral': 714, 'n_tokens_neox': 705, 'n_words': 139}