コード例 #1
0
 protected function addCapability(array $capability_data, IOpenStackImplementation $implementation)
 {
     $validator = $this->validator_factory->buildValidatorForCapability($capability_data);
     if ($validator->fails()) {
         return $this->validationError($validator->messages());
     }
     $component = $this->component_repository->getById(intval($capability_data['component_id']));
     if (!$component) {
         throw new NotFoundEntityException('OpenStackComponent', sprintf('id %', intval($capability_data['component_id'])));
     }
     $release = $this->release_repository->getById(intval($capability_data['release_id']));
     if (!$release) {
         throw new NotFoundEntityException('OpenStackRelease', sprintf('id %', intval($capability_data['release_id'])));
     }
     if (!$release->supportsComponent($component->getCodeName())) {
         throw new NonSupportedComponent($release, $component);
     }
     $supported_version = null;
     if ($component->getSupportsVersioning()) {
         $version = $this->api_version_repository->getById(intval($capability_data['version_id']));
         if (!$version) {
             throw new NotFoundEntityException('OpenStackApiVersion', sprintf('id %', intval($capability_data['version_id'])));
         }
         $supported_version = $release->supportsApiVersion($version);
     } else {
         $supported_version = $this->supported_version_repository->getByReleaseAndComponentAndApiVersion(intval($capability_data['release_id']), intval($capability_data['component_id']), 0);
     }
     if (!$supported_version) {
         throw new NotFoundEntityException('OpenStackReleaseSupportedVersion', '');
     }
     $capability = $this->factory->buildCapability(intval($capability_data['coverage']), $supported_version, $implementation);
     $this->registerCapability($implementation, $capability);
 }
コード例 #2
0
 /**
  * @param int $release_id
  * @param int $component_id
  * @return IOpenStackApiVersion[]
  * @throws NotFoundEntityException
  * @throws InvalidAggregateRootException
  */
 public function getReleaseSupportedVersionsByComponent($release_id, $component_id)
 {
     $release = $this->release_repository->getById($release_id);
     if (!$release) {
         throw new NotFoundEntityException('OpenStackRelease', sprintf('id %s', $release_id));
     }
     $component = $this->component_repository->getById($component_id);
     if (!$component) {
         throw new NotFoundEntityException('OpenStackComponent', sprintf('id %s', $component));
     }
     if (!$release->supportsComponent($component->getCodeName())) {
         throw new InvalidAggregateRootException('OpenStackRelease', $release_id, 'OpenStackComponent', $component_id);
     }
     $res = array();
     foreach ($this->version_repository->getByReleaseAndComponent($release_id, $component_id) as $version) {
         if ($release->supportsApiVersion($version)) {
             array_push($res, $version);
         }
     }
     return $res;
 }