Author: chabotc Date: Sun Aug 2 12:05:10 2009 New Revision: 800038 URL: http://svn.apache.org/viewvc?rev=800038&view=rev Log: JIRA-678, allow for chained autoloading
Modified: incubator/shindig/trunk/php/config/container.php incubator/shindig/trunk/php/index.php Modified: incubator/shindig/trunk/php/config/container.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/config/container.php?rev=800038&r1=800037&r2=800038&view=diff ============================================================================== --- incubator/shindig/trunk/php/config/container.php (original) +++ incubator/shindig/trunk/php/config/container.php Sun Aug 2 12:05:10 2009 @@ -112,6 +112,10 @@ // Force these libraries to be external (included through <script src="..."> tags), this way they could be cached by the browser 'focedJsLibs' => '', + // After checking the internal __autoload function, shindig can also call the 'extension_autoloader' function to load an + // unknown custom class, this is particuarly useful for when intergrating shindig into an existing framework that also depends on autoloading + 'extension_autoloader' => false, + // Configurable classes. Change these to the class name to use, and make sure the auto-loader can find them 'blacklist_class' => 'BasicGadgetBlacklist', 'remote_content' => 'BasicRemoteContent', @@ -158,7 +162,6 @@ // If your development server is behind a proxy, enter the proxy details here in 'proxy.host.com:port' format. 'proxy' => '', - // If your server is behind a reverse proxy, set the real hostname here so that OAuth signatures match up, for example: // 'http_host' => 'modules.partuza.nl' 'http_host' => false, Modified: incubator/shindig/trunk/php/index.php URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/index.php?rev=800038&r1=800037&r2=800038&view=diff ============================================================================== --- incubator/shindig/trunk/php/index.php (original) +++ incubator/shindig/trunk/php/index.php Sun Aug 2 12:05:10 2009 @@ -46,23 +46,10 @@ // All configurable classes are autoloaded (see config.php for the configurable classes) // To load these, we scan our entire directory structure function __autoload($className) { - $locations = array( - 'src/common', - 'src/common/sample', - 'src/gadgets', - 'src/gadgets/servlet', - 'src/gadgets/oauth', - 'src/gadgets/sample', - 'src/social', - 'src/social/servlet', - 'src/social/service', - 'src/social/opensocial', - 'src/social/model', - 'src/social/spi', - 'src/social/converters', - 'src/social/oauth', - 'src/social/sample' - ); + $locations = array('src/common', 'src/common/sample', 'src/gadgets', 'src/gadgets/servlet', + 'src/gadgets/oauth', 'src/gadgets/sample', 'src/social', 'src/social/servlet', + 'src/social/service', 'src/social/opensocial', 'src/social/model', 'src/social/spi', + 'src/social/converters', 'src/social/oauth', 'src/social/sample'); $extension_class_paths = Config::get('extension_class_paths'); if (! empty($extension_class_paths)) { $locations = array_merge(explode(',', $extension_class_paths), $locations); @@ -71,27 +58,28 @@ $fileName = $className . '.php'; foreach ($locations as $path) { if (file_exists("{$path}/$fileName")) { - require $path.'/'.$fileName; - break; + require $path . '/' . $fileName; + return; } } + if (($loader = Config::get('extension_autoloader')) && function_exists($loader)) { + call_user_func($loader, $className); + } } -$servletMap = array( - Config::get('web_prefix') . '/gadgets/files' => 'FilesServlet', - Config::get('web_prefix') . '/gadgets/js' => 'JsServlet', - Config::get('web_prefix') . '/gadgets/proxy' => 'ProxyServlet', - Config::get('web_prefix') . '/gadgets/makeRequest' => 'MakeRequestServlet', - Config::get('web_prefix') . '/gadgets/ifr' => 'GadgetRenderingServlet', - Config::get('web_prefix') . '/gadgets/metadata' => 'MetadataServlet', - Config::get('web_prefix') . '/gadgets/oauthcallback' => 'OAuthCallbackServlet', - Config::get('web_prefix') . '/gadgets/api/rpc' => 'JsonRpcServlet', - Config::get('web_prefix') . '/gadgets/api/rest' => 'DataServiceServlet', - Config::get('web_prefix') . '/social/rest' => 'DataServiceServlet', - Config::get('web_prefix') . '/social/rpc' => 'JsonRpcServlet', - Config::get('web_prefix') . '/public.crt' => 'CertServlet', - Config::get('web_prefix') . '/public.cer' => 'CertServlet' -); +$servletMap = array(Config::get('web_prefix') . '/gadgets/files' => 'FilesServlet', + Config::get('web_prefix') . '/gadgets/js' => 'JsServlet', + Config::get('web_prefix') . '/gadgets/proxy' => 'ProxyServlet', + Config::get('web_prefix') . '/gadgets/makeRequest' => 'MakeRequestServlet', + Config::get('web_prefix') . '/gadgets/ifr' => 'GadgetRenderingServlet', + Config::get('web_prefix') . '/gadgets/metadata' => 'MetadataServlet', + Config::get('web_prefix') . '/gadgets/oauthcallback' => 'OAuthCallbackServlet', + Config::get('web_prefix') . '/gadgets/api/rpc' => 'JsonRpcServlet', + Config::get('web_prefix') . '/gadgets/api/rest' => 'DataServiceServlet', + Config::get('web_prefix') . '/social/rest' => 'DataServiceServlet', + Config::get('web_prefix') . '/social/rpc' => 'JsonRpcServlet', + Config::get('web_prefix') . '/public.crt' => 'CertServlet', + Config::get('web_prefix') . '/public.cer' => 'CertServlet'); // Try to match the request url to our servlet mapping $servlet = false;