findMediaIdsInImageGalleriesInOverridesTable example

return [
            UnusedMediaSearchEvent::class => 'removeUsedMedia',
        ];
    }

    public function removeUsedMedia(UnusedMediaSearchEvent $event): void
    {
        $event->markAsUsed($this->findMediaIdsInImageGalleries($event));
        $event->markAsUsed($this->findMediaIdsInImages($event));

        foreach (['category_translation', 'product_translation'] as $table) {
            $event->markAsUsed($this->findMediaIdsInImageGalleriesInOverridesTable($table$event));
            $event->markAsUsed($this->findMediaIdsInImagesInOverridesTable($table$event));
        }
    }

    /** * @return array<string> */
    private function findMediaIdsInImageGalleriesInOverridesTable(string $table, UnusedMediaSearchEvent $event): array
    {
        $sql = <<<'SQL' SELECT JSON_EXTRACT(slot_config, "$.*.sliderItems.value[*].mediaId") as mediaId FROM `$table` WHERE JSON_OVERLAPS( JSON_EXTRACT(slot_config, "$.*.sliderItems.value[*].mediaId"), JSON_ARRAY(%s) );
Home | Imprint | This part of the site doesn't use cookies.