Exemplo n.º 1
0
 /**
  * Test Get and Set Request Url
  *
  * @return void
  *
  * @covers \Rcm\Entity\Redirect
  */
 public function testGetAndSetRequestUrl()
 {
     $url = '/some-page';
     $this->redirect->setRequestUrl($url);
     $actual = $this->redirect->getRequestUrl();
     $this->assertEquals($url, $actual);
 }
Exemplo n.º 2
0
 /**
  * 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);
 }