本文整理匯總了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;
}
示例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;
}
示例3: pluralize
/**
* @see DoctrineInflector::pluralize
*/
public static function pluralize($word)
{
return DoctrineInflector::pluralize($word);
}