コード例 #1
0
ファイル: ClearCacheCommand.php プロジェクト: jousch/clitools
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // ####################
     // Init
     // ####################
     $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/');
     $maxDepth = 3;
     $output->writeln('<h2>Clear TYPO3 cache</h2>');
     if ($input->getArgument('path')) {
         $basePath = $input->getArgument('path');
     }
     // ####################
     // Find and loop through TYPO3 instances
     // ####################
     foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) {
         // Check if coreapi is installed
         if (!is_dir($dirPath . '/typo3conf/ext/coreapi/')) {
             $output->writeln('<p>EXT:coreapi is missing on ' . $dirPath . ', skipping</p>');
             continue;
         }
         $params = array($dirPath . '/typo3/cli_dispatch.phpsh', 'coreapi', 'cache:clearallcaches');
         $output->writeln('<p>Running clearcache command on ' . $dirPath . '</p>');
         try {
             $command = new CommandBuilder('php');
             $command->setArgumentList($params)->executeInteractive();
         } catch (\Exception $e) {
             $output->writeln('<p-error> Failed with exception: ' . $e->getMessage() . '</p-error>');
         }
     }
     return 0;
 }
コード例 #2
0
ファイル: InstallerCommand.php プロジェクト: jousch/clitools
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // ####################
     // Init
     // ####################
     $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/');
     $maxDepth = 3;
     $enableInstaller = true;
     $basePath = Typo3Utility::guessBestTypo3BasePath($basePath, $input, 'path');
     if ($input->getOption('remove')) {
         $enableInstaller = false;
     }
     // ####################
     // Find and loop through TYPO3 instances
     // ####################
     foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) {
         $installFilePath = $dirPath . '/typo3conf/ENABLE_INSTALL_TOOL';
         if ($enableInstaller) {
             // ####################
             // Enable installer
             // ####################
             // Check if install tool file is already there
             if (is_file($installFilePath)) {
                 // Already existing, just update timestamp
                 touch($installFilePath);
                 $output->writeln('<comment>Already enabled on ' . $dirPath . '</comment>');
             } else {
                 // Not existing, create file
                 touch($installFilePath);
                 $output->writeln('<info>Enabled on ' . $dirPath . '</info>');
             }
         } else {
             // ####################
             // Disable installer
             // ####################
             // Check if install tool file is already there
             if (is_file($installFilePath)) {
                 // Remove installer file
                 unlink($installFilePath);
                 $output->writeln('<info>Disabled on ' . $dirPath . '</info>');
             } else {
                 $output->writeln('<comment>Not enabled on ' . $dirPath . '</comment>');
             }
         }
     }
     return 0;
 }
コード例 #3
0
ファイル: ListCommand.php プロジェクト: jousch/clitools
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // ####################
     // Init
     // ####################
     $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/');
     $maxDepth = 3;
     $basePath = Typo3Utility::guessBestTypo3BasePath($basePath, $input, 'path');
     $versionFileList = array('/typo3/sysext/core/Classes/Core/SystemEnvironmentBuilder.php' => '/define\\(\'TYPO3_version\',[\\s]*\'([^\']+)\'\\)/i', '/t3lib/config_default.php' => '/\\$TYPO_VERSION[\\s]*=[\\s]*\'([^\']+)\'/i');
     // ####################
     // Find and loop through TYPO3 instances
     // ####################
     $typo3List = array();
     foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) {
         $typo3Version = null;
         $typo3Path = $dirPath;
         // Detect version (dirty way...)
         foreach ($versionFileList as $versionFile => $versionRegExp) {
             $versionFile = $dirPath . $versionFile;
             if (file_exists($versionFile)) {
                 $tmp = file_get_contents($versionFile);
                 if (preg_match($versionRegExp, $tmp, $matches)) {
                     $typo3Version = $matches[1];
                     break;
                 }
             }
         }
         if (strpos($typo3Version, '6') === 0) {
             // TYPO3 6.x
             $typo3Version = '<info>' . $typo3Version . '</info>';
         } elseif (!empty($typo3Version)) {
             // TYPO3 4.x
             $typo3Version = '<comment>' . $typo3Version . '</comment>';
         } else {
             // Unknown
             $typo3Version = '<error>unknown</error>';
         }
         $typo3List[] = array($typo3Path, $typo3Version);
     }
     $table = new Table($output);
     $table->setHeaders(array('Path', 'Version'));
     foreach ($typo3List as $row) {
         $table->addRow(array_values($row));
     }
     $table->render();
     return 0;
 }
コード例 #4
0
ファイル: SchedulerCommand.php プロジェクト: jousch/clitools
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     // ####################
     // Init
     // ####################
     $basePath = $this->getApplication()->getConfigValue('config', 'www_base_path', '/var/www/');
     $maxDepth = 3;
     $basePath = Typo3Utility::guessBestTypo3BasePath($basePath, $input, 'path');
     // ####################
     // Find and loop through TYPO3 instances
     // ####################
     foreach (Typo3Utility::getTypo3InstancePathList($basePath, $maxDepth) as $dirPath) {
         $output->writeln('<info>Running TYPO3 scheduler on ' . $dirPath . '</info>');
         try {
             $command = new CommandBuilder('php');
             $command->addArgument('/typo3/cli_dispatch.phpsh')->addArgument('scheduler')->executeInteractive();
         } catch (\Exception $e) {
             $output->writeln('<error>Failed TYPO3 scheduler on ' . $dirPath . '</error>');
         }
     }
     return 0;
 }