List of all Symfony2 Exceptions (symfony)

Source: http:\\\list-of-all-symfony2-exceptions-symfony.html

I regularly want a list of all the symfony2 exceptions to see if there are any that I can reuse, instead of creating my own.
Unfortunately, I have found no way to find a list of all the exceptions, so I took it upon myself to create an Exception list.
The list below shows all the exceptions with their full namespace as of Symfony 2.1.2


Since most symfony2 installations also include doctrine2, below is a list of all the Doctrine 2 Exceptions.


Symfony2 Sonata Admin sonata_type_collection inline editing hidden field

Here I've found the answer to my simple question: How to inline edit a dependend one to many field without showing the parent as select box.

Here is a brief answer: Use prePersist / preUpdate methods in ParentAdmin.php class.
// in the ParentAdmin class

public function prePersist($promotion)
foreach ($promotion->getRules() as $rule) {

public function preUpdate($promotion)
foreach ($promotion->getRules() as $rule) {

Yes indeed, the sonata admin class allows for prePersist and preUpdate calls that allows us to set the promotion for the rule before persisting. Of course don’t forget to declare your admin classes as services in your configs. Other than that, I hope that this helps somebody out there.

Symfony2: 3d to 2d. Display tree navigation menu in a select dropdown in SonataAdmin

Keys: SonataAdmin, Gedmo Tree nested type, Select Dropdown, use EntityManager in configureFormFields Admin page

I've lost 2 days bumping my head on a simple task - I needed to display simple dropdown combo box that will display Nested Gedmo Tree in a Sonata Admin form.

I've installed and get working - It's simple implementation of Gedmo\Tree type="nested" - exactly what I need for a simple menu navigation + it has ready Sonataadmin page to edit nodes.
The nice thing about this exact bundle is that it uses @Translatable, @Blameable, @Timestampable and this is all what I need - to be able to translate my menu, to see when and who updated the records.

After installing it I've noticed that 'path' is missing/empty event getting undefined notice.
I've dug around and found that I have to implement getpath() myself.
I did and created custom repository. I wasn't able to use childrenHierarchy directly in the Entity.

namespace Room13\NavigationBundle\Entity\Repository;
class NavigationNodeRepository extends \Gedmo\Tree\Entity\Repository\NestedTreeRepository{
function getFlatNodes($startNode = null, $options = null) {
if (is_null($options)) {
$options = array(
'decorate' => false,
'rootOpen' => '
    'rootClose' => '
'childOpen' => '
  • ',
    'childClose' => '
  • ',
    'nodeDecorator' => function($node) {
    return ''.$node['title'].'';
    $htmlTree = $this->childrenHierarchy(
    $startNode, / starting from root nodes /
    false, / load all children, not only direct /
    return $this->ToFlat($htmlTree, ' » ');

    function ToFlat($node, $sep = ' > ', $path = '') {
    $els = array();
    foreach ($node as $id => $opts) {
    $els[$opts['id']] = $path . $opts['title'];
    if (isset($opts['__children']) && is_array($opts['__children']) && sizeof($opts['__children'])) {
    $r = $this->ToFlat($opts['__children'], $sep, ($path . $opts['title'] . $sep));
    foreach($r as $id => $title) {
    $els[$id] = $title;
    return $els;

    After implementing it I've had to find a way so I can display result of this for root node in a flat select box in SonataAdminPage so user can select from a dropdown where the content should show.
    Well.. it turned out that entity type is impossible to be used because it can't call the method from CustomRepo, just the native Entity methods.
    I ended up using simple 'select' type like this:

    $em = $this->modelManager->getEntityManager('Room13NavigationBundle:NavigationNode');
    $tree = $em->getRepository('Room13NavigationBundle:NavigationNode')->getFlatNodes();
    ->add('menu', 'choice', array(
    'label' => 'Place in menu',
    'empty_value' => 'Select menu',
    'choices' => $tree,

    DomPDF with UNICODE UTF-8 Support! At last!

    A colleague of mine spent some time and was able to make DomPDF library to run with almost ALL UTF-8 alphabets displayed.
    Until now I was using TCPDF. It supports UTF-8 from a lot of time, but has crappy way of generating documents - VERY simple HTML support and A LOT of calls to internal methods so you can documents looks like the HTML page.

    As far he explained to me the problem was generating proper fonts.

    DomPDF with UTF-8 Support

    UPDATE: Because DomPDF is "the memory MONSTER" (30pages table eat up about 1.5Gigs! GEE!!!) we are now using wkhtmltopdf. It's AMAZINGLY fast and keeps the memory footprint low (same page that took about 2-3min and 1.5Gigs ram for dompdf wkthml uses about 100-200mb and 20-40sec.)
    The funny thing is that it's webkit based and renders PERFECTLY everything on each page I've tested with.
    It's simply SWEET!

    Roundcube with plugins support!!! WOW! Writing a plugin - display custom template has bogus docs.

    Today I've noticed Roundcube has released a new version that finally has plugins support!

    As expected in there is a change password plugin (with drivers supports) and some other that are pretty cool!
    A list of plugins here:

    Of course I've had some custom patching for my hosting users and now it's not working.
    I've configured my change password plugin (which was the main showstopper for not upgrating to new roundcube) and the the little tiny hack for domain notification left.
    I've decided to write a plugin that will do the job for me, so I can easily upgade after that.

    Writing plugin isn't that hard at all. Here you can read more:

    also you can read plugins directory for more.

    While creating my plugin I hit a problem and I've lost about 40 minutes searching for description and resolution.
    The Resolutions was 5mins reading the class for temapltes but I thought I was wrong - no this is a mis-explanation in docs.
    When you want to create a custom template you mkdir skins/default/templates and create/copy-modify html in it (I've copied login.html template).
    Well all was fine while I've tried to show it.
    Documentation is wrong.
    When you call:


    you must actually call:

    so the tpl class can understand this is a plugin and show your template and not search for default tpl.

    Hope that helps someone.
    Going to change/report this in docs now.
    Oh. Symptoms are:

    [12.Nov.2009 17:57:27 +0200]: PHP Error: Error loading template for logininfo in /var/www/roundcube/program/include/rcube_template.php on line 372 (GET /)

    in your error log.

    Serendipity and dpSyntaxHighlighter plugin with bash support.

    I wanted a syntax highlighter for the previous post.
    I've installed dpsyntaxhighlighter from serendipity plugins list. I wanted a JS code highlighter - not a php one (like GeSHi), so I've chosen this one. (it uses google syntaxhighlighter)
    I've noticed that this nice lib don't have a bash syntax support which I needed now.
    In the wiki of the project I've found this link to a script a guy wrote for bash syntax.
    I've placed the js file in ROOT/plugins/serendipity_event_dpsyntaxhighlighter/dp.SyntaxHighlighter/Scripts/ and expected it to work.
    No, it didn't.

    It turned out that you have to add each language highliter js script file in ROOT/serendipity_event_dpsyntaxhighlighter.php

                    case 'frontend_header':
                        echo '    <link rel="stylesheet" type="text/css" href="' . $pluginDir.  '/SyntaxHighlighter.css" />' . "\n";
                        return true;
                    case 'frontend_footer':

    there is a list with all js files.
    Simply add the new language (on both frontend_footer and backend_preview cases) and there you go!

    How to highlight your text?
    It is used very simple.
    You add code like this in your post:
        ... some code here ...

    and you have nice formatted code.
    More usage tips here.

    That's all folks.
    Hope that helps you.

    PureEdit (rocking ultra light CMS system) and utf8 / unicode support. Pagination.

    I've found PureEdit today and decided to use it as my CMS backend for some of my simpler projects!
    This is a GREAT and FAST way to setup a backend content editing.
    Take a look at the videos on their site! I was fascinated!

    I've had old database filled with correct Unicode (UTF-8) data (in Cyrillic).
    I've installed and loaded pe-admin, updated my db accortind to PureEdit specs, added some fields type like (status 1||0).
    When opened pe-admin I've come up with few Unicode problems.
    (as described here: )
    I've solved my problem exactly by putting: mysql_query('SET NAMES UTF8');

    I've had to modify the connect function in pe-admin/databases/mysql.db.php like this:
    function connect($host, $username, $password, $database)
    $dbh = mysql_connect($host, $username, $password);
    mysql_query('SET NAMES UTF8');
    mysql_select_db($database, $dbh);
    (it used to connect/select db in one line, but you MUST make SET NAMES BEFORE selecting db!)

    The second problem that I've had as with utf8 again.
    Utils class is not UTF-8 ready.
    I've had to add to set utf8 encoding
    public function __construct() {
    and replace all str functions with mb_str.

    After that I wanted to have pagination.
    Here it's described how to set it up.

    Now I have to setup host type filed (that will be automatically filled with $_SERVER['REMOTE_ADDR']) and some othe fancy stuff, but in about 40 minutes I've setup a GREAT and easy to use backend posting solution for my website!

    Thanks PureEdit :-)

    The PureEdit code is not from the greatest ones but when it works and if .htaccess protected - it simply works! :-)

    php mail function overloading or why we shouldn't use mb_send_mail as sending mail function.

    As a programmer I have a nice cool helpers - classes I've written to help me do my daily work.
    Such class is my Mailer class which I use almost daily.
    It has all kind of fancy options and can do all kind of stuff - from sending simple mail to just setting an array with files which should be attached in the mail.
    It used to work very good until today.
    I was very surprised when I saw a broken email coming from it.
    I've investigated a few minutes what has changed and I've found that the problem
    I've set
    mbstring.func_overload = 7
    according to the description in file:
    ; For example, 7 for overload everything.
    ; 0: No overload
    ; 1: Overload mail() function
    ; 2: Overload str*() functions
    ; 4: Overload ereg*() functions
    it turned out that when set to 7 instead of using mail() function, php starts using mb_send_mail.
    mb_send_mail works only with base64 emails.
    It automatically encodes the body and subject (but not the sender wtf?) and it breaks mail ugly!
    If you manually add/set headers do not put \r\n at the very end of the string, mb_send_mail adds two headers after yours:
    Mime-Version: 1.0
    Content-Transfer-Encoding: BASE64
    and if you put one new line(\r\n) to separate the headers from body then you get the email totally messed up, because the base64 transfer won't apply and you'll get encoded string as plain text or html or whatever content-type you set previously.
    After I've lost another 20 minutes figuring out this, I've finally achieved receiving my email as it should be... well... almost.
    When the mail contained only ASCII symbols everything was ok, but when I tried to send email in utf8 Bulgarian... omfg?!
    The encoding was broke and for some reason the UTF8 symbols looked like you have page in UTF8 but your browser is set to WINDOWS-1251....
    WTF?!!! I've read few posts that said they never got it successfully working fine with mb_send_mail.
    It took me some time to find something very useful - there is an undocumented php function: mb_orig_mail (
    When you use overloaded function you can fall back to the standart mail function by calling this one.
    So here is what I did to solve my problem - I use exactly the same class that used to work until the overload get active.
    But when it comes to sending I simply check if the mail function is overloaded and if yes, then call the mb_orig_mail.
    Here is the actual code:

    $mailFunct = 'mail';
    if (ini_get('mbstring.func_overload') == 1 || ini_get('mbstring.func_overload') > 4) {
    $mailFunct = 'mb_orig_mail';
    if(! $mailFunct($tostr, $subject, $tmpBody, $tmpHeaders) ) {
    echo 'sent';
    } else {
    echo 'error sending';

    It's as simple as that.
    Hope that helps to anyone.
    Comments are welcome.