Skip to content
Browse files

Extended behavior

  • Loading branch information...
1 parent 9df0b7d commit b791e9f2a83781534632c60729e7e95f5abb0b7d @mpscholten committed Oct 5, 2013
Showing with 27 additions and 0 deletions.
  1. +27 −0 src/Propel/Generator/Model/Behavior.php
View
27 src/Propel/Generator/Model/Behavior.php
@@ -405,4 +405,31 @@ public function getAdditionalBuilders()
{
return $this->additionalBuilders;
}
+
+ /**
+ * Returns the path to the attribute template.
+ */
+ public function getTemplateDirectory()
+ {
+ $path = $this->getDirname() . DIRECTORY_SEPARATOR . 'templates';
+ if(!file_exists($path)) {
+ return null;
+ }
+
+ return $path;
+ }
+
+ public function getTemplateNamespace()
+ {
+ $fullClassName = explode('\\', get_class($this));
+ $simpleClassName = end($fullClassName);
+
+ // converts the classname from CamelCase to camel_case (see http://stackoverflow.com/a/1993772)
+ preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $simpleClassName, $matches);
+ $ret = $matches[0];
+ foreach ($ret as &$match) {
+ $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
+ }
+ return implode('_', $ret);
+ }
}

0 comments on commit b791e9f

Please sign in to comment.
Something went wrong with that request. Please try again.