Symfony World blog is not maintained anymore. Check new sys.exit() programming blog.

Command line SVN editor

For those of you who still use Subversion as the software versioning system, setting SVN_EDITOR option will be important sooner or later.

SVN properties such as svn:externals or svn:ignore need to be set manually by the developer. To do this, run svn propedit or svn propset command (IDEs such as NetBeans have built-in SVN support which does the same stuff). If you're working in the command line, run one of the following commands:

export SVN_EDITOR=vim
or
export SVN_EDITOR=nano
or
export SVN_EDITOR=mcedit (or whatever)

This sets the SVN editor for the current user session. If you want to store this option permanently (to be set whenever you log in to your machine), create/edit the ~/.bash_profile file and put the same content there.

(symfony) multiple select default value

Scene from "Pulp Fiction" by Quentin Tarantino (1994)

Symfony framework provides an easy way of defining default form values (you can find related post here). But you may find problems to define default values of a multiple select (m:n relation) widget.

example

We are given two models:

  • Offer - representing a business offer which is available online
  • Localization - representing geographical region
Two models above share a typical m:n relation, represented by OfferLocalization model, which means that a specific Offer is available in chosen regions.

We want the offer form to display default values for the localizations_list widget (the OfferLocalization m:n relation). Let's say, we want Localizations 3 and 5 (by id) to be the default ones, just like in the picture below (showing regions in Poland):

Unfortunately, the following code will not work:

$this->setDefault('localizations_list', array(3,5));
in the configure() method since the BaseOfferForm class has the public function updateDefaultsFromObject() method implemented (generated by Doctrine):
  public function updateDefaultsFromObject()
  {
    parent::updateDefaultsFromObject();
    if (isset($this->widgetSchema['localizations_list']))
    {
      $this->setDefault('localizations_list', $this->object->Localizations->getPrimaryKeys());
    }
  }

solution

You can simply override this method in the OfferForm class:

  public function updateDefaultsFromObject()
  {
    parent::updateDefaultsFromObject();
    if ($this->isNew())
    {
      $this->setDefault('localizations_list', array(3,5));
    }
  }
and you're done!

excellent modelling tool: cacoo

Scene from the epic "Braveheart" by Mel Gibson (1995)

This time I want to present an excellent visual tool I've started using recently to improve my projects' documentation. It's the Cacoo online diagram editor, which is a professional flash tool.

The basic concept is very easy: you create graphic diagrams. You may structure them in folders and sheets (don't worry, each country should have its own translation already - I'm using Polish version):

There's a history of all changes done on each diagram:
Creating a diagram usually starts with creating your own, custom objects which represent something. You may use standard, predefined objects or import any image from the internet to combine new objects:
You may resize or change the angle of an object:
There are lots of predefined stencils to USE, including entire UML:
The interface is very intuitive - it took me only an hour to learn how to make the most out of cacoo.
There are dozens of easy tools you can use to make really good quality diagrams:
I won't try to list al those tools, I hope the screenshots I made speak for themselves (especially I like the drag n'drop stuff and moving objects across the diagram).
And the most comfortable and user-friendy thing is easy diagram update. If your IT project has changed and your documentatin is not up to date anymore - just log in, make a tiny change in the diagram and dump it again, replace the old diagram in the docs and you're done!

predefined objects to use

Just get a predefined stencil - just like a nice looking professor below:

This stencil is a group of smaller objects. You can choose some objects to be grouped to make moving easier. You can even resize a whole group of objects, including font size changes! And groups can consist of groups...

Anyway, a group member can still be edited separately:

There are really lots and lots of possibilities there. You can do whatever you can think of.
Finally, you can export your work to few file formats (I use ksnapshot - PNG file is enough for me).

try the demo version

The free plan gives you the possibility to hold 25 diagrams and it's enough to create useful diagrams, documenting your projects. I did - and I'm satisfied. Just take a look:

they didn't found me - I found them :)

Just to make it clear - I was not contacted by the Cacoo team and I was not asked if I could write a nice review (things like this happen - some time ago I was asked to review a pro-symfony IDE) ;-). So there was no bribe. One day I was just looking for a free UML-designing software (desktop app or online), because I was finding StarUML less and less satisfying. I found Cacoo and I didn't need to search any longer.

Try it.