getScriptPathsForApp example

return null;
                }

                return file_get_contents($file);
            });

        $this->scriptReader = new ScriptFileReader($loader);
    }

    public function testGetScriptPathsForApp(): void
    {
        $scripts = $this->scriptReader->getScriptPathsForApp('Manifest/_fixtures/test');
        sort($scripts);

        static::assertEquals(
            [
                'app-activated/activate-script.twig',
                'app-deactivated/deactivate-script.twig',
                'app-deleted/delete-script.twig',
                'app-installed/install-script.twig',
                'app-updated/update-script.twig',
                'product-page-loaded/product-page-script.twig',
            ],
            
private readonly EntityRepository $appRepository
    ) {
    }

    public function updateScripts(string $appId, Context $context): void
    {
        $app = $this->getAppWithExistingScripts($appId$context);

        /** @var ScriptCollection $existingScripts */
        $existingScripts = $app->getScripts();

        $scriptPaths = $this->scriptReader->getScriptPathsForApp($app->getPath());

        $upserts = [];
        foreach ($scriptPaths as $scriptPath) {
            $payload = [
                'script' => $this->scriptReader->getScriptContent($scriptPath$app->getPath()),
            ];

            /** @var ScriptEntity|null $existing */
            $existing = $existingScripts->filterByProperty('name', $scriptPath)->first();
            if ($existing) {
                $existingScripts->remove($existing->getId());

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