Jump to content

Make ProcessPageView::getPage() hookable


wumbo
 Share

Recommended Posts

Hi,

I'm about to implement a multisite project with PW3 (which is great btw!!!).

Because of "reasons" I need to implement my own routing. To do this I implemented a little module the hooks ProcessPageView::execute(). I reviewed its code and found out, that the actual logic to look-up the requested page from the request is placed in a protected method ProcessPageView::getPage(). And because this method is currently not hookable, I needed to do a dirty hack (overriding the GET.it parameter that is inspected by ProcessPageView::getPage()).

I suggest making ProcessPageView::getPage() hookable and pass the arguments for the page look-up via method arguments instead of inspecting the GET scope within the method.

  • Like 1
Link to comment
Share on other sites

I think something like this would be better:

class ProcessPageView extends Process {
  // ...
  public function ___execute($internal = true) {
    // ...
    $page = $this->getPage(isset($_GET['it']) ? $_GET['it'] : '/');
  }
   
  public function ___getPage($it)
  {
     // use $it argument instead of $_GET['it']
  }
}

With this, the PW core could do its thing as always, but users may change the page look-up behaviour bei hooking into ProcessPageView::getPage.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...