コード例 #1
0
 /**
  * {@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;
 }
コード例 #2
0
 /**
  * {@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())];
 }
コード例 #3
0
 /**
  * {@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;
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 protected function convertValue($value)
 {
     $result = $this->getBackendData($value);
     return $this->presenter->present($result, ['locale' => $this->translator->getLocale()]);
 }
コード例 #5
0
 /**
  * {@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()];
 }
コード例 #6
0
 /**
  * Present a date
  *
  * @param string $date
  *
  * @return string
  */
 public function datePresenter($date)
 {
     return $this->datePresenter->present($date, ['locale' => $this->localeResolver->getCurrentLocale()]);
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 protected function convertValue($value)
 {
     $result = !$value instanceof \DateTime ? $this->getBackendData($value) : $value;
     return $this->presenter->present($result, ['locale' => $this->translator->getLocale()]);
 }
コード例 #8
0
 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);
 }