protected function execute(InputInterface $input, OutputInterface $output)
 {
     $url = $input->getOption('url');
     $email = $input->getOption('email');
     $disable = $input->getOption('disable');
     $events = $input->getOption('event');
     if (!$url && !$email) {
         $output->writeln('<error>Must specify either a url or an email address</error>');
         return;
     }
     if ($url && $email) {
         $output->writeln('<error>Must specify only a url or an email address</error>');
         return;
     }
     if (!($resource = $this->getResource('webhook', $output))) {
         return;
     }
     if ($url) {
         $resource->setUrl($url);
     } else {
         $resource->setEmail($email);
     }
     $resource->setEventTypes($events ? $events : Webhook::$events);
     $this->getApi()->create($resource);
     $resource = $this->getApi()->getLastResponse();
     $resource = $resource['body']['data'];
     $table = $this->getHelperSet()->get('table');
     $this->formatTableRow($resource, $table, false);
     $output->writeln('<info>Webhook created</info>');
     $table->render($output);
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @throws InvalidArgumentException
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->detectMagento($output, true);
     if (!$this->initMagento()) {
         return;
     }
     $type = $input->getArgument('type');
     $areas = array('global', 'adminhtml', 'frontend', 'crontab');
     if ($type === null) {
         $type = $this->askForArrayEntry($areas, $output, 'Please select an area:');
     }
     if (!in_array($type, $areas)) {
         throw new InvalidArgumentException('Invalid type! Use one of: ' . implode(', ', $areas));
     }
     if ($input->getOption('format') === null) {
         $this->writeSection($output, 'Observers: ' . $type);
     }
     $frontendEvents = \Mage::getConfig()->getNode($type . '/events')->asArray();
     if (true === $input->getOption('sort')) {
         // sorting for Observers is a bad idea because the order in which observers will be called is important.
         ksort($frontendEvents);
     }
     $table = array();
     foreach ($frontendEvents as $eventName => $eventData) {
         $observerList = array();
         foreach ($eventData['observers'] as $observer) {
             $observerList[] = $this->getObserver($observer, $type);
         }
         $table[] = array($eventName, implode("\n", $observerList));
     }
     $this->getHelper('table')->setHeaders(array('Event', 'Observers'))->setRows($table)->renderByFormat($output, $table, $input->getOption('format'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     if (!file_exists($path)) {
         $output->writeln("{$path} is not a file or a path");
     }
     $filePaths = [];
     if (is_file($path)) {
         $filePaths = [realpath($path)];
     } elseif (is_dir($path)) {
         $filePaths = array_diff(scandir($path), array('..', '.'));
     } else {
         $output->writeln("{$path} is not known.");
     }
     $generator = new StopwordGenerator($filePaths);
     if ($input->getArgument('type') === 'json') {
         echo json_encode($this->toArray($generator->getStopwords()), JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
         echo json_last_error_msg();
         die;
         $output->write(json_encode($this->toArray($generator->getStopwords())));
     } else {
         $stopwords = $generator->getStopwords();
         $stdout = fopen('php://stdout', 'w');
         echo 'token,freq' . PHP_EOL;
         foreach ($stopwords as $token => $freq) {
             fputcsv($stdout, [utf8_encode($token), $freq]) . PHP_EOL;
         }
         fclose($stdout);
     }
 }
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $class_name = ltrim($input->getArgument('class_name'), '\\');
        $namespace_root = $input->getArgument('namespace_root_path');
        $match = [];
        preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
        if ($match) {
            $root_namespace = $match[1];
            $rest_fqcn = $match[2];
            $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
            $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
            $proxy_class_string = $this->proxyBuilder->build($class_name);
            $file_string = <<<EOF
<?php
// @codingStandardsIgnoreFile

/**
 * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}".
 */
{{ proxy_class_string }}
EOF;
            $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
            mkdir(dirname($proxy_filename), 0775, TRUE);
            file_put_contents($proxy_filename, $file_string);
            $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
        }
    }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $username = $input->getArgument('userId');
     $password = $input->getArgument('password');
     $workspaceName = $input->getArgument('workspaceName');
     $this->get('phpcr.session_manager')->relogin($username, $password, $workspaceName);
 }
 /**
  * {@inheritdoc}
  */
 protected function listItems(InputInterface $input, \Reflector $reflector = null, $target = null)
 {
     // only list constants when no Reflector is present.
     //
     // TODO: make a NamespaceReflector and pass that in for commands like:
     //
     //     ls --constants Foo
     //
     // ... for listing constants in the Foo namespace
     if ($reflector !== null || $target !== null) {
         return;
     }
     // only list constants if we are specifically asked
     if (!$input->getOption('constants')) {
         return;
     }
     $category = $input->getOption('user') ? 'user' : $input->getOption('category');
     $label = $category ? ucfirst($category) . ' Constants' : 'Constants';
     $constants = $this->prepareConstants($this->getConstants($category));
     if (empty($constants)) {
         return;
     }
     $ret = array();
     $ret[$label] = $constants;
     return $ret;
 }
Exemple #7
1
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Replace this with dependency injection once available
     /** @var DiagnosticService $diagnosticService */
     $diagnosticService = StaticContainer::get('Piwik\\Plugins\\Diagnostics\\DiagnosticService');
     $showAll = $input->getOption('all');
     $report = $diagnosticService->runDiagnostics();
     foreach ($report->getAllResults() as $result) {
         $items = $result->getItems();
         if (!$showAll && $result->getStatus() === DiagnosticResult::STATUS_OK) {
             continue;
         }
         if (count($items) === 1) {
             $output->writeln($result->getLabel() . ': ' . $this->formatItem($items[0]), OutputInterface::OUTPUT_PLAIN);
             continue;
         }
         $output->writeln($result->getLabel() . ':');
         foreach ($items as $item) {
             $output->writeln("\t- " . $this->formatItem($item), OutputInterface::OUTPUT_PLAIN);
         }
     }
     if ($report->hasWarnings()) {
         $output->writeln(sprintf('<comment>%d warnings detected</comment>', $report->getWarningCount()));
     }
     if ($report->hasErrors()) {
         $output->writeln(sprintf('<error>%d errors detected</error>', $report->getErrorCount()));
         return 1;
     }
     return 0;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->output = $output;
     $this->client = $client = SnsClient::factory(array('key' => $this->getContainer()->getParameter('amazon_s3.key'), 'secret' => $this->getContainer()->getParameter('amazon_s3.secret'), 'region' => $this->getContainer()->getParameter('amazon_s3.region')));
     if ($input->getOption('list-android')) {
         $this->showEndpoints($this->getContainer()->getParameter('amazon_sns.android_arn'), 'List of GCM endpoints:');
     }
     if ($input->getOption('list-ios')) {
         $this->showEndpoints($this->getContainer()->getParameter('amazon_sns.ios_arn'), 'List of APNS endpoints:');
     }
     $endpoint = $input->getArgument('endpoint');
     if ($endpoint) {
         if ($input->getOption('delete')) {
             $output->writeln('<comment>Delete endpoint</comment>');
             $client->deleteEndpoint(array('EndpointArn' => $endpoint));
         } else {
             $testMessage = 'Test notification';
             try {
                 $client->publish(array('TargetArn' => $endpoint, 'MessageStructure' => 'json', 'Message' => json_encode(array('APNS' => json_encode(array('aps' => array('alert' => $testMessage))), 'GCM' => json_encode(array('data' => array('message' => $testMessage)))))));
             } catch (\Aws\Sns\Exception\SnsException $e) {
                 $output->writeln("<error>{$e->getMessage()}</error>");
             }
         }
     }
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputFile = $input->getArgument('output');
     $outputHandle = fopen($outputFile, 'w');
     $client = new Client([]);
     $headers = ['Accept' => 'application/json', 'Accept-Encoding' => 'gzip,deflate', 'User-Agent' => 'crossref-dois/0.1 (+https://github.com/hubgit/crossref-dois/)'];
     // https://api.crossref.org/works?filter=type:journal-article&cursor=*
     $filters = ['type' => 'journal-article'];
     $filter = implode(',', array_map(function ($key) use($filters) {
         return $key . ':' . $filters[$key];
     }, array_keys($filters)));
     $params = ['filter' => $filter, 'cursor' => '*', 'rows' => 1000];
     $progress = new ProgressBar($output);
     $progressStarted = false;
     do {
         $response = $client->get('https://api.crossref.org/works', ['connect_timeout' => 10, 'timeout' => 120, 'query' => $params, 'headers' => $headers]);
         $data = json_decode($response->getBody(), true);
         if (!$progressStarted) {
             $progress->start($data['message']['total-results']);
             $progressStarted = true;
         }
         $items = $this->parseResponse($data);
         foreach ($items as $item) {
             fwrite($outputHandle, json_encode($item) . "\n");
         }
         $params['cursor'] = $data['message']['next-cursor'];
         $progress->advance(count($items));
     } while ($params['cursor']);
     $progress->finish();
 }
Exemple #10
0
 private function formatErroneousPlugin(InputInterface $input, Plugin $plugin)
 {
     if ($input->getOption('json')) {
         return ['name' => $plugin->getName(), 'error' => true, 'description' => 'Error : ' . $plugin->getError()->getMessage(), 'version' => null];
     }
     return ['<error>' . $plugin->getName() . '</error>', '<error>Error : ' . $plugin->getError()->getMessage() . '</error>', ''];
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $emName = $input->getOption('em');
     $emName = $emName ? $emName : 'default';
     $emServiceName = sprintf('doctrine.orm.%s_entity_manager', $emName);
     $em = $this->container->get($emServiceName);
     $dirOrFile = $input->getOption('fixtures');
     if ($dirOrFile) {
         $paths = is_array($dirOrFile) ? $dirOrFile : array($dirOrFile);
     } else {
         $paths = array();
         foreach ($this->application->getKernel()->getBundles() as $bundle) {
             $paths[] = $bundle->getPath() . '/DataFixtures/ORM';
         }
     }
     $loader = new DataFixturesLoader($this->container);
     foreach ($paths as $path) {
         if (is_dir($path)) {
             $loader->loadFromDirectory($path);
         }
     }
     $fixtures = $loader->getFixtures();
     $purger = new ORMPurger($em);
     $executor = new ORMExecutor($em, $purger);
     $executor->setLogger(function ($message) use($output) {
         $output->writeln(sprintf('  <comment>></comment> <info>%s</info>', $message));
     });
     $executor->execute($fixtures, $input->getOption('append'));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption("maintenance-mode")) {
         // set the timeout between each iteration to 0 if maintenance mode is on, because
         // we don't have to care about the load on the server
         Warming::setTimoutBetweenIteration(0);
     }
     try {
         $types = $this->getArrayOption('types', 'validTypes', 'type', true);
         $documentTypes = $this->getArrayOption('documentTypes', 'validDocumentTypes', 'document type');
         $assetTypes = $this->getArrayOption('assetTypes', 'validAssetTypes', 'asset type');
         $objectTypes = $this->getArrayOption('objectTypes', 'validObjectTypes', 'object type');
     } catch (\InvalidArgumentException $e) {
         $this->writeError($e->getMessage());
         return 1;
     }
     if (in_array('document', $types)) {
         $this->writeWarmingMessage('document', $documentTypes);
         Warming::documents($documentTypes);
     }
     if (in_array('asset', $types)) {
         $this->writeWarmingMessage('asset', $assetTypes);
         Warming::assets($assetTypes);
     }
     if (in_array('object', $types)) {
         $this->writeWarmingMessage('object', $objectTypes);
         Warming::assets($assetTypes);
     }
     $this->disableMaintenanceMode();
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $subUrls = $input->getArgument('url');
     $outputFile = $input->getArgument('output-file');
     // Daten laden
     $kosS = new KingOfSatScrapper();
     $output->writeln('Start Pulling Data');
     if (count($subUrls) > 0) {
         $firstRun = true;
         foreach ($subUrls as $url) {
             $data = $kosS->getTransponderData($url);
             $output->writeln(count($data) . ' Transponders found in ' . $url);
             if (true === $firstRun && count($data) > 0) {
                 $this->setupExcel(array_keys($data[0]));
                 $firstRun = false;
             }
             $this->addRowsToExcel($data);
         }
         // Daten ausgeben
         $output->writeln('Generate Excelfile: ' . $outputFile);
         $this->saveExcel($outputFile);
     } else {
         $output->writeln('<error>Missing pages to Scrap. See help.</error>');
     }
     $output->writeln('<info>(c) Steven Buehner <*****@*****.**></info>');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $state = $this->getState();
     $mode = $input->getArgument('mode');
     $stateName = 'system.maintenance_mode';
     $modeMessage = null;
     $cacheRebuild = true;
     if ('ON' === strtoupper($mode)) {
         $state->set($stateName, true);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-on';
     }
     if ('OFF' === strtoupper($mode)) {
         $state->set($stateName, false);
         $modeMessage = 'commands.site.maintenance.messages.maintenance-off';
     }
     if ($modeMessage === null) {
         $modeMessage = 'commands.site.maintenance.errors.invalid-mode';
         $cacheRebuild = false;
     }
     $io->info($this->trans($modeMessage));
     if ($cacheRebuild) {
         $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
     }
 }
Exemple #15
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);
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     ini_set('memory_limit', -1);
     set_time_limit(0);
     $this->output = $output;
     $this->em = $this->getContainer()->get('doctrine')->getManager();
     $siteId = (int) $input->getOption('site_id');
     $this->site = $this->em->getRepository('SudouxCmsSiteBundle:Site')->find($siteId);
     if (!isset($this->site)) {
         throw new \Exception("Site was not found");
     }
     $availableFunctions = array('import_branches_from_csv');
     $function = $input->getArgument('function');
     if (!in_array($function, $availableFunctions)) {
         throw new \Exception("Function does not exist");
     }
     switch ($function) {
         case 'import_branches_from_csv':
             $csvPath = $input->getOption('csv_path');
             if (empty($csvPath)) {
                 throw new \Exception("Option --csv_path cannot be empty");
             }
             $this->importBranchesFromCsv($csvPath);
             break;
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('<comment>Scan begining.</comment>');
     $result = $this->getContainer()->get('dokapi.swagger.scanner')->scan();
     $output->writeln('<comment>Scan done.</comment>');
     $apis = $result->getAll('api');
     $output->writeln(sprintf('<info>%s api(s) detected(s)</info>', count($apis)));
     if ($input->getOption('verbose')) {
         foreach ($result->getAll('api') as $api) {
             $output->writeln(sprintf('-----------------------------------------------------------------'));
             $output->writeln(sprintf('--- Api version: <info>%s</info>, path: <info>%s</info>', $api->getVersion(), $api->getPath()));
             $output->writeln(sprintf('-----------------------------------------------------------------'));
             foreach ($api->getResources() as $resource) {
                 $output->writeln(sprintf('------ Resource: <comment>%s</comment>', $resource->getId()));
                 foreach ($resource->getOperations() as $operation) {
                     $output->writeln(sprintf('--------- <comment>%s</comment>, path: <comment>%s</comment>, parameters: <comment>%s</comment>, responses: <comment>%s</comment>', $operation->getId(), $operation->getPath(), count($operation->getParameters()), count($operation->getResponses())));
                 }
             }
         }
     }
     if ($outputDir = $input->getOption('output-dir')) {
         $output->writeln(sprintf('Output results in directory <info>%s</info>', $outputDir));
         $renderer = new FilesystemRenderer($outputDir);
         $renderer->render($result);
         $output->writeln('<info>Done.</info>');
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $manifest = $input->getOption('manifest') ?: 'https://platform.sh/cli/manifest.json';
     $currentVersion = $input->getOption('current-version') ?: $this->getApplication()->getVersion();
     if (extension_loaded('Phar') && !($localPhar = \Phar::running(false))) {
         $this->stdErr->writeln('This instance of the CLI was not installed as a Phar archive.');
         if (file_exists(CLI_ROOT . '/../../autoload.php')) {
             $this->stdErr->writeln('Update using: <info>composer global update</info>');
         }
         return 1;
     }
     $manager = new Manager(Manifest::loadFile($manifest));
     if (isset($localPhar)) {
         $manager->setRunningFile($localPhar);
     }
     $onlyMinor = !$input->getOption('major');
     $updated = $manager->update($currentVersion, $onlyMinor);
     if ($updated) {
         $this->stdErr->writeln("Successfully updated");
         $localPhar = $manager->getRunningFile();
         passthru('php ' . escapeshellarg($localPhar) . ' --version');
     } else {
         $this->stdErr->writeln("No updates found. The Platform.sh CLI is up-to-date.");
     }
     return 0;
 }
Exemple #19
0
 /**
  * Executes the current command.
  *
  * This method is not abstract because you can use this class
  * as a concrete class. In this case, instead of defining the
  * execute() method, you set the code to execute by passing
  * a Closure to the setCode() method.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @throws \Exception
  * @return null|integer null or 0 if everything went fine, or an error code
  *
  * @see    setCode()
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inputFile = $input->getArgument('inputFile');
     $mode = $input->getOption('mode');
     if (!in_array($mode, array(self::MODE_MATCHED, self::MODE_UNMATCHED))) {
         throw new \Exception('Mode must be "matched" or "unmatched"');
     }
     if (!file_exists($inputFile)) {
         throw new \Exception('Input File "' . $inputFile . '" does not exist, or cannot access');
     }
     $cacheDir = sys_get_temp_dir() . '/browscap-grep/' . microtime(true) . '/';
     if (!file_exists($cacheDir)) {
         mkdir($cacheDir, 0777, true);
     }
     $debug = $input->getOption('debug');
     $loggerHelper = new LoggerHelper();
     $this->logger = $loggerHelper->create($debug);
     $iniFile = $input->getArgument('iniFile');
     if (!$iniFile || !file_exists($iniFile)) {
         $this->logger->info('iniFile Argument not set or invalid - creating iniFile from resources');
         $iniFile = $cacheDir . 'full_php_browscap.ini';
         $buildGenerator = new BuildGenerator($input->getOption('resources'), $cacheDir);
         $writerCollectionFactory = new FullPhpWriterFactory();
         $writerCollection = $writerCollectionFactory->createCollection($this->logger, $cacheDir);
         $buildGenerator->setLogger($this->logger)->setCollectionCreator(new CollectionCreator())->setWriterCollection($writerCollection);
         $buildGenerator->run($input->getArgument('version'), false);
     }
     $generator = new GrepGenerator();
     $browscap = new Browscap($cacheDir);
     $browscap->localFile = $iniFile;
     $generator->setLogger($this->logger)->run($browscap, $inputFile, $mode);
     $this->logger->info('Grep done.');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $code = $input->getArgument('code');
     $variantGroup = $this->getVariantGroup($code);
     if (!$variantGroup || $variantGroup->getType()->isVariant() === false) {
         $output->writeln(sprintf('<error>The variant group "%s" does not exist.</error>', $code));
         return -1;
     }
     $template = $variantGroup->getProductTemplate();
     $products = $variantGroup->getProducts();
     $skipped = $this->apply($template, $products->toArray());
     $nbSkipped = count($skipped);
     $output->writeln(sprintf('<info>Following %s products have been updated</info>', count($products) - $nbSkipped));
     foreach ($products as $product) {
         $productIdentifier = (string) $product->getIdentifier();
         if (in_array($productIdentifier, array_keys($skipped)) === false) {
             $output->writeln(sprintf('<info> - "%s" has been updated</info>', $productIdentifier));
         }
     }
     if ($nbSkipped > 0) {
         $output->writeln(sprintf('<info>Following %s products have been skipped</info>', $nbSkipped));
     }
     foreach ($skipped as $productIdentifier => $messages) {
         $output->writeln(sprintf('<error> - "%s" is not valid</error>', $productIdentifier));
         foreach ($messages as $message) {
             $output->writeln(sprintf("<error>   - %s</error>", $message));
         }
     }
 }
Exemple #21
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);
 }
Exemple #22
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     foreach ($this->dropOrder as $option) {
         if ($input->getOption($option)) {
             $drop[] = $option;
         }
     }
     // Default to the full drop order if no options were specified
     $drop = empty($drop) ? $this->dropOrder : $drop;
     $class = $input->getOption('class');
     $sm = $this->getSchemaManager();
     $isErrored = false;
     foreach ($drop as $option) {
         try {
             if (isset($class)) {
                 $this->{'processDocument' . ucfirst($option)}($sm, $class);
             } else {
                 $this->{'process' . ucfirst($option)}($sm);
             }
             $output->writeln(sprintf('Dropped <comment>%s%s</comment> for <info>%s</info>', $option, isset($class) ? self::INDEX === $option ? '(es)' : '' : (self::INDEX === $option ? 'es' : 's'), isset($class) ? $class : 'all classes'));
         } catch (\Exception $e) {
             $output->writeln('<error>' . $e->getMessage() . '</error>');
             $isErrored = true;
         }
     }
     return $isErrored ? 255 : 0;
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $database = $input->getArgument('database');
     $file = $input->getOption('file');
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $databaseConnection = $this->resolveConnection($io, $database);
     if (!$file) {
         $date = new \DateTime();
         $file = sprintf('%s/%s-%s.sql', $this->getSite()->getSiteRoot(), $databaseConnection['database'], $date->format('Y-m-d-h-i-s'));
     }
     $command = sprintf('mysqldump --user=%s --password=%s --host=%s --port=%s %s > %s', $databaseConnection['username'], $databaseConnection['password'], $databaseConnection['host'], $databaseConnection['port'], $databaseConnection['database'], $file);
     if ($learning) {
         $io->commentBlock($command);
     }
     $processBuilder = new ProcessBuilder(['–lock-all-tables']);
     $process = $processBuilder->getProcess();
     $process->setTty('true');
     $process->setCommandLine($command);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $io->success(sprintf('%s %s', $this->trans('commands.database.dump.messages.success'), $file));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ModelManager $em */
     $em = $this->container->get('models');
     $repository = $em->getRepository('Shopware\\Models\\Plugin\\Plugin');
     $builder = $repository->createQueryBuilder('plugin');
     $builder->andWhere('plugin.capabilityEnable = true');
     $builder->addOrderBy('plugin.active', 'desc');
     $builder->addOrderBy('plugin.name');
     $filter = strtolower($input->getOption('filter'));
     if ($filter === 'active') {
         $builder->andWhere('plugin.active = true');
     }
     if ($filter === 'inactive') {
         $builder->andWhere('plugin.active = false');
     }
     $namespace = $input->getOption('namespace');
     if (count($namespace)) {
         $builder->andWhere('p.namespace IN (:namespace)');
         $builder->setParameter('namespace', $namespace);
     }
     $plugins = $builder->getQuery()->execute();
     $rows = array();
     /** @var Plugin $plugin */
     foreach ($plugins as $plugin) {
         $rows[] = array($plugin->getName(), $plugin->getLabel(), $plugin->getVersion(), $plugin->getAuthor(), $plugin->getActive() ? 'Yes' : 'No', $plugin->getInstalled() ? 'Yes' : 'No');
     }
     $table = $this->getHelperSet()->get('table');
     $table->setHeaders(array('Plugin', 'Label', 'Version', 'Author', 'Active', 'Installed'))->setRows($rows);
     $table->render($output);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $adapter = $this->getAdapter();
     $prNumber = $input->getArgument('pr_number');
     $pullRequest = $adapter->getPullRequest($prNumber);
     /** @var GitConfigHelper $gitConfig */
     $gitConfig = $this->getHelper('git_config');
     /** @var GitHelper $gitHelper */
     $gitHelper = $this->getHelper('git');
     $gitHelper->guardWorkingTreeReady();
     $sourceOrg = $pullRequest['head']['user'];
     $sourceRepo = $pullRequest['head']['repo'];
     $sourceBranch = $pullRequest['head']['ref'];
     $gitConfig->ensureRemoteExists($sourceOrg, $sourceRepo);
     $gitHelper->remoteUpdate($sourceOrg);
     if ($gitHelper->branchExists($sourceBranch)) {
         if ($gitConfig->getGitConfig('branch.' . $sourceBranch . '.remote') !== $sourceOrg) {
             throw new UserException([sprintf('A local branch named "%s" already exists but it\'s remote is not "%s".', $sourceBranch, $sourceOrg), 'Rename the local branch to resolve this conflict.']);
         }
         $gitHelper->checkout($sourceBranch);
         $gitHelper->pullRemote($sourceOrg, $sourceBranch);
     } else {
         $gitHelper->checkout($sourceOrg . '/' . $sourceBranch);
         $gitHelper->checkout($sourceBranch, true);
         $gitConfig->setGitConfig('branch.' . $sourceBranch . '.remote', $sourceOrg, true);
     }
     $this->getHelper('gush_style')->success("Successfully checked-out pull-request {$pullRequest['url']} in '{$sourceBranch}'");
     return self::COMMAND_SUCCESS;
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /*
     $manager = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine'));
     
     try {
                 $bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name'));
                 $output->writeln(sprintf('Getting info from entities "<info>%s</info>"', $bundle->getName()));
                 $metadata = $manager->getBundleMetadata($bundle);
             } catch (\InvalidArgumentException $e) {
                 $name = strtr($input->getArgument('name'), '/', '\\');
     
                 if (false !== $pos = strpos($name, ':')) {
                     $name = $this->getContainer()->get('doctrine')->getAliasNamespace(substr($name, 0, $pos)).'\\'.substr($name, $pos + 1);
                 }
     
                 if (class_exists($name)) {
                     $output->writeln(sprintf('Generating entity "<info>%s</info>"', $name));
                     $metadata = $manager->getClassMetadata($name, $input->getOption('path'));
                 } else {
                     $output->writeln(sprintf('Generating entities for namespace "<info>%s</info>"', $name));
                     $metadata = $manager->getNamespaceMetadata($name, $input->getOption('path'));
                 }
             }
     
     $output->writeln($metadata);
     */
     $generator = $this->getContainer()->get('gcob_ng_table.generator');
     $generator->setEntity($input->getArgument('name'));
     $generator->generate();
     $output->writeln('success');
 }
Exemple #27
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param array $items
  * @param string $prefix
  */
 protected function writeArrayInOutputFormat(InputInterface $input, OutputInterface $output, $items, $prefix = '  - ')
 {
     switch ($input->getOption('output')) {
         case self::OUTPUT_FORMAT_JSON:
             $output->writeln(json_encode($items));
             break;
         case self::OUTPUT_FORMAT_JSON_PRETTY:
             $output->writeln(json_encode($items, JSON_PRETTY_PRINT));
             break;
         default:
             foreach ($items as $key => $item) {
                 if (is_array($item)) {
                     $output->writeln($prefix . $key . ':');
                     $this->writeArrayInOutputFormat($input, $output, $item, '  ' . $prefix);
                     continue;
                 }
                 if (!is_int($key)) {
                     $value = $this->valueToString($item);
                     if (!is_null($value)) {
                         $output->writeln($prefix . $key . ': ' . $value);
                     } else {
                         $output->writeln($prefix . $key);
                     }
                 } else {
                     $output->writeln($prefix . $this->valueToString($item));
                 }
             }
             break;
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $magento = new Magento($input->getOption('magento-root'));
     $config_adapter = new ConfigurationAdapter($magento);
     $yaml = new Parser();
     if ($input->getArgument('config-yaml-file')) {
         $config_yaml_file = $input->getArgument('config-yaml-file');
         if (!file_exists($config_yaml_file)) {
             throw new \Exception("File ({$config_yaml_file}) does not exist");
         }
         if (!is_readable($config_yaml_file)) {
             throw new \Exception("File ({$config_yaml_file}) is not readable");
         }
         $config_db_yaml = ConfigYaml::build($config_adapter);
         $config_file_contents = $yaml->parse(file_get_contents($config_yaml_file));
         $config_file_yaml = new ConfigYaml($config_file_contents, $input->getOption('env'));
         $diff = ConfigYaml::compare($config_file_yaml, $config_db_yaml);
         if (count($diff) > 0) {
             $db_data = $config_db_yaml->getData();
             $file_data = $config_file_yaml->getData();
             $diff_count = 0;
             foreach ($diff as $scope => $scope_data) {
                 foreach ($scope_data as $key => $value) {
                     $diff_count++;
                     $diff_message = sprintf("%s/%s is different (File: %s, DB: %s)", $scope, $key, $this->decorateValue($file_data[$scope][$key]), $this->decorateValue($db_data[$scope][$key]));
                     $output->writeln($diff_message);
                 }
             }
             return $diff_count;
         } else {
             return 0;
         }
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->em = $this->getContainer()->get('doctrine')->getEntityManager();
     $this->output = $output;
     $supported_locales = $this->getContainer()->getParameter('supported_locales');
     $default_locale = $this->getContainer()->getParameter('locale');
     $locales = $input->getOption('locale');
     if (empty($locales)) {
         $locales = $supported_locales;
     }
     $path = $input->getArgument('path');
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, strlen($path) - 1);
     }
     $things = ['faction', 'type', 'cycle', 'pack'];
     foreach ($locales as $locale) {
         if ($locale === $default_locale) {
             continue;
         }
         $output->writeln("Importing translations for <info>{$locale}</info>");
         foreach ($things as $thing) {
             $output->writeln("Importing translations for <info>{$thing}s</info> in <info>{$locale}</info>");
             $fileInfo = $this->getFileInfo("{$path}/translations/{$locale}", "{$thing}s.json");
             $this->importThingsJsonFile($fileInfo, $locale, $thing);
         }
         $this->em->flush();
         $fileSystemIterator = $this->getFileSystemIterator("{$path}/translations/{$locale}");
         $output->writeln("Importing translations for <info>cards</info> in <info>{$locale}</info>");
         foreach ($fileSystemIterator as $fileInfo) {
             $output->writeln("Importing translations for <info>cards</info> from <info>" . $fileInfo->getFilename() . "</info>");
             $this->importCardsJsonFile($fileInfo, $locale);
         }
         $this->em->flush();
     }
 }
Exemple #30
-1
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->command !== null) {
         // help for an individual command
         $output->page($this->command->asText());
         $this->command = null;
     } elseif ($name = $input->getArgument('command_name')) {
         // help for an individual command
         $output->page($this->getApplication()->get($name)->asText());
     } else {
         // list available commands
         $commands = $this->getApplication()->all();
         $width = 0;
         foreach ($commands as $command) {
             $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width;
         }
         $width += 2;
         foreach ($commands as $name => $command) {
             if ($name !== $command->getName()) {
                 continue;
             }
             if ($command->getAliases()) {
                 $aliases = sprintf('  <comment>Aliases:</comment> %s', implode(', ', $command->getAliases()));
             } else {
                 $aliases = '';
             }
             $messages[] = sprintf("  <info>%-{$width}s</info> %s%s", $name, $command->getDescription(), $aliases);
         }
         $output->page($messages);
     }
 }