Back to AuthorField class

Method getOptions

protected array
getOptions
()
Method to get the options to populate list
Returns
  • array The field option objects.
Since
  • 3.2
Class: AuthorField
Project: Joomla

Method getOptions - Source code

/**
 * Method to get the options to populate list
 *
 * @return  array  The field option objects.
 *
 * @since   3.2
 */
protected function getOptions()
{
    // Accepted modifiers
    $hash = md5($this->element);
    if (!isset(static::$options[$hash])) {
        static::$options[$hash] = parent::getOptions();
        $db = Factory::getDbo();
        // Construct the query
        $query = $db->getQuery(true)->select([$db->quoteName('u.id', 'value'), $db->quoteName('u.name', 'text')])->from($db->quoteName('#__users', 'u'))->join('INNER', $db->quoteName('#__content', 'c'), $db->quoteName('c.created_by') . ' = ' . $db->quoteName('u.id'))->group([$db->quoteName('u.id'), $db->quoteName('u.name')])->order($db->quoteName('u.name'));
        // Setup the query
        $db->setQuery($query);
        // Return the result
        if ($options = $db->loadObjectList()) {
            static::$options[$hash] = array_merge(static::$options[$hash], $options);
        }
    }
    return static::$options[$hash];
}