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


PHP Inflector::classify方法代码示例

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


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

示例1: __call

 /**
  * Doctrine\ORM\EntityRepository.__call()と同じ動きで自前のfindBy関数を動かす
  *
  * @see Doctrine\ORM\EntityRepository::__call()
  */
 public function __call($method, $arguments)
 {
     $by = null;
     switch (true) {
         case 0 === strpos($method, 'findCountBy'):
             $by = substr($method, 11);
             $method = 'findCountBy';
             break;
     }
     // $by があれば、上記に定義した独自関数だったとする
     if (!is_null($by)) {
         $fieldName = lcfirst(\Doctrine\Common\Util\Inflector::classify($by));
         if ($this->_class->hasField($fieldName) || $this->_class->hasAssociation($fieldName)) {
             switch (count($arguments)) {
                 case 1:
                     return $this->{$method}(array($fieldName => $arguments[0]));
                 case 2:
                     return $this->{$method}(array($fieldName => $arguments[0]), $arguments[1]);
                 case 3:
                     return $this->{$method}(array($fieldName => $arguments[0]), $arguments[1], $arguments[2]);
                 case 4:
                     return $this->{$method}(array($fieldName => $arguments[0]), $arguments[1], $arguments[2], $arguments[3]);
                 default:
                     // Do nothing
             }
         }
     }
     return parent::__call($method, $arguments);
 }
开发者ID:iwatea,项目名称:Swim,代码行数:34,代码来源:AbstractRepository.php

示例2: setAttribute

 /**
  * Sets the attribute
  *
  * @param AttributeInterface $attribute
  *
  * @throws ColumnLabelException
  */
 public function setAttribute(AttributeInterface $attribute = null)
 {
     $this->attribute = $attribute;
     if (null === $attribute) {
         $this->locale = null;
         $this->scope = null;
         $this->suffixes = $this->rawSuffixes;
         $this->propertyPath = lcfirst(Inflector::classify($this->name));
     } else {
         if (!in_array($attribute->getBackendType(), [AbstractAttributeType::BACKEND_TYPE_REF_DATA_OPTION, AbstractAttributeType::BACKEND_TYPE_REF_DATA_OPTIONS])) {
             $this->propertyPath = $attribute->getBackendType();
         } else {
             $this->propertyPath = $attribute->getReferenceDataName();
         }
         $suffixes = $this->rawSuffixes;
         if ($attribute->isLocalizable()) {
             if (count($suffixes)) {
                 $this->locale = array_shift($suffixes);
             } else {
                 throw new ColumnLabelException('The column "%column%" must contain a locale code', ['%column%' => $this->label]);
             }
         }
         if ($attribute->isScopable()) {
             if (count($suffixes)) {
                 $this->scope = array_shift($suffixes);
             } else {
                 throw new ColumnLabelException('The column "%column%" must contain a scope code', ['%column%' => $this->label]);
             }
         }
         $this->suffixes = $suffixes;
     }
 }
开发者ID:qrz-io,项目名称:pim-community-dev,代码行数:39,代码来源:ColumnInfo.php

示例3: classify

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

示例4: __get

 public function __get($property)
 {
     if (count($this->getPropertiesMap()) > 0) {
         $map = $this->getPropertiesMap();
         if (array_key_exists($property, $map)) {
             $methodName = $map[$property];
             if (method_exists($this, $methodName)) {
                 return $this->{$methodName}();
             } elseif (method_exists($this->dataObject, $methodName)) {
                 return $this->dataObject->{$methodName}();
             }
         }
         throw new \LogicException("Undefined " . $property . " property.");
     }
     $methodName = 'get' . \Doctrine\Common\Util\Inflector::classify($property);
     if (method_exists($this, $methodName)) {
         return $this->{$methodName}();
     } elseif (property_exists($this, $property)) {
         return $this->{$property};
     } elseif (method_exists($this->dataObject, $methodName)) {
         return $this->dataObject->{$methodName}();
     } elseif (property_exists($this->dataObject, $property)) {
         return $this->dataObject->{$property};
     }
     throw new \LogicException("Undefined " . $methodName . " method or missing " . $property . " property.");
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:26,代码来源:MetaBase.php

示例5: setAttribute

 /**
  * Sets the attribute
  *
  * @param AttributeInterface $attribute
  *
  * @throws ColumnLabelException
  */
 public function setAttribute(AttributeInterface $attribute = null)
 {
     $this->attribute = $attribute;
     if (null === $attribute) {
         $this->locale = null;
         $this->scope = null;
         $this->suffixes = $this->rawSuffixes;
         $this->propertyPath = lcfirst(Inflector::classify($this->name));
     } else {
         $this->propertyPath = $attribute->getBackendType();
         $suffixes = $this->rawSuffixes;
         if ($attribute->isLocalizable()) {
             if (count($suffixes)) {
                 $this->locale = array_shift($suffixes);
             } else {
                 throw new ColumnLabelException('The column "%column%" must contain a locale code', array('%column%' => $this->label));
             }
         }
         if ($attribute->isScopable()) {
             if (count($suffixes)) {
                 $this->scope = array_shift($suffixes);
             } else {
                 throw new ColumnLabelException('The column "%column%" must contain a scope code', array('%column%' => $this->label));
             }
         }
         $this->suffixes = $suffixes;
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:35,代码来源:ColumnInfo.php

示例6: _autofixeuroformat

 private function _autofixeuroformat($object)
 {
     $formRequestData = $this->getRequest()->request->all();
     if (!isset($formRequestData[$this->getForm()->getName()])) {
         return;
     }
     $formRequestData = $formRequestData[$this->getForm()->getName()];
     $fields = $object->fieldsAsArray($object);
     foreach ($fields as $field => $value) {
         $fieldDescription = $this->getFormFieldDescription($field);
         if ($fieldDescription && ($type = $fieldDescription->getType())) {
             if ($type == 'money' || $type == 'number' || $type == 'float') {
                 if (isset($formRequestData[$field])) {
                     $method = ucfirst(\Doctrine\Common\Util\Inflector::classify($field));
                     $setMethod = 'set' . $method;
                     $getMethod = 'get' . $method;
                     $value = str_replace(array("\n", "\t", "\r"), " ", $formRequestData[$field]);
                     $value = str_replace(array(' ', ','), array('', '.'), $value);
                     $value = preg_replace('/[^(\\x20-\\x7F)]*/', '', $value);
                     $object->{$setMethod}($value);
                 }
             }
         }
     }
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:25,代码来源:AbstractCompteAdmin.php

示例7: transformName

 /**
  * {@inheritdoc}
  */
 public function transformName($name)
 {
     if ($this->ucFirst) {
         return Inflector::classify($name);
     } else {
         return Inflector::camelize($name);
     }
 }
开发者ID:rafrsr,项目名称:lib-array2object,代码行数:11,代码来源:CamelCaseNamingStrategy.php

示例8: testSetProperty

 public function testSetProperty()
 {
     $options = array('label' => 'my label', 'getter' => 'getFoo', 'sort_on' => 'foo', 'sortOn' => 'foo', 'dbType' => 'text', 'formType' => 'choices', 'formOptions' => array('foo' => 'bar'), 'filterType' => 'choice', 'filterOptions' => array('bar' => 'foo'));
     $column = new Column("test", false);
     foreach ($options as $option => $value) {
         $column->setProperty($option, $value);
         $this->assertEquals($value, call_user_func_array(array($column, 'get' . Inflector::classify($option)), array()));
     }
 }
开发者ID:Restless-ET,项目名称:GeneratorBundle,代码行数:9,代码来源:ColumnTest.php

示例9: setProperty

 public function setProperty($option, $value)
 {
     $setter = 'set' . Inflector::classify($option);
     if (method_exists($this, $setter)) {
         call_user_func_array(array($this, 'set' . $option), array($value));
     } else {
         throw new InvalidOptionException($option, $this->name, $this->debug['generator'], $this->debug['builder']);
     }
 }
开发者ID:kmehmety,项目名称:GeneratorBundle,代码行数:9,代码来源:Column.php

示例10: offsetGet

 public function offsetGet($offset)
 {
     $method = Inflector::classify($offset);
     if (method_exists($this, "get{$method}")) {
         return $this->{"get{$method}"}();
     } elseif (method_exists($this, "is{$method}")) {
         return $this->{"is{$method}"}();
     }
 }
开发者ID:noadless,项目名称:ec-cube,代码行数:9,代码来源:AbstractEntity.php

示例11: testSetOption

 public function testSetOption()
 {
     $from_to_array = array('name' => 'Name', 'underscored_name' => 'Underscored name');
     $options = array('label' => 'my label', 'getter' => 'getFoo', 'sort_on' => 'foo', 'sortOn' => 'foo', 'dbType' => 'text', 'formType' => 'choices', 'formOptions' => array('foo' => 'bar'));
     $column = new Column($from_to_array);
     foreach ($options as $option => $value) {
         $column->setOption($option, $value);
         $this->assertEquals($value, call_user_func_array(array($column, 'get' . Inflector::classify($option)), array()));
     }
 }
开发者ID:norfil,项目名称:AdmingeneratorGeneratorBundle,代码行数:10,代码来源:ColumnTest.php

示例12: getRelation

 protected function getRelation($fieldName, $class = null)
 {
     $table = $this->getMetadatas($class);
     foreach ($table->getRelations() as $relation) {
         if (Inflector::classify($fieldName) == $relation->getName()) {
             return $relation;
         }
     }
     return false;
 }
开发者ID:norfil,项目名称:AdmingeneratorGeneratorBundle,代码行数:10,代码来源:PropelORMFieldGuesser.php

示例13: init

 /**
  * Initialises the controller.
  */
 public function init()
 {
     /** @var \BedRest\Framework\Zend1\Container _bedRest */
     $this->_bedRest = $this->getFrontController()->getParam('bootstrap')->getResource('bedrest');
     $this->_bedRestRequest = new Request();
     $this->_bedRestRequest->setResource(Inflector::classify($this->getRequest()->getControllerName()));
     $routeComponents = array('identifier' => $this->_getParam('id'));
     $this->_bedRestRequest->setRouteComponents($routeComponents);
     $data = file_get_contents('php://input');
     $this->_bedRestRequest->setRawBody($data);
     $this->_helper->ViewRenderer->setNoRender(true);
 }
开发者ID:bedrest,项目名称:framework-zendframework1,代码行数:15,代码来源:Resource.php

示例14: compareValues

 /**
  * @param Object $object
  * @param array $valuesToCompare
  */
 public static function compareValues($object, $valuesToCompare)
 {
     foreach ($valuesToCompare as $key => $value) {
         $method = 'get' . Inflector::classify($key);
         if (method_exists($object, $method)) {
             if ($value != $object->{$method}()) {
                 return false;
             }
         }
     }
     return (bool) $valuesToCompare;
 }
开发者ID:l3l0,项目名称:php-travis-client,代码行数:16,代码来源:BuildUtil.php

示例15: extractClassMetadata

 /**
  *
  * @param  string $className
  * @return ClassMetadata
  */
 protected function extractClassMetadata($className)
 {
     $driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->_sm);
     foreach ($driver->getAllClassNames() as $dbTableName) {
         if (strtolower(Inflector::classify($dbTableName)) != strtolower($className)) {
             continue;
         }
         $class = new ClassMetadataInfo($dbTableName);
         $driver->loadMetadataForClass($dbTableName, $class);
         return $class;
     }
     $this->fail("No class matching the name '" . $className . "' was found!");
 }
开发者ID:rishta,项目名称:doctrine2,代码行数:18,代码来源:DatabaseDriverTest.php


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