getIcon example

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

        $metaData = $manifest->getMetadata();
        static::assertEquals('test', $metaData->getName());
        static::assertEquals('shopware AG', $metaData->getAuthor());
        static::assertEquals('(c) by shopware AG', $metaData->getCopyright());
        static::assertEquals('MIT', $metaData->getLicense());
        static::assertEquals('https://test.com/privacy', $metaData->getPrivacy());
        static::assertEquals('1.0.0', $metaData->getVersion());
        static::assertEquals('icon.png', $metaData->getIcon());

        static::assertEquals([
            'en-GB' => 'Swag App Test',
            'de-DE' => 'Swag App Test',
        ]$metaData->getLabel());
        static::assertEquals([
            'en-GB' => 'Test for App System',
            'de-DE' => 'Test für das App System',
        ]$metaData->getDescription());
        static::assertEquals([
            'en-GB' => 'Following personal information will be processed on shopware AG\'s servers: - Name - Billing address - Order value',
static::assertNotNull($manifest->getPayments());
        static::assertCount(2, $manifest->getPayments()->getPaymentMethods());

        $firstWebhook = $manifest->getPayments()->getPaymentMethods()[0];
        static::assertNotNull($firstWebhook);
        static::assertSame('myMethod', $firstWebhook->getIdentifier());
        static::assertSame('https://payment.app/payment/process', $firstWebhook->getPayUrl());
        static::assertSame('https://payment.app/payment/finalize', $firstWebhook->getFinalizeUrl());
        static::assertSame('https://payment.app/payment/refund', $firstWebhook->getRefundUrl());
        static::assertSame('https://payment.app/payment/recurring', $firstWebhook->getRecurringUrl());
        static::assertSame('Resources/payment.png', $firstWebhook->getIcon());
        static::assertSame([
            'en-GB' => 'The app payment method',
            'de-DE' => 'Die App Zahlungsmethode',
        ]$firstWebhook->getName());
        static::assertSame([
            'en-GB' => 'This is a description',
            'de-DE' => 'Die Zahlungsmethoden-Beschreibung',
        ]$firstWebhook->getDescription());

        $secondWebhook = $manifest->getPayments()->getPaymentMethods()[1];
        static::assertNotNull($secondWebhook);
        
static::assertSame('https://www.test.de/', $plugin->getManufacturerLink());
        static::assertSame('https://www.test.de/support', $plugin->getSupportLink());
    }

    private function assertPluginMetaInformation(PluginEntity $plugin): void
    {
        static::assertNotNull($plugin->getCreatedAt());
        static::assertNull($plugin->getUpdatedAt());
        static::assertNull($plugin->getUpgradeVersion());
        static::assertNull($plugin->getInstalledAt());
        static::assertNull($plugin->getUpgradedAt());
        static::assertSame($this->getValidIconAsBase64()$plugin->getIcon());
        static::assertSame('shopware AG', $plugin->getAuthor());
        static::assertSame('(c) by shopware AG', $plugin->getCopyright());
        static::assertSame('MIT', $plugin->getLicense());
    }

    private function fetchSwagTestPluginEntity(?Context $context = null): PluginEntity
    {
        if ($context === null) {
            $context = $this->context;
        }

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

        $metaData = $manifest->getMetadata();
        static::assertEquals('test', $metaData->getName());
        static::assertEquals('shopware AG', $metaData->getAuthor());
        static::assertEquals('(c) by shopware AG', $metaData->getCopyright());
        static::assertEquals('MIT', $metaData->getLicense());
        static::assertEquals('https://test.com/privacy', $metaData->getPrivacy());
        static::assertEquals('1.0.0', $metaData->getVersion());
        static::assertEquals('icon.png', $metaData->getIcon());

        static::assertEquals([
            'en-GB' => 'Swag App Test',
            'de-DE' => 'Swag App Test',
        ]$metaData->getLabel());
        static::assertEquals([
            'en-GB' => 'Test for App System',
            'de-DE' => 'Test für das App System',
        ]$metaData->getDescription());
        static::assertEquals([
            'en-GB' => 'Following personal information will be processed on shopware AG\'s servers: - Name - Billing address - Order value',
static::assertNotNull($flowActions->getActions());
        static::assertCount(1, $flowActions->getActions()->getActions());

        $firstAction = $flowActions->getActions()->getActions()[0];
        $meta = $firstAction->getMeta();

        static::assertEquals('abc.cde.ccc', $meta->getName());
        static::assertEquals(['order', 'customer']$meta->getRequirements());
        static::assertEquals('https://example.xyz', $meta->getUrl());
        static::assertEquals('sw-pencil', $meta->getSwIcon());
        static::assertEquals('resource/pencil', $meta->getIcon());
        static::assertEquals(
            [
                'en-GB' => 'First action app',
                'de-DE' => 'First action app DE',
            ],
            $firstAction->getMeta()->getLabel()
        );
        static::assertEquals(
            [
                'en-GB' => 'First action app description',
                'de-DE' => 'First action app description DE',
            ],
static::assertNotNull($manifest->getPayments());
        static::assertCount(2, $manifest->getPayments()->getPaymentMethods());

        $firstWebhook = $manifest->getPayments()->getPaymentMethods()[0];
        static::assertNotNull($firstWebhook);
        static::assertSame('myMethod', $firstWebhook->getIdentifier());
        static::assertSame('https://payment.app/payment/process', $firstWebhook->getPayUrl());
        static::assertSame('https://payment.app/payment/finalize', $firstWebhook->getFinalizeUrl());
        static::assertSame('https://payment.app/payment/refund', $firstWebhook->getRefundUrl());
        static::assertSame('https://payment.app/payment/recurring', $firstWebhook->getRecurringUrl());
        static::assertSame('Resources/payment.png', $firstWebhook->getIcon());
        static::assertSame([
            'en-GB' => 'The app payment method',
            'de-DE' => 'Die App Zahlungsmethode',
        ]$firstWebhook->getName());
        static::assertSame([
            'en-GB' => 'This is a description',
            'de-DE' => 'Die Zahlungsmethoden-Beschreibung',
        ]$firstWebhook->getDescription());

        $secondWebhook = $manifest->getPayments()->getPaymentMethods()[1];
        static::assertNotNull($secondWebhook);
        
$localExtension->setStoreLicense($storeExtension->getStoreLicense());
                $localExtension->setNotices($storeExtension->getNotices());

                if ($storeExtension->getDescription()) {
                    $localExtension->setDescription($storeExtension->getDescription());
                }

                if ($storeExtension->getShortDescription()) {
                    $localExtension->setShortDescription($storeExtension->getShortDescription());
                }

                $localExtension->setIcon($storeExtension->getIcon());
                $localExtension->setLabel($storeExtension->getLabel());

                if ($storeExtension->getLatestVersion()) {
                    $localExtension->setLatestVersion($storeExtension->getLatestVersion());
                    $localExtension->setUpdateSource($storeExtension->getUpdateSource());
                }

                continue;
            }

            $localCollection->set($storeExtension->getName()$storeExtension);
        }
string $defaultLocale,
        Context $context,
        bool $install
    ): AppEntity {
        // accessToken is not set on update, but in that case we don't run registration, so we won't need it         /** @var string $secretAccessKey */
        $secretAccessKey = $metadata['accessToken'] ?? '';
        unset($metadata['accessToken']$metadata['icon']);
        $metadata['path'] = str_replace($this->projectDir . '/', '', $manifest->getPath());
        $metadata['id'] = $id;
        $metadata['modules'] = [];
        $metadata['iconRaw'] = $this->getIcon($manifest);
        $metadata['cookies'] = $manifest->getCookies() !== null ? $manifest->getCookies()->getCookies() : [];
        $metadata['baseAppUrl'] = $manifest->getAdmin() !== null ? $manifest->getAdmin()->getBaseAppUrl() : null;
        $metadata['allowedHosts'] = $manifest->getAllHosts();
        $metadata['templateLoadPriority'] = $manifest->getStorefront() ? $manifest->getStorefront()->getTemplateLoadPriority() : 0;

        $this->updateMetadata($metadata$context);

        $app = $this->loadApp($id$context);

        $this->updateCustomEntities($app->getId()$app->getPath()$manifest);

        
$idFlowAction = $this->registerFlowAction();

        /** @var AppFlowActionEntity $appFlowAction */
        $appFlowAction = $appFlowActionRepository->search(new Criteria([$idFlowAction]), Context::createDefaultContext())->get($idFlowAction);
        static::assertNotNull($appFlowAction);

        $icon = \file_get_contents(__DIR__ . '/../../Manifest/_fixtures/test/icon.png');
        static::assertNotFalse($icon);

        static::assertEquals(
            base64_encode($icon),
            $appFlowAction->getIcon()
        );
    }

    private function registerFlowAction(): string
    {
        /** @var EntityRepository $appRepository */
        $appRepository = $this->getContainer()->get('app.repository');

        $idFlowAction = Uuid::randomHex();

        $appRepository->create([
            [
'callback' => '::settingsAjax',
        'wrapper' => 'field-layout-settings-wrapper',
      ],
    ];

    $form['field_layouts']['settings_wrapper'] = [
      '#type' => 'container',
      '#id' => 'field-layout-settings-wrapper',
      '#tree' => TRUE,
    ];

    $form['field_layouts']['settings_wrapper']['icon'] = $layout_plugin->getPluginDefinition()->getIcon();

    if ($layout_plugin instanceof PluginFormInterface) {
      $form['field_layouts']['settings_wrapper']['layout_settings'] = [];
      $subform_state = SubformState::createForSubform($form['field_layouts']['settings_wrapper']['layout_settings']$form$form_state);
      $form['field_layouts']['settings_wrapper']['layout_settings'] = $layout_plugin->buildConfigurationForm($form['field_layouts']['settings_wrapper']['layout_settings']$subform_state);
    }

    return $form;
  }

  /** * Gets the layout plugin for the currently selected field layout. * * @param \Drupal\field_layout\Display\EntityDisplayWithLayoutInterface $entity * The current form entity. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @return \Drupal\Core\Layout\LayoutInterface * The layout plugin. */
return $context->scope(Context::SYSTEM_SCOPE, function DContext $context) use ($criteria) {
            /** @var PaymentMethodCollection $paymentMethods */
            $paymentMethods = $this->paymentMethodRepository->search($criteria$context)->getEntities();

            return $paymentMethods;
        });
    }

    private function getMediaId(Manifest $manifest, PaymentMethod $paymentMethod, Context $context, ?AppPaymentMethodEntity $existing): ?string
    {
        if (!$iconPath = $paymentMethod->getIcon()) {
            return null;
        }

        $icon = $this->appLoader->loadFile($manifest->getPath()$iconPath);
        if (!$icon) {
            return null;
        }

        $fileName = sprintf('payment_app_%s_%s', $manifest->getMetadata()->getName()$paymentMethod->getIdentifier());
        $extension = pathinfo($paymentMethod->getIcon() ?? '', \PATHINFO_EXTENSION);
        $mimeType = $this->mimeDetector->detectMimeTypeFromBuffer($icon);
        
'name' => 'App1',
                ],
            ],
        ], Context::createDefaultContext());

        /** @var AppEntity $app */
        $app = $appRepository->search(new Criteria([$id]), Context::createDefaultContext())->get($id);
        $icon = \file_get_contents(__DIR__ . '/../Manifest/_fixtures/test/icon.png');
        static::assertNotNull($app);
        static::assertNotFalse($icon);

        static::assertEquals(\base64_encode($icon)$app->getIcon());
    }
}
public function updateActions(Action $flowAction, string $appId, Context $context, string $defaultLocale): void
    {
        /** @var array<string, string> $existingFlowActions */
        $existingFlowActions = $this->connection->fetchAllKeyValue('SELECT name, LOWER(HEX(id)) FROM app_flow_action WHERE app_id = :appId', [
            'appId' => Uuid::fromHexToBytes($appId),
        ]);

        $flowActions = $flowAction->getActions() ? $flowAction->getActions()->getActions() : [];
        $upserts = [];

        foreach ($flowActions as $action) {
            if ($icon = $action->getMeta()->getIcon()) {
                $icon = $this->appLoader->loadFile($flowAction->getPath()$icon);
            }

            $payload = array_merge([
                'appId' => $appId,
                'iconRaw' => $icon,
            ]$action->toArray($defaultLocale));

            $existing = $existingFlowActions[$action->getMeta()->getName()] ?? null;
            if ($existing) {
                $payload['id'] = $existing;
                

  public function build(SectionStorageInterface $section_storage, int $delta) {
    $items = [];
    $definitions = $this->layoutManager->getFilteredDefinitions('layout_builder', $this->getPopulatedContexts($section_storage)['section_storage' => $section_storage]);
    foreach ($definitions as $plugin_id => $definition) {
      $layout = $this->layoutManager->createInstance($plugin_id);
      $item = [
        '#type' => 'link',
        '#title' => [
          'icon' => $definition->getIcon(60, 80, 1, 3),
          'label' => [
            '#type' => 'container',
            '#children' => $definition->getLabel(),
          ],
        ],
        '#url' => Url::fromRoute(
          $layout instanceof PluginFormInterface ? 'layout_builder.configure_section' : 'layout_builder.add_section',
          [
            'section_storage_type' => $section_storage->getStorageType(),
            'section_storage' => $section_storage->getStorageId(),
            'delta' => $delta,
            

        return array_values(array_map(function DActionButtonEntity $button): array {
            /** @var AppEntity $app */
            $app = $button->getApp();

            return [
                'app' => $app->getName(),
                'id' => $button->getId(),
                'label' => $this->mapTranslatedLabels($button),
                'action' => $button->getAction(),
                'url' => $button->getUrl(),
                'icon' => $app->getIcon(),
            ];
        }$actionButtons->getElements()));
    }

    /** * @return array<string, string|null> */
    private function mapTranslatedLabels(ActionButtonEntity $button): array
    {
        $translations = $button->getTranslations();

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