forked from vmelnik-ukraine/DoctrineEncryptBundle
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated namespaces, added new code to subscriber
- Loading branch information
1 parent
e9030a4
commit 2fc0380
Showing
18 changed files
with
208 additions
and
159 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
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,61 @@ | ||
<?php | ||
|
||
namespace Ambta\DoctrineEncryptBundle\DependencyInjection; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
use Symfony\Component\DependencyInjection\Loader; | ||
use Symfony\Component\DependencyInjection\Definition; | ||
|
||
/** | ||
* 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 DoctrineEncryptExtension extends Extension { | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) { | ||
|
||
$configuration = new Configuration(); | ||
$config = $this->processConfiguration($configuration, $configs); | ||
|
||
$services = array('orm' => 'orm-services'); | ||
$supportedEncryptorClasses = array('aes256' => 'Ambta\DoctrineEncryptBundle\Encryptors\AES256Encryptor'); | ||
|
||
if (empty($config['secret_key'])) { | ||
if ($container->hasParameter('secret')) { | ||
$config['secret_key'] = $container->getParameter('secret'); | ||
} else { | ||
throw new \RuntimeException('You must provide "secret_key" for DoctrineEncryptBundle or "secret" for framework'); | ||
} | ||
} | ||
|
||
if (!empty($config['encryptor_class'])) { | ||
$encryptorFullName = $config['encryptor_class']; | ||
} else { | ||
$encryptorFullName = $supportedEncryptorClasses[$config['encryptor']]; | ||
} | ||
|
||
$container->setParameter('ambta_doctrine_encrypt.encryptor_class_name', $encryptorFullName); | ||
$container->setParameter('ambta_doctrine_encrypt.secret_key', $config['secret_key']); | ||
|
||
if (!empty($config['encryptor_service'])) { | ||
$container->setParameter('ambta_doctrine_encrypt.encryptor_service', $config['encryptor_service']); | ||
} | ||
|
||
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); | ||
$loader->load(sprintf('%s.yml', $services[$config['db_driver']])); | ||
} | ||
|
||
|
||
public function getAlias() { | ||
return 'ambta_doctrine_encrypt'; | ||
} | ||
|
||
} |
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,8 @@ | ||
services: | ||
ambta_doctrine_encrypt.orm_subscriber: | ||
class: %ambta_doctrine_encrypt.orm_subscriber.class% | ||
arguments: ["@annotation_reader", %ambta_doctrine_encrypt.encryptor_class_name%, %ambta_doctrine_encrypt.secret_key%] | ||
tags: | ||
- { name: doctrine.event_subscriber } | ||
ambta_doctrine_encrypt.subscriber: | ||
alias: ambta_doctrine_encrypt.orm_subscriber |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
services: | ||
ambta_doctrine_encrypt.orm_subscriber: | ||
class: Ambta\DoctrineEncryptBundle\Subscribers\DoctrineEncryptSubscriber | ||
arguments: ["@annotation_reader", %ambta_doctrine_encrypt.encryptor_class_name%, %ambta_doctrine_encrypt.secret_key%] | ||
tags: | ||
- { name: doctrine.event_subscriber } | ||
ambta_doctrine_encrypt.subscriber: | ||
alias: ambta_doctrine_encrypt.orm_subscriber |
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.