本文整理匯總了PHP中Inflector::decamelize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::decamelize方法的具體用法?PHP Inflector::decamelize怎麽用?PHP Inflector::decamelize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Inflector
的用法示例。
在下文中一共展示了Inflector::decamelize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: invokeListeners
/**
* Invoke listeners
*/
public static function invokeListeners($listeners, $data, $event)
{
if (!property_exists("AppConfiguration", "MODEL_LISTENERS")) {
return;
}
// Fire off events to the listeners
foreach ($listeners as $listener) {
$listener_class = $listener["listener"];
$listener_file = WEBAPP_ROOT . "/models/listeners/" . Inflector::decamelize($listener["listener"]) . ".php";
if (!class_exists($listener_class)) {
require_once $listener_file;
}
$listener_impl = new $listener_class();
foreach ($data as $item) {
// Invoke the listener
$listener_impl->{$event}($item);
}
}
}
示例2: test_decamelize
/**
* Tests Inflector::decamelize()
*
* @test
* @dataProvider provider_decamelize
* @param string Camelized string
* @param string Glue
* @param string Expected string
*/
public function test_decamelize($input, $glue, $expected)
{
$this->assertSame($expected, Inflector::decamelize($input, $glue));
}
示例3: executeController
public static final function executeController($controllerScript, $controllerFunction, $controllerParams, $requestURI, $methodParameters, $queryString, $presetVariables = array())
{
// First enable the API, if used
if (property_exists('AppConfiguration', 'API')) {
if (!empty(AppConfiguration::$API)) {
// Include the APIController, which will load itself in the routes as well
require_once LIBS_ROOT . "/api.php";
}
}
// Check routing
$routes = array();
if (property_exists('AppConfiguration', 'ROUTES')) {
$routes = AppConfiguration::$ROUTES;
}
if (file_exists(WEBAPP_ROOT . "/tmp/autoroutes.php")) {
require_once WEBAPP_ROOT . "/tmp/autoroutes.php";
$routes = array_merge($routes, AutoRoutes::$AUTO_ROUTES);
}
/**
* Check if the request is mapped normally or if we have a routing rule for it
*/
if (!empty($routes["/{$controllerScript}/{$controllerFunction}"])) {
/* Use routing */
$route = $routes["/{$controllerScript}/{$controllerFunction}"];
$controllerFilename = $route["file"];
$controllerClass = $route["class"];
} else {
/* Normal mapping */
// Find the controller class
$controllerFilename = WEBAPP_ROOT . "/controllers/" . $controllerScript . "_controller.php";
$controllerClass = ucfirst($controllerScript) . "Controller";
}
if (!file_exists($controllerFilename)) {
controllerErrors::missingcontroller($controllerScript);
}
require_once $controllerFilename;
/*
* Populate some variable to the controller
*/
$controller = new $controllerClass();
$controller->_requestURI = $requestURI;
$controller->params = $controllerParams;
$controller->controllerName = strtolower($controllerScript);
/* Set the controller to the context */
MVCContext::getContext()->setController(&$controller);
if (!empty($presetVariables)) {
$controller->_contextVariables = $presetVariables;
}
// Initialize the controller
$controller->_init();
/*
* See if the requested method exists. If not, we try to find
* a method with the name _default to call, which is a "catch-all" -method
*/
if (!method_exists($controller, $controllerFunction)) {
if (!method_exists($controller, "_default")) {
controllerErrors::missingMethod($controllerScript, $controllerFunction);
} else {
$methodParameters = array_merge(array($controllerScript, "default", $controllerFunction), array_slice($methodParameters, 3));
$controllerFunction = "_default";
}
}
/*
* Populate input
*/
$input = array();
if (!empty($_POST)) {
$input = $_POST;
$controller->inputmethod = INPUT_METHOD_POST;
} else {
parse_str($queryString, $input);
$controller->inputmethod = INPUT_METHOD_GET;
}
/*
* Begin the execution by processing any filters
*/
if (property_exists('AppConfiguration', 'FILTERS')) {
foreach (AppConfiguration::$FILTERS as $filter) {
if ($filter["target"][0] == $controllerScript || $filter["target"][0] == "*") {
// Controller -part matches, see if the action matches
if ($filter["target"][1] == $controllerFunction || $filter["target"][1] == "*" || is_array($filter["target"][1]) && in_array($controllerFunction, $filter["target"][1])) {
// Matches, execute the filter
if (!class_exists($filter["filter"])) {
require_once WEBAPP_ROOT . "/filters/" . Inflector::decamelize($filter["filter"]) . ".php";
}
/*
* Invoke the filter. We provide as parameter the controller name, action name and the input
* sent from the browser. The input is passed by reference so it can be modified
* by the filter along with any parameters defined in the AppConfiguration
*/
$filterClass = $filter["filter"];
$filterImpl = new $filterClass();
if (call_user_func_array(array($filterImpl, "processFilter"), array($controllerScript, $controllerFunction, $filter["parameters"], &$input)) === false) {
// By returning false, the filter can stop the processing
// Then we check if we just "die" or do we do some rendering
if ($filterImpl->_renderView) {
MVC::renderView(!empty($filterImpl->view) ? $filterImpl->view : $controllerFunction, $filterImpl->template, $filterImpl->_contextVariables, $controllerScript, $controllerFunction);
}
// Exit
exit;
//.........這裏部分代碼省略.........