Back to WorkflowconditionField class

Method getOptions

protected array
getOptions
()
Method to get the field options.
Returns
  • array The field option objects.
Since
  • 4.0.0

Method getOptions - Source code

/**
 * Method to get the field options.
 *
 * @return  array  The field option objects.
 *
 * @since   4.0.0
 */
protected function getOptions()
{
    $fieldname = preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname);
    $options = [];
    $conditions = [];
    $parts = explode('.', $this->extension);
    $component = Factory::getApplication()->bootComponent($parts[0]);
    if ($component instanceof WorkflowServiceInterface) {
        $conditions = $component->getConditions($this->extension);
    }
    foreach ($conditions as $value => $option) {
        $text = trim((string) $option) != '' ? trim((string) $option) : $value;
        $selected = (int) $this->value === $value;
        $tmp = array('value' => $value, 'text' => Text::alt($text, $fieldname), 'selected' => $selected, 'checked' => $selected);
        // Add the option object to the result set.
        $options[] = (object) $tmp;
    }
    if (!$this->hideAll) {
        $options[] = (object) array('value' => '*', 'text' => Text::_('JALL'), 'selected' => $this->value === '*', 'checked' => $this->value === '*');
    }
    // Merge any additional options in the XML definition.
    return array_merge(parent::getOptions(), $options);
}