|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Platformsh\Client\Model; |
| 4 | + |
| 5 | +use Platformsh\Client\Model\Ref\OrganizationRef; |
| 6 | + |
| 7 | +/** |
| 8 | + * Stub (meta) information about a Platform.sh project obtained from the /me API. |
| 9 | + * |
| 10 | + * @property-read string $id |
| 11 | + * @property-read string $title |
| 12 | + * @property-read string $created_at |
| 13 | + * @property-read string $updated_at |
| 14 | + * @property-read string $endpoint |
| 15 | + * @property-read string $subscription_id |
| 16 | + * @property-read string $region |
| 17 | + * @property-read string $region_label |
| 18 | + * @property-read string $status |
| 19 | + */ |
| 20 | +class ProjectStub extends ResourceWithReferences |
| 21 | +{ |
| 22 | + protected static $collectionItemsKey = 'projects'; |
| 23 | + |
| 24 | + /** |
| 25 | + * Returns the full project resource for this stub. |
| 26 | + * |
| 27 | + * @return Project |
| 28 | + */ |
| 29 | + public function getProject() |
| 30 | + { |
| 31 | + $project = Project::get($this->endpoint, '', $this->client); |
| 32 | + if ($project === false) { |
| 33 | + throw new \RuntimeException('Project not found: ' . $this->endpoint); |
| 34 | + } |
| 35 | + return $project; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Returns detailed information about the project's organization, if known. |
| 40 | + * |
| 41 | + * @return OrganizationRef|null |
| 42 | + */ |
| 43 | + public function getOrganizationInfo() |
| 44 | + { |
| 45 | + if (isset($this->data['organization_id']) && isset($this->data['ref:organizations'][$this->data['organization_id']])) { |
| 46 | + return $this->data['ref:organizations'][$this->data['organization_id']]; |
| 47 | + } |
| 48 | + return null; |
| 49 | + } |
| 50 | +} |
0 commit comments