Commit ed383556 authored by Jonathan.Wage's avatar Jonathan.Wage

Merged r3136:3137

parent b889f427
...@@ -441,9 +441,17 @@ final class Doctrine ...@@ -441,9 +441,17 @@ final class Doctrine
* *
* Array of all the loaded models and the path to each one for autoloading * Array of all the loaded models and the path to each one for autoloading
* *
* @var string * @var array
*/ */
private static $_loadedModels = array(); private static $_loadedModels = array();
/**
* _validators
*
* Array of all the loaded validators
* @var array
*/
private static $_validators = array();
/** /**
* __construct * __construct
...@@ -1070,7 +1078,13 @@ final class Doctrine ...@@ -1070,7 +1078,13 @@ final class Doctrine
return mkdir($path, $mode, true); return mkdir($path, $mode, true);
} }
function removeDirectories($folderPath) /**
* removeDirectories
*
* @param string $folderPath
* @return void
*/
public static function removeDirectories($folderPath)
{ {
if (is_dir($folderPath)) if (is_dir($folderPath))
{ {
...@@ -1093,4 +1107,31 @@ final class Doctrine ...@@ -1093,4 +1107,31 @@ final class Doctrine
return false; return false;
} }
} }
/**
* getValidators
*
* Get available doctrine validators
*
* @return array $validators
*/
public static function getValidators()
{
if (empty(self::$_validators)) {
$dir = Doctrine::getPath() . DIRECTORY_SEPARATOR . 'Doctrine' . DIRECTORY_SEPARATOR . 'Validator';
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
foreach ($files as $file) {
$e = explode('.', $file->getFileName());
if (end($e) == 'php') {
$name = strtolower($e[0]);
self::$_validators[$name] = $name;
}
}
}
return self::$_validators;
}
} }
\ No newline at end of file
This diff is collapsed.
...@@ -160,8 +160,9 @@ class Doctrine_Import_Schema ...@@ -160,8 +160,9 @@ class Doctrine_Import_Schema
$attributes = $this->getAttributes($properties); $attributes = $this->getAttributes($properties);
$templates = $this->getTemplates($properties); $templates = $this->getTemplates($properties);
$actAs = $this->getActAs($properties); $actAs = $this->getActAs($properties);
$tableOptions = $this->getTableOptions($properties);
$builder->buildRecord($options, $columns, $relations, $indexes, $attributes, $templates, $actAs); $builder->buildRecord($options, $columns, $relations, $indexes, $attributes, $templates, $actAs, $tableOptions);
} }
} }
...@@ -282,6 +283,17 @@ class Doctrine_Import_Schema ...@@ -282,6 +283,17 @@ class Doctrine_Import_Schema
{ {
return isset($properties['actAs']) ? $properties['actAs']:array(); return isset($properties['actAs']) ? $properties['actAs']:array();
} }
/**
* getTableOptions
*
* @param string $properties
* @return void
*/
public function getTableOptions($properties)
{
return isset($properties['options']) ? $properties['options']:array();
}
/** /**
* parseSchema * parseSchema
...@@ -332,17 +344,21 @@ class Doctrine_Import_Schema ...@@ -332,17 +344,21 @@ class Doctrine_Import_Schema
} }
$colDesc['ptype'] = isset($field['ptype']) ? (string) $field['ptype']:(string) $colDesc['type']; $colDesc['ptype'] = isset($field['ptype']) ? (string) $field['ptype']:(string) $colDesc['type'];
$colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed']:null; $colDesc['fixed'] = isset($field['fixed']) ? (int) $field['fixed']:null;
$colDesc['unsigned'] = isset($field['unsigned']) ? (bool) $field['unsigned']:null;
$colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']):null; $colDesc['primary'] = isset($field['primary']) ? (bool) (isset($field['primary']) && $field['primary']):null;
$colDesc['default'] = isset($field['default']) ? $field['default']:null; $colDesc['default'] = isset($field['default']) ? $field['default']:null;
$colDesc['notnull'] = isset($field['notnull']) ? (bool) (isset($field['notnull']) && $field['notnull']):null;
$colDesc['autoincrement'] = isset($field['autoincrement']) ? (bool) (isset($field['autoincrement']) && $field['autoincrement']):null; $colDesc['autoincrement'] = isset($field['autoincrement']) ? (bool) (isset($field['autoincrement']) && $field['autoincrement']):null;
$colDesc['autoincrement'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):$colDesc['autoincrement']; $colDesc['autoincrement'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):$colDesc['autoincrement'];
$colDesc['unique'] = isset($field['unique']) ? (bool) (isset($field['unique']) && $field['unique']):null; $colDesc['values'] = isset($field['values']) ? (array) $field['values']:null;
$colDesc['values'] = isset($field['values']) ? (array) $field['values']: null;
$validators = Doctrine::getValidators();
foreach ($validators as $validator) {
if (isset($field[$validator])) {
$colDesc[$validator] = $field[$validator];
}
}
$columns[(string) $colDesc['name']] = $colDesc; $columns[(string) $colDesc['name']] = $colDesc;
} }
} }
...@@ -356,8 +372,9 @@ class Doctrine_Import_Schema ...@@ -356,8 +372,9 @@ class Doctrine_Import_Schema
$build[$className]['attributes'] = isset($table['attributes']) ? $table['attributes']:array(); $build[$className]['attributes'] = isset($table['attributes']) ? $table['attributes']:array();
$build[$className]['templates'] = isset($table['templates']) ? $table['templates']:array(); $build[$className]['templates'] = isset($table['templates']) ? $table['templates']:array();
$build[$className]['actAs'] = isset($table['actAs']) ? $table['actAs']:array(); $build[$className]['actAs'] = isset($table['actAs']) ? $table['actAs']:array();
$build[$className]['options'] = isset($table['options']) ? $table['options']:array();
$build[$className]['package'] = isset($table['package']) ? $table['package']:null; $build[$className]['package'] = isset($table['package']) ? $table['package']:null;
if (isset($table['inheritance'])) { if (isset($table['inheritance'])) {
$build[$className]['inheritance'] = $table['inheritance']; $build[$className]['inheritance'] = $table['inheritance'];
} }
......
...@@ -43,7 +43,7 @@ class Doctrine_Template_Listener_Sluggable extends Doctrine_Record_Listener ...@@ -43,7 +43,7 @@ class Doctrine_Template_Listener_Sluggable extends Doctrine_Record_Listener
'type' => 'clob', 'type' => 'clob',
'length' => null, 'length' => null,
'options' => array(), 'options' => array(),
'columns' => array()); 'fields' => array());
/** /**
* __construct * __construct
...@@ -69,12 +69,12 @@ class Doctrine_Template_Listener_Sluggable extends Doctrine_Record_Listener ...@@ -69,12 +69,12 @@ class Doctrine_Template_Listener_Sluggable extends Doctrine_Record_Listener
protected function buildSlug($record) protected function buildSlug($record)
{ {
if (empty($this->_columns)) { if (empty($this->_options['fields'])) {
$value = (string) $record; $value = (string) $record;
} else { } else {
$value = ''; $value = '';
foreach ($this->_columns as $column) { foreach ($this->_options['fields'] as $field) {
$value = $record->$column . ' '; $value = $record->$field . ' ';
} }
} }
...@@ -93,4 +93,4 @@ class Doctrine_Template_Listener_Sluggable extends Doctrine_Record_Listener ...@@ -93,4 +93,4 @@ class Doctrine_Template_Listener_Sluggable extends Doctrine_Record_Listener
return $value; return $value;
} }
} }
\ No newline at end of file
...@@ -91,9 +91,9 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener ...@@ -91,9 +91,9 @@ class Doctrine_Template_Listener_Timestampable extends Doctrine_Record_Listener
$options = $this->_options[$type]; $options = $this->_options[$type];
if ($options['type'] == 'date') { if ($options['type'] == 'date') {
return date('Y-m-d', time()); return date($options['format'], time());
} else if ($options['type'] == 'timestamp') { } else if ($options['type'] == 'timestamp') {
return date('Y-m-d H:i:s', time()); return date($options['format'], time());
} else { } else {
return time(); return time();
} }
......
...@@ -43,7 +43,7 @@ class Doctrine_Template_Sluggable extends Doctrine_Template ...@@ -43,7 +43,7 @@ class Doctrine_Template_Sluggable extends Doctrine_Template
'type' => 'clob', 'type' => 'clob',
'length' => null, 'length' => null,
'options' => array(), 'options' => array(),
'columns' => array()); 'fields' => array());
/** /**
* __construct * __construct
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment