|
|
@ -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,12 +38,13 @@ 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'] = [ |
|
|
@ -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); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|