小编cra*_*ter的帖子

symfony2.7在服务容器中传递转换器

在symfony 2.3中,这是service.yml中的这一行来到翻译器

在service.yml

arguments: [@translator,....
Run Code Online (Sandbox Code Playgroud)

在serviceFunctions.php中

 public function __construct(Translator $translator,...) {
    $this->translator = $translator;
Run Code Online (Sandbox Code Playgroud)

现在我收到错误:

必须是Symfony\Component\Translation\Translator的实例,给出了Symfony\Component\Translation\DataCollectorTranslator的实例

如何在生产模式下使用2.7 in dev中的服务?

symfony symfony-2.7

10
推荐指数
2
解决办法
9201
查看次数

doctrine2 findby两列OR条件

我的行动:

   $matches_request = $em->getRepository('Bundle:ChanceMatch')->findByRequestUser(1);
   $matches_reply = $em->getRepository('Bundle:ChanceMatch')->findByReplyUser(1);
Run Code Online (Sandbox Code Playgroud)

是否可以or使用getRepository 加入查询条件,例如.

$matches_reply = $em->getRepository('FrontendChancesBundle:ChanceMatch')->findBy(array('requestUser' => 1, 'replyUser' => 1); 
//this of course gives me the a result when `requestUser` and `replyUser` is `1`. 
Run Code Online (Sandbox Code Playgroud)

我的桌子

id | requestUser | replyUser
....
12 |      1      |     2
13 |      5      |     1
Run Code Online (Sandbox Code Playgroud)

我的查询应该返回id 12 & 13.

感谢帮助!

symfony doctrine-orm symfony-2.1

5
推荐指数
1
解决办法
1万
查看次数

显示使用的配置和参数文件

有没有办法在symfony中通过命令行显示以显示在特定环境中使用了哪些所有配置文件和参数文件?

在文档中找不到任何内容。

symfony

5
推荐指数
1
解决办法
1326
查看次数

绑定后Symfony2抛出表单错误

我想绑定表单后抛出一个错误.这是我的代码:

$form = $this->createFormBuilder()
            ...
            ->add('date', 'birthday', array(
                'years' => range($year_18-90, $year_18),
                'empty_value' => array('year' => $year_18-16)
            ))->getForm;

//Post and valid 
if ($form->isValid()) {
            $formData = $form->getData();
            if ($formData['date']->getTimestamp() > $date_18) {
                //if user is under 18, then throw an error in from 'date' / ' birthday'
            }
Run Code Online (Sandbox Code Playgroud)

如何在Method-Post之后在symfony2中执行此操作?

forms validation post symfony

2
推荐指数
1
解决办法
2051
查看次数

检测鼠标是否在元素上

如果鼠标位于div事件上,我如何得到一个非常简单的true/false语句= true else = false

  var test = $("#main-nav").on("mouseenter", function (e) {
    e.preventDefault();
    console.log(e.preventDefault());
    return true;
});

if (test === true) {
   //do something
} else {
   //something different
}
Run Code Online (Sandbox Code Playgroud)

javascript jquery

0
推荐指数
1
解决办法
200
查看次数

symfony4将autowire迁移为true - 获取错误消息

我正在从symofony 2.7迁移到symfony 4.0.成功后,我迁移了一个捆绑包.现在我正在迁移第二个包,错误消息即将出现.我完全不了解symfony 4.0对我的要求.

如果我打开autowire: true此错误消息即将出现.

Cannot autowire service "App\Kernel": argument "$environment" of method "Symfony\Component\HttpKernel\Kernel::__construct()" must have a type-hint or be given a value explicitly.
Run Code Online (Sandbox Code Playgroud)

有人能帮助我吗?

如果我将其关闭,则不会出现任何消​​息.

更新

我只在bundles.php中注册了我的包

App\Backend\AccountBundle\BackendAccountBundle::class => ['all' => true],
Run Code Online (Sandbox Code Playgroud)

symfony symfony4

0
推荐指数
1
解决办法
963
查看次数