Esempio n. 1
0
  /**
   * {@inheritdoc}
   */
  public function validateArgument($argument) {
    if ($this->options['transform']) {
      $argument = str_replace('-', '_', $argument);
    }
    $properties = array('machine_name' => $argument);
    if ($bundles = array_filter($this->options['bundles'])) {
      $properties['vid'] = $bundles;
    }
    $terms = $this->termStorage->loadByProperties($properties);

    if (!$terms) {
      // Returned empty array no terms with the name.
      return FALSE;
    }

    // Not knowing which term will be used if more than one is returned check
    // each one.
    /** @var Term $term */
    foreach ($terms as $term) {
      if (!$this->validateEntity($term)) {
        return FALSE;
      }
    }

    $this->argument->realField = 'tid';
    $this->argument->argument = $term->id();

    // Property created dynamically.
    if (!$this->argument->validated_title = $term->getName()) {
      $this->argument->validated_title = $this->t('No name');
    }

    return TRUE;
  }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function validateArgument($argument)
 {
     if ($this->options['transform']) {
         $argument = str_replace('-', ' ', $argument);
     }
     $terms = $this->termStorage->loadByProperties(array('name' => $argument));
     if (!$terms) {
         // Returned empty array no terms with the name.
         return FALSE;
     }
     // Not knowing which term will be used if more than one is returned check
     // each one.
     foreach ($terms as $term) {
         if (!$this->validateEntity($term)) {
             return FALSE;
         }
     }
     return TRUE;
 }