Merged r3122:r3126
This commit is contained in:
parent
ec1ec99446
commit
b1c4c5f53f
@ -714,6 +714,8 @@ final class Doctrine
|
||||
$manager = Doctrine_Manager::getInstance();
|
||||
$connections = $manager->getConnections();
|
||||
|
||||
$results = array();
|
||||
|
||||
foreach ($connections as $name => $connection) {
|
||||
if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) {
|
||||
continue;
|
||||
@ -738,10 +740,14 @@ final class Doctrine
|
||||
|
||||
// Reopen original connection with newly created database
|
||||
$manager->openConnection(new PDO($info['dsn'], $username, $password), $name, true);
|
||||
} catch (Exception $e) {
|
||||
|
||||
$results[$name] = true;
|
||||
} catch (Exception $e) {
|
||||
$results[$name] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -762,6 +768,8 @@ final class Doctrine
|
||||
|
||||
$connections = $manager->getConnections();
|
||||
|
||||
$results = array();
|
||||
|
||||
foreach ($connections as $name => $connection) {
|
||||
if ( ! empty($specifiedConnections) && !in_array($name, $specifiedConnections)) {
|
||||
continue;
|
||||
@ -769,10 +777,14 @@ final class Doctrine
|
||||
|
||||
try {
|
||||
$connection->export->dropDatabase($name);
|
||||
} catch (Exception $e) {
|
||||
|
||||
$results[$name] = true;
|
||||
} catch (Exception $e) {
|
||||
$results[$name] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1047,10 +1059,38 @@ final class Doctrine
|
||||
*/
|
||||
public static function makeDirectories($path, $mode = 0777)
|
||||
{
|
||||
if (!$path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_dir($path) || is_file($path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return mkdir($path, $mode, true);
|
||||
}
|
||||
|
||||
function removeDirectories($folderPath)
|
||||
{
|
||||
if (is_dir($folderPath))
|
||||
{
|
||||
foreach (scandir($folderPath) as $value)
|
||||
{
|
||||
if ($value != '.' && $value != '..')
|
||||
{
|
||||
$value = $folderPath . "/" . $value;
|
||||
|
||||
if (is_dir($value)) {
|
||||
self::removeDirectories($value);
|
||||
} else if (is_file($value)) {
|
||||
@unlink($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rmdir ( $folderPath );
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
|
||||
// If they specified a specific yml file
|
||||
if (end($e) == 'yml') {
|
||||
$array = array_merge(Doctrine_Parser::load($dir, $this->getFormat()), $array);
|
||||
$array = array_merge($array, Doctrine_Parser::load($dir, $this->getFormat()));
|
||||
// If they specified a directory
|
||||
} else if(is_dir($dir)) {
|
||||
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir),
|
||||
@ -73,17 +73,17 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
foreach ($it as $file) {
|
||||
$e = explode('.', $file->getFileName());
|
||||
if (in_array(end($e), $this->getFormats())) {
|
||||
$array = array_merge(Doctrine_Parser::load($file->getPathName(), $this->getFormat()), $array);
|
||||
$array = array_merge($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->loadData($array);
|
||||
$this->_loadData($array);
|
||||
}
|
||||
|
||||
protected function buildRows($className, $data)
|
||||
protected function _buildRows($className, $data)
|
||||
{
|
||||
$rows = array();
|
||||
foreach ($data as $rowKey => $row) {
|
||||
@ -96,7 +96,7 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
|
||||
// Skip associative arrays defining keys to relationships
|
||||
if (!isset($keys[0])) {
|
||||
$rows = array_merge($rows, $this->buildRows(Doctrine::getTable($className)->getRelation($key)->getTable()->getOption('name'), $value));
|
||||
$rows = array_merge($rows, $this->_buildRows(Doctrine::getTable($className)->getRelation($key)->getTable()->getOption('name'), $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
* @param string $array
|
||||
* @return void
|
||||
*/
|
||||
protected function loadData(array $array)
|
||||
protected function _loadData(array $array)
|
||||
{
|
||||
$specifiedModels = $this->getModels();
|
||||
$rows = array();
|
||||
@ -127,9 +127,9 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
$templates = array_keys($obj->getTable()->getTemplates());
|
||||
|
||||
if (in_array('Doctrine_Template_NestedSet', $templates)) {
|
||||
$this->loadNestedSetData($className, $data);
|
||||
$this->_loadNestedSetData($className, $data);
|
||||
} else {
|
||||
$rows = array_merge($rows, $this->buildRows($className, $data));
|
||||
$rows = array_merge($rows, $this->_buildRows($className, $data));
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
}
|
||||
}
|
||||
|
||||
protected function loadNestedSetData($model, $nestedSetData, $parent = null)
|
||||
protected function _loadNestedSetData($model, $nestedSetData, $parent = null)
|
||||
{
|
||||
$manager = Doctrine_Manager::getInstance();
|
||||
|
||||
@ -222,7 +222,7 @@ class Doctrine_Data_Import extends Doctrine_Data
|
||||
|
||||
if( is_array($children) AND !empty($children) )
|
||||
{
|
||||
$this->loadNestedSetData($model, $children, $record);
|
||||
$this->_loadNestedSetData($model, $children, $record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,8 +131,8 @@ class Doctrine_Import_Builder
|
||||
{
|
||||
Doctrine::makeDirectories($path);
|
||||
|
||||
if (!$this->_packagesPath) {
|
||||
$this->_packagesPath = $path . DIRECTORY_SEPARATOR . 'packages';
|
||||
if ( ! $this->_packagesPath) {
|
||||
$this->setPackagesPath($path . DIRECTORY_SEPARATOR . 'packages');
|
||||
}
|
||||
|
||||
$this->_path = $path;
|
||||
@ -157,6 +157,8 @@ class Doctrine_Import_Builder
|
||||
*/
|
||||
public function setPackagesPath($packagesPath)
|
||||
{
|
||||
Doctrine::makeDirectories($packagesPath);
|
||||
|
||||
$this->_packagesPath = $packagesPath;
|
||||
}
|
||||
|
||||
@ -259,8 +261,14 @@ class Doctrine_Import_Builder
|
||||
*/
|
||||
public function setOption($key, $value)
|
||||
{
|
||||
$name = '_'.$key;
|
||||
$this->$name = $value;
|
||||
$name = 'set' . Doctrine::classify($key);
|
||||
|
||||
if (method_exists($this, $name)) {
|
||||
$this->$name($value);
|
||||
} else {
|
||||
$key = '_' . $key;
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +117,7 @@ class Doctrine_Import_Schema
|
||||
}
|
||||
}
|
||||
|
||||
$this->buildRelationships($array);
|
||||
$this->_buildRelationships($array);
|
||||
|
||||
return array('schema' => $array, 'relations' => $this->_relations);
|
||||
}
|
||||
@ -137,13 +137,12 @@ class Doctrine_Import_Schema
|
||||
{
|
||||
$builder = new Doctrine_Import_Builder();
|
||||
$builder->setTargetPath($directory);
|
||||
$builder->generateBaseClasses($this->getOption('generateBaseClasses'));
|
||||
$builder->generateTableClasses($this->getOption('generateTableClasses'));
|
||||
$builder->setBaseClassesDirectory($this->getOption('baseClassesDirectory'));
|
||||
$builder->setBaseClassName($this->getOption('baseClassName'));
|
||||
$builder->setPackagesPath($this->getOption('packagesPath'));
|
||||
$builder->setPackagesPrefix($this->getOption('packagesPrefix'));
|
||||
$builder->setSuffix($this->getOption('suffix'));
|
||||
|
||||
foreach ($this->_options as $key => $value) {
|
||||
if ($value) {
|
||||
$builder->setOption($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$schema = $this->buildSchema($schema, $format);
|
||||
|
||||
@ -376,7 +375,7 @@ class Doctrine_Import_Schema
|
||||
* @param string $array
|
||||
* @return void
|
||||
*/
|
||||
protected function buildRelationships(&$array)
|
||||
protected function _buildRelationships(&$array)
|
||||
{
|
||||
foreach ($array as $name => $properties) {
|
||||
if ( ! isset($properties['relations'])) {
|
||||
@ -420,7 +419,7 @@ class Doctrine_Import_Schema
|
||||
}
|
||||
|
||||
// Now we fix all the relationships and auto-complete opposite ends of relationships
|
||||
$this->fixRelationships();
|
||||
$this->_fixRelationships();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -430,7 +429,7 @@ class Doctrine_Import_Schema
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function fixRelationships()
|
||||
protected function _fixRelationships()
|
||||
{
|
||||
foreach($this->_relations as $className => $relations) {
|
||||
foreach ($relations AS $alias => $relation) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user