/**
  * Renders reST files to fjson files which can be processed by the import command.
  *
  * @param string $bundle Bundle to render. If not specified all configured bundles will be rendered
  * @return void
  */
 public function renderCommand($bundle = NULL)
 {
     $bundles = $bundle !== NULL ? array($bundle) : array_keys($this->settings['bundles']);
     $defaultConfiguration = isset($this->settings['defaultConfiguration']) ? $this->settings['defaultConfiguration'] : array();
     if ($bundles === array()) {
         $this->outputLine('No bundles configured.');
         $this->quit(1);
     }
     foreach ($bundles as $bundle) {
         if (!isset($this->settings['bundles'][$bundle])) {
             $this->outputLine('Bundle "%s" is not configured.', array($bundle));
             $this->quit(1);
         }
         $configuration = \TYPO3\FLOW3\Utility\Arrays::arrayMergeRecursiveOverrule($defaultConfiguration, $this->settings['bundles'][$bundle]);
         $outputFormat = 'json';
         if (!empty($configuration['renderingOutputFormat']) && !in_array($configuration['renderingOutputFormat'], $this->supportedOutputFormats)) {
             $this->outputLine('Output format ' . $outputFormat . ' is not supported. Choose one of the following: ' . implode(', ', $this->supportedOutputFormats));
             continue;
         } elseif (!empty($configuration['renderingOutputFormat'])) {
             $outputFormat = $configuration['renderingOutputFormat'];
         }
         $this->outputLine('Rendering bundle "%s"', array($bundle));
         if (is_dir($configuration['renderedDocumentationRootPath'])) {
             \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($configuration['renderedDocumentationRootPath']);
         }
         $renderCommand = $this->buildRenderCommand($configuration, $outputFormat);
         exec($renderCommand, $output, $result);
         if ($result !== 0) {
             $this->output('Could not execute sphinx-build command for Bundle %s', array($bundle));
             $this->quit(1);
         }
     }
 }
예제 #2
0
 /**
  * Recursively publishes static resources located in the specified directory.
  * These resources are typically public package resources provided by the active packages.
  *
  * @param string $sourcePath The full path to the source directory which should be published (includes sub directories)
  * @param string $relativeTargetPath Path relative to the target's root where resources should be published to.
  * @return boolean TRUE if publication succeeded or FALSE if the resources could not be published
  */
 public function publishStaticResources($sourcePath, $relativeTargetPath)
 {
     if (!is_dir($sourcePath)) {
         return FALSE;
     }
     $sourcePath = rtrim(\TYPO3\FLOW3\Utility\Files::getUnixStylePath($this->realpath($sourcePath)), '/');
     $targetPath = rtrim(\TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->resourcesPublishingPath, 'Static', $relativeTargetPath)), '/');
     if ($this->settings['resource']['publishing']['fileSystem']['mirrorMode'] === 'link') {
         if (\TYPO3\FLOW3\Utility\Files::is_link($targetPath) && rtrim(\TYPO3\FLOW3\Utility\Files::getUnixStylePath($this->realpath($targetPath)), '/') === $sourcePath) {
             return TRUE;
         } elseif (is_dir($targetPath)) {
             \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($targetPath);
         } elseif (is_link($targetPath)) {
             unlink($targetPath);
         } else {
             \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively(dirname($targetPath));
         }
         symlink($sourcePath, $targetPath);
     } else {
         foreach (\TYPO3\FLOW3\Utility\Files::readDirectoryRecursively($sourcePath) as $sourcePathAndFilename) {
             if (substr(strtolower($sourcePathAndFilename), -4, 4) === '.php') {
                 continue;
             }
             $targetPathAndFilename = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array($targetPath, str_replace($sourcePath, '', $sourcePathAndFilename)));
             if (!file_exists($targetPathAndFilename) || filemtime($sourcePathAndFilename) > filemtime($targetPathAndFilename)) {
                 $this->mirrorFile($sourcePathAndFilename, $targetPathAndFilename, TRUE);
             }
         }
     }
     return TRUE;
 }
 public function tearDown()
 {
     \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($this->temporaryDirectoryPath);
     \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($this->publishPath);
 }
예제 #4
0
 /**
  * Loads the states of available packages from the PackageStates.php file.
  * The result is stored in $this->packageStatesConfiguration.
  *
  * @return void
  */
 protected function loadPackageStates()
 {
     $this->packageStatesConfiguration = file_exists($this->packageStatesPathAndFilename) ? include $this->packageStatesPathAndFilename : array();
     if (!isset($this->packageStatesConfiguration['version']) || $this->packageStatesConfiguration['version'] < 2) {
         if (is_dir(FLOW3_PATH_PACKAGES . '.Shortcuts')) {
             Files::removeDirectoryRecursively(FLOW3_PATH_PACKAGES . '.Shortcuts');
         }
         $this->packageStatesConfiguration = array();
     }
     if ($this->packageStatesConfiguration === array() || !$this->bootstrap->getContext()->isProduction()) {
         $this->scanAvailablePackages();
     } else {
         $this->registerPackages();
     }
 }
예제 #5
0
파일: FilesTest.php 프로젝트: nxpthx/FLOW3
 /**
  * @test
  */
 public function unlinkProperlyRemovesSymlinksPointingToDirectories()
 {
     $targetPath = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array(dirname(tempnam($this->temporaryDirectory, '')), 'FLOW3FilesTestDirectory'));
     if (!is_dir($targetPath)) {
         \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($targetPath);
     }
     $linkPath = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array(dirname(tempnam($this->temporaryDirectory, '')), 'FLOW3FilesTestDirectoryLink'));
     if (is_dir($linkPath)) {
         \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($linkPath);
     }
     symlink($targetPath, $linkPath);
     $this->assertTrue(\TYPO3\FLOW3\Utility\Files::unlink($linkPath));
     $this->assertTrue(file_exists($targetPath));
     $this->assertFalse(file_exists($linkPath));
 }
 /**
  * @test
  */
 public function publishStaticResourcesLinksTheSpecifiedDirectoryIfMirrorModeIsLink()
 {
     $sourcePath = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array(realpath(sys_get_temp_dir()), 'FLOW3FileSystemPublishingTargetTestSource'));
     $targetRootPath = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array(realpath(sys_get_temp_dir()), 'FLOW3FileSystemPublishingTargetTestTarget'));
     $targetPath = \TYPO3\FLOW3\Utility\Files::concatenatePaths(array($targetRootPath, '_Resources'));
     mkdir($sourcePath);
     \TYPO3\FLOW3\Utility\Files::createDirectoryRecursively($targetPath);
     $settings = array('resource' => array('publishing' => array('fileSystem' => array('mirrorMode' => 'link'))));
     $publishingTarget = $this->getAccessibleMock('TYPO3\\FLOW3\\Resource\\Publishing\\FileSystemPublishingTarget', array('mirrorFile'));
     $publishingTarget->_set('settings', $settings);
     $publishingTarget->_set('resourcesPublishingPath', $targetPath);
     $publishingTarget->expects($this->never())->method('mirrorFile');
     $this->assertTrue($publishingTarget->publishStaticResources($sourcePath, 'Bar'));
     $this->assertTrue(\TYPO3\FLOW3\Utility\Files::is_link(\TYPO3\FLOW3\Utility\Files::concatenatePaths(array($targetPath, 'Static/Bar'))));
     \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($targetRootPath);
     \TYPO3\FLOW3\Utility\Files::removeDirectoryRecursively($sourcePath);
 }