forked from absolute-quantum/DoctrineEncryptBundle
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new configuration-key to migrate to
- Loading branch information
Showing
17 changed files
with
197 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Things we need to do before we can release 6.0 | ||
* [ ] Remove \Ambta\DoctrineEncryptBundle\DependencyInjection\DoctrineEncryptExtension::$wrapExceptions | ||
* [ ] Remove wrap_exceptions from configuration of the bundle | ||
* [ ] Remove wrap_exceptions from configuration of the bundle | ||
* [ ] Remove DeprecatedDoctrineEncryptExtension | ||
* [ ] Remove tests and demo using old `ambta_doctrine_encrypt` as configuration-key |
2 changes: 1 addition & 1 deletion
2
...nfig/packages/ambta_doctrine_encrypt.yaml → ...fig/packages/doctrine_encrypt_bundle.yaml
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ambta_doctrine_encrypt: | ||
doctrine_encrypt_bundle: | ||
enable_secret_generation: false | ||
secret: '%env(HALITE_SECRET)%' |
2 changes: 1 addition & 1 deletion
2
...nfig/packages/ambta_doctrine_encrypt.yaml → ...fig/packages/doctrine_encrypt_bundle.yaml
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ambta_doctrine_encrypt: | ||
doctrine_encrypt_bundle: | ||
enable_secret_generation: false | ||
secret: '%env(HALITE_SECRET)%' |
2 changes: 1 addition & 1 deletion
2
...nfig/packages/ambta_doctrine_encrypt.yaml → ...fig/packages/doctrine_encrypt_bundle.yaml
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ambta_doctrine_encrypt: | ||
doctrine_encrypt_bundle: | ||
enable_secret_generation: false | ||
secret: '%env(HALITE_SECRET)%' |
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
36 changes: 36 additions & 0 deletions
36
src/DependencyInjection/DeprecatedDoctrineEncryptExtension.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,36 @@ | ||
<?php | ||
|
||
namespace Ambta\DoctrineEncryptBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* Initialization of bundle. | ||
* | ||
* This is the class that loads and manages your bundle configuration | ||
* | ||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} | ||
*/ | ||
class DeprecatedDoctrineEncryptExtension extends DoctrineEncryptExtension | ||
{ | ||
public function getAlias(): string | ||
{ | ||
return 'ambta_doctrine_encrypt'; | ||
} | ||
|
||
public function load(array $configs, ContainerBuilder $container): void | ||
{ | ||
if (!empty($configs)) { | ||
trigger_deprecation( | ||
'doctrineencryptbundle/doctrine-encrypt-bundle', | ||
'5.4.2', | ||
<<<'EOF' | ||
Using `ambta_doctrine_encrypt` as the configuration-key is deprecated and you should replace this with `doctrine_encrypt_bundle`. | ||
Starting from 6.0, only `doctrine_encrypt_bundle` will be supported. | ||
EOF | ||
); | ||
|
||
parent::load($configs, $container); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ambta\DoctrineEncryptBundle\Tests\Unit; | ||
|
||
use Ambta\DoctrineEncryptBundle\AmbtaDoctrineEncryptBundle; | ||
use Ambta\DoctrineEncryptBundle\DependencyInjection\DoctrineEncryptExtension; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | ||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; | ||
|
||
class AmbtaDoctrineEncryptBundleTest extends TestCase | ||
{ | ||
use ExpectDeprecationTrait; | ||
|
||
private function createContainer(): ContainerBuilder | ||
{ | ||
return new ContainerBuilder( | ||
new ParameterBag(['kernel.debug' => false]) | ||
); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
DoctrineEncryptExtension::wrapExceptions(false); | ||
} | ||
|
||
/** | ||
* @group legacy | ||
*/ | ||
public function testContainerIsAbleToConfigFromOldNamespace(): void | ||
{ | ||
$container = $this->createContainer(); | ||
|
||
$bundle = new AmbtaDoctrineEncryptBundle(); | ||
|
||
$container->registerExtension($bundle->getContainerExtension()); | ||
$bundle->build($container); | ||
|
||
$yamlLoader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../_data')); | ||
$yamlLoader->load('ambta_doctrine_encrypt.yaml'); | ||
|
||
$container->addCompilerPass(new MergeExtensionConfigurationPass()); | ||
|
||
$this->expectDeprecation('Since doctrineencryptbundle/doctrine-encrypt-bundle 5.4.2: Using `ambta_doctrine_encrypt` as the configuration-key is deprecated and you should replace this with `doctrine_encrypt_bundle`. | ||
Starting from 6.0, only `doctrine_encrypt_bundle` will be supported.'); | ||
|
||
$container->compile(); | ||
|
||
$this->assertTrue($container->hasParameter('ambta_doctrine_encrypt.secret')); | ||
$this->assertEquals('ambta_doctrine_encrypt.yaml', $container->getParameter('ambta_doctrine_encrypt.secret')); | ||
} | ||
|
||
public function testContainerIsAbleToConfigFromNewNamespace(): void | ||
{ | ||
$container = $this->createContainer(); | ||
|
||
$bundle = new AmbtaDoctrineEncryptBundle(); | ||
|
||
$container->registerExtension($bundle->getContainerExtension()); | ||
$bundle->build($container); | ||
|
||
$yamlLoader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../_data')); | ||
$yamlLoader->load('doctrine_encrypt_bundle.yaml'); | ||
|
||
$container->addCompilerPass(new MergeExtensionConfigurationPass()); | ||
|
||
$container->compile(); | ||
|
||
$this->assertTrue($container->hasParameter('ambta_doctrine_encrypt.secret')); | ||
$this->assertEquals('doctrine_encrypt_bundle.yaml', $container->getParameter('ambta_doctrine_encrypt.secret')); | ||
} | ||
} |
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.