本文整理汇总了PHP中Loader::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::search方法的具体用法?PHP Loader::search怎么用?PHP Loader::search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader::search方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadTemplate
/**
* Load set template.
*
* @return string File resource
* @throws \Exception
*/
private function loadTemplate()
{
$file = \Loader::search('template' . DIRECTORY_SEPARATOR . $this->template);
if (!$file) {
throw new \Exception('Invalid template name: ' . $this->template);
}
return $file;
}
示例2: loadTemplate
/**
* Load the template provided in input data.
* @param type $templateDirectory
* @param type $template
* @return type
* @throws \Exception
*/
private function loadTemplate($templateDirectory, $template)
{
// Get type-specific suffix prefix.
$suffixPrefix = $this->getSuffixPrefix();
$path = $templateDirectory . DIRECTORY_SEPARATOR . $template . $suffixPrefix . FILE_EXTENSION;
$file = \Loader::search($path, FALSE);
if ($file === FALSE) {
throw new \Exception("Invalid template name: '{$template}'. Could not find file '{$path}'.");
}
return $file;
}
示例3: display_content
/**
* Generates template output.
* Extracts $this->_data into local namespace so that it can be
* interpolated into the output generated by template.
*/
public function display_content()
{
// Search for the template
$file = Loader::search('template', $this->template);
// We need to fetch file manually to allow local variable namespace.
if ($file !== FALSE) {
// Get template variables into local namespace.
extract($this->_data);
require $file;
return TRUE;
}
throw new Exception('Invalid template name');
}
示例4: loadConfig
/**
* Load configuration file.
*
* @param type $file
*/
private static function loadConfig($file)
{
$filename = Loader::search('config' . DIRECTORY_SEPARATOR . $file);
if ($filename) {
// Fetch valid configuration array.
// Cache will prevent multiple includes.
// In the event that it does not, honor the load.
include $filename;
// Cache configuration contents.
if (isset($config) && is_array($config)) {
self::set($file, $config);
}
}
}
示例5: current
/**
* Determines the appropriate controller, method, and arguments
* from the current URI request.
* Where necessary, defaults will be employed.
* Values are stored in local static members for use by the core.
*/
public static function current()
{
$current = self::getRequestPath();
// Are we being run from command line?
if (PHP_SAPI === 'cli') {
// $argv and $argc are disabled by default in some configurations.
$argc = isset($argc) ? $argc : $_SERVER['argc'];
if ($argc > 0) {
$args = isset($argv) ? $argv : $_SERVER['argv'];
// Merge all cli arguments as if they were in a uri from web context.
$current = implode('/', $args);
} else {
$current = self::getRequestPath();
}
}
// Remove dot paths
$current = preg_replace('#\\.[\\s./]*/#', '', $current);
// Remove leading slash
$current = ltrim($current, '/');
// Reduce multiple slashes
$current = preg_replace('#//+#', '/', $current);
// Remove front controller from URI if present (depends on variable used)
$frontController = \Config::get('core.front_controller') . FILE_EXTENSION;
if (substr($current, 0, strlen($frontController)) == $frontController) {
$current = substr($current, strlen($frontController));
}
// Remove any remaining leading/trailing slashes
$current = trim($current, '/');
// Check for rewrites matching configuration values.
$matched = $current;
$rewrites = \Config::get('rewrites');
if (!empty($rewrites)) {
foreach ($rewrites as $match => $replace) {
$match = trim($match, '/');
// Exact match?
if ($match == $current) {
$matched = $replace;
} elseif (preg_match('#^' . $match . '$#u', $current)) {
if (strpos($replace, '$')) {
// Replacement requires arguments that were parsed during match.
$matched = preg_replace('#^' . $match . '$#u', $replace, $current);
} else {
// Found match, no parsed arguments required.
$matched = $replace;
}
}
}
}
$current = $matched;
$parts = array();
if (strlen($current) > 0) {
$parts = explode('/', $current);
}
if (empty($parts)) {
self::$controller = \Config::get('core.default_controller');
} else {
$controller = '';
while (count($parts)) {
$controller .= array_shift($parts);
if (Loader::search('controller' . DIRECTORY_SEPARATOR . $controller)) {
self::$controller = $controller;
if (count($parts)) {
self::$method = array_shift($parts);
}
if (count($parts)) {
self::$arguments = $parts;
}
} else {
$controller .= DIRECTORY_SEPARATOR;
}
}
}
if (empty(self::$method)) {
self::$method = \Config::get('core.default_controller_method');
}
}