-
-
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 #633 from nextras/collection-functions-refactorings
Collection functions refactorings
- Loading branch information
Showing
33 changed files
with
713 additions
and
682 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
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,50 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Nextras\Orm\Collection\Functions; | ||
|
||
|
||
use Nextras\Dbal\QueryBuilder\QueryBuilder; | ||
use Nextras\Orm\Collection\Aggregations\IArrayAggregator; | ||
use Nextras\Orm\Collection\Aggregations\IDbalAggregator; | ||
use Nextras\Orm\Collection\Functions\Result\ArrayExpressionResult; | ||
use Nextras\Orm\Collection\Functions\Result\DbalExpressionResult; | ||
use Nextras\Orm\Collection\Helpers\ArrayCollectionHelper; | ||
use Nextras\Orm\Collection\Helpers\DbalQueryBuilderHelper; | ||
use Nextras\Orm\Entity\IEntity; | ||
|
||
|
||
/** | ||
* Collection function for custom functionality over array & dbal storage. | ||
* It processes an expression and reuse nested result for further evaluation. | ||
* If the collection function does not support particular storage (array or dbal), it may | ||
* throw an "unsupported" exception. | ||
*/ | ||
interface CollectionFunction | ||
{ | ||
/** | ||
* Returns a value depending on values of entity; the expression passed by args is evaluated during this method | ||
* execution. | ||
* Usually returns a boolean for filtering evaluation. | ||
* @phpstan-param array<mixed> $args | ||
* @phpstan-param IArrayAggregator<mixed>|null $aggregator | ||
*/ | ||
public function processArrayExpression( | ||
ArrayCollectionHelper $helper, | ||
IEntity $entity, | ||
array $args, | ||
?IArrayAggregator $aggregator = null, | ||
): ArrayExpressionResult; | ||
|
||
|
||
/** | ||
* Returns true if entity should stay in the result collection; the condition is evaluated in database and this | ||
* method just returns appropriate Nextras Dbal's filtering expression for passed args. | ||
* @phpstan-param array<int|string, mixed> $args | ||
*/ | ||
public function processDbalExpression( | ||
DbalQueryBuilderHelper $helper, | ||
QueryBuilder $builder, | ||
array $args, | ||
?IDbalAggregator $aggregator = null, | ||
): DbalExpressionResult; | ||
} |
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
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.