Ejemplo n.º 1
0
 /**
  * Prints the render structure of the current entity.
  *
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *    A RouteMatch object.
  *
  * @return array
  *    Array of page elements to render.
  */
 public function entityRender(RouteMatchInterface $route_match)
 {
     $output = array();
     $parameter_name = $route_match->getRouteObject()->getOption('_devel_entity_type_id');
     $entity = $route_match->getParameter($parameter_name);
     if ($entity && $entity instanceof EntityInterface) {
         $entity_type_id = $entity->getEntityTypeId();
         $view_hook = $entity_type_id . '_view';
         $build = array();
         // If module implements own {entity_type}_view
         if (function_exists($view_hook)) {
             $build = $view_hook($entity);
         } elseif ($this->entityManager()->hasHandler($entity_type_id, 'view_builder')) {
             $build = $this->entityManager()->getViewBuilder($entity_type_id)->view($entity);
         }
         $output = array('#markup' => kdevel_print_object($build));
     }
     return $output;
 }
Ejemplo n.º 2
0
 protected function renderObject($type, $object, $name = NULL)
 {
     $name = isset($name) ? $name : $type;
     $function = $type . '_view';
     $build = $function($object);
     return kdevel_print_object($build, '$' . $name . '->');
 }