svn: /phd/trunk/ phpdotnet/phd/Autoloader.php render.php
| From: | Hannes Magnusson | Date: | Tue, 08 Dec 2009 19:09:37 +0000 |
| Subject: | svn: /phd/trunk/ phpdotnet/phd/Autoloader.php render.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-5635@lists.php.net to get a copy of this message | ||
bjori Tue, 08 Dec 2009 19:09:37 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=291893
Log:
- Move the autoloader into its own class
- Only autoload classes from our namespace
Changed paths:
A phd/trunk/phpdotnet/phd/Autoloader.php
U phd/trunk/render.php
Added: phd/trunk/phpdotnet/phd/Autoloader.php
===================================================================
--- phd/trunk/phpdotnet/phd/Autoloader.php (rev 0)
+++ phd/trunk/phpdotnet/phd/Autoloader.php 2009-12-08 19:09:37 UTC (rev 291893)
@@ -0,0 +1,24 @@
+<?php
+namespace phpdotnet\phd;
+class Autoloader
+{
+ public static function autoload($name)
+ {
+ if (strncmp('phpdotnet\phd\\', $name, 14) === 0) {
+ $file = __INSTALLDIR__ . DIRECTORY_SEPARATOR . str_replace(array('\\',
'_'), DIRECTORY_SEPARATOR, $name) . '.php';
+ // Using fopen() because it has use_include_path parameter.
+ if (!$fp = @fopen($file, 'r', true)) {
+ v('Cannot find file for %s: %s', $name, $file, E_USER_ERROR);
+ }
+ fclose($fp);
+ require $file;
+ }
+ return false;
+ }
+}
+
+/*
+* vim600: sw=4 ts=4 syntax=php et
+* vim<600: sw=4 ts=4
+*/
+
Property changes on: phd/trunk/phpdotnet/phd/Autoloader.php
___________________________________________________________________
Added: svn:keywords
+ Id Rev Revision
Added: svn:eol-style
+ native
Modified: phd/trunk/render.php
===================================================================
--- phd/trunk/render.php 2009-12-08 19:01:07 UTC (rev 291892)
+++ phd/trunk/render.php 2009-12-08 19:09:37 UTC (rev 291893)
@@ -7,19 +7,11 @@
// running from SVN
define("__INSTALLDIR__", "@php_dir@" == "@"."php_dir@" ?
__DIR__ : "@php_dir@");
-function autoload($name)
-{
- $file = __INSTALLDIR__ . DIRECTORY_SEPARATOR . str_replace(array('\\',
'_'), DIRECTORY_SEPARATOR, $name) . '.php';
- // Using fopen() because it has use_include_path parameter.
- if (!$fp = @fopen($file, 'r', true)) {
- v('Cannot find file for %s: %s', $name, $file, E_USER_ERROR);
- }
- fclose($fp);
- require $file;
-}
-spl_autoload_register(__NAMESPACE__ . '\\autoload');
-require_once __INSTALLDIR__ . '/phpdotnet/phd/functions.php';
+require __INSTALLDIR__ . '/phpdotnet/phd/Autoloader.php';
+require __INSTALLDIR__ . '/phpdotnet/phd/functions.php';
+spl_autoload_register(array(__NAMESPACE__ . "\\Autoloader", "autoload"));
+
BuildOptionsParser::getopt();
/* If no docbook file was passed, die */