Esempio n. 1
0
 public function testInstance()
 {
     $rule = new RedirectRule([1, Redirect::TYPE_EXACT, Redirect::TARGET_TYPE_PATH_URL, '/from/url', '/to/url', null, null, 301, null, Carbon::today(), Carbon::tomorrow()]);
     self::assertEquals(1, $rule->getId());
     self::assertEquals(Redirect::TYPE_EXACT, $rule->getMatchType());
     self::assertEquals(Redirect::TARGET_TYPE_PATH_URL, $rule->getTargetType());
     self::assertEquals('/from/url', $rule->getFromUrl());
     self::assertEquals('/to/url', $rule->getToUrl());
     self::assertEquals(301, $rule->getStatusCode());
     self::assertEquals(Carbon::today(), $rule->getFromDate());
     self::assertEquals(Carbon::tomorrow(), $rule->getToDate());
 }
Esempio n. 2
0
 /**
  * @param RedirectRule $rule
  * @return string
  */
 private function redirectToPathOrUrl(RedirectRule $rule)
 {
     if ($rule->isExactMatchType()) {
         return $rule->getToUrl();
     }
     $placeholderMatches = $rule->getPlaceholderMatches();
     return str_replace(array_keys($placeholderMatches), array_values($placeholderMatches), $rule->getToUrl());
 }