Example #1
0
 function run($functionname, $par)
 {
     $dir = dirname(dirname(__FILE__)) . "/plugin/";
     $returnarr = array();
     $arr = $this->traverse($dir, $returnarr);
     $pluginsArray = array();
     for ($i = 0; $i < count($arr); $i++) {
         $classpat = $arr[$i]['classpath'];
         require_once $classpat;
         $classname = $arr[$i]['classname'];
         if ($classname == "pluginInterface") {
             continue;
         }
         $reflectionClass = new ReflectionClass($classname);
         if ($reflectionClass->implementsInterface('pluginInterface')) {
             try {
                 $cla = $reflectionClass->newInstance();
             } catch (Exception $e) {
                 continue;
             }
             if (method_exists($cla, $functionname)) {
                 $function = $reflectionClass->getmethod($functionname);
                 // 					$this->runfunction($classname,$classpat, "getName", $par);
                 $str = $function->invoke($cla, $par);
                 array_push($pluginsArray, $str);
             }
         }
     }
     return $pluginsArray;
 }
Example #2
0
 static function run()
 {
     App::init();
     App::route();
     try {
         $obj = new ReflectionClass(App::$_controller . 'Controller');
         $instance = $obj->newInstanceArgs();
         $obj->getmethod(App::$_action . 'Action')->invoke($instance);
     } catch (Exception $e) {
         APP_DEBUG ? exit($e->getMessage()) : APP::log($e->getMessage());
     }
 }
Example #3
0
 protected function callByParams($serviceClass, $method, $request)
 {
     $serviceClass .= 'Service';
     if (is_array($request)) {
         $class = new \ReflectionClass($serviceClass);
         if (!$class->getmethod($method)) {
             throw new \Exception('Service class:method definition is invalid. Detail: ' . $serviceClass . ' : ' . $method . '. Request: ' . json_encode($request));
         }
     } else {
         throw new \Exception('Request is not right format: ' . json_encode($request));
     }
     $serviceObj = $serviceClass::getInstance();
     if (is_callable(array($serviceObj, $method))) {
         $response = call_user_func_array(array($serviceObj, $method), $request);
         return $response;
     } else {
         throw new \Exception('Service:method not found. Detail: ' . $serviceClass . ' : ' . $method);
     }
 }
Example #4
0
function route_control($path)
{
    $domain_route_file = PATH_APP . "/include/domain_route.php";
    if (is_file($domain_route_file)) {
        include_once $domain_route_file;
        domain_route($path);
    }
    include_once PATH_PTPHP . "/libs/ui.php";
    $info = pathinfo($path);
    $model_file = str_replace(PATH_WEBROOT, "", $info['dirname']);
    PtApp::$model = PtApp::get_model($model_file);
    $model_file_path = PtLib\get_model_file_path($model_file);
    PtApp::$model_path = $model_file_path;
    if (is_dir(PATH_MODEL) && is_file($model_file_path)) {
        $model_action_name = "view_" . strtolower($info['filename']);
        $model_class_name = PtLib\get_model_class_name(PtApp::$model);
        if (class_exists($model_class_name)) {
            PtApp::$model_class_name = $model_class_name;
            $_reflector = new ReflectionClass($model_class_name);
            PtApp::$model_view_name = $model_action_name;
            if ($_reflector->hasMethod($model_action_name)) {
                $_reflector_func = $_reflector->getmethod($model_action_name);
                $_r_params = array();
                $_r_params_keys = $_reflector_func->getParameters();
                foreach ($_r_params_keys as $_k) {
                    $_r_params[] = $_k->getName();
                }
                $_r_args = array();
                foreach ($_r_params as $_k) {
                    $val = isset($_REQUEST[$_k]) ? trim($_REQUEST[$_k]) : null;
                    $_r_args[$_k] = $val;
                }
                $model_return = $_reflector_func->invokeArgs(new $model_class_name(), $_r_args);
                if ($model_return && is_array($model_return)) {
                    extract($model_return);
                }
            }
        }
    }
    PtApp::$control_path = $path;
    include_once $path;
    exit;
}
Example #5
0
<?php

$class = new ReflectionClass('mysqli');
foreach ($class->getMethods() as $m) {
    echo $m->name . '<br>';
    $param = $class->getmethod($m->name);
    foreach ($param->getParameters() as $i => $parametro) {
        echo '-->' . $parametro->getName();
    }
}