function regexArray($regexs) { $matches = array(); D::log($_SERVER['QUERY_STRING']); foreach ($regexs as $regex => $func) { preg_match_all($regex, $_SERVER['QUERY_STRING'], $matches); if (f_first($matches)) { return f_push(array($func), f_map('f_first', f_rest($matches))); } } return false; }
function _buildPulls($pulls, $on=null, $with=array()) { //D::log($pulls, '$pulls'); $builtPulls = array(); foreach($pulls as $k => $pull) { if(is_string($k)) { //sub join? $pullRel = $this->relationships[$k]; if(is_string($fKey = f_first(array_keys($pullRel)) )) { $flName = $fKey; $model = $this->model(f_first($pullRel[$fKey])); } else { $flName = $k; $model = $this->model(f_first($pullRel)); } if(is_array($rfName = f_last($pullRel))) { $rfName = f_last(f_last($pullRel)); } //$builtPulls[] = $model->_buildPull($k, $pullRel, $on, $flName, $rfName); $builtPulls[] = $model->_buildPull(join('$', f_push($k, $with)), $pullRel, $on, $flName, $rfName); $builtPulls = array_merge($builtPulls, $model->_buildPulls((array)$pull, join('$', f_push($k, $with)), f_push($k, (array)$with) )); } else { if(is_array($pull)) { $builtPulls = array_merge($builtPulls, $this->_buildPulls($pull, $on, $with)); continue; } //regular join if(!array_key_exists($pull, $this->relationships)) { //D::show($this->relationships, 'Current relationships'); D::warn($pull . ' can\'t be found in the ' . get_class($this) . ' model'); } $pullRel = $this->relationships[$pull]; if(is_string($fKey = f_first(array_keys($pullRel)) )) { $flName = $fKey; $model = $this->model(f_first($pullRel[$fKey])); } else { $flName = $pull; $model = $this->model(f_first($pullRel)); } if(is_array($rfName = f_last($pullRel))) { $rfName = f_last(f_last($pullRel)); } $builtPulls[] = $model->_buildPull(join('$', f_push($pull, $with)), $pullRel, $on, $flName, $rfName); } } return $builtPulls; }
private function regexArray($regexs) { $matches = array(); foreach($regexs as $regex => $func) { preg_match_all($regex, $this->request, $matches); if(f_first($matches)) { D::log($regex, 'regex'); return f_push( array($func), array_map('f_first', f_rest($matches)) ); } } return false; }