Esempio n. 1
0
 /**
  * RpcCall constructor.
  * @param string $className Class name without namespace
  * @param string $methodName Method Name
  * @param mixed $arguments Method argument
  * @throws InputError
  * @throws SecurityException
  * @throws \ema\exceptions\FatalError
  */
 public function __construct($className, $methodName, $arguments = '')
 {
     if (!self::classExists($className)) {
         throw new InputError('Unknown class requested', 6100);
     }
     $this->className = self::CALLER_NS . $className;
     if (!self::methodExists($className, $methodName)) {
         throw new InputError('Unknown method requested', 6101);
     }
     $this->methodName = $methodName;
     $gp = new GroupPolicy($this->className);
     $allowedMethods = $gp->getAjaxMethods();
     if (!in_array($methodName, $allowedMethods, true)) {
         throw new SecurityException('Method not allowed', 6102);
     }
     unset($allowedMethods, $gp);
     $this->arguments = $arguments;
 }
Esempio n. 2
0
 private static function getAjaxMethods($className)
 {
     if (self::modelExists($className) === true) {
         $gp = new GroupPolicy(self::MODELS_NAMESPACE . $className);
         $methods = $gp->getAjaxMethods();
         if (is_array($methods)) {
             print json_encode($methods);
         } else {
             throw new SecurityException("Access deny.");
         }
     } else {
         throw new RuntimeException("No such model");
     }
 }