/** * @ignore */ public function resolve($uPathInfo, $uMethod = null, $uMethodExt = null) { $this->load(); // @todo use $this->routes->top() if needed. foreach ($this->rewrites as $tRewriteItem) { if (isset($tRewriteItem[2]) && $uMethod !== null && !in_array($uMethod, $tRewriteItem[2])) { continue; } if ($this->rewriteUrl($uPathInfo, $tRewriteItem['match'], $tRewriteItem['forward'])) { break; } } // @todo use $this->routes->top() if needed. foreach ($this->routes as $tRouteItem) { if (isset($tRouteItem[2]) && $uMethod !== null && !in_array($uMethod, $tRouteItem[2])) { continue; } $tMatches = Utils::pregMatch(ltrim($tRouteItem[0], '/'), $uPathInfo); if (count($tMatches) > 0) { $tParameters = array('method' => $uMethod, 'methodext' => $uMethodExt); foreach ($tRouteItem[3] as $tDefaultKey => $tDefaultItem) { if (isset($tMatches[$tDefaultKey])) { $tParameters[$tDefaultKey] = $tMatches[$tDefaultKey]; } else { $tParameters[$tDefaultKey] = $tDefaultItem; } } return array($uPathInfo, $tRouteItem[1], $tParameters); } } return array($uPathInfo, null, null); }
/** * @ignore */ public function storageGetUrl($uKey) { return Utils::translate($this->baseurl) . $uKey; }
/** * @ignore */ public function __construct() { $this->db = Datasources::get(); // default datasource to member 'db' $this->logger = new LoggerInstance(get_class($this)); $this->prerender = new Delegate(); $this->postrender = new Delegate(); $tReflection = new \ReflectionClass($this); foreach ($tReflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $tMethodReflection) { if ($tMethodReflection->class === __CLASS__) { continue; } $tDocComment = $tMethodReflection->getDocComment(); if (strlen($tDocComment) > 0) { $this->annotations[$tMethodReflection->name] = Utils::parseAnnotations($tDocComment); } } }
/** * Loads the json decoded object into an array. * * @param mixed $uTarget target reference * @param mixed $uNode source object * @param bool $uOverwrite overwrite existing values * @param array $tNodeStack stack of nodes * @param bool $uIsArray whether is an array or not * @param array $uNodeFlags flags of the node */ private static function jsonProcessChildrenRecursive(&$uTarget, $uNode, $uOverwrite, &$tNodeStack, $uIsArray = false, array $uNodeFlags = array()) { if (is_object($uNode) && !in_array('direct', $uNodeFlags)) { foreach ($uNode as $tKey => $tSubnode) { $tNodeName = explode(':', $tKey); if (count($tNodeName) >= 2) { if ($tNodeName[1] === 'disabled') { continue; } elseif ($tNodeName[1] === 'development') { if (!Framework::$development) { continue; } } elseif ($tNodeName[1] === 'application') { if (Framework::$application->name !== $tNodeName[2]) { continue; } } elseif ($tNodeName[1] === 'phpversion') { if (!Utils::phpVersion($tNodeName[2])) { continue; } } elseif ($tNodeName[1] === 'phpextension') { if (!extension_loaded($tNodeName[2])) { continue; } } } $tNodeStack[] = $tNodeName[0]; array_shift($tNodeName); self::jsonProcessChildrenRecursive($uTarget, $tSubnode, $uOverwrite, $tNodeStack, false, $tNodeName); array_pop($tNodeStack); } } else { $tNodePath = implode('/', $tNodeStack); if ($uIsArray) { if (!is_scalar($uNode)) { if (in_array('override', $uNodeFlags)) { $uTarget = array(); } foreach ($uNode as $tSubnodeKey => $tSubnode) { $tNewNodeStack = array(); if (in_array('direct', $uNodeFlags)) { self::jsonProcessChildrenRecursive($uTarget[$tSubnodeKey], $tSubnode, $uOverwrite, $tNewNodeStack, true, $uNodeFlags); } else { self::jsonProcessChildrenRecursive($uTarget[], $tSubnode, $uOverwrite, $tNewNodeStack, true, $uNodeFlags); } } } else { $uTarget = $uNode; } } else { if (!is_scalar($uNode)) { if (in_array('override', $uNodeFlags) || !isset($uTarget[$tNodePath])) { $uTarget[$tNodePath] = array(); } foreach ($uNode as $tSubnodeKey => $tSubnode) { $tNewNodeStack = array(); if (in_array('direct', $uNodeFlags)) { self::jsonProcessChildrenRecursive($uTarget[$tNodePath][$tSubnodeKey], $tSubnode, $uOverwrite, $tNewNodeStack, true, $uNodeFlags); } else { self::jsonProcessChildrenRecursive($uTarget[$tNodePath][], $tSubnode, $uOverwrite, $tNewNodeStack, true, $uNodeFlags); } } } elseif ($uOverwrite || !isset($uTarget[$tNodePath])) { $uTarget[$tNodePath] = $uNode; } } } }
/** * Serializes an object into a file. * * @param string $uPath the file path * @param string $uContent the file content * @param string|null $uKeyphase the key * * @return bool */ public static function writeSerialize($uPath, $uContent, $uKeyphase = null) { $tContent = serialize($uContent); if ($uKeyphase !== null && strlen($uKeyphase) > 0) { $tContent = Utils::encrypt($tContent, $uKeyphase); } return self::write($uPath, $tContent); }