getAffectedDeleteRestrictions example

$ruleDefinition = $this->getContainer()->get(RuleDefinition::class);

        $this->createRule($ids);
        $this->createShippingMethod($ids);
        $this->createSalesChannel($ids);

        $deleteIds = [
            'id' => $ids->get('rule'),
        ];

        $affected = $this->getContainer()->get(EntityForeignKeyResolver::class)
            ->getAffectedDeleteRestrictions($ruleDefinition$deleteIds$context, true);

        static::assertCount(1, $affected);
        static::assertArrayHasKey('shipping_method', $affected);
        static::assertContains($ids->get('shipping-method')$affected['shipping_method']);
        static::assertArrayNotHasKey('sales_channel', $affected);
    }

    private function getStateId(string $state, string $machine)
    {
        return $this->getContainer()->get(Connection::class)
            ->fetchOne(' SELECT LOWER(HEX(state_machine_state.id)) FROM state_machine_state INNER JOIN state_machine ON state_machine.id = state_machine_state.state_machine_id AND state_machine.technical_name = :machine WHERE state_machine_state.technical_name = :state ',

    private function extractDeleteCommands(EntityDefinition $definition, array $ids, WriteContext $writeContext, WriteCommandQueue $commandQueue): array
    {
        $parameters = new WriteParameterBag($definition$writeContext, '', $commandQueue);
        $ids = $this->commandExtractor->normalize($definition$ids$parameters);
        $this->gateway->prefetchExistences($parameters);

        $resolved = $this->resolvePrimaryKeys($ids$definition$writeContext);

        if (!$definition instanceof MappingEntityDefinition) {
            $restrictions = $this->foreignKeyResolver->getAffectedDeleteRestrictions($definition$resolved$writeContext->getContext(), true);

            if (!empty($restrictions)) {
                throw new RestrictDeleteViolationException($definition[new RestrictDeleteViolation($restrictions)]);
            }
        }

        $skipped = [];
        foreach ($resolved as $primaryKey) {
            /** @var array<string, string> $mappedBytes */
            $mappedBytes = [];
            /** * @var string $key * @var string $value */
Home | Imprint | This part of the site doesn't use cookies.