-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added filter support and replaced contao model query builder with Doc…
…trineDBALQueryQueryBuilder instance
- Loading branch information
Rico Kaltofen
committed
Apr 20, 2018
1 parent
b28a6d4
commit 24a71b0
Showing
15 changed files
with
228 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (c) 2018 Heimrich & Hannot GmbH | ||
* | ||
* @license LGPL-3.0-or-later | ||
*/ | ||
|
||
namespace HeimrichHannot\ReaderBundle\Choice; | ||
|
||
use HeimrichHannot\FilterBundle\Model\FilterConfigModel; | ||
use HeimrichHannot\UtilsBundle\Choice\AbstractChoice; | ||
|
||
class FilterChoice extends AbstractChoice | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
protected function collect() | ||
{ | ||
$choices = []; | ||
|
||
$dataContainers = $this->getContext(); | ||
|
||
if (!is_array($dataContainers)) { | ||
$dataContainers = [$dataContainers]; | ||
} | ||
|
||
/** | ||
* @var FilterConfigModel | ||
*/ | ||
$adapter = $this->framework->getAdapter(FilterConfigModel::class); | ||
|
||
if (!empty($dataContainers)) { | ||
$filters = $adapter->findByDataContainers($dataContainers); | ||
} else { | ||
$filters = $adapter->findAll(); | ||
} | ||
|
||
if (null !== $filters) { | ||
$choices = $filters->fetchEach('title'); | ||
} | ||
|
||
return $choices; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright (c) 2018 Heimrich & Hannot GmbH | ||
* | ||
* @license LGPL-3.0-or-later | ||
*/ | ||
|
||
namespace HeimrichHannot\ReaderBundle\QueryBuilder; | ||
|
||
use Contao\CoreBundle\Framework\ContaoFrameworkInterface; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Query\QueryBuilder; | ||
|
||
class ReaderQueryBuilder extends QueryBuilder | ||
{ | ||
/** | ||
* @var ContaoFrameworkInterface | ||
*/ | ||
protected $framework; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected $contextualValues = []; | ||
|
||
public function __construct(ContaoFrameworkInterface $framework, Connection $connection) | ||
{ | ||
parent::__construct($connection); | ||
$this->framework = $framework; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.