Platformsh\Cli\Util\RelationshipsUtil::getRelationships PHP Метод

getRelationships() публичный Метод

public getRelationships ( string $sshUrl ) : array
$sshUrl string
Результат array
    public function getRelationships($sshUrl)
    {
        $args = ['ssh', $sshUrl, 'echo $' . $this->config->get('service.env_prefix') . 'RELATIONSHIPS'];
        $result = $this->shellHelper->execute($args, null, true);
        return json_decode(base64_decode($result), true);
    }

Usage Example

 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;
 }
All Usage Examples Of Platformsh\Cli\Util\RelationshipsUtil::getRelationships