Example #1
0
 public static function init($namespace)
 {
     self::$namespace = $namespace;
     self::$prefix = Config::get('app.prefix');
     self::$prefix = (self::$prefix == '' ? '' : '/') . self::$prefix;
     self::setupAutoloader();
     logger\Logger::init('logs/app.log');
     Config::readPath(self::$configPath, 'ntentan');
     kaikai\Cache::init();
     panie\InjectionContainer::bind(ModelClassResolverInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(ModelJoinerInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(TableNameResolverInterface::class)->to(nibii\Resolver::class);
     panie\InjectionContainer::bind(ComponentResolverInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(ControllerClassResolverInterface::class)->to(ClassNameResolver::class);
     panie\InjectionContainer::bind(controllers\RouterInterface::class)->to(DefaultRouter::class);
     if (Config::get('ntentan:db.driver')) {
         panie\InjectionContainer::bind(DriverAdapter::class)->to(Resolver::getDriverAdapterClassName());
         panie\InjectionContainer::bind(atiaa\Driver::class)->to(atiaa\Db::getDefaultDriverClassName());
     }
     Controller::setComponentResolverParameters(['type' => 'component', 'namespaces' => [$namespace, 'controllers\\components']]);
     nibii\RecordWrapper::setComponentResolverParameters(['type' => 'behaviour', 'namespaces' => [$namespace, 'nibii\\behaviours']]);
     controllers\ModelBinderRegister::setDefaultBinderClass(controllers\model_binders\DefaultModelBinder::class);
     controllers\ModelBinderRegister::register(utils\filesystem\UploadedFile::class, controllers\model_binders\UploadedFileBinder::class);
 }
Example #2
0
 private function getMethod($path)
 {
     $methods = kaikai\Cache::read("controller.{$this->getClassName()}.methods", function () {
         $class = new ReflectionClass($this);
         $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC);
         $results = [];
         foreach ($methods as $method) {
             $methodName = $method->getName();
             if (substr($methodName, 0, 2) == '__') {
                 continue;
             }
             if (array_search($methodName, ['addComponent', 'executeControllerAction', 'setComponentResolverParameters'])) {
                 continue;
             }
             $docComments = $this->parseDocComment($method->getDocComment());
             $keyName = isset($docComments['action']) ? $docComments['action'] . $docComments['method'] : $methodName;
             $results[$keyName] = ['name' => $method->getName(), 'binder' => isset($docComments['binder']) ? $docComments['binder'] : controllers\ModelBinderRegister::getDefaultBinderClass()];
         }
         return $results;
     });
     if (isset($methods[$path . utils\Input::server('REQUEST_METHOD')])) {
         return $methods[$path . utils\Input::server('REQUEST_METHOD')];
     } else {
         if (isset($methods[$path])) {
             return $methods[$path];
         }
     }
     return false;
 }
Example #3
0
 /**
  * 
  * @return ModelDescription
  */
 public function getDescription()
 {
     return Cache::read((new \ReflectionClass($this))->getName() . '::desc', function () {
         return new ModelDescription($this);
     });
 }
Example #4
0
<?php

/* 
 * The MIT License
 *
 * Copyright 2016 ekow.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
ntentan\config\Config::set('ntentan:db', ['driver' => getenv('NIBII_DATASTORE'), 'host' => getenv('NIBII_HOST'), 'user' => getenv('NIBII_USER'), 'password' => getenv('NIBII_PASSWORD'), 'file' => getenv('NIBII_FILE'), 'dbname' => getenv("NIBII_DBNAME")]);
\ntentan\kaikai\Cache::init();
ntentan\nibii\Nibii::setupDefaultBindings();
ntentan\panie\InjectionContainer::bind(ntentan\nibii\DriverAdapter::class)->to(\ntentan\nibii\Resolver::getDriverAdapterClassName());
ntentan\panie\InjectionContainer::bind(\ntentan\atiaa\Driver::class)->to(\ntentan\atiaa\Db::getDefaultDriverClassName());