当前位置: 首页>>代码示例>>PHP>>正文


PHP Container::make方法代码示例

本文整理汇总了PHP中Container::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::make方法的具体用法?PHP Container::make怎么用?PHP Container::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Container的用法示例。


在下文中一共展示了Container::make方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCanBindInterfaceUsingWhenNeedsGive

 public function testCanBindInterfaceUsingWhenNeedsGive()
 {
     $this->container->when('NetRivet\\Container\\Test\\Foo')->needs('NetRivet\\Container\\Test\\BarInterface')->give('NetRivet\\Container\\Test\\Bar2');
     $foo = $this->container->make('NetRivet\\Container\\Test\\Foo');
     $bar = $foo->getBar();
     $this->assertInstanceOf('NetRivet\\Container\\Test\\Bar2', $bar);
 }
开发者ID:netrivet,项目名称:container,代码行数:7,代码来源:ContainerTest.php

示例2: runMigrations

 /**
  * Runs the migrations for devise in our sqlite memory db
  *
  * @return void
  */
 public static function runMigrations()
 {
     $migrations = static::$application->make('migration.repository');
     if (!$migrations->repositoryExists()) {
         $migrations->createRepository();
     }
     $migrator = static::$application->make('migrator');
     $migrator->run(__DIR__ . '/../src/migrations');
 }
开发者ID:alpas29,项目名称:cms,代码行数:14,代码来源:DeviseTestCase.php

示例3: makeModel

 /**
  * Make Model.
  *
  * @return Model
  *
  * @throws RepositoryException
  */
 public function makeModel()
 {
     $model = $this->app->make($this->model());
     if (!$model instanceof Model) {
         throw new RepositoryException("Class {$this->model()}" . " must be an instance of Illuminate\\Database\\Eloquent\\Model");
     }
     return $this->model = $model;
 }
开发者ID:phanngoc,项目名称:elearnpub,代码行数:15,代码来源:Repository.php

示例4: make

 /**
  * @param $className
  * @param bool $singleton
  * @return object
  */
 public static function make($className, $singleton = true)
 {
     return static::$container->make($className, $singleton);
 }
开发者ID:mirfan,项目名称:Whirlpool,代码行数:9,代码来源:Whirlpool.php

示例5: bind

class Container
{
    protected $binds;
    protected $instances;
    public function bind($abstract, $concrete)
    {
        if ($concrete instanceof Closure) {
            $this->binds[$abstract] = $concrete;
        } else {
            $this->instances[$abstract] = $concrete;
        }
    }
    public function make($abstract, $parameters = [])
    {
        if (isset($this->instances[$abstract])) {
            return $this->instances[$abstract];
        }
        array_unshift($parameters, $this);
        return call_user_func_array($this->binds[$abstract], $parameters);
    }
}
$container = new Container();
$container->bind('superman', function ($container, $moduleName) {
    return new Superman($container->make($moduleName));
});
$container->bind('xpower', function ($container) {
    return new Xpower();
});
$superman_1 = $container->make('superman', ['xpower']);
var_dump($superman_1);
var_dump($superman_1 instanceof Superman);
开发者ID:Justin1989,项目名称:Toolkit,代码行数:31,代码来源:IoC.php

示例6: createClassCallable

 /**
  * Transform class to callable
  * 
  * @param  string|callable  $handler
  * @param  Container        $container
  * @return callable
  */
 protected function createClassCallable($handler, $container)
 {
     list($class, $method) = $this->parseClassCallable($handler);
     return [$container->make($class), $method];
 }
开发者ID:inoplate,项目名称:velatchet,代码行数:12,代码来源:TopicHandlers.php

示例7: make

 /**
  * Resolve the class out of the Container
  *
  * @param string $class
  * @return mixed
  */
 public function make($class)
 {
     return $this->container->make($class);
 }
开发者ID:RowlandOti,项目名称:ooglee-core,代码行数:10,代码来源:LaravelContainer.php


注:本文中的Container::make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。