File: D:/HostingSpaces/SBogers10/netwerkbrabant.komma.pro/app/KommaApp/Kms/Core/Attributes/KmsText.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\KommaApp\Kms\Core\Attributes;
use View;
class KmsText extends KmsAttribute
{
public $label;
public $template;
public $data;
function __construct($key, $value, array $options = [], array $errors = [], $siteId = null, $languageId = null, $section = null)
{
parent::__construct($key, $value, $options, $errors, $siteId, $languageId, $section);
$this->label = $this->getOption('label', $key);
$this->template = $this->getOption('template', $key);
$this->data = $this->setData($this->getOption('data', $key));
}
public function setData($data)
{
if ($data == '[[value]]') return $this->data = $this->value;
if (is_string($data) && strpos('@', $data) ) {
$data = explode('@', $data);
$method = array_pop($data);
$class = $data[0];
$this->data = \App::make($class)->{$method}($this->siteId, $this->languageId, $this->relatedId);
return $this->data;
}
return $this->data = $data;
}
public function getData()
{
return $this->data;
}
public function render()
{
return View::make('kms/attributes.text', [
'attribute' => $this
]);
}
}