Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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:58 - Dateigröße: 1.89 KiB


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