-
-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Maker] Resource, State provider and state processor makers #705
base: 1.11
Are you sure you want to change the base?
Conversation
loic425
commented
Apr 14, 2023
Q | A |
---|---|
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Related tickets | |
License | MIT |
40079e6
to
4317a1d
Compare
4317a1d
to
dd3135a
Compare
216e72a
to
9528dfd
Compare
1774077
to
5f623ea
Compare
b5a7698
to
5ad1d7d
Compare
I suppose this one should be rebased with 1.11? cc @loic425 |
5f623ea
to
b414aba
Compare
@Zales0123 This is now ready to review :) |
use Sylius\Component\Resource\Model\ResourceInterface; | ||
use Symfony\Component\Uid\AbstractUid; | ||
|
||
#[Resource] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, I forgot to specify driver option to false.
use Sylius\Component\Resource\Metadata\Operation; | ||
use Sylius\Component\Resource\State\ProviderInterface; | ||
|
||
final class BookItemProvider implements ProviderInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be removed from git.
$shortName = $resourceClassDetails->getShortName(); | ||
|
||
if (\str_ends_with($shortName, 'Resource')) { | ||
$shortName = \mb_substr($shortName, 0, -\strlen('Resource')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that $shortName === ""
here ?
$command | ||
->setDescription(self::getCommandDescription()) | ||
->addArgument('name', InputArgument::OPTIONAL, 'Class name of the resource to create') | ||
->addOption('is-entity', null, InputOption::VALUE_NONE, 'Do you want to store resource data in the database (via Doctrine)?') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->addOption('is-entity', null, InputOption::VALUE_NONE, 'Do you want to store resource data in the database (via Doctrine)?') | |
->addOption('is-entity', null, InputOption::VALUE_NONE, 'Do you want to store resource data in the database (eg: via Doctrine)?') |
public function interact(InputInterface $input, ConsoleStyle $io, Command $command): void | ||
{ | ||
$resourceIsEntity = $io->confirm( | ||
'Do you want to store resource data in the database (via Doctrine)?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'Do you want to store resource data in the database (via Doctrine)?', | |
'Do you want to store resource data in the database (eg: via Doctrine)?', |
/** @var string $name */ | ||
$name = $input->getArgument('name'); | ||
|
||
/** @var bool $resourceIsEntity */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** @var bool $resourceIsEntity */ | |
/** @var bool|null $resourceIsEntity */ |
Maybe it's better to set a default value for this option to avoid getting null at this point, WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome feature and huge effort. Thanks Loic! However, let's take small step and add just resource generation in the first PR. It would be easier to review. And we have inconsistencies among different makers. Let's build ground rules, decide what should be part of maker and then add more makers
if (!class_exists(MakerBundle::class)) { | ||
return false; | ||
} | ||
|
||
/** @var array $bundles */ | ||
$bundles = $container->getParameter('kernel.bundles'); | ||
|
||
return in_array(MakerBundle::class, $bundles, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic skips case when the maker bundle is installed, but it turned off in the given env
return <<<EOF | ||
<?php | ||
|
||
namespace App\Tests\Tmp\Sylius\Resource; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have Sylius
in the namespace for resources but not for processors? We have the command make:resource
that have Sylius in a namespace, but then we have make:sylius-state-processor
command, which generates processor without Sylius in namespace.
#[Index( | ||
// grid: BookGrid::class, | ||
)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[Index( | |
// grid: BookGrid::class, | |
)] | |
#[Index()] |
My recommendation would be to remove all the comments from attributes. Or even all the routes in the first iteration
|
||
This file is part of the Sylius package. | ||
|
||
(c) Paweł Jędrzejewski |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--- (c) Paweł Jędrzejewski
+++ (c) Sylius Sp. z o.o.
) | ||
; | ||
|
||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exit codes consts are available since Symfony 5.4, so it could/should be used over here, but I'm unsure if it's within scope of this PR.
public const SUCCESS = 0;
public const FAILURE = 1;
public const INVALID = 2;
--- return 0;
+++ return Command::SUCCESS;