CoreFiles by mySites.guru
WorkflowcontextsField.php70 lines, 1,386 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
15238bc9adfd94cabdea4de804d91b6e
sha1
1f8b80cbcc57a28226a28b3224b31be1bbe9580e
sha256
a66bc29af1f3fbd8d78d58a2f54fb97cde5aa0ee61d7de886e6d137963335d17
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_workflow
 *
 * @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\Workflow\Administrator\Field;

\defined('_JEXEC') or die;

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

/**
 * 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 [];
	}
}

No other release has this exact content. See every version of this file.