public static function buildContainer(MetaClass $class, MetaClassProperty $holder) { $out = self::getHead(); $containerName = $class->getName() . ucfirst($holder->getName()) . 'DAO'; $out .= 'final class ' . $containerName . ' extends ' . $holder->getRelation()->toString() . 'Linked' . "\n{\n"; $className = $class->getName(); $propertyName = strtolower($className[0]) . substr($className, 1); $remoteColumnName = $holder->getType()->getClass()->getTableName(); $out .= <<<EOT public function __construct({$className} \${$propertyName}, \$lazy = false) { \tparent::__construct( \t\t\${$propertyName}, \t\t{$holder->getType()->getClassName()}::dao(), \t\t\$lazy \t); } /** * @return {$containerName} **/ public static function create({$className} \${$propertyName}, \$lazy = false) { \treturn new self(\${$propertyName}, \$lazy); } EOT; if ($holder->getRelation()->getId() == MetaRelation::MANY_TO_MANY) { $out .= <<<EOT public function getHelperTable() { \treturn '{$class->getTableName()}_{$remoteColumnName}'; } public function getChildIdField() { \treturn '{$remoteColumnName}_id'; } EOT; } $out .= <<<EOT public function getParentIdField() { \treturn '{$class->getTableName()}_id'; } EOT; $out .= "}\n"; $out .= self::getHeel(); return $out; }
public function equals(MetaClassProperty $property) { return $property->getName() == $this->getName() && $property->getColumnName() == $this->getColumnName() && $property->getType() == $this->getType() && $property->getSize() == $this->getSize() && $property->getRelation() == $this->getRelation() && $property->isRequired() == $this->isRequired() && $property->isIdentifier() == $this->isIdentifier(); }