<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
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
*/
private $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 overrides it
*
* @param string $name
* @param object $object - managed object
* @see Doctrine\Common\DataFixtures\ReferenceRepository::addReference
* @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);
}
}