protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $app = $this->selectApp($input);
     $environment = $this->getSelectedEnvironment();
     $cacheKey = implode('-', ['relationships', $environment->id . $environment->project . $app]);
     $cache = CacheUtil::getCache();
     $relationships = $cache->fetch($cacheKey);
     if (empty($relationships) || $input->getOption('refresh')) {
         $util = new RelationshipsUtil($this->stdErr);
         $sshUrl = $environment->getSshUrl($app);
         $relationships = $util->getRelationships($sshUrl);
         if (empty($relationships)) {
             $this->stdErr->writeln('No relationships found');
             return 1;
         }
         $cache->save($cacheKey, $relationships, 3600);
     }
     $value = $relationships;
     $key = null;
     if ($property = $input->getOption('property')) {
         $parents = explode('.', $property);
         $key = end($parents);
         $value = Util::getNestedArrayValue($relationships, $parents, $key_exists);
         if (!$key_exists) {
             $this->stdErr->writeln("Relationship property not found: <error>{$property}</error>");
             return 1;
         }
     }
     $formatter = new PropertyFormatter();
     $formatter->yamlInline = 10;
     $output->writeln($formatter->format($value, $key));
     return 0;
 }
Пример #2
0
 /**
  * Clear the projects cache.
  */
 protected function clearProjectsCache()
 {
     CacheUtil::getCache()->delete(sprintf('%s:projects', self::$sessionId));
 }