@param Node  $node
@param Event $event
@param Pbjx  $pbjx

@return ExpireNode
342367
protected function createExpireNode(Node $node, Event $event, Pbjx $pbjx): ExpireNode
    {
        $curie = $node::schema()->getCurie();
        $commandCurie = "{$curie->getVendor()}:{$curie->getPackage()}:command:expire-{$curie->getMessage()}";

        /** @var ExpireNode $class */
        $class = MessageResolver::resolveCurie(SchemaCurie::fromString($commandCurie));
        return $class::create();
    }
306180
protected function createNodeLocked(LockNode $command, Pbjx $pbjx): NodeLocked
    {
        /** @var NodeLocked $event */
        $event = $this->createEventFromCommand($command, 'locked');
        return $event;
    }
1206588
function(node) {
            var instance = this,
                pjaxselectionCont = Y.one('.pjaxselection'),
                pjaxselectionButtons = pjaxselectionCont.all('button');

            pjaxselectionCont.delegate(
                'click',
                function(e) {
                    var btn = e.currentTarget,
                        pjaxtype;
                    pjaxselectionButtons.removeClass(PURE_BUTTON_ACTIVE);
                    btn.addClass(PURE_BUTTON_ACTIVE);
                    pjaxtype = btn.getAttribute('data-pjaxtype');
                    switch (pjaxtype) {
                        case '0':
                            instance.switchAttribute(false);
                        break;
                        case '1':
                            instance.switchAttribute(true);
                            instance.allAnchor.removeAttribute('data-pjax-cache');
                        break;
                        case '2':
                            instance.switchAttribute(true);
                            instance.allAnchor.setAttribute('data-pjax-cache', true);
                        break;
                    }
                    Y.soon(Y.bind(instance.refreshCodedescription, instance));
                },
                'button'
            );
        }
145567
public function leaveNode(Node $node)
    {
        if ($node instanceof Expr\ClassConstFetch
            && $node->name === 'class'
        ) {
            $class = $node->class;
            if (strcmp($class->toString(), 'static') === 0
                || strcmp($class->toString(), 'self') === 0
            ) {
                $name = Name::concat($this->namespaceNode, $this->classNode->name);
                return new Scalar\String_(trim($name->toString(), '\\'));
                // return new Expr\FuncCall(new Name('get_class'));
            }
            if ($class->isFullyQualified()) {
                return new Scalar\String_(trim($class->toString(), '\\'));
            }
            $prefix = $this->namespaceNode;
            foreach ($this->importNodes as $import) {
                if (strcmp($class->getFirst(), $import->getLast()) === 0) {
                    $prefix = $import->toString();
                    array_shift($class->parts);
                    break;
                }
            }
            $name = Name::concat($prefix, $class);
            return new Scalar\String_(trim($name->toString(), '\\'));
        }
    }
606686
public function createProxyEvent(Event $event)
    {
        if ($event instanceof GetResponseForControllerResultEvent) {
            $silexEvent = new PostDispatchEvent($event);

        } elseif ($event instanceof GetResponseEvent) {
            $silexEvent = new RequestEvent($event);

        } elseif ($event instanceof FilterControllerEvent) {
            $silexEvent = new PreDispatchEvent($event);

        } elseif ($event instanceof FilterResponseEvent) {
            $silexEvent = new ResponseEvent($event);

        } elseif ($event instanceof SfPostResponseEvent) {
            $silexEvent = new PostResponseEvent($event);

        } elseif ($event instanceof FinishRequestEvent) {
            $silexEvent = new PostRequestEvent($event);

        } elseif ($event instanceof KernelEvent) {
            $silexEvent = new SilexKernelEvent($event);

        } elseif ($event instanceof Event) {
            $silexEvent = new SilexEvent($event);

        } else {
            $silexEvent = null; // unknown event
        }

        return $silexEvent;
    }
1054941
private function prepareNode(&$node, $key)
    {
        if (!isset($node[$key])) {
            $node[$key] = null;
        } elseif (!is_array($node[$key])) {
            $node[$key] = [$node[$key]];
        }
    }
547125
protected function createNodeDeleted(DeleteNode $command, Pbjx $pbjx): NodeDeleted
    {
        /** @var NodeDeleted $event */
        $event = $this->createEventFromCommand($command, 'deleted');
        return $event;
    }
682052
public function onNodeAccess(NodeAccessEvent $event)
    {
        $node     = $event->getNode();
        $account  = $event->getAccount();
        $op       = $event->getOperation();
        $access   = $this->siteManager->getAccess();

        if ('create' === $op) {

            // Drupal gave a wrong input, this may happen
            if (!is_string($node) && !$node instanceof NodeInterface) {
                return $this->deny();
            }
            $type = is_string($node) ? $node : $node->bundle();

            // Locked types
            if (in_array($type, $this->typeHandler->getLockedTypes()) && !$account->hasPermission(Access::PERM_CONTENT_GOD)) {
                return $event->deny();
            }

            if ($this->siteManager->hasContext()) {
                $site = $this->siteManager->getContext();

                // Contributor can only create editorial content
                if ($access->userIsContributor($account, $site) && in_array($type, $this->typeHandler->getEditorialTypes())) {
                    return $event->allow();
                }

                // Webmasters can create anything
                if ($access->userIsWebmaster($account, $site) && in_array($type, $this->typeHandler->getAllTypes())) {
                    return $event->allow();
                }
            } else {

                // All user that may manage global content or manage group
                // content may create content outside of a site context, as
                // long as content is editorial (text and media)
                $canManage =
                    $account->hasPermission(Access::PERM_CONTENT_MANAGE_GLOBAL) ||
                    $account->hasPermission(Access::PERM_CONTENT_MANAGE_CORPORATE)
                ;

                if ($canManage && in_array($type, $this->typeHandler->getEditorialTypes())) {
                    return $event->allow();
                }
            }
        } else if (Permission::DELETE === $op) {
            // Locked types
            if (in_array($node->bundle(), $this->typeHandler->getLockedTypes()) && !$account->hasPermission(Access::PERM_CONTENT_GOD)) {
                return $event->deny();
            }
        }

        return $event->ignore();
    }
384781
protected function createSearchNodesResponse(SearchNodesRequest $request, Pbjx $pbjx): SearchNodesResponse
    {
        /** @var SearchNodesResponse $response */
        $response = $this->createResponseFromRequest($request, $pbjx);
        return $response;
    }
741137
public function parseExpressionNode(Node\Expr $node)
    {
        switch (true) {
            case $mappedNode = $this->parseOperatorNode($node):
                return $mappedNode;

            case $node instanceof Node\Scalar
                    && $mappedNode = $this->parseScalarNode($node):
                return $mappedNode;

            case $node instanceof Node\Expr\Variable:
                return Expression::variable($this->parseNameNode($node->name));

            case $node instanceof Node\Expr\Array_:
                return $this->parseArrayNode($node);

            case $node instanceof Node\Expr\FuncCall:
                return $this->parseFunctionCallNode($node);

            case $node instanceof Node\Expr\New_:
                return Expression::newExpression(
                        $this->parseNameNode($node->class),
                        $this->parseNodes($node->args)
                );

            case $node instanceof Node\Expr\MethodCall:
                return Expression::methodCall(
                        $this->parseNode($node->var),
                        $this->parseNameNode($node->name),
                        $this->parseNodes($node->args)
                );

            case $node instanceof Node\Expr\PropertyFetch:
                return Expression::field(
                        $this->parseNode($node->var),
                        $this->parseNameNode($node->name)
                );

            case $node instanceof Node\Expr\ArrayDimFetch:
                return Expression::index(
                        $this->parseNode($node->var),
                        $node->dim === null ? null : $this->parseNode($node->dim)
                );

            case $node instanceof Node\Expr\ConstFetch:
                return Expression::constant($this->parseAbsoluteName($node->name));

            case $node instanceof Node\Expr\ClassConstFetch:
                return Expression::classConstant(
                        $this->parseNameNode($node->class),
                        $node->name
                );

            case $node instanceof Node\Expr\StaticCall:
                return Expression::staticMethodCall(
                        $this->parseNameNode($node->class),
                        $this->parseNameNode($node->name),
                        $this->parseNodes($node->args)
                );

            case $node instanceof Node\Expr\StaticPropertyFetch:
                return Expression::staticField(
                        $this->parseNameNode($node->class),
                        $this->parseNameNode($node->name)
                );

            case $node instanceof Node\Expr\Ternary:
                return $this->parseTernaryNode($node);

            case $node instanceof Node\Expr\Closure:
                return $this->parseClosureNode($node);

            case $node instanceof Node\Expr\Empty_:
                return Expression::emptyExpression($this->parseNode($node->expr));

            case $node instanceof Node\Expr\Isset_:
                return Expression::issetExpression($this->parseNodes($node->vars));

            default:
                throw new ASTException(
                        'Cannot parse AST with unknown expression node: %s',
                        get_class($node));
        }
    }
1365025
protected function createGetNodeBatchResponse(GetNodeBatchRequest $request, Pbjx $pbjx): GetNodeBatchResponse
    {
        /** @var GetNodeBatchResponse $response */
        $response = $this->createResponseFromRequest($request, $pbjx);
        return $response;
    }
644895
public function dumpNode(BaseNode $node)
    {
        $reference = parent::dumpNode($node);

        // Simply convert the PHP to JSON for simicity's sake
        $reference = str_replace('<?php', null, $reference);
        $reference = eval($reference);
        $reference = json_encode($reference, JSON_PRETTY_PRINT);

        return $reference.PHP_EOL;
    }
602781
private function getOuterMostArrayNode(Node $node): Node
    {
        $outerMostArrayParent = $node;

        do {
            if ($node instanceof Node\Expr\Array_) {
                $outerMostArrayParent = $node;
            }
        } while ($node = $node->getAttribute(ParentConnectorVisitor::PARENT_KEY));

        return $outerMostArrayParent;
    }
280805
public function create(Event $event)
    {
        return $this->cache->store($this->store)->add(
            $event->mutexName(), true, $event->expiresAt * 60
        );
    }
624319
protected function handle(GetNodeRequest $request, Pbjx $pbjx): GetNodeResponse
    {
        $context = $this->createNcrContext($request);

        if ($request->has('node_ref')) {
            $node = $this->ncr->getNode(
                $request->get('node_ref'),
                $request->get('consistent_read'),
                $context
            );
        } elseif ($request->has('slug')) {
            $qname = SchemaQName::fromString($request->get('qname'));
            $query = IndexQueryBuilder::create($qname, 'slug', $request->get('slug'))
                ->setCount(1)
                ->build();
            $result = $this->ncr->findNodeRefs($query, $context);
            if (!$result->count()) {
                throw new NodeNotFound("Unable to locate {$qname->getMessage()}.");
            }

            $node = $this->ncr->getNode(
                $result->getNodeRefs()[0],
                $request->get('consistent_read'),
                $context
            );
        } else {
            throw new NodeNotFound('No method to locate node.');
        }

        $this->assertIsNodeSupported($node);
        return $this->createGetNodeResponse($request, $pbjx)->set('node', $node);
    }
1327050
public function wantToExecute($event)
    {
        return parent::wantToExecute($event)
            && (empty($this->operationName)
                || ($this->operationName === $event->getKey())
            );
    }
1165201
public function onNodePresave(NodeEvent $event)
    {
        $node = $event->getNode();

        // When coming from the node form, node form has already been submitted
        // case in which, if relevant, a group identifier has already been set
        // and this code won't be execute. In the other hand, if the prepare
        // hook has not been invoked, this will run and set things right.
        // There is still a use case where the node comes from the node form but
        // there is no contextual group, case in which this code will wrongly
        // run, but hopefuly since it is just setting defaults, it won't change
        // the normal behavior.
        if (empty($node->group_id)) {
            $groupId = $this->findMostRelevantGroupId();

            if ($groupId) {
                $node->group_id = $groupId;
            }

            $node->is_ghost = $this->findMostRelevantGhostValue($node);
        }
    }