Add custom UllUser columns

Define the new columns in the model

  • /config/doctrine/schema.yml
    • Only define you additional columns here. They are added to the default ones from ullCorePlugin
    • Example:
      • UllUser:
          columns:
            commercial_register_number:
              type: string(32)
            sales_tax_indentification_number:
              type: string(32)

Create migration to adapt the actual database layout

(Add columns, constraints, etc)

  • php symfony doctrine:generate-migration add_company_data
    • The migration file is created in /lib/migrations/doctrine/ and called something like 1304062858_add_company_data.php
  • Move the migration file to /lib/migrations/custom/ because it is a custom migration of yours
  • Edit the migration file and add your database changes.

    All possible command can be found here: http://www.doctrine-project.org/projects/orm/1.2/docs/manual/migrations/en#writing-migration-classes
    • Example:

       
    <?php
    
    class AddCompanyData extends Doctrine_Migration_Base
    {
      // List of user tables (one versionable table for each entity type)
      protected $tableNames = array(
        'ull_entity',
        'ull_entity_version',
        'ull_user_version',
        'ull_group_version',
        'ull_ventory_origin_dummy_user_version',
        'ull_ventory_status_dummy_user_version',
        'ull_clone_user_version'
      );  
      
      public function up()
      {
        // Add columns for each entity type table
        foreach ($this->tableNames as $tableName)
        {    
          $this->addColumn($tableName, 'commercial_register_number', 'string', 32);
          $this->addColumn($tableName, 'sales_tax_indentification_number', 'string', 32);
        }
      }
    
      public function down()
      {
        throw new Doctrine_Migration_IrreversibleMigrationException('This migration can not be undone.');
      }
    }
    

Adapt columnsConfig

ColumnConfigs provide additional information about database columns like which widgets to use, label and help texts

Your custom columnsConfig for the user fields can be found at apps/frontend/lib/generator/columnConfigCollection/UllUserColumnConfigCollection.class.php

Example:

<?php 

class UllUserColumnConfigCollection extends BaseUllUserColumnConfigCollection
{
  
  /**
   * Applies model specific custom column configuration
   * 
   */
  protected function applyCustomSettings()
  {
    parent::applyCustomSettings();
    
    # Disable some ullCore columns we don't need 
    $this->disable(array(
      'entry_date',
      'deactivation_date',
      'separation_date'
    ));
    
    # Configure custom columns
    $this['commercial_register_number']
      ->setLabel(__('Commercial reg. no.', null, 'custom'))
    ;
    
    $this['sales_tax_indentification_number']
      ->setLabel(__('Tax no.', null, 'custom'))
    ;
}

 

The e.g. german translations are added to apps/frontend/i18n/custom.de.xml

Example:

<?xml version="1.0"?>
<xliff version="1.0">
  <file orginal="global" source-language="en_US" datatype="plaintext" date="2007-12-13T14:54:05Z">
    <body>

<trans-unit id="1">
<source>Commercial reg. no.</source>
<target>Firmenbuchnummer</target>
</trans-unit>

<trans-unit id="2">
<source>Tax no.</source>
<target>USt. Id</target>
</trans-unit>

    </body>
  </file>
</xliff>

Rebuild the model and execute the migration

  • php symfony doctrine:build --model --forms --filters
  • php symfony ullright:custom-migrate