getLink example

/** * Helper function to build the final array to be handed to the view * * @param string $idPrefix * * @return array */
    private function getSiteNode($idPrefix, Site $site)
    {
        // Set icons         if ($site->getLink()) {
            $iconCls = 'sprite-chain-small';
        } else {
            $iconCls = 'sprite-blue-document-text';
        }

        // Build the structure         $node = [
            'id' => $idPrefix . $site->getId(),
            'active' => $site->getActive(),
            'text' => $site->getDescription() . '(' . $site->getId() . ')',
            'helperId' => $site->getId(),
            
 elseif ($element->getData()->get('media')) {
                    $elementArray['data']['media'] = $this->converter->convertMediaStruct($element->getData()->get('media'));
                }
                break;

            case ManufacturerSliderComponentHandler::COMPONENT_NAME:
                /** @var Manufacturer $manufacturer */
                foreach ($element->getData()->get('manufacturers') as $manufacturer) {
                    $manufacturerArray = $this->converter->convertManufacturerStruct($manufacturer);

                    $manufacturerArray['link'] = $this->config->get('baseFile') . '?controller=listing&action=manufacturer&sSupplier=' . $manufacturer->getId();
                    $manufacturerArray['website'] = $manufacturer->getLink();

                    $elementArray['data']['values'][$manufacturer->getId()] = $manufacturerArray;
                }
                break;

            case BlogComponentHandler::COMPONENT_NAME:
                $entries = [];
                foreach ($element->getData()->get('entries', []) as $blog) {
                    $entries[] = $this->converter->convertBlogStruct($blog);
                }

                
/** @var Banner|null $banner */
        $banner = $this->get('models')->getRepository(Banner::class)->findOneBy(['id' => $bannerId]);
        if ($banner === null) {
            return false;
        }

        $trackingRepo = $this->get('models')->getRepository(TrackingBanner::class);
        $bannerStatistics = $trackingRepo->getOrCreateBannerStatsModel($bannerId);
        $bannerStatistics->increaseClicks();
        $this->get('models')->flush($bannerStatistics);
        // Save         $jumpTarget = $banner->getLink();
        if (!empty($jumpTarget)) {
            $this->redirect($jumpTarget);
        }

        return true;
    }

    /** * Collects the numbers of view * * @return bool */
$routingContext = $this->getContext($shop$config);
            $href->setLink($this->filterUrl((string) $this->rewriteRouter->assemble($parameters$routingContext)$parameters));

            if (!$config->get('hrefLangCountry')) {
                $href->setLocale(explode('-', $languageShop['locale'])[0]);
            }

            if ((int) $languageShop['id'] === $config->get('hrefLangDefaultShop')) {
                $href->setLocale('x-default');
            }

            if ($this->config->get('hrefLangJustSeoUrl') && !$this->isSeoUrl($parameters$href->getLink()$routingContext)) {
                continue;
            }

            $hrefs[] = $href;
        }

        if (\count($hrefs) === 1) {
            return [];
        }

        return $hrefs;
    }


        $localPlugin->setUpdateAvailable((bool) ($updateAvailable == 1));

        if ($storePlugin->getDescription()) {
            $localPlugin->setDescription($storePlugin->getDescription());
        }
        if ($localPlugin->isUpdateAvailable()) {
            $localPlugin->setAvailableVersion($storePlugin->getVersion());
        }

        $localPlugin->setLink($storePlugin->getLink());
        $localPlugin->setRedirectToStore($storePlugin->isRedirectToStore());
        $localPlugin->setLowestPrice($storePlugin->getLowestPrice());
        $localPlugin->setContactForm($storePlugin->getContactForm());
        $localPlugin->setRating($storePlugin->getRating());
        $localPlugin->setUseContactForm($storePlugin->useContactForm());
        $localPlugin->setInstallationManual($storePlugin->getInstallationManual());
        $localPlugin->setChangelog($storePlugin->getChangelog());
        $localPlugin->setPrices($storePlugin->getPrices());
        $localPlugin->setComments($storePlugin->getComments());
        $localPlugin->setPictures($storePlugin->getPictures());
        $localPlugin->setProducer($storePlugin->getProducer());
        
'description' => $download->getDescription(),
                'filename' => $this->mediaService->getUrl($download->getFile()),
                'size' => $download->getSize(),
                'attributes' => $download->getAttributes(),
            ];
        }

        foreach ($product->getLinks() as $link) {
            $temp = [
                'id' => $link->getId(),
                'description' => $link->getDescription(),
                'link' => $link->getLink(),
                'target' => $link->getTarget(),
                'supplierSearch' => false,
                'attributes' => $link->getAttributes(),
            ];

            if (strpos($temp['link'], 'http') === false) {
                $temp['link'] = 'http://' . $link->getLink();
            }

            $data['sLinks'][] = $temp;
        }

        
$slot = new CmsSlotEntity();
        $slot->setUniqueIdentifier('id');
        $slot->setType('image');
        $slot->setFieldConfig($fieldConfig);

        $this->imageResolver->enrich($slot$resolverContext$result);

        /** @var ImageStruct|null $imageStruct */
        $imageStruct = $slot->getData();
        static::assertInstanceOf(ImageStruct::class$imageStruct);
        static::assertSame($manufacturer->getLink()$imageStruct->getUrl());
        static::assertEmpty($imageStruct->getMediaId());
        static::assertEmpty($imageStruct->getMedia());
    }
}
static::assertInstanceOf(ProductManufacturerEntity::class$product->getManufacturer());
        static::assertSame($manufacturerId$product->getManufacturerId());
        static::assertSame($manufacturerId$product->getManufacturer()->getId());
        static::assertSame('with id', $product->getManufacturer()->getName());

        $product = $products->get($ids[2]);
        static::assertInstanceOf(ProductEntity::class$product);
        static::assertInstanceOf(ProductManufacturerEntity::class$product->getManufacturer());
        static::assertSame($manufacturerId$product->getManufacturerId());
        static::assertSame($manufacturerId$product->getManufacturer()->getId());
        static::assertSame('with id', $product->getManufacturer()->getName());
        static::assertSame('test', $product->getManufacturer()->getLink());
    }

    public function testReadAndWriteOfProductManufacturerAssociation(): void
    {
        $id = Uuid::randomHex();

        // check nested events are triggered         $listener = $this->getMockBuilder(CallableClass::class)->getMock();
        $listener->expects(static::exactly(2))->method('__invoke');
        $this->eventDispatcher->addListener('product.written', $listener);
        $this->eventDispatcher->addListener('product_manufacturer.written', $listener);

        
$result->addIncluded($serialized);
        } else {
            $result->addEntity($serialized);
        }
    }

    protected function serializeRelationships(ResponseFields $fields, Record $record, Entity $entity, JsonApiEncodingResult $result): void
    {
        $relationships = $record->getRelationships();

        foreach ($relationships as $propertyName => &$relationship) {
            $relationship['links']['related'] = $record->getLink('self') . '/' . $this->camelCaseToSnailCase($propertyName);

            try {
                /** @var Entity|EntityCollection<Entity>|null $relationData */
                $relationData = $entity->get($propertyName);
            } catch (\InvalidArgumentException) {
                continue;
            }

            if (!$relationData) {
                continue;
            }

            
$result = $twig->render($name);
    $expected = '<div class="meow"></div>';
    $this->assertEquals($expected$result);
  }

  /** * @covers ::getLink */
  public function testLinkWithOverriddenAttributes() {
    $url = Url::fromRoute('<front>', []['attributes' => ['class' => ['foo']]]);

    $build = $this->systemUnderTest->getLink('test', $url['class' => ['bar']]);

    $this->assertEquals(['foo', 'bar']$build['#url']->getOption('attributes')['class']);
  }

  /** * Tests Twig 'add_suggestion' filter. * * @covers ::suggestThemeHook * @dataProvider providerTestTwigAddSuggestionFilter */
  public function testTwigAddSuggestionFilter($original_render_array$suggestion$expected_render_array) {
    
Home | Imprint | This part of the site doesn't use cookies.