1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace Doctrine\Common\DataFixtures;
- use Doctrine\Common\DataFixtures\ReferenceRepository;
- /**
- * Abstract Fixture class helps to manage references
- * between fixture classes in order to set relations
- * among other fixtures
- *
- * @author Gediminas Morkevicius <gediminas.morkevicius@gmail.com>
- */
- abstract class AbstractFixture implements SharedFixtureInterface
- {
- /**
- * Fixture reference repository
- *
- * @var ReferenceRepository
- */
- protected $referenceRepository;
-
- /**
- * {@inheritdoc}
- */
- public function setReferenceRepository(ReferenceRepository $referenceRepository)
- {
- $this->referenceRepository = $referenceRepository;
- }
-
- /**
- * Set the reference entry identified by $name
- * and referenced to managed $object. If $name
- * already is set, it overrides it
- *
- * @param string $name
- * @param object $object - managed object
- * @see Doctrine\Common\DataFixtures\ReferenceRepository::setReference
- * @return void
- */
- public function setReference($name, $object)
- {
- $this->referenceRepository->setReference($name, $object);
- }
-
- /**
- * Set the reference entry identified by $name
- * and referenced to managed $object. If $name
- * already is set, it throws a
- * BadMethodCallException exception
- *
- * @param string $name
- * @param object $object - managed object
- * @see Doctrine\Common\DataFixtures\ReferenceRepository::addReference
- * @throws \BadMethodCallException - if repository already has
- * a reference by $name
- * @return void
- */
- public function addReference($name, $object)
- {
- $this->referenceRepository->addReference($name, $object);
- }
-
- /**
- * Loads an object using stored reference
- * named by $name
- *
- * @param string $name
- * @see Doctrine\Common\DataFixtures\ReferenceRepository::getReference
- * @return object
- */
- public function getReference($name)
- {
- return $this->referenceRepository->getReference($name);
- }
-
- /**
- * Check if an object is stored using reference
- * named by $name
- *
- * @param string $name
- * @see Doctrine\Common\DataFixtures\ReferenceRepository::hasReference
- * @return boolean
- */
- public function hasReference($name)
- {
- return $this->referenceRepository->hasReference($name);
- }
- }
|