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


PHP Injector::delegate方法代码示例

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


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

 public function setup()
 {
     parent::setup();
     // Create a JigConfig object
     $jigConfig = new JigConfig(__DIR__ . "/../../fixtures/templates/", __DIR__ . "/../../var/generatedTemplates/", Jig::COMPILE_CHECK_MTIME);
     $this->injector = new Injector();
     $this->injector->alias('Jig\\Escaper', 'Jig\\Bridge\\ZendEscaperBridge');
     $this->injector->delegate('FastRoute\\Dispatcher', 'TierTest\\JigBridge\\createDispatcher');
     $this->injector->share('FastRoute\\Dispatcher');
     $this->injector->share($jigConfig);
 }
开发者ID:atawsports2,项目名称:Tier,代码行数:11,代码来源:JigRouterTest.php

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

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

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

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

示例7: apply

 /**
  * Applies a configuration set to a dependency injector.
  *
  * @param Injector $injector
  */
 public function apply(Injector $injector)
 {
     foreach (self::$entityRepositoryMap as $entityName => $repoClassName) {
         $injector->delegate($repoClassName, function () use($entityName, $injector) {
             /** @var EntityManager $entityManager */
             $entityManager = $injector->make(EntityManager::class);
             return $entityManager->getRepository($entityName);
         });
     }
 }
开发者ID:sctape,项目名称:rest-scheduler-api,代码行数:15,代码来源:DoctrineRepositoryConfiguration.php

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

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

示例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)
 {
     $injector->delegate(Stdio::class, [$this, 'getStdio']);
     $injector->delegate(Context::class, [$this, 'getContext']);
 }
开发者ID:equip,项目名称:beanstalkd-consumer,代码行数:5,代码来源:AuraCliConfiguration.php

示例12: apply

 public function apply(Injector $injector)
 {
     $injector->delegate(Client::class, [$this, 'makeClient']);
 }
开发者ID:graphis,项目名称:cookcountycommunityfund,代码行数:4,代码来源:GuzzleConfiguration.php

示例13: apply

 public function apply(Injector $injector)
 {
     $injector->delegate(Pheanstalk::class, [$this, 'getPheanstalk']);
 }
开发者ID:equip,项目名称:beanstalkd-consumer,代码行数:4,代码来源:PheanstalkConfiguration.php

示例14: function

$injector->alias(AdminStorage::class, $config['storage']['admin'] ?? FileAdminStorage::class);
$injector->alias(BanStorage::class, $config['storage']['ban'] ?? FileBanStorage::class);
$injector->alias(KeyValueStorage::class, $config['storage']['keyvalue'] ?? FileKeyValueStorage::class);
$injector->alias(KeyValueStorageFactory::class, ($config['storage']['keyvalue'] ?? FileKeyValueStorage::class) . 'Factory');
$injector->alias(PluginStorage::class, $config['storage']['plugin'] ?? FilePluginStorage::class);
$injector->alias(RoomStorage::class, $config['storage']['room'] ?? FileRoomStorage::class);
$injector->define(BitlyClient::class, [':accessToken' => $config['bitly']['accessToken']]);
$injector->define(TwitterApplicationCredentials::class, [':key' => $config['twitter']['consumerKey'], ':secret' => $config['twitter']['consumerSecret']]);
$injector->define(TranslationAPICredentials::class, [':clientId' => $config['ms-translate']['client-id'] ?? '', ':clientSecret' => $config['ms-translate']['client-secret'] ?? '']);
$injector->define(WebSocketEventDispatcher::class, [':devMode' => $config['dev-mode']['enable'] ?? false]);
$injector->delegate(Logger::class, function () use($config) {
    $flags = array_map('trim', explode('|', $config['logging']['level'] ?? ''));
    if (empty($flags[0])) {
        $flags = LogLevel::ALL;
    } else {
        $flags = array_reduce($flags, function ($carry, $flag) {
            return $carry | constant(LogLevel::class . "::{$flag}");
        }, 0);
    }
    $logger = $config['logging']['handler'] ?? StdOutLogger::class;
    return new $logger($flags, ...array_values($config['logging']['params'] ?? []));
});
$injector->delegate(CredentialManager::class, function () use($config) {
    $manager = new CredentialManager();
    $haveDefault = false;
    foreach ($config['openids'] ?? [] as $domain => $details) {
        if (!isset($details['username'], $details['password'])) {
            throw new InvalidConfigurationException("OpenID domain '{$domain}' does not define username and password");
        }
        $details = new Credentials(new OpenIdEmailAddress($details['username']), new OpenIdPassword($details['password']));
        if ($domain === 'default') {
            $haveDefault = true;
开发者ID:Room-11,项目名称:Jeeves,代码行数:32,代码来源:run.php

示例15: addInjectionParams

function addInjectionParams(Injector $injector, Tier $tier)
{
    $injectionParams = $tier->getInjectionParams();
    if (!$injectionParams) {
        return;
    }
    foreach ($injectionParams->getAliases() as $original => $alias) {
        $injector->alias($original, $alias);
    }
    foreach ($injectionParams->getShares() as $share) {
        $injector->share($share);
    }
    foreach ($injectionParams->getParams() as $paramName => $value) {
        $injector->defineParam($paramName, $value);
    }
    foreach ($injectionParams->getDelegates() as $className => $callable) {
        $injector->delegate($className, $callable);
    }
}
开发者ID:PeeHaa,项目名称:Jig,代码行数:19,代码来源:bootstrap.php


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