getDependentThemes example



    private function changeThemeActive(ThemeDependencies $themeData, bool $active, Context $context): void
    {
        if ($themeData->getId() === null) {
            return;
        }

        $data = [];
        $data[] = ['id' => $themeData->getId(), 'active' => $active];

        foreach ($themeData->getDependentThemes() as $id) {
            $data[] = ['id' => $id, 'active' => $active];
        }

        $this->themeRepository->upsert($data$context);
    }

    private function recompileThemesIfNecessary(
        StorefrontPluginConfiguration $config,
        Context $context,
        StorefrontPluginConfigurationCollection $configurationCollection,
        ?string $themeId
    ):
$criteria = new Criteria();
        $criteria->addAssociation('dependentThemes');
        $criteria->addFilter(new EqualsFilter('technicalName', $technicalName));

        /** @var ThemeEntity|null $theme */
        $theme = $this->themeRepository->search($criteria$context)->first();

        if ($theme === null) {
            return;
        }

        $dependentThemes = $theme->getDependentThemes() ?? new ThemeCollection();
        $ids = [...array_values($dependentThemes->getIds()), ...[$theme->getId()]];

        $this->removeOldMedia($technicalName$context);
        $this->themeRepository->delete(array_map(fn (string $id) => ['id' => $id]$ids)$context);
    }

    private function getThemeByTechnicalName(string $technicalName, Context $context): ?ThemeEntity
    {
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('technicalName', $technicalName));
        $criteria->addAssociation('previewMedia');

        


    public function testItRemovesAChildThemeCorrectly(): void
    {
        $bundle = $this->getThemeConfig();

        $this->themeLifecycleService->refreshTheme($bundle$this->context);

        $themeEntity = $this->getTheme($bundle, true);
        $childId = Uuid::randomHex();

        static::assertInstanceOf(ThemeCollection::class$themeEntity->getDependentThemes());
        // check if we have no dependent Themes         static::assertEquals(0, $themeEntity->getDependentThemes()->count());

        // clone theme and make it child         $this->themeRepository->clone($themeEntity->getId()$this->context, $childIdnew CloneBehavior([
            'technicalName' => null,
            'name' => 'Cloned theme',
            'parentThemeId' => $themeEntity->getId(),
        ]));

        // refresh theme to get child
Home | Imprint | This part of the site doesn't use cookies.