Added superficial tests for addConditionsToQuery
This commit is contained in:
@ -6,20 +6,22 @@ use \Drupal;
|
||||
use Drupal\Core\Entity\EntityTypeManager;
|
||||
use Drupal\Core\Entity\Query\QueryInterface;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use RuntimeException;
|
||||
|
||||
class Utils {
|
||||
|
||||
// public function __construct(
|
||||
// EntityTypeManager $entityTypeManager = null
|
||||
// ) {
|
||||
// if ($entityTypeManager == null) {
|
||||
// $entityTypeManager = Drupal::entityTypeManager();
|
||||
// }
|
||||
// $this->entityTypeManager = $entityTypeManager;
|
||||
// }
|
||||
public function __construct(
|
||||
EntityTypeManagerInterface $entityTypeManager = null
|
||||
) {
|
||||
if ($entityTypeManager == null) {
|
||||
$entityTypeManager = Drupal::entityTypeManager();
|
||||
}
|
||||
$this->entityTypeManager = $entityTypeManager;
|
||||
}
|
||||
|
||||
public function addConditionsToQuery(QueryInterface $query, array $conditions): void {
|
||||
foreach($conditions as $condition) {
|
||||
if (sizeof($condition) != 3) throw new RuntimeException('Utils::addConditionsToQuery needs each condition to consist of 3 strings');
|
||||
$field = $condition[0];
|
||||
$value = $condition[1];
|
||||
$operator = $condition[2];
|
||||
|
Reference in New Issue
Block a user