public function linkContentTypeToGroup($contentTypeId, Request $request)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId);

        try {
            $contentTypeGroupId = $this->requestParser->parseHref(
                $request->query->get('group'),
                'contentTypeGroupId'
            );
        } catch (Exceptions\InvalidArgumentException $e) {
            // Group URI does not match the required value
            throw new BadRequestException($e->getMessage());
        }

        $contentTypeGroup = $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId);

        $existingContentTypeGroups = $contentType->getContentTypeGroups();
        $contentTypeInGroup = false;
        foreach ($existingContentTypeGroups as $existingGroup) {
            if ($existingGroup->id == $contentTypeGroup->id) {
                $contentTypeInGroup = true;
                break;
            }
        }

        if ($contentTypeInGroup) {
            throw new ForbiddenException('Content type is already linked to provided group');
        }

        $this->contentTypeService->assignContentTypeGroup(
            $contentType,
            $contentTypeGroup
        );

        $existingContentTypeGroups[] = $contentTypeGroup;

        return new Values\ContentTypeGroupRefList(
            $contentType,
            $existingContentTypeGroups
        );
    }
public function linkContentTypeToGroup($contentTypeId, Request $request)
    {
        $contentType = $this->contentTypeService->loadContentType($contentTypeId);

        try {
            $contentTypeGroupId = $this->requestParser->parseHref(
                $request->query->get('group'),
                'contentTypeGroupId'
            );
        } catch (Exceptions\InvalidArgumentException $e) {
            // Group URI does not match the required value
            throw new BadRequestException($e->getMessage());
        }

        $contentTypeGroup = $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId);

        $existingContentTypeGroups = $contentType->getContentTypeGroups();
        $contentTypeInGroup = false;
        foreach ($existingContentTypeGroups as $existingGroup) {
            if ($existingGroup->id == $contentTypeGroup->id) {
                $contentTypeInGroup = true;
                break;
            }
        }

        if ($contentTypeInGroup) {
            throw new ForbiddenException('Content type is already linked to provided group');
        }

        $this->contentTypeService->assignContentTypeGroup(
            $contentType,
            $contentTypeGroup
        );

        $existingContentTypeGroups[] = $contentTypeGroup;

        return new Values\ContentTypeGroupRefList(
            $contentType,
            $existingContentTypeGroups
        );
    }
public function linkContentTypeToGroup ( $ contentTypeId , Request $ request ) { $ contentType = $ this -> contentTypeService -> loadContentType ( $ contentTypeId ) ; try { $ contentTypeGroupId = $ this -> requestParser -> parseHref ( $ request -> query -> get ( 'group' ) , 'contentTypeGroupId' ) ; } catch ( Exceptions \ InvalidArgumentException $ e ) { // Group URI does not match the required value throw new BadRequestException ( $ e -> getMessage ( ) ) ; } $ contentTypeGroup = $ this -> contentTypeService -> loadContentTypeGroup ( $ contentTypeGroupId ) ; $ existingContentTypeGroups = $ contentType -> getContentTypeGroups ( ) ; $ contentTypeInGroup = false ; foreach ( $ existingContentTypeGroups as $ existingGroup ) { if ( $ existingGroup -> id == $ contentTypeGroup -> id ) { $ contentTypeInGroup = true ; break ; } } if ( $ contentTypeInGroup ) { throw new ForbiddenException ( 'Content type is already linked to provided group' ) ; } $ this -> contentTypeService -> assignContentTypeGroup ( $ contentType , $ contentTypeGroup ) ; $ existingContentTypeGroups [ ] = $ contentTypeGroup ; return new Values \ ContentTypeGroupRefList ( $ contentType , $ existingContentTypeGroups ) ; }
Links a content type group to the content type and returns the updated group list.

@param mixed $contentTypeId

@throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
@throws \eZ\Publish\Core\REST\Server\Exceptions\BadRequestException

@return \eZ\Publish\Core\REST\Server\Values\ContentTypeGroupRefList
Links a content type group to the content type and returns the updated group list .