use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\views\Plugin\views\join\JoinPluginBase;
*/
protected $dateSql;
+ /**
+ * The messenger.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
/**
* Constructs a Sql object.
*
* The entity type manager.
* @param \Drupal\views\Plugin\views\query\DateSqlInterface $date_sql
* The database-specific date handler.
+ * @param \Drupal\Core\Messenger\MessengerInterface $messenger
+ * The messenger.
*/
- public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, DateSqlInterface $date_sql) {
+ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, DateSqlInterface $date_sql, MessengerInterface $messenger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
$this->dateSql = $date_sql;
+ $this->messenger = $messenger;
}
+ /**
+ * {@inheritdoc}
+ */
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('entity_type.manager'),
- $container->get('views.date_sql')
+ $container->get('views.date_sql'),
+ $container->get('messenger')
);
}
'link' => NULL,
'table' => $base_table,
'alias' => $base_table,
- 'base' => $base_table
+ 'base' => $base_table,
];
// init the table queue with our primary table.
$this->orderby[] = [
'field' => $as,
- 'direction' => strtoupper($order)
+ 'direction' => strtoupper($order),
];
}
if (!empty($this->limit) || !empty($this->offset)) {
// We can't have an offset without a limit, so provide a very large limit instead.
- $limit = intval(!empty($this->limit) ? $this->limit : 999999);
+ $limit = intval(!empty($this->limit) ? $this->limit : 999999);
$offset = intval(!empty($this->offset) ? $this->offset : 0);
$query->range($offset, $limit);
}
catch (DatabaseExceptionWrapper $e) {
$view->result = [];
if (!empty($view->live_preview)) {
- drupal_set_message($e->getMessage(), 'error');
+ $this->messenger->addError($e->getMessage());
}
else {
throw new DatabaseExceptionWrapper("Exception in {$view->storage->label()}[{$view->storage->id()}]: {$e->getMessage()}");
'filter' => 'groupby_numeric',
'sort' => 'groupby_numeric',
],
- ]
+ ],
];
}