本文整理汇总了PHP中Doctrine\Common\Inflector\Inflector::tableize方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::tableize方法的具体用法?PHP Inflector::tableize怎么用?PHP Inflector::tableize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Inflector\Inflector
的用法示例。
在下文中一共展示了Inflector::tableize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public function handle($className, Property $property)
{
try {
if ($type = $this->guesser->guessType($className, $property->getName())) {
$property->addType($this->getPropertyType($type));
$property->setFormat($this->getPropertyFormat($type));
if (in_array($type->getType(), array('document', 'entity'))) {
$options = $type->getOptions();
if (isset($options['class']) && $this->registry->hasNamespace($options['class'])) {
$alias = $this->registry->getAlias($options['class']);
if ($alias) {
$property->setObject($alias);
if (isset($options['multiple']) && $options['multiple'] == true) {
$property->setMultiple(true);
}
}
}
}
}
if ($required = $this->guesser->guessRequired($className, $property->getName())) {
$property->setRequired($required->getValue());
}
if ($pattern = $this->guesser->guessPattern($className, $property->getName())) {
$property->setPattern($pattern->getValue());
}
if ($maximum = $this->guesser->guessMaxLength($className, $property->getName())) {
$property->setMaximum($maximum->getValue());
}
if ($property->getTitle() == null) {
$title = ucwords(str_replace('_', ' ', Inflector::tableize($property->getName())));
$property->setTitle($title);
}
} catch (MappingException $e) {
}
}
示例2: reverseTransform
/**
* @param Request $request
* @param string $id
* @param string $type
* @param string $event
* @param string $eventClass
*
* @return Response
*/
protected function reverseTransform(Request $request, $id, $type, $event, $eventClass)
{
$facadeName = Inflector::classify($type) . 'Facade';
$typeName = Inflector::tableize($type);
$format = $request->get('_format', 'json');
$facade = $this->get('jms_serializer')->deserialize($request->getContent(), 'OpenOrchestra\\ApiBundle\\Facade\\' . $facadeName, $format);
$mixed = $this->get('open_orchestra_model.repository.' . $typeName)->find($id);
$oldStatus = null;
if ($mixed instanceof StatusableInterface) {
$oldStatus = $mixed->getStatus();
}
$mixed = $this->get('open_orchestra_api.transformer_manager')->get($typeName)->reverseTransform($facade, $mixed);
if ($this->isValid($mixed)) {
$em = $this->get('object_manager');
$em->persist($mixed);
$em->flush();
if (in_array('OpenOrchestra\\ModelInterface\\Event\\EventTrait\\EventStatusableInterface', class_implements($eventClass))) {
$this->dispatchEvent($event, new $eventClass($mixed, $oldStatus));
return array();
}
$this->dispatchEvent($event, new $eventClass($mixed));
return array();
}
return $this->getViolations();
}
示例3: createOperation
/**
* Creates operation.
*
* @param ResourceInterface $resource
* @param bool $collection
* @param string|array $methods
* @param string|null $path
* @param string|null $controller
* @param string|null $routeName
* @param array $context
*
* @return Operation
*/
private function createOperation(ResourceInterface $resource, $collection, $methods, $path = null, $controller = null, $routeName = null, array $context = [])
{
$shortName = $resource->getShortName();
if (!isset(self::$inflectorCache[$shortName])) {
self::$inflectorCache[$shortName] = Inflector::pluralize(Inflector::tableize($shortName));
}
// Populate path
if (null === $path) {
$path = '/' . self::$inflectorCache[$shortName];
if (!$collection) {
$path .= '/{id}';
}
}
// Guess default method
if (is_array($methods)) {
$defaultMethod = $methods[0];
} else {
$defaultMethod = $methods;
}
// Populate controller
if (null === $controller) {
$defaultAction = strtolower($defaultMethod);
if ($collection) {
$defaultAction = 'c' . $defaultAction;
}
$controller = self::DEFAULT_CONTROLLER . ':' . $defaultAction;
// Populate route name
if (null === $routeName) {
$routeName = self::ROUTE_NAME_PREFIX . self::$inflectorCache[$shortName] . '_' . $defaultAction;
}
}
return new Operation(new Route($path, ['_controller' => $controller, '_resource' => $shortName], [], [], '', [], $methods), $routeName, $context);
}
示例4: testChoiceNormalizer
public function testChoiceNormalizer()
{
// source data
$workflowAwareClass = 'WorkflowAwareClass';
$extendedClass = 'ExtendedClass';
$notExtendedClass = 'NotExtendedClass';
$notConfigurableClass = 'NotConfigurableClass';
// asserts
$this->entityConnector->expects($this->any())->method('isWorkflowAware')->will($this->returnCallback(function ($class) use($workflowAwareClass) {
return $class === $workflowAwareClass;
}));
$extendedEntityConfig = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
$extendedEntityConfig->expects($this->any())->method('is')->with('is_extend')->will($this->returnValue(true));
$notExtendedEntityConfig = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
$notExtendedEntityConfig->expects($this->any())->method('is')->with('is_extend')->will($this->returnValue(false));
$extendConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
$hasConfigMap = array(array($workflowAwareClass, null, false), array($extendedClass, null, true), array($notExtendedClass, null, true), array($notConfigurableClass, null, false));
$extendConfigProvider->expects($this->any())->method('hasConfig')->with($this->isType('string'), null)->will($this->returnValueMap($hasConfigMap));
$getConfigMap = array(array($extendedClass, null, $extendedEntityConfig), array($notExtendedClass, null, $notExtendedEntityConfig));
$extendConfigProvider->expects($this->any())->method('getConfig')->with($this->isType('string'), null)->will($this->returnValueMap($getConfigMap));
$this->configManager->expects($this->once())->method('getProvider')->with('extend')->will($this->returnValue($extendConfigProvider));
// test
$inputChoices = array($workflowAwareClass => Inflector::tableize($workflowAwareClass), $extendedClass => Inflector::tableize($extendedClass), $notExtendedClass => Inflector::tableize($notExtendedClass), $notConfigurableClass => Inflector::tableize($notConfigurableClass));
$expectedChoices = array($workflowAwareClass => Inflector::tableize($workflowAwareClass), $extendedClass => Inflector::tableize($extendedClass));
$resolver = new OptionsResolver();
$resolver->setDefaults(array('choices' => $inputChoices));
$this->formType->setDefaultOptions($resolver);
$result = $resolver->resolve(array());
$this->assertEquals($expectedChoices, $result['choices']);
}
示例5: invoke
/**
* @param FactoryArguments $arguments
* @param $method
* @param array $parameters
* @return mixed
* @throws \LukaszMordawski\CampaignMonitorBundle\Exception\Exception
* @throws \LogicException
*
* This method invokes proper API method and stores result in cache.
*/
public function invoke(FactoryArguments $arguments, $method, $parameters = [])
{
if (!$arguments->clientId) {
$arguments->clientId = $this->clientId;
}
$method = Inflector::tableize($method);
$cacheKey = $this->getCacheKey($arguments, $method, $parameters);
if ($this->cache->contains($cacheKey)) {
return unserialize($this->cache->fetch($cacheKey));
}
$csClient = $this->factory->factory($arguments);
if (method_exists($csClient, $method)) {
if (is_array($parameters)) {
$data = call_user_func_array([$csClient, $method], $parameters);
} else {
$data = call_user_func([$csClient, $method], $parameters);
}
} else {
throw new \LogicException(sprintf('Method %s does not exist for class %s', $method, get_class($csClient)));
}
if ($data->http_status_code != 200 && $data->http_status_code != 201) {
throw new Exception($data->response->Message, $data->response->Code);
}
$this->cache->save($cacheKey, serialize($data->response), $this->cacheLifetime);
return $data->response;
}
示例6: getName
public function getName()
{
$name = $this->reflection->getName();
$inflector = new Inflector();
$name = $inflector->tableize($name);
return $name;
}
示例7: toIdentifier
private function toIdentifier($object)
{
$className = get_class($object);
$className = substr($className, strrpos($className, '\\') + 1);
$className = str_replace('SystemInfo', '', $className);
return Inflector::tableize($className);
}
示例8: createOperation
/**
* Creates operation.
*
* @param ResourceInterface $resource
* @param bool $collection
* @param string|array $methods
* @param string|null $path
* @param string|null $controller
* @param string|null $routeName
* @param array $context
*
* @return Operation
*/
private function createOperation(ResourceInterface $resource, $collection, $methods, $path = null, $controller = null, $routeName = null, array $context = [])
{
$shortName = $resource->getShortName();
if (!isset(self::$inflectorCache[$shortName])) {
self::$inflectorCache[$shortName] = Inflector::pluralize(Inflector::tableize($shortName));
}
// Populate path
if (null === $path) {
$path = '/' . self::$inflectorCache[$shortName];
if (!$collection) {
$path .= '/{id}';
}
}
// Guess default method
if (is_array($methods)) {
$defaultMethod = $methods[0];
} else {
$defaultMethod = $methods;
}
// Populate controller
if (null === $controller) {
$actionName = sprintf('%s_%s', strtolower($defaultMethod), $collection ? 'collection' : 'item');
$controller = self::DEFAULT_ACTION_PATTERN . $actionName;
// Populate route name
if (null === $routeName) {
$routeName = sprintf('%s%s_%s', self::ROUTE_NAME_PREFIX, self::$inflectorCache[$shortName], $actionName);
}
}
return new Operation(new Route($path, ['_controller' => $controller, '_resource' => $shortName], [], [], '', [], $methods), $routeName, $context);
}
示例9: prePersist
/**
* @param LifecycleEventArgs $event
*/
public function prePersist(LifecycleEventArgs $event)
{
$document = $event->getDocument();
$className = get_class($document);
$generateAnnotations = $this->annotationReader->getClassAnnotation(new \ReflectionClass($className), 'OpenOrchestra\\Mapping\\Annotations\\Document');
if (!is_null($generateAnnotations)) {
$repository = $this->container->get($generateAnnotations->getServiceName());
$getSource = $generateAnnotations->getSource($document);
$getGenerated = $generateAnnotations->getGenerated($document);
$setGenerated = $generateAnnotations->setGenerated($document);
$testMethod = $generateAnnotations->getTestMethod();
if ($testMethod === null && $repository instanceof FieldAutoGenerableRepositoryInterface) {
$testMethod = 'testUniquenessInContext';
}
if (is_null($document->{$getGenerated}())) {
$source = $document->{$getSource}();
$source = Inflector::tableize($source);
$sourceField = $this->suppressSpecialCharacterHelper->transform($source);
$generatedField = $sourceField;
$count = 1;
while ($repository->{$testMethod}($generatedField)) {
$generatedField = $sourceField . '-' . $count;
$count++;
}
$document->{$setGenerated}($generatedField);
}
}
}
示例10: deduce
/**
* {@inheritdoc}
*/
public function deduce($class, $event)
{
$parts = explode('\\', $class);
$parts = array_map(function ($e) {
return Inflector::tableize($e);
}, $parts);
return sprintf('%s.%s', implode('.', $parts), Inflector::tableize($event));
}
示例11: resolveOperationPath
/**
* {@inheritdoc}
*/
public function resolveOperationPath(string $resourceShortName, array $operation, bool $collection) : string
{
$path = '/' . Inflector::pluralize(Inflector::tableize($resourceShortName));
if (!$collection) {
$path .= '/{id}';
}
$path .= '.{_format}';
return $path;
}
示例12: fromArray
/**
* Hydrate a collection from an array
*
* @param array $data
*
* @return Object
*/
public function fromArray(array $data)
{
foreach ($data as $key => $value) {
if (property_exists($this, $key)) {
$this->{'set' . Inflector::tableize($key)}($value);
}
}
return $this;
}
示例13: getWebhookUrl
/**
* Returns the url for the webhook
* @param $action Can be create, update or delete
* @return string
*/
public function getWebhookUrl($action)
{
$params = ['model' => Inflector::tableize($this->getName()), 'action' => $action];
if (defined('WEBHOOK_KEY')) {
$params = array_merge(['key' => WEBHOOK_KEY], $params);
}
$query = http_build_query($params);
return WEBHOOK_BASE . '/?' . $query;
}
示例14: getUri
/**
* Get the URI for this collection (with placeholders)
*
* @return string
*/
protected static function getUri()
{
if (isset(static::$uri)) {
return static::$uri;
}
// Guess URI
$class = preg_replace('/^.+\\\\/', '', static::getResourceClass());
$plural = Inflector::pluralize($class);
return '/' . strtr(Inflector::tableize($plural), '_', '-') . '/:id';
}
示例15: getModelName
/**
* @return string Model name
*/
public function getModelName()
{
if (is_null($this->model_name)) {
$model_name = get_class($this);
$model_name = explode('\\', $model_name);
$model_name = end($model_name);
$model_name = substr($model_name, 0, -strlen('Controller'));
$this->model_name = Inflector::tableize($model_name);
}
return $this->model_name;
}