Constrói e persiste informações relevantes sobre a transação através
do Modelo Logger

@param Model $Model
@param string $action
326793
protected function logQuery(Model $Model, $action = 'create')
	{
		// Se não houver modelo configurado para salvar o log, aborta
		if ($this->checkLogModels() === false) {
			CakeLog::write(LOG_WARNING, __d('auditable', 'You need to define AuditableConfig::$Logger'));
			return;
		}

		$diff = $this->getDiff($Model, $action);

		// Caso não haja alterações/registro criado/excluído, não cria log
		if (empty($diff)) {
			return;
		}

		$encoded = $this->buildEncodedMessage($action, $diff);

		$statement = $this->getQuery($Model, $action);

		$toSave = array(
			'Logger' => array(
				'responsible_id' => $this->activeResponsibleId ?: 0,
				'model_alias' => $Model->alias,
				'model_id' => $Model->id,
				'type' => $this->typesEnum[$action] ?: 0,
			),
			'LogDetail' => array(
				'difference' => $encoded,
				'statement' => $statement,
			)
		);

		$this->QueryLogSource->disable($this->Logger);

		// Salva a entrada nos logs. Caso haja falha, usa o Log default do Cake para registrar a falha
		if ($this->Logger->saveAssociated($toSave) === false) {
			CakeLog::write(LOG_WARNING, sprintf(__d('auditable', "Can't save log entry for statement: \"%s'\""), $statement));
		}

		$this->QueryLogSource->enable($this->Logger);
	}
362890
public function load(Action $action)
    {
        if ($action instanceof LoggerAwareInterface) {
            $action->setLogger(
                $this->getServiceLocator()->get(LoggerService::SERVICE_ID)
                    ->addLogger(
                        $this->hideColors
                            ? new VerboseLogger($this->getMinimumLogLevel())
                            : new ColoredVerboseLogger($this->getMinimumLogLevel())
                    )
            );
        }
    }
877543
public function action(String $action = NULL)
    {
        $time = $this->redirect['time'];
        $data = $this->redirect['data'];

        $this->redirect = [];

        if( strstr(get_called_class() , 'Refresh') )
        {
            $exit = false;
            $type = 'refresh';
        }
        
        $this->location($action, $time, $data, $exit ?? true, $type ?? 'location');
    }
80153
public function shouldLogChange($action)
    {
        if ($action != 'deleted'
            && count($this->getDirty()) == 1
            && $this->isDirty('remember_token')) {
            return false;
        }
        return parent::shouldLogChange($action);
    }
1187712
public function updateModelConcepts(array $modelsArray, $action)
    {
        $data['models'] = [];

        foreach ($modelsArray as $modelId => $modelConcepts) {
            $model = [];
            $model['id'] = (string)$modelId;
            $model['output_info'] = [];
            $model['output_info']['data'] = [];
            $model['output_info']['data'] = $this->addModelConcepts($model['output_info']['data'], $modelConcepts);

            $data['models'][] = $model;
        }
        $data['action'] = $action;

        $updateResult = $this->getRequest()->request(
            'PATCH',
            $this->getRequestUrl('models'),
            $data
        );

        return $this->getModelsFromResult($updateResult);
    }
861330
public function publishRelatedModels($action = null, $entity = null)
    {
        $models = $this->models($action);

        if (empty($models)) {
            return;
        }

        $controller = $this->_controller();

        foreach ($models as $name => $association) {
            list(, $associationName) = pluginSplit($association->getName());
            $viewVar = Inflector::variable($associationName);
            if (array_key_exists($viewVar, $controller->viewVars)) {
                continue;
            }

            $finder = $this->finder($association);
            $query = $association->find()->find($finder, $this->_findOptions($association));
            $subject = $this->_subject(compact('name', 'viewVar', 'query', 'association', 'entity'));
            $event = $this->_trigger('relatedModel', $subject);

            $controller->set($event->getSubject()->viewVar, $event->getSubject()->query->toArray());
        }
    }
612064
protected function invalidate(Model $model): void
    {
        $key = $this->prefix . ":" . $model->getKey();
        if ($this->cacheRepository->has($key)) {
            $this->cacheRepository->forget($key);
        }
        $this->cacheRepository->forget("$this->prefix.:all");
    }
470269
public function move($action, $entity)
    {
        $this->checkSortableGroupField(static::getSortableGroupField(), $entity);

        $this->_transaction(function () use ($entity, $action) {
            $sortableField = static::getSortableField();

            $oldPosition = $this->getAttribute($sortableField);
            $newPosition = $entity->getAttribute($sortableField);

            if ($oldPosition === $newPosition) {
                return;
            }

            $isMoveBefore = $action === 'moveBefore'; // otherwise moveAfter
            $isMoveForward = $oldPosition < $newPosition;

            if ($isMoveForward) {
                $this->queryBetween($oldPosition, $newPosition)->decrement($sortableField);
            } else {
                $this->queryBetween($newPosition, $oldPosition)->increment($sortableField);
            }

            $this->setAttribute($sortableField, $this->getNewPosition($isMoveBefore, $isMoveForward, $newPosition));
            $entity->setAttribute($sortableField, $this->getNewPosition(!$isMoveBefore, $isMoveForward, $newPosition));

            $this->save();
            $entity->save();
        });
    }
159552
public function log(string $action, string $entity, array $dados)
    {
        if (!empty($dados['id'])) {
            $store = new Json("store/{$entity}");

            if (!empty($_SESSION['userlogin']))
                $dados['userlogin'] = $_SESSION['userlogin']['id'];

            if ($action === "delete")
                $store->delete($dados['id']);
            else
                $store->save($dados['id'], $dados);
        }
    }
182870
private function getQuery(Model $Model, $action)
	{
		$queries = $this->QueryLogSource->getModelQueries($Model, $action);
		$statement = '';

		if (!empty($queries)) {
			$statement = implode(";\n", $queries);
		}

		return $statement;
	}
146695
public function handleController(
        $controller, $action = null, array $params = null, $model = null
    ) {

        ! $model || $model = $this->modelFactory->create(null, $model);

        $this->setController(
            $this->controllerFactory->create($params, $controller, $model)
        );

        if (!is_null($action)) {
            $this->setControllerResult(
                $this->executeMethod($this->getController(), $action, $params, $model)
            );
        }
    }
1027954
protected function fireSluggingEvent(Model $model, string $event)
    {
        return $this->events->until('eloquent.slugging: ' . get_class($model), [$model, $event]);
    }
102818
protected function updateRelations($eloquentModel, $action)
    {
        $mapping = $eloquentModel->getMapping();
        $eloquentRelations = $eloquentModel->getRelations();

        foreach($mapping['relations'] as $name => $relationMapping) {
            if (isset($eloquentRelations[$name])) {
                $this->updateRelation($eloquentModel, $name, $relationMapping, $action);
            }
        }
    }
848554
public function saved(Model $model)
    {
        $tags = $this->processTags(request('tags'));
        $this->syncTags($model, $tags);
    }
126342
public void addAction(ModelAction action, ModelActionListener listener)
    {
        
        synchronized(actionQueue) {
            this.actionQueue.add(new ModelActionEntry(action, listener));
        }
        
        wakeUp();
        
    }
970111
public function setAction($action)
    {
        if ($action instanceof Closure)
        {
            $this->action = $action;
            return;
        }
        else if (is_array($action) && is_callable($action))
        {
            $this->action = $action;
            return;
        }
        else if (strpos($action, '::') > 0)
        {
            $this->action = explode('::', $action);
            return;
        }

        $names = explode('.', $action);
        if (count($names) > 1) {
            $controller = array_shift($names);
            $action = array_shift($names);
            $this->setController($controller);
        } else {
            $action = array_shift($names);
        }
        $this->action = $action;
    }
620503
public static function hasAccess($model, $action, $session = 'Admin.crud', $exit = false) {
        if (!($model instanceof Model)) {
            $model = self::introspectModel($model);
        }

        $crud = Hash::get($_SESSION, $session);
        $exists = isset($crud[$model->qualifiedName][$action]);

        // Exit early
        if ($exit && !$exists) {
            return null;
        }

        $pass = ($exists && $crud[$model->qualifiedName][$action]);

        // Check editable
        if ($action === 'update') {
            return ($pass && $model->admin['editable']);
        }

        // Check deletable
        if ($action === 'delete') {
            return ($pass && $model->admin['deletable']);
        }

        return $pass;
    }