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


PHP CPropertyValue::ensureArray方法代码示例

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


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

示例1: send

 public function send($phones, $text)
 {
     $request = new DOMDocument("1.0", "UTF-8");
     $requestBody = $request->createElement('SMS');
     $requestBody->appendChild($this->createOperationsElement(array(self::SEND)));
     $requestBody->appendChild($this->createAuthElement());
     $request->appendChild($requestBody);
     $sms = $request->createElement('message');
     $sms->appendChild($request->createElement('sender', $this->sender));
     $textElement = $request->createElement('text');
     $textElement->appendChild(new DOMCdataSection($text));
     $sms->appendChild($textElement);
     $requestBody->appendChild($sms);
     if (is_array($phones) == false) {
         $phones = array($phones => array());
     }
     $numbers = $request->createElement('numbers');
     foreach ($phones as $phone => $value) {
         $variables = implode(';', CPropertyValue::ensureArray($value)) . ';';
         $number = $request->createElement('number', $phone);
         $number->setAttribute('messageid', md5($phone . date() . $variables));
         $number->setAttribute('variables', $variables);
         $numbers->appendChild($number);
     }
     $requestBody->appendChild($numbers);
     $responseText = $this->doRequest($request->saveXML());
     $result = $this->parseResponse($responseText);
     $status = $result['status'];
     $ok = (bool) ($status > 0);
     $needSmsAlert = $ok == false && $status != -4;
     $credits = $this->balance();
     return array('status' => $status, 'ok' => $ok, 'responseText' => $responseText, 'credits' => $credits, 'needSmsAlert' => $needSmsAlert);
 }
开发者ID:fduch2k,项目名称:yii-sms-manager,代码行数:33,代码来源:TSAtomparkGateway.php

示例2: testEnsureArray

 public function testEnsureArray()
 {
     $entries = array(array(123, array(123)), array(null, array()), array('', array()), array('abc', array('abc')), array('(1,2)', array(1, 2)), array('("key"=>"value",2=>3)', array("key" => "value", 2 => 3)), array(true, array(true)), array(array(), array()), array(array(0), array(0)));
     foreach ($entries as $index => $entry) {
         $this->assertTrue(CPropertyValue::ensureArray($entry[0]) === $entry[1], "Comparison {$index}: {$this->varToString($entry[0])}=={$this->varToString($entry[1])}");
     }
 }
开发者ID:super-d2,项目名称:codeigniter_demo,代码行数:7,代码来源:CPropertyValueTest.php

示例3: convertType

 public function convertType($value)
 {
     $value = trim($value);
     if (ctype_digit($value)) {
         return CPropertyValue::ensureInteger($value);
     }
     if (is_numeric($value)) {
         return CPropertyValue::ensureFloat($value);
     }
     if (strcasecmp($value, 'null') == 0) {
         return null;
     } else {
         if (strcasecmp($value, 'true') == 0 || strcasecmp($value, 'false') == 0) {
             return CPropertyValue::ensureBoolean($value);
         } else {
             if (preg_match('/^\\(.+\\)|\\(\\)$/', $value)) {
                 return CPropertyValue::ensureArray($value);
             }
         }
     }
     return $value;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-kamin,代码行数:22,代码来源:CDefaultValueValidatorForm.php

示例4: send

 public function send($phones, $text)
 {
     $sender = $this->sender;
     $result = array();
     foreach ($phones as $phone => $variables) {
         $variables = CPropertyValue::ensureArray($variables);
         $textMsg = $text;
         $i = 1;
         foreach ($variables as $variable) {
             $textMsg = str_replace('%' . $i . '%', $variable, $textMsg);
             $i++;
         }
         $args = array('login' => $this->username, 'password' => $this->password, 'messages' => array(array('clientId' => $sender, 'phone' => $phone, 'text' => $text)));
         $response = $this->doRequest(self::SEND_URL, $args);
         $responseText = CJSON::encode($response);
         $resultStatus = false;
         $credits = 0;
         $status = isset($response['status']) ? $response['status'] : 'no status';
         if ($status == 'ok') {
             if (isset($response['messages']) == false || count($response['messages']) == 0) {
                 throw new Exception('No messages in response');
             }
             $message = $response['messages'][0];
             $status = isset($message['status']) ? $message['status'] : 'no status';
             $resultStatus = $status == 'accepted';
             $response = $this->doRequest(self::CREDITS_URL, array('login' => $this->username, 'password' => $this->password));
             if (isset($response['balance'])) {
                 $credits = $response['balance'][0]['balance'];
             } else {
                 throw new Exception('No credits in response');
             }
         }
         $result = array('ok' => $status == 'ok', 'status' => $status, 'responseText' => $responseText, 'credits' => $credits, 'needSmsAlert' => true);
     }
     return $result;
 }
开发者ID:fduch2k,项目名称:yii-sms-manager,代码行数:36,代码来源:TSSmsFeedBackGateway.php

示例5: setScopes

 public function setScopes ($scopes)
 {
    $this->_scopes = CPropertyValue::ensureArray($scopes);
 }
开发者ID:nizsheanez,项目名称:PolymorphCMS,代码行数:4,代码来源:EActiveDataProvider.php

示例6: applyFlags

 /**
  * Apply flags conditions to given criteria
  * @param CDbCriteria $criteria the criteria to apply flags condition
  * @param array $flags the array with flags (as flag name or as flag value). Flag name started with '!' is mean 'not flag'
  * @param string $operator the operator that connect flags conditions
  * @return CDbCriteria the CDbCriteria object with applied flags conditions
  */
 public function applyFlags($criteria, $flags, $operator = 'AND')
 {
     $flagList = $this->cachedFlags();
     $flags = CPropertyValue::ensureArray($flags);
     $newCriteria = new CDbCriteria();
     foreach ($flags as $flag) {
         if (is_string($flag)) {
             if ($invert = $flag[0] == '!') {
                 $flag = substr($flag, 1);
             }
             $flagValue = $flagList[trim(strtolower($flag))];
         } else {
             $flagValue = $flag;
         }
         if (empty($flagValue) === false) {
             $equality = $invert ? '=' : '<>';
             $newCriteria->addCondition($this->flagsField . '&' . $flagValue . $equality . '0', $operator);
         }
     }
     $criteria->mergeWith($newCriteria);
     return $criteria;
 }
开发者ID:fduch2k,项目名称:yii-flagged-activerecord,代码行数:29,代码来源:TSFlaggedActiveRecord.php

示例7: prepareOutput

 private function prepareOutput()
 {
     $preparedAttributes = array();
     foreach ($this->getAttributes() as $key => $value) {
         if (in_array($key, array('enableClientValidation', 'safe', 'skipOnError', 'allowEmpty', 'caseSensitive'))) {
             $preparedAttributes[$key] = CPropertyValue::ensureBoolean($value);
         }
         if ($key === 'except' || $key === 'on') {
             if (!is_null($value)) {
                 $preparedAttributes[$key] = array_map('trim', explode(',', $value));
             }
         }
         if ($key === 'criteria') {
             if (is_string($value)) {
                 $value = trim($value);
             }
             $preparedAttributes[$key] = CPropertyValue::ensureArray($value);
         }
     }
     return $preparedAttributes;
 }
开发者ID:kuzmina-mariya,项目名称:unizaro-kamin,代码行数:21,代码来源:CUniqueValidatorForm.php

示例8: findByAttributeValue

 private function findByAttributeValue($array, $attribute, $value)
 {
     $array = CPropertyValue::ensureArray($array);
     foreach ($array as $key => $entry) {
         if ($entry[$attribute] == $value) {
             return $entry;
         }
     }
     return false;
 }
开发者ID:cebe,项目名称:chive,代码行数:10,代码来源:UserSettingsManager.php

示例9: in_array

<?php

/**
 * @var $authItem CAuthItem
 */
?>

<?php 
if ($authItem->type == CAuthItem::TYPE_OPERATION) {
    ?>
<label>
    <?php 
    echo CHtml::checkBox('role[' . $authItem->name . ']', in_array($authItem->name, CPropertyValue::ensureArray($role->data)));
    ?>
&nbsp;<?php 
    echo $authItem->description;
    ?>
</label>
<?php 
} else {
    ?>
<p class="form-control-static">
    <?php 
    echo CAuthItem::TYPE_ROLE == $authItem->type ? $authItem->name : $authItem->description;
    ?>
</p>

<?php 
}
开发者ID:apa-narola,项目名称:yiimoduledemo,代码行数:29,代码来源:_auth_item.php


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