Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group repository classes in Repository folder #281

Merged
merged 3 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
* The `Bitwise` operands was removed.
* The `Happyr\DoctrineSpecification\Specification\Having` class was removed, use
`Happyr\DoctrineSpecification\Query\Having` instead.
* The `Happyr\DoctrineSpecification\EntitySpecificationRepository` class was removed, use
`Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository` instead.
* The `Happyr\DoctrineSpecification\EntitySpecificationRepositoryInterface` class was removed, use
`Happyr\DoctrineSpecification\Repository\EntitySpecificationRepositoryInterface` instead.
* The `Happyr\DoctrineSpecification\EntitySpecificationRepositoryTrait` class was removed, use
`Happyr\DoctrineSpecification\Repository\EntitySpecificationRepositoryTrait` instead.
* The `Happyr\DoctrineSpecification\RepositoryFactory` class was removed, use
`Happyr\DoctrineSpecification\Repository\RepositoryFactory` instead.
* Removes the ability to use `array` as argument for the `PlatformFunction` operand.

Before:
Expand Down
4 changes: 2 additions & 2 deletions docs/0-0-symfony.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

## Replacing the default repository type

Replacing Doctrine's default repository type with `Happyr\DoctrineSpecification\EntitySpecificationRepository` is easy
Replacing Doctrine's default repository type with `Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository` is easy
in Symfony. The doctrine bundle provides a place in configuration to specify the new type.

```yml
// app/config/config.yml
doctrine:
orm:
default_repository_class: Happyr\DoctrineSpecification\EntitySpecificationRepository
default_repository_class: Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository
```
4 changes: 2 additions & 2 deletions docs/0-1-zend1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
Doctrine integration with Zend Framework 1 is done manually. However, replacing the default repository type is still
simple. In the bootstrap (or wherever Doctrine is configured in the system in question), use Doctrine configurations
`setRepositoryFactory` method and provide an implementation of `Doctrine\ORM\Repository\RepositoryFactory`. A basic
implementation is provided with `Happyr\DoctrineSpecification\RepositoryFactory`.
implementation is provided with `Happyr\DoctrineSpecification\Repository\RepositoryFactory`.

```php
// During doctrine configuration
$config->setRepositoryFactory(new \Happyr\DoctrineSpecification\RepositoryFactory());
$config->setRepositoryFactory(new \Happyr\DoctrineSpecification\Repository\RepositoryFactory());
```
4 changes: 2 additions & 2 deletions docs/0-2-zend2.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Doctrine integration with Zend Framework 2 can be achieved using the `DoctrineORM` bundle. This bundle contains
configuration options for the repository factory. To replace the default repository type, provide a factory creating
an instance of `Happyr\DoctrineSpecification\EntitySpecificationRepository` and any necessary configuration options.
an instance of `Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository` and any necessary configuration options.

```php
// Application configuration
Expand All @@ -17,7 +17,7 @@ configuration options for the repository factory. To replace the default reposit

'service_manager' => [
'services' => [
'happyr_doctrinespecification_repository' => new Happyr\DoctrineSpecification\RepositoryFactory(),
'happyr_doctrinespecification_repository' => new Happyr\DoctrineSpecification\Repository\RepositoryFactory(),
],
],
];
Expand Down
5 changes: 2 additions & 3 deletions docs/0-3-laravel.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ If you're choosing to use Doctrine with Laravel, there are some common Doctrine

### atrauzzi/laravel-doctrine

For this package, in its configuration settings, set the `defaultRepository` setting to `Happyr\DoctrineSpecification\EntitySpecificationRepository`
For this package, in its configuration settings, set the `defaultRepository` setting to `Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository`

### mitchellvanw/laravel-doctrine

For this package, in its configuration settings, set the `repository` setting to `Happyr\DoctrineSpecification\EntitySpecificationRepository`

For this package, in its configuration settings, set the `repository` setting to `Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository`
4 changes: 2 additions & 2 deletions docs/0-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Install this lib with composer.
}
```

Let your repositories extend `Happyr\DoctrineSpecification\EntitySpecificationRepository` instead of `Doctrine\ORM\EntityRepository`, or use the `EntitySpecificationRepositoryTrait` in your repositories, like so:
Let your repositories extend `Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository` instead of `Doctrine\ORM\EntityRepository`, or use the `EntitySpecificationRepositoryTrait` in your repositories, like so:

```php
<?php
Expand All @@ -40,7 +40,7 @@ class MyRepository extends ServiceEntityRepository
```

Also make sure that the default repository is changed. If you haven't created a repository class in your source
then you will have to tell `$this->em->getRepository('xxx')` to return a instance of `Happyr\DoctrineSpecification\EntitySpecificationRepository`.
then you will have to tell `$this->em->getRepository('xxx')` to return a instance of `Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository`.
See instructions for [Laravel](0-3-laravel.md), [Symfony2](0-0-symfony.md), [Zend1](0-1-zend1.md) and [Zend2](0-2-zend2.md).

Then you may start to create your specifications. Put them in `Acme\DemoBundle\Entity\Spec`. Lets start with a simple one:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* file that was distributed with this source code.
*/

namespace Happyr\DoctrineSpecification;
namespace Happyr\DoctrineSpecification\Repository;

use Doctrine\ORM\EntityRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* file that was distributed with this source code.
*/

namespace Happyr\DoctrineSpecification;
namespace Happyr\DoctrineSpecification\Repository;

use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
* file that was distributed with this source code.
*/

namespace Happyr\DoctrineSpecification;
namespace Happyr\DoctrineSpecification\Repository;

use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\NonUniqueResultException as DoctrineNonUniqueResultException;
use Doctrine\ORM\NoResultException as DoctrineNoResultException;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Happyr\DoctrineSpecification\Exception\NonUniqueResultException;
use Happyr\DoctrineSpecification\Exception\NoResultException;
use Happyr\DoctrineSpecification\Filter\Filter;
use Happyr\DoctrineSpecification\Query\QueryModifier;
use Happyr\DoctrineSpecification\Result\ResultModifier;
Expand Down Expand Up @@ -65,10 +67,10 @@ public function matchSingleResult($specification, ?ResultModifier $modifier = nu

try {
return $query->getSingleResult();
} catch (NonUniqueResultException $e) {
throw new Exception\NonUniqueResultException($e->getMessage(), $e->getCode(), $e);
} catch (NoResultException $e) {
throw new Exception\NoResultException($e->getMessage(), $e->getCode(), $e);
} catch (DoctrineNonUniqueResultException $e) {
throw new NonUniqueResultException($e->getMessage(), $e->getCode(), $e);
} catch (DoctrineNoResultException $e) {
throw new NoResultException($e->getMessage(), $e->getCode(), $e);
}
}

Expand All @@ -86,7 +88,7 @@ public function matchOneOrNullResult($specification, ?ResultModifier $modifier =
{
try {
return $this->matchSingleResult($specification, $modifier);
} catch (Exception\NoResultException $e) {
} catch (NoResultException $e) {
return null;
}
}
Expand All @@ -108,8 +110,8 @@ public function matchSingleScalarResult($specification, ?ResultModifier $modifie

try {
return $query->getSingleScalarResult();
} catch (NonUniqueResultException $e) {
throw new Exception\NonUniqueResultException($e->getMessage(), $e->getCode(), $e);
} catch (DoctrineNonUniqueResultException $e) {
throw new NonUniqueResultException($e->getMessage(), $e->getCode(), $e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* file that was distributed with this source code.
*/

namespace Happyr\DoctrineSpecification;
namespace Happyr\DoctrineSpecification\Repository;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
* file that was distributed with this source code.
*/

namespace tests\Happyr\DoctrineSpecification;
namespace tests\Happyr\DoctrineSpecification\Repository;

use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\NonUniqueResultException as DoctrineNonUniqueResultException;
use Doctrine\ORM\NoResultException as DoctrineNoResultException;
use Doctrine\ORM\QueryBuilder;
use Happyr\DoctrineSpecification\EntitySpecificationRepository;
use Happyr\DoctrineSpecification\Exception\NonUniqueResultException;
use Happyr\DoctrineSpecification\Exception\NoResultException;
use Happyr\DoctrineSpecification\Exception\UnexpectedResultException;
use Happyr\DoctrineSpecification\Filter\Filter;
use Happyr\DoctrineSpecification\Query\QueryModifier;
use Happyr\DoctrineSpecification\Repository\EntitySpecificationRepository;
use Happyr\DoctrineSpecification\Result\ResultModifier;
use Happyr\DoctrineSpecification\Specification\Specification;
use PhpSpec\ObjectBehavior;
Expand Down