container example

static::assertTrue($items->has('item'));

        $items = $facade->products();
        static::assertCount(3, $items);

        $price = $facade->price();
        static::assertEquals(100, $price->getTotal());

        $errors = $facade->errors();
        static::assertCount(1, $errors);

        static::assertSame('my-container', $facade->container('my-container')->getId());
        static::assertEquals(3, $facade->count());
        static::assertTrue($cart->has('item'));
        static::assertInstanceOf(LineItem::class$cart->get('item'));

        $states = $facade->states();
        static::assertTrue($states->has('within-test'));

        $facade->discount('my-discount', 'percentage', 10, 'my-discount');
        static::assertTrue($facade->has('my-discount'));

        $facade->discount('my-surcharge', 'percentage', 10, 'my-surcharge');
        
->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL, []);

        $hook = new CartHook($this->createCart()$context);

        $service = $this->getContainer()->get(CartFacadeHookFactory::class)
            ->factory($hook$this->script);

        $id = $this->ids->get('p1');

        $product = $service->products()->add($id, 10);

        $container = $service->container('my-container');

        static::assertInstanceOf(ItemFacade::class$product);
        static::assertInstanceOf(ContainerFacade::class$container);

        $split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);

        $split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);
        
/** * Gets the config factory for this form. * * When accessing configuration values, use $this->config(). Only use this * when the config factory needs to be manipulated directly. * * @return \Drupal\Core\Config\ConfigFactoryInterface */
  protected function configFactory() {
    if (!$this->configFactory) {
      $this->configFactory = $this->container()->get('config.factory');
    }
    return $this->configFactory;
  }

  /** * Sets the config factory for this form. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * * @return $this */
return new static();
  }

  /** * Retrieves the entity type manager. * * @return \Drupal\Core\Entity\EntityTypeManagerInterface * The entity type manager. */
  protected function entityTypeManager() {
    if (!isset($this->entityTypeManager)) {
      $this->entityTypeManager = $this->container()->get('entity_type.manager');
    }
    return $this->entityTypeManager;
  }

  /** * Retrieves the entity form builder. * * @return \Drupal\Core\Entity\EntityFormBuilderInterface * The entity form builder. */
  protected function entityFormBuilder() {
    
Home | Imprint | This part of the site doesn't use cookies.