/**
  * {@inheritdoc}
  */
 protected function defineOptions()
 {
     $options = parent::defineOptions();
     $options['type'] = array('default' => 'uid');
     $options['perm'] = array('default' => 'view all orders');
     return $options;
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $entity_type_id = $this->definition['entity_type'];
     // Derivative IDs are all entity:entity_type. Sanitized for js.
     // The ID is converted back on submission.
     $sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']);
     $entity_type = $this->entityManager->getDefinition($entity_type_id);
     // If the entity has bundles, allow option to restrict to bundle(s).
     if ($entity_type->hasKey('bundle')) {
         $bundle_options = array();
         foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle_id => $bundle_info) {
             $bundle_options[$bundle_id] = $bundle_info['label'];
         }
         $form['bundles'] = array('#title' => $entity_type->getBundleLabel() ?: $this->t('Bundles'), '#default_value' => $this->options['bundles'], '#type' => 'checkboxes', '#options' => $bundle_options, '#description' => $this->t('If none are selected, all are allowed.'));
     }
     // Offer the option to filter by access to the entity in the argument.
     $form['access'] = array('#type' => 'checkbox', '#title' => $this->t('Validate user has access to the %name', array('%name' => $entity_type->getLabel())), '#default_value' => $this->options['access']);
     $form['operation'] = array('#type' => 'radios', '#title' => $this->t('Access operation to check'), '#options' => array('view' => $this->t('View'), 'update' => $this->t('Edit'), 'delete' => $this->t('Delete')), '#default_value' => $this->options['operation'], '#states' => array('visible' => array(':input[name="options[validate][options][' . $sanitized_id . '][access]"]' => array('checked' => TRUE))));
     // If class is multiple capable give the option to validate single/multiple.
     if ($this->multipleCapable) {
         $form['multiple'] = array('#type' => 'radios', '#title' => $this->t('Multiple arguments'), '#options' => array(0 => $this->t('Single ID', array('%type' => $entity_type->getLabel())), 1 => $this->t('One or more IDs separated by , or +', array('%type' => $entity_type->getLabel()))), '#default_value' => (string) $this->options['multiple']);
     }
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 protected function defineOptions()
 {
     $options = parent::defineOptions();
     $options['test_value'] = ['default' => ''];
     return $options;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function calculateDependencies()
 {
     $dependencies = parent::calculateDependencies();
     $entity_type_id = $this->definition['entity_type'];
     $bundle_entity_type = $this->entityManager->getDefinition($entity_type_id)->getBundleEntityType();
     // The bundle entity type might not exist. For example, users do not have
     // bundles.
     if ($this->entityManager->hasHandler($bundle_entity_type, 'storage')) {
         $bundle_entity_storage = $this->entityManager->getStorage($bundle_entity_type);
         foreach ($bundle_entity_storage->loadMultiple(array_keys($this->options['bundles'])) as $bundle_entity) {
             $dependencies[$bundle_entity->getConfigDependencyKey()][] = $bundle_entity->getConfigDependencyName();
         }
     }
     return $dependencies;
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Build the list of all permissions grouped by module.
     $permissions = [];
     foreach ($this->permissionHandler->getPermissions() as $permission => $permission_item) {
         $provider = $permission_item['provider'];
         $display_name = $this->moduleHandler->getName($provider);
         $permissions[$display_name][$permission] = Html::escape($permission_item['title']);
     }
     $form['admin_permission'] = ['#type' => 'select', '#title' => $this->t('Admin permission'), '#description' => $this->t('Allows the current user to access the view even if the argument is a different user.'), '#options' => $permissions, '#empty_value' => '', '#default_value' => $this->options['admin_permission']];
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     if (!isset($this->argument_wrapper)) {
         return;
     }
     // We can't set default in defineOptions because argument is not set yet.
     if ($this->options['replacement_format']) {
         $default = $this->options['replacement_format'];
     } else {
         $default = $this->getDefaultReplacementFormat();
     }
     $form['replacement_format'] = ['#type' => 'textfield', '#title' => $this->t('Replacement date pattern'), '#default_value' => $default, '#description' => $this->t('Provide a date pattern to be used when replace this arguments as a title.')];
 }