Skip to content

Commit

Permalink
CC-25813: Tech Debt for AclMerchantPortal module (#9927)
Browse files Browse the repository at this point in the history
Tech Debt for AclMerchantPortal module
  • Loading branch information
dmiseev authored Mar 10, 2023
1 parent 0fc2010 commit 08971b8
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 1 deletion.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
"license": "proprietary",
"require": {
"php": ">=8.0",
"spryker/acl-merchant-portal-extension": "^1.0.0",
"spryker/application-extension": "^1.0.0",
"spryker/event-dispatcher-extension": "^1.0.0",
"spryker/kernel": "^3.52.0",
"spryker/locale-extension": "^1.0.0",
"spryker/propel-orm": "^1.8.0"
"spryker/propel-orm": "^1.8.0",
"spryker/transfer": "^3.25.0"
},
"require-dev": {
"spryker/code-sniffer": "*",
Expand Down
5 changes: 5 additions & 0 deletions dependency.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"include": {
"spryker/transfer": "Provides transfer objects definition with `::get*OrFail()` functionality."
}
}
19 changes: 19 additions & 0 deletions src/Spryker/Shared/Locale/Transfer/locale.transfer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,23 @@
<property name="localeName" type="string"/>
<property name="isActive" type="bool"/>
</transfer>

<transfer name="AclEntityMetadataConfig">
<property name="aclEntityMetadataCollection" type="AclEntityMetadataCollection"/>
</transfer>

<transfer name="AclEntityMetadata">
<property name="entityName" type="string"/>
<property name="defaultGlobalOperationMask" type="int"/>
</transfer>

<transfer name="AclEntityMetadataCollection">
<property name="collection" type="array" singular="aclEntityMetadata" associative="true"/>
</transfer>

<transfer name="AclEntityRule">
<property name="entity" type="string"/>
<property name="scope" type="string"/>
<property name="permissionMask" type="int"/>
</transfer>
</transfers>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\Locale\Communication\Plugin\AclMerchantPortal;

use Generated\Shared\Transfer\AclEntityMetadataConfigTransfer;
use Generated\Shared\Transfer\AclEntityMetadataTransfer;
use Spryker\Zed\AclMerchantPortalExtension\Dependency\Plugin\AclEntityConfigurationExpanderPluginInterface;
use Spryker\Zed\Kernel\Communication\AbstractPlugin;

/**
* @method \Spryker\Zed\Locale\Business\LocaleFacadeInterface getFacade()
* @method \Spryker\Zed\Locale\LocaleConfig getConfig()
* @method \Spryker\Zed\Locale\Persistence\LocaleQueryContainerInterface getQueryContainer()
* @method \Spryker\Zed\Locale\Communication\LocaleCommunicationFactory getFactory()
*/
class LocaleAclEntityConfigurationExpanderPlugin extends AbstractPlugin implements AclEntityConfigurationExpanderPluginInterface
{
/**
* @uses {@link \Spryker\Shared\AclEntity\AclEntityConstants::OPERATION_MASK_READ}
*
* @var int
*/
protected const OPERATION_MASK_READ = 0b1;

/**
* {@inheritDoc}
* - Expands provided `AclEntityMetadataConfig` transfer object with locale composite data.
*
* @api
*
* @param \Generated\Shared\Transfer\AclEntityMetadataConfigTransfer $aclEntityMetadataConfigTransfer
*
* @return \Generated\Shared\Transfer\AclEntityMetadataConfigTransfer
*/
public function expand(AclEntityMetadataConfigTransfer $aclEntityMetadataConfigTransfer): AclEntityMetadataConfigTransfer
{
$aclEntityMetadataConfigTransfer
->getAclEntityMetadataCollectionOrFail()
->addAclEntityMetadata(
'Orm\Zed\Locale\Persistence\SpyLocale',
(new AclEntityMetadataTransfer())
->setEntityName('Orm\Zed\Locale\Persistence\SpyLocale')
->setDefaultGlobalOperationMask(static::OPERATION_MASK_READ),
);

return $aclEntityMetadataConfigTransfer;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/**
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
*/

namespace Spryker\Zed\Locale\Communication\Plugin\AclMerchantPortal;

use Generated\Shared\Transfer\AclEntityRuleTransfer;
use Spryker\Zed\AclMerchantPortalExtension\Dependency\Plugin\MerchantAclEntityRuleExpanderPluginInterface;
use Spryker\Zed\Kernel\Communication\AbstractPlugin;

/**
* @method \Spryker\Zed\Locale\Business\LocaleFacadeInterface getFacade()
* @method \Spryker\Zed\Locale\LocaleConfig getConfig()
* @method \Spryker\Zed\Locale\Communication\LocaleCommunicationFactory getFactory()
* @method \Spryker\Zed\Locale\Persistence\LocaleQueryContainerInterface getQueryContainer()
*/
class LocaleMerchantAclEntityRuleExpanderPlugin extends AbstractPlugin implements MerchantAclEntityRuleExpanderPluginInterface
{
/**
* @uses {@link \Spryker\Shared\AclEntity\AclEntityConstants::SCOPE_GLOBAL}
*
* @var string
*/
protected const SCOPE_GLOBAL = 'global';

/**
* @uses {@link \Spryker\Shared\AclEntity\AclEntityConstants::OPERATION_MASK_READ}
*
* @var int
*/
protected const OPERATION_MASK_READ = 0b1;

/**
* {@inheritDoc}
* - Expands set of `AclEntityRule` transfer objects with locale composite data.
*
* @api
*
* @param list<\Generated\Shared\Transfer\AclEntityRuleTransfer> $aclEntityRuleTransfers
*
* @return list<\Generated\Shared\Transfer\AclEntityRuleTransfer>
*/
public function expand(array $aclEntityRuleTransfers): array
{
$aclEntityRuleTransfers[] = (new AclEntityRuleTransfer())
->setEntity('Orm\Zed\Locale\Persistence\SpyLocale')
->setScope(static::SCOPE_GLOBAL)
->setPermissionMask(static::OPERATION_MASK_READ);

return $aclEntityRuleTransfers;
}
}

0 comments on commit 08971b8

Please sign in to comment.