getLocation example


class TipPluginBaseTest extends UnitTestCase {

  /** * @covers ::getLocation */
  public function testGetLocationAssertion() {
    $base_plugin = $this->getMockForAbstractClass(TipPluginBase::class[], '', FALSE);

    $base_plugin->set('position', 'right');
    $this->assertSame('right', $base_plugin->getLocation());

    $base_plugin->set('position', 'not_valid');
    $this->expectException(\AssertionError::class);
    $this->expectExceptionMessage('not_valid is not a valid Tour Tip position value');
    $base_plugin->getLocation();
  }

}
foreach ($tour as $tour_id => $tips) {
      $tourEntity = $entities[$tour_id];

      foreach ($tips as $index => $tip) {
        $classes = [
          'tip-module-' . Html::getClass($tourEntity->getModule()),
          'tip-type-' . Html::getClass($tip->getPluginId()),
          'tip-' . Html::getClass($tip->id()),
        ];

        $selector = $tip->getSelector();
        $location = $tip->getLocation();

        $body_render_array = $tip->getBody();
        $body = (string) \Drupal::service('renderer')->renderPlain($body_render_array);
        $output = [
          'body' => $body,
          'title' => $tip->getLabel(),
        ];

        $selector = $tip->getSelector();

        if ($output) {
          
// transactions are currently not supported so they are excluded for comparison         $cart->setTransactions(new TransactionCollection());

        $this->removeExtensions($cart);
        $this->removeExtensions($convertedCart);

        // remove delivery information from line items
        foreach ($cart->getDeliveries() as $delivery) {
            // remove address from ShippingLocation             $property = ReflectionHelper::getProperty(ShippingLocation::class, 'address');
            $property->setValue($delivery->getLocation(), null);

            foreach ($delivery->getPositions() as $position) {
                $position->getLineItem()->setDeliveryInformation(null);
                $position->getLineItem()->setQuantityInformation(null);

                foreach ($position->getLineItem()->getChildren() as $lineItem) {
                    $lineItem->setDeliveryInformation(null);
                    $lineItem->setQuantityInformation(null);
                }
            }

            

    private function addDiscountDeliveryItem(DeliveryCollection $deliveries, Delivery $delivery, CalculatedPrice $price): void
    {
        if ($price->getTotalPrice() >= 0) {
            return;
        }

        $delivery = new Delivery(
            $delivery->getPositions(),
            $delivery->getDeliveryDate(),
            $delivery->getShippingMethod(),
            $delivery->getLocation(),
            $price
        );

        $deliveries->add($delivery);
    }

    /** * if we have a discount with scope delivery we add a lineItem in cart with price 0 * * @throws CartException */
    
if ($type === self::PLUGIN) {
            $this->pluginService->refreshPlugins($contextnew NullIO());
        }
    }

    public function downloadStorePlugin(PluginDownloadDataStruct $location, Context $context): void
    {
        /** @var string $tempFileName */
        $tempFileName = tempnam(sys_get_temp_dir(), 'store-plugin');

        try {
            $response = $this->client->request('GET', $location->getLocation()['sink' => $tempFileName]);
        } catch (\Exception) {
            throw PluginException::storeNotAvailable();
        }

        if ($response->getStatusCode() !== Response::HTTP_OK) {
            throw PluginException::storeNotAvailable();
        }

        $this->extractPluginZip($tempFileName, true, $location->getType());

        if ($location->getType() === self::PLUGIN) {
            
$this->forwardDownloadError(1);

            return;
        }

        if (empty($download->getFile())) {
            $this->forwardDownloadError(1);

            return;
        }

        $filePath = $esdService->getLocation($download);

        if ($filesystem->has($filePath) === false) {
            $this->forwardDownloadError(2);

            return;
        }

        try {
            $downloadService->send($filePath$filesystem);
        } catch (FileNotFoundException $exception) {
            $this->forwardDownloadError(2);
        }
->method('getShippingLocation')
            ->willReturn($deliveryLocation);

        $deliveryCollection = (new DeliveryBuilder())->buildByUsingShippingMethod($cart$shippingMethod$salesChannelContext);

        static::assertEquals(1, $deliveryCollection->count());

        /** @var Delivery $delivery */
        $delivery = $deliveryCollection->first();

        static::assertSame($shippingMethod$delivery->getShippingMethod());
        static::assertSame($deliveryLocation$delivery->getLocation());
        static::assertEquals(
            new CalculatedPrice(0, 0, new CalculatedTaxCollection()new TaxRuleCollection()),
            $delivery->getShippingCosts(),
        );

        static::assertEquals($expectedDeliveryDate$delivery->getDeliveryDate());
    }

    /** * @return iterable<array{0: LineItemCollection, 1: DeliveryDate}> */
    

class DateCaster
{
    private const PERIOD_LIMIT = 3;

    /** * @return array */
    public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter)
    {
        $prefix = Caster::PREFIX_VIRTUAL;
        $location = $d->getTimezone() ? $d->getTimezone()->getLocation() : null;
        $fromNow = (new \DateTimeImmutable())->diff($d);

        $title = $d->format('l, F j, Y')
            ."\n".self::formatInterval($fromNow).' from now'
            .($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '')
        ;

        unset(
            $a[Caster::PREFIX_DYNAMIC.'date'],
            $a[Caster::PREFIX_DYNAMIC.'timezone'],
            $a[Caster::PREFIX_DYNAMIC.'timezone_type']
        );
    // write. We can remove these from consideration, as rewriting would be a     // no-op.     $unchanged = $scaffold_files->checkUnchanged();
    $scaffold_files->filterFiles($unchanged);

    // Process the list of scaffolded files.     $scaffold_results = $scaffold_files->processScaffoldFiles($this->io, $scaffold_options);

    // Generate an autoload file in the document root that includes the     // autoload.php file in the vendor directory, wherever that is. Drupal     // requires this in order to easily locate relocated vendor dirs.     $web_root = $this->manageOptions->getOptions()->getLocation('web-root');
    if (!GenerateAutoloadReferenceFile::autoloadFileCommitted($this->io, $this->rootPackageName()$web_root)) {
      $scaffold_results[] = GenerateAutoloadReferenceFile::generateAutoload($this->io, $this->rootPackageName()$web_root$this->getVendorPath());
    }

    // Add the managed scaffold files to .gitignore if applicable.     $gitIgnoreManager = new ManageGitIgnore($this->io, getcwd());
    $gitIgnoreManager->manageIgnored($scaffold_results$scaffold_options);

    // Call post-scaffold scripts.     $dispatcher->dispatch(self::POST_DRUPAL_SCAFFOLD_CMD);
  }

  
return $this->filterDocBlockParams($docBlock$property);
        } catch (\InvalidArgumentException) {
            return null;
        }
    }

    private function filterDocBlockParams(DocBlock $docBlock, string $allowedParam): DocBlock
    {
        $tags = array_values(array_filter($docBlock->getTagsByName('param')fn ($tag) => $tag instanceof DocBlock\Tags\Param && $allowedParam === $tag->getVariableName()));

        return new DocBlock($docBlock->getSummary()$docBlock->getDescription()$tags$docBlock->getContext(),
            $docBlock->getLocation()$docBlock->isTemplateStart()$docBlock->isTemplateEnd());
    }

    /** * @return array{DocBlock|null, int|null, string|null} */
    private function getDocBlock(string $class, string $property): array
    {
        $propertyHash = sprintf('%s::%s', $class$property);

        if (isset($this->docBlocks[$propertyHash])) {
            return $this->docBlocks[$propertyHash];
        }

#[Package('checkout')] class DeliveryCollection extends Collection
{
    /** * Sorts the delivery collection by earliest delivery date */
    public function sortDeliveries(): self
    {
        $this->sort(function DDelivery $a, Delivery $b) {
            if ($a->getLocation() !== $b->getLocation()) {
                return -1;
            }

            return $a->getDeliveryDate()->getEarliest() > $b->getDeliveryDate()->getEarliest();
        });

        return $this;
    }

    public function getDelivery(DeliveryDate $deliveryDate, ShippingLocation $location): ?Delivery
    {
        
 {
    }

    /** * @throws DeliveryWithoutAddressException * * @return array<string, mixed|float|string|array<int, array<string, string|int|bool|mixed>>|null> */
    public function convertToOrder(Cart $cart, SalesChannelContext $context, OrderConversionContext $conversionContext): array
    {
        foreach ($cart->getDeliveries() as $delivery) {
            if ($delivery->getLocation()->getAddress() !== null || $delivery->hasExtensionOfType(self::ORIGINAL_ID, IdStruct::class)) {
                continue;
            }

            throw new DeliveryWithoutAddressException();
        }
        $data = CartTransformer::transform(
            $cart,
            $context,
            $this->initialStateIdLoader->get(OrderStates::STATE_MACHINE),
            $conversionContext->shouldIncludeOrderDate()
        );

        

class DateCaster
{
    private const PERIOD_LIMIT = 3;

    /** * @return array */
    public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter)
    {
        $prefix = Caster::PREFIX_VIRTUAL;
        $location = $d->getTimezone() ? $d->getTimezone()->getLocation() : null;
        $fromNow = (new \DateTimeImmutable())->diff($d);

        $title = $d->format('l, F j, Y')
            ."\n".self::formatInterval($fromNow).' from now'
            .($location ? ($d->format('I') ? "\nDST On" : "\nDST Off") : '')
        ;

        unset(
            $a[Caster::PREFIX_DYNAMIC.'date'],
            $a[Caster::PREFIX_DYNAMIC.'timezone'],
            $a[Caster::PREFIX_DYNAMIC.'timezone_type']
        );

    public static function transform(
        Delivery $delivery,
        array $lineItems,
        string $stateId,
        Context $context,
        array $addresses = []
    ): array {
        $addressId = $delivery->getLocation()->getAddress() ? $delivery->getLocation()->getAddress()->getId() : null;
        $shippingAddress = null;

        if ($addressId !== null && \array_key_exists($addressId$addresses)) {
            $shippingAddress = $addresses[$addressId];
        } elseif ($delivery->getLocation()->getAddress() !== null) {
            $shippingAddress = AddressTransformer::transform($delivery->getLocation()->getAddress());
        }

        $deliveryData = [
            'id' => self::getId($delivery),
            'shippingDateEarliest' => $delivery->getDeliveryDate()->getEarliest()->format(Defaults::STORAGE_DATE_TIME_FORMAT),
            
Home | Imprint | This part of the site doesn't use cookies.