- md5
- f9d3ceb85e65354f61c32e9e4103d043
- sha1
- 1047971282bcbee678453eaefb23c328bea2da63
- sha256
- 219160c61db0445dac67faf56161b872e1ce46e98841f7f8f1dcd4943e172723
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
<?php
/**
* @package Joomla.Plugin
* @subpackage Fields.list
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Plugin\Fields\ListField\Extension;
use Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Fields List Plugin
*
* @since 3.7.0
*/
final class ListPlugin extends FieldsListPlugin
{
/**
* Before prepares the field value.
*
* @param string $context The context.
* @param \stdclass $item The item.
* @param \stdclass $field The field.
*
* @return void
*
* @since 3.7.0
*/
public function onCustomFieldsBeforePrepareField($context, $item, $field)
{
if (!$this->getApplication()->isClient('api')) {
return;
}
if (!$this->isTypeSupported($field->type)) {
return;
}
$options = $this->getOptionsFromField($field);
$field->apivalue = [$field->value => $options[$field->value]];
}
/**
* Prepares the field
*
* @param string $context The context.
* @param stdclass $item The item.
* @param stdclass $field The field.
*
* @return object
*
* @since 3.9.2
*/
public function onCustomFieldsPrepareField($context, $item, $field)
{
// Check if the field should be processed
if (!$this->isTypeSupported($field->type)) {
return;
}
// The field's rawvalue should be an array
if (!is_array($field->rawvalue)) {
$field->rawvalue = (array) $field->rawvalue;
}
return parent::onCustomFieldsPrepareField($context, $item, $field);
}
}
The same content is in 28 releases, Joomla 4.3.0-beta1 to 5.0.0-beta2. See them all, or every version of this file.