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


PHP CMap::toArray方法代码示例

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


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

示例1: addFlashMessage

 /**
 * @param $message
   // пример использования в контроллере:
   // $err = array('test1','test2'); // складываем ошибки в массив // можно доделать с использовать _addError как в контроллере orders/cart если запрос через ajax
   // Yii::app()->user->setFlash('messages_red', $err);
   // $this->addFlashMessage($model->getErrors(),'red'); // до кучи берем ошибки модели
   // Если была/были впереди ошибка/ошибки, показываем все
 */
 public function addFlashMessage($message, $style = 'success')
 {
     $currentMessages = Yii::app()->user->getFlash('error');
     if (!is_array($currentMessages)) {
         $currentMessages = array($currentMessages);
     }
     $map = new CMap($currentMessages);
     if (is_array($message)) {
         foreach ($message as $mes) {
             if (is_array($mes)) {
                 $map->mergeWith($mes);
             } else {
                 $map->mergeWith(array($mes));
             }
         }
     } else {
         $map->mergeWith(array($message));
     }
     $messages = $map->toArray();
     Yii::app()->user->setFlash($style, $messages);
 }
开发者ID:Aplay,项目名称:myhistorypark_site,代码行数:29,代码来源:Controller.php

示例2: testToArray

 public function testToArray()
 {
     $map = new CMap(array('key' => 'value'));
     $this->assertEquals(array('key' => 'value'), $map->toArray());
 }
开发者ID:avtograd,项目名称:yii,代码行数:5,代码来源:CMapTest.php

示例3: actionGetGroceryRate

 public function actionGetGroceryRate()
 {
     $inquiry = new InquiryForm('api-rate-grocery');
     $req = Yii::app()->request;
     $inquiryMap = new CMap();
     $inquiryMap->add('receiver_postal', $req->getQuery('receiver_postal'));
     $inquiryMap->add('service_code', $req->getQuery('service_code'));
     $inquiry->setAttributes($inquiryMap->toArray());
     if (!$inquiry->validate()) {
         echo CJSON::encode($this->statusError($inquiry->getErrors()));
         Yii::app()->end();
     }
     $service_code = ProductService::model()->findByAttributes(array('code' => strtoupper($inquiry->service_code)));
     if (!$service_code instanceof ProductService) {
         echo CJSON::encode($this->statusError('No Service Available'));
         Yii::app()->end();
     } else {
         if ($service_code->code != 'LSX' && $service_code->code != 'HRX') {
             echo CJSON::encode($this->statusError('This service is not available'));
             Yii::app()->end();
         }
     }
     $routing = IntraCityRouting::model()->findByAttributes(array('postcode' => $inquiry->receiver_postal));
     if ($routing instanceof IntraCityRouting) {
         $area = Area::getZoneID($inquiry->receiver_postal, 'postcode');
         if (!$area) {
             echo CJSON::encode($this->statusError('No Available Service'));
             Yii::app()->end();
         }
         $rates = RateCity::getCityRate(ProductService::ProductCityCourier, $routing->code, 5);
         $rate = array();
         foreach ($rates as $key) {
             if ($key['service_code'] == $inquiry->service_code) {
                 $rate = $key;
             }
         }
         $product = 'City Courier';
         echo CJSON::encode($this->statusSuccess(array('service_type' => $product, 'rate' => $rate)));
         Yii::app()->end();
     } else {
         $result = array('status' => 'success', 'result' => $data);
     }
     echo CJSON::encode($result);
     Yii::app()->end();
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:45,代码来源:ServiceController.php

示例4: processAttributes

 /**
  * Save model attributes
  * @param ShopProduct $model
  * @return boolean
  */
 protected function processAttributes(ShopProduct $model)
 {
     $attributes = new CMap(Yii::app()->request->getPost('ShopAttribute', array()));
     if (empty($attributes)) {
         return false;
     }
     $deleteModel = ShopProduct::model()->findByPk($model->id);
     $deleteModel->deleteEavAttributes(array(), true);
     // Delete empty values
     foreach ($attributes as $key => $val) {
         if (is_string($val) && $val === '') {
             $attributes->remove($key);
         }
     }
     return $model->setEavAttributes($attributes->toArray(), true);
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:21,代码来源:ProductsController.php

示例5: processAttributes

    /**
	 * Save model attributes
	 * @param Products $model
	 * @return boolean
	 */
	protected function processAttributes($attributes)
	{
		$attributes = new CMap($attributes);

		if(empty($attributes))
			return false;

		$this->deleteEavAttributes(array(), true);

		// Delete empty values
		foreach($attributes as $key=>$val)
		{
			if(is_string($val) && $val === '')
				$attributes->remove($key);
		}

		return $this->setEavAttributes($attributes->toArray(), true);
	}
开发者ID:Aplay,项目名称:Fastreview_site,代码行数:23,代码来源:Objects.php


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