/** * @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; }