for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Tadcka package.
*
* (c) Tadas Gliaubicas <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tadcka\Bundle\RoutingBundle\Doctrine\EntityManager;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityRepository;
use Tadcka\Component\Routing\Model\Manager\RedirectRouteManager as BaseRedirectRouteManager;
use Tadcka\Component\Routing\Model\RedirectRouteInterface;
/**
* @author Tadas Gliaubicas <[email protected]>
* @since 8/28/14 2:31 PM
class RedirectRouteManager extends BaseRedirectRouteManager
{
* @var EntityManager
protected $em;
* @var EntityRepository
protected $repository;
* @var string
protected $class;
* Constructor.
* @param EntityManager $em
* @param string $class
public function __construct(EntityManager $em, $class)
$this->em = $em;
$this->repository = $em->getRepository($class);
$this->class = $em->getClassMetadata($class)->name;
}
* {@inheritdoc}
public function findByName($name)
return $this->repository->findOneBy(array('name' => $name));
public function add(RedirectRouteInterface $redirectRoute, $save = false)
$this->em->persist($redirectRoute);
if (true === $save) {
$this->save();
public function remove(RedirectRouteInterface $redirectRoute, $save = false)
$this->em->remove($redirectRoute);
public function save()
$this->em->flush();
public function clear()
$this->em->clear($this->getClass());
public function getClass()
return $this->class;