public function init(Atomik_Model_Builder $builder) { if (!$builder->hasField('created')) { $builder->addField(new Atomik_Model_Field_Timestamp('created', array('form-ignore' => true))); } if (!$builder->hasField('updated')) { $builder->addField(new Atomik_Model_Field_Timestamp('updated', array('form-ignore' => true))); } }
/** * Returns a builder without the references * * @param string $className * @return Atomik_Model_Builder */ private static function _getBaseBuilder($className) { if (isset(self::$_cache[$className])) { return self::$_cache[$className]; } if (!class_exists($className)) { require_once 'Atomik/Model/Builder/Exception.php'; throw new Atomik_Model_Builder_Exception('Class ' . $className . ' not found'); } $class = new ReflectionClass($className); $builder = new Atomik_Model_Builder($className, $className); foreach ($class->getProperties(ReflectionProperty::IS_PUBLIC) as $prop) { $propData = self::getMetadataFromDocBlock($prop->getDocComment()); // jump to the next property if there is the ignore tag if (isset($propData['ignore'])) { continue; } $type = 'string'; if (isset($propData['var'])) { $type = $propData['var']; unset($propData['var']); } else if (!isset($propData['length'])) { $propData['length'] = 255; } $field = Atomik_Model_Field_Factory::factory($type, $prop->getName(), $propData); $builder->addField($field); } $options = self::getMetadataFromDocBlock($class->getDocComment()); // sets the adapter if (isset($options['table'])) { $builder->tableName = $options['table']; unset($options['table']); } // use the remaining metadatas as options $builder->setOptions($options); if (($parentClass = $class->getParentClass()) != null) { if ($parentClass->getName() != 'Atomik_Model' && $parentClass->isSubclassOf('Atomik_Model')) { $builder->setParentModel($parentClass->getName()); } } self::$_cache[$className] = $builder; return $builder; }
public function init(Atomik_Model_Builder $builder) { $builder->addField(new Atomik_Model_Field('position', 'int')); }
public function init(Atomik_Model_Builder $builder) { $builder->addField(new Atomik_Model_Field_Bool('published')); }