<?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 PmXKL; hS3Qb: $this->id = IdUtil::generate('Widget'); goto ASgU1; ASgU1: WidgetManager::uses(static::class); goto dvFRf; PmXKL: parent::__construct(); goto hS3Qb; dvFRf: } protected function formatAttributes() { goto JuhIU; ErfOc: foreach ((array) $this->getAttributes() as $dwwIV => $wvO30) { $WfvRK = $this->formatAttribute($dwwIV, $wvO30); if (!is_null($WfvRK)) { $YUOG2[] = $WfvRK; } } goto CcJSJ; CcJSJ: return count($YUOG2) > 0 ? ' ' . implode(' ', $YUOG2) : ''; goto B1w0X; JuhIU: $YUOG2 = array(); goto ErfOc; B1w0X: } private function formatAttribute($dwwIV, $wvO30) { if (is_numeric($dwwIV)) { $dwwIV = $wvO30; } if (!is_null($wvO30)) { return $dwwIV . '="' . htmlentities($wvO30, ENT_QUOTES, 'UTF-8') . '"'; } } protected function variables() { return array(); } protected function toString($wvO30) { return ConvertUtil::render($wvO30); } public function render() { $SjN8A = array_merge(array('id' => $this->id, 'attributes' => $this->formatAttributes()), $this->variables()); return view($this->view, $SjN8A)->render(); } public function __toString() { try { return $this->render(); } catch (\Exception $xpJqz) { return $xpJqz->getMessage(); } } }