public function getContainer() {
    // kernel will only boot if necessary
    $this->kernel->boot();

    // boot bundles if necessary
    if (!$this->bundlesBooted) {
      foreach ($this->kernel->getBundles() as $bundle) {
        $bundle->boot();
      }
      $this->bundlesBooted = true;
    }

    return $this->kernel->getContainer();
  }