예제 #1
0
 private function getWyfClassName($wyfPath, $type)
 {
     $namespace = Ntentan::getNamespace();
     $wyfPathParts = explode('.', $wyfPath);
     $name = Text::ucamelize(array_pop($wyfPathParts));
     $base = (count($wyfPathParts) ? '\\' : '') . implode('\\', $wyfPathParts);
     return "\\{$namespace}\\app{$base}\\{$type}\\{$name}";
 }
예제 #2
0
 public function __construct()
 {
     $this->addComponent('auth', array('users_model' => 'system.users', 'on_success' => 'call_function', 'login_route' => 'auth/login', 'success_function' => AuthController::class . '::postLogin'));
     TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/default'));
     TemplateEngine::appendPath(realpath(__DIR__ . '/../../views/menus'));
     View::set('route_breakdown', explode('/', Router::getRoute()));
     View::set('wyf_title', Config::get('ntentan:app.name'));
     $class = get_class($this);
     $namespace = Ntentan::getNamespace();
     if (preg_match("/{$namespace}\\\\app\\\\(?<base>.*)\\\\controllers\\\\(?<name>.*)Controller/", $class, $matches)) {
         $this->package = strtolower(str_replace("\\", ".", $matches['base']) . "." . $matches['name']);
         $this->name = str_replace(".", " ", $this->package);
         $this->path = str_replace(' ', '/', $this->name);
     }
 }
예제 #3
0
파일: Wyf.php 프로젝트: ntentan/wyf
 public static function init($parameters = [])
 {
     Router::mapRoute('wyf_auth', 'auth/{action}', ['default' => ['controller' => controllers\AuthController::class]]);
     Router::mapRoute('wyf_api', 'api/{*path}', ['default' => ['controller' => controllers\ApiController::class, 'action' => 'rest']]);
     Router::mapRoute('wyf_main', function ($route) {
         $routeArray = explode('/', $route);
         $routeDetails = self::getController($routeArray, realpath(__DIR__ . '/../../../../src/app/'), \ntentan\Ntentan::getNamespace() . '\\app');
         return $routeDetails;
     }, ['default' => ['action' => 'index']]);
     TemplateEngine::appendPath(realpath(__DIR__ . '/../views/layouts'));
     TemplateEngine::appendPath(realpath(__DIR__ . '/../views'));
     AssetsLoader::appendSourceDir(realpath(__DIR__ . '/../assets'));
     View::set('wyf_app_name', $parameters['short_name']);
     InjectionContainer::bind(ModelClassResolver::class)->to(ClassNameResolver::class);
     InjectionContainer::bind(ControllerClassResolver::class)->to(ClassNameResolver::class);
 }
예제 #4
0
파일: Ntentan.php 프로젝트: ntentan/ntentan
 private static function setupAutoloader()
 {
     spl_autoload_register(function ($class) {
         $prefix = Ntentan::getNamespace() . "\\";
         $baseDir = 'src/';
         $len = strlen($prefix);
         if (strncmp($prefix, $class, $len) !== 0) {
             return;
         }
         $relativeClass = substr($class, $len);
         $file = $baseDir . str_replace('\\', '/', $relativeClass) . '.php';
         if (file_exists($file)) {
             require_once $file;
         }
     });
 }
예제 #5
0
 public function getControllerClassName($name)
 {
     return sprintf('\\%s\\controllers\\%sController', Ntentan::getNamespace(), utils\Text::ucamelize($name));
 }