Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed May 20, 2018
1 parent deccd18 commit 87a1fad
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions src/traits/TActiveRecord.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* @link https://cms.skeeks.com/
* @copyright Copyright (c) 2010 SkeekS
* @license https://cms.skeeks.com/license/
* @author Semenov Alexander <semenov@skeeks.com>
*/

namespace skeeks\cms\traits;

/**
* @property string $asText;
* @property string $asHtml;
*
* @author Semenov Alexander <semenov@skeeks.com>
*/
trait TActiveRecord
{
/**
* @return string
*/
public function __toString()
{
return $this->asText();
}
/**
* @return string
*/
public function asText()
{
$result = [];
$result[] = "#".$this->id;

if (isset($this->name) && is_string($this->name)) {
$result[] = $this->name;
} else if (isset($this->label) && is_string($this->label)) {
$result[] = $this->label;
}

return implode("#", $result);
}

/**
* @return string
*/
public function getAsText()
{
return $this->asText();
}

/**
* @return string
*/
public function getAsHtml()
{
return $this->asHtml();
}

/**
* @return string
*/
public function asHtml()
{
return $this->asText();
}
}

0 comments on commit 87a1fad

Please sign in to comment.