This method is invoked before moderating a record.

@return bool
967187
public function beforeModeration(): bool
    {
        if (method_exists($this->owner, 'beforeModeration')) {
            if (!$this->owner->beforeModeration()) {
                return false;
            }
        }

        $event = new ModelEvent();
        $this->owner->trigger(self::EVENT_BEFORE_MODERATION, $event);

        return $event->isValid;
    }
406394
public function beforeDelete()
    {
        $handler = $this->get('metadata')->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->beforeDelete($this);
        }

        return true;
    }
878405
protected function proceedingAllowed(): bool
    {
        if ($this->input->getOption('no-interaction')) {
            return true;
        }

        return $this->getHelper('question')->ask($this->input, $this->output, new ConfirmationQuestion('<question>Are you sure you wish to flush the whole database? (y/n)</question>', false));
    }
755248
public function isHintEnabled()
    {
        $isParamPresent = $this->_request->getParam('ath', false) === '1';

        if ($isParamPresent) {
            $applicationMode = $this->appState->getMode();
            $storeId = $this->storeManager->getStore()->getId();

            if ($applicationMode === AppState::MODE_DEVELOPER || $this->developerHelper->isDevAllowed($storeId)) {
                return true;
            }
        }

        return false;
    }
1071269
protected function BeforeInit()
    {
        if ($this->RemoveTemplate())
        {
            Response::Redirect(Request::Uri());
            return true;
        }
        parent::BeforeInit();
    }
280043
public function onBeforeInsert()
	{
		if ($this->defaultArchiveValue === null || !empty($this->owner->{$this->archiveAttribute})) return;
		$this->owner->{$this->archiveAttribute} = $this->defaultArchiveValue;
	}
143705
protected function beforeSave()
	{
		if(parent::beforeSave())
		{
			if($this->isNewRecord)
			{
				$this->create_time=$this->update_time=time();
				$this->author_id=Yii::app()->user->id;
			}
			else
				$this->update_time=time();
			return true;
		}
		else
			return false;
	}
578761
public function beforeQuery($event)
    {
        if (
            !isset($this->owner->model)
            || $this->owner->model->getBehavior('Archivable') === null
            || !$this->owner->model->isArchivable()) {
            return true;
        }
        if ($this->allowArchives === true) {
            $this->owner->andWhere('{{' . $this->owner->primaryAlias . '}}.[[' . $this->owner->model->getBehavior('Archivable')->archiveField . ']] IS NOT NULL');
        } elseif ($this->allowArchives === false) {
            $this->owner->andWhere('{{' . $this->owner->primaryAlias . '}}.[[' . $this->owner->model->getBehavior('Archivable')->archiveField . ']] IS NULL');
        }

        return true;
    }
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');
		}
	}
734846
public function beforeLock () {
        $event = new ModelEvent();
        $event->sender = $this;
        $this->onBeforeLock ($event);
        return $event->isValid;
    }
1011487
public function beforeSave()
    {
        if ('' !== $password = $this->getElement('changePassword')->getValue()) {
            $this->getRecord()->password = \Cms\Model\Auth::getSaltedPasswordHash($password);
        }
        return true;
    }
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();
    }
107337
public function beforeSave()
    {
        /* @var $model ActiveRecord */
        $model = $this->owner;
        foreach ($this->attributes as $attr => $options) {
            $this->ensureAttributes($attr, $options);
            if ($file = UploadedFile::getInstance($model, $attr)) {
                $this->createDirIfNotExists($attr);
                if (!$model->isNewRecord) {
                    $this->deleteFiles($attr);
                }
                $fileName = uniqid() . '.' . $file->extension;
                $model->{$attr} = $fileName;
                $file->saveAs($this->getSavePath($attr) . $fileName);
            } elseif (isset($model->oldAttributes[$attr])) {
                $model->{$attr} = $model->oldAttributes[$attr];
            }
        }
    }
1012845
public function beforeValidate()
    {
        if ($this->owner->getIsNewRecord()) {
            // added new record always on top
            $this->owner->{$this->sortAttribute} = $this->owner->find()->andWhere($this->getCondition())->count();
        } else {
            // prevent direct change of sort field
            $this->owner->{$this->sortAttribute} = $this->owner->getOldAttribute($this->sortAttribute);
        }
    }
74492
public function beforeModelSave()
    {
        $preferences = UserPreference::forUser();
        list($namespace, $group, $item) = $preferences->parseKey($this->recordCode);
        $this->model->item = $item;
        $this->model->group = $group;
        $this->model->namespace = $namespace;
        $this->model->user_id = $preferences->userContext->id;

        if ($this->fieldValues) {
            $this->model->value = $this->fieldValues;
        }
    }
482848
public function markRejected(): bool
    {
        $this->owner->{$this->statusAttribute} = Status::REJECTED;

        if ($this->beforeModeration()) {
            return $this->owner->save();
        }

        return false;
    }
296876
public function onBeforeWrite()
    {
        if ($w = $this->owner->ModernoLogoImageWidth) {
            $this->owner->ModernoLogoImageWidth = is_numeric($w) ? (int) $w : null;
        }
        
        if ($h = $this->owner->ModernoLogoImageHeight) {
            $this->owner->ModernoLogoImageHeight = is_numeric($h) ? (int) $h : null;
        }
        
        if ($w = $this->owner->ModernoLoadingImageWidth) {
            $this->owner->ModernoLoadingImageWidth = is_numeric($w) ? (int) $w : null;
        }
        
        if ($h = $this->owner->ModernoLoadingImageHeight) {
            $this->owner->ModernoLoadingImageHeight = is_numeric($h) ? (int) $h : null;
        }
    }