当前位置: 首页>>代码示例>>PHP>>正文


PHP Inflector::pluralize方法代码示例

本文整理汇总了PHP中Cake\Utility\Inflector::pluralize方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::pluralize方法的具体用法?PHP Inflector::pluralize怎么用?PHP Inflector::pluralize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Utility\Inflector的用法示例。


在下文中一共展示了Inflector::pluralize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Index method
  *
  * @param string $filter Parameter to filter on
  * @param string $id Id of the model to filter
  *
  * @return \Cake\Network\Response|void
  */
 public function index($filter = null, $id = null)
 {
     $findOptions = ['fields' => ['id', 'name', 'description', 'created', 'modified', 'sfw', 'status', 'user_id'], 'conditions' => ['Albums.status' => 1], 'contain' => ['Users' => ['fields' => ['id', 'username', 'realname']], 'Languages' => ['fields' => ['id', 'name', 'iso639_1']], 'Projects' => ['fields' => ['id', 'name', 'ProjectsAlbums.album_id']], 'Files' => ['fields' => ['id', 'name', 'filename', 'sfw', 'AlbumsFiles.album_id'], 'conditions' => ['status' => STATUS_PUBLISHED]]], 'order' => ['created' => 'desc'], 'sortWhitelist' => ['created', 'name', 'modified']];
     // Sfw condition
     if (!$this->request->session()->read('seeNSFW')) {
         $findOptions['conditions']['sfw'] = true;
     }
     // Other conditions:
     if (!is_null($filter)) {
         switch ($filter) {
             case 'language':
                 $findOptions['conditions']['Languages.id'] = $id;
                 break;
             case 'license':
                 $findOptions['conditions']['Licenses.id'] = $id;
                 break;
             case 'user':
                 $findOptions['conditions']['Users.id'] = $id;
                 break;
             default:
                 throw new \Cake\Network\Exception\NotFoundException();
         }
         // Get additionnal infos infos
         $modelName = \Cake\Utility\Inflector::camelize(\Cake\Utility\Inflector::pluralize($filter));
         $FilterModel = \Cake\ORM\TableRegistry::get($modelName);
         $filterData = $FilterModel->get($id);
         $this->set('filterData', $filterData);
     }
     $this->set('filter', $filter);
     $this->paginate = $findOptions;
     $this->set('albums', $this->paginate($this->Albums));
     $this->set('_serialize', ['files']);
 }
开发者ID:el-cms,项目名称:elabs,代码行数:41,代码来源:AlbumsController.php

示例2: __construct

 /**
  * Sets up the configuration for the model, and loads ACL models if they haven't been already
  *
  * @param Table $model Table instance being attached
  * @param array $config Configuration
  * @return void
  */
 public function __construct(Table $model, array $config = [])
 {
     $this->_table = $model;
     if (isset($config[0])) {
         $config['type'] = $config[0];
         unset($config[0]);
     }
     if (isset($config['type'])) {
         $config['type'] = strtolower($config['type']);
     }
     parent::__construct($model, $config);
     $types = $this->_typeMaps[$this->config()['type']];
     if (!is_array($types)) {
         $types = [$types];
     }
     foreach ($types as $type) {
         $alias = Inflector::pluralize($type);
         $className = App::className($alias . 'Table', 'Model/Table');
         if ($className == false) {
             $className = App::className('Acl.' . $alias . 'Table', 'Model/Table');
         }
         $config = [];
         if (!TableRegistry::exists($alias)) {
             $config = ['className' => $className];
         }
         $model->hasMany($type, ['targetTable' => TableRegistry::get($alias, $config)]);
     }
     if (!method_exists($model->entityClass(), 'parentNode')) {
         trigger_error(__d('cake_dev', 'Callback {0} not defined in {1}', ['parentNode()', $model->entityClass()]), E_USER_WARNING);
     }
 }
开发者ID:cakephp,项目名称:acl,代码行数:38,代码来源:AclBehavior.php

示例3: initialize

 /**
  * {@inheritdoc}
  *
  * @param array $config Strategy's configuration.
  * @return $this
  */
 public function initialize($config)
 {
     $config = parent::initialize($config)->config();
     $assocName = Inflector::pluralize(Inflector::classify($this->_alias));
     $this->_table->belongsTo($assocName, ['className' => $this->modelClass, 'foreignKey' => $config['field'], 'bindingKey' => 'name', 'conditions' => [$assocName . '.prefix' => $config['prefix']]]);
     return $this;
 }
开发者ID:omnuvito,项目名称:Enum,代码行数:13,代码来源:LookupStrategy.php

示例4: __construct

 /**
  * Class constructor
  *
  * @param Neomerx\JsonApi\Contracts\Schema\ContainerInterface $factory ContainerInterface
  * @param Neomerx\JsonApi\Contracts\Schema\SchemaFactoryInterface $container SchemaFactoryInterface
  * @param Cake\View\View $view Instance of the cake view we are rendering this in
  * @param string $entityName Name of the entity this schema is for
  */
 public function __construct(SchemaFactoryInterface $factory, ContainerInterface $container, View $view, $entityName)
 {
     $this->_view = $view;
     if (!$this->resourceType) {
         $this->resourceType = strtolower(Inflector::pluralize($entityName));
     }
     parent::__construct($factory, $container);
 }
开发者ID:josbeir,项目名称:cakephp-json-api,代码行数:16,代码来源:EntitySchema.php

示例5: _repository

 /**
  * Gets the repository for this entity
  *
  * @param EntityInterface $entity
  * @return Table
  */
 protected function _repository($entity)
 {
     $source = $entity->source();
     if ($source === null) {
         list(, $class) = namespaceSplit(get_class($entity));
         $source = Inflector::pluralize($class);
     }
     return TableRegistry::get($source);
 }
开发者ID:cakeplugins,项目名称:api,代码行数:15,代码来源:TransformerAbstract.php

示例6: setCustomMaker

 public function setCustomMaker()
 {
     $factory = $this->getFactoryClass();
     $factory::setCustomMaker(function ($class) {
         $parts = explode('\\', $class);
         $object = new $class();
         $object->source(Inflector::pluralize(array_pop($parts)));
         return $object;
     });
 }
开发者ID:gourmet,项目名称:muffin,代码行数:10,代码来源:TestFactory.php

示例7: asp

 /**
  * Auto-pluralizing a word using the Inflection class
  * //TODO: move to lib or bootstrap
  *
  * @param string $singular The string to be pl.
  * @param int $count
  * @return string "member" or "members" OR "Mitglied"/"Mitglieder" if autoTranslate TRUE
  */
 public function asp($singular, $count, $autoTranslate = false)
 {
     if ((int) $count !== 1) {
         $pural = Inflector::pluralize($singular);
     } else {
         $pural = null;
         // No pluralization necessary
     }
     return $this->sp($singular, $pural, $count, $autoTranslate);
 }
开发者ID:olmprakash,项目名称:cakephp-tools,代码行数:18,代码来源:CommonHelper.php

示例8: startup

 /**
  * {@inheritDoc}
  */
 public function startup()
 {
     $controller = $this->_registry->getController();
     $table = $controller->loadModel();
     $tableAlias = $table->table();
     if (empty($table->enums)) {
         return;
     }
     foreach ($table->enums as $field => $enum) {
         $controller->set(Inflector::pluralize(Inflector::variable($field)), $table->enum($field));
     }
 }
开发者ID:k1low,项目名称:property-enum,代码行数:15,代码来源:AutoSetComponent.php

示例9: _optionsOptions

 protected function _optionsOptions($fieldName, $options)
 {
     $pluralize = true;
     if (substr($fieldName, -5) === '._ids') {
         $fieldName = substr($fieldName, 0, -5);
         $pluralize = false;
     } elseif (substr($fieldName, -3) === '_id') {
         $fieldName = substr($fieldName, 0, -3);
     }
     $fieldName = array_slice(explode('.', $fieldName), -1)[0];
     $varName = Inflector::variable($pluralize ? Inflector::pluralize($fieldName) : $fieldName);
     return $this->_View->get($varName);
 }
开发者ID:leoruhland,项目名称:cakephp-fieldtypes,代码行数:13,代码来源:BootstrapSelectWidget.php

示例10: __construct

 /**
  * Make the helper, possibly configuring with CrudData objects
  * 
  * @param \Cake\View\View $View
  * @param array $config An array of CrudData objects
  */
 public function __construct(View $View, array $config = array())
 {
     parent::__construct($View, $config);
     $config += ['_CrudData' => [], 'actions' => []];
     $this->_defaultAlias = new NameConventions(Inflector::pluralize(Inflector::classify($this->request->controller)));
     $this->_CrudData = $config['_CrudData'];
     $this->DecorationSetups = new DecorationFactory($this);
     //		$this->_Field = new Collection();
     foreach ($config['actions'] as $name => $pattern) {
         $this->{$name} = $pattern;
     }
     $this->useCrudData($this->_defaultAlias->name);
 }
开发者ID:OrigamiStructures,项目名称:CrudViews,代码行数:19,代码来源:CrudHelper.php

示例11: _label

 protected function _label($field)
 {
     if (!isset($this->_properties[$field])) {
         return '';
     }
     $Table = TableRegistry::get($this->_registryAlias);
     $f = Inflector::variable(Inflector::pluralize($field));
     $values = $Table->{$f};
     $value = $this->{$field};
     if (isset($values[$value])) {
         return $values[$value];
     }
     return '';
 }
开发者ID:BreakfastMonkey,项目名称:breakfast-combo,代码行数:14,代码来源:Entity.php

示例12: display

 /**
  * {@inheritDoc}
  */
 public function display($fieldname, $value, $model = null)
 {
     $tableString = str_replace('_id', '', $fieldname);
     $tableName = Inflector::camelize(Inflector::pluralize($tableString));
     $table = TableRegistry::get($tableName);
     $tableConfig = [];
     if (defined('PHPUNIT_TESTSUITE')) {
         $tableConfig = ['className' => 'ModelHistoryTestApp\\Model\\Table\\ArticlesTable'];
     }
     $historizableBehavior = TableRegistry::get($model, $tableConfig)->behaviors()->get('Historizable');
     if (is_object($historizableBehavior) && method_exists($historizableBehavior, 'getRelationLink')) {
         return $historizableBehavior->getRelationLink($fieldname, $value);
     }
     return $value;
 }
开发者ID:codekanzlei,项目名称:cake-model-history,代码行数:18,代码来源:RelationTransform.php

示例13: _checkAssocitation

 /**
  * _checkAssociation method
  * @param array $data Candidate relation's data
  * @param string $candidate Candidate key
  * @param array $table Associated table
  * @param string $parentAssociation Name of the parent association
  * @return array
  */
 protected function _checkAssocitation($data, $candidate, $table, $parentAssociation = '')
 {
     if (!is_array($data)) {
         return [];
     }
     $associations = [];
     $pluralSec = Inflector::pluralize($candidate);
     if ($table->association($pluralSec)) {
         $association = ucwords($pluralSec);
         $assocString = $parentAssociation != '' ? $parentAssociation . '.' . $association : $association;
         $associations[] = $assocString;
         foreach ($data as $key => $info) {
             $associations = array_merge($associations, $this->_checkAssocitation($info, $key, $table->{$association}, $assocString));
         }
     }
     return $associations;
 }
开发者ID:oxenti,项目名称:user,代码行数:25,代码来源:AssociatableBehavior.php

示例14: _getTarget

 protected function _getTarget()
 {
     if (is_null($this->target)) {
         $name = Inflector::pluralize($this->entity);
         $table = TableRegistry::get($name);
         $keys = [$this->key1, $this->key2];
         $primary = $table->primaryKey();
         if (!is_array($primary)) {
             $primary = [$primary];
         }
         $where = [];
         foreach ($primary as $i => $id) {
             $where[$name . '.' . $id] = $keys[$i];
         }
         $q = $table->find()->where($where);
         $this->target = $table->findWithContain($q)->first();
     }
     return $this->target;
 }
开发者ID:pwerken,项目名称:va-void,代码行数:19,代码来源:Lammy.php

示例15: _process

 /**
  * Process tests regarding fixture usage and update it for 3.x
  *
  * @param string $content Fixture content.
  * @return bool
  */
 protected function _process($path)
 {
     $original = $contents = $this->Stage->source($path);
     // Serializes data from PHP data into PHP code.
     // Basically a code style conformant version of var_export()
     $export = function ($values) use(&$export) {
         $vals = [];
         if (!is_array($values)) {
             return $vals;
         }
         foreach ($values as $key => $val) {
             if (is_array($val)) {
                 $vals[] = "'{$key}' => [" . implode(", ", $export($val)) . "]";
             } else {
                 $val = var_export($val, true);
                 if ($val === 'NULL') {
                     $val = 'null';
                 }
                 if (!is_numeric($key)) {
                     $vals[] = "'{$key}' => {$val}";
                 } else {
                     $vals[] = "{$val}";
                 }
             }
         }
         return $vals;
     };
     // Process field property.
     $processor = function ($matches) use($export) {
         eval('$data = [' . $matches[2] . '];');
         $out = [];
         foreach ($data as $key => $fixture) {
             $pieces = explode('.', $fixture);
             $fixtureName = $pieces[count($pieces) - 1];
             $fixtureName = Inflector::pluralize($fixtureName);
             $pieces[count($pieces) - 1] = $fixtureName;
             $out[] = implode('.', $pieces);
         }
         return $matches[1] . "\n\t\t" . implode(",\n\t\t", $export($out)) . "\n\t" . $matches[3];
     };
     $contents = preg_replace_callback('/(public \\$fixtures\\s+=\\s+(?:array\\(|\\[))(.*?)(\\);|\\];)/ms', $processor, $contents, -1, $count);
     return $this->Stage->change($path, $original, $contents);
 }
开发者ID:cakephp,项目名称:upgrade,代码行数:49,代码来源:TestsTask.php


注:本文中的Cake\Utility\Inflector::pluralize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。