本文整理汇总了PHP中Thin\Arrays::inArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Arrays::inArray方法的具体用法?PHP Arrays::inArray怎么用?PHP Arrays::inArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thin\Arrays
的用法示例。
在下文中一共展示了Arrays::inArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run()
{
Request::$route = $route = Utils::get('appDispatch');
container()->setRoute($route);
$render = $route->getRender();
$tplDir = $route->getTemplateDir();
$module = $route->getModule();
$controller = $route->getController();
$action = $route->getAction();
$alert = $route->getAlert();
$page = container()->getPage();
$isCms = !empty($page);
if (!empty($render)) {
$tplMotor = $route->getTemplateMotor();
$tplDir = empty($tplDir) ? APPLICATION_PATH . DS . SITE_NAME . DS . 'app' . DS . 'views' : $tplDir;
$tpl = $tplDir . DS . $render . '.phtml';
if (File::exists($tpl)) {
if ('Twig' == $tplMotor) {
if (!class_exists('Twig_Autoloader')) {
require_once 'Twig/Autoloader.php';
}
$tab = explode(DS, $tpl);
$file = Arrays::last($tab);
$path = repl(DS . $file, '', $tpl);
$loader = new \Twig_Loader_Filesystem($path);
$view = new \Twig_Environment($loader, array('cache' => CACHE_PATH, 'debug' => false, 'charset' => 'utf-8', 'strict_variables' => false));
container()->setView($view);
if ($action instanceof Closure) {
$action($view);
}
$params = null === container()->getViewParams() ? array() : container()->getViewParams();
echo $view->render($file, $params);
/* stats */
if (null === container()->getNoShowStats() && null === $route->getNoShowStats()) {
echo View::showStats();
}
} else {
$view = new View($tpl);
container()->setView($view);
if ($action instanceof Closure) {
$action($view);
}
$view->render();
/* stats */
if (null === container()->getNoShowStats() && null === $route->getNoShowStats()) {
echo View::showStats();
}
}
return;
}
}
$module = Inflector::lower($module);
$controller = Inflector::lower($controller);
$action = Inflector::lower($action);
if (true === container()->getMultiSite()) {
$moduleDir = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $module;
} else {
$moduleDir = APPLICATION_PATH . DS . 'modules' . DS . $module;
}
if (!is_dir($moduleDir)) {
throw new Exception("The module '{$module}' does not exist.");
}
$controllerDir = $moduleDir . DS . 'controllers';
if (!is_dir($controllerDir)) {
throw new Exception("The controller '{$controller}' does not exist.");
}
$controllerFile = $controllerDir . DS . $controller . 'Controller.php';
if (!File::exists($controllerFile)) {
throw new Exception("The controller '{$controllerFile}' does not exist.");
}
require_once $controllerFile;
$controllerClass = 'Thin\\' . $controller . 'Controller';
$controller = new $controllerClass();
$controller->view = new View($route->getView());
if (null !== $alert) {
$controller->view->alert($alert);
}
container()->setController($controller);
$actions = get_class_methods($controllerClass);
if (true === $isCms) {
if (!Arrays::inArray($action, $actions)) {
$action = 'page';
}
}
container()->setAction($action);
if (strstr($action, '-')) {
$words = explode('-', $action);
$newAction = '';
for ($i = 0; $i < count($words); $i++) {
$word = trim($words[$i]);
if ($i > 0) {
$word = ucfirst($word);
}
$newAction .= $word;
}
$action = $newAction;
}
$actionName = $action . 'Action';
if (Arrays::in('init', $actions)) {
$controller->init();
//.........这里部分代码省略.........
示例2: populate
public function populate(array $datas, $namespace = null)
{
if (null !== $namespace) {
if (!isset($this->{$namespace})) {
$this->{$namespace} = array();
}
foreach ($datas as $k => $v) {
if (Arrays::is($k)) {
$this->populate($k, $namespace);
} else {
$this->{$namespace} = array_merge($this->{$namespace}, array($k => $v));
}
}
} else {
foreach ($datas as $k => $v) {
if (Arrays::is($v)) {
$o = new self();
$o->populate($v);
$this->{$k} = $o;
} else {
$this->{$k} = $v;
}
if (!Arrays::inArray($k, $this->_fields)) {
$this->_fields[] = $k;
}
}
}
return $this;
}