CoreFiles by mySites.guru
WorkflowcontextsField.php70 lines, 1,373 bytes, from Joomla_4.2.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 4.2.0-alpha1
md5
2bdf71cdf4d08c4dc86d1ea87b9abf8c
sha1
c6d76a1fce2b8d45ffb112777dbd47c72ec89134
sha256
0c510904c4d367f13357db08d28c5db80e743dbcf7e7db3c260222bf24da032a
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_workflow
 *
 * @copyright   (C) 2020 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Workflow\Administrator\Field;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Workflow\WorkflowServiceInterface;

/**
 * Fields Contexts
 *
 * @since  4.0.0
 */
class WorkflowcontextsField extends ListField
{
	/**
	 * Type of the field
	 *
	 * @var    string
	 */
	public $type = 'Workflowcontexts';

	/**
	 * 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   4.0.0
	 */
	protected function getInput()
	{
		if (count($this->getOptions()) < 2)
		{
			$this->layout = 'joomla.form.field.hidden';
		}

		return parent::getInput();
	}

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

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

		if ($component instanceof WorkflowServiceInterface)
		{
			return $component->getWorkflowContexts();
		}

		return [];
	}
}

The same content is in 51 releases, Joomla 4.0.0-beta6 to 4.2.0-beta2. See them all, or every version of this file.