@param ContextInterface $context
@param array|null       $serializedLogical

@return bool
768764
protected static function evaluateLogical(ContextInterface $context, array $serializedLogical = null): bool
    {
        if ($serializedLogical === null) {
            return true;
        }

        $evaluation = call_user_func($serializedLogical, $context);
        $result     = $evaluation === true;

        return $result;
    }
1335166
public function context(ContextInterface $context)
    {
        if (!empty($this->vary)) {
            $this->varyValue = $context->get($this->vary);
        }
    }
1344750
public function merge(ResourceSerializationContext $context): MutableSerializationContext
    {
        $cloned = clone $this;

        $cloned->payload = array_merge($cloned->payload, $context->payload);

        return $cloned;
    }
769601
public function isPathValid(ExecutionContextInterface $context)
    {
        if ($this->getStorage() instanceof Storage && $this->getStorage()->isPathRequired() && !$this->getPath()) {
            $context->addViolationAt('path', 'Path is required to fill for current type of storage');
        }
    }
1142953
protected function initializeFiltering(ContextInterface $context)
    {
        $activeFilters = $context->getActiveFilters();

        foreach ($activeFilters as $activeFilter) {
            $filterName = $activeFilter->getFilterName();
            if ($this->table->hasFilter($filterName)) {
                $this->table->getFilter($filterName)->applyFilter($this, $activeFilter);
            }
        }
    }
26606
public function getContext(ViewContextInterface $context = null)
    {
        $context = new ViewContext($context);
        $context->setEntity($this->getModel()->fetch());
        $context->setData($this->getData());
        $context->setParameters($this->getParameters());

        return $context;
    }
1374364
public function assert(AuthorizationService $authorizationService, $context = null)
    {
        /** @var EnvironmentInterface $context */
        /** @var UserInterface $identity */
        $identity = $authorizationService->getIdentity();

        if ($identity->getRole() === UserInterface::ROLE_USER) {
            return false;
        }

        if ($authorizationService->isGranted('manageAllEnv', $context) || ($context != null && $context->hasUser($identity))) {
            return true;
        }

        if ($context == null) {
            return false;
        }

        if (!$context->hasParent()) {
            return false;
        }

        $parent = $context->getParent();
        return $parent->hasUser($identity) || $authorizationService->isGranted('manageEnv', $parent);

    }
373256
public function getChildren(OperationContextInterface $context = null)
    {
        $context = $this->ensureContext($context);
        $children = $this->getBinding()->getNavigationService()->getChildren(
            $this->getRepositoryId(),
            $this->getId(),
            $context->getQueryFilterString(),
            $context->getOrderBy(),
            $context->isIncludeAllowableActions(),
            $context->getIncludeRelationships(),
            $context->getRenditionFilterString(),
            $context->isIncludePathSegments()
        );

        $result = [];
        $objectFactory = $this->getObjectFactory();
        foreach ($children->getObjects() as $objectData) {
            if ($objectData->getObject() !== null) {
                $result[] = $objectFactory->convertObject($objectData->getObject(), $context);
            }
        }

        return $result;
    }
190660
private function nested($annotation, $nestedContext)
    {
        if (property_exists($annotation, '_context') && $annotation->_context === $this->_context) {
            $annotation->_context = $nestedContext;
        }
        return $annotation;
    }
1042983
public function getContext(ModelContextInterface $context = null)
    {
        $context = new ModelContextDatabase(parent::getContext());
        $context->setQuery($this->getObject('lib:database.query.select'));
        return $context;
    }
1318356
public function assemble(ContextInterface $context)
    {
        $class = $context->getClass();
        $properties = $context->getType()->getProperties();
        $firstProperty = count($properties) ? current($properties) : null;

        try {
            $interfaceAssembler = new InterfaceAssembler(ResultProviderInterface::class);
            if ($interfaceAssembler->canAssemble($context)) {
                $interfaceAssembler->assemble($context);
            }

            if ($firstProperty) {
                $this->implementGetResult($context, $class, $firstProperty);
            }
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }
610350
public function getRootCategoriesForContext(ContextInterface $context = null)
    {
        $context = $this->getContext($context);

        $this->loadCategories($context);

        return $this->categories[$context->getId()];
    }
1265157
public function assemble(ContextInterface $context)
    {
        $class = ClassGenerator::fromArray(
            [
                'name' => $context->getName(),
            ]
        );
        $file = $context->getFile();
        $file->setClass($class);
        $file->setNamespace($context->getNamespace());
        $typeMap = $context->getTypeMap();
        $typeNamespace = $typeMap->getNamespace();
        $file->setUse($typeNamespace, preg_match('/\\\\Type$/', $typeNamespace) ? null : 'Type');

        try {
            $file->setUse(ClassMapCollection::class);
            $file->setUse(ClassMap::class);
            $linefeed = $file::LINE_FEED;
            $classMap = $this->assembleClassMap($typeMap, $linefeed, $file->getIndentation());
            $code = $this->assembleClassMapCollection($classMap, $linefeed).$linefeed;
            $class->addMethodFromGenerator(
                MethodGenerator::fromArray(
                    [
                        'name'       => 'getCollection',
                        'static'     => true,
                        'body'       => 'return '.$code,
                        'returntype' => ClassMapCollection::class,
                    ]
                )
            );
        } catch (\Exception $e) {
            throw AssemblerException::fromException($e);
        }
    }
1053331
public static function resolveContextFromArray($contextArray, $useDomainAlias = false)
    {
        $context = new ContextObject();

        return self::resolveSiteContextObject($context, $contextArray, $useDomainAlias);
    }
885272
public function isRoleScopePresentOnce(ExecutionContextInterface $context) 
    {
        $roleScopesId = array_map(function(RoleScope $roleScope) {
                    return $roleScope->getId();
                }, 
                $this->getRoleScopes()->toArray());
        $countedIds = array_count_values($roleScopesId);
        
        foreach ($countedIds as $id => $nb) {
            if ($nb > 1) {
                $context->buildViolation("A permission is already present "
                        . "for the same role and scope")
                        ->addViolation();
            }
        }
    }
313134
protected function _beforeBrowse(KControllerContextInterface $context)
    {
        if(!empty($this->_output))
        {
            $context->result = $this->_output;
            return false;
        }

        return null;
    }
979786
private function skip(ContextInterface $context)
    {
        $dataStack = $context->getDataStack();
        $metadataStack = $context->getMetadataStack();
        $references = [];
        $depth = 0;

        for ($index = count($metadataStack) - 1; $index >= 0; --$index) {
            $metadata = $metadataStack[$index];
            $data = $dataStack[$index];

            if ($metadata instanceof ClassMetadataInterface) {
                $hash = spl_object_hash($data);

                if (!isset($references[$hash])) {
                    $references[$hash] = 0;
                }

                if (++$references[$hash] > $this->circularReferenceLimit) {
                    return true;
                }
            }

            if ($metadata instanceof TypeMetadataInterface) {
                ++$depth;
            }

            if (!$metadata instanceof PropertyMetadataInterface) {
                continue;
            }

            ++$depth;

            if (!$metadata->hasMaxDepth()) {
                continue;
            }

            if ($depth > $metadata->getMaxDepth()) {
                return true;
            }
        }

        return false;
    }