Browse Source

remove ability to expose form; todo: bring back some day

pull/880/head
Seth Shaw 2 years ago
parent
commit
39c7b3180a
  1. 18
      src/Plugin/views/filter/NodeHasMediaUse.php

18
src/Plugin/views/filter/NodeHasMediaUse.php

@ -18,20 +18,16 @@ class NodeHasMediaUse extends FilterPluginBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function defineOptions() { protected function defineOptions() {
$options = parent::defineOptions(); return [
'use_uri' => ['default' => NULL],
$options['use_uri'] = ['default' => NULL]; 'negated' => ['default' => FALSE],
$options['negated'] = ['default' => FALSE]; ];
return $options;
} }
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function validateOptionsForm(&$form, FormStateInterface $form_state) { public function validateOptionsForm(&$form, FormStateInterface $form_state) {
parent::validateOptionsForm($form, $form_state);
$uri = $form_state->getValues()['options']['use_uri']; $uri = $form_state->getValues()['options']['use_uri'];
$term = \Drupal::service('islandora.utils')->getTermForUri($uri); $term = \Drupal::service('islandora.utils')->getTermForUri($uri);
if (empty($term)) { if (empty($term)) {
@ -42,13 +38,14 @@ class NodeHasMediaUse extends FilterPluginBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function valueForm(&$form, FormStateInterface $form_state) { public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['vid' => 'islandora_media_use']); $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['vid' => 'islandora_media_use']);
$uris = []; $uris = [];
foreach ($terms as $term) { foreach ($terms as $term) {
$uri = reset($term->get('field_external_uri')->getValue()); foreach ($term->get('field_external_uri')->getValue() as $uri) {
$uris[$uri['uri']] = $term->label(); $uris[$uri['uri']] = $term->label();
} }
}
$form['use_uri'] = [ $form['use_uri'] = [
'#type' => 'select', '#type' => 'select',
@ -92,7 +89,6 @@ class NodeHasMediaUse extends FilterPluginBase {
$sub_query->fields('of', ['field_media_of_target_id']) $sub_query->fields('of', ['field_media_of_target_id'])
->condition('use.field_media_use_target_id', $term->id()); ->condition('use.field_media_use_target_id', $term->id());
$this->query->addWhere(0, 'nid', $sub_query, $condition); $this->query->addWhere(0, 'nid', $sub_query, $condition);
} }
} }

Loading…
Cancel
Save