Add the production filter to the main query.

@param FilterCollectionEvent $event The filter collection event.

@return void
516267
public function addProductionFilter(FilterCollectionEvent $event): void
    {
        $now = new \DateTime();
        $qb = $event->getQueryBuilder();
        $query = $qb->query()->bool()
            ->addMust($qb->query()->term(['_index' => 'production']))
            ->addMust($qb->query()->term(['active' => true]))
            ->addMust($qb->query()->terms('id', $event->getGroupIds()))
            ->addMust(
                $qb->query()->bool()
                    ->addShould($qb->query()->range('expiry', ['gt' => $now->format('U') * 1000]))
                    ->addShould($qb->query()->bool()->addMustNot($qb->query()->exists('expiry')))
            )
        ;
        $event->addFilter($query);
    }
519236
public function onCollectionBefore(CollectionEvent $event)
    {
        $target = $event->getTarget();

        $this->output->writeln(sprintf(
            '<info>[START]</info> Migrating %s to <comment>%s</comment>:',
            $event->getOptions()->isDirectionUp() ? 'up' : 'down',
            $target->getId()
        ));
        if ($this->trackProgress) {
            $this->progress = new ProgressBar($this->output, $event->getProgress()->getTotal());
            $this->progress->setFormat('verbose');
            $this->progress->setProgress(0);
        }
    }
596928
public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();
        $template = $request->attributes->get('_template');

        if (!$template instanceof Template) {
            return;
        }

        $controller = $event->getController();
        if (!\is_array($controller) && method_exists($controller, '__invoke')) {
            $controller = [$controller, '__invoke'];
        }
        $template->setOwner($controller);

        // when no template has been given, try to resolve it based on the controller
        if (null === $template->getTemplate()) {
            $template->setTemplate($this->templateGuesser->guessTemplateName($controller, $request));
        }
    }
476455
public function filterConditions(IndexEngineIndexEvent $event)
    {
        $conditions = $event->getConditions();
        $event->setConditions([]);

        $event->addCondition("criteria", $conditions);
    }
164137
public function addEvent($collection, array $event = array())
    {
        $event['event_collection'] = $collection;
        $event['projectId'] = $this->getConfig('projectId');
        $event['writeKey'] = $this->getKeyForWriting();

        $command = parent::getCommand('addEvent', $event);

        return $this->execute($command);
    }
769016
public function onPostRender(FilterPostRenderEvent $event): void
    {
        foreach ($this->registry->getTemplateFilters() as $filter) {
            if (null !== ($mailRendered = $event->getMailRendered())
                    && $filter->supports($mailRendered)) {
                $filter->filter($mailRendered);
            }
        }
    }
434208
public function onKernelResponse(FilterResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $blockView = $event->getRequest()->attributes->get('ngbmView');
        if (!$blockView instanceof BlockViewInterface) {
            return;
        }

        $this->tagger->tagBlock($event->getResponse(), $blockView->getBlock());
    }
1344534
public function addScheduleFilter(FilterCollectionEvent $event): void
    {
        $now = new \DateTime();
        $qb = $event->getQueryBuilder();
        $query = $qb->query()->bool()
            ->addMust($qb->query()->term(['_index' => 'schedule']))
            ->addMust($qb->query()->term(['active' => true]))
            ->addMust($qb->query()->terms('groups.id', $event->getGroupIds()))
        ;
        $event->addFilter($query);
    }
226953
public function addProductionMenuItems(MenuCollectionEvent $event): void
    {
        // We only operate on group member users.
        $user = $this->token_storage->getToken()->getUser();
        if (!$user instanceof GroupMemberInterface) {
            return;
        }

        // Create productions menu dropdown item.
        $productions = $this->factory->createItem('menu_item.productions', [
            'extras' => ['translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN],
        ]);

        $items = [];
        foreach ($user->getMemberships() as $membership) {
            // Get the group for this membership, if not a production skip out.
            $group = $membership->getGroup();

            // If the membership and production are active and not expired.
            if ($membership->isActive()
                && !$membership->isExpired()
                && $group->isActive()
                && !$group->isExpired()) {
                // The membership is good, add a menu item.
                $items[] = $this->factory->createItem($membership->getGroup()->getName(), [
                    'route' => 'bkstg_production_read',
                    'routeParameters' => ['production_slug' => $membership->getGroup()->getSlug()],
                    'extras' => ['translation_domain' => false],
                ]);
            }
        }

        if (0 === count($user->getMemberships())) {
            $productions->addChild($this->factory->createItem('menu_item.no_productions', [
                'uri' => '#',
                'extras' => [
                    'translation_domain' => BkstgCoreBundle::TRANSLATION_DOMAIN,
                ],
            ]));
        } else {
            // Add all children (in alpha order) to production item.
            usort($items, function ($a, $b) {
                return strcasecmp($a->getLabel(), $b->getLabel());
            });
            $productions->setChildren($items);
        }

        // Add the production menu item to the main menu.
        $menu = $event->getMenu();
        $menu->addChild($productions);
    }
639645
public function getFilter(GetFilterEvent $event): void
    {
        $filter = $this->buildSharingFilter($event);
        $filter = $this->buildOwnerFilter($event, $filter);

        $event->setFilterConstraint($filter);
    }
705018
public function beforeFilter(Event $event)
    {
        EventManager::trigger('Controller.setup', $this);

        $pluginEvent = Plugin::getData('Core', 'Controller.beforeFilter');
        if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeFilter')) {
            call_user_func_array($pluginEvent->find(0), [$this, $event]);
        }
    }
1203306
private boolean filter(Event event) {
        if (null == filters) return false;

        for (EventFilter filter : filters) {
            if (filter.filter(event)) {
                return true;
            }
        }
        return false;
    }
28131
public function onKernelResponse(FilterResponseEvent $event): void
    {
        $link = new Link('mercure', $this->hub);

        $attributes = $event->getRequest()->attributes;
        if (
            null === ($resourceClass = $attributes->get('_api_resource_class')) ||
            false === $this->resourceMetadataFactory->create($resourceClass)->getAttribute('mercure', false)
        ) {
            return;
        }

        if (null === $linkProvider = $attributes->get('_links')) {
            $attributes->set('_links', new GenericLinkProvider([$link]));

            return;
        }

        $attributes->set('_links', $linkProvider->withLink($link));
    }
1224467
public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();
        $request  = $event->getRequest();
        if (!$event->isMasterRequest())
        {
            return;
        }
        if ($request->isXmlHttpRequest())
        {
            return;
        }
        $this->_injectDatatableScript($response, $request);
    }
421594
public function onKernelController(FilterControllerEvent $event)
    {
        $request = $event->getRequest();
        $route = $this->routes->get($request->attributes->get('_route'));
        if ($route && $converters = $route->getOption('_converters')) {
            foreach ($converters as $name => $callback) {
                $callback = $this->callbackResolver->resolveCallback($callback);

                $request->attributes->set($name, call_user_func($callback, $request->attributes->get($name), $request));
            }
        }
    }
1318203
public function onPostBind($event)
    {
        $form = $event->getForm();

        if ( ! $form->isRoot()) return;

        $clientData = $event->getForm()->getData();

        if ( ! is_object($clientData)) return;

        $this->filterService->filterEntity($clientData);

    }
1366184
protected function filterFields(Event $event) : void
    {
        $panelActions = (array)Configure::read('CsvMigrations.panels.actions');
        $dynamicPanelActions = (array)Configure::read('CsvMigrations.panels.dynamic_actions');
        if (!in_array($this->request->getParam('action'), array_diff($panelActions, $dynamicPanelActions))) {
            return;
        }

        $controller = $event->getSubject();
        Assert::isInstanceOf($controller, Controller::class);

        $config = new ModuleConfig(ConfigType::MODULE(), $controller->getName());
        $config = json_encode($config->parse());
        $config = false === $config ? [] : json_decode($config, true);

        $panels = $this->getPanels($config, $controller->viewVars['entity']->toArray());
        if (! empty($panels['fail'])) {
            // filter out fields of hidden panels
            $controller->viewVars['fields'] = array_diff_key(
                $controller->viewVars['fields'],
                array_flip($panels['fail'])
            );
        }

        if ((string)Configure::read('CsvMigrations.batch.action') === $this->request->getParam('action')) {
            $this->filterBatchFields($event);
        }
    }