本文整理汇总了PHP中Service::getGenerator方法的典型用法代码示例。如果您正苦于以下问题:PHP Service::getGenerator方法的具体用法?PHP Service::getGenerator怎么用?PHP Service::getGenerator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service::getGenerator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
public function editAction(Player $me, Team $team)
{
$response = $this->edit($team, $me, "team");
if ($this->newLeader) {
// Redirect to a confirmation form if we are assigning a new leader
$url = Service::getGenerator()->generate('team_assign_leader', array('team' => $team->getAlias(), 'player' => $this->newLeader->getAlias()));
return new RedirectResponse($url);
}
return $response;
}
示例2: editAction
public function editAction(Player $me, Match $match)
{
// TODO: Generating this response is unnecessary
$response = $this->edit($match, $me, "match");
if ($this->recalculateNeeded && $match->isOfficial()) {
// Redirect to a confirmation form if we are assigning a new leader
$url = Service::getGenerator()->generate('match_recalculate', array('match' => $match->getId()));
return new RedirectResponse($url);
}
return $response;
}
示例3: loginAction
public function loginAction(Request $request, Player $me)
{
if ($me->isValid()) {
throw new ForbiddenException("You are already logged in!");
}
$query = $request->query;
$session = $request->getSession();
$token = $query->get("token");
$username = $query->get("username");
if (!$token || !$username) {
throw new BadRequestException();
}
// Don't check whether IPs match if we're on a development environment
$checkIP = !$this->isDebug();
$info = validate_token($token, $username, array(), $checkIP);
if (!isset($info)) {
throw new ForbiddenException("There was an error processing your login. Please go back and try again.");
}
$session->set("username", $info['username']);
$session->set("groups", $info['groups']);
$redirectToProfile = false;
if (!Player::playerBZIDExists($info['bzid'])) {
// If they're new, redirect to their profile page so they can add some info
$player = Player::newPlayer($info['bzid'], $info['username']);
$redirectToProfile = true;
} else {
$player = Player::getFromBZID($info['bzid']);
if ($player->isDeleted()) {
$player->setStatus('active');
}
}
$session->set("playerId", $player->getId());
$player->updateLastLogin();
$player->setUsername($info['username']);
Visit::enterVisit($player->getId(), $request->getClientIp(), gethostbyaddr($request->getClientIp()), $request->server->get('HTTP_USER_AGENT'), $request->server->get('HTTP_REFERER'));
$this->configPromoteAdmin($player);
if ($redirectToProfile) {
$profile = Service::getGenerator()->generate('profile_show');
return new RedirectResponse($profile);
} else {
return $this->goBack();
}
}
示例4: generate
/**
* Generates a URL from the given parameters.
* @param string $name The name of the route
* @param mixed $parameters An array of parameters
* @param boolean $absolute Whether to generate an absolute URL
* @return string The generated URL
*/
public static function generate($name, $parameters = array(), $absolute = false)
{
return Service::getGenerator()->generate($name, $parameters, $absolute);
}
示例5: build
/**
* {@inheritdoc}
*/
protected function build($builder)
{
$notBlank = array('constraints' => new NotBlank());
return $builder->add('Recipients', new AdvancedModelType(array('player', 'team')), array('constraints' => new Count(array('min' => 2, 'minMessage' => 'You need to specify the recipients of your message')), 'multiple' => true, 'include' => $this->editing))->add('Subject', 'text', $notBlank)->add('Message', 'textarea', $notBlank)->add('Send', 'submit')->setAction(\Service::getGenerator()->generate('message_compose'));
}
示例6: getLink
/**
* Generate a link for a route related to this object
*
* @param mixed $identifier A parameter representing the model (e.g an ID or alias)
* @param string $action The action to perform
* @param bool $absolute Whether to return an absolute URL
* @param array $params Extra parameters to pass to the URL generator
*
* @return string A link
*/
protected function getLink($identifier, $action, $absolute, $params)
{
return Service::getGenerator()->generate(static::getRouteName($action), array_merge(array(static::getParamName() => $identifier), $params), $absolute);
}
示例7: getHomeURL
/**
* Returns the path to the home page
* @return string
*/
protected function getHomeURL()
{
return Service::getGenerator()->generate('index');
}
示例8: redirectToList
protected function redirectToList($model)
{
return new RedirectResponse(Service::getGenerator()->generate("index"));
}
示例9: getMatchesURL
/**
* Get the URL that points to the team's list of matches
*
* @return string The team's list of matches
*/
public function getMatchesURL()
{
return Service::getGenerator()->generate("match_by_team_list", array("team" => $this->getAlias()));
}
示例10: redirectToList
/**
* Get a redirection response to a list of models
*
* @param ModelInterface $model The model to whose list we should redirect
* @return Response
*/
protected function redirectToList($model)
{
$route = $model->getRouteName('list');
$url = Service::getGenerator()->generate($route);
return new RedirectResponse($url);
}
示例11: leaveAction
public function leaveAction(Player $me, Group $discussion)
{
if (!$discussion->isMember($me)) {
throw new ForbiddenException("You are not a member of this discussion.");
} elseif ($discussion->getCreator()->getId() == $me->getId()) {
throw new ForbiddenException("You can't abandon the conversation you started!");
}
return $this->showConfirmationForm(function () use($discussion, $me) {
$discussion->removeMember($me);
$event = new GroupAbandonEvent($discussion, $me);
Service::getDispatcher()->dispatch(Events::GROUP_ABANDON, $event);
return new RedirectResponse(Service::getGenerator()->generate('message_list'));
}, "Are you sure you want to abandon this discussion?", "You will no longer receive messages from this conversation", "Leave");
}
示例12: __invoke
/**
* Modify the current page URL
*
* @param array $parameters An array of parameters to add/modify in the request
* @return string The HTML link
*/
public function __invoke(array $parameters)
{
$attributes = \Service::getRequest()->attributes;
$query = \Service::getRequest()->query;
return \Service::getGenerator()->generate($attributes->get('_route'), $parameters + $attributes->get('_route_params') + $query->all());
}
示例13: build
/**
* {@inheritDoc}
*/
protected function build($builder)
{
return $builder->add('q', 'search')->setAction(\Service::getGenerator()->generate('message_search'))->setMethod('GET');
}
示例14: setUpTwig
private function setUpTwig()
{
$cacheDir = $this->isDebug() ? null : $this->getCacheDir() . '/twig';
// Set up the twig templating environment to parse views
$loader = new Twig_Loader_Filesystem(__DIR__ . '/../views');
$twig = new Twig_Environment($loader, array('cache' => $cacheDir, 'debug' => $this->isDebug()));
// Load the routing extension to twig, which adds functions such as path()
$formEngine = new TwigRendererEngine(array('form_layout.html.twig'));
$formEngine->setEnvironment($twig);
$twig->addExtension(new RoutingExtension(Service::getGenerator()));
$twig->addExtension(new FormExtension(new TwigRenderer($formEngine)));
$twig->addExtension(new ImagineExtension($this->container->get('liip_imagine.cache.manager')));
$twig->addExtension(new AssetExtension($this->container->get('assets.packages')));
$twig->addExtension(new StopwatchExtension($this->container->get('debug.stopwatch', null)));
if ($this->getEnvironment() == 'profile') {
$twig->addExtension(new DumpExtension($this->container->get('var_dumper.cloner')));
}
$twig->addFunction(LinkToFunction::get());
$twig->addFilter(HumanDateFilter::get());
$twig->addFilter(TruncateFilter::get());
$twig->addFilter(MarkdownFilter::get());
$twig->addFilter(PluralFilter::get());
$twig->addFilter(YesNoFilter::get());
$twig->addTest(ValidTest::get());
$twig->addTest(InvalidTest::get());
if ($this->isDebug()) {
$twig->addExtension(new Twig_Extension_Debug());
}
Service::setTemplateEngine($twig);
}
示例15: redirectTo
protected function redirectTo($model)
{
// Redirect to the server list after creating/editing a role
return new RedirectResponse(Service::getGenerator()->generate('admin_landing'));
}