Author: Kevin Bond (kevinbond@gmail.com)
Inheritance: extends Symfony\Component\Console\Style\OutputStyle
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Check Pre-commit requirements');
     $hasError = false;
     $resultOkVal = '<fg=green>✔</>';
     $resultNokVal = '<fg=red>✘</>';
     $commands = ['Composer' => array('command' => 'composer', 'result' => $resultOkVal), 'xmllint' => array('command' => 'xmllint', 'result' => $resultOkVal), 'jsonlint' => array('command' => 'jsonlint', 'result' => $resultOkVal), 'eslint' => array('command' => 'eslint', 'result' => $resultOkVal), 'sass-convert' => array('command' => 'sass-convert', 'result' => $resultOkVal), 'scss-lint' => array('command' => 'scss-lint', 'result' => $resultOkVal), 'phpcpd' => array('command' => 'phpcpd', 'result' => $resultOkVal), 'php-cs-fixer' => array('command' => 'php-cs-fixer', 'result' => $resultOkVal), 'phpmd' => array('command' => 'phpmd', 'result' => $resultOkVal), 'phpcs' => array('command' => 'phpcs', 'result' => $resultOkVal), 'box' => array('command' => 'box', 'result' => $resultOkVal)];
     foreach ($commands as $label => $command) {
         if (!$this->checkCommand($label, $command['command'])) {
             $commands[$label]['result'] = $resultNokVal;
             $hasError = true;
         }
     }
     // Check Php conf param phar.readonly
     if (!ini_get('phar.readonly')) {
         $commands['phar.readonly'] = array('result' => $resultOkVal);
     } else {
         $commands['phar.readonly'] = array('result' => 'not OK (set "phar.readonly = Off" on your php.ini)');
     }
     $headers = ['Command', 'check'];
     $rows = [];
     foreach ($commands as $label => $cmd) {
         $rows[] = [$label, $cmd['result']];
     }
     $io->table($headers, $rows);
     if (!$hasError) {
         $io->success('All Requirements are OK');
     } else {
         $io->note('Please fix all requirements');
     }
     exit(0);
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = str_replace('/', '\\', $input->getArgument('name'));
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->cache->purge();
     if (!in_array($name, $this->load_migrations())) {
         $io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
         return 1;
     } else {
         if ($this->migrator->migration_state($name) === false) {
             $io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
             return 1;
         }
     }
     try {
         while ($this->migrator->migration_state($name) !== false) {
             $this->migrator->revert($name);
         }
     } catch (\phpbb\db\migration\exception $e) {
         $io->error($e->getLocalisedMessage($this->user));
         $this->finalise_update();
         return 1;
     }
     $this->finalise_update();
     $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Warming up the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheWarmer->warmup($this->cacheDir);
     $io->success('Cache warmed up');
 }
 public function execute(SymfonyStyle $io = null)
 {
     $currentProfiles = $this->em->getRepository('CampaignChainLocationGoogleAnalyticsBundle:Profile')->findAll();
     if (empty($currentProfiles)) {
         $io->text('There is no Profile entity to update');
         return true;
     }
     foreach ($currentProfiles as $profile) {
         if (substr($profile->getProfileId(), 0, 2) != 'UA') {
             continue;
         }
         $profile->setPropertyId($profile->getProfileId());
         $gaProfileUrl = $profile->getLocation()->getUrl();
         $google_base_url = 'https:\\/\\/www.google.com\\/analytics\\/web\\/#report\\/visitors-overview\\/a' . $profile->getAccountId() . 'w\\d+p';
         $pattern = '/' . $google_base_url . '(.*)/';
         preg_match($pattern, $gaProfileUrl, $matches);
         if (!empty($matches) && count($matches) == 2) {
             $profile->setProfileId($matches[1]);
             $profile->setIdentifier($profile->getProfileId());
         }
         $this->em->persist($profile);
     }
     $this->em->flush();
     return true;
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->getFormatter()->setStyle('red', new OutputFormatterStyle('red', 'default'));
     $header = ['Show', 'Episode Title', 'Season/Episode', 'Date', 'Link'];
     $this->displayAsTable($io, $header, $this->getUpcomingEpisodes());
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputStyle = new SymfonyStyle($input, $output);
     $outputStyle->title('Displaying current configuration for currency exchange bundle');
     $this->displaySources($outputStyle)->displayNewLine($outputStyle)->displayProcessors($outputStyle)->displayNewLine($outputStyle)->displayRepository($outputStyle)->displayNewLine($outputStyle)->displayRates($outputStyle)->displayNewLine($outputStyle);
     $outputStyle->success('Configuration is valid.');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $fileInput = trim($input->getArgument('file'));
     $pathInfoFile = pathinfo(realpath($fileInput));
     $file = new File('', realpath($fileInput), $pathInfoFile['dirname']);
     $fileCollection = new FileCollection();
     $fileCollection = $fileCollection->append($file);
     $reporter = new Reporter($output, 1);
     $review = new StaticReview($reporter);
     $review->addReview(new PhpCsFixerReview(self::AUTO_ADD_GIT));
     // Review the staged files.
     $review->files($fileCollection);
     // Check if any matching issues were found.
     if ($reporter->hasIssues()) {
         $reporter->displayReport();
     }
     if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
         $io->error('✘ Please fix the errors above.');
         exit(1);
     } else {
         $io->success('✔ Looking good.');
         exit(0);
     }
 }
Exemplo n.º 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     mb_internal_encoding('UTF-8');
     try {
         list($line, $colonne) = explode("x", $input->getOption("size"));
         $symfonyStyle = new SymfonyStyle($input, $output);
         $symfonyStyle->title("IA");
         $mapRender = !$input->getOption("curse") ? new ConsoleMapRender($output, true) : new NCurseRender($line, $colonne);
         if (!$input->getOption("load-dump")) {
             $sizeMap = $mapRender->getSize();
             $mapProvider = $input->getOption("map") ? new FileMapProvider($input->getOption("map")) : new RandomMapProvider($sizeMap["y"], $sizeMap["x"]);
             $map = new MapBuilder($mapProvider->getMap());
             $world = new World($map, array($this->addChat(5, 5), $this->addChat(10, 10)));
         } else {
             $file = $input->getOption("load-dump");
             if (!file_exists($file)) {
                 if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
                     ncurses_end();
                 }
                 $symfonyStyle->error("le fichier {$file} n'existe pas");
                 return;
             }
             $world = unserialize(file_get_contents($file))->getFlashMemory()->all()[0]->getData();
         }
         while (1) {
             $this->render($mapRender, $world);
         }
     } catch (\Exception $e) {
         if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
             ncurses_end();
         }
         $symfonyStyle->error($e->getMessage());
         return;
     }
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Import sentry events');
     $organisation = $input->getArgument('organisation');
     $project = $input->getArgument('project');
     $projectBlacklist = $input->getOption('project-blacklist');
     $sentryRequest = new SentryRequest($input->getOption('sentry-url'), $input->getOption('sentry-api-key'));
     $projects = [$project];
     if (null === $project) {
         $projects = $this->application['project.collector']->getSlugs($sentryRequest, $organisation);
     }
     $progress = new ProgressBar($output);
     $progress->start();
     foreach ($projects as $project) {
         if (in_array($project, $projectBlacklist)) {
             continue;
         }
         $simplifiedEvents = $this->application['event.collector']->getSimplifiedEvents($sentryRequest, $organisation, $project);
         foreach ($simplifiedEvents as $simplifiedEvent) {
             $this->application['importer']->import($organisation, $project, $simplifiedEvent);
             $progress->advance();
         }
     }
     $progress->finish();
     $io->newLine(2);
     $eventCount = $this->application['db']->fetchColumn('SELECT COUNT(*) FROM events');
     $io->success(sprintf('%s events are available.', $eventCount));
 }
Exemplo n.º 10
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $workerCount = $input->getOption('count');
     $queues = $this->createQueues($input->getArgument('queues'));
     $output->write($queues);
     // This method of worker setup requires an array of queues
     if (!is_array($queues)) {
         throw new \Exception("Queues not initialized correctly");
     }
     $workers = array();
     for ($i = 0; $i < $workerCount; ++$i) {
         $worker = $this->workerFactory->createWorker();
         $workerProcess = $this->workerFactory->createWorkerProcess($worker);
         foreach ($queues as $queue) {
             $worker->addQueue($queue);
         }
         $workers[] = $workerProcess;
     }
     $this->foreman->pruneDeadWorkers();
     $this->foreman->work($workers, $input->getOption('wait'));
     echo sprintf('%d workers attached to the %s queues successfully started.', count($workers), implode($queues, ','));
     //        echo sprintf(
     //            'Workers (%s)',
     //            implode(', ', $workers)
     //        );
 }
Exemplo n.º 11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $stdout = $output;
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':l')) {
         $output->caution('The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.');
     }
     $twig = $this->getTwigEnvironment();
     if (null === $twig) {
         $output->error('The Twig environment needs to be set.');
         return 1;
     }
     $filenames = $input->getArgument('filename');
     if (0 === count($filenames)) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
         }
         $template = '';
         while (!feof(STDIN)) {
             $template .= fread(STDIN, 1024);
         }
         return $this->display($input, $stdout, $output, array($this->validate($twig, $template, uniqid('sf_'))));
     }
     $filesInfo = $this->getFilesInfo($twig, $filenames);
     return $this->display($input, $stdout, $output, $filesInfo);
 }
Exemplo n.º 12
0
 /**
  * Executes the command reparser:list
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return integer
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->section($this->user->lang('CLI_DESCRIPTION_REPARSER_AVAILABLE'));
     $io->listing($this->reparser_names);
     return 0;
 }
Exemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
Exemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $router = $this->getContainer()->get('router');
     $context = $router->getContext();
     if (null !== ($method = $input->getOption('method'))) {
         $context->setMethod($method);
     }
     if (null !== ($scheme = $input->getOption('scheme'))) {
         $context->setScheme($scheme);
     }
     if (null !== ($host = $input->getOption('host'))) {
         $context->setHost($host);
     }
     $matcher = new TraceableUrlMatcher($router->getRouteCollection(), $context);
     $traces = $matcher->getTraces($input->getArgument('path_info'));
     $io->newLine();
     $matches = false;
     foreach ($traces as $trace) {
         if (TraceableUrlMatcher::ROUTE_ALMOST_MATCHES == $trace['level']) {
             $io->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
         } elseif (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) {
             $io->success(sprintf('Route "%s" matches', $trace['name']));
             $routerDebugCommand = $this->getApplication()->find('debug:router');
             $routerDebugCommand->run(new ArrayInput(array('name' => $trace['name'])), $output);
             $matches = true;
         } elseif ($input->getOption('verbose')) {
             $io->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
         }
     }
     if (!$matches) {
         $io->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
         return 1;
     }
 }
Exemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $pools = array();
     $clearers = array();
     $container = $this->getContainer();
     $cacheDir = $container->getParameter('kernel.cache_dir');
     foreach ($input->getArgument('pools') as $id) {
         $pool = $container->get($id);
         if ($pool instanceof CacheItemPoolInterface) {
             $pools[$id] = $pool;
         } elseif ($pool instanceof Psr6CacheClearer) {
             $clearers[$id] = $pool;
         } else {
             throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
         }
     }
     foreach ($clearers as $id => $clearer) {
         $io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
         $clearer->clear($cacheDir);
     }
     foreach ($pools as $id => $pool) {
         $io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
         $pool->clear();
     }
     $io->success('Cache was successfully cleared.');
 }
Exemplo n.º 16
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $lockHandler = new LockHandler('app:sync.lock');
     if (!$lockHandler->lock()) {
         $io->warning('Sync process already running');
         return;
     }
     $service = $this->getContainer()->get('app.sync');
     switch ($input->getOption('type')) {
         case 'users':
             $service->syncUsers();
             break;
         case 'groups':
             $service->syncGroups();
             break;
         case 'grouphub':
             $service->syncGrouphubGroups();
             break;
         case 'queue':
             $service->syncGrouphubGroupsFromQueue();
             break;
         default:
             $service->sync();
     }
     $io->success('Done!');
 }
Exemplo n.º 17
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $groupRepository = $entityManager->getRepository('OctavaAdministratorBundle:Group');
     $resourceRepository = $entityManager->getRepository('OctavaAdministratorBundle:Resource');
     $groupNames = $input->getOption('group');
     foreach ($groupNames as $groupName) {
         /** @var Group $group */
         $group = $groupRepository->findOneBy(['name' => $groupName]);
         if (!$group) {
             $io->error(sprintf('Group "%s" not found', $groupName));
             continue;
         }
         $rows = [];
         $existsResources = $group->getResources();
         /** @var \Octava\Bundle\AdministratorBundle\Entity\Resource $resource */
         foreach ($resourceRepository->findAll() as $resource) {
             if ($existsResources->contains($resource)) {
                 continue;
             }
             $group->addResource($resource);
             $rows[] = [$resource->getResource(), $resource->getAction()];
         }
         if ($rows) {
             $io->section($groupName);
             $headers = ['Resource', 'Action'];
             $io->table($headers, $rows);
             $entityManager->persist($group);
             $entityManager->flush();
         }
     }
 }
Exemplo n.º 18
0
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $commandTitle = '                     Majora Installer                    ';
        $commandHelper = <<<COMMAND_HELPER
    <info>This is installer for majora-standard-edition</info>
   
    Create project to <info>current directory</info>: 
    
        <comment>majora new <Project Name></comment>
        
    Create project <info>for path</info>: 
    
        <comment>majora new <Path></comment>
        
    Create project <info>based on a specific branch</info>: 
    
        <comment>majora new <Project Name> <BranchName> </comment>
        
        
        
COMMAND_HELPER;
        $io->title($commandTitle);
        $io->writeln($commandHelper);
    }
Exemplo n.º 19
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $namespace = $input->getArgument('namespace');
     /** @var RouteCollection $RouteCollection */
     $RouteCollection = Service::get('kernel.routes');
     $Routes = $RouteCollection->all();
     $io = new SymfonyStyle($input, $output);
     $io->newLine();
     $rows = array();
     /** @var Route $Route */
     foreach ($Routes as $name => $Route) {
         $path = $Route->getPath();
         $local = $Route->getOption('_locale');
         $controller = $Route->getDefault('controller');
         $host = $Route->getHost();
         $methods = implode(', ', $Route->getMethods());
         $schemes = implode(', ', $Route->getSchemes());
         $_requirements = $Route->getRequirements();
         $requirements = null;
         $name = $local ? str_replace("-{$local}", '', $name) : $name;
         foreach ($_requirements as $var => $patt) {
             $requirements .= "\"{$var}={$patt}\" ";
         }
         $requirements = $requirements ? rtrim($requirements, ',') : '';
         $rows[] = array($name, $path, $local, $methods, $schemes);
     }
     $io->table(array('Name', 'Path', 'Local', 'Method', 'Scheme'), $rows);
     $io->success('Se han mostrado las rutas del proyecto exitosamente.');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Clearing the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheClearer->clear($this->cacheDir);
     $io->success('Cache cleared');
 }
Exemplo n.º 21
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $receipts = Yaml::parse(file_get_contents($input->getArgument('tasks-file')));
     $io = new SymfonyStyle($input, $output);
     foreach ($receipts['instances'] as $key => $instance) {
         $fs = new Filesystem();
         $tmpTime = sys_get_temp_dir() . "/backup_" . time();
         if ($fs->exists($tmpTime)) {
             $fs->remove($tmpTime);
         }
         $fs->mkdir($tmpTime);
         $this->tmpTime = $tmpTime;
         $io->note("Save : " . $key);
         /**
          * Save the database if is defined
          */
         $this->backupDatabase($io, $key, $instance);
         /**
          * Save the directories and compress if is defined
          */
         $this->backupDirectories($io, $key, $instance);
         $fileCompressedPath = $this->compress($io, $key, $instance);
         $hashFile = $this->generateHashFile($fileCompressedPath);
         $filesForCloud = [$fileCompressedPath, $hashFile];
         if (!array_key_exists('storages', $instance['processor'])) {
             throw new \RuntimeException("You storages is not defined");
         }
         $cloudStorage = new CloudStorage($io, $instance['processor']['storages'], $instance['cloud_storages'], $key, $filesForCloud);
         $cloudStorage->execute();
     }
 }
Exemplo n.º 22
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->migrationPath = str_replace('/', DIRECTORY_SEPARATOR, $this->getContainer()->getParameter('campaignchain_update.bundle.schema_dir'));
     $io = new SymfonyStyle($input, $output);
     $io->title('Gathering migration files from CampaignChain packages');
     $io->newLine();
     $locator = $this->getContainer()->get('campaignchain.core.module.locator');
     $bundleList = $locator->getAvailableBundles();
     if (empty($bundleList)) {
         $io->error('No CampaignChain Module found');
         return;
     }
     $migrationsDir = $this->getContainer()->getParameter('doctrine_migrations.dir_name');
     $fs = new Filesystem();
     $table = [];
     foreach ($bundleList as $bundle) {
         $packageSchemaDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $bundle->getName() . $this->migrationPath;
         if (!$fs->exists($packageSchemaDir)) {
             continue;
         }
         $migrationFiles = new Finder();
         $migrationFiles->files()->in($packageSchemaDir)->name('Version*.php');
         $files = [];
         /** @var SplFileInfo $migrationFile */
         foreach ($migrationFiles as $migrationFile) {
             $fs->copy($migrationFile->getPathname(), $migrationsDir . DIRECTORY_SEPARATOR . $migrationFile->getFilename(), true);
             $files[] = $migrationFile->getFilename();
         }
         $table[] = [$bundle->getName(), implode(', ', $files)];
     }
     $io->table(['Module', 'Versions'], $table);
     if (!$input->getOption('gather-only')) {
         $this->getApplication()->run(new ArrayInput(['command' => 'doctrine:migrations:migrate', '--no-interaction' => true]), $output);
     }
 }
Exemplo n.º 23
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $model = $input->getArgument('model');
     $seeds = $input->getArgument('seeds');
     $io = new SymfonyStyle($input, $output);
     if (!class_exists($model)) {
         $io->error(array('The model you specified does not exist.', 'You can create a model with the "model:create" command.'));
         return 1;
     }
     $this->dm = $this->createDocumentManager($input->getOption('server'));
     $faker = Faker\Factory::create();
     AnnotationRegistry::registerAutoloadNamespace('Hive\\Annotations', dirname(__FILE__) . '/../../');
     $reflectionClass = new \ReflectionClass($model);
     $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC);
     $reader = new AnnotationReader();
     for ($i = 0; $i < $seeds; $i++) {
         $instance = new $model();
         foreach ($properties as $property) {
             $name = $property->getName();
             $seed = $reader->getPropertyAnnotation($property, 'Hive\\Annotations\\Seed');
             if ($seed !== null) {
                 $fake = $seed->fake;
                 if (class_exists($fake)) {
                     $instance->{$name} = $this->createFakeReference($fake);
                 } else {
                     $instance->{$name} = $faker->{$seed->fake};
                 }
             }
         }
         $this->dm->persist($instance);
     }
     $this->dm->flush();
     $io->success(array("Created {$seeds} seeds for {$model}"));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
     $this->validateConfiguration($extension, $configuration);
     if ($name === $extension->getAlias()) {
         $message = sprintf('Default configuration for extension with alias: "%s"', $name);
     } else {
         $message = sprintf('Default configuration for "%s"', $name);
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $output->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $output->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $output->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $output->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }
Exemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputFile = $input->getOption('output');
     $this->renderTemplate($input, $outputFile, 'index.php.twig', dirname(__FILE__) . '/../../../templates/scaffold/api/', ['models' => $input->getArgument('models'), 'vendorPath' => $this->getVendorPath($input->getOption('output'))]);
     $io = new SymfonyStyle($input, $output);
     $io->success(["Hive API created in {$outputFile}"]);
 }
Exemplo n.º 27
0
 /**
  * Create a styled progress bar
  *
  * @param int             $max     Max value for the progress bar
  * @param SymfonyStyle    $io      Symfony style output decorator
  * @param OutputInterface $output  The output stream, used to print messages
  * @param bool            $message Should we display message output under the progress bar?
  * @return ProgressBar
  */
 public function create_progress_bar($max, SymfonyStyle $io, OutputInterface $output, $message = false)
 {
     $progress = $io->createProgressBar($max);
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
         $progress->setOverwrite(false);
     } else {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
             $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
             $progress->setOverwrite(false);
         } else {
             $io->newLine(2);
             $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "        " . ($message ? '%message%' : '                ') . " %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
             $progress->setBarWidth(60);
         }
     }
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $progress->setEmptyBarCharacter('░');
         // light shade character \u2591
         $progress->setProgressCharacter('');
         $progress->setBarCharacter('▓');
         // dark shade character \u2593
     }
     return $progress;
 }
Exemplo n.º 28
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $date = new \DateTime($input->getArgument('time'));
     // Get departure/arrival stops
     $departure = $this->cff->getStop($input->getArgument('departure'));
     $arrival = $this->cff->getStop($input->getArgument('arrival'));
     $output->write(sprintf('%s -> %s at %s : ', $departure['value'], $arrival['value'], $date->format('H:s')));
     $times = $this->cff->query($departure, $arrival, $date);
     $times = array_filter($times, function ($value) use($date) {
         return new \DateTime($value['departure']) == $date;
     });
     if ($infos = current($times)['infos']) {
         $output->writeln(sprintf('<comment>%s</comment>', $infos));
         // Create the Transport
         $transport = \Swift_SmtpTransport::newInstance($input->getOption('host'), $input->getOption('port'), $input->getOption('security'))->setUsername($input->getOption('username'))->setPassword($input->getOption('password'));
         $mailer = \Swift_Mailer::newInstance($transport);
         // Create a message
         $message = \Swift_Message::newInstance($infos)->setFrom(array($input->getOption('username') => 'CFFie'))->setTo(array($input->getOption('to')))->setBody(sprintf("%s -> %s at %s\nCFFie", $departure['value'], $arrival['value'], $date->format('H:m')));
         // Send the message
         $result = $mailer->send($message);
         if ($result) {
             $this->output->success($input->getOption('to') . ' alerted !');
         }
     } else {
         $output->writeln('<info>ok</info>');
     }
 }
Exemplo n.º 29
0
 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     foreach ($input->getOptions() as $option => $value) {
         if ($value === null) {
             $input->setOption($option, $this->io->ask(sprintf('%s', ucfirst($option))));
         }
     }
 }
Exemplo n.º 30
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $io->caution('The use of "twig:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:twig" instead.');
     }
     parent::execute($input, $io);
 }