removeOldMedia example

/** @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');

        $theme = $this->themeRepository->search($criteria$context)->first();

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