Getting Started
Formatting Blade
Parsing Templates
Blade Documents
Compilation
Validation
Workspaces
Validating workspaces works the same as validating individual documents. The difference is that all the configured nodes and document validators will be executed against all documents within the workspace.
1<?php 2use Stillat\BladeParser\Errors\BladeError; 3use Stillat\BladeParser\Workspaces\Workspace; 4 5$workspace = new Workspace(); 6$workspace->addDirectory(resource_path('views')) 7 ->withCoreValidators() 8 ->validate()->getValidationErrors()->each(function (BladeError $error) { 9 // Interact with the validation error.10 });
Validates all documents within the workspace using the internal BladeValidator
instance.
1<?php2 3use Stillat\BladeParser\Workspaces\Workspace;4 5public function validate(): Workspace;
Returns all validation errors present in the workspace.
1<?php2 3use Illuminate\Support\Collection;4 5public function getValidationErrors(): Collection;
Includes the core validators on the internal BladeValidator
instance.
If a BladeValidator
instance does not already exist on the document, a new one will be created automatically via the ValidatorFactory::makeBladeValidator()
factory method.
Under a typical installation environment, this will load the validators that are configured under the config path: blade.validation.core_validators
1<?php2 3use Stillat\BladeParser\Workspaces\Workspace;4 5public function withCoreValidators(): Workspace;
Returns access to an internal BladeValidator
instance.
If a validator instance does not already exist, one will be automatically created by calling the ValidatorFactory::makeBladeValidator()
method.
1<?php2 3use Stillat\BladeParser\Validation\BladeValidator;4 5public function validator(): BladeValidator;
Adds a single node validator instance to the internal BladeValidator
instance.
Argument | Description |
---|---|
$validator | The node validator. |
1<?php2 3use Stillat\BladeParser\Validation\AbstractNodeValidator;4use Stillat\BladeParser\Workspaces\Workspace;5 6public function addValidator(7 AbstractNodeValidator $validator8): Workspace;
Adds a single document validator instance to the internal BladeValidator
instance.
Argument | Description |
---|---|
$validator | The document validator. |
1<?php2 3use Stillat\BladeParser\Validation\AbstractDocumentValidator;4use Stillat\BladeParser\Workspaces\Workspace;5 6public function addDocumentValidator(7 AbstractDocumentValidator $validator8): Workspace;
Adds a validator instance to the internal BladeValidator
instance.
Argument | Description |
---|---|
$validator | The validator instance. |
1<?php2 3use Stillat\BladeParser\Validation\AbstractNodeValidator;4use Stillat\BladeParser\Workspaces\Workspace;5 6public function withValidator(7 AbstractNodeValidator $validator8): Workspace;
Adds a list of validator instances to the internal BladeValidator
instance.
Argument | Description |
---|---|
$validators | The validator instances. |
1<?php2 3use Stillat\BladeParser\Workspaces\Workspace;4 5public function withValidators(6 array $validators7): Workspace;
Tests if any errors are present.
1<?php2 3public function hasErrors(): bool;
Tests if any fatal errors are present.
1<?php2 3public function hasFatalErrors(): bool;
Retrieves a collection of BladeError
instances for the workspace.
1<?php2 3use Illuminate\Support\Collection;4 5public function getErrors(): Collection;
Retrieves the first error.
If the error source contains multiple types of errors, such as parser errors and validation errors, all errors will be considered.
1<?php2 3use Stillat\BladeParser\Errors\BladeError;4 5public function getFirstError(): BladeError;
Retrieves the first fatal error.
If the error source contains multiple types of errors, such as parser errors and validation errors, all errors will be considered. Fatal errors are considered those that would produce invalid compiled PHP code, regardless of which compiler implementation is used.
1<?php2 3use Stillat\BladeParser\Errors\BladeError;4 5public function getFirstFatalError(): BladeError;
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.