CoreFiles by mySites.guru
FieldcontextsField.php65 lines, 1,295 bytes, from Joomla_4.0.0-beta4-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta3
md5
aaa2c1d24d4e390fae18eb5cce5d3e52
sha1
e9a2ac94a116a9914a52d422a83c1a79820321b5
sha256
8d660e7c0898af760c7411323e19590d1c9e33b1a9dbbf2ecd811f10d2a47d6b
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_fields
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Fields\Administrator\Field;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Fields\FieldsServiceInterface;
use Joomla\CMS\Form\Field\ListField;

/**
 * Fields Contexts
 *
 * @since  3.7.0
 */
class FieldcontextsField extends ListField
{
	/**
	 * Type of the field
	 *
	 * @var    string
	 */
	public $type = 'Fieldcontexts';

	/**
	 * Method to get the field input markup for a generic list.
	 * Use the multiple attribute to enable multiselect.
	 *
	 * @return  string  The field input markup.
	 *
	 * @since   3.7.0
	 */
	protected function getInput()
	{
		return $this->getOptions() ? parent::getInput() : '';
	}

	/**
	 * Method to get the field options.
	 *
	 * @return  array  The field option objects.
	 *
	 * @since   3.7.0
	 */
	protected function getOptions()
	{
		$parts = explode('.', $this->value);

		$component = Factory::getApplication()->bootComponent($parts[0]);

		if ($component instanceof FieldsServiceInterface)
		{
			return $component->getContexts();
		}

		return [];
	}
}

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.