posts under symfony tag

Using a custom config file with symfony 1.2/1.4

If you want to store some parameters in your own configuration file (other than /config/app.yml for different reasons) with your very own prefix, you just have to create a /config/config_handlers.yml file :

config/my_config_file.yml:
  class:    sfDefineEnvironmentConfigHandler
  param:
    prefix: myprefix_

Now, symfony will process your config file with sfDefineEnvironmentConfigHandler and add your parameters to global settings values with myprefix_ prefix. Don't forget to tell symfony to include your file, in your application configuration file (/app/myapp/config/myappConfiguration.class.php) :

<?php

class myappConfiguration extends sfApplicationConfiguration
{
  /* ... */

  public function initialize()
  {
    require_once($this->getConfigCache()->checkConfig('config/my_config_file.yml'));
  }
}

You can have more information about symfony internals by checking the /cache/myapp/myenv/config/config_settings.yml.php file.

Some examples of Propel Criteria syntax

To start, we have a Criteria, with a Criterion for each condition :

$criteria = new Criteria();

$a = $criteria->getNewCriterion( /* A */ );
$b = $criteria->getNewCriterion( /* B */ );
$c = $criteria->getNewCriterion( /* C */ );
...

A AND B

$a->addAnd($b);

A AND (B OR C)

$b->addOr($c);
$a->addAnd($b);

(A AND B) OR (C AND D)

$a->addAnd($b);
$c->addAnd($d);
$a->addOr($c);

A AND (B OR (C AND D))

$c->addAnd($d);
$b->addOr($c);
$a->addAnd($b);

And, don't forget to link your main Criteria with your first condition ($a in these examples) :

$criteria->add($a);

You can generate more complicated cases with the Propel Criteria Builder.

If you use Propel 1.5 (or newer), you can avoid using criterias, check Propel Documantation to learn more. Get more advanced examples on Propel 1.5 lead developer's blog.

Change symfony default culture in admin-generator

By default, symfony admin is in english, but you can easily change the default language for the generated pages (without creating a specific dictionary). Just enable the i18n and set up your culture in your apps/backend/config/settings.yml :

all:
  .settings:
    i18n:                   on
    default_culture:        fr

Then, retrieve your ORM plugin's dictionary and put it into your application :

mkdir -p apps/backend/i18n/en/
cp lib/vendor/symfony/lib/plugins/sfPropelPlugin/i18n/sf_admin.fr.xml apps/backend/i18n/en/
./symfony plugin:publish-assets
./symfony cache:clear