hasError example

$label      = $field;
        $field      = 'temp';
        $validation = Services::validation(null, false);
        $validation->setRules([
            $field => [
                'label' => $label,
                'rules' => $rules,
            ],
        ]);
        $validation->run([$field => $value]);

        if ($validation->hasError($field)) {
            static::error($validation->getError($field));

            return false;
        }

        return true;
    }

    /** * Outputs a string to the CLI without any surrounding newlines. * Useful for showing repeating elements on a single line. * * @return void */
$app->view()->setData('error', (bool) $systemCheckResults['hasErrors']);
    $app->view()->setData('systemError', (bool) $systemCheckResults['hasErrors']);
    $app->view()->setData('phpVersionNotSupported', $systemCheckResults['phpVersionNotSupported']);

    // Check file & directory permissions     /** @var RequirementsPath $shopwareSystemCheckPath */
    $shopwareSystemCheckPath = $container->offsetGet('install.requirementsPath');
    $shopwareSystemCheckPathResult = $shopwareSystemCheckPath->check();

    $app->view()->setData('pathError', false);

    if ($shopwareSystemCheckPathResult->hasError()) {
        $app->view()->setData('error', true);
        $app->view()->setData('pathError', true);
    }

    if ($app->request()->isPost() && $app->view()->getData('error') == false) {
        // No errors and submitted form - proceed with next-step         $app->redirect($menuHelper->getNextUrl());
    }

    $app->render('/requirements.php', [
        'systemCheckResults' => $systemCheckResults['checks'],
        


    #[Route(path: '/installer/requirements', name: 'installer.requirements', methods: ['GET', 'POST'])]     public function requirements(Request $request): Response
    {
        $checks = new RequirementsCheckCollection();

        foreach ($this->validators as $validator) {
            $checks = $validator->validateRequirements($checks);
        }

        if ($request->isMethod('POST') && !$checks->hasError()) {
            // The JWT dir exist and is writable, so we generate a new key pair             $this->jwtCertificateGenerator->generate(
                $this->jwtDir . '/private.pem',
                $this->jwtDir . '/public.pem'
            );

            return $this->redirectToRoute('installer.license');
        }

        return $this->renderInstaller('@Installer/installer/requirements.html.twig', ['requirementChecks' => $checks]);
    }
}

        return $this->filterInstance(SystemCheck::class);
    }

    public function hasError(): bool
    {
        return $this->filter(static fn (RequirementCheck $check): bool => $check->getStatus() === RequirementCheck::STATUS_ERROR)->first() !== null;
    }

    public function hasPathError(): bool
    {
        return $this->getPathChecks()->hasError();
    }

    public function hasSystemError(): bool
    {
        return $this->getSystemChecks()->hasError();
    }

    protected function getExpectedClass(): ?string
    {
        return RequirementCheck::class;
    }
}


    /** * @param RequirementCheck[] $elements * * @dataProvider errorProvider */
    public function testHasError(array $elements, bool $expected): void
    {
        $collection = new RequirementsCheckCollection($elements);

        static::assertSame($expected$collection->hasError());
    }

    public static function errorProvider(): \Generator
    {
        $successCheck = new PathCheck('name', RequirementCheck::STATUS_SUCCESS);
        $errorCheck = new PathCheck('name', RequirementCheck::STATUS_ERROR);
        $warningCheck = new PathCheck('name', RequirementCheck::STATUS_WARNING);

        yield 'empty checks' => [
            [],
            false,
        ];
Home | Imprint | This part of the site doesn't use cookies.