예제 #1
0
파일: Scripts.php 프로젝트: nxpthx/FLOW3
 /**
  * Does some emergency, forced, low level flush caches if the user told to do
  * so through the command line.
  *
  * @param \TYPO3\FLOW3\Core\Bootstrap $bootstrap
  * @return void
  */
 public static function forceFlushCachesIfNeccessary(Bootstrap $bootstrap)
 {
     if (!isset($_SERVER['argv']) || !isset($_SERVER['argv'][1]) || !isset($_SERVER['argv'][2]) || !in_array($_SERVER['argv'][1], array('typo3.flow3:cache:flush', 'flow3:cache:flush')) || !in_array($_SERVER['argv'][2], array('--force', '-f'))) {
         return;
     }
     $bootstrap->getEarlyInstance('TYPO3\\FLOW3\\Cache\\CacheManager')->flushCaches();
     $environment = $bootstrap->getEarlyInstance('TYPO3\\FLOW3\\Utility\\Environment');
     \TYPO3\FLOW3\Utility\Files::emptyDirectoryRecursively($environment->getPathToTemporaryDirectory());
     echo 'Force-flushed caches for "' . $bootstrap->getContext() . '" context.' . PHP_EOL;
     exit(0);
 }
예제 #2
0
 /**
  * Loads all files in $sourcePath, transforms and stores them in $targetPath
  *
  * @param string $sourcePath Absolute path of the source file directory
  * @param string $targetPath Absolute path of the target file directory
  * @return void
  * @author Bastian Waidelich <*****@*****.**>
  */
 public function processFiles($sourcePath, $targetPath)
 {
     $this->setSourcePath($sourcePath);
     $this->setTargetPath($targetPath);
     if ($this->emptyTargetPath) {
         \TYPO3\FLOW3\Utility\Files::emptyDirectoryRecursively($this->targetPath);
     }
     $this->findSourceFilenames();
     $codeProcessor = $this->objectManager->get($this->codeProcessorClassName);
     $codeProcessor->setExtensionKey($this->extensionKey);
     $unusedReplacePairs = $this->replacePairs;
     foreach ($this->sourceFilenames as $sourceFilename) {
         $classCode = \TYPO3\FLOW3\Utility\Files::getFileContents($sourceFilename);
         $relativeFilePath = substr($sourceFilename, strlen($this->sourcePath) + 1);
         if (!$this->shouldFileBeProcessed($relativeFilePath)) {
             continue;
         }
         $targetFilename = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->targetPath, $relativeFilePath));
         $targetFilename = $this->renameTargetFilename($targetFilename);
         \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively(dirname($targetFilename));
         $codeProcessor->setClassCode($classCode);
         $fileSpecificReplacePairs = array();
         $unusedFileSpecificReplacePairs = array();
         if (isset($this->fileSpecificReplacePairs[$relativeFilePath]) && is_array($this->fileSpecificReplacePairs[$relativeFilePath])) {
             $fileSpecificReplacePairs = $this->fileSpecificReplacePairs[$relativeFilePath];
             $unusedFileSpecificReplacePairs = $fileSpecificReplacePairs;
         }
         file_put_contents($targetFilename, $codeProcessor->processCode($this->replacePairs, $fileSpecificReplacePairs, $unusedReplacePairs, $unusedFileSpecificReplacePairs));
         if (count($unusedFileSpecificReplacePairs)) {
             /*\TYPO3\FLOW3\var_dump(
             			$unusedFileSpecificReplacePairs,
             			'Unused file specific replace pairs'
             		);*/
             //echo '--- Unused file specific replace pairs: ' . $relativeFilePath . chr(10);
             //var_dump($unusedFileSpecificReplacePairs);
         }
     }
     // Additional classes
     if (count($unusedReplacePairs)) {
         /*\TYPO3\FLOW3\var_dump(
         			$unusedReplacePairs,
         			'Unused replace pairs'
         		);*/
         //echo '--- Unused replace pairs: ' . chr(10);
         //var_dump($unusedReplacePairs);
     }
 }
예제 #3
0
 /**
  * Removes all cache entries of this cache.
  *
  * @return void
  * @api
  */
 public function flush()
 {
     \TYPO3\FLOW3\Utility\Files::emptyDirectoryRecursively($this->cacheDirectory);
 }
예제 #4
0
파일: PhpSession.php 프로젝트: nxpthx/FLOW3
 /**
  * Destroys (file) data from all active PHP sessions.
  *
  * @param \TYPO3\FLOW3\Core\Bootstrap $bootstrap
  * @return integer The number of session files which have been removed
  */
 public static function destroyAll(Bootstrap $bootstrap)
 {
     $settings = $bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Configuration\\ConfigurationManager')->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.FLOW3');
     if (empty($settings['session']['PhpSession']['savePath'])) {
         $sessionsPath = Files::concatenatePaths(array($bootstrap->getObjectManager()->get('TYPO3\\FLOW3\\Utility\\Environment')->getPathToTemporaryDirectory(), 'Sessions'));
     } else {
         $sessionsPath = $settings['session']['PhpSession']['savePath'];
     }
     if (is_dir($sessionsPath)) {
         $filenames = Files::readDirectoryRecursively($sessionsPath);
         if (count($filenames) > 0) {
             Files::emptyDirectoryRecursively($sessionsPath);
         }
         return count($filenames);
     } else {
         return 0;
     }
 }
예제 #5
0
 /**
  * Removes all cache entries of this cache and sets the frozen flag to FALSE.
  *
  * @return void
  * @api
  */
 public function flush()
 {
     \TYPO3\FLOW3\Utility\Files::emptyDirectoryRecursively($this->cacheDirectory);
     if ($this->frozen === TRUE) {
         @unlink($this->cacheDirectory . 'FrozenCache.data');
         $this->frozen = FALSE;
     }
 }
예제 #6
0
파일: Service.php 프로젝트: nxpthx/FLOW3
 /**
  * Compiles the Doctrine proxy class code using the Doctrine ProxyFactory.
  *
  * @return void
  */
 public function compileProxies()
 {
     Files::emptyDirectoryRecursively(Files::concatenatePaths(array($this->environment->getPathToTemporaryDirectory(), 'Doctrine/Proxies')));
     $proxyFactory = $this->entityManager->getProxyFactory();
     $proxyFactory->generateProxyClasses($this->entityManager->getMetadataFactory()->getAllMetadata());
 }
예제 #7
0
파일: FilesTest.php 프로젝트: nxpthx/FLOW3
 /**
  * @test
  * @expectedException \TYPO3\FLOW3\Utility\Exception
  */
 public function emptyDirectoryRecursivelyThrowsExceptionIfSpecifiedPathDoesNotExist()
 {
     \TYPO3\FLOW3\Utility\Files::emptyDirectoryRecursively('NonExistingPath');
 }