本文整理汇总了PHP中AkInflector::classify方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::classify方法的具体用法?PHP AkInflector::classify怎么用?PHP AkInflector::classify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkInflector
的用法示例。
在下文中一共展示了AkInflector::classify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
public function &addAssociated($association_id, $options = array())
{
$default_options = array('class_name' => empty($options['class_name']) ? AkInflector::classify($association_id) : $options['class_name'], 'conditions' => false, 'order' => false, 'include_conditions_when_included' => true, 'include_order_when_included' => true, 'foreign_key' => false, 'dependent' => 'nullify', 'finder_sql' => false, 'counter_sql' => false, 'include' => false, 'instantiate' => false, 'group' => false, 'limit' => false, 'offset' => false, 'handler_name' => strtolower(AkInflector::underscore(AkInflector::singularize($association_id))), 'select' => false);
$options = array_merge($default_options, $options);
$options['foreign_key'] = empty($options['foreign_key']) ? AkInflector::underscore($this->Owner->getModelName()) . '_id' : $options['foreign_key'];
$Collection =& $this->_setCollectionHandler($association_id, $options['handler_name']);
$Collection->setOptions($association_id, $options);
$this->addModel($association_id, $Collection);
if ($options['instantiate']) {
$associated =& $Collection->load();
}
$this->setAssociatedId($association_id, $options['handler_name']);
$Collection->association_id = $association_id;
return $Collection;
}
示例2: _get_default_full_menu
function _get_default_full_menu()
{
$controller_file_names = Ak::dir(AK_CONTROLLERS_DIR, array('files' => false));
krsort($controller_file_names);
$menu_options = array();
foreach ($controller_file_names as $controller_file_name => $options) {
$controller_file_name = array_pop($options);
$controller_name = str_replace('.php', '', $controller_file_name);
if (file_exists(AK_CONTROLLERS_DIR . DS . $controller_file_name)) {
include_once AK_CONTROLLERS_DIR . DS . $controller_file_name;
$controller_class_name = AkInflector::classify($controller_name);
$menu_options[str_replace('_controller', '', $controller_name)] = $this->_get_this_class_methods($controller_class_name);
}
}
return $menu_options;
}
示例3: _get_default_full_menu
public function _get_default_full_menu()
{
$controllers_dir = AkConfig::getDir('controllers');
$controller_file_names = array_map('array_pop', (array) AkFileSystem::dir($controllers_dir, array('files' => false)));
sort($controller_file_names);
$menu_options = array();
foreach ($controller_file_names as $controller_file_name) {
$controller_name = str_replace('.php', '', $controller_file_name);
if (strstr($controller_file_name, '_controller.php') && file_exists($controllers_dir . DS . $controller_file_name)) {
include_once $controllers_dir . DS . $controller_file_name;
$controller_class_name = AkInflector::classify($controller_name);
$menu_options[str_replace('_controller', '', $controller_name)] = $this->_get_this_class_methods($controller_class_name);
}
}
return $menu_options;
}
示例4: clear
function clear($table, $environment = AK_ENVIRONMENT)
{
$modelName = AkInflector::singularize(AkInflector::classify($table));
$cacheFileName = AkDbSchemaCache::_generateCacheFileName($modelName, $environment);
//echo "Cleaning cache: $cacheFileName\n";
if (file_exists($cacheFileName)) {
@unlink($cacheFileName);
}
AkDbSchemaCache::_get($modelName, $environment, false, false);
$tableName = AkInflector::tableize($table);
$databaseInternalsFileName = AkDbSchemaCache::_generateCacheFileName('database_table_internals_' . $tableName);
//echo "Cleaning cache: $databaseInternalsFileName\n";
if (file_exists($databaseInternalsFileName)) {
@unlink($databaseInternalsFileName);
}
AkDbSchemaCache::_get('database_table_internals_' . $tableName, $environment, false, false);
}
示例5: populateTables
function populateTables()
{
$args = func_get_args();
$tables = !empty($args) ? (is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args))) : array();
foreach ($tables as $table){
$file = AK_TEST_DIR.DS.'fixtures'.DS.'data'.DS.(empty($this->module)?'':$this->module.DS).Ak::sanitize_include($table).'.yaml';
if(!file_exists($file)){
continue;
}
$class_name = AkInflector::classify($table);
if($this->instantiateModel($class_name)){
$contents = &Ak::getStaticVar('yaml_fixture_'.$file);
if (!$contents) {
ob_start();
require_once($file);
$contents = ob_get_clean();
Ak::setStaticVar('yaml_fixture_'.$file, $contents);
}
$items = Ak::convert('yaml','array',$contents);
foreach ($items as $item){
$obj=&$this->{$class_name}->create($item);
if (isset($item['created_at'])) {
$obj->updateAttribute('created_at',$item['created_at']);
} else if (isset($item['created_on'])) {
$obj->updateAttribute('created_on',$item['created_on']);
}
}
}
}
}
示例6: _getIncludedControllerNames
function _getIncludedControllerNames()
{
$controllers = array();
foreach (get_included_files() as $file_name) {
if (strstr($file_name, AK_CONTROLLERS_DIR)) {
$controllers[] = AkInflector::classify(str_replace(array(AK_CONTROLLERS_DIR . DS, '.php', DS, '//'), array('', '', '/', '/'), $file_name));
}
}
return $controllers;
}
示例7: dropTable
function dropTable($table_name, $options = array())
{
require_once(AK_LIB_DIR.DS.'AkActiveRecord'.DS.'AkDbSchemaCache.php');
AkDbSchemaCache::clear(AkInflector::classify($table_name));
$result = $this->tableExists($table_name) ? $this->db->execute('DROP TABLE '.$table_name) : true;
if($result){
unset($this->available_tables[array_search($table_name, $this->available_tables)]);
if(!empty($options['sequence'])){
$this->dropSequence($table_name);
}
}
}
示例8: array
public function &addAssociated($association_id, $options = array())
{
$default_options = array('class_name' => empty($options['class_name']) ? AkInflector::classify($association_id) : $options['class_name'], 'table_name' => false, 'join_table' => false, 'join_class_name' => false, 'foreign_key' => false, 'association_foreign_key' => false, 'conditions' => false, 'order' => false, 'join_class_extends' => AK_HAS_AND_BELONGS_TO_MANY_JOIN_CLASS_EXTENDS, 'join_class_primary_key' => 'id', 'finder_sql' => false, 'delete_sql' => false, 'insert_sql' => false, 'include' => false, 'group' => false, 'limit' => false, 'offset' => false, 'handler_name' => strtolower(AkInflector::underscore(AkInflector::singularize($association_id))), 'select' => false, 'instantiate' => false, 'unique' => false);
$options = array_merge($default_options, $options);
$owner_name = $this->Owner->getModelName();
$owner_table = $this->Owner->getTableName();
$associated_name = $options['class_name'];
$associated_table_name = $options['table_name'] = empty($options['table_name']) ? AkInflector::tableize($associated_name) : $options['table_name'];
$join_tables = array($owner_table, $associated_table_name);
sort($join_tables);
$options['join_table'] = empty($options['join_table']) ? join('_', $join_tables) : $options['join_table'];
$options['join_class_name'] = empty($options['join_class_name']) ? join(array_map(array('AkInflector', 'classify'), array_map(array('AkInflector', 'singularize'), $join_tables))) : $options['join_class_name'];
$options['foreign_key'] = empty($options['foreign_key']) ? AkInflector::underscore($owner_name) . '_id' : $options['foreign_key'];
$options['association_foreign_key'] = empty($options['association_foreign_key']) ? AkInflector::underscore($associated_name) . '_id' : $options['association_foreign_key'];
$Collection =& $this->_setCollectionHandler($association_id, $options['handler_name']);
$Collection->setOptions($association_id, $options);
$this->addModel($association_id, $Collection);
if ($options['instantiate']) {
$associated =& $Collection->load();
}
$this->setAssociatedId($association_id, $options['handler_name']);
$Collection->association_id = $association_id;
$Collection->_loadJoinObject();
return $Collection;
}
示例9: getApplicationHelpers
function getApplicationHelpers()
{
$helper_names = array();
if ($this->app_helpers == 'all') {
$available_helpers = Ak::dir(AK_HELPERS_DIR, array('dirs' => false));
$helper_names = array();
foreach ($available_helpers as $available_helper) {
$helper_names[$available_helper] = AkInflector::classify(substr($available_helper, 0, -10));
}
} elseif (is_string($this->app_helpers)) {
foreach (Ak::toArray($this->app_helpers) as $helper_name) {
$helper_names[AK_HELPERS_DIR . DS . AkInflector::underscore($helper_name) . '_helper.php'] = AkInflector::classify($helper_name);
}
}
return $helper_names;
}
示例10: _initSweeper
function _initSweeper($sweeper, $options = array())
{
if (!empty($options['only']) && !in_array($this->_controller->getActionName(), $options['only'])) return;
if (!empty($options['except']) && !in_array($this->_controller->getActionName(), $options['except'])) return;
$sweeper_class = AkInflector::classify($sweeper);
if (!class_exists($sweeper_class)) {
$filePath = AK_APP_DIR . DS . 'sweepers' . DS . $sweeper.'.php';
if (file_exists($filePath)) {
require_once($filePath);
if (!class_exists($sweeper_class)) {
trigger_error('Cache Sweeper "' . $sweeper_class . '" does not exist in: ' . $filePath, E_USER_ERROR);
}
} else if (AK_ENVIRONMENT == 'development') {
trigger_error('Cache Sweeper file does not exist: ' . $filePath, E_USER_ERROR);
}
}
$this->_Sweepers[] = &new $sweeper_class(&$this);
}
示例11: Test_of_classify
function Test_of_classify()
{
foreach ($this->ClassNameToTableName as $class_name => $table_name) {
$this->assertEqual($class_name, AkInflector::classify($table_name));
}
}
示例12: _getFilterClassName
function _getFilterClassName($filter_name)
{
// We might allow other classes to be created as filters in order to create image filter plugins from outside the framework
if (!class_exists($filter_name)) {
return 'AkImage' . AkInflector::classify($filter_name) . 'Filter';
} else {
return $filter_name;
}
}
示例13: populateTables
function populateTables()
{
$args = func_get_args();
$tables = !empty($args) ? is_array($args[0]) ? $args[0] : (count($args) > 1 ? $args : Ak::toArray($args)) : array();
foreach ($tables as $table) {
$file = AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . (empty($this->module) ? '' : $this->module . DS) . Ak::sanitize_include($table) . '.yaml';
if (!file_exists($file)) {
continue;
}
$class_name = AkInflector::classify($table);
if ($this->instantiateModel($class_name)) {
$items = Ak::convert('yaml', 'array', file_get_contents($file));
foreach ($items as $item) {
$this->{$class_name}->create($item);
}
}
}
}
示例14: getApplicationHelperNames
function getApplicationHelperNames()
{
$handler =& $this->_Handler;
$handler->app_helpers = !isset($handler->app_helpers) ? null : $handler->app_helpers;
$helper_names = array();
if ($handler->app_helpers == 'all') {
$available_helpers = Ak::dir(AK_HELPERS_DIR, array('dirs' => false));
$helper_names = array();
foreach ($available_helpers as $available_helper) {
$helper_names[AK_HELPERS_DIR . DS . $available_helper] = AkInflector::classify(substr($available_helper, 0, -10));
}
} elseif (!empty($handler->app_helpers)) {
foreach (Ak::toArray($handler->app_helpers) as $helper_name) {
$helper_names[AK_HELPERS_DIR . DS . AkInflector::underscore($helper_name) . '_helper.php'] = AkInflector::camelize($helper_name);
}
}
return $helper_names;
}
示例15: _getIncludedControllerNames
public function _getIncludedControllerNames()
{
$controllers = array();
foreach (get_included_files() as $file_name) {
if (strstr($file_name, AkConfig::getDir('controllers'))) {
$controllers[] = AkInflector::classify(str_replace(array(AkConfig::getDir('controllers') . DS, '.php', DS, '//'), array('', '', '/', '/'), $file_name));
}
}
return $controllers;
}