Default.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * Maps classes to paths following the PHP Framework Interop Group PSR-0
  4. * reference implementation. Under this guideline, the following rules apply:
  5. *
  6. * Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system.
  7. * Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.
  8. * The fully-qualified namespace and class is suffixed with ".php" when loading from the file system.
  9. *
  10. * Examples:
  11. *
  12. * \Doctrine\Common\IsolatedClassLoader => /path/to/project/lib/vendor/Doctrine/Common/IsolatedClassLoader.php
  13. * \namespace\package\Class_Name => /path/to/project/lib/vendor/namespace/package/Class/Name.php
  14. * \namespace\package_name\Class_Name => /path/to/project/lib/vendor/namespace/package_name/Class/Name.php
  15. *
  16. * @author Chuck Hagenbuch <chuck@horde.org>
  17. * @category Horde
  18. * @package Autoloader
  19. */
  20. class Horde_Autoloader_ClassPathMapper_Default implements Horde_Autoloader_ClassPathMapper
  21. {
  22. private $_includePath;
  23. public function __construct($includePath)
  24. {
  25. $this->_includePath = $includePath;
  26. }
  27. public function mapToPath($className)
  28. {
  29. // @FIXME: Follow reference implementation
  30. $relativePath = str_replace(['\\', '_'], DIRECTORY_SEPARATOR, $className) . '.php';
  31. return $this->_includePath . DIRECTORY_SEPARATOR . $relativePath;
  32. }
  33. }