protected function _copyPackage($clearDestination = false)
    {
        $source = new Folder($this->_workingDir);
        $destinationPath = normalizePath(ROOT . "/plugins/{$this->_plugin['name']}/");

        // allow to install from destination folder
        if ($this->_workingDir === $destinationPath) {
            return true;
        }

        if (!$clearDestination && is_readable($destinationPath)) {
            $this->err(__d('installer', 'Destination directory already exists, please delete manually this directory: {0}', $destinationPath));

            return false;
        } elseif ($clearDestination && is_readable($destinationPath)) {
            $destination = new Folder($destinationPath);
            if (!$destination->delete()) {
                $this->err(__d('installer', 'Destination directory could not be cleared, please check write permissions: {0}', $destinationPath));

                return false;
            }
        }

        if ($source->copy(['to' => $destinationPath])) {
            return true;
        }

        $this->err(__d('installer', 'Error when moving package content.'));

        return false;
    }