__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Document;
use Joomla\CMS\Factory;
use Tobscure\JsonApi\Document;
use Tobscure\JsonApi\ElementInterface;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* JsonapiDocument class, provides an easy interface to parse output in JSON-API format.
*
* @link http://www.jsonapi.org/
* @since 4.0.0
*/
class JsonapiDocument extends JsonDocument implements \JsonSerializable
{
/**
* The JsonApi Document object.
*
* @var Document
* @since 4.0.0
*/
protected $document;
/**
* Class constructor.
*
* @param array $options Associative array of options
*
* @since 4.0.0
*/
public function __construct($options = [])
{
parent::__construct($options);
// Set mime type to JSON-API
$this->_mime = 'application/vnd.api+json';
$this->_type = 'jsonapi';
if (\array_key_exists('api_document', $options) && $options['api_document'] instanceof Document) {
$this->document = $options['api_document'];
} else {
$this->document = new Document();
}
}
/**
* Set the data object.
*
* @param ElementInterface $element Element interface.
*
* @return $this
*
* @since 4.0.0
*/
public function setData(ElementInterface $element)
{
$this->document->setData($element);
return $this;
}
/**
* Set the errors array.
*
* @param array $errors Error array.
*
* @return $this
*
* @since 4.0.0
*/
public function setErrors($errors)
{
$this->document->setErrors($errors);
return $this;
}
/**
* Set the JSON-API array.
*
* @param array $jsonapi JSON-API array.
*
* @return $this
*
* @since 4.0.0
*/
public function setJsonapi($jsonapi)
{
$this->document->setJsonapi($jsonapi);
return $this;
}
/**
* Map everything to arrays.
*
* @return array
*
* @since 4.0.0
*/
public function toArray()
{
return $this->document->toArray();
}
/**
* Map to string.
*
* @return string
*
* @since 4.0.0
*/
public function __toString()
{
return json_encode($this->toArray());
}
/**
* Outputs the document.
*
* @param boolean $cache If true, cache the output.
* @param array $params Associative array of attributes.
*
* @return string The rendered data.
*
* @since 4.0.0
*/
public function render($cache = false, $params = [])
{
$app = Factory::getApplication();
if ($mdate = $this->getModifiedDate()) {
$app->modifiedDate = $mdate;
}
$app->mimeType = $this->_mime;
$app->charSet = $this->_charset;
return json_encode($this->document);
}
/**
* Serialize for JSON usage.
*
* @return array
*
* @since 4.0.0
*/
public function jsonSerialize(): mixed
{
return $this->toArray();
}
/**
* Add a link to the output.
*
* @param string $key The name of the link
* @param string $value The link
*
* @return $this
*
* @since 4.0.0
*/
public function addLink($key, $value)
{
$this->document->addLink($key, $value);
return $this;
}
/**
* Add a link to the output.
*
* @param string $key The name of the metadata key
* @param string $value The value
*
* @return $this
*
* @since 4.0.0
*/
public function addMeta($key, $value)
{
$this->document->addMeta($key, $value);
return $this;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Feed | Folder | 0775 |
|
|
| Opensearch | Folder | 0775 |
|
|
| Renderer | Folder | 0775 |
|
|
| Document.php | File | 29.08 KB | 0664 |
|
| DocumentAwareInterface.php | File | 709 B | 0664 |
|
| DocumentAwareTrait.php | File | 1.22 KB | 0664 |
|
| DocumentRenderer.php | File | 1.68 KB | 0664 |
|
| ErrorDocument.php | File | 3.73 KB | 0664 |
|
| Factory.php | File | 3.28 KB | 0664 |
|
| FactoryInterface.php | File | 1.29 KB | 0664 |
|
| FeedDocument.php | File | 4.95 KB | 0664 |
|
| HtmlDocument.php | File | 26.28 KB | 0664 |
|
| ImageDocument.php | File | 1.73 KB | 0664 |
|
| JsonDocument.php | File | 2.04 KB | 0664 |
|
| JsonapiDocument.php | File | 4.02 KB | 0664 |
|
| OpensearchDocument.php | File | 6.11 KB | 0664 |
|
| PreloadManager.php | File | 4.51 KB | 0664 |
|
| PreloadManagerInterface.php | File | 2.83 KB | 0664 |
|
| RawDocument.php | File | 1.23 KB | 0664 |
|
| RendererInterface.php | File | 869 B | 0664 |
|
| XmlDocument.php | File | 2.89 KB | 0664 |
|