本文整理汇总了PHP中Pim\Bundle\CatalogBundle\Manager\ChannelManager::getChannelByCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ChannelManager::getChannelByCode方法的具体用法?PHP ChannelManager::getChannelByCode怎么用?PHP ChannelManager::getChannelByCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pim\Bundle\CatalogBundle\Manager\ChannelManager
的用法示例。
在下文中一共展示了ChannelManager::getChannelByCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPimLocales
/**
* Get all Pim locales for the given channel.
*
* @param string $channel
*
* @return array
*/
protected function getPimLocales($channel)
{
if (!$this->pimLocales) {
$this->pimLocales = $this->channelManager->getChannelByCode($channel)->getLocales();
}
return $this->pimLocales;
}
示例2: getQuery
/**
* {@inheritdoc}
*/
public function getQuery()
{
if (!$this->query) {
$channel = $this->channelManager->getChannelByCode($this->channel);
$this->query = $this->repository->findOrderedCategories($channel->getCategory())->getQuery();
}
return $this->query;
}
示例3: addFieldFilter
/**
* {@inheritdoc}
*/
public function addFieldFilter($field, $operator, $value, $locale = null, $scope = null, $options = [])
{
$this->checkValue($field, $value, $locale, $scope);
$channel = $this->channelManager->getChannelByCode($scope);
foreach ($channel->getLocales() as $locale) {
$field = sprintf("%s.%s.%s-%s", ProductQueryUtility::NORMALIZED_FIELD, 'completenesses', $scope, $locale);
$value = intval($value);
$this->qb->addOr($this->getExpr($value, $field, $operator));
}
return $this;
}
示例4: validate
/**
* Checks if the passed value is valid.
*
* @param AbstractProductProcessor $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*
* @api
*/
public function validate($value, Constraint $constraint)
{
if (!$value instanceof AbstractProductProcessor) {
return null;
}
if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) {
foreach ($channel->getLocales() as $locale) {
if ($locale->getCode() === $value->getDefaultLocale()) {
return null;
}
}
}
$this->context->addViolationAt('defaultLocale', $constraint->message, ['defaultLocale']);
}
示例5: validate
/**
* Checks if the passed value is valid.
*
* @param mixed $value The value that should be validated
* @param Constraint $constraint The constraint for the validation
*
* @api
* @return null
*/
public function validate($value, Constraint $constraint)
{
if (!$value instanceof AbstractProductProcessor) {
return null;
}
if ($channel = $this->channelManager->getChannelByCode($value->getChannel())) {
foreach ($channel->getCurrencies() as $currency) {
if ($currency->getCode() === $value->getCurrency()) {
return null;
}
}
}
$this->context->addViolationAt('currency', $constraint->message, ['currency']);
}
示例6: read
/**
* {@inheritdoc}
*/
public function read()
{
$this->documentManager->clear();
if (!$this->executed) {
$this->executed = true;
if (!is_object($this->channel)) {
$this->channel = $this->channelManager->getChannelByCode($this->channel);
}
if ($this->missingCompleteness) {
$this->completenessManager->generateMissingForChannel($this->channel);
}
$this->query = $this->repository->buildByChannelAndCompleteness($this->channel)->getQuery();
$this->products = $this->getQuery()->execute();
// MongoDB Cursor are not positioned on first element (whereas ArrayIterator is)
// as long as getNext() hasn't be called
$this->products->getNext();
}
$result = $this->products->current();
if ($result) {
$this->metricConverter->convert($result, $this->channel);
$this->stepExecution->incrementSummaryInfo('read');
$this->products->next();
}
return $result;
}
示例7:
function it_returns_flat_data_without_media(ChannelInterface $channel, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$product->getValues()->willReturn([]);
$serializer->normalize($product, 'flat', ['scopeCode' => 'foobar', 'localeCodes' => ''])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$this->setChannel('foobar');
$this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]);
}
示例8: read
/**
* {@inheritdoc}
*/
public function read()
{
if (!$this->query) {
$code = $this->channel;
if (!is_object($this->channel)) {
$this->channel = $this->channelManager->getChannelByCode($this->channel);
}
if (!$this->channel) {
throw new \InvalidArgumentException(sprintf('Could not find the channel "%s"', $code));
}
$this->completenessManager->generateMissingForChannel($this->channel);
$this->query = $this->repository->buildByChannelAndCompleteness($this->channel)->getQuery();
}
$product = parent::read();
if ($product) {
$this->metricConverter->convert($product, $this->channel);
}
return $product;
}
示例9:
function it_throws_an_exception_if_no_file_is_found(ChannelInterface $channel, ProductInterface $product, ChannelManager $channelManager, Serializer $serializer, ProductValueInterface $productValue, AttributeInterface $attribute)
{
$product->getValues()->willReturn([$productValue]);
$productValue->getAttribute()->willReturn($attribute);
$attribute->getAttributeType()->willReturn('pim_catalog_image');
$product->getIdentifier()->willReturn($productValue);
$productValue->getData()->willReturn('data');
$this->setChannel('foobar');
$channelManager->getChannelByCode('foobar')->willReturn($channel);
$serializer->normalize(['data'], 'flat', ['field_name' => 'media', 'prepare_copy' => true])->willThrow('Symfony\\Component\\HttpFoundation\\File\\Exception\\FileNotFoundException');
$this->shouldThrow('Akeneo\\Bundle\\BatchBundle\\Item\\InvalidItemException')->during('process', [$product]);
}
示例10: ArrayCollection
function it_returns_flat_data_without_media($productBuilder, ChannelInterface $channel, LocaleInterface $locale, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$localeCodes = ['en_US'];
$channel->getLocales()->willReturn(new ArrayCollection([$locale]));
$channel->getLocaleCodes()->willReturn($localeCodes);
$productBuilder->addMissingProductValues($product, [$channel], [$locale])->shouldBeCalled();
$product->getValues()->willReturn([]);
$this->setDecimalSeparator(',');
$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' => [], 'product' => ['normalized_product']]);
}
示例11: read
/**
* @{inheritdoc}
*/
public function read()
{
$product = null;
if ($this->products->valid()) {
$product = $this->products->current();
$this->stepExecution->incrementSummaryInfo('read');
$this->products->next();
}
if (null !== $product) {
$channel = $this->channelManager->getChannelByCode($this->channel);
$this->metricConverter->convert($product, $channel);
}
return $product;
}
示例12: getIds
/**
* Get ids of products which are completes and in channel
*
* @return array
*/
protected function getIds()
{
if (!is_object($this->channel)) {
$this->channel = $this->channelManager->getChannelByCode($this->channel);
}
if ($this->missingCompleteness) {
$this->completenessManager->generateMissingForChannel($this->channel);
}
$this->query = $this->DnDBuildByChannelAndCompleteness($this->channel, $this->getIsComplete());
$rootAlias = current($this->query->getRootAliases());
$rootIdExpr = sprintf('%s.id', $rootAlias);
$from = current($this->query->getDQLPart('from'));
$this->query->select($rootIdExpr)->resetDQLPart('from')->from($from->getFrom(), $from->getAlias(), $rootIdExpr)->andWhere($this->query->expr()->orX($this->query->expr()->gte($from->getAlias() . '.updated', ':updated')))->setParameter('updated', $this->getDateFilter())->setParameter('enabled', $this->getIsEnabled())->groupBy($rootIdExpr);
$results = $this->query->getQuery()->getArrayResult();
return array_keys($results);
}
示例13: getIds
/**
* Get ids of products which are completes and in channel
*
* @return array
*/
protected function getIds()
{
if (!is_object($this->channel)) {
$this->channel = $this->channelManager->getChannelByCode($this->channel);
}
if ($this->missingCompleteness) {
$this->completenessManager->generateMissingForChannel($this->channel);
}
$this->query = $this->repository->buildByChannelAndCompleteness($this->channel);
$rootAlias = current($this->query->getRootAliases());
$rootIdExpr = sprintf('%s.id', $rootAlias);
$from = current($this->query->getDQLPart('from'));
$this->query->select($rootIdExpr)->resetDQLPart('from')->from($from->getFrom(), $from->getAlias(), $rootIdExpr)->groupBy($rootIdExpr);
$results = $this->query->getQuery()->getArrayResult();
return array_keys($results);
}
示例14:
function it_returns_flat_data_without_media($dateformatProvider, $numberFormatProvider, ChannelInterface $channel, ChannelManager $channelManager, ProductInterface $product, Serializer $serializer)
{
$dateformatProvider->getFormat('en_US')->willReturn('n/j/y');
$numberFormatProvider->getFormat('en_US')->willReturn(['decimal_separator' => '.']);
$this->configureOptions('en_US');
$product->getValues()->willReturn([]);
$serializer->normalize($product, 'flat', ['scopeCode' => 'mobile', 'localeCodes' => '', 'decimal_separator' => '.', 'date_format' => 'n/j/y'])->willReturn(['normalized_product']);
$channelManager->getChannelByCode('mobile')->willReturn($channel);
$this->setChannelCode('mobile');
$this->process($product)->shouldReturn(['media' => [], 'product' => ['normalized_product']]);
}
示例15: getLocaleCodes
/**
* Get locale codes for a channel
*
* @param string $channelCode
*
* @return array
*/
protected function getLocaleCodes($channelCode)
{
$channel = $this->channelManager->getChannelByCode($channelCode);
return $channel->getLocaleCodes();
}