我有一个小问题,如何创建一个简单的cron任务,在Symfony中调用一些服务操作,谁可以每晚自动执行?
我想在注册之后将用户重定向到另一个表单,然后才能访问我网站上的任何内容(例如https://github.com/FriendsOfSymfony/FOSUserBundle/issues/387).
所以我在doc中创建了一个eventListener:
<?php
namespace rs\UserBundle\EventListener;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\UserEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Listener responsible to change the redirection at the end of the password resetting
*/
class RegistrationConfirmedListener implements EventSubscriberInterface
{
private $router;
public function __construct(UrlGeneratorInterface $router)
{
$this->router = $router;
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::REGISTRATION_CONFIRMED => 'onRegistrationConfirmed'
);
}
public function onRegistrationConfirmed()
{
$url = $this->router->generate('rsWelcomeBundle_check_full_register');
$response = new RedirectResponse($url);
return $response;
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个像这样定义的SQL请求:
private static final String fetchOfferQuery = "SELECT DISTINCT "
+ "sim_id, sim_code, sim_label, sim_state, sim_type, sim_customerid, sim_storeid, sim_projectnumber, sim_version, sim_type_user, sim_type_vente, sim_statut, "
+ "(SELECT MAX(set_date) FROM offer_storage.t_simulationeventtrack_set WHERE set_sim_id = sim_id) AS sim_dateevtmax, "
+ "sim_creation_user, sim_modif_user, sim_rayon, sim_hours_lifetime, sim_eligible_reduced_vat, sim_store_linked, sim_canal, "
+ "ofr_id, CAST(ofr_creationdate AS timestamp) AS ofr_creationdate, ofr_label, ofr_state, ofr_transaction, ofr_modif_date, ofr_del_valid, "
+ "ofr_numcdecli, "
+ "ofi_id, ofi_productid, ofi_quantity,ofi_productprice, ofi_top, ofi_c1promo, ofi_codeactivite, ofi_codrem, "
+ "ofi_datejour, ofi_datepose, ofi_dateprevpose, ofi_datfinc1, ofi_datfinprxvtepromo, ofi_delai, ofi_libligdtl, ofi_montantpresta, " …Run Code Online (Sandbox Code Playgroud) 我使用Symfony和boostrap来定制我的网站的风格.我有一个twig文件:register_content.html.twig,其中包含一个注册表单.
在我的index.html.twig中我希望有类似的东西:
<a href="{{ path('fos_user_registration_register') }}" class="btn" data-toggle="modal">Je m'inscris !</a>
Run Code Online (Sandbox Code Playgroud)
要在模态窗口中显示寄存器表单的内容,但它不起作用.
我尝试使用twitter-bootstrap文档:http: //bootstrap.braincrafted.com/javascript#modals
但我无法找到一种方法在symfony中轻松应用它...
你可以帮帮我吗 ?
谢谢
我在Java项目中使用Apache commons fileupload 1.4库。我有一个具有经典形式的html部分,带有文件输入和一些隐藏字段。
我仅使用Firefox> = 52上载> 500ko左右的文件时遇到问题
它与Chrome或Internet Explorer中的10mo文件兼容。但是,使用Firefox,在提交表单后等待了几分钟,我超时了。
经过一些调试后,我看到造成超时的代码是:
List<FileItem> items = (new ServletFileUpload(new DiskFileItemFactory())).parseRequest(request);
Run Code Online (Sandbox Code Playgroud)
等待原因的部分是“ parseRequest”。
我尝试使用IntelliJ中的调试器调试请求的内容,但是无法以原始格式复制此请求对象的整个内容值。
在以下情况下可以正常工作:-Firefox:版本<= 52或文件大小<500ko(大约不是很精确)-Internet Explorer-Chrome
没有文件大小限制,这似乎取决于请求的大小,因为解析请求部分要花费太多时间...
在两种情况下,我都收到带有Firefox扩展名的HTTP请求。一个生成的文件上传失败的3mo文件(请求文件很大,是上传文件大小的3倍):https : //code.empreintesduweb.com/13561.html
一个生成的上传文件200ko有效(请求文件很小):https ://code.empreintesduweb.com/13560.html
实际上,主要区别在于在Chrome或IE中,我在请求标头中没有上传文件的原始内容:
具有以下部分的对象:obj stream .... endstream endobj
仅在Firefox中显示...
我刚开始使用fosuserbundle,今天我激活确认注册链接.它工作得很好,但如果用户第二次点击电子邮件中的确认链接,他会收到该错误:
具有确认令牌"3hiqollkisg0s4ck4w8g0gw4soc0wwoo8ko084o4ww4sss8o4"的用户不存在404 Not Found - NotFoundHttpException
我认为这个错误应该由捆绑处理,不是吗?
谢谢
我几天前在这里发布了一个问题: FOSUserBundle:嵌入登录表单并选择其模板
但它非常复杂,我认为在这个问题背后,可能存在一个简单的路由问题,所以我认为创建一个并行主题,删除我所做的所有修改,并从全新的安装开始是一个好主意.
所以,我安装了FOSUserBundle,我有一个WelcomeBundle,它包含了我网站的几个页面,我还创建了一个新的UserBundle,它只包含FOSUserBundle的用户实体,没有别的(没有任何覆盖).
在我的rsWelcomeBundle中,在我的index.html.twig中,我把这个简单的代码:
{% extends "rsWelcomeBundle::layout.html.twig" %}
{% block title "Page d'accueil" %}
{% block body %}
<div class="span6">
<div class="well">
<h2>Présentation du jeu</h2>
<a href="{{ path('rsWelcomeBundle_homepage_inscription') }}" class="btn ">Je m'inscris !</a></p>
</div>
</div>
<div class="span6">
<div class="well">
{% render "FOSUserBundle:Security:login" %}
</div>
</div>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
我总是有这个错误:
在rsWelcomeBundle:Homepage:index.html.twig第1行的模板渲染过程中抛出异常("找不到"GET Security:login""的路径).
如果我将这一行放在渲染部分,它就能正常工作.
{% render(controller("FOSUserBundle:Security:login")) %}
Run Code Online (Sandbox Code Playgroud)
但为什么 ??在文档中我从未看到我们要使用"渲染(控制器".为什么我不能直接使用:渲染"FOSUserBundle:安全:登录"?
在app/config/routing.yml我有:
tuto_welcome:
resource: "@rsWelcomeBundle/Resources/config/routing.yml"
prefix: /
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
fos_user_profile:
resource: "@FOSUserBundle/Resources/config/routing/profile.xml"
prefix: /profile
fos_user_register:
resource: "@FOSUserBundle/Resources/config/routing/registration.xml"
prefix: /register
fos_user_resetting:
resource: "@FOSUserBundle/Resources/config/routing/resetting.xml" …Run Code Online (Sandbox Code Playgroud) 我有一个小问题.我希望无论用户在我的网站上,如果他有"ROLE_DEGRADE"角色,他都会被重定向到特定页面.
我怎么能这样做,我必须使用防火墙?我不想将用户重定向到表单登录,只是简单的页面.我希望在我的网站上无处不在,而不是在所有控制器中随处可见"if role degrade ..."
谢谢你的帮助 ;)
我想做那样的事情:

现在,我正在使用保证金,但我确信有一些"干净"的方法可以做到这一点......:http: //jsfiddle.net/vXMMA/445/
<ul class="media-grid">
<li>
<a href="#">
<img class="thumbnail" src="http://placehold.it/140x90" alt=""/>
</a>
<a href="#" class="btn" style="margin-left:-23px;margin-top:67px;">+</a>
</li>
<li>
<a href="#">
<img class="thumbnail" src="http://placehold.it/140x90" alt=""/>
</a>
<a href="#" class="btn" style="margin-left:-23px;margin-top:67px;">+</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud) 我在bootstrap文档中创建了一个Form builder.php来构建我的登录表单和我的注册表单,如下所示:http: //bootstrap.braincrafted.com/base-css#forms但接下来我发现了FOSUserBundle,我认为它可能是使用它是一个好主意.问题是:我不能简单地重用之前创建的表单.
我想使用bootstrap来自定义FOSUser模板.特别是对于提交按钮,我想添加所有这些:class ="btn primary large"
我创建了一个覆盖FOSUserBundle的UserBundle.
我在FOSUserBundle中自定义了login.html.twig,将login.html.twig放在UserBundle/Ressources/Views/Security/login.html.twig中
这很简单,因为登录模板只有一个文件.
但是我如何才能为注册部分做这件事呢?
有两个文件:register.html.twig和register_content.html.twig
所以我在UserBundle中创建了一个Registration文件夹,然后我输入了这两个文件.
但是,我用什么来改变提交按钮的样式?
在register.html.twig我让:
{% extends "UserBundle::layout.html.twig" %}
{% block fos_user_content %}
{% include "UserBundle:Registration:register_content.html.twig" %}
{% endblock fos_user_content %}
Run Code Online (Sandbox Code Playgroud)
在register_content.html.twig中:
<form action="{{ path('fos_user_registration_register') }}" {{ form_enctype(form) }} method="POST" class="fos_user_registration_register">
{{ form_widget(form) }}
<div>
<input class="btn primary large" type="submit" value="{{ 'registration.submit'|trans({}, 'FOSUserBundle') }}" />
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
您是否认为使用该捆绑包是一个很好的解决方案? https://github.com/CCETC/FOSUserBundle
它直接将所有表单与bootstrap样式集成在一起.
但是如果有一天我想在注册表格中添加一个字段(例如性别),我可以在这个包中做,就像使用原始的FOSUserBundle一样吗?
知道我想以寄存器形式添加一些自定义字段,并使用bootstrap自定义表单,我想知道使用FOSUserBundle是不是一个好主意,或者如果最好建立一个我自己的全新包来管理我的用户网站.