/** * Handle the command. * * Add a default Module route, language entries etc per Module * */ public function handle() { $module = $this->module; $dest = $module->getPath(); $data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'module_name' => studly_case($module->getSlug())]; $src = __DIR__ . '/../../resources/stubs/module'; try { if (_config('builder.landing_page', $module)) { /* adding routes to the module service provider class (currently, just for the optional landing (home) page) */ $this->processFile("{$dest}/src/" . $data['module_name'] . 'ModuleServiceProvider.php', ['routes' => $src . '/routes.php'], $data); /* adding sections to the module class (currently, just for the optional landing (home) page)*/ $this->processFile("{$dest}/src/" . $data['module_name'] . 'Module.php', ['sections' => $src . '/sections.php'], $data, true); } /* generate sitemap for the module main stream */ if ($stream_slug = _config('builder.sitemap.stream_slug', $module)) { $data['entity_name'] = studly_case(str_singular($stream_slug)); $data['repository_name'] = str_plural($stream_slug); $this->files->parseDirectory("{$src}/config", "{$dest}/resources/config", $data); } /* adding module icon */ $this->processVariable("{$dest}/src/" . $data['module_name'] . 'Module.php', ' "' . _config('builder.icon', $module) . '"', 'protected $icon =', ';'); } catch (\PhpParser\Error $e) { die($e->getMessage()); } }
/** * Handle the command. * */ public function handle() { $module = $this->module; $stream = $this->stream; $assignment = $this->assignment; $destination = $module->getPath(); $entity = __DIR__ . '/../../resources/stubs/entity'; $source = $entity . '/code/{{namespace|studly_case}}/'; /* get the field config params from build.php */ $fieldConfig = _getFieldConfig($module, $stream->getNamespace(), $assignment->getFieldSlug()); /* protect module classes from being overwriten */ $this->files->setAvoidOverwrite(_config('builder.avoid_overwrite', $module)); /* get the template data */ $data = ['config' => _config('builder', $module), 'field_slug' => $assignment->getFieldSlug(), 'vendor' => $module->getVendor(), 'module_slug' => $module->getSlug(), 'namespace' => $stream->getNamespace(), 'stream_slug' => $stream->getSlug(), 'entity_name' => studly_case(str_singular($stream->getSlug())), 'column_template' => $fieldConfig['column_template']]; $entityDest = $destination . '/src/' . (_config('builder.group', $module) ? $data['namespace'] . '/' : '') . $data['entity_name']; /* get the assigned class name, i.e. TextFieldType */ $fieldTypeClassName = _getFieldTypeClassName($assignment); /* (1) process the form builder class */ if (!$fieldConfig['hide_field']) { $this->processFormBuilder($entityDest . '/Form/' . $data['entity_name'] . 'FormBuilder.php', $entity . '/templates/field/form/', $fieldTypeClassName, $data); } /* (2) process the table column class */ if (!$fieldConfig['hide_column']) { $this->processTableColumns($entityDest . '/Table/' . $data['entity_name'] . 'TableColumns.php', $entity . '/templates/field/table/' . ($data['column_template'] ? 'template/' : ''), $fieldTypeClassName, $data); } /* (3) process the field language file */ $this->processFile($destination . '/resources/lang/en/field.php', [$data['field_slug'] => $entity . '/templates/module/field.php'], $data); }
/** * Handle the command. * */ public function handle() { $stream = $this->stream; $module = $this->module; $entityPath = __DIR__ . '/../../resources/stubs/entity'; $modulePath = __DIR__ . '/../../resources/stubs/module'; $dest = $module->getPath(); /* seed file path for this entity */ $seedFile = "{$dest}/resources/seeders/" . strtolower(str_singular($stream->getSlug())) . ".php"; $data = ['config' => _config('builder', $module), 'vendor' => $module->getVendor(), 'namespace' => $stream->getNamespace(), 'module_slug' => $module->getSlug(), 'stream_slug' => $stream->getSlug(), 'entity_name' => studly_case(str_singular($stream->getSlug())), 'seeder_data' => file_exists($seedFile) ? file_get_contents($seedFile) : '']; $moduleName = studly_case($data['module_slug']); /* protect module classes from being overwriten */ $this->files->setAvoidOverwrite(_config('builder.avoid_overwrite', $module)); /* initially, copy the entity template files to the module src folder */ if (_config('builder.group', $module)) { $this->files->parseDirectory($entityPath . "/code/", "{$dest}/src", $data); } else { $this->files->parseDirectory($entityPath . "/code/{{namespace|studly_case}}/", "{$dest}/src", $data); $this->files->parseDirectory($entityPath . "/code/Http", "{$dest}/src/Http", $data); } /* create an empty seeder if it does not exist */ $this->put("{$dest}/resources/seeders/" . strtolower($data['entity_name']) . '.php', '', true); try { /* stitch the entity with the module classes */ $this->processFile("{$dest}/src/{$moduleName}" . 'ModuleServiceProvider.php', ['routes' => $entityPath . '/templates/module/routes.php', 'bindings' => $entityPath . '/templates/module/bindings.php', 'singletons' => $entityPath . '/templates/module/singletons.php'], $data); $this->processFile("{$dest}/src/{$moduleName}" . 'Module.php', ['sections' => $entityPath . '/templates/module/sections.php'], $data); $this->processFile("{$dest}/src/{$moduleName}" . 'ModuleSeeder.php', ['seeders' => $entityPath . '/templates/module/seeding.php'], $data); $this->processFile("{$dest}/resources/lang/en/section.php", [strtolower(str_plural($data['entity_name'])) => $entityPath . '/templates/module/section.php'], $data); $this->processFile("{$dest}/resources/config/permissions.php", [$data['stream_slug'] => $entityPath . '/templates/module/permissions.php'], $data); $this->processFile("{$dest}/resources/lang/en/stream.php", [$data['stream_slug'] => $entityPath . '/templates/module/stream.php'], $data); $this->processFile("{$dest}/resources/lang/en/permission.php", [$data['stream_slug'] => $entityPath . '/templates/module/permission.php'], $data); } catch (\PhpParser\Error $e) { die($e->getMessage()); } }
function display($View, $Data = null, $DoNotWrap = FALSE) { $View = 'admin/' . $View; _set_config('_include_before', _config('_admin_include_before')); _set_config('_include_after', _config('_admin_include_after')); _set_config('template_root_folder', _config('admin_template_root_folder')); _set_config('class_as_root', FALSE); return parent::display($View, $Data, $DoNotWrap); }
private function _load_views($views, $data) { $views = is_array($views) ? $views : array($views); foreach ($views as $view) { if (strlen($view) == 0) { continue; } $this->load->view(_config('template_root_folder') . $view, $data); } }
/** * Dispaches two jobs, 'ModifyModule' and 'SeedModule' *question of configuration * * @param ModuleWasInstalled $event * @return void */ public function handle(ModuleWasInstalled $event) { $module = $event->getModule(); if (count(_getNamespaces($module)) > 0) { $this->dispatch(new ModifyModule($module)); if (_config('builder.seed', $module)) { $this->dispatch(new SeedModule($module)); } } }
/** * Execute the console command. */ public function fire(AddonManager $addons) { $this->logo(); list($vendor, $type, $slug, $path) = _resolveAddonNamespace($this->argument('namespace'), $this->option('shared')); /* Get the template name if provided by the user */ if (!($template = $this->argument('template'))) { /* otherwise, construct an index for a potential template based on the addon type */ $index = "templates.{$type}" . ($type !== 'theme' ? "" : ($this->option('admin') ? '.0' : '.1')); /* if the template option is provided, create a template project, not the actual addon */ $template = _config("config." . ($this->option('template') ? "default-template" : $index)); } if ($template && $this->download($template, $this->option('force'))) { $context = $this->getTemplateContext($template, ['vendor' => $vendor, 'slug' => $slug, 'type' => $type], true, $this->option('defaults')); $this->dispatch(new ScaffoldTemplate($vendor, $type, $slug, $this->getBuilderPath($template), $path, $context)); $this->info("Builder has successfully created a {$type} addon from '{$template}' at:"); $this->line($path); return; } else { /* When things go wrong - which happens sometimes - fallback to Pyro make:addon */ $this->ignoreJobs = false; } parent::fire($addons); }
/** * Compile options into an associative array definition * * @param array $options, a stream or assignment options * @param boolean $wrap, wrap the compiled options into a slug entry * * @return string, an associative array, stringfied! */ protected function compileOptions($options, $wrap = true) { $definition = ''; $slug = $options['slug']; // Filter-out all false values (untruths) & the slug if $wrap flag is true // And finally the type option (only used for fields) $options = array_filter($options, function ($v, $k) use($wrap) { return $k !== 'type' && !($wrap && $k === 'slug') && !empty($v); }, ARRAY_FILTER_USE_BOTH); $i = 0; $s = count($options); foreach ($options as $option => $value) { $definition .= "\n\t\t\t\t" . str_pad(($wrap ? "\t\t" : "") . "'{$option}'", _config('config.padding')) . "=> {$value}" . (++$i !== $s ? "," : ""); } return $wrap ? "\n\t\t\t\t" . str_pad("{$slug}", _config('config.padding') + 2) . (!empty($definition) ? "=> [{$definition}\n\t\t\t\t]" : "") : $definition; }
function _getFieldConfig($module, $namespace_slug, $field_slug) { $namespaces = _config('builder.namespaces', $module); $namespace = array_get($namespaces, $namespace_slug, []); $field = array_get($namespace, $field_slug, []); return ['hide_column' => array_get($field, 'hide_column', false), 'hide_field' => array_get($field, 'hide_field', false), 'column_template' => array_get($field, 'column_template', null)]; }
/** * Get the specified configuration value. * * @param string $key * @param mixed $default * @return mixed */ function config($key, $default = null) { $configs = _config(); return array_get($configs, $key, $default); }
/** * Download a Builder template from the registery,. * * @param string $template, the selected template * @param bool $force, force download if the template already exists * * @return bool (true = success) */ protected function download($template, $force = false) { $dist = $this->getBuilderPath(); $path = "{$dist}/{$template}"; if (!$this->files->exists($path) || $force) { $bar = $this->createProgressIndicator(); $src = _render(_config('config.archive'), ['registry' => $this->registry, 'template' => $template]); /* get a temp folder to download the template zip to */ $tmp = $this->getBuilderPath(_config('config.tmp')); try { /* download the template zip file, show progress, uncompress and remove */ $bar->start(" Downloading '{$template}' ... "); $this->files->put($tmp, file_get_contents($src, false, stream_context_create([], ['notification' => function ($notification_code) use($bar) { if (in_array($notification_code, [STREAM_NOTIFY_CONNECT, STREAM_NOTIFY_PROGRESS])) { $bar->advance(); } }]))); $this->zip->open($tmp); $this->zip->extractTo($dist); $this->zip->close(); $this->files->moveDirectory("{$path}-master", $path, true); $this->files->deleteDirectory(dirname($tmp)); $bar->finish(" Download '{$template}' was successful "); } catch (\ErrorException $e) { return false; } } else { $this->output->note("Builder template '{$template}' already exists. \nUse --force option to get a fresh copy."); } return true; }
</div> <div class="panel-body"> <form role="form" class="form-horizontal"> <fieldset> <div class="form-group has-feedback has-feedback-left"> <div class="col-md-10 col-sm-offset-1"> <i class="form-control-feedback glyphicon glyphicon-user"></i> <input type="text" class="form-control" placeholder="Login ou E-mail" /> </div> </div> <div class="form-group has-feedback has-feedback-left"> <div class="col-md-10 col-sm-offset-1"> <i class="form-control-feedback glyphicon glyphicon-lock"></i> <input type="password" class="form-control" placeholder="Senha" /> </div> </div> <div class="form-group"> <div class="col-md-10 col-sm-offset-1"> <button class="btn btn-lg btn-success btn-block" onclick="<?php _config('adicionar'); ?> ">Login</button> </div> </div> </fieldset> </form> </div> </div> </div> </div> </div>
/** * Get the console command options. * * @return array */ protected function getOptions() { return [['force', null, InputOption::VALUE_NONE, "Indicates whether to force a fresh download of the '" . _config('config.default-module') . "'."], ['shared', null, InputOption::VALUE_NONE, 'Indicates if the addon should be created in shared addons.'], ['migration', null, InputOption::VALUE_NONE, 'Indicates if a fields migration should be created.']]; }