Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileServiceFactory.php
Go to the documentation of this file.
1 <?php
7 
12 {
18  protected $_objectManager;
19 
27  {
28  $this->_objectManager = $objectManager;
29  $this->_types = $config->getFileTypes();
30  }
31 
40  public function create($type, array $data = [])
41  {
42  if (empty($this->_types[$type])) {
43  throw new \InvalidArgumentException('Unsupported file type');
44  }
45  $fileService = $this->_objectManager->get($this->_types[$type], [$data]);
46  if (!$fileService instanceof \Magento\Framework\View\Design\Theme\Customization\FileInterface) {
47  throw new \InvalidArgumentException('Service don\'t implement interface');
48  }
49  return $fileService;
50  }
51 }
$objectManager
Definition: bootstrap.php:17
$config
Definition: fraud_order.php:17
$type
Definition: item.phtml:13
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, ConfigInterface $config)