Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Path.php
Go to the documentation of this file.
1 <?php
7 
11 class Path extends \Magento\Framework\App\Config\Value
12 {
16  protected $configValidator;
17 
29  public function __construct(
30  \Magento\Framework\Model\Context $context,
31  \Magento\Framework\Registry $registry,
32  \Magento\Framework\App\Config\ScopeConfigInterface $config,
33  \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
34  \Magento\Framework\Session\Config\Validator\CookiePathValidator $configValidator,
35  \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
36  \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
37  array $data = []
38  ) {
39  $this->configValidator = $configValidator;
40  parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
41  }
42 
49  public function beforeSave()
50  {
51  $value = $this->getValue();
52 
53  if (!empty($value) && !$this->configValidator->isValid($value)) {
54  throw new \Magento\Framework\Exception\LocalizedException(__('Invalid cookie path'));
55  }
56  }
57 }
$config
Definition: fraud_order.php:17
__()
Definition: __.php:13
$resource
Definition: bulk.php:12
$value
Definition: gender.phtml:16