-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
deccd18
commit 87a1fad
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |