/**
  * Invoke the rendering.
  *
  * @param array $row The child as array.
  *
  * @return mixed|string
  */
 public function __invoke($row)
 {
     $buffer = call_user_func($this->callback, $row);
     if ($row['ptable'] === 'tl_content_node') {
         $parent = \ContentModel::findByPk($row['pid']);
         if ($this->registry->hasNodeType($parent->type)) {
             $node = $this->registry->getNode($parent->type);
             return $node->generateChildInBackendView($row, $buffer);
         }
     }
     return $buffer;
 }
 /**
  * Inject the breadcrumb.
  *
  * @param string $buffer   The generated output.
  * @param string $template The template name.
  *
  * @return string
  */
 public function injectBreadcrumb($buffer, $template)
 {
     if (!$this->isBreadcrumbRequired($template)) {
         return $buffer;
     }
     $items = array();
     $model = \ContentModel::findByPk(CURRENT_ID);
     $current = $model;
     while ($model && $this->registry->hasNodeType($model->type)) {
         array_unshift($items, $model);
         if ($model->ptable !== 'tl_content_node') {
             break;
         }
         $model = \ContentModel::findByPk($model->pid);
     }
     if ($items) {
         $breadcrumb = new Breadcrumb();
         $this->addParentToBreadcrumb($model, $breadcrumb);
         foreach ($items as $item) {
             $this->registry->getNode($item->type)->buildBreadcrumb($breadcrumb, $item);
         }
         $replacement = $breadcrumb->generate() . '<div class="tl_listing_container node-' . $current->type;
         $buffer = str_replace('<div class="tl_listing_container', $replacement, $buffer);
     }
     return $buffer;
 }
Example #3
0
 /**
  * Generate the header fields.
  *
  * @param array $fields The header fields.
  *
  * @return array
  */
 public function generateHeaderFields($fields)
 {
     $model = \ContentModel::findByPk(CURRENT_ID);
     if ($model instanceof \ContentModel && $this->registry->hasNodeType($model->type)) {
         return $this->registry->getNode($model->type)->generateHeaderFields($fields, $model);
     }
     return $fields;
 }