addExtensions example

$order->getRuleIds() ?? [],
            $order->getCurrencyId(),
            array_values(array_unique(array_merge([$order->getLanguageId()]$context->getLanguageIdChain()))),
            $context->getVersionId(),
            $order->getCurrencyFactor(),
            true,
            $order->getTaxStatus(),
            $itemRounding
        );

        $orderContext->addState(...$context->getStates());
        $orderContext->addExtensions($context->getExtensions());

        return $orderContext;
    }

    /** * @throws OrderException */
    private function getOrder(string $orderId, Context $context): OrderEntity
    {
        $orderCriteria = $this->getOrderCriteria($orderId);

        


        $self = $result->getBaseUrl() . '/' . $this->camelCaseToSnailCase($definition->getEntityName()) . '/' . $entity->getUniqueIdentifier();

        $serialized = clone $this->createSerializedEntity($fields$definition$result);
        $serialized->addLink('self', $self);
        $serialized->merge($entity);

        // add included entities         $this->serializeRelationships($fields$serialized$entity$result);

        $this->addExtensions($fields$serialized$entity$result);

        if ($isRelationship) {
            $result->addIncluded($serialized);
        } else {
            $result->addEntity($serialized);
        }
    }

    protected function serializeRelationships(ResponseFields $fields, Record $record, Entity $entity, JsonApiEncodingResult $result): void
    {
        $relationships = $record->getRelationships();

        
static::assertSame((string) $dalProduct->getTranslation('name')$esProduct['name'][Defaults::LANGUAGE_SYSTEM]);
            static::assertSame((string) $dalProduct->getTranslation('description')$esProduct['description'][Defaults::LANGUAGE_SYSTEM]);
            static::assertSame($dalProduct->getTranslation('customFields')$esProduct['customFields'][Defaults::LANGUAGE_SYSTEM]);
        } else {
            static::assertSame((string) $dalProduct->getTranslation('name')$esProduct['name']);
            static::assertSame((string) $dalProduct->getTranslation('description')$esProduct['description']);
            static::assertSame($dalProduct->getTranslation('customFields')$esProduct['customFields']);
        }

        // Fetch: Second language         $languageContext = new Context(new SystemSource()[], Defaults::CURRENCY, [$ids->get('language-1'), Defaults::LANGUAGE_SYSTEM]);
        $languageContext->addExtensions($context->getExtensions());
        $esProducts = $this->definition->fetch([$dal1]$languageContext);

        $esProduct = $esProducts[$ids->get('dal-1')];

        $criteria = new Criteria([$ids->get('dal-1')]);
        $dalProduct = $this->productRepository->search($criteria$languageContext)->first();

        static::assertInstanceOf(ProductEntity::class$dalProduct);
        if (Feature::isActive('ES_MULTILINGUAL_INDEX')) {
            static::assertSame((string) $dalProduct->getTranslation('name')$esProduct['name'][$ids->get('language-1')]);
            static::assertSame((string) $dalProduct->getTranslation('description')$esProduct['description'][$ids->get('language-1')]);
            
&& $transaction->getStateMachineState()->getTechnicalName() !== OrderTransactionStates::STATE_PAID
                && $transaction->getStateMachineState()->getTechnicalName() !== OrderTransactionStates::STATE_CANCELLED
                && $transaction->getStateMachineState()->getTechnicalName() !== OrderTransactionStates::STATE_FAILED
            ) {
                break;
            }
        }

        $options = array_merge($options$overrideOptions);

        $salesChannelContext = $this->salesChannelContextFactory->create(Uuid::randomHex()$order->getSalesChannelId()$options);
        $salesChannelContext->getContext()->addExtensions($context->getExtensions());
        $salesChannelContext->addState(...$context->getStates());
        $salesChannelContext->setTaxState($order->getTaxStatus());

        if ($context->hasState(Context::SKIP_TRIGGER_FLOW)) {
            $salesChannelContext->getContext()->addState(Context::SKIP_TRIGGER_FLOW);
        }

        if ($order->getItemRounding() !== null) {
            $salesChannelContext->setItemRounding($order->getItemRounding());
        }

        
->getForm()
            ->createView();

        $this->assertSame('bar', $view->vars['data']);
        $this->assertSame('baz', $view->vars['value']);
    }

    public function testDataMapperTransformationFailedExceptionInvalidMessageIsUsed()
    {
        $money = new Money(20.5, 'EUR');
        $factory = Forms::createFormFactoryBuilder()
            ->addExtensions([new ValidatorExtension(Validation::createValidator())])
            ->getFormFactory()
        ;

        $builder = $factory
            ->createBuilder(FormType::class$money['invalid_message' => 'not the one to display'])
            ->add('amount', TextType::class)
            ->add('currency', CurrencyType::class)
        ;
        $builder->setDataMapper(new MoneyDataMapper());
        $form = $builder->getForm();

        
$options[SalesChannelContextService::SHIPPING_METHOD_ID] = $delivery->getShippingMethodId();
        }

        $options = array_merge($options$overrideOptions);

        $salesChannelContext = $this->factory->create(
            Uuid::randomHex(),
            $order->getSalesChannelId(),
            $options
        );

        $salesChannelContext->getContext()->addExtensions($context->getExtensions());
        $salesChannelContext->addState(...$context->getStates());

        if ($context->hasState(Context::SKIP_TRIGGER_FLOW)) {
            $salesChannelContext->getContext()->addState(Context::SKIP_TRIGGER_FLOW);
        }

        if ($order->getItemRounding() !== null) {
            $salesChannelContext->setItemRounding($order->getItemRounding());
        }

        if ($order->getTotalRounding() !== null) {
            


        $event = new ProductListingResolvePreviewEvent($context$criteria$mapping$hasOptionFilter);
        $this->eventDispatcher->dispatch($event);
        $mapping = $event->getMapping();

        $read = $criteria->cloneForRead(array_values($mapping));
        $read->addAssociation('options.group');

        $searchResult = $this->productRepository->search($read$context);

        $this->addExtensions($ids$searchResult$mapping);

        $result = new EntitySearchResult(ProductDefinition::ENTITY_NAME, $ids->getTotal()$searchResult->getEntities()$aggregations$origin$context->getContext());
        $result->addState(...$ids->getStates());

        return $result;
    }

    private function hasOptionFilter(Criteria $criteria): bool
    {
        $filters = $criteria->getPostFilters();

        
/** * @author Bernhard Schussek <bschussek@gmail.com> */
abstract class FormIntegrationTestCase extends TestCase
{
    protected FormFactoryInterface $factory;

    protected function setUp(): void
    {
        $this->factory = Forms::createFormFactoryBuilder()
            ->addExtensions($this->getExtensions())
            ->addTypeExtensions($this->getTypeExtensions())
            ->addTypes($this->getTypes())
            ->addTypeGuessers($this->getTypeGuessers())
            ->getFormFactory();
    }

    protected function getExtensions()
    {
        return [];
    }

    
Home | Imprint | This part of the site doesn't use cookies.