InputInterface PHP Class Code Examples

This page contains top rated real world PHP examples of class InputInterface extracted from open source projects. You can rate examples to help us improve the quality of examples

Example #1
Show file File: Install.php Project: luisbrito/Phraseanet
0
 /**
  * {@inheritdoc}
  */
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $output->writeln("<comment>\n                                                      ,-._.-._.-._.-._.-.\n                                                      `-.             ,-'\n .----------------------------------------------.       |             |\n|                                                |      |             |\n|  Hello !                                       |      |             |\n|                                                |      |             |\n|  You are on your way to install Phraseanet,    |     ,';\".________.-.\n|  You will need access to 2 MySQL databases.    |     ;';_'         )]\n|                                                |    ;             `-|\n|                                                `.    `T-            |\n `----------------------------------------------._ \\    |             |\n                                                  `-;   |             |\n                                                        |..________..-|\n                                                       /\\/ |________..|\n                                                  ,'`./  >,(           |\n                                                  \\_.-|_/,-/   ii  |   |\n                                                   `.\"' `-/  .-\"\"\"||    |\n                                                    /`^\"-;   |    ||____|\n                                                   /     /   `.__/  | ||\n                                                        /           | ||\n                                                                    | ||\n</comment>");
     if (!$input->getOption('yes') && !$input->getOption('appbox')) {
         $continue = $dialog->askConfirmation($output, 'Do you have these two DB handy ? (N/y)', false);
         if (!$continue) {
             $output->writeln("See you later !");
             return 0;
         }
     }
     $abConn = $this->getABConn($input, $output, $dialog);
     list($dbConn, $template) = $this->getDBConn($input, $output, $abConn, $dialog);
     list($email, $password) = $this->getCredentials($input, $output, $dialog);
     $dataPath = $this->getDataPath($input, $output, $dialog);
     $serverName = $this->getServerName($input, $output, $dialog);
     if (!$input->getOption('yes')) {
         $continue = $dialog->askConfirmation($output, "<question>Phraseanet is going to be installed, continue ? (N/y)</question>", false);
         if (!$continue) {
             $output->writeln("See you later !");
             return 0;
         }
     }
     $this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $template, $this->detectBinaries());
     if (null !== $this->getApplication()) {
         $command = $this->getApplication()->find('crossdomain:generate');
         $command->run(new ArrayInput(array('command' => 'crossdomain:generate')), $output);
     }
     $output->writeln("<info>Install successful !</info>");
     return;
 }
Example #2
Show file File: Application.php Project: ProgrammingPeter/nba-schedule-api
0
 /**
  * Runs the current command.
  *
  * If an event dispatcher has been attached to the application,
  * events are also dispatched during the life-cycle of the command.
  *
  * @param Command         $command A Command instance
  * @param InputInterface  $input   An Input instance
  * @param OutputInterface $output  An Output instance
  *
  * @return int 0 if everything went fine, or an error code
  *
  * @throws \Exception when the command being run threw an exception
  */
 protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
 {
     foreach ($command->getHelperSet() as $helper) {
         if ($helper instanceof InputAwareInterface) {
             $helper->setInput($input);
         }
     }
     if (null === $this->dispatcher) {
         return $command->run($input, $output);
     }
     $event = new ConsoleCommandEvent($command, $input, $output);
     $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
     if ($event->commandShouldRun()) {
         try {
             $exitCode = $command->run($input, $output);
         } catch (\Exception $e) {
             $event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
             $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
             $event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
             $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
             throw $event->getException();
         }
     } else {
         $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
     }
     $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
     $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
     return $event->getExitCode();
 }
Example #3
Show file File: Application.php Project: astronautyan/O2OMobile_PHP
0
 /**
  * Runs the current command.
  *
  * If an event dispatcher has been attached to the application,
  * events are also dispatched during the life-cycle of the command.
  *
  * @param Command         $command A Command instance
  * @param InputInterface  $input   An Input instance
  * @param OutputInterface $output  An Output instance
  *
  * @return int 0 if everything went fine, or an error code
  */
 protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
 {
     foreach ($command->getHelperSet() as $helper) {
         if ($helper instanceof InputAwareInterface) {
             $helper->setInput($input);
         }
     }
     if (null === $this->dispatcher) {
         return $command->run($input, $output);
     }
     $event = new ConsoleCommandEvent($command, $input, $output);
     $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
     try {
         $exitCode = $command->run($input, $output);
     } catch (\Exception $e) {
         $event = new ConsoleTerminateEvent($command, $input, $output, $e->getCode());
         $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
         $event = new ConsoleExceptionEvent($command, $input, $output, $e, $event->getExitCode());
         $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
         throw $event->getException();
     }
     $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
     $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
     return $event->getExitCode();
 }
Example #4
Show file File: CreateCommand.php Project: brentwpeterson/n98-magerun2
0
 /**
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int|void
  * @throws \InvalidArgumentException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $subCommandFactory = $this->createSubCommandFactory($input, $output, 'N98\\Magento\\Command\\Developer\\Module\\Create\\SubCommand');
     $configBag = $subCommandFactory->getConfig();
     if (!$input->getOption('modman')) {
         $this->detectMagento($output);
     }
     $configBag->setBool('isModmanMode', $input->getOption('modman'));
     $configBag->setString('magentoRootFolder', $this->_magentoRootFolder);
     $this->initConfigBagDefaultValues($configBag);
     if ($input->getOption('add-all')) {
         $configBag->setBool('shouldAddBlocks', true);
         $configBag->setBool('shouldAddHelpers', true);
         $configBag->setBool('shouldAddModels', true);
         $configBag->setBool('shouldAddSetup', true);
     }
     if ($input->getOption('add-blocks')) {
         $configBag->setBool('shouldAddBlocks', true);
     }
     if ($input->getOption('add-helpers')) {
         $configBag->setBool('shouldAddHelpers', true);
     }
     if ($input->getOption('add-models')) {
         $configBag->setBool('shouldAddModels', true);
     }
     if ($input->getOption('add-setup')) {
         $configBag->setBool('shouldAddSetup', true);
     }
     if ($input->getOption('enable')) {
         $configBag->setBool('shouldEnableModule', true);
     }
     $configBag->setString('baseFolder', __DIR__ . '/../../../../../../res/module/create');
     $configBag->setString('vendorNamespace', ucfirst($input->getArgument('vendorNamespace')));
     $configBag->setString('moduleName', ucfirst($input->getArgument('moduleName')));
     $this->initView($input, $configBag);
     $subCommandFactory->create('CreateModuleFolders')->execute();
     $subCommandFactory->create('CreateModuleRegistrationFiles')->execute();
     if (!$input->getOption('minimal')) {
         $subCommandFactory->create('CreateModuleConfigFile')->execute();
         $subCommandFactory->create('CreateModuleDiFile')->execute();
         $subCommandFactory->create('CreateModuleEventsFile')->execute();
         $subCommandFactory->create('CreateModuleCrontabFile')->execute();
     }
     $subCommandFactory->create('EnableModule')->execute();
     if ($input->getOption('add-readme')) {
         $subCommandFactory->create('CreateReadmeFile')->execute();
     }
     if ($input->getOption('modman')) {
         $subCommandFactory->create('CreateModmanFile')->execute();
     }
     if ($input->getOption('add-composer')) {
         $subCommandFactory->create('CreateComposerFile')->execute();
     }
     if ($input->getOption('add-setup')) {
         $subCommandFactory->create('CreateSetupFiles')->execute();
     }
     if (!$input->getOption('minimal')) {
         $subCommandFactory->create('CreateAdditionalFiles')->execute();
     }
 }
Example #5
Show file File: CoreConfigureCommand.php Project: mistymagich/gush
0
 private function configureAdapter(InputInterface $input, OutputInterface $output, $adapterName, array $adapter)
 {
     /** @var \Gush\Application $application */
     $application = $this->getApplication();
     $isAuthenticated = false;
     $authenticationAttempts = 0;
     $config = [];
     /** @var StyleHelper $styleHelper */
     $styleHelper = $this->getHelper('gush_style');
     $configurator = $application->getAdapterFactory()->createConfigurator($adapterName, $application->getHelperSet());
     while (!$isAuthenticated) {
         // Prevent endless loop with a broken test
         if ($authenticationAttempts > 50) {
             throw new \RuntimeException('Too many attempts, aborting.');
         }
         if ($authenticationAttempts > 0) {
             $styleHelper->error('Authentication failed please try again.');
         }
         try {
             $config = $configurator->interact($input, $output);
             $isAuthenticated = $this->isCredentialsValid($adapterName, $adapter, $config);
         } catch (\Exception $e) {
             $styleHelper->error($e->getMessage());
         }
         ++$authenticationAttempts;
     }
     if ($isAuthenticated) {
         $rawConfig = $this->getConfig()->toArray(Config::CONFIG_SYSTEM);
         $rawConfig['adapters'][$adapterName] = $config;
         $styleHelper->success(sprintf('The "%s" adapter was successfully authenticated.', $adapter['label']));
         $this->getConfig()->merge($rawConfig, Config::CONFIG_SYSTEM);
     }
 }
Example #6
Show file File: CreateRoleCommand.php Project: Silwereth/sulu
0
 /**
  * @see Command
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $helper = $this->getHelper('question');
     $doctrine = $this->getContainer()->get('doctrine');
     $pool = $this->getContainer()->get('sulu_admin.admin_pool');
     $contexts = $pool->getSecurityContexts();
     $systems = array_keys($contexts);
     if (!$input->getArgument('name')) {
         $question = new Question('Please choose a rolename: ');
         $question->setValidator(function ($name) use($doctrine) {
             if (empty($name)) {
                 throw new \InvalidArgumentException('Rolename cannot be empty');
             }
             $roles = $this->getContainer()->get('sulu.repository.role')->findBy(['name' => $name]);
             if (count($roles) > 0) {
                 throw new \InvalidArgumentException(sprintf('Rolename "%s" is not unique', $name));
             }
             return $name;
         });
         $name = $helper->ask($input, $output, $question);
         $input->setArgument('name', $name);
     }
     if (!$input->getArgument('system')) {
         $question = new ChoiceQuestion('Please choose a system: ', $systems, 0);
         $system = $helper->ask($input, $output, $question);
         $input->setArgument('system', $system);
     }
 }
Example #7
Show file File: GlobalCommand.php Project: detain/composer
0
 public function run(InputInterface $input, OutputInterface $output)
 {
     // extract real command name
     $tokens = preg_split('{\\s+}', $input->__toString());
     $args = array();
     foreach ($tokens as $token) {
         if ($token && $token[0] !== '-') {
             $args[] = $token;
             if (count($args) >= 2) {
                 break;
             }
         }
     }
     // show help for this command if no command was found
     if (count($args) < 2) {
         return parent::run($input, $output);
     }
     // change to global dir
     $config = Factory::createConfig();
     chdir($config->get('home'));
     $this->getIO()->writeError('<info>Changed current directory to ' . $config->get('home') . '</info>');
     // create new input without "global" command prefix
     $input = new StringInput(preg_replace('{\\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\\b}', '', $input->__toString(), 1));
     $this->getApplication()->resetComposer();
     return $this->getApplication()->run($input, $output);
 }
Example #8
Show file File: Procedure.php Project: greut/php-phantomjs
0
 /**
  * Run procedure.
  *
  * @access public
  * @param  \JonnyW\PhantomJs\Procedure\InputInterface           $input
  * @param  \JonnyW\PhantomJs\Procedure\OutputInterface          $output
  * @throws \JonnyW\PhantomJs\Exception\ProcedureFailedException
  * @throws \JonnyW\PhantomJs\Exception\NotWritableException
  * @return void
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         $executable = $this->write($this->compile($input));
         $descriptorspec = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
         $process = proc_open(escapeshellcmd(sprintf('%s %s', $this->engine->getCommand(), $executable)), $descriptorspec, $pipes, null, null);
         if (!is_resource($process)) {
             throw new ProcedureFailedException('proc_open() did not return a resource');
         }
         $result = stream_get_contents($pipes[1]);
         $log = stream_get_contents($pipes[2]);
         fclose($pipes[0]);
         fclose($pipes[1]);
         fclose($pipes[2]);
         proc_close($process);
         $output->import($this->parser->parse($result));
         $this->engine->log($log);
         $this->remove($executable);
     } catch (NotWritableException $e) {
         throw $e;
     } catch (\Exception $e) {
         if (isset($executable)) {
             $this->remove($executable);
         }
         throw new ProcedureFailedException(sprintf('Error when executing PhantomJs procedure - %s', $e->getMessage()));
     }
 }
Example #9
Show file File: Command.php Project: GeorgeBroadley/caffeine-vendor
0
 /**
  * Runs the command.
  *
  * The code to execute is either defined directly with the
  * setCode() method or by overriding the execute() method
  * in a sub-class.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  *
  * @throws \Exception
  *
  * @see setCode()
  * @see execute()
  *
  * @api
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // force the creation of the synopsis before the merge with the app definition
     $this->getSynopsis();
     // add the application arguments and options
     $this->mergeApplicationDefinition();
     // bind the input against the command specific arguments/options
     try {
         $input->bind($this->definition);
     } catch (\Exception $e) {
         if (!$this->ignoreValidationErrors) {
             throw $e;
         }
     }
     $this->initialize($input, $output);
     if (null !== $this->processTitle) {
         if (function_exists('cli_set_process_title')) {
             cli_set_process_title($this->processTitle);
         } elseif (function_exists('setproctitle')) {
             setproctitle($this->processTitle);
         } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
             $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
         }
     }
     if ($input->isInteractive()) {
         $this->interact($input, $output);
     }
     $input->validate();
     if ($this->code) {
         $statusCode = call_user_func($this->code, $input, $output);
     } else {
         $statusCode = $this->execute($input, $output);
     }
     return is_numeric($statusCode) ? (int) $statusCode : 0;
 }
Example #10
Show file File: tui.class.php Project: Poket-Jony/school-todo-app
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // $model = new ModelController2(new NotePrototype, new GroupPrototype, new JSONController());
     // $model = new ModelController2(new NotePrototype, new GroupPrototype, new MySQLController());
     // $model = new ModelController(new JSONController(), new DataHelper(), new Validator());
     $model = new ModelController(new MySQLController(), new DataHelper(), new Validator());
     $this->setInput($input);
     $this->setOutput($output);
     $this->setModel($model);
     $output->writeln('<info>Todo App</>');
     while (true) {
         switch ($this->showMainMenu()) {
             case $this->startMenuOptions[0]:
                 // all notes
                 switch ($this->showAllNotes()) {
                     case $this->noteMenuOptions[0]:
                         // add note
                         $this->createNote();
                         break;
                     case $this->noteMenuOptions[1]:
                         // edit note
                         $this->editNote();
                         break;
                     case $this->noteMenuOptions[2]:
                         // delete note
                         $this->deleteNote();
                         break;
                     case $this->noteMenuOptions[3]:
                         // back to menu
                         continue;
                         break;
                 }
                 break;
             case $this->startMenuOptions[1]:
                 // all groups
                 switch ($this->showAllGroups()) {
                     case $this->groupMenuOptions[0]:
                         // add group
                         $this->addGroup();
                         break;
                     case $this->groupMenuOptions[1]:
                         // edit group
                         $this->editGroup();
                         break;
                     case $this->groupMenuOptions[2]:
                         // delete group
                         $this->deleteGroup();
                         break;
                     case $this->groupMenuOptions[3]:
                         continue;
                         break;
                 }
                 break;
             case $this->startMenuOptions[2]:
             default:
                 $this->closeApplication();
                 break;
         }
     }
 }
Example #11
Show file File: MigrationsDiffDoctrineCommand.php Project: ccq18/EduSoho
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
     $configuration = $this->getMigrationConfiguration($input, $output);
     DoctrineCommand::configureMigrations($this->getApplication()->getKernel()->getContainer(), $configuration);
     parent::execute($input, $output);
 }
Example #12
Show file File: YamlLintCommand.php Project: brennantom/hackazon
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     if (!$filename) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
         }
         $content = '';
         while (!feof(STDIN)) {
             $content .= fread(STDIN, 1024);
         }
         return $this->display($input, $output, array($this->validate($content)));
     }
     if (0 !== strpos($filename, '@') && !is_readable($filename)) {
         throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
     }
     $files = array();
     if (is_file($filename)) {
         $files = array($filename);
     } elseif (is_dir($filename)) {
         $files = Finder::create()->files()->in($filename)->name('*.yml');
     } else {
         $dir = $this->getApplication()->getKernel()->locateResource($filename);
         $files = Finder::create()->files()->in($dir)->name('*.yml');
     }
     $filesInfo = array();
     foreach ($files as $file) {
         $filesInfo[] = $this->validate(file_get_contents($file), $file);
     }
     return $this->display($input, $output, $filesInfo);
 }
Example #13
Show file File: InstallCommand.php Project: abdeldayem/pim-community-dev
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $forceInstall = $input->getOption('force');
     // if there is application is not installed or no --force option
     if ($this->getContainer()->hasParameter('installed') && $this->getContainer()->getParameter('installed') && !$forceInstall) {
         throw new \RuntimeException('Oro Application already installed.');
     } elseif ($forceInstall) {
         // if --force option we have to clear cache and set installed to false
         $this->updateInstalledFlag($input, $output, false);
     }
     $output->writeln(sprintf('<info>Installing %s Application.</info>', static::APP_NAME));
     $output->writeln('');
     try {
         foreach ($this->getDirectoriesContainer()->getDirectories() as $directory) {
             $this->cleanDirectory($directory);
         }
         $this->checkStep($input, $output)->databaseStep($input, $output)->assetsStep($input, $output);
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>Error during PIM installation. %s</error>', $e->getMessage()));
         $output->writeln('');
         return $e->getCode();
     }
     $this->updateInstalledFlag($input, $output, date('c'));
     $output->writeln('');
     $output->writeln(sprintf('<info>%s Application has been successfully installed.</info>', static::APP_NAME));
     return 0;
 }
Example #14
Show file File: Console.php Project: hitechdk/Codeception
0
 protected function executeCommands(InputInterface $input, OutputInterface $output, $I, $bootstrap)
 {
     $dialog = new QuestionHelper();
     if (file_exists($bootstrap)) {
         require $bootstrap;
     }
     do {
         $question = new Question("<comment>\$I-></comment>");
         $question->setAutocompleterValues($this->actions);
         $command = $dialog->ask($input, $output, $question);
         if ($command == 'actions') {
             $output->writeln("<info>" . implode(' ', $this->actions));
             continue;
         }
         if ($command == 'exit') {
             return;
         }
         if ($command == '') {
             continue;
         }
         try {
             $value = eval("return \$I->{$command};");
             if ($value && !is_object($value)) {
                 codecept_debug($value);
             }
         } catch (\PHPUnit_Framework_AssertionFailedError $fail) {
             $output->writeln("<error>fail</error> " . $fail->getMessage());
         } catch (\Exception $e) {
             $output->writeln("<error>error</error> " . $e->getMessage());
         }
     } while (true);
 }
Example #15
Show file File: GenerateCommand.php Project: xtx-dev/mongodb-migrations
0
 /**
  * @param Symfony\Component\Console\Input\InputInterface
  * @param Symfony\Component\Console\Output\OutputInterface
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = $this->getMigrationConfiguration($input, $output);
     $version = $this->getVersionString();
     $path = $this->generateMigration($configuration, $input, $version);
     $output->writeln(sprintf('Generated new migration class to "<info>%s</info>"', $path));
 }
Example #16
Show file File: Rollback.php Project: Slayug/castor
0
 /**
  * Rollback the migration.
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->bootstrap($input, $output);
     $environment = $input->getOption('environment');
     $version = $input->getOption('target');
     $date = $input->getOption('date');
     if (null === $environment) {
         $environment = $this->getConfig()->getDefaultEnvironment();
         $output->writeln('<comment>warning</comment> no environment specified, defaulting to: ' . $environment);
     } else {
         $output->writeln('<info>using environment</info> ' . $environment);
     }
     $envOptions = $this->getConfig()->getEnvironment($environment);
     if (isset($envOptions['adapter'])) {
         $output->writeln('<info>using adapter</info> ' . $envOptions['adapter']);
     }
     if (isset($envOptions['wrapper'])) {
         $output->writeln('<info>using wrapper</info> ' . $envOptions['wrapper']);
     }
     if (isset($envOptions['name'])) {
         $output->writeln('<info>using database</info> ' . $envOptions['name']);
     }
     // rollback the specified environment
     $start = microtime(true);
     if (null !== $date) {
         $this->getManager()->rollbackToDateTime($environment, new \DateTime($date));
     } else {
         $this->getManager()->rollback($environment, $version);
     }
     $end = microtime(true);
     $output->writeln('');
     $output->writeln('<comment>All Done. Took ' . sprintf('%.4fs', $end - $start) . '</comment>');
 }
Example #17
Show file File: DbvInstallCommand.php Project: zitec/CodePaxCLI
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configuration = CodePax_Config::getInstance(CONFIG_PATH . 'config.ini');
     try {
         $sql_engine = CodePax_DbVersioning_SqlEngines_Factory::factory($configuration);
         $dir = ABS_PATH . 'app' . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR;
         switch (strtolower($configuration->db_engine)) {
             case 'mysql':
                 $sql_file_name = 'db_versions_mysql.sql';
                 break;
             case 'pgsql':
                 $sql_file_name = 'db_versions_pgsql.sql';
                 break;
             case 'sqlsrv':
                 $sql_file_name = 'db_versions_sqlsrv.sql';
                 break;
         }
         $sql_engine->executeChangeScript($dir . $sql_file_name);
     } catch (CodePax_DbVersioning_Exception $e) {
         $output->writeln('An error ocurred: ' . $e->getMessage());
         exit;
     } catch (Exception $e) {
         $output->writeln('Generic error: ' . $e->getMessage());
         exit;
     }
     $output->writeln('CodePax successfully installed!');
 }
Example #18
Show file File: systemBackupDB.php Project: luisbrito/Phraseanet
0
 protected function dump_base(base $base, InputInterface $input, OutputInterface $output)
 {
     $date_obj = new DateTime();
     $filename = sprintf('%s%s_%s.sql', p4string::addEndSlash($input->getArgument('directory')), $base->get_dbname(), $date_obj->format('Y_m_d_H_i_s'));
     $command = sprintf('mysqldump %s %s %s %s %s %s --default-character-set=utf8', '--host=' . escapeshellarg($base->get_host()), '--port=' . escapeshellarg($base->get_port()), '--user=' . escapeshellarg($base->get_user()), '--password=' . escapeshellarg($base->get_passwd()), '--databases', escapeshellarg($base->get_dbname()));
     if ($input->getOption('gzip')) {
         $filename .= '.gz';
         $command .= ' | gzip -9';
     } elseif ($input->getOption('bzip')) {
         $filename .= '.bz2';
         $command .= ' | bzip2 -9';
     }
     $output->write(sprintf('Generating <info>%s</info> ... ', $filename));
     $command .= ' > ' . escapeshellarg($filename);
     $process = new Process($command);
     $process->setTimeout((int) $input->getOption('timeout'));
     $process->run();
     if (!$process->isSuccessful()) {
         $output->writeln('<error>Failed</error>');
         return 1;
     }
     if (file_exists($filename) && filesize($filename) > 0) {
         $output->writeln('OK');
         return 0;
     } else {
         $output->writeln('<error>Failed</error>');
         return 1;
     }
 }
Example #19
Show file File: BaseCommand.php Project: neon64/composer
0
 /**
  * {@inheritDoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
         $input->setOption('no-progress', true);
     }
     parent::initialize($input, $output);
 }
Example #20
Show file File: DiCompileMultiTenantCommand.php Project: kidaa30/magento2-platformsh
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $errors = $this->validate($input);
     if ($errors) {
         $output->writeln($errors);
         return;
     }
     $generationDir = $input->getOption(self::INPUT_KEY_GENERATION) ? $input->getOption(self::INPUT_KEY_GENERATION) : $this->directoryList->getPath(DirectoryList::GENERATION);
     $modulesExcludePatterns = $this->getModuleExcludePatterns();
     $testExcludePatterns = ["#^" . $this->directoryList->getPath(DirectoryList::SETUP) . "/[\\w]+/[\\w]+/Test#", "#^" . $this->directoryList->getRoot() . "/dev/tools/Magento/Tools/[\\w]+/Test#"];
     $librariesExcludePatterns = $this->getLibraryExcludePatterns();
     $testExcludePatterns = array_merge($testExcludePatterns, $modulesExcludePatterns, $librariesExcludePatterns);
     $fileExcludePatterns = $input->getOption('exclude-pattern') ? [$input->getOption(self::INPUT_KEY_EXCLUDE_PATTERN)] : ['#[\\\\/]M1[\\\\/]#i'];
     $fileExcludePatterns = array_merge($fileExcludePatterns, $testExcludePatterns);
     /** @var Writer\Console logWriter Writer model for success messages */
     $logWriter = new Writer\Console($output);
     $this->log = new Log($logWriter, $logWriter);
     AutoloaderRegistry::getAutoloader()->addPsr4('Magento\\', $generationDir . '/Magento/');
     // 1 Code generation
     $this->generateCode($generationDir, $fileExcludePatterns, $input);
     // 2. Compilation
     $this->compileCode($generationDir, $fileExcludePatterns, $input);
     //Reporter
     $this->log->report();
     if (!$this->log->hasError()) {
         $output->writeln('<info>On *nix systems, verify the Magento application has permissions to modify files ' . 'created by the compiler in the "var" directory. For instance, if you run the Magento application ' . 'using Apache, the owner of the files in the "var" directory should be the Apache user (example ' . 'command: "chown -R www-data:www-data <MAGENTO_ROOT>/var" where MAGENTO_ROOT is the Magento ' . 'root directory).</info>');
     }
 }
Example #21
Show file File: CiconiaCommand.php Project: bencalie/Ciconia
0
 /**
  * Runs help command
  *
  * @param InputInterface  $input  The InputInterface instance
  * @param OutputInterface $output The OutputInterface instance
  *
  * @return int
  */
 protected function runHelp(InputInterface $input, OutputInterface $output)
 {
     /* @var HelpCommand $help */
     $help = $this->getApplication()->find('help');
     $help->setCommand($this);
     $help->run($input, $output);
 }
Example #22
Show file File: ContainerDebugCommand.php Project: iurkidi/nmarcajunto
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     if ($input->getOption('parameters')) {
         $object = $this->getContainerBuilder()->getParameterBag();
         $options = array();
     } elseif ($parameter = $input->getOption('parameter')) {
         $object = $this->getContainerBuilder();
         $options = array('parameter' => $parameter);
     } elseif ($input->getOption('tags')) {
         $object = $this->getContainerBuilder();
         $options = array('group_by' => 'tags', 'show_private' => $input->getOption('show-private'));
     } elseif ($tag = $input->getOption('tag')) {
         $object = $this->getContainerBuilder();
         $options = array('tag' => $tag, 'show_private' => $input->getOption('show-private'));
     } elseif ($name = $input->getArgument('name')) {
         $object = $this->getContainerBuilder();
         $options = array('id' => $name);
     } else {
         $object = $this->getContainerBuilder();
         $options = array('show_private' => $input->getOption('show-private'));
     }
     $helper = new DescriptorHelper();
     $options['format'] = $input->getOption('format');
     $options['raw_text'] = $input->getOption('raw');
     $helper->describe($output, $object, $options);
 }
Example #23
Show file File: RunCommand.php Project: PedroTroller/CircleCI-Parallel-Builder
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     if (null === $input->getOption('index')) {
         $input->setOption('index', getenv('CIRCLE_NODE_INDEX') ?: 1);
     }
     $config = Yaml::parse(file_get_contents($input->getArgument('tests')));
     $suites = (new SuiteBuilder($config))->buildSuites($input->getOption('total'));
     $index = $input->getOption('index');
     if (false === array_key_exists($index, $suites)) {
         return;
     }
     $suite = $suites[$index];
     $output->writeln('');
     $output->writeln($this->getHelper('formater')->formatBlock([$suite->getName()], 'bg=green;fg=black', true));
     $output->writeln('');
     $helper = new SuiteHelper($output);
     foreach ($suite->getTests() as $test) {
         $output->writeln($this->getHelper('formater')->formatBlock([sprintf('Test : %s', $test)], 'info', true));
         $output->writeln('');
         $test->run(function ($e) use($test, $helper) {
             $helper->renderTestLine($test);
         });
         $output->writeln($test->getIncrementalOutput());
         if (false === $test->isSuccessful()) {
             $output->writeln($this->getHelper('formater')->formatBlock([sprintf('"%s" failed', $test)], 'error', true));
         } else {
             $output->writeln($this->getHelper('formater')->formatBlock([sprintf('"%s" succeed', $test)], 'bg=green;fg=black', true));
         }
         $output->writeln('');
     }
     $helper->renderErrors($suite);
     $output->writeln('');
     return $suite->isSuccessful() ? 0 : 1;
 }
Example #24
Show file File: AnalyzeCommand.php Project: original-brownbear/php-transpiler
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<info>PHP Transpiler</info>');
     $path = $this->getInputPath($input);
     $output->writeln('<info>Analyzing ' . $path . '</info>');
     $output->writeln('<info>' . (new SourceDirView($this->sourceDir($path)))->render() . '</info>');
 }
Example #25
Show file File: ConfigCommand.php Project: pradeep-wagento/magento2
0
 /**
  * {@inheritDoc}
  */
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     parent::initialize($input, $output);
     if ($input->getOption('global') && null !== $input->getOption('file')) {
         throw new \RuntimeException('--file and --global can not be combined');
     }
     $io = $this->getIO();
     $this->config = Factory::createConfig($io);
     // Get the local composer.json, global config.json, or if the user
     // passed in a file to use
     $configFile = $input->getOption('global') ? $this->config->get('home') . '/config.json' : ($input->getOption('file') ?: trim(getenv('COMPOSER')) ?: 'composer.json');
     // Create global composer.json if this was invoked using `composer global config`
     if ($configFile === 'composer.json' && !file_exists($configFile) && realpath(getcwd()) === realpath($this->config->get('home'))) {
         file_put_contents($configFile, "{\n}\n");
     }
     $this->configFile = new JsonFile($configFile, null, $io);
     $this->configSource = new JsonConfigSource($this->configFile);
     $authConfigFile = $input->getOption('global') ? $this->config->get('home') . '/auth.json' : dirname(realpath($configFile)) . '/auth.json';
     $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
     $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
     // Initialize the global file if it's not there, ignoring any warnings or notices
     if ($input->getOption('global') && !$this->configFile->exists()) {
         touch($this->configFile->getPath());
         $this->configFile->write(array('config' => new \ArrayObject()));
         Silencer::call('chmod', $this->configFile->getPath(), 0600);
     }
     if ($input->getOption('global') && !$this->authConfigFile->exists()) {
         touch($this->authConfigFile->getPath());
         $this->authConfigFile->write(array('http-basic' => new \ArrayObject(), 'github-oauth' => new \ArrayObject(), 'gitlab-oauth' => new \ArrayObject()));
         Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
     }
     if (!$this->configFile->exists()) {
         throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
     }
 }