-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-22: Add logic to process changes in Sales Channel (#46)
- Added voter that use to check is sales channel group links to any integration and forbid delete action for this case - Added logic to process enabling/disabling, removing Sales Channel
- Loading branch information
1 parent
854eab6
commit d9db8bb
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Marello/Bundle/SalesBundle/Acl/Voter/SalesChannelGroupVoter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Marello\Bundle\SalesBundle\Acl\Voter; | ||
|
||
use Marello\Bundle\SalesBundle\Entity\Repository\SalesChannelGroupRepository; | ||
use Marello\Bundle\SalesBundle\Entity\SalesChannelGroup; | ||
use Oro\Bundle\SecurityBundle\Acl\BasicPermission; | ||
use Oro\Bundle\SecurityBundle\Acl\Voter\AbstractEntityVoter; | ||
|
||
/** | ||
* Disables deleting the sales channel group in case when it has attached integration | ||
*/ | ||
class SalesChannelGroupVoter extends AbstractEntityVoter | ||
{ | ||
/** @var array */ | ||
protected $supportedAttributes = [BasicPermission::DELETE]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getPermissionForAttribute($class, $identifier, $attribute) | ||
{ | ||
/** @var SalesChannelGroupRepository $scgRepository */ | ||
$scgRepository = $this->doctrineHelper->getEntityRepository(SalesChannelGroup::class); | ||
|
||
if ($scgRepository->hasAttachedIntegration($identifier)) { | ||
return self::ACCESS_DENIED; | ||
} | ||
|
||
return self::ACCESS_ABSTAIN; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters