function StageBase::destroy

Deletes the stage directory.

Parameters

bool $force: (optional) If TRUE, the stage directory will be destroyed even if it is not owned by the current user or session. Defaults to FALSE.

\Drupal\Core\StringTranslation\TranslatableMarkup|null $message: (optional) A message about why the stage was destroyed.

Throws

\Drupal\package_manager\Exception\StageException If the staged changes are being applied to the active directory.

\Drupal\Core\TempStore\TempStoreException

2 calls to StageBase::destroy()
StageBase::create in core/modules/package_manager/src/StageBase.php
Copies the active code base into the stage directory.
StageBase::require in core/modules/package_manager/src/StageBase.php
Adds or updates packages in the stage directory.

File

core/modules/package_manager/src/StageBase.php, line 548

Class

StageBase
Creates and manages a stage directory in which to install or update code.

Namespace

Drupal\package_manager

Code

public function destroy(bool $force = FALSE, ?TranslatableMarkup $message = NULL) : void {
    if (!$force) {
        $this->checkOwnership();
    }
    if ($this->isApplying()) {
        throw new StageException($this, 'Cannot destroy the stage directory while it is being applied to the active directory.');
    }
    // If the stage directory exists, queue it to be automatically cleaned up
    // later by a queue (which may or may not happen during cron).
    // @see \Drupal\package_manager\Plugin\QueueWorker\Cleaner
    if ($this->stageDirectoryExists()) {
        $this->queueFactory
            ->get('package_manager_cleanup')
            ->createItem($this->getStageDirectory());
    }
    $this->storeDestroyInfo($force, $message);
    $this->markAsAvailable();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.