Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Fix XML and YAML drivers to correctly include files and throw excepti…
Browse files Browse the repository at this point in the history
…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
Saem Ghani committed Sep 25, 2012
1 parent 1967e38 commit a0749ee
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 2 additions & 4 deletions Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
6 changes: 2 additions & 4 deletions Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.