コード例 #1
0
 /**
  * Handle the command.
  *
  * @param ModifyEntity $command
  */
 public function handle(ModifyEntity $command)
 {
     $module = $command->getModule();
     $stream = $command->getStream();
     $assignment = $command->getAssignment();
     // Get the field config params from build.php
     $field_config = ebxGetFieldConfig($module, $stream->getNamespace(), $assignment->getFieldSlug());
     $entity = __DIR__ . '/../../../resources/assets/entity';
     // Set a list of files to avoid overwrite
     $this->files->setAvoidOverwrite(ebxGetAvoidOverwrite($module));
     // Get the template data
     $data = $this->getTemplateData($module, $stream, $assignment, $field_config);
     $source = $entity . '/code/{namespace}/';
     // Get the namespace destination folder, if any!
     $namespace_folder = ebxGetNamespaceFolder($module, $data['namespace'], true);
     $destination = $module->getPath();
     $entity_destination = $destination . '/src/' . $namespace_folder . '/' . $data['entity_name'];
     // Get the assigned class name, i.e. TextFieldType
     $fieldTypeClassName = ebxGetFieldTypeClassName($assignment);
     // (1) Process the form builder class
     if (!$field_config['hide_field']) {
         $this->processFormBuilder($entity_destination . '/Form/' . $data['entity_name'] . 'FormBuilder.php', $entity . "/templates/field/form/{$fieldTypeClassName}.txt", $data);
     }
     // (2) Process the table column class
     if (!$field_config['hide_column']) {
         $this->processTableColumns($entity_destination . '/Table/' . $data['entity_name'] . 'TableColumns.php', $entity . '/templates/field/table/' . ($data['column_template'] ? 'template/' : '') . "{$fieldTypeClassName}.txt", $data);
     }
     // (3) Process the field language file
     $this->processFile($destination . '/resources/lang/en/field.php', [$data['field_slug'] => $entity . '/templates/module/field.php'], $data);
 }
コード例 #2
0
 /**
  * Handle the command.
  *
  * @param GenerateEntity $command
  */
 public function handle(GenerateEntity $command)
 {
     $stream = $command->getStream();
     $module = $command->getModule();
     $entityPath = __DIR__ . '/../../../resources/assets/entity';
     $modulePath = __DIR__ . '/../../../resources/assets/module';
     $namespace_folder = ebxGetNamespaceFolderTemplate($module);
     $data = $this->getTemplateData($module, $stream);
     $this->files->setAvoidOverwrite(ebxGetAvoidOverwrite($module, []));
     $destination = $module->getPath();
     /* Make sure Module's main files are present: Seeder etc
        (TODO, optomize, doesn't have to run everytime) */
     $this->files->parseDirectory($modulePath . '/src', $destination . '/src', $data);
     $this->files->parseDirectory($entityPath . "/code/{$namespace_folder}", $destination . '/src', $data);
     try {
         $this->processFile($destination . '/src/' . $data['module_name'] . 'ModuleServiceProvider.php', ['routes' => $entityPath . '/templates/module/routes.php', 'bindings' => $entityPath . '/templates/module/bindings.php', 'singletons' => $entityPath . '/templates/module/singletons.php'], $data);
         $this->processFile($destination . '/src/' . $data['module_name'] . 'Module.php', ['sections' => $entityPath . '/templates/module/sections.php'], $data);
         $this->processFile($destination . '/src/' . $data['module_name'] . 'ModuleSeeder.php', ['seeders' => $entityPath . '/templates/module/seeding.php'], $data);
         $this->processFile($destination . '/resources/lang/en/addon.php', ['section' => $entityPath . '/templates/module/addon.php'], $data);
         $this->processFile($destination . '/resources/lang/en/stream.php', [$data['stream_slug'] => $entityPath . '/templates/module/stream.php'], $data);
     } catch (\PhpParser\Error $e) {
         die($e->getMessage());
     }
 }