Permalink
Browse files

Fix XML and YAML drivers to correctly include files and throw excepti…

…ons.

Previously files were not correctly searched for when using automapping,
additionally all paths weren't traversed before throwing and exception,
lastly the exception factory method being used didn't exist in the
dependency (which has been added as a separate commit).
  • Loading branch information...
1 parent 1967e38 commit a0749ee7b1d166d959f118f4e1467d1e3dc36358 Saem Ghani committed Sep 25, 2012
Showing with 4 additions and 8 deletions.
  1. +2 −4 Mapping/Driver/XmlDriver.php
  2. +2 −4 Mapping/Driver/YamlDriver.php
View
6 Mapping/Driver/XmlDriver.php
@@ -127,7 +127,7 @@ protected function initialize()
protected function findMappingFile($className)
{
$defaultFileName = str_replace('\\', '.', $className) . $this->fileExtension;
- foreach ($this->paths as $path) {
+ foreach ($this->paths as $path => $prefix) {
if (!isset($this->prefixes[$path])) {
if (file_exists($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
return $path . DIRECTORY_SEPARATOR . $defaultFileName;
@@ -146,10 +146,8 @@ protected function findMappingFile($className)
if (file_exists($filename)) {
return $filename;
}
-
- throw MappingException::mappingFileNotFound($className, $filename);
}
- throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension);
+ throw MappingException::mappingFileNotFound($className, $defaultFileName);
}
}
View
6 Mapping/Driver/YamlDriver.php
@@ -127,7 +127,7 @@ protected function initialize()
protected function _findMappingFile($className)
{
$defaultFileName = str_replace('\\', '.', $className) . $this->fileExtension;
- foreach ($this->paths as $path) {
+ foreach ($this->paths as $path => $prefix) {
if (!isset($this->prefixes[$path])) {
if (file_exists($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
return $path . DIRECTORY_SEPARATOR . $defaultFileName;
@@ -146,10 +146,8 @@ protected function _findMappingFile($className)
if (file_exists($filename)) {
return $filename;
}
-
- throw MappingException::mappingFileNotFound($className, $filename);
}
- throw MappingException::mappingFileNotFound($className, substr($className, strrpos($className, '\\') + 1).$this->fileExtension);
+ throw MappingException::mappingFileNotFound($className, $defaultFileName);
}
}

0 comments on commit a0749ee

Please sign in to comment.