mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 16:57:53 +00:00
[FEATURE] Added getIdentifier method to RouterBase
- Fixed getter for getLoadedRoute
This commit is contained in:
@@ -120,8 +120,11 @@ class RouterBase {
|
|||||||
/**
|
/**
|
||||||
* @return RouterEntry
|
* @return RouterEntry
|
||||||
*/
|
*/
|
||||||
public function getLoadedClass() {
|
public function getLoadedRoute() {
|
||||||
return $this->loadedClass;
|
if(!($this->loadedRoute instanceof RouterGroup)) {
|
||||||
|
return $this->loadedRoute;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,6 +33,20 @@ abstract class RouterEntry {
|
|||||||
return new $name();
|
return new $name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns callback name/identifier for the current route based on the callback.
|
||||||
|
* Useful if you need to get a unique identifier for the loaded route, for instance
|
||||||
|
* when using translations etc.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getIdentifier() {
|
||||||
|
if(strpos($this->callback, '@') !== false) {
|
||||||
|
return $this->callback;
|
||||||
|
}
|
||||||
|
return 'function_' . md5($this->callback);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $callback
|
* @param string $callback
|
||||||
* @return self;
|
* @return self;
|
||||||
|
|||||||
Reference in New Issue
Block a user