original_string: public function onInstallPlugin()
      {
          try {
              if (!$code = trim(post('code'))) {
                  throw new ApplicationException(Lang::get('system::lang.install.missing_plugin_name'));
              }
  
              $manager = UpdateManager::instance();
              $result = $manager->requestPluginDetails($code);
  
              if (!isset($result['code']) || !isset($result['hash'])) {
                  throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
              }
  
              $name = $result['code'];
              $hash = $result['hash'];
              $plugins = [$name => $hash];
              $plugins = $this->appendRequiredPlugins($plugins, $result);
  
              /*
               * Update steps
               */
              $updateSteps = $this->buildUpdateSteps(null, $plugins, [], true);
  
              /*
               * Finish up
               */
              $updateSteps[] = [
                  'code'  => 'completeInstall',
                  'label' => Lang::get('system::lang.install.install_completing'),
              ];
  
              $this->vars['updateSteps'] = $updateSteps;
  
              return $this->makePartial('execute');
          }
          catch (Exception $ex) {
              $this->handleError($ex);
              return $this->makePartial('plugin_form');
          }
      }
code: public function onInstallPlugin()
      {
          try {
              if (!$code = trim(post('code'))) {
                  throw new ApplicationException(Lang::get('system::lang.install.missing_plugin_name'));
              }
  
              $manager = UpdateManager::instance();
              $result = $manager->requestPluginDetails($code);
  
              if (!isset($result['code']) || !isset($result['hash'])) {
                  throw new ApplicationException(Lang::get('system::lang.server.response_invalid'));
              }
  
              $name = $result['code'];
              $hash = $result['hash'];
              $plugins = [$name => $hash];
              $plugins = $this->appendRequiredPlugins($plugins, $result);
  
              /*
               * Update steps
               */
              $updateSteps = $this->buildUpdateSteps(null, $plugins, [], true);
  
              /*
               * Finish up
               */
              $updateSteps[] = [
                  'code'  => 'completeInstall',
                  'label' => Lang::get('system::lang.install.install_completing'),
              ];
  
              $this->vars['updateSteps'] = $updateSteps;
  
              return $this->makePartial('execute');
          }
          catch (Exception $ex) {
              $this->handleError($ex);
              return $this->makePartial('plugin_form');
          }
      }
code_tokens: public function onInstallPlugin ( ) { try { if ( ! $ code = trim ( post ( 'code' ) ) ) { throw new ApplicationException ( Lang :: get ( 'system::lang.install.missing_plugin_name' ) ) ; } $ manager = UpdateManager :: instance ( ) ; $ result = $ manager -> requestPluginDetails ( $ code ) ; if ( ! isset ( $ result [ 'code' ] ) || ! isset ( $ result [ 'hash' ] ) ) { throw new ApplicationException ( Lang :: get ( 'system::lang.server.response_invalid' ) ) ; } $ name = $ result [ 'code' ] ; $ hash = $ result [ 'hash' ] ; $ plugins = [ $ name => $ hash ] ; $ plugins = $ this -> appendRequiredPlugins ( $ plugins , $ result ) ; /*
               * Update steps
               */ $ updateSteps = $ this -> buildUpdateSteps ( null , $ plugins , [ ] , true ) ; /*
               * Finish up
               */ $ updateSteps [ ] = [ 'code' => 'completeInstall' , 'label' => Lang :: get ( 'system::lang.install.install_completing' ) , ] ; $ this -> vars [ 'updateSteps' ] = $ updateSteps ; return $ this -> makePartial ( 'execute' ) ; } catch ( Exception $ ex ) { $ this -> handleError ( $ ex ) ; return $ this -> makePartial ( 'plugin_form' ) ; } }
docstring: Validate the plugin code and execute the plugin installation
docstring_tokens: Validate the plugin code and execute the plugin installation