/** * @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(); }