本文整理汇总了PHP中AkInflector::pluralize方法的典型用法代码示例。如果您正苦于以下问题:PHP AkInflector::pluralize方法的具体用法?PHP AkInflector::pluralize怎么用?PHP AkInflector::pluralize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkInflector
的用法示例。
在下文中一共展示了AkInflector::pluralize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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';
}
}
示例2: Test_of_pluralize_singular
function Test_of_pluralize_singular()
{
foreach ($this->SingularToPlural as $singular => $plural) {
$this->assertEqual($plural, AkInflector::pluralize($singular));
$this->assertEqual(ucfirst($plural), AkInflector::pluralize(ucfirst($singular)));
}
}
示例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';
}
}
示例4: _setupCloner
function _setupCloner()
{
$this->clone_setup_done = true;
$this->class_to_clone = AkInflector::underscore($this->class_to_clone);
$this->class_name = AkInflector::underscore($this->class_name);
$this->clone_replacements = array(AkInflector::camelize($this->class_to_clone) . 'Controller' => AkInflector::camelize($this->class_name) . 'Controller', AkInflector::humanize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::humanize(AkInflector::pluralize($this->class_name)), AkInflector::titleize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::titleize(AkInflector::pluralize($this->class_name)), AkInflector::humanize($this->class_to_clone) => AkInflector::humanize($this->class_name), AkInflector::titleize($this->class_to_clone) => AkInflector::titleize($this->class_name), AkInflector::camelize(AkInflector::pluralize($this->class_to_clone)) => AkInflector::camelize(AkInflector::pluralize($this->class_name)), AkInflector::pluralize($this->class_to_clone) => AkInflector::pluralize($this->class_name), AkInflector::camelize($this->class_to_clone) => AkInflector::camelize($this->class_name), $this->class_to_clone => $this->class_name);
//AK_VIEWS_DIR.DS.AkInflector::underscore($this->class_name).DS.$action.'.tpl'
$this->files_to_clone = array(AkInflector::toModelFilename($this->class_to_clone) => AkInflector::toModelFilename($this->class_name), AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_to_clone . '.php' => AK_TEST_DIR . DS . 'unit' . DS . 'test_' . $this->class_name . '.php', AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_to_clone) . '.yml' => AK_TEST_DIR . DS . 'fixtures' . DS . AkInflector::tableize($this->class_name) . '.yml', AkInflector::toControllerFilename($this->class_to_clone) => AkInflector::toControllerFilename($this->class_name), AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_to_clone . '_controller') . '.php' => AK_TEST_DIR . DS . 'functional' . DS . 'test_' . AkInflector::camelize($this->class_name . '_controller') . '.php', AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_to_clone}_helper") . '.php' => AK_HELPERS_DIR . DS . AkInflector::underscore("{$this->class_name}_helper") . '.php');
foreach ($this->_getControllerViews() as $view_file) {
$this->files_to_clone[AK_VIEWS_DIR . DS . $this->class_to_clone . DS . $view_file . '.tpl'] = AK_VIEWS_DIR . DS . $this->class_name . DS . $view_file . '.tpl';
}
$this->files_to_clone[AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_to_clone . '.tpl'] = AK_VIEWS_DIR . DS . 'layouts' . DS . $this->class_name . '.tpl';
foreach (Ak::dir(AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone, array('dirs' => false)) as $locale_file) {
$this->files_to_clone[AK_APP_DIR . DS . 'locales' . DS . $this->class_to_clone . DS . $locale_file] = AK_APP_DIR . DS . 'locales' . DS . $this->class_name . DS . $locale_file;
}
}
示例5: _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);
}
示例6: __construct
public function __construct($entity, $options)
{
$this->singular = $this->plural = $entity;
$this->options['controller'] = $this->controller = isset($options['controller']) ? $options['controller'] : AkInflector::pluralize($this->singular);
parent::__construct($entity, $options);
}
示例7: beforeDestroy
function beforeDestroy(&$object)
{
$association_ids = $object->getAssociatedIds();
foreach ($association_ids as $association_id) {
if (!empty($object->{$association_id}) && is_object($object->{$association_id}) && method_exists($object->{$association_id}, 'getType') && strtolower($object->belongsTo->getOption($association_id, 'class_name')) == strtolower($object->{$association_id}->getType())) {
$primary_key_name = $this->Owner->{$association_id}->getAssociationOption('primary_key_name');
if ($this->Owner->{$association_id}->getAssociationOption('counter_cache')) {
$object->{$association_id}->decrementCounter(AkInflector::pluralize($association_id) . '_count', $object->get($primary_key_name));
}
}
}
return true;
}
示例8: renderPartialCollection
function renderPartialCollection($partial_name, $collection, $partial_spacer_template = null, $local_assigns = null, $status = null)
{
$this->_addVariablesToAssigns();
$collection_name = AkInflector::pluralize($partial_name) . '_collection';
$result = $this->Template->renderPartialCollection($partial_name, $collection, $partial_spacer_template, $local_assigns);
if (empty($this->{$collection_name})) {
$this->{$collection_name} = $result;
}
$this->variables_added = false;
$this->performed_render = false;
return $result;
}
示例9: quantify
public function quantify($item)
{
if ($this->value == 1) {
return $this->value . ' ' . Ak::t(AkInflector::singularize($item));
} else {
return $this->value . ' ' . Ak::t(AkInflector::pluralize($item));
}
}
示例10: is_plural
function is_plural($plural)
{
return AkInflector::pluralize(AkInflector::singularize($plural)) == $plural;
}
示例11: pluralize
public function pluralize($dictionary = null)
{
return AkInflector::pluralize($this->value, null, $dictionary);
}
示例12: assertSingletonNamedRoutesFor
public function assertSingletonNamedRoutesFor($singleton_name, $options = array())
{
$options['options'] = empty($options['options']) ? array() : $options['options'];
$options['options']['controller'] = !empty($options['controller']) ? Ak::deleteAndGetValue($options, 'controller') : AkInflector::pluralize($singleton_name);
$controller_class_name = AkInflector::camelize($options['options']['controller']) . 'Controller';
$this->recognizeRouteForPath($singleton_name);
$this->Controller = new $controller_class_name();
$this->Request = new AkTestRequest();
$this->Response = new AkTestResponse();
Ak::deleteAndGetValue($options['options'], 'action');
$path = isset($options['as']) ? $options['as'] : $singleton_name;
$name_prefix = @$options['path_prefix'];
$full_path = '/' . $name_prefix . $path;
$this->assertNamedRoute($full_path, $name_prefix . $singleton_name . '_path', $options['options']);
$this->assertNamedRoute($full_path . '.xml', $name_prefix . $singleton_name . '_path', array_merge($options['options'], array('format' => 'xml')));
$this->assertNamedRoute($full_path . '/add', 'add_' . $name_prefix . $singleton_name . '_path', $options['options']);
$this->assertNamedRoute($full_path . '/add.xml', 'add_' . $name_prefix . $singleton_name . '_path', array_merge($options['options'], array('format' => 'xml')));
$this->assertNamedRoute($full_path . '/edit', 'edit_' . $name_prefix . $singleton_name . '_path', $options['options']);
$this->assertNamedRoute($full_path . '/edit.xml', 'edit_' . $name_prefix . $singleton_name . '_path', array_merge($options['options'], array('format' => 'xml')));
}
示例13: test_spanish_dictionary
public function test_spanish_dictionary()
{
$this->assertNotEqual('tijeras',AkInflector::singularize('tijeras'));
$this->assertEqual('tijeras',AkInflector::singularize('tijeras',null,'es'));
$this->assertEqual('ingleses',AkInflector::pluralize('inglés',null,'es'));
}
示例14: loadFixture
function loadFixture($model_name)
{
if (!($fixture_file_name = $this->findFixtureForModel($model_name))) {
return false;
}
$Model = new $model_name();
$Fixture = array();
$items = Ak::convert('yaml', 'array', file_get_contents($fixture_file_name));
foreach ($items as $id => $item) {
$Record = $Model->create($item);
#we replace the 'id' with the returned value from the db
$item['id'] = $Record->getId();
$Fixture[$id] = new FixedActiveRecord($item, $Model);
}
return $this->{AkInflector::pluralize($model_name)} = $Fixture;
}
示例15: toXml
/**
* Generate a xml representation of the model record.
*
* Example result:
*
* <?xml version="1.0" encoding="UTF-8"?>
* <person>
* <id>1</id>
* <first-name>Hansi</first-name>
* <last-name>Müller</last-name>
* <email>hans@mueller.com</email>
* <created-at type="datetime">2008-01-01 13:01:23</created-at>
* </person>
*
* parameters:
*
* @param array $options
*
* option parameters:
* array(
* 'collection' => array($Person1,$Person), // array of ActiveRecords
* 'include' => array('association1','association2'), // include the associations when exporting
* 'exclude' => array('id','name'), // exclude the attribtues
* 'only' => array('email','last_name') // only export these attributes
* )
* @return string in Xml Format
*/
public function toXml($options = array())
{
$options['padding'] = empty($options['padding']) ? 0 : $options['padding'] + 1;
$current_padding = str_repeat(' ', $options['padding']);
if (is_array($options) && isset($options[0]) && $options[0] instanceof ArrayAccess) {
$options = array('collection' => $options);
}
if (isset($options['collection']) && (is_array($options['collection']) || $options['collection'] instanceof ArrayAccess) && $options['collection'][0]->_modelName == $this->_Model->getModelName()) {
$root = AkInflector::underscore(AkInflector::pluralize($this->_Model->getModelName()));
$root = $this->_convertColumnToXmlElement($root);
$xml = '';
if (!(isset($options['skip_instruct']) && $options['skip_instruct'] == true)) {
$xml .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
$xml .= $current_padding . '<' . $root . " type=\"array\">\n";
$collection = $options['collection'];
unset($options['collection']);
$options['skip_instruct'] = true;
$options['padding']++;
foreach ($collection as $element) {
$xml .= $element->toXml($options);
}
$xml .= $current_padding . '</' . $root . ">\n";
return $xml;
}
/**
* see if we need to include associations
*/
$associatedIds = array();
if (isset($options['include']) && !empty($options['include'])) {
$options['include'] = is_array($options['include']) ? $options['include'] : preg_split('/,\\s*/', $options['include']);
foreach ($this->_Model->getAssociations() as $key => $obj) {
if (in_array($key, $options['include'])) {
if ($obj->getType() != 'hasAndBelongsToMany') {
$associatedIds[$obj->getAssociationIds() . '_id'] = array('name' => $key, 'type' => $obj->getType());
} else {
$associatedIds[$key] = array('name' => $key, 'type' => $obj->getType());
}
}
}
}
if (isset($options['only'])) {
$options['only'] = is_array($options['only']) ? $options['only'] : preg_split('/,\\s*/', $options['only']);
}
if (isset($options['except'])) {
$options['except'] = is_array($options['except']) ? $options['except'] : preg_split('/,\\s*/', $options['except']);
}
$xml = '';
if (!(isset($options['skip_instruct']) && $options['skip_instruct'] == true)) {
$xml .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
}
$root = $this->_convertColumnToXmlElement(AkInflector::underscore($this->_Model->getModelName()));
$xml .= $current_padding . '<' . $root . ">\n";
foreach ($this->_Model->getColumns() as $key => $def) {
if (isset($options['except']) && in_array($key, $options['except'])) {
continue;
} else {
if (isset($options['only']) && !in_array($key, $options['only'])) {
continue;
} else {
$columnType = $def['type'];
$elementName = $this->_convertColumnToXmlElement($key);
$xml .= $current_padding . ' <' . $elementName;
$val = $this->_Model->{$key};
if (!in_array($columnType, array('string', 'text', 'serial'))) {
$xml .= ' type="' . $columnType . '"';
if ($columnType == 'boolean') {
$val = $val ? 1 : 0;
}
} elseif ($columnType == 'serial' && is_numeric($val)) {
$xml .= ' type="integer"';
}
if (!empty($val) && in_array($columnType, array('datetime'))) {
//.........这里部分代码省略.........