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


PHP Inflector::tableize方法代码示例

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


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

示例1: getTranslationKey

 /**
  * Returns translation key (placeholder) by entity class name, field name and property code
  * examples (for default scope which is 'entity'):
  *      [vendor].[bundle].[entity].[field].[config property]
  *      oro.user.group.name.label
  *
  *      if [entity] == [bundle] -> skip it
  *      oro.user.first_name.label
  *
  *      if NO fieldName -> add prefix 'entity_'
  *      oro.user.entity_label
  *      oro.user.group.entity_label
  * examples (for other scopes, for instance 'test'):
  *      [vendor].[bundle].[entity].[field].[scope]_[config property]
  *      oro.user.group.name.test_label
  *
  *      if [entity] == [bundle] -> skip it
  *      oro.user.first_name.test_label
  *
  *      if NO fieldName -> add prefix 'entity_'
  *      oro.user.entity_test_label
  *      oro.user.group.entity_test_label
  *
  * @param string $scope
  * @param string $propertyName property key: label, description, plural_label, etc.
  * @param string $className
  * @param string $fieldName
  *
  * @return string
  *
  * @throws \InvalidArgumentException
  */
 public static function getTranslationKey($scope, $propertyName, $className, $fieldName = null)
 {
     if (empty($scope)) {
         throw new \InvalidArgumentException('$scope must not be empty');
     }
     if (empty($propertyName)) {
         throw new \InvalidArgumentException('$propertyName must not be empty');
     }
     if (empty($className)) {
         throw new \InvalidArgumentException('$className must not be empty');
     }
     // handle 'entity' scope separately
     if ($scope === 'entity') {
         return EntityLabelBuilder::getTranslationKey($propertyName, $className, $fieldName);
     }
     $parts = EntityLabelBuilder::explodeClassName($className);
     $propertyName = Inflector::tableize($scope) . '_' . $propertyName;
     if ($fieldName) {
         $parts[] = Inflector::tableize($fieldName);
         $parts[] = $propertyName;
     } else {
         $parts[] = 'entity_' . $propertyName;
     }
     return implode('.', $parts);
 }
开发者ID:Maksold,项目名称:platform,代码行数:57,代码来源:ConfigHelper.php

示例2: tableize

 /**
  * @inheritdoc
  */
 public static function tableize($word)
 {
     if (!isset(static::$cache['tableize'][$word])) {
         static::$cache['tableize'][$word] = parent::tableize($word);
     }
     return static::$cache['tableize'][$word];
 }
开发者ID:doctrine,项目名称:orientdb-odm,代码行数:10,代码来源:Cached.php

示例3: getName

 /**
  * Return name
  *
  * @return string
  */
 public function getName()
 {
     $classname = get_class($this);
     if (preg_match('@\\\\([\\w]+)$@', $classname, $matches)) {
         $classname = $matches[1];
     }
     return Inflector::tableize($classname);
 }
开发者ID:xleliberty,项目名称:BatchBundle,代码行数:13,代码来源:AbstractConfigurableStepElement.php

示例4: __call

 /**
  * Magic method to execute curl_xxx calls
  *
  * @param string $name      Method name (should be camelized)
  * @param array  $arguments Method arguments
  *
  * @return mixed
  * @throws \Exception
  */
 public function __call($name, $arguments)
 {
     $name = Inflector::tableize($name);
     if (function_exists("curl_{$name}")) {
         array_unshift($arguments, $this->handle);
         return call_user_func_array("curl_{$name}", $arguments);
     }
     throw new \Exception("Function 'curl_{$name}' do not exist, see PHP manual.");
 }
开发者ID:bebetojefry,项目名称:LswApiCallerBundle,代码行数:18,代码来源:Curl.php

示例5: configureMigrationsForBundle

 public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
 {
     $bundle = $application->getKernel()->getBundle($bundle);
     $dir = $bundle->getPath() . '/DoctrineMigrations';
     $configuration->setMigrationsNamespace($bundle->getNamespace() . '\\DoctrineMigrations');
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($bundle->getName() . ' Migrations');
     $configuration->setMigrationsTableName(Inflector::tableize($bundle->getName()) . '_migration_versions');
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:10,代码来源:DoctrineCommand.php

示例6: getName

 /**
  * Creates a name for a command that can be used throughout configuration files
  *
  * @return string
  */
 public function getName()
 {
     $class = get_class($this);
     $class = explode('\\', $class);
     $class = $class[count($class) - 1];
     $class = str_replace(array('Supra', 'Package'), '', $class);
     $inflector = new Inflector();
     $name = $inflector->tableize($class);
     return $name;
 }
开发者ID:sitesupra,项目名称:sitesupra,代码行数:15,代码来源:AbstractSupraPackage.php

示例7: getTranslationKey

 /**
  * Returns the translation key for the given entity property
  *
  * The result format for entity: [vendor].[bundle].[entity].entity_[property]
  * Examples:
  *  label for Acme\Bundle\TestBundle\Entity\Product          -> acme.test.product.entity_label
  *  description for Acme\Bundle\ProductBundle\Entity\Product -> acme.product.entity_label
  *
  * The result format for field: [vendor].[bundle].[entity].[field].[property]
  * Examples:
  *  label for Acme\Bundle\TestBundle\Entity\Product::sellPrice    -> acme.test.product.sell_price.label
  *  label for Acme\Bundle\ProductBundle\Entity\Product::sellPrice -> acme.product.sell_price.label
  *
  * @param string      $propertyName
  * @param string      $className
  * @param string|null $fieldName
  *
  * @return string
  */
 public static function getTranslationKey($propertyName, $className, $fieldName = null)
 {
     $parts = self::explodeClassName($className);
     if ($fieldName) {
         $parts[] = Inflector::tableize($fieldName);
         $parts[] = $propertyName;
     } else {
         $parts[] = 'entity_' . $propertyName;
     }
     return implode('.', $parts);
 }
开发者ID:Maksold,项目名称:platform,代码行数:30,代码来源:EntityLabelBuilder.php

示例8: configureMigrationsForBundle

 public static function configureMigrationsForBundle(Application $application, $bundle, Configuration $configuration)
 {
     $configuration->setMigrationsNamespace($bundle . '\\DoctrineMigrations');
     $dirs = $application->getKernel()->getBundleDirs();
     $tmp = str_replace('\\', '/', $bundle);
     $namespace = str_replace('/', '\\', dirname($tmp));
     $bundle = basename($tmp);
     $dir = $dirs[$namespace] . '/' . $bundle . '/DoctrineMigrations';
     $configuration->setMigrationsDirectory($dir);
     $configuration->registerMigrationsFromDirectory($dir);
     $configuration->setName($bundle . ' Migrations');
     $configuration->setMigrationsTableName(Inflector::tableize($bundle) . '_migration_versions');
 }
开发者ID:bill97420,项目名称:symfony,代码行数:13,代码来源:DoctrineCommand.php

示例9: getDirname

 public function getDirname($model)
 {
     $className = get_class($model);
     if (isset($this->basedirs[$className])) {
         $basedir = $this->basedirs[$className];
     } else {
         $reflection = new \ReflectionClass($className);
         $basedir = $this->basedirs[$className] = Inflector::tableize($reflection->getShortName());
     }
     $id = sprintf('%012s', $model->id);
     // Format
     //      $basedir / id[0..4] / id[5..8] / id[9..12]
     //      $basedir / 0000 / 0000 / 0001
     return sprintf('%s/%04s/%04s/%04s', $basedir, substr($id, 0, 4), substr($id, 5, 4), substr($id, 9, 4));
 }
开发者ID:subbly,项目名称:framework,代码行数:15,代码来源:MediaResolver.php

示例10: map

 /**
  * Map domain model to DTO.
  *
  * @param \Staffim\DTOBundle\Model\ModelInterface $model
  * @return object $dto
  */
 public function map(ModelInterface $model, $parentPropertyName = null)
 {
     $dto = $this->factory->create($model);
     $properties = get_object_vars($dto);
     // @todo trigger pre event
     foreach ($properties as $propertyName => $property) {
         $this->updateProperty($model, $dto, $propertyName, $parentPropertyName);
     }
     if ($this->eventDispatcher) {
         $event = new PostMapEvent($model, $dto);
         $modelClassParts = explode('\\', get_class($model));
         $modelName = \Doctrine\Common\Util\Inflector::tableize(end($modelClassParts));
         $this->eventDispatcher->dispatch('dto.' . $modelName . '.post_map', $event);
     }
     return $dto;
 }
开发者ID:anyx,项目名称:StaffimDTOBundle,代码行数:22,代码来源:Mapper.php

示例11: generate

 /**
  * @param BundleInterface $bundle
  * @param string          $entity
  * @param string          $format
  * @param array           $fields
  *
  * @return EntityGeneratorResult
  *
  * @throws \Doctrine\ORM\Tools\Export\ExportException
  */
 public function generate(BundleInterface $bundle, $entity, $format, array $fields)
 {
     // configure the bundle (needed if the bundle does not contain any Entities yet)
     $config = $this->registry->getManager(null)->getConfiguration();
     $config->setEntityNamespaces(array_merge(array($bundle->getName() => $bundle->getNamespace() . '\\Entity'), $config->getEntityNamespaces()));
     $entityClass = $this->registry->getAliasNamespace($bundle->getName()) . '\\' . $entity;
     $entityPath = $bundle->getPath() . '/Entity/' . str_replace('\\', '/', $entity) . '.php';
     if (file_exists($entityPath)) {
         throw new \RuntimeException(sprintf('Entity "%s" already exists.', $entityClass));
     }
     $class = new ClassMetadataInfo($entityClass);
     $class->customRepositoryClassName = str_replace('\\Entity\\', '\\Repository\\', $entityClass) . 'Repository';
     $class->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO);
     foreach ($fields as $field) {
         $class->mapField($field);
     }
     $entityGenerator = $this->getEntityGenerator();
     if ('annotation' === $format) {
         $entityGenerator->setGenerateAnnotations(true);
         $class->setPrimaryTable(array('name' => Inflector::tableize($entity)));
         $entityCode = $entityGenerator->generateEntityClass($class);
         $mappingPath = $mappingCode = false;
     } else {
         $cme = new ClassMetadataExporter();
         $exporter = $cme->getExporter('yml' == $format ? 'yaml' : $format);
         $mappingPath = $bundle->getPath() . '/Resources/config/doctrine/' . str_replace('\\', '.', $entity) . '.orm.' . $format;
         if (file_exists($mappingPath)) {
             throw new \RuntimeException(sprintf('Cannot generate entity when mapping "%s" already exists.', $mappingPath));
         }
         $mappingCode = $exporter->exportClassMetadata($class);
         $entityGenerator->setGenerateAnnotations(false);
         $entityCode = $entityGenerator->generateEntityClass($class);
     }
     $entityCode = str_replace(array("@var integer\n", "@var boolean\n", "@param integer\n", "@param boolean\n", "@return integer\n", "@return boolean\n"), array("@var int\n", "@var bool\n", "@param int\n", "@param bool\n", "@return int\n", "@return bool\n"), $entityCode);
     $this->filesystem->mkdir(dirname($entityPath));
     file_put_contents($entityPath, $entityCode);
     if ($mappingPath) {
         $this->filesystem->mkdir(dirname($mappingPath));
         file_put_contents($mappingPath, $mappingCode);
     }
     $path = $bundle->getPath() . str_repeat('/..', substr_count(get_class($bundle), '\\'));
     $this->getRepositoryGenerator()->writeEntityRepositoryClass($class->customRepositoryClassName, $path);
     $repositoryPath = $path . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $class->customRepositoryClassName) . '.php';
     return new EntityGeneratorResult($entityPath, $repositoryPath, $mappingPath);
 }
开发者ID:coreight,项目名称:SensioGeneratorBundle,代码行数:56,代码来源:DoctrineEntityGenerator.php

示例12: setUp

 protected function setUp()
 {
     $this->importProcessor = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\ImportExport\\Processor\\StepExecutionAwareImportProcessor')->disableOriginalConstructor()->getMock();
     $this->exportProcessor = $this->getMockBuilder('Oro\\Bundle\\IntegrationBundle\\ImportExport\\Processor\\StepExecutionAwareExportProcessor')->disableOriginalConstructor()->getMock();
     $this->importProcessor->expects($this->any())->method('process')->will($this->returnCallback(function ($item) {
         $keys = array_map(function ($key) {
             return Inflector::camelize($key);
         }, array_keys($item));
         return (object) array_combine($keys, array_values($item));
     }));
     $this->exportProcessor->expects($this->any())->method('process')->will($this->returnCallback(function ($item) {
         $item = (array) $item;
         $keys = array_map(function ($key) {
             return Inflector::tableize($key);
         }, array_keys($item));
         return array_combine($keys, array_values($item));
     }));
     $this->strategy = new TwoWaySyncStrategy($this->importProcessor, $this->exportProcessor);
 }
开发者ID:antrampa,项目名称:crm,代码行数:19,代码来源:TwoWaySyncStrategyTest.php

示例13: _serializeEntity

 /**
  * @param object $entity
  * @return array|null
  */
 protected function _serializeEntity($entity)
 {
     $className = get_class($entity);
     $metadata = $this->_em->getClassMetadata($className);
     $data = array();
     foreach ($metadata->fieldMappings as $field => $mapping) {
         $value = $metadata->reflFields[$field]->getValue($entity);
         $field = Inflector::tableize($field);
         if ($value instanceof \DateTime) {
             // We cast DateTime to array to keep consistency with array result
             $data[$field] = (array) $value;
         } elseif (is_object($value)) {
             $data[$field] = (string) $value;
         } else {
             $data[$field] = $value;
         }
     }
     foreach ($metadata->associationMappings as $field => $mapping) {
         $key = Inflector::tableize($field);
         if ($mapping['isCascadeDetach']) {
             $data[$key] = $metadata->reflFields[$field]->getValue($entity);
             if (null !== $data[$key]) {
                 $data[$key] = $this->_serializeEntity($data[$key]);
             }
         } elseif ($mapping['isOwningSide'] && $mapping['type'] & ClassMetadata::TO_ONE) {
             if (null !== $metadata->reflFields[$field]->getValue($entity)) {
                 if ($this->_recursionDepth < $this->_maxRecursionDepth) {
                     $this->_recursionDepth++;
                     $data[$key] = $this->_serializeEntity($metadata->reflFields[$field]->getValue($entity));
                     $this->_recursionDepth--;
                 } else {
                     $data[$key] = $this->getEntityManager()->getUnitOfWork()->getEntityIdentifier($metadata->reflFields[$field]->getValue($entity));
                 }
             } else {
                 // In some case the relationship may not exist, but we want
                 // to know about it
                 $data[$key] = null;
             }
         }
     }
     return $data;
 }
开发者ID:javierugalde,项目名称:symfony2-quiz,代码行数:46,代码来源:EntitySerializer.php

示例14: __call

 /**
  * Convenient method that intercepts the find*By*() calls.
  *
  * @param string $method
  * @param array $arguments
  * @return method
  * @throws RuntimeException
  */
 public function __call($method, $arguments)
 {
     if (strpos($method, 'findOneBy') === 0) {
         $property = substr($method, 9);
         $method = 'findOneBy';
     } elseif (strpos($method, 'findBy') === 0) {
         $property = substr($method, 6);
         $method = 'findBy';
     } else {
         throw new RuntimeException(sprintf("The %s repository class does not have a method %s", get_called_class(), $method));
     }
     $property = Inflector::tableize($property);
     foreach ($arguments as $position => $argument) {
         if (is_object($argument)) {
             if (!method_exists($argument, 'getRid')) {
                 throw new RuntimeException("When calling \$repository->find*By*(), you can only pass, as arguments, objects that have the getRid() method (shortly, entitites)");
             }
             $arguments[$position] = $argument->getRid();
         }
     }
     return $this->{$method}(array($property => $arguments[0]));
 }
开发者ID:doctrine,项目名称:orientdb-odm,代码行数:30,代码来源:Repository.php

示例15: toDOMDocument

 public function toDOMDocument()
 {
     $arrToXml = function ($node, $data) use(&$arrToXml) {
         foreach ($data as $k => $v) {
             $child = $node->ownerDocument->createElement($k);
             $node->appendChild($child);
             if (is_array($v)) {
                 $arrToXml($child, $v);
             } else {
                 $child->appendChild($node->ownerDocument->createTextNode($v));
             }
         }
     };
     $className = get_class($this);
     $em = ActiveEntityRegistry::getClassManager($className);
     $class = $em->getClassMetadata($className);
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $root = $dom->createElement(Inflector::tableize($class->reflClass->getShortName()));
     $dom->appendChild($root);
     $arrToXml($root, $this->toArray());
     return $dom;
 }
开发者ID:sbaldani,项目名称:serializable-entity-doctrine,代码行数:22,代码来源:SerializableEntity.php


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