Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2488 from laboro/feature/BAP-11132_Feature_Toggle
BAP-11132: feature toggle
- Loading branch information
Showing
93 changed files
with
5,553 additions
and
62 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/Oro/Bundle/ActionBundle/Configuration/FeatureConfigurationExtension.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,21 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ActionBundle\Configuration; | ||
|
||
use Oro\Bundle\FeatureToggleBundle\Configuration\ConfigurationExtensionInterface; | ||
use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
|
||
class FeatureConfigurationExtension implements ConfigurationExtensionInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function extendConfigurationTree(NodeBuilder $node) | ||
{ | ||
$node | ||
->arrayNode('operations') | ||
->prototype('variable') | ||
->end() | ||
->end(); | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
src/Oro/Bundle/ApiBundle/Config/FeatureConfigurationExtension.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,21 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ApiBundle\Config; | ||
|
||
use Oro\Bundle\FeatureToggleBundle\Configuration\ConfigurationExtensionInterface; | ||
use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
|
||
class FeatureConfigurationExtension implements ConfigurationExtensionInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function extendConfigurationTree(NodeBuilder $node) | ||
{ | ||
$node | ||
->arrayNode('api_resources') | ||
->prototype('variable') | ||
->end() | ||
->end(); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/Oro/Bundle/ApiBundle/Processor/Shared/EntityTypeFeatureCheck.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,44 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ApiBundle\Processor\Shared; | ||
|
||
use Oro\Bundle\ApiBundle\Processor\Context; | ||
use Oro\Bundle\FeatureToggleBundle\Checker\FeatureChecker; | ||
use Oro\Component\ChainProcessor\ContextInterface; | ||
use Oro\Component\ChainProcessor\ProcessorInterface; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
/** | ||
* Validates whether an feature is enabled for the type of entities specified | ||
* in the "class" property of the Context. | ||
*/ | ||
class EntityTypeFeatureCheck implements ProcessorInterface | ||
{ | ||
const API_RESOURCE_KEY = 'api_resources'; | ||
|
||
/** | ||
* @var FeatureChecker | ||
*/ | ||
protected $featureChecker; | ||
|
||
/** | ||
* @param FeatureChecker $featureChecker | ||
*/ | ||
public function __construct(FeatureChecker $featureChecker) | ||
{ | ||
$this->featureChecker = $featureChecker; | ||
} | ||
|
||
/** | ||
* @param Context $context | ||
* | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContextInterface $context) | ||
{ | ||
$entityClass = $context->getClassName(); | ||
if (!$this->featureChecker->isResourceEnabled($entityClass, self::API_RESOURCE_KEY)) { | ||
throw new AccessDeniedException(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Oro/Bundle/ApiBundle/Processor/Subresource/Shared/ParentEntityTypeFeatureCheck.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,44 @@ | ||
<?php | ||
|
||
namespace Oro\Bundle\ApiBundle\Processor\Subresource\Shared; | ||
|
||
use Oro\Bundle\ApiBundle\Processor\Subresource\SubresourceContext; | ||
use Oro\Bundle\FeatureToggleBundle\Checker\FeatureChecker; | ||
use Oro\Component\ChainProcessor\ContextInterface; | ||
use Oro\Component\ChainProcessor\ProcessorInterface; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
/** | ||
* Validates whether an feature is enabled for the type of entities specified | ||
* in the "parentClass" property of the Context. | ||
*/ | ||
class ParentEntityTypeFeatureCheck implements ProcessorInterface | ||
{ | ||
const API_RESOURCE_KEY = 'api_resources'; | ||
|
||
/** | ||
* @var FeatureChecker | ||
*/ | ||
protected $featureChecker; | ||
|
||
/** | ||
* @param FeatureChecker $featureChecker | ||
*/ | ||
public function __construct(FeatureChecker $featureChecker) | ||
{ | ||
$this->featureChecker = $featureChecker; | ||
} | ||
|
||
/** | ||
* @var SubresourceContext $context | ||
* | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContextInterface $context) | ||
{ | ||
$parentClassName = $context->getParentClassName(); | ||
if (!$this->featureChecker->isResourceEnabled($parentClassName, self::API_RESOURCE_KEY)) { | ||
throw new AccessDeniedException(); | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.