public function loadAction($nameOrAction, $format = null) {
		$model = null;
		if ($nameOrAction instanceof Action) {
			$model = $nameOrAction;
			$actionName = $nameOrAction->getName();
		} else {
			$actionName = $nameOrAction;
		}

		if (!isset($this->actions[$actionName])) {
			throw new ModuleException(sprintf('Action (%s) not found in Module (%s)', $actionName, $this->model->getName()));
		}

		if ($model === null) {
			$model = $this->actions[$actionName]['model'];
		}

		/* @var $action ActionSchema */
		$action = $this->actions[$actionName]['action'];


		// check permission
		if (!$this->service->getFirewall()->hasActionPermission($model)) {
			throw new PermissionDeniedException(sprintf('Can\'t access Action (%s) in Module (%s)', $actionName, $this->model->getName()));
		}

		// check if a response is given
		if ($format !== null) {
			if (!$action->hasResponder($format)) {
				throw new ModuleException(sprintf('No Responder (%s) given for Action (%s) in Module (%s)', $format, $actionName, $this->model->getName()));
			}
			$responseClass = $action->getResponder($format);

			if (!class_exists($responseClass)) {
				throw new ModuleException(sprintf('Responder (%s) not found in Module (%s)', $responseClass, $this->model->getName()));
			}
			$responder = new $responseClass($this);
		} else {
			$responder = new NullResponder($this);
		}

		// gets the action class
		$className = $model->getClassName();

		if (!class_exists($className)) {
			throw new ModuleException(sprintf('Action (%s) not found in Module (%s)', $className, $this->model->getName()));
		}

		$class = new $className($model, $this, $responder);


		// locales
		// ------------

		$localeService = $this->getServiceContainer()->getLocaleService();

		// load module l10n
		$file = sprintf('/%s/locales/{locale}/translations.json', $this->package->getFullName());
		$localeService->loadLocaleFile($file, $class->getCanonicalName());

// 		// load additional l10n files
// 		foreach ($action->getL10n() as $file) {
// 			$file = sprintf('/%s/locales/{locale}/%s', $this->package->getFullName(), $file);
// 			$localeService->loadLocaleFile($file, $class->getCanonicalName());
// 		}

// 		// load action l10n
// 		$file = sprintf('/%s/locales/{locale}/actions/%s', $this->package->getFullName(), $actionName);
// 		$localeService->loadLocaleFile($file, $class->getCanonicalName());


		// assets
		// ------------
		$app = $this->getServiceContainer()->getKernel()->getApplication();
		$page = $app->getPage();

		// scripts
		foreach ($action->getScripts() as $script) {
			$page->addScript($script);
		}

		// styles
		foreach ($action->getStyles() as $style) {
			$page->addStyle($style);
		}

		return $class;
	}
public function loadAction($nameOrAction, $format = null) {
		$model = null;
		if ($nameOrAction instanceof Action) {
			$model = $nameOrAction;
			$actionName = $nameOrAction->getName();
		} else {
			$actionName = $nameOrAction;
		}

		if (!isset($this->actions[$actionName])) {
			throw new ModuleException(sprintf('Action (%s) not found in Module (%s)', $actionName, $this->model->getName()));
		}

		if ($model === null) {
			$model = $this->actions[$actionName]['model'];
		}

		/* @var $action ActionSchema */
		$action = $this->actions[$actionName]['action'];


		// check permission
		if (!$this->service->getFirewall()->hasActionPermission($model)) {
			throw new PermissionDeniedException(sprintf('Can\'t access Action (%s) in Module (%s)', $actionName, $this->model->getName()));
		}

		// check if a response is given
		if ($format !== null) {
			if (!$action->hasResponder($format)) {
				throw new ModuleException(sprintf('No Responder (%s) given for Action (%s) in Module (%s)', $format, $actionName, $this->model->getName()));
			}
			$responseClass = $action->getResponder($format);

			if (!class_exists($responseClass)) {
				throw new ModuleException(sprintf('Responder (%s) not found in Module (%s)', $responseClass, $this->model->getName()));
			}
			$responder = new $responseClass($this);
		} else {
			$responder = new NullResponder($this);
		}

		// gets the action class
		$className = $model->getClassName();

		if (!class_exists($className)) {
			throw new ModuleException(sprintf('Action (%s) not found in Module (%s)', $className, $this->model->getName()));
		}

		$class = new $className($model, $this, $responder);


		// locales
		// ------------

		$localeService = $this->getServiceContainer()->getLocaleService();

		// load module l10n
		$file = sprintf('/%s/locales/{locale}/translations.json', $this->package->getFullName());
		$localeService->loadLocaleFile($file, $class->getCanonicalName());

// 		// load additional l10n files
// 		foreach ($action->getL10n() as $file) {
// 			$file = sprintf('/%s/locales/{locale}/%s', $this->package->getFullName(), $file);
// 			$localeService->loadLocaleFile($file, $class->getCanonicalName());
// 		}

// 		// load action l10n
// 		$file = sprintf('/%s/locales/{locale}/actions/%s', $this->package->getFullName(), $actionName);
// 		$localeService->loadLocaleFile($file, $class->getCanonicalName());


		// assets
		// ------------
		$app = $this->getServiceContainer()->getKernel()->getApplication();
		$page = $app->getPage();

		// scripts
		foreach ($action->getScripts() as $script) {
			$page->addScript($script);
		}

		// styles
		foreach ($action->getStyles() as $style) {
			$page->addStyle($style);
		}

		return $class;
	}
public function loadAction ( $ nameOrAction , $ format = null ) { $ model = null ; if ( $ nameOrAction instanceof Action ) { $ model = $ nameOrAction ; $ actionName = $ nameOrAction -> getName ( ) ; } else { $ actionName = $ nameOrAction ; } if ( ! isset ( $ this -> actions [ $ actionName ] ) ) { throw new ModuleException ( sprintf ( 'Action (%s) not found in Module (%s)' , $ actionName , $ this -> model -> getName ( ) ) ) ; } if ( $ model === null ) { $ model = $ this -> actions [ $ actionName ] [ 'model' ] ; } /* @var $action ActionSchema */ $ action = $ this -> actions [ $ actionName ] [ 'action' ] ; // check permission if ( ! $ this -> service -> getFirewall ( ) -> hasActionPermission ( $ model ) ) { throw new PermissionDeniedException ( sprintf ( 'Can\'t access Action (%s) in Module (%s)' , $ actionName , $ this -> model -> getName ( ) ) ) ; } // check if a response is given if ( $ format !== null ) { if ( ! $ action -> hasResponder ( $ format ) ) { throw new ModuleException ( sprintf ( 'No Responder (%s) given for Action (%s) in Module (%s)' , $ format , $ actionName , $ this -> model -> getName ( ) ) ) ; } $ responseClass = $ action -> getResponder ( $ format ) ; if ( ! class_exists ( $ responseClass ) ) { throw new ModuleException ( sprintf ( 'Responder (%s) not found in Module (%s)' , $ responseClass , $ this -> model -> getName ( ) ) ) ; } $ responder = new $ responseClass ( $ this ) ; } else { $ responder = new NullResponder ( $ this ) ; } // gets the action class $ className = $ model -> getClassName ( ) ; if ( ! class_exists ( $ className ) ) { throw new ModuleException ( sprintf ( 'Action (%s) not found in Module (%s)' , $ className , $ this -> model -> getName ( ) ) ) ; } $ class = new $ className ( $ model , $ this , $ responder ) ; // locales // ------------ $ localeService = $ this -> getServiceContainer ( ) -> getLocaleService ( ) ; // load module l10n $ file = sprintf ( '/%s/locales/{locale}/translations.json' , $ this -> package -> getFullName ( ) ) ; $ localeService -> loadLocaleFile ( $ file , $ class -> getCanonicalName ( ) ) ; // 		// load additional l10n files // 		foreach ($action->getL10n() as $file) { // 			$file = sprintf('/%s/locales/{locale}/%s', $this->package->getFullName(), $file); // 			$localeService->loadLocaleFile($file, $class->getCanonicalName()); // 		} // 		// load action l10n // 		$file = sprintf('/%s/locales/{locale}/actions/%s', $this->package->getFullName(), $actionName); // 		$localeService->loadLocaleFile($file, $class->getCanonicalName()); // assets // ------------ $ app = $ this -> getServiceContainer ( ) -> getKernel ( ) -> getApplication ( ) ; $ page = $ app -> getPage ( ) ; // scripts foreach ( $ action -> getScripts ( ) as $ script ) { $ page -> addScript ( $ script ) ; } // styles foreach ( $ action -> getStyles ( ) as $ style ) { $ page -> addStyle ( $ style ) ; } return $ class ; }
Loads the given action

@param Action|string $actionName
@param string $format the response type (e.g. html, json, ...)
@return AbstractAction
Loads the given action