本文整理汇总了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);
}
示例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;
}
}
示例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];
}
示例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.");
}
示例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;
}
}
示例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);
}
}
}
}
}
示例7: transformName
/**
* {@inheritdoc}
*/
public function transformName($name)
{
if ($this->ucFirst) {
return Inflector::classify($name);
} else {
return Inflector::camelize($name);
}
}
示例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()));
}
}
示例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']);
}
}
示例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}"}();
}
}
示例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()));
}
}
示例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;
}
示例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);
}
示例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;
}
示例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!");
}