getId example

public function createRevision(RevisionableInterface $entity$default = TRUE, $keep_untranslatable_fields = NULL) {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    $new_revision = clone $entity;

    $original_keep_untranslatable_fields = $keep_untranslatable_fields;

    // For translatable entities, create a merged revision of the active     // translation and the other translations in the default revision. This     // permits the creation of pending revisions that can always be saved as the     // new default revision without reverting changes in other languages.     if (!$entity->isNew() && !$entity->isDefaultRevision() && $entity->isTranslatable() && $this->isAnyRevisionTranslated($entity)) {
      $active_langcode = $entity->language()->getId();
      $skipped_field_names = array_flip($this->getRevisionTranslationMergeSkippedFieldNames());

      // By default we copy untranslatable field values from the default       // revision, unless they are configured to affect only the default       // translation. This way we can ensure we always have only one affected       // translation in pending revisions. This constraint is enforced by       // EntityUntranslatableFieldsConstraintValidator.       if (!isset($keep_untranslatable_fields)) {
        $keep_untranslatable_fields = $entity->isDefaultTranslation() && $entity->isDefaultTranslationAffectedOnly();
      }

      
        $deleteBuffer = [];

        // make sure we have an ID index for         // all our delete-items with a qty of 0         foreach (array_keys($lineItemsToRemove) as $id) {
            $deleteBuffer[$id] = 0;
        }

        foreach ($restOfCart as $item) {
            // if its a totally different item             // just add it to the rest of our cart             if (!\in_array($item->getId()$lineItemsToRemoveIDs, true)) {
                $newRestOfCart->add($item);
            } else {
                // we have an item that should be removed                 // now we have to calculate how many of the item position (qty diff)                 // or if we have even reached our max amount of quantities to remove for this item                 $maxRemoveMeta = $lineItemsToRemove[$item->getId()]->getQuantity();

                $alreadyDeletedCount = $deleteBuffer[$item->getId()];

                // now check if we can remove our current item completely                 // or if we have a sub quantity that still needs to be
return TRUE;
      }
    }
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function hasTranslation(LanguageInterface $language) {
    foreach ($this->getConfigNames() as $name) {
      if ($this->localeConfigManager->hasTranslation($name$language->getId())) {
        return TRUE;
      }
    }
    return FALSE;
  }

  /** * {@inheritdoc} */
  public function getTypeName() {
    return $this->t('Settings');
  }
/** * @param array<Group> $config * @param array<VariantCondition> $conditions */
    private function buildListingVariantLink(string $number, array $config, array $conditions): string
    {
        $groupIds = array_map(function DVariantCondition $condition) {
            return $condition->getGroupId();
        }$conditions);

        $filtered = array_filter($configfunction DGroup $group) use ($groupIds) {
            return \in_array($group->getId()$groupIds, true);
        });

        if (\count($config) === \count($filtered)) {
            return 'number=' . $number;
        }

        $keys = [];
        foreach ($filtered as $group) {
            $keys['group'][$group->getId()] = $group->getOptions()[0]->getId();
        }

        
public function testRemoveNonRemovableLineItemFromCart(): void
    {
        $cart = new Cart('test');

        $lineItem = new LineItem('A', 'test');
        $lineItem->setRemovable(false);

        $cart->add($lineItem);

        $this->expectException(CartException::class);

        $cart->remove($lineItem->getId());

        static::assertCount(1, $cart->getLineItems());
    }
}


  /** * {@inheritdoc} */
  public function delete() {
    // Delete all aliases associated with this entity in the current language.     $entity = $this->getEntity();
    $path_alias_storage = \Drupal::entityTypeManager()->getStorage('path_alias');
    $entities = $path_alias_storage->loadByProperties([
      'path' => '/' . $entity->toUrl()->getInternalPath(),
      'langcode' => $entity->language()->getId(),
    ]);
    $path_alias_storage->delete($entities);
  }

}
// Delete English.     $this->drupalGet('admin/config/regional/language/delete/en');
    $this->submitForm([], 'Delete');

    // Changing the default language causes a container rebuild. Therefore need     // to rebuild the container in the test environment.     $this->rebuildContainer();

    // Verify that French is the only language.     $this->container->get('language_manager')->reset();
    $this->assertFalse(\Drupal::languageManager()->isMultilingual(), 'Site is mono-lingual');
    $this->assertEquals('fr', \Drupal::languageManager()->getDefaultLanguage()->getId(), 'French is the default language');

    // Set language detection to URL.     $edit = ['language_interface[enabled][language-url]' => TRUE];
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm($edit, 'Save settings');
    $this->drupalPlaceBlock('local_actions_block');
  }

  /** * Verifies that links do not have language prefixes in them. */
  
return $definition;
    }

    /** * @param Context|SalesChannelContext $context */
    private function addConstraints(DataValidationDefinition $definition$context): void
    {
        if ($context instanceof SalesChannelContext) {
            $frameworkContext = $context->getContext();
            $salesChannelId = $context->getSalesChannel()->getId();
        } else {
            $frameworkContext = $context;
            $salesChannelId = null;
        }

        $definition
            ->add('salutationId', new EntityExists(['entity' => $this->salutationDefinition->getEntityName(), 'context' => $frameworkContext]))
            ->add('firstName', new NotBlank())
            ->add('lastName', new NotBlank())
            ->add('accountType', new Choice($this->accountTypes));

        
$tax = $taxes->get(array_rand($taxes->getIds()));
        \assert($tax instanceof TaxEntity);
        $taxRate = 1 + ($tax->getTaxRate() / 100);

        return [
            'id' => Uuid::randomHex(),
            'productNumber' => Uuid::randomHex(),
            'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => $price, 'net' => $price / $taxRate, 'linked' => true]],
            'purchasePrices' => [['currencyId' => Defaults::CURRENCY, 'gross' => $purchasePrice, 'net' => $purchasePrice / $taxRate, 'linked' => true]],
            'name' => $this->faker->format('productName'),
            'description' => $this->faker->text(),
            'taxId' => $tax->getId(),
            'manufacturerId' => $this->faker->randomElement($manufacturer),
            'active' => true,
            'height' => $this->faker->numberBetween(1, 1000),
            'width' => $this->faker->numberBetween(1, 1000),
            'categories' => $this->getCategoryIds(),
            'tags' => $this->getTags($tags),
            'stock' => $this->faker->numberBetween(1, 50),
        ];
    }

    /** * @param list<string> $rules * * @return list<array<string, mixed>> */

  protected function assertEntity(int $id, string $expected_language, string $expected_label, string $expected_vid, ?string $expected_description = '', ?string $expected_format = NULL, int $expected_weight = 0, array $expected_parents = [], int $expected_field_integer_value = NULL, int $expected_term_reference_tid = NULL): void {
    /** @var \Drupal\taxonomy\TermInterface $entity */
    $entity = Term::load($id);
    $this->assertInstanceOf(TermInterface::class$entity);
    $this->assertSame($expected_language$entity->language()->getId());
    $this->assertSame($expected_label$entity->label());
    $this->assertSame($expected_vid$entity->bundle());
    $this->assertSame($expected_description$entity->getDescription());
    $this->assertSame($expected_format$entity->getFormat());
    $this->assertSame($expected_weight$entity->getWeight());
    $this->assertHierarchy($expected_vid$id$expected_parents);
  }

  /** * Asserts that a term is present in the tree storage, with the right parents. * * @param string $vid * Vocabulary ID. * @param int $tid * ID of the term to check. * @param array $parent_ids * The expected parent term IDs. * * @internal */

                    new EqualsFilter('fileName', 'demostore-logo'),
                    new EqualsFilter('fileName', 'favicon'),
                ]
            )
        );
        $medias = $this->mediaRepository->search($criteria$this->context);

        /** @var MediaEntity $media */
        foreach ($medias as $media) {
            if ($media->getFileName() === 'favicon') {
                $this->faviconId = $media->getId();
            } elseif ($media->getFileName() === 'demostore-logo') {
                $this->demostoreLogoId = $media->getId();
            }
        }
    }

    protected function tearDown(): void
    {
        if ($this->createdStorefrontTheme !== '') {
            $this->themeRepository->delete([['id' => $this->createdStorefrontTheme]]$this->context);
        }
    }

        $cacheKey = $this->generateCacheKeyForShop($shop);

        return $this->cache->fetch($cacheKey) !== false;
    }

    /** * @return string */
    private function generateCacheKeyForShop(Shop $shop)
    {
        return sprintf($this->cacheKey, $shop->getId());
    }
}
$context = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create(Uuid::randomHex(), TestDefaults::SALES_CHANNEL);

        $cart = new Cart('test');
        $cart->setLineItems(new LineItemCollection([$item]));

        $new = new Cart('after');
        $processor->process(new CartDataCollection()$cart$new$contextnew CartBehavior());

        if ($expected === null) {
            static::assertFalse($new->has($item->getId()));

            return;
        }

        static::assertTrue($new->has($item->getId()));

        static::assertInstanceOf(CalculatedPrice::class$item->getPrice());
        static::assertEquals($expected->getUnitPrice()$item->getPrice()->getUnitPrice());
        static::assertEquals($expected->getTotalPrice()$item->getPrice()->getTotalPrice());
        static::assertEquals($expected->getCalculatedTaxes()->getAmount()$item->getPrice()->getCalculatedTaxes()->getAmount());

        


        if (Uuid::isValid($iso)) {
            $criteria = new Criteria([$iso]);
        } else {
            $criteria = (new Criteria())->addFilter(new EqualsFilter('isoCode', $iso));
        }

        /** @var CurrencyEntity|null $currency */
        $currency = $this->currencyRepository->search($criteria, Context::createDefaultContext())->first();

        return $currency === null ? null : $currency->getId();
    }
}


        $role->fromArray($params);

        $this->modelManager->persist($role);
        $this->modelManager->flush();

        // Check if admin flag is set or unset         if ($params['admin'] == true) {
            Shopware()->Db()->query(' INSERT IGNORE INTO s_core_acl_roles (roleID,resourceID,privilegeID) VALUES (?,?,?) ', [$role->getId(), null, null]);
        } else {
            $query = $this->getUserRepository()->getAdminRuleDeleteQuery($role->getId());
            $query->execute();
        }

        $this->View()->assign([
            'success' => true,
            'data' => $this->modelManager->toArray($role),
        ]);
    }

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