public function boot()
 {
     if (false === Type::hasType(ExtendedDataType::NAME)) {
         ExtendedDataType::setEncryptionService($this->container->get('payment.encryption_service'));
         Type::addType(ExtendedDataType::NAME, 'JMS\\Payment\\CoreBundle\\Entity\\ExtendedDataType');
     }
 }
 public function process(ContainerBuilder $container)
 {
     if (false !== Type::hasType(ExtendedDataType::NAME)) {
         return;
     }
     ExtendedDataType::setEncryptionService($container->get('payment.encryption_service'));
     Type::addType(ExtendedDataType::NAME, 'JMS\\Payment\\CoreBundle\\Entity\\ExtendedDataType');
 }
 public function boot()
 {
     if (false === Type::hasType(ExtendedDataType::NAME)) {
         ExtendedDataType::setEncryptionService($this->container->get('payment.encryption_service'));
         Type::addType(ExtendedDataType::NAME, 'JMS\\Payment\\CoreBundle\\Entity\\ExtendedDataType');
         if ($this->container->has('doctrine.dbal.default_connection')) {
             $platform = $this->container->get('doctrine.dbal.default_connection')->getDatabasePlatform();
             $platform->markDoctrineTypeCommented(Type::getType(ExtendedDataType::NAME));
         }
     }
 }
 public function testConversion()
 {
     ExtendedDataType::setEncryptionService(new MCryptEncryptionService('foo'));
     $extendedData = new ExtendedData();
     $extendedData->set('foo', 'foo', false);
     $extendedData->set('foo2', 'secret', true);
     $extendedData->set('foo3', 'foo', false);
     $type = Type::getType(ExtendedDataType::NAME);
     $serialized = $type->convertToDatabaseValue($extendedData, $this->getPlatform());
     $this->assertTrue(false !== ($unserialized = unserialize($serialized)));
     $this->assertInternalType('array', $unserialized);
     $this->assertEquals('secret', $extendedData->get('foo2'), 'ExtendedData object is not affected by encryption.');
     $this->assertEquals('foo', $extendedData->get('foo'), 'ExtendedData object is not affected by conversion.');
     $this->assertEquals('foo', $unserialized['foo'][0]);
     $this->assertNotEquals('secret', $unserialized['foo2'][0]);
     $this->assertEquals('foo', $unserialized['foo3'][0]);
     $extendedData = $type->convertToPHPValue($serialized, $this->getPlatform());
     $this->assertEquals('foo', $extendedData->get('foo'));
     $this->assertEquals('secret', $extendedData->get('foo2'));
     $this->assertEquals('foo', $extendedData->get('foo'));
 }