Added getter function to retrieve active page object
authorAlexander Ebert <ebert@woltlab.com>
Thu, 19 May 2016 21:12:54 +0000 (23:12 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 19 May 2016 21:18:39 +0000 (23:18 +0200)
wcfsetup/install/files/lib/system/WCF.class.php

index a2652411160b8c03e70f293ab0f4af6e4b8ed096..f0a637df0ff73814f68ab386428ee99ce3f21062 100644 (file)
@@ -5,6 +5,8 @@ use wcf\data\option\OptionEditor;
 use wcf\data\package\Package;
 use wcf\data\package\PackageCache;
 use wcf\data\package\PackageEditor;
+use wcf\data\page\Page;
+use wcf\data\page\PageCache;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\application\IApplication;
 use wcf\system\box\BoxHandler;
@@ -20,6 +22,7 @@ use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\SystemException;
 use wcf\system\language\LanguageFactory;
 use wcf\system\package\PackageInstallationDispatcher;
+use wcf\system\request\Request;
 use wcf\system\request\RequestHandler;
 use wcf\system\request\RouteHandler;
 use wcf\system\session\SessionFactory;
@@ -796,6 +799,24 @@ class WCF {
                return self::getRequestURI() . '#' . $fragment;
        }
        
+       /**
+        * Returns the currently active page or null if unknown.
+        * 
+        * @return Page|null
+        */
+       public static function getActivePage() {
+               return PageCache::getInstance()->getPageByController(self::getActiveRequest()->getClassName());
+       }
+       
+       /**
+        * Returns the currently active request.
+        * 
+        * @return Request
+        */
+       public static function getActiveRequest() {
+               return RequestHandler::getInstance()->getActiveRequest();
+       }
+       
        /**
         * Returns the URI of the current page.
         *