/** * {@inheritdoc} */ public function normalize($comment, $format = null, array $context = []) { if (!$this->serializer instanceof NormalizerInterface) { throw new \LogicException('Serializer must be a normalizer'); } $context = ['locale' => $this->localeResolver->getCurrentLocale()]; $data = ['id' => $comment->getId(), 'resourceName' => $comment->getResourceName(), 'resourceId' => $comment->getResourceId(), 'author' => ['username' => $comment->getAuthor()->getUsername(), 'fullName' => $comment->getAuthor()->getFirstName() . ' ' . $comment->getAuthor()->getLastName()], 'body' => $comment->getBody(), 'created' => $this->datetimePresenter->present($comment->getCreatedAt(), $context), 'replied' => $this->datetimePresenter->present($comment->getRepliedAt(), $context), 'replies' => $this->serializer->normalize($comment->getChildren(), 'json')]; return $data; }
/** * {@inheritdoc} */ public function normalize($object, $format = null, array $context = []) { $normalizedWarnings = $this->normalizeWarnings($object->getWarnings(), $context); if (isset($context['limit_warnings']) && $object->getWarnings()->count() > 0) { $object->addSummaryInfo('displayed', count($normalizedWarnings) . '/' . $object->getWarnings()->count()); } return ['label' => $this->labelProvider->getStepLabel($object->getJobExecution()->getJobInstance()->getJobName(), $object->getStepName()), 'status' => $this->normalizeStatus($object->getStatus()->getValue()), 'summary' => $this->normalizeSummary($object->getSummary()), 'startedAt' => $this->presenter->present($object->getStartTime(), $context), 'endedAt' => $this->presenter->present($object->getEndTime(), $context), 'warnings' => $normalizedWarnings, 'failures' => array_map(function ($failure) { return $this->translator->trans($failure['message'], $failure['messageParameters']); }, $object->getFailureExceptions())]; }
/** * {@inheritdoc} */ public function getData() { $operations = $this->manager->getLastOperationsData([]); foreach ($operations as &$operation) { $operation['statusLabel'] = $this->translator->trans('pim_import_export.batch_status.' . $operation['status']); if ($operation['date'] instanceof \DateTime) { $locale = $this->tokenStorage->getToken()->getUser()->getUiLocale()->getCode(); $operation['date'] = $this->presenter->present($operation['date'], ['locale' => $locale]); } } return $operations; }
/** * {@inheritdoc} */ protected function convertValue($value) { $result = $this->getBackendData($value); return $this->presenter->present($result, ['locale' => $this->translator->getLocale()]); }
/** * {@inheritdoc} */ public function normalize($version, $format = null, array $context = []) { $context = ['locale' => $this->translator->getLocale()]; return ['id' => $version->getId(), 'author' => $this->normalizeAuthor($version->getAuthor()), 'resource_id' => (string) $version->getResourceId(), 'snapshot' => $version->getSnapshot(), 'changeset' => $this->convertChangeset($version->getChangeset(), $context), 'context' => $version->getContext(), 'version' => $version->getVersion(), 'logged_at' => $this->datetimePresenter->present($version->getLoggedAt(), $context), 'pending' => $version->isPending()]; }
/** * Present a date * * @param string $date * * @return string */ public function datePresenter($date) { return $this->datePresenter->present($date, ['locale' => $this->localeResolver->getCurrentLocale()]); }
/** * {@inheritdoc} */ protected function convertValue($value) { $result = !$value instanceof \DateTime ? $this->getBackendData($value) : $value; return $this->presenter->present($result, ['locale' => $this->translator->getLocale()]); }