本文整理汇总了PHP中Symfony\Component\DependencyInjection\Container::getParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::getParameter方法的具体用法?PHP Container::getParameter怎么用?PHP Container::getParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\Container
的用法示例。
在下文中一共展示了Container::getParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: warmUp
public function warmUp($cacheDir)
{
// we need the directory no matter the proxy cache generation strategy.
$proxyCacheDir = $this->container->getParameter('doctrine.orm.proxy_dir');
if (!file_exists($proxyCacheDir)) {
if (false === @mkdir($proxyCacheDir, 0777, true)) {
throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory (%s)', dirname($proxyCacheDir)));
}
} else {
if (!is_writable($proxyCacheDir)) {
throw new \RuntimeException(sprintf('Doctrine Proxy directory (%s) is not writeable for the current system user.', $proxyCacheDir));
}
}
// if proxys are autogenerated we don't need to generate them in the cache warmer.
if ($this->container->getParameter('doctrine.orm.auto_generate_proxy_classes') === true) {
return;
}
$entityManagers = $this->container->getParameter('doctrine.orm.entity_managers');
foreach ($entityManagers as $entityManagerName) {
$em = $this->container->get(sprintf('doctrine.orm.%s_entity_manager', $entityManagerName));
/* @var $em Doctrine\ORM\EntityManager */
$classes = $em->getMetadataFactory()->getAllMetadata();
$em->getProxyFactory()->generateProxyClasses($classes);
}
}
示例2: renderMedia
/**
* Renders jwplayer
*
* @param MediaInterface $media
* @param array $options
*
* @return string
*/
public function renderMedia(MediaInterface $media, array $options = array())
{
$defaultOptions = $this->container->getParameter('thrace_media.jwplayer.options');
$configs = array('key' => $defaultOptions['key'], 'html5player' => $defaultOptions['html5player'], 'flashplayer' => $defaultOptions['flashplayer'], 'type' => $media->getType(), 'id' => uniqid('thrace_media', true), 'file' => $this->container->get('router')->generate('thrace_media_render', array('name' => $media->getMediaPath(), 'hash' => $media->getHash()), true));
$configs = array_replace_recursive($configs, $options);
return $this->container->get('templating')->render('ThraceMediaBundle:Media:media.html.twig', array('media' => $media, 'configs' => $configs));
}
示例3: param
public function param($key)
{
if ($this->container->hasParameter($key)) {
return $this->container->getParameter($key);
}
throw new Exception("Brak parametru w parameters.yml o nazwie '" . $key . "'");
}
示例4: createTicket
/**
* @param Event $event
* @param User $user
*
* @return Ticket
*/
public function createTicket($event, $user)
{
// @todo це ще треба передивитись і поправити
$em = $this->container->get('doctrine.orm.default_entity_manager');
// Вытягиваем скидку из конфига
$paymentsConfig = $this->container->getParameter('stfalcon_event.config');
$discount = (double) $paymentsConfig['discount'];
$ticket = new Ticket();
$ticket->setEvent($event);
$ticket->setUser($user);
$ticket->setAmountWithoutDiscount($event->getCost());
$paidPayments = $em->getRepository('StfalconEventBundle:Payment')->findPaidPaymentsForUser($user);
// если пользователь имеет оплаченные события,
// то он получает скидку (если для события разрешена такая скидка)
if (count($paidPayments) > 0 && $event->getUseDiscounts()) {
$cost = $event->getCost() - $event->getCost() * $discount;
$hasDiscount = true;
} else {
$cost = $event->getCost();
$hasDiscount = false;
}
$ticket->setAmount($cost);
$ticket->setHasDiscount($hasDiscount);
$em->persist($ticket);
$em->flush();
return $ticket;
}
示例5: dump
public function dump(AssetInterface $asset)
{
$writer = new \Assetic\AssetWriter(sys_get_temp_dir(), $this->container->getParameter('assetic.variables'));
$ref = new \ReflectionMethod($writer, 'getCombinations');
$ref->setAccessible(true);
$name = $asset->getSourcePath();
$type = substr($name, strrpos($name, '.') + 1);
switch ($type) {
case 'coffee':
$asset->ensureFilter($this->container->get('assetic.filter.coffee'));
$type = 'js';
break;
case 'less':
$asset->ensureFilter($this->container->get('assetic.filter.less'));
$type = 'css';
break;
}
$combinations = $ref->invoke($writer, $asset->getVars());
$asset->setValues($combinations[0]);
$asset->load();
$content = $asset->getContent();
// because the assetic cssrewrite makes bullshit here, we need to reimplement the filter
if ($type === 'css') {
$content = $this->cssFilter($content, '/' . dirname($asset->getSourcePath()));
}
return $content;
}
示例6: authentifyAsSystem
/**
* Authentify as system
*
* @return Auth
*/
public function authentifyAsSystem()
{
$this->login = $this->container->getParameter('fidesio_isidore.client.login');
$this->password = $this->container->getParameter('fidesio_isidore.client.password');
$this->authentify($this->login, $this->password);
return $this;
}
示例7: warmUp
public function warmUp($cacheDir)
{
// we need the directory no matter the hydrator cache generation strategy.
$hydratorCacheDir = $this->container->getParameter('doctrine.odm.mongodb.hydrator_dir');
if (!file_exists($hydratorCacheDir)) {
if (false === @mkdir($hydratorCacheDir, 0777, true)) {
throw new \RuntimeException(sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir)));
}
} else {
if (!is_writable($hydratorCacheDir)) {
throw new \RuntimeException(sprintf('Doctrine Hydrator directory (%s) is not writeable for the current system user.', $hydratorCacheDir));
}
}
// if hydrators are autogenerated we don't need to generate them in the cache warmer.
if ($this->container->getParameter('doctrine.odm.mongodb.auto_generate_hydrator_classes') === true) {
return;
}
$documentManagers = $this->container->getParameter('doctrine.odm.mongodb.document_managers');
foreach ($documentManagers as $documentManagerName) {
$dm = $this->container->get(sprintf('doctrine.odm.mongodb.%s_document_manager', $documentManagerName));
/* @var $dm Doctrine\ODM\MongoDB\DocumentManager */
$classes = $dm->getMetadataFactory()->getAllMetadata();
$dm->getHydratorFactory()->generateHydratorClasses($classes);
}
}
示例8: getTemplates
/**
* Template Loader
*
* @return Twig_TemplateInterface[]
*
* @throws \Exception
*/
protected function getTemplates()
{
if (empty($this->templates)) {
$this->templates[] = $this->environment->loadTemplate($this->container->getParameter('pedro_teixeira_grid.template'));
}
return $this->templates;
}
示例9: createProvider
public static function createProvider(Container $container)
{
$annotationsEnabled = $container->getParameter('rezonant.mapper.providers.annotations.enabled');
$configEnabled = $container->getParameter('rezonant.mapper.providers.config.enabled');
$cacheEnabled = $container->getParameter('rezonant.mapper.cache.enabled');
$cacheStrategy = $container->getParameter('rezonant.mapper.cache.strategy');
//$maps = $container->getParameter('rezonant.mapper.maps');
$providers = array();
if ($annotationsEnabled) {
$providers[] = $container->get('rezonant.mapper.annotation_map_provider');
}
if ($configEnabled) {
$configMapProvider = $container->get('rezonant.mapper.config_map_provider');
//$configMapProvider->setMaps($maps);
$providers[] = $configMapProvider;
}
$provider = new MapProviderModerator($providers);
if ($cacheEnabled) {
if (!class_exists($cacheStrategy, true)) {
throw new InvalidConfigurationException("No such strategy class {$cacheStrategy}");
}
$provider = new CacheProvider($provider, new $cacheStrategy());
}
return $provider;
}
示例10: getRecaptchaSecureToken
/**
* Get a secure token for reCAPTCHA so we aren't restricted to a specific domain...
* @see https://developers.google.com/recaptcha/docs/secure_token
*
* @return string
*/
public function getRecaptchaSecureToken()
{
$public_key = $this->container->getParameter('recaptcha.public_key');
$private_key = $this->container->getParameter('recaptcha.private_key');
$recaptchaToken = new ReCaptchaToken(array('site_key' => $public_key, 'site_secret' => $private_key));
return $recaptchaToken->secureToken(uniqid('recaptcha'));
}
示例11: postTweet
private function postTweet($text)
{
Codebird::setConsumerKey($this->container->getParameter('twitter_consumer_key'), $this->container->getParameter('twitter_consumer_secret'));
$cb = Codebird::getInstance();
$cb->setToken($this->container->getParameter('twitter_access_token'), $this->container->getParameter('twitter_access_token_secret'));
$reply = $cb->statuses_update('status=' . $text);
return $reply;
}
示例12: render
public function render($type = 'search', $entities = null, $fields = null)
{
if ($this->templateEngine === null) {
$this->templateEngine = $this->container->get('templating');
}
$template = $this->container->getParameter('enhavo_search.' . $type . '.template');
return $this->templateEngine->render($template, array('type' => $type, 'entities' => $entities, 'fields' => $fields));
}
示例13: __construct
public function __construct(Container $container, $soapUrl)
{
$this->talonClientSOAP = $container->get('be_simple_talon.soap_client.talon_soap_client');
$this->setSoapUrl($soapUrl);
$this->talonClientSOAP->setWsdl($this->getSoapUrl() . self::WSDL_PATH);
$this->talonClientSOAP->setOptions(array("login" => $container->getParameter('http_auth_login'), "password" => $container->getParameter('http_auth_password'), "httpauth" => $container->getParameter('http_auth'), "verifyhost" => $container->getParameter('verifyhost')));
$this->talonClientSOAP->TalonSoapClient();
}
示例14: setUp
/**
* {@inheritDoc}
*/
protected function setUp()
{
static::bootKernel();
$this->container = static::$kernel->getContainer();
$this->baseUrl = $this->container->getParameter('mink.base_url');
$this->session = $this->getMink()->getSession();
$this->session->maximizeWindow();
}
示例15: __construct
/**
* Constructor
*
* @param Container $container
*/
public function __construct(Container $container)
{
$this->request = $container->get('request');
$this->kernel = $container->get('kernel');
$this->doctrine = $container->get('doctrine');
$this->sessionData = array();
$this->config = array('sessionDuration' => $container->getParameter('tga_audience.session_duration'), 'disabledRoutes' => $container->getParameter('tga_audience.disabled_routes'), 'environnements' => $container->getParameter('tga_audience.environnements'));
}