本文整理汇总了PHP中CMap::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP CMap::remove方法的具体用法?PHP CMap::remove怎么用?PHP CMap::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMap
的用法示例。
在下文中一共展示了CMap::remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remove
/**
* Removes position from the shopping cart of key
* @param mixed $key
*/
public function remove($key)
{
parent::remove($key);
$this->applyDiscounts();
$this->onRemovePosition(new CEvent($this));
$this->saveState();
}
示例2: get
public function get($alias)
{
if (($menuRoot = Category::model()->menuRoot($alias)) == null) {
$this->error("Параметр tag для menu не верен. Шаблон $this->tmplAlias");
$res = $this->command;
}
$params = new CMap();
if ($params->remove('expand')) {
$res = $menuRoot->makeTreeHtml(Y::controller()->category, true);
} else {
$params['items'] = $menuRoot->makeMenu(Y::controller()->category);
$res = Y::controller()->widget('Menu', $params, true);
}
return $res;
}
示例3: remove
/**
* Removes a cookie with the specified name.
* This overrides the parent implementation by performing additional
* cleanup work when removing a CHttpCookie object.
* Since version 1.1.11, the second parameter is available that can be used to specify
* the options of the CHttpCookie being removed. For example, this may be useful when dealing
* with ".domain.tld" where multiple subdomains are expected to be able to manage cookies:
*
* <pre>
* $options=array('domain'=>'.domain.tld');
* Yii::app()->request->cookies['foo']=new CHttpCookie('cookie','value',$options);
* Yii::app()->request->cookies->remove('cookie',$options);
* </pre>
*
* @param mixed $name Cookie name.
* @param array $options Cookie configuration array consisting of name-value pairs, available since 1.1.11.
* @return CHttpCookie The removed cookie object.
*/
public function remove($name, $options = array())
{
if (($cookie = parent::remove($name)) !== null) {
if ($this->_initialized) {
$cookie->configure($options);
$this->removeCookie($cookie);
}
}
return $cookie;
}
示例4: remove
public function remove($name)
{
if (($cookie = parent::remove($name)) !== null) {
if ($this->_initialized) {
$this->removeCookie($cookie);
}
}
return $cookie;
}
示例5: remove
/**
* Removes the specified element by key.
* @param string the name of the element to be removed from the collection
*/
public function remove($key)
{
if (($item = parent::remove($key)) !== null) {
$this->_form->removedElement($key, $item, $this->_forButtons);
}
}
示例6: remove
/**
* Removes a key-value pair from a map.
*
* @param mixed $key The key of the key-value pair to be removed.
*
* @return void
*/
public function remove($key)
{
CMap::remove($this->m_map, $key);
}
示例7: remove
/**
* Removes an item from the map by its key.
* This overrides the parent implementation by converting the key to lower case first if {@link caseSensitive} is false.
* @param mixed $key the key of the item to be removed
* @return mixed the removed value, null if no such key exists.
*/
public function remove($key)
{
if ($this->caseSensitive) {
return parent::remove($key);
} else {
return parent::remove(strtolower($key));
}
}
示例8: testCanNotRemoveWhenReadOnly
public function testCanNotRemoveWhenReadOnly()
{
$map = new CMap(array('key' => 'value'), true);
$this->setExpectedException('CException');
$map->remove('key');
}
示例9: __construct
/**
* Creates a parsed URL from a URL string.
*
* The URL string is expected to be by all means valid, with characters being percent-encoded where it is required
* by the URL standard and without any leading or trailing whitespace. It is only when the URL string does not
* indicate any protocol that the URL may still be considered valid and the default protocol is assigned to the
* URL, which is "http".
*
* @param string $url The URL string.
*/
public function __construct($url)
{
assert('is_cstring($url)', vs(isset($this), get_defined_vars()));
assert('self::isValid($url, true)', vs(isset($this), get_defined_vars()));
$this->m_url = $url;
$parsedUrl = parse_url($url);
assert('is_cmap($parsedUrl)', vs(isset($this), get_defined_vars()));
// should not rise for a valid URL
// Protocol (scheme).
if (CMap::hasKey($parsedUrl, "scheme")) {
$this->m_hasProtocol = true;
$this->m_protocol = $parsedUrl["scheme"];
// Normalize by converting to lowercase.
$this->m_normProtocol = CString::toLowerCase($this->m_protocol);
} else {
$this->m_hasProtocol = false;
$this->m_normProtocol = self::DEFAULT_PROTOCOL;
if (!CMap::hasKey($parsedUrl, "host")) {
// Most likely, `parse_url` function has not parsed the host because the protocol (scheme) is absent
// and there are no "//" in the front, so try parsing the host with the default protocol in the URL.
$parsedUrl = parse_url(self::ensureProtocol($url));
assert('is_cmap($parsedUrl)', vs(isset($this), get_defined_vars()));
CMap::remove($parsedUrl, "scheme");
}
}
// Host (domain).
$this->m_hostIsInBrackets = false;
if (CMap::hasKey($parsedUrl, "host")) {
$this->m_host = $parsedUrl["host"];
if (CRegex::find($this->m_host, "/^\\[.*\\]\\z/")) {
// Most likely, an IPv6 enclosed in "[]".
$this->m_hostIsInBrackets = true;
$this->m_host = CString::substr($this->m_host, 1, CString::length($this->m_host) - 2);
}
// Normalize by converting to lowercase.
$this->m_normHost = CString::toLowerCase($this->m_host);
} else {
// Same as invalid.
assert('false', vs(isset($this), get_defined_vars()));
}
// Port.
if (CMap::hasKey($parsedUrl, "port")) {
$this->m_hasPort = true;
$this->m_port = $parsedUrl["port"];
// Should be `int`, but look into the type just in case.
if (is_cstring($this->m_port)) {
$this->m_port = CString::toInt($this->m_port);
}
} else {
$this->m_hasPort = false;
}
// Path.
if (CMap::hasKey($parsedUrl, "path")) {
$this->m_hasPath = true;
$this->m_path = $parsedUrl["path"];
// Normalize by replacing percent-encoded bytes of unreserved characters with their literal equivalents and
// ensuring that all percent-encoded parts are in uppercase.
$pathDelimitersReEsc = CRegex::enterTd(self::$ms_delimiters);
$this->m_normPath = CRegex::replaceWithCallback($this->m_path, "/[^{$pathDelimitersReEsc}]+/", function ($matches) {
return CUrl::enterTdNew(CUrl::leaveTdNew($matches[0]));
});
} else {
$this->m_hasPath = false;
$this->m_normPath = "/";
}
$this->m_urlPath = new CUrlPath($this->m_normPath);
// Query string.
$this->m_hasQuery = false;
if (CMap::hasKey($parsedUrl, "query")) {
$this->m_hasQuery = true;
$this->m_queryString = $parsedUrl["query"];
$parsingWasFruitful;
$this->m_urlQuery = new CUrlQuery($this->m_queryString, $parsingWasFruitful);
if ($parsingWasFruitful) {
$this->m_hasQuery = true;
$this->m_normQueryString = $this->m_urlQuery->queryString(true);
}
}
// Fragment ID.
if (CMap::hasKey($parsedUrl, "fragment")) {
$this->m_hasFragmentId = true;
$this->m_fragmentId = $parsedUrl["fragment"];
// Normalize by replacing percent-encoded bytes of unreserved characters with their literal equivalents and
// ensuring that all percent-encoded parts are in uppercase.
$fiDelimitersReEsc = CRegex::enterTd(self::$ms_delimiters);
$this->m_normFragmentId = CRegex::replaceWithCallback($this->m_fragmentId, "/[^{$fiDelimitersReEsc}]+/", function ($matches) {
// Use the newer flavor of percent-encoding.
return CUrl::enterTdNew(CUrl::leaveTdNew($matches[0]));
});
} else {
//.........这里部分代码省略.........
示例10: unsetLock
/**
* Removes the lock that was previously set on a file.
*
* @param string $lockFp The path to the file to be unlocked.
*
* @return void
*/
public static function unsetLock($lockFp)
{
assert('is_cstring($lockFp)', vs(isset($this), get_defined_vars()));
$lockFpAbs = CFilePath::absolute($lockFp);
$file = self::$ms_fhFromLockFp[$lockFpAbs];
flock($file, LOCK_UN);
fclose($file);
CMap::remove(self::$ms_fhFromLockFp, $lockFpAbs);
}
示例11: 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);
}
示例12: remove
/**
* Removes position from the favorite of key
* @param mixed $key
*/
public function remove($key)
{
parent::remove($key);
$this->saveState();
}
示例13: 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);
}
示例14: testRemove
public function testRemove()
{
$map = ["one" => "a", "two" => "b", "three" => "c", "four" => "d", "five" => "e"];
CMap::remove($map, "three");
$this->assertTrue(CMap::equals($map, ["one" => "a", "two" => "b", "four" => "d", "five" => "e"]));
}
示例15: remove
/**
* Removes position from the shopping cart of key
* @param mixed $key
* @return mixed|void
* @throws CException
*/
public function remove($key)
{
parent::remove($key);
$this->applyDiscounts();
$this->saveState();
$this->eventManager->fire(CartEvents::CART_REMOVE_ITEM, new CartEvent(Yii::app()->getUser(), $this));
}