public function generateRouteGenerator(\Symforce\AdminBundle\Compiler\Generator\PhpWriter $generator, $use_object, $is_first = false)
 {
     $admin_name = $this->admin->getName();
     $route_parent = $this->admin->getRouteParent();
     if ($route_parent) {
         if ($is_first) {
             $generator->writeln(sprintf('$%s = $loader->getAdminByClass("%s");', $admin_name, $this->admin->getClassName()));
             $generator->writeln(sprintf('$_sf_admin_route_parameters = $%s->getRouteParameters();', $admin_name));
         }
         $route_parent_name = $route_parent->getName();
         $parent_property = $this->admin->getRouteParentProperty();
         $generator->writeln(sprintf('if( !isset($options["%s_id"] )) {', $route_parent_name))->indent();
         if ($use_object) {
             $generator->writeln(sprintf('$%s_object = $%s_object ? $accessor->getValue($%s_object, "%s") : null ;', $route_parent_name, $admin_name, $admin_name, $parent_property))->writeln(sprintf('if( $%s_object ) {', $route_parent_name))->indent()->writeln(sprintf('$options["%s_id"] = $accessor->getValue($%s_object, "%s") ;', $route_parent_name, $route_parent_name, $route_parent->getPropertyIdName()))->outdent()->writeln(sprintf('} else if( isset($_sf_admin_route_parameters["%s_id"] )) {', $route_parent_name))->indent()->writeln(sprintf('$options["%s_id"] = $_sf_admin_route_parameters["%s_id"] ;', $route_parent_name, $route_parent_name))->outdent()->writeln('} else {')->indent()->writeln(sprintf(' $options["%s_id"] = $loader->getAdminByClass("%s")->getRouteObjectId() ;', $route_parent_name, $route_parent->getClassName()))->outdent()->writeln('}');
         } else {
             $generator->writeln(sprintf('if( isset($_sf_admin_route_parameters["%s_id"] )) {', $route_parent_name))->indent()->writeln(sprintf(' $options["%s_id"] = $_sf_admin_route_parameters["%s_id"] ;', $route_parent_name, $route_parent_name))->outdent()->writeln('} else {')->indent()->writeln(sprintf(' $options["%s_id"] = $loader->getAdminByClass("%s")->getRouteObjectId() ;', $route_parent_name, $route_parent->getClassName()))->outdent()->writeln('} ');
         }
         $generator->outdent()->writeln('}');
         $route_parent_generator = $this->loader->getAdminRouteGenerator($route_parent_name);
         $route_parent_generator->generateRouteGenerator($generator, $use_object);
     }
 }