-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
FieldcontextsField.php
60 lines (51 loc) · 1.21 KB
/
FieldcontextsField.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* @package Joomla.Administrator
* @subpackage com_fields
*
* @copyright Copyright (C) 2005 - 2019 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
{
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 [];
}
}