<?php
namespace App\Controller;

use Cake\Event\EventInterface;

trait AjaxTrait {

	public function beforeFilter(EventInterface $event)
	{
		if (!empty($this->request->getParam('action'))) {
			$this->request->withParam('action', str_replace("ajax_","", $this->request->getParam('action')));
		}

		if (!empty($this->action)) {
			$this->action =  str_replace("ajax_", "", $this->action);
		}

		return parent::beforeFilter($event);
	}
//
//
//	protected function _getViewObject() {
//		/* @var $view View */
//		$view = parent::_getViewObject();
//		$view->viewPath = 'Api';
//		$view->subDir = str_replace( "Controller", "",__CLASS__);
//
//		if (!empty($view->view)) {
//			$view->view =  str_replace("ajax_", "", $view->view);
//		}
//
//		return $view;
//	}
}
