本文整理汇总了PHP中NodeInterface类的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface类的具体用法?PHP NodeInterface怎么用?PHP NodeInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFromNode
public function createFromNode(NodeInterface $node)
{
$item = $this->createItem($node->getName(), $node->getOptions());
foreach ($node->getChildren() as $childNode) {
$item->addChild($this->createFromNode($childNode));
}
return $item;
}
示例2: process
/**
* Processes an array of configurations.
*
* @param NodeInterface $configTree The node tree describing the configuration
* @param array $configs An array of configuration items to process
*
* @return array The processed configuration
*/
public function process(NodeInterface $configTree, array $configs)
{
$currentConfig = array();
foreach ($configs as $config) {
$config = $configTree->normalize($config);
$currentConfig = $configTree->merge($currentConfig, $config);
}
return $configTree->finalize($currentConfig);
}
示例3: translateChild
private function translateChild(ValueObject $meta, ResultInterface $result, NodeInterface $node) : CollectionInterface
{
$relMeta = $meta->relationship();
$relationships = $result->relationships()->filter(function (RelationshipInterface $relationship) use($node, $relMeta) {
return (string) $relationship->type() === (string) $relMeta->type() && $relationship->endNode()->value() === $node->id()->value();
});
if ($relationships->count() > 1) {
throw MoreThanOneRelationshipFoundException::for($meta);
}
return $this->translateRelationship($meta, $result, $relationships->first());
}
示例4: process
/**
* Processes an array of configurations.
*
* @param NodeInterface $configTree The node tree describing the configuration
* @param array $configs An array of configuration items to process
* @param bool $normalizeKeys Flag indicating if config key normalization is needed. True by default.
*
* @return array The processed configuration
*/
public function process(NodeInterface $configTree, array $configs, $normalizeKeys = true)
{
if ($normalizeKeys) {
$configs = self::normalizeKeys($configs);
}
$currentConfig = array();
foreach ($configs as $config) {
$config = $configTree->normalize($config);
$currentConfig = $configTree->merge($currentConfig, $config);
}
return $configTree->finalize($currentConfig);
}
示例5: hook_scheduler_allow_unpublishing
/**
* Allows to prevent unpublication of a scheduled node.
*
* @param \Drupal\node\NodeInterface $node
* The scheduled node that is about to be unpublished.
*
* @return bool
* FALSE if the node should not be unpublished. TRUE otherwise.
*/
function hook_scheduler_allow_unpublishing(NodeInterface $node)
{
$allowed = TRUE;
// Prevent unpublication of competition entries if not all prizes have been
// claimed.
if ($node->getType() == 'competition' && ($items = $node->field_competition_prizes->getValue())) {
$allowed = (bool) count($items);
// If unpublication is denied then inform the user why.
if (!$allowed) {
drupal_set_message(t('The competition will only be unpublished after all prizes have been claimed by the winners.'));
}
}
return $allowed;
}
示例6: registerChild
public function registerChild(NodeInterface $node, $overwrite = false, $prepend = false)
{
$this->registerAdopters();
if ($node->getParent() !== $this) {
throw new \RuntimeException('Nodes being registered must return this node from their getParentNode method.');
}
$name = $node->getName();
if (!$overwrite && isset($this->childNodes[$name])) {
throw new \RuntimeException(sprintf('Node name %s is already registered.', $name));
}
if ($prepend) {
$this->childNodes = array_merge([$name => null], $this->getChildren(), [$name => $node]);
} else {
$this->childNodes[$name] = $node;
}
}
示例7: addContentNode
/**
* Adiciona um Nó ao Conteúdo
* @param NodeInterface $node Nó de Conteúdo Interno
*/
public function addContentNode(NodeInterface $node)
{
$node->setParentNode($this);
$this->_content[] = $node;
return $this;
}
示例8: getLabel
/**
* Render a node label
*
* @param NodeInterface $node
* @param boolean $crop This argument is deprecated as of Neos 1.2 and will be removed. Don't rely on this behavior and crop labels in the view.
* @return string
*/
public function getLabel(NodeInterface $node, $crop = true)
{
return $this->nodeDataLabelGenerator->getLabel($node->getNodeData(), $crop);
}
示例9: check
private function check(NodeInterface $node) : bool
{
return $node instanceof ElementInterface && $node->attributes()->contains('role') && $node->attributes()->get('role')->value() === $this->role;
}
示例10: __construct
public function __construct(NodeInterface $entity)
{
$this->originalData = array('id' => $entity->getId(), 'left' => $entity->getLeftValue(), 'right' => $entity->getRightValue(), 'level' => $entity->getLevel(), 'isLeaf' => $entity instanceof NodeLeafInterface);
}
示例11: getUriFromNode
/**
* Get the uri for the given node
*
* @param NodeInterface $node
* @return string
*/
protected function getUriFromNode(NodeInterface $node)
{
return $node->getUri();
}
示例12: appendChild
public function appendChild(NodeInterface $node)
{
$node->setParent($this);
$this->children->add($node);
return $this;
}
示例13: mergeWith
public function mergeWith(NodeInterface $node, $deep = true)
{
// @todo ensure that this method work as expected
foreach ($node->getChildren() as $key => $child) {
if (!$this->hasChild($key)) {
$this->addChild($child->duplicate());
} else {
if ($deep) {
$this->getChild($key)->mergeWith($child, $deep);
}
}
}
}
示例14: setChild
/**
* Set child
*
* @param int $position
* @param NodeInterface|null $child
* @return $this
*/
public function setChild($position, NodeInterface $child = null)
{
$this->children[$position] = $child;
if (null !== $child) {
$child->setParent($this)->setPosition($position);
}
return $this;
}
示例15: setParent
public function setParent(NodeInterface $parent)
{
$this->parent = $parent;
$this->setDepth($parent->getDepth() + 1);
}