sets a single category

@param \OxidEsales\Eshop\Application\Model\Category $oContent the category
@param string                                       $sKey     optional, the key for that category,
without a key, the category is just added to the array
506323
public function setContentCat($oContent, $sKey = null)
    {
        if ($sKey) {
            $this->_aContentCats[$sKey] = $oContent;
        } else {
            $this->_aContentCats[] = $oContent;
        }
    }
1224332
public function fromPhpFileCache($sKey)
    {
        // setting meta
        $this->setCacheMeta($sKey, ["include" => true, "cachepath" => $this->getCacheFilePath($sKey, false, 'php')]);

        return $this->fromFileCache($sKey);
    }
1020042
function(sEntitySetName, sKeys) {
					sKeys = decodeURIComponent(sKeys);
					var oFoundEntry;
					var oEntitySet = that._mEntitySets[sEntitySetName];
					var aKeys = oEntitySet.keys;
					// split keys
					var aRequestedKeys = sKeys.split(',');

					// check number of keys to be equal to the entity keys and validates keys type for quotations
					if (aRequestedKeys.length !== aKeys.length) {
						that._logAndThrowMockServerCustomError(400, that._oErrorMessages.INVALID_KEY_PREDICATE_QUANTITY);
					}
					that._isRequestedKeysValid(oEntitySet, aRequestedKeys);
					if (aRequestedKeys.length === 1 && !aRequestedKeys[0].split('=')[1]) {
						aRequestedKeys = [aKeys[0] + "=" + aRequestedKeys[0]];
					}
					jQuery.each(that._oMockdata[sEntitySetName], function(iIndex, oEntry) {
						// check each key for existence and value
						for (var i = 0; i < aRequestedKeys.length; i++) {
							var aKeyVal = aRequestedKeys[i].split('=');
							var sKey = that._trim(aKeyVal[0]);
							//key doesn't match, continue to next entry
							if (!aKeys || aKeys.indexOf(sKey) === -1) {
								return true; // = continue
							}

							var sNewValue = that._trim(aKeyVal[1]);
							var sOrigiValue = oEntry[sKey];

							switch (oEntitySet.keysType[sKey]) {
								case "Edm.String":
									sNewValue = sNewValue.replace(/^\'|\'$/g, '');
									break;
								case "Edm.Time":
								case "Edm.DateTime":
									sOrigiValue = that._getDateTime(sOrigiValue);
									break;
								case "Edm.Int16":
								case "Edm.Int32":
									//case "Edm.Int64": In ODataModel this type is represented as a string. (https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.model.odata.type.Int64.html)
								case "Edm.Decimal":
								case "Edm.Byte":
								case "Edm.Double":
								case "Edm.Single":
								case "Edm.SByte":
									if (!that._isValidNumber(sNewValue)) {
										//TODO check better handling
										return false; // = break
									}
									sNewValue = parseFloat(sNewValue);
									break;
								case "Edm.Guid":
									sNewValue = sNewValue.replace(/^guid\'|\'$/g, '');
									break;
								case "Edm.Boolean":
									if (["true", "false"].indexOf(sNewValue) === -1) {
										that._logAndThrowMockServerCustomError(400, that._oErrorMessages.INVALID_KEY_TYPE, sKey);
									}
									sNewValue = sNewValue === "true";
									break;
								case "Edm.Binary":
								case "Edm.DateTimeOffset":
								default:
									sNewValue = sNewValue;
							}

							//value doesn't match, continue to next entry
							if (sOrigiValue !== sNewValue) {
								return true; // = continue
							}
						}
						oFoundEntry = {
							index: iIndex,
							entry: oEntry
						};
						return false; // = break
					});
					return oFoundEntry;
				}
791702
public function onDeleteCategory($oCategory)
    {
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $sIdQuoted = $oDb->quote($oCategory->getId());
        $oDb->execute("update oxseo, (select oxseourl from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcategory') as test set oxseo.oxexpired=1 where oxseo.oxseourl like concat(test.oxseourl, '%') and (oxtype = 'oxcategory' or oxtype = 'oxarticle')");
        $oDb->execute("delete from oxseo where oxseo.oxtype = 'oxarticle' and oxseo.oxparams = $sIdQuoted");
        $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcategory'");
        $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
        $oDb->execute("delete from oxseohistory where oxobjectid = $sIdQuoted");
    }
314952
protected function setPropertyAttribute($arValue)
    {
        if (is_string($arValue)) {
            $arValue = $this->fromJson($arValue);
        }

        if (empty($arValue) || !is_array($arValue)) {
            return;
        }

        $arPropertyList = $this->property;
        if (empty($arPropertyList)) {
            $arPropertyList = [];
        }

        foreach ($arValue as $sKey => $sValue) {
            $arPropertyList[$sKey] = $sValue;
        }

        $this->attributes['property'] = $this->asJson($arPropertyList);
    }
496957
public function setContent(ChildContent $v = null)
    {
        if ($v === null) {
            $this->setContentId(NULL);
        } else {
            $this->setContentId($v->getId());
        }

        $this->aContent = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the ChildContent object, it will not be re-added.
        if ($v !== null) {
            $v->addDealerContent($this);
        }


        return $this;
    }
463649
public function setContent( $content ) {
		if ( ! is_array( $content ) ) {
			$content = [ $content ];
		}
		foreach ( $content as $v ) {
			if ( $this === $v ) {
				throw new \LogicException( 'Recursion problem: cannot set self as content to self' );
			}
		}
		$this->content = $content;
	}
772889
protected function unsetCache($sKey)
    {
        if (!static::$CACHING_ENABLED) {
            return false;
        } elseif (empty($sKey)) {
            return false;
        }

        $iCacheIndex = $this->getCache($sKey, false);
        if (is_null($iCacheIndex)) {
            return false;
        }

        unset($this->aCache[$iCacheIndex]);

        return true;
    }
857744
function gen($sKey, array $aOption = []) {

		if (!self::_checkKey($sKey)) {
			throw TangoException('illegal key name');
		}

		$aOption += [
			'init' => 1,
			'step' => 1,
		];

		$aQuery = [
			'$and' => [
				[static::$_mKey => $this->_mID],
				[$sKey => ['$exists' => TRUE]],
			],
		];
		$aUpdate = ['$inc' => [$sKey => $aOption['step']]];
		$aField = [$sKey => TRUE];
		$aFindOption = ['new' => TRUE];

		$aResult = $this->_coll()
			->findAndModify($aQuery, $aUpdate, $aField, $aFindOption);

		if ($aResult && isset($aResult[$sKey])) {
			return $aResult[$sKey];
		}

		/*
		$aResult = $this->_coll()
			->update([static::$_mKey => $this->_mID], ['$set' => [$sKey => 0]], ['upsert' => TRUE]);
		 */

		try {

			$aQuery['$and'][1][$sKey]['$exists'] = FALSE;
			$aSet = ['$set' => [$sKey => $aOption['init']]];
			$aResult = $this->_coll()
				->findAndModify($aQuery, $aSet, $aField, $aFindOption + ['upsert' => TRUE]);
			if ($aResult && isset($aResult[$sKey])) {
				return $aResult[$sKey];
			}

		} catch(\MongoDuplicateKeyException $e) {

			// 这其实是同一个语句执行两遍
			//
			// 也就是虽然都不满足（_id = ? and 不存在key）这个条件，
			// 但是也分“没有 document”和“有 document 但没有指定 key”两种情况
			//
			// 上面的 upsert = ture 是试探第一种情况，这里是试探第二种情况

			$aResult = $this->_coll()
				->findAndModify($aQuery, $aSet, $aField, $aFindOption);
			if ($aResult && isset($aResult[$sKey])) {
				return $aResult[$sKey];
			}
		}

		$aQuery = [static::$_mKey => $this->_mID];
		$aResult = $this->_coll()
			->findAndModify($aQuery, $aUpdate, $aField, $aFindOption);

		if (!$aResult || isset($aResult[$sKey])) {

			// 除了在这几条语句执行的过程中有别的连接
			// 执行了创建并删除 document 的操作，
			//
			// 不然我实在想象不出还有什么理由会没法生成自增id

			throw TangoException('can not update , unknown reason');
		}
		return $aResult[$sKey];
	}
402444
public function setSkeVent($skeVent)
    {
        if (is_array($skeVent))
            $skeVent = new SkeVent($skeVent);
        $this->skeVent = $skeVent;
        return $this;
    }
167480
public function setCatArticleCount($aCache, $sCatId, $sActIdent)
    {
        $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
        $sTable = $oArticle->getViewName();
        $sO2CView = getViewName('oxobject2category');
        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();

        // we use distinct if article is assigned to category twice
        $sQ = "SELECT COUNT( DISTINCT $sTable.`oxid` )
               FROM $sO2CView
                   INNER JOIN $sTable ON $sO2CView.`oxobjectid` = $sTable.`oxid` AND $sTable.`oxparentid` = ''
               WHERE $sO2CView.`oxcatnid` = " . $oDb->quote($sCatId) . " AND " . $oArticle->getSqlActiveSnippet();

        $aCache[$sCatId][$sActIdent] = $oDb->getOne($sQ);

        $this->_setCatCache($aCache);

        return $aCache[$sCatId][$sActIdent];
    }
1251155
protected function newItem(string $sKey): Item
    {
        $oObj = (object) [
            'sKey'  => $sKey,
            'sPath' => $this->prepKey($sKey),
        ];

        //  When testing the Factory isn't available
        if (defined('PHPUNIT_NAILS_COMMON_TEST_SUITE')) {
            $oItem = new Item($oObj);
        } else {
            /** @var Item $oItem */
            $oItem = Factory::resource('FileCacheItem', null, $oObj);
        }

        return $oItem;
    }
1347383
public function toStaticCache($sName, $sContent, $sKey = null)
    {
        // if it's an array then we add
        if ($sKey) {
            $this->_aStaticCache[$sName][$sKey] = $sContent;
        } else {
            $this->_aStaticCache[$sName] = $sContent;
        }
    }
1361087
protected function _isObjectFieldWithValidValue( $sKey, $sValue, $aMap, $oObject )
    {
        if ( !array_key_exists( $sKey, $aMap ) ) {
            return false;
        }

        $sField = $aMap[$sKey];

        if ( empty( $sValue ) or ( $oObject->$sField->value == $sValue ) ) {
            return false;
        }

        return true;
    }
568757
public function setContent($content)
    {
        if (is_array($content)) {
            $this->setContentType('json');
            $this->_content = json_encode($content, JSON_PRETTY_PRINT);
        } else {
            $this->_content = (string) $content;
        }
    }
697344
public function addContent(\Coral\ContentBundle\Entity\Content $contents)
    {
        $this->contents[] = $contents;

        return $this;
    }
1309098
public function setContent($content)
    {
        $this->content = $content;
        $this->setHeader('content-length', strlen($this->content));
    }