/**
  * @return bool True if we are able to boot from a cached container. False otherwise.
  */
 private function _canBootFromCache()
 {
     if ($this->_logEnabled) {
         $this->_logDebug('Determining if system cache is available.');
     }
     if (!$this->_bootSettings->isSystemCacheEnabled()) {
         if ($this->_logEnabled) {
             $this->_logDebug('System cache is disabled by user settings.php');
         }
         return false;
     }
     if ($this->_tubePressContainerClassExists()) {
         return true;
     }
     $file = $this->_getPathToContainerCacheFile();
     if (!is_readable($file)) {
         if ($this->_logEnabled) {
             $this->_logDebug(sprintf('<code>%s</code> is not a readable file.', $file));
         }
         return false;
     }
     if ($this->_logEnabled) {
         $this->_logDebug(sprintf('<code>%s</code> is a readable file. Now including it.', $file));
     }
     /** @noinspection PhpIncludeInspection */
     require $file;
     $iocContainerHit = $this->_tubePressContainerClassExists();
     if ($this->_logEnabled) {
         if ($iocContainerHit) {
             $this->_logDebug(sprintf('Service container found in cache? <code>%s</code>', $iocContainerHit ? 'yes' : 'no'));
         }
     }
     return $iocContainerHit;
 }
 /**
  * @param tubepress_internal_ioc_ContainerBuilder $containerBuilder
  *
  * @return \Symfony\Component\DependencyInjection\ContainerInterface
  */
 private function _convertToSymfonyContainer(tubepress_internal_ioc_ContainerBuilder $containerBuilder)
 {
     if ($this->_shouldLog) {
         $this->_logDebug('Preparing to store boot to cache.');
     }
     $dumpedContainerText = $this->_getDumpedSymfonyContainerAsString($containerBuilder->getDelegateContainerBuilder());
     if ($this->_bootSettings->isSystemCacheEnabled()) {
         $cachePath = $this->_bootSettings->getPathToSystemCacheDirectory();
         $storagePath = sprintf('%s%sTubePressServiceContainer.php', $cachePath, DIRECTORY_SEPARATOR);
     } else {
         $storagePath = tempnam(sys_get_temp_dir(), 'TubePressServiceContainer');
     }
     if (!is_dir(dirname($storagePath))) {
         if ($this->_shouldLog) {
             $this->_logDebug(sprintf('Attempting to create all the parent directories of <code>%s</code>', $storagePath));
         }
         $success = @mkdir(dirname($storagePath), 0755, true);
         if ($this->_shouldLog) {
             if ($success === true) {
                 $this->_logDebug(sprintf('Created all the parent directories of <code>%s</code>', $storagePath));
             } else {
                 $this->_logger->error(sprintf('Failed to create all the parent directories of <code>%s</code>', $storagePath));
             }
         }
         if ($success !== true) {
             return $containerBuilder->getDelegateContainerBuilder();
         }
     }
     if ($this->_shouldLog) {
         $this->_logDebug(sprintf('Now writing dumped container to <code>%s</code>', $storagePath));
     }
     $success = @file_put_contents($storagePath, $dumpedContainerText) !== false;
     if ($success) {
         if ($this->_shouldLog) {
             $this->_logDebug(sprintf('Saved service container to <code>%s</code>. Now including it.', $storagePath));
         }
         if (!class_exists('TubePressServiceContainer', false)) {
             /** @noinspection PhpIncludeInspection */
             require $storagePath;
         }
     } else {
         if ($this->_shouldLog) {
             $this->_logger->error(sprintf('Could not write service container to <code>%s</code>.', $storagePath));
         }
         return $containerBuilder->getDelegateContainerBuilder();
     }
     /** @noinspection PhpUndefinedClassInspection */
     return new TubePressServiceContainer();
 }