コード例 #1
0
ファイル: HelpCommand.php プロジェクト: miracle84/johnny5
 public function execute()
 {
     /** @var AbstractCommand[] $commandList */
     $commandList = ServiceContainer::getInstance()->getListByTag('command');
     echo 'Command list: ' . PHP_EOL;
     echo '====================' . PHP_EOL;
     foreach ($commandList as $command) {
         echo PHP_EOL . ' ' . $command->getName() . ' - ' . $command->getDescription() . PHP_EOL;
         $optionList = $command->getOptionList();
         if ($optionList) {
             echo '  ' . 'Options list: ' . PHP_EOL;
             foreach ($optionList as $option) {
                 $req = ConsoleOption::REQUIRED === $option->getMode() ? ' (req) ' : '';
                 echo '    ' . '-' . $option->getName() . $req . ' --- ' . $option->getDescription() . PHP_EOL;
             }
         }
         $argumentList = $command->getArgumentList();
         if ($argumentList) {
             echo '  ' . 'Arguments list: ' . PHP_EOL;
             foreach ($argumentList as $argument) {
                 $req = ConsoleOption::REQUIRED === $argument->getMode() ? ' (req) ' : '';
                 echo '    ' . '-' . $argument->getName() . $req . ' --- ' . $argument->getDescription() . PHP_EOL;
             }
         }
     }
 }
コード例 #2
0
ファイル: ScheduleCommand.php プロジェクト: miracle84/johnny5
 public function execute()
 {
     /** @var $urlProvider UrlProviderInterface */
     $urlProvider = ServiceContainer::getInstance()->get('provider.url_from_file');
     $urlProvider->init($this->getArgumentValue('fileName'));
     /** @var $botService BotService */
     $botService = ServiceContainer::getInstance()->get('service.bot');
     /** @var UrlProcessing[] $urlProcessingList */
     $urlProcessingList = $botService->scheduler($urlProvider);
     /** @var ConsoleViewService $consoleViewService */
     $consoleViewService = ServiceContainer::getInstance()->get('service.console_view');
     $consoleViewService->showUrlProcessingReport($urlProcessingList);
 }
コード例 #3
0
ファイル: DownloadCommand.php プロジェクト: miracle84/johnny5
 public function execute()
 {
     /** @var BotService $botService */
     $botService = ServiceContainer::getInstance()->get('service.bot');
     $limit = (int) $this->getOptionValue('limit');
     $rewrite = $this->hasOptionValue('force');
     /** @var DownloadService $downloadService */
     $downloadService = ServiceContainer::getInstance()->get('service.download');
     /** @var UrlProcessing[] $urlProcessingList */
     $urlProcessingList = $botService->download($downloadService, $rewrite, $limit);
     /** @var ConsoleViewService $consoleViewService */
     $consoleViewService = ServiceContainer::getInstance()->get('service.console_view');
     $consoleViewService->showUrlProcessingReport($urlProcessingList);
 }
コード例 #4
0
ファイル: CommandManager.php プロジェクト: miracle84/johnny5
 /**
  * @param $consoleArgDataList
  * @throws Exception
  */
 protected function initConsoleCommand($consoleArgDataList)
 {
     if (empty($consoleArgDataList[1])) {
         throw new Exception('Command name is empty');
     }
     /** @var AbstractCommand[] $commandList */
     $commandList = ServiceContainer::getInstance()->getListByTag('command');
     if (!$commandList) {
         throw new Exception('Empty command list');
     }
     $commandName = $consoleArgDataList[1];
     $command = array_filter($commandList, function ($commandInfo) use($commandName) {
         /** @var AbstractCommand $commandInfo */
         return $commandInfo->getName() === $commandName;
     });
     if (!$command) {
         throw new Exception('Command ' . $commandName . ' not found');
     }
     if (count($command) > 1) {
         throw new Exception('Found more than one command with name ' . $commandName);
     }
     $this->command = current($command);
 }
コード例 #5
0
ファイル: Init.php プロジェクト: miracle84/johnny5
<?php

namespace Johnny5;

use Johnny5\Kernel\ServiceContainer;
$serviceList = [];
$paramList = [];
require_once PROJECT_DIR . '/app/config/config.php';
require_once PROJECT_DIR . '/src/Johnny5/Kernel/Autoload.php';
require_once PROJECT_DIR . '/src/Johnny5/Kernel/ServiceContainer.php';
if (file_exists(PROJECT_DIR . '/vendor/autoload.php')) {
    include_once PROJECT_DIR . '/vendor/autoload.php';
}
ServiceContainer::init($serviceList, $paramList);