当前位置: 首页>>代码示例>>PHP>>正文


PHP ProductValueInterface::getMedia方法代码示例

本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Model\ProductValueInterface::getMedia方法的典型用法代码示例。如果您正苦于以下问题:PHP ProductValueInterface::getMedia方法的具体用法?PHP ProductValueInterface::getMedia怎么用?PHP ProductValueInterface::getMedia使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Bundle\CatalogBundle\Model\ProductValueInterface的用法示例。


在下文中一共展示了ProductValueInterface::getMedia方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isComplete

 /**
  * {@inheritdoc}
  */
 public function isComplete(ProductValueInterface $productValue, ChannelInterface $channel = null, LocaleInterface $locale = null)
 {
     $media = $productValue->getMedia();
     if (!$media || '' === $media->__toString()) {
         return false;
     }
     return true;
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:MediaCompleteChecker.php

示例2:

 function it_updates_normalized_product_template_values_if_media_values_have_been_handled($normalizer, ProductTemplateInterface $imageTemplate, ProductTemplateInterface $textTemplate, ProductValueInterface $imageValue, ProductValueInterface $textValue, ProductMediaInterface $imageMedia)
 {
     $normalizer->normalize(Argument::cetera())->willReturn([]);
     $imageTemplate->getValues()->willReturn([$imageValue]);
     $imageValue->getMedia()->willReturn($imageMedia);
     $imageTemplate->setValuesData([])->shouldBeCalled();
     $textTemplate->getValues()->willReturn([$textValue]);
     $textTemplate->setValuesData([])->shouldNotBeCalled();
     $this->handleProductTemplateMedia($imageTemplate);
     $this->handleProductTemplateMedia($textTemplate);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:11,代码来源:ProductTemplateMediaManagerSpec.php

示例3:

 function it_generates_the_path_when_the_value_is_localisable_and_scopable(ProductValueInterface $value, FileInfoInterface $fileInfo, AttributeInterface $attribute)
 {
     $value->getMedia()->willReturn($fileInfo);
     $value->getLocale()->willReturn('fr_FR');
     $value->getScope()->willReturn('ecommerce');
     $value->getAttribute()->willReturn($attribute);
     $fileInfo->getOriginalFilename()->willReturn('file.jpg');
     $attribute->getCode()->willReturn('picture');
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(true);
     $this->generate($value, ['identifier' => 'sku001'])->shouldReturn('files/sku001/picture/fr_FR/ecommerce/file.jpg');
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:12,代码来源:MediaExporterPathGeneratorSpec.php

示例4: it_succesfully_checks_complete_media

 public function it_succesfully_checks_complete_media(ProductValueInterface $value, ChannelInterface $channel, LocaleInterface $locale, ProductMediaInterface $media)
 {
     $value->getMedia()->willReturn(null);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
     $value->getMedia()->willReturn([]);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
     $media->__toString()->willReturn('');
     $value->getMedia()->willReturn($media);
     $this->isComplete($value, $channel, $locale)->shouldReturn(false);
     $media->__toString()->willReturn('other');
     $value->getMedia()->willReturn($media);
     $this->isComplete($value, $channel, $locale)->shouldReturn(true);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:13,代码来源:MediaCompleteCheckerSpec.php

示例5:

 function it_returns_flat_data_with_media($channelManager, Filesystem $filesystem, ChannelInterface $channel, ProductInterface $product, FileInterface $media1, FileInterface $media2, ProductValueInterface $value1, ProductValueInterface $value2, AttributeInterface $attribute, ProductValueInterface $identifierValue, AttributeInterface $identifierAttribute, $serializer)
 {
     $media1->getKey()->willReturn('key/to/media1.jpg');
     $media2->getKey()->willReturn('key/to/media2.jpg');
     $value1->getAttribute()->willReturn($attribute);
     $value1->getMedia()->willReturn($media1);
     $value2->getAttribute()->willReturn($attribute);
     $value2->getMedia()->willReturn($media2);
     $attribute->getAttributeType()->willReturn('pim_catalog_image');
     $product->getValues()->willReturn([$value1, $value2, $identifierValue]);
     $identifierValue->getAttribute()->willReturn($identifierAttribute);
     $identifierAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $product->getIdentifier()->willReturn($identifierValue);
     $identifierValue->getData()->willReturn('data');
     $filesystem->has('key/to/media1.jpg')->willReturn(true);
     $filesystem->has('key/to/media2.jpg')->willReturn(true);
     $serializer->normalize($media1, 'flat', ['field_name' => 'media', 'prepare_copy' => true, 'value' => $value1])->willReturn(['normalized_media1']);
     $serializer->normalize($media2, 'flat', ['field_name' => 'media', 'prepare_copy' => true, 'value' => $value2])->willReturn(['normalized_media2']);
     $serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => ''])->willReturn(['normalized_product']);
     $channelManager->getChannelByCode('foobar')->willReturn($channel);
     $this->setChannel('foobar');
     $this->process($product)->shouldReturn(['media' => [['normalized_media1'], ['normalized_media2']], 'product' => ['normalized_product']]);
 }
开发者ID:umpirsky,项目名称:pim-community-dev,代码行数:23,代码来源:ProductToFlatArrayProcessorSpec.php

示例6: validateMedia

 /**
  * Check if the media is not empty
  *
  * @param ProductValueInterface $value
  * @param Constraint            $constraint
  */
 protected function validateMedia(ProductValueInterface $value, Constraint $constraint)
 {
     $media = $value->getMedia();
     if (!$media || $media->__toString() === '') {
         $this->context->addViolation($constraint->messageComplete);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:13,代码来源:ProductValueCompleteValidator.php

示例7: realpath

 function it_sets_a_media_to_a_product_that_has_no_value($manager, $builder, $mediaFactory, AttributeInterface $attribute, ProductInterface $product, ProductValueInterface $value, ProductMediaInterface $media)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $product->getValue('attributeCode', Argument::cetera())->willReturn(null);
     $value->getMedia()->willReturn(null);
     $data = ['originalFilename' => 'akeneo', 'filePath' => realpath(__DIR__ . '/../../../../../../features/Context/fixtures/akeneo.jpg')];
     $builder->addProductValue($product, $attribute, Argument::cetera())->shouldBeCalled()->willReturn($value);
     $mediaFactory->createMedia(Argument::any())->shouldBeCalled()->willReturn($media);
     $value->setMedia($media)->shouldBeCalled($value);
     $manager->handleAllProductsMedias([$product])->shouldBeCalled();
     $this->setValue([$product], $attribute, $data, 'fr_FR', 'mobile');
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:12,代码来源:MediaValueSetterSpec.php

示例8: ProductMedia

 function it_does_not_validate_a_product_value_with_backendtype_as_media($context, ProductValueComplete $constraint, ProductValueInterface $productValue, AttributeInterface $attribute, ConstraintViolationBuilderInterface $violation)
 {
     $constraint->getChannel()->willReturn($this->getChannel());
     $productMedia = new ProductMedia();
     $productValue->getMedia()->willReturn($productMedia);
     $productValue->getData()->willReturn('data');
     $attribute->getBackendType()->willReturn('media');
     $productValue->getAttribute()->willReturn($attribute);
     $context->buildViolation($constraint->messageComplete)->shouldBeCalled()->willReturn($violation);
     $this->validate($productValue, $constraint);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:11,代码来源:ProductValueCompleteValidatorSpec.php

示例9:

 function it_copies_an_empty_media($attrValidatorHelper, ProductMediaInterface $toMedia, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product, ProductValueInterface $fromProductValue, ProductValueInterface $toProductValue)
 {
     $fromLocale = 'fr_FR';
     $toLocale = 'fr_FR';
     $toScope = 'mobile';
     $fromScope = 'mobile';
     $fromAttribute->getCode()->willReturn('fromAttributeCode');
     $toAttribute->getCode()->willReturn('toAttributeCode');
     $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled();
     $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled();
     $fromProductValue->getMedia()->willReturn(null);
     $toProductValue->getMedia()->willReturn($toMedia);
     $toMedia->setOriginalFilename(null)->shouldBeCalled();
     $toMedia->setFilename(null)->shouldBeCalled();
     $toMedia->setMimeType(null)->shouldBeCalled();
     $product->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
     $product->getValue('toAttributeCode', $toLocale, $toScope)->willReturn($toProductValue);
     $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]);
 }
开发者ID:jacko972,项目名称:pim-community-dev,代码行数:19,代码来源:MediaAttributeCopierSpec.php

示例10: duplicateMedia

 /**
  * TODO: remove this method after the refactoring of the product media manager
  *
  * @param ProductInterface      $product
  * @param ProductValueInterface $fromValue
  * @param ProductValueInterface $toValue
  */
 protected function duplicateMedia(ProductInterface $product, ProductValueInterface $fromValue, ProductValueInterface $toValue)
 {
     if (null === $toValue->getMedia()) {
         $media = $this->mediaFactory->createMedia();
         $toValue->setMedia($media);
     }
     $this->mediaManager->duplicate($fromValue->getMedia(), $toValue->getMedia(), $this->mediaManager->generateFilenamePrefix($product, $fromValue));
 }
开发者ID:vpetrovych,项目名称:pim-community-dev,代码行数:15,代码来源:MediaAttributeCopier.php

示例11: setProductFile

 /**
  * @param ProductValueInterface $productValue
  * @param ProductValueInterface $value
  */
 protected function setProductFile(ProductValueInterface $productValue, ProductValueInterface $value)
 {
     if (null === ($media = $productValue->getMedia())) {
         $media = new $this->productMediaClass();
         $productValue->setMedia($media);
     }
     $file = $value->getMedia()->getFile();
     if ($file) {
         $media->setFile($file);
     } else {
         $media->setRemoved(true);
     }
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:17,代码来源:EditCommonAttributes.php

示例12:

 function it_copies_when_a_product_value_has_a_media_but_not_the_target_value($builder, $attrValidatorHelper, FileInfoInterface $fromMedia, FileInfoInterface $toMedia, \SplFileInfo $rawFile, FileInfoInterface $fileInfo, ProductMediaInterface $fromMedia, ProductMediaInterface $toMedia, AttributeInterface $fromAttribute, AttributeInterface $toAttribute, ProductInterface $product, ProductValueInterface $fromProductValue, FileStorerInterface $fileStorer, ProductValueInterface $toProductValue, FileFetcherInterface $fileFetcher, MountManager $mountManager, FilesystemInterface $fileSystem)
 {
     $fromLocale = 'fr_FR';
     $toLocale = 'fr_FR';
     $toScope = 'mobile';
     $fromScope = 'mobile';
     $fromAttribute->getCode()->willReturn('fromAttributeCode');
     $toAttribute->getCode()->willReturn('toAttributeCode');
     $attrValidatorHelper->validateLocale(Argument::cetera())->shouldBeCalled();
     $attrValidatorHelper->validateScope(Argument::cetera())->shouldBeCalled();
     $fromProductValue->getMedia()->willReturn($fromMedia);
     $fromMedia->getOriginalFilename()->willReturn('akeneo.jpg');
     $fromMedia->getKey()->willReturn('key');
     $mountManager->getFilesystem(FileStorage::CATALOG_STORAGE_ALIAS)->willReturn($fileSystem);
     $fileFetcher->fetch($fileSystem, 'key')->willReturn($rawFile);
     $fileStorer->store($rawFile, FileStorage::CATALOG_STORAGE_ALIAS, false)->willReturn($fileInfo);
     $product->getValue('fromAttributeCode', $fromLocale, $fromScope)->willReturn($fromProductValue);
     $product->getValue('toAttributeCode', $toLocale, $toScope)->willReturn(null);
     $builder->addProductValue($product, $toAttribute, $toLocale, $toScope)->willReturn($toProductValue);
     $toProductValue->getMedia()->willReturn($toMedia);
     $toProductValue->setMedia($fileInfo)->shouldBeCalled();
     $this->copyAttributeData($product, $product, $fromAttribute, $toAttribute, ['from_locale' => $fromLocale, 'to_locale' => $toLocale, 'from_scope' => $fromScope, 'to_scope' => $toScope]);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:23,代码来源:MediaAttributeCopierSpec.php


注:本文中的Pim\Bundle\CatalogBundle\Model\ProductValueInterface::getMedia方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。