protected function execute(InputInterface $input, OutputInterface $output) { $outputFile = $input->getOption('outfile'); $includes = $input->getOption('include'); $configuration = $this->getConfig(); $factory = DrupalClient::createFactory(); $decoratedFactory = new FileCacheFactory($factory); $client = new DrupalClient($decoratedFactory); $outputFileHandle = fopen($outputFile, 'w'); $modules = $client->getProjects(['field_project_type' => 'full']); fputcsv($outputFileHandle, array('url', 'module_name', 'name', 'author', 'status')); $processed = 0; $included = 0; $excluded = 0; /** @var \EclipseGc\DrupalOrg\Api\Resources\Node\ProjectModule $module */ foreach ($modules->getAll() as $module) { $include = FALSE; $processed++; // @todo Actually honor --include foreach ($configuration['lister']['modules']['include'] as $include_match) { if (fnmatch($include_match, $module->getMachineName())) { $include = TRUE; break; } } if (!$include) { continue; } foreach ($configuration['lister']['modules']['exclude'] as $exclude_match) { if (fnmatch($exclude_match, $module->getMachineName())) { $include = FALSE; $excluded++; break; } } if (!$include) { continue; } $included++; fputcsv($outputFileHandle, array($module->getUrl(), $module->getMachineName(), $module->getTitle(), $module->getAuthor()->getName())); printf("%5d processed, %4d included, %4d excluded\r", $processed, $included, $excluded); } fclose($outputFileHandle); return 0; }
protected function execute(InputInterface $input, OutputInterface $output) { $outputFile = $input->getOption('outfile'); $includes = $input->getOption('include'); $factory = DrupalClient::createFactory(); $decoratedFactory = new FileCacheFactory($factory); $client = new DrupalClient($decoratedFactory); $outputFileHandle = fopen($outputFile, 'w'); $sandboxes = $client->getProjects(['field_project_type' => 'sandbox']); fputcsv($outputFileHandle, array('title', 'name', 'url', 'created', 'changed', 'comments')); /** @var \EclipseGc\DrupalOrg\Api\Resources\Node\ProjectModule $sandbox */ foreach ($sandboxes->getAll() as $sandbox) { // @todo Actually honor --include if (stristr($sandbox->getTitle(), 'commerce') !== FALSE) { fputcsv($outputFileHandle, array($sandbox->getTitle(), $sandbox->getAuthor()->getName(), $sandbox->getUrl(), $sandbox->getCreated(), $sandbox->getChanged(), $sandbox->getCommentCount())); } } fclose($outputFileHandle); return 0; }
protected function getClient() { if ($this->client == NULL) { $factory = DrupalClient::createFactory(); $decoratedFactory = new FileCacheFactory($factory); $this->client = new DrupalClient($decoratedFactory); } return $this->client; }