草庐IT

symfony-plugins

全部标签

php - Symfony2 : Using a repository in a command

我正在使用Symfony2(2.6),我想在名称为CRM:fetchEmails的命令中使用联系人实体的自定义存储库。我尝试了两种不同的方法来获取存储库:第一种方法:在我的命令文件的执行函数中$repository=$this->getContainer()->get('doctrine')->getEntityManager()->getRepository('CRMBundle:Contact');第二种方法:在我的命令文件的执行函数中$repository=$this->getContainer()->get('myrepository');在config.yml中myrepos

php - 如何在 2 个不同的表中提交表单值 symfony

我想提交一个表单并将值存储在2个不同的表中(在同一个数据库中)。这是表格:Naam{{form_widget(form.product)}}{{form_errors(form.product)}}Aantal{{form_widget(form.amount)}}{{form_errors(form.amount)}}这是表单生成器:$builder->add("amount","number",array("label"=>"Aantal"));$builder->add("product","text",array("attr"=>array("autocomplete"=>"o

php - Symfony/Swiftmailer 电子邮件未发送且无日志

我在尝试通过swiftmailer和mailjet作为SMTP服务器发送电子邮件时遇到问题。一切都曾经完美地工作,然后有些东西坏了。我正在尝试找出问题所在。文档似乎说swiftmailer在Debug模式下生成日志。http://symfony.com/doc/current/reference/configuration/swiftmailer.html#logging所以我在app.php中激活了Debug模式当我启动命令时,一切看起来都很完美sudo-uwww-dataphpapp/consoleswiftmailer:spool:send--env=prod[2015-11-2

php - Symfony2 - 使用 Controller Autowiring 服务

我能够使用Symfony2的新Autowiring功能将服务注入(inject)到服务中。但是,我无法将服务注入(inject)Controller。我没有做什么/做错了什么?这是我的services.yml文件:services:home_controller:class:AppBundle\Controller\HomeControllerautowire:true这是我的ServiceConsumerDemo:namespaceAppBundle\Services;classServiceConsumerDemo{private$serviceDemo;publicfunctio

php - Symfony/验证器 : Property validation in Callback

我正在尝试创建一个地址实体,其中包含根据给定国家/地区验证的邮政编码。要走的路显然是CallbackValidator。现在我有这段代码:useSLLH\IsoCodesValidator\Constraints\ZipCode;useSymfony\Component\Validator\Constraints\Callback;useSymfony\Component\Validator\Context\ExecutionContextInterface;classAddress{/***@Callback()*/publicfunctionvalidatePostalCode(E

php - Symfony Doctrine 存储库 (findOneBy) 结果不是对象

我尝试理解Doctrine方面的一些奇怪行为,例如:我有一个简单的表单,并在最后创建表单的请求中发送参数。/***DisplaysaformtocreateanewCommententity.**@Route("/saveComment/",name="comment_new")*@Method("POST")*@Template()*/publicfunctionnewAction(Request$request){$entity=newComment();$form=$this->createCreateForm($entity,$request);returnarray('ent

php - Symfony3 错误命名空间不包含任何映射实体

我尝试在Symfony3.0.1中生成getter和setter当我运行命令时phpbin/consoledoctrine:generate:entitiesVendorName/MyBundle/EntityName我有错误Namespace"VendorName\MyBundle\EntityName"doesnotcontainanymappedentities.错在哪里?Edit-1:首先生成YAML格式的实体Edit-2:我尝试为供应商包生成getter和setter我也尝试使用命令phpbin/consoledoctrine:generate:entitiesVendorN

php - Symfony 2文件上传设置默认文件

我的Symfony2应用程序中有一个表单,我要求用户上传文件。该字段不是必需的。目前我使用以下命令处理用户的文件:$file=$form['attachement']->getData();我的问题是,如果$file返回NULL,即用户不想上传任何文件,我该如何设置默认文件?谢谢。 最佳答案 首先,您必须从默认文件创建一个有效对象。为此,请使用Symfony\Component\HttpFoundation\File.用法:$file=newFile('path/of/your/default/file');然后,您必须在数据绑定(

php - 带有授权检查器的 Symfony kernel.response 监听器

我正在设置一个kernel.response事件,我想测试用户是否已登录。这是我的代码:services.ymlapp.kernel.modal_injection:class:App\UserBundle\EventListener\ModalListenertags:-{name:kernel.event_listener,event:kernel.response}arguments:-@security.authorization_checkerModalListener.phpsecurityChecker=$securityChecker;}publicfunctionon

php - Symfony 2.8 - 如何为任何 URL 配置防火墙?

每当我故意-尝试自定义错误页面-尝试访问未定义的路由时,服务器都会响应500错误。日志说:request.CRITICAL:Exceptionthrownwhenhandlinganexception(Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException:Thetokenstoragecontainsnoauthenticationtoken.OnepossiblereasonmaybethatthereisnofirewallconfiguredforthisURL.此