Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ContentTypeFactory.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
20  protected $types;
21 
27  protected $objectManager;
28 
36  {
37  $this->types = $types;
38  $this->objectManager = $objectManager;
39  }
40 
48  public function get($type)
49  {
50  if (!isset($this->types[$type])) {
51  throw new \InvalidArgumentException(sprintf("Wrong content type '%s', renderer not exists.", $type));
52  }
53 
54  $contentRender = $this->objectManager->get($this->types[$type]);
55  if (!$contentRender instanceof ContentTypeInterface) {
56  throw new \InvalidArgumentException(
57  sprintf('"%s" must implement the interface ContentTypeInterface.', $this->types[$type])
58  );
59  }
60 
61  return $contentRender;
62  }
63 }
__construct(ObjectManagerInterface $objectManager, array $types)
$type
Definition: item.phtml:13