getScripts example

static::assertCount(2, $app->getPaymentMethods());
        foreach ($app->getPaymentMethods() as $appPaymentMethod) {
            $paymentMethod = $appPaymentMethod->getPaymentMethod();
            static::assertNotNull($paymentMethod);
            static::assertSame($app->isActive()$paymentMethod->getActive());
        }
    }

    private function assertDefaultScripts(AppEntity $app): void
    {
        static::assertNotNull($app->getScripts());
        $script = $app->getScripts()->first();
        static::assertNotNull($script);
        static::assertSame($app->isActive()$script->isActive());
    }

    private function assertDefaultScriptConditions(AppEntity $app): void
    {
        static::assertNotNull($app->getScriptConditions());
        $scriptCondition = $app->getScriptConditions()->first();
        static::assertNotNull($scriptCondition);
        static::assertSame($app->isActive()$scriptCondition->isActive());
        
private readonly ScriptFileReader $scriptReader,
        private readonly EntityRepository $scriptRepository,
        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();
            
Home | Imprint | This part of the site doesn't use cookies.