/**
  * Returns classpath to parent class.
  * @return     string
  */
 protected function getParentClassName()
 {
     $ancestorClassName = ClassTools::classname($this->getChild()->getAncestor());
     if ($this->getDatabase()->hasTableByPhpName($ancestorClassName)) {
         return $this->getNewStubQueryBuilder($this->getDatabase()->getTableByPhpName($ancestorClassName))->getClassname();
     } else {
         // find the inheritance for the parent class
         foreach ($this->getTable()->getChildrenColumn()->getChildren() as $child) {
             if ($child->getClassName() == $ancestorClassName) {
                 return $this->getNewStubQueryInheritanceBuilder($child)->getClassname();
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * Validates the current table to make sure that it won't
  * result in generated code that will not parse.
  *
  * This method may emit warnings for code which may cause problems
  * and will throw exceptions for errors that will definitely cause
  * problems.
  */
 protected function validateModel()
 {
     parent::validateModel();
     $table = $this->getTable();
     // Check to see if any of the column constants are PHP reserved words.
     $colConstants = array();
     foreach ($table->getColumns() as $col) {
         $colConstants[] = $this->getColumnName($col);
     }
     $reservedConstants = array_map('strtoupper', ClassTools::getPhpReservedWords());
     $intersect = array_intersect($reservedConstants, $colConstants);
     if (!empty($intersect)) {
         throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with a PHP reserved word (" . implode(", ", $intersect) . ")");
     }
 }
Esempio n. 3
0
 /**
  * Gets the full path to the file for the current class.
  *
  * @return string
  */
 public function getClassFilePath()
 {
     return ClassTools::createFilePath($this->getPackagePath(), $this->getUnqualifiedClassName());
 }
Esempio n. 4
0
 /**
  * Adds a boolean isser method.
  *
  * @param string &$script
  * @param Column $column
  */
 protected function addBooleanAccessor(&$script, Column $column)
 {
     $name = self::getBooleanAccessorName($column);
     if (in_array($name, ClassTools::getPropelReservedMethods())) {
         //TODO: Issue a warning telling the user to use default accessors
         return;
         // Skip boolean accessors for reserved names
     }
     $this->addDefaultAccessorComment($script, $column);
     $this->addBooleanAccessorOpen($script, $column);
     $this->addBooleanAccessorBody($script, $column);
     $this->addDefaultAccessorClose($script);
 }
 /**
  * Returns the file path to the parent class.
  *
  * @return string
  */
 protected function getParentClassFilePath()
 {
     return ClassTools::getFilePath($this->getParentClasspath());
 }
Esempio n. 6
0
 /**
  * Adds class phpdoc comment and opening of class.
  *
  * @param string &$script
  */
 protected function addClassOpen(&$script)
 {
     $table = $this->getTable();
     $tableName = $table->getName();
     $tableDesc = $table->getDescription();
     if (null !== ($parentClass = $this->getBehaviorContent('parentClass')) || null !== ($parentClass = ClassTools::classname($this->getBaseClass()))) {
         $parentClass = ' extends ' . $parentClass;
     }
     if ($this->getBuildProperty('generator.objectModel.addClassLevelComment')) {
         $script .= "\n/**\n * Base class that represents a row from the '{$tableName}' table.\n *\n * {$tableDesc}\n *";
         if ($this->getBuildProperty('generator.objectModel.addTimeStamp')) {
             $now = strftime('%c');
             $script .= "\n * This class was autogenerated by Propel " . $this->getBuildProperty('general.version') . " on:\n *\n * {$now}\n *";
         }
         $script .= "\n* @package    propel.generator." . $this->getPackage() . "\n*/";
     }
     $script .= "\nabstract class " . $this->getUnqualifiedClassName() . $parentClass . " implements ActiveRecordInterface ";
     if ($interface = $this->getInterface()) {
         $script .= ", Child" . ClassTools::classname($interface);
         if ($interface !== ClassTools::classname($interface)) {
             $this->declareClass($interface);
         } else {
             $this->declareClassFromBuilder($this->getInterfaceBuilder());
         }
     }
     $script .= "\n{";
 }
Esempio n. 7
0
 /**
  * Adds class phpdoc comment and openning of class.
  * @param      string &$script The script will be modified in this method.
  */
 protected function addClassOpen(&$script)
 {
     $table = $this->getTable();
     $tableName = $table->getName();
     $tableDesc = $table->getDescription();
     $interface = $this->getInterface();
     $parentClass = $this->getBehaviorContent('parentClass');
     $parentClass = null !== $parentClass ? $parentClass : ClassTools::classname($this->getBaseClass());
     $script .= "\n/**\n * Base class that represents a row from the '{$tableName}' table.\n *\n * {$tableDesc}\n *";
     if ($this->getBuildProperty('addTimeStamp')) {
         $now = strftime('%c');
         $script .= "\n * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:\n *\n * {$now}\n *";
     }
     $script .= "\n */\nabstract class " . $this->getClassname() . " extends " . $parentClass . " ";
     $interface = ClassTools::getInterface($table);
     if ($interface) {
         $script .= " implements " . ClassTools::classname($interface);
     }
     if ($this->getTable()->getInterface()) {
         $this->declareClassFromBuilder($this->getInterfaceBuilder());
     }
     $script .= "\n{\n";
 }
 /**
  * Returns classname of parent class.
  *
  * @return string
  */
 protected function getParentClassName()
 {
     return ClassTools::classname($this->getParentClasspath());
 }