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


PHP Injector::alias方法代碼示例

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


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

示例3: apply

 /**
  * @inheritDoc
  */
 public function apply(Injector $injector)
 {
     $injector->alias(RequestInterface::class, ServerRequest::class);
     $injector->alias(ResponseInterface::class, Response::class);
     $injector->alias(ServerRequestInterface::class, ServerRequest::class);
     $injector->delegate(ServerRequest::class, [ServerRequestFactory::class, 'fromGlobals']);
 }
開發者ID:equip,項目名稱:framework,代碼行數:10,代碼來源:DiactorosConfiguration.php

示例4: apply

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

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

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

示例7: __construct

 public function __construct(JigConfig $jigConfig, Injector $injector, JigConverter $jigConverter = null, Escaper $escaper = null)
 {
     parent::__construct($jigConfig, $jigConverter);
     $this->injector = $injector;
     $this->injector->alias('Jig\\Jig', get_class($this));
     $this->injector->share($this);
     if ($escaper === null) {
         $escaper = new ZendEscaperBridge(new ZendEscaper());
     }
     $this->injector->alias('Jig\\Escaper', get_class($escaper));
     $this->injector->share($escaper);
     $this->escaper = $escaper;
 }
開發者ID:danack,項目名稱:jig,代碼行數:13,代碼來源:JigDispatcher.php

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

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

示例10: createProvider

/**
 * @param array $implementations
 * @param array $shareClasses
 * @return Provider
 */
function createProvider($implementations = array(), $shareClasses = array())
{
    $provider = new Injector();
    $provider->define('GithubService\\GithubArtaxService\\GithubArtaxService', [':userAgent' => 'Danack_test']);
    $provider->prepare('Amp\\Artax\\Client', 'prepareArtaxClient');
    $standardImplementations = ['GithubService\\GithubService' => 'DebugGithub', 'Amp\\Artax\\AsyncClient' => 'Amp\\Artax\\AsyncClient', 'Amp\\Reactor' => 'Amp\\NativeReactor', 'ArtaxServiceBuilder\\ResponseCache' => 'ArtaxServiceBuilder\\ResponseCache\\NullResponseCache', 'PSR\\Cache' => 'PSR\\Cache\\APCCache', 'Amp\\Addr\\Cache' => 'Amp\\Addr\\MemoryCache'];
    $standardShares = ['Amp\\Reactor' => 'Amp\\Reactor'];
    $provider->delegate('Amp\\Artax\\Client', 'createClient');
    foreach ($standardImplementations as $interface => $implementation) {
        if (array_key_exists($interface, $implementations)) {
            if (is_object($implementations[$interface]) == true) {
                $provider->alias($interface, get_class($implementations[$interface]));
                $provider->share($implementations[$interface]);
            } else {
                $provider->alias($interface, $implementations[$interface]);
            }
            unset($implementations[$interface]);
        } else {
            if (is_object($implementation)) {
                $implementation = get_class($implementation);
            }
            $provider->alias($interface, $implementation);
        }
    }
    foreach ($implementations as $class => $implementation) {
        if (is_object($implementation) == true) {
            $provider->alias($class, get_class($implementation));
            $provider->share($implementation);
        } else {
            $provider->alias($class, $implementation);
        }
    }
    foreach ($standardShares as $class => $share) {
        if (array_key_exists($class, $shareClasses)) {
            $provider->share($shareClasses[$class]);
            unset($shareClasses[$class]);
        } else {
            $provider->share($share);
        }
    }
    foreach ($shareClasses as $class => $share) {
        $provider->share($share);
    }
    $provider->share($provider);
    //YOLO
    return $provider;
}
開發者ID:danack,項目名稱:githubartaxservice,代碼行數:52,代碼來源:testBootstrap.php

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

示例12: apply

 public function apply(Injector $injector)
 {
     $injector->alias(Collection::class, DefaultCollection::class);
     $injector->prepare(Collection::class, function (Collection $collection) {
         $middleware = $collection->getArrayCopy();
         // Do session checking before routing
         array_splice($middleware, array_search(RouteHandler::class, $middleware), 0, CheckSessionMiddleware::class);
         $collection->exchangeArray($middleware);
     });
 }
開發者ID:shadowhand,項目名稱:radiotide,代碼行數:10,代碼來源:MiddlewareConfiguration.php

示例13: testRouting405

 public function testRouting405()
 {
     $request = new CLIRequest("/introduction", 'example.com', 'POST');
     $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request));
     $this->injector->share($request);
     $router = $this->injector->make('Tier\\Bridge\\FastRouter');
     $fn404ErrorPage = function () {
         return new TextBody("Route not found.", 404);
     };
     $fn405ErrorPage = function () {
         return new TextBody("Method not allowed for route.", 405);
     };
     $result = $router->routeRequest($request, $fn404ErrorPage, $fn405ErrorPage);
     $body = TierApp::executeExecutable($result, $this->injector);
     $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body);
     /** @var $body \Room11\HTTP\Body\HtmlBody */
     $html = $body->getData();
     $this->assertContains("Method not allowed for route.", $html);
     $this->assertEquals(405, $body->getStatusCode());
 }
開發者ID:danack,項目名稱:tier,代碼行數:20,代碼來源:FastRouterTest.php

示例14: apply

 /**
  * Applies a configuration set to a dependency injector.
  *
  * @param Injector $injector
  */
 public function apply(Injector $injector)
 {
     foreach (self::$commandHandlerMapping as $command => $handler) {
         $injector->alias($command, $handler);
     }
     $injector->delegate(CommandBus::class, function () use($injector) {
         $handlerMiddleware = new CommandHandlerMiddleware(new ClassNameExtractor(), new CallableLocator([$injector, 'make']), new HandleInflector());
         $lockingMiddleware = new LockingMiddleware();
         $transactionMiddleware = new TransactionMiddleware($injector->make(EntityManager::class));
         return new CommandBus([$transactionMiddleware, $lockingMiddleware, $handlerMiddleware]);
     });
 }
開發者ID:elevenone,項目名稱:rest-scheduler-api,代碼行數:17,代碼來源:TacticianConfiguration.php

示例15: testRouting405

 public function testRouting405()
 {
     $request = new CLIRequest("/introduction", 'example.com', 'POST');
     $this->injector->alias('Psr\\Http\\Message\\ServerRequestInterface', get_class($request));
     $this->injector->share($request);
     $renderCallable = $this->injector->execute('Tier\\Bridge\\JigFastRouter::routeRequest');
     $body = TierApp::executeExecutable($renderCallable, $this->injector);
     $this->assertInstanceOf('Room11\\HTTP\\Body\\TextBody', $body);
     /** @var $body \Room11\HTTP\Body\HtmlBody */
     $html = $body->getData();
     $this->assertContains("Method not allowed for route.", $html);
     $this->assertEquals(405, $body->getStatusCode());
 }
開發者ID:danack,項目名稱:tier,代碼行數:13,代碼來源:JigFastRouterTest.php


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