示例#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);
 }
示例#2
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());