__construct() public method

CacheBase constructor.
public __construct ( Config $config = null, Psr\Log\LoggerInterface $logger = null )
$config Config
$logger Psr\Log\LoggerInterface OPTIONAL override default logger
Example #1
0
 /**
  * Cache constructor.
  * @param Config $config
  * @param LoggerInterface $logger
  * @throws Exception
  */
 public function __construct(Config $config, LoggerInterface $logger)
 {
     parent::__construct($config, $logger);
     if (($this->config->usecache || $this->config->storecache) && !is_dir($this->config->cachedir)) {
         @mkdir($this->config->cachedir, 0700, true);
         if (!is_dir($this->config->cachedir)) {
             $this->logger->critical("[Cache] Configured cache directory [{$this->config->cachedir}] does not exist!");
             throw new Exception("[Cache] Configured cache directory [{$this->config->cachedir}] does not exist!");
         }
     }
     if ($this->config->storecache && !is_writable($this->config->cachedir)) {
         $this->logger->critical("[Cache] Configured cache directory [{$this->config->cachedir}] lacks write permission!");
         throw new Exception("[Cache] Configured cache directory [{$this->config->cachedir}] lacks write permission!");
     }
 }