Skip to content

Commit

Permalink
Added feature to specify the phpVisiblity in the database model gener…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
yannickl88 committed Apr 21, 2016
1 parent 1075b9d commit b718e10
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 .= ")
{
Expand Down Expand Up @@ -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 .= "
Expand All @@ -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 .= ")
{
Expand Down Expand Up @@ -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 .= "
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Column extends XMLElement {
private $description;
private $phpName = null;
private $phpNamingMethod;
private $phpVisiblity = 'public';
private $isNotNull = false;
private $size;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

0 comments on commit b718e10

Please sign in to comment.