Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fix #96 refactor Loader to override hash method #97

Closed
wants to merge 1 commit into from

2 participants

@pscheit

okay it was that easy..

just a little bit refactoring to override the hash method (currently get_class) easier

@pscheit pscheit fix #96
okay it was that easy..
ca9e4e0
@lavoiesl
Collaborator

Closing this PR since the milestone would be 2.0, please continue discussion in #96 and reopen if needed.

@lavoiesl lavoiesl closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2013
  1. @pscheit

    fix #96

    pscheit authored
    okay it was that easy..
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 4 deletions.
  1. +15 −4 lib/Doctrine/Common/DataFixtures/Loader.php
View
19 lib/Doctrine/Common/DataFixtures/Loader.php
@@ -116,7 +116,7 @@ public function loadFromDirectory($dir)
*/
public function hasFixture($fixture)
{
- return isset($this->fixtures[get_class($fixture)]);
+ return isset($this->fixtures[$this->hashFixture($fixture)]);
}
/**
@@ -126,9 +126,9 @@ public function hasFixture($fixture)
*/
public function addFixture(FixtureInterface $fixture)
{
- $fixtureClass = get_class($fixture);
+ $fixtureHash = this->hashFixture($fixture);
- if (!isset($this->fixtures[$fixtureClass])) {
+ if (!isset($this->fixtures[$fixtureHash])) {
if ($fixture instanceof OrderedFixtureInterface && $fixture instanceof DependentFixtureInterface) {
throw new \InvalidArgumentException(sprintf('Class "%s" can\'t implement "%s" and "%s" at the same time.',
get_class($fixture),
@@ -143,9 +143,20 @@ public function addFixture(FixtureInterface $fixture)
}
}
- $this->fixtures[$fixtureClass] = $fixture;
+ $this->fixtures[$fixtureHash] = $fixture;
}
}
+
+ /**
+ * Returns a unique hash for a fixture
+ *
+ * fixtures with the same hash cannot be added more than once
+ * @return string
+ */
+ protected function hashFixture(FixtureInterface $fixture)
+ {
+ return get_class($fixture);
+ }
/**
* Returns the array of data fixtures to execute.
Something went wrong with that request. Please try again.