本文整理汇总了PHP中Lib::module_root_path方法的典型用法代码示例。如果您正苦于以下问题:PHP Lib::module_root_path方法的具体用法?PHP Lib::module_root_path怎么用?PHP Lib::module_root_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lib
的用法示例。
在下文中一共展示了Lib::module_root_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handler
/**
* URLパターンからハンドリング
* @param mixed{} $urls
* @param int $index
* @return $this
*/
private function handler(array $urls = array(), $index = 0)
{
if (preg_match("/^\\/" . str_replace("/", "\\/", self::$package_media_url) . "\\/(\\d+)\\/(\\d+)\\/(.+)\$/", $this->args(), $match)) {
if ($match[1] == $index) {
foreach ($urls as $args) {
if ($match[2] == $args['map_index'] && isset($args['class'])) {
$this->attach_file(File::absolute(Lib::module_root_path(Lib::imported_path(Lib::import($args['class']))) . '/resources/media', $match[3]));
}
}
Http::status_header(404);
exit;
}
return $this;
}
foreach (array_keys($urls) as $pattern) {
if (preg_match("/^" . (empty($pattern) ? "" : "\\/") . str_replace(array("\\/", "/", "__SLASH__"), array("__SLASH__", "\\/", "\\/"), $pattern) . '[\\/]{0,1}$/', $this->args(), $params)) {
Log::debug("match pattern `" . $pattern . "` " . (empty($urls[$pattern]['name']) ? '' : '[' . $urls[$pattern]['name'] . ']'));
array_shift($params);
$this->pattern = $pattern;
$map = $urls[$pattern];
$action = null;
if (!empty($map['redirect']) && empty($map['class'])) {
$this->redirect($map['redirect'][0] == '/' ? substr($map['redirect'], 1) : $map['redirect']);
}
if (!empty($map['template']) && empty($map['method'])) {
$action = new self('_scope_=' . $map['scope']);
$action->set($this, $map, $pattern, $params, $urls);
} else {
if (empty($map['class'])) {
throw new RuntimeException('Invalid map');
}
$class = class_exists($map['class']) ? $map['class'] : Lib::import($map['class']);
if (!method_exists($class, $map['method'])) {
throw new RuntimeException($map['class'] . '::' . $map['method'] . ' not found');
}
if (!is_subclass_of($class, __CLASS__)) {
throw new RuntimeException("class is not " . __CLASS__);
}
$action = new $class('_scope_=' . $map['scope'] . ',_init_=false');
foreach (array('redirect', 'name') as $k) {
$action->{$k} = $map[$k];
}
$action->set($this, $map, $pattern, $params, $urls);
call_user_func_array(array($action, $map['method']), $params);
if (!$action->is_filename()) {
$ref = new ReflectionObject($action);
$file = dirname($ref->getFileName()) . '/resources/templates/' . $map['method'] . '.html';
if (is_file($file)) {
$action->template($file);
$action->media_url(App::url('/' . self::$package_media_url . '/' . $index . '/' . $urls[$pattern]['map_index']));
} else {
if ($action->is_filename($map['method'] . '.html')) {
$action->template($map['method'] . '.html');
}
}
}
}
$action->call_module('after_flow', $action);
$this->add_object($action->o('Template'));
$this->cp(self::execute_var($map['vars']));
$this->vars('t', new Templf($action));
break;
}
}
return $this;
}
示例2: module_media
/**
* パッケージのmediaのパスを返す
* @param strng $path ベースパスに続くメディアのパス
* @return string
*/
function module_media($path = null)
{
list($file) = debug_backtrace(false);
$root = Lib::module_root_path($file["file"]) . "/resources/media";
return empty($path) ? $root : File::absolute($root, $path);
}