classloader-config.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use ClassPreloader\ClassLoader;
  3. use ClassPreloader\ClassLoader\Config;
  4. use WP_SQLite_DB\AlterQuery;
  5. use WP_SQLite_DB\CreateQuery;
  6. use WP_SQLite_DB\ObjectArray;
  7. use WP_SQLite_DB\PDOEngine;
  8. use WP_SQLite_DB\PDOSQLiteDriver;
  9. use WP_SQLite_DB\wpsqlitedb;
  10. $config = new Config();
  11. // Exclude all WordPress core classes (e.g. wpdb) from being included.
  12. $config->addExclusiveFilter('#/wordpress/#');
  13. // Based on ClassLoader::getIncludes.
  14. $loader = new ClassLoader();
  15. call_user_func(function (ClassLoader $loader) {
  16. require dirname(__DIR__) . '/vendor/autoload.php';
  17. $loader->register();
  18. // Load files and classes in the order they should be written.
  19. // Load wpsqlitedb manually to avoid
  20. $loader->loadClass(wpsqlitedb::class);
  21. define('FQDB', '');
  22. new PDOEngine();
  23. new PDOSQLiteDriver();
  24. new CreateQuery();
  25. new AlterQuery();
  26. new ObjectArray([]);
  27. new WP_SQLite_DB__Main();
  28. }, $loader);
  29. $loader->unregister();
  30. foreach ($loader->getFilenames() as $file) {
  31. $config->addFile($file);
  32. }
  33. $config->addFile(dirname(__DIR__) . '/partials/bootstrap.php');
  34. return $config;