<?php
trait AjaxTrait {

	public function beforeFilter()
	{
		if (!empty($this->params['action'])) {
			$this->params['action'] =  str_replace("ajax_","", $this->params['action']);
		}

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

		return parent::beforeFilter();
	}


	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;
	}
}
