registry = $registry; $this->metadataExtractor = $metadataExtractor; } /** * @param EntityWorkflow $object * * @throws ExceptionInterface * * @return array|ArrayObject|bool|float|int|string|void|null */ public function normalize($object, ?string $format = null, array $context = []): array { $data = $this->normalizer->normalize($object, $format, array_merge( $context, [self::IGNORE_ENTITY_WORKFLOW => spl_object_hash($object)] )); $workflow = $this->registry->get($object, $object->getWorkflowName()); $data['workflow'] = $this->metadataExtractor->buildArrayPresentationForWorkflow($workflow); $data['current_place'] = $this->metadataExtractor->buildArrayPresentationForPlace($object); $data['current_place_at'] = $this->normalizer->normalize($object->getCurrentStepCreatedAt(), 'json', ['groups' => ['read']]); $data['current_place_by'] = $this->normalizer->normalize($object->getCurrentStepCreatedBy(), 'json', ['groups' => ['read']]); return $data; } public function supportsNormalization($data, ?string $format = null, array $context = []): bool { return 'json' === $format && $data instanceof EntityWorkflow && !array_key_exists(self::IGNORE_ENTITY_WORKFLOW, $context); } }