/**
  * Initializes the manager
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function initializeObject()
 {
     $this->lockPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'FLOW3.lock';
     if (file_exists($this->lockPathAndFilename)) {
         if (filemtime($this->lockPathAndFilename) < time() - self::LOCKFILE_MAXIMUM_AGE) {
             unlink($this->lockPathAndFilename);
         } else {
             $this->siteLocked = TRUE;
         }
     }
 }
 /**
  * Sets a reference to the cache frontend which uses this backend and
  * initializes the default cache directory
  *
  * @return void
  * @author Robert Lemke <*****@*****.**>
  */
 public function setCache(\F3\FLOW3\Cache\Frontend\FrontendInterface $cache)
 {
     parent::setCache($cache);
     $cacheDirectory = $this->environment->getPathToTemporaryDirectory() . 'Cache/' . $this->cacheIdentifier . '/';
     if (!is_writable($cacheDirectory)) {
         try {
             \F3\FLOW3\Utility\Files::createDirectoryRecursively($cacheDirectory);
         } catch (\F3\FLOW3\Utility\Exception $exception) {
             throw new \F3\FLOW3\Cache\Exception('The cache directory "' . $cacheDirectory . '" could not be created.', 1264426237);
         }
     }
     if (!is_dir($cacheDirectory)) {
         throw new \F3\FLOW3\Cache\Exception('The cache directory "' . $cacheDirectory . '" does not exist.', 1203965199);
     }
     if (!is_writable($cacheDirectory)) {
         throw new \F3\FLOW3\Cache\Exception('The cache directory "' . $cacheDirectory . '" is not writable.', 1203965200);
     }
     $this->cacheDirectory = $cacheDirectory;
 }
 /**
  * Starts the session, if is has not been already started
  *
  * @return void
  * @author Andreas Förthner <*****@*****.**>
  */
 public function start()
 {
     if ($this->started === FALSE) {
         if (empty($this->settings['PHPSession']['savePath'])) {
             $sessionsPath = \F3\FLOW3\Utility\Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Sessions'));
         } else {
             $sessionsPath = $this->settings['PHPSession']['savePath'];
         }
         if (!file_exists($sessionsPath)) {
             mkdir($sessionsPath);
         }
         session_save_path($sessionsPath);
         session_start();
         $this->sessionId = session_id();
         $this->started = TRUE;
     }
 }
 /**
  * Imports a resource (file) from the given location as a persistent resource.
  * On a successful import this method returns a Resource object representing the
  * newly imported persistent resource.
  *
  * @param string $uri An URI (can also be a path and filename) pointing to the resource to import
  * @return mixed A resource object representing the imported resource or FALSE if an error occurred.
  * @author Robert Lemke <*****@*****.**>
  * @api
  */
 public function importResource($uri)
 {
     $pathInfo = pathinfo($uri);
     if (!isset($pathInfo['extension']) || substr(strtolower($pathInfo['extension']), -3, 3) === 'php') {
         return FALSE;
     }
     $temporaryTargetPathAndFilename = $this->environment->getPathToTemporaryDirectory() . uniqid('FLOW3_ResourceImport_');
     if (copy($uri, $temporaryTargetPathAndFilename) === FALSE) {
         return FALSE;
     }
     $hash = sha1_file($temporaryTargetPathAndFilename);
     $finalTargetPathAndFilename = $this->persistentResourcesStorageBaseUri . $hash;
     if (rename($temporaryTargetPathAndFilename, $finalTargetPathAndFilename) === FALSE) {
         unlink($temporaryTargetPathAndFilename);
         return FALSE;
     }
     return $this->objectFactory->create('F3\\FLOW3\\Resource\\Resource', $hash, $pathInfo['extension']);
 }
    /**
     * Saves the current configuration into a cache file and creates a cache inclusion script
     * in the context's Configuration directory.
     *
     * @return void
     * @author Robert Lemke <*****@*****.**>
     */
    protected function saveConfigurationCache()
    {
        $configurationCachePath = $this->environment->getPathToTemporaryDirectory() . 'Configuration/';
        if (!file_exists($configurationCachePath)) {
            \F3\FLOW3\Utility\Files::createDirectoryRecursively($configurationCachePath);
        }
        $cachePathAndFilename = $configurationCachePath . $this->context . 'Configurations.php';
        $currentRevision = \F3\FLOW3\Core\Bootstrap::REVISION;
        $includeCachedConfigurationsCode = <<<EOD
<?php
\tif (file_exists('{$cachePathAndFilename}') && \\F3\\FLOW3\\Core\\Bootstrap::REVISION === '{$currentRevision}') {
\t\treturn require '{$cachePathAndFilename}';
\t} else {
\t\tunlink(__FILE__);
\t\treturn array();
\t}
?>
EOD;
        file_put_contents($cachePathAndFilename, '<?php return ' . var_export($this->configurations, TRUE) . '?>');
        file_put_contents($this->includeCachedConfigurationsPathAndFilename, $includeCachedConfigurationsCode);
    }