在树枝上我需要获得当前的完整uri(url + uri)而不需要渲染它
path('route_test', {param1:1})
Run Code Online (Sandbox Code Playgroud)
怎么弄?
我的symfony 2.4环境中存在大量问题,在我的翻译中使用换行符
我试过两个:
#messages.de.yml
foo: |
Hello i am a line
Hello i am a new line
Run Code Online (Sandbox Code Playgroud)
和
#messages.de.yml
foo: >
Hello i am a line
Hello i am a new line
Run Code Online (Sandbox Code Playgroud)
枝条
#template.html.twig
{{ 'foo'|trans }}
Run Code Online (Sandbox Code Playgroud)
翻译工作但换行没有.
也许我错了,但我想我完全按照文件说的做了.
我有一个Repository类,其中包含一个调用自定义Query的方法.当我尝试findAllWithRating()从控制器内部调用时,我得到以下异常:
[2/2] QueryException: [Syntax Error] line 0, col 156: Error: Unexpected 'NULL'
Run Code Online (Sandbox Code Playgroud)
如果我尝试在phpmyadmin中调用查询,则查询效果很好!
任何的想法?
<?php
namespace Anchorbrands\Bundle\MessageBundle\Entity;
use Doctrine\ORM\EntityRepository;
class MessageRepository extends EntityRepository
{
public function findAllWithRating() {
return $this->getEntityManager()
->createQuery("SELECT id, user_id, title, slug, content, question, image_name, created_at, updated_at,
MAX(CASE WHEN rating = '1' THEN totalCount ELSE NULL END) 'Rating 1',
MAX(CASE WHEN rating = '2' THEN totalCount ELSE NULL END) 'Rating 2',
MAX(CASE WHEN rating = '3' THEN totalCount ELSE NULL END) 'Rating 3'
FROM
( …Run Code Online (Sandbox Code Playgroud) 假设我有两个实体:
一个位置拥有多个图像(一对多)。图像可能具有属性类型。我经常遇到一个用例,我需要按类型过滤图像。目前,我通过生命周期回调来完成此操作,如下例所示:
/**
* This functions sets all images when the entity is loaded
*
* @ORM\PostLoad
*/
public function onPostLoadSetImages($eventArgs)
{
$this->recommendedForIcons = new ArrayCollection();
$this->whatYouGetImages = new ArrayCollection();
foreach ($this->getImages() as $image) {
if ('background-image' === $image->getType()->getSlug()) {
$this->backgroundImage = $image;
} elseif ('product-icon' === $image->getType()->getSlug()) {
$this->mainIcon = $image;
} elseif ('product-image' === $image->getType()->getSlug()) {
$this->productImage = $image;
} elseif ('recommended-icon' === $image->getType()->getSlug()) {
$this->recommendedForIcons->add($image);
} elseif ('what-you-get-image' === $image->getType()->getSlug()) {
$this->whatYouGetImages->add($image);
} elseif …Run Code Online (Sandbox Code Playgroud) 我有一个登录success_handler,它将某些用户重定向到一个特殊的表单.无论如何,AuthenticationSuccessHandlerInterface需要返回一个Response并且除了一个案例之外还能正常工作.如果用户首先填写他的凭证错误并再次重定向到登录页面,则处理程序在正确登录后将其重定向到登录页面.
如果我只是使用选项use_referer:true它是正确的.所以我可以把逻辑放到控制器而不是一个事件,但也许你们中的某个人有我的解决方案.
谢谢
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
success_handler: applypie_userbundle.login.handler
#default_target_path: applypie_user_dashboard
use_referer: true
logout: true
anonymous: true
Run Code Online (Sandbox Code Playgroud)
namespace Applypie\Bundle\UserBundle\EventListener;
use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
class NewUserListener implements AuthenticationSuccessHandlerInterface
{
protected $router;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$user = $token->getUser();
if(!$user->getApplicant() && !count($user->getCompanies())) {
return new RedirectResponse($this->router->generate('applypie_user_applicant_create'));
}
return new RedirectResponse($request->headers->get('referer'));
}
}
Run Code Online (Sandbox Code Playgroud)
applypie_userbundle.login.handler:
class: Applypie\Bundle\UserBundle\EventListener\NewUserListener
arguments: …Run Code Online (Sandbox Code Playgroud)