BeforeFilter Event

This method will check if the `initMenuItems`-method exists in the
`AppController`. That method contains menu-items to add.

@param \Cake\Event\Event $event Event.
@return void
357127
public function beforeFilter($event)
    {
        $this->setController($event->subject());

        if (method_exists($this->Controller, 'initMenuItems')) {
            $this->Controller->initMenuItems($event);
        }
    }
761496
public function onViewBeforeRender(Event $event)
    {
        /**
         * @var Container $container
         * @var Profiler  $profiler
         */
        $container = $event['view']->getPackage()->getContainer();
        $profiler  = $container->get('profiler');

        $name = $event['view']->getPackage()->name . '@' . $event['view']->getName();

        $profiler->mark(__FUNCTION__ . ' / ' . $name . ' (' . uniqid() . ')', [
            'tag' => 'package.process',
        ]);
    }
202917
public function beforeFilter(Event $event)
    {
        if (is_readable(ROOT . '/config/settings.php')) {
            $this->redirect('/');
        }

        $this->_prepareLayout();
        $this->viewBuilder()
            ->className('CMS\View\View')
            ->theme(false)
            ->layout('Installer.startup')
            ->helpers(['Menu.Menu']);

        if (!empty($this->request->query['locale']) && !in_array($this->request->params['action'], ['language', 'index'])) {
            I18n::locale($this->request->query['locale']);
            $this->request->session()->write('installation.language', I18n::locale());
        } elseif ($this->request->session()->read('installation.language')) {
            I18n::locale($this->request->session()->read('installation.language'));
        }

        Router::addUrlFilter(function ($params, $request) {
            if (!in_array($request->params['action'], ['language', 'index'])) {
                $params['locale'] = I18n::locale();
            }

            return $params;
        });
    }
857105
public function beforeSend($event = null)
    {
        if (isset($this->stream)) {
            return;
        }
        if (isset($this->controller) && $this->task) {
            if ($this->isInstructable) {
                $this->format = static::FORMAT_JSON;
                $this->data = $this->generateInstructions();
            } else {
                $this->handleFlashStatus();
                if ($this->redirect) {
                    $this->redirect($this->redirect);
                } elseif ($this->refresh) {
                    $this->refresh();
                } else {
                    if (is_null($this->content)) {
                        $this->content = $this->renderContent(true);
                    }
                }
            }
        }
    }
115023
public function beforeFilter(\Cake\Event\Event $event)
    {
        parent::beforeFilter($event);

        $this->loadModel('Settings.Configurations');

        $this->prefixes = Configure::read('Settings.Prefixes');

        $this->Menu->active('ca.settings');
        $this->Menu->area('navbar');

        foreach ($this->prefixes as $prefix => $alias) {
            $this->Menu->add($alias, [
                'url' => [
                    'action' => 'index', $prefix,
                ]
            ]);
        }
    }
1148198
public function beforeFilter(Event $event) {
		$actions = $this->getConfig('actions');
		if ($actions && !in_array($this->controller->request->param('action'), $actions)) {
			return;
		}

		$model = $this->controller->modelClass;
		if (!isset($this->controller->$model) || $this->controller->$model->hasBehavior('Captcha')) {
			return;
		}
		$this->controller->$model->addBehavior('Captcha.Captcha');
	}
1361031
public function adminBeforeRender($event)
    {
        // setting up the default title-variable for default view
        if (!key_exists('title', $this->Controller->viewVars)) {
            $this->Controller->set('title', $this->Controller->name);
        }
    }
854908
public function beforeFilter(\Cake\Event\Event $event)
    {
        parent::beforeFilter($event);

        // get the type-string
        $type = $this->PostTypes->postTypeFinder($this->request);
        $this->_type = $type;

        // check if the string exists. Will throw an exception
        $this->PostTypes->check($type, ['exception' => true]);

        // intialize the settings
        $this->Settings = $this->PostTypes->get($type);

        // lets initialize the model too
        $this->Model = $this->loadModel($this->Settings['model']);
    }
1118595
public function beforeFilter(\Cake\Event\Event $event)
    {
        parent::beforeFilter($event);

        $this->Auth->allow([]);
    }
122841
public function beforeFilter(Event $event)
    {
        $this->controller = $event->getSubject();
        $this->request = $this->controller->request;
        $this->action = $this->request->getParam('action');
        $this->Filters = TableRegistry::get($this->getConfig('filterTable'));

        $this->_setupSort();
        $this->_setupFilters();
        $this->_setupPagination();
    }
227978
public function onMainMenuBuild(ConfigureMenuEvent $event)
    {
        if (!$this->authorizationChecker->isGranted('ez:tags:read')) {
            return;
        }

        $this->addTagsSubMenu($event->getMenu());
    }
502728
public function beforeRender($event)
    {
        $this->Controller->set('authUser', $this->Controller->authUser);

        // beforeRender-event
        $_event = new Event('Component.Manager.beforeRender', $this, [
        ]);
        $this->Controller->eventManager()->dispatch($_event);

        if ($this->isPrefix()) {
            $this->_runCallback("beforeRender", $event);

            // beforeRender-event with Prefix
            $this->_runEvent("beforeRender");
        }
    }
453667
public function beforeApiRequestSend($event)
    {
        $request = $event->request;
        $data = $request->getData();
        $data['openid'] = $this->getOpenid();
        $request->setData($data);

        parent::beforeApiRequestSend($event);
    }
922591
public function beforeFilter(Event $event)
    {
        $slug = lcfirst($this->request->params['type']);

        $this->type = $this->PostTypes->getOption($slug);

        if (!$this->type) {
            throw new Exception("The PostType is not registered");
        }

        $this->Model = TableRegistry::get($this->type['model']);

        // making the current item active
        $this->Menu->active($this->type['alias']);

        parent::beforeFilter($event);
    }
357749
public function beforePrepare(Event $event)
	{
		$command = $event['command'];

		if ($command->getName() !== 'createEntity') return;
		if (!$command['_id']) return;

		$operation = $command->getOperation();
		$operation->setHttpMethod('PUT');
	}
1250502
public function beforePrepare(Event $event)
	{
		$command = $event['command'];
		$operation = $command->getOperation();

		if ($command->offsetGet('collection') === 'user' || $command->getClient()->getCollectionName() === 'user')
		{
			if (strstr($operation->getURI(), 'user') !== false) return;

			$operation->setURI('/user/{appKey}/{_id}');
		}
		elseif ($command->offsetGet('collection') === 'files' || $command->getClient()->getCollectionName() === 'files')
		{
			if (strstr($operation->getURI(), 'files') !== false) return;
			$operation->setURI('/blob/{appKey}/{_id}');
			$command->getRequestHeaders()->add('X-Kinvey-API-Version', 3);
		}
		elseif ($command->offsetGet('collection') === 'group' || $command->getClient()->getCollectionName() === 'group')
		{
			if (strstr($operation->getURI(), 'group') !== false) return;
			$operation->setURI('/group/{appKey}/{_id}');
		}
	}
1011674
public function onBeforeControllerGet(AnEvent $event)
    {
        parent::onBeforeControllerGet($event);

        if ($this->getController()->getItem()) {
            $this->addToolbarCommands();
        }
    }