本文整理汇总了PHP中Nette\DI\Container::removeService方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::removeService方法的具体用法?PHP Container::removeService怎么用?PHP Container::removeService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\DI\Container
的用法示例。
在下文中一共展示了Container::removeService方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: resetManager
/**
* {@inheritdoc}
*/
public function resetManager($name = null)
{
if (null === $name) {
$name = $this->defaultManager;
}
if (!isset($this->managers[$name])) {
throw new \InvalidArgumentException(sprintf('Doctrine Manager named "%s" does not exist.', $name));
}
// force the creation of a new document manager
// if the current one is closed
$this->container->removeService($this->managers[$name]);
}
示例3: doRequest
/**
* Makes a request.
*
* @param IRequest $request
* @return BrowserKit\Response
* @throws MissingContainerException
*/
protected function doRequest($request)
{
if ($this->container === NULL) {
throw new MissingContainerException('Container is missing, use setContainer() method to set it.');
}
$response = new Response();
$this->container->removeService('httpRequest');
$this->container->addService('httpRequest', $request);
$this->container->removeService('httpResponse');
$this->container->addService('httpResponse', $response);
/** @var IPresenterFactory $presenterFactory */
$presenterFactory = $this->container->getByType(IPresenterFactory::class);
/** @var IRouter $router */
$router = $this->container->getByType(IRouter::class);
$application = new Application($presenterFactory, $router, $request, $response);
$this->container->removeService('application');
$this->container->addService('application', $application);
ob_start();
$application->run();
$content = ob_get_clean();
return new BrowserKit\Response($content, $response->getCode(), $response->getHeaders());
}
示例4: boot
public function boot(Nette\DI\Container $container, $databaseName)
{
$this->windows = array();
$this->waitForSeleniumSlot();
$this->serviceLocator = $container;
TesterHelpers::setup();
// ensure error & exception helpers are registered
$this->httpServer = new HttpServer();
$env = (array) $this->options[self::OPTION_ENV_VARIABLES] + array($this->options[self::OPTION_ENV_PREFIX] . '_DEBUG' => '0', $this->options[self::OPTION_ENV_PREFIX] . '_SELENIUM' => '1', $this->options[self::OPTION_ENV_PREFIX] . '_DATABASE' => $databaseName, $this->options[self::OPTION_ENV_PREFIX] . '_LOG_DIR' => TEMP_DIR, $this->options[self::OPTION_ENV_PREFIX] . '_TEMP_DIR' => TEMP_DIR);
$this->httpServer->start($this->serviceLocator->expand($this->options[self::OPTION_ROUTER]), $env);
$httpRequest = new Nette\Http\Request($this->httpServer->getUrl(), array(), array(), array(), array(), array(), 'GET');
$this->serviceLocator->removeService('httpRequest');
$this->serviceLocator->addService('httpRequest', $httpRequest);
$this->sessionFactory = new SessionFactory($this->serviceLocator, $this->httpServer, $this->options);
$this->currentSession = $this->sessionFactory->create();
$this->currentSession->setContext($this);
$this->windows[] = $this->currentSession;
if ($this->options[self::OPTION_VIDEO_ENABLE]) {
$this->videoRecorder = new VideoRecorder(TEMP_DIR);
$this->videoRecorder->start();
}
}
示例5: request
/**
* @param string $method
* @param string $path
* @param array $headers
* @param string|null $body
* @return Http\Response
*/
public function request($method, $path, array $headers = [], $body = NULL)
{
$this->appResponse = NULL;
$url = new Http\UrlScript($this->baseUri . $path);
$this->httpRequest = (new HttpRequestMock($url, NULL, [], [], [], $headers, $method, '127.0.0.1', '127.0.0.1'))->setRawBody($body);
$this->httpResponse = new HttpResponseMock();
// mock request & response
$this->sl->removeService('httpRequest');
$this->sl->addService('httpRequest', $this->httpRequest);
$this->sl->removeService('httpResponse');
$this->sl->addService('httpResponse', $this->httpResponse);
/** @var Kdyby\FakeSession\Session $session */
$session = $this->sl->getService('session');
$session->__construct(new Http\Session($this->httpRequest, $this->httpResponse));
/** @var Nette\Application\IPresenterFactory $presenterFactory */
$presenterFactory = $this->sl->getByType('Nette\\Application\\IPresenterFactory');
/** @var Application $application */
$application = $this->sl->getByType('Nette\\Application\\Application');
$application->__construct($presenterFactory, $this->getRouter(), $this->httpRequest, $this->httpResponse);
$application->onResponse[] = function (Application $application, Nette\Application\IResponse $response) {
$this->appResponse = $response;
$this->httpResponse->setAppResponse($response);
};
$appRequest = $this->getRouter()->match($this->httpRequest);
$this->onBeforeRequest($appRequest, $this->sl);
try {
ob_start();
try {
$this->appResponse = NULL;
$application->processRequest($appRequest);
} catch (\Exception $e) {
$application->processException($e);
}
$this->httpResponse->setContent(ob_get_clean());
} finally {
$this->logger->log($this->httpRequest, $this->httpResponse);
}
return $this->httpResponse;
}
示例6: resetService
/**
* Resets the given services.
*
* A service in this context is connection or a manager instance.
*
* @param string $name The name of the service.
* @return void
*/
protected function resetService($name)
{
$this->serviceLocator->removeService($name);
}
示例7: remove
/**
* @param string $name
* @return void
*/
public function remove($name)
{
$this->container->removeService($name);
}