コード例 #1
0
 public function render(RenderableInterface $element, array $parameters = array())
 {
     try {
         $rendered = $this->engine->render($element->getContent(), $parameters);
     } catch (\Exception $e) {
         $rendered = $e->getMessage();
     }
     return $rendered;
 }
コード例 #2
0
ファイル: BootstrapMenuRenderer.php プロジェクト: aamant/menu
 public function render(RenderableInterface $element, array $attributes = array('class' => 'nav navbar-nav navbar-right'))
 {
     $attributes_to_str = '';
     foreach ($attributes as $key => $value) {
         $attributes_to_str .= sprintf(' %s="%s"', $key, $value);
     }
     if ($element->parent) {
         echo '<li class="dropdown">';
         echo sprintf('<a href="#" class="dropdown-toggle" data-toggle="dropdown">%s <b class="caret"></b></a>', $element->label);
         echo '<ul class="dropdown-menu">';
     } else {
         echo sprintf('<ul%s>', $attributes_to_str);
     }
     $element->items()->map(function ($item) {
         echo $item->render();
     });
     echo '</ul>';
     if ($element->parent) {
         echo '</li>';
     }
 }
コード例 #3
0
 /**
  * Remove a renderable from this renderable.
  *
  * This function will be wrapped by the subclasses, f.e. with an "removePage"
  * or "removeElement" method with the correct type hint.
  *
  * @param RenderableInterface $renderableToRemove
  * @return void
  * @throws \Neos\Form\Exception\FormDefinitionConsistencyException
  * @internal
  */
 protected function removeRenderable(RenderableInterface $renderableToRemove)
 {
     if ($renderableToRemove->getParentRenderable() !== $this) {
         throw new \Neos\Form\Exception\FormDefinitionConsistencyException('The renderable to be removed must be part of the calling parent renderable.', 1326090127);
     }
     $updatedRenderables = array();
     foreach ($this->renderables as $renderable) {
         if ($renderable === $renderableToRemove) {
             continue;
         }
         $updatedRenderables[] = $renderable;
     }
     $this->renderables = $updatedRenderables;
     $renderableToRemove->onRemoveFromParentRenderable();
 }