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


PHP ProductValueInterface::getMedia方法代码示例

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


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

示例1: use

 function it_allows_to_get_errors_if_the_copy_went_wrong($mediaFetcher, $filesystemProvider, $fileExporterPath, FileInfoInterface $fileInfo, FileInfoInterface $fileInfo2, ArrayCollection $productValuesCollection, \ArrayIterator $valuesIterator, ProductValueInterface $productValue, ProductValueInterface $productValue2, AttributeInterface $attribute, FilesystemInterface $filesystem)
 {
     $fileInfo->getStorage()->willReturn('storageAlias');
     $fileInfo->getKey()->willReturn('a/b/c/d/product.jpg');
     $fileInfo->getOriginalFilename()->willReturn('my product.jpg');
     $fileInfo2->getStorage()->willReturn('storageAlias');
     $fileInfo2->getKey()->willReturn('wrong-path.jpg');
     $fileInfo2->getOriginalFilename()->willReturn('my-second-media.jpg');
     $productValue->getAttribute()->willReturn($attribute);
     $productValue->getMedia()->willReturn($fileInfo);
     $productValue->getLocale()->willReturn('en_US');
     $productValue->getScope()->willReturn(null);
     $productValue2->getAttribute()->willReturn($attribute);
     $productValue2->getMedia()->willReturn($fileInfo2);
     $productValue2->getLocale()->willReturn('fr_FR');
     $productValue2->getScope()->willReturn('ecommerce');
     $attribute->getAttributeType()->willReturn('pim_catalog_image');
     $attribute->getCode()->willReturn('my_picture');
     $productValuesCollection->getIterator()->willReturn($valuesIterator);
     $valuesIterator->rewind()->shouldBeCalled();
     $valuesCount = 2;
     $valuesIterator->valid()->will(function () use(&$valuesCount) {
         return $valuesCount-- > 0;
     });
     $valuesIterator->next()->shouldBeCalled();
     $valuesIterator->current()->will(new ReturnPromise([$productValue, $productValue2]));
     $filesystemProvider->getFilesystem('storageAlias')->willReturn($filesystem);
     $mediaFetcher->fetch($filesystem, 'a/b/c/d/product.jpg', ['filePath' => $this->directory . 'files/the_sku/my_picture/en_US/', 'filename' => 'my product.jpg'])->willThrow(new FileTransferException());
     $fileExporterPath->generate(['locale' => 'en_US', 'scope' => null], ['identifier' => 'the_sku', 'code' => 'my_picture'])->willReturn('files/the_sku/my_picture/en_US/');
     $mediaFetcher->fetch($filesystem, 'wrong-path.jpg', ['filePath' => $this->directory . 'files/the_sku/my_picture/fr_FR/ecommerce/', 'filename' => 'my-second-media.jpg'])->willThrow(new \LogicException('Something went wrong.'));
     $fileExporterPath->generate(['locale' => 'fr_FR', 'scope' => 'ecommerce'], ['identifier' => 'the_sku', 'code' => 'my_picture'])->willReturn('files/the_sku/my_picture/fr_FR/ecommerce/');
     $this->fetchAll($productValuesCollection, $this->directory, 'the_sku');
     $this->getErrors()->shouldBeEqualTo([['message' => 'The media has not been found or is not currently available', 'media' => ['from' => 'a/b/c/d/product.jpg', 'to' => ['filePath' => $this->directory . 'files/the_sku/my_picture/en_US/', 'filename' => 'my product.jpg'], 'storage' => 'storageAlias']], ['message' => 'The media has not been copied. Something went wrong.', 'media' => ['from' => 'wrong-path.jpg', 'to' => ['filePath' => $this->directory . 'files/the_sku/my_picture/fr_FR/ecommerce/', 'filename' => 'my-second-media.jpg'], 'storage' => 'storageAlias']]]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:34,代码来源:BulkMediaFetcherSpec.php

示例2: ArrayCollection

 function it_returns_flat_data_with_media($channelManager, Filesystem $filesystem, ChannelInterface $channel, LocaleInterface $locale, ProductInterface $product, FileInfoInterface $media1, FileInfoInterface $media2, ProductValueInterface $value1, ProductValueInterface $value2, AttributeInterface $attribute, ProductValueInterface $identifierValue, AttributeInterface $identifierAttribute, $serializer, $productBuilder)
 {
     $localeCodes = ['en_US'];
     $channel->getLocales()->willReturn(new ArrayCollection([$locale]));
     $channel->getLocaleCodes()->willReturn($localeCodes);
     $productBuilder->addMissingProductValues($product, [$channel], [$locale])->shouldBeCalled();
     $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' => $localeCodes, 'decimal_separator' => '.', 'date_format' => 'yyyy-MM-dd'])->willReturn(['normalized_product']);
     $channelManager->getChannelByCode('foobar')->willReturn($channel);
     $this->setChannel('foobar');
     $this->process($product)->shouldReturn(['media' => [['normalized_media1'], ['normalized_media2']], 'product' => ['normalized_product']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:27,代码来源:ProductToFlatArrayProcessorSpec.php

示例3: 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:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:MediaCompleteChecker.php

示例4:

 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:alexisfroger,项目名称:pim-community-dev,代码行数:12,代码来源:MediaExporterPathGeneratorSpec.php

示例5:

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

示例6: 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:alexisfroger,项目名称:pim-community-dev,代码行数:13,代码来源:MediaCompleteCheckerSpec.php

示例7: 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() === '' || $media->__toString() === null) {
         $this->context->buildViolation($constraint->messageComplete)->addViolation();
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:13,代码来源:ProductValueCompleteValidator.php

示例8:

 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, FileInfoInterface $fromMedia, FileInfoInterface $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:abdeldayem,项目名称:pim-community-dev,代码行数:23,代码来源:MediaAttributeCopierSpec.php

示例9: 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:alexisfroger,项目名称:pim-community-dev,代码行数:11,代码来源:ProductValueCompleteValidatorSpec.php


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