/** * initialize * * Initialize the plugin. Call in Doctrine_Template setTableDefinition() in order to initiate a generator in a template * SEE: Doctrine_Template_I18n for an example * * @param Doctrine_Table $table * @return void */ public function initialize(Doctrine_Table $table) { if ($this->_initialized) { return false; } $this->_initialized = true; $this->initOptions(); $table->addGenerator($this, get_class($this)); $this->_options['table'] = $table; $this->_options['className'] = str_replace('%CLASS%', $this->_options['table']->getComponentName(), $this->_options['className']); // check that class doesn't exist (otherwise we cannot create it) if ($this->_options['generateFiles'] === false && class_exists($this->_options['className'], false)) { return false; } $this->buildTable(); $fk = $this->buildForeignKeys($this->_options['table']); $this->_table->setColumns($fk); $this->buildRelation(); $this->setTableDefinition(); $this->setUp(); $definition = array(); $definition['columns'] = $this->_table->getColumns(); $definition['tableName'] = $this->_table->getTableName(); $definition['actAs'] = $this->_table->getTemplates(); $this->generateClass($definition); $this->buildChildDefinitions(); $this->_table->initIdentifier(); }
/** * Initialize the plugin. Call in Doctrine_Template setTableDefinition() in order to initiate a generator in a template * * @see Doctrine_Template_I18n * @param Doctrine_Table $table * @return void */ public function initialize(Doctrine_Table $table) { if ($this->_initialized) { return false; } $this->_initialized = true; $this->initOptions(); $table->addGenerator($this, get_class($this)); $this->_options['table'] = $table; $ownerClassName = $this->_options['table']->getComponentName(); $className = $this->_options['className']; $this->_options['className'] = str_replace('%CLASS%', $ownerClassName, $className); if (isset($this->_options['tableName'])) { $ownerTableName = $this->_options['table']->getTableName(); $tableName = $this->_options['tableName']; $this->_options['tableName'] = str_replace('%TABLE%', $ownerTableName, $tableName); } // check that class doesn't exist (otherwise we cannot create it) if ($this->_options['generateFiles'] === false && class_exists($this->_options['className'])) { $this->_table = Doctrine_Core::getTable($this->_options['className']); return false; } $this->buildTable(); $fk = $this->buildForeignKeys($this->_options['table']); $this->_table->setColumns($fk); $this->buildRelation(); $this->setTableDefinition(); $this->setUp(); $this->generateClassFromTable($this->_table); $this->buildChildDefinitions(); $this->_table->initIdentifier(); }
/** * Initialize the plugin. Call in Doctrine_Template setTableDefinition() in order to initiate a generator in a template * * @see Doctrine_Template_I18n * @param Doctrine_Table $table * @return void */ public function initialize(Doctrine_Table $table) { if ($this->_initialized) { return false; } $this->_initialized = true; $this->initOptions(); $table->addGenerator($this, get_class($this)); $this->_options['table'] = $table; $ownerClassName = $this->_options['table']->getComponentName(); $className = $this->_options['className']; $this->_options['className'] = str_replace('%CLASS%', $ownerClassName, $className); if (isset($this->_options['tableName'])) { $ownerTableName = $this->_options['table']->getTableName(); $tableName = $this->_options['tableName']; $this->_options['tableName'] = str_replace('%TABLE%', $ownerTableName, $tableName); } $currentTableHash = spl_object_hash($table); if (!empty(self::$initializedTables[$currentTableHash])) { return null; } self::$initializedTables[$currentTableHash] = true; $this->buildTable(); $fk = $this->buildForeignKeys($this->_options['table']); $this->_table->setColumns($fk); $this->buildRelation(); $this->setTableDefinition(); $this->setUp(); if ($this->_options['generateFiles'] === true || !class_exists($this->_options['className'])) { $this->generateClassFromTable($this->_table); } $this->buildChildDefinitions(); $this->_table->initIdentifier(); }