Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Validator\Mapping\Loader; Chris@0: Chris@0: use Symfony\Component\Validator\Exception\MappingException; Chris@0: Chris@0: /** Chris@0: * Base loader for loading validation metadata from a file. Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: * Chris@0: * @see YamlFileLoader Chris@0: * @see XmlFileLoader Chris@0: */ Chris@0: abstract class FileLoader extends AbstractLoader Chris@0: { Chris@0: protected $file; Chris@0: Chris@0: /** Chris@0: * Creates a new loader. Chris@0: * Chris@0: * @param string $file The mapping file to load Chris@0: * Chris@0: * @throws MappingException If the file does not exist or is not readable Chris@0: */ Chris@0: public function __construct($file) Chris@0: { Chris@0: if (!is_file($file)) { Chris@0: throw new MappingException(sprintf('The mapping file "%s" does not exist', $file)); Chris@0: } Chris@0: Chris@0: if (!is_readable($file)) { Chris@0: throw new MappingException(sprintf('The mapping file "%s" is not readable', $file)); Chris@0: } Chris@0: Chris@0: if (!stream_is_local($this->file)) { Chris@0: throw new MappingException(sprintf('The mapping file "%s" is not a local file', $file)); Chris@0: } Chris@0: Chris@0: $this->file = $file; Chris@0: } Chris@0: }