Before login event
@return void
762324
public function beforeLogin()
    {
        if ($this->is_guest) {
            $login = $this->getLogin();
            throw new AuthException(sprintf(
                'Cannot login user "%s" as they are not registered.', $login
            ));
        }

        parent::beforeLogin();
    }
1124906
protected function beforeValidate() 
	{
		if(parent::beforeValidate()) {
			if($this->isNewRecord) {
				if($this->default == 1)
					$this->actived = 1;
				$this->creation_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
			} else
				$this->modified_id = !Yii::app()->user->isGuest ? Yii::app()->user->id : null;
		}
		return true;
	}
816608
public function onBeforeWrite()
    {
        if (!$this->owner->MFAEnabled && SiteConfig::current_site_config()->ForceMFA) {
            $this->owner->MFAEnabled = true;
            $this->owner->updateMFA = true;
        }
        if (!$this->owner->BackupCodeSalt || $this->owner->updateMFA) {
            $algorithm = Security::config()->get('password_encryption_algorithm');

            $encryptor = PasswordEncryptor::create_for_algorithm($algorithm);

            // No password. It's not even used in the salt generation
            $this->owner->BackupCodeSalt = $encryptor->salt('');
        }
    }
164083
public function beforeCompile(): void
	{
		// Skip if it's not CLI mode
		if (!$this->cliMode) return;

		$builder = $this->getContainerBuilder();

		// Lookup for Symfony Console Application
		$application = $builder->getDefinitionByType('Symfony\Component\Console\Application');

		// Register helpers
		$connectionHelper = $this->prefix('@connectionHelper');
		$application->addSetup(new Statement('$service->getHelperSet()->set(?, ?)', [$connectionHelper, 'db']));
	}
156067
public function beforeCompile(): void
	{
		$builder = $this->getContainerBuilder();
		$config = $this->config;

		// Handle nette/mail configuration
		if ($this->name === 'mail') {
			return;
		}

		if ($config->mode === self::MODE_STANDALONE) {
			// Disable autowiring of nette.mailer
			if ($builder->hasDefinition('mail.mailer')) {
				$builder->getDefinition('mail.mailer')
					->setAutowired(false);
			}
		} elseif ($config->mode === self::MODE_OVERRIDE) {
			// Remove nette.mailer and replace with our mailer
			$builder->removeDefinition('mail.mailer');
			$builder->addAlias('mail.mailer', $this->prefix('mailer'));
		}
	}
566931
protected function beforeRender()
    {
        $this->setLayout("layout");

        $this->setBasePathModule();

        if ($this->isAjax()) {
            $this->invalidateControl('flashMessages');
        }

        // boxes settings, only if page is module
        if ($this->getParam('id')) {
            $this->template->boxesSettings = true;
        } else {
            $this->template->boxesSettings = false;
        }

        // check filled info email
        $infoEmail = $this->settings->get('Info email', \WebCMS\Settings::SECTION_BASIC)->getValue();
        if (!Nette\Utils\Validators::isEmail($infoEmail)) {
            $this->flashMessage('Please fill in correct info email. Settings -> Basic settings.', 'warning');
        }

        if (!$this->isAjax()) {
            $this->template->structures = $this->getStructures(); // TODO add function for AJAX and normal request it is not necessary to load everything
        }

        $this->template->registerHelperLoader('\WebCMS\Helpers\SystemHelper::loader');
        $this->template->actualPage = $this->actualPage;
        $this->template->user = $this->getUser();
        $this->template->setTranslator($this->translator);
        $this->template->language = $this->state->language;
        $this->template->version = \WebCMS\Helpers\SystemHelper::getVersion();
        $this->template->activePresenter = $this->getPresenter()->getName();
        $this->template->settings = $this->settings;
        $this->template->languages = $this->em->getRepository('WebCMS\Entity\Language')->findAll();
    }
465168
public function beforeDelete()
    {
        if (($url = UrlRule::findOne(['route' => '/system/page/view', 'params' => 'id=' . $this->id])) != null) {
            $url->delete();
        }
        parent::beforeDelete();
    }
1118595
public function beforeFilter(\Cake\Event\Event $event)
    {
        parent::beforeFilter($event);

        $this->Auth->allow([]);
    }
792872
public function triggerBeforeFind()
    {
        if (!$this->_beforeFindFired && $this->_type === 'select') {
            $this->_beforeFindFired = true;

            /** @var \Cake\Event\EventDispatcherInterface $repository */
            $repository = $this->getRepository();
            $repository->dispatchEvent('Model.beforeFind', [
                $this,
                new ArrayObject($this->_options),
                !$this->isEagerLoaded()
            ]);
        }
    }
618879
public function beforeValidate()
    {
        /*
         * Guests are special
         */
        if ($this->is_guest && !$this->password) {
            $this->generatePassword();
        }

        /*
         * When the username is not used, the email is substituted.
         */
        if (
            (!$this->username) ||
            ($this->isDirty('email') && $this->getOriginal('email') == $this->username)
        ) {
            $this->username = $this->email;
        }
    }
1247483
protected function BeforeGather()
    {  
        if ($this->IsTriggered() && $this->Elements()->Check(Request::MethodArray($this->Method())))
        {
            return $this->OnSuccess();
        }
        return parent::BeforeGather();
    }
1144217
public function beforeSave(Event $event)
    {
        if (isset($this->_controller()->request->data['password'])) {
            $password = $this->_controller()->request->data['password'];
            $event->subject->entity['password'] = $password;
        }
    }
373016
public function before()
    {
        parent::before();
        // check if user have permission to access there
        if (!App::$User->isAuth() || !App::$User->identity()->role->can('global/file'))
            throw new NativeException('Permission denied');

        App::$Translate->append(__DIR__ . '/Translation/' . App::$Request->getLanguage() . '.php');
    }
848705
protected function before_user_func()
    {
        if ($this->config['error_reporting'] !== false) {
            set_error_handler(sprintf('%s::error_handler', __CLASS__), $this->config['error_reporting']);
        }

        if (empty($_POST['phery']['csrf'])) {
            $_POST['phery']['csrf'] = '';
        }

        if ($this->csrf($_POST['phery']['csrf']) === false) {
            self::exception($this, 'Invalid CSRF token', self::ERROR_CSRF);
        }
    }
174750
public function onBeforeWrite()
    {
        // save submitter if a Member is logged in
        $currentMember = Security::getCurrentUser();
        if (!$this->SubmitterID && $currentMember) {
            $this->SubmitterID = $currentMember->ID;
        }

        parent::onBeforeWrite();
    }
337926
public function beforeDisplay()
    {
        if ($this->_csrf) {
            $this->_csrf->initCsrfToken();
        }

        $links = $this->getMenuList();
        if (\MUtil_Bootstrap::enabled()) {
            if ($links) {
                $element = $this->_form->createElement('html', 'menuLinks');
                $element->setValue($links);
                $element->setOrder(999);
                $this->_form->addElement($element);
            }
        } else {
            $table = new \MUtil_Html_TableElement(array('class' => $this->class));
            $table->setAsFormLayout($this->_form, true, true);

            // There is only one row with formLayout, so all in output fields get class.
            $table['tbody'][0][0]->appendAttrib('class', $this->labelClass);

            if ($links) {
                $table->tf(); // Add empty cell, no label
                $table->tf($links);
            }
        }
    }
165830
protected function before() {
		if($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
			$this->connection->executeUpdate('EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"');
		} else if($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
			$this->connection->executeUpdate('SET FOREIGN_KEY_CHECKS=0');
		} else if($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
			$this->connection->executeUpdate('PRAGMA foreign_keys = OFF');
		}
	}