summaryrefslogtreecommitdiff
path: root/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php
diff options
context:
space:
mode:
authorxue <>2006-09-23 01:51:57 +0000
committerxue <>2006-09-23 01:51:57 +0000
commita5467e842316daf6a8a4345740f05a9731167ce1 (patch)
tree0a982dd52df5c682fd2de8f9b22137471cee2dbe /framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php
parent9af56fd93ed071d86f14296cec618073f6c0941a (diff)
merge from 3.0 branch till 1435.
Diffstat (limited to 'framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php')
-rw-r--r--framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php
new file mode 100644
index 00000000..72a5692b
--- /dev/null
+++ b/framework/3rdParty/PhpShell/PHP/Shell/Extensions/Autoload.php
@@ -0,0 +1,60 @@
+<?php
+/**
+* Autoload Extension
+*
+* Note: shell wrapper has to create the __autoload() function when
+* isAutoloadEnabled() is true
+*
+* handles the options to enable the internal autoload support
+*
+* :set al
+* :set autoload
+*
+* autoload can't be disabled
+*/
+
+class PHP_Shell_Extensions_Autoload implements PHP_Shell_Extension {
+ /**
+ * does the use want to use the internal autoload ?
+ *
+ * @var bool
+ */
+ protected $autoload = false;
+
+ public function register() {
+ $opt = PHP_Shell_Options::getInstance();
+
+ $opt->registerOption("autoload", $this, "optSetAutoload");
+ $opt->registerOptionAlias("al", "autoload");
+ }
+
+ /**
+ * sets the autoload-flag
+ *
+ * - the $value is ignored and doesn't have to be set
+ * - if __autoload() is defined, the set fails
+ */
+ public function optSetAutoload($key, $value) {
+ if ($this->autoload) {
+ print('autload is already enabled');
+ return;
+ }
+
+ if (function_exists('__autoload')) {
+ print('can\'t enabled autoload as a external __autoload() function is already defined');
+ return;
+ }
+
+ $this->autoload = true;
+ }
+
+ /**
+ * is the autoload-flag set ?
+ *
+ * @return bool true if __autoload() should be set by the external wrapper
+ */
+ public function isAutoloadEnabled() {
+ return $this->autoload;
+ }
+}
+