<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Widget; use Illuminate\Contracts\Support\Renderable; use Illuminate\Support\Fluent; use ModStart\Core\Util\ConvertUtil; use ModStart\Core\Util\IdUtil; use ModStart\Support\Manager\WidgetManager; class AbstractWidget extends Fluent implements Renderable { protected $view; protected $id; public function __construct() { goto PF8Ho; OLMBY: $this->id = IdUtil::generate('Widget'); goto wRGxq; wRGxq: WidgetManager::uses(static::class); goto UZX4A; PF8Ho: parent::__construct(); goto OLMBY; UZX4A: } protected function formatAttributes() { goto DJ8Yj; DJ8Yj: $STW4e = array(); goto ELxbu; gEpMj: return count($STW4e) > 0 ? ' ' . implode(' ', $STW4e) : ''; goto bxT_1; ELxbu: foreach ((array) $this->getAttributes() as $rvTrU => $gwXrh) { $F6q3h = $this->formatAttribute($rvTrU, $gwXrh); if (!is_null($F6q3h)) { $STW4e[] = $F6q3h; } } goto gEpMj; bxT_1: } private function formatAttribute($rvTrU, $gwXrh) { if (is_numeric($rvTrU)) { $rvTrU = $gwXrh; } if (!is_null($gwXrh)) { return $rvTrU . '="' . htmlentities($gwXrh, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($gwXrh) { return ConvertUtil::render($gwXrh); } public function render() { $OTBPk = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $OTBPk)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $Y5fnH) { return $Y5fnH->getMessage(); } } }