/** * @param array $drupalProduct * @param ProductValue $productValue * @param string $field * @param array $context * @throws \Pim\Bundle\CatalogBundle\Exception\MissingIdentifierException */ public function normalize(array &$drupalProduct, $productValue, $field, array $context = array()) { $media = $productValue->getMedia(); if ($media && null !== $media->getFilename()) { $drupalProduct['values'][$field][$context['locale']][] = ['type' => 'pim_catalog_image', 'filename_original' => $media->getOriginalFilename(), 'filename' => $media->getFilename(), 'mimetype' => $media->getMimeType(), 'length' => filesize($this->mediaManager->getFilePath($media)), 'absolute_path' => $this->mediaManager->getFilePath($media), 'attribute_id' => $media->getValue()->getAttribute()->getId(), 'media_id' => $media->getId(), 'rest_url' => '/api/rest/media/' . $productValue->getEntity()->getIdentifier() . '/' . $productValue->getAttribute()->getId()]; } }
/** * {@inheritDoc} */ public function getEntity() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getEntity', array()); return parent::getEntity(); }