/** * Compile the controller stub. * * @return string */ protected function compileControllerStub() { $stub = $this->files->get(substr(__DIR__, 0, -5) . 'Stubs/controller.stub'); $this->buildStub($this->scaffoldCommandObj->getMeta(), $stub); // $this->replaceValidator($stub); return $stub; }
/** * Replace the schema for the stub. * * @param string $stub * @param string $type * @return $this */ protected function replaceSchema(&$stub) { if ($schema = $this->scaffoldCommandObj->getMeta()['schema']) { $schema = (new SchemaParser())->parse($schema); } $schema = (new SyntaxBuilder())->create($schema, $this->scaffoldCommandObj->getMeta()); $stub = str_replace(['{{schema_up}}', '{{schema_down}}'], $schema, $stub); return $this; }
protected function getFields($ui, $type) { $stubsFields = $this->getStubFields($ui, $type); $stubsFieldsAllow = array_keys($stubsFields); $schemas = $this->getSchemaArray(); $metas = $this->scaffoldCommandObj->getMeta(); $stubs = []; foreach ($schemas as $schema) { $variablesFromField = $this->getVariablesFromField($schema); $fieldType = $variablesFromField['field.type']; if (!in_array($fieldType, $stubsFieldsAllow)) { $fieldType = 'default'; } $stub = $stubsFields[$fieldType]; $stub = $this->buildStub($variablesFromField, $stub); $stub = $this->buildStub($metas, $stub); $stubs[] = $stub; } return join(' ', $stubs); }