當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inflector::pluralize方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Util\Inflector::pluralize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::pluralize方法的具體用法?PHP Inflector::pluralize怎麽用?PHP Inflector::pluralize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Util\Inflector的用法示例。


在下文中一共展示了Inflector::pluralize方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: collection

 /**
  * Serialize a collection.
  *
  * @param string $resourceKey
  * @param array  $data
  *
  * @return array
  */
 public function collection($resourceKey, array $data)
 {
     $dataResponse = [];
     $resourceKey = strtolower($resourceKey);
     $pluralize = Inflector::pluralize($resourceKey);
     $singularize = Inflector::singularize($resourceKey);
     if (!$this->scope->hasParent()) {
         $dataResponse[$pluralize] = [$singularize => $data];
     } else {
         $dataResponse = [$singularize => $data];
     }
     return $dataResponse;
 }
開發者ID:eliberty,項目名稱:api-bundle,代碼行數:21,代碼來源:DataXmlSerializer.php

示例2: addRootRelations

 public function addRootRelations(Root $root, ClassMetadataInterface $classMetadata)
 {
     $prefix = $root->getPrefix();
     $relations = array();
     $self_args = $this->router->match($root->getPrefix());
     $relations[] = new Hateoas\Relation('self', new Hateoas\Route($self_args['_route'], array(), false));
     foreach ($root->getEntityNames() as $rel => $entityName) {
         /** @var ClassMetadata $metadata */
         $metadata = $this->entityManager->getMetadataFactory()->getMetadataFor($entityName);
         $routeName = $this->routeResolver->resolveRouteName($metadata->getName(), 'cgetAction');
         if ($routeName) {
             $arguments = array();
             foreach (self::$COLLECTION_ARGUMENTS as $argument) {
                 $arguments[$argument] = '{' . $argument . '}';
             }
             $relations[] = new Hateoas\Relation(Inflector::pluralize($rel), new Hateoas\Route($routeName, $arguments, false));
         }
         $routeName = $this->routeResolver->resolveRouteName($metadata->getName(), 'getAction');
         if ($routeName) {
             $relations[] = new Hateoas\Relation($rel, new Hateoas\Route($routeName, array('id' => "{id}"), false));
         }
         $routeName = $self_args['_route'] . '_schema';
         if ($this->router->getRouteCollection()->get($routeName)) {
             $relations[] = new Hateoas\Relation('schema:' . $rel, new Hateoas\Route($routeName, array('rel' => $rel), false));
         }
     }
     $user = $root->getCurrentUser();
     if ($user instanceof User) {
         $routeName = $this->routeResolver->resolveRouteName(get_class($user), 'getAction');
         if ($routeName) {
             $relations[] = new Hateoas\Relation('currentUser', new Hateoas\Route($routeName, array('id' => $user->getId()), false));
         }
     }
     return $relations;
 }
開發者ID:uebb,項目名稱:hateoas-bundle,代碼行數:35,代碼來源:RelationProvider.php

示例3: pluralize

 /**
  * @see DoctrineInflector::pluralize
  */
 public static function pluralize($word)
 {
     return DoctrineInflector::pluralize($word);
 }
開發者ID:gointegro,項目名稱:hateoas,代碼行數:7,代碼來源:Inflector.php


注:本文中的Doctrine\Common\Util\Inflector::pluralize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。