Skip to content

Commit

Permalink
Adding columnMap function to Frogg\Model
Browse files Browse the repository at this point in the history
  • Loading branch information
magroski committed Sep 1, 2017
1 parent 8c27433 commit 82d06af
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
class Model extends PhalconModel
{

public function columnMap()
{
$columnMap = [];
$child = new static();
$reflect = new \ReflectionObject($child);
$props = $reflect->getProperties(\ReflectionProperty::IS_PUBLIC);
foreach ($props as $prop) {
if (substr($prop->getName(), 0, 1) !== '_') {
$output = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $prop->getName()));
$columnMap[$output] = $prop->getName();
}
}

return $columnMap;
}

public function permalinkFor($attribute)
{
$tmp = new Permalink($this->$attribute);
Expand Down

0 comments on commit 82d06af

Please sign in to comment.