mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 16:30:51 +00:00
[Doc] Documentation how to register custom SetList contant (#5921)
This commit is contained in:
parent
6b8631f789
commit
57acbe7cdc
37
docs/how_to_register_custom_setlist_constant.md
Normal file
37
docs/how_to_register_custom_setlist_constant.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
# How To Register Custom SetList Constant
|
||||
|
||||
You can have custom `SetList` class that has constants that pointed to your own config, for example:
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace App\Set\ValueObject;
|
||||
|
||||
use Rector\Set\Contract\SetListInterface;
|
||||
|
||||
class SetList implements SetListInterface
|
||||
{
|
||||
public const MY_FRAMEWORK_20 = __DIR__ . '/../../../config/set/my-framework-20.php';
|
||||
}
|
||||
```
|
||||
|
||||
Now, you can register your custom `SetList`'s constant via import from `$containerConfigurator`, for example:
|
||||
|
||||
|
||||
```php
|
||||
<?php
|
||||
// rector.php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use App\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$containerConfigurator->import(SetList::MY_FRAMEWORK_20);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(Option::PATHS, [__DIR__ . '/src']);
|
||||
};
|
||||
```
|
Loading…
Reference in New Issue
Block a user