Handle the command.

@var string
558
public function handle()
    {
        $indexConfigurator = $this->getIndexConfigurator();

        if ($indexConfigurator && ! $this->alreadyExists($indexConfigurator)) {
            $this->call('make:index-configurator', [
                'name' => $indexConfigurator,
            ]);
        }

        $searchRule = $this->getSearchRule();

        if ($searchRule && ! $this->alreadyExists($searchRule)) {
            $this->call('make:search-rule', [
                'name' => $searchRule,
            ]);
        }

        parent::handle();
    }
708669
public function handle()
    {
        $alphabets = $this->generateRandomAlphabets(
            $this->getTimes(),
            (string) $this->option('characters')
        );

        $this->comment(implode(PHP_EOL, $alphabets));
    }
884168
public function handle()
    {
        $this->abortCommandExecution();
        $command = $this->argument('git_command');
        $this->info("Running git $command on production...");

        $this->runSSH("cd $this->domain;git $command");
    }
1260031
public function handle()
    {
        parent::handle();

        $modelGenerator = new ModelGenerator($this->commandData);
        $modelGenerator->generate();

        $this->performPostActions();
    }
430564
public function handle()
    {

        $path = base_path('/app/Templates');

        if ( $this->deleteDirectoryAndFiles($path) ) {

            $this->sendSuccessMessage();

            return;

        }

        $this->error('Oops, something went wrong!');


    }
608587
public function handle()
    {

        $this->modelName = $this->formatModel($this->argument('ModelName'));

        $this->modelPath = $this->formatModelPath($this->argument('ModelName'));

        $this->setCommandType($this->argument('command'));

        $this->setCrudPaths();

        if ( $this->deleteFiles() ) {

            $this->sendSuccessMessage();

            return;

        }

        $this->error('Oops, something went wrong!');


    }
72664
public function handle()
    {
        Log::notice('Queued Script handled for ' . $this->script_id);
        if ($script = $this->getEventScript($this->script_id)) {
            $session = json_decode(Crypt::decrypt($this->session), true);
            Session::replace($session);

            $data = json_decode(Crypt::decrypt($this->event), true);
            if (null !== $this->handleScript($script->name, $script->content, $script->type, $script->config, $data)) {
                Log::notice('Queued Script success for ' . $this->script_id);
            }
        }
    }
732619
public function handle()
    {
        $cmd = collect(array_merge($this->getSeleniumDefaultCommand(), $this->getArguments()))
            ->except('driver', 'serverVersion')
            ->implode(' ');

        $this->info('Starting Selenium server v'.$this->argument('serverVersion'));
        $this->info("Using {$this->argument('driver')} driver");

        echo shell_exec($cmd.' '.$this->getSeleniumOptions());
    }
625527
public function handle()
    {
        $this->line('=== Install assets via bower ===');

        $libraries = ['fancybox', 'jquery-validation', 'jquery.cookie', 'fileapi', 'jquery.spinner', 'microplugin', 'pickadate',
            'selectize', 'sifter', 'tinymce', 'uikit', ];

        foreach ($libraries as $library) {
            if (! \File::exists(base_path('public_html/_assets/bower_components/'.$library))) {
                echo shell_exec('bower install '.$library);
                if (\File::exists(base_path('public_html/_assets/bower_components/'.$library))) {
                    $this->info('=== '.$library.' successfully installed ===');
                } else {
                    $this->alert('=== ERROR! '.$library.' not installed ===');
                }
            } else {
                $this->info('=== '.$library.' already installed ===');
            }
        }
        $this->info('=== END of assets ===');
    }
1027590
public function handle()
    {
        $path = $this->argument('path');
        $text = $this->option('text');
        $root = session('cd_base_path');
        $path = trim($root, '/').'/'.$path;

        if (is_null($text) === false) {
            $this->files->put($path, $text);
        } else {
            $this->line($this->files->get($path));
        }
    }
1012821
public function handle()
    {
        $deploymentsPath = $this->option('path');
        if(!$deploymentsPath) {
            $deploymentsPath = base_path($this->deploymentsPath);
        }

        // Drop tables
        if($this->option('drop')) {
            $tables = DB::select('SHOW TABLES');
            if($tables) {
                $this->comment("\nDropping current tables");
                $this->dropAllTables();
                $this->info("Current tables dropped");
            }else{
                $this->comment("No tables to drop!");
            }
        }

        // Import sql files
        if(File::isDirectory($deploymentsPath)) {
            $sqlFiles = File::files($deploymentsPath);
            if ($sqlFiles) {
                $this->comment("\nImporting deployment SQL files");
                foreach ($sqlFiles as $file) {
                    if ($file->getExtension() == "sql") {
                        $command = 'mysql -h ' . env('DB_HOST') . ' -u ' . env('DB_USERNAME') . ' -p' . env('DB_PASSWORD') . ' ' . env('DB_DATABASE') . ' < ' . $file->getPathName();

                        $this->process->setCommandLine($command);
                        $this->process->setTimeout(null);
                        $this->process->run();

                        if (!$this->process->isSuccessful()) {
                            $this->error("Database '" . $file->getPathName() . "' not deployed!");
                            break;
                        }else{
                            // Delete file
                            File::delete($file->getPathName());
                        }
                    }
                }
                $this->info("Deployment SQL files imported!");
            }
        }
    }
360404
public function handle()
    {
        $id = $this->argument('id');
        $rule = $this->argument('rule');

        if( $id && $rule ) {
            $this->generateThumbByRule($id, $rule);
        } else {
            if( $id ) {
                $this->generateGlobalThumb($id);
            } else {

                if( $this->confirm('Are you sure you want to generate thumbs for all resources?') ) {
                    $list = HCResources::all()->pluck('id');

                    foreach ( $list as $id )
                        $this->generateGlobalThumb($id);
                }
            }
        }
    }
104168
public function handle()
    {
        parent::handle();

        $repositoryGenerator = new RepositoryGenerator($this->commandData);
        $repositoryGenerator->generate();

        $this->performPostActions();
    }
605426
public function handle()
    {
        parent::handle();

        if (!$this->commandData->getOption('fromTable')) {
            $migrationGenerator = new MigrationGenerator($this->commandData);
            $migrationGenerator->generate();
        }

        $modelGenerator = new ModelGenerator($this->commandData);
        $modelGenerator->generate();

        $repositoryGenerator = new RepositoryGenerator($this->commandData);
        $repositoryGenerator->generate();

        $requestGenerator = new APIRequestGenerator($this->commandData);
        $requestGenerator->generate();

        $controllerGenerator = new ControllerGenerator($this->commandData);
        $controllerGenerator->generate();

        $modelJsConfigGenerator = new ModelJsConfigGenerator($this->commandData);
        $modelJsConfigGenerator->generate();

        $routeGenerator = new RoutesGenerator($this->commandData);
        $routeGenerator->generate();

        $viewGenerator = new ViewGenerator($this->commandData);
        $viewGenerator->generate();

        if ($this->commandData->config->getAddOn('menu.enabled')) {
            $menuGenerator = new MenuGenerator($this->commandData);
            $menuGenerator->generate();
        }

        $this->performPostActionsWithMigration();
    }
953774
public function handle()
    {
        $folders         = $this->manager->getPath($this->folders);
        $this->display   = ! $this->option('silent');
        $extension       = $this->option('php-file-extension');
        $obsolete_prefix = (empty($this->obsolete_array_key)) ? '' : $this->obsolete_array_key.'.';

        //////////////////////////////////////////////////
        // Display where translations are searched in //
        //////////////////////////////////////////////////
        if ($this->option('verbose')) {
            $this->writeLine("Lemmas will be searched in the following directories:");

            foreach ($folders as $path) {
                $this->writeLine('    <info>'.$path.'</info>');
            }

            $this->writeLine('');
        }

        ////////////////////////////////
        // Parse all lemmas from code //
        ////////////////////////////////
        $lemmas = $this->manager->extractTranslationsFromFolders($folders, $this->trans_methods, $extension);

        if (count($lemmas) === 0) {
            $this->writeComment("No lemma has been found in code.");
            $this->writeLine("I have searched recursively in PHP files in these directories:");

            foreach ($this->manager->getPath($this->folders) as $path) {
                $this->writeLine("    ".$path);
            }

            $this->writeLine("for these functions/methods:");

            foreach ($this->trans_methods as $k => $v) {
                $this->writeLine("    ".$k);
            }

            return self::SUCCESS;
        }

        $this->writeLine((count($lemmas) > 1) ? count($lemmas)." lemmas have been found in code" : "1 lemma has been found in code");

        if ($this->option('verbose')) {
            foreach ($lemmas as $key => $value) {
                if (strpos($key, '.') !== false) {
                    $this->writeLine('    <info>'.$key.'</info> in file <comment>'.$this->manager->getShortPath($value).'</comment>');
                }
            }
        }

        /////////////////////////////////////////////
        // Convert dot lemmas to structured lemmas //
        /////////////////////////////////////////////
        if ($this->option('output-flat')) {
            $lemmas_structured = $this->manager->convertLemmaToFlatArray($lemmas);
        } else {
            $lemmas_structured = $this->manager->convertLemmaToStructuredArray($lemmas, $this->dot_notation_split_regex, null);
        }

        $this->writeLine('');

        /////////////////////////////////////
        // Generate lang files :           //
        // - add missing lemmas on top     //
        // - keep already defined lemmas   //
        // - add obsolete lemmas on bottom //
        /////////////////////////////////////
        try {
            $dir_lang = $this->manager->getLangPath($this->lang_folder_path);
        } catch (Exception $e) {
            switch ($e->getCode()) {
                //@codeCoverageIgnoreStart
                case Localization::NO_LANG_FOLDER_FOUND_IN_THESE_PATHS:
                    $this->writeError("No lang folder found in these paths:");
                    foreach ($e->getParameter() as $path) {
                        $this->writeError("- ".$path);
                    }
                    break;
                //@codeCoverageIgnoreEnd

                case Localization::NO_LANG_FOLDER_FOUND_IN_YOUR_CUSTOM_PATH:
                    $this->writeError('No lang folder found in your custom path: "'.$e->getParameter().'"');
                    break;
            }

            $this->writeLine('');

            return self::ERROR;
        }

        $job           = [];
        $there_are_new = false;

        $this->writeLine('Scan files:');

        /**
         * Parse all lang file types
         *
         * @var LangFileAbstract $langFileType
         */
        foreach (LangFile::getLangFiles($dir_lang, $this->json_languages) as $langFileType) {
            if ($langFileType->getTypeVendor()) {
                continue;
            }

            $lang = $langFileType->getLang();

            /**
             * Parse now all extracted families
             */
            foreach ($lemmas_structured as $family => $array) {
                if ($family === Localization::JSON_HEADER) {
                    $lang_file = new LangFileJson($dir_lang, $lang);
                } else {
                    $lang_file = new LangFileGenuine($dir_lang, $lang, $family);

                    if (in_array($family, $this->ignore_lang_files) || in_array($lang_file->getShortFilePath(), $this->ignore_lang_files)) {
                        if ($this->option('verbose')) {
                            $this->writeLine('');
                            $this->writeInfo("    ! Skip lang file '$family' !");
                        }
                        continue;
                    }
                }

                if ($this->option('verbose')) {
                    $this->writeLine('');
                }

                $this->writeLine('    '.$lang_file->getShortFilePath());

                if (! $this->option('dry-run')) {

                    if (! $lang_file->ensureFolder()) {
                        // @codeCoverageIgnoreStart
                        $this->writeError("    > Unable to create directory ".$lang_file->getFileFolderPath());

                        return self::ERROR;
                        // @codeCoverageIgnoreEnd
                    }

                    if (! $lang_file->isFolderWritable()) {
                        // @codeCoverageIgnoreStart
                        $this->writeError("    > Unable to write file in directory ".$lang_file->getFileFolderPath());

                        return self::ERROR;
                        // @codeCoverageIgnoreEnd
                    }

                    if (! $lang_file->fileExists()) {
                        // @codeCoverageIgnoreStart
                        $this->writeInfo("    > File has been created");
                        // @codeCoverageIgnoreEnd
                    }

                    if (! $lang_file->touch()) {
                        // @codeCoverageIgnoreStart
                        $this->writeError("    > Unable to touch file ".$lang_file->getFilePath());

                        return self::ERROR;
                        // @codeCoverageIgnoreEnd
                    }

                    if (! $lang_file->isReadable()) {
                        // @codeCoverageIgnoreStart
                        $this->writeError("    > Unable to read file ".$lang_file->getFilePath());

                        return self::ERROR;
                        // @codeCoverageIgnoreEnd
                    }

                    if (! $lang_file->isWritable()) {
                        // @codeCoverageIgnoreStart
                        $this->writeError("    > Unable to write in file ".$lang_file->getFilePath());

                        return self::ERROR;
                        // @codeCoverageIgnoreEnd
                    }
                }

                /** @noinspection PhpIncludeInspection */
                $a                        = $lang_file->load();
                $old_lemmas_with_obsolete = (is_array($a)) ? array_dot($a) : [];
                $new_lemmas               = array_dot($array);
                $final_lemmas             = [];
                $display_already_comment  = false;
                $something_to_do          = false;
                $i                        = 0;

                // Remove the obsolete prefix key
                $old_lemmas             = [];
                $obsolete_prefix_length = strlen($obsolete_prefix);
                foreach ($old_lemmas_with_obsolete as $key => $value) {
                    if (starts_with($key, $obsolete_prefix)) {
                        $key = substr($key, $obsolete_prefix_length);
                        if (! isset($old_lemmas[$key])) {
                            $old_lemmas[$key] = $value;
                        }
                    } else {
                        $old_lemmas[$key] = $value;
                    }
                }

                // Check if keys from new lemmas are not sub-keys from old_lemma (#47)
                // Ignore them if this is the case
                $new_lemmas_clean = $new_lemmas;
                $old_lemmas_clean = $old_lemmas;

                foreach ($new_lemmas as $new_key => $new_value) {
                    foreach ($old_lemmas as $old_key => $old_value) {
                        if (starts_with($old_key, $new_key.'.')) {
                            if ($this->option('verbose')) {
                                $this->writeLine("            <info>".$new_key."</info> seems to be used to access an array and is already defined in lang file as ".$old_key);
                                $this->writeLine("            <info>".$new_key."</info> not handled!");
                            }

                            unset($new_lemmas_clean[$new_key]);
                            unset($old_lemmas_clean[$old_key]);
                        }
                    }
                }

                $obsolete_lemmas = array_diff_key($old_lemmas_clean, $new_lemmas_clean);
                $welcome_lemmas  = array_diff_key($new_lemmas_clean, $old_lemmas_clean);
                $already_lemmas  = array_intersect_key($old_lemmas_clean, $new_lemmas_clean);

                // disable check for obsolete lemma and consolidate with already_lemmas
                if ($this->option('disable-obsolete-check')) {
                    $already_lemmas  = array_unique($obsolete_lemmas + $already_lemmas);
                    $obsolete_lemmas = [];
                }

                ksort($obsolete_lemmas);
                ksort($welcome_lemmas);
                ksort($already_lemmas);

                //////////////////////////
                // Deal with new lemmas //
                //////////////////////////
                if (count($welcome_lemmas) > 0) {
                    $display_already_comment               = true;
                    $something_to_do                       = true;
                    $there_are_new                         = true;
                    $final_lemmas["POTSKY___NEW___POTSKY"] = "POTSKY___NEW___POTSKY";

                    $this->writeInfo('        '.($c = count($welcome_lemmas)).' new string'.Tools::getPlural($c).' to translate');

                    foreach ($welcome_lemmas as $key => $value) {
                        if ($this->option('verbose')) {
                            $this->writeLine("            <info>".$key."</info> in ".$this->manager->getShortPath($value));
                        }
                        if (! $this->option('no-comment')) {
                            $final_lemmas['POTSKY___COMMENT___POTSKY'.$i] = "Defined in file $value";
                            $i                                            = $i + 1;
                        }

                        $key_last_token = preg_split($this->dot_notation_split_regex, $key);

                        if ($this->option('translation')) {
                            $translation = $this->manager->translate(end($key_last_token), $lang);
                        } else {
                            $translation = end($key_last_token);
                        }

                        if (strtolower($this->option('new-value')) === 'null') {
                            $translation = null;
                        } else {
                            $translation = str_replace('%LEMMA', $translation, $this->option('new-value'));
                        }

                        Tools::arraySet($final_lemmas, $key, $translation, $this->dot_notation_split_regex);
                    }
                }

                ///////////////////////////////
                // Deal with existing lemmas //
                ///////////////////////////////
                if (count($already_lemmas) > 0) {
                    if ($this->option('verbose')) {
                        $this->writeLine('        '.($c = count($already_lemmas)).' already translated string'.Tools::getPlural($c));
                    }

                    $final_lemmas["POTSKY___OLD___POTSKY"] = "POTSKY___OLD___POTSKY";

                    foreach ($already_lemmas as $key => $value) {
                        Tools::arraySet($final_lemmas, $key, $value, $this->dot_notation_split_regex);
                    }
                }

                ///////////////////////////////
                // Deal with obsolete lemmas //
                ///////////////////////////////
                if (count($obsolete_lemmas) > 0) {
                    $protected_already_included = false;

                    // Remove all dynamic fields
                    foreach ($obsolete_lemmas as $key => $value) {
                        foreach ($this->never_obsolete_keys as $remove) {
                            if ((strpos($key, '.'.$remove.'.') !== false) || starts_with($key, $remove.'.')) {
                                if ($this->option('verbose')) {
                                    $this->writeLine("        <comment>".$key."</comment> is protected as a dynamic lemma");
                                }

                                unset($obsolete_lemmas[$key]);

                                if ($protected_already_included === false) {
                                    $final_lemmas["POTSKY___PROTECTED___POTSKY"] = "POTSKY___PROTECTED___POTSKY";
                                    $protected_already_included                  = true;
                                }

                                // Given that this lemma is never obsolete, we need to send it back to the final lemma array
                                Tools::arraySet($final_lemmas, $key, $value, $this->dot_notation_split_regex);
                            }
                        }
                    }
                }

                /////////////////////////////////////
                // Fill the final lemmas array now //
                /////////////////////////////////////
                if (count($obsolete_lemmas) > 0) {
                    $display_already_comment = true;
                    $something_to_do         = true;

                    if ($this->option('no-obsolete')) {
                        $this->writeComment("        ".($c = count($obsolete_lemmas)).' obsolete string'.Tools::getPlural($c).' (will be deleted)');
                    } else {
                        $this->writeComment("        ".($c = count($obsolete_lemmas)).' obsolete string'.Tools::getPlural($c).' (can be deleted manually in the generated file)');

                        $final_lemmas["POTSKY___OBSOLETE___POTSKY"] = "POTSKY___OBSOLETE___POTSKY";

                        foreach ($obsolete_lemmas as $key => $value) {
                            if ($this->option('verbose')) {
                                $this->writeLine("            <comment>".$key."</comment>");
                            }

                            Tools::arraySet($final_lemmas, $obsolete_prefix.$key, $value, $this->dot_notation_split_regex);
                        }
                    }
                }

                // Flat style
                if ($this->option('output-flat')) {
                    $final_lemmas = array_dot($final_lemmas);
                }

                if (($something_to_do === true) || ($this->option('force'))) {
                    $content = var_export($final_lemmas, true);
                    $content = preg_replace("@'POTSKY___COMMENT___POTSKY[0-9]*' => '(.*)',@", '// $1', $content);
                    $content = str_replace([
                        "'POTSKY___NEW___POTSKY' => 'POTSKY___NEW___POTSKY',",
                        "'POTSKY___OLD___POTSKY' => 'POTSKY___OLD___POTSKY',",
                        "'POTSKY___PROTECTED___POTSKY' => 'POTSKY___PROTECTED___POTSKY',",
                        "'POTSKY___OBSOLETE___POTSKY' => 'POTSKY___OBSOLETE___POTSKY',",
                    ], [
                        '//============================== New strings to translate ==============================//',
                        ($display_already_comment === true) ? '//==================================== Translations ====================================//' : '',
                        '//============================== Dynamic protected strings =============================//',
                        '//================================== Obsolete strings ==================================//',
                    ], $content);

                    $file_content = "<?php\n";

                    if (! $this->option('no-date')) {
                        $a            = " Generated via \"php artisan ".$this->argument('command')."\" at ".date("Y/m/d H:i:s")." ";
                        $file_content .= "/".str_repeat('*', strlen($a))."\n".$a."\n".str_repeat('*', strlen($a))."/\n";
                    }

                    $file_content                   .= "\nreturn ".$content.";";
                    $job[$lang_file->getFilePath()] = $file_content;
                } else {
                    if ($this->option('verbose')) {
                        $this->writeLine("        > <comment>Nothing to do for this file</comment>");
                    }
                }
            }
        }

        ///////////////////////////////////////////
        // Silent mode                           //
        // only return an exit code on new lemma //
        ///////////////////////////////////////////
        if ($this->option('silent')) {
            if ($there_are_new === true) {
                return self::ERROR;
            } else {
                // @codeCoverageIgnoreStart
                return self::SUCCESS;
                // @codeCoverageIgnoreEnd
            }
        }

        ///////////////////////////////////////////
        // Normal mode                           //
        ///////////////////////////////////////////
        if (count($job) > 0) {

            if ($this->option('no-interaction')) {
                $do = true;
            } // @codeCoverageIgnoreStart
            else {
                $this->writeLine('');
                $do = ($this->ask('Do you wish to apply these changes now? [yes|no]') === 'yes');
                $this->writeLine('');
            }
            // @codeCoverageIgnoreEnd

            if ($do === true) {

                if (! $this->option('no-backup')) {
                    $this->writeLine('Backup files:');

                    $now = $this->manager->getBackupDate();

                    foreach ($job as $file_lang_path => $file_content) {
                        $backup_path = $this->manager->getBackupPath($file_lang_path, $now, $extension);

                        if (! $this->option('dry-run')) {
                            rename($file_lang_path, $backup_path);
                        }

                        $this->writeLine("    <info>".$this->manager->getShortPath($file_lang_path)."</info> -> <info>".$this->manager->getShortPath($backup_path)."</info>");
                    }

                    $this->writeLine('');
                }

                $this->writeLine('Save files:');
                $open_files = '';

                foreach ($job as $file_lang_path => $file_content) {
                    if (! $this->option('dry-run')) {
                        file_put_contents($file_lang_path, $file_content);
                    }

                    $this->writeLine("    <info>".$this->manager->getShortPath($file_lang_path)."</info>");

                    // Fix code style
                    try {
                        $this->manager->fixCodeStyle($file_lang_path, $this->code_style_rules);
                    } // @codeCoverageIgnoreStart
                    catch (Exception $e) {
                        $this->writeError("    Cannot fix code style (".$e->getMessage().")");
                    }
                    // @codeCoverageIgnoreEnd

                    // @codeCoverageIgnoreStart
                    if ($this->option('editor')) {
                        $open_files .= ' '.escapeshellarg($file_lang_path);
                    }
                    // @codeCoverageIgnoreEnd

                }

                $this->writeLine('');
                $this->writeInfo('Process done!');

                // @codeCoverageIgnoreStart
                if ($this->option('editor')) {
                    exec($this->editor.$open_files);
                }
                // @codeCoverageIgnoreEnd

                // @codeCoverageIgnoreStart
            } else {
                $this->writeLine('');
                $this->writeComment('Process aborted. No file has been changed.');
            }
        } // @codeCoverageIgnoreEnd
        else {
            $this->writeLine('');
            $this->writeInfo('Drink a Piña colada and/or smoke Super Skunk, you have nothing to do!');
        }
        $this->writeLine('');

        return self::SUCCESS;
    }
1133404
public function command()
    {
        $cmd = func_get_args();
        if (strpos($cmd[0], 'plugin.') !== false)
            $this->js_commands[] = array('triggerEvent', $cmd[0], $cmd[1]);
        else
            $this->js_commands[] = $cmd;
    }
1058699
public function handle()
    {
        $extension = $this->argument('extension');

        if (empty($extension) || !Arr::has(Admin::$extensions, $extension)) {
            $extension = $this->choice('Please choose a extension to import', array_keys(Admin::$extensions));
        }

        $className = Arr::get(Admin::$extensions, $extension);

        if (!class_exists($className) || !method_exists($className, 'import')) {
            $this->error("Invalid Extension [$className]");

            return;
        }

        call_user_func([$className, 'import'], $this);

        $this->info("Extension [$className] imported");
    }