/** * Test Get and Set Redirect Id * * @return void * * @covers \Rcm\Entity\Redirect */ public function testGetAndSetRedirectId() { $id = 4; $this->redirect->setRedirectId($id); $actual = $this->redirect->getRedirectId(); $this->assertEquals($id, $actual); }
/** * save * * @param RedirectEntity $redirect * @return void */ public function save(\Rcm\Entity\Redirect $redirect) { /** @var \Rcm\Entity\Redirect $result */ $result = $this->findOneBy(['requestUrl' => $redirect->getRequestUrl(), 'redirectUrl' => $redirect->getRedirectUrl(), 'siteId' => $redirect->getSiteId()]); if (!empty($result) && $result->getRedirectId() !== $redirect->getRedirectId()) { throw new RedirectException('Duplicate redirects not allowed'); } if ($redirect->getSiteId() !== null) { $siteRepo = $this->getEntityManager()->getRepository('Rcm\\Entity\\Site'); $site = $siteRepo->find($redirect->getSiteId()); if (empty($site)) { throw new RedirectException('Valid site required'); } $redirect->setSite($site); } $this->getEntityManager()->persist($redirect); $this->getEntityManager()->flush($redirect); }