Populator.php 1015 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Autoload;
  7. use Magento\Framework\App\Filesystem\DirectoryList;
  8. use Magento\Framework\Filesystem\FileResolver;
  9. /**
  10. * Utility class for populating an autoloader with application-specific information for PSR-0 and PSR-4 mappings
  11. * and include-path contents
  12. */
  13. class Populator
  14. {
  15. /**
  16. * @param AutoloaderInterface $autoloader
  17. * @param DirectoryList $dirList
  18. * @return void
  19. */
  20. public static function populateMappings(AutoloaderInterface $autoloader, DirectoryList $dirList)
  21. {
  22. $generationDir = $dirList->getPath(DirectoryList::GENERATED_CODE);
  23. $autoloader->addPsr4('Magento\\', [$generationDir . '/Magento/'], true);
  24. /** Required for code generation to occur */
  25. FileResolver::addIncludePath($generationDir);
  26. /** Required to autoload custom classes */
  27. $autoloader->addPsr0('', [$generationDir]);
  28. }
  29. }