original_string: public function addPage(PageInterface $page, $route = null)
      {
          if (!isset($this->instances[$page->path()])) {
              $this->instances[$page->path()] = $page;
          }
          $route = $page->route($route);
          if ($page->parent()) {
              $this->children[$page->parent()->path()][$page->path()] = ['slug' => $page->slug()];
          }
          $this->routes[$route] = $page->path();
  
          $this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
      }
code: public function addPage(PageInterface $page, $route = null)
      {
          if (!isset($this->instances[$page->path()])) {
              $this->instances[$page->path()] = $page;
          }
          $route = $page->route($route);
          if ($page->parent()) {
              $this->children[$page->parent()->path()][$page->path()] = ['slug' => $page->slug()];
          }
          $this->routes[$route] = $page->path();
  
          $this->grav->fireEvent('onPageProcessed', new Event(['page' => $page]));
      }
code_tokens: public function addPage ( PageInterface $ page , $ route = null ) { if ( ! isset ( $ this -> instances [ $ page -> path ( ) ] ) ) { $ this -> instances [ $ page -> path ( ) ] = $ page ; } $ route = $ page -> route ( $ route ) ; if ( $ page -> parent ( ) ) { $ this -> children [ $ page -> parent ( ) -> path ( ) ] [ $ page -> path ( ) ] = [ 'slug' => $ page -> slug ( ) ] ; } $ this -> routes [ $ route ] = $ page -> path ( ) ; $ this -> grav -> fireEvent ( 'onPageProcessed' , new Event ( [ 'page' => $ page ] ) ) ; }
docstring: Adds a page and assigns a route to it.
  
  @param PageInterface   $page  Page to be added.
  @param string $route Optional route (uses route from the object if not set).
docstring_tokens: Adds a page and assigns a route to it .