/**
  * Execute the console command.
  */
 public function fire()
 {
     /*
      * Extract the author and name from the plugin code
      */
     $pluginCode = $this->argument('pluginCode');
     $parts = explode('.', $pluginCode);
     if (count($parts) != 2) {
         $this->error('Invalid plugin name, either too many dots or not enough.');
         $this->error('Example name: AuthorName.PluginName');
         return;
     }
     $pluginName = array_pop($parts);
     $authorName = array_pop($parts);
     $destinationPath = base_path() . '/plugins/' . strtolower($authorName) . '/' . strtolower($pluginName);
     $vars = ['plugin' => $pluginName, 'author' => $authorName];
     $scanner = TranslationScanner::instance();
     $this->info(sprintf('Scanning classes...'));
     $this->noFiles($scanner->with($vars)->scan($destinationPath . '/classes'));
     $this->info(sprintf('Scanning controllers...'));
     $this->noFiles($scanner->with($vars)->scan($destinationPath . '/controllers'));
     $this->info(sprintf('Scanning models...'));
     $this->noFiles($scanner->with($vars)->scan($destinationPath . '/models'));
     $this->info(sprintf('Scanning components...'));
     $this->noFiles($scanner->with($vars)->scan($destinationPath . '/components'));
     $this->info(sprintf('Scanning widgets...'));
     $this->noFiles($scanner->with($vars)->scan($destinationPath . '/widgets'));
     $this->info(sprintf('Scanning formwidgets...'));
     $this->noFiles($scanner->with($vars)->scan($destinationPath . '/formwidgets'));
     $this->info(sprintf('Scanning plugin files...'));
     $this->noFiles($scanner->with($vars)->scanFile($destinationPath . '/Plugin.php'));
     $this->info(sprintf('Successfully generated translation entries for plugin "%s"', $pluginCode));
 }
 /**
  * Execute the console command.
  */
 public function fire()
 {
     $this->comment(trans('bnb.scaffoldtranslation::lang.commands.disclaimer'));
     /*
      * Extract the author and name from the plugin code
      */
     $pluginCode = $this->argument('pluginCode');
     $parts = explode('.', $pluginCode);
     $pluginName = array_pop($parts);
     $authorName = array_pop($parts);
     $destinationPath = base_path() . '/plugins/' . strtolower($authorName) . '/' . strtolower($pluginName);
     $componentName = $this->argument('componentName');
     $vars = ['name' => $componentName, 'author' => $authorName, 'plugin' => $pluginName];
     Component::make($destinationPath, $vars, $this->option('force'), $this->option('translated'));
     $langPrefix = strtolower($authorName) . '.' . strtolower($pluginName) . '::lang.components.' . strtolower($componentName) . '.';
     $defaultLocale = Lang::getLocale();
     $locales = TranslationScanner::loadPluginLocales();
     foreach ($locales as $locale) {
         Lang::setLocale($locale);
         $vars[$locale] = [$langPrefix . 'name' => trans('bnb.scaffoldtranslation::lang.defaults.component.name', ['name' => $componentName]), $langPrefix . 'description' => trans('bnb.scaffoldtranslation::lang.defaults.component.description')];
     }
     Lang::setLocale($defaultLocale);
     TranslationScanner::instance()->with($vars)->scan($destinationPath . '/components');
     $this->info(sprintf('Successfully generated Component for "%s"', $componentName));
 }
 /**
  * Execute the console command.
  */
 public function fire()
 {
     /*
      * Extract the author and name from the plugin code
      */
     $pluginCode = $this->argument('pluginCode');
     $parts = explode('.', $pluginCode);
     $pluginName = array_pop($parts);
     $authorName = array_pop($parts);
     $destinationPath = plugins_path() . '/' . strtolower($authorName) . '/' . strtolower($pluginName);
     $widgetName = $this->argument('widgetName');
     $vars = ['name' => $widgetName, 'author' => $authorName, 'plugin' => $pluginName];
     Widget::make($destinationPath, $vars, $this->option('force'));
     $vars['plugin'] = $vars['name'];
     $langPrefix = strtolower($authorName) . '.' . strtolower($pluginName) . '::lang.';
     $defaultLocale = Lang::getLocale();
     $locales = TranslationScanner::loadPluginLocales();
     foreach ($locales as $locale) {
         Lang::setLocale($locale);
         $vars[$locale] = [$langPrefix . 'plugin.name' => trans('bnb.scaffoldtranslation::lang.defaults.widget.name', ['name' => $pluginName]), $langPrefix . 'plugin.description' => trans('bnb.scaffoldtranslation::lang.defaults.widget.description')];
     }
     Lang::setLocale($defaultLocale);
     TranslationScanner::instance()->with($vars)->scan($destinationPath . '/widgets');
     $this->info(sprintf('Successfully generated Form Widget named "%s"', $widgetName));
 }
 /**
  * Execute the console command.
  */
 public function fire()
 {
     /*
      * Extract the author and name from the plugin code
      */
     $plugin = $this->argument('name');
     $parts = explode('.', $plugin);
     if (count($parts) != 2) {
         $this->error('Invalid plugin name, either too many dots or not enough.');
         $this->error('Example name: AuthorName.PluginName');
         return;
     }
     $pluginName = array_pop($parts);
     $authorName = array_pop($parts);
     $destinationPath = base_path() . '/plugins/' . strtolower($authorName) . '/' . strtolower($pluginName);
     $vars = ['plugin' => $pluginName, 'author' => $authorName];
     $scanner = TranslationScanner::instance();
     collect(['behaviors', 'classes', 'console', 'controllers', 'components', 'helpers', 'models', 'partials', 'widgets', 'formwidgets', 'reportwidgets', 'traits', 'twig', 'views'])->each(function ($path) use($destinationPath, $scanner, $vars) {
         $target = "{$destinationPath}/{$path}";
         if (is_dir($target)) {
             $this->info(sprintf("Scanning {$path}..."));
             $this->noFiles($scanner->with($vars)->scan($target));
         }
     });
     collect(['Plugin.php'])->each(function ($path) use($destinationPath, $scanner, $vars) {
         $target = "{$destinationPath}/{$path}";
         if (is_file($target)) {
             $this->info(sprintf("Scanning {$path}..."));
             $this->noFiles($scanner->with($vars)->scanFile($target));
         }
     });
     $this->info(sprintf('Successfully generated translation entries for plugin "%s"', $plugin));
 }
 /**
  * Execute the console command.
  */
 public function fire()
 {
     $this->comment(trans('bnb.scaffoldtranslation::lang.commands.disclaimer'));
     /*
      * Extract the author and name from the plugin code
      */
     $pluginCode = $this->argument('pluginCode');
     $parts = explode('.', $pluginCode);
     if (count($parts) != 2) {
         $this->error('Invalid plugin name, either too many dots or not enough.');
         $this->error('Example name: AuthorName.PluginName');
         return;
     }
     $pluginName = array_pop($parts);
     $authorName = array_pop($parts);
     $destinationPath = base_path() . '/plugins';
     $vars = ['name' => $pluginName, 'author' => $authorName];
     Plugin::make($destinationPath, $vars, $this->option('force'), $this->option('translated'));
     $vars['plugin'] = $vars['name'];
     $langPrefix = strtolower($authorName) . '.' . strtolower($pluginName) . '::lang.';
     $defaultLocale = Lang::getLocale();
     $locales = TranslationScanner::loadPluginLocales();
     foreach ($locales as $locale) {
         Lang::setLocale($locale);
         $vars[$locale] = [$langPrefix . 'plugin.name' => trans('bnb.scaffoldtranslation::lang.defaults.plugin.name', ['name' => $pluginName]), $langPrefix . 'plugin.description' => trans('bnb.scaffoldtranslation::lang.defaults.plugin.description')];
     }
     Lang::setLocale($defaultLocale);
     TranslationScanner::instance()->with($vars)->scanFile($destinationPath . '/' . strtolower($authorName) . '/' . strtolower($pluginName) . '/Plugin.php');
     $this->info(sprintf('Successfully generated Plugin named "%s"', $pluginCode));
 }
 /**
  * Prepare translated variables for stubs.
  *
  * @return array
  */
 protected function processTranslatedVars()
 {
     $defaultLocale = Lang::getLocale();
     $locales = TranslationScanner::loadPluginLocales();
     $vars = array_merge_recursive([], $this->vars);
     foreach ($locales as $locale) {
         Lang::setLocale($locale);
         $vars = array_merge_recursive($vars, [$locale => $this->prepareTranslatedVars()]);
     }
     Lang::setLocale($defaultLocale);
     return $vars;
 }
 /**
  * Execute the console command.
  */
 public function fire()
 {
     $this->comment(trans('bnb.scaffoldtranslation::lang.commands.disclaimer'));
     /*
      * Extract the author and name from the plugin code
      */
     $pluginCode = $this->argument('pluginCode');
     $parts = explode('.', $pluginCode);
     $pluginName = array_pop($parts);
     $authorName = array_pop($parts);
     $destinationPath = base_path() . '/plugins/' . strtolower($authorName) . '/' . strtolower($pluginName);
     $controllerName = $this->argument('controllerName');
     /*
      * Determine the model name to use,
      * either supplied or singular from the controller name.
      */
     $modelName = $this->option('model');
     if (!$modelName) {
         $modelName = Str::singular($controllerName);
     }
     $vars = ['name' => $controllerName, 'model' => $modelName, 'author' => $authorName, 'plugin' => $pluginName];
     Controller::make($destinationPath, $vars, $this->option('force'), $this->option('translated'));
     $langPrefix = strtolower($authorName) . '.' . strtolower($pluginName) . '::lang.';
     $titleSingular = ucwords(str_replace('_', ' ', Str::snake(str_singular($controllerName))));
     $titlePlural = ucwords(str_replace('_', ' ', Str::snake(str_plural($controllerName))));
     $lowerTitlePlural = strtolower(str_replace('_', ' ', Str::snake(str_plural($controllerName))));
     $plural = strtolower(str_plural($controllerName));
     $singular = strtolower(str_singular($controllerName));
     $vars['en'] = [$langPrefix . $plural . '.return_to_list' => 'Return to ' . $titlePlural, $langPrefix . $plural . '.delete_confirm' => 'Do you really want to delete this ' . $singular . '?', $langPrefix . $plural . '.delete_selected_success' => 'Successfully deleted the selected ' . $lowerTitlePlural . '.', $langPrefix . $plural . '.delete_selected_empty' => 'There are no selected ' . $lowerTitlePlural . ' to delete.', $langPrefix . $plural . '.delete_selected_confirm' => 'Delete the selected ' . $lowerTitlePlural . '?', $langPrefix . $plural . '.menu_label' => $titlePlural, $langPrefix . $singular . '.new' => 'New ' . $titleSingular, $langPrefix . $singular . '.label' => $titleSingular, $langPrefix . $singular . '.list_title' => 'Manage ' . $titlePlural, $langPrefix . $singular . '.create_title' => 'Create ' . $titleSingular, $langPrefix . $singular . '.update_title' => 'Edit ' . $titleSingular, $langPrefix . $singular . '.preview_title' => 'Preview ' . $titleSingular];
     $langPrefix = strtolower($authorName) . '.' . strtolower($pluginName) . '::lang.';
     $titleSingular = ucwords(str_replace('_', ' ', Str::snake(str_singular($controllerName))));
     $titlePlural = ucwords(str_replace('_', ' ', Str::snake(str_plural($controllerName))));
     $lowerTitlePlural = strtolower(str_replace('_', ' ', Str::snake(str_plural($controllerName))));
     $plural = strtolower(str_plural($controllerName));
     $singular = strtolower(str_singular($controllerName));
     $defaultLocale = Lang::getLocale();
     $locales = TranslationScanner::loadPluginLocales();
     foreach ($locales as $locale) {
         Lang::setLocale($locale);
         $vars[$locale] = [$langPrefix . $plural . '.return_to_list' => trans('bnb.scaffoldtranslation::lang.defaults.controller.return_to_list', ['name' => $titlePlural]), $langPrefix . $plural . '.delete_confirm' => trans('bnb.scaffoldtranslation::lang.defaults.controller.delete_confirm', ['name' => $singular]), $langPrefix . $plural . '.delete_selected_success' => trans('bnb.scaffoldtranslation::lang.defaults.controller.delete_selected_success', ['name' => $lowerTitlePlural]), $langPrefix . $plural . '.delete_selected_empty' => trans('bnb.scaffoldtranslation::lang.defaults.controller.delete_selected_empty'), $langPrefix . $plural . '.delete_selected_confirm' => trans('bnb.scaffoldtranslation::lang.defaults.controller.delete_selected_confirm', ['name' => $lowerTitlePlural]), $langPrefix . $plural . '.menu_label' => trans('bnb.scaffoldtranslation::lang.defaults.controller.menu_label', ['name' => $titlePlural]), $langPrefix . $singular . '.new' => trans('bnb.scaffoldtranslation::lang.defaults.controller.new', ['name' => $titleSingular]), $langPrefix . $singular . '.label' => trans('bnb.scaffoldtranslation::lang.defaults.controller.label', ['name' => $titleSingular]), $langPrefix . $singular . '.list_title' => trans('bnb.scaffoldtranslation::lang.defaults.controller.manage', ['name' => $titlePlural]), $langPrefix . $singular . '.create_title' => trans('bnb.scaffoldtranslation::lang.defaults.controller.create', ['name' => $titleSingular]), $langPrefix . $singular . '.update_title' => trans('bnb.scaffoldtranslation::lang.defaults.controller.update', ['name' => $titleSingular]), $langPrefix . $singular . '.preview_title' => trans('bnb.scaffoldtranslation::lang.defaults.controller.preview', ['name' => $titleSingular])];
     }
     Lang::setLocale($defaultLocale);
     TranslationScanner::instance()->with($vars)->scan($destinationPath . '/controllers');
     $this->info(sprintf('Successfully generated Controller and views for "%s"', $controllerName));
 }