if ($this->
isCollection($payload)) { throw ApiException::
badRequest('Only single write operations are supported. Please send the entities one by one or use the /sync api endpoint.'
);
} $pathSegments =
$this->
buildEntityPath($entityName,
$path,
$context,
[WriteProtection::
class]);
$last =
$pathSegments[\
count($pathSegments) - 1
];
if ($type === self::WRITE_CREATE && !
empty($last['value'
])) { $methods =
['GET', 'PATCH', 'DELETE'
];
throw ApiException::
methodNotAllowed($methods,
sprintf('No route found for "%s %s": Method Not Allowed (Allow: %s)',
$request->
getMethod(),
$request->
getPathInfo(),
implode(', ',
$methods)));
} if ($type === self::WRITE_UPDATE &&
isset($last['value'
])) { $payload['id'
] =
$last['value'
];
} /** @var EntityPathSegment $first */
$first =
array_shift($pathSegments);
if (\
count($pathSegments) === 0
) { $definition =
$first['definition'
];