getModules example

/** * @internal */
class AdminTest extends TestCase
{
    public function testFromXml(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/test/manifest.xml');

        static::assertNotNull($manifest->getAdmin());
        static::assertCount(2, $manifest->getAdmin()->getActionButtons());
        static::assertCount(2, $manifest->getAdmin()->getModules());

        $firstActionButton = $manifest->getAdmin()->getActionButtons()[0];
        static::assertEquals('viewOrder', $firstActionButton->getAction());
        static::assertEquals('order', $firstActionButton->getEntity());
        static::assertEquals('detail', $firstActionButton->getView());
        static::assertEquals('https://swag-test.com/your-order', $firstActionButton->getUrl());

        static::assertEquals([
            'en-GB' => 'View Order',
            'de-DE' => 'Zeige Bestellung',
        ]$firstActionButton->getLabel());

        
'position' => 1,
            ],
            [
                'source' => 'http://testApp-module-2',
                'label' => [
                    'de-DE' => 'test',
                    'en-GB' => 'test',
                ],
                'parent' => null,
                'position' => 1,
            ],
        ]$app->getModules());
    }

    public function testMigrationAddsDefaultValuesModulesInMultipleApps(): void
    {
        $firstAppId = $this->insertAppWithModule('testApp1', [
            [
                'source' => 'http://testApp1-module',
                'label' => [
                    'de-DE' => 'test',
                    'en-GB' => 'test',
                ],
            ],
return $appModules;
    }

    /** * @return list<Module> */
    private function formatModules(AppEntity $app, Context $context): array
    {
        $modules = [];

        foreach ($app->getModules() as $module) {
            $module['source'] = $this->getModuleUrlWithQuery($app$module$context);
            $modules[] = $module;
        }

        return $modules;
    }

    /** * @return array{source: string}|null */
    private function formatMainModule(AppEntity $app, Context $context): ?array
    {
$criteria = new Criteria();
        $criteria->addAssociation('webhooks');
        /** @var AppCollection $apps */
        $apps = $this->appRepository->search($criteria$this->context)->getEntities();

        static::assertCount(1, $apps);

        /** @var AppEntity $appEntity */
        $appEntity = $apps->first();
        static::assertNotNull($appEntity);
        static::assertCount(0, $appEntity->getModules());

        $webhookCollection = $appEntity->getWebhooks();
        static::assertInstanceOf(WebhookCollection::class$webhookCollection);
        static::assertCount(0, $webhookCollection);
    }

    public function testInstallWithSystemDefaultLanguageNotProvidedByApp(): void
    {
        $this->setNewSystemLanguage('nl-NL');
        $this->setNewSystemLanguage('en-GB');
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../Manifest/_fixtures/test/manifest.xml');

        
'modules' => [],
        ];

        if ($manifest->getAdmin() !== null) {
            if ($manifest->getAdmin()->getMainModule() !== null) {
                $payload['mainModule'] = [
                    'source' => $manifest->getAdmin()->getMainModule()->getSource(),
                ];
            }

            $payload['modules'] = array_reduce(
                $manifest->getAdmin()->getModules(),
                static function Darray $modules, Module $module) use ($defaultLocale) {
                    $modules[] = $module->toArray($defaultLocale);

                    return $modules;
                },
                []
            );
        }

        $this->appRepository->update([$payload]$context);
    }

    

class AdminTest extends TestCase
{
    public function testFromXml(): void
    {
        $manifest = Manifest::createFromXmlFile(__DIR__ . '/../_fixtures/test-manifest.xml');

        static::assertNotNull($manifest->getAdmin());
        static::assertCount(2, $manifest->getAdmin()->getActionButtons());
        static::assertCount(2, $manifest->getAdmin()->getModules());

        $firstActionButton = $manifest->getAdmin()->getActionButtons()[0];
        static::assertEquals('viewOrder', $firstActionButton->getAction());
        static::assertEquals('order', $firstActionButton->getEntity());
        static::assertEquals('detail', $firstActionButton->getView());
        static::assertEquals('https://swag-test.com/your-order', $firstActionButton->getUrl());
        static::assertEquals([
            'en-GB' => 'View Order',
            'de-DE' => 'Zeige Bestellung',
        ]$firstActionButton->getLabel());

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