/** * {@inheritdoc} */ public function validateArgument($argument) { if (!parent::validateArgument($argument)) { return FALSE; } // Extract the IDs from the argument. See parent::validateArgument(). if ($this->multipleCapable && $this->options['multiple']) { $user_ids = array_filter(preg_split('/[,+ ]/', $argument)); } else { $user_ids = [$argument]; } // Allow access when the current user has access to view all payments, or // when the current user only tries to view their own payments and has // permission to do so. return [$this->currentUser->id()] == $user_ids && $this->currentUser->hasPermission('payment.payment.view.own') || $this->currentUser->hasPermission('payment.payment.view.any'); }
/** * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $entity_type = $this->entityManager->getDefinition('user'); $form['multiple']['#options'] = array(0 => $this->t('Single name', array('%type' => $entity_type->getLabel())), 1 => $this->t('One or more names separated by , or +', array('%type' => $entity_type->getLabel()))); }