本文整理汇总了PHP中StringUtil::camelize方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::camelize方法的具体用法?PHP StringUtil::camelize怎么用?PHP StringUtil::camelize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::camelize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCamelize
public function testCamelize()
{
$this->assertThat(StringUtil::camelize('word'), $this->equalTo('Word'));
$this->assertThat(StringUtil::camelize('main-controller'), $this->equalTo('MainController'));
$this->assertThat(StringUtil::camelize('main_controller_class'), $this->equalTo('MainControllerClass'));
$this->assertThat(StringUtil::camelize('some undefined words'), $this->equalTo('SomeUndefinedWords'));
}
示例2: renderFile
public function renderFile()
{
if ($this->oJournalComment === null) {
throw new Exception('Hash invalid');
}
JournalCommentPeer::ignoreRights(true);
$sAction = StringUtil::camelize("comment_{$this->sAction}");
$this->{$sAction}();
echo TranslationPeer::getString("journal_comment.executed_{$this->sAction}", null, 'done');
}
示例3: smarty_function_selectmodobject
/**
* render plugin for fetching a particular module object
*
* Examples
* {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
* {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
* {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
*
* Parameters:
* module Name of the module storing the desired object (in DBObject mode)
* objecttype Name of object type (in DBObject mode)
* recordClass Class name of an doctrine record. (in Doctrine mode)
* id Identifier of desired object
* prefix Optional prefix for class names (defaults to PN) (in DBObject mode)
* assign Name of the returned object
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return void
*/
function smarty_function_selectmodobject($params, Zikula_View $view)
{
if (isset($params['recordClass']) && !empty($params['recordClass'])) {
$doctrineMode = true;
} else {
// DBObject checks
if (!isset($params['module']) || empty($params['module'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
}
if (!isset($params['objecttype']) || empty($params['objecttype'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
}
if (!isset($params['prefix'])) {
$params['prefix'] = 'PN';
}
$doctrineMode = false;
}
if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
}
if (!isset($params['assign']) || empty($params['assign'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
}
// load object depending on mode: doctrine or dbobject
if (!$doctrineMode) {
if (!ModUtil::available($params['module'])) {
$view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
}
ModUtil::dbInfoLoad($params['module']);
$class = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
// intantiate object model
$object = new $class();
$idField = $object->getIDField();
// assign object data
// this performs a new database select operation
// while the result will be saved within the object, we assign it to a local variable for convenience
$objectData = $object->get(intval($params['id']), $idField);
if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
$view->trigger_error(__('Sorry! No such item found.'));
}
} else {
if ($params['recordClass'] instanceof \Doctrine_Record) {
$objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
if ($objectData === false) {
$view->trigger_error(__('Sorry! No such item found.'));
}
} else {
/** @var $em Doctrine\ORM\EntityManager */
$em = \ServiceUtil::get('doctrine.entitymanager');
$result = $em->getRepository($params['recordClass'])->find($params['id']);
$objectData = $result->toArray();
}
}
$view->assign($params['assign'], $objectData);
}
示例4: smarty_function_selectmodobject
/**
* render plugin for fetching a particular module object
*
* Examples
* {selectmodobject module="AutoCustomer" objecttype="customer" id=4 assign="myCustomer"}
* {selectmodobject module="AutoCocktails" objecttype="recipe" id=12 assign="myRecipe"}
* {selectmodobject recordClass="AutoCocktails_Model_Recipe" id=12 assign="myRecipe"}
*
* Parameters:
* module Name of the module storing the desired object (in DBObject mode)
* objecttype Name of object type (in DBObject mode)
* recordClass Class name of an doctrine record. (in Doctrine mode)
* id Identifier of desired object
* prefix Optional prefix for class names (defaults to PN) (in DBObject mode)
* assign Name of the returned object
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return void
*/
function smarty_function_selectmodobject($params, Zikula_View $view)
{
if (isset($params['recordClass']) && !empty($params['recordClass'])) {
$doctrineMode = true;
} else {
// DBObject checks
if (!isset($params['module']) || empty($params['module'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'module')));
}
if (!isset($params['objecttype']) || empty($params['objecttype'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'objecttype')));
}
if (!isset($params['prefix'])) {
$params['prefix'] = 'PN';
}
$doctrineMode = false;
}
if (!isset($params['id']) || empty($params['id']) || !is_numeric($params['id'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'id')));
}
if (!isset($params['assign']) || empty($params['assign'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobject', 'assign')));
}
// load object depending on mode: doctrine or dbobject
if (!$doctrineMode) {
if (!ModUtil::available($params['module'])) {
$view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobject')));
}
ModUtil::dbInfoLoad($params['module']);
$classname = "{$params['module']}_DBObject_" . StringUtil::camelize($params['objecttype']);
if (!class_exists($classname) && System::isLegacyMode()) {
// BC check for PNObject old style.
// load the object class corresponding to $params['objecttype']
if (!($class = Loader::loadClassFromModule($params['module'], $params['objecttype'], false, false, $params['prefix']))) {
z_exit(__f('Unable to load class [%s] for module [%s]', array(DataUtil::formatForDisplay($params['objecttype']), DataUtil::formatForDisplay($params['module']))));
}
}
// intantiate object model
$object = new $class();
$idField = $object->getIDField();
// assign object data
// this performs a new database select operation
// while the result will be saved within the object, we assign it to a local variable for convenience
$objectData = $object->get(intval($params['id']), $idField);
if (!is_array($objectData) || !isset($objectData[$idField]) || !is_numeric($objectData[$idField])) {
$view->trigger_error(__('Sorry! No such item found.'));
}
} else {
$objectData = Doctrine_Core::getTable($params['recordClass'])->find($params['id']);
if ($objectData === false) {
$view->trigger_error(__('Sorry! No such item found.'));
}
}
$view->assign($params['assign'], $objectData);
}
示例5: may
public function may($mPage, $sRightName, $bInheritedOnly = false)
{
$sRightName = "getMay" . StringUtil::camelize($sRightName, true);
$aRights = $this->getRights();
foreach ($aRights as $oRight) {
if ($bInheritedOnly && !$oRight->getIsInherited()) {
continue;
}
if ($oRight->rightFits($mPage, $sRightName)) {
return true;
}
}
return false;
}
示例6: getFileName
public function getFileName($name)
{
return StringUtil::camelize($name);
}
示例7: isValidModuleClassName
public static function isValidModuleClassName($sName)
{
return StringUtil::endsWith($sName, StringUtil::camelize(self::getType(), true) . "Module");
}
示例8: smarty_function_selectmodobjectarray
/**
* render plugin for fetching a list of module objects
*
* Examples
* {selectmodobjectarray module="AutoCustomer" objecttype="customer" assign="myCustomers"}
* {selectmodobjectarray module="AutoCocktails" objecttype="recipe" orderby="name desc" assign="myRecipes"}
* {selectmodobjectarray recordClass="AutoCocktails_Model_Recipe" orderby="name desc" assign="myRecipes"}
*
* Parameters:
* module Name of the module storing the desired object (in DBObject mode)
* objecttype Name of object type (in DBObject mode)
* recordClass Class name of an doctrine record. (in Doctrine mode)
* useArrays true to fetch arrays and false to fetch objects (default is true) (in Doctrine mode)
* where Filter value
* orderby Sorting field and direction
* pos Start offset
* num Amount of selected objects
* prefix Optional prefix for class names (defaults to PN) (in DBObject mode)
* assign Name of the returned object
*
* @param array $params All attributes passed to this function from the template.
* @param Zikula_View $view Reference to the Zikula_View object.
*
* @return void
*/
function smarty_function_selectmodobjectarray($params, Zikula_View $view)
{
if (isset($params['recordClass']) && !empty($params['recordClass'])) {
$doctrineMode = true;
} else {
// DBObject checks
if (!isset($params['module']) || empty($params['module'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobjectarray', 'module')));
}
if (!isset($params['objecttype']) || empty($params['objecttype'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobjectarray', 'objecttype')));
}
if (!isset($params['prefix'])) {
$params['prefix'] = 'PN';
}
$doctrineMode = false;
}
if (!isset($params['assign'])) {
$view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('selectmodobjectarray', 'assign')));
}
// load object depending on mode: doctrine or dbobject
if (!$doctrineMode) {
if (!ModUtil::available($params['module'])) {
$view->trigger_error(__f('Invalid %1$s passed to %2$s.', array('module', 'selectmodobjectarray')));
}
$classname = "{$params['module']}\\DBObject\\" . StringUtil::camelize($params['objecttype']) . 'Array';
// instantiate the object-array
$objectArray = new $classname();
// convenience vars to make code clearer
$where = $sort = '';
if (isset($params['where']) && !empty($params['where'])) {
$where = $params['where'];
}
// TODO: add FilterUtil support here in 2.0
if (isset($params['orderby']) && !empty($params['orderby'])) {
$sort = $params['orderby'];
}
$pos = 1;
if (isset($params['pos']) && !empty($params['pos']) && is_numeric($params['pos'])) {
$pos = $params['pos'];
}
$num = 10;
if (isset($params['num']) && !empty($params['num']) && is_numeric($params['num'])) {
$num = $params['num'];
}
// get() returns the cached object fetched from the DB during object instantiation
// get() with parameters always performs a new select
// while the result will be saved in the object, we assign in to a local variable for convenience.
$objectData = $objectArray->get($where, $sort, $pos - 1, $num);
} else {
$query = Doctrine_Core::getTable($params['recordClass'])->createQuery();
if (isset($params['where']) && !empty($params['where'])) {
if (is_array($params['where'])) {
$query->where($params['where'][0], $params['where'][1]);
} else {
$query->where($params['where']);
}
}
if (isset($params['orderby']) && !empty($params['orderby'])) {
$query->orderBy($params['orderby']);
}
$pos = 0;
if (isset($params['pos']) && !empty($params['pos']) && is_numeric($params['pos'])) {
$pos = $params['pos'];
}
$num = 10;
if (isset($params['num']) && !empty($params['num']) && is_numeric($params['num'])) {
$num = $params['num'];
}
$query->offset($pos);
$query->limit($num);
if (isset($params['useArrays']) && !$params['useArrays']) {
$objectData = $query->execute();
} else {
$objectData = $query->fetchArray();
//.........这里部分代码省略.........
示例9: testCamelize
public function testCamelize()
{
$this->assertSame('HogeFuga', StringUtil::camelize('hoge_fuga'));
}
示例10: insertRow
public static function insertRow($aArrayOfValues)
{
$oDocumentType = new DocumentType();
foreach ($aArrayOfValues as $sFieldName => $mValue) {
$sMethodName = 'set' . StringUtil::camelize($sFieldName, true);
$mValue = $mValue === true ? 1 : $mValue;
$oDocumentType->{$sMethodName}($mValue);
}
$oDocumentType->save();
}
示例11: getOption
public function getOption($sName)
{
$sName = 'get' . StringUtil::camelize($sName, true);
$aArgs = func_get_args();
return call_user_func_array(array($this->oDelegate, $sName), array_splice($aArgs, 1));
}
示例12: resolveFunctionNameFromTemplateName
protected function resolveFunctionNameFromTemplateName($name)
{
preg_match("~^(\\d+)~", $name, $columnCount);
// Not Coding Standard
if (isset($columnCount[1])) {
$columnCount = NumberToWordsUtil::convert($columnCount[1]);
$name = strtolower($columnCount . substr($name, strlen($columnCount[1])));
}
$name = 'make ' . strtolower($name);
$name = preg_replace('/[^a-z ]/', '', $name);
$name = StringUtil::camelize($name, false, ' ');
return $name;
}
示例13: getSelector_ObjectArray
/**
* Creates an object array selector.
*
* @param string $modname Module name.
* @param string $objectType Object type.
* @param string $name Select field name.
* @param string $field Value field.
* @param string $displayField Display field.
* @param string $where Where clause.
* @param string $sort Sort clause.
* @param string $selectedValue Selected value.
* @param string $defaultValue Value for "default" option.
* @param string $defaultText Text for "default" option.
* @param string $allValue Value for "all" option.
* @param string $allText Text for "all" option.
* @param string $displayField2 Second display field.
* @param boolean $submit Submit on choose.
* @param boolean $disabled Add Disabled attribute to select.
* @param string $fieldSeparator Field seperator if $displayField2 is given.
* @param integer $multipleSize Size for multiple selects.
*
* @return string The rendered output.
*/
public static function getSelector_ObjectArray($modname, $objectType, $name, $field = '', $displayField = 'name', $where = '', $sort = '', $selectedValue = '', $defaultValue = 0, $defaultText = '', $allValue = 0, $allText = '', $displayField2 = null, $submit = true, $disabled = false, $fieldSeparator = ', ', $multipleSize = 1)
{
if (!$modname) {
return z_exit(__f('Invalid %1$s passed to %2$s.', array('modname', 'HtmlUtil::getSelector_ObjectArray')));
}
if (!$objectType) {
return z_exit(__f('Invalid %1$s passed to %2$s.', array('objectType', 'HtmlUtil::getSelector_ObjectArray')));
}
if (!ModUtil::dbInfoLoad($modname)) {
return __f('Unavailable/Invalid %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_ObjectArray'));
}
if (!SecurityUtil::checkPermission("{$objectType}::", '::', ACCESS_OVERVIEW)) {
return __f('Security check failed for %1$s [%2$s] passed to %3$s.', array('modulename', $modname, 'HtmlUtil::getSelector_ObjectArray'));
}
$cacheKey = md5("{$modname}|{$objectType}|{$where}|{$sort}");
if (isset($cache[$cacheKey])) {
$dataArray = $cache[$cacheKey];
} else {
$classname = "{$modname}\\DBObject\\" . StringUtil::camelize($objectType) . 'Array';
$class = new $classname();
//$dataArray = $class->get($where, $sort, -1, -1, '', false, $distinct);
$dataArray = $class->get($where, $sort, -1, -1, '', false);
$cache[$cacheKey] = $dataArray;
if (!$field) {
$field = $class->_objField;
}
}
$data2 = array();
foreach ($dataArray as $object) {
$val = $object[$field];
$disp = $object[$displayField];
if ($displayField2) {
$disp .= $fieldSeparator . $object[$displayField2];
}
$data2[$val] = $disp;
}
return self::getSelector_Generic($name, $data2, $selectedValue, $defaultValue, $defaultText, $allValue, $allText, $submit, $disabled, $multipleSize);
}
示例14: getName
public function getName($name)
{
$camelized = StringUtil::camelize($name);
return lcfirst($camelized) . 'Action';
}
示例15: doIndex
public static function doIndex($sPageType, NavigationItem $oNavigationItem)
{
$sPageType = StringUtil::camelize($sPageType . '_page_type_module', true);
if (method_exists($sPageType, 'doIndex') && $sPageType::doIndex($oNavigationItem) === false) {
return false;
}
return true;
}