id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,500 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/pkgExtranet/objects/db/TShopWishlistDataExtranetUser.class.php | TShopWishlistDataExtranetUser.AddArticleIdToWishlist | public function AddArticleIdToWishlist($sArticleId, $dAmount = 1)
{
$dNewAmountOnList = 0;
$oWishlist = &$this->GetWishlist(true);
$dNewAmountOnList = $oWishlist->AddArticle($sArticleId, $dAmount);
return $dNewAmountOnList;
} | php | public function AddArticleIdToWishlist($sArticleId, $dAmount = 1)
{
$dNewAmountOnList = 0;
$oWishlist = &$this->GetWishlist(true);
$dNewAmountOnList = $oWishlist->AddArticle($sArticleId, $dAmount);
return $dNewAmountOnList;
} | [
"public",
"function",
"AddArticleIdToWishlist",
"(",
"$",
"sArticleId",
",",
"$",
"dAmount",
"=",
"1",
")",
"{",
"$",
"dNewAmountOnList",
"=",
"0",
";",
"$",
"oWishlist",
"=",
"&",
"$",
"this",
"->",
"GetWishlist",
"(",
"true",
")",
";",
"$",
"dNewAmountOnList",
"=",
"$",
"oWishlist",
"->",
"AddArticle",
"(",
"$",
"sArticleId",
",",
"$",
"dAmount",
")",
";",
"return",
"$",
"dNewAmountOnList",
";",
"}"
] | add an article to the wishlist.
@param string $sArticleId
@param float $dAmount
@return float - new amount on list | [
"add",
"an",
"article",
"to",
"the",
"wishlist",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/pkgExtranet/objects/db/TShopWishlistDataExtranetUser.class.php#L22-L29 |
31,501 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/pkgExtranet/objects/db/TShopWishlistDataExtranetUser.class.php | TShopWishlistDataExtranetUser.RemoveArticleFromWishlist | public function RemoveArticleFromWishlist($sPkgShopWishlistArticleId)
{
$oWishlist = &$this->GetWishlist(true);
$oWishlistItem = TdbPkgShopWishlistArticle::GetNewInstance();
/** @var $oWishlistItem TdbPkgShopWishlistArticle */
if ($oWishlistItem->LoadFromFields(array('pkg_shop_wishlist_id' => $oWishlist->id, 'id' => $sPkgShopWishlistArticleId))) {
$oWishlistItem->AllowEditByAll(true);
$oWishlistItem->Delete();
}
} | php | public function RemoveArticleFromWishlist($sPkgShopWishlistArticleId)
{
$oWishlist = &$this->GetWishlist(true);
$oWishlistItem = TdbPkgShopWishlistArticle::GetNewInstance();
/** @var $oWishlistItem TdbPkgShopWishlistArticle */
if ($oWishlistItem->LoadFromFields(array('pkg_shop_wishlist_id' => $oWishlist->id, 'id' => $sPkgShopWishlistArticleId))) {
$oWishlistItem->AllowEditByAll(true);
$oWishlistItem->Delete();
}
} | [
"public",
"function",
"RemoveArticleFromWishlist",
"(",
"$",
"sPkgShopWishlistArticleId",
")",
"{",
"$",
"oWishlist",
"=",
"&",
"$",
"this",
"->",
"GetWishlist",
"(",
"true",
")",
";",
"$",
"oWishlistItem",
"=",
"TdbPkgShopWishlistArticle",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oWishlistItem TdbPkgShopWishlistArticle */",
"if",
"(",
"$",
"oWishlistItem",
"->",
"LoadFromFields",
"(",
"array",
"(",
"'pkg_shop_wishlist_id'",
"=>",
"$",
"oWishlist",
"->",
"id",
",",
"'id'",
"=>",
"$",
"sPkgShopWishlistArticleId",
")",
")",
")",
"{",
"$",
"oWishlistItem",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"oWishlistItem",
"->",
"Delete",
"(",
")",
";",
"}",
"}"
] | remove an article form the wishlist.
@param string $sPkgShopWishlistArticleId - the id of the item on the list | [
"remove",
"an",
"article",
"form",
"the",
"wishlist",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/pkgExtranet/objects/db/TShopWishlistDataExtranetUser.class.php#L36-L45 |
31,502 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/pkgExtranet/objects/db/TShopWishlistDataExtranetUser.class.php | TShopWishlistDataExtranetUser.& | public function &GetWishlist($bCreateIfNotExists = false)
{
$oWishlist = &$this->GetFromInternalCache('oUserWishlist');
if (is_null($oWishlist)) {
$oWishlists = $this->GetFieldPkgShopWishlistList();
if ($oWishlists->Length() > 0) {
$oWishlist = $oWishlists->Current();
}
if (is_null($oWishlist) && $bCreateIfNotExists) {
$oWishlist = TdbPkgShopWishlist::GetNewInstance();
/** @var $oWishlist TdbPkgShopWishlist */
if (!$oWishlist->LoadFromField('data_extranet_user_id', $this->id)) {
$aBaseData = array('data_extranet_user_id' => $this->id, 'is_public' => '0');
$oWishlist->LoadFromRow($aBaseData);
$oWishlist->Save();
}
}
$this->SetInternalCache('oUserWishlist', $oWishlist);
}
return $oWishlist;
} | php | public function &GetWishlist($bCreateIfNotExists = false)
{
$oWishlist = &$this->GetFromInternalCache('oUserWishlist');
if (is_null($oWishlist)) {
$oWishlists = $this->GetFieldPkgShopWishlistList();
if ($oWishlists->Length() > 0) {
$oWishlist = $oWishlists->Current();
}
if (is_null($oWishlist) && $bCreateIfNotExists) {
$oWishlist = TdbPkgShopWishlist::GetNewInstance();
/** @var $oWishlist TdbPkgShopWishlist */
if (!$oWishlist->LoadFromField('data_extranet_user_id', $this->id)) {
$aBaseData = array('data_extranet_user_id' => $this->id, 'is_public' => '0');
$oWishlist->LoadFromRow($aBaseData);
$oWishlist->Save();
}
}
$this->SetInternalCache('oUserWishlist', $oWishlist);
}
return $oWishlist;
} | [
"public",
"function",
"&",
"GetWishlist",
"(",
"$",
"bCreateIfNotExists",
"=",
"false",
")",
"{",
"$",
"oWishlist",
"=",
"&",
"$",
"this",
"->",
"GetFromInternalCache",
"(",
"'oUserWishlist'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"oWishlist",
")",
")",
"{",
"$",
"oWishlists",
"=",
"$",
"this",
"->",
"GetFieldPkgShopWishlistList",
"(",
")",
";",
"if",
"(",
"$",
"oWishlists",
"->",
"Length",
"(",
")",
">",
"0",
")",
"{",
"$",
"oWishlist",
"=",
"$",
"oWishlists",
"->",
"Current",
"(",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"oWishlist",
")",
"&&",
"$",
"bCreateIfNotExists",
")",
"{",
"$",
"oWishlist",
"=",
"TdbPkgShopWishlist",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oWishlist TdbPkgShopWishlist */",
"if",
"(",
"!",
"$",
"oWishlist",
"->",
"LoadFromField",
"(",
"'data_extranet_user_id'",
",",
"$",
"this",
"->",
"id",
")",
")",
"{",
"$",
"aBaseData",
"=",
"array",
"(",
"'data_extranet_user_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'is_public'",
"=>",
"'0'",
")",
";",
"$",
"oWishlist",
"->",
"LoadFromRow",
"(",
"$",
"aBaseData",
")",
";",
"$",
"oWishlist",
"->",
"Save",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"SetInternalCache",
"(",
"'oUserWishlist'",
",",
"$",
"oWishlist",
")",
";",
"}",
"return",
"$",
"oWishlist",
";",
"}"
] | return the users wishlist. if no wishlist exists, the method will return
null - unless the option bCreateIfNotExists is set, then we will
create a new on.
@param bool $bCreateIfNotExists
@return TdbPkgShopWishlist | [
"return",
"the",
"users",
"wishlist",
".",
"if",
"no",
"wishlist",
"exists",
"the",
"method",
"will",
"return",
"null",
"-",
"unless",
"the",
"option",
"bCreateIfNotExists",
"is",
"set",
"then",
"we",
"will",
"create",
"a",
"new",
"on",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/pkgExtranet/objects/db/TShopWishlistDataExtranetUser.class.php#L56-L77 |
31,503 | chameleon-system/chameleon-shop | src/ImageHotspotBundle/objects/WebModules/MTPkgImageHotspotCore/MTPkgImageHotspotCore.class.php | MTPkgImageHotspotCore.& | protected function &GetNextItem()
{
if (is_null($this->oNextItem)) {
$oActiveItem = &$this->GetActiveItem();
$oItemList = &$this->GetHotspotConfig()->GetFieldPkgImageHotspotItemList();
if ($oItemList->Length() < 2) {
$retValue = null; // write to variable to satisfy strict mode
return $retValue;
}
$oItemList->GoToStart();
while (is_null($this->oNextItem) && ($oItem = $oItemList->Next())) {
if ($oItem->IsSameAs($oActiveItem)) {
$this->oNextItem = $oItemList->Next();
if (false == $this->oNextItem) {
$oItemList->GoToStart();
$this->oNextItem = $oItemList->Next();
}
}
}
if (!is_null($this->oNextItem) && $this->oNextItem->IsSameAs($oActiveItem)) {
$this->oNextItem = null;
}
}
return $this->oNextItem;
} | php | protected function &GetNextItem()
{
if (is_null($this->oNextItem)) {
$oActiveItem = &$this->GetActiveItem();
$oItemList = &$this->GetHotspotConfig()->GetFieldPkgImageHotspotItemList();
if ($oItemList->Length() < 2) {
$retValue = null; // write to variable to satisfy strict mode
return $retValue;
}
$oItemList->GoToStart();
while (is_null($this->oNextItem) && ($oItem = $oItemList->Next())) {
if ($oItem->IsSameAs($oActiveItem)) {
$this->oNextItem = $oItemList->Next();
if (false == $this->oNextItem) {
$oItemList->GoToStart();
$this->oNextItem = $oItemList->Next();
}
}
}
if (!is_null($this->oNextItem) && $this->oNextItem->IsSameAs($oActiveItem)) {
$this->oNextItem = null;
}
}
return $this->oNextItem;
} | [
"protected",
"function",
"&",
"GetNextItem",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oNextItem",
")",
")",
"{",
"$",
"oActiveItem",
"=",
"&",
"$",
"this",
"->",
"GetActiveItem",
"(",
")",
";",
"$",
"oItemList",
"=",
"&",
"$",
"this",
"->",
"GetHotspotConfig",
"(",
")",
"->",
"GetFieldPkgImageHotspotItemList",
"(",
")",
";",
"if",
"(",
"$",
"oItemList",
"->",
"Length",
"(",
")",
"<",
"2",
")",
"{",
"$",
"retValue",
"=",
"null",
";",
"// write to variable to satisfy strict mode",
"return",
"$",
"retValue",
";",
"}",
"$",
"oItemList",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oNextItem",
")",
"&&",
"(",
"$",
"oItem",
"=",
"$",
"oItemList",
"->",
"Next",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"oItem",
"->",
"IsSameAs",
"(",
"$",
"oActiveItem",
")",
")",
"{",
"$",
"this",
"->",
"oNextItem",
"=",
"$",
"oItemList",
"->",
"Next",
"(",
")",
";",
"if",
"(",
"false",
"==",
"$",
"this",
"->",
"oNextItem",
")",
"{",
"$",
"oItemList",
"->",
"GoToStart",
"(",
")",
";",
"$",
"this",
"->",
"oNextItem",
"=",
"$",
"oItemList",
"->",
"Next",
"(",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oNextItem",
")",
"&&",
"$",
"this",
"->",
"oNextItem",
"->",
"IsSameAs",
"(",
"$",
"oActiveItem",
")",
")",
"{",
"$",
"this",
"->",
"oNextItem",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"oNextItem",
";",
"}"
] | return the hotspot following the current active spot. if the active spot is the
last spot, then we will return the first step.
@return TdbPkgImageHotspotItem|null | [
"return",
"the",
"hotspot",
"following",
"the",
"current",
"active",
"spot",
".",
"if",
"the",
"active",
"spot",
"is",
"the",
"last",
"spot",
"then",
"we",
"will",
"return",
"the",
"first",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ImageHotspotBundle/objects/WebModules/MTPkgImageHotspotCore/MTPkgImageHotspotCore.class.php#L144-L169 |
31,504 | chameleon-system/chameleon-shop | src/ImageHotspotBundle/objects/WebModules/MTPkgImageHotspotCore/MTPkgImageHotspotCore.class.php | MTPkgImageHotspotCore.& | protected function &GetHotspotConfig()
{
if (is_null($this->oHotspotConfig)) {
$this->oHotspotConfig = TdbPkgImageHotspot::GetNewInstance();
if (!$this->oHotspotConfig->LoadFromField('cms_tpl_module_instance_id', $this->instanceID)) {
$this->oHotspotConfig = null;
}
}
return $this->oHotspotConfig;
} | php | protected function &GetHotspotConfig()
{
if (is_null($this->oHotspotConfig)) {
$this->oHotspotConfig = TdbPkgImageHotspot::GetNewInstance();
if (!$this->oHotspotConfig->LoadFromField('cms_tpl_module_instance_id', $this->instanceID)) {
$this->oHotspotConfig = null;
}
}
return $this->oHotspotConfig;
} | [
"protected",
"function",
"&",
"GetHotspotConfig",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oHotspotConfig",
")",
")",
"{",
"$",
"this",
"->",
"oHotspotConfig",
"=",
"TdbPkgImageHotspot",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"oHotspotConfig",
"->",
"LoadFromField",
"(",
"'cms_tpl_module_instance_id'",
",",
"$",
"this",
"->",
"instanceID",
")",
")",
"{",
"$",
"this",
"->",
"oHotspotConfig",
"=",
"null",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"oHotspotConfig",
";",
"}"
] | return config for the instance.
@return TdbPkgImageHotspot | [
"return",
"config",
"for",
"the",
"instance",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ImageHotspotBundle/objects/WebModules/MTPkgImageHotspotCore/MTPkgImageHotspotCore.class.php#L176-L186 |
31,505 | chameleon-system/chameleon-shop | src/ImageHotspotBundle/objects/WebModules/MTPkgImageHotspotCore/MTPkgImageHotspotCore.class.php | MTPkgImageHotspotCore.& | protected function &GetActiveItem()
{
if (is_null($this->oActiveItem) && !is_null($this->sActiveItemId)) {
$this->oActiveItem = TdbPkgImageHotspotItem::GetNewInstance();
$this->oActiveItem->Load($this->sActiveItemId);
}
return $this->oActiveItem;
} | php | protected function &GetActiveItem()
{
if (is_null($this->oActiveItem) && !is_null($this->sActiveItemId)) {
$this->oActiveItem = TdbPkgImageHotspotItem::GetNewInstance();
$this->oActiveItem->Load($this->sActiveItemId);
}
return $this->oActiveItem;
} | [
"protected",
"function",
"&",
"GetActiveItem",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"oActiveItem",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"sActiveItemId",
")",
")",
"{",
"$",
"this",
"->",
"oActiveItem",
"=",
"TdbPkgImageHotspotItem",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"this",
"->",
"oActiveItem",
"->",
"Load",
"(",
"$",
"this",
"->",
"sActiveItemId",
")",
";",
"}",
"return",
"$",
"this",
"->",
"oActiveItem",
";",
"}"
] | return the active item.
@return TdbPkgImageHotspotItem | [
"return",
"the",
"active",
"item",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ImageHotspotBundle/objects/WebModules/MTPkgImageHotspotCore/MTPkgImageHotspotCore.class.php#L193-L201 |
31,506 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics._ExecuteCron | protected function _ExecuteCron()
{
$sQuery = "SELECT * FROM `shop_order_basket`
WHERE `shop_order_basket`.`processed` != '1'
ORDER BY `shop_order_basket`.`lastmodified` DESC";
$oOrderBasketList = TdbShopOrderBasketList::GetList($sQuery);
$sStatistics = "#########################################################\r\n";
while ($oOrderBasket = $oOrderBasketList->Next()) {
$sStatistics .= $this->GenerateStatisticsFromOrderBasket($oOrderBasket);
$this->MarkOrderBasketAsProcessed($oOrderBasket);
++$this->sTotalBaskets;
}
if ($oOrderBasketList->Length() > 0) {
$sTotalStatistics = $this->GetTotalStatistics().$sStatistics;
$this->SendBasketStatistics($sTotalStatistics);
}
} | php | protected function _ExecuteCron()
{
$sQuery = "SELECT * FROM `shop_order_basket`
WHERE `shop_order_basket`.`processed` != '1'
ORDER BY `shop_order_basket`.`lastmodified` DESC";
$oOrderBasketList = TdbShopOrderBasketList::GetList($sQuery);
$sStatistics = "#########################################################\r\n";
while ($oOrderBasket = $oOrderBasketList->Next()) {
$sStatistics .= $this->GenerateStatisticsFromOrderBasket($oOrderBasket);
$this->MarkOrderBasketAsProcessed($oOrderBasket);
++$this->sTotalBaskets;
}
if ($oOrderBasketList->Length() > 0) {
$sTotalStatistics = $this->GetTotalStatistics().$sStatistics;
$this->SendBasketStatistics($sTotalStatistics);
}
} | [
"protected",
"function",
"_ExecuteCron",
"(",
")",
"{",
"$",
"sQuery",
"=",
"\"SELECT * FROM `shop_order_basket`\n WHERE `shop_order_basket`.`processed` != '1'\n ORDER BY `shop_order_basket`.`lastmodified` DESC\"",
";",
"$",
"oOrderBasketList",
"=",
"TdbShopOrderBasketList",
"::",
"GetList",
"(",
"$",
"sQuery",
")",
";",
"$",
"sStatistics",
"=",
"\"#########################################################\\r\\n\"",
";",
"while",
"(",
"$",
"oOrderBasket",
"=",
"$",
"oOrderBasketList",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"sStatistics",
".=",
"$",
"this",
"->",
"GenerateStatisticsFromOrderBasket",
"(",
"$",
"oOrderBasket",
")",
";",
"$",
"this",
"->",
"MarkOrderBasketAsProcessed",
"(",
"$",
"oOrderBasket",
")",
";",
"++",
"$",
"this",
"->",
"sTotalBaskets",
";",
"}",
"if",
"(",
"$",
"oOrderBasketList",
"->",
"Length",
"(",
")",
">",
"0",
")",
"{",
"$",
"sTotalStatistics",
"=",
"$",
"this",
"->",
"GetTotalStatistics",
"(",
")",
".",
"$",
"sStatistics",
";",
"$",
"this",
"->",
"SendBasketStatistics",
"(",
"$",
"sTotalStatistics",
")",
";",
"}",
"}"
] | Get all none processed shop baskets and send generated statistics to shop owner. | [
"Get",
"all",
"none",
"processed",
"shop",
"baskets",
"and",
"send",
"generated",
"statistics",
"to",
"shop",
"owner",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L26-L42 |
31,507 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.MarkOrderBasketAsProcessed | protected function MarkOrderBasketAsProcessed($oOrderBasket)
{
$oOrderBasket->AllowEditByAll(true);
$oOrderBasket->sqlData['processed'] = 1;
$oOrderBasket->Save();
$oOrderBasket->AllowEditByAll(false);
} | php | protected function MarkOrderBasketAsProcessed($oOrderBasket)
{
$oOrderBasket->AllowEditByAll(true);
$oOrderBasket->sqlData['processed'] = 1;
$oOrderBasket->Save();
$oOrderBasket->AllowEditByAll(false);
} | [
"protected",
"function",
"MarkOrderBasketAsProcessed",
"(",
"$",
"oOrderBasket",
")",
"{",
"$",
"oOrderBasket",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"oOrderBasket",
"->",
"sqlData",
"[",
"'processed'",
"]",
"=",
"1",
";",
"$",
"oOrderBasket",
"->",
"Save",
"(",
")",
";",
"$",
"oOrderBasket",
"->",
"AllowEditByAll",
"(",
"false",
")",
";",
"}"
] | Mark order basket as processed. So no statistics for this order basket will be generated next time.
@param TdbShopOrderBasket $oOrderBasket | [
"Mark",
"order",
"basket",
"as",
"processed",
".",
"So",
"no",
"statistics",
"for",
"this",
"order",
"basket",
"will",
"be",
"generated",
"next",
"time",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L49-L55 |
31,508 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.GetTotalStatistics | protected function GetTotalStatistics()
{
$sTotalStatistics = "#########################################################\r\n";
$sTotalStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.headline')."\r\n";
$sTotalStatistics .= "------------------------------------\r\n";
foreach ($this->aCancelStep as $sStempName => $sValue) {
$sPercent = round((100 / $this->sTotalBaskets) * $sValue);
if ($sStempName != TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed')) {
$sTotalStatistics .= TGlobal::Translate(
'chameleon_system_shop.cron_send_basket_stats.text_aborted',
array(
'%step%' => $sStempName,
'%value%' => $sValue,
'%totalBaskets%' => $this->sTotalBaskets,
'%percent%' => $sPercent,
)
)."\r\n";
} else {
$sTotalStatistics .= TGlobal::Translate(
'chameleon_system_shop.cron_send_basket_stats.text_completed',
array(
'%value%' => $sValue,
'%totalBaskets%' => $this->sTotalBaskets,
'%percent%' => $sPercent,
)
)."\r\n";
}
}
$sTotalStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_total_aborted_orders').': '.$this->sTotalMoneyCanceled;
return $sTotalStatistics."\r\n";
} | php | protected function GetTotalStatistics()
{
$sTotalStatistics = "#########################################################\r\n";
$sTotalStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.headline')."\r\n";
$sTotalStatistics .= "------------------------------------\r\n";
foreach ($this->aCancelStep as $sStempName => $sValue) {
$sPercent = round((100 / $this->sTotalBaskets) * $sValue);
if ($sStempName != TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed')) {
$sTotalStatistics .= TGlobal::Translate(
'chameleon_system_shop.cron_send_basket_stats.text_aborted',
array(
'%step%' => $sStempName,
'%value%' => $sValue,
'%totalBaskets%' => $this->sTotalBaskets,
'%percent%' => $sPercent,
)
)."\r\n";
} else {
$sTotalStatistics .= TGlobal::Translate(
'chameleon_system_shop.cron_send_basket_stats.text_completed',
array(
'%value%' => $sValue,
'%totalBaskets%' => $this->sTotalBaskets,
'%percent%' => $sPercent,
)
)."\r\n";
}
}
$sTotalStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_total_aborted_orders').': '.$this->sTotalMoneyCanceled;
return $sTotalStatistics."\r\n";
} | [
"protected",
"function",
"GetTotalStatistics",
"(",
")",
"{",
"$",
"sTotalStatistics",
"=",
"\"#########################################################\\r\\n\"",
";",
"$",
"sTotalStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.headline'",
")",
".",
"\"\\r\\n\"",
";",
"$",
"sTotalStatistics",
".=",
"\"------------------------------------\\r\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"aCancelStep",
"as",
"$",
"sStempName",
"=>",
"$",
"sValue",
")",
"{",
"$",
"sPercent",
"=",
"round",
"(",
"(",
"100",
"/",
"$",
"this",
"->",
"sTotalBaskets",
")",
"*",
"$",
"sValue",
")",
";",
"if",
"(",
"$",
"sStempName",
"!=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.completed'",
")",
")",
"{",
"$",
"sTotalStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.text_aborted'",
",",
"array",
"(",
"'%step%'",
"=>",
"$",
"sStempName",
",",
"'%value%'",
"=>",
"$",
"sValue",
",",
"'%totalBaskets%'",
"=>",
"$",
"this",
"->",
"sTotalBaskets",
",",
"'%percent%'",
"=>",
"$",
"sPercent",
",",
")",
")",
".",
"\"\\r\\n\"",
";",
"}",
"else",
"{",
"$",
"sTotalStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.text_completed'",
",",
"array",
"(",
"'%value%'",
"=>",
"$",
"sValue",
",",
"'%totalBaskets%'",
"=>",
"$",
"this",
"->",
"sTotalBaskets",
",",
"'%percent%'",
"=>",
"$",
"sPercent",
",",
")",
")",
".",
"\"\\r\\n\"",
";",
"}",
"}",
"$",
"sTotalStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.text_total_aborted_orders'",
")",
".",
"': '",
".",
"$",
"this",
"->",
"sTotalMoneyCanceled",
";",
"return",
"$",
"sTotalStatistics",
".",
"\"\\r\\n\"",
";",
"}"
] | Get overfiew statistics of all processed order baskets.
@return string | [
"Get",
"overfiew",
"statistics",
"of",
"all",
"processed",
"order",
"baskets",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L62-L93 |
31,509 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.GenerateStatisticsFromOrderBasket | protected function GenerateStatisticsFromOrderBasket($oOrderBasket)
{
$sStatistics = '';
if (empty($oOrderBasket->fieldShopOrderId)) {
$sStatistics = $this->GetCancelBasketInformation($oOrderBasket);
$oUser = TdbDataExtranetUser::GetNewInstance();
$oUser = unserialize(base64_decode($oOrderBasket->fieldRawdataUser));
if (is_object($oUser)) {
$sStatistics .= $this->GetUserStatistics($oUser);
}
$oBasket = new TShopBasket();
$oBasket = unserialize(base64_decode($oOrderBasket->fieldRawdataBasket));
if (is_object($oBasket)) {
$sStatistics .= $this->GetBasketStatistics($oBasket);
}
$sStatistics .= "#########################################################\r\n";
} else {
$this->AddCompleteOrderToStatistics();
}
return $sStatistics;
} | php | protected function GenerateStatisticsFromOrderBasket($oOrderBasket)
{
$sStatistics = '';
if (empty($oOrderBasket->fieldShopOrderId)) {
$sStatistics = $this->GetCancelBasketInformation($oOrderBasket);
$oUser = TdbDataExtranetUser::GetNewInstance();
$oUser = unserialize(base64_decode($oOrderBasket->fieldRawdataUser));
if (is_object($oUser)) {
$sStatistics .= $this->GetUserStatistics($oUser);
}
$oBasket = new TShopBasket();
$oBasket = unserialize(base64_decode($oOrderBasket->fieldRawdataBasket));
if (is_object($oBasket)) {
$sStatistics .= $this->GetBasketStatistics($oBasket);
}
$sStatistics .= "#########################################################\r\n";
} else {
$this->AddCompleteOrderToStatistics();
}
return $sStatistics;
} | [
"protected",
"function",
"GenerateStatisticsFromOrderBasket",
"(",
"$",
"oOrderBasket",
")",
"{",
"$",
"sStatistics",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"oOrderBasket",
"->",
"fieldShopOrderId",
")",
")",
"{",
"$",
"sStatistics",
"=",
"$",
"this",
"->",
"GetCancelBasketInformation",
"(",
"$",
"oOrderBasket",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oUser",
"=",
"unserialize",
"(",
"base64_decode",
"(",
"$",
"oOrderBasket",
"->",
"fieldRawdataUser",
")",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"oUser",
")",
")",
"{",
"$",
"sStatistics",
".=",
"$",
"this",
"->",
"GetUserStatistics",
"(",
"$",
"oUser",
")",
";",
"}",
"$",
"oBasket",
"=",
"new",
"TShopBasket",
"(",
")",
";",
"$",
"oBasket",
"=",
"unserialize",
"(",
"base64_decode",
"(",
"$",
"oOrderBasket",
"->",
"fieldRawdataBasket",
")",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"oBasket",
")",
")",
"{",
"$",
"sStatistics",
".=",
"$",
"this",
"->",
"GetBasketStatistics",
"(",
"$",
"oBasket",
")",
";",
"}",
"$",
"sStatistics",
".=",
"\"#########################################################\\r\\n\"",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"AddCompleteOrderToStatistics",
"(",
")",
";",
"}",
"return",
"$",
"sStatistics",
";",
"}"
] | Generate user and basket statistics for given order basket.
@param TdbShopOrderBasket $oOrderBasket
@return string | [
"Generate",
"user",
"and",
"basket",
"statistics",
"for",
"given",
"order",
"basket",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L102-L123 |
31,510 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.AddCompleteOrderToStatistics | protected function AddCompleteOrderToStatistics()
{
if (array_key_exists(TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed'), $this->aCancelStep)) {
++$this->aCancelStep[TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed')];
} else {
$this->aCancelStep[TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed')] = 1;
}
} | php | protected function AddCompleteOrderToStatistics()
{
if (array_key_exists(TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed'), $this->aCancelStep)) {
++$this->aCancelStep[TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed')];
} else {
$this->aCancelStep[TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.completed')] = 1;
}
} | [
"protected",
"function",
"AddCompleteOrderToStatistics",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.completed'",
")",
",",
"$",
"this",
"->",
"aCancelStep",
")",
")",
"{",
"++",
"$",
"this",
"->",
"aCancelStep",
"[",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.completed'",
")",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aCancelStep",
"[",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.completed'",
")",
"]",
"=",
"1",
";",
"}",
"}"
] | If basket was finished completely add it to overfiew statistics. | [
"If",
"basket",
"was",
"finished",
"completely",
"add",
"it",
"to",
"overfiew",
"statistics",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L128-L135 |
31,511 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.GetCancelBasketInformation | protected function GetCancelBasketInformation($oOrderBasket)
{
$sCancelBasketInformation = '';
$sCancelBasketInformation .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_general_info')."\r\n";
$sCancelBasketInformation .= "------------------------------------\r\n";
$oCancelStep = TdbShopOrderStep::GetStep($oOrderBasket->fieldUpdateStepname);
$sCancelBasketInformation .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_general_aborted', array('%step%' => $oCancelStep->fieldName))."\r\n";
if (array_key_exists($oCancelStep->fieldName, $this->aCancelStep)) {
++$this->aCancelStep[$oCancelStep->fieldName];
} else {
$this->aCancelStep[$oCancelStep->fieldName] = 1;
}
return $sCancelBasketInformation;
} | php | protected function GetCancelBasketInformation($oOrderBasket)
{
$sCancelBasketInformation = '';
$sCancelBasketInformation .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_general_info')."\r\n";
$sCancelBasketInformation .= "------------------------------------\r\n";
$oCancelStep = TdbShopOrderStep::GetStep($oOrderBasket->fieldUpdateStepname);
$sCancelBasketInformation .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_general_aborted', array('%step%' => $oCancelStep->fieldName))."\r\n";
if (array_key_exists($oCancelStep->fieldName, $this->aCancelStep)) {
++$this->aCancelStep[$oCancelStep->fieldName];
} else {
$this->aCancelStep[$oCancelStep->fieldName] = 1;
}
return $sCancelBasketInformation;
} | [
"protected",
"function",
"GetCancelBasketInformation",
"(",
"$",
"oOrderBasket",
")",
"{",
"$",
"sCancelBasketInformation",
"=",
"''",
";",
"$",
"sCancelBasketInformation",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.text_general_info'",
")",
".",
"\"\\r\\n\"",
";",
"$",
"sCancelBasketInformation",
".=",
"\"------------------------------------\\r\\n\"",
";",
"$",
"oCancelStep",
"=",
"TdbShopOrderStep",
"::",
"GetStep",
"(",
"$",
"oOrderBasket",
"->",
"fieldUpdateStepname",
")",
";",
"$",
"sCancelBasketInformation",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.text_general_aborted'",
",",
"array",
"(",
"'%step%'",
"=>",
"$",
"oCancelStep",
"->",
"fieldName",
")",
")",
".",
"\"\\r\\n\"",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"oCancelStep",
"->",
"fieldName",
",",
"$",
"this",
"->",
"aCancelStep",
")",
")",
"{",
"++",
"$",
"this",
"->",
"aCancelStep",
"[",
"$",
"oCancelStep",
"->",
"fieldName",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"aCancelStep",
"[",
"$",
"oCancelStep",
"->",
"fieldName",
"]",
"=",
"1",
";",
"}",
"return",
"$",
"sCancelBasketInformation",
";",
"}"
] | Get statistics on which basket step the user canceled.
@param TdbShopOrderBasket $oOrderBasket
@return string | [
"Get",
"statistics",
"on",
"which",
"basket",
"step",
"the",
"user",
"canceled",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L144-L158 |
31,512 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.GetUserStatistics | protected function GetUserStatistics($oUser)
{
$sUserStatistics = '';
$sUserStatistics .= "------------------------------------\r\n\r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_user')."\r\n";
$sUserStatistics .= "------------------------------------\r\n";
if (count($oUser->sqlData) > 0) {
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_name').': '.$oUser->fieldFirstname.' '.$oUser->fieldLastname." \r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_email').': '.$oUser->fieldName." \r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_street').': '.$oUser->fieldStreet.' '.$oUser->fieldStreetnr." \r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_zip').': '.$oUser->fieldPostalcode.' '.$oUser->fieldCity." \r\n";
$oCountry = TdbDataCountry::GetNewInstance();
if ($oCountry->Load($oUser->fieldDataCountryId)) {
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_country').': '.$oCountry->GetName()." \r\n";
}
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_telefon').': '.$oUser->fieldTelefon." \r\n";
} else {
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.guest_user')."\r\n";
}
return $sUserStatistics;
} | php | protected function GetUserStatistics($oUser)
{
$sUserStatistics = '';
$sUserStatistics .= "------------------------------------\r\n\r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.text_user')."\r\n";
$sUserStatistics .= "------------------------------------\r\n";
if (count($oUser->sqlData) > 0) {
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_name').': '.$oUser->fieldFirstname.' '.$oUser->fieldLastname." \r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_email').': '.$oUser->fieldName." \r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_street').': '.$oUser->fieldStreet.' '.$oUser->fieldStreetnr." \r\n";
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_zip').': '.$oUser->fieldPostalcode.' '.$oUser->fieldCity." \r\n";
$oCountry = TdbDataCountry::GetNewInstance();
if ($oCountry->Load($oUser->fieldDataCountryId)) {
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_country').': '.$oCountry->GetName()." \r\n";
}
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.user_telefon').': '.$oUser->fieldTelefon." \r\n";
} else {
$sUserStatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.guest_user')."\r\n";
}
return $sUserStatistics;
} | [
"protected",
"function",
"GetUserStatistics",
"(",
"$",
"oUser",
")",
"{",
"$",
"sUserStatistics",
"=",
"''",
";",
"$",
"sUserStatistics",
".=",
"\"------------------------------------\\r\\n\\r\\n\"",
";",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.text_user'",
")",
".",
"\"\\r\\n\"",
";",
"$",
"sUserStatistics",
".=",
"\"------------------------------------\\r\\n\"",
";",
"if",
"(",
"count",
"(",
"$",
"oUser",
"->",
"sqlData",
")",
">",
"0",
")",
"{",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.user_name'",
")",
".",
"': '",
".",
"$",
"oUser",
"->",
"fieldFirstname",
".",
"' '",
".",
"$",
"oUser",
"->",
"fieldLastname",
".",
"\" \\r\\n\"",
";",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.user_email'",
")",
".",
"': '",
".",
"$",
"oUser",
"->",
"fieldName",
".",
"\" \\r\\n\"",
";",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.user_street'",
")",
".",
"': '",
".",
"$",
"oUser",
"->",
"fieldStreet",
".",
"' '",
".",
"$",
"oUser",
"->",
"fieldStreetnr",
".",
"\" \\r\\n\"",
";",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.user_zip'",
")",
".",
"': '",
".",
"$",
"oUser",
"->",
"fieldPostalcode",
".",
"' '",
".",
"$",
"oUser",
"->",
"fieldCity",
".",
"\" \\r\\n\"",
";",
"$",
"oCountry",
"=",
"TdbDataCountry",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"$",
"oCountry",
"->",
"Load",
"(",
"$",
"oUser",
"->",
"fieldDataCountryId",
")",
")",
"{",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.user_country'",
")",
".",
"': '",
".",
"$",
"oCountry",
"->",
"GetName",
"(",
")",
".",
"\" \\r\\n\"",
";",
"}",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.user_telefon'",
")",
".",
"': '",
".",
"$",
"oUser",
"->",
"fieldTelefon",
".",
"\" \\r\\n\"",
";",
"}",
"else",
"{",
"$",
"sUserStatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.guest_user'",
")",
".",
"\"\\r\\n\"",
";",
"}",
"return",
"$",
"sUserStatistics",
";",
"}"
] | Get user statistics for canceled basket step.
@param TdbDataExtranetUser $oUser
@return string | [
"Get",
"user",
"statistics",
"for",
"canceled",
"basket",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L167-L188 |
31,513 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.GetBasketStatistics | protected function GetBasketStatistics($oBasket)
{
$sBasketstatistics = '';
$sBasketstatistics .= "------------------------------------\r\n\r\n";
$sBasketstatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.basket_content')."\r\n";
$sBasketstatistics .= "------------------------------------\r\n";
$oArticleList = $oBasket->GetBasketContents();
$oArticleList->GoToStart();
while ($oArticle = $oArticleList->Next()) {
$sBasketstatistics .= TGlobal::Translate(
'chameleon_system_shop.cron_send_basket_stats.basket_content_line',
array(
'%amount%' => '',
'%name%' => '',
'%price%' => '',
'%totalPrice%' => '',
)
)."\r\n";
}
$sBasketstatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.basket_content_total', array('%basketTotal%' => $oBasket->dCostArticlesTotal))."\r\n";
$this->sTotalMoneyCanceled = $this->sTotalMoneyCanceled + $oBasket->dCostArticlesTotal;
$sBasketstatistics .= "------------------------------------\r\n";
return $sBasketstatistics;
} | php | protected function GetBasketStatistics($oBasket)
{
$sBasketstatistics = '';
$sBasketstatistics .= "------------------------------------\r\n\r\n";
$sBasketstatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.basket_content')."\r\n";
$sBasketstatistics .= "------------------------------------\r\n";
$oArticleList = $oBasket->GetBasketContents();
$oArticleList->GoToStart();
while ($oArticle = $oArticleList->Next()) {
$sBasketstatistics .= TGlobal::Translate(
'chameleon_system_shop.cron_send_basket_stats.basket_content_line',
array(
'%amount%' => '',
'%name%' => '',
'%price%' => '',
'%totalPrice%' => '',
)
)."\r\n";
}
$sBasketstatistics .= TGlobal::Translate('chameleon_system_shop.cron_send_basket_stats.basket_content_total', array('%basketTotal%' => $oBasket->dCostArticlesTotal))."\r\n";
$this->sTotalMoneyCanceled = $this->sTotalMoneyCanceled + $oBasket->dCostArticlesTotal;
$sBasketstatistics .= "------------------------------------\r\n";
return $sBasketstatistics;
} | [
"protected",
"function",
"GetBasketStatistics",
"(",
"$",
"oBasket",
")",
"{",
"$",
"sBasketstatistics",
"=",
"''",
";",
"$",
"sBasketstatistics",
".=",
"\"------------------------------------\\r\\n\\r\\n\"",
";",
"$",
"sBasketstatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.basket_content'",
")",
".",
"\"\\r\\n\"",
";",
"$",
"sBasketstatistics",
".=",
"\"------------------------------------\\r\\n\"",
";",
"$",
"oArticleList",
"=",
"$",
"oBasket",
"->",
"GetBasketContents",
"(",
")",
";",
"$",
"oArticleList",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"$",
"oArticle",
"=",
"$",
"oArticleList",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"sBasketstatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.basket_content_line'",
",",
"array",
"(",
"'%amount%'",
"=>",
"''",
",",
"'%name%'",
"=>",
"''",
",",
"'%price%'",
"=>",
"''",
",",
"'%totalPrice%'",
"=>",
"''",
",",
")",
")",
".",
"\"\\r\\n\"",
";",
"}",
"$",
"sBasketstatistics",
".=",
"TGlobal",
"::",
"Translate",
"(",
"'chameleon_system_shop.cron_send_basket_stats.basket_content_total'",
",",
"array",
"(",
"'%basketTotal%'",
"=>",
"$",
"oBasket",
"->",
"dCostArticlesTotal",
")",
")",
".",
"\"\\r\\n\"",
";",
"$",
"this",
"->",
"sTotalMoneyCanceled",
"=",
"$",
"this",
"->",
"sTotalMoneyCanceled",
"+",
"$",
"oBasket",
"->",
"dCostArticlesTotal",
";",
"$",
"sBasketstatistics",
".=",
"\"------------------------------------\\r\\n\"",
";",
"return",
"$",
"sBasketstatistics",
";",
"}"
] | Get basket statistics for canceled basket step.
@param TShopBasket $oBasket
@return string | [
"Get",
"basket",
"statistics",
"for",
"canceled",
"basket",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L197-L221 |
31,514 | chameleon-system/chameleon-shop | src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php | TCMSCronJob_ShopSendBasketLogStatisics.SendBasketStatistics | protected function SendBasketStatistics($sStatistics)
{
$oMail = TDataMailProfile::GetProfile(self::MAIL_SYSTEM_NAME);
$aMailData = array();
$aMailData['sStatistics'] = $sStatistics;
$oMail->AddDataArray($aMailData);
$oMail->SendUsingObjectView('emails', 'Customer');
} | php | protected function SendBasketStatistics($sStatistics)
{
$oMail = TDataMailProfile::GetProfile(self::MAIL_SYSTEM_NAME);
$aMailData = array();
$aMailData['sStatistics'] = $sStatistics;
$oMail->AddDataArray($aMailData);
$oMail->SendUsingObjectView('emails', 'Customer');
} | [
"protected",
"function",
"SendBasketStatistics",
"(",
"$",
"sStatistics",
")",
"{",
"$",
"oMail",
"=",
"TDataMailProfile",
"::",
"GetProfile",
"(",
"self",
"::",
"MAIL_SYSTEM_NAME",
")",
";",
"$",
"aMailData",
"=",
"array",
"(",
")",
";",
"$",
"aMailData",
"[",
"'sStatistics'",
"]",
"=",
"$",
"sStatistics",
";",
"$",
"oMail",
"->",
"AddDataArray",
"(",
"$",
"aMailData",
")",
";",
"$",
"oMail",
"->",
"SendUsingObjectView",
"(",
"'emails'",
",",
"'Customer'",
")",
";",
"}"
] | Send complete statisticreport to shop owner.
@param string $sStatistics | [
"Send",
"complete",
"statisticreport",
"to",
"shop",
"owner",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/CronJobs/TCMSCronJob_ShopSendBasketLogStatisics.class.php#L228-L235 |
31,515 | edmondscommerce/doctrine-static-meta | src/Entity/Savers/BulkEntityUpdater.php | BulkEntityUpdater.convertExtractedToSqlRow | private function convertExtractedToSqlRow(array $extracted): string
{
if ([] === $extracted) {
throw new \RuntimeException('Extracted array is empty in ' . __METHOD__);
}
$primaryKeyCol = null;
$primaryKey = null;
$sql = "update `{$this->tableName}` set ";
$sqls = [];
foreach ($extracted as $key => $value) {
if (null === $primaryKeyCol) {
$primaryKeyCol = $key;
$primaryKey = $this->convertUuidToSqlString($value);
continue;
}
$value = $this->mysqli->escape_string((string)$value);
$sqls[] = "`$key` = '$value'";
}
$sql .= implode(",\n", $sqls);
$sql .= " where `$primaryKeyCol` = $primaryKey; ";
return $sql;
} | php | private function convertExtractedToSqlRow(array $extracted): string
{
if ([] === $extracted) {
throw new \RuntimeException('Extracted array is empty in ' . __METHOD__);
}
$primaryKeyCol = null;
$primaryKey = null;
$sql = "update `{$this->tableName}` set ";
$sqls = [];
foreach ($extracted as $key => $value) {
if (null === $primaryKeyCol) {
$primaryKeyCol = $key;
$primaryKey = $this->convertUuidToSqlString($value);
continue;
}
$value = $this->mysqli->escape_string((string)$value);
$sqls[] = "`$key` = '$value'";
}
$sql .= implode(",\n", $sqls);
$sql .= " where `$primaryKeyCol` = $primaryKey; ";
return $sql;
} | [
"private",
"function",
"convertExtractedToSqlRow",
"(",
"array",
"$",
"extracted",
")",
":",
"string",
"{",
"if",
"(",
"[",
"]",
"===",
"$",
"extracted",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Extracted array is empty in '",
".",
"__METHOD__",
")",
";",
"}",
"$",
"primaryKeyCol",
"=",
"null",
";",
"$",
"primaryKey",
"=",
"null",
";",
"$",
"sql",
"=",
"\"update `{$this->tableName}` set \"",
";",
"$",
"sqls",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"extracted",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"primaryKeyCol",
")",
"{",
"$",
"primaryKeyCol",
"=",
"$",
"key",
";",
"$",
"primaryKey",
"=",
"$",
"this",
"->",
"convertUuidToSqlString",
"(",
"$",
"value",
")",
";",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"mysqli",
"->",
"escape_string",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"$",
"sqls",
"[",
"]",
"=",
"\"`$key` = '$value'\"",
";",
"}",
"$",
"sql",
".=",
"implode",
"(",
"\",\\n\"",
",",
"$",
"sqls",
")",
";",
"$",
"sql",
".=",
"\" where `$primaryKeyCol` = $primaryKey; \"",
";",
"return",
"$",
"sql",
";",
"}"
] | Take the extracted array and build an update query
@param array $extracted
@return string | [
"Take",
"the",
"extracted",
"array",
"and",
"build",
"an",
"update",
"query"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Savers/BulkEntityUpdater.php#L174-L196 |
31,516 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Creation/AbstractCreator.php | AbstractCreator.updateRootDirOnTargetFile | private function updateRootDirOnTargetFile(): void
{
$realTemplateTestsPath = realpath(self::ROOT_TEMPLATE_PATH . self::TEST_DIR);
if (0 === \strpos($this->templateFile->getPath(), $realTemplateTestsPath)) {
$updatedPath = str_replace(
'/src/',
'/tests/',
$this->targetFile->getPath()
);
$this->targetFile->setPath($updatedPath);
}
} | php | private function updateRootDirOnTargetFile(): void
{
$realTemplateTestsPath = realpath(self::ROOT_TEMPLATE_PATH . self::TEST_DIR);
if (0 === \strpos($this->templateFile->getPath(), $realTemplateTestsPath)) {
$updatedPath = str_replace(
'/src/',
'/tests/',
$this->targetFile->getPath()
);
$this->targetFile->setPath($updatedPath);
}
} | [
"private",
"function",
"updateRootDirOnTargetFile",
"(",
")",
":",
"void",
"{",
"$",
"realTemplateTestsPath",
"=",
"realpath",
"(",
"self",
"::",
"ROOT_TEMPLATE_PATH",
".",
"self",
"::",
"TEST_DIR",
")",
";",
"if",
"(",
"0",
"===",
"\\",
"strpos",
"(",
"$",
"this",
"->",
"templateFile",
"->",
"getPath",
"(",
")",
",",
"$",
"realTemplateTestsPath",
")",
")",
"{",
"$",
"updatedPath",
"=",
"str_replace",
"(",
"'/src/'",
",",
"'/tests/'",
",",
"$",
"this",
"->",
"targetFile",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"this",
"->",
"targetFile",
"->",
"setPath",
"(",
"$",
"updatedPath",
")",
";",
"}",
"}"
] | Where the template file is in tests, we need to fix that in the target file | [
"Where",
"the",
"template",
"file",
"is",
"in",
"tests",
"we",
"need",
"to",
"fix",
"that",
"in",
"the",
"target",
"file"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Creation/AbstractCreator.php#L134-L145 |
31,517 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Creation/AbstractCreator.php | AbstractCreator.configurePipeline | protected function configurePipeline(): void
{
$this->pipeline = new Pipeline($this->findReplaceFactory);
$this->registerReplaceName();
$this->registerReplaceProjectRootNamespace();
} | php | protected function configurePipeline(): void
{
$this->pipeline = new Pipeline($this->findReplaceFactory);
$this->registerReplaceName();
$this->registerReplaceProjectRootNamespace();
} | [
"protected",
"function",
"configurePipeline",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"pipeline",
"=",
"new",
"Pipeline",
"(",
"$",
"this",
"->",
"findReplaceFactory",
")",
";",
"$",
"this",
"->",
"registerReplaceName",
"(",
")",
";",
"$",
"this",
"->",
"registerReplaceProjectRootNamespace",
"(",
")",
";",
"}"
] | In this method we register all the process steps that we want to rnu against the file
By default this registers the ReplaceNameProcess which is almost certainly required. Other processes can be
registered as required | [
"In",
"this",
"method",
"we",
"register",
"all",
"the",
"process",
"steps",
"that",
"we",
"want",
"to",
"rnu",
"against",
"the",
"file"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Creation/AbstractCreator.php#L161-L166 |
31,518 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Creation/AbstractCreator.php | AbstractCreator.writeIfNotExists | public function writeIfNotExists(): string
{
if ($this->targetFile->exists()) {
return $this->targetFile->getPath();
}
return $this->write();
} | php | public function writeIfNotExists(): string
{
if ($this->targetFile->exists()) {
return $this->targetFile->getPath();
}
return $this->write();
} | [
"public",
"function",
"writeIfNotExists",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"targetFile",
"->",
"exists",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"targetFile",
"->",
"getPath",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}"
] | Write the file only if it doesn't already exist
@return string
@throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException | [
"Write",
"the",
"file",
"only",
"if",
"it",
"doesn",
"t",
"already",
"exist"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Creation/AbstractCreator.php#L193-L200 |
31,519 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Creation/AbstractCreator.php | AbstractCreator.write | public function write(): string
{
$this->targetFile->removeIfExists();
return $this->fileWriter->write($this->targetFile);
} | php | public function write(): string
{
$this->targetFile->removeIfExists();
return $this->fileWriter->write($this->targetFile);
} | [
"public",
"function",
"write",
"(",
")",
":",
"string",
"{",
"$",
"this",
"->",
"targetFile",
"->",
"removeIfExists",
"(",
")",
";",
"return",
"$",
"this",
"->",
"fileWriter",
"->",
"write",
"(",
"$",
"this",
"->",
"targetFile",
")",
";",
"}"
] | Write the file and return the generated path
@return string
@throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException | [
"Write",
"the",
"file",
"and",
"return",
"the",
"generated",
"path"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Creation/AbstractCreator.php#L208-L213 |
31,520 | comporu/compo-core | src/Compo/Sonata/AdminBundle/Listener/LogRevisionsListenerExtend.php | LogRevisionsListenerExtend.getOriginalEntityData | private function getOriginalEntityData($entity)
{
$class = $this->em->getClassMetadata(\get_class($entity));
$data = $this->uow->getOriginalEntityData($entity);
if ($class->isVersioned) {
$versionField = $class->versionField;
$data[$versionField] = $class->reflFields[$versionField]->getValue($entity);
}
return $data;
} | php | private function getOriginalEntityData($entity)
{
$class = $this->em->getClassMetadata(\get_class($entity));
$data = $this->uow->getOriginalEntityData($entity);
if ($class->isVersioned) {
$versionField = $class->versionField;
$data[$versionField] = $class->reflFields[$versionField]->getValue($entity);
}
return $data;
} | [
"private",
"function",
"getOriginalEntityData",
"(",
"$",
"entity",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"\\",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"uow",
"->",
"getOriginalEntityData",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"$",
"class",
"->",
"isVersioned",
")",
"{",
"$",
"versionField",
"=",
"$",
"class",
"->",
"versionField",
";",
"$",
"data",
"[",
"$",
"versionField",
"]",
"=",
"$",
"class",
"->",
"reflFields",
"[",
"$",
"versionField",
"]",
"->",
"getValue",
"(",
"$",
"entity",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | get original entity data, including versioned field, if "version" constraint is used.
@param mixed $entity
@return array | [
"get",
"original",
"entity",
"data",
"including",
"versioned",
"field",
"if",
"version",
"constraint",
"is",
"used",
"."
] | ebaa9fe8a4b831506c78fdf637da6b4deadec1e2 | https://github.com/comporu/compo-core/blob/ebaa9fe8a4b831506c78fdf637da6b4deadec1e2/src/Compo/Sonata/AdminBundle/Listener/LogRevisionsListenerExtend.php#L374-L384 |
31,521 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.setEntityHasRelationToEntity | public function setEntityHasRelationToEntity(
string $owningEntityFqn,
string $hasType,
string $ownedEntityFqn,
bool $requiredReciprocation = false,
bool $internalUseOnly = true
): void {
$reciprocate = $internalUseOnly;
try {
$this->validateHasType($hasType);
list(
$owningTraitPath,
$owningInterfacePath,
$reciprocatingInterfacePath,
) = $this->getPathsForOwningTraitsAndInterfaces(
$hasType,
$ownedEntityFqn
);
list($owningClass, , $owningClassSubDirs) = $this->parseFullyQualifiedName($owningEntityFqn);
$owningClassPath = $this->pathHelper->getPathFromNameAndSubDirs(
$this->pathToProjectRoot,
$owningClass,
$owningClassSubDirs
);
$this->useRelationTraitInClass($owningClassPath, $owningTraitPath);
$this->useRelationInterfaceInEntityInterface($owningClassPath, $owningInterfacePath);
if (\in_array($hasType, self::HAS_TYPES_RECIPROCATED, true)) {
$this->useRelationInterfaceInEntityInterface($owningClassPath, $reciprocatingInterfacePath);
}
if (true === $reciprocate && \in_array($hasType, self::HAS_TYPES_RECIPROCATED, true)) {
$inverseType = $this->getInverseHasType($hasType);
$inverseType = $this->updateHasTypeForPossibleRequired($inverseType, $requiredReciprocation);
$this->setEntityHasRelationToEntity(
$ownedEntityFqn,
$inverseType,
$owningEntityFqn,
/**
* Setting required reciprocation to false,
* actually it is irrelevant because reciprocation is disabled
*/
false,
false
);
}
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | public function setEntityHasRelationToEntity(
string $owningEntityFqn,
string $hasType,
string $ownedEntityFqn,
bool $requiredReciprocation = false,
bool $internalUseOnly = true
): void {
$reciprocate = $internalUseOnly;
try {
$this->validateHasType($hasType);
list(
$owningTraitPath,
$owningInterfacePath,
$reciprocatingInterfacePath,
) = $this->getPathsForOwningTraitsAndInterfaces(
$hasType,
$ownedEntityFqn
);
list($owningClass, , $owningClassSubDirs) = $this->parseFullyQualifiedName($owningEntityFqn);
$owningClassPath = $this->pathHelper->getPathFromNameAndSubDirs(
$this->pathToProjectRoot,
$owningClass,
$owningClassSubDirs
);
$this->useRelationTraitInClass($owningClassPath, $owningTraitPath);
$this->useRelationInterfaceInEntityInterface($owningClassPath, $owningInterfacePath);
if (\in_array($hasType, self::HAS_TYPES_RECIPROCATED, true)) {
$this->useRelationInterfaceInEntityInterface($owningClassPath, $reciprocatingInterfacePath);
}
if (true === $reciprocate && \in_array($hasType, self::HAS_TYPES_RECIPROCATED, true)) {
$inverseType = $this->getInverseHasType($hasType);
$inverseType = $this->updateHasTypeForPossibleRequired($inverseType, $requiredReciprocation);
$this->setEntityHasRelationToEntity(
$ownedEntityFqn,
$inverseType,
$owningEntityFqn,
/**
* Setting required reciprocation to false,
* actually it is irrelevant because reciprocation is disabled
*/
false,
false
);
}
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"public",
"function",
"setEntityHasRelationToEntity",
"(",
"string",
"$",
"owningEntityFqn",
",",
"string",
"$",
"hasType",
",",
"string",
"$",
"ownedEntityFqn",
",",
"bool",
"$",
"requiredReciprocation",
"=",
"false",
",",
"bool",
"$",
"internalUseOnly",
"=",
"true",
")",
":",
"void",
"{",
"$",
"reciprocate",
"=",
"$",
"internalUseOnly",
";",
"try",
"{",
"$",
"this",
"->",
"validateHasType",
"(",
"$",
"hasType",
")",
";",
"list",
"(",
"$",
"owningTraitPath",
",",
"$",
"owningInterfacePath",
",",
"$",
"reciprocatingInterfacePath",
",",
")",
"=",
"$",
"this",
"->",
"getPathsForOwningTraitsAndInterfaces",
"(",
"$",
"hasType",
",",
"$",
"ownedEntityFqn",
")",
";",
"list",
"(",
"$",
"owningClass",
",",
",",
"$",
"owningClassSubDirs",
")",
"=",
"$",
"this",
"->",
"parseFullyQualifiedName",
"(",
"$",
"owningEntityFqn",
")",
";",
"$",
"owningClassPath",
"=",
"$",
"this",
"->",
"pathHelper",
"->",
"getPathFromNameAndSubDirs",
"(",
"$",
"this",
"->",
"pathToProjectRoot",
",",
"$",
"owningClass",
",",
"$",
"owningClassSubDirs",
")",
";",
"$",
"this",
"->",
"useRelationTraitInClass",
"(",
"$",
"owningClassPath",
",",
"$",
"owningTraitPath",
")",
";",
"$",
"this",
"->",
"useRelationInterfaceInEntityInterface",
"(",
"$",
"owningClassPath",
",",
"$",
"owningInterfacePath",
")",
";",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"hasType",
",",
"self",
"::",
"HAS_TYPES_RECIPROCATED",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"useRelationInterfaceInEntityInterface",
"(",
"$",
"owningClassPath",
",",
"$",
"reciprocatingInterfacePath",
")",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"reciprocate",
"&&",
"\\",
"in_array",
"(",
"$",
"hasType",
",",
"self",
"::",
"HAS_TYPES_RECIPROCATED",
",",
"true",
")",
")",
"{",
"$",
"inverseType",
"=",
"$",
"this",
"->",
"getInverseHasType",
"(",
"$",
"hasType",
")",
";",
"$",
"inverseType",
"=",
"$",
"this",
"->",
"updateHasTypeForPossibleRequired",
"(",
"$",
"inverseType",
",",
"$",
"requiredReciprocation",
")",
";",
"$",
"this",
"->",
"setEntityHasRelationToEntity",
"(",
"$",
"ownedEntityFqn",
",",
"$",
"inverseType",
",",
"$",
"owningEntityFqn",
",",
"/**\n * Setting required reciprocation to false,\n * actually it is irrelevant because reciprocation is disabled\n */",
"false",
",",
"false",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'Exception in '",
".",
"__METHOD__",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Set a relationship from one Entity to Another Entity.
Also used internally to set the reciprocal side. Uses an undocumented 4th bool parameter to kill recursion.
@param string $owningEntityFqn
@param string $hasType
@param string $ownedEntityFqn
@param bool $requiredReciprocation
You should never pass in this parameter, it is only used internally
@param bool $internalUseOnly
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Set",
"a",
"relationship",
"from",
"one",
"Entity",
"to",
"Another",
"Entity",
"."
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L237-L288 |
31,522 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.getPathsForOwningTraitsAndInterfaces | protected function getPathsForOwningTraitsAndInterfaces(
string $hasType,
string $ownedEntityFqn
): array {
try {
$ownedHasName = $this->namespaceHelper->getOwnedHasName(
$hasType,
$ownedEntityFqn,
$this->srcSubFolderName,
$this->projectRootNamespace
);
$reciprocatedHasName = $this->namespaceHelper->getReciprocatedHasName(
$ownedEntityFqn,
$this->srcSubFolderName,
$this->projectRootNamespace
);
$owningTraitFqn = $this->getOwningTraitFqn($hasType, $ownedEntityFqn);
list($traitName, , $traitSubDirsNoEntities) = $this->parseFullyQualifiedName($owningTraitFqn);
$owningTraitPath = $this->pathHelper->getPathFromNameAndSubDirs(
$this->pathToProjectRoot,
$traitName,
$traitSubDirsNoEntities
);
if (!\file_exists($owningTraitPath)) {
$this->generateRelationCodeForEntity($ownedEntityFqn);
}
$owningInterfaceFqn = $this->getOwningInterfaceFqn($hasType, $ownedEntityFqn);
list($interfaceName, , $interfaceSubDirsNoEntities) = $this->parseFullyQualifiedName($owningInterfaceFqn);
$owningInterfacePath = $this->pathHelper->getPathFromNameAndSubDirs(
$this->pathToProjectRoot,
$interfaceName,
$interfaceSubDirsNoEntities
);
$reciprocatingInterfacePath = \preg_replace(
'%Has(Required|)' . $ownedHasName . '%',
'Reciprocates' . $reciprocatedHasName,
$owningInterfacePath
);
return [
$owningTraitPath,
$owningInterfacePath,
$reciprocatingInterfacePath,
];
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | php | protected function getPathsForOwningTraitsAndInterfaces(
string $hasType,
string $ownedEntityFqn
): array {
try {
$ownedHasName = $this->namespaceHelper->getOwnedHasName(
$hasType,
$ownedEntityFqn,
$this->srcSubFolderName,
$this->projectRootNamespace
);
$reciprocatedHasName = $this->namespaceHelper->getReciprocatedHasName(
$ownedEntityFqn,
$this->srcSubFolderName,
$this->projectRootNamespace
);
$owningTraitFqn = $this->getOwningTraitFqn($hasType, $ownedEntityFqn);
list($traitName, , $traitSubDirsNoEntities) = $this->parseFullyQualifiedName($owningTraitFqn);
$owningTraitPath = $this->pathHelper->getPathFromNameAndSubDirs(
$this->pathToProjectRoot,
$traitName,
$traitSubDirsNoEntities
);
if (!\file_exists($owningTraitPath)) {
$this->generateRelationCodeForEntity($ownedEntityFqn);
}
$owningInterfaceFqn = $this->getOwningInterfaceFqn($hasType, $ownedEntityFqn);
list($interfaceName, , $interfaceSubDirsNoEntities) = $this->parseFullyQualifiedName($owningInterfaceFqn);
$owningInterfacePath = $this->pathHelper->getPathFromNameAndSubDirs(
$this->pathToProjectRoot,
$interfaceName,
$interfaceSubDirsNoEntities
);
$reciprocatingInterfacePath = \preg_replace(
'%Has(Required|)' . $ownedHasName . '%',
'Reciprocates' . $reciprocatedHasName,
$owningInterfacePath
);
return [
$owningTraitPath,
$owningInterfacePath,
$reciprocatingInterfacePath,
];
} catch (\Exception $e) {
throw new DoctrineStaticMetaException(
'Exception in ' . __METHOD__ . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
} | [
"protected",
"function",
"getPathsForOwningTraitsAndInterfaces",
"(",
"string",
"$",
"hasType",
",",
"string",
"$",
"ownedEntityFqn",
")",
":",
"array",
"{",
"try",
"{",
"$",
"ownedHasName",
"=",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getOwnedHasName",
"(",
"$",
"hasType",
",",
"$",
"ownedEntityFqn",
",",
"$",
"this",
"->",
"srcSubFolderName",
",",
"$",
"this",
"->",
"projectRootNamespace",
")",
";",
"$",
"reciprocatedHasName",
"=",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getReciprocatedHasName",
"(",
"$",
"ownedEntityFqn",
",",
"$",
"this",
"->",
"srcSubFolderName",
",",
"$",
"this",
"->",
"projectRootNamespace",
")",
";",
"$",
"owningTraitFqn",
"=",
"$",
"this",
"->",
"getOwningTraitFqn",
"(",
"$",
"hasType",
",",
"$",
"ownedEntityFqn",
")",
";",
"list",
"(",
"$",
"traitName",
",",
",",
"$",
"traitSubDirsNoEntities",
")",
"=",
"$",
"this",
"->",
"parseFullyQualifiedName",
"(",
"$",
"owningTraitFqn",
")",
";",
"$",
"owningTraitPath",
"=",
"$",
"this",
"->",
"pathHelper",
"->",
"getPathFromNameAndSubDirs",
"(",
"$",
"this",
"->",
"pathToProjectRoot",
",",
"$",
"traitName",
",",
"$",
"traitSubDirsNoEntities",
")",
";",
"if",
"(",
"!",
"\\",
"file_exists",
"(",
"$",
"owningTraitPath",
")",
")",
"{",
"$",
"this",
"->",
"generateRelationCodeForEntity",
"(",
"$",
"ownedEntityFqn",
")",
";",
"}",
"$",
"owningInterfaceFqn",
"=",
"$",
"this",
"->",
"getOwningInterfaceFqn",
"(",
"$",
"hasType",
",",
"$",
"ownedEntityFqn",
")",
";",
"list",
"(",
"$",
"interfaceName",
",",
",",
"$",
"interfaceSubDirsNoEntities",
")",
"=",
"$",
"this",
"->",
"parseFullyQualifiedName",
"(",
"$",
"owningInterfaceFqn",
")",
";",
"$",
"owningInterfacePath",
"=",
"$",
"this",
"->",
"pathHelper",
"->",
"getPathFromNameAndSubDirs",
"(",
"$",
"this",
"->",
"pathToProjectRoot",
",",
"$",
"interfaceName",
",",
"$",
"interfaceSubDirsNoEntities",
")",
";",
"$",
"reciprocatingInterfacePath",
"=",
"\\",
"preg_replace",
"(",
"'%Has(Required|)'",
".",
"$",
"ownedHasName",
".",
"'%'",
",",
"'Reciprocates'",
".",
"$",
"reciprocatedHasName",
",",
"$",
"owningInterfacePath",
")",
";",
"return",
"[",
"$",
"owningTraitPath",
",",
"$",
"owningInterfacePath",
",",
"$",
"reciprocatingInterfacePath",
",",
"]",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'Exception in '",
".",
"__METHOD__",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Get the absolute paths for the owning traits and interfaces for the specified relation type
Will ensure that the files exists
@param string $hasType
@param string $ownedEntityFqn
@return array [
$owningTraitPath,
$owningInterfacePath,
$reciprocatingInterfacePath
]
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess)
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Get",
"the",
"absolute",
"paths",
"for",
"the",
"owning",
"traits",
"and",
"interfaces",
"for",
"the",
"specified",
"relation",
"type",
"Will",
"ensure",
"that",
"the",
"files",
"exists"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L321-L372 |
31,523 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.generateRelationCodeForEntity | public function generateRelationCodeForEntity(string $entityFqn): void
{
$invokable = new GenerateRelationCodeForEntity(
$entityFqn,
$this->pathToProjectRoot,
$this->projectRootNamespace,
$this->srcSubFolderName,
$this->namespaceHelper,
$this->pathHelper,
$this->findAndReplaceHelper
);
$invokable($this->getRelativePathRelationsGenerator());
} | php | public function generateRelationCodeForEntity(string $entityFqn): void
{
$invokable = new GenerateRelationCodeForEntity(
$entityFqn,
$this->pathToProjectRoot,
$this->projectRootNamespace,
$this->srcSubFolderName,
$this->namespaceHelper,
$this->pathHelper,
$this->findAndReplaceHelper
);
$invokable($this->getRelativePathRelationsGenerator());
} | [
"public",
"function",
"generateRelationCodeForEntity",
"(",
"string",
"$",
"entityFqn",
")",
":",
"void",
"{",
"$",
"invokable",
"=",
"new",
"GenerateRelationCodeForEntity",
"(",
"$",
"entityFqn",
",",
"$",
"this",
"->",
"pathToProjectRoot",
",",
"$",
"this",
"->",
"projectRootNamespace",
",",
"$",
"this",
"->",
"srcSubFolderName",
",",
"$",
"this",
"->",
"namespaceHelper",
",",
"$",
"this",
"->",
"pathHelper",
",",
"$",
"this",
"->",
"findAndReplaceHelper",
")",
";",
"$",
"invokable",
"(",
"$",
"this",
"->",
"getRelativePathRelationsGenerator",
"(",
")",
")",
";",
"}"
] | Generate the relation traits for specified Entity
This works by copying the template traits folder over and then updating the file contents, name and path
@param string $entityFqn Fully Qualified Name of Entity
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Generate",
"the",
"relation",
"traits",
"for",
"specified",
"Entity"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L401-L413 |
31,524 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.getRelativePathRelationsGenerator | public function getRelativePathRelationsGenerator(): \Generator
{
try {
$recursiveIterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
\realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH),
\RecursiveDirectoryIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($recursiveIterator as $path => $fileInfo) {
$relativePath = rtrim(
$this->getFilesystem()->makePathRelative(
$path,
\realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH)
),
'/'
);
yield $relativePath => $fileInfo;
}
} finally {
$recursiveIterator = null;
unset($recursiveIterator);
}
} | php | public function getRelativePathRelationsGenerator(): \Generator
{
try {
$recursiveIterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
\realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH),
\RecursiveDirectoryIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($recursiveIterator as $path => $fileInfo) {
$relativePath = rtrim(
$this->getFilesystem()->makePathRelative(
$path,
\realpath(AbstractGenerator::RELATIONS_TEMPLATE_PATH)
),
'/'
);
yield $relativePath => $fileInfo;
}
} finally {
$recursiveIterator = null;
unset($recursiveIterator);
}
} | [
"public",
"function",
"getRelativePathRelationsGenerator",
"(",
")",
":",
"\\",
"Generator",
"{",
"try",
"{",
"$",
"recursiveIterator",
"=",
"new",
"\\",
"RecursiveIteratorIterator",
"(",
"new",
"\\",
"RecursiveDirectoryIterator",
"(",
"\\",
"realpath",
"(",
"AbstractGenerator",
"::",
"RELATIONS_TEMPLATE_PATH",
")",
",",
"\\",
"RecursiveDirectoryIterator",
"::",
"SKIP_DOTS",
")",
",",
"\\",
"RecursiveIteratorIterator",
"::",
"SELF_FIRST",
")",
";",
"foreach",
"(",
"$",
"recursiveIterator",
"as",
"$",
"path",
"=>",
"$",
"fileInfo",
")",
"{",
"$",
"relativePath",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"getFilesystem",
"(",
")",
"->",
"makePathRelative",
"(",
"$",
"path",
",",
"\\",
"realpath",
"(",
"AbstractGenerator",
"::",
"RELATIONS_TEMPLATE_PATH",
")",
")",
",",
"'/'",
")",
";",
"yield",
"$",
"relativePath",
"=>",
"$",
"fileInfo",
";",
"}",
"}",
"finally",
"{",
"$",
"recursiveIterator",
"=",
"null",
";",
"unset",
"(",
"$",
"recursiveIterator",
")",
";",
"}",
"}"
] | Generator that yields relative paths of all the files in the relations template path and the SplFileInfo objects
Use a PHP Generator to iterate over a recursive iterator iterator and then yield:
- key: string $relativePath
- value: \SplFileInfo $fileInfo
The `finally` step unsets the recursiveIterator once everything is done
@return \Generator | [
"Generator",
"that",
"yields",
"relative",
"paths",
"of",
"all",
"the",
"files",
"in",
"the",
"relations",
"template",
"path",
"and",
"the",
"SplFileInfo",
"objects"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L426-L450 |
31,525 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.useRelationTraitInClass | protected function useRelationTraitInClass(string $classPath, string $traitPath): void
{
try {
$class = PhpClass::fromFile($classPath);
} catch (Error $e) {
throw new DoctrineStaticMetaException(
'PHP parsing error when loading class ' . $classPath . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
try {
$trait = PhpTrait::fromFile($traitPath);
} catch (Error $e) {
throw new DoctrineStaticMetaException(
'PHP parsing error when loading class ' . $classPath . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
$class->addTrait($trait);
$this->codeHelper->generate($class, $classPath);
} | php | protected function useRelationTraitInClass(string $classPath, string $traitPath): void
{
try {
$class = PhpClass::fromFile($classPath);
} catch (Error $e) {
throw new DoctrineStaticMetaException(
'PHP parsing error when loading class ' . $classPath . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
try {
$trait = PhpTrait::fromFile($traitPath);
} catch (Error $e) {
throw new DoctrineStaticMetaException(
'PHP parsing error when loading class ' . $classPath . ': ' . $e->getMessage(),
$e->getCode(),
$e
);
}
$class->addTrait($trait);
$this->codeHelper->generate($class, $classPath);
} | [
"protected",
"function",
"useRelationTraitInClass",
"(",
"string",
"$",
"classPath",
",",
"string",
"$",
"traitPath",
")",
":",
"void",
"{",
"try",
"{",
"$",
"class",
"=",
"PhpClass",
"::",
"fromFile",
"(",
"$",
"classPath",
")",
";",
"}",
"catch",
"(",
"Error",
"$",
"e",
")",
"{",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'PHP parsing error when loading class '",
".",
"$",
"classPath",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"try",
"{",
"$",
"trait",
"=",
"PhpTrait",
"::",
"fromFile",
"(",
"$",
"traitPath",
")",
";",
"}",
"catch",
"(",
"Error",
"$",
"e",
")",
"{",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'PHP parsing error when loading class '",
".",
"$",
"classPath",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"$",
"class",
"->",
"addTrait",
"(",
"$",
"trait",
")",
";",
"$",
"this",
"->",
"codeHelper",
"->",
"generate",
"(",
"$",
"class",
",",
"$",
"classPath",
")",
";",
"}"
] | Add the specified trait to the specified class
@param string $classPath
@param string $traitPath
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Add",
"the",
"specified",
"trait",
"to",
"the",
"specified",
"class"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L478-L500 |
31,526 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.useRelationInterfaceInEntityInterface | protected function useRelationInterfaceInEntityInterface(string $classPath, string $interfacePath): void
{
$entityFqn = PhpClass::fromFile($classPath)->getQualifiedName();
$entityInterfaceFqn = $this->namespaceHelper->getEntityInterfaceFromEntityFqn($entityFqn);
$entityInterfacePath = (new \ts\Reflection\ReflectionClass($entityInterfaceFqn))->getFileName();
$entityInterface = PhpInterface::fromFile($entityInterfacePath);
$relationInterface = PhpInterface::fromFile($interfacePath);
$entityInterface->addInterface($relationInterface);
$this->codeHelper->generate($entityInterface, $entityInterfacePath);
} | php | protected function useRelationInterfaceInEntityInterface(string $classPath, string $interfacePath): void
{
$entityFqn = PhpClass::fromFile($classPath)->getQualifiedName();
$entityInterfaceFqn = $this->namespaceHelper->getEntityInterfaceFromEntityFqn($entityFqn);
$entityInterfacePath = (new \ts\Reflection\ReflectionClass($entityInterfaceFqn))->getFileName();
$entityInterface = PhpInterface::fromFile($entityInterfacePath);
$relationInterface = PhpInterface::fromFile($interfacePath);
$entityInterface->addInterface($relationInterface);
$this->codeHelper->generate($entityInterface, $entityInterfacePath);
} | [
"protected",
"function",
"useRelationInterfaceInEntityInterface",
"(",
"string",
"$",
"classPath",
",",
"string",
"$",
"interfacePath",
")",
":",
"void",
"{",
"$",
"entityFqn",
"=",
"PhpClass",
"::",
"fromFile",
"(",
"$",
"classPath",
")",
"->",
"getQualifiedName",
"(",
")",
";",
"$",
"entityInterfaceFqn",
"=",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getEntityInterfaceFromEntityFqn",
"(",
"$",
"entityFqn",
")",
";",
"$",
"entityInterfacePath",
"=",
"(",
"new",
"\\",
"ts",
"\\",
"Reflection",
"\\",
"ReflectionClass",
"(",
"$",
"entityInterfaceFqn",
")",
")",
"->",
"getFileName",
"(",
")",
";",
"$",
"entityInterface",
"=",
"PhpInterface",
"::",
"fromFile",
"(",
"$",
"entityInterfacePath",
")",
";",
"$",
"relationInterface",
"=",
"PhpInterface",
"::",
"fromFile",
"(",
"$",
"interfacePath",
")",
";",
"$",
"entityInterface",
"->",
"addInterface",
"(",
"$",
"relationInterface",
")",
";",
"$",
"this",
"->",
"codeHelper",
"->",
"generate",
"(",
"$",
"entityInterface",
",",
"$",
"entityInterfacePath",
")",
";",
"}"
] | Add the specified interface to the specified entity interface
@param string $classPath
@param string $interfacePath
@throws \ReflectionException
@SuppressWarnings(PHPMD.StaticAccess) | [
"Add",
"the",
"specified",
"interface",
"to",
"the",
"specified",
"entity",
"interface"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L511-L520 |
31,527 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.getInverseHasType | protected function getInverseHasType(string $hasType): string
{
switch ($hasType) {
case self::HAS_ONE_TO_ONE:
case self::HAS_REQUIRED_ONE_TO_ONE:
case self::HAS_MANY_TO_MANY:
case self::HAS_REQUIRED_MANY_TO_MANY:
return \str_replace(
self::PREFIX_OWNING,
self::PREFIX_INVERSE,
$hasType
);
case self::HAS_INVERSE_ONE_TO_ONE:
case self::HAS_REQUIRED_INVERSE_ONE_TO_ONE:
case self::HAS_INVERSE_MANY_TO_MANY:
case self::HAS_REQUIRED_INVERSE_MANY_TO_MANY:
return \str_replace(
self::PREFIX_INVERSE,
self::PREFIX_OWNING,
$hasType
);
case self::HAS_MANY_TO_ONE:
return self::HAS_ONE_TO_MANY;
case self::HAS_REQUIRED_MANY_TO_ONE:
return self::HAS_REQUIRED_ONE_TO_MANY;
case self::HAS_ONE_TO_MANY:
return self::HAS_MANY_TO_ONE;
case self::HAS_REQUIRED_ONE_TO_MANY:
return self::HAS_REQUIRED_MANY_TO_ONE;
default:
throw new DoctrineStaticMetaException(
'invalid $hasType ' . $hasType . ' when trying to get the inverted relation'
);
}
} | php | protected function getInverseHasType(string $hasType): string
{
switch ($hasType) {
case self::HAS_ONE_TO_ONE:
case self::HAS_REQUIRED_ONE_TO_ONE:
case self::HAS_MANY_TO_MANY:
case self::HAS_REQUIRED_MANY_TO_MANY:
return \str_replace(
self::PREFIX_OWNING,
self::PREFIX_INVERSE,
$hasType
);
case self::HAS_INVERSE_ONE_TO_ONE:
case self::HAS_REQUIRED_INVERSE_ONE_TO_ONE:
case self::HAS_INVERSE_MANY_TO_MANY:
case self::HAS_REQUIRED_INVERSE_MANY_TO_MANY:
return \str_replace(
self::PREFIX_INVERSE,
self::PREFIX_OWNING,
$hasType
);
case self::HAS_MANY_TO_ONE:
return self::HAS_ONE_TO_MANY;
case self::HAS_REQUIRED_MANY_TO_ONE:
return self::HAS_REQUIRED_ONE_TO_MANY;
case self::HAS_ONE_TO_MANY:
return self::HAS_MANY_TO_ONE;
case self::HAS_REQUIRED_ONE_TO_MANY:
return self::HAS_REQUIRED_MANY_TO_ONE;
default:
throw new DoctrineStaticMetaException(
'invalid $hasType ' . $hasType . ' when trying to get the inverted relation'
);
}
} | [
"protected",
"function",
"getInverseHasType",
"(",
"string",
"$",
"hasType",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"hasType",
")",
"{",
"case",
"self",
"::",
"HAS_ONE_TO_ONE",
":",
"case",
"self",
"::",
"HAS_REQUIRED_ONE_TO_ONE",
":",
"case",
"self",
"::",
"HAS_MANY_TO_MANY",
":",
"case",
"self",
"::",
"HAS_REQUIRED_MANY_TO_MANY",
":",
"return",
"\\",
"str_replace",
"(",
"self",
"::",
"PREFIX_OWNING",
",",
"self",
"::",
"PREFIX_INVERSE",
",",
"$",
"hasType",
")",
";",
"case",
"self",
"::",
"HAS_INVERSE_ONE_TO_ONE",
":",
"case",
"self",
"::",
"HAS_REQUIRED_INVERSE_ONE_TO_ONE",
":",
"case",
"self",
"::",
"HAS_INVERSE_MANY_TO_MANY",
":",
"case",
"self",
"::",
"HAS_REQUIRED_INVERSE_MANY_TO_MANY",
":",
"return",
"\\",
"str_replace",
"(",
"self",
"::",
"PREFIX_INVERSE",
",",
"self",
"::",
"PREFIX_OWNING",
",",
"$",
"hasType",
")",
";",
"case",
"self",
"::",
"HAS_MANY_TO_ONE",
":",
"return",
"self",
"::",
"HAS_ONE_TO_MANY",
";",
"case",
"self",
"::",
"HAS_REQUIRED_MANY_TO_ONE",
":",
"return",
"self",
"::",
"HAS_REQUIRED_ONE_TO_MANY",
";",
"case",
"self",
"::",
"HAS_ONE_TO_MANY",
":",
"return",
"self",
"::",
"HAS_MANY_TO_ONE",
";",
"case",
"self",
"::",
"HAS_REQUIRED_ONE_TO_MANY",
":",
"return",
"self",
"::",
"HAS_REQUIRED_MANY_TO_ONE",
";",
"default",
":",
"throw",
"new",
"DoctrineStaticMetaException",
"(",
"'invalid $hasType '",
".",
"$",
"hasType",
".",
"' when trying to get the inverted relation'",
")",
";",
"}",
"}"
] | Get the inverse of a hasType
@param string $hasType
@return string
@throws DoctrineStaticMetaException
@SuppressWarnings(PHPMD.CyclomaticComplexity) | [
"Get",
"the",
"inverse",
"of",
"a",
"hasType"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L531-L571 |
31,528 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/Generator/RelationsGenerator.php | RelationsGenerator.updateHasTypeForPossibleRequired | private function updateHasTypeForPossibleRequired(string $relation, bool $required): string
{
$inverseIsRequired = \ts\stringContains($relation, self::PREFIX_REQUIRED);
if (false === $required) {
if (false === $inverseIsRequired) {
return $relation;
}
return $this->removeRequiredToRelation($relation);
}
if (true === $required) {
if (true === $inverseIsRequired) {
return $relation;
}
return $this->addRequiredToRelation($relation);
}
} | php | private function updateHasTypeForPossibleRequired(string $relation, bool $required): string
{
$inverseIsRequired = \ts\stringContains($relation, self::PREFIX_REQUIRED);
if (false === $required) {
if (false === $inverseIsRequired) {
return $relation;
}
return $this->removeRequiredToRelation($relation);
}
if (true === $required) {
if (true === $inverseIsRequired) {
return $relation;
}
return $this->addRequiredToRelation($relation);
}
} | [
"private",
"function",
"updateHasTypeForPossibleRequired",
"(",
"string",
"$",
"relation",
",",
"bool",
"$",
"required",
")",
":",
"string",
"{",
"$",
"inverseIsRequired",
"=",
"\\",
"ts",
"\\",
"stringContains",
"(",
"$",
"relation",
",",
"self",
"::",
"PREFIX_REQUIRED",
")",
";",
"if",
"(",
"false",
"===",
"$",
"required",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"inverseIsRequired",
")",
"{",
"return",
"$",
"relation",
";",
"}",
"return",
"$",
"this",
"->",
"removeRequiredToRelation",
"(",
"$",
"relation",
")",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"required",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"inverseIsRequired",
")",
"{",
"return",
"$",
"relation",
";",
"}",
"return",
"$",
"this",
"->",
"addRequiredToRelation",
"(",
"$",
"relation",
")",
";",
"}",
"}"
] | Take a relationship and a possibility of being required and ensure it is set as the correct relationship
@param string $relation
@param bool $required
@return string | [
"Take",
"a",
"relationship",
"and",
"a",
"possibility",
"of",
"being",
"required",
"and",
"ensure",
"it",
"is",
"set",
"as",
"the",
"correct",
"relationship"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/Generator/RelationsGenerator.php#L581-L598 |
31,529 | Erebot/Erebot | src/IrcConnection.php | IrcConnection.setURIFactory | public function setURIFactory($factory)
{
$reflector = new \ReflectionClass($factory);
if (!$reflector->implementsInterface('\\Erebot\\URIInterface')) {
throw new \Erebot\InvalidValueException(
'The factory must implement \\Erebot\\URIInterface'
);
}
$this->uriFactory = $factory;
} | php | public function setURIFactory($factory)
{
$reflector = new \ReflectionClass($factory);
if (!$reflector->implementsInterface('\\Erebot\\URIInterface')) {
throw new \Erebot\InvalidValueException(
'The factory must implement \\Erebot\\URIInterface'
);
}
$this->uriFactory = $factory;
} | [
"public",
"function",
"setURIFactory",
"(",
"$",
"factory",
")",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"factory",
")",
";",
"if",
"(",
"!",
"$",
"reflector",
"->",
"implementsInterface",
"(",
"'\\\\Erebot\\\\URIInterface'",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"'The factory must implement \\\\Erebot\\\\URIInterface'",
")",
";",
"}",
"$",
"this",
"->",
"uriFactory",
"=",
"$",
"factory",
";",
"}"
] | Sets the class to use as a factory
to parse Uniform Resource Identifiers.
\param string $factory
Name of the class to use to parse an URI. | [
"Sets",
"the",
"class",
"to",
"use",
"as",
"a",
"factory",
"to",
"parse",
"Uniform",
"Resource",
"Identifiers",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcConnection.php#L165-L174 |
31,530 | Erebot/Erebot | src/IrcConnection.php | IrcConnection.realLoadModule | protected function realLoadModule(
$module,
$chan,
$flags,
&$plainModules,
&$channelModules
) {
if ($chan !== null) {
if (isset($channelModules[$chan][$module])) {
return $channelModules[$chan][$module];
}
} elseif (isset($plainModules[$module])) {
return $plainModules[$module];
}
if (!class_exists($module, true)) {
throw new \Erebot\InvalidValueException("No such class '$module'");
}
if (!is_subclass_of($module, '\\Erebot\\Module\\Base')) {
throw new \Erebot\InvalidValueException(
"Invalid module! Not a subclass of \\Erebot\\Module\\Base."
);
}
$reflector = new \ReflectionClass($module);
$instance = new $module($chan);
if ($chan === null) {
$plainModules[$module] = $instance;
} else {
$channelModules[$chan][$module] = $instance;
}
$instance->reloadModule($this, $flags);
$logger = \Plop\Plop::getInstance();
$logger->info(
$this->bot->gettext("Successfully loaded module '%(module)s' [%(source)s]"),
array(
'module' => $module,
'source' => (substr($reflector->getFileName(), 0, 7) == 'phar://')
? $this->bot->gettext('PHP archive')
: $this->bot->gettext('regular file'),
)
);
return $instance;
} | php | protected function realLoadModule(
$module,
$chan,
$flags,
&$plainModules,
&$channelModules
) {
if ($chan !== null) {
if (isset($channelModules[$chan][$module])) {
return $channelModules[$chan][$module];
}
} elseif (isset($plainModules[$module])) {
return $plainModules[$module];
}
if (!class_exists($module, true)) {
throw new \Erebot\InvalidValueException("No such class '$module'");
}
if (!is_subclass_of($module, '\\Erebot\\Module\\Base')) {
throw new \Erebot\InvalidValueException(
"Invalid module! Not a subclass of \\Erebot\\Module\\Base."
);
}
$reflector = new \ReflectionClass($module);
$instance = new $module($chan);
if ($chan === null) {
$plainModules[$module] = $instance;
} else {
$channelModules[$chan][$module] = $instance;
}
$instance->reloadModule($this, $flags);
$logger = \Plop\Plop::getInstance();
$logger->info(
$this->bot->gettext("Successfully loaded module '%(module)s' [%(source)s]"),
array(
'module' => $module,
'source' => (substr($reflector->getFileName(), 0, 7) == 'phar://')
? $this->bot->gettext('PHP archive')
: $this->bot->gettext('regular file'),
)
);
return $instance;
} | [
"protected",
"function",
"realLoadModule",
"(",
"$",
"module",
",",
"$",
"chan",
",",
"$",
"flags",
",",
"&",
"$",
"plainModules",
",",
"&",
"$",
"channelModules",
")",
"{",
"if",
"(",
"$",
"chan",
"!==",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"channelModules",
"[",
"$",
"chan",
"]",
"[",
"$",
"module",
"]",
")",
")",
"{",
"return",
"$",
"channelModules",
"[",
"$",
"chan",
"]",
"[",
"$",
"module",
"]",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"plainModules",
"[",
"$",
"module",
"]",
")",
")",
"{",
"return",
"$",
"plainModules",
"[",
"$",
"module",
"]",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"module",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"\"No such class '$module'\"",
")",
";",
"}",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"module",
",",
"'\\\\Erebot\\\\Module\\\\Base'",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"\"Invalid module! Not a subclass of \\\\Erebot\\\\Module\\\\Base.\"",
")",
";",
"}",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"module",
")",
";",
"$",
"instance",
"=",
"new",
"$",
"module",
"(",
"$",
"chan",
")",
";",
"if",
"(",
"$",
"chan",
"===",
"null",
")",
"{",
"$",
"plainModules",
"[",
"$",
"module",
"]",
"=",
"$",
"instance",
";",
"}",
"else",
"{",
"$",
"channelModules",
"[",
"$",
"chan",
"]",
"[",
"$",
"module",
"]",
"=",
"$",
"instance",
";",
"}",
"$",
"instance",
"->",
"reloadModule",
"(",
"$",
"this",
",",
"$",
"flags",
")",
";",
"$",
"logger",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
"$",
"logger",
"->",
"info",
"(",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"\"Successfully loaded module '%(module)s' [%(source)s]\"",
")",
",",
"array",
"(",
"'module'",
"=>",
"$",
"module",
",",
"'source'",
"=>",
"(",
"substr",
"(",
"$",
"reflector",
"->",
"getFileName",
"(",
")",
",",
"0",
",",
"7",
")",
"==",
"'phar://'",
")",
"?",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"'PHP archive'",
")",
":",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"'regular file'",
")",
",",
")",
")",
";",
"return",
"$",
"instance",
";",
"}"
] | Load a single module for this connection.
\param string $module
Name of the module to load. If the module
is already loaded, nothing will happen.
\param string|null $chan
Name of the IRC channel for which this module
is being loaded. Pass \b null to load a module
globally (for the whole connection) rather than
for a specific IRC channel.
\param opaque $flags
Bitwise-OR combination of flags to pass to
the module's initialization method.
\param array $plainModules
An associative array containing the global modules
currently loaded. This array will be updated if it
needs to be once the module has been successfully
loaded.
\param array $channelModules
An associative array containing the modules currently
loaded for the given IRC channel. This array will be
updated if it needs to be once the module has been
successfully loaded.
\retval Erebot::Module::Base
An instance of the module with the given name. | [
"Load",
"a",
"single",
"module",
"for",
"this",
"connection",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcConnection.php#L621-L666 |
31,531 | Erebot/Erebot | src/IrcConnection.php | IrcConnection.dispatchEvent | protected function dispatchEvent(\Erebot\Interfaces\Event\Base\Generic $event)
{
$logger = \Plop\Plop::getInstance();
$logger->debug(
$this->bot->gettext('Dispatching "%(type)s" event.'),
array('type' => get_class($event))
);
try {
foreach ($this->events as $handler) {
if ($handler->handleEvent($event) === false) {
break;
}
}
} catch (\Erebot\ErrorReportingException $e) {
// This should help make the code a little more "bug-free" (TM).
$logger->exception($this->bot->gettext('Code is not clean!'), $e);
$this->disconnect($e->getMessage());
}
} | php | protected function dispatchEvent(\Erebot\Interfaces\Event\Base\Generic $event)
{
$logger = \Plop\Plop::getInstance();
$logger->debug(
$this->bot->gettext('Dispatching "%(type)s" event.'),
array('type' => get_class($event))
);
try {
foreach ($this->events as $handler) {
if ($handler->handleEvent($event) === false) {
break;
}
}
} catch (\Erebot\ErrorReportingException $e) {
// This should help make the code a little more "bug-free" (TM).
$logger->exception($this->bot->gettext('Code is not clean!'), $e);
$this->disconnect($e->getMessage());
}
} | [
"protected",
"function",
"dispatchEvent",
"(",
"\\",
"Erebot",
"\\",
"Interfaces",
"\\",
"Event",
"\\",
"Base",
"\\",
"Generic",
"$",
"event",
")",
"{",
"$",
"logger",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"'Dispatching \"%(type)s\" event.'",
")",
",",
"array",
"(",
"'type'",
"=>",
"get_class",
"(",
"$",
"event",
")",
")",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"events",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"handleEvent",
"(",
"$",
"event",
")",
"===",
"false",
")",
"{",
"break",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Erebot",
"\\",
"ErrorReportingException",
"$",
"e",
")",
"{",
"// This should help make the code a little more \"bug-free\" (TM).",
"$",
"logger",
"->",
"exception",
"(",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"'Code is not clean!'",
")",
",",
"$",
"e",
")",
";",
"$",
"this",
"->",
"disconnect",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Dispatches the given event to handlers
which have been registered for this type of event.
\param Erebot::Interfaces::Event::Base::Generic $event
An event to dispatch. | [
"Dispatches",
"the",
"given",
"event",
"to",
"handlers",
"which",
"have",
"been",
"registered",
"for",
"this",
"type",
"of",
"event",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcConnection.php#L755-L773 |
31,532 | Erebot/Erebot | src/IrcConnection.php | IrcConnection.dispatchNumeric | protected function dispatchNumeric(\Erebot\Interfaces\Event\Numeric $numeric)
{
$logger = \Plop\Plop::getInstance();
$logger->debug(
$this->bot->gettext('Dispatching numeric %(code)s.'),
array('code' => sprintf('%03d', $numeric->getCode()))
);
try {
foreach ($this->numerics as $handler) {
if ($handler->handleNumeric($numeric) === false) {
break;
}
}
} catch (\Erebot\ErrorReportingException $e) {
// This should help make the code a little more "bug-free" (TM).
$logger->exception($this->bot->gettext('Code is not clean!'), $e);
$this->disconnect($e->getMessage());
}
} | php | protected function dispatchNumeric(\Erebot\Interfaces\Event\Numeric $numeric)
{
$logger = \Plop\Plop::getInstance();
$logger->debug(
$this->bot->gettext('Dispatching numeric %(code)s.'),
array('code' => sprintf('%03d', $numeric->getCode()))
);
try {
foreach ($this->numerics as $handler) {
if ($handler->handleNumeric($numeric) === false) {
break;
}
}
} catch (\Erebot\ErrorReportingException $e) {
// This should help make the code a little more "bug-free" (TM).
$logger->exception($this->bot->gettext('Code is not clean!'), $e);
$this->disconnect($e->getMessage());
}
} | [
"protected",
"function",
"dispatchNumeric",
"(",
"\\",
"Erebot",
"\\",
"Interfaces",
"\\",
"Event",
"\\",
"Numeric",
"$",
"numeric",
")",
"{",
"$",
"logger",
"=",
"\\",
"Plop",
"\\",
"Plop",
"::",
"getInstance",
"(",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"'Dispatching numeric %(code)s.'",
")",
",",
"array",
"(",
"'code'",
"=>",
"sprintf",
"(",
"'%03d'",
",",
"$",
"numeric",
"->",
"getCode",
"(",
")",
")",
")",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"this",
"->",
"numerics",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"handleNumeric",
"(",
"$",
"numeric",
")",
"===",
"false",
")",
"{",
"break",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Erebot",
"\\",
"ErrorReportingException",
"$",
"e",
")",
"{",
"// This should help make the code a little more \"bug-free\" (TM).",
"$",
"logger",
"->",
"exception",
"(",
"$",
"this",
"->",
"bot",
"->",
"gettext",
"(",
"'Code is not clean!'",
")",
",",
"$",
"e",
")",
";",
"$",
"this",
"->",
"disconnect",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Dispatches the given numeric event to handlers
which have been registered for this type of numeric.
\param Erebot::Interfaces::Event::Numeric $numeric
A numeric message to dispatch. | [
"Dispatches",
"the",
"given",
"numeric",
"event",
"to",
"handlers",
"which",
"have",
"been",
"registered",
"for",
"this",
"type",
"of",
"numeric",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcConnection.php#L782-L800 |
31,533 | Erebot/Erebot | src/IrcConnection.php | IrcConnection.handleCapabilities | public function handleCapabilities(
\Erebot\Interfaces\EventHandler $handler,
\Erebot\Event\ServerCapabilities $event
) {
$module = $event->getModule();
$validMappings = array(
// This is already the default value, but we still define it
// in case setCollator() was called to change the default.
'rfc1459' => '\\Erebot\\IrcCollator\\RFC1459',
'strict-rfc1459' => '\\Erebot\\IrcCollator\\StrictRFC1459',
'ascii' => '\\Erebot\\IrcCollator\\ASCII',
);
$caseMapping = strtolower($module->getCaseMapping());
if (in_array($caseMapping, array_keys($validMappings))) {
$cls = $validMappings[$caseMapping];
$this->collator = new $cls();
}
} | php | public function handleCapabilities(
\Erebot\Interfaces\EventHandler $handler,
\Erebot\Event\ServerCapabilities $event
) {
$module = $event->getModule();
$validMappings = array(
// This is already the default value, but we still define it
// in case setCollator() was called to change the default.
'rfc1459' => '\\Erebot\\IrcCollator\\RFC1459',
'strict-rfc1459' => '\\Erebot\\IrcCollator\\StrictRFC1459',
'ascii' => '\\Erebot\\IrcCollator\\ASCII',
);
$caseMapping = strtolower($module->getCaseMapping());
if (in_array($caseMapping, array_keys($validMappings))) {
$cls = $validMappings[$caseMapping];
$this->collator = new $cls();
}
} | [
"public",
"function",
"handleCapabilities",
"(",
"\\",
"Erebot",
"\\",
"Interfaces",
"\\",
"EventHandler",
"$",
"handler",
",",
"\\",
"Erebot",
"\\",
"Event",
"\\",
"ServerCapabilities",
"$",
"event",
")",
"{",
"$",
"module",
"=",
"$",
"event",
"->",
"getModule",
"(",
")",
";",
"$",
"validMappings",
"=",
"array",
"(",
"// This is already the default value, but we still define it",
"// in case setCollator() was called to change the default.",
"'rfc1459'",
"=>",
"'\\\\Erebot\\\\IrcCollator\\\\RFC1459'",
",",
"'strict-rfc1459'",
"=>",
"'\\\\Erebot\\\\IrcCollator\\\\StrictRFC1459'",
",",
"'ascii'",
"=>",
"'\\\\Erebot\\\\IrcCollator\\\\ASCII'",
",",
")",
";",
"$",
"caseMapping",
"=",
"strtolower",
"(",
"$",
"module",
"->",
"getCaseMapping",
"(",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"caseMapping",
",",
"array_keys",
"(",
"$",
"validMappings",
")",
")",
")",
"{",
"$",
"cls",
"=",
"$",
"validMappings",
"[",
"$",
"caseMapping",
"]",
";",
"$",
"this",
"->",
"collator",
"=",
"new",
"$",
"cls",
"(",
")",
";",
"}",
"}"
] | Handles the "ServerCapabilities" event.
\param Erebot::Interfaces::EventHandler $handler
The event handler responsible for calling
this method.
\param Erebot::Event::ServerCapabilities $event
The "ServerCapabilities" event to process. | [
"Handles",
"the",
"ServerCapabilities",
"event",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcConnection.php#L856-L873 |
31,534 | Erebot/Erebot | src/IrcConnection.php | IrcConnection.handleConnect | public function handleConnect(
\Erebot\Interfaces\EventHandler $handler,
\Erebot\Interfaces\Event\Connect $event
) {
$this->connected = true;
} | php | public function handleConnect(
\Erebot\Interfaces\EventHandler $handler,
\Erebot\Interfaces\Event\Connect $event
) {
$this->connected = true;
} | [
"public",
"function",
"handleConnect",
"(",
"\\",
"Erebot",
"\\",
"Interfaces",
"\\",
"EventHandler",
"$",
"handler",
",",
"\\",
"Erebot",
"\\",
"Interfaces",
"\\",
"Event",
"\\",
"Connect",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"connected",
"=",
"true",
";",
"}"
] | Handles the "Connect" event.
\param Erebot::Interfaces::EventHandler $handler
The event handler responsible for calling
this method.
\param Erebot::Interfaces::Event::Connect $event
The "Connect" event to process. | [
"Handles",
"the",
"Connect",
"event",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcConnection.php#L885-L890 |
31,535 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.LoadChildTreeExecute | protected function LoadChildTreeExecute($sChildCategoryId)
{
$sSelect = $this->GetQuery($sChildCategoryId);
$oChildCategoryList = TdbShopCategoryList::GetList($sSelect);
if ($oChildCategoryList->Length() > 1) {
$this->oChildCategoryTreeList = new TIterator();
}
while ($oChildCategory = $oChildCategoryList->Next()) {
if ($oChildCategory->id == $sChildCategoryId) {
$this->oRealCategory = $oChildCategory;
$this->iItemCount = 0;
$this->iAllItemCount = 0;
$this->id = $oChildCategory->id;
} else {
$oMainTree = new self();
$oMainTree->LoadChildTreeExecute($oChildCategory->id);
$this->aContainingChildCategories = array_merge($this->aContainingChildCategories, $oMainTree->aContainingChildCategories);
$this->iAllItemCount = $this->iAllItemCount + $oMainTree->iAllItemCount;
$this->oChildCategoryTreeList->AddItem($oMainTree);
$this->aContainingChildCategories[$oChildCategory->id] = $oChildCategory->GetName();
}
}
if (empty($this->id)) {
$this->id = TTools::GetUUID();
}
} | php | protected function LoadChildTreeExecute($sChildCategoryId)
{
$sSelect = $this->GetQuery($sChildCategoryId);
$oChildCategoryList = TdbShopCategoryList::GetList($sSelect);
if ($oChildCategoryList->Length() > 1) {
$this->oChildCategoryTreeList = new TIterator();
}
while ($oChildCategory = $oChildCategoryList->Next()) {
if ($oChildCategory->id == $sChildCategoryId) {
$this->oRealCategory = $oChildCategory;
$this->iItemCount = 0;
$this->iAllItemCount = 0;
$this->id = $oChildCategory->id;
} else {
$oMainTree = new self();
$oMainTree->LoadChildTreeExecute($oChildCategory->id);
$this->aContainingChildCategories = array_merge($this->aContainingChildCategories, $oMainTree->aContainingChildCategories);
$this->iAllItemCount = $this->iAllItemCount + $oMainTree->iAllItemCount;
$this->oChildCategoryTreeList->AddItem($oMainTree);
$this->aContainingChildCategories[$oChildCategory->id] = $oChildCategory->GetName();
}
}
if (empty($this->id)) {
$this->id = TTools::GetUUID();
}
} | [
"protected",
"function",
"LoadChildTreeExecute",
"(",
"$",
"sChildCategoryId",
")",
"{",
"$",
"sSelect",
"=",
"$",
"this",
"->",
"GetQuery",
"(",
"$",
"sChildCategoryId",
")",
";",
"$",
"oChildCategoryList",
"=",
"TdbShopCategoryList",
"::",
"GetList",
"(",
"$",
"sSelect",
")",
";",
"if",
"(",
"$",
"oChildCategoryList",
"->",
"Length",
"(",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"oChildCategoryTreeList",
"=",
"new",
"TIterator",
"(",
")",
";",
"}",
"while",
"(",
"$",
"oChildCategory",
"=",
"$",
"oChildCategoryList",
"->",
"Next",
"(",
")",
")",
"{",
"if",
"(",
"$",
"oChildCategory",
"->",
"id",
"==",
"$",
"sChildCategoryId",
")",
"{",
"$",
"this",
"->",
"oRealCategory",
"=",
"$",
"oChildCategory",
";",
"$",
"this",
"->",
"iItemCount",
"=",
"0",
";",
"$",
"this",
"->",
"iAllItemCount",
"=",
"0",
";",
"$",
"this",
"->",
"id",
"=",
"$",
"oChildCategory",
"->",
"id",
";",
"}",
"else",
"{",
"$",
"oMainTree",
"=",
"new",
"self",
"(",
")",
";",
"$",
"oMainTree",
"->",
"LoadChildTreeExecute",
"(",
"$",
"oChildCategory",
"->",
"id",
")",
";",
"$",
"this",
"->",
"aContainingChildCategories",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"aContainingChildCategories",
",",
"$",
"oMainTree",
"->",
"aContainingChildCategories",
")",
";",
"$",
"this",
"->",
"iAllItemCount",
"=",
"$",
"this",
"->",
"iAllItemCount",
"+",
"$",
"oMainTree",
"->",
"iAllItemCount",
";",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"AddItem",
"(",
"$",
"oMainTree",
")",
";",
"$",
"this",
"->",
"aContainingChildCategories",
"[",
"$",
"oChildCategory",
"->",
"id",
"]",
"=",
"$",
"oChildCategory",
"->",
"GetName",
"(",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"id",
")",
")",
"{",
"$",
"this",
"->",
"id",
"=",
"TTools",
"::",
"GetUUID",
"(",
")",
";",
"}",
"}"
] | Loads Category tree from given master category id.
@param $sChildCategoryId | [
"Loads",
"Category",
"tree",
"from",
"given",
"master",
"category",
"id",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L81-L106 |
31,536 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.GetQuery | protected function GetQuery($sChildCategoryId)
{
$sSelect = "SELECT `shop_category`.*
FROM `shop_category`
WHERE `shop_category`.`shop_category_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sChildCategoryId)."'
OR `shop_category`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sChildCategoryId)."'
ORDER BY `shop_category`.`position`";
return $sSelect;
} | php | protected function GetQuery($sChildCategoryId)
{
$sSelect = "SELECT `shop_category`.*
FROM `shop_category`
WHERE `shop_category`.`shop_category_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sChildCategoryId)."'
OR `shop_category`.`id` = '".MySqlLegacySupport::getInstance()->real_escape_string($sChildCategoryId)."'
ORDER BY `shop_category`.`position`";
return $sSelect;
} | [
"protected",
"function",
"GetQuery",
"(",
"$",
"sChildCategoryId",
")",
"{",
"$",
"sSelect",
"=",
"\"SELECT `shop_category`.*\n FROM `shop_category`\n WHERE `shop_category`.`shop_category_id` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sChildCategoryId",
")",
".",
"\"'\n OR `shop_category`.`id` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sChildCategoryId",
")",
".",
"\"'\n ORDER BY `shop_category`.`position`\"",
";",
"return",
"$",
"sSelect",
";",
"}"
] | Returns query to get all child categories for given category id.
If given category id is empty then returns query to get master categories.
@param $sChildCategoryId
@return string | [
"Returns",
"query",
"to",
"get",
"all",
"child",
"categories",
"for",
"given",
"category",
"id",
".",
"If",
"given",
"category",
"id",
"is",
"empty",
"then",
"returns",
"query",
"to",
"get",
"master",
"categories",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L116-L125 |
31,537 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.ResetCounter | public function ResetCounter()
{
$this->iAllItemCount = 0;
$this->iItemCount = 0;
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while ($oChildCategoryTree = $this->oChildCategoryTreeList->Next()) {
$oChildCategoryTree->ResetCounter();
}
}
} | php | public function ResetCounter()
{
$this->iAllItemCount = 0;
$this->iItemCount = 0;
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while ($oChildCategoryTree = $this->oChildCategoryTreeList->Next()) {
$oChildCategoryTree->ResetCounter();
}
}
} | [
"public",
"function",
"ResetCounter",
"(",
")",
"{",
"$",
"this",
"->",
"iAllItemCount",
"=",
"0",
";",
"$",
"this",
"->",
"iItemCount",
"=",
"0",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oChildCategoryTreeList",
")",
")",
"{",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"$",
"oChildCategoryTree",
"=",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"oChildCategoryTree",
"->",
"ResetCounter",
"(",
")",
";",
"}",
"}",
"}"
] | Resets all item count in all category trees. | [
"Resets",
"all",
"item",
"count",
"in",
"all",
"category",
"trees",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L130-L140 |
31,538 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.Render | public function Render($sListFilterItemId = false, $bHideEmptyCategories = false, $bShowArticleCount = false, $iLevelCount = 1)
{
$sHtml = '';
$sCategoryNameHtml = '';
if (!is_null($this->oRealCategory)) {
$sCategoryNameHtml = $this->RenderCategoryName($sListFilterItemId, $bShowArticleCount, $iLevelCount);
}
$sChildCategoriesHtml = $this->RenderChildCategories($sListFilterItemId, $bHideEmptyCategories, $bShowArticleCount, $iLevelCount + 1);
if (empty($sChildCategoriesHtml) && 0 == $this->iAllItemCount && $bHideEmptyCategories) {
$sHtml = '';
} else {
if (!is_null($this->oRealCategory)) {
$aClass = array('CategoryLevel_'.$iLevelCount);
if (!empty($sChildCategoriesHtml)) {
$aClass[] = 'hasChildren';
} else {
$aClass[] = 'isLeaflet';
}
if ($this->bIsActive) {
$aClass[] = 'active expanded';
}
$sHtml .= '<ul>';
$sHtml .= '<li class="'.implode(' ', $aClass).'">'.$sCategoryNameHtml;
}
$sHtml .= $sChildCategoriesHtml;
if (!is_null($this->oRealCategory)) {
$sHtml .= '</li>';
$sHtml .= '</ul>';
}
}
return $sHtml;
} | php | public function Render($sListFilterItemId = false, $bHideEmptyCategories = false, $bShowArticleCount = false, $iLevelCount = 1)
{
$sHtml = '';
$sCategoryNameHtml = '';
if (!is_null($this->oRealCategory)) {
$sCategoryNameHtml = $this->RenderCategoryName($sListFilterItemId, $bShowArticleCount, $iLevelCount);
}
$sChildCategoriesHtml = $this->RenderChildCategories($sListFilterItemId, $bHideEmptyCategories, $bShowArticleCount, $iLevelCount + 1);
if (empty($sChildCategoriesHtml) && 0 == $this->iAllItemCount && $bHideEmptyCategories) {
$sHtml = '';
} else {
if (!is_null($this->oRealCategory)) {
$aClass = array('CategoryLevel_'.$iLevelCount);
if (!empty($sChildCategoriesHtml)) {
$aClass[] = 'hasChildren';
} else {
$aClass[] = 'isLeaflet';
}
if ($this->bIsActive) {
$aClass[] = 'active expanded';
}
$sHtml .= '<ul>';
$sHtml .= '<li class="'.implode(' ', $aClass).'">'.$sCategoryNameHtml;
}
$sHtml .= $sChildCategoriesHtml;
if (!is_null($this->oRealCategory)) {
$sHtml .= '</li>';
$sHtml .= '</ul>';
}
}
return $sHtml;
} | [
"public",
"function",
"Render",
"(",
"$",
"sListFilterItemId",
"=",
"false",
",",
"$",
"bHideEmptyCategories",
"=",
"false",
",",
"$",
"bShowArticleCount",
"=",
"false",
",",
"$",
"iLevelCount",
"=",
"1",
")",
"{",
"$",
"sHtml",
"=",
"''",
";",
"$",
"sCategoryNameHtml",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oRealCategory",
")",
")",
"{",
"$",
"sCategoryNameHtml",
"=",
"$",
"this",
"->",
"RenderCategoryName",
"(",
"$",
"sListFilterItemId",
",",
"$",
"bShowArticleCount",
",",
"$",
"iLevelCount",
")",
";",
"}",
"$",
"sChildCategoriesHtml",
"=",
"$",
"this",
"->",
"RenderChildCategories",
"(",
"$",
"sListFilterItemId",
",",
"$",
"bHideEmptyCategories",
",",
"$",
"bShowArticleCount",
",",
"$",
"iLevelCount",
"+",
"1",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"sChildCategoriesHtml",
")",
"&&",
"0",
"==",
"$",
"this",
"->",
"iAllItemCount",
"&&",
"$",
"bHideEmptyCategories",
")",
"{",
"$",
"sHtml",
"=",
"''",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oRealCategory",
")",
")",
"{",
"$",
"aClass",
"=",
"array",
"(",
"'CategoryLevel_'",
".",
"$",
"iLevelCount",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sChildCategoriesHtml",
")",
")",
"{",
"$",
"aClass",
"[",
"]",
"=",
"'hasChildren'",
";",
"}",
"else",
"{",
"$",
"aClass",
"[",
"]",
"=",
"'isLeaflet'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"bIsActive",
")",
"{",
"$",
"aClass",
"[",
"]",
"=",
"'active expanded'",
";",
"}",
"$",
"sHtml",
".=",
"'<ul>'",
";",
"$",
"sHtml",
".=",
"'<li class=\"'",
".",
"implode",
"(",
"' '",
",",
"$",
"aClass",
")",
".",
"'\">'",
".",
"$",
"sCategoryNameHtml",
";",
"}",
"$",
"sHtml",
".=",
"$",
"sChildCategoriesHtml",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oRealCategory",
")",
")",
"{",
"$",
"sHtml",
".=",
"'</li>'",
";",
"$",
"sHtml",
".=",
"'</ul>'",
";",
"}",
"}",
"return",
"$",
"sHtml",
";",
"}"
] | Renders the category tree.
Function not uses external views. Html was rendered in class for better performance.
If you want to change something on the html overwrite one of the render functions.
@param bool $sListFilterItemId
@param bool $bHideEmptyCategories
@param bool $bShowArticleCount
@param int $iLevelCount
@return string | [
"Renders",
"the",
"category",
"tree",
".",
"Function",
"not",
"uses",
"external",
"views",
".",
"Html",
"was",
"rendered",
"in",
"class",
"for",
"better",
"performance",
".",
"If",
"you",
"want",
"to",
"change",
"something",
"on",
"the",
"html",
"overwrite",
"one",
"of",
"the",
"render",
"functions",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L154-L186 |
31,539 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.RenderChildCategories | public function RenderChildCategories($sListFilterItemId = false, $bHideEmptyCategories = false, $bShowArticleCount = false, $iLevelCount = 1)
{
$sHtml = '';
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while ($oChildCategoryTree = $this->oChildCategoryTreeList->Next()) {
$sHtml .= $oChildCategoryTree->Render($sListFilterItemId, $bHideEmptyCategories, $bShowArticleCount, $iLevelCount);
}
}
return $sHtml;
} | php | public function RenderChildCategories($sListFilterItemId = false, $bHideEmptyCategories = false, $bShowArticleCount = false, $iLevelCount = 1)
{
$sHtml = '';
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while ($oChildCategoryTree = $this->oChildCategoryTreeList->Next()) {
$sHtml .= $oChildCategoryTree->Render($sListFilterItemId, $bHideEmptyCategories, $bShowArticleCount, $iLevelCount);
}
}
return $sHtml;
} | [
"public",
"function",
"RenderChildCategories",
"(",
"$",
"sListFilterItemId",
"=",
"false",
",",
"$",
"bHideEmptyCategories",
"=",
"false",
",",
"$",
"bShowArticleCount",
"=",
"false",
",",
"$",
"iLevelCount",
"=",
"1",
")",
"{",
"$",
"sHtml",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oChildCategoryTreeList",
")",
")",
"{",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"$",
"oChildCategoryTree",
"=",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"sHtml",
".=",
"$",
"oChildCategoryTree",
"->",
"Render",
"(",
"$",
"sListFilterItemId",
",",
"$",
"bHideEmptyCategories",
",",
"$",
"bShowArticleCount",
",",
"$",
"iLevelCount",
")",
";",
"}",
"}",
"return",
"$",
"sHtml",
";",
"}"
] | Renders list of child categories recursively.
@param bool $sListFilterItemId
@param bool $bHideEmptyCategories
@param bool $bShowArticleCount
@param int $iLevelCount
@return string | [
"Renders",
"list",
"of",
"child",
"categories",
"recursively",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L198-L209 |
31,540 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.RenderCategoryName | protected function RenderCategoryName($sListFilterItemId = false, $bShowArticleCount = false, $iLevelCount = 1)
{
$aClass = array('CategoryName');
if ($this->bIsActive) {
$aClass[] = 'active';
$aClass[] = 'expanded';
}
$sHtml = '<a class="'.implode(' ', $aClass).'" href="'.$this->GetCategoryURL($sListFilterItemId).'">'.TGlobal::OutHtml($this->oRealCategory->GetName());
if ($bShowArticleCount) {
$sHtml .= $this->RenderCategoryCount();
}
$sHtml .= '</a>';
return $sHtml;
} | php | protected function RenderCategoryName($sListFilterItemId = false, $bShowArticleCount = false, $iLevelCount = 1)
{
$aClass = array('CategoryName');
if ($this->bIsActive) {
$aClass[] = 'active';
$aClass[] = 'expanded';
}
$sHtml = '<a class="'.implode(' ', $aClass).'" href="'.$this->GetCategoryURL($sListFilterItemId).'">'.TGlobal::OutHtml($this->oRealCategory->GetName());
if ($bShowArticleCount) {
$sHtml .= $this->RenderCategoryCount();
}
$sHtml .= '</a>';
return $sHtml;
} | [
"protected",
"function",
"RenderCategoryName",
"(",
"$",
"sListFilterItemId",
"=",
"false",
",",
"$",
"bShowArticleCount",
"=",
"false",
",",
"$",
"iLevelCount",
"=",
"1",
")",
"{",
"$",
"aClass",
"=",
"array",
"(",
"'CategoryName'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"bIsActive",
")",
"{",
"$",
"aClass",
"[",
"]",
"=",
"'active'",
";",
"$",
"aClass",
"[",
"]",
"=",
"'expanded'",
";",
"}",
"$",
"sHtml",
"=",
"'<a class=\"'",
".",
"implode",
"(",
"' '",
",",
"$",
"aClass",
")",
".",
"'\" href=\"'",
".",
"$",
"this",
"->",
"GetCategoryURL",
"(",
"$",
"sListFilterItemId",
")",
".",
"'\">'",
".",
"TGlobal",
"::",
"OutHtml",
"(",
"$",
"this",
"->",
"oRealCategory",
"->",
"GetName",
"(",
")",
")",
";",
"if",
"(",
"$",
"bShowArticleCount",
")",
"{",
"$",
"sHtml",
".=",
"$",
"this",
"->",
"RenderCategoryCount",
"(",
")",
";",
"}",
"$",
"sHtml",
".=",
"'</a>'",
";",
"return",
"$",
"sHtml",
";",
"}"
] | Renders the category name and item count.
@param bool $sListFilterItemId
@param bool $bShowArticleCount
@param int $iLevelCount
@return string | [
"Renders",
"the",
"category",
"name",
"and",
"item",
"count",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L220-L235 |
31,541 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.GetCategoryURL | protected function GetCategoryURL($sListFilterItemId = false)
{
$sURL = '';
if (!is_null($this->oRealCategory)) {
if ($sListFilterItemId) {
$sURL = $this->GetAddFilterURL($sListFilterItemId);
} else {
$sURL = $this->oRealCategory->GetLink();
}
}
return $sURL;
} | php | protected function GetCategoryURL($sListFilterItemId = false)
{
$sURL = '';
if (!is_null($this->oRealCategory)) {
if ($sListFilterItemId) {
$sURL = $this->GetAddFilterURL($sListFilterItemId);
} else {
$sURL = $this->oRealCategory->GetLink();
}
}
return $sURL;
} | [
"protected",
"function",
"GetCategoryURL",
"(",
"$",
"sListFilterItemId",
"=",
"false",
")",
"{",
"$",
"sURL",
"=",
"''",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oRealCategory",
")",
")",
"{",
"if",
"(",
"$",
"sListFilterItemId",
")",
"{",
"$",
"sURL",
"=",
"$",
"this",
"->",
"GetAddFilterURL",
"(",
"$",
"sListFilterItemId",
")",
";",
"}",
"else",
"{",
"$",
"sURL",
"=",
"$",
"this",
"->",
"oRealCategory",
"->",
"GetLink",
"(",
")",
";",
"}",
"}",
"return",
"$",
"sURL",
";",
"}"
] | Returns the URL of the category.
If tree was used as a filter function returns url to filter for the category.
If tree was used as normal category tree then function returns link to category detail page.
@param bool $sListFilterItemId
@return string | [
"Returns",
"the",
"URL",
"of",
"the",
"category",
".",
"If",
"tree",
"was",
"used",
"as",
"a",
"filter",
"function",
"returns",
"url",
"to",
"filter",
"for",
"the",
"category",
".",
"If",
"tree",
"was",
"used",
"as",
"normal",
"category",
"tree",
"then",
"function",
"returns",
"link",
"to",
"category",
"detail",
"page",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L256-L268 |
31,542 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.GetAddFilterURL | public function GetAddFilterURL($sListFilterItemId)
{
$oActiveListFilter = TdbPkgShopListfilter::GetActiveInstance();
$aURLData = $oActiveListFilter->GetCurrentFilterAsArray();
$aURLData = $this->ClearOtherCategoryTreeFilter($aURLData, $sListFilterItemId);
$aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA][$sListFilterItemId][] = $this->oRealCategory->id;
$aURLData[TdbPkgShopListfilter::URL_PARAMETER_IS_NEW_REQUEST] = '1';
return $this->getActivePageService()->getLinkToActivePageRelative($aURLData);
} | php | public function GetAddFilterURL($sListFilterItemId)
{
$oActiveListFilter = TdbPkgShopListfilter::GetActiveInstance();
$aURLData = $oActiveListFilter->GetCurrentFilterAsArray();
$aURLData = $this->ClearOtherCategoryTreeFilter($aURLData, $sListFilterItemId);
$aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA][$sListFilterItemId][] = $this->oRealCategory->id;
$aURLData[TdbPkgShopListfilter::URL_PARAMETER_IS_NEW_REQUEST] = '1';
return $this->getActivePageService()->getLinkToActivePageRelative($aURLData);
} | [
"public",
"function",
"GetAddFilterURL",
"(",
"$",
"sListFilterItemId",
")",
"{",
"$",
"oActiveListFilter",
"=",
"TdbPkgShopListfilter",
"::",
"GetActiveInstance",
"(",
")",
";",
"$",
"aURLData",
"=",
"$",
"oActiveListFilter",
"->",
"GetCurrentFilterAsArray",
"(",
")",
";",
"$",
"aURLData",
"=",
"$",
"this",
"->",
"ClearOtherCategoryTreeFilter",
"(",
"$",
"aURLData",
",",
"$",
"sListFilterItemId",
")",
";",
"$",
"aURLData",
"[",
"TdbPkgShopListfilterItem",
"::",
"URL_PARAMETER_FILTER_DATA",
"]",
"[",
"$",
"sListFilterItemId",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"oRealCategory",
"->",
"id",
";",
"$",
"aURLData",
"[",
"TdbPkgShopListfilter",
"::",
"URL_PARAMETER_IS_NEW_REQUEST",
"]",
"=",
"'1'",
";",
"return",
"$",
"this",
"->",
"getActivePageService",
"(",
")",
"->",
"getLinkToActivePageRelative",
"(",
"$",
"aURLData",
")",
";",
"}"
] | return url that sets the filter to the current category.
@param string $sValue | [
"return",
"url",
"that",
"sets",
"the",
"filter",
"to",
"the",
"current",
"category",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L275-L284 |
31,543 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.ClearOtherCategoryTreeFilter | protected function ClearOtherCategoryTreeFilter($aURLData, $sListFilterItemId)
{
if (is_array($aURLData) && array_key_exists(TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA, $aURLData) && is_array($aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA]) && array_key_exists($sListFilterItemId, $aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA])
) {
unset($aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA][$sListFilterItemId]);
}
return $aURLData;
} | php | protected function ClearOtherCategoryTreeFilter($aURLData, $sListFilterItemId)
{
if (is_array($aURLData) && array_key_exists(TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA, $aURLData) && is_array($aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA]) && array_key_exists($sListFilterItemId, $aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA])
) {
unset($aURLData[TdbPkgShopListfilterItem::URL_PARAMETER_FILTER_DATA][$sListFilterItemId]);
}
return $aURLData;
} | [
"protected",
"function",
"ClearOtherCategoryTreeFilter",
"(",
"$",
"aURLData",
",",
"$",
"sListFilterItemId",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"aURLData",
")",
"&&",
"array_key_exists",
"(",
"TdbPkgShopListfilterItem",
"::",
"URL_PARAMETER_FILTER_DATA",
",",
"$",
"aURLData",
")",
"&&",
"is_array",
"(",
"$",
"aURLData",
"[",
"TdbPkgShopListfilterItem",
"::",
"URL_PARAMETER_FILTER_DATA",
"]",
")",
"&&",
"array_key_exists",
"(",
"$",
"sListFilterItemId",
",",
"$",
"aURLData",
"[",
"TdbPkgShopListfilterItem",
"::",
"URL_PARAMETER_FILTER_DATA",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"aURLData",
"[",
"TdbPkgShopListfilterItem",
"::",
"URL_PARAMETER_FILTER_DATA",
"]",
"[",
"$",
"sListFilterItemId",
"]",
")",
";",
"}",
"return",
"$",
"aURLData",
";",
"}"
] | Clear active category filter for the filter url.
You can filter onyl for one category.
@param $aURLData
@param $sListFilterItemId
@return array | [
"Clear",
"active",
"category",
"filter",
"for",
"the",
"filter",
"url",
".",
"You",
"can",
"filter",
"onyl",
"for",
"one",
"category",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L295-L303 |
31,544 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.AddItemCount | public function AddItemCount($sCategoryId, $iArticleCount)
{
$bSet = false;
if (array_key_exists($sCategoryId, $this->aContainingChildCategories)) {
$this->iAllItemCount = $this->iAllItemCount + $iArticleCount;
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while ($oChildCategoryTree = $this->oChildCategoryTreeList->Next()) {
if (!$bSet) {
$bSet = $oChildCategoryTree->AddItemCount($sCategoryId, $iArticleCount);
}
}
}
} else {
if (!is_null($this->oRealCategory) && $sCategoryId == $this->oRealCategory->id) {
$this->iAllItemCount = $iArticleCount;
$bSet = true;
}
}
return $bSet;
} | php | public function AddItemCount($sCategoryId, $iArticleCount)
{
$bSet = false;
if (array_key_exists($sCategoryId, $this->aContainingChildCategories)) {
$this->iAllItemCount = $this->iAllItemCount + $iArticleCount;
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while ($oChildCategoryTree = $this->oChildCategoryTreeList->Next()) {
if (!$bSet) {
$bSet = $oChildCategoryTree->AddItemCount($sCategoryId, $iArticleCount);
}
}
}
} else {
if (!is_null($this->oRealCategory) && $sCategoryId == $this->oRealCategory->id) {
$this->iAllItemCount = $iArticleCount;
$bSet = true;
}
}
return $bSet;
} | [
"public",
"function",
"AddItemCount",
"(",
"$",
"sCategoryId",
",",
"$",
"iArticleCount",
")",
"{",
"$",
"bSet",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"sCategoryId",
",",
"$",
"this",
"->",
"aContainingChildCategories",
")",
")",
"{",
"$",
"this",
"->",
"iAllItemCount",
"=",
"$",
"this",
"->",
"iAllItemCount",
"+",
"$",
"iArticleCount",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oChildCategoryTreeList",
")",
")",
"{",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"$",
"oChildCategoryTree",
"=",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"Next",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"bSet",
")",
"{",
"$",
"bSet",
"=",
"$",
"oChildCategoryTree",
"->",
"AddItemCount",
"(",
"$",
"sCategoryId",
",",
"$",
"iArticleCount",
")",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oRealCategory",
")",
"&&",
"$",
"sCategoryId",
"==",
"$",
"this",
"->",
"oRealCategory",
"->",
"id",
")",
"{",
"$",
"this",
"->",
"iAllItemCount",
"=",
"$",
"iArticleCount",
";",
"$",
"bSet",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"bSet",
";",
"}"
] | Add item count to category in tree and add it to all parent categories.
@param $sCategoryId
@param $iArticleCount
@return bool | [
"Add",
"item",
"count",
"to",
"category",
"in",
"tree",
"and",
"add",
"it",
"to",
"all",
"parent",
"categories",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L313-L334 |
31,545 | chameleon-system/chameleon-shop | src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php | TShopCategoryTree.MarkActiveCategories | public function MarkActiveCategories($aActiveCategories)
{
$this->bIsActive = false;
if (in_array($this->id, $aActiveCategories)) {
$this->bIsActive = true;
} else {
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while (!$this->bIsActive && ($oCatTree = &$this->oChildCategoryTreeList->Next())) {
$this->bIsActive = $this->bIsActive || $oCatTree->MarkActiveCategories($aActiveCategories);
}
$this->oChildCategoryTreeList->GoToStart();
}
}
return $this->bIsActive;
} | php | public function MarkActiveCategories($aActiveCategories)
{
$this->bIsActive = false;
if (in_array($this->id, $aActiveCategories)) {
$this->bIsActive = true;
} else {
if (!is_null($this->oChildCategoryTreeList)) {
$this->oChildCategoryTreeList->GoToStart();
while (!$this->bIsActive && ($oCatTree = &$this->oChildCategoryTreeList->Next())) {
$this->bIsActive = $this->bIsActive || $oCatTree->MarkActiveCategories($aActiveCategories);
}
$this->oChildCategoryTreeList->GoToStart();
}
}
return $this->bIsActive;
} | [
"public",
"function",
"MarkActiveCategories",
"(",
"$",
"aActiveCategories",
")",
"{",
"$",
"this",
"->",
"bIsActive",
"=",
"false",
";",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"aActiveCategories",
")",
")",
"{",
"$",
"this",
"->",
"bIsActive",
"=",
"true",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"oChildCategoryTreeList",
")",
")",
"{",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"GoToStart",
"(",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"bIsActive",
"&&",
"(",
"$",
"oCatTree",
"=",
"&",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"Next",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"bIsActive",
"=",
"$",
"this",
"->",
"bIsActive",
"||",
"$",
"oCatTree",
"->",
"MarkActiveCategories",
"(",
"$",
"aActiveCategories",
")",
";",
"}",
"$",
"this",
"->",
"oChildCategoryTreeList",
"->",
"GoToStart",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"bIsActive",
";",
"}"
] | mark categories and their parents as active if they are in the array.
@param $aActiveCategories
@return bool | [
"mark",
"categories",
"and",
"their",
"parents",
"as",
"active",
"if",
"they",
"are",
"in",
"the",
"array",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/TShopCategoryTree/TShopCategoryTree.class.php#L343-L359 |
31,546 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.createFactoryForEntity | public function createFactoryForEntity(string $entityFqn)
{
$this->assertEntityManagerSet();
$factoryFqn = $this->namespaceHelper->getFactoryFqnFromEntityFqn($entityFqn);
return new $factoryFqn($this, $this->entityManager);
} | php | public function createFactoryForEntity(string $entityFqn)
{
$this->assertEntityManagerSet();
$factoryFqn = $this->namespaceHelper->getFactoryFqnFromEntityFqn($entityFqn);
return new $factoryFqn($this, $this->entityManager);
} | [
"public",
"function",
"createFactoryForEntity",
"(",
"string",
"$",
"entityFqn",
")",
"{",
"$",
"this",
"->",
"assertEntityManagerSet",
"(",
")",
";",
"$",
"factoryFqn",
"=",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getFactoryFqnFromEntityFqn",
"(",
"$",
"entityFqn",
")",
";",
"return",
"new",
"$",
"factoryFqn",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"entityManager",
")",
";",
"}"
] | Get an instance of the specific Entity Factory for a specified Entity
Not type hinting the return because the whole point of this is to have an entity specific method, which we
can't hint for
@param string $entityFqn
@return mixed | [
"Get",
"an",
"instance",
"of",
"the",
"specific",
"Entity",
"Factory",
"for",
"a",
"specified",
"Entity"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L80-L86 |
31,547 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.create | public function create(string $entityFqn, DataTransferObjectInterface $dto = null)
{
$this->assertEntityManagerSet();
return $this->createEntity($entityFqn, $dto, true);
} | php | public function create(string $entityFqn, DataTransferObjectInterface $dto = null)
{
$this->assertEntityManagerSet();
return $this->createEntity($entityFqn, $dto, true);
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"entityFqn",
",",
"DataTransferObjectInterface",
"$",
"dto",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"assertEntityManagerSet",
"(",
")",
";",
"return",
"$",
"this",
"->",
"createEntity",
"(",
"$",
"entityFqn",
",",
"$",
"dto",
",",
"true",
")",
";",
"}"
] | Build a new entity, optionally pass in a DTO to provide the data that should be used
Optionally pass in an array of property=>value
@param string $entityFqn
@param DataTransferObjectInterface|null $dto
@return mixed
@throws MultipleValidationException
@throws ValidationException | [
"Build",
"a",
"new",
"entity",
"optionally",
"pass",
"in",
"a",
"DTO",
"to",
"provide",
"the",
"data",
"that",
"should",
"be",
"used"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L115-L120 |
31,548 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.getNewInstance | private function getNewInstance(string $entityFqn, $id): EntityInterface
{
if (isset(self::$created[$entityFqn][(string)$id])) {
throw new \RuntimeException('Trying to get a new instance when one has already been created for this ID');
}
$reflection = $this->getDoctrineStaticMetaForEntityFqn($entityFqn)
->getReflectionClass();
$entity = $reflection->newInstanceWithoutConstructor();
$runInit = $reflection->getMethod(UsesPHPMetaDataInterface::METHOD_RUN_INIT);
$runInit->setAccessible(true);
$runInit->invoke($entity);
$transactionProperty = $reflection->getProperty(AlwaysValidInterface::CREATION_TRANSACTION_RUNNING_PROPERTY);
$transactionProperty->setAccessible(true);
$transactionProperty->setValue($entity, true);
$idSetter = $reflection->getMethod('set' . IdFieldInterface::PROP_ID);
$idSetter->setAccessible(true);
$idSetter->invoke($entity, $id);
if ($entity instanceof EntityInterface) {
$this->initialiseEntity($entity);
$this->entityManager->persist($entity);
return $entity;
}
throw new \LogicException('Failed to create an instance of EntityInterface');
} | php | private function getNewInstance(string $entityFqn, $id): EntityInterface
{
if (isset(self::$created[$entityFqn][(string)$id])) {
throw new \RuntimeException('Trying to get a new instance when one has already been created for this ID');
}
$reflection = $this->getDoctrineStaticMetaForEntityFqn($entityFqn)
->getReflectionClass();
$entity = $reflection->newInstanceWithoutConstructor();
$runInit = $reflection->getMethod(UsesPHPMetaDataInterface::METHOD_RUN_INIT);
$runInit->setAccessible(true);
$runInit->invoke($entity);
$transactionProperty = $reflection->getProperty(AlwaysValidInterface::CREATION_TRANSACTION_RUNNING_PROPERTY);
$transactionProperty->setAccessible(true);
$transactionProperty->setValue($entity, true);
$idSetter = $reflection->getMethod('set' . IdFieldInterface::PROP_ID);
$idSetter->setAccessible(true);
$idSetter->invoke($entity, $id);
if ($entity instanceof EntityInterface) {
$this->initialiseEntity($entity);
$this->entityManager->persist($entity);
return $entity;
}
throw new \LogicException('Failed to create an instance of EntityInterface');
} | [
"private",
"function",
"getNewInstance",
"(",
"string",
"$",
"entityFqn",
",",
"$",
"id",
")",
":",
"EntityInterface",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"created",
"[",
"$",
"entityFqn",
"]",
"[",
"(",
"string",
")",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Trying to get a new instance when one has already been created for this ID'",
")",
";",
"}",
"$",
"reflection",
"=",
"$",
"this",
"->",
"getDoctrineStaticMetaForEntityFqn",
"(",
"$",
"entityFqn",
")",
"->",
"getReflectionClass",
"(",
")",
";",
"$",
"entity",
"=",
"$",
"reflection",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"$",
"runInit",
"=",
"$",
"reflection",
"->",
"getMethod",
"(",
"UsesPHPMetaDataInterface",
"::",
"METHOD_RUN_INIT",
")",
";",
"$",
"runInit",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"runInit",
"->",
"invoke",
"(",
"$",
"entity",
")",
";",
"$",
"transactionProperty",
"=",
"$",
"reflection",
"->",
"getProperty",
"(",
"AlwaysValidInterface",
"::",
"CREATION_TRANSACTION_RUNNING_PROPERTY",
")",
";",
"$",
"transactionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"transactionProperty",
"->",
"setValue",
"(",
"$",
"entity",
",",
"true",
")",
";",
"$",
"idSetter",
"=",
"$",
"reflection",
"->",
"getMethod",
"(",
"'set'",
".",
"IdFieldInterface",
"::",
"PROP_ID",
")",
";",
"$",
"idSetter",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"idSetter",
"->",
"invoke",
"(",
"$",
"entity",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"entity",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"this",
"->",
"initialiseEntity",
"(",
"$",
"entity",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"return",
"$",
"entity",
";",
"}",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Failed to create an instance of EntityInterface'",
")",
";",
"}"
] | Build a new instance, bypassing PPP protections so that we can call private methods and set the private
transaction property
@param string $entityFqn
@param mixed $id
@return EntityInterface | [
"Build",
"a",
"new",
"instance",
"bypassing",
"PPP",
"protections",
"so",
"that",
"we",
"can",
"call",
"private",
"methods",
"and",
"set",
"the",
"private",
"transaction",
"property"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L196-L225 |
31,549 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.initialiseEntity | public function initialiseEntity(EntityInterface $entity): void
{
$entity->ensureMetaDataIsSet($this->entityManager);
$this->addListenerToEntityIfRequired($entity);
$this->entityDependencyInjector->injectEntityDependencies($entity);
$debugInitMethod = $entity::getDoctrineStaticMeta()
->getReflectionClass()
->getMethod(UsesPHPMetaDataInterface::METHOD_DEBUG_INIT);
$debugInitMethod->setAccessible(true);
$debugInitMethod->invoke($entity);
} | php | public function initialiseEntity(EntityInterface $entity): void
{
$entity->ensureMetaDataIsSet($this->entityManager);
$this->addListenerToEntityIfRequired($entity);
$this->entityDependencyInjector->injectEntityDependencies($entity);
$debugInitMethod = $entity::getDoctrineStaticMeta()
->getReflectionClass()
->getMethod(UsesPHPMetaDataInterface::METHOD_DEBUG_INIT);
$debugInitMethod->setAccessible(true);
$debugInitMethod->invoke($entity);
} | [
"public",
"function",
"initialiseEntity",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"void",
"{",
"$",
"entity",
"->",
"ensureMetaDataIsSet",
"(",
"$",
"this",
"->",
"entityManager",
")",
";",
"$",
"this",
"->",
"addListenerToEntityIfRequired",
"(",
"$",
"entity",
")",
";",
"$",
"this",
"->",
"entityDependencyInjector",
"->",
"injectEntityDependencies",
"(",
"$",
"entity",
")",
";",
"$",
"debugInitMethod",
"=",
"$",
"entity",
"::",
"getDoctrineStaticMeta",
"(",
")",
"->",
"getReflectionClass",
"(",
")",
"->",
"getMethod",
"(",
"UsesPHPMetaDataInterface",
"::",
"METHOD_DEBUG_INIT",
")",
";",
"$",
"debugInitMethod",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"debugInitMethod",
"->",
"invoke",
"(",
"$",
"entity",
")",
";",
"}"
] | Take an already instantiated Entity and perform the final initialisation steps
@param EntityInterface $entity | [
"Take",
"an",
"already",
"instantiated",
"Entity",
"and",
"perform",
"the",
"final",
"initialisation",
"steps"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L237-L247 |
31,550 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.addListenerToEntityIfRequired | private function addListenerToEntityIfRequired(EntityInterface $entity): void
{
if (!$entity instanceof NotifyPropertyChanged) {
return;
}
$listener = $this->entityManager->getUnitOfWork();
$entity->addPropertyChangedListener($listener);
} | php | private function addListenerToEntityIfRequired(EntityInterface $entity): void
{
if (!$entity instanceof NotifyPropertyChanged) {
return;
}
$listener = $this->entityManager->getUnitOfWork();
$entity->addPropertyChangedListener($listener);
} | [
"private",
"function",
"addListenerToEntityIfRequired",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"entity",
"instanceof",
"NotifyPropertyChanged",
")",
"{",
"return",
";",
"}",
"$",
"listener",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getUnitOfWork",
"(",
")",
";",
"$",
"entity",
"->",
"addPropertyChangedListener",
"(",
"$",
"listener",
")",
";",
"}"
] | Generally DSM Entities are using the Notify change tracking policy.
This ensures that they are fully set up for that
@param EntityInterface $entity | [
"Generally",
"DSM",
"Entities",
"are",
"using",
"the",
"Notify",
"change",
"tracking",
"policy",
".",
"This",
"ensures",
"that",
"they",
"are",
"fully",
"set",
"up",
"for",
"that"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L255-L262 |
31,551 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.convertCollectionOfDtosToEntities | private function convertCollectionOfDtosToEntities(Collection $collection)
{
if (0 === $collection->count()) {
return;
}
list($dtoFqn, $collectionEntityFqn) = $this->deriveDtoAndEntityFqnFromCollection($collection);
foreach ($collection as $key => $dto) {
if ($dto instanceof $collectionEntityFqn) {
continue;
}
if (false === \is_object($dto)) {
throw new \InvalidArgumentException('Unexpected DTO value ' .
\print_r($dto, true) .
', expected an instance of' .
$dtoFqn);
}
if (false === ($dto instanceof DataTransferObjectInterface)) {
throw new \InvalidArgumentException('Found none DTO item in collection, was instance of ' .
\get_class($dto));
}
if (false === ($dto instanceof $dtoFqn)) {
throw new \InvalidArgumentException('Unexpected DTO ' . \get_class($dto) . ', expected ' . $dtoFqn);
}
$collection->set($key, $this->createEntity($collectionEntityFqn, $dto, false));
}
} | php | private function convertCollectionOfDtosToEntities(Collection $collection)
{
if (0 === $collection->count()) {
return;
}
list($dtoFqn, $collectionEntityFqn) = $this->deriveDtoAndEntityFqnFromCollection($collection);
foreach ($collection as $key => $dto) {
if ($dto instanceof $collectionEntityFqn) {
continue;
}
if (false === \is_object($dto)) {
throw new \InvalidArgumentException('Unexpected DTO value ' .
\print_r($dto, true) .
', expected an instance of' .
$dtoFqn);
}
if (false === ($dto instanceof DataTransferObjectInterface)) {
throw new \InvalidArgumentException('Found none DTO item in collection, was instance of ' .
\get_class($dto));
}
if (false === ($dto instanceof $dtoFqn)) {
throw new \InvalidArgumentException('Unexpected DTO ' . \get_class($dto) . ', expected ' . $dtoFqn);
}
$collection->set($key, $this->createEntity($collectionEntityFqn, $dto, false));
}
} | [
"private",
"function",
"convertCollectionOfDtosToEntities",
"(",
"Collection",
"$",
"collection",
")",
"{",
"if",
"(",
"0",
"===",
"$",
"collection",
"->",
"count",
"(",
")",
")",
"{",
"return",
";",
"}",
"list",
"(",
"$",
"dtoFqn",
",",
"$",
"collectionEntityFqn",
")",
"=",
"$",
"this",
"->",
"deriveDtoAndEntityFqnFromCollection",
"(",
"$",
"collection",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"key",
"=>",
"$",
"dto",
")",
"{",
"if",
"(",
"$",
"dto",
"instanceof",
"$",
"collectionEntityFqn",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"false",
"===",
"\\",
"is_object",
"(",
"$",
"dto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unexpected DTO value '",
".",
"\\",
"print_r",
"(",
"$",
"dto",
",",
"true",
")",
".",
"', expected an instance of'",
".",
"$",
"dtoFqn",
")",
";",
"}",
"if",
"(",
"false",
"===",
"(",
"$",
"dto",
"instanceof",
"DataTransferObjectInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Found none DTO item in collection, was instance of '",
".",
"\\",
"get_class",
"(",
"$",
"dto",
")",
")",
";",
"}",
"if",
"(",
"false",
"===",
"(",
"$",
"dto",
"instanceof",
"$",
"dtoFqn",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unexpected DTO '",
".",
"\\",
"get_class",
"(",
"$",
"dto",
")",
".",
"', expected '",
".",
"$",
"dtoFqn",
")",
";",
"}",
"$",
"collection",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"createEntity",
"(",
"$",
"collectionEntityFqn",
",",
"$",
"dto",
",",
"false",
")",
")",
";",
"}",
"}"
] | This will take an ArrayCollection of DTO objects and replace them with the Entities
@param Collection $collection
@throws MultipleValidationException
@throws ValidationException | [
"This",
"will",
"take",
"an",
"ArrayCollection",
"of",
"DTO",
"objects",
"and",
"replace",
"them",
"with",
"the",
"Entities"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L418-L444 |
31,552 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.deriveDtoAndEntityFqnFromCollection | private function deriveDtoAndEntityFqnFromCollection(Collection $collection): array
{
if (0 === $collection->count()) {
throw new \RuntimeException('Collection is empty');
}
$dtoFqn = null;
$collectionEntityFqn = null;
foreach ($collection as $dto) {
if ($dto instanceof EntityInterface) {
$collectionEntityFqn = \get_class($dto);
continue;
}
if (false === ($dto instanceof DataTransferObjectInterface)) {
throw new \InvalidArgumentException(
'Found none DTO item in collection, was instance of ' . \get_class($dto)
);
}
if (null === $dtoFqn) {
$dtoFqn = \get_class($dto);
continue;
}
if (false === ($dto instanceof $dtoFqn)) {
throw new \InvalidArgumentException(
'Mismatched collection, expecting dtoFqn ' .
$dtoFqn .
' but found ' .
\get_class($dto)
);
}
}
if (null === $dtoFqn && null === $collectionEntityFqn) {
throw new \RuntimeException('Failed deriving either the DTO or Entity FQN from the collection');
}
if (null === $collectionEntityFqn) {
$collectionEntityFqn = $this->namespaceHelper->getEntityFqnFromEntityDtoFqn($dtoFqn);
}
if (null === $dtoFqn) {
$dtoFqn = $this->namespaceHelper->getEntityDtoFqnFromEntityFqn($collectionEntityFqn);
}
return [$dtoFqn, $collectionEntityFqn];
} | php | private function deriveDtoAndEntityFqnFromCollection(Collection $collection): array
{
if (0 === $collection->count()) {
throw new \RuntimeException('Collection is empty');
}
$dtoFqn = null;
$collectionEntityFqn = null;
foreach ($collection as $dto) {
if ($dto instanceof EntityInterface) {
$collectionEntityFqn = \get_class($dto);
continue;
}
if (false === ($dto instanceof DataTransferObjectInterface)) {
throw new \InvalidArgumentException(
'Found none DTO item in collection, was instance of ' . \get_class($dto)
);
}
if (null === $dtoFqn) {
$dtoFqn = \get_class($dto);
continue;
}
if (false === ($dto instanceof $dtoFqn)) {
throw new \InvalidArgumentException(
'Mismatched collection, expecting dtoFqn ' .
$dtoFqn .
' but found ' .
\get_class($dto)
);
}
}
if (null === $dtoFqn && null === $collectionEntityFqn) {
throw new \RuntimeException('Failed deriving either the DTO or Entity FQN from the collection');
}
if (null === $collectionEntityFqn) {
$collectionEntityFqn = $this->namespaceHelper->getEntityFqnFromEntityDtoFqn($dtoFqn);
}
if (null === $dtoFqn) {
$dtoFqn = $this->namespaceHelper->getEntityDtoFqnFromEntityFqn($collectionEntityFqn);
}
return [$dtoFqn, $collectionEntityFqn];
} | [
"private",
"function",
"deriveDtoAndEntityFqnFromCollection",
"(",
"Collection",
"$",
"collection",
")",
":",
"array",
"{",
"if",
"(",
"0",
"===",
"$",
"collection",
"->",
"count",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Collection is empty'",
")",
";",
"}",
"$",
"dtoFqn",
"=",
"null",
";",
"$",
"collectionEntityFqn",
"=",
"null",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"dto",
")",
"{",
"if",
"(",
"$",
"dto",
"instanceof",
"EntityInterface",
")",
"{",
"$",
"collectionEntityFqn",
"=",
"\\",
"get_class",
"(",
"$",
"dto",
")",
";",
"continue",
";",
"}",
"if",
"(",
"false",
"===",
"(",
"$",
"dto",
"instanceof",
"DataTransferObjectInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Found none DTO item in collection, was instance of '",
".",
"\\",
"get_class",
"(",
"$",
"dto",
")",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"dtoFqn",
")",
"{",
"$",
"dtoFqn",
"=",
"\\",
"get_class",
"(",
"$",
"dto",
")",
";",
"continue",
";",
"}",
"if",
"(",
"false",
"===",
"(",
"$",
"dto",
"instanceof",
"$",
"dtoFqn",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Mismatched collection, expecting dtoFqn '",
".",
"$",
"dtoFqn",
".",
"' but found '",
".",
"\\",
"get_class",
"(",
"$",
"dto",
")",
")",
";",
"}",
"}",
"if",
"(",
"null",
"===",
"$",
"dtoFqn",
"&&",
"null",
"===",
"$",
"collectionEntityFqn",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Failed deriving either the DTO or Entity FQN from the collection'",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"collectionEntityFqn",
")",
"{",
"$",
"collectionEntityFqn",
"=",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getEntityFqnFromEntityDtoFqn",
"(",
"$",
"dtoFqn",
")",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"dtoFqn",
")",
"{",
"$",
"dtoFqn",
"=",
"$",
"this",
"->",
"namespaceHelper",
"->",
"getEntityDtoFqnFromEntityFqn",
"(",
"$",
"collectionEntityFqn",
")",
";",
"}",
"return",
"[",
"$",
"dtoFqn",
",",
"$",
"collectionEntityFqn",
"]",
";",
"}"
] | Loop through a collection and determine the DTO and Entity Fqn it contains
@param Collection $collection
@return array
@SuppressWarnings(PHPMD.NPathComplexity)
@SuppressWarnings(PHPMD.CyclomaticComplexity) | [
"Loop",
"through",
"a",
"collection",
"and",
"determine",
"the",
"DTO",
"and",
"Entity",
"Fqn",
"it",
"contains"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L455-L496 |
31,553 | edmondscommerce/doctrine-static-meta | src/Entity/Factory/EntityFactory.php | EntityFactory.stopTransaction | private function stopTransaction(): void
{
$validationExceptions = [];
foreach (self::$created as $entities) {
foreach ($entities as $entity) {
$transactionProperty =
$entity::getDoctrineStaticMeta()
->getReflectionClass()
->getProperty(AlwaysValidInterface::CREATION_TRANSACTION_RUNNING_PROPERTY);
$transactionProperty->setAccessible(true);
$transactionProperty->setValue($entity, false);
try {
$entity->getValidator()->validate();
} catch (ValidationException $validationException) {
$validationExceptions[] = $validationException;
continue;
}
}
}
if ([] !== $validationExceptions) {
throw new MultipleValidationException($validationExceptions);
}
self::$created = [];
$this->dtosProcessed = [];
} | php | private function stopTransaction(): void
{
$validationExceptions = [];
foreach (self::$created as $entities) {
foreach ($entities as $entity) {
$transactionProperty =
$entity::getDoctrineStaticMeta()
->getReflectionClass()
->getProperty(AlwaysValidInterface::CREATION_TRANSACTION_RUNNING_PROPERTY);
$transactionProperty->setAccessible(true);
$transactionProperty->setValue($entity, false);
try {
$entity->getValidator()->validate();
} catch (ValidationException $validationException) {
$validationExceptions[] = $validationException;
continue;
}
}
}
if ([] !== $validationExceptions) {
throw new MultipleValidationException($validationExceptions);
}
self::$created = [];
$this->dtosProcessed = [];
} | [
"private",
"function",
"stopTransaction",
"(",
")",
":",
"void",
"{",
"$",
"validationExceptions",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"$",
"created",
"as",
"$",
"entities",
")",
"{",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"transactionProperty",
"=",
"$",
"entity",
"::",
"getDoctrineStaticMeta",
"(",
")",
"->",
"getReflectionClass",
"(",
")",
"->",
"getProperty",
"(",
"AlwaysValidInterface",
"::",
"CREATION_TRANSACTION_RUNNING_PROPERTY",
")",
";",
"$",
"transactionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"transactionProperty",
"->",
"setValue",
"(",
"$",
"entity",
",",
"false",
")",
";",
"try",
"{",
"$",
"entity",
"->",
"getValidator",
"(",
")",
"->",
"validate",
"(",
")",
";",
"}",
"catch",
"(",
"ValidationException",
"$",
"validationException",
")",
"{",
"$",
"validationExceptions",
"[",
"]",
"=",
"$",
"validationException",
";",
"continue",
";",
"}",
"}",
"}",
"if",
"(",
"[",
"]",
"!==",
"$",
"validationExceptions",
")",
"{",
"throw",
"new",
"MultipleValidationException",
"(",
"$",
"validationExceptions",
")",
";",
"}",
"self",
"::",
"$",
"created",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"dtosProcessed",
"=",
"[",
"]",
";",
"}"
] | Loop through all created entities and reset the transaction running property to false,
then remove the list of created entities
@throws MultipleValidationException | [
"Loop",
"through",
"all",
"created",
"entities",
"and",
"reset",
"the",
"transaction",
"running",
"property",
"to",
"false",
"then",
"remove",
"the",
"list",
"of",
"created",
"entities"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/Entity/Factory/EntityFactory.php#L504-L528 |
31,554 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Model/IdList.php | OffAmazonPaymentsNotifications_Model_IdList.setId | public function setId($Id)
{
if (!$this->_isNumericArray($Id)) {
$Id = array ($Id);
}
$this->fields['Id']['FieldValue'] = $Id;
return $this;
} | php | public function setId($Id)
{
if (!$this->_isNumericArray($Id)) {
$Id = array ($Id);
}
$this->fields['Id']['FieldValue'] = $Id;
return $this;
} | [
"public",
"function",
"setId",
"(",
"$",
"Id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isNumericArray",
"(",
"$",
"Id",
")",
")",
"{",
"$",
"Id",
"=",
"array",
"(",
"$",
"Id",
")",
";",
"}",
"$",
"this",
"->",
"fields",
"[",
"'Id'",
"]",
"[",
"'FieldValue'",
"]",
"=",
"$",
"Id",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the value of the Id.
@param string|array $Id string or array of string Ids
@return this instance | [
"Sets",
"the",
"value",
"of",
"the",
"Id",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Model/IdList.php#L70-L77 |
31,555 | chameleon-system/chameleon-shop | src/ShopRatingServiceBundle/objects/db/TPkgShopRatingServiceRating.class.php | TPkgShopRatingServiceRating.Render | public function Render($sViewName = 'RatingServiceRating_standard', $sViewSubType = 'pkgShopRatingService/views', $sViewType = 'Customer', $sSpotName = null, $aCallTimeVars = array())
{
$oView = new TViewParser();
$oRatingService = $this->GetFieldPkgShopRatingService();
$oView->AddVar('oRating', $this);
$oView->AddVar('oRatingService', $oRatingService);
$oView->AddVar('fieldRatingDate', $this->fieldRatingDate);
$sRatingText = $this->fieldRatingText;
if (false == $oRatingService->fieldRatingsContainHtml) {
$sRatingText = nl2br(TGlobal::OutHTML(strip_tags($sRatingText)));
}
$oView->AddVar('fieldRatingText', $sRatingText);
$oView->AddVar('fieldRatingService_CurrentRating', $this->GetFieldPkgShopRatingService()->fieldCurrentRating);
return $oView->RenderObjectPackageView($sViewName, $sViewSubType, $sViewType);
} | php | public function Render($sViewName = 'RatingServiceRating_standard', $sViewSubType = 'pkgShopRatingService/views', $sViewType = 'Customer', $sSpotName = null, $aCallTimeVars = array())
{
$oView = new TViewParser();
$oRatingService = $this->GetFieldPkgShopRatingService();
$oView->AddVar('oRating', $this);
$oView->AddVar('oRatingService', $oRatingService);
$oView->AddVar('fieldRatingDate', $this->fieldRatingDate);
$sRatingText = $this->fieldRatingText;
if (false == $oRatingService->fieldRatingsContainHtml) {
$sRatingText = nl2br(TGlobal::OutHTML(strip_tags($sRatingText)));
}
$oView->AddVar('fieldRatingText', $sRatingText);
$oView->AddVar('fieldRatingService_CurrentRating', $this->GetFieldPkgShopRatingService()->fieldCurrentRating);
return $oView->RenderObjectPackageView($sViewName, $sViewSubType, $sViewType);
} | [
"public",
"function",
"Render",
"(",
"$",
"sViewName",
"=",
"'RatingServiceRating_standard'",
",",
"$",
"sViewSubType",
"=",
"'pkgShopRatingService/views'",
",",
"$",
"sViewType",
"=",
"'Customer'",
",",
"$",
"sSpotName",
"=",
"null",
",",
"$",
"aCallTimeVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"oView",
"=",
"new",
"TViewParser",
"(",
")",
";",
"$",
"oRatingService",
"=",
"$",
"this",
"->",
"GetFieldPkgShopRatingService",
"(",
")",
";",
"$",
"oView",
"->",
"AddVar",
"(",
"'oRating'",
",",
"$",
"this",
")",
";",
"$",
"oView",
"->",
"AddVar",
"(",
"'oRatingService'",
",",
"$",
"oRatingService",
")",
";",
"$",
"oView",
"->",
"AddVar",
"(",
"'fieldRatingDate'",
",",
"$",
"this",
"->",
"fieldRatingDate",
")",
";",
"$",
"sRatingText",
"=",
"$",
"this",
"->",
"fieldRatingText",
";",
"if",
"(",
"false",
"==",
"$",
"oRatingService",
"->",
"fieldRatingsContainHtml",
")",
"{",
"$",
"sRatingText",
"=",
"nl2br",
"(",
"TGlobal",
"::",
"OutHTML",
"(",
"strip_tags",
"(",
"$",
"sRatingText",
")",
")",
")",
";",
"}",
"$",
"oView",
"->",
"AddVar",
"(",
"'fieldRatingText'",
",",
"$",
"sRatingText",
")",
";",
"$",
"oView",
"->",
"AddVar",
"(",
"'fieldRatingService_CurrentRating'",
",",
"$",
"this",
"->",
"GetFieldPkgShopRatingService",
"(",
")",
"->",
"fieldCurrentRating",
")",
";",
"return",
"$",
"oView",
"->",
"RenderObjectPackageView",
"(",
"$",
"sViewName",
",",
"$",
"sViewSubType",
",",
"$",
"sViewType",
")",
";",
"}"
] | Render object.
@param string $sViewName
@param string $sViewSubType
@param string $sViewType
@param null $sSpotName
@param array $aCallTimeVars
@return string | [
"Render",
"object",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopRatingServiceBundle/objects/db/TPkgShopRatingServiceRating.class.php#L25-L43 |
31,556 | PGB-LIV/php-ms | src/Utility/Fragment/FragmentFactory.php | FragmentFactory.getMethodFragments | public static function getMethodFragments($method, ModifiableSequenceInterface $sequence)
{
$fragmentTypes = array();
switch (strtoupper($method)) {
case 'CID':
case 'HCD':
$fragmentTypes['B'] = new BFragment($sequence);
$fragmentTypes['Y'] = new YFragment($sequence);
break;
case 'ECD':
$fragmentTypes['C'] = new CFragment($sequence);
$fragmentTypes['Z'] = new ZFragment($sequence);
$fragmentTypes['B'] = new BFragment($sequence);
break;
case 'ETD':
$fragmentTypes['C'] = new CFragment($sequence);
$fragmentTypes['Z'] = new ZFragment($sequence);
break;
case 'CTD':
case 'EDD':
case 'NETD':
$fragmentTypes['A'] = new AFragment($sequence);
$fragmentTypes['X'] = new XFragment($sequence);
break;
case 'ETHCD':
$fragmentTypes['B'] = new BFragment($sequence);
$fragmentTypes['Y'] = new YFragment($sequence);
$fragmentTypes['C'] = new CFragment($sequence);
$fragmentTypes['Z'] = new ZFragment($sequence);
break;
default:
throw new \InvalidArgumentException('Unknown fragmentation method type "' . $method . '"');
}
return $fragmentTypes;
} | php | public static function getMethodFragments($method, ModifiableSequenceInterface $sequence)
{
$fragmentTypes = array();
switch (strtoupper($method)) {
case 'CID':
case 'HCD':
$fragmentTypes['B'] = new BFragment($sequence);
$fragmentTypes['Y'] = new YFragment($sequence);
break;
case 'ECD':
$fragmentTypes['C'] = new CFragment($sequence);
$fragmentTypes['Z'] = new ZFragment($sequence);
$fragmentTypes['B'] = new BFragment($sequence);
break;
case 'ETD':
$fragmentTypes['C'] = new CFragment($sequence);
$fragmentTypes['Z'] = new ZFragment($sequence);
break;
case 'CTD':
case 'EDD':
case 'NETD':
$fragmentTypes['A'] = new AFragment($sequence);
$fragmentTypes['X'] = new XFragment($sequence);
break;
case 'ETHCD':
$fragmentTypes['B'] = new BFragment($sequence);
$fragmentTypes['Y'] = new YFragment($sequence);
$fragmentTypes['C'] = new CFragment($sequence);
$fragmentTypes['Z'] = new ZFragment($sequence);
break;
default:
throw new \InvalidArgumentException('Unknown fragmentation method type "' . $method . '"');
}
return $fragmentTypes;
} | [
"public",
"static",
"function",
"getMethodFragments",
"(",
"$",
"method",
",",
"ModifiableSequenceInterface",
"$",
"sequence",
")",
"{",
"$",
"fragmentTypes",
"=",
"array",
"(",
")",
";",
"switch",
"(",
"strtoupper",
"(",
"$",
"method",
")",
")",
"{",
"case",
"'CID'",
":",
"case",
"'HCD'",
":",
"$",
"fragmentTypes",
"[",
"'B'",
"]",
"=",
"new",
"BFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'Y'",
"]",
"=",
"new",
"YFragment",
"(",
"$",
"sequence",
")",
";",
"break",
";",
"case",
"'ECD'",
":",
"$",
"fragmentTypes",
"[",
"'C'",
"]",
"=",
"new",
"CFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'Z'",
"]",
"=",
"new",
"ZFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'B'",
"]",
"=",
"new",
"BFragment",
"(",
"$",
"sequence",
")",
";",
"break",
";",
"case",
"'ETD'",
":",
"$",
"fragmentTypes",
"[",
"'C'",
"]",
"=",
"new",
"CFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'Z'",
"]",
"=",
"new",
"ZFragment",
"(",
"$",
"sequence",
")",
";",
"break",
";",
"case",
"'CTD'",
":",
"case",
"'EDD'",
":",
"case",
"'NETD'",
":",
"$",
"fragmentTypes",
"[",
"'A'",
"]",
"=",
"new",
"AFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'X'",
"]",
"=",
"new",
"XFragment",
"(",
"$",
"sequence",
")",
";",
"break",
";",
"case",
"'ETHCD'",
":",
"$",
"fragmentTypes",
"[",
"'B'",
"]",
"=",
"new",
"BFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'Y'",
"]",
"=",
"new",
"YFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'C'",
"]",
"=",
"new",
"CFragment",
"(",
"$",
"sequence",
")",
";",
"$",
"fragmentTypes",
"[",
"'Z'",
"]",
"=",
"new",
"ZFragment",
"(",
"$",
"sequence",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unknown fragmentation method type \"'",
".",
"$",
"method",
".",
"'\"'",
")",
";",
"}",
"return",
"$",
"fragmentTypes",
";",
"}"
] | For a specified method, returns the possible fragmentat ion types that may be produced
@param string $method
The method to get fragment types for
@param ModifiableSequenceInterface $sequence
The peptide or protein sequence object to get fragment types for
@return FragmentInterface[] | [
"For",
"a",
"specified",
"method",
"returns",
"the",
"possible",
"fragmentat",
"ion",
"types",
"that",
"may",
"be",
"produced"
] | 091751eb12512f4bc6ada07bda745ce49331e24f | https://github.com/PGB-LIV/php-ms/blob/091751eb12512f4bc6ada07bda745ce49331e24f/src/Utility/Fragment/FragmentFactory.php#L59-L95 |
31,557 | chameleon-system/chameleon-shop | src/ShopArticlePreorderBundle/pkgShop/objects/db/TPkgShopArticlePreorder_ShopArticle.class.php | TPkgShopArticlePreorder_ShopArticle.StockWasUpdatedHook | protected function StockWasUpdatedHook($dOldValue, $dNewValue)
{
$bReturn = parent::StockWasUpdatedHook($dOldValue, $dNewValue);
if ($dOldValue < 1 && $dNewValue > 0) {
$oShopArticlePreorderList = &TdbPkgShopArticlePreorderList::GetListForShopArticleId($this->id);
while ($oShopArticlePreorder = $oShopArticlePreorderList->Next()) {
$oShopArticlePreorder->SendMail();
}
}
return $bReturn;
} | php | protected function StockWasUpdatedHook($dOldValue, $dNewValue)
{
$bReturn = parent::StockWasUpdatedHook($dOldValue, $dNewValue);
if ($dOldValue < 1 && $dNewValue > 0) {
$oShopArticlePreorderList = &TdbPkgShopArticlePreorderList::GetListForShopArticleId($this->id);
while ($oShopArticlePreorder = $oShopArticlePreorderList->Next()) {
$oShopArticlePreorder->SendMail();
}
}
return $bReturn;
} | [
"protected",
"function",
"StockWasUpdatedHook",
"(",
"$",
"dOldValue",
",",
"$",
"dNewValue",
")",
"{",
"$",
"bReturn",
"=",
"parent",
"::",
"StockWasUpdatedHook",
"(",
"$",
"dOldValue",
",",
"$",
"dNewValue",
")",
";",
"if",
"(",
"$",
"dOldValue",
"<",
"1",
"&&",
"$",
"dNewValue",
">",
"0",
")",
"{",
"$",
"oShopArticlePreorderList",
"=",
"&",
"TdbPkgShopArticlePreorderList",
"::",
"GetListForShopArticleId",
"(",
"$",
"this",
"->",
"id",
")",
";",
"while",
"(",
"$",
"oShopArticlePreorder",
"=",
"$",
"oShopArticlePreorderList",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"oShopArticlePreorder",
"->",
"SendMail",
"(",
")",
";",
"}",
"}",
"return",
"$",
"bReturn",
";",
"}"
] | hook called when the stock value of the article changed.
@param float $dOldValue
@param float $dNewValue
@return bool | [
"hook",
"called",
"when",
"the",
"stock",
"value",
"of",
"the",
"article",
"changed",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticlePreorderBundle/pkgShop/objects/db/TPkgShopArticlePreorder_ShopArticle.class.php#L22-L33 |
31,558 | Erebot/Erebot | src/IrcParser.php | IrcParser.stripCodes | public static function stripCodes($text, $strip = self::STRIP_ALL)
{
if (!is_int($strip)) {
throw new \Erebot\InvalidValueException("Invalid stripping flags");
}
if ($strip & self::STRIP_BOLD) {
$text = str_replace("\002", '', $text);
}
if ($strip & self::STRIP_COLORS) {
$text = preg_replace("/\003(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/", '', $text);
}
if ($strip & self::STRIP_RESET) {
$text = str_replace("\017", '', $text);
}
if ($strip & self::STRIP_REVERSE) {
$text = str_replace("\026", '', $text);
}
if ($strip & self::STRIP_UNDERLINE) {
$text = str_replace("\037", '', $text);
}
return $text;
} | php | public static function stripCodes($text, $strip = self::STRIP_ALL)
{
if (!is_int($strip)) {
throw new \Erebot\InvalidValueException("Invalid stripping flags");
}
if ($strip & self::STRIP_BOLD) {
$text = str_replace("\002", '', $text);
}
if ($strip & self::STRIP_COLORS) {
$text = preg_replace("/\003(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/", '', $text);
}
if ($strip & self::STRIP_RESET) {
$text = str_replace("\017", '', $text);
}
if ($strip & self::STRIP_REVERSE) {
$text = str_replace("\026", '', $text);
}
if ($strip & self::STRIP_UNDERLINE) {
$text = str_replace("\037", '', $text);
}
return $text;
} | [
"public",
"static",
"function",
"stripCodes",
"(",
"$",
"text",
",",
"$",
"strip",
"=",
"self",
"::",
"STRIP_ALL",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"strip",
")",
")",
"{",
"throw",
"new",
"\\",
"Erebot",
"\\",
"InvalidValueException",
"(",
"\"Invalid stripping flags\"",
")",
";",
"}",
"if",
"(",
"$",
"strip",
"&",
"self",
"::",
"STRIP_BOLD",
")",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"\"\\002\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}",
"if",
"(",
"$",
"strip",
"&",
"self",
"::",
"STRIP_COLORS",
")",
"{",
"$",
"text",
"=",
"preg_replace",
"(",
"\"/\\003(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}",
"if",
"(",
"$",
"strip",
"&",
"self",
"::",
"STRIP_RESET",
")",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"\"\\017\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}",
"if",
"(",
"$",
"strip",
"&",
"self",
"::",
"STRIP_REVERSE",
")",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"\"\\026\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}",
"if",
"(",
"$",
"strip",
"&",
"self",
"::",
"STRIP_UNDERLINE",
")",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"\"\\037\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Strips IRC styles from a text.
\param string $text
The text from which styles must be stripped.
\param int $strip
A bitwise OR of the codes of the styles we want to strip.
The default is to strip all forms of styles from the text.
See also the Erebot::IrcParser::STRIP_* constants.
\retval string
The text with all the styles specified in $strip stripped. | [
"Strips",
"IRC",
"styles",
"from",
"a",
"text",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L88-L115 |
31,559 | Erebot/Erebot | src/IrcParser.php | IrcParser.ctcpUnquote | protected static function ctcpUnquote($msg)
{
// CTCP-level unquoting
$quoting = array(
"\\a" => "\001",
"\\\\" => "\\",
"\\" => "", // Ignore quoting character
// for invalid sequences.
);
$msg = strtr($msg, $quoting);
// Low-level unquoting
$quoting = array(
"\0200" => "\000",
"\020n" => "\n",
"\020r" => "\r",
"\020\020" => "\020",
"\020" => "", // Ignore quoting character
// for invalid sequences.
);
$msg = strtr($msg, $quoting);
return $msg;
} | php | protected static function ctcpUnquote($msg)
{
// CTCP-level unquoting
$quoting = array(
"\\a" => "\001",
"\\\\" => "\\",
"\\" => "", // Ignore quoting character
// for invalid sequences.
);
$msg = strtr($msg, $quoting);
// Low-level unquoting
$quoting = array(
"\0200" => "\000",
"\020n" => "\n",
"\020r" => "\r",
"\020\020" => "\020",
"\020" => "", // Ignore quoting character
// for invalid sequences.
);
$msg = strtr($msg, $quoting);
return $msg;
} | [
"protected",
"static",
"function",
"ctcpUnquote",
"(",
"$",
"msg",
")",
"{",
"// CTCP-level unquoting",
"$",
"quoting",
"=",
"array",
"(",
"\"\\\\a\"",
"=>",
"\"\\001\"",
",",
"\"\\\\\\\\\"",
"=>",
"\"\\\\\"",
",",
"\"\\\\\"",
"=>",
"\"\"",
",",
"// Ignore quoting character",
"// for invalid sequences.",
")",
";",
"$",
"msg",
"=",
"strtr",
"(",
"$",
"msg",
",",
"$",
"quoting",
")",
";",
"// Low-level unquoting",
"$",
"quoting",
"=",
"array",
"(",
"\"\\0200\"",
"=>",
"\"\\000\"",
",",
"\"\\020n\"",
"=>",
"\"\\n\"",
",",
"\"\\020r\"",
"=>",
"\"\\r\"",
",",
"\"\\020\\020\"",
"=>",
"\"\\020\"",
",",
"\"\\020\"",
"=>",
"\"\"",
",",
"// Ignore quoting character",
"// for invalid sequences.",
")",
";",
"$",
"msg",
"=",
"strtr",
"(",
"$",
"msg",
",",
"$",
"quoting",
")",
";",
"return",
"$",
"msg",
";",
"}"
] | Unquotes a CTCP message.
\param string $msg
Some CTCP message to unquote.
\retval string
The message, with CTCP quoting removed.
\see
http://www.irchelp.org/irchelp/rfc/ctcpspec.html | [
"Unquotes",
"a",
"CTCP",
"message",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L160-L182 |
31,560 | Erebot/Erebot | src/IrcParser.php | IrcParser.noticeOrPrivmsg | protected function noticeOrPrivmsg($origin, $msg, $mapping)
{
// :nick1!ident@host NOTICE <nick2/#chan> :Message
// :nick1!ident@host PRIVMSG <nick2/#chan> :Message
$target = $msg[0];
$msg = $msg[1];
$isChan = (int) $this->connection->isChannel($target);
$len = strlen($msg);
if ($len > 1 && $msg[$len-1] == "\x01" && $msg[0] == "\x01") {
// Remove the markers.
$msg = (string) substr($msg, 1, -1);
// Unquote the message.
$msg = self::ctcpUnquote($msg);
// Extract the tag from the rest of the message.
$pos = strcspn($msg, " ");
$ctcp = substr($msg, 0, $pos);
$msg = (string) substr($msg, $pos + 1);
if ($ctcp == "ACTION") {
if ($isChan) {
return $this->connection->dispatch(
$this->makeEvent($mapping['action'][$isChan], $target, $origin, $msg)
);
}
return $this->connection->dispatch(
$this->makeEvent($mapping['action'][$isChan], $origin, $msg)
);
}
if ($isChan) {
return $this->connection->dispatch(
$this->makeEvent($mapping['ctcp'][$isChan], $target, $origin, $ctcp, $msg)
);
}
return $this->connection->dispatch(
$this->makeEvent($mapping['ctcp'][$isChan], $origin, $ctcp, $msg)
);
}
if ($isChan) {
return $this->connection->dispatch(
$this->makeEvent(
$mapping['normal'][$isChan],
$target,
$origin,
$msg
)
);
}
return $this->connection->dispatch(
$this->makeEvent($mapping['normal'][$isChan], $origin, $msg)
);
} | php | protected function noticeOrPrivmsg($origin, $msg, $mapping)
{
// :nick1!ident@host NOTICE <nick2/#chan> :Message
// :nick1!ident@host PRIVMSG <nick2/#chan> :Message
$target = $msg[0];
$msg = $msg[1];
$isChan = (int) $this->connection->isChannel($target);
$len = strlen($msg);
if ($len > 1 && $msg[$len-1] == "\x01" && $msg[0] == "\x01") {
// Remove the markers.
$msg = (string) substr($msg, 1, -1);
// Unquote the message.
$msg = self::ctcpUnquote($msg);
// Extract the tag from the rest of the message.
$pos = strcspn($msg, " ");
$ctcp = substr($msg, 0, $pos);
$msg = (string) substr($msg, $pos + 1);
if ($ctcp == "ACTION") {
if ($isChan) {
return $this->connection->dispatch(
$this->makeEvent($mapping['action'][$isChan], $target, $origin, $msg)
);
}
return $this->connection->dispatch(
$this->makeEvent($mapping['action'][$isChan], $origin, $msg)
);
}
if ($isChan) {
return $this->connection->dispatch(
$this->makeEvent($mapping['ctcp'][$isChan], $target, $origin, $ctcp, $msg)
);
}
return $this->connection->dispatch(
$this->makeEvent($mapping['ctcp'][$isChan], $origin, $ctcp, $msg)
);
}
if ($isChan) {
return $this->connection->dispatch(
$this->makeEvent(
$mapping['normal'][$isChan],
$target,
$origin,
$msg
)
);
}
return $this->connection->dispatch(
$this->makeEvent($mapping['normal'][$isChan], $origin, $msg)
);
} | [
"protected",
"function",
"noticeOrPrivmsg",
"(",
"$",
"origin",
",",
"$",
"msg",
",",
"$",
"mapping",
")",
"{",
"// :nick1!ident@host NOTICE <nick2/#chan> :Message",
"// :nick1!ident@host PRIVMSG <nick2/#chan> :Message",
"$",
"target",
"=",
"$",
"msg",
"[",
"0",
"]",
";",
"$",
"msg",
"=",
"$",
"msg",
"[",
"1",
"]",
";",
"$",
"isChan",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"connection",
"->",
"isChannel",
"(",
"$",
"target",
")",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"msg",
")",
";",
"if",
"(",
"$",
"len",
">",
"1",
"&&",
"$",
"msg",
"[",
"$",
"len",
"-",
"1",
"]",
"==",
"\"\\x01\"",
"&&",
"$",
"msg",
"[",
"0",
"]",
"==",
"\"\\x01\"",
")",
"{",
"// Remove the markers.",
"$",
"msg",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"msg",
",",
"1",
",",
"-",
"1",
")",
";",
"// Unquote the message.",
"$",
"msg",
"=",
"self",
"::",
"ctcpUnquote",
"(",
"$",
"msg",
")",
";",
"// Extract the tag from the rest of the message.",
"$",
"pos",
"=",
"strcspn",
"(",
"$",
"msg",
",",
"\" \"",
")",
";",
"$",
"ctcp",
"=",
"substr",
"(",
"$",
"msg",
",",
"0",
",",
"$",
"pos",
")",
";",
"$",
"msg",
"=",
"(",
"string",
")",
"substr",
"(",
"$",
"msg",
",",
"$",
"pos",
"+",
"1",
")",
";",
"if",
"(",
"$",
"ctcp",
"==",
"\"ACTION\"",
")",
"{",
"if",
"(",
"$",
"isChan",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"mapping",
"[",
"'action'",
"]",
"[",
"$",
"isChan",
"]",
",",
"$",
"target",
",",
"$",
"origin",
",",
"$",
"msg",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"mapping",
"[",
"'action'",
"]",
"[",
"$",
"isChan",
"]",
",",
"$",
"origin",
",",
"$",
"msg",
")",
")",
";",
"}",
"if",
"(",
"$",
"isChan",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"mapping",
"[",
"'ctcp'",
"]",
"[",
"$",
"isChan",
"]",
",",
"$",
"target",
",",
"$",
"origin",
",",
"$",
"ctcp",
",",
"$",
"msg",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"mapping",
"[",
"'ctcp'",
"]",
"[",
"$",
"isChan",
"]",
",",
"$",
"origin",
",",
"$",
"ctcp",
",",
"$",
"msg",
")",
")",
";",
"}",
"if",
"(",
"$",
"isChan",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"mapping",
"[",
"'normal'",
"]",
"[",
"$",
"isChan",
"]",
",",
"$",
"target",
",",
"$",
"origin",
",",
"$",
"msg",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"mapping",
"[",
"'normal'",
"]",
"[",
"$",
"isChan",
"]",
",",
"$",
"origin",
",",
"$",
"msg",
")",
")",
";",
"}"
] | Process a NOTICE or PRIVMSG message.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately.
\param array $mapping
A mapping of types to a list of event names.
Each list should contain two items. The first
one if the name of the event to use when the
message is targeted at an IRC user. The second
one is used for messages targeted at IRC channels.
The following (case-sensitive) types must appear
in the mapping: 'ctcp' (for CTCP messages),
'action' (for the special ACTION CTCP message)
and 'normal' for regular messages. | [
"Process",
"a",
"NOTICE",
"or",
"PRIVMSG",
"message",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L347-L402 |
31,561 | Erebot/Erebot | src/IrcParser.php | IrcParser.handleINVITE | protected function handleINVITE($origin, $msg)
{
// :nick1!ident@host INVITE nick2 :#chan
return $this->connection->dispatch(
$this->makeEvent('!Invite', $msg[1], $origin, $msg[0])
);
} | php | protected function handleINVITE($origin, $msg)
{
// :nick1!ident@host INVITE nick2 :#chan
return $this->connection->dispatch(
$this->makeEvent('!Invite', $msg[1], $origin, $msg[0])
);
} | [
"protected",
"function",
"handleINVITE",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :nick1!ident@host INVITE nick2 :#chan",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Invite'",
",",
"$",
"msg",
"[",
"1",
"]",
",",
"$",
"origin",
",",
"$",
"msg",
"[",
"0",
"]",
")",
")",
";",
"}"
] | Processes a message of type INVITE.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"INVITE",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L415-L421 |
31,562 | Erebot/Erebot | src/IrcParser.php | IrcParser.handleJOIN | protected function handleJOIN($origin, $msg)
{
// :nick1!ident@host JOIN :#chan
return $this->connection->dispatch(
$this->makeEvent('!Join', $msg[0], $origin)
);
} | php | protected function handleJOIN($origin, $msg)
{
// :nick1!ident@host JOIN :#chan
return $this->connection->dispatch(
$this->makeEvent('!Join', $msg[0], $origin)
);
} | [
"protected",
"function",
"handleJOIN",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :nick1!ident@host JOIN :#chan",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Join'",
",",
"$",
"msg",
"[",
"0",
"]",
",",
"$",
"origin",
")",
")",
";",
"}"
] | Processes a message of type JOIN.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"JOIN",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L434-L440 |
31,563 | Erebot/Erebot | src/IrcParser.php | IrcParser.handleKICK | protected function handleKICK($origin, $msg)
{
// :nick1!ident@host KICK #chan nick2 :Reason
return $this->connection->dispatch(
$this->makeEvent('!Kick', $msg[0], $origin, $msg[1], $msg[2])
);
} | php | protected function handleKICK($origin, $msg)
{
// :nick1!ident@host KICK #chan nick2 :Reason
return $this->connection->dispatch(
$this->makeEvent('!Kick', $msg[0], $origin, $msg[1], $msg[2])
);
} | [
"protected",
"function",
"handleKICK",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :nick1!ident@host KICK #chan nick2 :Reason",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Kick'",
",",
"$",
"msg",
"[",
"0",
"]",
",",
"$",
"origin",
",",
"$",
"msg",
"[",
"1",
"]",
",",
"$",
"msg",
"[",
"2",
"]",
")",
")",
";",
"}"
] | Processes a message of type KICK.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"KICK",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L453-L459 |
31,564 | Erebot/Erebot | src/IrcParser.php | IrcParser.handleNICK | protected function handleNICK($origin, $msg)
{
// :oldnick!ident@host NICK newnick
return $this->connection->dispatch(
$this->makeEvent('!Nick', $origin, $msg[0])
);
} | php | protected function handleNICK($origin, $msg)
{
// :oldnick!ident@host NICK newnick
return $this->connection->dispatch(
$this->makeEvent('!Nick', $origin, $msg[0])
);
} | [
"protected",
"function",
"handleNICK",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :oldnick!ident@host NICK newnick",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Nick'",
",",
"$",
"origin",
",",
"$",
"msg",
"[",
"0",
"]",
")",
")",
";",
"}"
] | Processes a message of type NICK.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"NICK",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L558-L564 |
31,565 | Erebot/Erebot | src/IrcParser.php | IrcParser.handlePART | protected function handlePART($origin, $msg)
{
// :nick1!ident@host PART #chan [reason]
return $this->connection->dispatch(
$this->makeEvent(
'!Part',
$msg[0],
$origin,
isset($msg[1]) ? $msg[1] : ''
)
);
} | php | protected function handlePART($origin, $msg)
{
// :nick1!ident@host PART #chan [reason]
return $this->connection->dispatch(
$this->makeEvent(
'!Part',
$msg[0],
$origin,
isset($msg[1]) ? $msg[1] : ''
)
);
} | [
"protected",
"function",
"handlePART",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :nick1!ident@host PART #chan [reason]",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Part'",
",",
"$",
"msg",
"[",
"0",
"]",
",",
"$",
"origin",
",",
"isset",
"(",
"$",
"msg",
"[",
"1",
"]",
")",
"?",
"$",
"msg",
"[",
"1",
"]",
":",
"''",
")",
")",
";",
"}"
] | Processes a message of type PART.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"PART",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L600-L611 |
31,566 | Erebot/Erebot | src/IrcParser.php | IrcParser.handlePONG | protected function handlePONG($origin, $msg)
{
// :origin PONG origin target
return $this->connection->dispatch(
$this->makeEvent('!Pong', $origin, $msg[1])
);
} | php | protected function handlePONG($origin, $msg)
{
// :origin PONG origin target
return $this->connection->dispatch(
$this->makeEvent('!Pong', $origin, $msg[1])
);
} | [
"protected",
"function",
"handlePONG",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :origin PONG origin target",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Pong'",
",",
"$",
"origin",
",",
"$",
"msg",
"[",
"1",
"]",
")",
")",
";",
"}"
] | Processes a message of type PONG.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"PONG",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L643-L649 |
31,567 | Erebot/Erebot | src/IrcParser.php | IrcParser.handleQUIT | protected function handleQUIT($origin, $msg)
{
// :nick1!ident@host QUIT :Reason
return $this->connection->dispatch(
$this->makeEvent('!Quit', $origin, $msg[0])
);
} | php | protected function handleQUIT($origin, $msg)
{
// :nick1!ident@host QUIT :Reason
return $this->connection->dispatch(
$this->makeEvent('!Quit', $origin, $msg[0])
);
} | [
"protected",
"function",
"handleQUIT",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :nick1!ident@host QUIT :Reason",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Quit'",
",",
"$",
"origin",
",",
"$",
"msg",
"[",
"0",
"]",
")",
")",
";",
"}"
] | Processes a message of type QUIT.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"QUIT",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L685-L691 |
31,568 | Erebot/Erebot | src/IrcParser.php | IrcParser.handleTOPIC | protected function handleTOPIC($origin, $msg)
{
// :nick1!ident@host TOPIC #chan :New topic
return $this->connection->dispatch(
$this->makeEvent('!Topic', $msg[0], $origin, $msg[1])
);
} | php | protected function handleTOPIC($origin, $msg)
{
// :nick1!ident@host TOPIC #chan :New topic
return $this->connection->dispatch(
$this->makeEvent('!Topic', $msg[0], $origin, $msg[1])
);
} | [
"protected",
"function",
"handleTOPIC",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// :nick1!ident@host TOPIC #chan :New topic",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Topic'",
",",
"$",
"msg",
"[",
"0",
"]",
",",
"$",
"origin",
",",
"$",
"msg",
"[",
"1",
"]",
")",
")",
";",
"}"
] | Processes a message of type TOPIC.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"of",
"type",
"TOPIC",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L704-L710 |
31,569 | Erebot/Erebot | src/IrcParser.php | IrcParser.handle255 | protected function handle255($origin, $msg)
{
// \Erebot\Interfaces\Numerics::RPL_LUSERME
/* We can't rely on RPL_WELCOME because we may need
* to detect the server's capabilities first.
* So, we delay detection of the connection for as
* long as we can (while retaining portability). */
if (!$this->connection->isConnected()) {
return $this->connection->dispatch($this->makeEvent('!Connect'));
}
} | php | protected function handle255($origin, $msg)
{
// \Erebot\Interfaces\Numerics::RPL_LUSERME
/* We can't rely on RPL_WELCOME because we may need
* to detect the server's capabilities first.
* So, we delay detection of the connection for as
* long as we can (while retaining portability). */
if (!$this->connection->isConnected()) {
return $this->connection->dispatch($this->makeEvent('!Connect'));
}
} | [
"protected",
"function",
"handle255",
"(",
"$",
"origin",
",",
"$",
"msg",
")",
"{",
"// \\Erebot\\Interfaces\\Numerics::RPL_LUSERME",
"/* We can't rely on RPL_WELCOME because we may need\n * to detect the server's capabilities first.\n * So, we delay detection of the connection for as\n * long as we can (while retaining portability). */",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
"->",
"isConnected",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"'!Connect'",
")",
")",
";",
"}",
"}"
] | Processes a message with numeric 255.
\param string $origin
Origin of the message to process.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately.
\TODO
Use a NumericEventHandler instead, even though it is less effective. | [
"Processes",
"a",
"message",
"with",
"numeric",
"255",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L726-L736 |
31,570 | Erebot/Erebot | src/IrcParser.php | IrcParser.watchList | protected function watchList($event, $msg)
{
// <bot> <nick> <ident> <host> <timestamp> :<msg>
unset($msg[0]);
$nick = $msg[0];
$ident = $msg[1];
$host = $msg[2];
$timestamp = intval($msg[3], 10);
$timestamp = new \DateTime('@'.$timestamp);
$text = $msg[4];
return $this->connection->dispatch(
$this->makeEvent(
$event,
$nick,
($ident == '*' ? null : $ident),
($host == '*' ? null : $host),
$timestamp,
$text
)
);
} | php | protected function watchList($event, $msg)
{
// <bot> <nick> <ident> <host> <timestamp> :<msg>
unset($msg[0]);
$nick = $msg[0];
$ident = $msg[1];
$host = $msg[2];
$timestamp = intval($msg[3], 10);
$timestamp = new \DateTime('@'.$timestamp);
$text = $msg[4];
return $this->connection->dispatch(
$this->makeEvent(
$event,
$nick,
($ident == '*' ? null : $ident),
($host == '*' ? null : $host),
$timestamp,
$text
)
);
} | [
"protected",
"function",
"watchList",
"(",
"$",
"event",
",",
"$",
"msg",
")",
"{",
"// <bot> <nick> <ident> <host> <timestamp> :<msg>",
"unset",
"(",
"$",
"msg",
"[",
"0",
"]",
")",
";",
"$",
"nick",
"=",
"$",
"msg",
"[",
"0",
"]",
";",
"$",
"ident",
"=",
"$",
"msg",
"[",
"1",
"]",
";",
"$",
"host",
"=",
"$",
"msg",
"[",
"2",
"]",
";",
"$",
"timestamp",
"=",
"intval",
"(",
"$",
"msg",
"[",
"3",
"]",
",",
"10",
")",
";",
"$",
"timestamp",
"=",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"timestamp",
")",
";",
"$",
"text",
"=",
"$",
"msg",
"[",
"4",
"]",
";",
"return",
"$",
"this",
"->",
"connection",
"->",
"dispatch",
"(",
"$",
"this",
"->",
"makeEvent",
"(",
"$",
"event",
",",
"$",
"nick",
",",
"(",
"$",
"ident",
"==",
"'*'",
"?",
"null",
":",
"$",
"ident",
")",
",",
"(",
"$",
"host",
"==",
"'*'",
"?",
"null",
":",
"$",
"host",
")",
",",
"$",
"timestamp",
",",
"$",
"text",
")",
")",
";",
"}"
] | Processes a message related to the WATCH list.
\param string $event
Interface name for the event to produce.
\param Erebot::Interfaces::IrcTextWrapper $msg
The message to process, wrapped in
a special object that makes it easier
to analyze each token separately. | [
"Processes",
"a",
"message",
"related",
"to",
"the",
"WATCH",
"list",
"."
] | 691fc3fa8bc6f07061ff2b3798fec76bc3a039aa | https://github.com/Erebot/Erebot/blob/691fc3fa8bc6f07061ff2b3798fec76bc3a039aa/src/IrcParser.php#L829-L850 |
31,571 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.CommitProcessData | protected function CommitProcessData()
{
TdbShopSearchFieldWeight::AddQueryBlock(false, null, null);
$sTmp = serialize($this->aTablesToProcess);
$aData = $this->sqlData;
$aData['processdata'] = $sTmp;
$this->LoadFromRow($aData);
$this->AllowEditByAll(true);
$this->Save();
} | php | protected function CommitProcessData()
{
TdbShopSearchFieldWeight::AddQueryBlock(false, null, null);
$sTmp = serialize($this->aTablesToProcess);
$aData = $this->sqlData;
$aData['processdata'] = $sTmp;
$this->LoadFromRow($aData);
$this->AllowEditByAll(true);
$this->Save();
} | [
"protected",
"function",
"CommitProcessData",
"(",
")",
"{",
"TdbShopSearchFieldWeight",
"::",
"AddQueryBlock",
"(",
"false",
",",
"null",
",",
"null",
")",
";",
"$",
"sTmp",
"=",
"serialize",
"(",
"$",
"this",
"->",
"aTablesToProcess",
")",
";",
"$",
"aData",
"=",
"$",
"this",
"->",
"sqlData",
";",
"$",
"aData",
"[",
"'processdata'",
"]",
"=",
"$",
"sTmp",
";",
"$",
"this",
"->",
"LoadFromRow",
"(",
"$",
"aData",
")",
";",
"$",
"this",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"this",
"->",
"Save",
"(",
")",
";",
"}"
] | commit processing data to database. | [
"commit",
"processing",
"data",
"to",
"database",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L63-L72 |
31,572 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.GetRemainingRowCount | protected function GetRemainingRowCount()
{
$aTableList = $this->aTablesToProcess;
$iCount = 0;
foreach ($aTableList as $iWorkId) {
$oIndexQuery = TdbShopSearchQuery::GetNewInstance();
/** @var $oIndexQuery TdbShopSearchQuery */
if ($oIndexQuery->Load($iWorkId)) {
$iCount = $iCount + $oIndexQuery->NumberOfRecordsLeftToIndex();
}
}
return $iCount;
} | php | protected function GetRemainingRowCount()
{
$aTableList = $this->aTablesToProcess;
$iCount = 0;
foreach ($aTableList as $iWorkId) {
$oIndexQuery = TdbShopSearchQuery::GetNewInstance();
/** @var $oIndexQuery TdbShopSearchQuery */
if ($oIndexQuery->Load($iWorkId)) {
$iCount = $iCount + $oIndexQuery->NumberOfRecordsLeftToIndex();
}
}
return $iCount;
} | [
"protected",
"function",
"GetRemainingRowCount",
"(",
")",
"{",
"$",
"aTableList",
"=",
"$",
"this",
"->",
"aTablesToProcess",
";",
"$",
"iCount",
"=",
"0",
";",
"foreach",
"(",
"$",
"aTableList",
"as",
"$",
"iWorkId",
")",
"{",
"$",
"oIndexQuery",
"=",
"TdbShopSearchQuery",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oIndexQuery TdbShopSearchQuery */",
"if",
"(",
"$",
"oIndexQuery",
"->",
"Load",
"(",
"$",
"iWorkId",
")",
")",
"{",
"$",
"iCount",
"=",
"$",
"iCount",
"+",
"$",
"oIndexQuery",
"->",
"NumberOfRecordsLeftToIndex",
"(",
")",
";",
"}",
"}",
"return",
"$",
"iCount",
";",
"}"
] | return the number of rows still to process.
@return unknown | [
"return",
"the",
"number",
"of",
"rows",
"still",
"to",
"process",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L100-L113 |
31,573 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.ProcessNextIndexStep | public function ProcessNextIndexStep($bIndexUsingTicker = true)
{
TCacheManager::SetDisableCaching(true);
// if no index is running, prepare the indexer
$iTickerSize = self::INDEX_SET_SIZE;
if (!$bIndexUsingTicker) {
$iTickerSize = -1;
}
if (!$this->IsRunning()) {
$this->InitializeIndexer();
}
if ($this->IndexerHasFinished()) {
// indexing is done...
$this->IndexCompletedHook();
} elseif ($this->IsRunning()) {
// now process the next tick...
$iRecordsProcessed = 0;
do {
$iWorkId = $this->aTablesToProcess[0];
$oIndexQuery = TdbShopSearchQuery::GetNewInstance();
/** @var $oIndexQuery TdbShopSearchQuery */
if ($oIndexQuery->Load($iWorkId)) {
$iRecordsProcessedByIndexer = $oIndexQuery->CreateIndexTick($iTickerSize);
$iRecordsProcessed += $iRecordsProcessedByIndexer;
if (($iRecordsProcessedByIndexer < $iTickerSize) || ($iTickerSize < 0)) {
// if we processed less than we requested, we must be done with this query
// so we drop it from the list of queries we need to process
array_shift($this->aTablesToProcess);
}
} else {
// unalbe to load query object... so drop it from the list
array_shift($this->aTablesToProcess);
}
} while (!$this->IndexerHasFinished() && (($iRecordsProcessed < self::INDEX_SET_SIZE) || ($iTickerSize < 0)));
}
$this->CommitProcessData();
TCacheManager::SetDisableCaching(false);
} | php | public function ProcessNextIndexStep($bIndexUsingTicker = true)
{
TCacheManager::SetDisableCaching(true);
// if no index is running, prepare the indexer
$iTickerSize = self::INDEX_SET_SIZE;
if (!$bIndexUsingTicker) {
$iTickerSize = -1;
}
if (!$this->IsRunning()) {
$this->InitializeIndexer();
}
if ($this->IndexerHasFinished()) {
// indexing is done...
$this->IndexCompletedHook();
} elseif ($this->IsRunning()) {
// now process the next tick...
$iRecordsProcessed = 0;
do {
$iWorkId = $this->aTablesToProcess[0];
$oIndexQuery = TdbShopSearchQuery::GetNewInstance();
/** @var $oIndexQuery TdbShopSearchQuery */
if ($oIndexQuery->Load($iWorkId)) {
$iRecordsProcessedByIndexer = $oIndexQuery->CreateIndexTick($iTickerSize);
$iRecordsProcessed += $iRecordsProcessedByIndexer;
if (($iRecordsProcessedByIndexer < $iTickerSize) || ($iTickerSize < 0)) {
// if we processed less than we requested, we must be done with this query
// so we drop it from the list of queries we need to process
array_shift($this->aTablesToProcess);
}
} else {
// unalbe to load query object... so drop it from the list
array_shift($this->aTablesToProcess);
}
} while (!$this->IndexerHasFinished() && (($iRecordsProcessed < self::INDEX_SET_SIZE) || ($iTickerSize < 0)));
}
$this->CommitProcessData();
TCacheManager::SetDisableCaching(false);
} | [
"public",
"function",
"ProcessNextIndexStep",
"(",
"$",
"bIndexUsingTicker",
"=",
"true",
")",
"{",
"TCacheManager",
"::",
"SetDisableCaching",
"(",
"true",
")",
";",
"// if no index is running, prepare the indexer",
"$",
"iTickerSize",
"=",
"self",
"::",
"INDEX_SET_SIZE",
";",
"if",
"(",
"!",
"$",
"bIndexUsingTicker",
")",
"{",
"$",
"iTickerSize",
"=",
"-",
"1",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"IsRunning",
"(",
")",
")",
"{",
"$",
"this",
"->",
"InitializeIndexer",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"IndexerHasFinished",
"(",
")",
")",
"{",
"// indexing is done...",
"$",
"this",
"->",
"IndexCompletedHook",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"IsRunning",
"(",
")",
")",
"{",
"// now process the next tick...",
"$",
"iRecordsProcessed",
"=",
"0",
";",
"do",
"{",
"$",
"iWorkId",
"=",
"$",
"this",
"->",
"aTablesToProcess",
"[",
"0",
"]",
";",
"$",
"oIndexQuery",
"=",
"TdbShopSearchQuery",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oIndexQuery TdbShopSearchQuery */",
"if",
"(",
"$",
"oIndexQuery",
"->",
"Load",
"(",
"$",
"iWorkId",
")",
")",
"{",
"$",
"iRecordsProcessedByIndexer",
"=",
"$",
"oIndexQuery",
"->",
"CreateIndexTick",
"(",
"$",
"iTickerSize",
")",
";",
"$",
"iRecordsProcessed",
"+=",
"$",
"iRecordsProcessedByIndexer",
";",
"if",
"(",
"(",
"$",
"iRecordsProcessedByIndexer",
"<",
"$",
"iTickerSize",
")",
"||",
"(",
"$",
"iTickerSize",
"<",
"0",
")",
")",
"{",
"// if we processed less than we requested, we must be done with this query",
"// so we drop it from the list of queries we need to process",
"array_shift",
"(",
"$",
"this",
"->",
"aTablesToProcess",
")",
";",
"}",
"}",
"else",
"{",
"// unalbe to load query object... so drop it from the list",
"array_shift",
"(",
"$",
"this",
"->",
"aTablesToProcess",
")",
";",
"}",
"}",
"while",
"(",
"!",
"$",
"this",
"->",
"IndexerHasFinished",
"(",
")",
"&&",
"(",
"(",
"$",
"iRecordsProcessed",
"<",
"self",
"::",
"INDEX_SET_SIZE",
")",
"||",
"(",
"$",
"iTickerSize",
"<",
"0",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"CommitProcessData",
"(",
")",
";",
"TCacheManager",
"::",
"SetDisableCaching",
"(",
"false",
")",
";",
"}"
] | performs the next index set.
@param bool $bIndexUsingTicker - if set to true, each call to this method will only index as many rows as defined by INDEX_SET_SIZE | [
"performs",
"the",
"next",
"index",
"set",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L140-L178 |
31,574 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.InitializeIndexer | public function InitializeIndexer()
{
$bWorkToDo = true;
if (!$this->bRegenerateCompleteIndex) {
// drop index
$query = "UPDATE shop_search_reindex_queue SET `processing` = '1'";
MySqlLegacySupport::getInstance()->query($query);
$query = "SELECT COUNT(*) AS reccount FROM shop_search_reindex_queue WHERE `processing` = '1'";
$aCount = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query));
if ($aCount['reccount'] > 0) {
$query = "SHOW TABLES LIKE '_index_%'";
$tRes = MySqlLegacySupport::getInstance()->query($query);
while ($aIndexTable = MySqlLegacySupport::getInstance()->fetch_row($tRes)) {
$query = "DELETE FROM {$aIndexTable[0]} USING {$aIndexTable[0]}, shop_search_reindex_queue WHERE {$aIndexTable[0]}.`shop_article_id`= shop_search_reindex_queue.object_id AND `shop_search_reindex_queue`.`processing`='1' ";
MySqlLegacySupport::getInstance()->query($query);
}
$sQuery = "DELETE FROM shop_search_reindex_queue WHERE `processing` = '1' AND `action` = 'delete'";
MySqlLegacySupport::getInstance()->query($sQuery);
$query = "SELECT COUNT(*) AS reccount FROM shop_search_reindex_queue WHERE `processing` = '1'";
$aCount = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query));
if (0 == $aCount['reccount']) {
$bWorkToDo = false;
}
} else {
$bWorkToDo = false;
}
}
if ($bWorkToDo) {
$this->aTablesToProcess = array();
$aData = $this->sqlData;
$aData['started'] = date('Y-m-d H:i:s');
$aData['completed'] = date('0000-00-00 00:00:00');
$iTotalRows = 0;
$query = 'SELECT shop_search_query.*
FROM shop_search_query
INNER JOIN shop_search_field_weight ON shop_search_query.id = shop_search_field_weight.shop_search_query_id
GROUP BY shop_search_query.id
';
$oIndexQueries = &TdbShopSearchQueryList::GetList($query);
while ($oIndexQuery = &$oIndexQueries->Next()) {
$oIndexQuery->StartIndex($this->bRegenerateCompleteIndex);
$iNumberOfItems = $oIndexQuery->NumberOfRecordsLeftToIndex();
if ($iNumberOfItems > 0) {
$iTotalRows += $iNumberOfItems;
$this->aTablesToProcess[] = $oIndexQuery->id;
}
}
$aData['total_rows_to_process'] = $iTotalRows;
$sTmp = serialize($this->aTablesToProcess);
$aData['processdata'] = $sTmp;
$this->LoadFromRow($aData);
$this->AllowEditByAll(true);
$this->Save();
$this->CommitProcessData();
$this->CreateIndexTables();
}
} | php | public function InitializeIndexer()
{
$bWorkToDo = true;
if (!$this->bRegenerateCompleteIndex) {
// drop index
$query = "UPDATE shop_search_reindex_queue SET `processing` = '1'";
MySqlLegacySupport::getInstance()->query($query);
$query = "SELECT COUNT(*) AS reccount FROM shop_search_reindex_queue WHERE `processing` = '1'";
$aCount = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query));
if ($aCount['reccount'] > 0) {
$query = "SHOW TABLES LIKE '_index_%'";
$tRes = MySqlLegacySupport::getInstance()->query($query);
while ($aIndexTable = MySqlLegacySupport::getInstance()->fetch_row($tRes)) {
$query = "DELETE FROM {$aIndexTable[0]} USING {$aIndexTable[0]}, shop_search_reindex_queue WHERE {$aIndexTable[0]}.`shop_article_id`= shop_search_reindex_queue.object_id AND `shop_search_reindex_queue`.`processing`='1' ";
MySqlLegacySupport::getInstance()->query($query);
}
$sQuery = "DELETE FROM shop_search_reindex_queue WHERE `processing` = '1' AND `action` = 'delete'";
MySqlLegacySupport::getInstance()->query($sQuery);
$query = "SELECT COUNT(*) AS reccount FROM shop_search_reindex_queue WHERE `processing` = '1'";
$aCount = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query));
if (0 == $aCount['reccount']) {
$bWorkToDo = false;
}
} else {
$bWorkToDo = false;
}
}
if ($bWorkToDo) {
$this->aTablesToProcess = array();
$aData = $this->sqlData;
$aData['started'] = date('Y-m-d H:i:s');
$aData['completed'] = date('0000-00-00 00:00:00');
$iTotalRows = 0;
$query = 'SELECT shop_search_query.*
FROM shop_search_query
INNER JOIN shop_search_field_weight ON shop_search_query.id = shop_search_field_weight.shop_search_query_id
GROUP BY shop_search_query.id
';
$oIndexQueries = &TdbShopSearchQueryList::GetList($query);
while ($oIndexQuery = &$oIndexQueries->Next()) {
$oIndexQuery->StartIndex($this->bRegenerateCompleteIndex);
$iNumberOfItems = $oIndexQuery->NumberOfRecordsLeftToIndex();
if ($iNumberOfItems > 0) {
$iTotalRows += $iNumberOfItems;
$this->aTablesToProcess[] = $oIndexQuery->id;
}
}
$aData['total_rows_to_process'] = $iTotalRows;
$sTmp = serialize($this->aTablesToProcess);
$aData['processdata'] = $sTmp;
$this->LoadFromRow($aData);
$this->AllowEditByAll(true);
$this->Save();
$this->CommitProcessData();
$this->CreateIndexTables();
}
} | [
"public",
"function",
"InitializeIndexer",
"(",
")",
"{",
"$",
"bWorkToDo",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"bRegenerateCompleteIndex",
")",
"{",
"// drop index",
"$",
"query",
"=",
"\"UPDATE shop_search_reindex_queue SET `processing` = '1'\"",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"$",
"query",
"=",
"\"SELECT COUNT(*) AS reccount FROM shop_search_reindex_queue WHERE `processing` = '1'\"",
";",
"$",
"aCount",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_assoc",
"(",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
")",
";",
"if",
"(",
"$",
"aCount",
"[",
"'reccount'",
"]",
">",
"0",
")",
"{",
"$",
"query",
"=",
"\"SHOW TABLES LIKE '_index_%'\"",
";",
"$",
"tRes",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"while",
"(",
"$",
"aIndexTable",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_row",
"(",
"$",
"tRes",
")",
")",
"{",
"$",
"query",
"=",
"\"DELETE FROM {$aIndexTable[0]} USING {$aIndexTable[0]}, shop_search_reindex_queue WHERE {$aIndexTable[0]}.`shop_article_id`= shop_search_reindex_queue.object_id AND `shop_search_reindex_queue`.`processing`='1' \"",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}",
"$",
"sQuery",
"=",
"\"DELETE FROM shop_search_reindex_queue WHERE `processing` = '1' AND `action` = 'delete'\"",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"sQuery",
")",
";",
"$",
"query",
"=",
"\"SELECT COUNT(*) AS reccount FROM shop_search_reindex_queue WHERE `processing` = '1'\"",
";",
"$",
"aCount",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_assoc",
"(",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
")",
";",
"if",
"(",
"0",
"==",
"$",
"aCount",
"[",
"'reccount'",
"]",
")",
"{",
"$",
"bWorkToDo",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"$",
"bWorkToDo",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"bWorkToDo",
")",
"{",
"$",
"this",
"->",
"aTablesToProcess",
"=",
"array",
"(",
")",
";",
"$",
"aData",
"=",
"$",
"this",
"->",
"sqlData",
";",
"$",
"aData",
"[",
"'started'",
"]",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"aData",
"[",
"'completed'",
"]",
"=",
"date",
"(",
"'0000-00-00 00:00:00'",
")",
";",
"$",
"iTotalRows",
"=",
"0",
";",
"$",
"query",
"=",
"'SELECT shop_search_query.*\n FROM shop_search_query\n INNER JOIN shop_search_field_weight ON shop_search_query.id = shop_search_field_weight.shop_search_query_id\n GROUP BY shop_search_query.id\n '",
";",
"$",
"oIndexQueries",
"=",
"&",
"TdbShopSearchQueryList",
"::",
"GetList",
"(",
"$",
"query",
")",
";",
"while",
"(",
"$",
"oIndexQuery",
"=",
"&",
"$",
"oIndexQueries",
"->",
"Next",
"(",
")",
")",
"{",
"$",
"oIndexQuery",
"->",
"StartIndex",
"(",
"$",
"this",
"->",
"bRegenerateCompleteIndex",
")",
";",
"$",
"iNumberOfItems",
"=",
"$",
"oIndexQuery",
"->",
"NumberOfRecordsLeftToIndex",
"(",
")",
";",
"if",
"(",
"$",
"iNumberOfItems",
">",
"0",
")",
"{",
"$",
"iTotalRows",
"+=",
"$",
"iNumberOfItems",
";",
"$",
"this",
"->",
"aTablesToProcess",
"[",
"]",
"=",
"$",
"oIndexQuery",
"->",
"id",
";",
"}",
"}",
"$",
"aData",
"[",
"'total_rows_to_process'",
"]",
"=",
"$",
"iTotalRows",
";",
"$",
"sTmp",
"=",
"serialize",
"(",
"$",
"this",
"->",
"aTablesToProcess",
")",
";",
"$",
"aData",
"[",
"'processdata'",
"]",
"=",
"$",
"sTmp",
";",
"$",
"this",
"->",
"LoadFromRow",
"(",
"$",
"aData",
")",
";",
"$",
"this",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"this",
"->",
"Save",
"(",
")",
";",
"$",
"this",
"->",
"CommitProcessData",
"(",
")",
";",
"$",
"this",
"->",
"CreateIndexTables",
"(",
")",
";",
"}",
"}"
] | initialize indexer. | [
"initialize",
"indexer",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L205-L265 |
31,575 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.& | protected static function &GetShopConfigForIndexer()
{
static $oShop;
if (!isset($oShop)) {
// get first shop we find
$oShops = &TdbShopList::GetList();
$oShop = $oShops->Current();
}
return $oShop;
} | php | protected static function &GetShopConfigForIndexer()
{
static $oShop;
if (!isset($oShop)) {
// get first shop we find
$oShops = &TdbShopList::GetList();
$oShop = $oShops->Current();
}
return $oShop;
} | [
"protected",
"static",
"function",
"&",
"GetShopConfigForIndexer",
"(",
")",
"{",
"static",
"$",
"oShop",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"oShop",
")",
")",
"{",
"// get first shop we find",
"$",
"oShops",
"=",
"&",
"TdbShopList",
"::",
"GetList",
"(",
")",
";",
"$",
"oShop",
"=",
"$",
"oShops",
"->",
"Current",
"(",
")",
";",
"}",
"return",
"$",
"oShop",
";",
"}"
] | get the shop we use for config data for the indexer... for now we just take
the first we find. later we need some way to connect the two.
@return TdbShop | [
"get",
"the",
"shop",
"we",
"use",
"for",
"config",
"data",
"for",
"the",
"indexer",
"...",
"for",
"now",
"we",
"just",
"take",
"the",
"first",
"we",
"find",
".",
"later",
"we",
"need",
"some",
"way",
"to",
"connect",
"the",
"two",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L273-L283 |
31,576 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.CreateIndexTables | public function CreateIndexTables()
{
$aIndexTableNames = TdbShopSearchIndexer::GetAllIndexTableNames();
$aTmpIndex = array();
foreach ($aIndexTableNames as $sTableName => $length) {
$aTmpIndex['_tmp'.$sTableName] = $length;
}
$aIndexTableNames = $aTmpIndex;
foreach ($aIndexTableNames as $sTableName => $iLength) {
if (TCMSRecord::TableExists($sTableName)) {
$query = "DROP TABLE `{$sTableName}`";
MySqlLegacySupport::getInstance()->query($query);
}
$sPrimaryKey = '';
$query = 'CREATE TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($sTableName)."` (
`shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',
`substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',
`cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',
`occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',
`weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',
`shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'
{$sPrimaryKey}
)";
MySqlLegacySupport::getInstance()->query($query);
}
// drop index fields not needed
$sBaseName = '_tmp'.self::INDEX_TBL_PREFIX;
$query = "SHOW TABLES LIKE '".MySqlLegacySupport::getInstance()->real_escape_string($sBaseName)."%'";
$rTableRes = MySqlLegacySupport::getInstance()->query($query);
while ($aTableData = MySqlLegacySupport::getInstance()->fetch_row($rTableRes)) {
if (!array_key_exists($aTableData[0], $aIndexTableNames)) {
$query = 'DROP TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($aTableData[0]).'`';
MySqlLegacySupport::getInstance()->query($query);
}
}
} | php | public function CreateIndexTables()
{
$aIndexTableNames = TdbShopSearchIndexer::GetAllIndexTableNames();
$aTmpIndex = array();
foreach ($aIndexTableNames as $sTableName => $length) {
$aTmpIndex['_tmp'.$sTableName] = $length;
}
$aIndexTableNames = $aTmpIndex;
foreach ($aIndexTableNames as $sTableName => $iLength) {
if (TCMSRecord::TableExists($sTableName)) {
$query = "DROP TABLE `{$sTableName}`";
MySqlLegacySupport::getInstance()->query($query);
}
$sPrimaryKey = '';
$query = 'CREATE TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($sTableName)."` (
`shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',
`substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',
`cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',
`occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',
`weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',
`shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'
{$sPrimaryKey}
)";
MySqlLegacySupport::getInstance()->query($query);
}
// drop index fields not needed
$sBaseName = '_tmp'.self::INDEX_TBL_PREFIX;
$query = "SHOW TABLES LIKE '".MySqlLegacySupport::getInstance()->real_escape_string($sBaseName)."%'";
$rTableRes = MySqlLegacySupport::getInstance()->query($query);
while ($aTableData = MySqlLegacySupport::getInstance()->fetch_row($rTableRes)) {
if (!array_key_exists($aTableData[0], $aIndexTableNames)) {
$query = 'DROP TABLE `'.MySqlLegacySupport::getInstance()->real_escape_string($aTableData[0]).'`';
MySqlLegacySupport::getInstance()->query($query);
}
}
} | [
"public",
"function",
"CreateIndexTables",
"(",
")",
"{",
"$",
"aIndexTableNames",
"=",
"TdbShopSearchIndexer",
"::",
"GetAllIndexTableNames",
"(",
")",
";",
"$",
"aTmpIndex",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"aIndexTableNames",
"as",
"$",
"sTableName",
"=>",
"$",
"length",
")",
"{",
"$",
"aTmpIndex",
"[",
"'_tmp'",
".",
"$",
"sTableName",
"]",
"=",
"$",
"length",
";",
"}",
"$",
"aIndexTableNames",
"=",
"$",
"aTmpIndex",
";",
"foreach",
"(",
"$",
"aIndexTableNames",
"as",
"$",
"sTableName",
"=>",
"$",
"iLength",
")",
"{",
"if",
"(",
"TCMSRecord",
"::",
"TableExists",
"(",
"$",
"sTableName",
")",
")",
"{",
"$",
"query",
"=",
"\"DROP TABLE `{$sTableName}`\"",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}",
"$",
"sPrimaryKey",
"=",
"''",
";",
"$",
"query",
"=",
"'CREATE TABLE `'",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sTableName",
")",
".",
"\"` (\n `shop_article_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'the shop article',\n `substring` CHAR( {$iLength} ) NOT NULL COMMENT 'the substring',\n `cms_language_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'language of substring',\n `occurrences` INT NOT NULL COMMENT 'Number of times the substring occured in the field for that article',\n `weight` FLOAT NOT NULL COMMENT 'calculated weight for the substring',\n `shop_search_field_weight_id` CHAR(36) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL COMMENT 'field for which the search term was made'\n {$sPrimaryKey}\n )\"",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}",
"// drop index fields not needed",
"$",
"sBaseName",
"=",
"'_tmp'",
".",
"self",
"::",
"INDEX_TBL_PREFIX",
";",
"$",
"query",
"=",
"\"SHOW TABLES LIKE '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sBaseName",
")",
".",
"\"%'\"",
";",
"$",
"rTableRes",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"while",
"(",
"$",
"aTableData",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_row",
"(",
"$",
"rTableRes",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"aTableData",
"[",
"0",
"]",
",",
"$",
"aIndexTableNames",
")",
")",
"{",
"$",
"query",
"=",
"'DROP TABLE `'",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"aTableData",
"[",
"0",
"]",
")",
".",
"'`'",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}",
"}",
"}"
] | create all index tables for the field and drop tables no longer needed. | [
"create",
"all",
"index",
"tables",
"for",
"the",
"field",
"and",
"drop",
"tables",
"no",
"longer",
"needed",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L303-L339 |
31,577 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.GetAllIndexTableNames | public static function GetAllIndexTableNames()
{
static $aNames;
if (!isset($aNames)) {
$aNames = array();
$oShop = &TdbShopSearchIndexer::GetShopConfigForIndexer();
for ($i = $oShop->fieldShopSearchMinIndexLength; $i <= $oShop->fieldShopSearchMaxIndexLength; ++$i) {
$aNames[TdbShopSearchIndexer::GetIndexTableNameForIndexLength($i)] = $i;
}
}
return $aNames;
} | php | public static function GetAllIndexTableNames()
{
static $aNames;
if (!isset($aNames)) {
$aNames = array();
$oShop = &TdbShopSearchIndexer::GetShopConfigForIndexer();
for ($i = $oShop->fieldShopSearchMinIndexLength; $i <= $oShop->fieldShopSearchMaxIndexLength; ++$i) {
$aNames[TdbShopSearchIndexer::GetIndexTableNameForIndexLength($i)] = $i;
}
}
return $aNames;
} | [
"public",
"static",
"function",
"GetAllIndexTableNames",
"(",
")",
"{",
"static",
"$",
"aNames",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"aNames",
")",
")",
"{",
"$",
"aNames",
"=",
"array",
"(",
")",
";",
"$",
"oShop",
"=",
"&",
"TdbShopSearchIndexer",
"::",
"GetShopConfigForIndexer",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"oShop",
"->",
"fieldShopSearchMinIndexLength",
";",
"$",
"i",
"<=",
"$",
"oShop",
"->",
"fieldShopSearchMaxIndexLength",
";",
"++",
"$",
"i",
")",
"{",
"$",
"aNames",
"[",
"TdbShopSearchIndexer",
"::",
"GetIndexTableNameForIndexLength",
"(",
"$",
"i",
")",
"]",
"=",
"$",
"i",
";",
"}",
"}",
"return",
"$",
"aNames",
";",
"}"
] | get all index tables for the field.
@return array | [
"get",
"all",
"index",
"tables",
"for",
"the",
"field",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L451-L463 |
31,578 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.GetWordListQuery | protected static function GetWordListQuery($aTerms, $sLanguageId, $aFieldRestrictions = null, $sTypeOfFieldRestriction = 'OR')
{
$aTableQueries = array();
// get affected tables
$aTableList = array();
foreach ($aTerms as $sTerm) {
$sTableName = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sTerm));
if (!in_array($sTableName, $aTableList)) {
$aTableList[] = $sTableName;
}
if (false == TdbShopSearchIndexer::searchWithAND()) {
$sSoundEX = TdbShopSearchIndexer::GetSoundexForWord($sTerm);
$sSoundTable = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sSoundEX));
if (!in_array($sSoundTable, $aTableList)) {
$aTableList[] = $sSoundTable;
}
}
}
$aFieldRestrictionQueries = array();
if (!is_null($aFieldRestrictions)) {
reset($aTableList);
foreach ($aTableList as $sTableName) {
$aFieldRestrictionQueries[$sTableName] = " ('".implode("','", $aFieldRestrictions)."')";
}
}
// build query
$aTableQueries = array();
reset($aTerms);
$sLanguageId = MySqlLegacySupport::getInstance()->real_escape_string($sLanguageId);
foreach ($aTerms as $sTerm) {
$sTermTable = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sTerm));
if (!array_key_exists($sTermTable, $aTableQueries)) {
$aTableQueries[$sTermTable] = array();
}
$sTmpQuery = '';
$sTmpQuery .= " (`{$sTermTable}`.`substring` = '".MySqlLegacySupport::getInstance()->real_escape_string($sTerm)."' AND (`{$sTermTable}`.`cms_language_id` = '{$sLanguageId}' OR `{$sTermTable}`.`cms_language_id` = '')";
if (is_array($aFieldRestrictions)) {
$sTmpQuery .= " AND `{$sTermTable}`.`shop_search_field_weight_id` IN {$aFieldRestrictionQueries[$sTermTable]}";
}
$sTmpQuery .= ')';
$aTableQueries[$sTermTable][] = $sTmpQuery;
if (false == TdbShopSearchIndexer::searchWithAND()) {
//OR `{$sSoundTable}`.`substring` = '".MySqlLegacySupport::getInstance()->real_escape_string($sSoundEX)."')
$sSoundEX = TdbShopSearchIndexer::GetSoundexForWord($sTerm);
if ('0000' != $sSoundEX) {
$sSoundTable = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sSoundEX));
$sTmpQuerySoundex = '';
$sTmpQuerySoundex .= " (`{$sSoundTable}`.`substring` = '".MySqlLegacySupport::getInstance()->real_escape_string($sSoundEX)."' AND (`{$sSoundTable}`.`cms_language_id` = '{$sLanguageId}' OR `{$sSoundTable}`.`cms_language_id` = '')";
if (is_array($aFieldRestrictions)) {
$sTmpQuerySoundex .= " AND `{$sSoundTable}`.`shop_search_field_weight_id` IN {$aFieldRestrictionQueries[$sSoundTable]}";
}
$sTmpQuerySoundex .= ')';
$aTableQueries[$sSoundTable][] = $sTmpQuerySoundex;
}
}
}
return $aTableQueries;
} | php | protected static function GetWordListQuery($aTerms, $sLanguageId, $aFieldRestrictions = null, $sTypeOfFieldRestriction = 'OR')
{
$aTableQueries = array();
// get affected tables
$aTableList = array();
foreach ($aTerms as $sTerm) {
$sTableName = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sTerm));
if (!in_array($sTableName, $aTableList)) {
$aTableList[] = $sTableName;
}
if (false == TdbShopSearchIndexer::searchWithAND()) {
$sSoundEX = TdbShopSearchIndexer::GetSoundexForWord($sTerm);
$sSoundTable = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sSoundEX));
if (!in_array($sSoundTable, $aTableList)) {
$aTableList[] = $sSoundTable;
}
}
}
$aFieldRestrictionQueries = array();
if (!is_null($aFieldRestrictions)) {
reset($aTableList);
foreach ($aTableList as $sTableName) {
$aFieldRestrictionQueries[$sTableName] = " ('".implode("','", $aFieldRestrictions)."')";
}
}
// build query
$aTableQueries = array();
reset($aTerms);
$sLanguageId = MySqlLegacySupport::getInstance()->real_escape_string($sLanguageId);
foreach ($aTerms as $sTerm) {
$sTermTable = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sTerm));
if (!array_key_exists($sTermTable, $aTableQueries)) {
$aTableQueries[$sTermTable] = array();
}
$sTmpQuery = '';
$sTmpQuery .= " (`{$sTermTable}`.`substring` = '".MySqlLegacySupport::getInstance()->real_escape_string($sTerm)."' AND (`{$sTermTable}`.`cms_language_id` = '{$sLanguageId}' OR `{$sTermTable}`.`cms_language_id` = '')";
if (is_array($aFieldRestrictions)) {
$sTmpQuery .= " AND `{$sTermTable}`.`shop_search_field_weight_id` IN {$aFieldRestrictionQueries[$sTermTable]}";
}
$sTmpQuery .= ')';
$aTableQueries[$sTermTable][] = $sTmpQuery;
if (false == TdbShopSearchIndexer::searchWithAND()) {
//OR `{$sSoundTable}`.`substring` = '".MySqlLegacySupport::getInstance()->real_escape_string($sSoundEX)."')
$sSoundEX = TdbShopSearchIndexer::GetSoundexForWord($sTerm);
if ('0000' != $sSoundEX) {
$sSoundTable = TdbShopSearchIndexer::GetIndexTableNameForIndexLength(mb_strlen($sSoundEX));
$sTmpQuerySoundex = '';
$sTmpQuerySoundex .= " (`{$sSoundTable}`.`substring` = '".MySqlLegacySupport::getInstance()->real_escape_string($sSoundEX)."' AND (`{$sSoundTable}`.`cms_language_id` = '{$sLanguageId}' OR `{$sSoundTable}`.`cms_language_id` = '')";
if (is_array($aFieldRestrictions)) {
$sTmpQuerySoundex .= " AND `{$sSoundTable}`.`shop_search_field_weight_id` IN {$aFieldRestrictionQueries[$sSoundTable]}";
}
$sTmpQuerySoundex .= ')';
$aTableQueries[$sSoundTable][] = $sTmpQuerySoundex;
}
}
}
return $aTableQueries;
} | [
"protected",
"static",
"function",
"GetWordListQuery",
"(",
"$",
"aTerms",
",",
"$",
"sLanguageId",
",",
"$",
"aFieldRestrictions",
"=",
"null",
",",
"$",
"sTypeOfFieldRestriction",
"=",
"'OR'",
")",
"{",
"$",
"aTableQueries",
"=",
"array",
"(",
")",
";",
"// get affected tables",
"$",
"aTableList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"aTerms",
"as",
"$",
"sTerm",
")",
"{",
"$",
"sTableName",
"=",
"TdbShopSearchIndexer",
"::",
"GetIndexTableNameForIndexLength",
"(",
"mb_strlen",
"(",
"$",
"sTerm",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"sTableName",
",",
"$",
"aTableList",
")",
")",
"{",
"$",
"aTableList",
"[",
"]",
"=",
"$",
"sTableName",
";",
"}",
"if",
"(",
"false",
"==",
"TdbShopSearchIndexer",
"::",
"searchWithAND",
"(",
")",
")",
"{",
"$",
"sSoundEX",
"=",
"TdbShopSearchIndexer",
"::",
"GetSoundexForWord",
"(",
"$",
"sTerm",
")",
";",
"$",
"sSoundTable",
"=",
"TdbShopSearchIndexer",
"::",
"GetIndexTableNameForIndexLength",
"(",
"mb_strlen",
"(",
"$",
"sSoundEX",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"sSoundTable",
",",
"$",
"aTableList",
")",
")",
"{",
"$",
"aTableList",
"[",
"]",
"=",
"$",
"sSoundTable",
";",
"}",
"}",
"}",
"$",
"aFieldRestrictionQueries",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"aFieldRestrictions",
")",
")",
"{",
"reset",
"(",
"$",
"aTableList",
")",
";",
"foreach",
"(",
"$",
"aTableList",
"as",
"$",
"sTableName",
")",
"{",
"$",
"aFieldRestrictionQueries",
"[",
"$",
"sTableName",
"]",
"=",
"\" ('\"",
".",
"implode",
"(",
"\"','\"",
",",
"$",
"aFieldRestrictions",
")",
".",
"\"')\"",
";",
"}",
"}",
"// build query",
"$",
"aTableQueries",
"=",
"array",
"(",
")",
";",
"reset",
"(",
"$",
"aTerms",
")",
";",
"$",
"sLanguageId",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sLanguageId",
")",
";",
"foreach",
"(",
"$",
"aTerms",
"as",
"$",
"sTerm",
")",
"{",
"$",
"sTermTable",
"=",
"TdbShopSearchIndexer",
"::",
"GetIndexTableNameForIndexLength",
"(",
"mb_strlen",
"(",
"$",
"sTerm",
")",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"sTermTable",
",",
"$",
"aTableQueries",
")",
")",
"{",
"$",
"aTableQueries",
"[",
"$",
"sTermTable",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"sTmpQuery",
"=",
"''",
";",
"$",
"sTmpQuery",
".=",
"\" (`{$sTermTable}`.`substring` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sTerm",
")",
".",
"\"' AND (`{$sTermTable}`.`cms_language_id` = '{$sLanguageId}' OR `{$sTermTable}`.`cms_language_id` = '')\"",
";",
"if",
"(",
"is_array",
"(",
"$",
"aFieldRestrictions",
")",
")",
"{",
"$",
"sTmpQuery",
".=",
"\" AND `{$sTermTable}`.`shop_search_field_weight_id` IN {$aFieldRestrictionQueries[$sTermTable]}\"",
";",
"}",
"$",
"sTmpQuery",
".=",
"')'",
";",
"$",
"aTableQueries",
"[",
"$",
"sTermTable",
"]",
"[",
"]",
"=",
"$",
"sTmpQuery",
";",
"if",
"(",
"false",
"==",
"TdbShopSearchIndexer",
"::",
"searchWithAND",
"(",
")",
")",
"{",
"//OR `{$sSoundTable}`.`substring` = '\".MySqlLegacySupport::getInstance()->real_escape_string($sSoundEX).\"')",
"$",
"sSoundEX",
"=",
"TdbShopSearchIndexer",
"::",
"GetSoundexForWord",
"(",
"$",
"sTerm",
")",
";",
"if",
"(",
"'0000'",
"!=",
"$",
"sSoundEX",
")",
"{",
"$",
"sSoundTable",
"=",
"TdbShopSearchIndexer",
"::",
"GetIndexTableNameForIndexLength",
"(",
"mb_strlen",
"(",
"$",
"sSoundEX",
")",
")",
";",
"$",
"sTmpQuerySoundex",
"=",
"''",
";",
"$",
"sTmpQuerySoundex",
".=",
"\" (`{$sSoundTable}`.`substring` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sSoundEX",
")",
".",
"\"' AND (`{$sSoundTable}`.`cms_language_id` = '{$sLanguageId}' OR `{$sSoundTable}`.`cms_language_id` = '')\"",
";",
"if",
"(",
"is_array",
"(",
"$",
"aFieldRestrictions",
")",
")",
"{",
"$",
"sTmpQuerySoundex",
".=",
"\" AND `{$sSoundTable}`.`shop_search_field_weight_id` IN {$aFieldRestrictionQueries[$sSoundTable]}\"",
";",
"}",
"$",
"sTmpQuerySoundex",
".=",
"')'",
";",
"$",
"aTableQueries",
"[",
"$",
"sSoundTable",
"]",
"[",
"]",
"=",
"$",
"sTmpQuerySoundex",
";",
"}",
"}",
"}",
"return",
"$",
"aTableQueries",
";",
"}"
] | return subquery that searches for the terms in aTerms in all fields defined by aFieldRestriction
if no restrctions are passed, we search in all.
@param array $aTerms
@param string $sLanguage - search in which language?
@param array $aFieldRestrictions
@param string $sTypeOfFieldRestriction - if the field restrictions are ORed or ANDed
@return array - returns an array with one parameter holding the query, the other a list of relevant table names | [
"return",
"subquery",
"that",
"searches",
"for",
"the",
"terms",
"in",
"aTerms",
"in",
"all",
"fields",
"defined",
"by",
"aFieldRestriction",
"if",
"no",
"restrctions",
"are",
"passed",
"we",
"search",
"in",
"all",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L632-L695 |
31,579 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.PrepareSearchWords | public static function PrepareSearchWords($sOrigianlString, $bFilterIgnoreWords = true)
{
$aWords = array();
$sOrigianlString = strip_tags($sOrigianlString);
$sOrigianlString = str_replace(array('/', "\n", '-', '_', '&', '+'), array(' ', ' ', ' ', ' ', ' ', ' '), $sOrigianlString);
$aTmpWords = explode(' ', $sOrigianlString);
foreach ($aTmpWords as $iIndex => $sWord) {
$sWord = trim($sWord);
if (!empty($sWord)) {
$sTmpWord = TdbShopSearchIndexer::PrepareSearchWord($sWord, $bFilterIgnoreWords);
if (!empty($sTmpWord)) {
$aWords[] = $sTmpWord;
}
}
}
return $aWords;
} | php | public static function PrepareSearchWords($sOrigianlString, $bFilterIgnoreWords = true)
{
$aWords = array();
$sOrigianlString = strip_tags($sOrigianlString);
$sOrigianlString = str_replace(array('/', "\n", '-', '_', '&', '+'), array(' ', ' ', ' ', ' ', ' ', ' '), $sOrigianlString);
$aTmpWords = explode(' ', $sOrigianlString);
foreach ($aTmpWords as $iIndex => $sWord) {
$sWord = trim($sWord);
if (!empty($sWord)) {
$sTmpWord = TdbShopSearchIndexer::PrepareSearchWord($sWord, $bFilterIgnoreWords);
if (!empty($sTmpWord)) {
$aWords[] = $sTmpWord;
}
}
}
return $aWords;
} | [
"public",
"static",
"function",
"PrepareSearchWords",
"(",
"$",
"sOrigianlString",
",",
"$",
"bFilterIgnoreWords",
"=",
"true",
")",
"{",
"$",
"aWords",
"=",
"array",
"(",
")",
";",
"$",
"sOrigianlString",
"=",
"strip_tags",
"(",
"$",
"sOrigianlString",
")",
";",
"$",
"sOrigianlString",
"=",
"str_replace",
"(",
"array",
"(",
"'/'",
",",
"\"\\n\"",
",",
"'-'",
",",
"'_'",
",",
"'&'",
",",
"'+'",
")",
",",
"array",
"(",
"' '",
",",
"' '",
",",
"' '",
",",
"' '",
",",
"' '",
",",
"' '",
")",
",",
"$",
"sOrigianlString",
")",
";",
"$",
"aTmpWords",
"=",
"explode",
"(",
"' '",
",",
"$",
"sOrigianlString",
")",
";",
"foreach",
"(",
"$",
"aTmpWords",
"as",
"$",
"iIndex",
"=>",
"$",
"sWord",
")",
"{",
"$",
"sWord",
"=",
"trim",
"(",
"$",
"sWord",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sWord",
")",
")",
"{",
"$",
"sTmpWord",
"=",
"TdbShopSearchIndexer",
"::",
"PrepareSearchWord",
"(",
"$",
"sWord",
",",
"$",
"bFilterIgnoreWords",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sTmpWord",
")",
")",
"{",
"$",
"aWords",
"[",
"]",
"=",
"$",
"sTmpWord",
";",
"}",
"}",
"}",
"return",
"$",
"aWords",
";",
"}"
] | splits the search words into an array with prepared search words.
@param string $sWords
@param bool $bFilterIgnoreWords - removes ignore words form the list if set
@return array | [
"splits",
"the",
"search",
"words",
"into",
"an",
"array",
"with",
"prepared",
"search",
"words",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L705-L722 |
31,580 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.IsIgnoreWord | protected static function IsIgnoreWord($sWord)
{
static $aIgnoreWordCache;
static $bCompleteLoad = null;
// first try to cache all... if we have to many (more than 500) then work an a word base system instead
if (!isset($aIgnoreWordCache)) {
$aIgnoreWordCache = array();
$oShop = &TdbShopSearchIndexer::GetShopConfigForIndexer();
$query = "SELECT DISTINCT `name` FROM `shop_search_ignore_word` WHERE `shop_id`='".MySqlLegacySupport::getInstance()->real_escape_string($oShop->id)."'";
$tres = MySqlLegacySupport::getInstance()->query($query);
if (MySqlLegacySupport::getInstance()->num_rows($tres) <= 500) {
$bCompleteLoad = true;
} else {
$bCompleteLoad = false;
}
$count = 0;
while ($count < 500 && ($aRow = MySqlLegacySupport::getInstance()->fetch_row($tres))) {
$aIgnoreWordCache[mb_strtolower($aRow[0])] = 1; // store as assoc so we later have a quick lookup
++$count;
}
}
$sTmpWord = mb_strtolower($sWord);
$bIgnore = false;
if (array_key_exists($sTmpWord, $aIgnoreWordCache)) {
$bIgnore = true;
} elseif (!$bCompleteLoad) {
// check if we find it in the db
$oShop = &TdbShopSearchIndexer::GetShopConfigForIndexer();
$query = "SELECT DISTINCT `name` FROM `shop_search_ignore_word` WHERE `shop_id`='".MySqlLegacySupport::getInstance()->real_escape_string($oShop->id)."' AND `name` = '".MySqlLegacySupport::getInstance()->real_escape_string($sWord)."'";
$tres = MySqlLegacySupport::getInstance()->query($query);
if (MySqlLegacySupport::getInstance()->num_rows($tres) > 0) {
$aIgnoreWordCache[$sTmpWord] = 1;
$bIgnore = true;
}
}
return $bIgnore;
} | php | protected static function IsIgnoreWord($sWord)
{
static $aIgnoreWordCache;
static $bCompleteLoad = null;
// first try to cache all... if we have to many (more than 500) then work an a word base system instead
if (!isset($aIgnoreWordCache)) {
$aIgnoreWordCache = array();
$oShop = &TdbShopSearchIndexer::GetShopConfigForIndexer();
$query = "SELECT DISTINCT `name` FROM `shop_search_ignore_word` WHERE `shop_id`='".MySqlLegacySupport::getInstance()->real_escape_string($oShop->id)."'";
$tres = MySqlLegacySupport::getInstance()->query($query);
if (MySqlLegacySupport::getInstance()->num_rows($tres) <= 500) {
$bCompleteLoad = true;
} else {
$bCompleteLoad = false;
}
$count = 0;
while ($count < 500 && ($aRow = MySqlLegacySupport::getInstance()->fetch_row($tres))) {
$aIgnoreWordCache[mb_strtolower($aRow[0])] = 1; // store as assoc so we later have a quick lookup
++$count;
}
}
$sTmpWord = mb_strtolower($sWord);
$bIgnore = false;
if (array_key_exists($sTmpWord, $aIgnoreWordCache)) {
$bIgnore = true;
} elseif (!$bCompleteLoad) {
// check if we find it in the db
$oShop = &TdbShopSearchIndexer::GetShopConfigForIndexer();
$query = "SELECT DISTINCT `name` FROM `shop_search_ignore_word` WHERE `shop_id`='".MySqlLegacySupport::getInstance()->real_escape_string($oShop->id)."' AND `name` = '".MySqlLegacySupport::getInstance()->real_escape_string($sWord)."'";
$tres = MySqlLegacySupport::getInstance()->query($query);
if (MySqlLegacySupport::getInstance()->num_rows($tres) > 0) {
$aIgnoreWordCache[$sTmpWord] = 1;
$bIgnore = true;
}
}
return $bIgnore;
} | [
"protected",
"static",
"function",
"IsIgnoreWord",
"(",
"$",
"sWord",
")",
"{",
"static",
"$",
"aIgnoreWordCache",
";",
"static",
"$",
"bCompleteLoad",
"=",
"null",
";",
"// first try to cache all... if we have to many (more than 500) then work an a word base system instead",
"if",
"(",
"!",
"isset",
"(",
"$",
"aIgnoreWordCache",
")",
")",
"{",
"$",
"aIgnoreWordCache",
"=",
"array",
"(",
")",
";",
"$",
"oShop",
"=",
"&",
"TdbShopSearchIndexer",
"::",
"GetShopConfigForIndexer",
"(",
")",
";",
"$",
"query",
"=",
"\"SELECT DISTINCT `name` FROM `shop_search_ignore_word` WHERE `shop_id`='\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"oShop",
"->",
"id",
")",
".",
"\"'\"",
";",
"$",
"tres",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"num_rows",
"(",
"$",
"tres",
")",
"<=",
"500",
")",
"{",
"$",
"bCompleteLoad",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"bCompleteLoad",
"=",
"false",
";",
"}",
"$",
"count",
"=",
"0",
";",
"while",
"(",
"$",
"count",
"<",
"500",
"&&",
"(",
"$",
"aRow",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_row",
"(",
"$",
"tres",
")",
")",
")",
"{",
"$",
"aIgnoreWordCache",
"[",
"mb_strtolower",
"(",
"$",
"aRow",
"[",
"0",
"]",
")",
"]",
"=",
"1",
";",
"// store as assoc so we later have a quick lookup",
"++",
"$",
"count",
";",
"}",
"}",
"$",
"sTmpWord",
"=",
"mb_strtolower",
"(",
"$",
"sWord",
")",
";",
"$",
"bIgnore",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"sTmpWord",
",",
"$",
"aIgnoreWordCache",
")",
")",
"{",
"$",
"bIgnore",
"=",
"true",
";",
"}",
"elseif",
"(",
"!",
"$",
"bCompleteLoad",
")",
"{",
"// check if we find it in the db",
"$",
"oShop",
"=",
"&",
"TdbShopSearchIndexer",
"::",
"GetShopConfigForIndexer",
"(",
")",
";",
"$",
"query",
"=",
"\"SELECT DISTINCT `name` FROM `shop_search_ignore_word` WHERE `shop_id`='\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"oShop",
"->",
"id",
")",
".",
"\"' AND `name` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"sWord",
")",
".",
"\"'\"",
";",
"$",
"tres",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"if",
"(",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"num_rows",
"(",
"$",
"tres",
")",
">",
"0",
")",
"{",
"$",
"aIgnoreWordCache",
"[",
"$",
"sTmpWord",
"]",
"=",
"1",
";",
"$",
"bIgnore",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"bIgnore",
";",
"}"
] | return true if the word is in the ignore list.
@param string $sWord
@return bool | [
"return",
"true",
"if",
"the",
"word",
"is",
"in",
"the",
"ignore",
"list",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L769-L807 |
31,581 | chameleon-system/chameleon-shop | src/SearchBundle/objects/db/TShopSearchIndexer.class.php | TShopSearchIndexer.searchWithAND | public static function searchWithAND()
{
$bUseAnd = false;
$oShop = TdbShop::GetInstance();
if ($oShop && array_key_exists('shop_search_use_boolean_and', $oShop->sqlData)) {
$bUseAnd = ('1' == $oShop->sqlData['shop_search_use_boolean_and']);
}
return $bUseAnd;
} | php | public static function searchWithAND()
{
$bUseAnd = false;
$oShop = TdbShop::GetInstance();
if ($oShop && array_key_exists('shop_search_use_boolean_and', $oShop->sqlData)) {
$bUseAnd = ('1' == $oShop->sqlData['shop_search_use_boolean_and']);
}
return $bUseAnd;
} | [
"public",
"static",
"function",
"searchWithAND",
"(",
")",
"{",
"$",
"bUseAnd",
"=",
"false",
";",
"$",
"oShop",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oShop",
"&&",
"array_key_exists",
"(",
"'shop_search_use_boolean_and'",
",",
"$",
"oShop",
"->",
"sqlData",
")",
")",
"{",
"$",
"bUseAnd",
"=",
"(",
"'1'",
"==",
"$",
"oShop",
"->",
"sqlData",
"[",
"'shop_search_use_boolean_and'",
"]",
")",
";",
"}",
"return",
"$",
"bUseAnd",
";",
"}"
] | returns always true!
non AND searches are disabled currently.
@return bool | [
"returns",
"always",
"true!",
"non",
"AND",
"searches",
"are",
"disabled",
"currently",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/SearchBundle/objects/db/TShopSearchIndexer.class.php#L874-L883 |
31,582 | edmondscommerce/doctrine-static-meta | src/CodeGeneration/PathHelper.php | PathHelper.resolvePath | public function resolvePath(string $relativePath): string
{
$path = [];
$absolute = (strpos($relativePath, '/') === 0);
foreach (explode('/', $relativePath) as $part) {
// ignore parts that have no value
if (empty($part) || $part === '.') {
continue;
}
if ($part !== '..') {
$path[] = $part;
continue;
}
if (count($path) > 0) {
// going back up? sure
array_pop($path);
continue;
}
throw new \RuntimeException('Relative path resolves above root path.');
}
$return = implode('/', $path);
if ($absolute) {
$return = "/$return";
}
return $return;
} | php | public function resolvePath(string $relativePath): string
{
$path = [];
$absolute = (strpos($relativePath, '/') === 0);
foreach (explode('/', $relativePath) as $part) {
// ignore parts that have no value
if (empty($part) || $part === '.') {
continue;
}
if ($part !== '..') {
$path[] = $part;
continue;
}
if (count($path) > 0) {
// going back up? sure
array_pop($path);
continue;
}
throw new \RuntimeException('Relative path resolves above root path.');
}
$return = implode('/', $path);
if ($absolute) {
$return = "/$return";
}
return $return;
} | [
"public",
"function",
"resolvePath",
"(",
"string",
"$",
"relativePath",
")",
":",
"string",
"{",
"$",
"path",
"=",
"[",
"]",
";",
"$",
"absolute",
"=",
"(",
"strpos",
"(",
"$",
"relativePath",
",",
"'/'",
")",
"===",
"0",
")",
";",
"foreach",
"(",
"explode",
"(",
"'/'",
",",
"$",
"relativePath",
")",
"as",
"$",
"part",
")",
"{",
"// ignore parts that have no value",
"if",
"(",
"empty",
"(",
"$",
"part",
")",
"||",
"$",
"part",
"===",
"'.'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"part",
"!==",
"'..'",
")",
"{",
"$",
"path",
"[",
"]",
"=",
"$",
"part",
";",
"continue",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"path",
")",
">",
"0",
")",
"{",
"// going back up? sure",
"array_pop",
"(",
"$",
"path",
")",
";",
"continue",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Relative path resolves above root path.'",
")",
";",
"}",
"$",
"return",
"=",
"implode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"absolute",
")",
"{",
"$",
"return",
"=",
"\"/$return\"",
";",
"}",
"return",
"$",
"return",
";",
"}"
] | Take a potentially non existent path and resolve the relativeness into a normal path
@param string $relativePath
@return string
@throws \RuntimeException | [
"Take",
"a",
"potentially",
"non",
"existent",
"path",
"and",
"resolve",
"the",
"relativeness",
"into",
"a",
"normal",
"path"
] | c5b1caab0b2e3a84c34082af96529a274f0c3d7e | https://github.com/edmondscommerce/doctrine-static-meta/blob/c5b1caab0b2e3a84c34082af96529a274f0c3d7e/src/CodeGeneration/PathHelper.php#L215-L243 |
31,583 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/WebModules/MTShopBasketCore/MTShopWishlistBasketCore.class.php | MTShopWishlistBasketCore.RemoveFromWishlist | protected function RemoveFromWishlist($sPkgShopWishlistArticleId = null, $sMessageHandler = null, $bIsInternalCall = false)
{
$oGlobal = TGlobal::instance();
$aRequestData = $oGlobal->GetUserData(self::URL_REQUEST_PARAMETER);
if (is_null($sPkgShopWishlistArticleId) && array_key_exists(self::URL_ITEM_ID_NAME, $aRequestData)) {
$sPkgShopWishlistArticleId = $aRequestData[self::URL_ITEM_ID_NAME];
}
if (is_null($sMessageHandler) && array_key_exists(self::URL_MESSAGE_CONSUMER_NAME, $aRequestData)) {
$sMessageHandler = $aRequestData[self::URL_MESSAGE_CONSUMER_NAME];
if (empty($sMessageHandler)) {
$sMessageHandler = null;
}
}
if (is_null($sMessageHandler)) {
$sMessageHandler = self::MSG_CONSUMER_NAME;
}
$oMessageManager = TCMSMessageManager::GetInstance();
$oUser = TdbDataExtranetUser::GetInstance();
if (!$oUser->IsLoggedIn()) {
$oMessageManager->AddMessage($sMessageHandler, 'WISHLIST-USER-NOT-LOGGED-IN');
} else {
$oWishlistItem = TdbPkgShopWishlistArticle::GetNewInstance();
/** @var $oWishlistItem TdbPkgShopWishlistArticle */
$oWishlistItem->Load($sPkgShopWishlistArticleId);
$oArticle = $oWishlistItem->GetFieldShopArticle();
if ($oArticle) {
$aMessageData = array('sArticleLinkStart' => '<a href="'.TGlobal::OutHTML($oArticle->GetDetailLink()).'">', 'sArticleLinkEnd' => '</a>', 'sArticleName' => $oArticle->GetName());
} else {
$aMessageData = array();
}
$oUser->RemoveArticleFromWishlist($sPkgShopWishlistArticleId);
$oMessageManager->AddMessage($sMessageHandler, 'WISHLIST-REMOVED-ITEM', $aMessageData);
}
$iRedirectNodeId = null;
if (array_key_exists(self::URL_REDIRECT_NODE_ID_NAME, $aRequestData)) {
$iRedirectNodeId = $aRequestData[self::URL_REDIRECT_NODE_ID_NAME];
if (empty($iRedirectNodeId)) {
$iRedirectNodeId = null;
}
}
if (!$bIsInternalCall) {
$this->RedirectAfterEvent($iRedirectNodeId);
}
} | php | protected function RemoveFromWishlist($sPkgShopWishlistArticleId = null, $sMessageHandler = null, $bIsInternalCall = false)
{
$oGlobal = TGlobal::instance();
$aRequestData = $oGlobal->GetUserData(self::URL_REQUEST_PARAMETER);
if (is_null($sPkgShopWishlistArticleId) && array_key_exists(self::URL_ITEM_ID_NAME, $aRequestData)) {
$sPkgShopWishlistArticleId = $aRequestData[self::URL_ITEM_ID_NAME];
}
if (is_null($sMessageHandler) && array_key_exists(self::URL_MESSAGE_CONSUMER_NAME, $aRequestData)) {
$sMessageHandler = $aRequestData[self::URL_MESSAGE_CONSUMER_NAME];
if (empty($sMessageHandler)) {
$sMessageHandler = null;
}
}
if (is_null($sMessageHandler)) {
$sMessageHandler = self::MSG_CONSUMER_NAME;
}
$oMessageManager = TCMSMessageManager::GetInstance();
$oUser = TdbDataExtranetUser::GetInstance();
if (!$oUser->IsLoggedIn()) {
$oMessageManager->AddMessage($sMessageHandler, 'WISHLIST-USER-NOT-LOGGED-IN');
} else {
$oWishlistItem = TdbPkgShopWishlistArticle::GetNewInstance();
/** @var $oWishlistItem TdbPkgShopWishlistArticle */
$oWishlistItem->Load($sPkgShopWishlistArticleId);
$oArticle = $oWishlistItem->GetFieldShopArticle();
if ($oArticle) {
$aMessageData = array('sArticleLinkStart' => '<a href="'.TGlobal::OutHTML($oArticle->GetDetailLink()).'">', 'sArticleLinkEnd' => '</a>', 'sArticleName' => $oArticle->GetName());
} else {
$aMessageData = array();
}
$oUser->RemoveArticleFromWishlist($sPkgShopWishlistArticleId);
$oMessageManager->AddMessage($sMessageHandler, 'WISHLIST-REMOVED-ITEM', $aMessageData);
}
$iRedirectNodeId = null;
if (array_key_exists(self::URL_REDIRECT_NODE_ID_NAME, $aRequestData)) {
$iRedirectNodeId = $aRequestData[self::URL_REDIRECT_NODE_ID_NAME];
if (empty($iRedirectNodeId)) {
$iRedirectNodeId = null;
}
}
if (!$bIsInternalCall) {
$this->RedirectAfterEvent($iRedirectNodeId);
}
} | [
"protected",
"function",
"RemoveFromWishlist",
"(",
"$",
"sPkgShopWishlistArticleId",
"=",
"null",
",",
"$",
"sMessageHandler",
"=",
"null",
",",
"$",
"bIsInternalCall",
"=",
"false",
")",
"{",
"$",
"oGlobal",
"=",
"TGlobal",
"::",
"instance",
"(",
")",
";",
"$",
"aRequestData",
"=",
"$",
"oGlobal",
"->",
"GetUserData",
"(",
"self",
"::",
"URL_REQUEST_PARAMETER",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"sPkgShopWishlistArticleId",
")",
"&&",
"array_key_exists",
"(",
"self",
"::",
"URL_ITEM_ID_NAME",
",",
"$",
"aRequestData",
")",
")",
"{",
"$",
"sPkgShopWishlistArticleId",
"=",
"$",
"aRequestData",
"[",
"self",
"::",
"URL_ITEM_ID_NAME",
"]",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"sMessageHandler",
")",
"&&",
"array_key_exists",
"(",
"self",
"::",
"URL_MESSAGE_CONSUMER_NAME",
",",
"$",
"aRequestData",
")",
")",
"{",
"$",
"sMessageHandler",
"=",
"$",
"aRequestData",
"[",
"self",
"::",
"URL_MESSAGE_CONSUMER_NAME",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"sMessageHandler",
")",
")",
"{",
"$",
"sMessageHandler",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"sMessageHandler",
")",
")",
"{",
"$",
"sMessageHandler",
"=",
"self",
"::",
"MSG_CONSUMER_NAME",
";",
"}",
"$",
"oMessageManager",
"=",
"TCMSMessageManager",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"!",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"oMessageManager",
"->",
"AddMessage",
"(",
"$",
"sMessageHandler",
",",
"'WISHLIST-USER-NOT-LOGGED-IN'",
")",
";",
"}",
"else",
"{",
"$",
"oWishlistItem",
"=",
"TdbPkgShopWishlistArticle",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oWishlistItem TdbPkgShopWishlistArticle */",
"$",
"oWishlistItem",
"->",
"Load",
"(",
"$",
"sPkgShopWishlistArticleId",
")",
";",
"$",
"oArticle",
"=",
"$",
"oWishlistItem",
"->",
"GetFieldShopArticle",
"(",
")",
";",
"if",
"(",
"$",
"oArticle",
")",
"{",
"$",
"aMessageData",
"=",
"array",
"(",
"'sArticleLinkStart'",
"=>",
"'<a href=\"'",
".",
"TGlobal",
"::",
"OutHTML",
"(",
"$",
"oArticle",
"->",
"GetDetailLink",
"(",
")",
")",
".",
"'\">'",
",",
"'sArticleLinkEnd'",
"=>",
"'</a>'",
",",
"'sArticleName'",
"=>",
"$",
"oArticle",
"->",
"GetName",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"aMessageData",
"=",
"array",
"(",
")",
";",
"}",
"$",
"oUser",
"->",
"RemoveArticleFromWishlist",
"(",
"$",
"sPkgShopWishlistArticleId",
")",
";",
"$",
"oMessageManager",
"->",
"AddMessage",
"(",
"$",
"sMessageHandler",
",",
"'WISHLIST-REMOVED-ITEM'",
",",
"$",
"aMessageData",
")",
";",
"}",
"$",
"iRedirectNodeId",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"URL_REDIRECT_NODE_ID_NAME",
",",
"$",
"aRequestData",
")",
")",
"{",
"$",
"iRedirectNodeId",
"=",
"$",
"aRequestData",
"[",
"self",
"::",
"URL_REDIRECT_NODE_ID_NAME",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"iRedirectNodeId",
")",
")",
"{",
"$",
"iRedirectNodeId",
"=",
"null",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"bIsInternalCall",
")",
"{",
"$",
"this",
"->",
"RedirectAfterEvent",
"(",
"$",
"iRedirectNodeId",
")",
";",
"}",
"}"
] | remove an item from the users wishlist.
@param string $sPkgShopWishlistArticleId - the pkg_shop_wishlist_article_id to remove from the list
@param string $sMessageHandler
@param bool $bIsInternalCall | [
"remove",
"an",
"item",
"from",
"the",
"users",
"wishlist",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/WebModules/MTShopBasketCore/MTShopWishlistBasketCore.class.php#L110-L156 |
31,584 | chameleon-system/chameleon-shop | src/ShopBundle/objects/WebModules/MTShopCentralHandlerCore/MTShopCentralHandlerCoreEndPoint.class.php | MTShopCentralHandlerCoreEndPoint.GetArticleView | protected function GetArticleView($sShopArticleId = null, $sViewName = 'standard', $sViewType = 'Customer', $aCallTimeVars = array())
{
$oReturnObject = new stdClass();
$oArticle = TdbShopArticle::GetNewInstance();
$oArticle->Load($sShopArticleId);
if ($oArticle->IsVariant()) {
TdbShop::RegisterActiveVariantForSpot($this->sCallingSpotName, $oArticle->fieldVariantParentId, $oArticle->id);
}
$oReturnObject->sItemPage = $oArticle->Render($sViewName, $sViewType, $aCallTimeVars);
$sKey = $oArticle->id;
if ($oArticle->IsVariant()) {
$sKey = $oArticle->fieldVariantParentId;
}
$oReturnObject->iListKey = 'key'.md5($sKey);
return $oReturnObject;
} | php | protected function GetArticleView($sShopArticleId = null, $sViewName = 'standard', $sViewType = 'Customer', $aCallTimeVars = array())
{
$oReturnObject = new stdClass();
$oArticle = TdbShopArticle::GetNewInstance();
$oArticle->Load($sShopArticleId);
if ($oArticle->IsVariant()) {
TdbShop::RegisterActiveVariantForSpot($this->sCallingSpotName, $oArticle->fieldVariantParentId, $oArticle->id);
}
$oReturnObject->sItemPage = $oArticle->Render($sViewName, $sViewType, $aCallTimeVars);
$sKey = $oArticle->id;
if ($oArticle->IsVariant()) {
$sKey = $oArticle->fieldVariantParentId;
}
$oReturnObject->iListKey = 'key'.md5($sKey);
return $oReturnObject;
} | [
"protected",
"function",
"GetArticleView",
"(",
"$",
"sShopArticleId",
"=",
"null",
",",
"$",
"sViewName",
"=",
"'standard'",
",",
"$",
"sViewType",
"=",
"'Customer'",
",",
"$",
"aCallTimeVars",
"=",
"array",
"(",
")",
")",
"{",
"$",
"oReturnObject",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"oArticle",
"=",
"TdbShopArticle",
"::",
"GetNewInstance",
"(",
")",
";",
"$",
"oArticle",
"->",
"Load",
"(",
"$",
"sShopArticleId",
")",
";",
"if",
"(",
"$",
"oArticle",
"->",
"IsVariant",
"(",
")",
")",
"{",
"TdbShop",
"::",
"RegisterActiveVariantForSpot",
"(",
"$",
"this",
"->",
"sCallingSpotName",
",",
"$",
"oArticle",
"->",
"fieldVariantParentId",
",",
"$",
"oArticle",
"->",
"id",
")",
";",
"}",
"$",
"oReturnObject",
"->",
"sItemPage",
"=",
"$",
"oArticle",
"->",
"Render",
"(",
"$",
"sViewName",
",",
"$",
"sViewType",
",",
"$",
"aCallTimeVars",
")",
";",
"$",
"sKey",
"=",
"$",
"oArticle",
"->",
"id",
";",
"if",
"(",
"$",
"oArticle",
"->",
"IsVariant",
"(",
")",
")",
"{",
"$",
"sKey",
"=",
"$",
"oArticle",
"->",
"fieldVariantParentId",
";",
"}",
"$",
"oReturnObject",
"->",
"iListKey",
"=",
"'key'",
".",
"md5",
"(",
"$",
"sKey",
")",
";",
"return",
"$",
"oReturnObject",
";",
"}"
] | returns an article view.
@param string $sShopArticleId
@param string $sViewName
@param string $sViewType
@param array $aCallTimeVars
@return stdClass | [
"returns",
"an",
"article",
"view",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/WebModules/MTShopCentralHandlerCore/MTShopCentralHandlerCoreEndPoint.class.php#L45-L62 |
31,585 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/pkgShop/OrderSteps/AmazonAddressStep.php | AmazonAddressStep.Init | public function Init()
{
parent::Init();
$oUser = TdbDataExtranetUser::GetInstance();
$shippingAddress = $oUser->GetShippingAddress();
if (true === $shippingAddress->getIsAmazonShippingAddress()) {
$oUser->resetAmazonAddresses();
$basket = $this->getShopService()->getActiveBasket();
$basket->RecalculateBasket(); // need to recalculate maybe changing address can change basket amount (gross net change)
}
} | php | public function Init()
{
parent::Init();
$oUser = TdbDataExtranetUser::GetInstance();
$shippingAddress = $oUser->GetShippingAddress();
if (true === $shippingAddress->getIsAmazonShippingAddress()) {
$oUser->resetAmazonAddresses();
$basket = $this->getShopService()->getActiveBasket();
$basket->RecalculateBasket(); // need to recalculate maybe changing address can change basket amount (gross net change)
}
} | [
"public",
"function",
"Init",
"(",
")",
"{",
"parent",
"::",
"Init",
"(",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"$",
"shippingAddress",
"=",
"$",
"oUser",
"->",
"GetShippingAddress",
"(",
")",
";",
"if",
"(",
"true",
"===",
"$",
"shippingAddress",
"->",
"getIsAmazonShippingAddress",
"(",
")",
")",
"{",
"$",
"oUser",
"->",
"resetAmazonAddresses",
"(",
")",
";",
"$",
"basket",
"=",
"$",
"this",
"->",
"getShopService",
"(",
")",
"->",
"getActiveBasket",
"(",
")",
";",
"$",
"basket",
"->",
"RecalculateBasket",
"(",
")",
";",
"// need to recalculate maybe changing address can change basket amount (gross net change)",
"}",
"}"
] | reset address data because customer choose new in this step. | [
"reset",
"address",
"data",
"because",
"customer",
"choose",
"new",
"in",
"this",
"step",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/pkgShop/OrderSteps/AmazonAddressStep.php#L89-L99 |
31,586 | chameleon-system/chameleon-shop | src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Samples/CancellationResult.php | CancellationResult._waitUntilAuthorizationProcessingIsCompleted | private function _waitUntilAuthorizationProcessingIsCompleted
($amazonAuthorizationId)
{
// Check for the presence of the ipn notification
$this->waitForNotificationToBeProcessedBeforeContinuing(
$amazonAuthorizationId,
"AuthorizationNotification"
);
// Notification is present, go and get the full
// information for this notification
$response
= $this->callStepAndCheckForException(
'getAuthorizationDetails',
array($amazonAuthorizationId)
);
echo $this->printResponseToWebpage(
"printGetAuthorizationDetailsResponse", array($response)
);
validateThatAuthorizationIsOpen($response);
} | php | private function _waitUntilAuthorizationProcessingIsCompleted
($amazonAuthorizationId)
{
// Check for the presence of the ipn notification
$this->waitForNotificationToBeProcessedBeforeContinuing(
$amazonAuthorizationId,
"AuthorizationNotification"
);
// Notification is present, go and get the full
// information for this notification
$response
= $this->callStepAndCheckForException(
'getAuthorizationDetails',
array($amazonAuthorizationId)
);
echo $this->printResponseToWebpage(
"printGetAuthorizationDetailsResponse", array($response)
);
validateThatAuthorizationIsOpen($response);
} | [
"private",
"function",
"_waitUntilAuthorizationProcessingIsCompleted",
"(",
"$",
"amazonAuthorizationId",
")",
"{",
"// Check for the presence of the ipn notification",
"$",
"this",
"->",
"waitForNotificationToBeProcessedBeforeContinuing",
"(",
"$",
"amazonAuthorizationId",
",",
"\"AuthorizationNotification\"",
")",
";",
"// Notification is present, go and get the full ",
"// information for this notification",
"$",
"response",
"=",
"$",
"this",
"->",
"callStepAndCheckForException",
"(",
"'getAuthorizationDetails'",
",",
"array",
"(",
"$",
"amazonAuthorizationId",
")",
")",
";",
"echo",
"$",
"this",
"->",
"printResponseToWebpage",
"(",
"\"printGetAuthorizationDetailsResponse\"",
",",
"array",
"(",
"$",
"response",
")",
")",
";",
"validateThatAuthorizationIsOpen",
"(",
"$",
"response",
")",
";",
"}"
] | Check that we have received an IPN notification for the authorization
For PHP, there is an IPN handler that will write the contents of the IPN to
a file in the format of
<amazonAuthorizationId>_Authorization.
This method will check for the presnece of this file
and will loop/timeout until the notification has been handled.
Merchants can use alternative approaches such as memory caches,
shared memory or database storage so that scripts serving user
pages are able to check on the status of a notification
@param string $amazonAuthorizationId authorization transaction to query
@return void | [
"Check",
"that",
"we",
"have",
"received",
"an",
"IPN",
"notification",
"for",
"the",
"authorization"
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/AmazonPaymentBundle/lib/amazon/OffAmazonPaymentsNotifications/Samples/CancellationResult.php#L161-L182 |
31,587 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopOrderStep/TShopStepBasketCore.class.php | TShopStepBasketCore.& | public function &GetNextStep()
{
static $oNextStep;
if (!$oNextStep) {
$oUsers = TdbDataExtranetUser::GetInstance();
if ($oUsers->IsLoggedIn() && $oUsers->HasData()) {
$oBasket = TShopBasket::GetInstance();
$oBasket->aCompletedOrderStepList['user'] = true;
// now search for the next step not marked as completed
$oStepList = TdbShopOrderStepList::GetList();
$oStepList->bAllowItemCache = true;
$oNextStep = null;
$bDone = false;
// do not allow access to the last stpe
$iNumItems = $oStepList->Length();
while (($iNumItems > 0) && !$bDone && ($oTmpStep = $oStepList->Next())) {
--$iNumItems;
if (!$oTmpStep->AllowAccessToStepPublic()) {
// step not completed...
$bDone = true;
} else {
$oNextStep = $oTmpStep;
}
}
} else {
$oNextStep = &TdbShopOrderStepList::GetNextStep($this);
}
}
return $oNextStep;
} | php | public function &GetNextStep()
{
static $oNextStep;
if (!$oNextStep) {
$oUsers = TdbDataExtranetUser::GetInstance();
if ($oUsers->IsLoggedIn() && $oUsers->HasData()) {
$oBasket = TShopBasket::GetInstance();
$oBasket->aCompletedOrderStepList['user'] = true;
// now search for the next step not marked as completed
$oStepList = TdbShopOrderStepList::GetList();
$oStepList->bAllowItemCache = true;
$oNextStep = null;
$bDone = false;
// do not allow access to the last stpe
$iNumItems = $oStepList->Length();
while (($iNumItems > 0) && !$bDone && ($oTmpStep = $oStepList->Next())) {
--$iNumItems;
if (!$oTmpStep->AllowAccessToStepPublic()) {
// step not completed...
$bDone = true;
} else {
$oNextStep = $oTmpStep;
}
}
} else {
$oNextStep = &TdbShopOrderStepList::GetNextStep($this);
}
}
return $oNextStep;
} | [
"public",
"function",
"&",
"GetNextStep",
"(",
")",
"{",
"static",
"$",
"oNextStep",
";",
"if",
"(",
"!",
"$",
"oNextStep",
")",
"{",
"$",
"oUsers",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oUsers",
"->",
"IsLoggedIn",
"(",
")",
"&&",
"$",
"oUsers",
"->",
"HasData",
"(",
")",
")",
"{",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oBasket",
"->",
"aCompletedOrderStepList",
"[",
"'user'",
"]",
"=",
"true",
";",
"// now search for the next step not marked as completed",
"$",
"oStepList",
"=",
"TdbShopOrderStepList",
"::",
"GetList",
"(",
")",
";",
"$",
"oStepList",
"->",
"bAllowItemCache",
"=",
"true",
";",
"$",
"oNextStep",
"=",
"null",
";",
"$",
"bDone",
"=",
"false",
";",
"// do not allow access to the last stpe",
"$",
"iNumItems",
"=",
"$",
"oStepList",
"->",
"Length",
"(",
")",
";",
"while",
"(",
"(",
"$",
"iNumItems",
">",
"0",
")",
"&&",
"!",
"$",
"bDone",
"&&",
"(",
"$",
"oTmpStep",
"=",
"$",
"oStepList",
"->",
"Next",
"(",
")",
")",
")",
"{",
"--",
"$",
"iNumItems",
";",
"if",
"(",
"!",
"$",
"oTmpStep",
"->",
"AllowAccessToStepPublic",
"(",
")",
")",
"{",
"// step not completed...",
"$",
"bDone",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"oNextStep",
"=",
"$",
"oTmpStep",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"oNextStep",
"=",
"&",
"TdbShopOrderStepList",
"::",
"GetNextStep",
"(",
"$",
"this",
")",
";",
"}",
"}",
"return",
"$",
"oNextStep",
";",
"}"
] | overwrite this to jump directly to the payment page for signed in users.
@return TdbShopOrderStep | [
"overwrite",
"this",
"to",
"jump",
"directly",
"to",
"the",
"payment",
"page",
"for",
"signed",
"in",
"users",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepBasketCore.class.php#L86-L116 |
31,588 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopOrderStep/TShopStepBasketCore.class.php | TShopStepBasketCore.UpdateBasket | public function UpdateBasket($bInternalCall = false)
{
// we use the existing basket module to do all the work...
$oShop = TdbShop::GetInstance();
$oController = TGlobal::GetController();
$oBasketModule = $oController->moduleLoader->GetPointerToModule($oShop->fieldBasketSpotName);
$bSuccess = $oBasketModule->UpdateBasketItems(null, false, true);
// redirect to current page
if (!$bInternalCall) {
$this->ReloadCurrentStep();
}
return $bSuccess;
} | php | public function UpdateBasket($bInternalCall = false)
{
// we use the existing basket module to do all the work...
$oShop = TdbShop::GetInstance();
$oController = TGlobal::GetController();
$oBasketModule = $oController->moduleLoader->GetPointerToModule($oShop->fieldBasketSpotName);
$bSuccess = $oBasketModule->UpdateBasketItems(null, false, true);
// redirect to current page
if (!$bInternalCall) {
$this->ReloadCurrentStep();
}
return $bSuccess;
} | [
"public",
"function",
"UpdateBasket",
"(",
"$",
"bInternalCall",
"=",
"false",
")",
"{",
"// we use the existing basket module to do all the work...",
"$",
"oShop",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oController",
"=",
"TGlobal",
"::",
"GetController",
"(",
")",
";",
"$",
"oBasketModule",
"=",
"$",
"oController",
"->",
"moduleLoader",
"->",
"GetPointerToModule",
"(",
"$",
"oShop",
"->",
"fieldBasketSpotName",
")",
";",
"$",
"bSuccess",
"=",
"$",
"oBasketModule",
"->",
"UpdateBasketItems",
"(",
"null",
",",
"false",
",",
"true",
")",
";",
"// redirect to current page",
"if",
"(",
"!",
"$",
"bInternalCall",
")",
"{",
"$",
"this",
"->",
"ReloadCurrentStep",
"(",
")",
";",
"}",
"return",
"$",
"bSuccess",
";",
"}"
] | update current basket.
@param bool $bInternalCall - if set to true, all redirects will be supressed
@return bool | [
"update",
"current",
"basket",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopOrderStep/TShopStepBasketCore.class.php#L125-L139 |
31,589 | chameleon-system/chameleon-shop | src/ShopCurrencyBundle/objects/db/TPkgShopCurrency.class.php | TPkgShopCurrency.GetBaseCurrency | public static function GetBaseCurrency()
{
static $oInstance = null;
if (null === $oInstance) {
$oInstance = TdbPkgShopCurrency::GetNewInstance();
if (false === $oInstance->LoadFromField('is_base_currency', '1')) {
$oInstance = false;
}
}
return $oInstance;
} | php | public static function GetBaseCurrency()
{
static $oInstance = null;
if (null === $oInstance) {
$oInstance = TdbPkgShopCurrency::GetNewInstance();
if (false === $oInstance->LoadFromField('is_base_currency', '1')) {
$oInstance = false;
}
}
return $oInstance;
} | [
"public",
"static",
"function",
"GetBaseCurrency",
"(",
")",
"{",
"static",
"$",
"oInstance",
"=",
"null",
";",
"if",
"(",
"null",
"===",
"$",
"oInstance",
")",
"{",
"$",
"oInstance",
"=",
"TdbPkgShopCurrency",
"::",
"GetNewInstance",
"(",
")",
";",
"if",
"(",
"false",
"===",
"$",
"oInstance",
"->",
"LoadFromField",
"(",
"'is_base_currency'",
",",
"'1'",
")",
")",
"{",
"$",
"oInstance",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"oInstance",
";",
"}"
] | return the base currency relative to which all other currencies are calculated.
@return TdbPkgShopCurrency | [
"return",
"the",
"base",
"currency",
"relative",
"to",
"which",
"all",
"other",
"currencies",
"are",
"calculated",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopCurrencyBundle/objects/db/TPkgShopCurrency.class.php#L115-L126 |
31,590 | chameleon-system/chameleon-shop | src/ShopCurrencyBundle/objects/db/TPkgShopCurrency.class.php | TPkgShopCurrency.SetAsActive | public function SetAsActive()
{
$sCurrencyId = $this->id;
/** @var Request $request */
$request = ServiceLocator::get('request_stack')->getCurrentRequest();
$request->getSession()->set(TdbPkgShopCurrency::SESSION_NAME, $sCurrencyId);
$sDomain = $request->getHost();
if ('www.' == substr($sDomain, 0, 4)) {
$sDomain = substr($sDomain, 4);
}
setcookie(TdbPkgShopCurrency::SESSION_NAME, base64_encode($sCurrencyId), time() + 60 * 60 * 24 * 365, '/', '.'.$sDomain, false, true);
$oUser = TdbDataExtranetUser::GetInstance();
if (!is_null($oUser->id) && !empty($oUser->id) && array_key_exists('pkg_shop_currency_id', $oUser->sqlData) && $oUser->sqlData['pkg_shop_currency_id'] != $sCurrencyId && $oUser->IsLoggedIn()) {
$oUser->SaveFieldsFast(array('pkg_shop_currency_id' => $sCurrencyId));
} else {
$oUser->sqlData['pkg_shop_currency_id'] = $sCurrencyId;
$oUser->fieldPkgShopCurrencyId = $sCurrencyId;
}
TdbPkgShopCurrency::GetActiveInstance(true);
$this->getEventDispatcher()->dispatch(
ShopCurrencyEvents::CURRENCY_CHANGED,
new CurrencyChangedEvent($sCurrencyId)
);
// also mark basket as "requires recalculation"
$oBasket = TShopBasket::GetInstance();
$oBasket->SetBasketRecalculationFlag(true);
} | php | public function SetAsActive()
{
$sCurrencyId = $this->id;
/** @var Request $request */
$request = ServiceLocator::get('request_stack')->getCurrentRequest();
$request->getSession()->set(TdbPkgShopCurrency::SESSION_NAME, $sCurrencyId);
$sDomain = $request->getHost();
if ('www.' == substr($sDomain, 0, 4)) {
$sDomain = substr($sDomain, 4);
}
setcookie(TdbPkgShopCurrency::SESSION_NAME, base64_encode($sCurrencyId), time() + 60 * 60 * 24 * 365, '/', '.'.$sDomain, false, true);
$oUser = TdbDataExtranetUser::GetInstance();
if (!is_null($oUser->id) && !empty($oUser->id) && array_key_exists('pkg_shop_currency_id', $oUser->sqlData) && $oUser->sqlData['pkg_shop_currency_id'] != $sCurrencyId && $oUser->IsLoggedIn()) {
$oUser->SaveFieldsFast(array('pkg_shop_currency_id' => $sCurrencyId));
} else {
$oUser->sqlData['pkg_shop_currency_id'] = $sCurrencyId;
$oUser->fieldPkgShopCurrencyId = $sCurrencyId;
}
TdbPkgShopCurrency::GetActiveInstance(true);
$this->getEventDispatcher()->dispatch(
ShopCurrencyEvents::CURRENCY_CHANGED,
new CurrencyChangedEvent($sCurrencyId)
);
// also mark basket as "requires recalculation"
$oBasket = TShopBasket::GetInstance();
$oBasket->SetBasketRecalculationFlag(true);
} | [
"public",
"function",
"SetAsActive",
"(",
")",
"{",
"$",
"sCurrencyId",
"=",
"$",
"this",
"->",
"id",
";",
"/** @var Request $request */",
"$",
"request",
"=",
"ServiceLocator",
"::",
"get",
"(",
"'request_stack'",
")",
"->",
"getCurrentRequest",
"(",
")",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"TdbPkgShopCurrency",
"::",
"SESSION_NAME",
",",
"$",
"sCurrencyId",
")",
";",
"$",
"sDomain",
"=",
"$",
"request",
"->",
"getHost",
"(",
")",
";",
"if",
"(",
"'www.'",
"==",
"substr",
"(",
"$",
"sDomain",
",",
"0",
",",
"4",
")",
")",
"{",
"$",
"sDomain",
"=",
"substr",
"(",
"$",
"sDomain",
",",
"4",
")",
";",
"}",
"setcookie",
"(",
"TdbPkgShopCurrency",
"::",
"SESSION_NAME",
",",
"base64_encode",
"(",
"$",
"sCurrencyId",
")",
",",
"time",
"(",
")",
"+",
"60",
"*",
"60",
"*",
"24",
"*",
"365",
",",
"'/'",
",",
"'.'",
".",
"$",
"sDomain",
",",
"false",
",",
"true",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oUser",
"->",
"id",
")",
"&&",
"!",
"empty",
"(",
"$",
"oUser",
"->",
"id",
")",
"&&",
"array_key_exists",
"(",
"'pkg_shop_currency_id'",
",",
"$",
"oUser",
"->",
"sqlData",
")",
"&&",
"$",
"oUser",
"->",
"sqlData",
"[",
"'pkg_shop_currency_id'",
"]",
"!=",
"$",
"sCurrencyId",
"&&",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"oUser",
"->",
"SaveFieldsFast",
"(",
"array",
"(",
"'pkg_shop_currency_id'",
"=>",
"$",
"sCurrencyId",
")",
")",
";",
"}",
"else",
"{",
"$",
"oUser",
"->",
"sqlData",
"[",
"'pkg_shop_currency_id'",
"]",
"=",
"$",
"sCurrencyId",
";",
"$",
"oUser",
"->",
"fieldPkgShopCurrencyId",
"=",
"$",
"sCurrencyId",
";",
"}",
"TdbPkgShopCurrency",
"::",
"GetActiveInstance",
"(",
"true",
")",
";",
"$",
"this",
"->",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"ShopCurrencyEvents",
"::",
"CURRENCY_CHANGED",
",",
"new",
"CurrencyChangedEvent",
"(",
"$",
"sCurrencyId",
")",
")",
";",
"// also mark basket as \"requires recalculation\"",
"$",
"oBasket",
"=",
"TShopBasket",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oBasket",
"->",
"SetBasketRecalculationFlag",
"(",
"true",
")",
";",
"}"
] | set this currency object as the active object. | [
"set",
"this",
"currency",
"object",
"as",
"the",
"active",
"object",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopCurrencyBundle/objects/db/TPkgShopCurrency.class.php#L169-L199 |
31,591 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopModuleArticleListFilter/TShopModuleArticlelistFilterSearch.class.php | TShopModuleArticlelistFilterSearch.ModuleInitHook | public function ModuleInitHook()
{
parent::ModuleInitHook();
$oShop = TdbShop::GetInstance();
if ($oShop->fieldRedirectToNotFoundPageProductSearchOnNoResults) {
// in this case the shop may redirect after running the search. since this occurs in the Execute of the module, we need
// to prevent any other output from being auto-sent to the browser
TGlobal::GetController()->SetBlockAutoFlushToBrowser(true);
}
} | php | public function ModuleInitHook()
{
parent::ModuleInitHook();
$oShop = TdbShop::GetInstance();
if ($oShop->fieldRedirectToNotFoundPageProductSearchOnNoResults) {
// in this case the shop may redirect after running the search. since this occurs in the Execute of the module, we need
// to prevent any other output from being auto-sent to the browser
TGlobal::GetController()->SetBlockAutoFlushToBrowser(true);
}
} | [
"public",
"function",
"ModuleInitHook",
"(",
")",
"{",
"parent",
"::",
"ModuleInitHook",
"(",
")",
";",
"$",
"oShop",
"=",
"TdbShop",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oShop",
"->",
"fieldRedirectToNotFoundPageProductSearchOnNoResults",
")",
"{",
"// in this case the shop may redirect after running the search. since this occurs in the Execute of the module, we need",
"// to prevent any other output from being auto-sent to the browser",
"TGlobal",
"::",
"GetController",
"(",
")",
"->",
"SetBlockAutoFlushToBrowser",
"(",
"true",
")",
";",
"}",
"}"
] | is called when the module initializes. | [
"is",
"called",
"when",
"the",
"module",
"initializes",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopModuleArticleListFilter/TShopModuleArticlelistFilterSearch.class.php#L138-L147 |
31,592 | Firesphere/silverstripe-bootstrapmfa | src/Extensions/SiteConfigExtension.php | SiteConfigExtension.updateCMSFields | public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab(
'Root.MFA',
$checkbox = CheckboxField::create(
'EnforceMFA',
_t(self::class . '.ENFORCEMFA', 'Enforce MFA on all users'),
$this->isMFAEnforced()
)
);
$checkbox->setDescription(null);
$this->updateCheckboxDescription($fields);
} | php | public function updateCMSFields(FieldList $fields)
{
$fields->addFieldToTab(
'Root.MFA',
$checkbox = CheckboxField::create(
'EnforceMFA',
_t(self::class . '.ENFORCEMFA', 'Enforce MFA on all users'),
$this->isMFAEnforced()
)
);
$checkbox->setDescription(null);
$this->updateCheckboxDescription($fields);
} | [
"public",
"function",
"updateCMSFields",
"(",
"FieldList",
"$",
"fields",
")",
"{",
"$",
"fields",
"->",
"addFieldToTab",
"(",
"'Root.MFA'",
",",
"$",
"checkbox",
"=",
"CheckboxField",
"::",
"create",
"(",
"'EnforceMFA'",
",",
"_t",
"(",
"self",
"::",
"class",
".",
"'.ENFORCEMFA'",
",",
"'Enforce MFA on all users'",
")",
",",
"$",
"this",
"->",
"isMFAEnforced",
"(",
")",
")",
")",
";",
"$",
"checkbox",
"->",
"setDescription",
"(",
"null",
")",
";",
"$",
"this",
"->",
"updateCheckboxDescription",
"(",
"$",
"fields",
")",
";",
"}"
] | Add the checkbox and if enabled the date since enforcement
@param FieldList $fields | [
"Add",
"the",
"checkbox",
"and",
"if",
"enabled",
"the",
"date",
"since",
"enforcement"
] | 8d2d6c6f2f918c8fa157da91550b897816495a4b | https://github.com/Firesphere/silverstripe-bootstrapmfa/blob/8d2d6c6f2f918c8fa157da91550b897816495a4b/src/Extensions/SiteConfigExtension.php#L31-L44 |
31,593 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopArticlePreviewImage.class.php | TShopArticlePreviewImage.LoadByName | public function LoadByName(&$oArticle, $sInternalName)
{
$bLoaded = false;
$this->oArticle = &$oArticle;
$this->oImageSize = TdbShopArticleImageSize::GetNewInstance();
/** @var $oImageSize TdbShopArticleImageSize */
if ($this->oImageSize->LoadFromField('name_internal', $sInternalName)) {
if ($this->LoadFromFields(array('shop_article_id' => $oArticle->id, 'shop_article_image_size_id' => $this->oImageSize->id))) {
$bLoaded = true;
} else {
$oPrimaryImage = $oArticle->GetPrimaryImage();
/** @var $oPrimaryImage TdbShopArticleImage */
if (!is_null($oPrimaryImage)) {
$aData = array('cms_media_id' => $oPrimaryImage->sqlData['cms_media_id'], 'shop_article_image_size_id' => $this->oImageSize->id, 'shop_article_id' => $oArticle->id);
$this->LoadFromRow($aData);
$bLoaded = true;
}
}
}
return $bLoaded;
} | php | public function LoadByName(&$oArticle, $sInternalName)
{
$bLoaded = false;
$this->oArticle = &$oArticle;
$this->oImageSize = TdbShopArticleImageSize::GetNewInstance();
/** @var $oImageSize TdbShopArticleImageSize */
if ($this->oImageSize->LoadFromField('name_internal', $sInternalName)) {
if ($this->LoadFromFields(array('shop_article_id' => $oArticle->id, 'shop_article_image_size_id' => $this->oImageSize->id))) {
$bLoaded = true;
} else {
$oPrimaryImage = $oArticle->GetPrimaryImage();
/** @var $oPrimaryImage TdbShopArticleImage */
if (!is_null($oPrimaryImage)) {
$aData = array('cms_media_id' => $oPrimaryImage->sqlData['cms_media_id'], 'shop_article_image_size_id' => $this->oImageSize->id, 'shop_article_id' => $oArticle->id);
$this->LoadFromRow($aData);
$bLoaded = true;
}
}
}
return $bLoaded;
} | [
"public",
"function",
"LoadByName",
"(",
"&",
"$",
"oArticle",
",",
"$",
"sInternalName",
")",
"{",
"$",
"bLoaded",
"=",
"false",
";",
"$",
"this",
"->",
"oArticle",
"=",
"&",
"$",
"oArticle",
";",
"$",
"this",
"->",
"oImageSize",
"=",
"TdbShopArticleImageSize",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oImageSize TdbShopArticleImageSize */",
"if",
"(",
"$",
"this",
"->",
"oImageSize",
"->",
"LoadFromField",
"(",
"'name_internal'",
",",
"$",
"sInternalName",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"LoadFromFields",
"(",
"array",
"(",
"'shop_article_id'",
"=>",
"$",
"oArticle",
"->",
"id",
",",
"'shop_article_image_size_id'",
"=>",
"$",
"this",
"->",
"oImageSize",
"->",
"id",
")",
")",
")",
"{",
"$",
"bLoaded",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"oPrimaryImage",
"=",
"$",
"oArticle",
"->",
"GetPrimaryImage",
"(",
")",
";",
"/** @var $oPrimaryImage TdbShopArticleImage */",
"if",
"(",
"!",
"is_null",
"(",
"$",
"oPrimaryImage",
")",
")",
"{",
"$",
"aData",
"=",
"array",
"(",
"'cms_media_id'",
"=>",
"$",
"oPrimaryImage",
"->",
"sqlData",
"[",
"'cms_media_id'",
"]",
",",
"'shop_article_image_size_id'",
"=>",
"$",
"this",
"->",
"oImageSize",
"->",
"id",
",",
"'shop_article_id'",
"=>",
"$",
"oArticle",
"->",
"id",
")",
";",
"$",
"this",
"->",
"LoadFromRow",
"(",
"$",
"aData",
")",
";",
"$",
"bLoaded",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"$",
"bLoaded",
";",
"}"
] | return the image preview object. if the shop did not define one for this size,
then we create a virtual instance based on the first image of the article.
@param TdbShopArticle $oArticle - the article object
@param string $sInternalName - image size name
@return true | [
"return",
"the",
"image",
"preview",
"object",
".",
"if",
"the",
"shop",
"did",
"not",
"define",
"one",
"for",
"this",
"size",
"then",
"we",
"create",
"a",
"virtual",
"instance",
"based",
"on",
"the",
"first",
"image",
"of",
"the",
"article",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopArticlePreviewImage.class.php#L44-L65 |
31,594 | chameleon-system/chameleon-shop | src/ShopBundle/objects/db/TShopArticlePreviewImage.class.php | TShopArticlePreviewImage.GetImageThumbnailObject | public function GetImageThumbnailObject($aEffects = array())
{
$oImageSize = &$this->GetImageSizeObject();
$oImage = &$this->GetImageObject();
$oThumb = null;
TdbCmsConfigImagemagick::SetEnableEffects(true);
$bEnableEffects = TdbCmsConfigImagemagick::GetEnableEffects();
if ($oImageSize->fieldForceSize) {
$oThumb = $oImage->GetForcedSizeThumbnail($oImageSize->fieldWidth, $oImageSize->fieldHeight);
} else {
$oThumb = $oImage->GetThumbnail($oImageSize->fieldWidth, $oImageSize->fieldHeight, true, $aEffects);
}
TdbCmsConfigImagemagick::SetEnableEffects($bEnableEffects);
return $oThumb;
} | php | public function GetImageThumbnailObject($aEffects = array())
{
$oImageSize = &$this->GetImageSizeObject();
$oImage = &$this->GetImageObject();
$oThumb = null;
TdbCmsConfigImagemagick::SetEnableEffects(true);
$bEnableEffects = TdbCmsConfigImagemagick::GetEnableEffects();
if ($oImageSize->fieldForceSize) {
$oThumb = $oImage->GetForcedSizeThumbnail($oImageSize->fieldWidth, $oImageSize->fieldHeight);
} else {
$oThumb = $oImage->GetThumbnail($oImageSize->fieldWidth, $oImageSize->fieldHeight, true, $aEffects);
}
TdbCmsConfigImagemagick::SetEnableEffects($bEnableEffects);
return $oThumb;
} | [
"public",
"function",
"GetImageThumbnailObject",
"(",
"$",
"aEffects",
"=",
"array",
"(",
")",
")",
"{",
"$",
"oImageSize",
"=",
"&",
"$",
"this",
"->",
"GetImageSizeObject",
"(",
")",
";",
"$",
"oImage",
"=",
"&",
"$",
"this",
"->",
"GetImageObject",
"(",
")",
";",
"$",
"oThumb",
"=",
"null",
";",
"TdbCmsConfigImagemagick",
"::",
"SetEnableEffects",
"(",
"true",
")",
";",
"$",
"bEnableEffects",
"=",
"TdbCmsConfigImagemagick",
"::",
"GetEnableEffects",
"(",
")",
";",
"if",
"(",
"$",
"oImageSize",
"->",
"fieldForceSize",
")",
"{",
"$",
"oThumb",
"=",
"$",
"oImage",
"->",
"GetForcedSizeThumbnail",
"(",
"$",
"oImageSize",
"->",
"fieldWidth",
",",
"$",
"oImageSize",
"->",
"fieldHeight",
")",
";",
"}",
"else",
"{",
"$",
"oThumb",
"=",
"$",
"oImage",
"->",
"GetThumbnail",
"(",
"$",
"oImageSize",
"->",
"fieldWidth",
",",
"$",
"oImageSize",
"->",
"fieldHeight",
",",
"true",
",",
"$",
"aEffects",
")",
";",
"}",
"TdbCmsConfigImagemagick",
"::",
"SetEnableEffects",
"(",
"$",
"bEnableEffects",
")",
";",
"return",
"$",
"oThumb",
";",
"}"
] | return thumbnail for current size.
@return TCMSImage | [
"return",
"thumbnail",
"for",
"current",
"size",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopBundle/objects/db/TShopArticlePreviewImage.class.php#L134-L150 |
31,595 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/WebModules/MTPkgShopWishlistCore/MTPkgShopWishlistCore.class.php | MTPkgShopWishlistCore.ExecuteSendFormMode | protected function ExecuteSendFormMode()
{
if (!is_array($this->aUserInput)) {
$this->aUserInput = array('to_name' => '', 'to_mail' => '', 'comment' => '');
}
$this->data['aUserInput'] = $this->aUserInput;
} | php | protected function ExecuteSendFormMode()
{
if (!is_array($this->aUserInput)) {
$this->aUserInput = array('to_name' => '', 'to_mail' => '', 'comment' => '');
}
$this->data['aUserInput'] = $this->aUserInput;
} | [
"protected",
"function",
"ExecuteSendFormMode",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"aUserInput",
")",
")",
"{",
"$",
"this",
"->",
"aUserInput",
"=",
"array",
"(",
"'to_name'",
"=>",
"''",
",",
"'to_mail'",
"=>",
"''",
",",
"'comment'",
"=>",
"''",
")",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"'aUserInput'",
"]",
"=",
"$",
"this",
"->",
"aUserInput",
";",
"}"
] | Execute method called when the module is in the SendForm mode. | [
"Execute",
"method",
"called",
"when",
"the",
"module",
"is",
"in",
"the",
"SendForm",
"mode",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/WebModules/MTPkgShopWishlistCore/MTPkgShopWishlistCore.class.php#L73-L79 |
31,596 | chameleon-system/chameleon-shop | src/ShopWishlistBundle/objects/WebModules/MTPkgShopWishlistCore/MTPkgShopWishlistCore.class.php | MTPkgShopWishlistCore.UpdateWishlist | protected function UpdateWishlist()
{
$aInput = $this->global->GetUserData(TdbPkgShopWishlist::URL_PARAMETER_FILTER_DATA);
$sWishListDescription = '';
if (array_key_exists('description', $aInput)) {
$sWishListDescription = $aInput['description'];
}
$oMsgManager = TCMSMessageManager::GetInstance();
$oUser = TdbDataExtranetUser::GetInstance();
if ($oUser->IsLoggedIn()) {
$oWishlist = &$oUser->GetWishlist(true);
$aTmp = $oWishlist->sqlData;
$aTmp['description'] = $sWishListDescription;
if (array_key_exists('is_public', $aInput)) {
$aTmp['is_public'] = $aInput['is_public'];
}
$oWishlist->LoadFromRow($aTmp);
$oWishlist->Save();
$aItems = array();
if (array_key_exists('aItem', $aInput) && is_array($aInput['aItem'])) {
$aItems = $aInput['aItem'];
foreach ($aItems as $sWishlistItemId => $aItemData) {
$oWishlistItem = TdbPkgShopWishlistArticle::GetNewInstance();
/** @var $oWishlistItem TdbPkgShopWishlistArticle */
if ($oWishlistItem->LoadFromFields(array('pkg_shop_wishlist_id' => $oWishlist->id, 'id' => $sWishlistItemId))) {
$atmpData = $oWishlistItem->sqlData;
if (array_key_exists('comment', $aItemData)) {
$atmpData['comment'] = $aItemData['comment'];
}
if (array_key_exists('amount', $aItemData)) {
$atmpData['amount'] = $aItemData['amount'];
}
$oWishlistItem->LoadFromRow($atmpData);
$oWishlistItem->AllowEditByAll(true);
$oWishlistItem->Save();
}
}
}
$oMsgManager->AddMessage($oWishlist->GetMsgConsumerName(), 'WISHLIST-UPDATED-INFOS');
}
} | php | protected function UpdateWishlist()
{
$aInput = $this->global->GetUserData(TdbPkgShopWishlist::URL_PARAMETER_FILTER_DATA);
$sWishListDescription = '';
if (array_key_exists('description', $aInput)) {
$sWishListDescription = $aInput['description'];
}
$oMsgManager = TCMSMessageManager::GetInstance();
$oUser = TdbDataExtranetUser::GetInstance();
if ($oUser->IsLoggedIn()) {
$oWishlist = &$oUser->GetWishlist(true);
$aTmp = $oWishlist->sqlData;
$aTmp['description'] = $sWishListDescription;
if (array_key_exists('is_public', $aInput)) {
$aTmp['is_public'] = $aInput['is_public'];
}
$oWishlist->LoadFromRow($aTmp);
$oWishlist->Save();
$aItems = array();
if (array_key_exists('aItem', $aInput) && is_array($aInput['aItem'])) {
$aItems = $aInput['aItem'];
foreach ($aItems as $sWishlistItemId => $aItemData) {
$oWishlistItem = TdbPkgShopWishlistArticle::GetNewInstance();
/** @var $oWishlistItem TdbPkgShopWishlistArticle */
if ($oWishlistItem->LoadFromFields(array('pkg_shop_wishlist_id' => $oWishlist->id, 'id' => $sWishlistItemId))) {
$atmpData = $oWishlistItem->sqlData;
if (array_key_exists('comment', $aItemData)) {
$atmpData['comment'] = $aItemData['comment'];
}
if (array_key_exists('amount', $aItemData)) {
$atmpData['amount'] = $aItemData['amount'];
}
$oWishlistItem->LoadFromRow($atmpData);
$oWishlistItem->AllowEditByAll(true);
$oWishlistItem->Save();
}
}
}
$oMsgManager->AddMessage($oWishlist->GetMsgConsumerName(), 'WISHLIST-UPDATED-INFOS');
}
} | [
"protected",
"function",
"UpdateWishlist",
"(",
")",
"{",
"$",
"aInput",
"=",
"$",
"this",
"->",
"global",
"->",
"GetUserData",
"(",
"TdbPkgShopWishlist",
"::",
"URL_PARAMETER_FILTER_DATA",
")",
";",
"$",
"sWishListDescription",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'description'",
",",
"$",
"aInput",
")",
")",
"{",
"$",
"sWishListDescription",
"=",
"$",
"aInput",
"[",
"'description'",
"]",
";",
"}",
"$",
"oMsgManager",
"=",
"TCMSMessageManager",
"::",
"GetInstance",
"(",
")",
";",
"$",
"oUser",
"=",
"TdbDataExtranetUser",
"::",
"GetInstance",
"(",
")",
";",
"if",
"(",
"$",
"oUser",
"->",
"IsLoggedIn",
"(",
")",
")",
"{",
"$",
"oWishlist",
"=",
"&",
"$",
"oUser",
"->",
"GetWishlist",
"(",
"true",
")",
";",
"$",
"aTmp",
"=",
"$",
"oWishlist",
"->",
"sqlData",
";",
"$",
"aTmp",
"[",
"'description'",
"]",
"=",
"$",
"sWishListDescription",
";",
"if",
"(",
"array_key_exists",
"(",
"'is_public'",
",",
"$",
"aInput",
")",
")",
"{",
"$",
"aTmp",
"[",
"'is_public'",
"]",
"=",
"$",
"aInput",
"[",
"'is_public'",
"]",
";",
"}",
"$",
"oWishlist",
"->",
"LoadFromRow",
"(",
"$",
"aTmp",
")",
";",
"$",
"oWishlist",
"->",
"Save",
"(",
")",
";",
"$",
"aItems",
"=",
"array",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'aItem'",
",",
"$",
"aInput",
")",
"&&",
"is_array",
"(",
"$",
"aInput",
"[",
"'aItem'",
"]",
")",
")",
"{",
"$",
"aItems",
"=",
"$",
"aInput",
"[",
"'aItem'",
"]",
";",
"foreach",
"(",
"$",
"aItems",
"as",
"$",
"sWishlistItemId",
"=>",
"$",
"aItemData",
")",
"{",
"$",
"oWishlistItem",
"=",
"TdbPkgShopWishlistArticle",
"::",
"GetNewInstance",
"(",
")",
";",
"/** @var $oWishlistItem TdbPkgShopWishlistArticle */",
"if",
"(",
"$",
"oWishlistItem",
"->",
"LoadFromFields",
"(",
"array",
"(",
"'pkg_shop_wishlist_id'",
"=>",
"$",
"oWishlist",
"->",
"id",
",",
"'id'",
"=>",
"$",
"sWishlistItemId",
")",
")",
")",
"{",
"$",
"atmpData",
"=",
"$",
"oWishlistItem",
"->",
"sqlData",
";",
"if",
"(",
"array_key_exists",
"(",
"'comment'",
",",
"$",
"aItemData",
")",
")",
"{",
"$",
"atmpData",
"[",
"'comment'",
"]",
"=",
"$",
"aItemData",
"[",
"'comment'",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'amount'",
",",
"$",
"aItemData",
")",
")",
"{",
"$",
"atmpData",
"[",
"'amount'",
"]",
"=",
"$",
"aItemData",
"[",
"'amount'",
"]",
";",
"}",
"$",
"oWishlistItem",
"->",
"LoadFromRow",
"(",
"$",
"atmpData",
")",
";",
"$",
"oWishlistItem",
"->",
"AllowEditByAll",
"(",
"true",
")",
";",
"$",
"oWishlistItem",
"->",
"Save",
"(",
")",
";",
"}",
"}",
"}",
"$",
"oMsgManager",
"->",
"AddMessage",
"(",
"$",
"oWishlist",
"->",
"GetMsgConsumerName",
"(",
")",
",",
"'WISHLIST-UPDATED-INFOS'",
")",
";",
"}",
"}"
] | Updates the wishlist comment, the lists item amount an comments using the data from post. | [
"Updates",
"the",
"wishlist",
"comment",
"the",
"lists",
"item",
"amount",
"an",
"comments",
"using",
"the",
"data",
"from",
"post",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopWishlistBundle/objects/WebModules/MTPkgShopWishlistCore/MTPkgShopWishlistCore.class.php#L151-L195 |
31,597 | chameleon-system/chameleon-shop | src/ShopPrimaryNavigationBundle/pkgCmsNavigation/objects/TPkgShopPrimaryNavigation_TPkgCmsNavigationNode_Category.class.php | TPkgShopPrimaryNavigation_TPkgCmsNavigationNode_Category.getNodeIconURL | public function getNodeIconURL()
{
$sURL = null;
/** @var $oNode TdbShopCategory */
$oNode = $this->getNodeCopy();
$oImage = $oNode->GetImage(0, 'navi_icon_cms_media_id', $this->dummyImagesAllowed());
if ($oImage) {
$sURL = $oImage->GetRelativeURL();
$this->sNavigationIconId = $oImage->id;
}
return $sURL;
} | php | public function getNodeIconURL()
{
$sURL = null;
/** @var $oNode TdbShopCategory */
$oNode = $this->getNodeCopy();
$oImage = $oNode->GetImage(0, 'navi_icon_cms_media_id', $this->dummyImagesAllowed());
if ($oImage) {
$sURL = $oImage->GetRelativeURL();
$this->sNavigationIconId = $oImage->id;
}
return $sURL;
} | [
"public",
"function",
"getNodeIconURL",
"(",
")",
"{",
"$",
"sURL",
"=",
"null",
";",
"/** @var $oNode TdbShopCategory */",
"$",
"oNode",
"=",
"$",
"this",
"->",
"getNodeCopy",
"(",
")",
";",
"$",
"oImage",
"=",
"$",
"oNode",
"->",
"GetImage",
"(",
"0",
",",
"'navi_icon_cms_media_id'",
",",
"$",
"this",
"->",
"dummyImagesAllowed",
"(",
")",
")",
";",
"if",
"(",
"$",
"oImage",
")",
"{",
"$",
"sURL",
"=",
"$",
"oImage",
"->",
"GetRelativeURL",
"(",
")",
";",
"$",
"this",
"->",
"sNavigationIconId",
"=",
"$",
"oImage",
"->",
"id",
";",
"}",
"return",
"$",
"sURL",
";",
"}"
] | returns the url to an icon for the node - if set.
@return string|null | [
"returns",
"the",
"url",
"to",
"an",
"icon",
"for",
"the",
"node",
"-",
"if",
"set",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopPrimaryNavigationBundle/pkgCmsNavigation/objects/TPkgShopPrimaryNavigation_TPkgCmsNavigationNode_Category.class.php#L134-L146 |
31,598 | chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/db/TPkgShopArticleReviewShopArticleReview.class.php | TPkgShopArticleReviewShopArticleReview.GetRateURL | public function GetRateURL($bPositiveLink = true, $bUseFullUrl = false)
{
if ($bPositiveLink) {
$bPositiveLink = '1';
} else {
$bPositiveLink = '0';
}
$aParameter = array('bRate' => $bPositiveLink, TdbShopArticleReview::URL_PARAM_REVIEW_ID => $this->id);
$sRatePositiveLink = TTools::GetExecuteMethodOnCurrentModuleURL('RateReview', $aParameter, $bUseFullUrl);
return $sRatePositiveLink;
} | php | public function GetRateURL($bPositiveLink = true, $bUseFullUrl = false)
{
if ($bPositiveLink) {
$bPositiveLink = '1';
} else {
$bPositiveLink = '0';
}
$aParameter = array('bRate' => $bPositiveLink, TdbShopArticleReview::URL_PARAM_REVIEW_ID => $this->id);
$sRatePositiveLink = TTools::GetExecuteMethodOnCurrentModuleURL('RateReview', $aParameter, $bUseFullUrl);
return $sRatePositiveLink;
} | [
"public",
"function",
"GetRateURL",
"(",
"$",
"bPositiveLink",
"=",
"true",
",",
"$",
"bUseFullUrl",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"bPositiveLink",
")",
"{",
"$",
"bPositiveLink",
"=",
"'1'",
";",
"}",
"else",
"{",
"$",
"bPositiveLink",
"=",
"'0'",
";",
"}",
"$",
"aParameter",
"=",
"array",
"(",
"'bRate'",
"=>",
"$",
"bPositiveLink",
",",
"TdbShopArticleReview",
"::",
"URL_PARAM_REVIEW_ID",
"=>",
"$",
"this",
"->",
"id",
")",
";",
"$",
"sRatePositiveLink",
"=",
"TTools",
"::",
"GetExecuteMethodOnCurrentModuleURL",
"(",
"'RateReview'",
",",
"$",
"aParameter",
",",
"$",
"bUseFullUrl",
")",
";",
"return",
"$",
"sRatePositiveLink",
";",
"}"
] | Returns URL to rate a comment.
@param bool $bPositiveLink Set if you want the url to rate a review positive or negative
@param bool $bUseFullUrl
@return string | [
"Returns",
"URL",
"to",
"rate",
"a",
"comment",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/db/TPkgShopArticleReviewShopArticleReview.class.php#L28-L39 |
31,599 | chameleon-system/chameleon-shop | src/ShopArticleReviewBundle/objects/db/TPkgShopArticleReviewShopArticleReview.class.php | TPkgShopArticleReviewShopArticleReview.RateReview | public function RateReview($bRateUp = true)
{
if (false == $this->ReviewRatedByActiveUser()) {
$sRateString = 'helpful_count';
//helpful_count
//not_helpful_count
if (false == $bRateUp) {
$sRateString = 'not_helpful_count';
}
$query = 'UPDATE `'.MySqlLegacySupport::getInstance()->real_escape_string($this->table)."`
SET `{$sRateString}` = `{$sRateString}`+1
WHERE `id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
LIMIT 1
";
MySqlLegacySupport::getInstance()->query($query);
// get value from disc
$query = "SELECT `{$sRateString}` FROM `".MySqlLegacySupport::getInstance()->real_escape_string($this->table)."` WHERE `id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'";
if ($aTmp = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
$this->sqlData[$sRateString] = $aTmp[$sRateString];
if ($bRateUp) {
$this->fieldHelpfulCount = $this->sqlData[$sRateString];
} else {
$this->fieldNotHelpfulCount = $this->sqlData[$sRateString];
}
}
if (!array_key_exists('TPkgShopArticleReviewShopArticleReviewRated', $_SESSION)) {
$_SESSION['TPkgShopArticleReviewShopArticleReviewRated'] = array();
}
$_SESSION['TPkgShopArticleReviewShopArticleReviewRated'][(string) $this->id] = time();
}
} | php | public function RateReview($bRateUp = true)
{
if (false == $this->ReviewRatedByActiveUser()) {
$sRateString = 'helpful_count';
//helpful_count
//not_helpful_count
if (false == $bRateUp) {
$sRateString = 'not_helpful_count';
}
$query = 'UPDATE `'.MySqlLegacySupport::getInstance()->real_escape_string($this->table)."`
SET `{$sRateString}` = `{$sRateString}`+1
WHERE `id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'
LIMIT 1
";
MySqlLegacySupport::getInstance()->query($query);
// get value from disc
$query = "SELECT `{$sRateString}` FROM `".MySqlLegacySupport::getInstance()->real_escape_string($this->table)."` WHERE `id` = '".MySqlLegacySupport::getInstance()->real_escape_string($this->id)."'";
if ($aTmp = MySqlLegacySupport::getInstance()->fetch_assoc(MySqlLegacySupport::getInstance()->query($query))) {
$this->sqlData[$sRateString] = $aTmp[$sRateString];
if ($bRateUp) {
$this->fieldHelpfulCount = $this->sqlData[$sRateString];
} else {
$this->fieldNotHelpfulCount = $this->sqlData[$sRateString];
}
}
if (!array_key_exists('TPkgShopArticleReviewShopArticleReviewRated', $_SESSION)) {
$_SESSION['TPkgShopArticleReviewShopArticleReviewRated'] = array();
}
$_SESSION['TPkgShopArticleReviewShopArticleReviewRated'][(string) $this->id] = time();
}
} | [
"public",
"function",
"RateReview",
"(",
"$",
"bRateUp",
"=",
"true",
")",
"{",
"if",
"(",
"false",
"==",
"$",
"this",
"->",
"ReviewRatedByActiveUser",
"(",
")",
")",
"{",
"$",
"sRateString",
"=",
"'helpful_count'",
";",
"//helpful_count",
"//not_helpful_count",
"if",
"(",
"false",
"==",
"$",
"bRateUp",
")",
"{",
"$",
"sRateString",
"=",
"'not_helpful_count'",
";",
"}",
"$",
"query",
"=",
"'UPDATE `'",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"this",
"->",
"table",
")",
".",
"\"`\n SET `{$sRateString}` = `{$sRateString}`+1\n WHERE `id` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"this",
"->",
"id",
")",
".",
"\"'\n LIMIT 1\n \"",
";",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
";",
"// get value from disc",
"$",
"query",
"=",
"\"SELECT `{$sRateString}` FROM `\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"this",
"->",
"table",
")",
".",
"\"` WHERE `id` = '\"",
".",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"real_escape_string",
"(",
"$",
"this",
"->",
"id",
")",
".",
"\"'\"",
";",
"if",
"(",
"$",
"aTmp",
"=",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"fetch_assoc",
"(",
"MySqlLegacySupport",
"::",
"getInstance",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
")",
")",
"{",
"$",
"this",
"->",
"sqlData",
"[",
"$",
"sRateString",
"]",
"=",
"$",
"aTmp",
"[",
"$",
"sRateString",
"]",
";",
"if",
"(",
"$",
"bRateUp",
")",
"{",
"$",
"this",
"->",
"fieldHelpfulCount",
"=",
"$",
"this",
"->",
"sqlData",
"[",
"$",
"sRateString",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"fieldNotHelpfulCount",
"=",
"$",
"this",
"->",
"sqlData",
"[",
"$",
"sRateString",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'TPkgShopArticleReviewShopArticleReviewRated'",
",",
"$",
"_SESSION",
")",
")",
"{",
"$",
"_SESSION",
"[",
"'TPkgShopArticleReviewShopArticleReviewRated'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"_SESSION",
"[",
"'TPkgShopArticleReviewShopArticleReviewRated'",
"]",
"[",
"(",
"string",
")",
"$",
"this",
"->",
"id",
"]",
"=",
"time",
"(",
")",
";",
"}",
"}"
] | vote the review up or down.
@param bool $bRateUp | [
"vote",
"the",
"review",
"up",
"or",
"down",
"."
] | 2e47f4eeab604449605ee1867180c9a37a8c208e | https://github.com/chameleon-system/chameleon-shop/blob/2e47f4eeab604449605ee1867180c9a37a8c208e/src/ShopArticleReviewBundle/objects/db/TPkgShopArticleReviewShopArticleReview.class.php#L56-L86 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.