<?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($L2koq) { goto gJ_aV; gJ_aV: $this->model = $L2koq; goto vJzZO; t9M1H: return $this; goto tzd3F; vJzZO: 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 t9M1H; tzd3F: } public function grid() { $this->grid->builder(function (Grid $cRz_h) { if ($this->field) { call_user_func($this->field, $cRz_h); } }); return $this->grid; } public function form() { $this->form->builder(function (Form $yfPYJ) { if ($this->field) { call_user_func($this->field, $yfPYJ); } }); return $this->form; } public function detail() { $this->detail->builder(function (Detail $uvktA) { if ($this->field) { call_user_func($this->field, $uvktA); } }); return $this->detail; } public function mode() { return $this->mode; } public function __call($f0dxO, $RSGSj) { goto IRlOv; v5UyL: throw new \Exception('AdminCRUDBuilder call error : ' . $f0dxO); goto fQah5; XS05F: switch ($this->mode) { case 'grid': return call_user_func_array(array($this->grid, $f0dxO), $RSGSj); case 'form': return call_user_func_array(array($this->form, $f0dxO), $RSGSj); case 'detail': return call_user_func_array(array($this->detail, $f0dxO), $RSGSj); } goto v5UyL; IRlOv: if ($this->isFluentAttribute($f0dxO)) { return $this->fluentAttribute($f0dxO, $RSGSj); } goto XS05F; fQah5: } }