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


PHP Container::getService方法代码示例

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


在下文中一共展示了Container::getService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getWallet

 /**
  * @param string $name
  * @return Wallet
  */
 public function getWallet($name)
 {
     if (!isset($this->serviceMap[$name])) {
         throw new \Nette\InvalidArgumentException("Unknown wallet {$name}.");
     }
     return $this->serviceLocator->getService($this->serviceMap[$name]);
 }
开发者ID:brosland,项目名称:blockchain,代码行数:11,代码来源:Blockchain.php

示例2: getModel

 /**
  * getter for specified model
  *
  * @param string $name name of model
  * @return BaseModel
  * @throws \InvalidArgumentException
  */
 public function getModel($name)
 {
     if ($this->container->hasService($name)) {
         return $this->container->getService($name);
     }
     throw new \InvalidArgumentException("Model '{$name}' not found.");
 }
开发者ID:b4nan,项目名称:doctrine,代码行数:14,代码来源:BaseModelLoader.php

示例3: getWallet

 /**
  * @param string $name
  * @return \Blocktrail\SDK\Wallet
  * @throws \Nette\InvalidArgumentException
  */
 public function getWallet($name = self::DEFAULT_NAME)
 {
     if (!isset($this->walletsServiceMap[$name])) {
         throw new \Nette\InvalidArgumentException("Unknown wallet '{$name}'.");
     }
     return $this->serviceLocator->getService($this->walletsServiceMap[$name]);
 }
开发者ID:brosland,项目名称:blocktrail,代码行数:12,代码来源:Blocktrail.php

示例4: runMigrations

 /**
  * Vytvoří DB a naplní testovacími daty.
  */
 public function runMigrations()
 {
     if (!$this->context->parameters['migrations']['enabled']) {
         return;
     }
     $connection = $this->context->getService('dibiConnection');
     $dbNamePrefix = $this->context->parameters['testDbPrefix'] . date('Ymd_His') . '_' . rand(1, 1000) . '_';
     $i = 1;
     do {
         $dbName = $dbNamePrefix . $i;
         $i++;
     } while ($connection->query('SHOW DATABASES WHERE %n', 'Database', ' = %s', $dbName)->count());
     $connection->query('CREATE DATABASE %n COLLATE=utf8_czech_ci', $dbName);
     $connection->query('USE %n', $dbName);
     $migrationsPath = $this->context->parameters['wwwDir'] . '/' . $this->context->parameters['migrations']['path'];
     $finder = new Migration\Finders\MultipleDirectories();
     $finder->addDirectory($migrationsPath . '/struct');
     $finder->addDirectory($migrationsPath . '/data');
     $migrations = $this->createRunner($connection);
     ob_start();
     $migrations->run($finder, FALSE, TRUE);
     $result = ob_get_clean();
     if (substr(strip_tags($result), -2) !== 'OK') {
         throw new \Exception('Migrace neproběhly v pořádku: ' . $result);
     }
     $this->context->parameters['testDbName'] = $dbName;
 }
开发者ID:clevis,项目名称:migration,代码行数:30,代码来源:MigrationsLoader.php

示例5: getLoginProviderByName

 /**
  * @param string $name
  * @return \Venne\Security\ILoginProvider
  */
 public function getLoginProviderByName($name)
 {
     if (!isset($this->loginProviders[$name])) {
         throw new InvalidArgumentException(sprintf('Social login name \'%s\' has not been registered.', $name));
     }
     return $this->context->getService($this->loginProviders[$name]);
 }
开发者ID:venne,项目名称:venne,代码行数:11,代码来源:SecurityManager.php

示例6: getLoginProviderByName

 /**
  * @param $name
  * @return ILoginProvider
  * @throws InvalidArgumentException
  */
 public function getLoginProviderByName($name)
 {
     if (!isset($this->loginProviders[$name])) {
         throw new InvalidArgumentException("Social login name '{$name}' has not been registered.");
     }
     return $this->content->getService($this->loginProviders[$name]);
 }
开发者ID:svobodni,项目名称:web,代码行数:12,代码来源:SecurityManager.php

示例7: __construct

 public function __construct(Context $context, Container $container, EntityManager $entityManager)
 {
     $this->context = $context;
     $this->container = $container;
     $this->em = $entityManager;
     $this->cache = $this->container->getService('cacheStorage');
 }
开发者ID:rutrader,项目名称:nette-blog,代码行数:7,代码来源:BasePresenter.php

示例8: create

 /**
  * @return CDNLoader
  */
 public function create()
 {
     $compiler = $this->container->getService('cdnloader.compiler');
     $httpRequest = $this->container->getService('httpRequest');
     $loader = new CDNLoader($compiler, $httpRequest);
     return $loader;
 }
开发者ID:Lawondyss,项目名称:CDNLoader,代码行数:10,代码来源:CDNLoaderFactory.php

示例9: getRpcServer

 /**
  * @param string $name
  * @return RpcServer
  */
 public function getRpcServer($name)
 {
     if (!isset($this->rpcServers[$name])) {
         throw new InvalidArgumentException("Unknown RPC server {$name}");
     }
     return $this->serviceLocator->getService($this->rpcServers[$name]);
 }
开发者ID:petrnemec,项目名称:RabbitMq,代码行数:11,代码来源:Registry.php

示例10: run

 /**
  * @return Nette\Application\IResponse
  */
 public function run(Application\Request $request)
 {
     $this->request = $request;
     $httpRequest = $this->context->getByType('Nette\\Http\\IRequest');
     if (!$httpRequest->isAjax() && ($request->isMethod('get') || $request->isMethod('head'))) {
         $refUrl = clone $httpRequest->getUrl();
         $url = $this->context->getService('router')->constructUrl($request, $refUrl->setPath($refUrl->getScriptPath()));
         if ($url !== NULL && !$httpRequest->getUrl()->isEqual($url)) {
             return new Responses\RedirectResponse($url, Http\IResponse::S301_MOVED_PERMANENTLY);
         }
     }
     $params = $request->getParameters();
     if (!isset($params['callback'])) {
         throw new Application\BadRequestException("Parameter callback is missing.");
     }
     $params['presenter'] = $this;
     $callback = new Nette\Callback($params['callback']);
     $response = $callback->invokeArgs(Application\UI\PresenterComponentReflection::combineArgs($callback->toReflection(), $params));
     if (is_string($response)) {
         $response = array($response, array());
     }
     if (is_array($response)) {
         if ($response[0] instanceof \SplFileInfo) {
             $response = $this->createTemplate('Nette\\Templating\\FileTemplate')->setParameters($response[1])->setFile($response[0]);
         } else {
             $response = $this->createTemplate('Nette\\Templating\\Template')->setParameters($response[1])->setSource($response[0]);
         }
     }
     if ($response instanceof Nette\Templating\ITemplate) {
         return new Responses\TextResponse($response);
     } else {
         return $response;
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:37,代码来源:MicroPresenter.php

示例11: __construct

 public function __construct(\Nette\DI\Container $container)
 {
     $this->container = $container;
     $this->connection = $container->getService('leanMapper.connection');
     $this->entityFactory = $container->getService('entityFactory');
     $this->mapper = $container->getService('standardMapper');
     $this->transaction = $container->getService('transaction');
 }
开发者ID:blitzik,项目名称:vycetky,代码行数:8,代码来源:BaseFacadeTest.php

示例12: create

 /**
  * @return MapperMatrix
  */
 public function create()
 {
     $matrix = new MapperMatrix();
     foreach ($this->container->findByTag('echo511.leanmapper.mapper') as $serviceName => $tagAttributes) {
         $matrix->addMapper($this->container->getService($serviceName));
     }
     return $matrix;
 }
开发者ID:echo511,项目名称:leanmapper,代码行数:11,代码来源:MapperMatrixFactory.php

示例13: initializeListener

 /**
  * @param string $eventName
  */
 private function initializeListener($eventName)
 {
     foreach ($this->listenerIds[$eventName] as $serviceName) {
         $subscriber = $this->container->getService($serviceName);
         /** @var Doctrine\Common\EventSubscriber $subscriber */
         $this->addEventSubscriber($subscriber);
     }
     unset($this->listenerIds[$eventName]);
 }
开发者ID:BianoCZ,项目名称:Events,代码行数:12,代码来源:LazyEventManager.php

示例14: create

 public function create() : Registry
 {
     $tagToService = function (array $tags) {
         return array_map(function (string $serviceName) {
             return $this->container->getService($serviceName);
         }, array_keys($tags));
     };
     return new Registry($tagToService($this->container->findByTag(self::RULE_TAG)));
 }
开发者ID:phpstan,项目名称:phpstan,代码行数:9,代码来源:RegistryFactory.php

示例15: getInstance

 /**
  * {@inheritDoc}
  */
 public function getInstance(Constraint $constraint)
 {
     $name = $constraint->validatedBy();
     if (!isset($this->validators[$name])) {
         $this->validators[$name] = new $name();
     } elseif (is_string($this->validators[$name])) {
         $this->validators[$name] = $this->serviceLocator->getService($this->validators[$name]);
     }
     return $this->validators[$name];
 }
开发者ID:kdyby,项目名称:validator,代码行数:13,代码来源:ConstraintValidatorFactory.php


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