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


PHP Injector::share方法代碼示例

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


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

示例1: addToInjector

 public function addToInjector(Injector $injector)
 {
     foreach ($this->shares as $share) {
         $injector->share($share);
     }
     foreach ($this->aliases as $original => $alias) {
         $injector->alias($original, $alias);
     }
     foreach ($this->definitions as $name => $args) {
         $injector->define($name, $args);
     }
     foreach ($this->params as $param => $value) {
         $injector->defineParam($param, $value);
     }
     foreach ($this->delegates as $param => $callable) {
         $injector->delegate($param, $callable);
     }
     foreach ($this->prepares as $class => $callable) {
         $injector->prepare($class, $callable);
     }
 }
開發者ID:zvax,項目名稱:stepping,代碼行數:21,代碼來源:InjectionParams.php

示例2: registerExceptionHandlerServices

 private function registerExceptionHandlerServices(Injector $injector)
 {
     $injector->share(Run::class);
     $injector->prepare(Run::class, function (Run $run) {
         $run->pushHandler(new PrettyPageHandler());
     });
     $injector->share(ExceptionHandlingPlugin::class);
 }
開發者ID:cspray,項目名稱:labrador-http,代碼行數:8,代碼來源:Services.php

示例3: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->alias('Psr\\Http\\Message\\ResponseInterface', 'Zend\\Diactoros\\Response');
     $injector->share('Psr\\Http\\Message\\ResponseInterface');
     $injector->delegate('Psr\\Http\\Message\\ServerRequestInterface', 'Zend\\Diactoros\\ServerRequestFactory::fromGlobals');
     $injector->share('Psr\\Http\\Message\\ServerRequestInterface');
     $injector->alias('Psr\\Http\\Message\\RequestInterface', 'Psr\\Http\\Message\\ServerRequestInterface');
 }
開發者ID:mHz28,項目名稱:rest-scheduler-api,代碼行數:11,代碼來源:DiactorosConfiguration.php

示例4: setTemplatePath

 /**
  * Sets the templates path.
  *
  * @param  string            $path
  * @param  \Twig_Environment $twig
  * @param  array             $extensions
  * @return self
  */
 public function setTemplatePath($path, \Twig_Environment $twig = null, $extensions = [])
 {
     $this->paths['templates'] = $path;
     if (is_null($twig)) {
         $loader = new \Twig_Loader_Filesystem($path);
         $twig = new \Twig_Environment($loader);
     }
     $twig->setExtensions($extensions);
     $this->injector->share($twig);
     return $this;
 }
開發者ID:rougin,項目名稱:blueprint,代碼行數:19,代碼來源:Blueprint.php

示例5: performInjections

 /**
  * @param array $injections Single dimensional array of shareable values from the Silex\Application (pimple) object
  *
  * @return void
  */
 public function performInjections(array $injections)
 {
     foreach ($injections as $shareable) {
         $this->injector->share($this->application[$shareable]);
     }
     /**
      * This can only be done here because security / user is only read to be read after boot
      */
     if (isset($this->application['twig']) && isset($this->application['security.authorization_checker'])) {
         $this->application['twig']->addExtension(new SecurityExtension($this->application['security.authorization_checker']));
     }
 }
開發者ID:j7mbo,項目名稱:aurex,代碼行數:17,代碼來源:DelayedInjectionHandler.php

示例6: createInjector

function createInjector()
{
    $jigTemplatePath = new \Jig\JigTemplatePath(__DIR__ . "/fixtures/templates/");
    $jigCompilePath = new \Jig\JigCompilePath(__DIR__ . "/var/generatedTemplates/");
    // Create a JigConfig object
    $jigConfig = new JigConfig($jigTemplatePath, $jigCompilePath, Jig::COMPILE_CHECK_MTIME);
    $injector = new Injector();
    $injector->alias('Jig\\Escaper', 'Jig\\Bridge\\ZendEscaperBridge');
    $injector->delegate('FastRoute\\Dispatcher', 'TierTest\\JigBridge\\createDispatcher');
    $injector->share('FastRoute\\Dispatcher');
    $injector->share($jigConfig);
    return $injector;
}
開發者ID:danack,項目名稱:tier,代碼行數:13,代碼來源:phpunit_bootstrap.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     $this->compileDirectory = new JigCompilePath(dirname(__DIR__) . "/./../tmp/generatedTemplates/");
     $this->templateDirectory = new JigTemplatePath(dirname(__DIR__) . "/./templates/");
     $jigConfig = new JigConfig($this->templateDirectory, $this->compileDirectory, Jig::COMPILE_ALWAYS, "php.tpl");
     $injector = new \Auryn\Injector();
     $this->injector = $injector;
     $escaper = new ZendEscaperBridge(new ZendEscaper());
     $this->injector->alias('Jig\\Escaper', get_class($escaper));
     $this->injector->share($escaper);
     $this->jigDispatcher = new JigDispatcher($jigConfig, $injector);
 }
開發者ID:danack,項目名稱:jig,代碼行數:13,代碼來源:JigConverterTest.php

示例8: 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

示例9: __invoke

 public function __invoke(Injector $injector)
 {
     $injector->share($injector);
     foreach ($this->classes as $class) {
         $injector->execute($class);
     }
 }
開發者ID:elazar,項目名稱:auryn-configuration,代碼行數:7,代碼來源:ConfigurationSet.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: 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

示例12: apply

 /**
  * Applies a configuration set to a dependency injector.
  *
  * @param Injector $injector
  */
 public function apply(Injector $injector)
 {
     $paths = ["src/Users/Entity/", "src/Shifts/Entity/"];
     $isDevMode = true;
     // the connection configuration
     $dbParams = array('host' => $_ENV['DB_HOST'], 'driver' => $_ENV['DB_DRIVER'], 'user' => $_ENV['DB_USER'], 'password' => $_ENV['DB_PASSWORD'], 'dbname' => $_ENV['DB_DATABASE_NAME']);
     $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode, null, null, false);
     $injector->share(EntityManager::create($dbParams, $config));
 }
開發者ID:sctape,項目名稱:rest-scheduler-api,代碼行數:14,代碼來源:DoctrineConfiguration.php

示例13: apply

 /**
  * Applies a configuration set to a dependency injector.
  *
  * @param Injector $injector
  */
 public function apply(Injector $injector)
 {
     // Create a new Manager instance.
     $manager = new Manager(new ArrayDriver());
     // Managers can do everything
     $manager->role('manager')->allow('all');
     //        $manager->role('employee')->allow('guest', 'read');
     $injector->share($manager);
 }
開發者ID:sctape,項目名稱:rest-scheduler-api,代碼行數:14,代碼來源:AclConfiguration.php

示例14: apply

 public function apply(Injector $injector)
 {
     //START: auth
     $injector->alias(AdapterInterface::class, \trejeraos\SimpleServerMonitor\Auth\FooAdapter::class);
     $injector->alias(AuthHandler::class, FooAuthHandler::class);
     $injector->share(FooAuthHandler::class);
     // get auth token
     $injector->alias(TokenExtractorInterface::class, QueryExtractor::class);
     $injector->define(QueryExtractor::class, [':parameter' => 'tok']);
     // get auth credentials
     $injector->alias(CredentialsExtractorInterface::class, BodyExtractor::class);
     $injector->define(BodyExtractor::class, [':identifier' => 'user', ':password' => 'password']);
     // share valid auth token class
     $injector->share(\trejeraos\SimpleServerMonitor\Auth\ValidTokens::class);
     //END: auth
     // share global config class
     $injector->share(\trejeraos\SimpleServerMonitor\Data\Configuration::class);
 }
開發者ID:triple-j,項目名稱:simple-server-monitor,代碼行數:18,代碼來源:FooConfiguration.php

示例15: getServiceLocator

 public function getServiceLocator()
 {
     if (!$this->service_locator) {
         $di_container = new DiContainer(new StandardReflector());
         $di_container->share($di_container);
         $service_provisioner = $di_container->make(ServiceProvisioner::CLASS);
         $this->service_locator = $service_provisioner->provision();
     }
     return $this->service_locator;
 }
開發者ID:honeybee,項目名稱:honeybee-agavi-cmf-vendor,代碼行數:10,代碼來源:Context.php


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