CoreFiles by mySites.guru
StylesController.php99 lines, 2,158 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
1f90cfeffaf95a78a7858d2ec08bb247
sha1
e930a9f7f6de140ba9aa0c1c25face798c728df8
sha256
a463f06a80c1d1259febdfdee2c146245e51bb340f60cd945dc396cb31a1d341
<?php
/**
 * @package     Joomla.API
 * @subpackage  com_templates
 *
 * @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\Templates\Api\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\MVC\Controller\ApiController;

/**
 * The styles controller
 *
 * @since  4.0.0
 */
class StylesController extends ApiController
{
	/**
	 * The content type of the item.
	 *
	 * @var    string
	 * @since  4.0.0
	 */
	protected $contentType = 'styles';

	/**
	 * The default view for the display method.
	 *
	 * @var    string
	 * @since  3.0
	 */
	protected $default_view = 'styles';

	/**
	 * Basic display of an item view
	 *
	 * @param   integer  $id  The primary key to display. Leave empty if you want to retrieve data from the request
	 *
	 * @return  static  A \JControllerLegacy object to support chaining.
	 *
	 * @since   4.0.0
	 */
	public function displayItem($id = null)
	{
		$this->input->set('model_state', ['client_id' => $this->getClientIdFromInput()]);

		return parent::displayItem($id);
	}

	/**
	 * Basic display of a list view
	 *
	 * @return  static  A \JControllerLegacy object to support chaining.
	 *
	 * @since   4.0.0
	 */
	public function displayList()
	{
		$this->input->set('model_state', ['client_id' => $this->getClientIdFromInput()]);

		return parent::displayList();
	}

	/**
	 * Method to save a record.
	 *
	 * @param   integer  $recordKey  The primary key of the item (if exists)
	 *
	 * @return  integer  The record ID on success, false on failure
	 *
	 * @since   4.0.0
	 */
	protected function save($recordKey = null)
	{
		$data              = (array) json_decode($this->input->json->getRaw(), true);
		$data['client_id'] = $this->getClientIdFromInput();

		$this->input->set('data', $data);

		return parent::save($recordKey);
	}

	/**
	 * Get client id from input
	 *
	 * @return string
	 *
	 * @since 4.0
	 */
	private function getClientIdFromInput()
	{
		return $this->input->exists('client_id') ? $this->input->get('client_id') : $this->input->post->get('client_id');
	}
}

No other release has this exact content. See every version of this file.