Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Factory.php
Go to the documentation of this file.
1 <?php
8 
10 
14 class Factory
15 {
21  protected $types = [
26  ];
27 
33  protected $objectManager;
34 
41  {
42  $this->objectManager = $objectManager;
43  }
44 
54  public function create($type, $text = null)
55  {
56  if (!in_array($type, $this->types)) {
57  throw new \InvalidArgumentException('Wrong message type');
58  }
59 
60  $className = 'Magento\\Framework\\Message\\' . ucfirst($type);
61 
62  $message = $this->objectManager->create($className, $text === null ? [] : ['text' => $text]);
63  if (!$message instanceof MessageInterface) {
64  throw new \InvalidArgumentException(
65  $className . ' doesn\'t implement \Magento\Framework\Message\MessageInterface'
66  );
67  }
68 
69  return $message;
70  }
71 }
endifif( $block->getLastPageNum()>1)( 'Page') ?></strong >< ul class $text
Definition: pager.phtml:43
create($type, $text=null)
Definition: Factory.php:54
$message
$type
Definition: item.phtml:13
__construct(ObjectManagerInterface $objectManager)
Definition: Factory.php:40
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31