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;
    }