eZ\Publish\Core\Repository\ContentTypeService::assignContentTypeGroup PHP Метод

assignContentTypeGroup() публичный Метод

Assigns a content type to a content type group.
public assignContentTypeGroup ( eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup $contentTypeGroup )
$contentType eZ\Publish\API\Repository\Values\ContentType\ContentType
$contentTypeGroup eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup
    public function assignContentTypeGroup(APIContentType $contentType, APIContentTypeGroup $contentTypeGroup)
    {
        if ($this->repository->hasAccess('class', 'update') !== true) {
            throw new UnauthorizedException('ContentType', 'update');
        }
        $spiContentType = $this->contentTypeHandler->load($contentType->id, $contentType->status);
        if (in_array($contentTypeGroup->id, $spiContentType->groupIds)) {
            throw new InvalidArgumentException('$contentTypeGroup', 'The given ContentType is already assigned to the ContentTypeGroup');
        }
        $this->repository->beginTransaction();
        try {
            $this->contentTypeHandler->link($contentTypeGroup->id, $contentType->id, $contentType->status);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
    }