本文整理汇总了PHP中Magento\Framework\Stdlib\StringUtils::upperCaseWords方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtils::upperCaseWords方法的具体用法?PHP StringUtils::upperCaseWords怎么用?PHP StringUtils::upperCaseWords使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Stdlib\StringUtils
的用法示例。
在下文中一共展示了StringUtils::upperCaseWords方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getType
/**
* Get attribute type based on its backend model.
*
* @param \Magento\Eav\Api\Data\AttributeInterface $attribute
* @param string $serviceClass
* @param $serviceBackendModelDataInterfaceMap array
* @return string|null
*/
public function getType($attribute, $serviceClass, $serviceBackendModelDataInterfaceMap)
{
$backendModel = $attribute->getBackendModel();
//If empty backend model, check if it can be derived
if (empty($backendModel)) {
$backendModelClass = sprintf('Magento\\Eav\\Model\\Attribute\\Data\\%s', $this->stringUtility->upperCaseWords($attribute->getFrontendInput()));
$backendModel = class_exists($backendModelClass) ? $backendModelClass : null;
}
$dataInterface = isset($serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel]) ? $serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel] : null;
return $dataInterface;
}
示例2: getVariable
/**
* Return variable value for var construction
*
* @param string $value raw parameters
* @param string $default default value
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function getVariable($value, $default = '{no_value_defined}')
{
\Magento\Framework\Profiler::start('email_template_processing_variables');
$tokenizer = new Template\Tokenizer\Variable();
$tokenizer->setString($value);
$stackVars = $tokenizer->tokenize();
$result = $default;
$last = 0;
for ($i = 0; $i < count($stackVars); $i++) {
if ($i == 0 && isset($this->templateVars[$stackVars[$i]['name']])) {
// Getting of template value
$stackVars[$i]['variable'] =& $this->templateVars[$stackVars[$i]['name']];
} elseif (isset($stackVars[$i - 1]['variable']) && $stackVars[$i - 1]['variable'] instanceof \Magento\Framework\DataObject) {
// If object calling methods or getting properties
if ($stackVars[$i]['type'] == 'property') {
$caller = 'get' . $this->string->upperCaseWords($stackVars[$i]['name'], '_', '');
$stackVars[$i]['variable'] = method_exists($stackVars[$i - 1]['variable'], $caller) ? $stackVars[$i - 1]['variable']->{$caller}() : $stackVars[$i - 1]['variable']->getData($stackVars[$i]['name']);
} elseif ($stackVars[$i]['type'] == 'method') {
// Calling of object method
if (method_exists($stackVars[$i - 1]['variable'], $stackVars[$i]['name']) || substr($stackVars[$i]['name'], 0, 3) == 'get') {
$stackVars[$i]['args'] = $this->getStackArgs($stackVars[$i]['args']);
$stackVars[$i]['variable'] = call_user_func_array([$stackVars[$i - 1]['variable'], $stackVars[$i]['name']], $stackVars[$i]['args']);
}
}
$last = $i;
}
}
if (isset($stackVars[$last]['variable'])) {
// If value for construction exists set it
$result = $stackVars[$last]['variable'];
}
\Magento\Framework\Profiler::stop('email_template_processing_variables');
return $result;
}
示例3: _saveSection
/**
* Custom save logic for section
*
* @return void
*/
protected function _saveSection()
{
$method = '_save' . $this->string->upperCaseWords($this->getRequest()->getParam('section'), '_', '');
if (method_exists($this, $method)) {
$this->{$method}();
}
}
示例4: create
/**
* Create Form Element
*
* @param \Magento\Customer\Api\Data\AttributeMetadataInterface $attribute
* @param string|int|bool $value
* @param string $entityTypeCode
* @param bool $isAjax
* @return \Magento\Customer\Model\Metadata\Form\AbstractData
*/
public function create(\Magento\Customer\Api\Data\AttributeMetadataInterface $attribute, $value, $entityTypeCode, $isAjax = false)
{
$dataModelClass = $attribute->getDataModel();
$params = ['entityTypeCode' => $entityTypeCode, 'value' => is_null($value) ? false : $value, 'isAjax' => $isAjax, 'attribute' => $attribute];
/** TODO fix when Validation is implemented MAGETWO-17341 */
if ($dataModelClass == 'Magento\\Customer\\Model\\Attribute\\Data\\Postcode') {
$dataModelClass = 'Magento\\Customer\\Model\\Metadata\\Form\\Postcode';
}
if (!empty($dataModelClass)) {
$dataModel = $this->_objectManager->create($dataModelClass, $params);
} else {
$dataModelClass = sprintf('Magento\\Customer\\Model\\Metadata\\Form\\%s', $this->_string->upperCaseWords($attribute->getFrontendInput()));
$dataModel = $this->_objectManager->create($dataModelClass, $params);
}
return $dataModel;
}
示例5: processMetadataContent
/**
* @param string $name
* @param string $content
* @return mixed
*/
protected function processMetadataContent($name, $content)
{
$method = 'get' . $this->string->upperCaseWords($name, '_', '');
if (method_exists($this->pageConfig, $method)) {
$content = $this->pageConfig->{$method}();
}
return $content;
}
示例6: groupFactory
/**
* Group model factory
*
* @param string $type Option type
* @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
* @throws LocalizedException
*/
public function groupFactory($type)
{
$group = $this->getGroupByType($type);
if (!empty($group)) {
return $this->_optionFactory->create('Magento\\Catalog\\Model\\Product\\Option\\Type\\' . $this->string->upperCaseWords($group));
}
throw new LocalizedException(__('The option type to get group instance is incorrect.'));
}
示例7: getType
/**
* {@inheritdoc}
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function getType($attributeCode, $serviceClass)
{
if (!$serviceClass || !$attributeCode || !isset($this->serviceEntityTypeMap[$serviceClass]) || !isset($this->serviceBackendModelDataInterfaceMap[$serviceClass])) {
return null;
}
try {
$attribute = $this->attributeRepository->get($this->serviceEntityTypeMap[$serviceClass], $attributeCode);
$backendModel = $attribute->getBackendModel();
} catch (NoSuchEntityException $e) {
return null;
}
//If empty backend model, check if it can be derived
if (empty($backendModel)) {
$backendModelClass = sprintf('Magento\\Eav\\Model\\Attribute\\Data\\%s', $this->stringUtility->upperCaseWords($attribute->getFrontendInput()));
$backendModel = class_exists($backendModelClass) ? $backendModelClass : null;
}
$dataInterface = isset($this->serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel]) ? $this->serviceBackendModelDataInterfaceMap[$serviceClass][$backendModel] : null;
return $dataInterface;
}
示例8: setOptions
/**
* Set many options at once
*
* @param array $options
* @param array $default
* @return $this
*/
public function setOptions($options, $default = [])
{
$options = !is_array($options) && !$options instanceof \Traversable ? $default : $options;
if (is_array($options) || $options instanceof \Traversable) {
foreach ($options as $option => $value) {
$setter = 'set' . $this->_stringHelper->upperCaseWords($option, '_', '');
if (method_exists($this, $setter)) {
$this->{$setter}($value);
} else {
$this->setOption($option, $value);
}
}
}
return $this;
}
示例9: create
/**
* Return attribute data model by attribute
* Set entity to data model (need for work)
*
* @param \Magento\Eav\Model\Attribute $attribute
* @param \Magento\Framework\Model\AbstractModel $entity
* @return \Magento\Eav\Model\Attribute\Data\AbstractData
*/
public function create(\Magento\Eav\Model\Attribute $attribute, \Magento\Framework\Model\AbstractModel $entity)
{
/* @var $dataModel \Magento\Eav\Model\Attribute\Data\AbstractData */
$dataModelClass = $attribute->getDataModel();
if (!empty($dataModelClass)) {
if (empty($this->_dataModels[$dataModelClass])) {
$dataModel = $this->_objectManager->create($dataModelClass);
$this->_dataModels[$dataModelClass] = $dataModel;
} else {
$dataModel = $this->_dataModels[$dataModelClass];
}
} else {
if (empty($this->_dataModels[$attribute->getFrontendInput()])) {
$dataModelClass = sprintf('Magento\\Eav\\Model\\Attribute\\Data\\%s', $this->string->upperCaseWords($attribute->getFrontendInput()));
$dataModel = $this->_objectManager->create($dataModelClass);
$this->_dataModels[$attribute->getFrontendInput()] = $dataModel;
} else {
$dataModel = $this->_dataModels[$attribute->getFrontendInput()];
}
}
$dataModel->setAttribute($attribute);
$dataModel->setEntity($entity);
return $dataModel;
}
示例10: testUpperCaseWordsWithSeparators
/**
* @param string $testString
* @param string $sourceSeparator
* @param string $destinationSeparator
* @param string $expected
*
* @dataProvider upperCaseWordsWithSeparatorsDataProvider
*/
public function testUpperCaseWordsWithSeparators($testString, $sourceSeparator, $destinationSeparator, $expected)
{
$actual = $this->_string->upperCaseWords($testString, $sourceSeparator, $destinationSeparator);
$this->assertEquals($expected, $actual);
}