Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Adapter.php
Go to the documentation of this file.
1 <?php
13 
18 class Adapter extends \Magento\Framework\App\Config\Value
19 {
23  protected $_imageFactory;
24 
35  public function __construct(
36  \Magento\Framework\Model\Context $context,
37  \Magento\Framework\Registry $registry,
39  \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
40  \Magento\Framework\Image\AdapterFactory $imageFactory,
41  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
42  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
43  array $data = []
44  ) {
45  parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
46  $this->_imageFactory = $imageFactory;
47  }
48 
55  public function beforeSave()
56  {
57  try {
58  $this->_imageFactory->create($this->getValue());
59  } catch (\Exception $e) {
60  $message = __('The specified image adapter cannot be used because of: %1', $e->getMessage());
61  throw new \Magento\Framework\Exception\LocalizedException($message);
62  }
63 
64  return $this;
65  }
66 }
$config
Definition: fraud_order.php:17
__()
Definition: __.php:13
$resource
Definition: bulk.php:12
$message
__construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList, \Magento\Framework\Image\AdapterFactory $imageFactory, \Magento\Framework\Model\ResourceModel\AbstractResource $resource=null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection=null, array $data=[])
Definition: Adapter.php:35