Skip to content

Commit

Permalink
BUGFIX: Exchange Doctrine Objectmanager import
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed Nov 1, 2019
1 parent 0a9db59 commit b4e0607
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
* source code.
*/

use Doctrine\DBAL\DBALException;
use Doctrine\ORM\EntityManagerInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Security\Authorization\Privilege\Entity\Doctrine\FalseConditionGenerator;
use Neos\ContentRepository\Security\Authorization\Privilege\Node\Doctrine\ConditionGenerator as NeosContentRepositoryConditionGenerator;
use Neos\Flow\Security\Authorization\Privilege\Entity\Doctrine\SqlGeneratorInterface;
use Doctrine\Common\Persistence\ObjectManager;


/**
Expand All @@ -25,7 +26,7 @@ class ConditionGenerator extends NeosContentRepositoryConditionGenerator
{
/**
* @Flow\Inject
* @var ObjectManager
* @var EntityManagerInterface
*/
protected $entityManager;

Expand All @@ -34,16 +35,17 @@ class ConditionGenerator extends NeosContentRepositoryConditionGenerator
* @param mixed $value
*
* @return SqlGeneratorInterface
* @throws DBALException
*/
public function nodePropertyIs($property, $value)
public function nodePropertyIs(string $property, $value): SqlGeneratorInterface
{
$propertyConditionGenerator = new PropertyConditionGenerator('properties');

if (!is_string($property) || is_array($value)) {
return new FalseConditionGenerator();
}

if ($this->entityManager->getConnection()->getDatabasePlatform()->getName() === "postgresql"){
if ($this->entityManager->getConnection()->getDatabasePlatform()->getName() === "postgresql") {
return $propertyConditionGenerator->postgresJsonContains('{"' . trim($property) . '": ' . json_encode($value) . '}');
}

Expand All @@ -55,8 +57,9 @@ public function nodePropertyIs($property, $value)
* @param mixed $value
*
* @return SqlGeneratorInterface
* @throws DBALException
*/
public function parentNodePropertyIs($property, $value)
public function parentNodePropertyIs(string $property, $value): SqlGeneratorInterface
{
$propertiesConditionGenerator = $this->nodePropertyIs($property, $value);
$subQueryGenerator = new ParentNodePropertyGenerator($propertiesConditionGenerator);
Expand Down

0 comments on commit b4e0607

Please sign in to comment.