$className = get_class($tpl);
$this->_templates[$className] = $tpl;
- $tpl->setTable($this);
- $tpl->setUp();
- $tpl->setTableDefinition();
+ $tpl->setTableDefinition($this);
}
public function getGenerators()
<?php
-abstract class IPF_ORM_Template extends IPF_ORM_Record_Abstract
+abstract class IPF_ORM_Template
{
protected $_invoker;
- public function setTable(IPF_ORM_Table $table)
- {
- $this->_table = $table;
- }
-
- public function getTable()
- {
- return $this->_table;
- }
-
public function setInvoker(IPF_ORM_Record $invoker)
{
$this->_invoker = $invoker;
return $this->_invoker;
}
- public function get($name)
- {
- throw new IPF_ORM_Exception("Templates doesn't support accessors.");
- }
-
- public function set($name, $value)
- {
- throw new IPF_ORM_Exception("Templates doesn't support accessors.");
- }
-
- public function setUp()
- {
- }
-
- public function setTableDefinition()
- {
- }
+ abstract public function setTableDefinition(IPF_ORM_Table $table)
}
return $this->columnName;
}
- public function setTableDefinition()
+ public function setTableDefinition(IPF_ORM_Table $table)
{
- $table = $this->getTable();
$table->setColumn($this->columnName, 'integer', null, array('exclude' => $this->exclude));
$table->addIndex($table->getOption('tableName') . '_orderable_' . $this->columnName, array('fields' => array($this->columnName)));
$table->listeners['Orderable_'.$this->columnName] = new IPF_ORM_Template_Listener_Orderable($this->columnName, $this->prepend);
return $this->columnName;
}
- public function setTableDefinition()
+ public function setTableDefinition(IPF_ORM_Table $table)
{
- $this->getTable()->setColumn($this->columnName, 'integer', null, array(
+ $table->setColumn($this->columnName, 'integer', null, array(
'exclude' => $this->exclude,
'verbose' => $this->verbose,
));
'foreign' => 'id',
'onDelete' => 'CASCADE',
));
- $this->getTable()->listeners['Owned_'.$this->columnName] = new IPF_ORM_Template_Listener_Owned($this->columnName);
+ $table->listeners['Owned_'.$this->columnName] = new IPF_ORM_Template_Listener_Owned($this->columnName);
}
}
$this->_options = IPF_ORM_Utils::arrayDeepMerge($this->_options, $options);
}
- public function setTableDefinition()
+ public function setTableDefinition(IPF_ORM_Table $table)
{
- $table = $this->getTable();
-
$table->setColumn($this->_options['name'], $this->_options['type'], $this->_options['length'], $this->_options['options']);
if ($this->_options['unique'] == true && $this->_options['uniqueIndex'] == true && !empty($this->_options['fields'])) {
$this->_options = IPF_ORM_Utils::arrayDeepMerge($this->_options, $options);
}
- public function setTableDefinition()
+ public function setTableDefinition(IPF_ORM_Table $table)
{
if (!$this->_options['created']['disabled']) {
- $this->getTable()->setColumn($this->_options['created']['name'], $this->_options['created']['type'], null, $this->_options['created']['options']);
+ $table->setColumn($this->_options['created']['name'], $this->_options['created']['type'], null, $this->_options['created']['options']);
}
if (!$this->_options['updated']['disabled']) {
- $this->getTable()->setColumn($this->_options['updated']['name'], $this->_options['updated']['type'], null, $this->_options['updated']['options']);
+ $table->setColumn($this->_options['updated']['name'], $this->_options['updated']['type'], null, $this->_options['updated']['options']);
}
- $this->getTable()->listeners['Timestampable_'.print_r($this->_options, true)] = new IPF_ORM_Template_Listener_Timestampable($this->_options);
+ $table->listeners['Timestampable_'.print_r($this->_options, true)] = new IPF_ORM_Template_Listener_Timestampable($this->_options);
}
}