當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Injector::make方法代碼示例

本文整理匯總了PHP中Auryn\Injector::make方法的典型用法代碼示例。如果您正苦於以下問題:PHP Injector::make方法的具體用法?PHP Injector::make怎麽用?PHP Injector::make使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Auryn\Injector的用法示例。


在下文中一共展示了Injector::make方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __invoke

 /**
  * Resolve a class spec into an object, if it is not already instantiated.
  *
  * @param string|object $specOrObject
  *
  * @return object
  */
 public function __invoke($specOrObject)
 {
     if (is_object($specOrObject)) {
         return $specOrObject;
     }
     return $this->injector->make($specOrObject);
 }
開發者ID:equip,項目名稱:framework,代碼行數:14,代碼來源:AurynResolver.php

示例2: run

 /**
  * Start the console application
  * 
  * @return int 0 if everything went fine, or an error code
  */
 public function run()
 {
     $this->configuration->apply($this->injector);
     $application = $this->injector->make(ConsoleApplication::class);
     array_map(function ($command) use($application) {
         $application->add($this->injector->make($command));
     }, $this->commands->toArray());
     return $application->run();
 }
開發者ID:equip,項目名稱:console,代碼行數:14,代碼來源:Application.php

示例3: make

 /**
  * {@inheritdoc}
  */
 public function make($class)
 {
     try {
         return $this->auryn->make($class);
     } catch (InjectionException $e) {
         throw new DependencyInjectionException('Dependency injection failed while trying to make ' . $class . ', ' . $e->getMessage(), $e->getCode(), $e);
         //@codeCoverageIgnoreStart
     } catch (ReflectionException $e) {
         throw new DependencyInjectionException('Dependency injection failed while trying to make ' . $class . ', ' . $e->getMessage(), $e->getCode(), $e);
         //@codeCoverageIgnoreEnd
     }
 }
開發者ID:opsbears,項目名稱:piccolo-dic-auryn,代碼行數:15,代碼來源:AurynDependencyInjectionContainer.php

示例4: add

 /**
  * Adds a new instance to the container.
  *
  * @param string $id
  * @param mixed  $concrete
  */
 public function add($id, $concrete = null)
 {
     if ($concrete && !is_array($concrete)) {
         $this->instances[$id] = $concrete;
         return $this;
     }
     $arguments = [];
     if (is_array($concrete)) {
         $arguments = $concrete;
     }
     $this->instances[$id] = $this->injector->make($id, $arguments);
     return $this;
 }
開發者ID:rougin,項目名稱:slytherin,代碼行數:19,代碼來源:Container.php

示例5: execute

 /**
  * 
  */
 function execute()
 {
     $gauges = [];
     $counters = [];
     $asyncStats = $this->injector->make('Stats\\AsyncStats');
     $gauges = array_merge($gauges, $this->getQueueGauges());
     $counters = array_merge($counters, $asyncStats->getCounters());
     $requiredTimers = [\ImagickDemo\Queue\ImagickTaskRunner::event_imageGenerated, \ImagickDemo\Queue\ImagickTaskRunner::event_pageGenerated];
     $gauges = array_merge($gauges, $asyncStats->summariseTimers($requiredTimers));
     if (count($counters) || count($gauges)) {
         $librato = $this->injector->make('Stats\\Librato');
         $librato->send($gauges, $counters);
     }
 }
開發者ID:sdmmember,項目名稱:Imagick-demos,代碼行數:17,代碼來源:SimpleStats.php

示例6: setUp

 protected function setUp()
 {
     define('MODEL_DIR', '\\Test\\Model');
     //define('DEBUG_MODE', true);
     $this->injector = new Injector();
     $this->injector->share(Database::class);
     $this->database = $this->injector->make('Minute\\Database\\Database', [true]);
     try {
         $this->pdo = $this->database->getPdo();
     } catch (\PDOException $e) {
         $this->markTestSkipped('Database connection error: ' . $e->getMessage());
     }
     parent::setUp();
 }
開發者ID:minutephp,項目名稱:framework,代碼行數:14,代碼來源:PHPUnit_Db_Test_Base.php

示例7: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     foreach ($this as $class) {
         $configuration = $injector->make($class);
         $configuration->apply($injector);
     }
 }
開發者ID:mikegreiling,項目名稱:spark,代碼行數:10,代碼來源:ConfigurationSet.php

示例8: initialize

 /**
  * Creates all service hook handlers.
  */
 private function initialize()
 {
     $injector = new Injector();
     $namespace = __NAMESPACE__ . "\\Service\\";
     $basePath = __DIR__ . "/../vendor/kelunik/chat-services/res/schema/";
     $transform = function ($match) {
         return strtoupper($match[1]);
     };
     try {
         foreach ($this->config["services"] as $name => $enabled) {
             if (!$enabled) {
                 continue;
             }
             $service = $injector->make($namespace . preg_replace_callback("~-([a-z])~", $transform, ucfirst($name)));
             $found = false;
             foreach (scandir($basePath . $name) as $file) {
                 if ($file === "." || $file === "..") {
                     continue;
                 }
                 $found = true;
                 $uri = realpath($basePath . $name . "/" . $file);
                 $schema = $this->retriever->retrieve("file://" . $uri);
                 $this->schemas[$name][strtok($file, ".")] = $schema;
             }
             if (!$found) {
                 throw new RuntimeException("every service must have at least one event schema");
             }
             $this->services[$name] = $service;
         }
     } catch (InjectorException $e) {
         throw new RuntimeException("couldn't create all services", 0, $e);
     }
 }
開發者ID:kelunik,項目名稱:chat-hooks,代碼行數:36,代碼來源:Dispatcher.php

示例9: run

 /**
  * Run the application
  *
  * @param string $runner
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function run($runner = 'Relay\\Relay')
 {
     foreach ($this->configuration as $entry) {
         $this->injector->make($entry)->apply($this->injector);
     }
     return $this->injector->share($this->middleware)->prepare('Spark\\Directory', $this->routing)->execute($runner);
 }
開發者ID:curtis1000,項目名稱:spark,代碼行數:14,代碼來源:Application.php

示例10: setMedoo

 function setMedoo()
 {
     $injector = new Injector();
     $injector->share('medoo');
     $injector->define('medoo', [':options' => $this->databaseconfig]);
     $this->medoodb = $injector->make('medoo');
 }
開發者ID:WeihuaGu,項目名稱:incolor,代碼行數:7,代碼來源:Model.php

示例11: testApply

 /**
  * @param string $class
  * @dataProvider dataMapping
  */
 public function testApply($class)
 {
     $injector = new Injector();
     $configuration = $injector->make(AuraCliConfiguration::class);
     $configuration->apply($injector);
     $instance = $injector->make($class);
     $this->assertInstanceOf($class, $instance);
 }
開發者ID:equip,項目名稱:redis-queue,代碼行數:12,代碼來源:AuraCliConfigurationTest.php

示例12: createController

 /**
  * resolve router target to class object
  * @param string $target route target, format: Class#method or Class/method
  * @return array [object, method]
  */
 public function createController($target)
 {
     $matches = null;
     if (false === preg_match('/[#|\\/]/', $target, $matches)) {
         throw new HttpException(404, 'Invalid route: ' . $target);
     }
     list($class, $method) = explode($matches[0], $target, 2);
     $class = 'Controller\\' . $class;
     if (!class_exists($class)) {
         throw new HttpException(404, sprintf('Controller "%s" does not exist.', $class));
     }
     $instance = $this->injector->make($class);
     if (!method_exists($instance, $method)) {
         throw new HttpException(404, sprintf('Action "%s" not found on controller "%s"', $method, $class));
     }
     return [$instance, $method];
 }
開發者ID:raisoblast,項目名稱:rakitan,代碼行數:22,代碼來源:Dispatcher.php

示例13: testApply

 public function testApply()
 {
     $injector = new Injector();
     $configuration = $injector->make(PredisConfiguration::class);
     $configuration->apply($injector);
     $instance = $injector->make(Client::class);
     $this->assertInstanceOf(Client::class, $instance);
 }
開發者ID:equip,項目名稱:redis-queue,代碼行數:8,代碼來源:PredisConfigurationTest.php

示例14: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     foreach ($this as $configuration) {
         if (!is_object($configuration)) {
             $configuration = $injector->make($configuration);
         }
         $configuration->apply($injector);
     }
 }
開發者ID:equip,項目名稱:config,代碼行數:12,代碼來源:ConfigurationSet.php

示例15: apply

 public function apply(Injector $injector)
 {
     $injector->prepare(Engine::class, function (Engine $engine) use($injector) {
         $session = $injector->make(Session::class);
         $engine->registerFunction('is_logged_in', function () use($session) {
             return $session->has('rdio.token') && $session->has('tidal.session');
         });
     });
 }
開發者ID:shadowhand,項目名稱:radiotide,代碼行數:9,代碼來源:PlatesSessionConfiguration.php


注:本文中的Auryn\Injector::make方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。