You are here

public function CheckViewResultCount::getSettingsForm in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/Plugin/BusinessRulesCondition/CheckViewResultCount.php \Drupal\business_rules\Plugin\BusinessRulesCondition\CheckViewResultCount::getSettingsForm()

Return the form array.

@internal param array $form

Parameters

array $form: The form array.

\Drupal\Core\Form\FormStateInterface $form_state: The form state object.

\Drupal\business_rules\ItemInterface $item: The configured item.

Return value

array The render array for the settings form.

Overrides BusinessRulesItemPluginBase::getSettingsForm

File

src/Plugin/BusinessRulesCondition/CheckViewResultCount.php, line 34

Class

CheckViewResultCount
Class CheckViewResultCount.

Namespace

Drupal\business_rules\Plugin\BusinessRulesCondition

Code

public function getSettingsForm(array &$form, FormStateInterface $form_state, ItemInterface $item) {
  $settings['view'] = [
    '#type' => 'select',
    '#title' => t('View to execute. View name : Display mode id : Display mode title.'),
    '#options' => $this->util
      ->getViewsOptions(),
    '#required' => TRUE,
    '#default_value' => $item
      ->getSettings('view'),
    '#description' => t('Select the view to compare the number of results.'),
  ];
  $settings['arguments'] = [
    '#type' => 'textarea',
    '#title' => t('Arguments'),
    '#description' => t('Any argument the view may need, one per line. Be aware of including them at same order as the CONTEXTUAL FILTERS configured in the view. You may use variables.'),
    '#default_value' => $item
      ->getSettings('arguments'),
  ];
  $settings['comparison'] = [
    '#type' => 'number',
    '#title' => t('Minimum number of results'),
    '#description' => t('The condition will return true if the view has at least the given number of results.'),
    '#min' => 0,
    '#default_value' => $item
      ->getSettings('comparison'),
  ];
  return $settings;
}