예제 #1
0
  /**
   * {@inheritdoc}
   */
  protected function buildEntityQuery($match) {
    $query = parent::buildEntityQuery($match);

    $no_access = !$this->currentUser->hasPermission('bypass node access') && !count($this->moduleHandler->getImplementations('node_grants'));
    if ($this->configuration['include_unpublished'] !== TRUE || $no_access) {
      $query->condition('status', NODE_PUBLISHED);
    }

    return $query;
  }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
   $form = parent::buildConfigurationForm($form, $form_state);
   $this->insertTokenList($form, ['term']);
   return $form;
 }
예제 #3
0
  /**
   * {@inheritdoc}
   */
  protected function buildEntityQuery($match) {
    $query = parent::buildEntityQuery($match);

    $match = $this->database->escapeLike($match);
    // The user entity don't specify a label key so we have to do it instead.
    $query->condition('name', '%' . $match . '%', 'LIKE');

    // Filter by role.
    if (!empty($this->configuration['roles'])) {
      $query->condition('roles', $this->configuration['roles'], 'IN');
    }

    if ($this->configuration['include_blocked'] !== TRUE || !$this->currentUser->hasPermission('administer users')) {
      $query->condition('status', 1);
    }

    return $query;
  }
예제 #4
0
  /**
   * {@inheritdoc}
   */
  protected function buildDescription($entity) {
    $description_array = array();

    $description_array[] = parent::buildDescription($entity);

    /** @var \Drupal\file\FileInterface $entity */
    $file = $entity->getFileUri();

    /** @var \Drupal\Core\Image\ImageInterface $image */
    $image = \Drupal::service('image.factory')->get($file);
    if ($image->isValid()) {
      if ($this->configuration['images']['show_dimensions']) {
        $description_array[] = $image->getWidth() . 'x' . $image->getHeight() . 'px';
      }

      if ($this->configuration['images']['show_thumbnail'] && $this->moduleHandler->moduleExists('image')) {
        $image_element = array(
          '#weight' => -10,
          '#theme' => 'image_style',
          '#style_name' => $this->configuration['images']['thumbnail_image_style'],
          '#uri' => $entity->getFileUri(),
        );

        $description_array[] = (string) \Drupal::service('renderer')->render($image_element);
      }
    }

    $description = implode('<br />' , $description_array);
    return LinkitXss::descriptionFilter($description);
  }