CodeExplorer createSerializedEntity example
protected function serializeEntity(ResponseFields
$fields, Entity
$entity, EntityDefinition
$definition, JsonApiEncodingResult
$result, bool
$isRelationship = false
): void
{ if ($result->
containsInData($entity->
getUniqueIdentifier(),
$definition->
getEntityName()) || ($isRelationship &&
$result->
containsInIncluded($entity->
getUniqueIdentifier(),
$definition->
getEntityName())) ) { return;
} $self =
$result->
getBaseUrl() . '/' .
$this->
camelCaseToSnailCase($definition->
getEntityName()) . '/' .
$entity->
getUniqueIdentifier();
$serialized =
clone $this->
createSerializedEntity($fields,
$definition,
$result);
$serialized->
addLink('self',
$self);
$serialized->
merge($entity);
// add included entities
$this->
serializeRelationships($fields,
$serialized,
$entity,
$result);
$this->
addExtensions($fields,
$serialized,
$entity,
$result);
if ($isRelationship) { $result->
addIncluded($serialized);
} else {