getAllowedWriteScopes example

throw DataAbstractionLayerException::invalidSerializerField(CreatedByField::class$field);
        }

        // only required for new entities         if ($existence->exists()) {
            return;
        }

        $context = $parameters->getContext()->getContext();
        $scope = $context->getScope();

        if (!\in_array($scope$field->getAllowedWriteScopes(), true)) {
            return;
        }

        if ($data->getValue()) {
            yield from parent::encode($field$existence$data$parameters);

            return;
        }

        if (!$context->getSource() instanceof AdminApiSource) {
            return;
        }
throw DataAbstractionLayerException::invalidSerializerField(StateMachineStateField::class$field);
        }

        // Always allow any status when creating a new entity. A state transition from one state into another makes no         // sense in that case.         if (!$existence->exists()) {
            return parent::encode($field$existence$data$parameters);
        }

        // Allow the change of the stateMachineState if the scope is one of the allowed ones.         $scope = $parameters->getContext()->getContext()->getScope();
        if (\in_array($scope$field->getAllowedWriteScopes(), true)) {
            return parent::encode($field$existence$data$parameters);
        }

        // In every other case force the user to use a state-transition         $messageTemplate = 'Changing the state-machine-state of this entity is not allowed for scope {{ scope }}. '
            . 'Either change the state-machine-state via a state-transition or use a different scope.';
        $messageParameters = [
            '{{ scope }}' => $scope,
        ];

        throw new WriteConstraintViolationException(new ConstraintViolationList([
            
if (!($field instanceof UpdatedByField)) {
            throw DataAbstractionLayerException::invalidSerializerField(UpdatedByField::class$field);
        }

        if (!$existence->exists()) {
            return;
        }

        $context = $parameters->getContext()->getContext();
        $scope = $context->getScope();

        if (!\in_array($scope$field->getAllowedWriteScopes(), true)) {
            return;
        }

        if (!$context->getSource() instanceof AdminApiSource) {
            return;
        }

        $userId = $context->getSource()->getUserId();

        if (!$userId) {
            return;
        }
Home | Imprint | This part of the site doesn't use cookies.