code: private function isScope(string $scope): bool
      {
          if (
              null === $this->container
              || null === ($request = $this->container->get('request_stack')->getCurrentRequest())
          ) {
              return false;
          }
  
          $matcher = $this->container->get('contao.routing.scope_matcher');
  
          if (ContaoCoreBundle::SCOPE_BACKEND === $scope) {
              return $matcher->isBackendRequest($request);
          }
  
          if (ContaoCoreBundle::SCOPE_FRONTEND === $scope) {
              return $matcher->isFrontendRequest($request);
          }
  
          return false;
      }
docs: Checks whether the _scope attributes matches a scope.