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


PHP CRM_Utils_String::convertStringToCamel方法代码示例

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


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

示例1: documentMe

 /**
  * Create test generated example in api/v3/examples.
  *
  * To turn this off (e.g. on the server) set
  * define(DONT_DOCUMENT_TEST_CONFIG ,1);
  * in your settings file
  *
  * @param string $entity
  * @param string $action
  * @param array $params
  *   Array as passed to civicrm_api function.
  * @param array $result
  *   Array as received from the civicrm_api function.
  * @param string $testFunction
  *   Calling function - generally __FUNCTION__.
  * @param string $testFile
  *   Called from file - generally __FILE__.
  * @param string $description
  *   Descriptive text for the example file.
  * @param string $exampleName
  *   Name for this example file (CamelCase) - if omitted the action name will be substituted.
  */
 private function documentMe($entity, $action, $params, $result, $testFunction, $testFile, $description = "", $exampleName = NULL)
 {
     if (defined('DONT_DOCUMENT_TEST_CONFIG') && DONT_DOCUMENT_TEST_CONFIG) {
         return;
     }
     $entity = _civicrm_api_get_camel_name($entity);
     $action = strtolower($action);
     if (empty($exampleName)) {
         // Attempt to convert lowercase action name to CamelCase.
         // This is clunky/imperfect due to the convention of all lowercase actions.
         $exampleName = CRM_Utils_String::convertStringToCamel($action);
         $knownPrefixes = array('Get', 'Set', 'Create', 'Update', 'Send');
         foreach ($knownPrefixes as $prefix) {
             if (strpos($exampleName, $prefix) === 0 && $prefix != $exampleName) {
                 $exampleName[strlen($prefix)] = strtoupper($exampleName[strlen($prefix)]);
             }
         }
     }
     $this->tidyExampleResult($result);
     if (isset($params['version'])) {
         unset($params['version']);
     }
     // Format multiline description as array
     $desc = array();
     if (is_string($description) && strlen($description)) {
         foreach (explode("\n", $description) as $line) {
             $desc[] = trim($line);
         }
     }
     $smarty = CRM_Core_Smarty::singleton();
     $smarty->assign('testFunction', $testFunction);
     $smarty->assign('function', _civicrm_api_get_entity_name_from_camel($entity) . "_{$action}");
     $smarty->assign('params', $params);
     $smarty->assign('entity', $entity);
     $smarty->assign('testFile', basename($testFile));
     $smarty->assign('description', $desc);
     $smarty->assign('result', $result);
     $smarty->assign('action', $action);
     global $civicrm_root;
     if (file_exists($civicrm_root . '/tests/templates/documentFunction.tpl')) {
         if (!is_dir($civicrm_root . "/api/v3/examples/{$entity}")) {
             mkdir($civicrm_root . "/api/v3/examples/{$entity}");
         }
         $f = fopen($civicrm_root . "/api/v3/examples/{$entity}/{$exampleName}.php", "w+b");
         fwrite($f, $smarty->fetch($civicrm_root . '/tests/templates/documentFunction.tpl'));
         fclose($f);
     }
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:70,代码来源:CiviUnitTestCase.php

示例2: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     //@todo document the purpose of cdType (if still in use)
     if ($this->_cdType) {
         CRM_Custom_Form_CustomData::buildQuickForm($this);
         return;
     }
     $allPanes = array();
     //tax rate from financialType
     $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates()));
     $this->assign('currencies', json_encode(CRM_Core_OptionGroup::values('currencies_enabled')));
     // build price set form.
     $buildPriceSet = FALSE;
     $invoiceSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
     $this->assign('invoicing', $invoicing);
     // display tax amount on edit contribution page
     if ($invoicing && $this->_action & CRM_Core_Action::UPDATE && isset($this->_values['tax_amount'])) {
         $this->assign('totalTaxAmount', $this->_values['tax_amount']);
     }
     if (empty($this->_lineItems) && ($this->_priceSetId || !empty($_POST['price_set_id']))) {
         $buildPriceSet = TRUE;
         $getOnlyPriceSetElements = TRUE;
         if (!$this->_priceSetId) {
             $this->_priceSetId = $_POST['price_set_id'];
             $getOnlyPriceSetElements = FALSE;
         }
         $this->set('priceSetId', $this->_priceSetId);
         CRM_Price_BAO_PriceSet::buildPriceSet($this);
         // get only price set form elements.
         if ($getOnlyPriceSetElements) {
             return;
         }
     }
     // use to build form during form rule.
     $this->assign('buildPriceSet', $buildPriceSet);
     $showAdditionalInfo = FALSE;
     $defaults = $this->_values;
     $additionalDetailFields = array('note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', 'net_amount');
     foreach ($additionalDetailFields as $key) {
         if (!empty($defaults[$key])) {
             $defaults['hidden_AdditionalDetail'] = 1;
             break;
         }
     }
     if ($this->_productDAO) {
         if ($this->_productDAO->product_id) {
             $defaults['hidden_Premium'] = 1;
         }
     }
     if ($this->_noteID && isset($this->_values['note'])) {
         $defaults['hidden_AdditionalDetail'] = 1;
     }
     $paneNames = array(ts('Additional Details') => 'AdditionalDetail');
     //Add Premium pane only if Premium is exists.
     $dao = new CRM_Contribute_DAO_Product();
     $dao->is_active = 1;
     if ($dao->find(TRUE)) {
         $paneNames[ts('Premium Information')] = 'Premium';
     }
     $billingPanes = array();
     if ($this->_mode) {
         if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE) == TRUE) {
             $buildRecurBlock = TRUE;
             foreach ($this->billingPane as $name => $label) {
                 if (!empty($this->billingFieldSets[$name]['fields'])) {
                     // @todo reduce variation so we don't have to convert 'credit_card' to 'CreditCard'
                     $billingPanes[$label] = $this->generatePane(CRM_Utils_String::convertStringToCamel($name), $defaults);
                 }
             }
         }
     }
     foreach ($paneNames as $name => $type) {
         $allPanes[$name] = $this->generatePane($type, $defaults);
     }
     if (empty($this->_recurPaymentProcessors)) {
         $buildRecurBlock = FALSE;
     }
     if ($buildRecurBlock) {
         CRM_Contribute_Form_Contribution_Main::buildRecur($this);
         $this->setDefaults(array('is_recur' => 0));
     }
     $this->assign('buildRecurBlock', $buildRecurBlock);
     $qfKey = $this->controller->_key;
     $this->assign('qfKey', $qfKey);
     $this->assign('billingPanes', $billingPanes);
     $this->assign('allPanes', $allPanes);
     $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this);
     if ($this->_formType) {
         $this->assign('formType', $this->_formType);
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     if ($this->_action & CRM_Core_Action::DELETE) {
         $this->addButtons(array(array('type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
         return;
     }
//.........这里部分代码省略.........
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:101,代码来源:Contribution.php

示例3: normalizeEntityName

 /**
  * Normalize/validate entity and action names
  *
  * @param string $entity
  * @param int $version
  * @return string
  * @throws \API_Exception
  */
 public static function normalizeEntityName($entity, $version)
 {
     if ($version <= 3) {
         // APIv1-v3 munges entity/action names, and accepts any mixture of case and underscores.
         // We normalize entity to be CamelCase.
         return \CRM_Utils_String::convertStringToCamel(\CRM_Utils_String::munge($entity));
     } else {
         // APIv4 requires exact spelling & capitalization of entity/action name; deviations should cause errors
         if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $entity)) {
             throw new \API_Exception("Malformed entity");
         }
         return $entity;
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:22,代码来源:Request.php

示例4: _civicrm_api_get_camel_name

/**
 * Get camel case version of entity name.
 *
 * @param string|null $entity
 *
 * @return string|null
 */
function _civicrm_api_get_camel_name($entity)
{
    return is_string($entity) ? CRM_Utils_String::convertStringToCamel($entity) : NULL;
}
开发者ID:kidaa30,项目名称:yes,代码行数:11,代码来源:api.php

示例5: normalizeEntityName

 /**
  * Normalize entity to be CamelCase.
  *
  * APIv1-v3 munges entity/action names, and accepts any mixture of case and underscores.
  *
  * @param string $entity
  * @param int $version
  * @return string
  */
 public static function normalizeEntityName($entity, $version)
 {
     return \CRM_Utils_String::convertStringToCamel(\CRM_Utils_String::munge($entity));
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:13,代码来源:Request.php

示例6: onApiAuthorize

 /**
  * @param \Civi\API\Event\AuthorizeEvent $event
  *   API authorization event.
  * @throws \API_Exception
  * @throws \Civi\API\Exception\UnauthorizedException
  */
 public function onApiAuthorize(\Civi\API\Event\AuthorizeEvent $event)
 {
     $apiRequest = $event->getApiRequest();
     if ($apiRequest['version'] == 3 && \CRM_Utils_String::convertStringToCamel($apiRequest['entity']) == $this->entityName && in_array(strtolower($apiRequest['action']), $this->actions)) {
         if (isset($apiRequest['params']['field_name'])) {
             $fldIdx = \CRM_Utils_Array::index(array('field_name'), $this->getCustomFields());
             if (empty($fldIdx[$apiRequest['params']['field_name']])) {
                 throw new \Exception("Failed to map custom field to entity table");
             }
             $apiRequest['params']['entity_table'] = $fldIdx[$apiRequest['params']['field_name']]['entity_table'];
             unset($apiRequest['params']['field_name']);
         }
         if (empty($apiRequest['params']['id']) && empty($apiRequest['params']['entity_table'])) {
             throw new \API_Exception("Mandatory key(s) missing from params array: 'id' or 'entity_table'");
         }
         if (isset($apiRequest['params']['id'])) {
             list($isValidId, $entityTable, $entityId) = $this->getDelegate($apiRequest['params']['id']);
             if ($isValidId && $entityTable && $entityId) {
                 $this->authorizeDelegate($apiRequest['action'], $entityTable, $entityId, $apiRequest);
                 $this->preventReassignment($apiRequest['params']['id'], $entityTable, $entityId, $apiRequest);
                 return;
             } elseif ($isValidId) {
                 throw new \API_Exception("Failed to match record to related entity");
             } elseif (!$isValidId && strtolower($apiRequest['action']) == 'get') {
                 // The matches will be an empty set; doesn't make a difference if we
                 // reject or accept.
                 // To pass SyntaxConformanceTest, we won't veto "get" on empty-set.
                 return;
             }
         }
         if (isset($apiRequest['params']['entity_table'])) {
             $this->authorizeDelegate($apiRequest['action'], $apiRequest['params']['entity_table'], \CRM_Utils_Array::value('entity_id', $apiRequest['params'], NULL), $apiRequest);
             return;
         }
         throw new \API_Exception("Failed to run permission check");
     }
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:43,代码来源:DynamicFKAuthorization.php

示例7: normalizeNames

 /**
  * Normalize/validate entity and action names
  *
  * @param string $entity
  * @param string $action
  * @param array $apiRequest
  * @throws \API_Exception
  */
 protected static function normalizeNames(&$entity, &$action, &$apiRequest)
 {
     if ($apiRequest['version'] <= 3) {
         // APIv1-v3 munges entity/action names, and accepts any mixture of case and underscores.
         // We normalize entity to be CamelCase and action to be lowercase.
         $apiRequest['entity'] = $entity = \CRM_Utils_String::convertStringToCamel(\CRM_Utils_String::munge($entity));
         $apiRequest['action'] = $action = strtolower(\CRM_Utils_String::munge($action));
     } else {
         // APIv4 requires exact spelling & capitalization of entity/action name; deviations should cause errors
         if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $entity)) {
             throw new \API_Exception("Malformed entity");
         }
         if (!preg_match('/^[a-zA-Z][a-zA-Z0-9]*$/', $action)) {
             throw new \API_Exception("Malformed action");
         }
         $apiRequest['entity'] = $entity;
         // TODO: Not sure about camelCase actions - in v3 they are all lowercase.
         $apiRequest['action'] = strtolower($action[0]) . substr($action, 1);
     }
 }
开发者ID:JSProffitt,项目名称:civicrm-website-org,代码行数:28,代码来源:Request.php


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