本文整理汇总了PHP中Doctrine\Common\Inflector\Inflector::camelize方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::camelize方法的具体用法?PHP Inflector::camelize怎么用?PHP Inflector::camelize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Inflector\Inflector
的用法示例。
在下文中一共展示了Inflector::camelize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postPersist
public function postPersist(LifecycleEventArgs $event)
{
/** @var OroEntityManager $em */
$em = $event->getEntityManager();
$entity = $event->getEntity();
$configProvider = $em->getExtendManager()->getConfigProvider();
$className = get_class($entity);
if ($configProvider->hasConfig($className)) {
$config = $configProvider->getConfig($className);
$schema = $config->get('schema');
if (isset($schema['relation'])) {
foreach ($schema['relation'] as $fieldName) {
/** @var Config $fieldConfig */
$fieldConfig = $configProvider->getConfig($className, $fieldName);
if ($fieldConfig->getId()->getFieldType() == 'optionSet' && ($setData = $entity->{Inflector::camelize('get_' . $fieldName)}())) {
$model = $configProvider->getConfigManager()->getConfigFieldModel($fieldConfig->getId()->getClassName(), $fieldConfig->getId()->getFieldName());
/**
* in case of single select field type, should wrap value in array
*/
if ($setData && !is_array($setData)) {
$setData = [$setData];
}
foreach ($setData as $option) {
$optionSetRelation = new OptionSetRelation();
$optionSetRelation->setData(null, $entity->getId(), $model, $em->getRepository(OptionSet::ENTITY_NAME)->find($option));
$em->persist($optionSetRelation);
$this->needFlush = true;
}
}
}
}
}
}
示例2: theFollowingEntitiesExist
/**
* @Given the following :entityName entities exist:
*/
public function theFollowingEntitiesExist($entityName, TableNode $table)
{
/** @var EntityManager $doctrine */
$doctrine = $this->get('doctrine')->getManager();
$meta = $doctrine->getClassMetadata($entityName);
$rows = [];
$hash = $table->getHash();
foreach ($hash as $row) {
$id = $row['id'];
unset($row['id']);
foreach ($row as $property => &$value) {
$propertyName = Inflector::camelize($property);
$fieldType = $meta->getTypeOfField($propertyName);
switch ($fieldType) {
case 'array':
case 'json_array':
$value = json_decode($value, true);
break;
case 'datetime':
$value = new \DateTime($value);
break;
}
}
$rows[$id] = $row;
}
$this->persistEntities($entityName, $rows);
}
示例3: fromArray
/**
* @param array $data
*/
public function fromArray(array $data)
{
foreach ($data as $key => $value) {
$property = Inflector::camelize($key);
$this->{$property} = $value;
}
}
示例4: create
public static function create(DeclareSchema $schema, $baseClass)
{
$cTemplate = new ClassFile($schema->getBaseModelClass());
$cTemplate->addConsts(array('schema_proxy_class' => $schema->getSchemaProxyClass(), 'collection_class' => $schema->getCollectionClass(), 'model_class' => $schema->getModelClass(), 'table' => $schema->getTable(), 'read_source_id' => $schema->getReadSourceId(), 'write_source_id' => $schema->getWriteSourceId(), 'primary_key' => $schema->primaryKey));
$cTemplate->addMethod('public', 'getSchema', [], ['if ($this->_schema) {', ' return $this->_schema;', '}', 'return $this->_schema = \\LazyRecord\\Schema\\SchemaLoader::load(' . var_export($schema->getSchemaProxyClass(), true) . ');']);
$cTemplate->addStaticVar('column_names', $schema->getColumnNames());
$cTemplate->addStaticVar('column_hash', array_fill_keys($schema->getColumnNames(), 1));
$cTemplate->addStaticVar('mixin_classes', array_reverse($schema->getMixinSchemaClasses()));
if ($traitClasses = $schema->getModelTraitClasses()) {
foreach ($traitClasses as $traitClass) {
$cTemplate->useTrait($traitClass);
}
}
$cTemplate->extendClass('\\' . $baseClass);
// interfaces
if ($ifs = $schema->getModelInterfaces()) {
foreach ($ifs as $iface) {
$cTemplate->implementClass($iface);
}
}
// Create column accessor
if ($schema->enableColumnAccessors) {
foreach ($schema->getColumnNames() as $columnName) {
$accessorMethodName = 'get' . ucfirst(Inflector::camelize($columnName));
$cTemplate->addMethod('public', $accessorMethodName, [], ['if (isset($this->_data[' . var_export($columnName, true) . '])) {', ' return $this->_data[' . var_export($columnName, true) . '];', '}']);
}
}
return $cTemplate;
}
示例5: getStructureMetadata
/**
* {@inheritDoc}
*/
public function getStructureMetadata($type, $structureType = null)
{
$cacheKey = $type . $structureType;
if (isset($this->cache[$cacheKey])) {
return $this->cache[$cacheKey];
}
$this->assertExists($type);
if (!$structureType) {
$structureType = $this->getDefaultStructureType($type);
}
if (!is_string($structureType)) {
throw new \InvalidArgumentException(sprintf('Expected string for structureType, got: %s', is_object($structureType) ? get_class($structureType) : gettype($structureType)));
}
$cachePath = sprintf('%s/%s%s', $this->cachePath, Inflector::camelize($type), Inflector::camelize($structureType));
$cache = new ConfigCache($cachePath, $this->debug);
if ($this->debug || !$cache->isFresh()) {
$paths = $this->getPaths($type);
// reverse paths, so that the last path overrides previous ones
$fileLocator = new FileLocator(array_reverse($paths));
try {
$filePath = $fileLocator->locate(sprintf('%s.xml', $structureType));
} catch (\InvalidArgumentException $e) {
throw new Exception\StructureTypeNotFoundException(sprintf('Could not load structure type "%s" for document type "%s", looked in "%s"', $structureType, $type, implode('", "', $paths)), null, $e);
}
$metadata = $this->loader->load($filePath, $type);
$resources = [new FileResource($filePath)];
$cache->write(sprintf('<?php $metadata = \'%s\';', serialize($metadata)), $resources);
}
require $cachePath;
$structure = unserialize($metadata);
$this->cache[$cacheKey] = $structure;
return $structure;
}
示例6: buildForm
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('added', 'oro_entity_identifier', array('class' => $options['class'], 'multiple' => true))->add('removed', 'oro_entity_identifier', array('class' => $options['class'], 'multiple' => true));
if ($options['extend']) {
$em = $this->entityManager;
$class = $options['class'];
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use($em, $class) {
$data = $event->getData();
$repository = $em->getRepository($class);
$targetData = $event->getForm()->getParent()->getData();
$fieldName = $event->getForm()->getName();
foreach (explode(',', $data['added']) as $id) {
$entity = $repository->find($id);
if ($entity) {
$targetData->{Inflector::camelize('add_' . $fieldName)}($entity);
}
}
foreach (explode(',', $data['removed']) as $id) {
$entity = $repository->find($id);
if ($entity) {
$targetData->{Inflector::camelize('remove_' . $fieldName)}($entity);
}
}
});
}
}
示例7: generateDocParameter
/**
* {@inheritDoc}
*
* @param $parameter BodyParameter
*/
public function generateDocParameter($parameter, Context $context)
{
list($class, $array) = $this->getClass($parameter, $context);
if (null === $class) {
return sprintf('%s $%s %s', 'mixed', Inflector::camelize($parameter->getName()), $parameter->getDescription() ?: '');
}
return sprintf('%s $%s %s', $class, Inflector::camelize($parameter->getName()), $parameter->getDescription() ?: '');
}
示例8: testCreateDialect
/**
* @dataProvider providerCreateDialect
*/
public function testCreateDialect($method, $expected)
{
$dialect = call_user_func(array('\\CSanquer\\ColibriCsv\\Dialect', $method));
$this->assertInstanceOf('\\CSanquer\\ColibriCsv\\Dialect', $dialect);
foreach ($expected as $key => $value) {
$this->assertEquals($value, call_user_func(array($dialect, Inflector::camelize('get_' . $key))), 'the value is not the expected for the option ' . $key);
}
}
示例9: getRowValue
public function getRowValue($row, $key)
{
if (is_array($row)) {
return $row[$key];
}
$method = 'get' . Inflector::camelize($key);
$value = $row->{$method}();
return $value;
}
示例10: updateParentFields
/**
* @ORM\PrePersist
*/
public function updateParentFields()
{
if ($this->object->getLocale() == $this->locale) {
$method = Inflector::camelize('set' . ucfirst($this->field));
if (method_exists($this->object, $method)) {
$this->object->{$method}($this->getContent());
}
}
}
示例11: fromLine
/**
* @param string $line
*
* @return mixed
*
* @throws \Exception
*/
public static function fromLine($line, array $lineOptions)
{
$line = json_decode($line, true);
$method = Inflector::camelize($line['type']) . 'FromLine';
if (method_exists(get_class(new static()), $method) && $method !== 'FromLine') {
return static::$method($line, $lineOptions);
}
throw new \Exception('Unknown message type: ' . $line['type']);
}
示例12: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->commandParserChain->execute($input, $output);
$filename = sprintf('%s.json', Inflector::camelize(strtolower($this->collectionName)));
$filepath = $this->rootDir . '/../' . $filename;
file_put_contents($filepath, json_encode($this->normalizer->normalize($this->collectionGenerator->generate(), 'json')));
$text = sprintf('Postman collection has been successfully built in file %s.', $filename);
$output->writeln(['', $this->getHelperSet()->get('formatter')->formatBlock($text, 'bg=blue;fg=white', true), '']);
}
示例13: instantiate
public function instantiate(string $class, array $data)
{
$object = new $class();
foreach ($data as $key => $value) {
$property = Inflector::camelize($key);
$object->{$property} = $value;
}
return $object;
}
示例14: initializeAction
public function initializeAction(string $token)
{
$payment = $this->getManager()->findPaymentByToken($token);
$order = $payment->getOrder();
$processor = $this->getPaymentProcessor($order->getPaymentMethod()->getProcessor());
$processorName = ucfirst(Inflector::camelize($processor->getConfigurator()->getName()));
$content = $this->renderView(sprintf('WellCommercePaymentBundle:Front/%s:initialize.html.twig', $processorName), ['payment' => $payment]);
return new Response($content);
}
示例15: relation_maker
public function relation_maker($model_name, $relation_type)
{
return '
public function ' . ($relation_type == 'belongsTo' ? strtolower($model_name) : Inflector::pluralize(strtolower($model_name))) . '()
{
return $this->' . Inflector::camelize($relation_type) . '(\'App\\' . $model_name . '\');
}
';
}