- md5
- 3423985643106e92f6427db471f2bd39
- sha1
- 9bf5a16a02abb71ac0c0526b745172f24cac1358
- sha256
- fc8de72a44933798e63919f59e344683641a3d9d067b83f8c096fd0a6392a832
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
<?php
/**
* @package Joomla.API
* @subpackage com_contact
*
* @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\Contact\Api\View\Contacts;
\defined('_JEXEC') or die;
use Joomla\CMS\MVC\View\JsonApiView as BaseApiView;
use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;
/**
* The contacts view
*
* @since 4.0.0
*/
class JsonapiView extends BaseApiView
{
/**
* The fields to render item in the documents
*
* @var array
* @since 4.0.0
*/
protected $fieldsToRenderItem = ['id', 'alias', 'name', 'catid', 'created'];
/**
* The fields to render items in the documents
*
* @var array
* @since 4.0.0
*/
protected $fieldsToRenderList = ['id', 'alias', 'name', 'catid', 'created'];
/**
* Execute and display a template script.
*
* @param array|null $items Array of items
*
* @return string
*
* @since 4.0.0
*/
public function displayList(array $items = null)
{
foreach (FieldsHelper::getFields('com_contact.contact') as $field)
{
$this->fieldsToRenderList[] = $field->name;
}
return parent::displayList();
}
/**
* Execute and display a template script.
*
* @param object $item Item
*
* @return string
*
* @since 4.0.0
*/
public function displayItem($item = null)
{
foreach (FieldsHelper::getFields('com_contact.contact') as $field)
{
$this->fieldsToRenderItem[] = $field->name;
}
return parent::displayItem();
}
/**
* Prepare item before render.
*
* @param object $item The model item
*
* @return object
*
* @since 4.0.0
*/
protected function prepareItem($item)
{
foreach (FieldsHelper::getFields('com_contact.contact', $item, true) as $field)
{
$item->{$field->name} = isset($field->apivalue) ? $field->apivalue : $field->rawvalue;
}
return parent::prepareItem($item);
}
}
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.