getEntities example

$adminUiEntity->setAttribute('icon', 'triangle');
        $adminUiEntity->setAttribute('color', 'red');
        $adminUiEntity->setAttribute('position', '1');
        $adminUiEntity->setAttribute('navigation-parent', 'test');

        $adminUi->appendChild(
            $adminUiEntity
        );

        $adminUi = AdminUi::fromXml($adminUi);

        $adminUiEntities = $adminUi->getEntities();
        static::assertInstanceOf(AdminUi::class$adminUi);
        static::assertIsArray($adminUiEntities);
        static::assertInstanceOf(AdminUiEntity::class, \array_pop($adminUiEntities));
    }
}


    /** * @return array<string, mixed> */
    public function toStorage(): array
    {
        if ($this->entities === null) {
            return [];
        }

        return json_decode(json_encode($this->entities->getEntities(), \JSON_THROW_ON_ERROR), true, 512, \JSON_THROW_ON_ERROR);
    }
}
$aggregation = $listing->getAggregations()->get($expected['aggregation']);

        if ($expected['instanceOf'] === null) {
            static::assertNull($aggregation);
        } else {
            static::assertInstanceOf($expected['instanceOf']$aggregation);
        }

        if ($expected['aggregation'] === 'properties' && isset($expected['propertyWhitelistIds'])) {
            static::assertInstanceOf(EntityResult::class$aggregation);
            /** @var PropertyGroupCollection $properties */
            $properties = $aggregation->getEntities();

            static::assertSame($expected['propertyWhitelistIds']$properties->getIds());
        }
    }

    /** * @return list<array{0: IdsCollection, 1: array<string, mixed>, 2: Request, 3: array<string, mixed>}> */
    public static function filterAggregationsWithProducts(): array
    {
        $ids = new TestDataCollection();

        
private function getExistingTaxProviders(string $appId, Context $context): TaxProviderCollection
    {
        $criteria = new Criteria();

        $criteria->addFilter(new MultiFilter(MultiFilter::CONNECTION_OR, [
            new EqualsFilter('appId', $appId),
        ]));

        return $context->scope(Context::SYSTEM_SCOPE, function DContext $context) use ($criteria) {
            /** @var TaxProviderCollection $taxProviders */
            $taxProviders = $this->taxProviderRepository->search($criteria$context)->getEntities();

            return $taxProviders;
        });
    }
}

    /** * @var AccountNewsletterRecipientResult */
    protected $object;

    /** * @param EntitySearchResult<NewsletterRecipientCollection> $newsletterRecipients */
    public function __construct(EntitySearchResult $newsletterRecipients)
    {
        $firstNewsletterRecipient = $newsletterRecipients->getEntities()->first();
        if ($firstNewsletterRecipient) {
            $accNlRecipientResult = new AccountNewsletterRecipientResult($firstNewsletterRecipient->getStatus());
            parent::__construct($accNlRecipientResult);

            return;
        }
        $accNlRecipientResult = new AccountNewsletterRecipientResult();
        parent::__construct($accNlRecipientResult);
    }

    public function getAccountNewsletterRecipient(): AccountNewsletterRecipientResult
    {
'link' => 'https://shopware.com',
                ],
                'toOne' => [
                    'name' => 'test',
                ],
            ],
        ], Context::createDefaultContext());

        $criteria = new Criteria([$productId]);
        $criteria->addAssociation('toOne.toOne');

        $product = $this->productRepository->search($criteria, Context::createDefaultContext())->getEntities()->get($productId);
        static::assertNotNull($product);
        static::assertTrue($product->hasExtension('toOne'));

        $extension = $product->getExtension('toOne');
        static::assertInstanceOf(ArrayEntity::class$extension);
        static::assertInstanceOf(ProductEntity::class$extension->get('toOne'));
    }

    public function testICanReadNestedAssociationsFromToManyExtensions(): void
    {
        $productId = Uuid::randomHex();

        

        $this->appLifecycle->install(
            Manifest::createFromXmlFile(__DIR__ . '/_fixtures/apps/cmsAwareAndAdminUiApp/manifest.xml'),
            true,
            $this->context
        );

        /** @var AppCollection $apps */
        $apps = $this->appRepository->search(
            new Criteria(),
            $this->context
        )->getEntities();
        static::assertCount(1, $apps);

        $appEntity = $apps->first();
        static::assertNotNull($appEntity);
        static::assertEquals(self::APP_NAME, $appEntity->getName());

        return $appEntity;
    }

    private function uninstallApp(AppEntity $appEntity): void
    {
        

            }
        }

        if (\count($dataUpdate) > 0) {
            $this->aclRoleRepository->update($dataUpdate$context);
        }
    }

    private function updateCustomEntities(string $appId, string $appPath, Manifest $manifest): void
    {
        $entities = $this->customEntityLifecycleService->updateApp($appId$appPath)?->getEntities()?->getEntities();

        foreach ($entities ?? [] as $entity) {
            $manifest->addPermissions([
                $entity->getName() => [
                    AclRoleDefinition::PRIVILEGE_READ,
                    AclRoleDefinition::PRIVILEGE_CREATE,
                    AclRoleDefinition::PRIVILEGE_UPDATE,
                    AclRoleDefinition::PRIVILEGE_DELETE,
                ],
            ]);
        }
    }
if (Feature::isActive('v6.6.0.0')) {
            $context = $msg->getContext();
        } else {
            $context = $msg->readContext();
        }

        $criteria = new Criteria();
        $criteria->addAssociation('mediaFolder.configuration.mediaThumbnailSizes');
        $criteria->addFilter(new EqualsAnyFilter('media.id', $msg->getMediaIds()));

        /** @var MediaCollection $entities */
        $entities = $this->mediaRepository->search($criteria$context)->getEntities();

        if ($msg instanceof UpdateThumbnailsMessage) {
            foreach ($entities as $media) {
                $this->thumbnailService->updateThumbnails($media$context$msg->isStrict());
            }
        } else {
            $this->thumbnailService->generate($entities$context);
        }
    }
}
'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => 50, 'net' => 25, 'linked' => false]],
        ];

        $browser->request('POST', '/api/product', [][][]json_encode($data, \JSON_THROW_ON_ERROR));

        $browser->request('POST', '/api/_action/version/' . Defaults::LIVE_VERSION . '/product/' . $id);

        $repo = $this->getContainer()->get(ProductDefinition::ENTITY_NAME . '.repository');
        $criteria = new Criteria([$id]);
        $criteria->addFilter(new EqualsFilter('versionId', Defaults::LIVE_VERSION));

        static::assertNotNull($repo->search($criteria, Context::createDefaultContext())->getEntities()->first());

        $response = $browser->getResponse();

        static::assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $response->getStatusCode()(string) $response->getContent());

        $content = json_decode((string) $response->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertSame(ApiException::deleteLiveVersion()->getErrorCode()$content['errors'][0]['code']);
    }

    public function testDeleteWithoutPermission(): void
    {
return;
        }

        $source = $context->getSource();
        $salesChannelId = null;

        if ($source instanceof SalesChannelApiSource) {
            $salesChannelId = $source->getSalesChannelId();
        }

        /** @var CustomerCollection $customers */
        $customers = $this->customerRepository->search(new Criteria($ids)$context)->getEntities();

        $event->addSuccess(function D) use ($customers$context$salesChannelId): void {
            foreach ($customers->getElements() as $customer) {
                $salesChannelContext = $this->salesChannelContextService->get(
                    new SalesChannelContextServiceParameters(
                        $salesChannelId ?? $customer->getSalesChannelId(),
                        Random::getAlphanumericString(32),
                        $customer->getLanguageId(),
                        null,
                        null,
                        $context,
                    )
return [
            MediaEvents::MEDIA_LOADED_EVENT => [
                ['unserialize', 10],
                ['addUrls'],
            ],
        ];
    }

    public function addUrls(EntityLoadedEvent $event): void
    {
        /** @var MediaEntity $media */
        foreach ($event->getEntities() as $media) {
            if (!$media->hasFile() || $media->isPrivate()) {
                continue;
            }

            $media->setUrl($this->urlGenerator->getAbsoluteMediaUrl($media));

            foreach ($media->getThumbnails() ?? [] as $thumbnail) {
                $this->addThumbnailUrl($thumbnail$media);
            }
        }
    }

    
$affected = array_values($event->getIds(MediaDefinition::ENTITY_NAME));
        if (!empty($affected)) {
            $this->handleMediaDeletion($affected$event->getContext());
        }
    }

    /** * @param list<string> $affected */
    private function handleMediaDeletion(array $affected, Context $context): void
    {
        $media = $context->scope(Context::SYSTEM_SCOPE, fn (Context $context): MediaCollection => $this->mediaRepository->search(new Criteria($affected)$context)->getEntities());

        $privatePaths = [];
        $publicPaths = [];
        $thumbnails = [];

        foreach ($media as $mediaEntity) {
            if (!$mediaEntity->hasFile()) {
                continue;
            }

            if ($mediaEntity->isPrivate()) {
                
return new NoContentResponse();
    }

    private function getNewsletterRecipient(string $identifier, string $value, Context $context): NewsletterRecipientEntity
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter($identifier$value));
        $criteria->addAssociation('salutation');
        $criteria->setLimit(1);

        /** @var NewsletterRecipientEntity|null $newsletterRecipient */
        $newsletterRecipient = $this->newsletterRecipientRepository->search($criteria$context)->getEntities()->first();

        if (!$newsletterRecipient) {
            throw NewsletterException::recipientNotFound($identifier$value);
        }

        return $newsletterRecipient;
    }

    private function getBeforeConfirmSubscribeValidation(string $emHash): DataValidationDefinition
    {
        $definition = new DataValidationDefinition('newsletter_recipient.opt_in_before');
        
$criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT));

        if ($activeOnly) {
            $criteria->addFilter(new EqualsFilter('active', 1));
        }

        $criteria->addAssociation('themes');

        /** @var SalesChannelCollection $result */
        $result = $this->salesChannelRepository->search($criteria$context)->getEntities();

        $list = [];

        foreach ($result->getElements() as $salesChannel) {
            /** @var ThemeCollection|null $themes */
            $themes = $salesChannel->getExtensionOfType('themes', ThemeCollection::class);
            if (!$themes || !$theme = $themes->first()) {
                continue;
            }

            $list[$salesChannel->getId()] = $theme->getId();
        }
Home | Imprint | This part of the site doesn't use cookies.