One of my favorite mobile games (Dead Trigger) recently launched a challenge. You can find a code in there game and the first 10 to decrypt it will receive a T-shirt. Before I share the solution with anyone, I'd like to give you a chance to crack the code as well:
Soon after writing my previous blog, where I described a way to speed up the rendering of entity dropdowns, I received lots of feedback about better and nicer ways of doing this. All the suggestions where the same: use a custom form type and a datatransformer.
So I did for one entity, but I didn't feel like doing it for every entity. So I wrote a console command that allowed me to do this automatically (for one or all entities within a bundle).
After a short discussion with my boss, we agreed upon releasing the generator to the public and today the day is here.
One of the great features of Symfony 2 is the simplicity of rendering a form, even when you're using external entities. The only problem is that rendering a dropdown with 3662 entities is quite slow. In my case this took almost 2 seconds!
As some of you might have noticed by now, I am quite interested in the performance of my application. Since Symfony 2 has such a great profiler I was looking for a way to time my own code within the existing profiler and without writing to much code.
I just updated my symfony using Composer (which also updated my Doctrine etc). All of a sudden I now get the error 'Invalid parameter number: number of bound variables does not match number of tokens'.
I was able to fix this by making a change to /vendor/knplabs/knp-components/src/Knp/Component/Pager/Event/Subscriber/Paginate/Doctrine/ORM/QuerySubscriber.php
The updating/removing of ACE's is a bit harder than creating a new one. Therefore I just wanted to share a simple example. This code comes from a UserController where a User object can be assigned to one or multiple companies which (s)he should be able to manage.
In the Symfony 2 manual there's a small part about 'Impersonating a User', which talks about how you can switch between users if you are an administrator. After following the steps, as discussed in the manual, I wanted to find a way to see if the current logged in user was an impersonation, or the real user. After searching on Google for a bit, I found a couple of posts (1, 2, 3) that all described that the impersonated user should have the role 'ROLE_PREVIOUS_ADMIN'. But for some case my impersonated users did not have that role.