Permalink
Browse files

Merge with Propel/master

  • Loading branch information...
rozwell committed Aug 4, 2012
1 parent 573fe8c commit 242350646cd61ef3a70c2bf13a088443e6d45d39
Showing with 850 additions and 491 deletions.
  1. +44 −0 CHANGELOG
  2. +1 −1 generator/build.properties-sample
  3. +2 −1 generator/default.properties
  4. +1 −1 generator/lib/behavior/nestedset/NestedSetBehaviorObjectBuilderModifier.php
  5. +14 −10 generator/lib/builder/om/ExtensionQueryBuilder.php
  6. +105 −60 generator/lib/builder/om/OMBuilder.php
  7. +15 −12 generator/lib/builder/om/PHP5ExtensionObjectBuilder.php
  8. +14 −10 generator/lib/builder/om/PHP5ExtensionPeerBuilder.php
  9. +289 −274 generator/lib/builder/om/PHP5ObjectBuilder.php
  10. +16 −11 generator/lib/builder/om/PHP5PeerBuilder.php
  11. +35 −24 generator/lib/builder/om/QueryBuilder.php
  12. +3 −3 generator/lib/builder/util/XmlToAppData.php
  13. +2 −2 generator/lib/config/QuickGeneratorConfig.php
  14. +12 −3 generator/lib/model/Table.php
  15. +13 −10 generator/lib/platform/DefaultPlatform.php
  16. +4 −4 generator/lib/platform/MysqlPlatform.php
  17. +3 −3 generator/lib/platform/PropelPlatformInterface.php
  18. +0 −1 generator/lib/platform/SqlitePlatform.php
  19. +3 −3 generator/lib/util/PropelQuickBuilder.php
  20. +1 −1 runtime/lib/Propel.php
  21. +39 −1 runtime/lib/collection/PropelObjectCollection.php
  22. +59 −52 runtime/lib/om/BaseObject.php
  23. +10 −0 test/fixtures/generator/behavior/Foobar.php
  24. +3 −3 test/testsuite/generator/behavior/DelegateBehaviorTest.php
  25. +32 −0 test/testsuite/generator/behavior/NamespacedBehaviorTest.php
  26. +16 −0 test/testsuite/generator/model/TableTest.php
  27. +1 −1 test/testsuite/runtime/collection/PropelCollectionTest.php
  28. +113 −0 test/testsuite/runtime/collection/PropelObjectCollectionTest.php
View
@@ -1,5 +1,49 @@
# Changelog Of The Propel 1.6 Branch #
+## 2012-07-30: Version 1.6.7 ##
+
+38cfc9e Update generator/build.properties-sample
+f90dfa9 fix for issue 425
+74ee4e1 fix for issue 425
+88e21e6 Avoid blank line in object stub class
+8709d3a Fix tests
+cefc9ef More CS fixes
+e1e1078 Fix doc blocks
+29c9db3 Fix NULL => null
+3c1717b Improve code generation to follow PSR recommendations
+6bae0ca Changed FIXME to TODO
+bfef0d7 Changed comments
+5e9dfc1 PropelSQLParser with delimiter and fixed tests
+39d7958 fix for issue 425
+9667675 SQL Parser Delimiter Tests
+8cafbd6 Merge remote-tracking branch 'upstream/master' into delimiter-trigger-parser
+5522fbf fix test to pass on platform with EOF != \n
+cad1ac6 fix test 2 new relations added to book ;) for issue #421
+a9097da this fix issue #409 thank to toaotc for the patch
+2ca7067 add test to prove issue #409
+e84c67c add chaining in PropelObjectCollection::toKeyValue
+5dd5394 Revert "Fix platform loading" as it breaks multiple builds using the runtime config
+55fef69 Fix regression that removed Persistent interfaces in base classes
+d87e9a5 Add test that prove a regression
+7c7a608 Fix composer config
+c476e50 Add generator classes to the classmap
+0d1515d Added column positioning ability to mysql migration
+66e7a59 fixes translateFieldname and concrete inheritance
+3c891ed add test to show the inheritance issue with php5.4
+66f91c9 Fix platform loading
+2874edb fix call on a non object ;)
+790b3e4 [aggregate_column behavior] computeCall call reduced from n+1 to 1 or 2 fix #403, add computeCall on main object save() add isAlreadyInSave(),
+ddd028c add test to prove to much query on aggregate_column behavior
+c36fc7f Add back previous include but change the order of the include path
+c107e8e Issue #388: Fix propel-gen path issues Fixes an issue with the check for the propel-gen home-path in propel-gen script Fixes an issue with classes being redeclared because of custom include in phing.php (code is not there in the phing.php version from phing itself)
+9731032 Fix collection cache overriding existing one when related object are fetched with criteria
+f371602 Fix data loss where parent object won't save related objects when fetched with criteria
+3a3ad2c Fixed Versionable Object Modifier not to reload object collection after populateFromVersion
+dde4460 Fix joining related object
+abc7fc8 Change ObjectBuilder to reload related objects when collection is partially loaded
+05b7e1d Fixed possible bug
+5d9517a Improved SQLParser to work with triggers in additional .sql files
+
## 2012-07-02: Version 1.6.6 ##
17edd0f Prepare 1.6.6 release
@@ -84,7 +84,7 @@ propel.home = .
# or php4 (experimental).
#
# packageObjectModel
-# Sets whether Propel is packaging ObjectModel fro several
+# Sets whether Propel is packaging ObjectModel for several
# [package].schema.xml files. The <database package="packageName">
# attribute has to be set then. (warning: this is experimental!)
#
@@ -16,7 +16,7 @@
#
# -------------------------------------------------------------------
-propel.version = 1.6.7-dev
+propel.version = 1.6.7
propel.home = .
@@ -86,6 +86,7 @@ propel.addGenericAccessors = true
propel.addGenericMutators = true
propel.addSaveMethod = true
propel.addTimeStamp = false
+propel.addClassLevelComment = true
propel.addValidateMethod = true
propel.addIncludes = false
propel.addHooks = true
@@ -716,7 +716,7 @@ public function addNestedSetChild($objectName)
if (\$this->collNestedSetChildren === null) {
\$this->initNestedSetChildren();
}
- if (!\$this->collNestedSetChildren->contains($objectName)) { // only add it if the **same** object is not already associated
+ if (!in_array($objectName, \$this->collNestedSetChildren->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
\$this->collNestedSetChildren[]= $objectName;
{$objectName}->setParent(\$this);
}
@@ -56,30 +56,34 @@ protected function addClassOpen(&$script)
$tableDesc = $table->getDescription();
$baseClassname = $this->getQueryBuilder()->getClassname();
- $script .= "
+ if ($this->getBuildProperty('addClassLevelComment')) {
+ $script .= "
/**
* Skeleton subclass for performing query and update operations on the '$tableName' table.
*
* $tableDesc
*";
- if ($this->getBuildProperty('addTimeStamp')) {
- $now = strftime('%c');
- $script .= "
+ if ($this->getBuildProperty('addTimeStamp')) {
+ $now = strftime('%c');
+ $script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
- }
- $script .= "
+ }
+ $script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.".$this->getPackage()."
- */
-class ".$this->getClassname()." extends $baseClassname {
-";
+ */";
+ }
+
+ $script .= "
+class ".$this->getClassname()." extends $baseClassname
+{";
}
/**
@@ -102,7 +106,7 @@ protected function addClassBody(&$script)
protected function addClassClose(&$script)
{
$script .= "
-} // " . $this->getClassname() . "
+}
";
$this->applyBehaviorModifier('extensionQueryFilter', $script, "");
}
@@ -44,24 +44,28 @@ public function build()
$this->validateModel();
$script = '';
+
if ($this->isAddIncludes()) {
$this->addIncludes($script);
}
+
$this->addClassOpen($script);
$this->addClassBody($script);
$this->addClassClose($script);
if ($useStatements = $this->getUseStatements($ignoredNamespace = $this->getNamespace())) {
$script = $useStatements . $script;
}
+
if ($namespaceStatement = $this->getNamespaceStatement()) {
$script = $namespaceStatement . $script;
}
- //if($this->getTable()->getName() == 'book_club_list') die($ignoredNamespace);
- return "<" . "?php
+ $script = "<?php
" . $script;
+
+ return $this->clean($script);
}
/**
@@ -498,66 +502,107 @@ protected function isAddIncludes()
}
/**
- * Checks whether any registered behavior on that table has a modifier for a hook
- * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
- * @param string $modifier The name of the modifier object providing the method in the behavior
- * @return boolean
- */
- public function hasBehaviorModifier($hookName, $modifier)
- {
- $modifierGetter = 'get' . $modifier;
- foreach ($this->getTable()->getBehaviors() as $behavior) {
- if (method_exists($behavior->$modifierGetter(), $hookName)) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Checks whether any registered behavior on that table has a modifier for a hook
- * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
- * @param string $modifier The name of the modifier object providing the method in the behavior
+ * Checks whether any registered behavior on that table has a modifier for a hook
+ * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
+ * @param string $modifier The name of the modifier object providing the method in the behavior
+ * @return boolean
+ */
+ public function hasBehaviorModifier($hookName, $modifier)
+ {
+ $modifierGetter = 'get' . $modifier;
+ foreach ($this->getTable()->getBehaviors() as $behavior) {
+ if (method_exists($behavior->$modifierGetter(), $hookName)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks whether any registered behavior on that table has a modifier for a hook
+ * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
+ * @param string $modifier The name of the modifier object providing the method in the behavior
* @param string &$script The script will be modified in this method.
- */
- public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = " ")
- {
- $modifierGetter = 'get' . $modifier;
- foreach ($this->getTable()->getBehaviors() as $behavior) {
- $modifier = $behavior->$modifierGetter();
- if (method_exists($modifier, $hookName)) {
- if (strpos($hookName, 'Filter') !== false) {
- // filter hook: the script string will be modified by the behavior
- $modifier->$hookName($script, $this);
- } else {
- // regular hook: the behavior returns a string to append to the script string
- if (!$addedScript = $modifier->$hookName($this)) {
- continue;
- }
- $script .= "
+ */
+ public function applyBehaviorModifierBase($hookName, $modifier, &$script, $tab = " ")
+ {
+ $modifierGetter = 'get' . $modifier;
+ foreach ($this->getTable()->getBehaviors() as $behavior) {
+ $modifier = $behavior->$modifierGetter();
+
+ if (method_exists($modifier, $hookName)) {
+ if (strpos($hookName, 'Filter') !== false) {
+ // filter hook: the script string will be modified by the behavior
+ $modifier->$hookName($script, $this);
+ } else {
+ // regular hook: the behavior returns a string to append to the script string
+ if (!$addedScript = $modifier->$hookName($this)) {
+ continue;
+ }
+
+ $script .= "
" . $tab . '// ' . $behavior->getName() . " behavior
";
- $script .= preg_replace('/^/m', $tab, $addedScript);
- }
- }
- }
- }
-
- /**
- * Checks whether any registered behavior content creator on that table exists a contentName
- * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname"
- * @param string $modifier The name of the modifier object providing the method in the behavior
- */
- public function getBehaviorContentBase($contentName, $modifier)
- {
- $modifierGetter = 'get' . $modifier;
- foreach ($this->getTable()->getBehaviors() as $behavior) {
- $modifier = $behavior->$modifierGetter();
- if (method_exists($modifier, $contentName)) {
- return $modifier->$contentName($this);
- }
- }
- }
+ $script .= preg_replace('/^/m', $tab, $addedScript);
+ }
+ }
+ }
+ }
+ /**
+ * Checks whether any registered behavior content creator on that table exists a contentName
+ * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname"
+ * @param string $modifier The name of the modifier object providing the method in the behavior
+ */
+ public function getBehaviorContentBase($contentName, $modifier)
+ {
+ $modifierGetter = 'get' . $modifier;
+ foreach ($this->getTable()->getBehaviors() as $behavior) {
+ $modifier = $behavior->$modifierGetter();
+ if (method_exists($modifier, $contentName)) {
+ return $modifier->$contentName($this);
+ }
+ }
+ }
+
+ /**
+ * Most of the code comes from the PHP-CS-Fixer project
+ */
+ private function clean($content)
+ {
+ // trailing whitespaces
+ $content = preg_replace('/[ \t]*$/m', '', $content);
+
+ // indentation
+ $content = preg_replace_callback('/^([ \t]+)/m', function ($matches) use ($content) {
+ return str_replace("\t", ' ', $matches[0]);
+ }, $content);
+
+ // line feed
+ $content = str_replace("\r\n", "\n", $content);
+
+ // Unused "use" statements
+ preg_match_all('/^use (?P<class>[^\s;]+)(?:\s+as\s+(?P<alias>.*))?;/m', $content, $matches, PREG_SET_ORDER);
+ foreach ($matches as $match) {
+ if (isset($match['alias'])) {
+ $short = $match['alias'];
+ } else {
+ $parts = explode('\\', $match['class']);
+ $short = array_pop($parts);
+ }
+
+ preg_match_all('/\b'.$short.'\b/i', str_replace($match[0]."\n", '', $content), $m);
+ if (!count($m[0])) {
+ $content = str_replace($match[0]."\n", '', $content);
+ }
+ }
+
+ // end of line
+ if (strlen($content) && "\n" != substr($content, -1)) {
+ $content = $content."\n";
+ }
+
+ return $content;
+ }
}
@@ -77,30 +77,34 @@ protected function addClassOpen(&$script)
break;
}
- $script .= "
+ if ($this->getBuildProperty('addClassLevelComment')) {
+ $script .= "
/**
* Skeleton subclass for representing a row from the '$tableName' table.
*
* $tableDesc
*";
- if ($this->getBuildProperty('addTimeStamp')) {
- $now = strftime('%c');
- $script .= "
+ if ($this->getBuildProperty('addTimeStamp')) {
+ $now = strftime('%c');
+ $script .= "
* This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
*
* $now
*";
- }
- $script .= "
+ }
+ $script .= "
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
* @package propel.generator.".$this->getPackage()."
- */
-".($table->isAbstract() ? "abstract " : "")."class ".$this->getClassname()." extends $baseClassname {
-";
+ */";
+ }
+
+ $script .= "
+".($table->isAbstract() ? "abstract " : "")."class ".$this->getClassname()." extends $baseClassname
+{";
}
/**
@@ -122,9 +126,8 @@ protected function addClassBody(&$script)
protected function addClassClose(&$script)
{
$script .= "
-} // " . $this->getClassname() . "
+}
";
$this->applyBehaviorModifier('extensionObjectFilter', $script, "");
}
-
-} // PHP5ExtensionObjectBuilder
+}
Oops, something went wrong.

0 comments on commit 2423506

Please sign in to comment.