![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-page-cache/Model/System/Config/Backend/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\PageCache\Model\System\Config\Backend; use Magento\Framework\App\Cache\TypeListInterface; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\App\Config\Value; use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Collection\AbstractDb; use Magento\Framework\Escaper; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Model\Context; use Magento\Framework\Model\ResourceModel\AbstractResource; use Magento\Framework\Registry; /** * Backend model for processing Public content cache lifetime settings * * Class Ttl */ class Ttl extends Value { /** * @var Escaper */ private $escaper; /** * Ttl constructor. * @param Context $context * @param Registry $registry * @param ScopeConfigInterface $config * @param TypeListInterface $cacheTypeList * @param AbstractResource|null $resource * @param AbstractDb|null $resourceCollection * @param array $data * @param Escaper|null $escaper */ public function __construct( Context $context, Registry $registry, ScopeConfigInterface $config, TypeListInterface $cacheTypeList, ?AbstractResource $resource = null, ?AbstractDb $resourceCollection = null, array $data = [], ?Escaper $escaper = null ) { parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data); $this->escaper = $escaper ?: ObjectManager::getInstance()->create(Escaper::class); } /** * Throw exception if Ttl data is invalid or empty * * @return $this * @throws LocalizedException */ public function beforeSave() { $value = $this->getValue() ?? ''; if ((bool) $value < 0 || !preg_match('/^[0-9]+$/', $value)) { throw new LocalizedException( __( 'Ttl value "%1" is not valid. Please use only numbers equal or greater than zero.', $this->escaper->escapeHtml($value) ) ); } return $this; } }