本文整理汇总了PHP中Auryn\Injector类的典型用法代码示例。如果您正苦于以下问题:PHP Injector类的具体用法?PHP Injector怎么用?PHP Injector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Injector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: __invoke
public function __invoke(Injector $injector)
{
$injector->share($injector);
foreach ($this->classes as $class) {
$injector->execute($class);
}
}
开发者ID:elazar,项目名称:auryn-configuration,代码行数:7,代码来源:ConfigurationSet.php
示例3: apply
/**
* @inheritDoc
*/
public function apply(Injector $injector)
{
foreach ($this as $class) {
$configuration = $injector->make($class);
$configuration->apply($injector);
}
}
开发者ID:mikegreiling,项目名称:spark,代码行数:10,代码来源:ConfigurationSet.php
示例4: 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
示例5: testStageRunning
public function testStageRunning()
{
$functionsCalled = [];
$tiersByStage = new ExecutableListByTier();
$fn2 = function () use(&$functionsCalled) {
$functionsCalled[2] = true;
};
$fn0 = function () use(&$functionsCalled, $tiersByStage, $fn2) {
$functionsCalled[0] = true;
$tiersByStage->addExecutableToTier(4, $fn2);
};
$fn1 = function () use(&$functionsCalled) {
$functionsCalled[1] = true;
};
$tiersByStage->addExecutableToTier(2, $fn0);
$tiersByStage->addExecutableToTier(2, $fn1);
$injector = new Injector();
foreach ($tiersByStage as $appStage => $executablesForTier) {
foreach ($executablesForTier as $executable) {
$injector->execute($executable->getCallable());
}
}
$this->assertArrayHasKey(0, $functionsCalled);
$this->assertArrayHasKey(1, $functionsCalled);
$this->assertArrayHasKey(2, $functionsCalled);
}
开发者ID:atawsports2,项目名称:Tier,代码行数:26,代码来源:TierStageTest.php
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: makeClient
public function makeClient(Injector $injector)
{
if (empty($this->env['chamber_api_secret'])) {
throw new \DomainException('Bad API configuration');
}
$handler = $injector->execute([$this, 'makeStack']);
return new Client(compact('handler'));
}
开发者ID:graphis,项目名称:cookcountycommunityfund,代码行数:8,代码来源:GuzzleConfiguration.php
示例14: 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
示例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
示例16: 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
示例17: 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
示例18: 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
示例19: 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
示例20: 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
注:本文中的Auryn\Injector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论