• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP DI\Container类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


示例2: __construct

 public function __construct($containerFactory = NULL, Container $container = NULL)
 {
     parent::__construct($containerFactory);
     /** @var IStorage $storage */
     $storage = $container->getService('cacheStorage');
     $this->cache = new Cache($storage);
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:7,代码来源:RepositoryContainer.php


示例3: __construct

 public function __construct(Container $container)
 {
     $p = $container->getParameters();
     foreach (['app' => 'appDir', 'backup' => 'backupDir', 'bin' => 'binDir', 'libs' => 'libsDir', 'log' => 'logDir', 'migrations' => 'migrationsDir', 'temp' => 'tempDir', 'tests' => 'testsDir', 'www' => 'wwwDir'] as $prop => $key) {
         $this->{$prop} = $p[$key];
     }
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:7,代码来源:Paths.php


示例4: __construct

 public function __construct(Container $context)
 {
     parent::__construct();
     $secured = NULL;
     if ($context->getParameters()['tls']) {
         Route::$defaultFlags |= Route::SECURED;
         $secured = Route::SECURED;
     }
     $this[] = new StaticRouter(['Homepage:default' => 'index.php'], StaticRouter::ONE_WAY | $secured);
     $this[] = new StaticRouter(['Homepage:default' => '', 'Homepage:marathon' => 'maraton', 'Homepage:preklad' => 'preklad', 'Profile:default' => 'profil', 'Auth:in' => 'prihlaseni', 'Auth:out' => 'odhlaseni', 'Auth:registration' => 'registrace', 'Auth:resetPassword' => 'heslo', 'Text:about' => 'o-skole', 'Text:team' => 'o-skole/tym', 'Subjects:default' => 'predmety', 'File:opensearch' => 'opensearch.xml', 'File:robots' => 'robots.txt', 'Sitemap:default' => 'sitemap.xml', 'Text:tos' => 'podminky', 'Text:privacy' => 'soukromi'], $secured);
     $this[] = new Route('vyhledavani/?hledat=<query>', 'Search:results');
     $this[] = new Route('vyhledavani/cviceni', 'Search:blueprints');
     $this[] = new Route('schema/[<action \\D+>/]<schemaId \\d+>[-<slug>]', 'Schema:default');
     $this[] = new Route('blok/[<action \\D+>/][<schemaId \\d+>/]<blockId \\d+>[-<slug>]', 'Block:default');
     $this[] = new Route('video/[<action \\D+>/][[<schemaId \\d+>/]<blockId \\d+>/]<videoId \\d+>[-<slug>]?zacatek=<startAtTime \\d+>', 'Video:default');
     $this[] = new Route('cviceni/[<action \\D+>/][[<schemaId \\d+>/]<blockId \\d+>/]<blueprintId \\d+>[-<slug>]', 'Blueprint:default');
     $this[] = new Route('tabule/[<action \\D+>/][[<schemaId \\d+>/]<blockId \\d+>/]<blackboardId \\d+>[-<slug>]?zacatek=<startAtTime \\d+>', 'Blackboard:default');
     // old links
     $this[] = new Route('video/<youtubeId>', 'Video:youtube');
     $this[] = new Redirect('dobrovolnici', 'https://wiki.khanovaskola.cz/doku.php?id=dobrovolnici');
     $this[] = new Redirect('dobrovolnici/preklad', 'https://wiki.khanovaskola.cz/doku.php?id=jaknato');
     $this[] = new Redirect('dobrovolnici/pravidla-prekladu', 'https://wiki.khanovaskola.cz/doku.php?id=pravidla');
     $this[] = new Redirect('o-skole/projekty', 'https://wiki.khanovaskola.cz/doku.php?id=start');
     $this[] = new Redirect('kontakt', 'https://wiki.khanovaskola.cz/doku.php?id=tym');
     $this[] = $context->createInstance(Routers\OldVideo::class);
     $this[] = $context->createInstance(Routers\OldCategory::class);
     $this[] = $context->createInstance(Routers\OldBlog::class);
     $this[] = new Route('<presenter>/<action \\D+>[/<id>]', 'Homepage:default');
 }
开发者ID:VasekPurchart,项目名称:khanovaskola-v3,代码行数:29,代码来源:Router.php


示例5: create

 public static function create(DI\Container $container)
 {
     $robotLoader = $container->getService('robotLoader');
     //$cacheStorage = $container->getService('cacheStorage');
     $shortcutsManager = new \ShortcutsManager($robotLoader);
     return $shortcutsManager;
 }
开发者ID:bazo,项目名称:Tatami,代码行数:7,代码来源:ShortcutsManagerFactory.php


示例6: signIn

 public function signIn(Nette\DI\Container $container)
 {
     $container->removeService('nette.userStorage');
     $userStorage = m::mock('Nette\\Security\\IUserStorage');
     $userStorage->shouldReceive('isAuthenticated')->once()->andReturn(true);
     $userStorage->shouldReceive('getIdentity')->once()->andReturn(new Nette\Security\Identity(1));
     $container->addService('nette.userStorage', $userStorage);
 }
开发者ID:CSHH,项目名称:website,代码行数:8,代码来源:Login.php


示例7: registerAddPaymentButtonsUsingDependencyContainer

 /**
  * Registers 'addPaymentButtons' & 'addPaymentButton' methods to form using DI container
  *
  * @param Container $container
  */
 public static function registerAddPaymentButtonsUsingDependencyContainer(Container $container)
 {
     $binder = $container->getByType(Binder::class);
     $services = $container->findByType(AbstractPaymentService::class);
     foreach ($services as $service) {
         self::registerAddPaymentButtons($binder, $container->getService($service));
     }
 }
开发者ID:markette,项目名称:gopay,代码行数:13,代码来源:Helpers.php


示例8: findServicesOfType

 /**
  * @param string $type
  * @param Container $container
  * @return object[]
  */
 public static function findServicesOfType($type, Container $container)
 {
     $services = array();
     foreach ($container->findByType($type) as $name) {
         $services[] = $container->getService($name);
     }
     return $services;
 }
开发者ID:darkknightik,项目名称:nette-injects-extension,代码行数:13,代码来源:Helpers.php


示例9: createFromContainer

 public static function createFromContainer(Container $context)
 {
     /** @var EntityManager $em */
     $em = $context->getByType(EntityManager::class);
     /** @var Configuration $conf */
     $conf = $context->getByType(Configuration::class);
     return new self($em, $conf, $context->getParameters()['tempDir']);
 }
开发者ID:instante,项目名称:php-test-suite,代码行数:8,代码来源:DoctrineTester.php


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


示例11: getUser

 /**
  * @return \Nette\Security\User
  */
 private function getUser()
 {
     if (!$this->user) {
         $this->user = $this->container->getByType(User::class);
     }
     return $this->user;
 }
开发者ID:venne,项目名称:files,代码行数:10,代码来源:FileListener.php


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


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


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


示例15: doRequest

 /**
  * @param Request $request
  * @return Response
  */
 public function doRequest($request)
 {
     $_COOKIE = $request->getCookies();
     $_SERVER = $request->getServer();
     $_FILES = $request->getFiles();
     $_SERVER['REQUEST_METHOD'] = $method = strtoupper($request->getMethod());
     $_SERVER['REQUEST_URI'] = $uri = str_replace('http://localhost', '', $request->getUri());
     $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
     if ($method === 'HEAD' || $method === 'GET') {
         $_GET = $request->getParameters();
         $_POST = [];
     } else {
         $_POST = $request->getParameters();
         $_GET = [];
     }
     $httpRequest = $this->container->getByType(IRequest::class);
     $httpResponse = $this->container->getByType(IResponse::class);
     if (!$httpRequest instanceof HttpRequest || !$httpResponse instanceof HttpResponse) {
         throw new Exception('Arachne\\Codeception\\DI\\CodeceptionExtension is not used or conflicts with another extension.');
     }
     $httpRequest->reset();
     $httpResponse->reset();
     try {
         ob_start();
         $this->container->getByType(Application::class)->run();
         $content = ob_get_clean();
     } catch (Exception $e) {
         ob_end_clean();
         throw $e;
     }
     $code = $httpResponse->getCode();
     $headers = $httpResponse->getHeaders();
     return new Response($content, $code, $headers);
 }
开发者ID:Northys,项目名称:Codeception,代码行数:38,代码来源:Nette.php


示例16: createNew

 public function createNew($arguments = array())
 {
     /** @var BaseFileEntity $entity */
     $entity = parent::createNew($arguments);
     $entity->setUser($this->container->getByType('Nette\\Security\\User'));
     return $entity;
 }
开发者ID:svobodni,项目名称:web,代码行数:7,代码来源:AbstractFileRepository.php


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


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


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP DI\ContainerBuilder类代码示例发布时间:2022-05-23
下一篇:
PHP DI\Compiler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap