Skip to content

Commit f61b79c

Browse files
Alessandro FrangioniAlessandro Frangioni
authored andcommitted
Added interface
1 parent 43dc37f commit f61b79c

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

spec/SpecificationRepositoryStub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Doctrine\ORM\EntityRepository;
66

7-
class SpecificationRepositoryStub extends EntityRepository
7+
class SpecificationRepositoryStub extends EntityRepository implements SpecificationAware
88
{
99
use SpecificationRepositoryTrait;
1010
}

src/SpecificationAware.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Rb\Specification\Doctrine;
4+
5+
use Doctrine\ORM\Query;
6+
use Rb\Specification\Doctrine\Result\ModifierInterface;
7+
8+
/**
9+
* SpecificationAware can be used to implement custom repository.
10+
*/
11+
interface SpecificationAware
12+
{
13+
/**
14+
* Get the query after matching with given specification.
15+
*
16+
* @param SpecificationInterface $specification
17+
* @param ModifierInterface $modifier
18+
*
19+
* @return Query
20+
*/
21+
public function match(SpecificationInterface $specification, ModifierInterface $modifier = null);
22+
}

src/SpecificationRepositoryTrait.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ trait SpecificationRepositoryTrait
1818
protected $dqlAlias = 'e';
1919

2020
/**
21-
* Get the query after matching with given specification.
21+
* @see SpecificationAware::match()
2222
*
2323
* @param SpecificationInterface $specification
24-
* @param ModifierInterface $modifier
25-
*
26-
* @throws LogicException
24+
* @param ModifierInterface|null $modifier
2725
*
2826
* @return Query
27+
* @throws LogicException
2928
*/
3029
public function match(SpecificationInterface $specification, ModifierInterface $modifier = null)
3130
{

0 commit comments

Comments
 (0)