Example #1
0
 /**
  * Return a registered response plugin
  *
  * Pass the plugin name as the first argument and the plugin object will be returned.
  * You can then access the methods of the plugin directly.
  *
  * @param string        $sName                The plugin name
  *
  * @return \Xajax\Plugin\Response
  */
 public function plugin($sName)
 {
     $xPlugin = $this->xPluginManager->getResponsePlugin($sName);
     if (!$xPlugin) {
         return null;
     }
     $xPlugin->setResponse($this);
     return $xPlugin;
 }
Example #2
0
 /**
  * Process the incoming Xajax request
  *
  * @return boolean
  */
 public function processRequest()
 {
     if (!$this->canProcessRequest()) {
         return false;
     }
     $aArgs = RequestManager::getInstance()->process();
     // Try to register an instance of the requested class, if it isn't yet
     if (!array_key_exists($this->sRequestedClass, $this->aCallableObjects)) {
         PluginManager::getInstance()->registerClass($this->sRequestedClass);
     }
     if (array_key_exists($this->sRequestedClass, $this->aCallableObjects)) {
         $xCallableObject = $this->aCallableObjects[$this->sRequestedClass];
         if ($xCallableObject->hasMethod($this->sRequestedMethod)) {
             $xCallableObject->call($this->sRequestedMethod, $aArgs);
             return true;
         }
     }
     // Unable to find the requested object or method
     throw new \Xajax\Exception\Error('errors.objects.invalid', array('class' => $this->sRequestedClass, 'method' => $this->sRequestedMethod));
 }
Example #3
0
/**
 * start.php - 
 *
 * This file is automatically loaded by the Composer autoloader
 *
 * The Xajax global functions are defined here, and the library is initialised.
 *
 * @package xajax-core
 * @author Thierry Feuzeu <*****@*****.**>
 * @copyright 2016 Thierry Feuzeu <*****@*****.**>
 * @license https://opensource.org/licenses/BSD-2-Clause BSD 2-Clause License
 * @link https://github.com/lagdo/xajax-core
 */
/**
 * Translate a text to the selected language
 *
 * @param string        $sText                The text to translate
 * @param array            $aPlaceHolders        The placeholders in the text
 * @param string        $sLanguage            The language to translate to
 *
 * @return string
 */
function xajax_trans($sText, array $aPlaceHolders = array(), $sLanguage = null)
{
    return \Xajax\Utils\Container::getInstance()->getTranslator()->trans($sText, $aPlaceHolders, $sLanguage);
}
/*
 * Load the Xajax request plugins
 */
\Xajax\Plugin\Manager::getInstance()->loadPlugins();
Example #4
0
 /**
  * Provides access to registered response plugins
  *
  * Pass the plugin name as the first argument and the plugin object will be returned.
  * You can then access the methods of the plugin directly.
  *
  * @param string        $sName                The name of the plugin
  *
  * @return \Xajax\Plugin\Response
  */
 public function plugin($sName)
 {
     $xPlugin = PluginManager::getInstance()->getResponsePlugin($sName);
     if (!$xPlugin) {
         return false;
     }
     $xPlugin->setResponse($this);
     return $xPlugin;
 }