class RendererFactory in Entity Print 8.2
Same name and namespace in other branches
- 8 src/Renderer/RendererFactory.php \Drupal\entity_print\Renderer\RendererFactory
The RendererFactory class.
Hierarchy
- class \Drupal\entity_print\Renderer\RendererFactory implements RendererFactoryInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
Expanded class hierarchy of RendererFactory
1 string reference to 'RendererFactory'
1 service uses RendererFactory
File
- src/
Renderer/ RendererFactory.php, line 12
Namespace
Drupal\entity_print\RendererView source
class RendererFactory implements RendererFactoryInterface {
use ContainerAwareTrait;
/**
* {@inheritdoc}
*/
public function create($item, $context = 'entity') {
$entity_type_manager = $this->container
->get('entity_type.manager');
// If we get an array or something, just look at the first one.
if (is_array($item)) {
$item = array_pop($item);
}
if ($item instanceof EntityInterface && $entity_type_manager
->hasHandler($item
->getEntityTypeId(), 'entity_print')) {
return $entity_type_manager
->getHandler($item
->getEntityTypeId(), 'entity_print');
}
throw new PrintEngineException(sprintf('Rendering not yet supported for "%s". Entity Print context "%s"', is_object($item) ? get_class($item) : $item, $context));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RendererFactory:: |
public | function |
Create a new entity renderer. Overrides RendererFactoryInterface:: |