Created
November 30, 2010 19:35
-
-
Save shadab16/722240 to your computer and use it in GitHub Desktop.
Saved in /library/GeekPoint/Symfony.php for autoloading purpose.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A helper class for use in the Symfony Framework. Although there's no restriction to use it in | |
* any other framework or script. Just the autoloader needs to be setup before using this class. | |
* Sample code for initializing XenForo from your own script: | |
* | |
* <code> | |
* $startTime = microtime(true); | |
* $xenforoRoot = '/absolute/path/to/xenforo/root/directory'; | |
* | |
* require_once($xenforoRoot . '/library/XenForo/Autoloader.php'); | |
* XenForo_Autoloader::getInstance()->setupAutoloader($xenforoRoot . '/library'); | |
* | |
* GeekPoint_Symfony::initializeXenforo($xenforoRoot, $startTime); | |
* </code> | |
* | |
* @package GeekPoint_Symfony | |
* @author Shadab Ansari | |
*/ | |
class GeekPoint_Symfony | |
{ | |
/** | |
* The dependencies object | |
* | |
* @var XenForo_Dependencies_Abstract | |
*/ | |
static protected $_dependencies = null; | |
/** | |
* Initialize the XenForo Framework and setup the session; | |
* for use from outside the MVC framework. | |
* | |
* @param string $xenforoRoot The path to your XenForo instance | |
* @param float $startTime The current time as Unix Timestamp (Optional Param) | |
*/ | |
public static function initializeXenforo($xenforoRoot, $startTime = NULL) | |
{ | |
if (!$startTime) | |
{ | |
$startTime = microtime(true); | |
} | |
// Initialize the XenForo application | |
XenForo_Application::initialize($xenforoRoot . '/library', $xenforoRoot); | |
XenForo_Application::set('page_start_time', $startTime); | |
// Preload the dependencies for XenForo | |
self::$_dependencies = new XenForo_Dependencies_Public(); | |
self::$_dependencies->preLoadData(); | |
// Initialize the Session using XenForo | |
XenForo_Session::startPublicSession(); | |
} | |
/** | |
* Get the internal dependencies object | |
* | |
* @return XenForo_Dependencies_Abstract | |
*/ | |
public static function getDependencies() | |
{ | |
return self::$_dependencies; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment