/**
  * {@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->translator->trans($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())];
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 protected function convertValue($value)
 {
     $data = $this->getBackendData($value);
     $prices = [];
     foreach ($data as $price) {
         if (isset($price['data']) && $price['data'] !== null) {
             $prices[] = $this->presenter->present($price, ['locale' => $this->translator->getLocale()]);
         }
     }
     return implode(', ', $prices);
 }
 /**
  * {@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;
 }
 /**
  * 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 = $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' => $version->getChangeset(), 'context' => $version->getContext(), 'version' => $version->getVersion(), 'logged_at' => $this->datetimePresenter->present($version->getLoggedAt(), $context), 'pending' => $version->isPending()];
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 protected function convertValue($value)
 {
     $result = !$value instanceof \DateTime ? $this->getBackendData($value) : $value;
     return $this->presenter->present($result, ['locale' => $this->translator->getLocale()]);
 }
 function it_returns_null_if_there_is_no_product_value_localizer(PresenterInterface $presenter)
 {
     $presenter->supports('pim_catalog_number')->willReturn(false);
     $this->register($presenter, 'attribute_option');
     $this->getAttributeOptionPresenter('pim_catalog_number')->shouldReturn(null);
 }