예제 #1
0
파일: View.php 프로젝트: TuxBoy/Demo-saf
 /**
  * @param $view_name     string   the view name is the associated data class name
  * @param $feature_names string[] feature and inherited feature which view will be searched
  * @param $template      string   if a specific template is set, the view named with it will be
  *                       searched into the view / feature namespace first
  * @return callable
  */
 private static function getView($view_name, $feature_names, $template = null)
 {
     $view_engine_name = get_class(View::current());
     $view_engine_name = Namespaces::shortClassName(Namespaces::of($view_engine_name));
     if (isset($template)) {
         foreach ([$view_engine_name . '_View', 'View'] as $suffix) {
             foreach ($feature_names as $feature_name) {
                 list($class, $method) = Getter::get($view_name, $feature_name, Names::methodToClass($template) . '_' . $suffix, 'php');
                 if (isset($class)) {
                     break 2;
                 }
             }
         }
     }
     if (!isset($class)) {
         foreach ([$view_engine_name . '_View', 'View'] as $suffix) {
             foreach ($feature_names as $feature_name) {
                 list($class, $method) = Getter::get($view_name, $feature_name, $suffix, 'php');
                 if (isset($class)) {
                     break 2;
                 }
             }
         }
     }
     if (!isset($class)) {
         list($class, $method) = [__CLASS__ . BS . $view_engine_name . BS . 'Default_View', 'run'];
     }
     /** @noinspection PhpUndefinedVariableInspection if $class is set, then $method is set too */
     return [$class, $method];
 }
예제 #2
0
파일: Engine.php 프로젝트: TuxBoy/Demo-saf
 /**
  * @param $class_name    string   the associated data class name
  * @param $feature_names string[] feature and inherited feature which view will be searched
  * @param $template      string   if a specific template is set, the view named with it will be
  *                       searched into the view / feature namespace first
  * @param $template_file_type string can search template files with another extension than 'html'
  * @return string the resulting path of the found template file
  */
 public static function getTemplateFile($class_name, $feature_names, $template = null, $template_file_type = 'html')
 {
     if (isset($template)) {
         foreach ($feature_names as $feature_name) {
             $class = Getter::get($class_name, $feature_name, $template, $template_file_type, false)[0];
             if (isset($class)) {
                 break;
             }
         }
     }
     if (!isset($class)) {
         foreach ($feature_names as $feature_name) {
             $class = Getter::get($class_name, $feature_name, '', $template_file_type, false)[0];
             if (isset($class)) {
                 break;
             }
         }
     }
     return isset($class) ? Names::classToPath($class) . DOT . $template_file_type : stream_resolve_include_path('default' . DOT . $template_file_type);
 }
예제 #3
0
파일: Main.php 프로젝트: TuxBoy/Demo-saf
 /**
  * @param $controller_name string the name of the data class which controller we are looking for
  * @param $feature_name    string the feature which controller we are looking for
  * @param $sub_feature     string if set, the sub feature controller is searched into the feature
  *                         controller namespace
  * @return callable
  */
 private function getController($controller_name, $feature_name, $sub_feature = null)
 {
     if (isset($sub_feature)) {
         list($class, $method) = Getter::get($controller_name, $feature_name, Names::methodToClass($sub_feature) . '_Controller', 'php');
     }
     if (!isset($class)) {
         list($class, $method) = Getter::get($controller_name, $feature_name, 'Controller', 'php');
     }
     if (!isset($class)) {
         list($class, $method) = [Default_Controller::class, 'run'];
     }
     /** @noinspection PhpUndefinedVariableInspection if $class is set, then $method is set too */
     return [$class, $method];
 }