original_string: protected function _finish(PluginPackage $plugin)
      {
          $pluginEntity = $this->Plugins
              ->find()
              ->where(['name' => $plugin->name])
              ->first();
          $pluginEntity->set('status', $this->params['status'] === 'enable' ? true : false);
  
          if (!$this->Plugins->save($pluginEntity)) {
              if ($this->params['status'] === 'enable') {
                  $this->err(__d('installer', 'Plugin "{0}" could not be enabled due to an internal error.', $plugin->humanName));
              } else {
                  $this->err(__d('installer', 'Plugin "{0}" could not be disabled due to an internal error.', $plugin->humanName));
              }
  
              return false;
          }
  
          snapshot();
  
          if (!$this->params['no-callbacks']) {
              $this->_triggerAfterEvents($plugin);
          }
  
          return true;
      }
code: protected function _finish(PluginPackage $plugin)
      {
          $pluginEntity = $this->Plugins
              ->find()
              ->where(['name' => $plugin->name])
              ->first();
          $pluginEntity->set('status', $this->params['status'] === 'enable' ? true : false);
  
          if (!$this->Plugins->save($pluginEntity)) {
              if ($this->params['status'] === 'enable') {
                  $this->err(__d('installer', 'Plugin "{0}" could not be enabled due to an internal error.', $plugin->humanName));
              } else {
                  $this->err(__d('installer', 'Plugin "{0}" could not be disabled due to an internal error.', $plugin->humanName));
              }
  
              return false;
          }
  
          snapshot();
  
          if (!$this->params['no-callbacks']) {
              $this->_triggerAfterEvents($plugin);
          }
  
          return true;
      }
code_tokens: protected function _finish ( PluginPackage $ plugin ) { $ pluginEntity = $ this -> Plugins -> find ( ) -> where ( [ 'name' => $ plugin -> name ] ) -> first ( ) ; $ pluginEntity -> set ( 'status' , $ this -> params [ 'status' ] === 'enable' ? true : false ) ; if ( ! $ this -> Plugins -> save ( $ pluginEntity ) ) { if ( $ this -> params [ 'status' ] === 'enable' ) { $ this -> err ( __d ( 'installer' , 'Plugin "{0}" could not be enabled due to an internal error.' , $ plugin -> humanName ) ) ; } else { $ this -> err ( __d ( 'installer' , 'Plugin "{0}" could not be disabled due to an internal error.' , $ plugin -> humanName ) ) ; } return false ; } snapshot ( ) ; if ( ! $ this -> params [ 'no-callbacks' ] ) { $ this -> _triggerAfterEvents ( $ plugin ) ; } return true ; }
docstring: Finish this task.
  
  @param \CMS\Core\Package\PluginPackage $plugin The plugin being managed
  by this task
  @return bool True on success
docstring_tokens: Finish this task .