getUrl example

->addSelect('ROUND(price.price*(100+tax.tax)/100,2) as price')
            ->addSelect('manual_sorting.position as position')
            ->addSelect('CONCAT("media/image/thumbnail/", img.img, "_140x140.", img.extension) as thumbnail')
            ->setParameter('categoryId', $categoryId)
            ->setMaxResults($limit)
            ->setFirstResult($start)
            ->addGroupBy('product.id');

        $data['data'] = $query->execute()->fetchAll();

        $data['data'] = array_map(function D$item) {
            $item['thumbnail'] = $this->mediaService->getUrl($item['thumbnail']);

            return $item;
        }$data['data']);

        $data['total'] = $query->getConnection()->fetchColumn('SELECT FOUND_ROWS()');

        return $data;
    }
}
$commandTester->getStatusCode(),
            "\"bin/console sales-channel:maintenance:disable\" returned errors:\n" . $commandTester->getDisplay()
        );

        $domainRepo = $this->getContainer()->get('sales_channel_domain.repository');
        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('salesChannel.typeId', Defaults::SALES_CHANNEL_TYPE_STOREFRONT));

        /** @var SalesChannelDomainEntity $domain */
        $domain = $domainRepo->search($criteria, Context::createDefaultContext())->first();

        static::assertSame('test.de', parse_url($domain->getUrl(), \PHP_URL_HOST));
    }

    public function testUpdateWithRandomPreviousDomain(): void
    {
        $commandTester = new CommandTester($this->getContainer()->get(SalesChannelUpdateDomainCommand::class));
        $commandTester->execute(['domain' => 'test.de', '--previous-domain' => 'shop.test']);

        static::assertEquals(
            0,
            $commandTester->getStatusCode(),
            "\"bin/console sales-channel:maintenance:disable\" returned errors:\n" . $commandTester->getDisplay()
        );
// Display creation form.     $this->drupalGet('entity_test/add');
    $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
    $this->assertSession()->responseContains('placeholder="0.00"');

    // Submit a signed decimal value within the allowed precision and scale.     $value = '-1234.5678';
    $edit = [
      "{$field_name}[0][value]" => $value,
    ];
    $this->submitForm($edit, 'Save');
    preg_match('|entity_test/manage/(\d+)|', $this->getUrl()$match);
    $id = $match[1];
    $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');
    $this->assertSession()->responseContains($value);

    // Try to create entries with more than one decimal separator; assert fail.     $wrong_entries = [
      '3.14.159',
      '0..45469',
      '..4589',
      '6.459.52',
      '6.3..25',
    ];
// Verify that we are still on the same page after login for allowed page.     $this->assertSession()->responseMatches('!<title.*?Compose tips.*?</title>!');

    // Log out again and repeat with a non-403 page including query arguments.     $this->drupalLogout();
    $this->drupalGet('filter/tips', ['query' => ['foo' => 'bar']]);
    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
    $this->submitForm($edit, 'Log in');
    $this->assertSession()->pageTextNotContains('User login');
    // Verify that we are still on the same page after login for allowed page.     $this->assertSession()->responseMatches('!<title.*?Compose tips.*?</title>!');
    $this->assertStringContainsString('/filter/tips?foo=bar', $this->getUrl(), 'Correct query arguments are displayed after login');

    // Repeat with different query arguments.     $this->drupalLogout();
    $this->drupalGet('filter/tips', ['query' => ['foo' => 'baz']]);
    $this->assertSession()->responseHeaderEquals(DynamicPageCacheSubscriber::HEADER, 'HIT');
    $this->submitForm($edit, 'Log in');
    $this->assertSession()->pageTextNotContains('User login');
    // Verify that we are still on the same page after login for allowed page.     $this->assertSession()->responseMatches('!<title.*?Compose tips.*?</title>!');
    $this->assertStringContainsString('/filter/tips?foo=baz', $this->getUrl(), 'Correct query arguments are displayed after login');

    
    $this->drupalGet('entity_test/add');
    $this->assertSession()->fieldValueEquals("{$field_name}[0][value]", '');
    $this->assertSession()->fieldNotExists("{$field_name}[0][format]");
    $this->assertSession()->responseContains(new FormattableMarkup('placeholder="A placeholder on @widget_type"', ['@widget_type' => $widget_type]));

    // Submit with some value.     $value = $this->randomMachineName();
    $edit = [
      "{$field_name}[0][value]" => $value,
    ];
    $this->submitForm($edit, 'Save');
    preg_match('|entity_test/manage/(\d+)|', $this->getUrl()$match);
    $id = $match[1];
    $this->assertSession()->pageTextContains('entity_test ' . $id . ' has been created.');

    // Display the entity.     $entity = EntityTest::load($id);
    $display = $display_repository->getViewDisplay($entity->getEntityTypeId()$entity->bundle(), 'full');
    $content = $display->build($entity);
    $rendered_entity = \Drupal::service('renderer')->renderRoot($content);
    $this->assertStringContainsString($value(string) $rendered_entity);
  }

}
#[Package('checkout')] class SourceTest extends TestCase
{
    public function testPayload(): void
    {
        $url = 'https://foo.bar';
        $shopId = 'foo';
        $appVersion = '1.0.0';

        $source = new Source($url$shopId$appVersion);

        static::assertSame($url$source->getUrl());
        static::assertSame($shopId$source->getShopId());
        static::assertSame($appVersion$source->getAppVersion());
    }
}

        $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());

        $secondActionButton = $manifest->getAdmin()->getActionButtons()[1];
        static::assertEquals('doStuffWithProducts', $secondActionButton->getAction());
        static::assertEquals('product', $secondActionButton->getEntity());
        static::assertEquals('list', $secondActionButton->getView());
        static::assertEquals('https://swag-test.com/do-stuff', $secondActionButton->getUrl());

        
private function formatCollection(ActionButtonCollection $actionButtons): array
    {
        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();

        
use Shopware\Core\Framework\Adapter\Asset\FallbackUrlPackage;
use Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy;

/** * @internal */
class FallbackUrlPackageTest extends TestCase
{
    public function testCliFallbacksToAppUrl(): void
    {
        $package = new FallbackUrlPackage(['']new EmptyVersionStrategy());
        $url = $package->getUrl('test');

        static::assertSame($_SERVER['APP_URL'] . '/test', $url);
    }

    public function testCliUrlGiven(): void
    {
        $package = new FallbackUrlPackage(['http://shopware.com']new EmptyVersionStrategy());
        $url = $package->getUrl('test');

        static::assertSame('http://shopware.com/test', $url);
    }

    

    private function parseConfig(array $config, bool $lessCompatible = true): array
    {
        foreach ($config as &$row) {
            if (!isset($row['value'])) {
                $row['value'] = unserialize($row['defaultValue']['allowed_classes' => false]);
            } else {
                $row['value'] = unserialize($row['value']['allowed_classes' => false]);
            }

            if ($row['type'] === 'theme-media-selection' && $row['value'] !== $row['defaultValue'] && str_contains($row['value'], 'media/')) {
                $row['value'] = $this->mediaService->getUrl($row['value']);
            }

            if ($lessCompatible && $row['type'] === 'theme-media-selection') {
                $row['value'] = '"' . $row['value'] . '"';
            }
        }

        if (empty($config)) {
            return [];
        }

        
$this->promotionRepository = $this->getContainer()->get('promotion.repository');
        $this->context = Context::createDefaultContext();
        $this->customerRepository = $this->getContainer()->get('customer.repository');
        $this->connection = $this->getContainer()->get(Connection::class);
        $eventDispatcher = new EventDispatcher();
        $this->contextPersister = new SalesChannelContextPersister($this->connection, $eventDispatcher$this->getContainer()->get(CartPersister::class));
        $this->ids = new TestDataCollection();
    }

    public function testProxyWithInvalidSalesChannelId(): void
    {
        $this->getBrowser()->request('GET', $this->getUrl(Uuid::randomHex(), '/product'));

        $response = $this->getBrowser()->getResponse()->getContent();
        $response = json_decode($response ?: '', true, 512, \JSON_THROW_ON_ERROR);

        static::assertArrayHasKey('errors', $response);
        static::assertEquals('FRAMEWORK__INVALID_SALES_CHANNEL', $response['errors'][0]['code'] ?? null);
    }

    public function testProxyCallToSalesChannelApi(): void
    {
        $salesChannel = $this->createSalesChannel();

        
break;
                    case Field::VALUE_TYPE_STRING:
                    default:
                        $value = $entry['value'];
                        break;
                }

                if (\in_array($entry['name']['file', 'image', 'fallback_picture'], true)) {
                    $scheme = parse_url($value, PHP_URL_SCHEME);

                    if (!\in_array($scheme['http', 'https'], true) && !\is_int($value)) {
                        $value = $this->mediaService->getUrl($value);
                    }
                }

                if (\in_array($entry['name']['selected_manufacturers', 'banner_slider'], true)) {
                    foreach ($value as $k => $v) {
                        if (isset($v['path'])) {
                            $value[$k]['path'] = $this->mediaService->getUrl($v['path']);
                        }
                    }
                }

                

  public function buildResourceUrl($url) {
    $query = ['url' => $url];
    return $this->getUrl() . '?' . UrlHelper::buildQuery($query);
  }

}
    // Form ID. Base form ID should only be added when different.     if ($this->getBaseFormId() !== $this->getFormId()) {
      $form_state->addBuildInfo('base_form_id', $this->getBaseFormId());
    }

    $form = [];

    $query = $this->requestStack->getCurrentRequest()->query->all();
    $query = UrlHelper::filterQueryParameters($query['_wrapper_format', 'ajax_page_state'], '');

    $options = ['query' => $query];
    $form['#action'] = $view->hasUrl() ? $view->getUrl()->setOptions($options)->toString() : Url::fromRoute('<current>')->setOptions($options)->toString();
    // Tell the preprocessor whether it should hide the header, footer, pager,     // etc.     $form['show_view_elements'] = [
      '#type' => 'value',
      '#value' => ($step == 'views_form_views_form') ? TRUE : FALSE,
    ];

    $form_object = $this->getFormObject($form_state);
    $form += $form_object->buildForm($form$form_state$view$output);

    return $form;
  }
private function generateLink(Element $element, ShopContextInterface $context): void
    {
        $link = $element->getConfig()->get('link');
        if (empty($link)) {
            return;
        }

        preg_match('/^([a-z]*:\/\/|shopware\.php|mailto:)/i', $link$matches);

        if (empty($matches) && strpos($link, '/') === 0) {
            $link = $context->getShop()->getUrl() . $link;
        }

        $element->getConfig()->set('link', $link);
    }

    private function addMappings(PrepareDataCollection $collection, Element $element, ShopContextInterface $context): void
    {
        $mappings = $element->getConfig()->get('bannerMapping', []);
        if (empty($mappings)) {
            return;
        }

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