Sunday, July 24, 2011

How to add i18n conditionally to doctrine schema

In schema.yml file add following code.

#../schema.yml
TableName:
  actAs:
<?php if (sfConfig::get(condition_variable', false)): ?> #example condition: app_use_i18n
    I18n:                                             #condition variables stored in app.yml
      fields:         [i18n_column_name]
<?php endif; ?>
#other actAs config...
#other configs ...
  columns:
    i18n_column_name: ...
    .... #other columns

Main idea is you can use php code in yml config file.