本文整理汇总了PHP中AkInflector类的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector类的具体用法?PHP AkInflector怎么用?PHP AkInflector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AkInflector类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: runCommand
function runCommand($command)
{
$commands = $this->getOptionsFromCommand($command);
$generator_name = isset($commands['generator']) ? $commands['generator'] : array_shift($commands);
if (empty($generator_name)) {
echo "\n " . Ak::t("You must supply a valid generator as the first command.\n\n Available generator are:");
echo "\n\n " . join("\n ", $this->_getAvailableGenerators()) . "\n\n";
AK_CONSOLE_MODE ? null : exit;
return;
}
if (count(array_diff($commands, array('help', '-help', 'usage', '-usage', 'h', '-h', 'USAGE', '-USAGE'))) != count($commands) || count($commands) == 0) {
$usage = method_exists($this, 'banner') ? $this->banner() : @Ak::file_get_contents(AK_SCRIPT_DIR . DS . 'generators' . DS . $generator_name . DS . 'USAGE');
echo empty($usage) ? "\n" . Ak::t('Could not locate usage file for this generator') : "\n" . $usage . "\n";
return;
}
if (file_exists(AK_SCRIPT_DIR . DS . 'generators' . DS . $generator_name . DS . $generator_name . '_generator.php')) {
include_once AK_SCRIPT_DIR . DS . 'generators' . DS . $generator_name . DS . $generator_name . '_generator.php';
$generator_class_name = AkInflector::camelize($generator_name . '_generator');
$generator = new $generator_class_name();
$generator->type = $generator_name;
$generator->_identifyUnnamedCommands($commands);
$generator->_assignVars($commands);
$generator->cast();
$generator->_generate();
} else {
echo "\n" . Ak::t('Could not find %generator_name generator', array('%generator_name' => $generator_name)) . "\n";
}
}
开发者ID:joeymetal,项目名称:v1,代码行数:28,代码来源:AkelosGenerator.php
示例2: toString
/**
* Displays a tring representation of the model for debugging.
*/
public function toString($print = false)
{
$result = '';
if (!AK_CLI || AK_ENVIRONMENT == 'testing' && !AK_CLI) {
$result = "<h2>Details for " . AkInflector::humanize(AkInflector::underscore($this->_Model->getModelName())) . " with " . $this->_Model->getPrimaryKey() . " " . $this->_Model->getId() . "</h2>\n<dl>\n";
foreach ($this->_Model->getColumnNames() as $column => $caption) {
$result .= "<dt>{$caption}</dt>\n<dd>" . $this->_Model->getAttribute($column) . "</dd>\n";
}
$result .= "</dl>\n<hr />";
if ($print) {
echo $result;
}
} elseif (AK_DEV_MODE) {
$result = "\n" . str_replace("\n", " ", var_export($this->_Model->getAttributes(), true));
$result .= "\n";
echo $result;
return '';
} elseif (AK_CLI) {
$result = "\n-------\n Details for " . AkInflector::humanize(AkInflector::underscore($this->_Model->getModelName())) . " with " . $this->_Model->getPrimaryKey() . " " . $this->_Model->getId() . " ==\n\n/==\n";
foreach ($this->_Model->getColumnNames() as $column => $caption) {
$result .= "\t * {$caption}: " . $this->_Model->getAttribute($column) . "\n";
}
$result .= "\n\n-------\n";
if ($print) {
echo $result;
}
}
return $result;
}
开发者ID:bermi,项目名称:akelos,代码行数:32,代码来源:debug.php
示例3: cast
function cast()
{
$this->model_name = AkInflector::camelize($this->model_name);
$this->model_file_path = AkInflector::toModelFilename($this->model_name);
if (empty($this->actions) && !empty($this->controller_name) && strstr($this->controller_name, ',')) {
$this->controller_name = '';
}
$this->controller_name = empty($this->controller_name) ? AkInflector::pluralize($this->model_name) : AkInflector::camelize($this->controller_name);
$this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
$this->controller_class_name = str_replace(array('/', '::'), '_', $this->controller_name . 'Controller');
$this->controller_name = AkInflector::demodulize($this->controller_name);
$this->controller_human_name = AkInflector::humanize($this->controller_name);
$this->helper_name = (AkInflector::is_plural($this->controller_name) ? AkInflector::singularize($this->controller_name) : $this->controller_name) . 'Helper';
$this->helper_var_name = '$' . AkInflector::underscore($this->helper_name);
$this->singular_name = AkInflector::underscore($this->model_name);
$this->plural_name = AkInflector::pluralize($this->singular_name);
$this->singular_controller_name = AkInflector::underscore($this->controller_name);
$this->module_preffix = AkInflector::underscore(substr($this->controller_class_name, 0, strrpos($this->controller_class_name, '_')));
$this->module_preffix = empty($this->module_preffix) ? '' : DS . $this->module_preffix;
$this->files = array('controller.php' => $this->controller_file_path, 'helper.php' => AK_HELPERS_DIR . $this->module_preffix . DS . trim($this->helper_var_name, '$') . '.php', 'layout' => AK_VIEWS_DIR . DS . 'layouts' . DS . $this->singular_controller_name . '.tpl', 'view_add' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'add.tpl', 'view_destroy' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'destroy.tpl', 'view_edit' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'edit.tpl', 'view_listing' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'listing.tpl', 'view_show' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . 'show.tpl', 'form' => AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . '_form.tpl');
$this->user_actions = array();
foreach ((array) @$this->actions as $action) {
$this->user_actions[$action] = AK_VIEWS_DIR . $this->module_preffix . DS . $this->singular_controller_name . DS . $action . '.tpl';
}
}
开发者ID:bermi,项目名称:akelos,代码行数:25,代码来源:scaffold_generator.php
示例4: createController
public function createController($controller_name)
{
$controller_class_name = AkInflector::camelize($controller_name) . 'Controller';
$this->Controller = $this->partialMock($controller_class_name, $this->getMethodsToMockForController());
#$this->Controller->Template = $this->getMock('AkActionView');
return $this->Controller;
}
开发者ID:bermi,项目名称:akelos,代码行数:7,代码来源:controller.php
示例5: cast
function cast()
{
$this->model_name = AkInflector::camelize($this->model_name);
$this->model_file_path = AkInflector::toModelFilename($this->model_name);
$this->controller_name = empty($this->controller_name) ? $this->model_name : (AkInflector::camelize($this->controller_name));
$this->controller_file_path = AkInflector::toControllerFilename($this->controller_name);
$this->controller_class_name = $this->controller_name.'Controller';
$this->controller_human_name = AkInflector::humanize($this->controller_name);
$this->helper_var_name = '$'.AkInflector::underscore($this->controller_name).'_helper';
$this->singular_name = AkInflector::underscore($this->model_name);
$this->plural_name = AkInflector::pluralize($this->singular_name);
$this->singular_controller_name = AkInflector::underscore($this->controller_name);
$this->files = array(
'controller.php' => $this->controller_file_path,
/**
* @todo Implement generic functional tests
*/
// 'functional_test.php' => AK_TEST_DIR.DS.'functional'.DS.'test_'.$this->controller_class_name.'.php',
'helper.php' => AK_HELPERS_DIR.DS.trim($this->helper_var_name,'$').'.php',
'layout' => AK_VIEWS_DIR.DS.'layouts'.DS.$this->singular_controller_name.'.tpl',
'view_add' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'add.tpl',
'view_destroy' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'destroy.tpl',
'view_edit' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'edit.tpl',
'view_listing' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'listing.tpl',
'view_show' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'show.tpl',
'form' => AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.'_form.tpl',
);
$this->user_actions = array();
foreach ((array)@$this->actions as $action){
$this->user_actions[$action] = AK_VIEWS_DIR.DS.$this->singular_controller_name.DS.$action.'.tpl';
}
}
开发者ID:joeymetal,项目名称:v1,代码行数:35,代码来源:scaffold_generator.php
示例6: generate
function generate()
{
$this->_preloadPaths();
$this->class_name = AkInflector::camelize($this->class_name);
$files = array(
'mailer'=>AkInflector::toModelFilename($this->class_name),
'unit_test'=>AK_TEST_DIR.DS.'unit'.DS.'app'.DS.'models'.DS.$this->underscored_class_name.'.php'
);
foreach ($files as $template=>$file_path){
$this->save($file_path, $this->render($template));
}
$mailer_views_folder = AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name);
@Ak::make_dir($mailer_views_folder);
foreach ($this->actions as $action){
$this->assignVarToTemplate('action', $action);
$path = $mailer_views_folder.DS.$action.'.tpl';
$this->assignVarToTemplate('path', $path);
$this->save($path, $this->render('view'));
}
}
开发者ID:joeymetal,项目名称:v1,代码行数:25,代码来源:mailer_generator.php
示例7: runCommand
function runCommand($command)
{
$commands = $this->getOptionsFromCommand($command);
$generator_name = AkInflector::underscore(isset($commands['generator']) ? $commands['generator'] : array_shift($commands));
$available_generators = $this->_getAvailableGenerators();
$generator_file_name = array_shift(array_keys($available_generators, $generator_name));
if (empty($generator_file_name)) {
echo "\n " . Ak::t("You must supply a valid generator as the first command.\n\n Available generator are:");
echo "\n\n " . join("\n ", $available_generators) . "\n\n";
defined('AK_CONSOLE_MODE') && AK_CONSOLE_MODE ? null : exit;
return;
}
if (include_once $generator_file_name) {
$generator_class_name = AkInflector::camelize($generator_name . '_generator');
$generator = new $generator_class_name();
$generator->_generator_base_path = dirname($generator_file_name);
if (count(array_diff($commands, array('help', '-help', 'usage', '-usage', 'h', '-h', 'USAGE', '-USAGE'))) != count($commands) || count($commands) == 0) {
if (empty($generator->command_values) && empty($commands)) {
// generator without commands
} else {
$generator->banner();
return;
}
}
$generator->type = $generator_name;
$generator->_identifyUnnamedCommands($commands);
$generator->_assignVars($commands);
$generator->cast();
$generator->_generate();
} else {
echo "\n" . Ak::t('Could not find %generator_name generator', array('%generator_name' => $generator_name)) . "\n";
}
}
开发者ID:joeymetal,项目名称:v1,代码行数:33,代码来源:AkelosGenerator.php
示例8: guide
public function guide()
{
$this->tab = 'docs';
$this->docs_helper->docs_path = 'guides';
$this->title = AkInflector::titleize(@$this->params['id']) . ', Akelos guides';
$this->guide = $this->docs_helper->get_doc_contents(empty($this->params['id']) ? 'getting_started' : $this->params['id']);
}
开发者ID:bermi,项目名称:akelos,代码行数:7,代码来源:akelos_dashboard_controller.php
示例9: _getSingularAttributeName
function _getSingularAttributeName($attribute_name)
{
$singular_name = AkInflector::singularize($attribute_name);
if ($singular_name === $attribute_name) {
return false;
}
return $singular_name;
}
开发者ID:joeymetal,项目名称:v1,代码行数:8,代码来源:international_post.php
示例10: getUrlParamsForModel
public static function getUrlParamsForModel(AkBaseModel $Model)
{
$url_function = AkInflector::underscore($Model->getModelName()) . '_params';
if (!function_exists($url_function)) {
throw new Exception($url_function . ' function not found for AkRouterHelper::getUrlOptionsForModel');
}
return $url_function($Model);
}
开发者ID:bermi,项目名称:akelos,代码行数:8,代码来源:router_helper.php
示例11: init
function init($options = array())
{
$success = $this->_ensureIsActiveRecordInstance($this->_ActiveRecordInstance);
$singularized_model_name = AkInflector::underscore(AkInflector::singularize($this->_ActiveRecordInstance->getTableName()));
$default_options = array('class_name' => $this->_ActiveRecordInstance->getModelName() . 'IpGeocodeLookup');
$this->options = array_merge($default_options, $options);
return $success;
}
开发者ID:joeymetal,项目名称:v1,代码行数:8,代码来源:ip_geocode_lookup.php
示例12: generate
public function generate()
{
$destination_path = AK_APP_LIB_DIR . DS . 'generators' . DS . $this->generator_name;
$this->assignVarToTemplate('class_name', AkInflector::camelize($this->generator_name));
$this->save($destination_path . DS . $this->generator_name . '_generator.php', $this->render('generator'));
$this->save($destination_path . DS . 'templates' . DS . 'template.tpl', $this->render('template'));
$this->save($destination_path . DS . 'USAGE', $this->render('usage'));
}
开发者ID:bermi,项目名称:akelos,代码行数:8,代码来源:generator_generator.php
示例13: link_to_node
public function link_to_node($Node, $options = array())
{
$detault_options = array('display' => 'name', 'id' => $Node->id, 'controller' => AkInflector::underscore($Node->getModelName()), 'action' => 'edit');
$options = array_merge($detault_options, $options);
$display = $Node->get($options['display']);
unset($options['display']);
return $this->_controller->url_helper->link_to($display, $options);
}
开发者ID:bermi,项目名称:admin,代码行数:8,代码来源:role_helper.php
示例14: init
public function init($options = array())
{
$success = $this->_ensureIsActiveRecordInstance($this->_ActiveRecordInstance);
$singularized_model_name = AkInflector::underscore(AkInflector::singularize($this->_ActiveRecordInstance->getTableName()));
$default_options = array('base_path' => AK_BASE_DIR . DS . 'index' . AK_ENVIRONMENT . DS);
$this->options = array_merge($default_options, $options);
return $success;
}
开发者ID:joeymetal,项目名称:v1,代码行数:8,代码来源:ActsAsLucene.php
示例15: getPaginator
/**
* Returns a paginator object
*
* Options:
* 'items_per_page' => 15, // Number of items per page
* 'page_var_on_url' => 'page', // This var will be passed thru the url for pointing to current page
* 'count_method' => 'count' // This method will be called on selected model to get the total number of items.
* 'count_conditions' => null // A string that will be passed as the first parameter (conditions) to the count method
* 'count_joins' => null // A string that will be passed as the seccond parameter (join options) to the count method.
* 'column_dictionary' => array() // In case you need to map the sort key from the url to the database column you must define an array pair
* 'include' => array() // In case current sort column is not found on current model or in the column_dictionary this helper will look for the first associated model witrh a column named like given sort parameter.
*/
public function getPaginator(&$object, $options = array())
{
$default_options = array('items_per_page' => 15, 'page_var_on_url' => 'page', 'count_method' => 'count', 'count_conditions' => null, 'count_joins' => null);
$options = array_merge($default_options, $options);
$paginator_name = AkInflector::underscore($object->getModelName()) . '_pages';
$this->{$paginator_name} = new AkPaginator($this->_controller, $object->{$options['count_method']}($options['count_conditions'], $options['count_joins']), $options['items_per_page'], @$this->_controller->params[$options['page_var_on_url']]);
$this->{$paginator_name}->_ak_options =& $options;
return $this->{$paginator_name};
}
开发者ID:bermi,项目名称:akelos,代码行数:21,代码来源:ak_pagination_helper.php
示例16: includeClass
/**
* @return boolean
*/
static function includeClass($search_path, $class_name)
{
$file_name = AkInflector::underscore($class_name) . '.php';
if ($full_filename = self::searchFilenameInPath($search_path, $file_name)) {
require_once $full_filename;
return true;
}
return false;
}
开发者ID:joeymetal,项目名称:v1,代码行数:12,代码来源:PHPUnit_Akelos.php
示例17: _render_menu
function _render_menu($type)
{
$controller =& $this->_controller;
$current_controller = AkInflector::urlize($controller->getControllerName());
$current_action = !empty($controller->params['action'])?$controller->params['action']:'';
$menu_options = $this->_getMenuOptions($type);
$result = '';
$i = 0;
foreach ($menu_options as $k=>$menu_option) {
$i++;
$is_active = (@$controller->{"{$type}_selected_tab"} == $k || $current_controller == $menu_option['url']['controller'] && (
$type == 'admin' || (
empty($menu_option['url']['action']) || $current_action == $menu_option['url']['action'])
) ? true : false);
//$is_active ? $controller->capture_helper->_addVarToView("{$type}_selected_tab", $k) : null;
if(!empty($menu_option['url'])){
$list_item_options = array(
'id' => $menu_option['id'].'_link',
'class' => 'tab'.($is_active?' active':'')
);
}else{
trigger_error($this->t('You need to provide a valid URL for the menu tab.', E_USER_ERROR));
}
$show_tab = false;
if(is_string($menu_option['url'])){
$show_tab = $this->can($k.' ('.$menu_option['url'].')', 'Admin Menu Tabs');
}elseif(empty($menu_option['url']['action'])){
$show_tab = $this->can($k.' ('.$menu_option['url']['controller'].' controller)', 'Admin Menu Tabs');
}else{
$show_tab = $this->can($k.' ('.$menu_option['url']['controller'].' controller, '.$menu_option['url']['action'].' action)', 'Admin Menu Tabs');
}
if(empty($show_tab)){
continue;
}
$link_options = (array)@$menu_option['link_options'];
if($type == 'controller' && !isset($link_options['accesskey'])){
$link_options['accesskey'] = $i;
}
$access_key_info = isset($link_options['accesskey']) ? ' '.$this->t('(Access key: %key)', array('%key'=>$link_options['accesskey'])) : '';
isset($link_options['title']) ? $link_options['title'] = $this->t($link_options['title']).$access_key_info : null;
!empty($access_key_info) && empty($link_options['title']) ? $link_options['title'] = trim($access_key_info,"() ") : null;
$result .= $controller->tag_helper->content_tag('li',
$controller->url_helper->link_to($this->t($k), $menu_option['url'], $link_options), $list_item_options);
}
return empty($result) ? '' : '<ul id="'.$type.'_menu">'.$result.'</ul>';
}
开发者ID:joeymetal,项目名称:v1,代码行数:56,代码来源:admin_helper.php
示例18: trim
function &recognize($Map = null)
{
AK_ENVIRONMENT != 'setup' ? $this->_connectToDatabase() : null;
$this->_startSession();
$this->_enableInternationalizationSupport();
$this->_mapRoutes($Map);
$params = $this->getParams();
$module_path = $module_class_peffix = '';
if (!empty($params['module'])) {
$module_path = trim(str_replace(array('/', '\\'), DS, Ak::sanitize_include($params['module'], 'high')), DS) . DS;
$module_shared_model = AK_CONTROLLERS_DIR . DS . trim($module_path, DS) . '_controller.php';
$module_class_peffix = str_replace(' ', '_', AkInflector::titleize(str_replace(DS, ' ', trim($module_path, DS)))) . '_';
}
$controller_file_name = AkInflector::underscore($params['controller']) . '_controller.php';
$controller_class_name = $module_class_peffix . AkInflector::camelize($params['controller']) . 'Controller';
$controller_path = AK_CONTROLLERS_DIR . DS . $module_path . $controller_file_name;
include_once AK_APP_DIR . DS . 'application_controller.php';
if (!empty($module_path) && file_exists($module_shared_model)) {
include_once $module_shared_model;
}
if (!is_file($controller_path) || !(include_once $controller_path)) {
defined('AK_LOG_EVENTS') && AK_LOG_EVENTS && $this->Logger->error('Controller ' . $controller_path . ' not found.');
if (AK_ENVIRONMENT == 'development') {
trigger_error(Ak::t('Could not find the file /app/controllers/<i>%controller_file_name</i> for ' . 'the controller %controller_class_name', array('%controller_file_name' => $controller_file_name, '%controller_class_name' => $controller_class_name)), E_USER_ERROR);
} elseif (@(include AK_PUBLIC_DIR . DS . '404.php')) {
$response = new AkTestResponse();
$response->addHeader('Status', 404);
return false;
//exit;
} else {
//header("HTTP/1.1 404 Not Found");
$response = new AkResponse();
$response->addHeader('Status', 404);
return false;
//die('404 Not found');
}
}
if (!class_exists($controller_class_name)) {
defined('AK_LOG_EVENTS') && AK_LOG_EVENTS && $this->Logger->error('Controller ' . $controller_path . ' does not implement ' . $controller_class_name . ' class.');
if (AK_ENVIRONMENT == 'development') {
trigger_error(Ak::t('Controller <i>%controller_name</i> does not exist', array('%controller_name' => $controller_class_name)), E_USER_ERROR);
} elseif (@(include AK_PUBLIC_DIR . DS . '405.php')) {
exit;
} else {
$response = new AkResponse();
$response->addHeader('Status', 405);
return false;
//header("HTTP/1.1 405 Method Not Allowed");
//die('405 Method Not Allowed');
}
}
$Controller =& new $controller_class_name(array('controller' => true));
$Controller->_module_path = $module_path;
isset($_SESSION) ? $Controller->session =& $_SESSION : null;
return $Controller;
}
开发者ID:joeymetal,项目名称:v1,代码行数:56,代码来源:AkTestRequest.php
示例19: suite
public static function suite()
{
$class_name = substr(basename(__FILE__), 0, -4);
$test_folder = strtolower(substr($class_name, 0, -9));
$suite = new ExamplesTestSuite(AkInflector::titleize($class_name));
$path = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . $test_folder;
$directory = new PHPUnit_Runner_IncludePathTestCollector(array($path));
$suite->addTestFiles($directory->collectTests());
return $suite;
}
开发者ID:joeymetal,项目名称:v1,代码行数:10,代码来源:ExamplesTestSuite.php
示例20: hasCollisions
public function hasCollisions()
{
$this->collisions = array();
$this->namespace = AkInflector::underscore(Ak::first(explode(':', $this->task_name . ':')));
$this->task_name = AkInflector::underscore(Ak::last(explode(':', ':' . $this->task_name)));
$this->destination_path = AK_TASKS_DIR . DS . $this->namespace;
if (file_exists($this->destination_path . DS . $this->task_name . '.task.php')) {
$this->collisions[] = Ak::t('%path already exists', array('%path' => $this->destination_path . DS . $this->task_name . '.task.php'));
}
return count($this->collisions) > 0;
}
开发者ID:bermi,项目名称:akelos,代码行数:11,代码来源:task_generator.php
注:本文中的AkInflector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论