for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Happyr Doctrine Specification package.
*
* (c) Tobias Nyholm <[email protected]>
* Kacper Gunia <[email protected]>
* Peter Gribanov <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Happyr\DoctrineSpecification\Query;
use Doctrine\ORM\QueryBuilder;
* @author Tobias Nyholm
abstract class AbstractJoin implements QueryModifier
{
* @var string
private $field;
private $newAlias;
* @var string|null
private $dqlAlias;
* @param string $field
* @param string $newAlias
* @param string|null $dqlAlias
public function __construct($field, $newAlias, $dqlAlias = null)
$this->field = $field;
$this->newAlias = $newAlias;
$this->dqlAlias = $dqlAlias;
}
* @param QueryBuilder $qb
* @param string $dqlAlias
public function modify(QueryBuilder $qb, $dqlAlias)
if (null !== $this->dqlAlias) {
$dqlAlias = $this->dqlAlias;
$join = $this->getJoinType();
$qb->$join(sprintf('%s.%s', $dqlAlias, $this->field), $this->newAlias);
* Return a join type (ie a function of QueryBuilder) like: "join", "innerJoin", "leftJoin".
* @return string
abstract protected function getJoinType();