本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerInterface::getParameter方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface::getParameter方法的具體用法?PHP ContainerInterface::getParameter怎麽用?PHP ContainerInterface::getParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\ContainerInterface
的用法示例。
在下文中一共展示了ContainerInterface::getParameter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onKernelRequest
/**
* Invoked to modify the controller that should be executed.
*
* @param GetResponseEvent $event The event
*
* @access public
* @return null|void
* @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
*/
public function onKernelRequest(GetResponseEvent $event)
{
if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
// ne rien faire si ce n'est pas la requête principale
return;
}
$this->request = $event->getRequest($event);
//if (!$this->request->hasPreviousSession()) {
// return;
//}
// print_r('priority 1');
// we set locale
$locale = $this->request->cookies->has('_locale');
$localevalue = $this->request->cookies->get('_locale');
$is_switch_language_browser_authorized = $this->container->getParameter('sfynx.auth.browser.switch_language_authorized');
// Sets the user local value.
if ($is_switch_language_browser_authorized && !$locale) {
$lang_value = $this->container->get('request')->getPreferredLanguage();
$all_locales = $this->container->get('sfynx.auth.locale_manager')->getAllLocales();
if (in_array($lang_value, $all_locales)) {
$this->request->setLocale($lang_value);
$_GET['_locale'] = $lang_value;
return;
}
}
if ($locale && !empty($localevalue)) {
$this->request->attributes->set('_locale', $localevalue);
$this->request->setLocale($localevalue);
$_GET['_locale'] = $localevalue;
} else {
$this->request->attributes->set('_locale', $this->defaultLocale);
$this->request->setLocale($this->defaultLocale);
$_GET['_locale'] = $this->defaultLocale;
}
}
示例2: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$entity = new Office();
$entity->setName('En Office');
$entity->setAlias('en');
$entity->setEmail('test@test.com');
$entity->setProtocol('http');
$entity->setHost($this->container->getParameter('hosts.root'));
$entity->setRelatedUrl(null);
$entity->setDefaultLanguage('en');
$entity->setRecognizeLanguage('en');
$entity->setAvailableLanguages(['en', 'ru']);
$entity->setCurrencies(['EUR', 'USD']);
$entity->setIncludeLangInUrl(false);
$manager->persist($entity);
$entity = new Office();
$entity->setName('Ru Office');
$entity->setAlias('ru');
$entity->setEmail('test@test.com');
$entity->setProtocol('http');
$entity->setHost($this->container->getParameter('hosts.root'));
$entity->setRelatedUrl(null);
$entity->setDefaultLanguage('ru');
$entity->setRecognizeLanguage('ru');
$entity->setAvailableLanguages(['en', 'ru']);
$entity->setCurrencies(['EUR', 'USD', 'RUB']);
$manager->persist($entity);
$manager->flush();
}
示例3: __construct
/**
* GeoExporter constructor.
* @param ContainerInterface $container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->locations = $this->container->getParameter("locations");
$this->dispatcher = new EventDispatcher();
//var_dump($this->locations);
}
示例4: load
/**
* @param ObjectManager|EntityManager $manager
*/
public function load(ObjectManager $manager)
{
$settingsProvider = $this->container->get('orocrm_channel.provider.settings_provider');
$lifetimeSettings = $settingsProvider->getLifetimeValueSettings();
if (!array_key_exists(ChannelType::TYPE, $lifetimeSettings)) {
return;
}
$magentoChannelSettings = $lifetimeSettings[ChannelType::TYPE];
$customerIdentityClass = $magentoChannelSettings['entity'];
$lifetimeField = $magentoChannelSettings['field'];
$accountClass = $this->container->getParameter('orocrm_account.account.entity.class');
$channelClass = $this->container->getParameter('orocrm_channel.entity.class');
/** @var LifetimeHistoryRepository $lifetimeRepo */
$lifetimeRepo = $manager->getRepository('OroCRMChannelBundle:LifetimeValueHistory');
$brokenAccountQb = $this->getBrokenAccountsQueryBuilder($customerIdentityClass, $lifetimeField, $lifetimeRepo);
$brokenAccountsData = new BufferedQueryResultIterator($brokenAccountQb);
$toOutDate = [];
foreach ($brokenAccountsData as $brokenDataRow) {
/** @var Account $account */
$account = $manager->getReference($accountClass, $brokenDataRow['account_id']);
/** @var Channel $channel */
$channel = $manager->getReference($channelClass, $brokenDataRow['channel_id']);
$lifetimeAmount = $lifetimeRepo->calculateAccountLifetime($customerIdentityClass, $lifetimeField, $account, $channel);
$history = new LifetimeValueHistory();
$history->setAmount($lifetimeAmount);
$history->setDataChannel($channel);
$history->setAccount($account);
$manager->persist($history);
$toOutDate[] = [$account, $channel, $history];
}
$manager->flush();
foreach (array_chunk($toOutDate, self::MAX_UPDATE_CHUNK_SIZE) as $chunks) {
$lifetimeRepo->massStatusUpdate($chunks);
}
}
示例5: testDefaultServicesAndParamsLookOkay
public function testDefaultServicesAndParamsLookOkay()
{
$api = $this->container->get('amara_one_hydra.api');
$this->assertInstanceOf(Api::class, $api);
$httpRequestBuilder = $this->container->get('amara_one_hydra.api.http_request_builder');
$this->assertInstanceOf(HttpRequestBuilder::class, $httpRequestBuilder);
$transportGuzzle = $this->container->get('amara_one_hydra.api.transport.guzzle');
$this->assertInstanceOf(GuzzleTransport::class, $transportGuzzle);
$resultBuilderEngine = $this->container->get('amara_one_hydra.api.result_builder_engine');
$this->assertInstanceOf(ResultBuilderEngine::class, $resultBuilderEngine);
$guzzleClient = $this->container->get('amara_one_hydra.api.guzzle_client');
$this->assertInstanceOf(Client::class, $guzzleClient);
$pageManager = $this->container->get('amara_one_hydra.page_manager');
$this->assertInstanceOf(PageManager::class, $pageManager);
$pageStorage = $this->container->get('amara_one_hydra.page_storage');
$this->assertInstanceOf(PageStorage::class, $pageStorage);
$pageTransformStrategy = $this->container->get('amara_one_hydra.page_transform_strategy');
$this->assertInstanceOf(DefaultPageTransformStrategy::class, $pageTransformStrategy);
$twigExtension = $this->container->get('twig.onehydra_extension.default');
$this->assertInstanceOf(OneHydraExtension::class, $twigExtension);
$this->assertEquals(true, $this->container->getParameter('amara_one_hydra.is_uat'));
$this->assertEquals(false, $this->container->getParameter('amara_one_hydra.is_not_uat'));
$this->assertEquals('PT15M', $this->container->getParameter('amara_one_hydra.dateinterval'));
$this->assertEquals(['example' => ['auth_token' => 'authtoken1'], 'example2' => ['auth_token' => 'authtoken2']], $this->container->getParameter('amara_one_hydra.programs'));
}
示例6: load
public function load(ObjectManager $manager)
{
$yaml = new Parser();
$symbonfy_base_dir = $this->container->getParameter('kernel.root_dir');
$data_dir = $symbonfy_base_dir . '/Resources/data/';
try {
$value = Yaml::parse(file_get_contents($data_dir . 'tasks.yml'));
} catch (ParseException $e) {
printf("Unable to parse the YAML string: %s", $e->getMessage());
}
/*
tasks:
0: { id: 1, name: ''}
1: { id: 1, name: ''}
taskauthor:
0: { id: 1, name: "Brad Taylor", isActive: true }
1: { id: 2, name: "William O'Neil", isActive: false }
*/
$tasks = array(0 => array('name' => 'Task 0', 'description' => 'Description Task 0', 'products' => [1, 2, 3]), 1 => array('name' => 'Task 1', 'description' => 'Description Task 1', 'products' => [1, 4]), 2 => array('name' => 'Task 2', 'description' => 'Description Task 2', 'products' => [2, 3]));
foreach ($tasks as $task_id => $data) {
$task = new Task();
$task->setName($data['name']);
$task->setDescription($data['description']);
foreach ($data['products'] as $product) {
$task->addProduct($this->getReference($product));
}
$manager->persist($task);
}
$manager->flush();
}
示例7: load
/**
* @param \Doctrine\Common\Persistence\ObjectManager $manager
*/
public function load(ObjectManager $manager)
{
$languages = $this->container->getParameter('networking_init_cms.page.languages');
foreach ($languages as $lang) {
$this->createMenuItems($manager, $lang['locale']);
}
}
示例8: authenticate
/**
* {@inheritDoc}
*/
public function authenticate(TokenInterface $token)
{
$ownerName = $token->getResourceOwnerName();
$oauthUtil = $this->container->get('glory_oauth.util.token2oauth');
$oauth = $oauthUtil->generate($token);
$connect = $this->container->get('glory_oauth.connect');
if (!($user = $connect->getConnect($oauth))) {
if ($this->container->getParameter('glory_oauth.auto_register')) {
$user = $connect->connect($oauth);
} else {
$key = time();
$this->container->get('session')->set('glory_oauth.connect.oauth.' . $key, [$oauth->getOwner(), $oauth->getUsername()]);
$url = $this->container->get('router')->generate('glory_oauth_register', ['key' => $key]);
return new RedirectResponse($url);
}
}
if (!$user instanceof UserInterface) {
throw new BadCredentialsException('');
}
try {
$this->userChecker->checkPreAuth($user);
$this->userChecker->checkPostAuth($user);
} catch (BadCredentialsException $e) {
if ($this->hideUserNotFoundExceptions) {
throw new BadCredentialsException('Bad credentials', 0, $e);
}
throw $e;
}
$token = new OAuthToken($token->getRawToken(), $user->getRoles());
$token->setOwnerName($ownerName);
$token->setUser($user);
$token->setAuthenticated(true);
return $token;
}
示例9: getUrlPattern
private function getUrlPattern()
{
if (null == $this->_url_pattern) {
$this->_url_pattern = File::getAllFilesPattern($this->container->getParameter('sf.web_assets_dir'));
}
return $this->_url_pattern;
}
示例10: getParameter
/**
* @param string $parameter
*
* @return mixed
*/
public static function getParameter($parameter)
{
if (self::$container->hasParameter($parameter)) {
return self::$container->getParameter($parameter);
}
return false;
}
示例11: load
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$currency = new Currency();
$currency->setLabel('EUR');
$basket = new Basket();
$basket->setCurrency($currency);
$basket->setProductPool($this->getProductPool());
$products = array($this->getReference('php_plush_blue_goodie_product'), $this->getReference('php_plush_green_goodie_product'), $this->getReference('travel_japan_small_product'), $this->getReference('travel_japan_medium_product'), $this->getReference('travel_japan_large_product'), $this->getReference('travel_japan_extra_large_product'), $this->getReference('travel_quebec_small_product'), $this->getReference('travel_quebec_medium_product'), $this->getReference('travel_quebec_large_product'), $this->getReference('travel_quebec_extra_large_product'), $this->getReference('travel_paris_small_product'), $this->getReference('travel_paris_medium_product'), $this->getReference('travel_paris_large_product'), $this->getReference('travel_paris_extra_large_product'), $this->getReference('travel_switzerland_small_product'), $this->getReference('travel_switzerland_medium_product'), $this->getReference('travel_switzerland_large_product'), $this->getReference('travel_switzerland_extra_large_product'));
$nbCustomers = $this->container->hasParameter("sonata.fixtures.customer.fake") ? (int) $this->container->getParameter("sonata.fixtures.customer.fake") : 20;
for ($i = 1; $i <= $nbCustomers; $i++) {
$customer = $this->generateCustomer($manager, $i);
$customerProducts = array();
$orderProductsKeys = array_rand($products, rand(1, count($products)));
if (is_array($orderProductsKeys)) {
foreach ($orderProductsKeys as $orderProductKey) {
$customerProducts[] = $products[$orderProductKey];
}
} else {
$customerProducts = array($products[$orderProductsKeys]);
}
$order = $this->createOrder($basket, $customer, $customerProducts, $manager, $i);
$this->createTransaction($order, $manager);
$this->createInvoice($order, $manager);
if (!($i % 10)) {
$manager->flush();
}
}
$manager->flush();
}
示例12: getFirstTemplate
/**
* @return array
*/
protected function getFirstTemplate()
{
$templates = $this->container->getParameter('networking_init_cms.page.templates');
foreach ($templates as $key => $template) {
return $key;
}
}
示例13: load
public function load(ObjectManager $manager)
{
$symbonfy_base_dir = $this->container->getParameter('kernel.root_dir');
$data_dir = $symbonfy_base_dir . '/Resources/data/';
$row = 0;
$fd = fopen($data_dir . 'person.csv', "r");
if ($fd) {
while (($data = fgetcsv($fd)) !== false) {
$row++;
if ($row == 1) {
continue;
}
//skip header
$person = new Person();
$person->setName($data[0]);
$person->setAge($data[1]);
$birthDate = \DateTime::createFromFormat('d/m/Y', $data[2]);
$person->setBirthDate($birthDate);
$person->setHeight($data[3]);
$person->setEmail($data[4]);
$person->setPhone($data[5]);
$person->setGender($data[6]);
$person->setDescends($data[7]);
$person->setVehicle($data[8]);
$person->setPreferredLanguage($data[9]);
$person->setEnglishLevel($data[10]);
$person->setPersonalWebSite($data[11]);
$person->setCardNumber($data[12]);
$person->setIBAN($data[13]);
$manager->persist($person);
}
fclose($fd);
}
$manager->flush();
}
示例14: warmUp
/**
* {@inheritdoc}
*/
public function warmUp($cacheDir)
{
$serviceProxyIds = $this->container->getParameter('openclassrooms.service_proxy.service_proxy_ids');
foreach ($serviceProxyIds as $serviceProxyId) {
$this->container->get($serviceProxyId);
}
}
示例15: getItems
/**
* {@inheritdoc}
*/
public function getItems()
{
/* @var TokenStorageInterface $tokenStorage */
$tokenStorage = $this->container->get('security.token_storage');
/* @var RequestStack */
$requestStack = $this->container->get('request_stack');
/* @var Request $request */
$request = $requestStack->getCurrentRequest();
if (null === $request) {
return array();
}
/* @var Router $router */
$router = $this->container->get('router');
$locale = $request->getLocale();
$runtimeConfig = $this->container->getParameter(ModeraMjrIntegrationExtension::CONFIG_KEY);
$token = $tokenStorage->getToken();
if ($token->isAuthenticated() && $token->getUser() instanceof User) {
/* @var EntityManager $em */
$em = $this->container->get('doctrine.orm.entity_manager');
/* @var UserSettings $settings */
$settings = $em->getRepository(UserSettings::clazz())->findOneBy(array('user' => $token->getUser()->getId()));
if ($settings && $settings->getLanguage() && $settings->getLanguage()->getEnabled()) {
$locale = $settings->getLanguage()->getLocale();
$session = $request->getSession();
$session->set('_backend_locale', $locale);
}
}
return array('extjs_localization_runtime_plugin' => array('className' => 'Modera.backend.languages.runtime.ExtJsLocalizationPlugin', 'tags' => ['runtime_plugin'], 'args' => array(array('urls' => array($runtimeConfig['extjs_path'] . '/locale/ext-lang-' . $locale . '.js', $router->generate('modera_backend_languages_extjs_l10n', array('locale' => $locale)))))), 'modera_backend_languages.user_settings_window_contributor' => array('className' => 'Modera.backend.languages.runtime.UserSettingsWindowContributor', 'args' => ['@application'], 'tags' => ['shared_activities_provider']));
}