function StageBase::postApply

Performs post-apply tasks.

This should be called as soon as possible after ::apply(), in a new request.

See also

::apply()

File

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

Class

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

Namespace

Drupal\package_manager

Code

public function postApply() : void {
    $this->checkOwnership();
    if ($this->tempStore
        ->get(self::TEMPSTORE_APPLY_TIME_KEY) === $this->time
        ->getRequestTime()) {
        $this->logger?->warning('Post-apply tasks are running in the same request during which staged changes were applied to the active code base. This can result in unpredictable behavior.');
    }
    // Rebuild the container and clear all caches, to ensure that new services
    // are picked up.
    drupal_flush_all_caches();
    // Refresh the event dispatcher so that new or changed event subscribers
    // will be called. The other services we depend on are either stateless or
    // unlikely to call newly added code during the current request.
    $this->eventDispatcher = \Drupal::service('event_dispatcher');
    $release_apply = $this->setNotApplying(...);
    $this->dispatch(new PostApplyEvent($this), $release_apply);
    $release_apply();
}

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