Closed cavasinf closed 5 months ago
This seems reasonable - we should give the tags an optional priority and the highest priority wins. PR welcome :)
@cavasinf,
As provided above.
# src/Maker/CrudMaker.php
namespace App\Maker;
use Symfony\Bundle\MakerBundle\ConsoleStyle;
use Symfony\Bundle\MakerBundle\DependencyBuilder;
use Symfony\Bundle\MakerBundle\Generator;
use Symfony\Bundle\MakerBundle\InputConfiguration;
use Symfony\Bundle\MakerBundle\Maker\AbstractMaker;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
class CrudMaker extends AbstractMaker
{
public static function getCommandName(): string
{
return 'make:crud';
}
public static function getCommandDescription(): string
{
return 'CRUD Maker override';
}
public function configureCommand(Command $command, InputConfiguration $inputConfig)
{
// TODO: Implement configureCommand() method.
}
public function configureDependencies(DependencyBuilder $dependencies)
{
// TODO: Implement configureDependencies() method.
}
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
{
$this->writeSuccessMessage($io);
$io->text('CRUD Maker override');
}
}
Solution -> overwrite service id to overwrite command
# config/services.yaml
services:
# ...
maker.maker.make_crud:
alias: 'App\Maker\CrudMaker'
Result:-
Placement same and overwrite works as expected.
make
make:auth Creates a Guard authenticator of different flavors
make:command Creates a new console command class
make:controller Creates a new controller class
make:crud CRUD Maker override
make:docker:database Adds a database container to your docker-compose.yaml file
make:entity Creates or updates a Doctrine entity class, and optionally an API Platform resource
make:fixtures Creates a new class to load Doctrine fixtures
make:form Creates a new form class
@susonwaiba is that a temporary fix or the final solution?
@weaverryan can you please, suggest your view.
Howdy! - For now, we're are going to go with @susonwaiba solution of overriding the service via an alias in services.yaml
. E.g.
# config/services.yaml
services:
# ...
maker.maker.make_crud:
alias: App\Maker\CrudMaker
We currently do not have any immediate plans on implementing command priorities in MakerBundle. However, if someone would like submit PR with such a feature - we'll be happy to give it a review... Thanks!
Hi, I want to make some changes with the current crud maker command:
Since we are not able to extend existing Maker NOR change skeletons, I want to "override" the existing
make:crud
from MakerBundle.I've created my own CrudMaker in
src/Maker
with the command name asmake:crud
, but it doesn't hide or override the default one.Here's my Maker:
Result of
php bin/console make:
:ATE, it just moved to the top of the list. Are we also not able to replace existing Makers?
In our company we are used to mechanically typing
make:crud
when we work. And this custom Maker is only for ONE of our Symfony projects. So I don't want to create a new command likemake:front
and tell others "in this specific project and case, use this because this and not the defaultmake:crud
"... So I really want to make the transition to the new maker as invisible as possible to others.Version
5.4.15
1.48.0