original_string: public function getGenerator()
      {
          if (null !== $this->generator) {
              return $this->generator;
          }
  
          $compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && UrlGenerator::class === $this->options['generator_base_class'];
  
          if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
              $routes = $this->getRouteCollection();
              if ($compiled) {
                  $routes = (new CompiledUrlGeneratorDumper($routes))->getCompiledRoutes();
              }
              $this->generator = new $this->options['generator_class']($routes, $this->context, $this->logger, $this->defaultLocale);
          } else {
              $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$this->options['generator_cache_class'].'.php',
                  function (ConfigCacheInterface $cache) {
                      $dumper = $this->getGeneratorDumperInstance();
  
                      $options = [
                          'class' => $this->options['generator_cache_class'],
                          'base_class' => $this->options['generator_base_class'],
                      ];
  
                      $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
                  }
              );
  
              if ($compiled) {
                  $this->generator = new $this->options['generator_class'](require $cache->getPath(), $this->context, $this->logger);
              } else {
                  if (!class_exists($this->options['generator_cache_class'], false)) {
                      require_once $cache->getPath();
                  }
  
                  $this->generator = new $this->options['generator_cache_class']($this->context, $this->logger, $this->defaultLocale);
              }
          }
  
          if ($this->generator instanceof ConfigurableRequirementsInterface) {
              $this->generator->setStrictRequirements($this->options['strict_requirements']);
          }
  
          return $this->generator;
      }
code: public function getGenerator()
      {
          if (null !== $this->generator) {
              return $this->generator;
          }
  
          $compiled = is_a($this->options['generator_class'], CompiledUrlGenerator::class, true) && UrlGenerator::class === $this->options['generator_base_class'];
  
          if (null === $this->options['cache_dir'] || null === $this->options['generator_cache_class']) {
              $routes = $this->getRouteCollection();
              if ($compiled) {
                  $routes = (new CompiledUrlGeneratorDumper($routes))->getCompiledRoutes();
              }
              $this->generator = new $this->options['generator_class']($routes, $this->context, $this->logger, $this->defaultLocale);
          } else {
              $cache = $this->getConfigCacheFactory()->cache($this->options['cache_dir'].'/'.$this->options['generator_cache_class'].'.php',
                  function (ConfigCacheInterface $cache) {
                      $dumper = $this->getGeneratorDumperInstance();
  
                      $options = [
                          'class' => $this->options['generator_cache_class'],
                          'base_class' => $this->options['generator_base_class'],
                      ];
  
                      $cache->write($dumper->dump($options), $this->getRouteCollection()->getResources());
                  }
              );
  
              if ($compiled) {
                  $this->generator = new $this->options['generator_class'](require $cache->getPath(), $this->context, $this->logger);
              } else {
                  if (!class_exists($this->options['generator_cache_class'], false)) {
                      require_once $cache->getPath();
                  }
  
                  $this->generator = new $this->options['generator_cache_class']($this->context, $this->logger, $this->defaultLocale);
              }
          }
  
          if ($this->generator instanceof ConfigurableRequirementsInterface) {
              $this->generator->setStrictRequirements($this->options['strict_requirements']);
          }
  
          return $this->generator;
      }
code_tokens: public function getGenerator ( ) { if ( null !== $ this -> generator ) { return $ this -> generator ; } $ compiled = is_a ( $ this -> options [ 'generator_class' ] , CompiledUrlGenerator :: class , true ) && UrlGenerator :: class === $ this -> options [ 'generator_base_class' ] ; if ( null === $ this -> options [ 'cache_dir' ] || null === $ this -> options [ 'generator_cache_class' ] ) { $ routes = $ this -> getRouteCollection ( ) ; if ( $ compiled ) { $ routes = ( new CompiledUrlGeneratorDumper ( $ routes ) ) -> getCompiledRoutes ( ) ; } $ this -> generator = new $ this -> options [ 'generator_class' ] ( $ routes , $ this -> context , $ this -> logger , $ this -> defaultLocale ) ; } else { $ cache = $ this -> getConfigCacheFactory ( ) -> cache ( $ this -> options [ 'cache_dir' ] . '/' . $ this -> options [ 'generator_cache_class' ] . '.php' , function ( ConfigCacheInterface $ cache ) { $ dumper = $ this -> getGeneratorDumperInstance ( ) ; $ options = [ 'class' => $ this -> options [ 'generator_cache_class' ] , 'base_class' => $ this -> options [ 'generator_base_class' ] , ] ; $ cache -> write ( $ dumper -> dump ( $ options ) , $ this -> getRouteCollection ( ) -> getResources ( ) ) ; } ) ; if ( $ compiled ) { $ this -> generator = new $ this -> options [ 'generator_class' ] ( require $ cache -> getPath ( ) , $ this -> context , $ this -> logger ) ; } else { if ( ! class_exists ( $ this -> options [ 'generator_cache_class' ] , false ) ) { require_once $ cache -> getPath ( ) ; } $ this -> generator = new $ this -> options [ 'generator_cache_class' ] ( $ this -> context , $ this -> logger , $ this -> defaultLocale ) ; } } if ( $ this -> generator instanceof ConfigurableRequirementsInterface ) { $ this -> generator -> setStrictRequirements ( $ this -> options [ 'strict_requirements' ] ) ; } return $ this -> generator ; }
docstring: Gets the UrlGenerator instance associated with this Router.
  
  @return UrlGeneratorInterface A UrlGeneratorInterface instance
docstring_tokens: Gets the UrlGenerator instance associated with this Router .