/** * Returns the number of Groups the type is assigned to. * * @param int $typeId * @param int $status * * @return int */ public function countGroupsForType($typeId, $status) { try { return $this->innerGateway->countGroupsForType($typeId, $status); } catch (DBALException $e) { throw new RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new RuntimeException('Database error', 0, $e); } }
/** * Unlink a content type group from a content type * * @param mixed $groupId * @param mixed $contentTypeId * @param int $status * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If group or type with provided status is not found * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If $groupId is last group on $contentTypeId or * not a group assigned to type * @todo Add throws for NotFound and BadState when group is not assigned to type */ public function unlink($groupId, $contentTypeId, $status) { $groupCount = $this->contentTypeGateway->countGroupsForType($contentTypeId, $status); if ($groupCount < 2) { throw new Exception\RemoveLastGroupFromType($contentTypeId, $status); } $this->contentTypeGateway->deleteGroupAssignment($groupId, $contentTypeId, $status); // @todo FIXME: What is to be returned? return true; }