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
[Docs] Add docs for custom entity with access per admin channel #12619
[Docs] Add docs for custom entity with access per admin channel #12619
Conversation
Tomanhez
commented
May 10, 2021
•
edited
edited
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
License | MIT |
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.
Good to have this document here, but we should think about making this process simpler
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
use Symfony\Component\OptionsResolver\Options; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
final class ChannelPerAdminChannelType extends AbstractType |
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.
Can we have this form type predefined in Plus and use it somewhere?
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.
Yep. I think we should replace all places with ChannelChoiceType
for ChannelPerAdminChannelChoiceType
. This is not scope this task, but good improvement in future. Next good improvement is to add resources name as parameters in services, without decorating ResourceChannelEnabilibityChecker
service:
Now:
final class ResourceChannelEnabilibityChecker implements ResourceChannelEnabilibityCheckerInterface
{
public function forResourceName(string $resourceName): bool
{
return in_array($resourceName, [
'credit_memo',
'customer',
'invoice',
'order',
'payment',
'product',
'product_variant',
'return_request',
'shipment',
]);
}
}
It could be more generic, for example:
final class ResourceChannelEnabilibityChecker implements ResourceChannelEnabilibityCheckerInterface
{
private $resources;
public function __construct($resources)
{
$this->resources = array_merge(
$resources,
[
'credit_memo',
'customer',
'invoice',
'order',
'payment',
'product',
'product_variant',
'return_request',
'shipment',
]
);
}
public function forResourceName(string $resourceName): bool
{
return in_array($resourceName, $this->resources);
}
After this changes, final application needs overwrite only service and add new entity names
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
8ecdf55
to
2ab2627
Compare
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
2ab2627
to
7ea7c33
Compare
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
use Sylius\Plus\ChannelAdmin\Application\Checker\ResourceChannelCheckerInterface; | ||
use Sylius\Plus\Entity\ChannelInterface; | ||
|
||
final class ResourceChannelChecker implements ResourceChannelCheckerInterface |
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.
We definitely should at least define in ResourceChannelChecker
, in Plus the behaviour for checking the entity with ChannelAwareInterface
and then recommend for implementing this interface instead of decorating this service
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
817a2aa
to
0af4801
Compare
docs/cookbook/entities/custom-model-accessible-per-admin-channel.rst
Outdated
Show resolved
Hide resolved
676df9e
to
1c17671
Compare
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
1c17671
to
e8b7bc1
Compare
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
e8b7bc1
to
5b49812
Compare
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
30ab0f5
to
251beda
Compare
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
251beda
to
da03535
Compare
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
91af348
to
5239b2d
Compare
docs/cookbook/entities/custom-model-accessible-for-channel-admin.rst
Outdated
Show resolved
Hide resolved
The base of this pull-request was changed, you need fetch and reset your local branch Unless you added new commits (to this branch) locally that you did not push yet, Feel free to ask for assistance when you get stuck 👍 |
5239b2d
to
6dc078e
Compare
Thank you, Tomasz! 🎉 |
…ccessing to entities by channel admins (GSadee) This PR was merged into the 1.9 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.9 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | improvements to #12619 | License | MIT Commits ------- 3266c30 [Documentation][Plus] Minor improvements in cookbook for accessing to entities by channel admins