2017 © Pedro Peláez
 

library doctrine-specification

This library allows you to write Doctrine ORM queries using the specification pattern

image

gbprod/doctrine-specification

This library allows you to write Doctrine ORM queries using the specification pattern

  • Thursday, February 22, 2018
  • by gbprod
  • Repository
  • 2 Watchers
  • 6 Stars
  • 962 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 19 % Grown

The README.md

Doctrine specification

Build Status codecov Scrutinizer Code Quality Dependency Status, (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

This library allows you to write Doctrine ORM queries using the specification pattern., (*3)

Usage

You can write specifications using gbprod/specification library., (*4)

Creates a doctrine specification filter

namespace GBProd\Acme\Doctrine\SpecificationFactory;

use GBProd\DoctrineSpecification\QueryFactory\Factory;
use GBProd\Specification\Specification;
use Doctrine\ORM\QueryBuilder;

class IsAvailableFactory implements Factory
{
    public function create(Specification $spec, QueryFactory $qb)
    {
        return $qb->expr()
            ->andx(
                $qb->expr()->eq('available', "0"),
                $qb->expr()->gt('limitDate', "2016-03-05 00:00:00"),
            )
        ;
    }
}

Configure

$registry = new GBProd\DoctrineSpecification\Registry();

$handler = new GBProd\DoctrineSpecification\Handler(
    $registry,
    $this->em->createQueryBuilder()
);

$handler->registerFactory(
    IsAvailable::class,
    new IsAvailableFactory()
);

$handler->registerFactory(
    StockGreaterThan::class,
    new StockGreaterThanFactory()
);

Use it

$availableWithLowStock = (new IsAvailable())
    ->andX((new StockGreaterThan(4))->not())
;

$qb = $this->em
    ->getRepository('GBProd\Acme\CoreDomain\Product\Product')
    ->createQueryBuilder('p')
;

$qb->where(
    $handler->handle($availableWithLowStock)
);

return $qb->getQuery()->getResult();

Requirements

  • PHP 7.0+

Installation

Using composer

composer require gbprod/doctrine-specification

The Versions

22/02 2018

dev-master

9999999-dev

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT WTFPL

The Requires

 

The Development Requires

by Avatar gbprod

22/02 2018

dev-chore/licence

dev-chore/licence

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Avatar gbprod

08/02 2018

v2.1.0

2.1.0.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

30/06 2017

v2.0.1

2.0.1.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

27/06 2017

v2.0.0

2.0.0.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

25/06 2017

v1.0.x-dev

1.0.9999999.9999999-dev

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

25/06 2017

v1.0.0

1.0.0.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

21/09 2016

v0.2.0

0.2.0.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

11/03 2016

v0.1.1

0.1.1.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

09/03 2016

v0.1.0

0.1.0.0

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

06/03 2016

v0.0.3-alpha

0.0.3.0-alpha

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

05/03 2016

v0.0.2-alpha

0.0.2.0-alpha

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod

05/03 2016

v0.0.1-alpha

0.0.1.0-alpha

This library allows you to write Doctrine ORM queries using the specification pattern

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar gbprod