AppInstalledEvent example

throw AppException::alreadyInstalled($manifest->getMetadata()->getName());
        }

        $defaultLocale = $this->getDefaultLocale($context);
        $metadata = $manifest->getMetadata()->toArray($defaultLocale);
        $appId = Uuid::randomHex();
        $roleId = Uuid::randomHex();
        $metadata = $this->enrichInstallMetadata($manifest$metadata$roleId);

        $app = $this->updateApp($manifest$metadata$appId$roleId$defaultLocale$context, true);

        $event = new AppInstalledEvent($app$manifest$context);
        $this->eventDispatcher->dispatch($event);
        $this->scriptExecutor->execute(new AppInstalledHook($event));

        if ($activate) {
            $this->appStateService->activateApp($appId$context);
        }

        $this->updateAclRole($app->getName()$context);
    }

    /** * @param array{id: string, roleId: string} $app */
return 'Reinstall all apps anew for the new URL, so app communication on the old URLs installation keeps working like before. App-data from the old installation will not be available in this installation.';
    }

    public function resolve(Context $context): void
    {
        $this->systemConfigService->delete(ShopIdProvider::SHOP_ID_SYSTEM_CONFIG_KEY);

        $this->forEachInstalledApp($contextfunction DManifest $manifest, AppEntity $app, Context $context): void {
            $this->reRegisterApp($manifest$app$context);
            $this->eventDispatcher->dispatch(
                new AppInstalledEvent($app$manifest$context)
            );
        });
    }
}
static::assertEquals([
            'appVersion' => '1.0.0',
        ]$event->getWebhookPayload());
    }

    public function testIsAllowed(): void
    {
        $appId = Uuid::randomHex();
        $app = (new AppEntity())
            ->assign(['id' => $appId]);
        $context = Context::createDefaultContext();
        $event = new AppInstalledEvent(
            $app,
            Manifest::createFromXmlFile(__DIR__ . '/../Manifest/_fixtures/test/manifest.xml'),
            $context
        );

        static::assertTrue($event->isAllowed($appIdnew AclPrivilegeCollection([])));
        static::assertFalse($event->isAllowed(Uuid::randomHex()new AclPrivilegeCollection([])));
    }
}
use Shopware\Core\Framework\Webhook\AclPrivilegeCollection;

/** * @internal */
class AppInstalledEventTest extends TestCase
{
    public function testGetter(): void
    {
        $app = new AppEntity();
        $context = Context::createDefaultContext();
        $event = new AppInstalledEvent(
            $app,
            Manifest::createFromXmlFile(__DIR__ . '/../Manifest/_fixtures/test/manifest.xml'),
            $context
        );

        static::assertEquals($app$event->getApp());
        static::assertInstanceOf(Manifest::class$event->getManifest());
        static::assertEquals($context$event->getContext());
        static::assertEquals(AppInstalledEvent::NAME, $event->getName());
        static::assertEquals([
            'appVersion' => '1.0.0',
        ],
Home | Imprint | This part of the site doesn't use cookies.