예제 #1
0
 public function getLogic($name)
 {
     $className = "Logics_" . ucfirst($name);
     if (Sabel::using($className)) {
         return Sabel_Container::load($className, new Logics_DI());
     }
     $message = __METHOD__ . "() logic class not found.";
     throw new Sabel_Exception_ClassNotFound($message);
 }
예제 #2
0
 /**
  * clear all injection configs
  */
 public static function clearAllConfigs()
 {
     self::$configs = array();
 }
예제 #3
0
<?php

class Config_DI extends Sabel_Container_Injection
{
    public function configure()
    {
    }
}
Sabel_Container::addConfig("default", new Config_DI());
예제 #4
0
 protected function getLogic($name)
 {
     $logicName = "Logics_" . ucfirst($name);
     return Sabel_Container::load($logicName, new Logics_DI());
 }
예제 #5
0
파일: Container.php 프로젝트: reoring/sabel
<?php

class Config_Container extends Sabel_Container_Injection
{
    public function configure()
    {
    }
}
Sabel_Container::setDefaultConfig(new Config_Container());
예제 #6
0
파일: Container.php 프로젝트: reoring/sabel
 /**
  * set default config
  *
  * @param Sabel_Container_Injection $config
  * @static
  * @access public
  * @return void
  * @throws Sabel_Container_Exception_InvalidConfiguration
  */
 public static function setDefaultConfig(Sabel_Container_Injection $config)
 {
     if (!$config instanceof Sabel_Container_Injection) {
         $msg = "object type must be Sabel_Container_Injection";
         throw new Sabel_Container_Exception_InvalidConfiguration($msg);
     }
     self::$defaultConfig = $config;
 }
예제 #7
0
function load($class, $config = null)
{
    static $container = null;
    if ($container === null) {
        $container = Sabel_Container::create();
    }
    if ($config === null) {
        return $container->load($class);
    } else {
        return $container->load($class, $config);
    }
}
예제 #8
0
파일: Container.php 프로젝트: reoring/sabel
 public function testSpecificSetter()
 {
     $injector = Sabel_Container::create(new SpecificSetterConfig());
     $instance = $injector->newInstance("SpecificSetter");
     $engineOil = new EngineOil("specific");
     $specific = new SpecificSetter();
     $specific->setSpecificSetter($engineOil);
     $this->assertEquals($instance, $specific);
 }
예제 #9
0
파일: core.php 프로젝트: reoring/sabel
function load()
{
    static $container = null;
    if ($container === null) {
        $container = Sabel_Container::create();
    }
    $args = func_get_args();
    return call_user_func_array(array($container, "load"), $args);
}