在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中的服务?
我的行动:
$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中通过命令行显示以显示在特定环境中使用了哪些所有配置文件和参数文件?
在文档中找不到任何内容。
我想绑定表单后抛出一个错误.这是我的代码:
$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中执行此操作?
如果鼠标位于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) 我正在从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 ×5
doctrine-orm ×1
forms ×1
javascript ×1
jquery ×1
post ×1
symfony-2.1 ×1
symfony-2.7 ×1
symfony4 ×1
validation ×1