eZ\Publish\Core\REST\Server\Controller\ContentType::updateContentTypeDraftFieldDefinition PHP Метод

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

Updates the attributes of a field definition.
public updateContentTypeDraftFieldDefinition ( $contentTypeId, $fieldDefinitionId, Request $request ) : FieldDefinitionList
$contentTypeId
$fieldDefinitionId
$request Symfony\Component\HttpFoundation\Request
Результат eZ\Publish\Core\REST\Server\Values\FieldDefinitionList
    public function updateContentTypeDraftFieldDefinition($contentTypeId, $fieldDefinitionId, Request $request)
    {
        $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
        $fieldDefinitionUpdate = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type'), 'Url' => $request->getPathInfo()), $request->getContent()));
        $fieldDefinition = null;
        foreach ($contentTypeDraft->getFieldDefinitions() as $fieldDef) {
            if ($fieldDef->id == $fieldDefinitionId) {
                $fieldDefinition = $fieldDef;
            }
        }
        if ($fieldDefinition === null) {
            throw new Exceptions\NotFoundException("Field definition not found: '{$request->getPathInfo()}'.");
        }
        try {
            $this->contentTypeService->updateFieldDefinition($contentTypeDraft, $fieldDefinition, $fieldDefinitionUpdate);
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }
        $updatedDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
        foreach ($updatedDraft->getFieldDefinitions() as $fieldDef) {
            if ($fieldDef->id == $fieldDefinitionId) {
                return new Values\RestFieldDefinition($updatedDraft, $fieldDef);
            }
        }
        throw new Exceptions\NotFoundException("Field definition not found: '{$request->getPathInfo()}'.");
    }