<?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($iPHAm) { goto fMI8Y; fMI8Y: $this->model = $iPHAm; goto iaabD; iaabD: 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 B3oh3; B3oh3: return $this; goto tXCiX; tXCiX: } public function grid() { $this->grid->builder(function (Grid $TzF5r) { if ($this->field) { call_user_func($this->field, $TzF5r); } }); return $this->grid; } public function form() { $this->form->builder(function (Form $aDbJm) { if ($this->field) { call_user_func($this->field, $aDbJm); } }); return $this->form; } public function detail() { $this->detail->builder(function (Detail $S8rqk) { if ($this->field) { call_user_func($this->field, $S8rqk); } }); return $this->detail; } public function mode() { return $this->mode; } public function __call($sQIr6, $g59Hh) { goto xqHkJ; ghpGP: throw new \Exception('AdminCRUDBuilder call error : ' . $sQIr6); goto bocAG; SoQrl: switch ($this->mode) { case 'grid': return call_user_func_array(array($this->grid, $sQIr6), $g59Hh); case 'form': return call_user_func_array(array($this->form, $sQIr6), $g59Hh); case 'detail': return call_user_func_array(array($this->detail, $sQIr6), $g59Hh); } goto ghpGP; xqHkJ: if ($this->isFluentAttribute($sQIr6)) { return $this->fluentAttribute($sQIr6, $g59Hh); } goto SoQrl; bocAG: } }