symfony-2.2

Check if ArrayCollection is empty

眉间皱痕 提交于 2019-12-02 23:43:46
I have an Entity Order which hold Suppliers in an Arraycollection. In my controller i want to check if this arraycollection is empty: $suppliers = $order->getSuppliers(); I tried: if(!($suppliers)) {} if(empty($suppliers)) {} Any ideas? Ken Hannel Doctrine ArrayCollection has a method isEmpty that will do what you are looking for. if ($suppliers->isEmpty()) { } Take a look at the documentation for it here You can also use the count() PHP function: if (count($suppliers) < 1) { } 来源: https://stackoverflow.com/questions/17643047/check-if-arraycollection-is-empty

use PHPExcel with composer and Symfony2.2

我们两清 提交于 2019-11-30 22:54:10
I found this on SO: How to use PHPExcel correctly with Symfony 2 This works, but I want to use it with composer. The first part I already solved: to load PHPExcel for a special tag (the last stable release) I don't find out how to fetch a tag with this syntax: "repositories": [ { "type": "vcs", "url": "https://github.com/umpirsky/SyliusAssortmentBundle" } ] So I use the Package notation: I found out, the reference should be the tag name on github. And the version cannot be the same value (PHPExcel_1.7.8). Seems that alphabetical characters are not allowed, so it's only the version as a number

Logging swiftmailer send() activity in symfony2

[亡魂溺海] 提交于 2019-11-30 17:39:28
Im using swiftmailer for sending mails from my symfony2.2 project. Is there a way to log globally all email info and send results? It would be great if mailer send() method have trigger somę event, but I can't see it does. This question was answered already, This solution is better for Symfony 4 combined with Monolog. It is based on umpirsky his Answer. But without the overhead of a custom file logger. Note: Logs will be placed in ./var/logs/... App\Util\MailLoggerUtil.php <?php namespace App\Util; use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; use Swift_Events_SendEvent; use Swift_Events

What is the Symfony firewall doing that takes so long?

不羁岁月 提交于 2019-11-30 06:34:03
问题 My Symfony page isn't too slow (it loads in about 400 ms) but considering the fact that it's just a simple hello world page with basic authentication, it should be loading in less than 100 ms. When I enter the profiler, I see this: Notice it just says "Firewall" for 250 ms. I thought the firewall was just responsible for keeping users out of certain areas of the page - I can't imagine that taking any longer than a few milliseconds plus the time it takes to fetch the user information from the

symfony2 how to upload file without doctrine?

烈酒焚心 提交于 2019-11-30 02:31:58
问题 Is it possible to upload files in symfony2 WITHOUT using doctrine? With doctrine, its example is given here: http://symfony.com/doc/2.2/cookbook/doctrine/file_uploads.html Is there a simple way to upload files, like in core PHP we have move_uploaded_file() function with which we can move the uploaded to file after the form is submitted. For now when I submit the form in symfony this is what I get in 'files' section of request array (Symfony\Component\HttpFoundation\Request) [files] => Symfony

Logging swiftmailer send() activity in symfony2

浪子不回头ぞ 提交于 2019-11-29 17:05:22
问题 Im using swiftmailer for sending mails from my symfony2.2 project. Is there a way to log globally all email info and send results? It would be great if mailer send() method have trigger somę event, but I can't see it does. 回答1: This question was answered already, This solution is better for Symfony 4 combined with Monolog. It is based on umpirsky his Answer. But without the overhead of a custom file logger. Note: Logs will be placed in ./var/logs/... App\Util\MailLoggerUtil.php <?php

What is the Symfony firewall doing that takes so long?

我与影子孤独终老i 提交于 2019-11-28 20:01:38
My Symfony page isn't too slow (it loads in about 400 ms) but considering the fact that it's just a simple hello world page with basic authentication, it should be loading in less than 100 ms. When I enter the profiler, I see this: Notice it just says "Firewall" for 250 ms. I thought the firewall was just responsible for keeping users out of certain areas of the page - I can't imagine that taking any longer than a few milliseconds plus the time it takes to fetch the user information from the database (which in this case is 61 ms). Could somebody explain what the firewall actually does? If you

SonataAdminBundle : display non crud (statistics)

偶尔善良 提交于 2019-11-28 03:20:55
I'm using sonata admin bundle to generate my backend, I'm so happy with it that I would like to use my backend to display statistics as well. I guess I can do that by tweaking bundle's views, "standard_layout.html.twig" maybe. Problem is, I can't find examples or even people speaking about it, so I'm wondering, is that possible ? Aren't people speaking about it because it's too simple ? Did you do it ? I really would like to have a single backend, so pls enlighten me ! Thank you, copndz Yes, it`s possible. It can be done with Sonata Block or using your own controller. If you use your

How to insert a Controller in Twig with “render” in Symfony 2.2?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 19:00:44
I'm upgrading my project from Symfony 2.0.22 to 2.2.0 and review somes changes, but i'm blocked on this : I would like to render (like in Sf 2.0.X) a header with their controller and the "render" twig method don't work for me. Their is the error : An exception has been thrown during the rendering of a template ("No route found for "GET Index:header"") in "OSSiteBundle:Index:index.html.twig". Here is the actual render method : {# src/OS/SiteBundle/Resources/views/layout.html.twig #} ... {% render "OSSiteBundle:Index:header" with {'thisid' : block('thisid'), ... } %} I tried : {{ render(

Build a form having a checkbox for each entity in a doctrine collection

感情迁移 提交于 2019-11-27 08:06:40
I'm displaying an html table for a filtered collection of entities and I want to display a checkbox in each row as part of a form which will add the selected entities to a session var. I'm thinking that each checkbox should have the entity id as its value and I'll get an array of ids from the form field data (ok, so the value ought to be an indirect ref to the entity, but for the sake of simplicity). I've tried creating a form Type with a single entity type field, mapped to the id property of the entity and embedded into another form Type which has a collection type field. class