1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Enhancements to CLI and removing sandbox files. Will add ignores.

This commit is contained in:
Jonathan.Wage 2007-10-20 06:12:20 +00:00
parent 8d2aebad70
commit 975b74bd6f
69 changed files with 1189 additions and 1116 deletions

View File

@ -18,6 +18,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
*
* Doctrine_Adapter

View File

@ -32,10 +32,13 @@
*/
class Doctrine_Cli
{
protected $tasks = array();
protected $scriptName = null;
protected $config = array();
protected $tasks = array(),
$taskInstance = null,
$formatter = null,
$scriptName = null,
$message = null,
$config = array();
/**
* __construct
*
@ -45,6 +48,29 @@ class Doctrine_Cli
public function __construct($config = array())
{
$this->config = $config;
$this->formatter = new Doctrine_Cli_AnsiColorFormatter();
}
/**
* notify
*
* @param string $notification
* @return void
*/
public function notify($notification = null)
{
echo $this->formatter->format($this->taskInstance->getTaskName(), 'INFO') . ' - ' . $this->formatter->format($notification, 'HEADER') . "\n";
}
/**
* notifyException
*
* @param string $exception
* @return void
*/
public function notifyException($exception)
{
echo $this->formatter->format($exception->getMessage(), 'ERROR') . "\n";
}
/**
@ -56,43 +82,79 @@ class Doctrine_Cli
*/
public function run($args)
{
$this->scriptName = $args[0];
echo "\n";
if (!isset($args[1])) {
echo $this->printTasks();
try {
$this->_run($args);
} catch (Exception $exception) {
$this->notifyException($exception);
}
echo "\n";
}
protected function _getTaskClassFromArgs($args)
{
$taskName = str_replace('-', '_', $args[1]);
$taskClass = 'Doctrine_Task_' . Doctrine::classify($taskName);
return $taskClass;
}
protected function _run($args)
{
$this->scriptName = $args[0];
$taskName = $args[1];
$arg1 = isset($args[1]) ? $args[1]:null;
if (!$arg1 || $arg1 == 'help') {
echo $this->printTasks(null, $arg1 == 'help' ? true:false);
return;
}
if (isset($args[1]) && isset($args[2]) && $args[2] == 'help') {
echo $this->printTasks($args[1], true);
return;
}
$taskClass = $this->_getTaskClassFromArgs($args);
if (!class_exists($taskClass)) {
throw new Doctrine_Cli_Exception('Cli task could not be found: ' . $taskClass);
}
unset($args[0]);
$taskName = str_replace('-', '_', $args[1]);
unset($args[1]);
$taskClass = 'Doctrine_Task_' . Doctrine::classify($taskName);
$this->taskInstance = new $taskClass($this);
if (class_exists($taskClass)) {
$taskInstance = new $taskClass();
$args = $this->prepareArgs($taskInstance, $args);
$taskInstance->setArguments($args);
if ($taskInstance->validate()) {
$taskInstance->execute();
$args = $this->prepareArgs($args);
$this->taskInstance->setArguments($args);
try {
if ($this->taskInstance->validate()) {
$this->taskInstance->execute();
} else {
echo $this->formatter->format('Requires arguments missing!!', 'ERROR') . "\n\n";
echo $this->printTasks($taskName, true);
}
} else {
throw new Doctrine_Cli_Exception('Cli task could not be found: '.$taskClass);
} catch (Exception $e) {
throw new Doctrine_Cli_Exception($e->getMessage());
}
}
/**
* prepareArgs
*
* @param string $taskInstance
* @param string $args
* @return array $prepared
*/
protected function prepareArgs($taskInstance, $args)
protected function prepareArgs($args)
{
$taskInstance = $this->taskInstance;
$args = array_values($args);
// First lets load populate an array with all the possible arguments. required and optional
@ -137,54 +199,63 @@ class Doctrine_Cli
*
* @return void
*/
public function printTasks()
public function printTasks($task = null, $full = false)
{
$task = Doctrine::classify(str_replace('-', '_', $task));
$tasks = $this->loadTasks();
echo "\nAvailable Doctrine Command Line Interface Tasks\n";
echo str_repeat('-', 40)."\n\n";
echo $this->formatter->format("Doctrine Command Line Interface", 'HEADER') . "\n\n";
foreach ($tasks as $taskName)
{
if ($task != null && strtolower($task) != strtolower($taskName)) {
continue;
}
$className = 'Doctrine_Task_' . $taskName;
$taskInstance = new $className();
$taskInstance->taskName = str_replace('_', '-', Doctrine::tableize($taskName));
$taskInstance->taskName = str_replace('_', '-', Doctrine::tableize($taskName));
echo $taskInstance->getDescription() . "\n";
$syntax = $this->scriptName . ' ' . $taskInstance->getTaskName();
$syntax = "Syntax: ";
echo $this->formatter->format($syntax, 'INFO');
$syntax .= $this->scriptName . ' ' . $taskInstance->getTaskName();
if ($full) {
echo " - " . $taskInstance->getDescription() . "\n";
$args = null;
$requiredArguments = $taskInstance->getRequiredArgumentsDescriptions();
if (!empty($requiredArguments)) {
foreach ($requiredArguments as $name => $description) {
$args .= $this->formatter->format($name, "ERROR");
if (isset($this->config[$name])) {
$args .= " - " . $this->formatter->format($this->config[$name], 'COMMENT');
} else {
$args .= " - " . $description;
}
$args .= "\n";
}
}
if ($required = $taskInstance->getRequiredArguments()) {
$syntax .= ' <' . implode('> <', $required) . '>';
}
if ($optional = $taskInstance->getOptionalArguments()) {
$syntax .= ' <' . implode('> <', $optional) . '>';
}
$optionalArguments = $taskInstance->getOptionalArgumentsDescriptions();
if (!empty($optionalArguments)) {
foreach ($optionalArguments as $name => $description) {
$args .= $name . ' - ' . $description."\n";
}
}
echo $syntax."\n";
$args = null;
if ($requiredArguments = $taskInstance->getRequiredArgumentsDescriptions()) {
foreach ($requiredArguments as $name => $description) {
$args .= '*' . $name . ' - ' . $description."\n";
if ($args) {
echo "\n" . $this->formatter->format('Arguments:', 'HEADER') . "\n" . $args;
}
}
if ($optionalArguments = $taskInstance->getOptionalArgumentsDescriptions()) {
foreach ($optionalArguments as $name => $description) {
$args .= $name . ' - ' . $description."\n";
}
}
if ($args) {
echo "\nArguments (* = required):\n";
echo $args;
}
echo "\n".str_repeat("-", 40)."\n";
echo "\n";
}
}

View File

@ -0,0 +1,162 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* $Id: AnsiColorFormatter.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_AnsiColorFormatter provides methods to colorize text to be displayed on a console.
*
* @package Doctrine
* @subpackage Cli
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id: sfAnsiColorFormatter.class.php 5250 2007-09-24 08:11:50Z fabien $
*/
class Doctrine_Cli_AnsiColorFormatter extends Doctrine_Cli_Formatter
{
protected
$styles = array(
'HEADER' => array('fg' => 'black', 'bold' => true),
'ERROR' => array('bg' => 'red', 'fg' => 'white', 'bold' => true),
'INFO' => array('fg' => 'green', 'bold' => true),
'COMMENT' => array('fg' => 'yellow'),
),
$options = array('bold' => 1, 'underscore' => 4, 'blink' => 5, 'reverse' => 7, 'conceal' => 8),
$foreground = array('black' => 30, 'red' => 31, 'green' => 32, 'yellow' => 33, 'blue' => 34, 'magenta' => 35, 'cyan' => 36, 'white' => 37),
$background = array('black' => 40, 'red' => 41, 'green' => 42, 'yellow' => 43, 'blue' => 44, 'magenta' => 45, 'cyan' => 46, 'white' => 47);
/**
* Sets a new style.
*
* @param string The style name
* @param array An array of options
*/
public function setStyle($name, $options = array())
{
$this->styles[$name] = $options;
}
/**
* Formats a text according to the given style or parameters.
*
* @param string The test to style
* @param mixed An array of options or a style name
*
* @return string The styled text
*/
public function format($text = '', $parameters = array(), $stream = STDOUT)
{
if (!$this->supportsColors($stream))
{
return $text;
}
if (!is_array($parameters) && 'NONE' == $parameters)
{
return $text;
}
if (!is_array($parameters) && isset($this->styles[$parameters]))
{
$parameters = $this->styles[$parameters];
}
$codes = array();
if (isset($parameters['fg']))
{
$codes[] = $this->foreground[$parameters['fg']];
}
if (isset($parameters['bg']))
{
$codes[] = $this->background[$parameters['bg']];
}
foreach ($this->options as $option => $value)
{
if (isset($parameters[$option]) && $parameters[$option])
{
$codes[] = $value;
}
}
return "\033[".implode(';', $codes).'m'.$text."\033[0m";
}
/**
* Formats a message within a section.
*
* @param string The section name
* @param string The text message
* @param integer The maximum size allowed for a line (65 by default)
*/
public function formatSection($section, $text, $size = null)
{
$width = 9 + strlen($this->format('', 'INFO'));
return sprintf(">> %-${width}s %s", $this->format($section, 'INFO'), $this->excerpt($text, $size));
}
/**
* Truncates a line.
*
* @param string The text
* @param integer The maximum size of the returned string (65 by default)
*
* @return string The truncated string
*/
public function excerpt($text, $size = null)
{
if (!$size)
{
$size = $this->size;
}
if (strlen($text) < $size)
{
return $text;
}
$subsize = floor(($size - 3) / 2);
return substr($text, 0, $subsize).$this->format('...', 'INFO').substr($text, -$subsize);
}
/**
* Returns true if the stream supports colorization.
*
* Colorization is disabled if not supported by the stream:
*
* - windows
* - non tty consoles
*
* @param mixed A stream
*
* @return Boolean true if the stream supports colorization, false otherwise
*/
public function supportsColors($stream)
{
return DIRECTORY_SEPARATOR != '\\' && function_exists('posix_isatty') && @posix_isatty($stream);
}
}

View File

@ -0,0 +1,108 @@
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* $Id: Formatter.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Cli_Formatter provides methods to format text to be displayed on a console.
*
* @package Doctrine
* @subpackage Cli
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id: Doctrine_Cli_Formatter.class.php 5250 2007-09-24 08:11:50Z fabien $
*/
class Doctrine_Cli_Formatter
{
protected
$size = 65;
function __construct($maxLineSize = 65)
{
$this->size = $maxLineSize;
}
/**
* Formats a text according to the given parameters.
*
* @param string The test to style
* @param mixed An array of parameters
* @param stream A stream (default to STDOUT)
*
* @return string The formatted text
*/
public function format($text = '', $parameters = array(), $stream = STDOUT)
{
return $text;
}
/**
* Formats a message within a section.
*
* @param string The section name
* @param string The text message
* @param integer The maximum size allowed for a line (65 by default)
*/
public function formatSection($section, $text, $size = null)
{
return sprintf(">> %-$9s %s", $section, $this->excerpt($text, $size));
}
/**
* Truncates a line.
*
* @param string The text
* @param integer The maximum size of the returned string (65 by default)
*
* @return string The truncated string
*/
public function excerpt($text, $size = null)
{
if (!$size)
{
$size = $this->size;
}
if (strlen($text) < $size)
{
return $text;
}
$subsize = floor(($size - 3) / 2);
return substr($text, 0, $subsize).'...'.substr($text, -$subsize);
}
/**
* Sets the maximum line size.
*
* @param integer The maximum line size for a message
*/
public function setMaxLineSize($size)
{
$this->size = $size;
}
}

746
lib/Doctrine/FileFinder.php Normal file
View File

@ -0,0 +1,746 @@
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
*
* This is a port of sfFinder from the symfony-project.
* http://www.symfony-project.com
*
* Allow to build rules to find files and directories.
*
* All rules may be invoked several times, except for ->in() method.
* Some rules are cumulative (->name() for example) whereas others are destructive
* (most recent value is used, ->maxdepth() method for example).
*
* All methods return the current Doctrine_FileFinder object to allow easy chaining:
*
* $files = Doctrine_FileFinder::type('file')->name('*.php')->in(.);
*
* Interface loosely based on perl File::Find::Rule module.
*
* Doctrine_FileFinder
*
* @package Doctrine
* @subpackage FileFinder
* @author Symfony Project/Fabien Potencier <fabien.potencier@symfony-project.com>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @version $Revision$
* @link www.symfony-project.com
* @since 1.0
*/
class Doctrine_FileFinder
{
protected $type = 'file';
protected $names = array();
protected $prunes = array();
protected $discards = array();
protected $execs = array();
protected $mindepth = 0;
protected $sizes = array();
protected $maxdepth = 1000000;
protected $relative = false;
protected $follow_link = false;
/**
* Sets maximum directory depth.
*
* Finder will descend at most $level levels of directories below the starting point.
*
* @param integer level
* @return object current Doctrine_FileFinder object
*/
public function maxdepth($level)
{
$this->maxdepth = $level;
return $this;
}
/**
* Sets minimum directory depth.
*
* Finder will start applying tests at level $level.
*
* @param integer level
* @return object current Doctrine_FileFinder object
*/
public function mindepth($level)
{
$this->mindepth = $level;
return $this;
}
public function get_type()
{
return $this->type;
}
/**
* Sets the type of elements to returns.
*
* @param string directory or file or any (for both file and directory)
* @return object new Doctrine_FileFinder object
*/
public static function type($name)
{
$finder = new Doctrine_FileFinder();
return $finder->setType($name);
}
public function setType($name)
{
if (strtolower(substr($name, 0, 3)) == 'dir')
{
$this->type = 'directory';
}
else if (strtolower($name) == 'any')
{
$this->type = 'any';
}
else
{
$this->type = 'file';
}
return $this;
}
/*
* glob, patterns (must be //) or strings
*/
protected function to_regex($str)
{
if ($str{0} == '/' && $str{strlen($str) - 1} == '/')
{
return $str;
}
else
{
return Doctrine_GlobToRegex::glob_to_regex($str);
}
}
protected function args_to_array($arg_list, $not = false)
{
$list = array();
for ($i = 0; $i < count($arg_list); $i++)
{
if (is_array($arg_list[$i]))
{
foreach ($arg_list[$i] as $arg)
{
$list[] = array($not, $this->to_regex($arg));
}
}
else
{
$list[] = array($not, $this->to_regex($arg_list[$i]));
}
}
return $list;
}
/**
* Adds rules that files must match.
*
* You can use patterns (delimited with / sign), globs or simple strings.
*
* $finder->name('*.php')
* $finder->name('/\.php$/') // same as above
* $finder->name('test.php')
*
* @param list a list of patterns, globs or strings
* @return object current Doctrine_FileFinder object
*/
public function name()
{
$args = func_get_args();
$this->names = array_merge($this->names, $this->args_to_array($args));
return $this;
}
/**
* Adds rules that files must not match.
*
* @see ->name()
* @param list a list of patterns, globs or strings
* @return object current Doctrine_FileFinder object
*/
public function not_name()
{
$args = func_get_args();
$this->names = array_merge($this->names, $this->args_to_array($args, true));
return $this;
}
/**
* Adds tests for file sizes.
*
* $finder->size('> 10K');
* $finder->size('<= 1Ki');
* $finder->size(4);
*
* @param list a list of comparison strings
* @return object current Doctrine_FileFinder object
*/
public function size()
{
$args = func_get_args();
for ($i = 0; $i < count($args); $i++)
{
$this->sizes[] = new Doctrine_NumberCompare($args[$i]);
}
return $this;
}
/**
* Traverses no further.
*
* @param list a list of patterns, globs to match
* @return object current Doctrine_FileFinder object
*/
public function prune()
{
$args = func_get_args();
$this->prunes = array_merge($this->prunes, $this->args_to_array($args));
return $this;
}
/**
* Discards elements that matches.
*
* @param list a list of patterns, globs to match
* @return object current Doctrine_FileFinder object
*/
public function discard()
{
$args = func_get_args();
$this->discards = array_merge($this->discards, $this->args_to_array($args));
return $this;
}
/**
* Ignores version control directories.
*
* Currently supports subversion, CVS, DARCS, Gnu Arch, Monotone, Bazaar-NG
*
* @return object current Doctrine_FileFinder object
*/
public function ignore_version_control()
{
$ignores = array('.svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr');
return $this->discard($ignores)->prune($ignores);
}
/**
* Executes function or method for each element.
*
* Element match if functino or method returns true.
*
* $finder->exec('myfunction');
* $finder->exec(array($object, 'mymethod'));
*
* @param mixed function or method to call
* @return object current Doctrine_FileFinder object
*/
public function exec()
{
$args = func_get_args();
for ($i = 0; $i < count($args); $i++)
{
if (is_array($args[$i]) && !method_exists($args[$i][0], $args[$i][1]))
{
throw new Doctrine_Exception(sprintf('method "%s" does not exist for object "%s".', $args[$i][1], $args[$i][0]));
}
else if (!is_array($args[$i]) && !function_exists($args[$i]))
{
throw new Doctrine_Exception(sprintf('function "%s" does not exist.', $args[$i]));
}
$this->execs[] = $args[$i];
}
return $this;
}
/**
* Returns relative paths for all files and directories.
*
* @return object current Doctrine_FileFinder object
*/
public function relative()
{
$this->relative = true;
return $this;
}
/**
* Symlink following.
*
* @return object current Doctrine_FileFinder object
*/
public function follow_link()
{
$this->follow_link = true;
return $this;
}
/**
* Searches files and directories which match defined rules.
*
* @return array list of files and directories
*/
public function in()
{
$files = array();
$here_dir = getcwd();
$numargs = func_num_args();
$arg_list = func_get_args();
// first argument is an array?
if ($numargs == 1 && is_array($arg_list[0]))
{
$arg_list = $arg_list[0];
$numargs = count($arg_list);
}
for ($i = 0; $i < $numargs; $i++)
{
$real_dir = realpath($arg_list[$i]);
// absolute path?
if (!self::isPathAbsolute($real_dir))
{
$dir = $here_dir.DIRECTORY_SEPARATOR.$real_dir;
}
else
{
$dir = $real_dir;
}
if (!is_dir($real_dir))
{
continue;
}
if ($this->relative)
{
$files = array_merge($files, str_replace($dir.DIRECTORY_SEPARATOR, '', $this->search_in($dir)));
}
else
{
$files = array_merge($files, $this->search_in($dir));
}
}
return array_unique($files);
}
protected function search_in($dir, $depth = 0)
{
if ($depth > $this->maxdepth)
{
return array();
}
if (is_link($dir) && !$this->follow_link)
{
return array();
}
$files = array();
if (is_dir($dir))
{
$current_dir = opendir($dir);
while (false !== $entryname = readdir($current_dir))
{
if ($entryname == '.' || $entryname == '..') continue;
$current_entry = $dir.DIRECTORY_SEPARATOR.$entryname;
if (is_link($current_entry) && !$this->follow_link)
{
continue;
}
if (is_dir($current_entry))
{
if (($this->type == 'directory' || $this->type == 'any') && ($depth >= $this->mindepth) && !$this->is_discarded($dir, $entryname) && $this->match_names($dir, $entryname) && $this->exec_ok($dir, $entryname))
{
$files[] = realpath($current_entry);
}
if (!$this->is_pruned($dir, $entryname))
{
$files = array_merge($files, $this->search_in($current_entry, $depth + 1));
}
}
else
{
if (($this->type != 'directory' || $this->type == 'any') && ($depth >= $this->mindepth) && !$this->is_discarded($dir, $entryname) && $this->match_names($dir, $entryname) && $this->size_ok($dir, $entryname) && $this->exec_ok($dir, $entryname))
{
$files[] = realpath($current_entry);
}
}
}
closedir($current_dir);
}
return $files;
}
protected function match_names($dir, $entry)
{
if (!count($this->names)) return true;
// we must match one "not_name" rules to be ko
$one_not_name_rule = false;
foreach ($this->names as $args)
{
list($not, $regex) = $args;
if ($not)
{
$one_not_name_rule = true;
if (preg_match($regex, $entry))
{
return false;
}
}
}
$one_name_rule = false;
// we must match one "name" rules to be ok
foreach ($this->names as $args)
{
list($not, $regex) = $args;
if (!$not)
{
$one_name_rule = true;
if (preg_match($regex, $entry))
{
return true;
}
}
}
if ($one_not_name_rule && $one_name_rule)
{
return false;
}
else if ($one_not_name_rule)
{
return true;
}
else if ($one_name_rule)
{
return false;
}
else
{
return true;
}
}
protected function size_ok($dir, $entry)
{
if (!count($this->sizes)) return true;
if (!is_file($dir.DIRECTORY_SEPARATOR.$entry)) return true;
$filesize = filesize($dir.DIRECTORY_SEPARATOR.$entry);
foreach ($this->sizes as $number_compare)
{
if (!$number_compare->test($filesize)) return false;
}
return true;
}
protected function is_pruned($dir, $entry)
{
if (!count($this->prunes)) return false;
foreach ($this->prunes as $args)
{
$regex = $args[1];
if (preg_match($regex, $entry)) return true;
}
return false;
}
protected function is_discarded($dir, $entry)
{
if (!count($this->discards)) return false;
foreach ($this->discards as $args)
{
$regex = $args[1];
if (preg_match($regex, $entry)) return true;
}
return false;
}
protected function exec_ok($dir, $entry)
{
if (!count($this->execs)) return true;
foreach ($this->execs as $exec)
{
if (!call_user_func_array($exec, array($dir, $entry))) return false;
}
return true;
}
public static function isPathAbsolute($path)
{
if ($path{0} == '/' || $path{0} == '\\' ||
(strlen($path) > 3 && ctype_alpha($path{0}) &&
$path{1} == ':' &&
($path{2} == '\\' || $path{2} == '/')
)
)
{
return true;
}
return false;
}
}
/**
* Match globbing patterns against text.
*
* if match_glob("foo.*", "foo.bar") echo "matched\n";
*
* // prints foo.bar and foo.baz
* $regex = glob_to_regex("foo.*");
* for (array('foo.bar', 'foo.baz', 'foo', 'bar') as $t)
* {
* if (/$regex/) echo "matched: $car\n";
* }
*
* Doctrine_GlobToRegex implements glob(3) style matching that can be used to match
* against text, rather than fetching names from a filesystem.
*
* based on perl Text::Glob module.
*
* @package Doctrine
* @subpackage FileFinder
* @author Fabien Potencier <fabien.potencier@gmail.com> php port
* @author Richard Clamp <richardc@unixbeard.net> perl version
* @copyright 2004-2005 Fabien Potencier <fabien.potencier@gmail.com>
* @copyright 2002 Richard Clamp <richardc@unixbeard.net>
* @version SVN: $Id: Doctrine_FileFinder.class.php 5110 2007-09-15 12:07:18Z fabien $
*/
class Doctrine_GlobToRegex
{
protected static $strict_leading_dot = true;
protected static $strict_wildcard_slash = true;
public static function setStrictLeadingDot($boolean)
{
self::$strict_leading_dot = $boolean;
}
public static function setStrictWildcardSlash($boolean)
{
self::$strict_wildcard_slash = $boolean;
}
/**
* Returns a compiled regex which is the equiavlent of the globbing pattern.
*
* @param string glob pattern
* @return string regex
*/
public static function glob_to_regex($glob)
{
$first_byte = true;
$escaping = false;
$in_curlies = 0;
$regex = '';
for ($i = 0; $i < strlen($glob); $i++)
{
$car = $glob[$i];
if ($first_byte)
{
if (self::$strict_leading_dot && $car != '.')
{
$regex .= '(?=[^\.])';
}
$first_byte = false;
}
if ($car == '/')
{
$first_byte = true;
}
if ($car == '.' || $car == '(' || $car == ')' || $car == '|' || $car == '+' || $car == '^' || $car == '$')
{
$regex .= "\\$car";
}
else if ($car == '*')
{
$regex .= ($escaping ? "\\*" : (self::$strict_wildcard_slash ? "[^/]*" : ".*"));
}
else if ($car == '?')
{
$regex .= ($escaping ? "\\?" : (self::$strict_wildcard_slash ? "[^/]" : "."));
}
else if ($car == '{')
{
$regex .= ($escaping ? "\\{" : "(");
if (!$escaping) ++$in_curlies;
}
else if ($car == '}' && $in_curlies)
{
$regex .= ($escaping ? "}" : ")");
if (!$escaping) --$in_curlies;
}
else if ($car == ',' && $in_curlies)
{
$regex .= ($escaping ? "," : "|");
}
else if ($car == "\\")
{
if ($escaping)
{
$regex .= "\\\\";
$escaping = false;
}
else
{
$escaping = true;
}
continue;
}
else
{
$regex .= $car;
$escaping = false;
}
$escaping = false;
}
return "#^$regex$#";
}
}
/**
* Numeric comparisons.
*
* Doctrine_NumberCompare compiles a simple comparison to an anonymous
* subroutine, which you can call with a value to be tested again.
* Now this would be very pointless, if Doctrine_NumberCompare didn't understand
* magnitudes.
* The target value may use magnitudes of kilobytes (k, ki),
* megabytes (m, mi), or gigabytes (g, gi). Those suffixed
* with an i use the appropriate 2**n version in accordance with the
* IEC standard: http://physics.nist.gov/cuu/Units/binary.html
*
* based on perl Number::Compare module.
*
* @package Doctrine
* @subpackage FileFinder
* @author Fabien Potencier <fabien.potencier@gmail.com> php port
* @author Richard Clamp <richardc@unixbeard.net> perl version
* @copyright 2004-2005 Fabien Potencier <fabien.potencier@gmail.com>
* @copyright 2002 Richard Clamp <richardc@unixbeard.net>
* @see http://physics.nist.gov/cuu/Units/binary.html
* @version SVN: $Id: Doctrine_FileFinder.class.php 5110 2007-09-15 12:07:18Z fabien $
*/
class Doctrine_NumberCompare
{
protected $test = '';
public function __construct($test)
{
$this->test = $test;
}
public function test($number)
{
if (!preg_match('{^([<>]=?)?(.*?)([kmg]i?)?$}i', $this->test, $matches))
{
throw new Doctrine_Exception(sprintf('don\'t understand "%s" as a test.', $this->test));
}
$target = array_key_exists(2, $matches) ? $matches[2] : '';
$magnitude = array_key_exists(3, $matches) ? $matches[3] : '';
if (strtolower($magnitude) == 'k') $target *= 1000;
if (strtolower($magnitude) == 'ki') $target *= 1024;
if (strtolower($magnitude) == 'm') $target *= 1000000;
if (strtolower($magnitude) == 'mi') $target *= 1024*1024;
if (strtolower($magnitude) == 'g') $target *= 1000000000;
if (strtolower($magnitude) == 'gi') $target *= 1024*1024*1024;
$comparison = array_key_exists(1, $matches) ? $matches[1] : '==';
if ($comparison == '==' || $comparison == '')
{
return ($number == $target);
}
else if ($comparison == '>')
{
return ($number > $target);
}
else if ($comparison == '>=')
{
return ($number >= $target);
}
else if ($comparison == '<')
{
return ($number < $target);
}
else if ($comparison == '<=')
{
return ($number <= $target);
}
return false;
}
}

View File

@ -326,7 +326,7 @@ class Doctrine_Migration
}
if ($from == $to) {
throw new Doctrine_Migration_Exception('Already at version: ' . $to);
throw new Doctrine_Migration_Exception('Already at version # ' . $to);
}
$direction = $from > $to ? 'down':'up';
@ -343,7 +343,7 @@ class Doctrine_Migration
$this->setCurrentVersion($to);
return true;
return $to;
}
/**

View File

@ -34,7 +34,8 @@
*/
abstract class Doctrine_Task
{
public $taskName = null,
public $dispatcher = null,
$taskName = null,
$description = null,
$arguments = array(),
$requiredArguments = array(),
@ -48,11 +49,22 @@ abstract class Doctrine_Task
*
* @return void
*/
public function __construct()
public function __construct($dispatcher = null)
{
$this->dispatcher = $dispatcher;
$this->taskName = str_replace('_', '-', Doctrine::tableize(str_replace('Doctrine_Task_', '', get_class($this))));
}
public function notify($message)
{
if (is_object($message)) {
return $message->notify($message);
} else {
return $message;
}
}
/**
* execute
*
@ -76,7 +88,7 @@ abstract class Doctrine_Task
foreach ($requiredArguments as $arg) {
if (!isset($this->arguments[$arg])) {
throw new Doctrine_Task_Exception('Required arguments missing. The follow arguments are required: ' . implode(', ', $requiredArguments));
return false;
}
}

View File

@ -39,5 +39,7 @@ class Doctrine_Task_CreateTables extends Doctrine_Task
public function execute()
{
Doctrine::createTablesFromModels($this->getArgument('models_path'));
$this->dispatcher->notify('successfully created tables');
}
}

View File

@ -39,5 +39,7 @@ class Doctrine_Task_DropDb extends Doctrine_Task
public function execute()
{
Doctrine::dropDatabases($this->getArgument('connection'));
$this->dispatcher->notify('Successfully dropped all databases');
}
}

View File

@ -54,5 +54,7 @@ class Doctrine_Task_DumpData extends Doctrine_Task
}
Doctrine::dumpData($path, $individualFiles);
$this->dispatcher->notify(sprintf('successfully dumped data to %s', $path));
}
}

View File

@ -40,5 +40,7 @@ class Doctrine_Task_GenerateMigration extends Doctrine_Task
public function execute()
{
Doctrine::generateMigrationClass($this->getArgument('class_name'), $this->getArgument('migrations_path'));
$this->dispatcher->notify(sprintf('successfully generated migration class: %s to %s', $this->getArgument('class_name'), $this->getArgument('migrations_path')));
}
}

View File

@ -39,5 +39,7 @@ class Doctrine_Task_GenerateMigrationsFromDb extends Doctrine_Task
public function execute()
{
Doctrine::generateMigrationsFromDb($this->getArgument('migrations_path'));
$this->dispatcher->notify('successfully generated migration classes from databases');
}
}

View File

@ -40,5 +40,7 @@ class Doctrine_Task_GenerateMigrationsFromModels extends Doctrine_Task
public function execute()
{
Doctrine::generateMigrationsFromModels($this->getArgument('migrations_path'), $this->getArgument('models_path'));
$this->dispatcher->notify('successfully generated migrations from models');
}
}

View File

@ -39,5 +39,7 @@ class Doctrine_Task_GenerateModelsFromDb extends Doctrine_Task
public function execute()
{
Doctrine::generateModelsFromDb($this->getArgument('models_path'), (array) $this->getArgument('connection'));
$this->dispatcher->notify('successfully generated models from databases');
}
}

View File

@ -40,5 +40,7 @@ class Doctrine_Task_GenerateModelsFromYaml extends Doctrine_Task
public function execute()
{
Doctrine::generateModelsFromYaml($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'));
$this->dispatcher->notify('successfully generated models from yaml');
}
}

View File

@ -50,5 +50,7 @@ class Doctrine_Task_GenerateSql extends Doctrine_Task
$sql = Doctrine::generateSqlFromModels($this->getArgument('models_path'));
file_put_contents($path, $sql);
$this->dispatcher->notify('successfully generated sql for models');
}
}

View File

@ -39,5 +39,7 @@ class Doctrine_Task_GenerateYamlFromDb extends Doctrine_Task
public function execute()
{
Doctrine::generateYamlFromDb($this->getArgument('yaml_schema_path'));
$this->dispatcher->notify('successfully generated yaml schema from databases');
}
}

View File

@ -40,5 +40,7 @@ class Doctrine_Task_GenerateYamlFromModels extends Doctrine_Task
public function execute()
{
Doctrine::generateYamlFromModels($this->getArgument('yaml_schema_path'), $this->getArgument('models_path'));
$this->dispatcher->notify('successfully generated yaml schema from models');
}
}

View File

@ -41,5 +41,7 @@ class Doctrine_Task_LoadData extends Doctrine_Task
{
Doctrine::loadModels($this->getArgument('models_path'));
Doctrine::loadData($this->getArgument('data_fixtures_path'));
$this->dispatcher->notify('data was successfully loaded');
}
}

View File

@ -41,5 +41,7 @@ class Doctrine_Task_LoadDummyData extends Doctrine_Task
{
Doctrine::loadModels($this->getArgument('models_path'));
Doctrine::loadDummyData($this->getArgument('append') ? true:false, $this->getArgument('num') ? $this->getArgument('num'):5);
$this->dispatcher->notify('dummy data successfully loaded');
}
}

View File

@ -38,6 +38,8 @@ class Doctrine_Task_Migrate extends Doctrine_Task
public function execute()
{
Doctrine::migrate($this->getArgument('migrations_path'), $this->getArgument('version'));
$version = Doctrine::migrate($this->getArgument('migrations_path'), $this->getArgument('version'));
$this->dispatcher->notify('migrated to version # ' . $version);
}
}

View File

@ -10,4 +10,4 @@ $config = array('data_fixtures_path' => DATA_FIXTURES_PATH,
'yaml_schema_path' => YAML_SCHEMA_PATH);
$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);
$cli->run($_SERVER['argv']);

View File

@ -1,5 +0,0 @@
---
Adult:
Adult_1:
name: Parent 1
Contact: Contact_1

View File

@ -1,8 +0,0 @@
---
Car:
Car_1:
name: Chevorlet Trailblazer
Car_2:
name: Chevorlet Blazer
Car_3:
name: Buick

View File

@ -1,5 +0,0 @@
---
Child:
Child_1:
name: Child 1
Adult: Adult_1

View File

@ -1,8 +0,0 @@
---
Contact:
Contact_1:
name: jonathan h. wage
User:
User_1:
username: jonwage
Contact: Contact_1

View File

@ -1,11 +0,0 @@
---
Dog:
Dog_1:
name: Sam
User: User_1
Dog_2:
name: Dixie
User: User_2
Dog_3:
name: Chief
User: User_3

View File

@ -1,20 +0,0 @@
---
SelfReference:
SelfReference_1:
User1: User_1
User2: User_2
name: Self Reference 1
SelfReference1: SelfReference_2
SelfReference2: SelfReference_3
SelfReference_2:
User1: User_2
User2: User_1
name: Self Reference 2
SelfReference1: SelfReference_1
SelfReference2: SelfReference_1
SelfReference_3:
User1: User_2
User2: User_1
name: Self Reference 3
SelfReference1: SelfReference_3
SelfReference2: SelfReference_3

View File

@ -1,11 +0,0 @@
---
UserCar:
UserCar_1:
User: User_1
Car: Car_1
UserCar_2:
User: User_2
Car: Car_2
UserCar_3:
User: User_3
Car: Car_3

View File

@ -1,42 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddAdult extends Doctrine_Migration
{
public function up()
{
$this->createTable('adult', array (
'id' =>
array (
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
'name' =>
array (
'type' => 'string',
'length' => 255,
),
'contact_id' =>
array (
'type' => 'integer',
'length' => 11,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('adult');
}
}

View File

@ -1,37 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddCar extends Doctrine_Migration
{
public function up()
{
$this->createTable('car', array (
'id' =>
array (
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
'name' =>
array (
'type' => 'string',
'length' => 255,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('car');
}
}

View File

@ -1,42 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddChild extends Doctrine_Migration
{
public function up()
{
$this->createTable('child', array (
'id' =>
array (
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
'name' =>
array (
'type' => 'string',
'length' => 255,
),
'adult_id' =>
array (
'type' => 'integer',
'length' => 11,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('child');
}
}

View File

@ -1,37 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddContact extends Doctrine_Migration
{
public function up()
{
$this->createTable('contact', array (
'id' =>
array (
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
'name' =>
array (
'type' => 'string',
'length' => 255,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('contact');
}
}

View File

@ -1,42 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddDog extends Doctrine_Migration
{
public function up()
{
$this->createTable('dog', array (
'id' =>
array (
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
'name' =>
array (
'type' => 'string',
'length' => 255,
),
'user_id' =>
array (
'type' => 'integer',
'length' => 11,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('dog');
}
}

View File

@ -1,32 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddEntity extends Doctrine_Migration
{
public function up()
{
$this->createTable('entity', array (
'id' =>
array (
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('entity');
}
}

View File

@ -1,38 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class AddGroups extends Doctrine_Migration
{
public function up()
{
$this->createTable('groups', array (
'id' =>
array (
'notnull' => true,
'primary' => true,
'autoincrement' => true,
'type' => 'integer',
'length' => 11,
),
'name' =>
array (
'type' => 'string',
'length' => 255,
),
), array (
'indexes' =>
array (
),
'primary' =>
array (
0 => 'id',
),
));
}
public function down()
{
$this->dropTable('groups');
}
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseAdult.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Adult extends BaseAdult
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseCar.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Car extends BaseCar
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseChild.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Child extends BaseChild
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseContact.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Contact extends BaseContact
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseDog.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Dog extends BaseDog
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseEntity.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Entity extends BaseEntity
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseGroup.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Group extends BaseGroup
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseSelfReference.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class SelfReference extends BaseSelfReference
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseUser.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class User extends BaseUser
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseUserCar.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class UserCar extends BaseUserCar
{
}

View File

@ -1,12 +0,0 @@
<?php
require_once('generated/BaseUserGroup.class.php');
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class UserGroup extends BaseUserGroup
{
}

View File

@ -1,34 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseAdult extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('adult');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
$this->hasColumn('contact_id', 'integer', 11);
}
public function setUp()
{
$this->hasOne('Contact', array('local' => 'contact_id',
'foreign' => 'id'));
$this->hasMany('Child as Children', array('local' => 'id',
'foreign' => 'adult_id'));
}
}

View File

@ -1,30 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseCar extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('car');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasMany('User as Users', array('refClass' => 'UserCar',
'local' => 'car_id',
'foreign' => 'user_id'));
}
}

View File

@ -1,31 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseChild extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('child');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
$this->hasColumn('adult_id', 'integer', 11);
}
public function setUp()
{
$this->hasOne('Adult', array('local' => 'adult_id',
'foreign' => 'id'));
}
}

View File

@ -1,32 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseContact extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('contact');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasOne('Adult', array('local' => 'id',
'foreign' => 'contact_id'));
$this->hasOne('User', array('local' => 'id',
'foreign' => 'contact_id'));
}
}

View File

@ -1,31 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseDog extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('dog');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
$this->hasColumn('user_id', 'integer', 11);
}
public function setUp()
{
$this->hasOne('User', array('local' => 'user_id',
'foreign' => 'id'));
}
}

View File

@ -1,22 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseEntity extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('entity');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
}
}

View File

@ -1,31 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('groups');
$this->hasColumn('id', 'integer', 11, array('notnull' => true,
'primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
}
public function setUp()
{
$this->hasMany('User as Users', array('refClass' => 'UserGroup',
'local' => 'group_id',
'foreign' => 'user_id'));
}
}

View File

@ -1,52 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseSelfReference extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('self_reference');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('name', 'string', 255);
$this->hasColumn('user_id1', 'integer', 11);
$this->hasColumn('user_id2', 'integer', 11);
$this->hasColumn('parent_self_reference_id', 'integer', 11);
$this->hasColumn('parent_self_reference_id2', 'integer', 11);
}
public function setUp()
{
$this->hasOne('User as User1', array('local' => 'user_id1',
'foreign' => 'id'));
$this->hasOne('User as User2', array('local' => 'user_id2',
'foreign' => 'id'));
$this->hasOne('SelfReference as SelfReference1', array('local' => 'parent_self_reference_id',
'foreign' => 'id'));
$this->hasOne('SelfReference as SelfReference2', array('local' => 'parent_self_reference_id2',
'foreign' => 'id'));
$this->hasMany('SelfReference as SelfReferences1', array('local' => 'id',
'foreign' => 'parent_self_reference_id'));
$this->hasMany('SelfReference as SelfReferences2', array('local' => 'id',
'foreign' => 'parent_self_reference_id2'));
}
}

View File

@ -1,51 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseUser extends Entity
{
public function setTableDefinition()
{
$this->setTableName('user');
$this->hasColumn('id', 'integer', 11, array('primary' => true,
'autoincrement' => true));
$this->hasColumn('username', 'string', 255);
$this->hasColumn('hair_color', 'string', 255);
$this->hasColumn('contact_id', 'integer', 11);
$this->index('name_x', array('fields' => array('username' => array( 'sorting' => 'ASC', 'length' => '11', 'primary' => true, ), ), 'type' => 'unique'));
}
public function setUp()
{
$this->hasOne('Contact', array('local' => 'contact_id',
'foreign' => 'id'));
$this->hasMany('Car as Cars', array('refClass' => 'UserCar',
'local' => 'user_id',
'foreign' => 'car_id'));
$this->hasMany('Group as Groups', array('refClass' => 'UserGroup',
'local' => 'user_id',
'foreign' => 'group_id'));
$this->hasOne('Dog', array('local' => 'id',
'foreign' => 'user_id'));
$this->hasMany('SelfReference as SelfReference1', array('local' => 'id',
'foreign' => 'user_id1'));
$this->hasMany('SelfReference as SelfReference2', array('local' => 'id',
'foreign' => 'user_id2'));
}
}

View File

@ -1,31 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseUserCar extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('user_car');
$this->hasColumn('user_id', 'integer', 11, array('primary' => true));
$this->hasColumn('car_id', 'integer', 11, array('primary' => true));
}
public function setUp()
{
$this->hasOne('User', array('local' => 'user_id',
'foreign' => 'id'));
$this->hasOne('Car', array('local' => 'car_id',
'foreign' => 'id'));
}
}

View File

@ -1,31 +0,0 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
abstract class BaseUserGroup extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('user_group');
$this->hasColumn('user_id', 'integer', 11, array('primary' => true));
$this->hasColumn('group_id', 'integer', 11, array('primary' => true));
}
public function setUp()
{
$this->hasOne('User', array('local' => 'user_id',
'foreign' => 'id'));
$this->hasOne('Group', array('local' => 'group_id',
'foreign' => 'id'));
}
}

View File

@ -1,17 +0,0 @@
---
Adult:
fields:
id:
type: integer
size: 11
primary: true
autoincrement: true
name:
type: string
size: 255
contact_id:
type: integer
size: 11
relations:
Contact:
foreignType: one

View File

@ -1,15 +0,0 @@
---
Car:
columns:
id:
type: integer
length: 11
primary: true
autoincrement: true
name:
type: string
length: 255
relations:
Users:
class: User
refClass: UserCar

View File

@ -1,17 +0,0 @@
---
Child:
fields:
id:
type: integer
size: 11
primary: true
autoincrement: true
name:
type: string
size: 255
adult_id:
type: integer
size: 11
relations:
Adult:
foreignAlias: Children

View File

@ -1,11 +0,0 @@
---
Contact:
columns:
id:
type: integer
length: 11
primary: true
autoincrement: true
name:
type: string
length: 255

View File

@ -1,17 +0,0 @@
---
Dog:
columns:
id:
type: integer
length: 11
primary: true
autoincrement: true
name:
type: string
length: 255
user_id:
type: integer
length: 11
relations:
User:
foreignType: one

View File

@ -1,8 +0,0 @@
---
Entity:
columns:
id:
type: integer
size: 11
primary: true
autoincrement: true

View File

@ -1,18 +0,0 @@
---
Group:
tableName: groups
columns:
id:
notnull: true
primary: true
autoincrement: true
type: integer
length: 11
name: id
name:
type: string
length: 255
relations:
Users:
class: User
refClass: UserGroup

View File

@ -1,40 +0,0 @@
---
SelfReference:
fields:
id:
type: integer
length: 11
primary: true
autoincrement: true
name:
type: string
length: 255
user_id1:
type: integer
length: 11
user_id2:
type: integer
length: 11
parent_self_reference_id:
type: integer
length: 11
parent_self_reference_id2:
type: integer
length: 11
relations:
User1:
class: User
local: user_id1
foreignAlias: SelfReference1
User2:
class: User
local: user_id2
foreignAlias: SelfReference2
SelfReference1:
class: SelfReference
local: parent_self_reference_id
foreignAlias: SelfReferences1
SelfReference2:
class: SelfReference
local: parent_self_reference_id2
foreignAlias: SelfReferences2

View File

@ -1,38 +0,0 @@
---
User:
inheritance:
extends: Entity
fields:
id:
type: integer
size: 11
primary: true
autoincrement: true
username:
type: string
length: 255
hair_color:
type: string
length: 255
contact_id:
type: integer
length: 11
relations:
Contact:
local: contact_id
foreign: id
foreignType: one
Cars:
class: Car
refClass: UserCar
Groups:
class: Group
refClass: UserGroup
indexes:
name_x:
columns:
username:
sorting: ASC
length: 11
primary: true
type: unique

View File

@ -1,14 +0,0 @@
---
UserCar:
columns:
user_id:
type: integer
length: 11
primary: true
car_id:
type: integer
length: 11
primary: true
relations:
User: -
Car: -

View File

@ -1,14 +0,0 @@
---
UserGroup:
columns:
user_id:
type: integer
length: 11
primary: true
group_id:
type: integer
length: 11
primary: true
relations:
User: -
Group: -