Skip to content

Commit e61fb80

Browse files
authored
Merge pull request rikbruil#21 from rikbruil/add-specification-repository-class
Added back the SpecificationRepository class for backwards-compatibility reasons
2 parents 75cc200 + 03558e0 commit e61fb80

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ The main one is that SpecificationRepository->match() does not return the result
1313

1414
Since I like Doctrine's Paginator object, I wanted to be able to use that in combination with the Specification pattern.
1515

16+
__Note:__ In versions prior to 1.2 it was required to extend the SpecificationRepository class. This is no longer needed since we provide a SpecificationRepositoryTrait that you can use instead.
17+
The class is still provided for backwards compatibility reasons. There is also the SpecificationAwareInterface that you can use if you need it.
18+
1619
## Usage
1720

1821
Install the latest version with `composer require rikbruil/doctrine-specification`
@@ -59,7 +62,7 @@ $spec = new Specification([
5962
)
6063
]);
6164

62-
// Note: Advertisement repository is an instance of the SpecificationRepository class
65+
// Note: Advertisement repository is an instance that uses the SpecificationRepositoryTrait
6366
return $this->em->getRepository('Advertisement')->match($spec)->execute();
6467
```
6568

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"psr-4": {"Rb\\Specification\\Doctrine\\": "src/"}
1616
},
1717
"autoload-dev": {
18-
"psr-4": {"spec\\Rb\\Specification\\Doctrine\\": "spec/"},
19-
"files": ["spec/SpecificationRepositoryStub.php"]
18+
"psr-4": {"spec\\Rb\\Specification\\Doctrine\\": "spec/"}
2019
},
2120
"require": {
2221
"php": ">=5.5",
@@ -32,7 +31,7 @@
3231
},
3332
"extra": {
3433
"branch-alias": {
35-
"dev-master": "1.2-dev"
34+
"dev-master": "1.3-dev"
3635
}
3736
},
3837
"scripts": {

spec/SpecificationRepositorySpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Rb\Specification\Doctrine\Exception\LogicException;
1212
use Rb\Specification\Doctrine\Result\ModifierInterface;
1313
use Rb\Specification\Doctrine\SpecificationInterface;
14-
use Rb\Specification\Doctrine\SpecificationRepositoryStub;
14+
use Rb\Specification\Doctrine\SpecificationRepository;
1515

1616
class SpecificationRepositorySpec extends ObjectBehavior
1717
{
@@ -23,7 +23,7 @@ class SpecificationRepositorySpec extends ObjectBehavior
2323

2424
public function let(EntityManager $entityManager, ClassMetadata $classMetadata)
2525
{
26-
$this->beAnInstanceOf(SpecificationRepositoryStub::class);
26+
$this->beAnInstanceOf(SpecificationRepository::class);
2727
$this->beConstructedWith($entityManager, $classMetadata);
2828
}
2929

spec/SpecificationRepositoryStub.php

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/SpecificationRepository.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Rb\Specification\Doctrine;
4+
5+
use Doctrine\ORM\EntityRepository;
6+
7+
/**
8+
* This class is only here for backwards compatibility reasons.
9+
*
10+
* The preferred way of interacting with specification objects is by writing your own
11+
* custom repository class that uses the SpecificationRepositoryTrait.
12+
*
13+
* The SpecificationAwareInterface is added in case you need it.
14+
*
15+
* @see SpecificationRepositoryTrait
16+
* @see SpecificationAwareInterface
17+
*/
18+
class SpecificationRepository extends EntityRepository implements SpecificationAwareInterface
19+
{
20+
use SpecificationRepositoryTrait;
21+
}

0 commit comments

Comments
 (0)