From b718e1093eac3993e5c990ac6689dae0e5d94396 Mon Sep 17 00:00:00 2001 From: Yannick de Lange Date: Thu, 21 Apr 2016 09:31:37 +0200 Subject: [PATCH] Added feature to specify the phpVisiblity in the database model generation --- .../builder/om/php5/PHP5BasicObjectBuilder.php | 9 ++++++--- .../propel/engine/database/model/Column.php | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php b/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php index 83f4a6a64b..df06619c61 100644 --- a/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php +++ b/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php @@ -324,6 +324,7 @@ public function getPeer() protected function addTemporalAccessor(&$script, $col) { $cfc=$col->getPhpName(); + $vis=$col->getPhpVisiblility(); $clo=strtolower($col->getName()); // these default values are based on the Creole defaults @@ -349,7 +350,7 @@ protected function addTemporalAccessor(&$script, $col) * @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). * @throws PropelException - if unable to convert the date/time to timestamp. */ - public function get$cfc(\$format = ".var_export($defaultfmt, true).""; + $vis function get$cfc(\$format = ".var_export($defaultfmt, true).""; if ($col->isLazyLoad()) $script .= ", \$con = null"; $script .= ") { @@ -393,6 +394,7 @@ public function get$cfc(\$format = ".var_export($defaultfmt, true).""; protected function addGenericAccessor(&$script, $col) { $cfc=$col->getPhpName(); + $vis=$col->getPhpVisiblility(); $clo=strtolower($col->getName()); $script .= " @@ -401,7 +403,7 @@ protected function addGenericAccessor(&$script, $col) * ".$col->getDescription()." * @return ".$col->getPhpNative()." */ - public function get$cfc("; + $vis function get$cfc("; if ($col->isLazyLoad()) $script .= "\$con = null"; $script .= ") { @@ -491,6 +493,7 @@ protected function load$cfc(\$con = null) protected function addMutatorOpen(&$script, Column $col) { $cfc=$col->getPhpName(); + $vis=$col->getPhpVisiblility(); $clo=strtolower($col->getName()); $script .= " @@ -500,7 +503,7 @@ protected function addMutatorOpen(&$script, Column $col) * @param ".$col->getPhpNative()." \$v new value * @return void */ - public function set$cfc(\$v) + $vis function set$cfc(\$v) { "; if ($col->isLazyLoad()) { diff --git a/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Column.php b/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Column.php index df5c6e8dab..bdf0bff357 100644 --- a/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Column.php +++ b/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Column.php @@ -45,6 +45,7 @@ class Column extends XMLElement { private $description; private $phpName = null; private $phpNamingMethod; + private $phpVisiblity = 'public'; private $isNotNull = false; private $size; @@ -149,6 +150,11 @@ protected function setupObject() $this->phpName = $this->getAttribute("phpName"); $this->phpType = $this->getAttribute("phpType"); $this->peerName = $this->getAttribute("peerName"); + $this->phpVisiblity = $this->getAttribute('phpVisibility'); + + if (!in_array($this->phpVisiblity, ['public', 'protected', 'private'])) { + $this->phpVisiblity = 'public'; + } if (empty($this->phpType)) { $this->phpType = null; @@ -918,4 +924,15 @@ public function getSqlString() $sb .= $this->getAutoIncrementString(); return trim($sb); } + + /** + * Return the desired visibility for the column. This can be: 'public', + * 'protected' or 'private'. + * + * @return string + */ + public function getPhpVisiblility() + { + return $this->phpVisiblity; + } }