protected function dispatchHooks($scopeType, \stdClass $entity)
    {
        $fullScopeClass = 'Drupal\\DrupalExtension\\Hook\\Scope\\' . $scopeType;
        $scope = new $fullScopeClass($this->getDrupal()->getEnvironment(), $this, $entity);
        $callResults = $this->dispatcher->dispatchScopeHooks($scope);

        // The dispatcher suppresses exceptions, throw them here if there are any.
        foreach ($callResults as $result) {
            if ($result->hasException()) {
                $exception = $result->getException();
                throw $exception;
            }
        }
    }