Check rules whether action must be performed.
If at least one rule returns true the action will be performed.
If result is `true` then action must be performed.
@param null $context
@return bool
346301
protected function checkRules($context = null)
    {
        $rules = $this->getRules();
        $result = false;

        foreach ($rules as $rule) {
            if ($rule->check($context)) {
                $result = true;
                break;
            }
        }

        return $result;
    }
549004
public function validate($entity, $context = null) : bool
    {
        if (!$entity instanceof AuditEvent) {
            throw new \LogicException('The Entity to validate must be an instance of \Fei\Service\Audit\Entity\AuditEvent');
        }

        return parent::validate($entity, $context);
    }
842796
public function isTargetValid(ExecutionContextInterface $context)
    {
        // Menu is not root and has no url or Article linked
        if ($this->getParent() != $this && !$this->getUrl() && !$this->getArticle()) {
            $context->addViolationAt('url', 'This value should not be blank.');
        }
    }
1122295
public function canCreate($member = null, $context = [])
    {
        // Check parent page
        $parent = $this->getCanCreateContext(func_get_args());
        if ($parent) {
            return $parent->canEdit($member);
        }

        // Fall back to secure admin permissions
        return parent::canCreate($member);
    }
322048
protected function _authorizeDelete($context)
    {
        $owneids = $this->_entity->getIds('owner');

        if (count($owneids) > 1) {
            return false;
        } elseif ($this->_viewer->admin()) {
            return true;
        } elseif ($this->_entity->owner->authorize('administration')) {
            return true;
        }

        return false;
    }
1053153
protected function _actionVerify($context)
    {
        $context->response->status = AnHttpResponse::RESET_CONTENT;
        $this->getItem()->verify();
        return;
    }
116369
public function canCreate($member = null, $context = [])
    {
        $extended = $this->extend('canCreate', $member);
        if ($extended && $extended !== null) {
            return $extended;
        }

        return true;
    }
991495
public function getRules($action = null){

        $rules = $this->rules;

        if( isset($this->rules[$action]) ){
            $rules = $this->rules[$action];
        }

        return $this->parserValidationRules($rules, $this->id);
    }
92552
public final function execute(ControllerContext $controllerContext): bool {
		$this->init($controllerContext);
		
		$request = $this->getRequest();
		$invokerFactory = new ActionInvokerFactory(
				$controllerContext->getCmdPath(), $controllerContext->getCmdContextPath(), $request,
				$request->getMethod(), $request->getQuery(), $request->getPostQuery(),
				$request->getAcceptRange(), $this->getN2nContext());
		$invokerFactory->setConstantValues($controllerContext->getParams());
		$interpreter = new ControllerInterpreter(new \ReflectionClass($this), $invokerFactory,
				new InterceptorFactory($controllerContext->getControllingPlan()->getN2nContext()));
		
		$this->resetCacheControl();
		
		if (!$this->intercept(...$interpreter->findControllerInterceptors())) {
			return true;
		}
		
		$catchedStatusException = null;
		
		try {
			$prepareInvokers = $interpreter->interpret(ControllerInterpreter::DETECT_PREPARE_METHOD);
			foreach ($prepareInvokers as $prepareInvoker) {
				$this->cu()->setInvokerInfo($prepareInvoker);
				if ($this->intercept(...$prepareInvoker->getInterceptors())) {
					$prepareInvoker->getInvoker()->invoke($this);
				} else {
					return true;
				}
			}
		
			$invokerInfos = $interpreter->interpret(ControllerInterpreter::DETECT_ALL & ~ ControllerInterpreter::DETECT_PREPARE_METHOD);
			if (!empty($invokerInfos)) {
				foreach ($invokerInfos as $invokerInfo) {
					$this->cu()->setInvokerInfo($invokerInfo);
					
					if (!$this->intercept(...$invokerInfo->getInterceptors())) continue;
					
					$invokerInfo->getInvoker()->invoke($this);
				}

				$this->cu()->reset(true);
				return true;
			}
		} catch (StatusException $e) {
			$catchedStatusException = $e;
		}
		
		if (empty($invokerInfos) || ($catchedStatusException !== null 
				&& $catchedStatusException->getStatus() == Response::STATUS_404_NOT_FOUND)) {
			try {
				$notFoundInvokers = $interpreter->interpret(ControllerInterpreter::DETECT_NOT_FOUND_METHOD);
				
				if (!empty($notFoundInvokers)) {
					foreach ($notFoundInvokers as $invokerInfo) {
						$this->cu()->setInvokerInfo($invokerInfo);
						
						if (!$this->intercept(...$invokerInfo->getInterceptors())) continue;
						
						$invokerInfo->getInvoker()->invoke($this);
						$catchedStatusException = null;
					}
					
					$this->cu()->reset(true);
					return true;
				}
			} catch (StatusException $e) {
				$catchedStatusException = $e;
			}
		}
		
		if ($catchedStatusException !== null) {
			$this->cu()->reset(false);
			throw $catchedStatusException;
		}
		
		$this->cu()->reset(true);
		return false;
	}
240029
final protected function _validate(AnCommandContext $context)
    {
        foreach ($this as $filter) {
            if ($filter->execute('validate', $context) === false) {
                return false;
            }
        }

        return true;
    }
327072
protected function loopThroughRules(array $rules, array $context = [], $condition = 'AND')
    {
        $result    = true;
        $condition = strtolower($condition);
        $this->validateCondition($condition);
        foreach ($rules as $rule) {
            $result = $this->evaluate($rule, $context);
            if ($result && $this->isNested($rule)) {
                $result = $this->loopThroughRules($rule->rules, $context, $condition);
            }
            // Conditions upon which we can stop evaluation.
            if ('and' == $condition && !$result) {
                break;
            } else {
                if ('or' == $condition && $result) {
                    break;
                }
            }
        }

        return $result;
    }
1244649
public function matches_all_filters(\context $context) {
        $filters = helper::get_all_filters();

        // All filters must match.
        // If any one filter fails to match, we return false.
        foreach ($filters as $filterclass) {
            if (!$filterclass::filter_matches($this, $context)) {
                return false;
            }
        }

        return true;
    }
290762
protected function checkBypassAccess($context) {
    $bypassAccessChecker = $this->getBypassAccessChecker();
    if(is_null($bypassAccessChecker)) {
      return FALSE;
    }

    $bypassAccess = $bypassAccessChecker->checkBypassAccess($context);
    if(!is_bool($bypassAccess)) {
      throw new InvalidReturnTypeException('The bypass access checker must return a boolean, see Ordermind\LogicalPermissions\BypassAccessCheckerInterface::checkBypassAccess().');
    }

    return $bypassAccess;
  }
1077284
protected function _actionBrowse($context)
    {
        if (!$context->query) {
            $context->query = $this->getRepository()->getQuery();
        }

        $query = $context->query;
        $query->order('open', 'DESC');

        if ($this->sort == 'priority') {
            $query->order('priority', 'DESC');
        }

        return parent::_actionBrowse($context);
    }
1352120
public function isGroupValid(ExecutionContextInterface $context)
    {
        if (!(count($this->getRoles()) > 0)) {
            $context
                ->buildViolation('errors.group.selectone', array())
                ->atPath('rolesCollection')
                ->addViolation();
        }
    }
929197
public static function checkRequiredActions(Event $event = null)
    {
        /** @var RequiredActionService $service */
        $service = ServiceManager::getServiceManager()->get(self::CONFIG_ID);
        $action = $service->getActionToBePerformed([], $event);
        if ($action !== null) {
            $action->execute([], $event);
        }
    }
366384
protected function evaluate($rule, array $context = [])
    {
        try {
            $ruleValue = $this->getValueFromRule($rule);
        } catch (\Exception $e) {
            $this->setError('Error attempting to get a value from a rule.');

            return false;
        }

        try {
            $contextValue = $this->getValueFromContext($rule, $context);
        } catch (\Exception $e) {
            $this->setError('Error attempting to get a value from context.');

            return false;
        }

        $result = $this->evaluateRuleAgainstContext($rule, $contextValue, $ruleValue);
        if (!$result) {
            $this->setError(
                $rule->field.' did not '.$rule->operator.' '.$ruleValue.' (actual value was '.$contextValue.')'
            );
        }

        return $result;
    }