Drupal investigation

FileLoader.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Serializer\Mapping\Loader;
  11. use Symfony\Component\Serializer\Exception\MappingException;
  12. /**
  13. * Base class for all file based loaders.
  14. *
  15. * @author Kévin Dunglas <dunglas@gmail.com>
  16. */
  17. abstract class FileLoader implements LoaderInterface
  18. {
  19. /**
  20. * @var string
  21. */
  22. protected $file;
  23. /**
  24. * Constructor.
  25. *
  26. * @param string $file The mapping file to load
  27. *
  28. * @throws MappingException if the mapping file does not exist or is not readable
  29. */
  30. public function __construct($file)
  31. {
  32. if (!is_file($file)) {
  33. throw new MappingException(sprintf('The mapping file %s does not exist', $file));
  34. }
  35. if (!is_readable($file)) {
  36. throw new MappingException(sprintf('The mapping file %s is not readable', $file));
  37. }
  38. $this->file = $file;
  39. }
  40. }