<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Admin\Layout; use ModStart\Detail\Detail; use ModStart\Form\Form; use ModStart\Grid\Grid; use ModStart\Support\Concern\HasFluentAttribute; class AdminCRUDBuilder { const MODE_GRID = 'grid'; const MODE_DETAIL = 'detail'; const MODE_FORM = 'form'; use HasFluentAttribute; private $mode; protected $fluentAttributes = array('model', 'field'); private $model; private $field; private $grid; private $form; private $detail; public function useModeGrid() { $this->mode = 'grid'; } public function useModeForm() { $this->mode = 'form'; } public function useModeDetail() { $this->mode = 'detail'; } public function init($cWs8n) { goto Txb1N; Txb1N: $this->model = $cWs8n; goto q0iT0; q0iT0: switch ($this->mode) { case 'grid': $this->grid = Grid::make($this->model); break; case 'form': $this->form = Form::make($this->model); break; case 'detail': $this->detail = Detail::make($this->model); break; } goto S_BKy; S_BKy: return $this; goto I111c; I111c: } public function grid() { $this->grid->builder(function (Grid $jfjOt) { if ($this->field) { call_user_func($this->field, $jfjOt); } }); return $this->grid; } public function form() { $this->form->builder(function (Form $wDk8k) { if ($this->field) { call_user_func($this->field, $wDk8k); } }); return $this->form; } public function detail() { $this->detail->builder(function (Detail $dZIpH) { if ($this->field) { call_user_func($this->field, $dZIpH); } }); return $this->detail; } public function mode() { return $this->mode; } public function __call($c6VKG, $lLyBI) { goto vUz89; bZerF: switch ($this->mode) { case 'grid': return call_user_func_array(array($this->grid, $c6VKG), $lLyBI); case 'form': return call_user_func_array(array($this->form, $c6VKG), $lLyBI); case 'detail': return call_user_func_array(array($this->detail, $c6VKG), $lLyBI); } goto VmLNX; vUz89: if ($this->isFluentAttribute($c6VKG)) { return $this->fluentAttribute($c6VKG, $lLyBI); } goto bZerF; VmLNX: throw new \Exception('AdminCRUDBuilder call error : ' . $c6VKG); goto GQ05Q; GQ05Q: } }