当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::getName方法代码示例

本文整理汇总了PHP中NodeInterface::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getName方法的具体用法?PHP NodeInterface::getName怎么用?PHP NodeInterface::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeInterface的用法示例。


在下文中一共展示了NodeInterface::getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:ner0tic,项目名称:landmarx,代码行数:8,代码来源:LandmarkFactory.php

示例2: createFromNode

 /**
  * Create a menu item from a NodeInterface
  *
  * @param NodeInterface $node
  * @return MenuItem
  */
 public function createFromNode(NodeInterface $node)
 {
     $item = new MenuItem($node->getName(), $this->getUriFromNode($node), $node->getAttributes());
     $item->setLabel($node->getLabel());
     foreach ($node->getChildren() as $childNode) {
         $item->addChild($this->createFromNode($childNode));
     }
     return $item;
 }
开发者ID:rogchap,项目名称:Diakonia,代码行数:15,代码来源:MenuFactory.php

示例3: 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;
     }
 }
开发者ID:mikegibson,项目名称:sentient,代码行数:16,代码来源:Node.php

示例4: writeNode

    /**
     * @param int $depth
     */
    private function writeNode(NodeInterface $node, $depth = 0)
    {
        $comments = array();
        $default = '';
        $defaultArray = null;
        $children = null;
        $example = $node->getExample();

        // defaults
        if ($node instanceof ArrayNode) {
            $children = $node->getChildren();

            if ($node instanceof PrototypedArrayNode) {
                $prototype = $node->getPrototype();

                if ($prototype instanceof ArrayNode) {
                    $children = $prototype->getChildren();
                }

                // check for attribute as key
                if ($key = $node->getKeyAttribute()) {
                    $keyNode = new ArrayNode($key, $node);
                    $keyNode->setInfo('Prototype');

                    // add children
                    foreach ($children as $childNode) {
                        $keyNode->addChild($childNode);
                    }
                    $children = array($key => $keyNode);
                }
            }

            if (!$children) {
                if ($node->hasDefaultValue() && count($defaultArray = $node->getDefaultValue())) {
                    $default = '';
                } elseif (!is_array($example)) {
                    $default = '[]';
                }
            }
        } else {
            $default = '~';

            if ($node->hasDefaultValue()) {
                $default = $node->getDefaultValue();

                if (true === $default) {
                    $default = 'true';
                } elseif (false === $default) {
                    $default = 'false';
                } elseif (null === $default) {
                    $default = '~';
                }
            }
        }

        // required?
        if ($node->isRequired()) {
            $comments[] = 'Required';
        }

        // example
        if ($example && !is_array($example)) {
            $comments[] = 'Example: '.$example;
        }

        $default = (string) $default != '' ? ' '.$default : '';
        $comments = count($comments) ? '# '.implode(', ', $comments) : '';

        $text = sprintf('%-20s %s %s', $node->getName().':', $default, $comments);

        if ($info = $node->getInfo()) {
            $this->writeLine('');
            $this->writeLine('# '.$info, $depth * 4);
        }

        $this->writeLine($text, $depth * 4);

        // output defaults
        if ($defaultArray) {
            $this->writeLine('');

            $message = count($defaultArray) > 1 ? 'Defaults' : 'Default';

            $this->writeLine('# '.$message.':', $depth * 4 + 4);

            $this->writeArray($defaultArray, $depth + 1);
        }

        if (is_array($example)) {
            $this->writeLine('');

            $message = count($example) > 1 ? 'Examples' : 'Example';

            $this->writeLine('# '.$message.':', $depth * 4 + 4);

            $this->writeArray($example, $depth + 1);
        }
//.........这里部分代码省略.........
开发者ID:n3b,项目名称:symfony,代码行数:101,代码来源:ReferenceDumper.php

示例5: addChild

 public function addChild(NodeInterface $node)
 {
     if ($this->isTerminal()) {
         throw new \LogicException("I am terminal");
     }
     $node->setParent($this);
     $this->children[$node->getName()] = $node;
 }
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:8,代码来源:Node.php


注:本文中的NodeInterface::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。