- md5
- c58be2df533cae6b4e9d21e82603f931
- sha1
- 33382c19a0d91cc527f8b91abb81b19bd9b50f3b
- sha256
- f3aff945a1d74c68ad657e10bbf12485730c5387c27dfb49e0af79d023f07ef4
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
<?php
/**
* Joomla! Content Management System
*
* @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\Content\Api\Serializer;
\defined('_JEXEC') or die;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Serializer\JoomlaSerializer;
use Joomla\CMS\Uri\Uri;
use Tobscure\JsonApi\Collection;
use Tobscure\JsonApi\Relationship;
use Tobscure\JsonApi\Resource;
/**
* Temporary serializer
*
* @since 4.0.0
*/
class ContentSerializer extends JoomlaSerializer
{
/**
* Build content relationships by associations
*
* @param \stdClass $model Item model
*
* @return Relationship
*
* @since 4.0
*/
public function languageAssociations($model)
{
$resources = [];
// TODO: This can't be hardcoded in the future?
$serializer = new JoomlaSerializer($this->type);
foreach ($model->associations as $association)
{
$resources[] = (new Resource($association, $serializer))
->addLink('self', Route::link('site', Uri::root() . 'api/index.php/v1/content/article/' . $association->id));
}
$collection = new Collection($resources, $serializer);
return new Relationship($collection);
}
/**
* Build category relationship
*
* @param \stdClass $model Item model
*
* @return Relationship
*
* @since 4.0
*/
public function category($model)
{
$serializer = new JoomlaSerializer('categories');
$resource = (new Resource($model->catid, $serializer))
->addLink('self', Route::link('site', Uri::root() . 'api/index.php/v1/content/categories/' . $model->catid));
return new Relationship($resource);
}
/**
* Build category relationship
*
* @param \stdClass $model Item model
*
* @return Relationship
*
* @since 4.0
*/
public function author($model)
{
$serializer = new JoomlaSerializer('users');
$resource = (new Resource($model->created_by, $serializer))
->addLink('self', Route::link('site', Uri::root() . 'api/index.php/v1/users/' . $model->created_by));
return new Relationship($resource);
}
}
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.