tryToThrow example

$this->createMock(EntityExistence::class),
            '/0'
        );

        $fakeConnection = new FakeConnection($this->getPromotionDbRows());

        $event = new PreWriteValidationEvent($this->context, $commands);
        $validator = new PromotionValidator($fakeConnection);
        $validator->preValidate($event);

        try {
            $event->getExceptions()->tryToThrow();
            static::fail('Validation with invalid until was not triggered.');
        } catch (WriteException $e) {
            static::assertCount(1, $e->getExceptions());

            $firstException = $e->getExceptions()[0];
            static::assertInstanceOf(WriteConstraintViolationException::class$firstException);

            $violation = $firstException->getViolations()->get(0);

            static::assertEquals('/0/code', $violation->getPropertyPath());

            
$this->shopwareProjectComposer = $this->getComposer($this->projectDir);
        $exceptionStack = new RequirementExceptionStack();

        $pluginDependencies = $this->getPluginDependencies($plugin);

        $pluginDependencies = $this->validateComposerPackages($pluginDependencies$exceptionStack);
        $pluginDependencies = $this->validateInstalledPlugins($context$plugin$pluginDependencies$exceptionStack);
        $pluginDependencies = $this->validateShippedDependencies($plugin$pluginDependencies$exceptionStack);

        $this->addRemainingRequirementsAsException($pluginDependencies['require']$exceptionStack);

        $exceptionStack->tryToThrow($method);
    }

    /** * resolveActiveDependants returns all active dependants of the given plugin. * * @param PluginEntity[] $dependants the plugins to check for a dependency on the given plugin * * @return PluginEntity[] */
    public function resolveActiveDependants(PluginEntity $dependency, array $dependants): array
    {
        
if ($field instanceof TranslationsAssociationField) {
                    $nested->setLimit(null);
                }
            }
        }

        if (isset($payload['fields'])) {
            $criteria->addFields($payload['fields']);
        }

        $searchException->tryToThrow();

        $this->validator->validate($definition->getEntityName()$criteria$context);

        return $criteria;
    }

    /** * @param list<array{order: string, type: string, field: string}> $sorting * * @return list<FieldSorting> */
    
Feature::ifNotActive('v6.6.0.0', fn () => $this->eventDispatcher->dispatch($entityDeleteEventLegacy));
        }

        // throws exception on violation and then aborts/rollbacks this transaction         $event = new PreWriteValidationEvent($context$commands);
        $this->eventDispatcher->dispatch($event);
        /** @var list<WriteCommand> $commands */
        $commands = $event->getCommands();

        $this->generateChangeSets($commands);

        $context->getExceptions()->tryToThrow();

        $previous = null;
        $mappings = new MultiInsertQueryQueue($this->connection, $this->batchSize, false, true);
        $inserts = new MultiInsertQueryQueue($this->connection, $this->batchSize);

        $executeInserts = function D) use ($mappings$inserts): void {
            $mappings->execute();
            $inserts->execute();
        };

        try {
            
$missingPrivileges[] = $resource . ':' . $privilege;
            }

            $event = new CommandAclValidationEvent($missingPrivileges$source$command);
            $this->eventDispatcher->dispatch($event);
            /** * @var list<string> $missingPrivileges */
            $missingPrivileges = $event->getMissingPrivileges();
        }

        $this->tryToThrow($missingPrivileges);
    }

    /** * @param list<string> $missingPrivileges */
    private function tryToThrow(array $missingPrivileges): void
    {
        if (!empty($missingPrivileges)) {
            throw ApiException::missingPrivileges($missingPrivileges);
        }
    }

    


        $fakeConnection = new FakeConnection([]);

        $event = new PreWriteValidationEvent($this->context, $commands);
        $validator = new ShippingMethodValidator($fakeConnection);
        $validator->preValidate($event);

        $exception = null;

        try {
            $event->getExceptions()->tryToThrow();
        } catch (WriteException $e) {
            $exception = $e;
        }

        if (!$success) {
            static::assertNotNull($exception);
            static::assertEquals(WriteConstraintViolationException::class$exception->getExceptions()[0]::class);
        } else {
            static::assertNull($exception);
        }
    }

    
foreach ($payload as $index => $row) {
                    $parameters->setPath('/' . $key . '/' . $index);
                    $context->resetPaths();
                    $this->commandExtractor->extract($row$parameters);
                }

                $writes[] = $this->factory->resolveWrite($definition$payload);
            }
        }

        $context->getExceptions()->tryToThrow();

        $this->gateway->execute($commandQueue->getCommandsInOrder()$context);

        $result = $this->factory->build($commandQueue);

        $notFound = array_merge_recursive(...$notFound);

        $writes = array_merge_recursive(...$writes);

        $deletes = array_merge_recursive(...$deletes);

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