本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerInterface::initialized方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface::initialized方法的具體用法?PHP ContainerInterface::initialized怎麽用?PHP ContainerInterface::initialized使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\ContainerInterface
的用法示例。
在下文中一共展示了ContainerInterface::initialized方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: resetDynamicSettings
/**
* Ensure that dynamic settings are correctly reset,
* so that services that rely on those are correctly updated.
*/
private function resetDynamicSettings()
{
// Ensure to reset services that need to be.
foreach ($this->resettableServiceIds as $serviceId) {
if (!$this->container->initialized($serviceId)) {
continue;
}
$this->container->set($serviceId, null);
}
// Update services that can be updated.
foreach ($this->updatableServices as $serviceId => $methodCalls) {
if (!$this->container->initialized($serviceId)) {
continue;
}
$service = $this->container->get($serviceId);
foreach ($methodCalls as $callConfig) {
list($method, $expression) = $callConfig;
$argument = $this->expressionLanguage->evaluate($expression, ['container' => $this->container]);
call_user_func_array([$service, $method], [$argument]);
}
}
}
示例2: findRealTransport
/**
* Returns a real transport used to send mails by a mailer specified in the constructor of this class
*
* @return \Swift_Transport|null
*/
protected function findRealTransport()
{
$realTransport = null;
$mailers = array_keys($this->container->getParameter('swiftmailer.mailers'));
foreach ($mailers as $name) {
if ($this->container instanceof IntrospectableContainerInterface && !$this->container->initialized(sprintf('swiftmailer.mailer.%s', $name))) {
continue;
}
$mailer = $this->container->get(sprintf('swiftmailer.mailer.%s', $name));
if ($mailer === $this->baseMailer) {
$realTransport = $this->container->get(sprintf('swiftmailer.mailer.%s.transport.real', $name));
break;
}
}
return $realTransport;
}
示例3: persistServices
/**
* Moves persistent service instances into a new container.
*/
protected function persistServices(ContainerInterface $container, array $persist)
{
foreach ($persist as $id => $object) {
// Do not override services already set() on the new container, for
// example 'service_container'.
if (!$container->initialized($id)) {
$container->set($id, $object);
}
}
}
示例4: testInitializedForAliases
/**
* Tests that Container::initialized works correctly for aliases.
*
* @covers ::initialized
*/
public function testInitializedForAliases()
{
$this->assertFalse($this->container->initialized('late.service_alias'), 'Late service is not initialized.');
$this->container->get('late.service');
$this->assertTrue($this->container->initialized('late.service_alias'), 'Late service is initialized after it was retrieved once.');
}