當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CMap::add方法代碼示例

本文整理匯總了PHP中CMap::add方法的典型用法代碼示例。如果您正苦於以下問題:PHP CMap::add方法的具體用法?PHP CMap::add怎麽用?PHP CMap::add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CMap的用法示例。


在下文中一共展示了CMap::add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addAPIKey

 /**
  * 
  * Adds a Google API key to collection
  * @param string $domain
  * @param string $key
  */
 public function addAPIKey($domain, $key)
 {
     if (null === $this->_keys) {
         $this->_keys = new CMap();
     }
     $this->_keys->add($domain, $key);
 }
開發者ID:romeo14,項目名稱:pow,代碼行數:13,代碼來源:EGMapApiKeyList.php

示例2: locate

 /**
  * 
  * Locates IP information
  * @param string $ip address. If null, it will locate the IP of request
  */
 public function locate($ip = null)
 {
     if (null === $ip) {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $host = str_replace('{IP}', $ip, $this->_service);
     $host = str_replace('{CURRENCY}', $this->_currency, $host);
     $response = $this->fetch($host);
     if (!is_null($response) && is_array($response)) {
         $this->_data->mergeWith($response);
         $this->_data->add('ip', $ip);
         return true;
     }
     return true;
 }
開發者ID:2amigos,項目名稱:egeoip,代碼行數:20,代碼來源:EGeoIP.php

示例3: addItem

 /**
  * 
  * Add a FeedItem to the main class
  * 
  * @param  object  instance of EFeedItemAbstract class
  */
 public function addItem(EFeedItemAbstract $item)
 {
     if (null === $this->feedElements->itemAt('items')) {
         $this->feedElements->add('items', new CTypedList('EFeedItemAbstract'));
     }
     $this->feedElements->itemAt('items')->add($item);
 }
開發者ID:2amigos,項目名稱:efeed,代碼行數:13,代碼來源:EFeed.php

示例4: add

 /**
  * Adds an item into the map.
  * This method overrides the parent implementation by
  * checking the item to be inserted is of certain type.
  * @param integer $index the specified position.
  * @param mixed $item new item
  * @throws CException If the index specified exceeds the bound,
  * the map is read-only or the element is not of the expected type.
  */
 public function add($index, $item)
 {
     if ($item instanceof $this->_type) {
         parent::add($index, $item);
     } else {
         throw new CException(Yii::t('yii', 'CTypedMap<{type}> can only hold objects of {type} class.', array('{type}' => $this->_type)));
     }
 }
開發者ID:frogoscar,項目名稱:mobcent-discuz,代碼行數:17,代碼來源:CTypedMap.php

示例5: __set

 /**
  * @since v1.0.8
  */
 public function __set($name, $value)
 {
     if ($this->hasEmbeddedDocuments() && isset(self::$_embeddedConfig[get_class($this)][$name])) {
         if (is_array($value)) {
             // Late creation of embedded documents on first access
             if (is_null($this->_embedded->itemAt($name))) {
                 $docClassName = self::$_embeddedConfig[get_class($this)][$name];
                 $doc = new $docClassName($this->getScenario());
                 $doc->setOwner($this);
                 $this->_embedded->add($name, $doc);
             }
             return $this->_embedded->itemAt($name)->attributes = $value;
         } else {
             if ($value instanceof EMongoEmbeddedDocument) {
                 return $this->_embedded->add($name, $value);
             }
         }
     } else {
         parent::__set($name, $value);
     }
 }
開發者ID:nmalservet,項目名稱:biocap,代碼行數:24,代碼來源:EMongoEmbeddedDocument.php

示例6: add

 /**
  * Adds an item to the collection.
  * This method overrides the parent implementation to ensure
  * only configuration arrays, strings, or {@link CFormElement} objects
  * can be stored in this collection.
  * @param mixed key
  * @param mixed value
  * @throws CException if the value is invalid.
  */
 public function add($key, $value)
 {
     if (is_array($value)) {
         if (is_string($key)) {
             $value['name'] = $key;
         }
         if ($this->_forButtons) {
             $class = $this->_form->buttonElementClass;
             $element = new $class($value, $this->_form);
         } else {
             if (!isset($value['type'])) {
                 $value['type'] = 'text';
             }
             if ($value['type'] === 'string') {
                 unset($value['type'], $value['name']);
                 $element = new CFormStringElement($value, $this->_form);
             } else {
                 if (!strcasecmp(substr($value['type'], -4), 'form')) {
                     $class = $value['type'] === 'form' ? get_class($this->_form) : Yii::import($value['type']);
                     $element = new $class($value, null, $this->_form);
                 } else {
                     $class = $this->_form->inputElementClass;
                     $element = new $class($value, $this->_form);
                 }
             }
         }
     } else {
         if ($value instanceof CFormElement) {
             if (property_exists($value, 'name') && is_string($key)) {
                 $value->name = $key;
             }
             $element = $value;
         } else {
             $element = new CFormStringElement(array('content' => $value), $this->_form);
         }
     }
     parent::add($key, $element);
     $this->_form->addedElement($key, $element, $this->_forButtons);
 }
開發者ID:hansenmakangiras,項目名稱:yiiframework-cms,代碼行數:48,代碼來源:CFormElementCollection.php

示例7: add

 public function add($name, $cookie = null)
 {
     if ($name instanceof CHttpCookie) {
         $cookieName = $name->name;
         $cookieObject = $name;
     } else {
         $cookieName = (string) $name;
         $cookieObject = $cookie;
     }
     if ($cookieObject instanceof CHttpCookie) {
         $this->remove($cookieName);
         parent::add($cookieName, $cookieObject);
         if ($this->_initialized) {
             $this->addCookie($cookieObject);
         }
     } else {
         throw new CException(Yii::t('yii', 'CHttpCookieCollection can only hold CHttpCookie objects.'));
     }
 }
開發者ID:BGCX067,項目名稱:fairytask-svn-to-git,代碼行數:19,代碼來源:yiilite.php

示例8: add

 /**
  * Adds an item into the map.
  * This overrides the parent implementation by converting the key to lower case first if {@link caseSensitive} is false.
  * @param mixed $key key
  * @param mixed $value value
  */
 public function add($key, $value)
 {
     if ($this->caseSensitive) {
         parent::add($key, $value);
     } else {
         parent::add(strtolower($key), $value);
     }
 }
開發者ID:phuluang,項目名稱:rosewellmusic,代碼行數:14,代碼來源:CAttributeCollection.php

示例9: updateStored

 /**
  * Updates the position in the shopping cart
  * If the position was previously added, then it will be updated in shopping cart,
  * if the position was not previously in the cart, it will be added there.
  * If the count of less than 1, the position will be deleted.
  *
  * @param IECartPosition $position
  * @param int $quantity
  */
 public function updateStored(IECartPosition $position, $quantity)
 {
     if ($this->objSectorCiudad !== null) {
         $key = $position->getId();
         $position->generate(array('objSectorCiudad' => $this->objSectorCiudad, 'codigoPerfil' => $this->codigoPerfil));
         $position->setQuantityStored($quantity);
         if ($position->getQuantity(true) + $position->getQuantity(false) < 1) {
             $this->remove($key);
         } else {
             parent::add($key, $position);
         }
         $this->applyDiscounts();
         $this->onUpdatePoistion(new CEvent($this));
         $this->saveState();
         return true;
     }
     return false;
 }
開發者ID:JeffreyMartinezEiso,項目名稱:lrv,代碼行數:27,代碼來源:EShoppingCart.php

示例10: getVisibleItems

 public function getVisibleItems()
 {
     $visibleItems = new CMap();
     foreach ($this->getItems() as $id => $item) {
         if ($item->getVisible() === true) {
             $visibleItems->add($id, $item);
         }
     }
     return $visibleItems;
 }
開發者ID:jayrulez,項目名稱:yiisns,代碼行數:10,代碼來源:Navigation.php

示例11: 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

示例12: put

 /**
  * Add item to the favorite
  * @param IEFavoritePosition $position
  */
 public function put(IEFavoritePosition $position)
 {
     parent::add($position->getId(), $position->id);
     $this->saveState();
 }
開發者ID:kuzmina-mariya,項目名稱:unizaro-stone,代碼行數:9,代碼來源:EFavorite.php

示例13: getBlocks

 /**
  *
  */
 public function getBlocks($regionId, $visibleOnly = true)
 {
     $instance = self::getInstance();
     $blocks = new CMap();
     if ($instance->regions->contains($regionId)) {
         foreach ($instance->regions[$regionId] as $blockId => $block) {
             if ($visibleOnly) {
                 if ($block->getVisible() === false) {
                     continue;
                 }
             }
             $blocks->add($blockId, $block);
         }
     }
     return self::sortBlocks($blocks);
 }
開發者ID:jayrulez,項目名稱:kcconline,代碼行數:19,代碼來源:Layout.php

示例14: updateCount

 public function updateCount(IECartPosition $position, $count)
 {
     if (!$position instanceof CComponent) {
         throw new InvalidArgumentException('invalid argument 1, product must implement CComponent interface');
     }
     $key = $position->getId();
     $position->detachBehavior("CartPosition");
     $position->attachBehavior("CartPosition", new ECartPositionBehaviour());
     $position->setRefresh($this->refresh);
     $position->count = $count;
     $position->calculatePriceForThisCount();
     parent::add($key, $position);
     $this->applyDiscounts();
     $this->onUpdatePosition(new CEvent($this));
     $this->saveState();
 }
開發者ID:bgshechka,項目名稱:pos-shop,代碼行數:16,代碼來源:EShoppingCart.php

示例15: update

 /**
  * Updates the position in the shopping cart
  * If position was previously added, then it will be updated in shopping cart,
  * if position was not previously in the cart, it will be added there.
  * If count is less than 1, the position will be deleted.
  *
  * @param IECartPosition $position
  * @param int $quantity
  */
 public function update(IECartPosition $position, $quantity)
 {
     if (!$position instanceof CComponent) {
         throw new InvalidArgumentException('invalid argument 1, product must implement CComponent interface');
     }
     $key = $position->getId();
     $position->detachBehavior("CartPosition");
     $position->attachBehavior("CartPosition", new ECartPositionBehaviour());
     $position->setRefresh($this->refresh);
     $position->setQuantity($quantity);
     if ($position->getQuantity() < 1) {
         $this->remove($key);
     } else {
         parent::add($key, $position);
     }
     $this->applyDiscounts();
     $this->onUpdatePosition(new CEvent($this));
     $this->saveState();
 }
開發者ID:elbrusto,項目名稱:YiiShop,代碼行數:28,代碼來源:EShoppingCart.php


注:本文中的CMap::add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。