diff --git a/.idea/php.xml b/.idea/php.xml
index 94d346e..f72d448 100644
--- a/.idea/php.xml
+++ b/.idea/php.xml
@@ -81,7 +81,6 @@
-
diff --git a/DependencyInjection/Curiosity26AclHelperExtension.php b/DependencyInjection/Curiosity26AclHelperExtension.php
index b9e3b8d..e927059 100644
--- a/DependencyInjection/Curiosity26AclHelperExtension.php
+++ b/DependencyInjection/Curiosity26AclHelperExtension.php
@@ -8,12 +8,14 @@
namespace Curiosity26\AclHelperBundle\DependencyInjection;
+use Curiosity26\AclHelperBundle\Doctrine\DQL\CastAsInt;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
+use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
-class Curiosity26AclHelperExtension extends Extension
+class Curiosity26AclHelperExtension extends Extension implements PrependExtensionInterface
{
/**
* @param array $configs
@@ -26,4 +28,19 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new YamlFileLoader($container, new FileLocator([__DIR__.'/../Resources/config/']));
$loader->load('services.yaml');
}
+
+ public function prepend(ContainerBuilder $container)
+ {
+ $configs = $container->getExtensionConfig('doctrine');
+
+ if (!empty($configs) && array_key_exists('orm', $configs[0])) {
+ $config = $configs[0];
+ $default = array_key_exists(
+ 'default_entity_manager',
+ $config['orm']
+ ) ? $config['orm']['default_entity_manager'] : 'default';
+ $config['orm']['entity_managers'][$default]['dql']['string_functions']['INT'] = CastAsInt::class;
+ $container->prependExtensionConfig('doctrine', $config);
+ }
+ }
}
diff --git a/Doctrine/DQL/CastAsInt.php b/Doctrine/DQL/CastAsInt.php
new file mode 100644
index 0000000..533e4df
--- /dev/null
+++ b/Doctrine/DQL/CastAsInt.php
@@ -0,0 +1,38 @@
+stringPrimary->dispatch($sqlWalker) . ' AS integer)';
+ }
+
+ public function parse(Parser $parser)
+ {
+ $parser->match(Lexer::T_IDENTIFIER);
+ $parser->match(Lexer::T_OPEN_PARENTHESIS);
+
+ $this->stringPrimary = $parser->StringPrimary();
+
+ $parser->match(Lexer::T_CLOSE_PARENTHESIS);
+ }
+}
\ No newline at end of file
diff --git a/QueryBuilder/AclHelperQueryBuilder.php b/QueryBuilder/AclHelperQueryBuilder.php
index d1699e0..90b641c 100644
--- a/QueryBuilder/AclHelperQueryBuilder.php
+++ b/QueryBuilder/AclHelperQueryBuilder.php
@@ -104,7 +104,7 @@ public function buildAclQuery($strategy = PermissionGrantingStrategy::ANY)
}
$q
- ->select('acl_o.objectIdentifier')
+ ->select('INT(acl_o.objectIdentifier)')
->distinct()
->from(ObjectIdentity::class, 'acl_o')
->innerJoin(AclClass::class, 'acl_c', Join::WITH, 'acl_c.id = acl_o.classId')