本文整理汇总了PHP中AkInflector::singularize方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::singularize方法的具体用法?PHP AkInflector::singularize怎么用?PHP AkInflector::singularize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkInflector
的用法示例。
在下文中一共展示了AkInflector::singularize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
}
}
示例2: Test_of_singularize_plural
function Test_of_singularize_plural()
{
foreach ($this->SingularToPlural as $singular => $plural) {
$this->assertEqual($singular, AkInflector::singularize($plural));
$this->assertEqual(ucfirst($singular), AkInflector::singularize(ucfirst($plural)));
}
}
示例3: 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;
}
示例4: _getSingularAttributeName
function _getSingularAttributeName($attribute_name)
{
$singular_name = AkInflector::singularize($attribute_name);
if ($singular_name === $attribute_name) {
return false;
}
return $singular_name;
}
示例5: 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;
}
示例6: __construct
public function __construct($entities, $options)
{
$this->plural = $entities;
$this->singular = isset($options['singular']) ? $options['singular'] : AkInflector::singularize($this->plural);
$this->path_segment = isset($options['singular']) || isset($options['as']) ? Ak::deleteAndGetValue($options, 'as') : $this->plural;
$this->options = $options;
$this->arrangeActions();
$this->addDefaultActions();
$this->setAllowedActions();
$this->setPrefixes();
}
示例7: 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;
}
示例8: array
function &addAssociated($association_id, $options = array())
{
$default_options = array('class_name' => empty($options['class_name']) ? AkInflector::camelize($association_id) : $options['class_name'], 'foreign_key' => empty($options['foreign_key']) ? AkInflector::singularize($this->Owner->getTableName()) . '_id' : $options['foreign_key'], 'remote' => false, 'instantiate' => false, 'conditions' => false, 'include_conditions_when_included' => true, 'order' => false, 'include_order_when_included' => true, 'dependent' => false, 'counter_cache' => false);
$options = array_merge($default_options, $options);
$options['table_name'] = empty($options['table_name']) ? AkInflector::tableize($options['class_name']) : $options['table_name'];
$this->setOptions($association_id, $options);
$this->addModel($association_id, new AkAssociatedActiveRecord());
$associated =& $this->getModel($association_id);
$this->setAssociatedId($association_id, $associated->getId());
$associated =& $this->_build($association_id, &$associated, false);
$this->_saveLoadedHandler($association_id, $associated);
if ($options['instantiate']) {
$associated =& $this->addModel($association_id, new $options['class_name']($options['foreign_key'] . ' = ' . $this->Owner->quotedId()));
}
return $associated;
}
示例9: _setDefaults
private function _setDefaults()
{
$this->class_name = AkInflector::camelize($this->class_name);
$this->table_name = AkInflector::tableize($this->class_name);
$this->file_name = AkInflector::underscore($this->class_name);
$this->controller_class_name = AkInflector::pluralize($this->class_name);
$this->controller_file_name = AkInflector::toControllerFilename($this->controller_class_name);
$this->table_columns = trim(join(' ', (array) @$this->table_columns));
$this->assignVarToTemplate('attributes', $this->_getModelAttributesForViews());
$this->assignVarToTemplate('class_name', $this->class_name);
$this->assignVarToTemplate('table_name', $this->table_name);
$this->assignVarToTemplate('plural_name', $this->table_name);
$this->assignVarToTemplate('singular_name', AkInflector::singularize($this->table_name));
$this->assignVarToTemplate('file_name', $this->file_name);
$this->assignVarToTemplate('table_columns', $this->table_columns);
$this->assignVarToTemplate('controller_class_name', $this->controller_class_name);
}
示例10: 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);
}
示例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() . 'ActsAsMappable');
$this->distance_column_name = array_key_exists('distance_column_name', $options) ? $options['distance_column_name'] : 'distance';
$this->default_units = array_key_exists('default_units', $options) ? $options['default_units'] : GEOKIT_DEFAULT_UNITS;
$this->default_foumula = array_key_exists('default_formula', $options) ? $options['default_formula'] : GEOKIT_DEFAULT_FORMULA;
$this->lat_column_name = array_key_exists('lat_column_name', $options) ? $options['lat_column_name'] : 'lat';
$this->lng_column_name = array_key_exists('lng_column_name', $options) ? $options['lng_column_name'] : 'lng';
$this->qualified_lat_column_name = $this->table_name . $this->lat_column_name;
$this->qualified_lng_column_name = $this->table_name . $this->lng_column_name;
if (array_key_exists('auto_geocode', $options)) {
if ($options['auto_geocode'] == true) {
$options['auto_geocode'] = array();
}
$this->auto_geocode_field = array_key_exists('field', $options['auto_geocode']) ? $options['auto_geocode']['field'] : 'address';
$this->auto_geocode_error_message = array_key_exists('error_message', $options['auto_geocode']) ? $options['auto_geocode']['error_message'] : 'could not locate address';
}
$this->options = array_merge($default_options, $options);
return $success;
}
示例12: 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().'Version',
'table_name' => $singularized_model_name.'_versions',
'foreign_key' => $singularized_model_name.'_id',
'inheritance_column' => 'versioned_type',
'version_column' => 'version',
'limit' => false,
'if' => true,
'if_changed' => array(),
'ignored_columns' => array('updated_at'),
);
$this->options = array_merge($default_options, $options);
$this->_ensureVersioningModelIsAvailable();
return $success;
}
示例13: Loop
function Loop($match, $state)
{
if(AK_LEXER_SPECIAL === $state){
$sintags_var = trim(preg_replace('/[\s|?]+/',' ', substr($match, 6,-1)));
if(strstr($sintags_var,' as ')){
$new_sintags_var = substr($sintags_var,0, strpos($sintags_var,' '));
$termination = $this->_getTerminationName(AkInflector::pluralize(str_replace($new_sintags_var.' as ','', $sintags_var)));
$sintags_var = $new_sintags_var;
}
$php_variable = $this->_convertSintagsVarToPhp($sintags_var);
if($php_variable){
$php_variable = $php_variable;
$termination = empty($termination) ? $this->_getTerminationName($sintags_var) : $termination;
$singular_variable = '$'.AkInflector::singularize($termination);
$plural_variable = '$'.$termination;
$this->output .=
"<?php ".
"\n empty({$php_variable}) ? null : {$singular_variable}_loop_counter = 0;".
"\n empty({$php_variable}) ? null : {$plural_variable}_available = count({$php_variable});".
"\n if(!empty({$php_variable}))".
"\n foreach ({$php_variable} as {$singular_variable}_loop_key=>{$singular_variable}){".
"\n {$singular_variable}_loop_counter++;".
"\n {$singular_variable}_is_first = {$singular_variable}_loop_counter === 1;".
"\n {$singular_variable}_is_last = {$singular_variable}_loop_counter === {$plural_variable}_available;".
"\n {$singular_variable}_odd_position = {$singular_variable}_loop_counter%2;".
"\n?>";
}else{
$this->output .= $match;
}
}
return true;
}
示例14: modulize
function modulize($module_description)
{
return AkInflector::camelize(AkInflector::singularize($module_description));
}
示例15: getCollectionHandlerName
function getCollectionHandlerName($association_id)
{
if (isset($this->{$association_id}) && is_object($this->{$association_id}) && method_exists($this->{$association_id}, 'getAssociatedFinderSqlOptions')) {
return false;
}
$collection_handler_name = AkInflector::singularize($association_id);
if (isset($this->{$collection_handler_name}) && is_object($this->{$collection_handler_name}) && in_array($this->{$collection_handler_name}->getType(), array('hasMany', 'hasAndBelongsToMany'))) {
return $collection_handler_name;
} else {
return false;
}
}