<?php

/** 
 *------------------------------------------------------------------------------
 * @package       T4 Page Builder for Joomla!
 *------------------------------------------------------------------------------
 * @copyright     Copyright (C) 2004-2020 JoomlArt.com. All Rights Reserved.
 * @license       GNU General Public License version 2 or later; see LICENSE.txt
 * @authors       JoomlArt
 * @forum:		  https://www.joomlart.com/forums/t/t4-builder
 * @Link:         https://demo.t4-builder.joomlart.com/
 *------------------------------------------------------------------------------
 */
namespace JPB\Editor\Action;
defined('_JEXEC') or die;

use Joomla\CMS\Factory;

class Pagekey extends Base {

	public $itemId;

	public function run() {
		$input = Factory::getApplication()->input;
		$this->itemId = $input->getInt('id');
		$row = \JPB\Helper\Item::load($this->itemId);
		$page_key = $row ? explode("-", $row->page_key) : null;
		if(is_array($page_key) && isset($page_key[1])){
			return ["data"=> ["id" => $page_key[1] , "title" => $row->title]];
		}
		return ["data"=> ["id" => "" , "title" => $row->title]];
	}

}

