public function actionCallback() { $config = NgRest::findConfig(Yii::$app->request->get('ngrestConfigHash', false)); $render = new RenderActiveWindowCallback(); $ngrest = new NgRest($config); return $ngrest->render($render); }
private static function findPluginInstance($field, array $plugin, $tableName) { if (!isset(self::$_pluginInstances[$tableName][$field])) { self::$_pluginInstances[$tableName][$field] = NgRest::createPluginObject($plugin['type']['class'], $plugin['name'], $plugin['alias'], $plugin['i18n'], $plugin['type']['args']); } return self::$_pluginInstances[$tableName][$field]; }
public function actionIndex($inline = false, $relation = false, $arrayIndex = false, $modelClass = false) { $apiEndpoint = $this->model->ngRestApiEndpoint(); $config = $this->model->getNgRestConfig(); /* // partial concept integration for $configClass = $this->module->getLinkedNgRestConfig($apiEndpoint); if ($configClass) { // $class = Yii::createObject($configClass, ['apiEndpoint' => '', 'primaryKey' => '..']); $config = false; } else { $config = $this->model->getNgRestConfig(); } */ if (!$config) { throw new Exception("Provided NgRest config for controller '' is invalid."); } if ($relation && $arrayIndex !== false && $modelClass !== false) { $config->relationCall = ['id' => $relation, 'arrayIndex' => $arrayIndex, 'modelClass' => $modelClass]; } // apply config informations $config->filters = $this->model->ngRestFilters(); $config->defaultOrder = $this->model->ngRestListOrder(); $userSortSettings = Yii::$app->adminuser->identity->setting->get('ngrestorder.admin/' . $apiEndpoint, false); if ($userSortSettings && is_array($userSortSettings)) { $config->defaultOrder = [$userSortSettings['field'] => $userSortSettings['sort']]; } $config->attributeGroups = $this->model->ngRestAttributeGroups(); $config->groupByField = $this->model->ngRestGroupByField(); $rel = []; foreach ($this->model->ngRestRelations() as $key => $item) { $rel[] = ['label' => $item['label'], 'apiEndpoint' => $item['apiEndpoint'], 'arrayIndex' => $key, 'modelClass' => base64_encode($this->model->className())]; } $config->relations = $rel; $ngrest = new NgRest($config); $crud = new RenderCrud(); if ($relation) { $crud->viewFile = '@admin/views/ngrest/render/crud_relation.php'; } return $ngrest->render($crud); }
private function renderElementPlugins($configContext, $typeConfig, $elmnId, $elmnName, $elmnModel, $elmnAlias, $elmni18n) { $obj = NgRest::createPluginObject($typeConfig['class'], $elmnName, $elmnAlias, $elmni18n, $typeConfig['args']); $method = 'render' . ucfirst($configContext); $html = $obj->{$method}($elmnId, $elmnModel); return is_array($html) ? implode(" ", $html) : $html; }