コード例 #1
0
 /**
  * @param string $name
  * @param string $identifier
  * @param string $url
  */
 public function update($name, $identifier, $url)
 {
     $dao = $this->getRouteDao();
     if (empty($url)) {
         return false;
     }
     if ($url[0] !== '/') {
         $url = '/' . $url;
         // Prefix urls with /
     }
     $routeModel = $dao->findByNameAndIdentifier((string) $name, (string) $identifier);
     if (!$routeModel) {
         // Create new route because it doesn't exist yet
         $routeModel = new Route();
     }
     $routeModel->name = $name;
     $routeModel->identifier = (string) $identifier;
     $routeModel->url = $url;
     $routeModel->save();
     return $routeModel;
 }
コード例 #2
0
 /**
  * @param string $name
  * @param string $identifier
  * @return RouteModel
  */
 public static function findByNameAndIdentifier($name, $identifier)
 {
     return RouteModel::findFirst(['conditions' => ['name' => $name, 'identifier' => $identifier]]);
 }