merge example


        private readonly DataValidationFactoryInterface $profileValidation
    ) {
    }

    public function create(SalesChannelContext $context): DataValidationDefinition
    {
        $definition = new DataValidationDefinition('customer.create');

        $profileDefinition = $this->profileValidation->create($context);

        $this->merge($definition$profileDefinition);

        $this->addConstraints($definition);

        return $definition;
    }

    public function update(SalesChannelContext $context): DataValidationDefinition
    {
        $definition = new DataValidationDefinition('customer.update');

        $profileDefinition = $this->profileValidation->update($context);

        
/** @var CategoryEntity $category */
        // check that the path updated         $category = $this->categoryRepository->search(new Criteria([$categoryD])$versionContext)->first();
        static::assertInstanceOf(CategoryEntity::class$category);
        static::assertEquals('|' . $categoryA . '|', $category->getPath());

        $category = $this->categoryRepository->search(new Criteria([$categoryD])$this->context)->first();
        static::assertInstanceOf(CategoryEntity::class$category);
        static::assertEquals('|' . $categoryA . '|' . $categoryC . '|', $category->getPath());

        $this->categoryRepository->merge($versionId$this->context);

        // test after merge the path is updated too         /** @var CategoryEntity $category */
        $category = $this->categoryRepository->search(new Criteria([$categoryD])$this->context)->first();
        static::assertInstanceOf(CategoryEntity::class$category);
        static::assertEquals('|' . $categoryA . '|', $category->getPath());
    }

    public function testIndexTree(): void
    {
        /* Category A ├── Category B ├── Category C │ └── Category D */
try {
                    if (!\array_key_exists($orderId$operations)) {
                        continue;
                    }

                    /** @var DocumentGenerateOperation $operation */
                    $operation = $operations[$orderId];

                    $config = clone $this->documentConfigLoader->load(self::TYPE, $order->getSalesChannelId()$context);

                    $config->merge($operation->getConfig());

                    $number = $config->getDocumentNumber() ?: $this->getNumber($context$order$operation);

                    $now = (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT);

                    $config->merge([
                        'documentDate' => $operation->getConfig()['documentDate'] ?? $now,
                        'documentNumber' => $number,
                        'custom' => [
                            'invoiceNumber' => $number,
                        ],
                    ]);
  // upon entity deletion.   $id = $entity->id();
  $type = $entity->getEntityTypeId();
  $count = \Drupal::database()->select('example_entity_data')
    ->condition('type', $type)
    ->condition('id', $id)
    ->countQuery()
    ->execute()
    ->fetchField();

  // Log the count in a table that records this statistic for deleted entities.   $connection->merge('example_deleted_entity_statistics')
    ->key(['type' => $type, 'id' => $id])
    ->fields(['count' => $count])
    ->execute();
}

/** * Act before entity deletion of a particular entity type. * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity object for the entity that is about to be deleted. * * @ingroup entity_crud * @see hook_entity_predelete() */
$nested = [];
                    if ($field instanceof ManyToManyAssociationField || $field instanceof OneToManyAssociationField) {
                        $ref = $field instanceof ManyToManyAssociationField ? $field->getToManyReferenceDefinition()->getEntityName() : $field->getReferenceDefinition()->getEntityName();
                        $nested = $this->collect($ref$value);
                    } elseif ($field instanceof ManyToOneAssociationField || $field instanceof OneToOneAssociationField) {
                        $tmp = [$value];
                        $nested = $this->collect($field->getReferenceDefinition()->getEntityName()$tmp);
                        $value = \array_shift($tmp);
                    }

                    $map = $this->merge($map$nested);
                }
            }
        }

        return $map;
    }

    /** * @param array<string, array<FkReference>> $map * @param array<string, array<FkReference>> $nested * * @return array<string, array<FkReference>> */
'size' => 'normal',
    ],
    'b' => [
      'type' => 'blob',
      'not null' => FALSE,
      'size' => 'normal',
    ],
  ],
]);

// Set the schema version. $connection->merge('key_value')
  ->condition('collection', 'system.schema')
  ->condition('name', 'update_test_schema')
  ->fields([
    'collection' => 'system.schema',
    'name' => 'update_test_schema',
    'value' => 'i:8000;',
  ])
  ->execute();

// Update core.extension. $extensions = $connection->select('config')
  
$container->getParameterBag()->mergeEnvPlaceholders($resolvingBag);
                }

                throw $e;
            }

            if ($resolvingBag instanceof MergeExtensionConfigurationParameterBag) {
                // don't keep track of env vars that are *overridden* when configs are merged                 $resolvingBag->freezeAfterProcessing($extension$tmpContainer);
            }

            $container->merge($tmpContainer);
            $container->getParameterBag()->add($parameters);
        }

        $container->addDefinitions($definitions);
        $container->addAliases($aliases);
    }
}

/** * @internal */
/** * {@inheritdoc} */
  public function findAll() {
    return $this->connection->query('SELECT * FROM {ban_ip}');
  }

  /** * {@inheritdoc} */
  public function banIp($ip) {
    $this->connection->merge('ban_ip')
      ->key(['ip' => $ip])
      ->fields(['ip' => $ip])
      ->execute();
  }

  /** * {@inheritdoc} */
  public function unbanIp($id) {
    $this->connection->delete('ban_ip')
      ->condition('ip', $id)
      
// First, delete any user assignments for this set, so that each of these     // users will go back to using whatever default set applies.     $this->connection->delete('shortcut_set_users')
      ->condition('set_name', $entity->id())
      ->execute();
  }

  /** * {@inheritdoc} */
  public function assignUser(ShortcutSetInterface $shortcut_set$account) {
    $this->connection->merge('shortcut_set_users')
      ->key('uid', $account->id())
      ->fields(['set_name' => $shortcut_set->id()])
      ->execute();
    drupal_static_reset('shortcut_current_displayed_set');
  }

  /** * {@inheritdoc} */
  public function unassignUser($account) {
    $deleted = $this->connection->delete('shortcut_set_users')
      

  public function __construct(Connection $connection) {
    $this->connection = $connection;
  }

  /** * {@inheritdoc} */
  protected function doInvalidateTags(array $tags) {
    try {
      foreach ($tags as $tag) {
        $this->connection->merge('cachetags')
          ->insertFields(['invalidations' => 1])
          ->expression('invalidations', '[invalidations] + 1')
          ->key('tag', $tag)
          ->execute();
      }
    }
    catch (\Exception $e) {
      // Create the cache table, which will be empty. This fixes cases during       // core install where cache tags are invalidated before the table is       // created.       if (!$this->ensureTableExists()) {
        
/** * {@inheritdoc} */
  public function validate() {
    return $this->getContextData()->validate();
  }

  /** * {@inheritdoc} */
  public function addCacheableDependency($dependency) {
    $this->cacheabilityMetadata = $this->cacheabilityMetadata->merge(CacheableMetadata::createFromObject($dependency));
    return $this;
  }

  /** * {@inheritdoc} */
  public function getCacheContexts() {
    return $this->cacheabilityMetadata->getCacheContexts();
  }

  /** * {@inheritdoc} */
// Map any expected 'a' or 'b' string value to the corresponding operand.       if ($$parameter === 'a') {
        $$parameter = $a;
      }
      elseif ($$parameter === 'b') {
        $$parameter = $b;
      }
      assert($$parameter instanceof HTMLRestrictions);
    }
    $this->assertEquals($expected_diff$a->diff($b));
    $this->assertEquals($expected_intersection$a->intersect($b));
    $this->assertEquals($expected_union$a->merge($b));
  }

  public function providerOperands(): \Generator {
    // Empty set operand cases.     yield 'any set + empty set' => [
      'a' => new HTMLRestrictions(['a' => ['href' => TRUE]]),
      'b' => HTMLRestrictions::emptySet(),
      'diff' => 'a',
      'intersection' => 'b',
      'union' => 'a',
    ];
    
return $this;
    }

    /** * Sets whether the node can be unset. * * @return $this */
    public function canBeUnset(bool $allow = true)static
    {
        $this->merge()->allowUnset($allow);

        return $this;
    }

    /** * Adds an "enabled" boolean to enable the current section. * * By default, the section is disabled. If any configuration is specified then * the node will be automatically enabled: * * enableableArrayNode: {enabled: true, ...} # The config is enabled & default values get overridden * enableableArrayNode: ~ # The config is enabled & use the default values * enableableArrayNode: true # The config is enabled & use the default values * enableableArrayNode: {other: value, ...} # The config is enabled & default values get overridden * enableableArrayNode: {enabled: false, ...} # The config is disabled * enableableArrayNode: false # The config is disabled * * @return $this */

    public function getBlocks(): CmsBlockCollection
    {
        $blocks = new CmsBlockCollection();

        /** @var CmsSectionEntity $section */
        foreach ($this->elements as $section) {
            if (!$section->getBlocks()) {
                continue;
            }

            $blocks->merge($section->getBlocks());
        }

        return $blocks;
    }

    public function getApiAlias(): string
    {
        return 'cms_page_section_collection';
    }

    protected function getExpectedClass(): string
    {
'name' => 'test',
            'price' => [['currencyId' => Defaults::CURRENCY, 'gross' => 10, 'net' => 8, 'linked' => false]],
            'manufacturer' => ['id' => $id, 'name' => 'test'],
            'tax' => ['id' => $id, 'name' => 'updated', 'taxRate' => 11000],
        ];

        $this->productRepository->upsert([$product]$context);

        $versionId = $this->productRepository->createVersion($id$context);
        $version = $context->createWithVersionId($versionId);
        $this->productRepository->update([['id' => $id, 'name' => 'test']]$version);
        $this->productRepository->merge($versionId$context);

        $changelog = $this->getVersionData($this->getContainer()->get(TaxDefinition::class)->getEntityName()$id, Defaults::LIVE_VERSION);
        static::assertCount(0, $changelog);

        $changelog = $this->getVersionData($this->getContainer()->get(ProductDefinition::class)->getEntityName()$id, Defaults::LIVE_VERSION);
        static::assertCount(1, $changelog);

        $changelog = $this->getVersionData($this->getContainer()->get(ProductManufacturerDefinition::class)->getEntityName()$id, Defaults::LIVE_VERSION);
        static::assertCount(0, $changelog);
    }

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