<?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; private $fluentAttributes = array('model', 'field', 'gridFilder'); private $model; private $field; private $gridFilder; 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($C6mwl) { goto XMfxY; XMfxY: $this->model = $C6mwl; goto VkS1U; VkS1U: 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 EKhC1; EKhC1: return $this; goto qpsPA; qpsPA: } public function grid() { $this->grid->builder(function (Grid $QnI0I) { if ($this->field) { call_user_func($this->field, $QnI0I); } if ($this->gridFilder) { $QnI0I->filter($this->gridFilder); } }); return $this->grid; } public function form() { $this->form->builder(function (Form $Pl0Cf) { if ($this->field) { call_user_func($this->field, $Pl0Cf); } }); return $this->form; } public function detail() { $this->detail->builder(function (Detail $z3x5T) { if ($this->field) { call_user_func($this->field, $z3x5T); } }); return $this->detail; } public function mode() { return $this->mode; } public function __call($TUuqF, $MVaFK) { goto eHidD; A7_7Q: switch ($this->mode) { case 'grid': return call_user_func_array(array($this->grid, $TUuqF), $MVaFK); case 'form': return call_user_func_array(array($this->form, $TUuqF), $MVaFK); case 'detail': return call_user_func_array(array($this->detail, $TUuqF), $MVaFK); } goto qQKCP; qQKCP: throw new \Exception('AdminCRUDBuilder call error : ' . $TUuqF); goto L6OAO; eHidD: if ($this->isFluentAttribute($TUuqF)) { return $this->fluentAttribute($TUuqF, $MVaFK); } goto A7_7Q; L6OAO: } }