This repository has been archived by the owner on Sep 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aertmann/master
A couple improvements to conditions
- Loading branch information
Showing
4 changed files
with
54 additions
and
3 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
37 changes: 37 additions & 0 deletions
37
...curity/Authorization/Privilege/Doctrine/AssetWithoutAssetCollectionConditionGenerator.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,37 @@ | ||
<?php | ||
namespace Wwwision\AssetConstraints\Security\Authorization\Privilege\Doctrine; | ||
|
||
use Doctrine\Common\Persistence\Mapping\ClassMetadata; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
use Doctrine\ORM\Query\Filter\SQLFilter as DoctrineSqlFilter; | ||
use TYPO3\Flow\Annotations as Flow; | ||
use TYPO3\Flow\Security\Authorization\Privilege\Entity\Doctrine\SqlGeneratorInterface; | ||
|
||
/** | ||
* Condition generator covering Asset >-< AssetCollection relations (M:M relations are not supported by the Flow PropertyConditionGenerator yet) | ||
*/ | ||
class AssetWithoutAssetCollectionConditionGenerator implements SqlGeneratorInterface | ||
{ | ||
|
||
/** | ||
* @Flow\Inject | ||
* @var ObjectManager | ||
*/ | ||
protected $entityManager; | ||
|
||
/** | ||
* @param DoctrineSqlFilter $sqlFilter | ||
* @param ClassMetadata $targetEntity Metadata object for the target entity to create the constraint for | ||
* @param string $targetTableAlias The target table alias used in the current query | ||
* @return string | ||
*/ | ||
public function getSql(DoctrineSqlFilter $sqlFilter, ClassMetadata $targetEntity, $targetTableAlias) | ||
{ | ||
$sql = $targetTableAlias . '.persistence_object_identifier IN ( | ||
SELECT ' . $targetTableAlias . '_a.persistence_object_identifier | ||
FROM typo3_media_domain_model_asset AS ' . $targetTableAlias . '_a | ||
LEFT JOIN typo3_media_domain_model_assetcollection_assets_join ' . $targetTableAlias . '_acj ON ' . $targetTableAlias . '_a.persistence_object_identifier = ' . $targetTableAlias . '_acj.media_asset | ||
WHERE ' . $targetTableAlias . '_acj.media_asset IS NULL)'; | ||
return $sql; | ||
} | ||
} |