当前位置: 首页>>代码示例>>PHP>>正文


PHP Service::getParameter方法代码示例

本文整理汇总了PHP中Service::getParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getParameter方法的具体用法?PHP Service::getParameter怎么用?PHP Service::getParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Service的用法示例。


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

示例1: boot

 public function boot()
 {
     parent::boot();
     if (!$this->container->getParameter('bzion.miscellaneous.development')) {
         if ($this->getEnvironment() != 'prod' || $this->isDebug()) {
             throw new ForbiddenDeveloperAccessException('You are not allowed to access this page in a non-production ' . 'environment. Please change the "development" configuration ' . 'value and clear the cache before proceeding.');
         }
     }
     if (in_array($this->getEnvironment(), array('profile', 'dev'), true)) {
         Debug::enable();
     }
     Service::setGenerator($this->container->get('router')->getGenerator());
     Service::setEnvironment($this->getEnvironment());
     Service::setModelCache(new ModelCache());
     Service::setContainer($this->container);
     $this->setUpTwig();
     // Ratchet doesn't support PHP's native session storage, so use our own
     // if we need it
     if (Service::getParameter('bzion.features.websocket.enabled') && $this->getEnvironment() !== 'test') {
         $storage = new NativeSessionStorage(array(), new DatabaseSessionHandler());
         $session = new Session($storage);
         Service::getContainer()->set('session', $session);
     }
     Notification::initializeAdapters();
 }
开发者ID:kleitz,项目名称:bzion,代码行数:25,代码来源:AppKernel.php

示例2: isEnabled

 /**
  * {@inheritDoc}
  */
 public static function isEnabled()
 {
     if (!parent::isEnabled()) {
         return false;
     }
     return \Service::getParameter('bzion.features.websocket.enabled');
 }
开发者ID:kleitz,项目名称:bzion,代码行数:10,代码来源:WebSocketAdapter.php

示例3: getSubscribedEvents

 /**
  * Returns all the events that this subscriber handles, and which method
  * handles each one
  *
  * @return array
  */
 public static function getSubscribedEvents()
 {
     if (!\Service::getParameter('bzion.features.elasticsearch.enabled')) {
         // Don't subscribe to events if elasticsearch is disabled
         return array();
     }
     return array('group.abandon' => 'update', 'group.join' => 'update', 'group.kick' => 'update', 'message.new' => 'onNew');
 }
开发者ID:kleitz,项目名称:bzion,代码行数:14,代码来源:ElasticaEventSubscriber.php

示例4: build

 /**
  * {@inheritDoc}
  */
 protected function build($builder)
 {
     $durations = \Service::getParameter('bzion.league.duration');
     foreach ($durations as $duration => &$value) {
         $durations[$duration] = $duration;
     }
     return $builder->add('first_team', new MatchTeamType())->add('second_team', new MatchTeamType())->add('duration', 'choice', array('choices' => $durations, 'constraints' => new NotBlank(), 'expanded' => true))->add('server_address', 'text', array('required' => false, 'attr' => array('placeholder' => 'brad.guleague.org:5100')))->add('time', new DatetimeWithTimezoneType(), array('constraints' => array(new NotBlank(), new LessThan(array('value' => \TimeDate::now()->addMinutes(10), 'message' => 'The timestamp of the match must not be in the future'))), 'data' => \TimeDate::now(\Controller::getMe()->getTimezone())))->add('enter', 'submit');
 }
开发者ID:kleitz,项目名称:bzion,代码行数:11,代码来源:MatchFormCreator.php

示例5: build

 /**
  * {@inheritdoc}
  */
 protected function build($builder)
 {
     $durations = \Service::getParameter('bzion.league.duration');
     foreach ($durations as $duration => &$value) {
         $durations[$duration] = $duration;
     }
     return $builder->add('first_team', new MatchTeamType(), array('disableTeam' => $this->isEdit() && $this->editing->isOfficial()))->add('second_team', new MatchTeamType(), array('disableTeam' => $this->isEdit() && $this->editing->isOfficial()))->add('duration', 'choice', array('choices' => $durations, 'constraints' => new NotBlank(), 'expanded' => true))->add('server_address', 'text', array('required' => false, 'attr' => array('placeholder' => 'brad.guleague.org:5100')))->add('time', new DatetimeWithTimezoneType(), array('constraints' => array(new NotBlank(), new LessThan(array('value' => \TimeDate::now()->addMinutes(10), 'message' => 'The timestamp of the match must not be in the future'))), 'data' => $this->isEdit() ? $this->editing->getTimestamp()->setTimezone(\Controller::getMe()->getTimezone()) : \TimeDate::now(\Controller::getMe()->getTimezone()), 'with_seconds' => $this->isEdit()))->add('map', new ModelType('Map'), array('required' => false))->add('type', 'choice', array('choices' => array(\Match::OFFICIAL => 'Official', \Match::FUN => 'Fun match', \Match::SPECIAL => 'Special event match'), 'disabled' => $this->editing && $this->editing->isOfficial(), 'label' => 'Match Type'))->add('enter', 'submit');
 }
开发者ID:allejo,项目名称:bzion,代码行数:11,代码来源:MatchFormCreator.php

示例6: __construct

 /**
  * Constructor for our extension of Parsedown
  */
 function __construct()
 {
     $this->camo = array();
     $this->camo['enabled'] = \Service::getParameter('bzion.features.camo.enabled');
     if ($this->camo['enabled']) {
         $this->camo['key'] = \Service::getParameter('bzion.features.camo.key');
         $this->camo['base_url'] = \Service::getParameter('bzion.features.camo.base_url');
         $this->camo['whitelisted_domains'] = \Service::getParameter('bzion.features.camo.whitelisted_domains');
     }
 }
开发者ID:blast007,项目名称:bzion,代码行数:13,代码来源:MarkdownEngine.php

示例7: search

 /**
  * Perform a search on messages and get the results
  *
  * @param  string    $query The query string
  * @return Message[] The results of the search
  */
 public function search($query)
 {
     Debug::startStopwatch('search.messages');
     if (\Service::getParameter('bzion.features.elasticsearch.enabled')) {
         $results = $this->elasticSearch($query);
     } else {
         $results = $this->mysqlSearch($query);
     }
     Debug::finishStopwatch('search.messages');
     return $results;
 }
开发者ID:kleitz,项目名称:bzion,代码行数:17,代码来源:MessageSearch.php

示例8: getInstance

 /**
  * Get an instance of the Database object
  *
  * This should be the main way to acquire access to the database
  *
  * @todo Move this to the Service class
  *
  * @return Database The Database object
  */
 public static function getInstance()
 {
     if (!self::$Database) {
         if (Service::getEnvironment() == 'test') {
             if (!Service::getParameter('bzion.testing.enabled')) {
                 throw new Exception('You have to specify a MySQL database for testing in the bzion.testing section of your configuration file.');
             }
             self::$Database = new self(Service::getParameter('bzion.testing.host'), Service::getParameter('bzion.testing.username'), Service::getParameter('bzion.testing.password'), Service::getParameter('bzion.testing.database'));
         } else {
             self::$Database = new self(Service::getParameter('bzion.mysql.host'), Service::getParameter('bzion.mysql.username'), Service::getParameter('bzion.mysql.password'), Service::getParameter('bzion.mysql.database'));
         }
     }
     return self::$Database;
 }
开发者ID:allejo,项目名称:bzion,代码行数:23,代码来源:Database.php

示例9: array

$autoreport = Player::newPlayer(55976, "AutoReport", null, "test");
$blast = Player::newPlayer(180, "blast", null, "active", Player::S_ADMIN);
$kierra = Player::newPlayer(2229, "kierra", null, "active", Player::ADMIN, "", "", 174);
$mdskpr = Player::newPlayer(8312, "mdskpr");
$snake = Player::newPlayer(54497, "Snake12534");
$tw1sted = Player::newPlayer(9736, "tw1sted", null, "active", Player::DEVELOPER);
$brad = Player::newPlayer(3030, "brad", null, "active", Player::S_ADMIN, "", "I keep nagging about when this project will be done");
$constitution = Player::newPlayer(9972, "Constitution", null, "active", Player::S_ADMIN);
$themap = Player::newPlayer(57422, "the map", null, "active", Player::COP);
$oldSnake = Player::newPlayer(54498, "Snake12534");
$oldSnake->setOutdated(true);
$allPlayers = array($alezakos, $allejo, $ashvala, $autoreport, $blast, $kierra, $mdskpr, $snake, $tw1sted, $brad, $constitution, $themap);
echo " done!";
echo "\nSending notifications...";
foreach (Player::getPlayers() as $player) {
    $event = new WelcomeEvent('Welcome to ' . Service::getParameter('bzion.site.name') . '!', $player);
    Notification::newNotification($player->getId(), 'welcome', $event);
}
echo " done!";
echo "\nAdding deleted objects...";
Team::createTeam("Amphibians", $snake->getId(), "", "")->delete();
$snake->refresh();
Team::createTeam("Serpents", $snake->getId(), "", "")->delete();
$snake->refresh();
Page::addPage("Test", "<p>This is a deleted page</p>", $tw1sted->getId())->delete();
echo " done!";
echo "\nAdding teams...";
$olfm = Team::createTeam("OpenLeague FM?", $kierra->getId(), "", "");
$reptitles = Team::createTeam("Reptitles", $snake->getId(), "", "", "open");
$fflood = Team::createTeam("Formal Flood", $allejo->getId(), "", "");
$lweak = Team::createTeam("[LakeWeakness]", $mdskpr->getId(), "", "");
开发者ID:allejo,项目名称:bzion,代码行数:31,代码来源:sampleData.php

示例10: staleInfo

 /**
  * Checks if the last update is older than or equal to the update interval
  * @return bool Whether the information is older than the update interval
  */
 public function staleInfo()
 {
     $update_time = $this->updated->copy();
     $update_time->modify(Service::getParameter('bzion.miscellaneous.update_interval'));
     return TimeDate::now() >= $update_time;
 }
开发者ID:kleitz,项目名称:bzion,代码行数:10,代码来源:Server.php

示例11: calculateEloDiff

 /**
  * Calculate the ELO score difference
  *
  * Computes the absolute value of the ELO score difference on each team
  * after a match, based on GU League's rules.
  *
  * @param  int $a_elo    Team A's current ELO score
  * @param  int $b_elo    Team B's current ELO score
  * @param  int $a_points Team A's match points
  * @param  int $b_points Team B's match points
  * @param  int $duration The match duration in minutes
  * @return int The ELO score difference
  */
 public static function calculateEloDiff($a_elo, $b_elo, $a_points, $b_points, $duration)
 {
     $prob = 1.0 / (1 + pow(10, ($b_elo - $a_elo) / 400.0));
     if ($a_points > $b_points) {
         $diff = 50 * (1 - $prob);
     } elseif ($a_points == $b_points) {
         $diff = 50 * (0.5 - $prob);
     } else {
         $diff = 50 * (0 - $prob);
     }
     // Apply ELO modifiers from `config.yml`
     $durations = Service::getParameter('bzion.league.duration');
     $diff *= isset($durations[$duration]) ? $durations[$duration] : 1;
     if (abs($diff) < 1 && $diff != 0) {
         // ELOs such as 0.75 should round up to 1...
         return $diff > 0 ? 1 : -1;
     }
     // ...everything else is rounded down (-3.7 becomes -3 and 48.1 becomes 48)
     return intval($diff);
 }
开发者ID:bchhun,项目名称:bzion,代码行数:33,代码来源:Match.php

示例12: getURL

 /**
  * {@inheritdoc}
  *
  * @todo Redirect models with wrong alias when bzion.site.url_type === 'permalink'
  */
 public function getURL($action = 'show', $absolute = false, $params = array(), $vanity = false)
 {
     if (!$this->isValid()) {
         return "";
     }
     $forbiddenAliases = array('edit', 'delete', 'kick', 'invite', 'change-leader', 'matches', 'members');
     if (Service::getParameter('bzion.site.url_type') === 'permalink' && $this instanceof DuplexUrlInterface && !$vanity) {
         // Add both the alias and the ID to the URL if the model supports them
         // Make sure the alias is not forbidden
         if (in_array(strtolower($action), $forbiddenAliases)) {
             $alias = $this->getId();
         } else {
             $alias = $this->alias;
         }
         // Add the alias to the query parameters
         $params = $params + array('alias' => $alias);
         $alias = $this->getId();
     } else {
         if (in_array(strtolower($action), $forbiddenAliases)) {
             $alias = $this->getId();
         } else {
             $alias = $this->getAlias();
         }
     }
     return $this->getLink($alias, $action, $absolute, $params);
 }
开发者ID:allejo,项目名称:bzion,代码行数:31,代码来源:AliasModel.php

示例13: hasBeenActive

 /**
  * Check whether or not a player been in a match or has logged on in the specified amount of time to be considered
  * active
  *
  * @return bool True if the player has been active
  */
 public function hasBeenActive()
 {
     $this->lazyLoad();
     $interval = Service::getParameter('bzion.miscellaneous.active_interval');
     $lastLogin = $this->last_login->copy()->modify($interval);
     $hasBeenActive = TimeDate::now() <= $lastLogin;
     if ($this->last_match->isValid()) {
         $lastMatch = $this->last_match->getTimestamp()->copy()->modify($interval);
         $hasBeenActive = $hasBeenActive || TimeDate::now() <= $lastMatch;
     }
     return $hasBeenActive;
 }
开发者ID:allejo,项目名称:bzion,代码行数:18,代码来源:Player.php


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