<?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($t5MzD) { goto XWIgp; A66JW: return $this; goto V_a0L; XWIgp: $this->model = $t5MzD; goto SV9Sk; SV9Sk: 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 A66JW; V_a0L: } public function grid() { $this->grid->builder(function (Grid $aGu71) { if ($this->field) { call_user_func($this->field, $aGu71); } }); return $this->grid; } public function form() { $this->form->builder(function (Form $u4AHU) { if ($this->field) { call_user_func($this->field, $u4AHU); } }); return $this->form; } public function detail() { $this->detail->builder(function (Detail $jDI3Z) { if ($this->field) { call_user_func($this->field, $jDI3Z); } }); return $this->detail; } public function mode() { return $this->mode; } public function __call($rPkIY, $HPXJC) { goto mZL5i; i_5mp: switch ($this->mode) { case 'grid': return call_user_func_array(array($this->grid, $rPkIY), $HPXJC); case 'form': return call_user_func_array(array($this->form, $rPkIY), $HPXJC); case 'detail': return call_user_func_array(array($this->detail, $rPkIY), $HPXJC); } goto zYO61; zYO61: throw new \Exception('AdminCRUDBuilder call error : ' . $rPkIY); goto gRe3Q; mZL5i: if ($this->isFluentAttribute($rPkIY)) { return $this->fluentAttribute($rPkIY, $HPXJC); } goto i_5mp; gRe3Q: } }