restler2.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Restler 2 compatibility mode enabler
  4. */
  5. use Luracast\Restler\Defaults;
  6. use Luracast\Restler\AutoLoader;
  7. use Luracast\Restler\CommentParser;
  8. //changes in auto loading
  9. $classMap = array();
  10. //find lowercase php files representing a class/interface
  11. foreach (explode(PATH_SEPARATOR, get_include_path()) as $path)
  12. foreach (new DirectoryIterator($path) as $fileInfo)
  13. if ($fileInfo->isFile()
  14. && 'php' === $fileInfo->getExtension()
  15. && ctype_lower($fileInfo->getBasename('.php'))
  16. && preg_match(
  17. '/^ *(class|interface|abstract +class)'
  18. . ' +([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/m',
  19. file_get_contents($fileInfo->getPathname()),
  20. $matches
  21. )
  22. )
  23. $classMap[$matches[2]] = $fileInfo->getPathname();
  24. AutoLoader::seen($classMap);
  25. //changes in iAuthenticate
  26. Defaults::$authenticationMethod = '__isAuthenticated';
  27. include __DIR__ . '/iAuthenticate.php';
  28. //changes in auto routing
  29. Defaults::$smartAutoRouting = false;
  30. Defaults::$smartParameterParsing = false;
  31. Defaults::$autoValidationEnabled = false;
  32. //changes in parsing embedded data in comments
  33. CommentParser::$embeddedDataPattern = '/\((\S+)\)/ms';
  34. CommentParser::$embeddedDataIndex = 1;