Browse files

Allowed FQCN as behavior names

  • Loading branch information...
1 parent c3e0e77 commit eb5240ee7536dbc5fa71c30f4e09c1fc70ab23cf @willdurand willdurand committed Dec 21, 2011
View
11 src/Propel/Generator/Model/XmlElement.php
@@ -147,10 +147,15 @@ public function getConfiguredBehavior($bname)
}
}
- $gen = new PhpNameGenerator();
- $phpName = $gen->generateName(array($bname, PhpNameGenerator::CONV_METHOD_PHPNAME));
+ if (false !== strpos($bname, '\\')) {
+ $class = $bname;
+ } else {
+ $gen = new PhpNameGenerator();
+ $phpName = $gen->generateName(array($bname, PhpNameGenerator::CONV_METHOD_PHPNAME));
+ $class = sprintf('\\Propel\\Generator\\Behavior\\%s\\%sBehavior', $phpName, $phpName);
+ }
- if(class_exists($class = sprintf('\\Propel\\Generator\\Behavior\\%s\\%sBehavior', $phpName, $phpName))) {
+ if (class_exists($class)) {
return $class;
}
View
2 tests/Fixtures/bookstore/behavior-add-class-schema.xml
@@ -4,7 +4,7 @@
<table name="add_class_table">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
- <behavior name="add_class" />
+ <behavior name="\Propel\Tests\Helpers\Bookstore\Behavior\AddClassBehavior" />
</table>
</database>
View
4 tests/Fixtures/bookstore/behavior-schema.xml
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<database name="bookstore-behavior" defaultIdMethod="native" package="behavior.alternative_coding_standards" namespace="Propel\Tests\Bookstore\Behavior">
- <behavior name="do_nothing">
+ <behavior name="\Propel\Tests\Helpers\Bookstore\Behavior\DoNothingBehavior">
<parameter name="foo" value="bar" />
</behavior>
<table name="table3">
<column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" />
<column name="title" type="VARCHAR" size="100" primaryString="true" />
- <behavior name="test_all_hooks" />
+ <behavior name="\Propel\Tests\Helpers\Bookstore\Behavior\Testallhooksbehavior" />
<behavior name="alternative_coding_standards" />
</table>
View
5 tests/Fixtures/bookstore/build.properties.dist
@@ -30,8 +30,3 @@ propel.database.password = ##DATABASE_PASSWORD##
# propel.database.createUrl = (doesn't apply for SQLite, since db is auto-created)
propel.targetPackage = bookstore
-
-# We need to test behavior hooks
-propel.behavior.test_all_hooks.class = \Propel\Tests\Helpers\Bookstore\Behavior\Testallhooksbehavior
-propel.behavior.do_nothing.class = \Propel\Tests\Helpers\Bookstore\Behavior\DonothingBehavior
-propel.behavior.add_class.class = \Propel\Tests\Helpers\Bookstore\Behavior\AddClassBehavior

0 comments on commit eb5240e

Please sign in to comment.