/** * Init hashmap for a clean * html render */ private function initHashmap() { // Calculate hashmaps (if they weren't just calculated) if (false == ArrayHelper::isAssociative(self::$md5VarHashmap)) { for ($i = 0; $i < count(self::$md5VarHashmap); $i++) { self::$md5VarHashmap[self::$md5VarHashmap[$i]] = md5(self::$md5VarHashmap[$i]); unset(self::$md5VarHashmap[$i]); } } }
/** * @param string $url * @param array $arguments */ public static function parseRouteUrl($url, $arguments = array()) { preg_match_all(Route::VAR_MASK, $url, $matches); if (ArrayHelper::isAssociative($arguments)) { for ($i = 0, $len = count($matches[1]); $i < $len; $i++) { if (array_key_exists($matches[1][$i], $arguments)) { $url = preg_replace('/' . $matches[0][$i] . '/', $arguments[$matches[1][$i]], $url); } } } else { for ($i = 0, $len = count($matches[1]); $i < $len; $i++) { if (array_key_exists($i, $arguments)) { $url = preg_replace('/' . $matches[0][$i] . '/', $arguments[$i], $url); } } } return $url; }
/** * @param {array} $values * @return self */ public function assignMultiple($values) { if (ArrayHelper::isAssociative($values)) { foreach ($values as $name => $content) { $this->assign($name, $content); } } else { throw new View\Exception\MultipleValuesNotAssociativeException('The array given is not associative. You need to pass a name for each variable content you want to assign to the view'); } return $this; }
/** * Transforms the attributes * to a valid array * * @param array $attributes * @return array */ private function addAttributes($attributes) { if (is_array($attributes) && array_key_exists(self::ATTRIBUTE_KEY, $attributes)) { return $attributes[self::ATTRIBUTE_KEY]; } else { if (ArrayHelper::isAssociative($attributes)) { return $attributes; } } return array(); }