lastCall()
function however, makes this process easy by connecting a parent route to its child routes even if they
are not within the same class.
<?php
...
use Window;
use spoova/mi/windows/Routes/HomeUser;
Home extends Window {
function __construct() {
self::call($this,
[
'home/user' => 'win:Routes/HomeUser',
'home/dashboard' => 'dashboard',
]
);
}
function dashboard() : array {
echo lastCall(); // home/dashboard
}
}
<?php
...
use Window;
use spoova/mi/windows/Routes/HomeUser;
Home extends Window {
function __construct() {
echo lastCall(); // home/user
}
}
dashboard() method is called.
However, if the home/user was called, then this will trigger a new class Home/User.
While we can easily guess the last url called for "home/user"
because the method called is within the same class. This may not be easy for the external class HomeUser
called. The lastCall() will however, make it easy to fetch the incoming url as long as a shutter method was used to trigger
the class.
window() function, we can also bind paths to the lastCall() function.
However, this function will not convert dots to slashes.
lastCall('new/path'); //append "new/path" to previous path