code: private function getPageId()
      {
          if (preg_match('/\/page\/(\w+)$/', $this->name, $matches)) {
              $id = $matches[1];
          } else {
              $id = $this->environment->getRequestHelper()->getIdentifierParam('id', null, true);
          }
          return $id;
      }
docs: Checks if the page is contained in service name or specified in parameter 'id' and returns the value then.
  
  @return mixed