Search code examples
phpsymfony1doctrinedoctrine-1.2symfony-1.2

Universally extending doctrine_table in symfony project


I have a symfony project (1.2). What I would like to do is ensure that when symfony build happens, instead of creating tables that extend doctrine_table they extend custom_table .

This way I can make ALL the tables I use have additional functionality without having to modify doctrine_table.


Solution

  • Yes you can, as follows (in Symfony 1.4 at least, I assume the same is true for 1.2):

    // config/ProjectConfiguration.class.php
    
    class ProjectConfiguration extends sfProjectConfiguration
    {
      public function configureDoctrine(Doctrine_Manager $manager)
      {
        $manager->setAttribute(Doctrine_Core::ATTR_TABLE_CLASS, 'yourDoctrineTable');
      }
    }
    

    And then define class yourDoctrineTable to extend Doctrine_Table.

    All newly generated *Table classes will now extend yourDoctrineTable instead of Doctrine_Table.

    See: http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/configuration.html#configure-table-class