コード例 #1
0
ファイル: Console.php プロジェクト: mothership-ec/cog
 /**
  * Constructor. This is run before any modules are loaded, so we can
  * initialise the console here.
  *
  * @param ContainerInterface $container The service container
  * @param array|null 		 $arguments Arguments to pass into the Console component
  *
  * @todo Change the environment earlier if possible. Can we make the context
  * run something before even Cog is bootstrapped?
  */
 public function __construct(ContainerInterface $container, array $arguments = null)
 {
     $this->_services = $container;
     $this->_services['console.commands'] = function () {
         return new CommandCollection(array(new Command\EventList(), new Command\ModuleList(), new Command\RouteList(), new Command\RouteCollectionTree(), new Command\Setup(), new Command\Status(), new Command\TaskGenerate(), new Command\TaskList(), new Command\TaskRun(), new Command\TaskRunScheduled(), new Command\AssetDump(), new Command\AssetGenerator(), new Command\MigrateInstall(), new Command\MigrateRollback(), new Command\MigrateReset(), new Command\MigrateRefresh(), new Command\MigrateRun(), new Command\DeployEvent(), new Command\DeployPermissions(), new Command\ModuleNamespace(), new Command\CacheClear()));
     };
     $this->_services['console.app'] = function ($c) {
         $app = new Application();
         $app->setContainer($c);
         $app->getDefinition()->addOption(new InputOption('--' . $app::ENV_OPT_NAME, '', InputOption::VALUE_OPTIONAL, 'The Environment name.'));
         // Add the commands
         foreach ($c['console.commands'] as $command) {
             $app->add($command);
         }
         return $app;
     };
     if (null === $arguments) {
         $arguments = $_SERVER['argv'];
     }
     $input = new ArgvInput($arguments);
     if ($env = $input->getParameterOption(array('--env'), '')) {
         $this->_services['environment']->setWithInstallation($env);
     }
     // Setup a fake request context
     $this->_services['http.request.context'] = function ($c) {
         $context = new \Message\Cog\Routing\RequestContext();
         return $context;
     };
 }
コード例 #2
0
 /**
  * @param OutputInterface $output
  */
 public function loadCommands(OutputInterface $output)
 {
     // $application is required to be defined in the register_command scripts
     $application = $this->application;
     require_once \OC::$SERVERROOT . '/core/register_command.php';
     if ($this->config->getSystemValue('installed', false)) {
         if (!\OCP\Util::needUpgrade()) {
             OC_App::loadApps();
             foreach (OC_App::getAllApps() as $app) {
                 $file = OC_App::getAppPath($app) . '/appinfo/register_command.php';
                 if (file_exists($file)) {
                     require $file;
                 }
             }
         } else {
             $output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
         }
     } else {
         $output->writeln("ownCloud is not installed - only a limited number of commands are available");
     }
     $input = new ArgvInput();
     if ($input->getFirstArgument() !== 'check') {
         $errors = \OC_Util::checkServer(\OC::$server->getConfig());
         if (!empty($errors)) {
             foreach ($errors as $error) {
                 $output->writeln($error['error']);
                 $output->writeln($error['hint']);
                 $output->writeln('');
             }
             throw new \Exception("Environment not properly prepared.");
         }
     }
 }
コード例 #3
0
 /**
  * @see FixturesExportCommand::execute
  */
 public function testExecute_SpecificEntity_Association()
 {
     $directoryPath = sys_get_temp_dir();
     $dumper = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\Fixture\\Dumper')->disableOriginalConstructor()->setMethods(['dumpToYaml', 'setAssociation', 'setClassMetadataInfo'])->getMock();
     $dumper->expects($this->once())->method('dumpToYaml')->with($directoryPath)->will($this->returnValue($directoryPath . '/table.yml'));
     $dumper->expects($this->once())->method('setAssociation')->with(true)->will($this->returnValue(null));
     $classMetaDataInfo = $this->getMockBuilder('\\Doctrine\\ORM\\Mapping\\ClassMetadataInfo')->disableOriginalConstructor()->getMock();
     $dumper->expects($this->once())->method('setClassMetadataInfo')->with($classMetaDataInfo)->will($this->returnValue(null));
     $metaDataFactory = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory')->disableOriginalConstructor()->setMethods(['getMetadataFor'])->getMockForAbstractClass();
     $metaDataFactory->expects($this->once())->method('getMetadataFor')->with('BundleName:EntityName')->will($this->returnValue($classMetaDataInfo));
     $entityManager = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->setMethods(['getMetadataFactory'])->getMock();
     $entityManager->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metaDataFactory));
     $doctrine = $this->getMockBuilder('\\Doctrine\\Bundle\\DoctrineBundle\\Registry')->disableOriginalConstructor()->setMethods(['getManager'])->getMock();
     $doctrine->expects($this->once())->method('getManager')->will($this->returnValue($entityManager));
     $container = new Container();
     $container->set('doctrine', $doctrine);
     $container->set('cosma_testing.fixture_dumper', $dumper);
     $command = $this->getMockBuilder('\\Cosma\\Bundle\\TestingBundle\\Command\\FixturesExportCommand')->disableOriginalConstructor()->setMethods(['getContainer'])->getMock();
     $command->expects($this->exactly(2))->method('getContainer')->will($this->returnValue($container));
     $reflectionClass = new \ReflectionClass($command);
     $dumperProperty = $reflectionClass->getParentClass()->getProperty('dumper');
     $dumperProperty->setAccessible(true);
     $dumperProperty->setValue($command, $dumper);
     $inputDefinition = new InputDefinition([new InputArgument('dumpDirectory', InputArgument::REQUIRED), new InputArgument('entity', InputArgument::OPTIONAL), new InputOption('associations', 'a', InputOption::VALUE_NONE)]);
     $input = new ArgvInput(['dummySoInputValidates' => 'dummy', 'dumpDirectory' => $directoryPath, 'entity' => 'BundleName:EntityName'], $inputDefinition);
     $input->setOption('associations', true);
     $output = new BufferedOutput();
     $reflectionClass = new \ReflectionClass($command);
     $executeMethod = $reflectionClass->getMethod('execute');
     $executeMethod->setAccessible(true);
     $executeMethod->invoke($command, $input, $output);
     $this->assertContains("successfully dumped in file  {$directoryPath}/table.yml", $output->fetch(), 'The entity was not dump successfully');
 }
コード例 #4
0
ファイル: InitHelper.php プロジェクト: quickstrap/quickstrap
 public function initComposer(OutputInterface $output)
 {
     $input = new ArgvInput(['composer', 'init']);
     $input->setInteractive(true);
     /** @var InitCommand $command */
     $command = $this->getHelperSet()->getCommand()->getApplication()->find('init');
     return $this->execute($input, $output, $command);
 }
コード例 #5
0
    /**
     * `psysh` command line executable.
     *
     * @return Closure
     */
    function bin()
    {
        return function () {
            $usageException = null;
            $input = new ArgvInput();
            try {
                $input->bind(new InputDefinition(array(new InputOption('help', 'h', InputOption::VALUE_NONE), new InputOption('config', 'c', InputOption::VALUE_REQUIRED), new InputOption('version', 'v', InputOption::VALUE_NONE), new InputOption('cwd', null, InputOption::VALUE_REQUIRED), new InputArgument('include', InputArgument::IS_ARRAY))));
            } catch (\RuntimeException $e) {
                $usageException = $e;
            }
            $config = array();
            // Handle --config
            if ($configFile = $input->getOption('config')) {
                $config['configFile'] = $configFile;
            }
            $shell = new Shell(new Configuration($config));
            // Handle --help
            if ($usageException !== null || $input->getOption('help')) {
                if ($usageException !== null) {
                    echo $usageException->getMessage() . PHP_EOL . PHP_EOL;
                }
                $version = $shell->getVersion();
                $name = basename(reset($_SERVER['argv']));
                echo <<<EOL
{$version}

Usage:
  {$name} [--version] [--help] [files...]

Options:
  --help     -h Display this help message.
  --config   -c Use an alternate PsySH config file location.
  --cwd         Use an alternate working directory.
  --version  -v Display the PsySH version.

EOL;
                exit($usageException === null ? 0 : 1);
            }
            // Handle --version
            if ($input->getOption('version')) {
                echo $shell->getVersion() . PHP_EOL;
                exit(0);
            }
            // Pass additional arguments to Shell as 'includes'
            $shell->setIncludes($input->getArgument('include'));
            try {
                // And go!
                $shell->run();
            } catch (Exception $e) {
                echo $e->getMessage() . PHP_EOL;
                // TODO: this triggers the "exited unexpectedly" logic in the
                // ForkingLoop, so we can't exit(1) after starting the shell...
                // fix this :)
                // exit(1);
            }
        };
    }
コード例 #6
0
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $env = $input->getParameterOption(['-e', '--env']);
     if (!$env) {
         $env = 'dev';
     }
     $this->kernel($env);
 }
コード例 #7
0
 public function isSafe(ArgvInput $input, $env)
 {
     if ('prod' == $env) {
         if (in_array($input->getFirstArgument(), $this->productionBlackList)) {
             return false;
         }
     }
     return true;
 }
コード例 #8
0
 /**
  * We need to add the profile enable option to all commands if we are in
  * the parameter mode.
  *
  * Inspired by
  * http://php-and-symfony.matthiasnoback.nl/2013/11/symfony2-add-a-global-option-to-console-commands-and-generate-pid-file/
  *
  * @param ConsoleCommandEvent $event
  * @return mixed
  */
 private function isProfileOption(ConsoleCommandEvent $event)
 {
     $inputDefinition = $event->getCommand()->getApplication()->getDefinition();
     $inputDefinition->addOption(new InputOption($this->optionName, null, InputOption::VALUE_NONE, '<info>JnsXhprofBundle</info>: Whether to profile this command with xhprof', null));
     // merge the application's input definition
     $event->getCommand()->mergeApplicationDefinition();
     $input = new ArgvInput();
     // we use the input definition of the command
     $input->bind($event->getCommand()->getDefinition());
     return $input->getOption($this->optionName);
 }
コード例 #9
0
ファイル: ConfigFileTest.php プロジェクト: Slayug/castor
 /**
  * Do the locateFile Action
  *
  * @param $arg
  * @param $dir
  * @return string
  */
 protected function runLocateFile($arg, $dir)
 {
     chdir($this->baseDir . '/' . $dir);
     $definition = new InputDefinition(array(new InputOption('configuration')));
     $input = new ArgvInput(array(), $definition);
     if ($arg) {
         $input->setOption('configuration', $arg);
     }
     $command = new VoidCommand('void');
     return $command->locateConfigFile($input);
 }
コード例 #10
0
 /**
  * @param ConsoleOutput $output
  * @param ArgvInput     $input
  */
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $env = $input->getParameterOption(['-e', '--env']);
     if (!$env) {
         $env = 'dev';
     }
     $this->bootKernel($env);
     $schemaHelper = new SchemaHelper($this->container);
     $this->productTemplateTable = $schemaHelper->getTableOrCollection('product_template');
 }
コード例 #11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->write('loading all fixtures...........');
     $input = new ArgvInput();
     $input->setInteractive(false);
     $command = $this->getApplication()->find('doctrine:fixtures:load');
     $command->run($input, new NullOutput());
     $output->writeln('<info>OK</info>');
     $output->write('setting up match fixtures......');
     $this->getContainer()->get('oss.league.service.fixture')->createFixtures(1);
     $output->writeln('<info>OK</info>');
 }
コード例 #12
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $definition = $this->getDefinition();
     $arguments = $definition->getArguments();
     $arguments['target']->setDefault($this->container->getParameter('kernel.root_dir') . '/../web/');
     $definition->setArguments($arguments);
     if (count($input->getArguments()) === 0) {
         $input = new ArgvInput(null, $definition);
         $input->setArgument('target', $this->container->getParameter('kernel.root_dir') . '/../web/');
     }
     return parent::execute($input, $output);
 }
コード例 #13
0
 /**
  * Overrides the original method from phinx in order to return a tailored
  * Config object containing the connection details for the database.
  *
  * @return Phinx\Config\Config
  */
 public function getConfig()
 {
     if ($this->configuration) {
         return $this->configuration;
     }
     $dir = APP_DIR . DS . 'Resource' . DS . 'migrations';
     $migrationTable = 'phinxlog';
     if ($bundleName = $this->input->getOption('bundle')) {
         $dir = Bundles::getPath($bundleName) . DS . 'Resource' . DS . 'migrations';
     }
     return $this->configuration = new Config(['paths' => ['migrations' => $dir], 'environments' => ['default_migration_table' => $migrationTable, 'default_database' => getenv('RAD_ENVIRONMENT'), getenv('RAD_ENVIRONMENT') => \Rad\Configure\Config::get('migrations.environments.' . getenv('RAD_ENVIRONMENT'))]]);
 }
コード例 #14
0
ファイル: Kernel.php プロジェクト: morki/bounce-bundle
 public static function runCLI($environment = 'dev', $debug = true)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     $environment = $input->getParameterOption(array('--env', '-e'), $environment);
     $debug = !$input->hasParameterOption(array('--no-debug', '')) && $environment !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new static($environment, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
コード例 #15
0
ファイル: Run.php プロジェクト: michaldudek/flavour
 /**
  * Runs Symfony2 in console mode.
  *
  * @param string $kernelClass Class name for the kernel to be ran.
  */
 public static function console($kernelClass)
 {
     set_time_limit(0);
     $input = new ArgvInput();
     // decide env and debug info based on cli params
     $env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev');
     $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod';
     if ($debug) {
         Debug::enable();
     }
     $kernel = new $kernelClass($env, $debug);
     $application = new Application($kernel);
     $application->run($input);
 }
コード例 #16
0
 public function requirePackage(OutputInterface $output, $package, $version = null, $dev = true)
 {
     $packageArg = sprintf("%s%s", $package, $version != null ? ':' . $version : null);
     $args = ['composer', 'require'];
     if ($dev) {
         $args[] = '--dev';
     }
     $args[] = $packageArg;
     $input = new ArgvInput($args);
     $input->setInteractive(true);
     /** @var RequireCommand $command */
     $command = $this->getHelperSet()->getCommand()->getApplication()->find('require');
     return $this->execute($input, $output, $command);
 }
コード例 #17
0
 /**
  * @param string $arg
  *
  * @return string
  */
 protected function escapeArg($arg)
 {
     // Get a blank ArgvInput object so we can use the 'escapeToken' method.
     $argv = new ArgvInput();
     // If the string looks like an option=value pair, split them up.
     if ($arg[0] === '-' && strpos($arg, '=')) {
         list($option, $value) = explode('=', $arg, 2);
         return $option . '=' . $argv->escapeToken($value);
     }
     if (strpos($arg, '-') === 0) {
         return $arg;
     }
     return $argv->escapeToken($arg);
 }
コード例 #18
0
 /**
  * @param ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     /** @var Application $application */
     $application = $command->getApplication();
     $inputDefinition = $command->getDefinition();
     if ($command instanceof HelpCommand) {
         $input = new ArgvInput();
         $input->bind($inputDefinition);
         $command = $application->find($input->getFirstArgument());
     }
     if ($command instanceof BaseCommand) {
         $this->setInputDefinition($inputDefinition);
     }
 }
コード例 #19
0
 /**
  * @param ConsoleOutput $output
  * @param ArgvInput     $input
  */
 public function __construct(ConsoleOutput $output, ArgvInput $input)
 {
     $this->output = $output;
     $kernel = $this->bootKernel($input->getParameterOption(['-e', '--env'], 'dev'));
     $this->container = $kernel->getContainer();
     $this->ormConnection = $this->container->get('database_connection');
     $this->schemaHelper = new SchemaHelper($this->container);
     $this->upgradeHelper = new UpgradeHelper($this->container);
     $this->mediaDirectory = $input->getParameterOption(['--media-directory'], $this->container->getParameter('kernel.root_dir') . self::MEDIA_DIR);
     $this->productMediaTable = $input->getParameterOption(['--product-media-table'], self::MEDIA_TABLE);
     $this->productTemplateTable = $input->getParameterOption(['--product-template-table'], self::TEMPLATE_TABLE);
     if (!is_dir($this->mediaDirectory)) {
         throw new \RuntimeException(sprintf('The media directory "%s" does not exist', $this->mediaDirectory));
     }
 }
コード例 #20
0
 public function testParameters()
 {
     $cw = $this->buildCommandWrapper();
     $originaDefinition = clone $cw->getDefinition();
     $appIndexDefinition = $this->buildInputDefinition();
     $this->mergeInputDefinitions($cw, $appIndexDefinition);
     $input = new ArgvInput(array('cmd', 'uno_value', 'name_value', '--go'));
     $input->bind($cw->getDefinition());
     $input = $cw->filterByOriginalDefinition($input, $appIndexDefinition);
     $input->validate();
     $this->assertEquals(count($originaDefinition->getArguments()), count($input->getArguments()));
     $this->assertEquals(1, count($input->getArguments()));
     $this->assertEquals(array('name' => 'name_value'), $input->getArguments());
     $this->assertEquals(array('go' => true), $input->getOptions());
 }
コード例 #21
0
ファイル: Module.php プロジェクト: im286er/ent
 /**
  *
  * @param Event $event
  */
 public function loadCli(EventInterface $event)
 {
     $commands = array(new \Doctrine\ODM\MongoDB\Tools\Console\Command\QueryCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateDocumentsCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\GenerateHydratorsCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\CreateCommand(), new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand());
     foreach ($commands as $command) {
         $command->getDefinition()->addOption(new InputOption('documentmanager', null, InputOption::VALUE_OPTIONAL, 'The name of the documentmanager to use. If none is provided, it will use odm_default.'));
     }
     $cli = $event->getTarget();
     $cli->addCommands($commands);
     $arguments = new ArgvInput();
     $documentManagerName = $arguments->getParameterOption('--documentmanager');
     $documentManagerName = !empty($documentManagerName) ? $documentManagerName : 'odm_default';
     $documentManager = $event->getParam('ServiceManager')->get('doctrine.documentmanager.' . $documentManagerName);
     $documentHelper = new \Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper($documentManager);
     $cli->getHelperSet()->set($documentHelper, 'dm');
 }
コード例 #22
0
ファイル: ArgvInput.php プロジェクト: mattketmo/yamldiff
 public function __construct()
 {
     $argv = $_SERVER['argv'];
     // auto insert a blank command name
     array_splice($argv, 1, 0, '');
     parent::__construct($argv);
 }
コード例 #23
0
 /**
  * @return string[]
  * @author Maximilian Ruta <*****@*****.**>
  */
 public function getBundles()
 {
     require_once $this->console->getAppDir() . '/AppKernel.php';
     $input = new ArgvInput();
     $env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
     $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
     $kernel = new \AppKernel($env, $debug);
     $bundles = $kernel->registerBundles();
     $bundleMap = [];
     foreach ($bundles as $bundle) {
         $reflector = new \ReflectionClass($bundle);
         $bundlePath = dirname($reflector->getFileName());
         $bundleMap[$bundle->getName()] = $bundlePath;
     }
     return $bundleMap;
 }
コード例 #24
0
ファイル: Application.php プロジェクト: erpk/erbot
 public function onCommand(ConsoleCommandEvent $event)
 {
     $output = $event->getOutput();
     $input = new ArgvInput();
     try {
         $input->bind($this->getDefinition());
     } catch (\RuntimeException $e) {
     }
     $delay = filter_var($input->getOption('delay'), FILTER_VALIDATE_INT);
     if ($delay > 0) {
         $wakeupAt = time() + mt_rand(1, $delay);
         $output->writeln('<comment>Waiting until ' . date('Y-m-d H:i:s', $wakeupAt) . ' eRepublik time.</comment>');
         time_sleep_until($wakeupAt);
     }
     $this->configPath = $input->getOption('config');
     $this->loadConfig();
 }
コード例 #25
0
ファイル: BootstrapHelper.php プロジェクト: kdyby/console
 /**
  * @param Nette\Configurator $configurator
  * @return bool has the debug mode been modified?
  */
 public static function setupMode(Nette\Configurator $configurator)
 {
     if (PHP_SAPI !== 'cli') {
         return FALSE;
     }
     $input = new ArgvInput();
     if (!$input->hasParameterOption('--debug-mode')) {
         return FALSE;
     }
     if ($input->hasParameterOption(['--debug-mode=no', '--debug-mode=off', '--debug-mode=false', '--debug-mode=0'])) {
         $configurator->setDebugMode(FALSE);
         return TRUE;
     } else {
         $configurator->setDebugMode(TRUE);
         return TRUE;
     }
 }
コード例 #26
0
 /**
  * Detect if a custom environment file matching the APP_ENV exists.
  *
  * @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $app
  *
  * @return void
  */
 protected function checkForSpecificEnvironmentFile($app)
 {
     if (php_sapi_name() == 'cli') {
         $input = new ArgvInput();
         if ($input->hasParameterOption('--env')) {
             $file = $app->environmentFile() . '.' . $input->getParameterOption('--env');
             $this->loadEnvironmentFile($app, $file);
         }
     }
     if (!env('APP_ENV')) {
         return;
     }
     if (empty($file)) {
         $file = $app->environmentFile() . '.' . env('APP_ENV');
         $this->loadEnvironmentFile($app, $file);
     }
 }
コード例 #27
0
ファイル: RawArgvInput.php プロジェクト: iamluc/buse
 public function __construct(array $argv = null)
 {
     if (null === $argv) {
         $argv = $_SERVER['argv'];
     }
     $argv = $this->extractRawArgs($argv);
     parent::__construct($argv);
 }
コード例 #28
0
ファイル: ArgvInput.php プロジェクト: rosstuck/Pok
 /**
  * Constructor.
  *
  * @param array $argv An array of parameters from the CLI (in the argv format)
  */
 public function __construct(array $argv = null)
 {
     parent::__construct($argv, null);
     // Strip the first argument if it is a directory because it will then be the pyrus directory
     if (isset($this->tokens[0]) && @is_dir($this->tokens[0])) {
         $this->registryPath = $this->tokens[0];
         array_shift($this->tokens);
     }
 }
コード例 #29
0
 /**
  * @inheritdoc
  */
 public static function run($request, $response, $args)
 {
     global $argv;
     $container = static::getApp()->getContainer();
     $pathResolver = $container['pathResolver'];
     $filesystem = new Filesystem();
     $creator = new MigrationCreator($filesystem);
     $definition = new InputDefinition();
     $definition->addArgument(new InputArgument('name', InputArgument::REQUIRED));
     $definition->addOption(new InputOption('table', 't', InputOption::VALUE_OPTIONAL));
     $input = new ArgvInput(array_slice($argv, 1), $definition);
     $output = new ConsoleOutput();
     $path = $pathResolver->getAlias('@db/migrations');
     $name = $input->getArgument('name');
     $table = $input->getOption('table');
     $file = pathinfo($creator->create($name, $path, $table), PATHINFO_FILENAME);
     \dump($file);
 }
コード例 #30
0
 /**
  * Determine whether a CLI command is for compilation, and if so, clear the directory
  *
  * @throws \Magento\Framework\Exception\FileSystemException
  * @return void
  */
 public function handleCompilerEnvironment()
 {
     $compilationCommands = [DiCompileCommand::NAME, DiCompileMultiTenantCommand::NAME];
     $cmdName = $this->input->getFirstArgument();
     $isHelpOption = $this->input->hasParameterOption('--help') || $this->input->hasParameterOption('-h');
     if (!in_array($cmdName, $compilationCommands) || $isHelpOption) {
         return;
     }
     $generationDir = $cmdName === DiCompileMultiTenantCommand::NAME ? $this->input->getParameterOption(DiCompileMultiTenantCommand::INPUT_KEY_GENERATION) : null;
     if (!$generationDir) {
         $mageInitParams = $this->serviceManager->get(InitParamListener::BOOTSTRAP_PARAM);
         $mageDirs = isset($mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS]) ? $mageInitParams[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] : [];
         $generationDir = (new DirectoryList(BP, $mageDirs))->getPath(DirectoryList::GENERATION);
     }
     if ($this->filesystemDriver->isExists($generationDir)) {
         $this->filesystemDriver->deleteDirectory($generationDir);
     }
 }