Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

AutoLoader.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 1.88 KiB


 01  <?php
 02  namespace OAuth\Common;
 03   
 04  /**
 05   * PSR-0 Autoloader
 06   * @author ieter Hordijk <info@pieterhordijk.com>
 07   */
 08  class AutoLoader
 09  {
 10      /**
 11       * @var string The namespace prefix for this instance.
 12       */
 13      protected $namespace = '';
 14   
 15      /**
 16       * @var string The filesystem prefix to use for this instance
 17       */
 18      protected $path = '';
 19   
 20      /**
 21       * Build the instance of the autoloader
 22       *
 23       * @param string $namespace The prefixed namespace this instance will load
 24       * @param string $path The filesystem path to the root of the namespace
 25       */
 26      public function __construct($namespace, $path)
 27      {
 28          $this->namespace = ltrim($namespace, '\\');
 29          $this->path      = rtrim($path, '/\\') . DIRECTORY_SEPARATOR;
 30      }
 31   
 32      /**
 33       * Try to load a class
 34       *
 35       * @param string $class The class name to load
 36       *
 37       * @return boolean If the loading was successful
 38       */
 39      public function load($class)
 40      {
 41          $class = ltrim($class, '\\');
 42   
 43          if (strpos($class, $this->namespace) === 0) {
 44              $nsparts   = explode('\\', $class);
 45              $class     = array_pop($nsparts);
 46              $nsparts[] = '';
 47              $path      = $this->path . implode(DIRECTORY_SEPARATOR, $nsparts);
 48              $path     .= str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
 49   
 50              if (file_exists($path)) {
 51                  require $path;
 52                  return true;
 53              }
 54          }
 55          return false;
 56      }
 57   
 58      /**
 59       * Register the autoloader to PHP
 60       *
 61       * @return boolean The status of the registration
 62       */
 63      public function register()
 64      {
 65          return spl_autoload_register(array($this, 'load'));
 66      }
 67   
 68      /**
 69       * Unregister the autoloader to PHP
 70       *
 71       * @return boolean The status of the unregistration
 72       */
 73      public function unregister()
 74      {
 75          return spl_autoload_unregister(array($this, 'load'));
 76      }
 77  }
 78