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


PHP Injector::define方法代碼示例

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


在下文中一共展示了Injector::define方法的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: setClassParameters

 /**
  * {@inheritdoc}
  */
 public function setClassParameters($className, $arguments)
 {
     foreach ($arguments as $key => $value) {
         unset($arguments[$key]);
         $arguments[':' . $key] = $value;
     }
     $this->auryn->define($className, $arguments);
 }
開發者ID:opsbears,項目名稱:piccolo-dic-auryn,代碼行數:11,代碼來源:AurynDependencyInjectionContainer.php

示例3: apply

 /**
  *
  * {@inheritDoc}
  *
  * @see \Spark\Configuration\ConfigurationInterface::apply()
  */
 public function apply(Injector $injector)
 {
     $host = $this->env['DB_HOST'];
     $username = $this->env['DB_USERNAME'];
     $password = $this->env['DB_PASSWORD'];
     $name = $this->env['DB_DBNAME'];
     $port = $this->env['DB_PORT'];
     $dsn = "mysql:dbname={$name};host={$host};port={$port}";
     $injector->define('PDO', [':dsn' => $dsn, ':username' => $username, ':passwd' => $password]);
     $injector->define('FluentPDO', [':pdo' => $injector->make('PDO')]);
 }
開發者ID:andypoorman,項目名稱:wheniwork,代碼行數:17,代碼來源:FluentPDOConfiguration.php

示例4: apply

 /**
  * Applies a configuration set to a dependency injector.
  *
  * @param Injector $injector
  */
 public function apply(Injector $injector)
 {
     // JWT
     $injector->define('Equip\\Auth\\Jwt\\Configuration', [':publicKey' => 'uhklzsdv89ywrahu', ':ttl' => 3600, ':algorithm' => 'HS256']);
     $injector->alias('Equip\\Auth\\Jwt\\GeneratorInterface', 'Equip\\Auth\\Jwt\\FirebaseGenerator');
     $injector->alias('Equip\\Auth\\Jwt\\ParserInterface', 'Equip\\Auth\\Jwt\\FirebaseParser');
     // Tokens
     $injector->alias(TokenExtractorInterface::class, TokenHeaderExtractor::class);
     $injector->define(TokenHeaderExtractor::class, [':header' => 'Bearer']);
     // Credentials
     $injector->alias(CredentialsExtractorInterface::class, CredentialsBodyExtractor::class);
     // Adapter
     $injector->alias(AdapterInterface::class, JWTAdapter::class);
 }
開發者ID:aronduby,項目名稱:wheniwork,代碼行數:19,代碼來源:AuthConfiguration.php

示例5: apply

 /**
  *
  * {@inheritDoc}
  *
  * @see \Spark\Configuration\ConfigurationInterface::apply()
  */
 public function apply(Injector $injector)
 {
     $injector->alias(ExtractorInterface::class, HeaderExtractor::class);
     $injector->define(HeaderExtractor::class, [':header' => 'token']);
     $injector->alias(\Spark\Auth\Credentials\ExtractorInterface::class, BodyExtractor::class);
     $injector->alias(AdapterInterface::class, AuthAdapter::class);
 }
開發者ID:andypoorman,項目名稱:wheniwork,代碼行數:13,代碼來源:AuthConfiguration.php

示例6: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->define(RelayBuilder::class, ['resolver' => 'Spark\\Resolver\\ResolverInterface']);
     $injector->delegate('Relay\\Relay', function (RelayBuilder $builder, Middleware $queue) {
         return $builder->newInstance($queue);
     });
 }
開發者ID:mHz28,項目名稱:rest-scheduler-api,代碼行數:10,代碼來源:RelayConfiguration.php

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

示例8: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->define(RelayBuilder::class, ['resolver' => ResolverInterface::class]);
     $factory = function (RelayBuilder $builder, MiddlewareSet $queue) {
         return $builder->newInstance($queue);
     };
     $injector->delegate(Relay::class, $factory);
 }
開發者ID:equip,項目名稱:framework,代碼行數:11,代碼來源:RelayConfiguration.php

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

示例10: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->define(Loader::class, [':filepaths' => $this->envfile]);
     $injector->share(Env::class);
     $injector->prepare(Env::class, function (Env $env, Injector $injector) {
         $loader = $injector->make(Loader::class);
         $values = $loader->parse()->toArray();
         return $env->withValues($values);
     });
 }
開發者ID:equip,項目名稱:framework,代碼行數:13,代碼來源:EnvConfiguration.php

示例11: registerRouterServices

 private function registerRouterServices(Injector $injector)
 {
     $injector->share(RouteCollector::class);
     $injector->define(RouteCollector::class, ['routeParser' => StdRouteParser::class, 'dataGenerator' => GcbGenerator::class]);
     $injector->share(Router\FastRouteRouter::class);
     $injector->define(Router\FastRouteRouter::class, ['collector' => RouteCollector::class, ':dispatcherCb' => function (array $data) use($injector) {
         return $injector->make(GcbDispatcher::class, [':data' => $data]);
     }]);
     $injector->alias(Router\Router::class, Router\FastRouteRouter::class);
     $injector->share(ResolverChain::class);
     $injector->prepare(ResolverChain::class, function (ResolverChain $chain, Injector $injector) {
         $chain->add($injector->make(ResponseResolver::class));
         $chain->add($injector->make(CallableResolver::class));
         $chain->add($injector->make(ControllerActionResolver::class));
     });
     $injector->share(InjectorExecutableResolver::class);
     $injector->define(InjectorExecutableResolver::class, ['resolver' => ResolverChain::class]);
     $injector->alias(HandlerResolver::class, InjectorExecutableResolver::class);
 }
開發者ID:cspray,項目名稱:labrador-http,代碼行數:19,代碼來源:Services.php

示例12: applyProviderConfig

 private function applyProviderConfig(Injector $injector, array $env)
 {
     $config = [];
     foreach ($env as $key => $value) {
         list($provider, $key) = explode('_', strtolower($key), 2);
         $key = $this->toCamelCase($key);
         $config[$provider][$key] = $value;
     }
     $injector->define(__NAMESPACE__ . '\\ProviderConfig', [':config' => $config]);
 }
開發者ID:elevenone,項目名稱:oauth2-demos,代碼行數:10,代碼來源:Configuration.php

示例13: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->alias('Equip\\Auth\\Token\\ExtractorInterface', 'Equip\\Auth\\Token\\QueryExtractor');
     $injector->define('Equip\\Auth\\Token\\QueryExtractor', [':parameter' => 'tk']);
     $injector->alias('Equip\\Auth\\Credentials\\ExtractorInterface', 'Equip\\Auth\\Credentials\\BodyExtractor');
     $injector->alias('Equip\\Auth\\AdapterInterface', 'Equip\\Project\\Auth\\Adapter');
     $dir = dirname(dirname(__DIR__));
     $dotenv = new Dotenv($dir);
     $dotenv->load();
     $dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS']);
 }
開發者ID:JasonBusse,項目名稱:rest_scheduler,代碼行數:14,代碼來源:ProjectConfiguration.php

示例14: apply

 /**
  * Applies a configuration set to a dependency injector.
  *
  * @param Injector $injector
  */
 public function apply(Injector $injector)
 {
     //Specify token parameter from query string
     $injector->define(QueryExtractor::class, [':parameter' => 'al']);
     //Use Query Extractor to grab auth token
     $injector->alias(\Spark\Auth\Token\ExtractorInterface::class, QueryExtractor::class);
     //Use Json Extractor to grab credentials
     $injector->alias(\Spark\Auth\Credentials\ExtractorInterface::class, JsonExtractor::class);
     //Specify custom auth adapter to use
     $injector->alias(AdapterInterface::class, Adapter::class);
 }
開發者ID:elevenone,項目名稱:rest-scheduler-api,代碼行數:16,代碼來源:AuthConfiguration.php

示例15: Injector

 function testValidControllerActionResultsInRightCallback()
 {
     $handler = HandlerWithMethod::class . '#action';
     $val = new \stdClass();
     $val->action = null;
     $injector = new Injector();
     $injector->define(HandlerWithMethod::class, [':val' => $val]);
     $resolver = new ControllerActionResolver($injector, $this->emitter);
     $cb = $resolver->resolve($this->request, $handler);
     $cb($this->getMock(ServerRequestInterface::class));
     $this->assertSame('invoked', $val->action);
 }
開發者ID:cspray,項目名稱:labrador-http,代碼行數:12,代碼來源:ControllerActionResolverTest.php


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