/** * @param ICompany $company * @return bool * @throws PolicyException */ public function canAdd(ICompany $company) { $current = $this->repository->countByCompany($company->getIdentifier()); $allowed = $company->getAllowedMarketplaceTypeInstances($this->marketplace_type_repository->getByType(IAppliance::MarketPlaceType)); if ($current >= $allowed) { throw new PolicyException('ApplianceAddPolicy', sprintf('You reach the max. amount of %s (%s) per Company', "Appliances", $allowed)); } return true; }
public function getMarketPlaceTypes() { $ds = new ArrayList(); if ($this->canAdmin('distributions')) { $ds->push($this->marketplace_repository->getByType(IDistribution::MarketPlaceType)); } if ($this->canAdmin('appliances')) { $ds->push($this->marketplace_repository->getByType(IAppliance::MarketPlaceType)); } if ($this->canAdmin('public_clouds')) { $ds->push($this->marketplace_repository->getByType(IPublicCloudService::MarketPlaceType)); } if ($this->canAdmin('private_clouds')) { $ds->push($this->marketplace_repository->getByType(IPrivateCloudService::MarketPlaceType)); } if ($this->canAdmin('consultants')) { $ds->push($this->marketplace_repository->getByType(IConsultant::MarketPlaceType)); } return $ds; }