-
-
Notifications
You must be signed in to change notification settings - Fork 59
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 #531 from nextras/expression_rewrite
Dbal expression rewrite
- Loading branch information
Showing
35 changed files
with
672 additions
and
157 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Nextras\Orm\Collection\Functions; | ||
|
||
|
||
use Nextras\Dbal\QueryBuilder\QueryBuilder; | ||
use Nextras\Orm\Collection\Helpers\ArrayAnyAggregator; | ||
use Nextras\Orm\Collection\Helpers\ArrayCollectionHelper; | ||
use Nextras\Orm\Collection\Helpers\DbalAnyAggregator; | ||
use Nextras\Orm\Collection\Helpers\DbalExpressionResult; | ||
use Nextras\Orm\Collection\Helpers\DbalQueryBuilderHelper; | ||
use Nextras\Orm\Collection\Helpers\IArrayAggregator; | ||
use Nextras\Orm\Collection\Helpers\IDbalAggregator; | ||
use Nextras\Orm\Entity\IEntity; | ||
use Nextras\Orm\Exception\InvalidStateException; | ||
|
||
|
||
class AnyAggregateFunction implements IArrayFunction, IQueryBuilderFunction | ||
{ | ||
public function processArrayExpression( | ||
ArrayCollectionHelper $helper, | ||
IEntity $entity, | ||
array $args, | ||
?IArrayAggregator $aggregator = null | ||
) | ||
{ | ||
if ($aggregator !== null) { | ||
throw new InvalidStateException("Cannot apply two aggregations simultaneously."); | ||
} | ||
|
||
return $helper->getValue($entity, $args[0], new ArrayAnyAggregator())->value; | ||
} | ||
|
||
|
||
public function processQueryBuilderExpression( | ||
DbalQueryBuilderHelper $helper, | ||
QueryBuilder $builder, | ||
array $args, | ||
?IDbalAggregator $aggregator = null | ||
): DbalExpressionResult | ||
{ | ||
if ($aggregator !== null) { | ||
throw new InvalidStateException("Cannot apply two aggregations simultaneously."); | ||
} | ||
|
||
return $helper->processPropertyExpr($builder, $args[0], new DbalAnyAggregator()); | ||
} | ||
} |
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
Oops, something went wrong.