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
partition
stringclasses
1 value
lovata/oc-toolbox-plugin
classes/store/AbstractStore.php
AbstractStore.getIDListFromCache
protected function getIDListFromCache() : array { $arCacheTags = $this->getCacheTagList(); $sCacheKey = $this->getCacheKey(); $arElementIDList = (array) CCache::get($arCacheTags, $sCacheKey); return $arElementIDList; }
php
protected function getIDListFromCache() : array { $arCacheTags = $this->getCacheTagList(); $sCacheKey = $this->getCacheKey(); $arElementIDList = (array) CCache::get($arCacheTags, $sCacheKey); return $arElementIDList; }
[ "protected", "function", "getIDListFromCache", "(", ")", ":", "array", "{", "$", "arCacheTags", "=", "$", "this", "->", "getCacheTagList", "(", ")", ";", "$", "sCacheKey", "=", "$", "this", "->", "getCacheKey", "(", ")", ";", "$", "arElementIDList", "=", ...
Get element ID list from array @return array|null
[ "Get", "element", "ID", "list", "from", "array" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/store/AbstractStore.php#L50-L58
train
lovata/oc-toolbox-plugin
classes/store/AbstractStore.php
AbstractStore.saveIDList
protected function saveIDList($arElementIDList) { $arCacheTags = $this->getCacheTagList(); $sCacheKey = $this->getCacheKey(); //Set cache data CCache::forever($arCacheTags, $sCacheKey, $arElementIDList); }
php
protected function saveIDList($arElementIDList) { $arCacheTags = $this->getCacheTagList(); $sCacheKey = $this->getCacheKey(); //Set cache data CCache::forever($arCacheTags, $sCacheKey, $arElementIDList); }
[ "protected", "function", "saveIDList", "(", "$", "arElementIDList", ")", "{", "$", "arCacheTags", "=", "$", "this", "->", "getCacheTagList", "(", ")", ";", "$", "sCacheKey", "=", "$", "this", "->", "getCacheKey", "(", ")", ";", "//Set cache data", "CCache", ...
Save element ID list in cache @param array $arElementIDList
[ "Save", "element", "ID", "list", "in", "cache" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/store/AbstractStore.php#L64-L71
train
lovata/oc-toolbox-plugin
classes/store/AbstractStore.php
AbstractStore.clearIDList
protected function clearIDList() { $arCacheTags = $this->getCacheTagList(); $sCacheKey = $this->getCacheKey(); CCache::clear($arCacheTags, $sCacheKey); }
php
protected function clearIDList() { $arCacheTags = $this->getCacheTagList(); $sCacheKey = $this->getCacheKey(); CCache::clear($arCacheTags, $sCacheKey); }
[ "protected", "function", "clearIDList", "(", ")", "{", "$", "arCacheTags", "=", "$", "this", "->", "getCacheTagList", "(", ")", ";", "$", "sCacheKey", "=", "$", "this", "->", "getCacheKey", "(", ")", ";", "CCache", "::", "clear", "(", "$", "arCacheTags",...
Clear element ID list in cache
[ "Clear", "element", "ID", "list", "in", "cache" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/store/AbstractStore.php#L76-L82
train
lovata/oc-toolbox-plugin
components/Pagination.php
Pagination.init
public function init() { $arAvailableValue = []; $sAvailableValue = $this->property('available_count_per_page'); if (!empty($sAvailableValue)) { $arAvailableValue = explode(',', $sAvailableValue); } //Get limit from request $iLimit = (int) Input::get('limit'); if ($iLimit > 0 && (empty($arAvailableValue) || in_array($iLimit, $arAvailableValue))) { $this->iElementOnPage = $iLimit; return; } $iRequestElementOnPage = (int) $this->property('count_per_page'); if ($iRequestElementOnPage > 0) { $this->iElementOnPage = $iRequestElementOnPage; } }
php
public function init() { $arAvailableValue = []; $sAvailableValue = $this->property('available_count_per_page'); if (!empty($sAvailableValue)) { $arAvailableValue = explode(',', $sAvailableValue); } //Get limit from request $iLimit = (int) Input::get('limit'); if ($iLimit > 0 && (empty($arAvailableValue) || in_array($iLimit, $arAvailableValue))) { $this->iElementOnPage = $iLimit; return; } $iRequestElementOnPage = (int) $this->property('count_per_page'); if ($iRequestElementOnPage > 0) { $this->iElementOnPage = $iRequestElementOnPage; } }
[ "public", "function", "init", "(", ")", "{", "$", "arAvailableValue", "=", "[", "]", ";", "$", "sAvailableValue", "=", "$", "this", "->", "property", "(", "'available_count_per_page'", ")", ";", "if", "(", "!", "empty", "(", "$", "sAvailableValue", ")", ...
Init start data
[ "Init", "start", "data" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/components/Pagination.php#L50-L70
train
lovata/oc-toolbox-plugin
components/Pagination.php
Pagination.get
public function get($iPage, $iCount) { if ($iCount < 1) { return null; } $iPage = (int) trim($iPage); //Check page value if ($iPage < 1) { $iPage = 1; } $this->properties['count_per_page'] = $this->iElementOnPage; return PaginationHelper::get($iPage, $iCount, $this->properties); }
php
public function get($iPage, $iCount) { if ($iCount < 1) { return null; } $iPage = (int) trim($iPage); //Check page value if ($iPage < 1) { $iPage = 1; } $this->properties['count_per_page'] = $this->iElementOnPage; return PaginationHelper::get($iPage, $iCount, $this->properties); }
[ "public", "function", "get", "(", "$", "iPage", ",", "$", "iCount", ")", "{", "if", "(", "$", "iCount", "<", "1", ")", "{", "return", "null", ";", "}", "$", "iPage", "=", "(", "int", ")", "trim", "(", "$", "iPage", ")", ";", "//Check page value",...
Get pagination data @param int $iPage @param int $iCount @return array|null
[ "Get", "pagination", "data" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/components/Pagination.php#L151-L167
train
lovata/oc-toolbox-plugin
classes/item/ItemStorage.php
ItemStorage.get
public static function get($sClassName, $iElementID) { $sKey = self::getKey($sClassName, $iElementID); if (isset(self::$arItemStore[$sKey]) && self::$arItemStore[$sKey] instanceof ElementItem) { return clone self::$arItemStore[$sKey]; } return null; }
php
public static function get($sClassName, $iElementID) { $sKey = self::getKey($sClassName, $iElementID); if (isset(self::$arItemStore[$sKey]) && self::$arItemStore[$sKey] instanceof ElementItem) { return clone self::$arItemStore[$sKey]; } return null; }
[ "public", "static", "function", "get", "(", "$", "sClassName", ",", "$", "iElementID", ")", "{", "$", "sKey", "=", "self", "::", "getKey", "(", "$", "sClassName", ",", "$", "iElementID", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "arItemSt...
Get item object from storage @param string $sClassName @param int $iElementID @return ElementItem|null
[ "Get", "item", "object", "from", "storage" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ItemStorage.php#L19-L27
train
lovata/oc-toolbox-plugin
classes/item/ItemStorage.php
ItemStorage.set
public static function set($sClassName, $iElementID, $obItem) { if (empty($obItem) || $obItem->isEmpty()) { return; } $sKey = self::getKey($sClassName, $iElementID); self::$arItemStore[$sKey] = clone $obItem; }
php
public static function set($sClassName, $iElementID, $obItem) { if (empty($obItem) || $obItem->isEmpty()) { return; } $sKey = self::getKey($sClassName, $iElementID); self::$arItemStore[$sKey] = clone $obItem; }
[ "public", "static", "function", "set", "(", "$", "sClassName", ",", "$", "iElementID", ",", "$", "obItem", ")", "{", "if", "(", "empty", "(", "$", "obItem", ")", "||", "$", "obItem", "->", "isEmpty", "(", ")", ")", "{", "return", ";", "}", "$", "...
Set item object in storage @param string $sClassName @param int $iElementID @param ElementItem $obItem
[ "Set", "item", "object", "in", "storage" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ItemStorage.php#L35-L43
train
lovata/oc-toolbox-plugin
classes/item/ItemStorage.php
ItemStorage.clear
public static function clear($sClassName, $iElementID) { $sKey = self::getKey($sClassName, $iElementID); if (!isset(self::$arItemStore[$sKey])) { return; } unset(self::$arItemStore[$sKey]); }
php
public static function clear($sClassName, $iElementID) { $sKey = self::getKey($sClassName, $iElementID); if (!isset(self::$arItemStore[$sKey])) { return; } unset(self::$arItemStore[$sKey]); }
[ "public", "static", "function", "clear", "(", "$", "sClassName", ",", "$", "iElementID", ")", "{", "$", "sKey", "=", "self", "::", "getKey", "(", "$", "sClassName", ",", "$", "iElementID", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", ...
Clear item object in storage @param string $sClassName @param int $iElementID
[ "Clear", "item", "object", "in", "storage" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/ItemStorage.php#L50-L58
train
lovata/oc-toolbox-plugin
classes/helper/UserHelper.php
UserHelper.getUser
public function getUser() { if (empty($this->obHelper)) { return null; } $sAuthFacadeClass = $this->obHelper->getAuthFacade(); return $sAuthFacadeClass::getUser(); }
php
public function getUser() { if (empty($this->obHelper)) { return null; } $sAuthFacadeClass = $this->obHelper->getAuthFacade(); return $sAuthFacadeClass::getUser(); }
[ "public", "function", "getUser", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "obHelper", ")", ")", "{", "return", "null", ";", "}", "$", "sAuthFacadeClass", "=", "$", "this", "->", "obHelper", "->", "getAuthFacade", "(", ")", ";", "ret...
Get auth user object @return \Lovata\Buddies\Models\User|\RainLab\User\Models\User|null
[ "Get", "auth", "user", "object" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/helper/UserHelper.php#L28-L37
train
lovata/oc-toolbox-plugin
classes/event/ModelHandler.php
ModelHandler.clearItemCache
protected function clearItemCache() { $sItemClass = $this->getItemClass(); $sField = $this->sIdentifierField; $sItemClass::clearCache($this->obElement->$sField); }
php
protected function clearItemCache() { $sItemClass = $this->getItemClass(); $sField = $this->sIdentifierField; $sItemClass::clearCache($this->obElement->$sField); }
[ "protected", "function", "clearItemCache", "(", ")", "{", "$", "sItemClass", "=", "$", "this", "->", "getItemClass", "(", ")", ";", "$", "sField", "=", "$", "this", "->", "sIdentifierField", ";", "$", "sItemClass", "::", "clearCache", "(", "$", "this", "...
Clear item cache
[ "Clear", "item", "cache" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/event/ModelHandler.php#L116-L122
train
lovata/oc-toolbox-plugin
classes/event/ModelHandler.php
ModelHandler.clearCacheNotEmptyValue
protected function clearCacheNotEmptyValue($sField, $obListStore) { if (empty($sField) || empty($obListStore) || empty($this->obElement->$sField)) { return; } if ($obListStore instanceof AbstractStoreWithoutParam) { $obListStore->clear(); } elseif ($obListStore instanceof AbstractStoreWithParam) { $obListStore->clear($this->obElement->$sField); } }
php
protected function clearCacheNotEmptyValue($sField, $obListStore) { if (empty($sField) || empty($obListStore) || empty($this->obElement->$sField)) { return; } if ($obListStore instanceof AbstractStoreWithoutParam) { $obListStore->clear(); } elseif ($obListStore instanceof AbstractStoreWithParam) { $obListStore->clear($this->obElement->$sField); } }
[ "protected", "function", "clearCacheNotEmptyValue", "(", "$", "sField", ",", "$", "obListStore", ")", "{", "if", "(", "empty", "(", "$", "sField", ")", "||", "empty", "(", "$", "obListStore", ")", "||", "empty", "(", "$", "this", "->", "obElement", "->",...
If field has not empty value, then cache clear by value @param string $sField @param AbstractStoreWithParam|AbstractStoreWithoutParam $obListStore
[ "If", "field", "has", "not", "empty", "value", "then", "cache", "clear", "by", "value" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/event/ModelHandler.php#L148-L159
train
lovata/oc-toolbox-plugin
classes/event/ModelHandler.php
ModelHandler.clearCacheEmptyValue
protected function clearCacheEmptyValue($sField, $obListStore) { if (empty($sField) || empty($obListStore) || !empty($this->obElement->$sField) || ! $obListStore instanceof AbstractStoreWithoutParam) { return; } $obListStore->clear(); }
php
protected function clearCacheEmptyValue($sField, $obListStore) { if (empty($sField) || empty($obListStore) || !empty($this->obElement->$sField) || ! $obListStore instanceof AbstractStoreWithoutParam) { return; } $obListStore->clear(); }
[ "protected", "function", "clearCacheEmptyValue", "(", "$", "sField", ",", "$", "obListStore", ")", "{", "if", "(", "empty", "(", "$", "sField", ")", "||", "empty", "(", "$", "obListStore", ")", "||", "!", "empty", "(", "$", "this", "->", "obElement", "...
If field has empty value, then cache clear by value @param string $sField @param AbstractStoreWithoutParam $obListStore
[ "If", "field", "has", "empty", "value", "then", "cache", "clear", "by", "value" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/event/ModelHandler.php#L166-L173
train
lovata/oc-toolbox-plugin
classes/storage/UserStorage.php
UserStorage.setDefaultStorage
public function setDefaultStorage($obUserStorage, $iMinutePeriod = 1440) { if (empty($obUserStorage)) { return; } $this->obDefaultStorage = app($obUserStorage); if (!empty($this->obDefaultStorage) && $this->obDefaultStorage instanceof CookieUserStorage) { $this->obDefaultStorage->setMinutePeriod($iMinutePeriod); } }
php
public function setDefaultStorage($obUserStorage, $iMinutePeriod = 1440) { if (empty($obUserStorage)) { return; } $this->obDefaultStorage = app($obUserStorage); if (!empty($this->obDefaultStorage) && $this->obDefaultStorage instanceof CookieUserStorage) { $this->obDefaultStorage->setMinutePeriod($iMinutePeriod); } }
[ "public", "function", "setDefaultStorage", "(", "$", "obUserStorage", ",", "$", "iMinutePeriod", "=", "1440", ")", "{", "if", "(", "empty", "(", "$", "obUserStorage", ")", ")", "{", "return", ";", "}", "$", "this", "->", "obDefaultStorage", "=", "app", "...
Set default user storage @param string $obUserStorage @param int $iMinutePeriod
[ "Set", "default", "user", "storage" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/storage/UserStorage.php#L20-L30
train
lovata/oc-toolbox-plugin
classes/storage/UserStorage.php
UserStorage.clear
public function clear($sKey) { if (empty($sKey)) { return; } $this->clearDefaultStorageValue($sKey); //Get auth user object $obUser = UserHelper::instance()->getUser(); if (empty($obUser)) { return; } $obUser->$sKey = null; $obUser->save(); }
php
public function clear($sKey) { if (empty($sKey)) { return; } $this->clearDefaultStorageValue($sKey); //Get auth user object $obUser = UserHelper::instance()->getUser(); if (empty($obUser)) { return; } $obUser->$sKey = null; $obUser->save(); }
[ "public", "function", "clear", "(", "$", "sKey", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", ")", "{", "return", ";", "}", "$", "this", "->", "clearDefaultStorageValue", "(", "$", "sKey", ")", ";", "//Get auth user object", "$", "obUser", "=",...
Clear value in storage @param string $sKey
[ "Clear", "value", "in", "storage" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/storage/UserStorage.php#L87-L103
train
lovata/oc-toolbox-plugin
classes/storage/UserStorage.php
UserStorage.getList
public function getList($sKey) { if (empty($sKey)) { return []; } $arDefaultStorageValue = $this->getListDefaultStorageValue($sKey); //Get auth user object $obUser = UserHelper::instance()->getUser(); if (empty($obUser)) { return $arDefaultStorageValue; } //Get value from user object $arValueList = $obUser->$sKey; if (empty($arValueList) || !is_array($arValueList)) { $arValueList = []; } if (!empty($arDefaultStorageValue)) { $arValueList = array_merge($arDefaultStorageValue, $arValueList); $arValueList = array_unique($arValueList); $this->put($sKey, $arValueList); $this->clearDefaultStorageValue($sKey); } return $arValueList; }
php
public function getList($sKey) { if (empty($sKey)) { return []; } $arDefaultStorageValue = $this->getListDefaultStorageValue($sKey); //Get auth user object $obUser = UserHelper::instance()->getUser(); if (empty($obUser)) { return $arDefaultStorageValue; } //Get value from user object $arValueList = $obUser->$sKey; if (empty($arValueList) || !is_array($arValueList)) { $arValueList = []; } if (!empty($arDefaultStorageValue)) { $arValueList = array_merge($arDefaultStorageValue, $arValueList); $arValueList = array_unique($arValueList); $this->put($sKey, $arValueList); $this->clearDefaultStorageValue($sKey); } return $arValueList; }
[ "public", "function", "getList", "(", "$", "sKey", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", ")", "{", "return", "[", "]", ";", "}", "$", "arDefaultStorageValue", "=", "$", "this", "->", "getListDefaultStorageValue", "(", "$", "sKey", ")", ...
Get list value from storage @param string $sKey @return array
[ "Get", "list", "value", "from", "storage" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/storage/UserStorage.php#L110-L139
train
lovata/oc-toolbox-plugin
classes/component/ComponentSubmitForm.php
ComponentSubmitForm.getModeProperty
protected function getModeProperty() { $arResult = [ self::PROPERTY_MODE => [ 'title' => 'lovata.toolbox::lang.component.property_mode', 'type' => 'dropdown', 'options' => [ self::MODE_SUBMIT => Lang::get('lovata.toolbox::lang.component.mode_'.self::MODE_SUBMIT), self::MODE_AJAX => Lang::get('lovata.toolbox::lang.component.mode_'.self::MODE_AJAX), ], ], self::PROPERTY_FLASH_ON => [ 'title' => 'lovata.toolbox::lang.component.property_flash_on', 'type' => 'checkbox', ], self::PROPERTY_REDIRECT_ON => [ 'title' => 'lovata.toolbox::lang.component.property_redirect_on', 'type' => 'checkbox', ], ]; try { $arPageList = Page::getNameList(); } catch (\Exception $obException) { $arPageList = []; } if (!empty($arPageList)) { $arResult[self::PROPERTY_REDIRECT_PAGE] = [ 'title' => 'lovata.toolbox::lang.component.property_redirect_page', 'type' => 'dropdown', 'options' => $arPageList, ]; } return $arResult; }
php
protected function getModeProperty() { $arResult = [ self::PROPERTY_MODE => [ 'title' => 'lovata.toolbox::lang.component.property_mode', 'type' => 'dropdown', 'options' => [ self::MODE_SUBMIT => Lang::get('lovata.toolbox::lang.component.mode_'.self::MODE_SUBMIT), self::MODE_AJAX => Lang::get('lovata.toolbox::lang.component.mode_'.self::MODE_AJAX), ], ], self::PROPERTY_FLASH_ON => [ 'title' => 'lovata.toolbox::lang.component.property_flash_on', 'type' => 'checkbox', ], self::PROPERTY_REDIRECT_ON => [ 'title' => 'lovata.toolbox::lang.component.property_redirect_on', 'type' => 'checkbox', ], ]; try { $arPageList = Page::getNameList(); } catch (\Exception $obException) { $arPageList = []; } if (!empty($arPageList)) { $arResult[self::PROPERTY_REDIRECT_PAGE] = [ 'title' => 'lovata.toolbox::lang.component.property_redirect_page', 'type' => 'dropdown', 'options' => $arPageList, ]; } return $arResult; }
[ "protected", "function", "getModeProperty", "(", ")", "{", "$", "arResult", "=", "[", "self", "::", "PROPERTY_MODE", "=>", "[", "'title'", "=>", "'lovata.toolbox::lang.component.property_mode'", ",", "'type'", "=>", "'dropdown'", ",", "'options'", "=>", "[", "self...
Get component property "mode" @return array
[ "Get", "component", "property", "mode" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/component/ComponentSubmitForm.php#L87-L123
train
lovata/oc-toolbox-plugin
classes/component/ComponentSubmitForm.php
ComponentSubmitForm.sendFlashMessage
protected function sendFlashMessage() { $bFlashOn = $this->property(self::PROPERTY_FLASH_ON); if (!$bFlashOn) { return; } $sMessage = Result::message(); if (empty($sMessage)) { return; } if (Result::status()) { Flash::success($sMessage); } else { Flash::error($sMessage); } }
php
protected function sendFlashMessage() { $bFlashOn = $this->property(self::PROPERTY_FLASH_ON); if (!$bFlashOn) { return; } $sMessage = Result::message(); if (empty($sMessage)) { return; } if (Result::status()) { Flash::success($sMessage); } else { Flash::error($sMessage); } }
[ "protected", "function", "sendFlashMessage", "(", ")", "{", "$", "bFlashOn", "=", "$", "this", "->", "property", "(", "self", "::", "PROPERTY_FLASH_ON", ")", ";", "if", "(", "!", "$", "bFlashOn", ")", "{", "return", ";", "}", "$", "sMessage", "=", "Res...
Send flash message
[ "Send", "flash", "message" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/component/ComponentSubmitForm.php#L190-L207
train
lovata/oc-toolbox-plugin
classes/storage/AbstractUserStorage.php
AbstractUserStorage.getList
public function getList($sKey) { if (empty($sKey)) { return []; } //Get value from storage $arValueList = $this->get($sKey); if (empty($arValueList) || !is_array($arValueList)) { $arValueList = []; } return $arValueList; }
php
public function getList($sKey) { if (empty($sKey)) { return []; } //Get value from storage $arValueList = $this->get($sKey); if (empty($arValueList) || !is_array($arValueList)) { $arValueList = []; } return $arValueList; }
[ "public", "function", "getList", "(", "$", "sKey", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", ")", "{", "return", "[", "]", ";", "}", "//Get value from storage", "$", "arValueList", "=", "$", "this", "->", "get", "(", "$", "sKey", ")", ";...
Get list value @param string $sKey @return array
[ "Get", "list", "value" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/storage/AbstractUserStorage.php#L37-L50
train
lovata/oc-toolbox-plugin
classes/storage/AbstractUserStorage.php
AbstractUserStorage.addToList
public function addToList($sKey, $sValue) { if (empty($sKey) || empty($sValue)) { return; } //Get value from storage $arValueList = $this->getList($sKey); array_unshift($arValueList, $sValue); $arValueList = array_unique($arValueList); $this->put($sKey, $arValueList); }
php
public function addToList($sKey, $sValue) { if (empty($sKey) || empty($sValue)) { return; } //Get value from storage $arValueList = $this->getList($sKey); array_unshift($arValueList, $sValue); $arValueList = array_unique($arValueList); $this->put($sKey, $arValueList); }
[ "public", "function", "addToList", "(", "$", "sKey", ",", "$", "sValue", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", "||", "empty", "(", "$", "sValue", ")", ")", "{", "return", ";", "}", "//Get value from storage", "$", "arValueList", "=", "...
Add value to list @param string $sKey @param string $sValue
[ "Add", "value", "to", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/storage/AbstractUserStorage.php#L57-L70
train
lovata/oc-toolbox-plugin
classes/storage/AbstractUserStorage.php
AbstractUserStorage.removeFromList
public function removeFromList($sKey, $sValue) { if (empty($sKey) || empty($sValue)) { return; } //Get value from storage $arValueList = $this->getList($sKey); $iPosition = array_search($sValue, $arValueList); if ($iPosition === false) { return; } unset($arValueList[$iPosition]); $arValueList = array_values($arValueList); $this->put($sKey, $arValueList); }
php
public function removeFromList($sKey, $sValue) { if (empty($sKey) || empty($sValue)) { return; } //Get value from storage $arValueList = $this->getList($sKey); $iPosition = array_search($sValue, $arValueList); if ($iPosition === false) { return; } unset($arValueList[$iPosition]); $arValueList = array_values($arValueList); $this->put($sKey, $arValueList); }
[ "public", "function", "removeFromList", "(", "$", "sKey", ",", "$", "sValue", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", "||", "empty", "(", "$", "sValue", ")", ")", "{", "return", ";", "}", "//Get value from storage", "$", "arValueList", "="...
Remove value from list @param string $sKey @param string $sValue
[ "Remove", "value", "from", "list" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/storage/AbstractUserStorage.php#L77-L95
train
lovata/oc-toolbox-plugin
classes/collection/CollectionStore.php
CollectionStore.save
public function save($sKey, $obCollection) { if (empty($sKey)) { return; } $this->arStore[$sKey] = $obCollection->copy(); }
php
public function save($sKey, $obCollection) { if (empty($sKey)) { return; } $this->arStore[$sKey] = $obCollection->copy(); }
[ "public", "function", "save", "(", "$", "sKey", ",", "$", "obCollection", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", ")", "{", "return", ";", "}", "$", "this", "->", "arStore", "[", "$", "sKey", "]", "=", "$", "obCollection", "->", "cop...
Save item collection @see \Lovata\Toolbox\Tests\Unit\CollectionTest::testSaveMethod() @param string $sKey @param ElementCollection $obCollection
[ "Save", "item", "collection" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/collection/CollectionStore.php#L23-L30
train
lovata/oc-toolbox-plugin
classes/collection/CollectionStore.php
CollectionStore.saved
public function saved($sKey) { if (empty($sKey) || empty($this->arStore) || !isset($this->arStore[$sKey])) { return null; } return $this->arStore[$sKey]->copy(); }
php
public function saved($sKey) { if (empty($sKey) || empty($this->arStore) || !isset($this->arStore[$sKey])) { return null; } return $this->arStore[$sKey]->copy(); }
[ "public", "function", "saved", "(", "$", "sKey", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", "||", "empty", "(", "$", "this", "->", "arStore", ")", "||", "!", "isset", "(", "$", "this", "->", "arStore", "[", "$", "sKey", "]", ")", ")",...
Get saved element collection @see \Lovata\Toolbox\Tests\Unit\CollectionTest::testSaveMethod() @param string $sKey @return ElementCollection
[ "Get", "saved", "element", "collection" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/collection/CollectionStore.php#L38-L45
train
lovata/oc-toolbox-plugin
classes/collection/CollectionStore.php
CollectionStore.clear
public function clear($sKey) { if (empty($sKey) || empty($this->arStore) || !isset($this->arStore[$sKey])) { return; } unset($this->arStore[$sKey]); }
php
public function clear($sKey) { if (empty($sKey) || empty($this->arStore) || !isset($this->arStore[$sKey])) { return; } unset($this->arStore[$sKey]); }
[ "public", "function", "clear", "(", "$", "sKey", ")", "{", "if", "(", "empty", "(", "$", "sKey", ")", "||", "empty", "(", "$", "this", "->", "arStore", ")", "||", "!", "isset", "(", "$", "this", "->", "arStore", "[", "$", "sKey", "]", ")", ")",...
Remove stored collection from store @param string $sKey
[ "Remove", "stored", "collection", "from", "store" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/collection/CollectionStore.php#L51-L58
train
lovata/oc-toolbox-plugin
classes/item/MainItem.php
MainItem.getLangAttribute
public function getLangAttribute($sName, $sLangCode = null) { if (empty($sName)) { return null; } if (empty($sLangCode)) { $sLangCode = self::$sActiveLang; } if (empty($sLangCode)) { return $this->getAttribute($sName); } $sLangName = $sName.'|'.$sLangCode; if (!empty($this->arModelData) && isset($this->arModelData[$sLangName])) { return $this->arModelData[$sLangName]; } return $this->getAttribute($sName); }
php
public function getLangAttribute($sName, $sLangCode = null) { if (empty($sName)) { return null; } if (empty($sLangCode)) { $sLangCode = self::$sActiveLang; } if (empty($sLangCode)) { return $this->getAttribute($sName); } $sLangName = $sName.'|'.$sLangCode; if (!empty($this->arModelData) && isset($this->arModelData[$sLangName])) { return $this->arModelData[$sLangName]; } return $this->getAttribute($sName); }
[ "public", "function", "getLangAttribute", "(", "$", "sName", ",", "$", "sLangCode", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "sName", ")", ")", "{", "return", "null", ";", "}", "if", "(", "empty", "(", "$", "sLangCode", ")", ")", "{", ...
Get lang attribute value @param string $sName @param string $sLangCode @return mixed|null
[ "Get", "lang", "attribute", "value" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/MainItem.php#L83-L103
train
lovata/oc-toolbox-plugin
classes/item/MainItem.php
MainItem.getUploadFileListField
protected function getUploadFileListField($sField, $sFakeField) { $arFileList = $this->getAttribute($sField); if (!empty($arFileList)) { return $arFileList; } $arFileList = []; $arCachedFileList = (array) $this->getAttribute($sFakeField); foreach ($arCachedFileList as $arFileData) { $obFile = $this->initUploadFileObject($arFileData); if (empty($obFile)) { continue; } $arFileList[] = $obFile; } $this->setAttribute($sField, $arFileList); return $arFileList; }
php
protected function getUploadFileListField($sField, $sFakeField) { $arFileList = $this->getAttribute($sField); if (!empty($arFileList)) { return $arFileList; } $arFileList = []; $arCachedFileList = (array) $this->getAttribute($sFakeField); foreach ($arCachedFileList as $arFileData) { $obFile = $this->initUploadFileObject($arFileData); if (empty($obFile)) { continue; } $arFileList[] = $obFile; } $this->setAttribute($sField, $arFileList); return $arFileList; }
[ "protected", "function", "getUploadFileListField", "(", "$", "sField", ",", "$", "sFakeField", ")", "{", "$", "arFileList", "=", "$", "this", "->", "getAttribute", "(", "$", "sField", ")", ";", "if", "(", "!", "empty", "(", "$", "arFileList", ")", ")", ...
Get image object form field with image array @param string $sField @param string $sFakeField @return File[]|null
[ "Get", "image", "object", "form", "field", "with", "image", "array" ]
e28f6cfd63f9091d5a215171568648ca5a0e4716
https://github.com/lovata/oc-toolbox-plugin/blob/e28f6cfd63f9091d5a215171568648ca5a0e4716/classes/item/MainItem.php#L218-L240
train
beardcoder/sitemap_generator
Classes/Service/LimitService.php
LimitService.getLimitString
public static function getLimitString($limit) { if (isset($limit) && !empty($limit)) { $limitParts = GeneralUtility::trimExplode(',', $limit); if (count($limitParts) === 1) { return intval($limitParts[0]); } if (count($limitParts) === 2) { return intval($limitParts[0]) . ',' . intval($limitParts[1]); } } return ''; }
php
public static function getLimitString($limit) { if (isset($limit) && !empty($limit)) { $limitParts = GeneralUtility::trimExplode(',', $limit); if (count($limitParts) === 1) { return intval($limitParts[0]); } if (count($limitParts) === 2) { return intval($limitParts[0]) . ',' . intval($limitParts[1]); } } return ''; }
[ "public", "static", "function", "getLimitString", "(", "$", "limit", ")", "{", "if", "(", "isset", "(", "$", "limit", ")", "&&", "!", "empty", "(", "$", "limit", ")", ")", "{", "$", "limitParts", "=", "GeneralUtility", "::", "trimExplode", "(", "','", ...
Returns the limit statement for database connection @param string $limit @return string
[ "Returns", "the", "limit", "statement", "for", "database", "connection" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Service/LimitService.php#L30-L43
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.makeClassInstance
protected function makeClassInstance() { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->entryStorage = $objectManager->get(ObjectStorage::class); $this->pageRepository = $objectManager->get(PageRepository::class); $this->fieldValueService = $objectManager->get(FieldValueService::class); }
php
protected function makeClassInstance() { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->entryStorage = $objectManager->get(ObjectStorage::class); $this->pageRepository = $objectManager->get(PageRepository::class); $this->fieldValueService = $objectManager->get(FieldValueService::class); }
[ "protected", "function", "makeClassInstance", "(", ")", "{", "$", "objectManager", "=", "GeneralUtility", "::", "makeInstance", "(", "ObjectManager", "::", "class", ")", ";", "$", "this", "->", "entryStorage", "=", "$", "objectManager", "->", "get", "(", "Obje...
Make instance of needed classes
[ "Make", "instance", "of", "needed", "classes" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L90-L96
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.generateSitemap
public function generateSitemap() { if ($this->findAllEntries()) { $sitemap = GeneralUtility::makeInstance(Sitemap::class); $sitemap->setUrlEntries($this->entryStorage); return $sitemap; } return null; }
php
public function generateSitemap() { if ($this->findAllEntries()) { $sitemap = GeneralUtility::makeInstance(Sitemap::class); $sitemap->setUrlEntries($this->entryStorage); return $sitemap; } return null; }
[ "public", "function", "generateSitemap", "(", ")", "{", "if", "(", "$", "this", "->", "findAllEntries", "(", ")", ")", "{", "$", "sitemap", "=", "GeneralUtility", "::", "makeInstance", "(", "Sitemap", "::", "class", ")", ";", "$", "sitemap", "->", "setUr...
Generate a sitemap @return Sitemap|null
[ "Generate", "a", "sitemap" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L103-L113
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.findAllPages
public function findAllPages() { if (empty($this->pluginConfig['urlEntries']['pages'])) { return; } $pages = $this->hidePagesIfNotTranslated($this->getPages()); $pages = $this->hidePagesIfHiddenInDefaultTranslation($pages); $this->getEntriesFromPages($pages); }
php
public function findAllPages() { if (empty($this->pluginConfig['urlEntries']['pages'])) { return; } $pages = $this->hidePagesIfNotTranslated($this->getPages()); $pages = $this->hidePagesIfHiddenInDefaultTranslation($pages); $this->getEntriesFromPages($pages); }
[ "public", "function", "findAllPages", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "pluginConfig", "[", "'urlEntries'", "]", "[", "'pages'", "]", ")", ")", "{", "return", ";", "}", "$", "pages", "=", "$", "this", "->", "hidePagesIfNotTran...
Find all pages
[ "Find", "all", "pages" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L131-L140
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.hidePagesIfNotTranslated
private function hidePagesIfNotTranslated($pages) { $language = GeneralUtility::_GET('L'); if ($this->isPageNotTranslated($language)) { foreach ($pages as $key => $page) { $pageOverlay = $this->pageRepository->getPageOverlay($page, $language); if (empty($pageOverlay['_PAGES_OVERLAY'])) { unset($pages[$key]); } } } return $pages; }
php
private function hidePagesIfNotTranslated($pages) { $language = GeneralUtility::_GET('L'); if ($this->isPageNotTranslated($language)) { foreach ($pages as $key => $page) { $pageOverlay = $this->pageRepository->getPageOverlay($page, $language); if (empty($pageOverlay['_PAGES_OVERLAY'])) { unset($pages[$key]); } } } return $pages; }
[ "private", "function", "hidePagesIfNotTranslated", "(", "$", "pages", ")", "{", "$", "language", "=", "GeneralUtility", "::", "_GET", "(", "'L'", ")", ";", "if", "(", "$", "this", "->", "isPageNotTranslated", "(", "$", "language", ")", ")", "{", "foreach",...
Remove page if not translated @param array $pages @return array
[ "Remove", "page", "if", "not", "translated" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L149-L162
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.hidePagesIfHiddenInDefaultTranslation
private function hidePagesIfHiddenInDefaultTranslation($pages) { $language = GeneralUtility::_GET('L'); if ($language != 0) { return $pages; } foreach ($pages as $key => $page) { if ($page['l18n_cfg'] === 1) { unset($pages[$key]); } } return $pages; }
php
private function hidePagesIfHiddenInDefaultTranslation($pages) { $language = GeneralUtility::_GET('L'); if ($language != 0) { return $pages; } foreach ($pages as $key => $page) { if ($page['l18n_cfg'] === 1) { unset($pages[$key]); } } return $pages; }
[ "private", "function", "hidePagesIfHiddenInDefaultTranslation", "(", "$", "pages", ")", "{", "$", "language", "=", "GeneralUtility", "::", "_GET", "(", "'L'", ")", ";", "if", "(", "$", "language", "!=", "0", ")", "{", "return", "$", "pages", ";", "}", "f...
Remove page if hidden in default translation @param array $pages @return array
[ "Remove", "page", "if", "hidden", "in", "default", "translation" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L183-L198
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.getPages
private function getPages() { $rootPageId = $this->pluginConfig['urlEntries']['pages']['rootPageId']; $rootPage = $this->pageRepository->getPage($rootPageId); $cacheIdentifier = md5($rootPageId . '-pagesForSitemap'); if ($this->cacheInstance->has($cacheIdentifier)) { $pages = $this->cacheInstance->get($cacheIdentifier); } else { $pages = $this->getSubPagesRecursive($rootPageId); $this->cacheInstance->set($cacheIdentifier, $pages, ['pagesForSitemap']); } return array_merge([$rootPage], $pages); }
php
private function getPages() { $rootPageId = $this->pluginConfig['urlEntries']['pages']['rootPageId']; $rootPage = $this->pageRepository->getPage($rootPageId); $cacheIdentifier = md5($rootPageId . '-pagesForSitemap'); if ($this->cacheInstance->has($cacheIdentifier)) { $pages = $this->cacheInstance->get($cacheIdentifier); } else { $pages = $this->getSubPagesRecursive($rootPageId); $this->cacheInstance->set($cacheIdentifier, $pages, ['pagesForSitemap']); } return array_merge([$rootPage], $pages); }
[ "private", "function", "getPages", "(", ")", "{", "$", "rootPageId", "=", "$", "this", "->", "pluginConfig", "[", "'urlEntries'", "]", "[", "'pages'", "]", "[", "'rootPageId'", "]", ";", "$", "rootPage", "=", "$", "this", "->", "pageRepository", "->", "g...
Get pages from Database @return array
[ "Get", "pages", "from", "Database" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L205-L219
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.getSubPagesRecursive
private function getSubPagesRecursive($rootPageId) { $pages = $this->getSubPages($rootPageId); foreach ($pages as $page) { if (false === $this->isPageTreeLeaf($page)) { ArrayUtility::mergeRecursiveWithOverrule( $pages, $this->getSubPagesRecursive($page['uid']) ); } } return $pages; }
php
private function getSubPagesRecursive($rootPageId) { $pages = $this->getSubPages($rootPageId); foreach ($pages as $page) { if (false === $this->isPageTreeLeaf($page)) { ArrayUtility::mergeRecursiveWithOverrule( $pages, $this->getSubPagesRecursive($page['uid']) ); } } return $pages; }
[ "private", "function", "getSubPagesRecursive", "(", "$", "rootPageId", ")", "{", "$", "pages", "=", "$", "this", "->", "getSubPages", "(", "$", "rootPageId", ")", ";", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "if", "(", "false", "==="...
Get sub pages recursive @param $rootPageId @return array
[ "Get", "sub", "pages", "recursive" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L228-L241
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.getSubPages
private function getSubPages($startPageId) { $where = $this->pageRepository->enableFields('pages') . ' AND ' . UrlEntry::EXCLUDE_FROM_SITEMAP . '!=1' . $this->pageAdditionalWhere; try { return $this->pageRepository->getMenu($startPageId, '*', 'sorting', $where); } catch (\Exception $exception) { return []; } }
php
private function getSubPages($startPageId) { $where = $this->pageRepository->enableFields('pages') . ' AND ' . UrlEntry::EXCLUDE_FROM_SITEMAP . '!=1' . $this->pageAdditionalWhere; try { return $this->pageRepository->getMenu($startPageId, '*', 'sorting', $where); } catch (\Exception $exception) { return []; } }
[ "private", "function", "getSubPages", "(", "$", "startPageId", ")", "{", "$", "where", "=", "$", "this", "->", "pageRepository", "->", "enableFields", "(", "'pages'", ")", ".", "' AND '", ".", "UrlEntry", "::", "EXCLUDE_FROM_SITEMAP", ".", "'!=1'", ".", "$",...
Get sub pages @param int $startPageId @return array
[ "Get", "sub", "pages" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L249-L258
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.generateEntriesFromTypoScript
public function generateEntriesFromTypoScript() { $urlEntries = $this->pluginConfig['urlEntries']; foreach ($urlEntries as $urlEntry) { if (!empty($urlEntry['active'])) { $this->mapToEntries($urlEntry); } } }
php
public function generateEntriesFromTypoScript() { $urlEntries = $this->pluginConfig['urlEntries']; foreach ($urlEntries as $urlEntry) { if (!empty($urlEntry['active'])) { $this->mapToEntries($urlEntry); } } }
[ "public", "function", "generateEntriesFromTypoScript", "(", ")", "{", "$", "urlEntries", "=", "$", "this", "->", "pluginConfig", "[", "'urlEntries'", "]", ";", "foreach", "(", "$", "urlEntries", "as", "$", "urlEntry", ")", "{", "if", "(", "!", "empty", "("...
Generate entries from TypoScript
[ "Generate", "entries", "from", "TypoScript" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L321-L329
train
beardcoder/sitemap_generator
Classes/Domain/Repository/SitemapRepository.php
SitemapRepository.getRecordsFromDatabase
private function getRecordsFromDatabase($typoScriptUrlEntry) { if (!isset($GLOBALS['TCA'][$typoScriptUrlEntry['table']]) || !is_array($GLOBALS['TCA'][$typoScriptUrlEntry['table']]['ctrl']) ) { return false; } $language = ''; if ((int)$typoScriptUrlEntry['hideIfNotTranslated'] === 1) { $language = 'AND (sys_language_uid=\'-1\' OR sys_language_uid="' . (int)GeneralUtility::_GET('L') . '") '; } return $this->getDatabaseConnection()->exec_SELECTquery( '*', $typoScriptUrlEntry['table'], 'pid!=0 ' . $language . ' ' . AdditionalWhereService::getWhereString( $typoScriptUrlEntry['additionalWhere'] ) . $this->pageRepository->enableFields( $typoScriptUrlEntry['table'] ), '', OrderByService::getOrderByString( $typoScriptUrlEntry['orderBy'], $typoScriptUrlEntry['table'] ), LimitService::getLimitString( $typoScriptUrlEntry['limit'] ) ); }
php
private function getRecordsFromDatabase($typoScriptUrlEntry) { if (!isset($GLOBALS['TCA'][$typoScriptUrlEntry['table']]) || !is_array($GLOBALS['TCA'][$typoScriptUrlEntry['table']]['ctrl']) ) { return false; } $language = ''; if ((int)$typoScriptUrlEntry['hideIfNotTranslated'] === 1) { $language = 'AND (sys_language_uid=\'-1\' OR sys_language_uid="' . (int)GeneralUtility::_GET('L') . '") '; } return $this->getDatabaseConnection()->exec_SELECTquery( '*', $typoScriptUrlEntry['table'], 'pid!=0 ' . $language . ' ' . AdditionalWhereService::getWhereString( $typoScriptUrlEntry['additionalWhere'] ) . $this->pageRepository->enableFields( $typoScriptUrlEntry['table'] ), '', OrderByService::getOrderByString( $typoScriptUrlEntry['orderBy'], $typoScriptUrlEntry['table'] ), LimitService::getLimitString( $typoScriptUrlEntry['limit'] ) ); }
[ "private", "function", "getRecordsFromDatabase", "(", "$", "typoScriptUrlEntry", ")", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'TCA'", "]", "[", "$", "typoScriptUrlEntry", "[", "'table'", "]", "]", ")", "||", "!", "is_array", "(", "$", "G...
Get records from database @param $typoScriptUrlEntry @SuppressWarnings(superglobals) @return bool|\mysqli_result|object
[ "Get", "records", "from", "database" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Domain/Repository/SitemapRepository.php#L388-L418
train
beardcoder/sitemap_generator
Classes/Service/FieldValueService.php
FieldValueService.getFieldValue
public function getFieldValue( $fieldName, $typoScriptUrlEntry, $row ) { // support for cObject if the value is a configuration if (!empty($typoScriptUrlEntry[$fieldName . '.'])) { $this->contentObject->start($row, $typoScriptUrlEntry['table']); return $this->contentObject->cObjGetSingle( $typoScriptUrlEntry[$fieldName], $typoScriptUrlEntry[$fieldName . '.'] ); } return $row[$typoScriptUrlEntry[$fieldName]]; }
php
public function getFieldValue( $fieldName, $typoScriptUrlEntry, $row ) { // support for cObject if the value is a configuration if (!empty($typoScriptUrlEntry[$fieldName . '.'])) { $this->contentObject->start($row, $typoScriptUrlEntry['table']); return $this->contentObject->cObjGetSingle( $typoScriptUrlEntry[$fieldName], $typoScriptUrlEntry[$fieldName . '.'] ); } return $row[$typoScriptUrlEntry[$fieldName]]; }
[ "public", "function", "getFieldValue", "(", "$", "fieldName", ",", "$", "typoScriptUrlEntry", ",", "$", "row", ")", "{", "// support for cObject if the value is a configuration", "if", "(", "!", "empty", "(", "$", "typoScriptUrlEntry", "[", "$", "fieldName", ".", ...
Uses the page's cObj instance to resolve the field's value. @param string $fieldName The name of the field to get. @param array $typoScriptUrlEntry The entry who is defined via typoscript @param array $row @SuppressWarnings(superglobals) @return string The field's value.
[ "Uses", "the", "page", "s", "cObj", "instance", "to", "resolve", "the", "field", "s", "value", "." ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Service/FieldValueService.php#L49-L65
train
beardcoder/sitemap_generator
Classes/Service/GoogleSitemapService.php
GoogleSitemapService.sendRequest
public function sendRequest() { $curlInit = curl_init(); curl_setopt($curlInit, CURLOPT_URL, $this->getGoogleSitemapToolUrl()); curl_setopt($curlInit, CURLOPT_HEADER, true); curl_setopt($curlInit, CURLOPT_NOBODY, true); curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, true); curl_exec($curlInit); $httpCode = curl_getinfo($curlInit, CURLINFO_HTTP_CODE); curl_close($curlInit); return $httpCode; }
php
public function sendRequest() { $curlInit = curl_init(); curl_setopt($curlInit, CURLOPT_URL, $this->getGoogleSitemapToolUrl()); curl_setopt($curlInit, CURLOPT_HEADER, true); curl_setopt($curlInit, CURLOPT_NOBODY, true); curl_setopt($curlInit, CURLOPT_RETURNTRANSFER, true); curl_exec($curlInit); $httpCode = curl_getinfo($curlInit, CURLINFO_HTTP_CODE); curl_close($curlInit); return $httpCode; }
[ "public", "function", "sendRequest", "(", ")", "{", "$", "curlInit", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "curlInit", ",", "CURLOPT_URL", ",", "$", "this", "->", "getGoogleSitemapToolUrl", "(", ")", ")", ";", "curl_setopt", "(", "$", ...
Send the request to google @return int
[ "Send", "the", "request", "to", "google" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Service/GoogleSitemapService.php#L52-L64
train
beardcoder/sitemap_generator
Classes/Service/GoogleSitemapService.php
GoogleSitemapService.getGoogleSitemapToolUrl
protected function getGoogleSitemapToolUrl() { $url = $this->toolUrl . urlencode($this->xmlSiteUrl); if (!GeneralUtility::isValidUrl($url)) { return null; } return $url; }
php
protected function getGoogleSitemapToolUrl() { $url = $this->toolUrl . urlencode($this->xmlSiteUrl); if (!GeneralUtility::isValidUrl($url)) { return null; } return $url; }
[ "protected", "function", "getGoogleSitemapToolUrl", "(", ")", "{", "$", "url", "=", "$", "this", "->", "toolUrl", ".", "urlencode", "(", "$", "this", "->", "xmlSiteUrl", ")", ";", "if", "(", "!", "GeneralUtility", "::", "isValidUrl", "(", "$", "url", ")"...
Generate Google tool url for sitemap submit
[ "Generate", "Google", "tool", "url", "for", "sitemap", "submit" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Service/GoogleSitemapService.php#L69-L77
train
beardcoder/sitemap_generator
Classes/Service/OrderByService.php
OrderByService.getOrderByString
public static function getOrderByString($orderBy, $tablename) { if (isset($orderBy) && !empty($orderBy)) { $cleanOrderByParts = []; $tableColumns = $GLOBALS['TCA'][$tablename]['columns']; $orderByParts = GeneralUtility::trimExplode(',', $orderBy); foreach ($orderByParts as $part) { $subparts = GeneralUtility::trimExplode(' ', $part); if (count($subparts) === 1) { if (is_array($tableColumns[$subparts[0]])) { $cleanOrderByParts[] = $subparts[0]; } } elseif (count($subparts) === 2) { if (is_array($tableColumns[$subparts[0]]) && ($subparts[1] === 'ASC' || $subparts[1] === 'DESC')) { $cleanOrderByParts[] = $subparts[0] . ' ' . $subparts[1]; } } } return implode(',', $cleanOrderByParts); } return ''; }
php
public static function getOrderByString($orderBy, $tablename) { if (isset($orderBy) && !empty($orderBy)) { $cleanOrderByParts = []; $tableColumns = $GLOBALS['TCA'][$tablename]['columns']; $orderByParts = GeneralUtility::trimExplode(',', $orderBy); foreach ($orderByParts as $part) { $subparts = GeneralUtility::trimExplode(' ', $part); if (count($subparts) === 1) { if (is_array($tableColumns[$subparts[0]])) { $cleanOrderByParts[] = $subparts[0]; } } elseif (count($subparts) === 2) { if (is_array($tableColumns[$subparts[0]]) && ($subparts[1] === 'ASC' || $subparts[1] === 'DESC')) { $cleanOrderByParts[] = $subparts[0] . ' ' . $subparts[1]; } } } return implode(',', $cleanOrderByParts); } return ''; }
[ "public", "static", "function", "getOrderByString", "(", "$", "orderBy", ",", "$", "tablename", ")", "{", "if", "(", "isset", "(", "$", "orderBy", ")", "&&", "!", "empty", "(", "$", "orderBy", ")", ")", "{", "$", "cleanOrderByParts", "=", "[", "]", "...
Returns the orderBy statement for database connection @param string $orderBy @param string $tablename @return string
[ "Returns", "the", "orderBy", "statement", "for", "database", "connection" ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Service/OrderByService.php#L31-L54
train
beardcoder/sitemap_generator
Classes/Command/TaskCommandController.php
TaskCommandController.googleSitemapToolCommand
public function googleSitemapToolCommand($xmlSiteUrl) { $googleSitemapPing = GeneralUtility::makeInstance(GoogleSitemapService::class, $xmlSiteUrl); $httpCode = $googleSitemapPing->sendRequest(); if ($httpCode === 200) { $this->outputLine('success'); } $this->outputLine('error'); }
php
public function googleSitemapToolCommand($xmlSiteUrl) { $googleSitemapPing = GeneralUtility::makeInstance(GoogleSitemapService::class, $xmlSiteUrl); $httpCode = $googleSitemapPing->sendRequest(); if ($httpCode === 200) { $this->outputLine('success'); } $this->outputLine('error'); }
[ "public", "function", "googleSitemapToolCommand", "(", "$", "xmlSiteUrl", ")", "{", "$", "googleSitemapPing", "=", "GeneralUtility", "::", "makeInstance", "(", "GoogleSitemapService", "::", "class", ",", "$", "xmlSiteUrl", ")", ";", "$", "httpCode", "=", "$", "g...
Send a request to google tools api for the sitemap crawling. @param string $xmlSiteUrl http://www.example.com/sitemap.xml
[ "Send", "a", "request", "to", "google", "tools", "api", "for", "the", "sitemap", "crawling", "." ]
022d60915ac72d21f31ef34e23ec049a2763578e
https://github.com/beardcoder/sitemap_generator/blob/022d60915ac72d21f31ef34e23ec049a2763578e/Classes/Command/TaskCommandController.php#L30-L40
train
samuelbednarcik/elastic-apm-php-agent
src/Builder/AbstractEventBuilder.php
AbstractEventBuilder.prepareHeaders
private static function prepareHeaders(HeaderBag $headerBag) { $headers = $headerBag->all(); $result = []; foreach ($headers as $header => $values) { $result[$header] = $values[0]; } return $result; }
php
private static function prepareHeaders(HeaderBag $headerBag) { $headers = $headerBag->all(); $result = []; foreach ($headers as $header => $values) { $result[$header] = $values[0]; } return $result; }
[ "private", "static", "function", "prepareHeaders", "(", "HeaderBag", "$", "headerBag", ")", "{", "$", "headers", "=", "$", "headerBag", "->", "all", "(", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "headers", "as", "$", "header", ...
Get array of headers from header bag @param HeaderBag $headerBag @return array
[ "Get", "array", "of", "headers", "from", "header", "bag" ]
3e6cb56513905b20c707ccb78ae7cfe7a0175648
https://github.com/samuelbednarcik/elastic-apm-php-agent/blob/3e6cb56513905b20c707ccb78ae7cfe7a0175648/src/Builder/AbstractEventBuilder.php#L60-L70
train
mcaskill/composer-plugin-exclude-files
src/ExcludeFilePlugin.php
ExcludeFilePlugin.parseAutoloads
public function parseAutoloads() { /** @var Composer $composer */ $composer = $this->composer; /** @var Package $package */ $package = $composer->getPackage(); if (!$package) { return; } $exclude = $this->getExcludedFiles($package); if (!$exclude) { return; } $filesystem = new Filesystem(); $config = $composer->getConfig(); $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir')))); $exclude = $this->parseExcludedFiles($exclude, $vendorPath); $generator = $composer->getAutoloadGenerator(); $packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); $packageMap = $generator->buildPackageMap($composer->getInstallationManager(), $package, $packages); $this->filterAutoloads($packageMap, $package, $exclude); }
php
public function parseAutoloads() { /** @var Composer $composer */ $composer = $this->composer; /** @var Package $package */ $package = $composer->getPackage(); if (!$package) { return; } $exclude = $this->getExcludedFiles($package); if (!$exclude) { return; } $filesystem = new Filesystem(); $config = $composer->getConfig(); $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir')))); $exclude = $this->parseExcludedFiles($exclude, $vendorPath); $generator = $composer->getAutoloadGenerator(); $packages = $composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); $packageMap = $generator->buildPackageMap($composer->getInstallationManager(), $package, $packages); $this->filterAutoloads($packageMap, $package, $exclude); }
[ "public", "function", "parseAutoloads", "(", ")", "{", "/** @var Composer $composer */", "$", "composer", "=", "$", "this", "->", "composer", ";", "/** @var Package $package */", "$", "package", "=", "$", "composer", "->", "getPackage", "(", ")", ";", "if", "(",...
Parse the vendor 'files' to be included before the autoloader is dumped. @return void
[ "Parse", "the", "vendor", "files", "to", "be", "included", "before", "the", "autoloader", "is", "dumped", "." ]
81fdd0def4d3aa9c26715f1108706ae92ab0a98c
https://github.com/mcaskill/composer-plugin-exclude-files/blob/81fdd0def4d3aa9c26715f1108706ae92ab0a98c/src/ExcludeFilePlugin.php#L63-L90
train
mcaskill/composer-plugin-exclude-files
src/ExcludeFilePlugin.php
ExcludeFilePlugin.filterAutoloads
private function filterAutoloads(array $packageMap, PackageInterface $mainPackage, array $blacklist = null) { $type = self::INCLUDE_FILES_PROPERTY; $blacklist = array_flip($blacklist); foreach ($packageMap as $item) { list($package, $installPath) = $item; // Skip root package if ($package === $mainPackage) { continue; } $autoload = $package->getAutoload(); // Skip misconfigured packages if (!isset($autoload[$type]) || !is_array($autoload[$type])) { continue; } if (null !== $package->getTargetDir()) { $installPath = substr($installPath, 0, -strlen('/' . $package->getTargetDir())); } foreach ($autoload[$type] as $key => $path) { if ($package->getTargetDir() && !is_readable($installPath.'/'.$path)) { // add target-dir from file paths that don't have it $path = $package->getTargetDir() . '/' . $path; } $resolvedPath = $installPath . '/' . $path; $resolvedPath = strtr($resolvedPath, '\\', '/'); if (isset($blacklist[$resolvedPath])) { unset($autoload[$type][$key]); } } $package->setAutoload($autoload); } }
php
private function filterAutoloads(array $packageMap, PackageInterface $mainPackage, array $blacklist = null) { $type = self::INCLUDE_FILES_PROPERTY; $blacklist = array_flip($blacklist); foreach ($packageMap as $item) { list($package, $installPath) = $item; // Skip root package if ($package === $mainPackage) { continue; } $autoload = $package->getAutoload(); // Skip misconfigured packages if (!isset($autoload[$type]) || !is_array($autoload[$type])) { continue; } if (null !== $package->getTargetDir()) { $installPath = substr($installPath, 0, -strlen('/' . $package->getTargetDir())); } foreach ($autoload[$type] as $key => $path) { if ($package->getTargetDir() && !is_readable($installPath.'/'.$path)) { // add target-dir from file paths that don't have it $path = $package->getTargetDir() . '/' . $path; } $resolvedPath = $installPath . '/' . $path; $resolvedPath = strtr($resolvedPath, '\\', '/'); if (isset($blacklist[$resolvedPath])) { unset($autoload[$type][$key]); } } $package->setAutoload($autoload); } }
[ "private", "function", "filterAutoloads", "(", "array", "$", "packageMap", ",", "PackageInterface", "$", "mainPackage", ",", "array", "$", "blacklist", "=", "null", ")", "{", "$", "type", "=", "self", "::", "INCLUDE_FILES_PROPERTY", ";", "$", "blacklist", "=",...
Alters packages to exclude files required in "autoload.files" by "extra.exclude-from-files". @param array $packageMap Array of `[ package, installDir-relative-to-composer.json) ]`. @param PackageInterface $mainPackage Root package instance. @param string[] $blacklist The files to exclude from the "files" autoload mechanism. @return void
[ "Alters", "packages", "to", "exclude", "files", "required", "in", "autoload", ".", "files", "by", "extra", ".", "exclude", "-", "from", "-", "files", "." ]
81fdd0def4d3aa9c26715f1108706ae92ab0a98c
https://github.com/mcaskill/composer-plugin-exclude-files/blob/81fdd0def4d3aa9c26715f1108706ae92ab0a98c/src/ExcludeFilePlugin.php#L100-L141
train
mcaskill/composer-plugin-exclude-files
src/ExcludeFilePlugin.php
ExcludeFilePlugin.getExcludedFiles
private function getExcludedFiles(PackageInterface $package) { $type = self::EXCLUDE_FILES_PROPERTY; $autoload = $package->getAutoload(); // Skip misconfigured or empty packages if (isset($autoload[$type]) && is_array($autoload[$type])) { return $autoload[$type]; } $extra = $package->getExtra(); // Skip misconfigured or empty packages if (isset($extra[$type]) && is_array($extra[$type])) { return $extra[$type]; } return null; }
php
private function getExcludedFiles(PackageInterface $package) { $type = self::EXCLUDE_FILES_PROPERTY; $autoload = $package->getAutoload(); // Skip misconfigured or empty packages if (isset($autoload[$type]) && is_array($autoload[$type])) { return $autoload[$type]; } $extra = $package->getExtra(); // Skip misconfigured or empty packages if (isset($extra[$type]) && is_array($extra[$type])) { return $extra[$type]; } return null; }
[ "private", "function", "getExcludedFiles", "(", "PackageInterface", "$", "package", ")", "{", "$", "type", "=", "self", "::", "EXCLUDE_FILES_PROPERTY", ";", "$", "autoload", "=", "$", "package", "->", "getAutoload", "(", ")", ";", "// Skip misconfigured or empty p...
Gets a list files the root package wants to exclude. @param PackageInterface $package Root package instance. @return array|null Retuns the list of excluded files otherwise NULL if misconfigured or undefined.
[ "Gets", "a", "list", "files", "the", "root", "package", "wants", "to", "exclude", "." ]
81fdd0def4d3aa9c26715f1108706ae92ab0a98c
https://github.com/mcaskill/composer-plugin-exclude-files/blob/81fdd0def4d3aa9c26715f1108706ae92ab0a98c/src/ExcludeFilePlugin.php#L149-L168
train
mcaskill/composer-plugin-exclude-files
src/ExcludeFilePlugin.php
ExcludeFilePlugin.parseExcludedFiles
private function parseExcludedFiles(array $paths, $vendorPath) { foreach ($paths as &$path) { $path = preg_replace('{/+}', '/', trim(strtr($path, '\\', '/'), '/')); $path = $vendorPath . '/' . $path; } return $paths; }
php
private function parseExcludedFiles(array $paths, $vendorPath) { foreach ($paths as &$path) { $path = preg_replace('{/+}', '/', trim(strtr($path, '\\', '/'), '/')); $path = $vendorPath . '/' . $path; } return $paths; }
[ "private", "function", "parseExcludedFiles", "(", "array", "$", "paths", ",", "$", "vendorPath", ")", "{", "foreach", "(", "$", "paths", "as", "&", "$", "path", ")", "{", "$", "path", "=", "preg_replace", "(", "'{/+}'", ",", "'/'", ",", "trim", "(", ...
Prepends the vendor directory to each path in "extra.exclude-from-files". @param string[] $paths Array of paths absolute from the vendor directory. @param string $vendorPath The directory for installed dependencies. @return array Retuns the list of excluded files, prepended with the vendor directory.
[ "Prepends", "the", "vendor", "directory", "to", "each", "path", "in", "extra", ".", "exclude", "-", "from", "-", "files", "." ]
81fdd0def4d3aa9c26715f1108706ae92ab0a98c
https://github.com/mcaskill/composer-plugin-exclude-files/blob/81fdd0def4d3aa9c26715f1108706ae92ab0a98c/src/ExcludeFilePlugin.php#L177-L185
train
schulzefelix/laravel-data-transfer-object
src/DataTransferObject.php
DataTransferObject.getAttribute
public function getAttribute($key) { if (! $key) { return; } if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key)) { return $this->getAttributeValue($key); } if (method_exists(self::class, $key)) { return; } }
php
public function getAttribute($key) { if (! $key) { return; } if (array_key_exists($key, $this->attributes) || $this->hasGetMutator($key)) { return $this->getAttributeValue($key); } if (method_exists(self::class, $key)) { return; } }
[ "public", "function", "getAttribute", "(", "$", "key", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", ";", "}", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "attributes", ")", "||", "$", "this", "->", "hasGetMu...
Get an attribute from the object. @param string $key @return mixed
[ "Get", "an", "attribute", "from", "the", "object", "." ]
932134ca8542d903e5e9d5dbb5b9e23fa24ecd95
https://github.com/schulzefelix/laravel-data-transfer-object/blob/932134ca8542d903e5e9d5dbb5b9e23fa24ecd95/src/DataTransferObject.php#L137-L150
train
schulzefelix/laravel-data-transfer-object
src/DataTransferObject.php
DataTransferObject.fillJsonAttribute
public function fillJsonAttribute($key, $value) { list($key, $path) = explode('->', $key, 2); $arrayValue = isset($this->attributes[$key]) ? $this->fromJson($this->attributes[$key]) : []; Arr::set($arrayValue, str_replace('->', '.', $path), $value); $this->attributes[$key] = $this->asJson($arrayValue); return $this; }
php
public function fillJsonAttribute($key, $value) { list($key, $path) = explode('->', $key, 2); $arrayValue = isset($this->attributes[$key]) ? $this->fromJson($this->attributes[$key]) : []; Arr::set($arrayValue, str_replace('->', '.', $path), $value); $this->attributes[$key] = $this->asJson($arrayValue); return $this; }
[ "public", "function", "fillJsonAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "list", "(", "$", "key", ",", "$", "path", ")", "=", "explode", "(", "'->'", ",", "$", "key", ",", "2", ")", ";", "$", "arrayValue", "=", "isset", "(", "$", ...
Set a given JSON attribute on the object. @param string $key @param mixed $value @return $this
[ "Set", "a", "given", "JSON", "attribute", "on", "the", "object", "." ]
932134ca8542d903e5e9d5dbb5b9e23fa24ecd95
https://github.com/schulzefelix/laravel-data-transfer-object/blob/932134ca8542d903e5e9d5dbb5b9e23fa24ecd95/src/DataTransferObject.php#L545-L556
train
schulzefelix/laravel-data-transfer-object
src/DataTransferObject.php
DataTransferObject.nestedObjectsToArray
public function nestedObjectsToArray() { $attributes = []; foreach ($this->getAttributes() as $key => $value) { // If the values implements the Arrayable interface we can just call this // toArray method on the instances which will convert both objects and // collections to their proper array form and we'll set the values. if ($value instanceof Arrayable) { $attributes[$key] = $value->toArray(); } if (is_array($value)) { $attributes[$key] = collect($value)->toArray(); } } return $attributes; }
php
public function nestedObjectsToArray() { $attributes = []; foreach ($this->getAttributes() as $key => $value) { // If the values implements the Arrayable interface we can just call this // toArray method on the instances which will convert both objects and // collections to their proper array form and we'll set the values. if ($value instanceof Arrayable) { $attributes[$key] = $value->toArray(); } if (is_array($value)) { $attributes[$key] = collect($value)->toArray(); } } return $attributes; }
[ "public", "function", "nestedObjectsToArray", "(", ")", "{", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getAttributes", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "// If the values implements the Arrayable interfa...
Get the object's nested objects in array form. @return array
[ "Get", "the", "object", "s", "nested", "objects", "in", "array", "form", "." ]
932134ca8542d903e5e9d5dbb5b9e23fa24ecd95
https://github.com/schulzefelix/laravel-data-transfer-object/blob/932134ca8542d903e5e9d5dbb5b9e23fa24ecd95/src/DataTransferObject.php#L601-L618
train
schulzefelix/laravel-data-transfer-object
src/DataTransferObject.php
DataTransferObject.attributesToArray
public function attributesToArray() { $attributes = $this->attributes; // If an attribute is a date, we will cast it to a string after converting it // to a DateTime / Carbon instance. This is so we will get some consistent // formatting while accessing attributes vs. arraying / JSONing a object. foreach ($this->getDates() as $key) { if (! isset($attributes[$key])) { continue; } $attributes[$key] = $this->serializeDate( $this->asDateTime($attributes[$key]) ); } $mutatedAttributes = $this->getMutatedAttributes(); // We want to spin through all the mutated attributes for this object and call // the mutator for the attribute. We cache off every mutated attributes so // we don't have to constantly check on attributes that actually change. foreach ($mutatedAttributes as $key) { if (! array_key_exists($key, $attributes)) { continue; } $attributes[$key] = $this->mutateAttributeForArray( $key, $attributes[$key] ); } // Next we will handle any casts that have been setup for this object and cast // the values to their appropriate type. If the attribute has a mutator we // will not perform the cast on those attributes to avoid any confusion. foreach ($this->getCasts() as $key => $value) { if (! array_key_exists($key, $attributes) || in_array($key, $mutatedAttributes)) { continue; } $attributes[$key] = $this->castAttribute( $key, $attributes[$key] ); if ($attributes[$key] && ($value === 'date' || $value === 'datetime')) { $attributes[$key] = $this->serializeDate($attributes[$key]); } } return $attributes; }
php
public function attributesToArray() { $attributes = $this->attributes; // If an attribute is a date, we will cast it to a string after converting it // to a DateTime / Carbon instance. This is so we will get some consistent // formatting while accessing attributes vs. arraying / JSONing a object. foreach ($this->getDates() as $key) { if (! isset($attributes[$key])) { continue; } $attributes[$key] = $this->serializeDate( $this->asDateTime($attributes[$key]) ); } $mutatedAttributes = $this->getMutatedAttributes(); // We want to spin through all the mutated attributes for this object and call // the mutator for the attribute. We cache off every mutated attributes so // we don't have to constantly check on attributes that actually change. foreach ($mutatedAttributes as $key) { if (! array_key_exists($key, $attributes)) { continue; } $attributes[$key] = $this->mutateAttributeForArray( $key, $attributes[$key] ); } // Next we will handle any casts that have been setup for this object and cast // the values to their appropriate type. If the attribute has a mutator we // will not perform the cast on those attributes to avoid any confusion. foreach ($this->getCasts() as $key => $value) { if (! array_key_exists($key, $attributes) || in_array($key, $mutatedAttributes)) { continue; } $attributes[$key] = $this->castAttribute( $key, $attributes[$key] ); if ($attributes[$key] && ($value === 'date' || $value === 'datetime')) { $attributes[$key] = $this->serializeDate($attributes[$key]); } } return $attributes; }
[ "public", "function", "attributesToArray", "(", ")", "{", "$", "attributes", "=", "$", "this", "->", "attributes", ";", "// If an attribute is a date, we will cast it to a string after converting it", "// to a DateTime / Carbon instance. This is so we will get some consistent", "// f...
Convert the object's attributes to an array. @return array
[ "Convert", "the", "object", "s", "attributes", "to", "an", "array", "." ]
932134ca8542d903e5e9d5dbb5b9e23fa24ecd95
https://github.com/schulzefelix/laravel-data-transfer-object/blob/932134ca8542d903e5e9d5dbb5b9e23fa24ecd95/src/DataTransferObject.php#L625-L676
train
samuelbednarcik/elastic-apm-php-agent
src/EventIntakeRequest.php
EventIntakeRequest.getRequestBody
public function getRequestBody(): string { if ($this->metadata === null) { throw new BadEventRequestException('Metadata must be defined!'); } $json = $this->serializer->encode( ['metadata' => $this->serializer->normalize($this->metadata)], JsonEncoder::FORMAT ); $json .= "\n"; foreach ($this->transactions as $transaction) { $json .= "\n"; $json .= $this->serializer->encode( ['transaction' => $this->serializer->normalize($transaction)], JsonEncoder::FORMAT ); } $json .= "\n"; foreach ($this->spans as $span) { $json .= "\n"; $json .= $this->serializer->encode( ['span' => $this->serializer->normalize($span)], JsonEncoder::FORMAT ); } $json .= "\n"; foreach ($this->errors as $error) { $json .= "\n"; $json .= $this->serializer->encode( ['error' => $this->serializer->normalize($error)], JsonEncoder::FORMAT ); } return $json; }
php
public function getRequestBody(): string { if ($this->metadata === null) { throw new BadEventRequestException('Metadata must be defined!'); } $json = $this->serializer->encode( ['metadata' => $this->serializer->normalize($this->metadata)], JsonEncoder::FORMAT ); $json .= "\n"; foreach ($this->transactions as $transaction) { $json .= "\n"; $json .= $this->serializer->encode( ['transaction' => $this->serializer->normalize($transaction)], JsonEncoder::FORMAT ); } $json .= "\n"; foreach ($this->spans as $span) { $json .= "\n"; $json .= $this->serializer->encode( ['span' => $this->serializer->normalize($span)], JsonEncoder::FORMAT ); } $json .= "\n"; foreach ($this->errors as $error) { $json .= "\n"; $json .= $this->serializer->encode( ['error' => $this->serializer->normalize($error)], JsonEncoder::FORMAT ); } return $json; }
[ "public", "function", "getRequestBody", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "metadata", "===", "null", ")", "{", "throw", "new", "BadEventRequestException", "(", "'Metadata must be defined!'", ")", ";", "}", "$", "json", "=", "$", "...
Returns NDJSON request body @throws BadEventRequestException
[ "Returns", "NDJSON", "request", "body" ]
3e6cb56513905b20c707ccb78ae7cfe7a0175648
https://github.com/samuelbednarcik/elastic-apm-php-agent/blob/3e6cb56513905b20c707ccb78ae7cfe7a0175648/src/EventIntakeRequest.php#L143-L185
train
samuelbednarcik/elastic-apm-php-agent
src/Agent.php
Agent.collect
private function collect(): array { $spans = []; foreach ($this->collectors as $collector) { foreach ($collector->getSpans() as $span) { $spans[] = $this->prepareSpan($span); } } return $spans; }
php
private function collect(): array { $spans = []; foreach ($this->collectors as $collector) { foreach ($collector->getSpans() as $span) { $spans[] = $this->prepareSpan($span); } } return $spans; }
[ "private", "function", "collect", "(", ")", ":", "array", "{", "$", "spans", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "collectors", "as", "$", "collector", ")", "{", "foreach", "(", "$", "collector", "->", "getSpans", "(", ")", "as", ...
Collect spans from registered collectors @return Span[] @throws \Exception
[ "Collect", "spans", "from", "registered", "collectors" ]
3e6cb56513905b20c707ccb78ae7cfe7a0175648
https://github.com/samuelbednarcik/elastic-apm-php-agent/blob/3e6cb56513905b20c707ccb78ae7cfe7a0175648/src/Agent.php#L150-L161
train
samuelbednarcik/elastic-apm-php-agent
src/Agent.php
Agent.prepareTransaction
private function prepareTransaction() { $this->transaction->setSpanCount([ 'started' => count($this->spans) ]); if (empty($this->transaction->getContext()) || empty($this->spans)) { $this->transaction->setSampled(false); } }
php
private function prepareTransaction() { $this->transaction->setSpanCount([ 'started' => count($this->spans) ]); if (empty($this->transaction->getContext()) || empty($this->spans)) { $this->transaction->setSampled(false); } }
[ "private", "function", "prepareTransaction", "(", ")", "{", "$", "this", "->", "transaction", "->", "setSpanCount", "(", "[", "'started'", "=>", "count", "(", "$", "this", "->", "spans", ")", "]", ")", ";", "if", "(", "empty", "(", "$", "this", "->", ...
Prepare transaction for sending to APM.
[ "Prepare", "transaction", "for", "sending", "to", "APM", "." ]
3e6cb56513905b20c707ccb78ae7cfe7a0175648
https://github.com/samuelbednarcik/elastic-apm-php-agent/blob/3e6cb56513905b20c707ccb78ae7cfe7a0175648/src/Agent.php#L199-L208
train
samuelbednarcik/elastic-apm-php-agent
src/Agent.php
Agent.prepareSpan
private function prepareSpan(Span $span): Span { $span->setTransactionId($this->transaction->getId()); $span->setTraceId($this->transaction->getTraceId()); if ($span->getId() === null) { $span->setId(AbstractEventBuilder::generateRandomBitsInHex(64)); } if ($span->getParentId() === null) { $span->setParentId($this->transaction->getId()); } if ($span->getStart() === null) { $span->setStart( intval(round(($span->getTimestamp() - $this->transaction->getTimestamp()) / 1000)) ); } return $span; }
php
private function prepareSpan(Span $span): Span { $span->setTransactionId($this->transaction->getId()); $span->setTraceId($this->transaction->getTraceId()); if ($span->getId() === null) { $span->setId(AbstractEventBuilder::generateRandomBitsInHex(64)); } if ($span->getParentId() === null) { $span->setParentId($this->transaction->getId()); } if ($span->getStart() === null) { $span->setStart( intval(round(($span->getTimestamp() - $this->transaction->getTimestamp()) / 1000)) ); } return $span; }
[ "private", "function", "prepareSpan", "(", "Span", "$", "span", ")", ":", "Span", "{", "$", "span", "->", "setTransactionId", "(", "$", "this", "->", "transaction", "->", "getId", "(", ")", ")", ";", "$", "span", "->", "setTraceId", "(", "$", "this", ...
Prepare span for for sending to APM. @param Span $span @return Span @throws \Exception
[ "Prepare", "span", "for", "for", "sending", "to", "APM", "." ]
3e6cb56513905b20c707ccb78ae7cfe7a0175648
https://github.com/samuelbednarcik/elastic-apm-php-agent/blob/3e6cb56513905b20c707ccb78ae7cfe7a0175648/src/Agent.php#L216-L236
train
yii2mod/yii2-ftp
FtpClient.php
FtpClient.connect
public function connect($host, $ssl = false, $port = 21, $timeout = 90) { if ($ssl) { $this->conn = @$this->ftp->ssl_connect($host, $port, $timeout); } else { $this->conn = @$this->ftp->connect($host, $port, $timeout); } if (!$this->conn) { throw new FtpException('Unable to connect'); } return $this; }
php
public function connect($host, $ssl = false, $port = 21, $timeout = 90) { if ($ssl) { $this->conn = @$this->ftp->ssl_connect($host, $port, $timeout); } else { $this->conn = @$this->ftp->connect($host, $port, $timeout); } if (!$this->conn) { throw new FtpException('Unable to connect'); } return $this; }
[ "public", "function", "connect", "(", "$", "host", ",", "$", "ssl", "=", "false", ",", "$", "port", "=", "21", ",", "$", "timeout", "=", "90", ")", "{", "if", "(", "$", "ssl", ")", "{", "$", "this", "->", "conn", "=", "@", "$", "this", "->", ...
Open a FTP connection @param string $host @param bool $ssl @param int $port @param int $timeout @return FTPClient @throws FtpException If unable to connect
[ "Open", "a", "FTP", "connection" ]
7ff81d63d80a7bc6ff4f24668d82ac9b77fe79a2
https://github.com/yii2mod/yii2-ftp/blob/7ff81d63d80a7bc6ff4f24668d82ac9b77fe79a2/FtpClient.php#L153-L165
train
yii2mod/yii2-ftp
FtpClient.php
FtpClient.rawlist
public function rawlist($directory = '.', $recursive = false, $includeHidden = false) { if (!$this->isDir($directory)) { throw new FtpException('"' . $directory . '" is not a directory.'); } if ($includeHidden) { $directory = "-la $directory"; } $list = $this->ftp->rawlist($directory); if (false === $list) { // $list can be false, convert to empty array $list = []; } $items = []; if (false == $recursive) { foreach ($list as $path => $item) { $chunks = preg_split("/\s+/", $item); // if not "name" if (empty($chunks[8]) || $chunks[8] == '.' || $chunks[8] == '..') { continue; } $path = $directory . '/' . $chunks[8]; if (substr($path, 0, 2) == './') { $path = substr($path, 2); } $items[$this->rawToType($item) . '#' . $path] = $item; } return $items; } foreach ($list as $item) { $len = strlen($item); if (!$len // "." || ($item[$len - 1] == '.' && $item[$len - 2] == ' ' // ".." or $item[$len - 1] == '.' && $item[$len - 2] == '.' && $item[$len - 3] == ' ') ) { continue; } $chunks = preg_split("/\s+/", $item); // if not "name" if (empty($chunks[8]) || $chunks[8] == '.' || $chunks[8] == '..') { continue; } $path = $directory . '/' . $chunks[8]; if (substr($path, 0, 2) == './') { $path = substr($path, 2); } $items[$this->rawToType($item) . '#' . $path] = $item; if ($item[0] == 'd') { $sublist = $this->rawlist($path, true); foreach ($sublist as $subpath => $subitem) { $items[$subpath] = $subitem; } } } return $items; }
php
public function rawlist($directory = '.', $recursive = false, $includeHidden = false) { if (!$this->isDir($directory)) { throw new FtpException('"' . $directory . '" is not a directory.'); } if ($includeHidden) { $directory = "-la $directory"; } $list = $this->ftp->rawlist($directory); if (false === $list) { // $list can be false, convert to empty array $list = []; } $items = []; if (false == $recursive) { foreach ($list as $path => $item) { $chunks = preg_split("/\s+/", $item); // if not "name" if (empty($chunks[8]) || $chunks[8] == '.' || $chunks[8] == '..') { continue; } $path = $directory . '/' . $chunks[8]; if (substr($path, 0, 2) == './') { $path = substr($path, 2); } $items[$this->rawToType($item) . '#' . $path] = $item; } return $items; } foreach ($list as $item) { $len = strlen($item); if (!$len // "." || ($item[$len - 1] == '.' && $item[$len - 2] == ' ' // ".." or $item[$len - 1] == '.' && $item[$len - 2] == '.' && $item[$len - 3] == ' ') ) { continue; } $chunks = preg_split("/\s+/", $item); // if not "name" if (empty($chunks[8]) || $chunks[8] == '.' || $chunks[8] == '..') { continue; } $path = $directory . '/' . $chunks[8]; if (substr($path, 0, 2) == './') { $path = substr($path, 2); } $items[$this->rawToType($item) . '#' . $path] = $item; if ($item[0] == 'd') { $sublist = $this->rawlist($path, true); foreach ($sublist as $subpath => $subitem) { $items[$subpath] = $subitem; } } } return $items; }
[ "public", "function", "rawlist", "(", "$", "directory", "=", "'.'", ",", "$", "recursive", "=", "false", ",", "$", "includeHidden", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "isDir", "(", "$", "directory", ")", ")", "{", "throw", "...
Returns a detailed list of files in the given directory. @see FtpClient::nlist() @see FtpClient::scanDir() @see FtpClient::dirSize() @param string $directory The directory, by default is the current directory @param bool $recursive @param bool $includeHidden @return array @throws FtpException
[ "Returns", "a", "detailed", "list", "of", "files", "in", "the", "given", "directory", "." ]
7ff81d63d80a7bc6ff4f24668d82ac9b77fe79a2
https://github.com/yii2mod/yii2-ftp/blob/7ff81d63d80a7bc6ff4f24668d82ac9b77fe79a2/FtpClient.php#L661-L724
train
yii2mod/yii2-ftp
FtpClient.php
FtpClient.parseRawList
public function parseRawList(array $rawlist) { $items = []; $path = ''; foreach ($rawlist as $key => $child) { $chunks = preg_split("/\s+/", $child); if (isset($chunks[8]) && ($chunks[8] == '.' or $chunks[8] == '..')) { continue; } if (count($chunks) === 1) { $len = strlen($chunks[0]); if ($len && $chunks[0][$len - 1] == ':') { $path = substr($chunks[0], 0, -1); } continue; } // $chunks[8] and up contains filename (multiple elements if filename contains spaces) // up to last element or element containing '->' (if type is 'link') $target = ''; $linkArrowElement = array_search('->', $chunks); if ($linkArrowElement !== false) { $filenameChunks = array_slice($chunks, 8, count($chunks) - $linkArrowElement - 1); $filename = implode(' ', $filenameChunks); $targetChunks = array_slice($chunks, $linkArrowElement + 1); $target = implode(' ', $targetChunks); } else { $filenameChunks = array_slice($chunks, 8); $filename = implode(' ', $filenameChunks); } $item = [ 'permissions' => $chunks[0], 'number' => $chunks[1], 'owner' => $chunks[2], 'group' => $chunks[3], 'size' => $chunks[4], 'month' => $chunks[5], 'day' => $chunks[6], 'time' => $chunks[7], 'name' => $filename, 'type' => $this->rawToType($chunks[0]), ]; if ($item['type'] == 'link') { $item['target'] = $target; } // if the key is not the path, behavior of ftp_rawlist() PHP function if (is_int($key) || false === strpos($key, $item['name'])) { array_splice($chunks, 0, 8); $key = $item['type'] . '#' . ($path ? $path . '/' : '') . implode(' ', $chunks); if ($item['type'] == 'link') { // get the first part of 'link#the-link.ext -> /path/of/the/source.ext' $exp = explode(' ->', $key); $key = rtrim($exp[0]); } $items[$key] = $item; } else { // the key is the path, behavior of FtpClient::rawlist() method() $items[$key] = $item; } } return $items; }
php
public function parseRawList(array $rawlist) { $items = []; $path = ''; foreach ($rawlist as $key => $child) { $chunks = preg_split("/\s+/", $child); if (isset($chunks[8]) && ($chunks[8] == '.' or $chunks[8] == '..')) { continue; } if (count($chunks) === 1) { $len = strlen($chunks[0]); if ($len && $chunks[0][$len - 1] == ':') { $path = substr($chunks[0], 0, -1); } continue; } // $chunks[8] and up contains filename (multiple elements if filename contains spaces) // up to last element or element containing '->' (if type is 'link') $target = ''; $linkArrowElement = array_search('->', $chunks); if ($linkArrowElement !== false) { $filenameChunks = array_slice($chunks, 8, count($chunks) - $linkArrowElement - 1); $filename = implode(' ', $filenameChunks); $targetChunks = array_slice($chunks, $linkArrowElement + 1); $target = implode(' ', $targetChunks); } else { $filenameChunks = array_slice($chunks, 8); $filename = implode(' ', $filenameChunks); } $item = [ 'permissions' => $chunks[0], 'number' => $chunks[1], 'owner' => $chunks[2], 'group' => $chunks[3], 'size' => $chunks[4], 'month' => $chunks[5], 'day' => $chunks[6], 'time' => $chunks[7], 'name' => $filename, 'type' => $this->rawToType($chunks[0]), ]; if ($item['type'] == 'link') { $item['target'] = $target; } // if the key is not the path, behavior of ftp_rawlist() PHP function if (is_int($key) || false === strpos($key, $item['name'])) { array_splice($chunks, 0, 8); $key = $item['type'] . '#' . ($path ? $path . '/' : '') . implode(' ', $chunks); if ($item['type'] == 'link') { // get the first part of 'link#the-link.ext -> /path/of/the/source.ext' $exp = explode(' ->', $key); $key = rtrim($exp[0]); } $items[$key] = $item; } else { // the key is the path, behavior of FtpClient::rawlist() method() $items[$key] = $item; } } return $items; }
[ "public", "function", "parseRawList", "(", "array", "$", "rawlist", ")", "{", "$", "items", "=", "[", "]", ";", "$", "path", "=", "''", ";", "foreach", "(", "$", "rawlist", "as", "$", "key", "=>", "$", "child", ")", "{", "$", "chunks", "=", "preg...
Parse raw list @see FtpClient::rawlist() @see FtpClient::scanDir() @see FtpClient::dirSize() @param array $rawlist @return array
[ "Parse", "raw", "list" ]
7ff81d63d80a7bc6ff4f24668d82ac9b77fe79a2
https://github.com/yii2mod/yii2-ftp/blob/7ff81d63d80a7bc6ff4f24668d82ac9b77fe79a2/FtpClient.php#L737-L800
train
keenlabs/KeenClient-PHP
src/Client/KeenIOClient.php
KeenIOClient.factory
public static function factory($config = array()) { $default = array( 'masterKey' => null, 'writeKey' => null, 'readKey' => null, 'projectId' => null, 'organizationKey' => null, 'organizationId' => null, 'version' => '3.0', 'headers' => array( 'Keen-Sdk' => 'php-' . self::VERSION ) ); // Create client configuration $config = self::parseConfig($config, $default); $file = 'keen-io-' . str_replace('.', '_', $config['version']) . '.php'; // Create the new Keen IO Client with our Configuration return new self( new Client($config), new Description(include __DIR__ . "/Resources/{$file}"), null, function ($arg) { return json_decode($arg->getBody(), true); }, null, $config ); }
php
public static function factory($config = array()) { $default = array( 'masterKey' => null, 'writeKey' => null, 'readKey' => null, 'projectId' => null, 'organizationKey' => null, 'organizationId' => null, 'version' => '3.0', 'headers' => array( 'Keen-Sdk' => 'php-' . self::VERSION ) ); // Create client configuration $config = self::parseConfig($config, $default); $file = 'keen-io-' . str_replace('.', '_', $config['version']) . '.php'; // Create the new Keen IO Client with our Configuration return new self( new Client($config), new Description(include __DIR__ . "/Resources/{$file}"), null, function ($arg) { return json_decode($arg->getBody(), true); }, null, $config ); }
[ "public", "static", "function", "factory", "(", "$", "config", "=", "array", "(", ")", ")", "{", "$", "default", "=", "array", "(", "'masterKey'", "=>", "null", ",", "'writeKey'", "=>", "null", ",", "'readKey'", "=>", "null", ",", "'projectId'", "=>", ...
Factory to create new KeenIOClient instance. @param array $config @returns \KeenIO\Client\KeenIOClient
[ "Factory", "to", "create", "new", "KeenIOClient", "instance", "." ]
883b75cb64327211d83d5756caa3fd7a17eabdbc
https://github.com/keenlabs/KeenClient-PHP/blob/883b75cb64327211d83d5756caa3fd7a17eabdbc/src/Client/KeenIOClient.php#L54-L85
train
keenlabs/KeenClient-PHP
src/Client/KeenIOClient.php
KeenIOClient.createScopedKey
public function createScopedKey($filters, $allowedOperations) { if (!$masterKey = $this->getMasterKey()) { throw new RuntimeException('A master key is needed to create a scoped key'); } $options = array('filters' => $filters); if (!empty($allowedOperations)) { $options['allowed_operations'] = $allowedOperations; } $apiKey = pack('H*', $masterKey); $opensslOptions = \OPENSSL_RAW_DATA; $optionsJson = json_encode($options); /** * Use the old block size and hex string input if using a legacy master key. * Old block size was 32 bytes and old master key was 32 hex characters in length. */ if (strlen($masterKey) == 32) { $apiKey = $masterKey; // Openssl's built-in PKCS7 padding won't use the 32 bytes block size, so apply it in userland // and use OPENSSL zero padding (no-op as already padded) $opensslOptions |= \OPENSSL_ZERO_PADDING; $optionsJson = $this->padString($optionsJson, 32); } $cipher = 'AES-256-CBC'; $ivLength = openssl_cipher_iv_length($cipher); $iv = random_bytes($ivLength); $encrypted = openssl_encrypt($optionsJson, $cipher, $apiKey, $opensslOptions, $iv); $ivHex = bin2hex($iv); $encryptedHex = bin2hex($encrypted); $scopedKey = $ivHex . $encryptedHex; return $scopedKey; }
php
public function createScopedKey($filters, $allowedOperations) { if (!$masterKey = $this->getMasterKey()) { throw new RuntimeException('A master key is needed to create a scoped key'); } $options = array('filters' => $filters); if (!empty($allowedOperations)) { $options['allowed_operations'] = $allowedOperations; } $apiKey = pack('H*', $masterKey); $opensslOptions = \OPENSSL_RAW_DATA; $optionsJson = json_encode($options); /** * Use the old block size and hex string input if using a legacy master key. * Old block size was 32 bytes and old master key was 32 hex characters in length. */ if (strlen($masterKey) == 32) { $apiKey = $masterKey; // Openssl's built-in PKCS7 padding won't use the 32 bytes block size, so apply it in userland // and use OPENSSL zero padding (no-op as already padded) $opensslOptions |= \OPENSSL_ZERO_PADDING; $optionsJson = $this->padString($optionsJson, 32); } $cipher = 'AES-256-CBC'; $ivLength = openssl_cipher_iv_length($cipher); $iv = random_bytes($ivLength); $encrypted = openssl_encrypt($optionsJson, $cipher, $apiKey, $opensslOptions, $iv); $ivHex = bin2hex($iv); $encryptedHex = bin2hex($encrypted); $scopedKey = $ivHex . $encryptedHex; return $scopedKey; }
[ "public", "function", "createScopedKey", "(", "$", "filters", ",", "$", "allowedOperations", ")", "{", "if", "(", "!", "$", "masterKey", "=", "$", "this", "->", "getMasterKey", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'A master key is ne...
Get a scoped key for an array of filters @param array $filters What filters to encode into a scoped key @param array $allowedOperations What operations the generated scoped key will allow @return string @throws RuntimeException If no master key is set
[ "Get", "a", "scoped", "key", "for", "an", "array", "of", "filters" ]
883b75cb64327211d83d5756caa3fd7a17eabdbc
https://github.com/keenlabs/KeenClient-PHP/blob/883b75cb64327211d83d5756caa3fd7a17eabdbc/src/Client/KeenIOClient.php#L304-L349
train
keenlabs/KeenClient-PHP
src/Client/KeenIOClient.php
KeenIOClient.padString
protected function padString($string, $blockSize = 32) { $paddingSize = $blockSize - (strlen($string) % $blockSize); $string .= str_repeat(chr($paddingSize), $paddingSize); return $string; }
php
protected function padString($string, $blockSize = 32) { $paddingSize = $blockSize - (strlen($string) % $blockSize); $string .= str_repeat(chr($paddingSize), $paddingSize); return $string; }
[ "protected", "function", "padString", "(", "$", "string", ",", "$", "blockSize", "=", "32", ")", "{", "$", "paddingSize", "=", "$", "blockSize", "-", "(", "strlen", "(", "$", "string", ")", "%", "$", "blockSize", ")", ";", "$", "string", ".=", "str_r...
Implement PKCS7 padding @param string $string @param int $blockSize @return string
[ "Implement", "PKCS7", "padding" ]
883b75cb64327211d83d5756caa3fd7a17eabdbc
https://github.com/keenlabs/KeenClient-PHP/blob/883b75cb64327211d83d5756caa3fd7a17eabdbc/src/Client/KeenIOClient.php#L359-L365
train
keenlabs/KeenClient-PHP
src/Client/KeenIOClient.php
KeenIOClient.unpadString
protected function unpadString($string) { $len = strlen($string); $pad = ord($string[$len - 1]); return substr($string, 0, $len - $pad); }
php
protected function unpadString($string) { $len = strlen($string); $pad = ord($string[$len - 1]); return substr($string, 0, $len - $pad); }
[ "protected", "function", "unpadString", "(", "$", "string", ")", "{", "$", "len", "=", "strlen", "(", "$", "string", ")", ";", "$", "pad", "=", "ord", "(", "$", "string", "[", "$", "len", "-", "1", "]", ")", ";", "return", "substr", "(", "$", "...
Remove padding for a PKCS7-padded string @param string $string @return string
[ "Remove", "padding", "for", "a", "PKCS7", "-", "padded", "string" ]
883b75cb64327211d83d5756caa3fd7a17eabdbc
https://github.com/keenlabs/KeenClient-PHP/blob/883b75cb64327211d83d5756caa3fd7a17eabdbc/src/Client/KeenIOClient.php#L422-L428
train
keenlabs/KeenClient-PHP
src/Client/KeenIOClient.php
KeenIOClient.parseConfig
protected static function parseConfig($config, $default) { array_walk($default, function ($value, $key) use (&$config) { if (empty($config[$key]) || !isset($config[$key])) { $config[$key] = $value; } }); return $config; }
php
protected static function parseConfig($config, $default) { array_walk($default, function ($value, $key) use (&$config) { if (empty($config[$key]) || !isset($config[$key])) { $config[$key] = $value; } }); return $config; }
[ "protected", "static", "function", "parseConfig", "(", "$", "config", ",", "$", "default", ")", "{", "array_walk", "(", "$", "default", ",", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "&", "$", "config", ")", "{", "if", "(", "...
Attempt to parse config and apply defaults @param array $config @param array $default @return array Returns the updated config array
[ "Attempt", "to", "parse", "config", "and", "apply", "defaults" ]
883b75cb64327211d83d5756caa3fd7a17eabdbc
https://github.com/keenlabs/KeenClient-PHP/blob/883b75cb64327211d83d5756caa3fd7a17eabdbc/src/Client/KeenIOClient.php#L438-L447
train
keenlabs/KeenClient-PHP
src/Client/KeenIOClient.php
KeenIOClient.combineEventCollectionArgs
private static function combineEventCollectionArgs(array $args) { $formattedArgs = array(); if (isset($args[0]) && is_string($args[0])) { $formattedArgs['event_collection'] = $args[0]; if (isset($args[1]) && is_array($args[1])) { $formattedArgs = array_merge($formattedArgs, $args[1]); } } elseif (isset($args[0]) && is_array($args[0])) { $formattedArgs = $args[0]; } return $formattedArgs; }
php
private static function combineEventCollectionArgs(array $args) { $formattedArgs = array(); if (isset($args[0]) && is_string($args[0])) { $formattedArgs['event_collection'] = $args[0]; if (isset($args[1]) && is_array($args[1])) { $formattedArgs = array_merge($formattedArgs, $args[1]); } } elseif (isset($args[0]) && is_array($args[0])) { $formattedArgs = $args[0]; } return $formattedArgs; }
[ "private", "static", "function", "combineEventCollectionArgs", "(", "array", "$", "args", ")", "{", "$", "formattedArgs", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "args", "[", "0", "]", ")", "&&", "is_string", "(", "$", "args", "[", ...
Translate a set of args to merge a lone event_collection into an array with the other params @param array $args Arguments to be formatted @return array A single array with event_collection merged in @access private
[ "Translate", "a", "set", "of", "args", "to", "merge", "a", "lone", "event_collection", "into", "an", "array", "with", "the", "other", "params" ]
883b75cb64327211d83d5756caa3fd7a17eabdbc
https://github.com/keenlabs/KeenClient-PHP/blob/883b75cb64327211d83d5756caa3fd7a17eabdbc/src/Client/KeenIOClient.php#L458-L473
train
unclecheese/silverstripe-display-logic
src/Extensions/DisplayLogic.php
DisplayLogic.displayIf
public function displayIf($master) { $class ="display-logic display-logic-hidden display-logic-display"; $this->owner->addExtraClass($class); if ($this->owner->hasMethod('addHolderClass')) { $this->owner->addHolderClass($class); } return $this->setDisplayLogicCriteria(Criteria::create($this->owner, $master)); }
php
public function displayIf($master) { $class ="display-logic display-logic-hidden display-logic-display"; $this->owner->addExtraClass($class); if ($this->owner->hasMethod('addHolderClass')) { $this->owner->addHolderClass($class); } return $this->setDisplayLogicCriteria(Criteria::create($this->owner, $master)); }
[ "public", "function", "displayIf", "(", "$", "master", ")", "{", "$", "class", "=", "\"display-logic display-logic-hidden display-logic-display\"", ";", "$", "this", "->", "owner", "->", "addExtraClass", "(", "$", "class", ")", ";", "if", "(", "$", "this", "->...
If the criteria evaluate true, the field should display @param string $master The name of the master field @return Criteria
[ "If", "the", "criteria", "evaluate", "true", "the", "field", "should", "display" ]
845ab12189439422b6dcd1becd20c9d5a94eb558
https://github.com/unclecheese/silverstripe-display-logic/blob/845ab12189439422b6dcd1becd20c9d5a94eb558/src/Extensions/DisplayLogic.php#L40-L50
train
unclecheese/silverstripe-display-logic
src/Extensions/DisplayLogic.php
DisplayLogic.DisplayLogic
public function DisplayLogic() { if ($criteria = $this->getDisplayLogicCriteria()) { Requirements::javascript('unclecheese/display-logic: client/dist/js/bundle.js'); Requirements::css('unclecheese/display-logic: client/dist/styles/bundle.css'); return $criteria->toScript(); } return false; }
php
public function DisplayLogic() { if ($criteria = $this->getDisplayLogicCriteria()) { Requirements::javascript('unclecheese/display-logic: client/dist/js/bundle.js'); Requirements::css('unclecheese/display-logic: client/dist/styles/bundle.css'); return $criteria->toScript(); } return false; }
[ "public", "function", "DisplayLogic", "(", ")", "{", "if", "(", "$", "criteria", "=", "$", "this", "->", "getDisplayLogicCriteria", "(", ")", ")", "{", "Requirements", "::", "javascript", "(", "'unclecheese/display-logic: client/dist/js/bundle.js'", ")", ";", "Req...
Loads the dependencies and renders the JavaScript-readable logic to the form HTML @return string
[ "Loads", "the", "dependencies", "and", "renders", "the", "JavaScript", "-", "readable", "logic", "to", "the", "form", "HTML" ]
845ab12189439422b6dcd1becd20c9d5a94eb558
https://github.com/unclecheese/silverstripe-display-logic/blob/845ab12189439422b6dcd1becd20c9d5a94eb558/src/Extensions/DisplayLogic.php#L127-L136
train
unclecheese/silverstripe-display-logic
src/Criteria.php
Criteria.set_default_animation
public static function set_default_animation($animation) { if (in_array($animation, Config::inst()->get(__CLASS__, 'animations'))) { Config::modify()->set(__CLASS__, 'default_animation', $animation); } }
php
public static function set_default_animation($animation) { if (in_array($animation, Config::inst()->get(__CLASS__, 'animations'))) { Config::modify()->set(__CLASS__, 'default_animation', $animation); } }
[ "public", "static", "function", "set_default_animation", "(", "$", "animation", ")", "{", "if", "(", "in_array", "(", "$", "animation", ",", "Config", "::", "inst", "(", ")", "->", "get", "(", "__CLASS__", ",", "'animations'", ")", ")", ")", "{", "Config...
Changes the configured default animation method @param string $animation
[ "Changes", "the", "configured", "default", "animation", "method" ]
845ab12189439422b6dcd1becd20c9d5a94eb558
https://github.com/unclecheese/silverstripe-display-logic/blob/845ab12189439422b6dcd1becd20c9d5a94eb558/src/Criteria.php#L73-L78
train
unclecheese/silverstripe-display-logic
src/Criteria.php
Criteria.toScript
public function toScript() { $script = "("; $first = true; foreach ($this->getCriteria() as $c) { $script .= $first ? "" : " {$this->getLogicalOperator()} "; $script .= $c->toScript(); $first = false; } $script .= ")"; return $script; }
php
public function toScript() { $script = "("; $first = true; foreach ($this->getCriteria() as $c) { $script .= $first ? "" : " {$this->getLogicalOperator()} "; $script .= $c->toScript(); $first = false; } $script .= ")"; return $script; }
[ "public", "function", "toScript", "(", ")", "{", "$", "script", "=", "\"(\"", ";", "$", "first", "=", "true", ";", "foreach", "(", "$", "this", "->", "getCriteria", "(", ")", "as", "$", "c", ")", "{", "$", "script", ".=", "$", "first", "?", "\"\"...
Creates a JavaScript readable representation of the logic @return string
[ "Creates", "a", "JavaScript", "readable", "representation", "of", "the", "logic" ]
845ab12189439422b6dcd1becd20c9d5a94eb558
https://github.com/unclecheese/silverstripe-display-logic/blob/845ab12189439422b6dcd1becd20c9d5a94eb558/src/Criteria.php#L271-L282
train
Sylius/SyliusResourceBundle
src/Bundle/Controller/RequestConfiguration.php
RequestConfiguration.getRedirectReferer
public function getRedirectReferer() { $redirect = $this->parameters->get('redirect'); $referer = $this->request->headers->get('referer'); if (!is_array($redirect) || empty($redirect['referer'])) { return $referer; } if ($redirect['referer'] === true) { return $referer; } return $redirect['referer']; }
php
public function getRedirectReferer() { $redirect = $this->parameters->get('redirect'); $referer = $this->request->headers->get('referer'); if (!is_array($redirect) || empty($redirect['referer'])) { return $referer; } if ($redirect['referer'] === true) { return $referer; } return $redirect['referer']; }
[ "public", "function", "getRedirectReferer", "(", ")", "{", "$", "redirect", "=", "$", "this", "->", "parameters", "->", "get", "(", "'redirect'", ")", ";", "$", "referer", "=", "$", "this", "->", "request", "->", "headers", "->", "get", "(", "'referer'",...
Get redirect referer, This will detected by configuration If not exists, The `referrer` from headers will be used. @return string
[ "Get", "redirect", "referer", "This", "will", "detected", "by", "configuration", "If", "not", "exists", "The", "referrer", "from", "headers", "will", "be", "used", "." ]
92c8e365a7c15aa436429b07dd14e7b2f8965f2f
https://github.com/Sylius/SyliusResourceBundle/blob/92c8e365a7c15aa436429b07dd14e7b2f8965f2f/src/Bundle/Controller/RequestConfiguration.php#L203-L217
train
Sylius/SyliusResourceBundle
src/Bundle/AbstractResourceBundle.php
AbstractResourceBundle.getMappingCompilerPassInfo
protected function getMappingCompilerPassInfo(string $driverType): array { switch ($driverType) { case SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM: @trigger_error(sprintf( 'The "%s" driver is deprecated in Sylius 1.3. Doctrine MongoDB and PHPCR will no longer be supported in Sylius 2.0.', $driverType ), \E_USER_DEPRECATED); $mappingsPassClassname = DoctrineMongoDBMappingsPass::class; break; case SyliusResourceBundle::DRIVER_DOCTRINE_ORM: $mappingsPassClassname = DoctrineOrmMappingsPass::class; break; case SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM: @trigger_error(sprintf( 'The "%s" driver is deprecated in Sylius 1.3. Doctrine MongoDB and PHPCR will no longer be supported in Sylius 2.0.', $driverType ), \E_USER_DEPRECATED); $mappingsPassClassname = DoctrinePhpcrMappingsPass::class; break; default: throw new UnknownDriverException($driverType); } $compilerPassMethod = sprintf('create%sMappingDriver', ucfirst($this->mappingFormat)); return [$mappingsPassClassname, $compilerPassMethod]; }
php
protected function getMappingCompilerPassInfo(string $driverType): array { switch ($driverType) { case SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM: @trigger_error(sprintf( 'The "%s" driver is deprecated in Sylius 1.3. Doctrine MongoDB and PHPCR will no longer be supported in Sylius 2.0.', $driverType ), \E_USER_DEPRECATED); $mappingsPassClassname = DoctrineMongoDBMappingsPass::class; break; case SyliusResourceBundle::DRIVER_DOCTRINE_ORM: $mappingsPassClassname = DoctrineOrmMappingsPass::class; break; case SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM: @trigger_error(sprintf( 'The "%s" driver is deprecated in Sylius 1.3. Doctrine MongoDB and PHPCR will no longer be supported in Sylius 2.0.', $driverType ), \E_USER_DEPRECATED); $mappingsPassClassname = DoctrinePhpcrMappingsPass::class; break; default: throw new UnknownDriverException($driverType); } $compilerPassMethod = sprintf('create%sMappingDriver', ucfirst($this->mappingFormat)); return [$mappingsPassClassname, $compilerPassMethod]; }
[ "protected", "function", "getMappingCompilerPassInfo", "(", "string", "$", "driverType", ")", ":", "array", "{", "switch", "(", "$", "driverType", ")", "{", "case", "SyliusResourceBundle", "::", "DRIVER_DOCTRINE_MONGODB_ODM", ":", "@", "trigger_error", "(", "sprintf...
Return mapping compiler pass class depending on driver. @throws UnknownDriverException
[ "Return", "mapping", "compiler", "pass", "class", "depending", "on", "driver", "." ]
92c8e365a7c15aa436429b07dd14e7b2f8965f2f
https://github.com/Sylius/SyliusResourceBundle/blob/92c8e365a7c15aa436429b07dd14e7b2f8965f2f/src/Bundle/AbstractResourceBundle.php#L108-L140
train
Sylius/SyliusResourceBundle
src/Bundle/DependencyInjection/Driver/Doctrine/AbstractDoctrineDriver.php
AbstractDoctrineDriver.getObjectManagerName
protected function getObjectManagerName(MetadataInterface $metadata): ?string { $objectManagerName = null; if ($metadata->hasParameter('options') && isset($metadata->getParameter('options')['object_manager'])) { $objectManagerName = $metadata->getParameter('options')['object_manager']; } return $objectManagerName; }
php
protected function getObjectManagerName(MetadataInterface $metadata): ?string { $objectManagerName = null; if ($metadata->hasParameter('options') && isset($metadata->getParameter('options')['object_manager'])) { $objectManagerName = $metadata->getParameter('options')['object_manager']; } return $objectManagerName; }
[ "protected", "function", "getObjectManagerName", "(", "MetadataInterface", "$", "metadata", ")", ":", "?", "string", "{", "$", "objectManagerName", "=", "null", ";", "if", "(", "$", "metadata", "->", "hasParameter", "(", "'options'", ")", "&&", "isset", "(", ...
Return the configured object managre name, or NULL if the default manager should be used.
[ "Return", "the", "configured", "object", "managre", "name", "or", "NULL", "if", "the", "default", "manager", "should", "be", "used", "." ]
92c8e365a7c15aa436429b07dd14e7b2f8965f2f
https://github.com/Sylius/SyliusResourceBundle/blob/92c8e365a7c15aa436429b07dd14e7b2f8965f2f/src/Bundle/DependencyInjection/Driver/Doctrine/AbstractDoctrineDriver.php#L61-L70
train
silverstripe/silverstripe-redirectedurls
src/Extension/RedirectedURLHandler.php
RedirectedURLHandler.arrayToLowercase
protected function arrayToLowercase($vars) { $result = array(); foreach ($vars as $k => $v) { if (is_array($v)) { $result[strtolower($k)] = $this->arrayToLowercase($v); } else { $result[strtolower($k)] = strtolower($v); } } return $result; }
php
protected function arrayToLowercase($vars) { $result = array(); foreach ($vars as $k => $v) { if (is_array($v)) { $result[strtolower($k)] = $this->arrayToLowercase($v); } else { $result[strtolower($k)] = strtolower($v); } } return $result; }
[ "protected", "function", "arrayToLowercase", "(", "$", "vars", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "vars", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "$"...
Converts an array of key value pairs to lowercase @param array $vars key value pairs @return array
[ "Converts", "an", "array", "of", "key", "value", "pairs", "to", "lowercase" ]
c0d4cde3a52744aa87f52780b553e24d94a2d397
https://github.com/silverstripe/silverstripe-redirectedurls/blob/c0d4cde3a52744aa87f52780b553e24d94a2d397/src/Extension/RedirectedURLHandler.php#L34-L47
train
silverstripe/silverstripe-redirectedurls
src/Admin/RedirectedURLAdmin.php
RedirectedURLAdmin.getExportFields
public function getExportFields() { $fields = array(); foreach (DataObject::getSchema()->databaseFields($this->modelClass) as $field => $spec) { $fields[$field] = $field; } return $fields; }
php
public function getExportFields() { $fields = array(); foreach (DataObject::getSchema()->databaseFields($this->modelClass) as $field => $spec) { $fields[$field] = $field; } return $fields; }
[ "public", "function", "getExportFields", "(", ")", "{", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "DataObject", "::", "getSchema", "(", ")", "->", "databaseFields", "(", "$", "this", "->", "modelClass", ")", "as", "$", "field", "=>", ...
Overriden so that the CSV column headings have the exact field names of the DataObject To prevent field name conversion in DataObject::summaryFields() during export e.g. 'FromBase' is output as 'From Base' @return array
[ "Overriden", "so", "that", "the", "CSV", "column", "headings", "have", "the", "exact", "field", "names", "of", "the", "DataObject" ]
c0d4cde3a52744aa87f52780b553e24d94a2d397
https://github.com/silverstripe/silverstripe-redirectedurls/blob/c0d4cde3a52744aa87f52780b553e24d94a2d397/src/Admin/RedirectedURLAdmin.php#L73-L80
train
commerceguys/guzzle-oauth2-plugin
src/Oauth2Subscriber.php
Oauth2Subscriber.acquireAccessToken
protected function acquireAccessToken() { $accessToken = null; if ($this->refreshTokenGrantType) { // Get an access token using the stored refresh token. if ($this->refreshToken) { $this->refreshTokenGrantType->setRefreshToken($this->refreshToken->getToken()); } if ($this->refreshTokenGrantType->hasRefreshToken()) { $accessToken = $this->refreshTokenGrantType->getToken(); } } if (!$accessToken && $this->grantType) { // Get a new access token. $accessToken = $this->grantType->getToken(); } return $accessToken ?: null; }
php
protected function acquireAccessToken() { $accessToken = null; if ($this->refreshTokenGrantType) { // Get an access token using the stored refresh token. if ($this->refreshToken) { $this->refreshTokenGrantType->setRefreshToken($this->refreshToken->getToken()); } if ($this->refreshTokenGrantType->hasRefreshToken()) { $accessToken = $this->refreshTokenGrantType->getToken(); } } if (!$accessToken && $this->grantType) { // Get a new access token. $accessToken = $this->grantType->getToken(); } return $accessToken ?: null; }
[ "protected", "function", "acquireAccessToken", "(", ")", "{", "$", "accessToken", "=", "null", ";", "if", "(", "$", "this", "->", "refreshTokenGrantType", ")", "{", "// Get an access token using the stored refresh token.", "if", "(", "$", "this", "->", "refreshToken...
Get a new access token. @return AccessToken|null
[ "Get", "a", "new", "access", "token", "." ]
f7ed19171c3c5accfb6f0b3d1209eb5815ef8148
https://github.com/commerceguys/guzzle-oauth2-plugin/blob/f7ed19171c3c5accfb6f0b3d1209eb5815ef8148/src/Oauth2Subscriber.php#L72-L92
train
commerceguys/guzzle-oauth2-plugin
src/Oauth2Subscriber.php
Oauth2Subscriber.setRefreshToken
public function setRefreshToken($refreshToken) { if (is_string($refreshToken)) { $refreshToken = new AccessToken($refreshToken, 'refresh_token'); } elseif (!$refreshToken instanceof AccessToken) { throw new \InvalidArgumentException('Invalid refresh token'); } $this->refreshToken = $refreshToken; }
php
public function setRefreshToken($refreshToken) { if (is_string($refreshToken)) { $refreshToken = new AccessToken($refreshToken, 'refresh_token'); } elseif (!$refreshToken instanceof AccessToken) { throw new \InvalidArgumentException('Invalid refresh token'); } $this->refreshToken = $refreshToken; }
[ "public", "function", "setRefreshToken", "(", "$", "refreshToken", ")", "{", "if", "(", "is_string", "(", "$", "refreshToken", ")", ")", "{", "$", "refreshToken", "=", "new", "AccessToken", "(", "$", "refreshToken", ",", "'refresh_token'", ")", ";", "}", "...
Set the refresh token. @param AccessToken|string $refreshToken The refresh token
[ "Set", "the", "refresh", "token", "." ]
f7ed19171c3c5accfb6f0b3d1209eb5815ef8148
https://github.com/commerceguys/guzzle-oauth2-plugin/blob/f7ed19171c3c5accfb6f0b3d1209eb5815ef8148/src/Oauth2Subscriber.php#L166-L174
train
commerceguys/guzzle-oauth2-plugin
src/GrantType/JwtBearer.php
JwtBearer.computeJwt
protected function computeJwt() { $payload = [ 'iss' => $this->config->get('client_id'), 'aud' => sprintf('%s/%s', rtrim($this->client->getBaseUrl(), '/'), ltrim($this->config->get('token_url'), '/')), 'exp' => time() + 60 * 60, 'iat' => time() ]; return JWT::encode($payload, $this->readPrivateKey($this->config->get('private_key')), 'RS256'); }
php
protected function computeJwt() { $payload = [ 'iss' => $this->config->get('client_id'), 'aud' => sprintf('%s/%s', rtrim($this->client->getBaseUrl(), '/'), ltrim($this->config->get('token_url'), '/')), 'exp' => time() + 60 * 60, 'iat' => time() ]; return JWT::encode($payload, $this->readPrivateKey($this->config->get('private_key')), 'RS256'); }
[ "protected", "function", "computeJwt", "(", ")", "{", "$", "payload", "=", "[", "'iss'", "=>", "$", "this", "->", "config", "->", "get", "(", "'client_id'", ")", ",", "'aud'", "=>", "sprintf", "(", "'%s/%s'", ",", "rtrim", "(", "$", "this", "->", "cl...
Compute JWT, signing with provided private key
[ "Compute", "JWT", "signing", "with", "provided", "private", "key" ]
f7ed19171c3c5accfb6f0b3d1209eb5815ef8148
https://github.com/commerceguys/guzzle-oauth2-plugin/blob/f7ed19171c3c5accfb6f0b3d1209eb5815ef8148/src/GrantType/JwtBearer.php#L55-L65
train
commerceguys/guzzle-oauth2-plugin
src/GrantType/JwtBearer.php
JwtBearer.readPrivateKey
protected function readPrivateKey(SplFileObject $privateKey) { $key = ''; while (!$privateKey->eof()) { $key .= $privateKey->fgets(); } return $key; }
php
protected function readPrivateKey(SplFileObject $privateKey) { $key = ''; while (!$privateKey->eof()) { $key .= $privateKey->fgets(); } return $key; }
[ "protected", "function", "readPrivateKey", "(", "SplFileObject", "$", "privateKey", ")", "{", "$", "key", "=", "''", ";", "while", "(", "!", "$", "privateKey", "->", "eof", "(", ")", ")", "{", "$", "key", ".=", "$", "privateKey", "->", "fgets", "(", ...
Read private key @param SplFileObject $privateKey @return string
[ "Read", "private", "key" ]
f7ed19171c3c5accfb6f0b3d1209eb5815ef8148
https://github.com/commerceguys/guzzle-oauth2-plugin/blob/f7ed19171c3c5accfb6f0b3d1209eb5815ef8148/src/GrantType/JwtBearer.php#L74-L81
train
neos/Neos.Demo
Classes/Controller/RegistrationController.php
RegistrationController.newAccountAction
public function newAccountAction() { $uniqueUsername = 'demo' . (time() - 1302876012); $registration = new Registration(); $registration->setFirstName('John'); $registration->setLastName('Doe'); $registration->setUsername($uniqueUsername); $registration->setPassword('demo'); $this->view->assign('registration', $registration); }
php
public function newAccountAction() { $uniqueUsername = 'demo' . (time() - 1302876012); $registration = new Registration(); $registration->setFirstName('John'); $registration->setLastName('Doe'); $registration->setUsername($uniqueUsername); $registration->setPassword('demo'); $this->view->assign('registration', $registration); }
[ "public", "function", "newAccountAction", "(", ")", "{", "$", "uniqueUsername", "=", "'demo'", ".", "(", "time", "(", ")", "-", "1302876012", ")", ";", "$", "registration", "=", "new", "Registration", "(", ")", ";", "$", "registration", "->", "setFirstName...
Displays a form that creates a temporary account @return void
[ "Displays", "a", "form", "that", "creates", "a", "temporary", "account" ]
4c1a7770db2a7359cae20ddcafb7cfc4efdbf420
https://github.com/neos/Neos.Demo/blob/4c1a7770db2a7359cae20ddcafb7cfc4efdbf420/Classes/Controller/RegistrationController.php#L68-L78
train
neos/Neos.Demo
Classes/Controller/RegistrationController.php
RegistrationController.createAccountAction
public function createAccountAction(Registration $registration) { $accountIdentifier = $registration->getUsername(); $existingAccount = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, 'Neos.Neos:Backend'); if ($existingAccount !== null) { $this->addFlashMessage('An account with the username "%s" already exists.', 'Account already exists', Message::SEVERITY_ERROR, array($accountIdentifier)); $this->forward('newAccount'); } $this->createTemporaryAccount($accountIdentifier, $registration->getPassword(), $registration->getFirstName(), $registration->getLastName()); $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($this->request->getParentRequest()); $redirectUri = $uriBuilder ->setCreateAbsoluteUri(true) ->uriFor('index', array('username' => $accountIdentifier), 'Login', 'Neos.Neos'); $this->redirectToUri($redirectUri); }
php
public function createAccountAction(Registration $registration) { $accountIdentifier = $registration->getUsername(); $existingAccount = $this->accountRepository->findActiveByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, 'Neos.Neos:Backend'); if ($existingAccount !== null) { $this->addFlashMessage('An account with the username "%s" already exists.', 'Account already exists', Message::SEVERITY_ERROR, array($accountIdentifier)); $this->forward('newAccount'); } $this->createTemporaryAccount($accountIdentifier, $registration->getPassword(), $registration->getFirstName(), $registration->getLastName()); $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($this->request->getParentRequest()); $redirectUri = $uriBuilder ->setCreateAbsoluteUri(true) ->uriFor('index', array('username' => $accountIdentifier), 'Login', 'Neos.Neos'); $this->redirectToUri($redirectUri); }
[ "public", "function", "createAccountAction", "(", "Registration", "$", "registration", ")", "{", "$", "accountIdentifier", "=", "$", "registration", "->", "getUsername", "(", ")", ";", "$", "existingAccount", "=", "$", "this", "->", "accountRepository", "->", "f...
Action for creating a temporary account @param Registration $registration @return void
[ "Action", "for", "creating", "a", "temporary", "account" ]
4c1a7770db2a7359cae20ddcafb7cfc4efdbf420
https://github.com/neos/Neos.Demo/blob/4c1a7770db2a7359cae20ddcafb7cfc4efdbf420/Classes/Controller/RegistrationController.php#L86-L103
train
neos/Neos.Demo
Classes/Controller/RegistrationController.php
RegistrationController.createTemporaryAccount
protected function createTemporaryAccount($accountIdentifier, $password, $firstName, $lastName) { if (strlen($firstName) === 0 && strlen($lastName) === 0) { $firstName = 'Santa'; $lastName = 'Claus'; } $user = new User(); $user->setName(new PersonName('', $firstName, '', $lastName)); $user->getPreferences()->set('context.workspace', 'user-' . $accountIdentifier); $this->partyRepository->add($user); $account = $this->accountFactory->createAccountWithPassword($accountIdentifier, $password, array('Neos.Neos:Editor'), 'Neos.Neos:Backend'); $this->partyService->assignAccountToParty($account, $user); $account->setExpirationDate(new \DateTime('+1 week')); $this->accountRepository->add($account); }
php
protected function createTemporaryAccount($accountIdentifier, $password, $firstName, $lastName) { if (strlen($firstName) === 0 && strlen($lastName) === 0) { $firstName = 'Santa'; $lastName = 'Claus'; } $user = new User(); $user->setName(new PersonName('', $firstName, '', $lastName)); $user->getPreferences()->set('context.workspace', 'user-' . $accountIdentifier); $this->partyRepository->add($user); $account = $this->accountFactory->createAccountWithPassword($accountIdentifier, $password, array('Neos.Neos:Editor'), 'Neos.Neos:Backend'); $this->partyService->assignAccountToParty($account, $user); $account->setExpirationDate(new \DateTime('+1 week')); $this->accountRepository->add($account); }
[ "protected", "function", "createTemporaryAccount", "(", "$", "accountIdentifier", ",", "$", "password", ",", "$", "firstName", ",", "$", "lastName", ")", "{", "if", "(", "strlen", "(", "$", "firstName", ")", "===", "0", "&&", "strlen", "(", "$", "lastName"...
Creates a temporary account @param string $accountIdentifier @param string $password @param string $firstName @param string $lastName @return Account
[ "Creates", "a", "temporary", "account" ]
4c1a7770db2a7359cae20ddcafb7cfc4efdbf420
https://github.com/neos/Neos.Demo/blob/4c1a7770db2a7359cae20ddcafb7cfc4efdbf420/Classes/Controller/RegistrationController.php#L114-L131
train
guzzle/retry-subscriber
src/RetrySubscriber.php
RetrySubscriber.createLoggingDelay
public static function createLoggingDelay( callable $delayFn, LoggerInterface $logger, $formatter = null ) { if (!$formatter) { $formatter = new Formatter(self::MSG_FORMAT); } elseif (!($formatter instanceof Formatter)) { $formatter = new Formatter($formatter); } return function ( $retries, AbstractTransferEvent $event ) use ($delayFn, $logger, $formatter) { $delay = $delayFn($retries, $event); $logger->log(LogLevel::NOTICE, $formatter->format( $event->getRequest(), $event->getResponse(), $event instanceof ErrorEvent ? $event->getException() : null, [ 'retries' => $retries + 1, 'delay' => $delay ] + $event->getTransferInfo() )); return $delay; }; }
php
public static function createLoggingDelay( callable $delayFn, LoggerInterface $logger, $formatter = null ) { if (!$formatter) { $formatter = new Formatter(self::MSG_FORMAT); } elseif (!($formatter instanceof Formatter)) { $formatter = new Formatter($formatter); } return function ( $retries, AbstractTransferEvent $event ) use ($delayFn, $logger, $formatter) { $delay = $delayFn($retries, $event); $logger->log(LogLevel::NOTICE, $formatter->format( $event->getRequest(), $event->getResponse(), $event instanceof ErrorEvent ? $event->getException() : null, [ 'retries' => $retries + 1, 'delay' => $delay ] + $event->getTransferInfo() )); return $delay; }; }
[ "public", "static", "function", "createLoggingDelay", "(", "callable", "$", "delayFn", ",", "LoggerInterface", "$", "logger", ",", "$", "formatter", "=", "null", ")", "{", "if", "(", "!", "$", "formatter", ")", "{", "$", "formatter", "=", "new", "Formatter...
Creates a delay function that logs each retry before proxying to a wrapped delay function. @param callable $delayFn Delay function to proxy to @param LoggerInterface $logger Logger used to log messages @param string|Formatter $formatter Message formatter to format messages @return callable
[ "Creates", "a", "delay", "function", "that", "logs", "each", "retry", "before", "proxying", "to", "a", "wrapped", "delay", "function", "." ]
68f89b0b00b8e0dc7978cbbe16cee190e2bed650
https://github.com/guzzle/retry-subscriber/blob/68f89b0b00b8e0dc7978cbbe16cee190e2bed650/src/RetrySubscriber.php#L114-L141
train
guzzle/retry-subscriber
src/RetrySubscriber.php
RetrySubscriber.createStatusFilter
public static function createStatusFilter( array $failureStatuses = [500, 503] ) { // Convert the array of values into a set for hash lookups $failureStatuses = array_fill_keys($failureStatuses, true); return function ( $retries, AbstractTransferEvent $event ) use ($failureStatuses) { if (!($response = $event->getResponse())) { return false; } return isset($failureStatuses[$response->getStatusCode()]); }; }
php
public static function createStatusFilter( array $failureStatuses = [500, 503] ) { // Convert the array of values into a set for hash lookups $failureStatuses = array_fill_keys($failureStatuses, true); return function ( $retries, AbstractTransferEvent $event ) use ($failureStatuses) { if (!($response = $event->getResponse())) { return false; } return isset($failureStatuses[$response->getStatusCode()]); }; }
[ "public", "static", "function", "createStatusFilter", "(", "array", "$", "failureStatuses", "=", "[", "500", ",", "503", "]", ")", "{", "// Convert the array of values into a set for hash lookups", "$", "failureStatuses", "=", "array_fill_keys", "(", "$", "failureStatus...
Creates a retry filter based on HTTP status codes @param array $failureStatuses Pass an array of status codes to override the default of [500, 503]. @return callable
[ "Creates", "a", "retry", "filter", "based", "on", "HTTP", "status", "codes" ]
68f89b0b00b8e0dc7978cbbe16cee190e2bed650
https://github.com/guzzle/retry-subscriber/blob/68f89b0b00b8e0dc7978cbbe16cee190e2bed650/src/RetrySubscriber.php#L150-L165
train
guzzle/retry-subscriber
src/RetrySubscriber.php
RetrySubscriber.createIdempotentFilter
public static function createIdempotentFilter() { static $retry = ['GET' => true, 'HEAD' => true, 'PUT' => true, 'DELETE' => true, 'OPTIONS' => true, 'TRACE' => true]; return function ($retries, AbstractTransferEvent $e) use ($retry) { return isset($retry[$e->getRequest()->getMethod()]) ? self::DEFER : self::BREAK_CHAIN; }; }
php
public static function createIdempotentFilter() { static $retry = ['GET' => true, 'HEAD' => true, 'PUT' => true, 'DELETE' => true, 'OPTIONS' => true, 'TRACE' => true]; return function ($retries, AbstractTransferEvent $e) use ($retry) { return isset($retry[$e->getRequest()->getMethod()]) ? self::DEFER : self::BREAK_CHAIN; }; }
[ "public", "static", "function", "createIdempotentFilter", "(", ")", "{", "static", "$", "retry", "=", "[", "'GET'", "=>", "true", ",", "'HEAD'", "=>", "true", ",", "'PUT'", "=>", "true", ",", "'DELETE'", "=>", "true", ",", "'OPTIONS'", "=>", "true", ",",...
Creates a retry filter based on whether an HTTP method is considered "safe" or "idempotent" based on RFC 7231. If the HTTP request method is a PUT, POST, or PATCH request, then the request will not be retried. Otherwise, the filter will defer to other filters if added to a filter chain via `createChainFilter()`. @return callable @link http://tools.ietf.org/html/rfc7231#section-4.2.2
[ "Creates", "a", "retry", "filter", "based", "on", "whether", "an", "HTTP", "method", "is", "considered", "safe", "or", "idempotent", "based", "on", "RFC", "7231", "." ]
68f89b0b00b8e0dc7978cbbe16cee190e2bed650
https://github.com/guzzle/retry-subscriber/blob/68f89b0b00b8e0dc7978cbbe16cee190e2bed650/src/RetrySubscriber.php#L178-L188
train
guzzle/retry-subscriber
src/RetrySubscriber.php
RetrySubscriber.createCurlFilter
public static function createCurlFilter($errorCodes = null) { // Only use the cURL filter if cURL is loaded. if (!extension_loaded('curl')) { return function () { return false; }; } $errorCodes = $errorCodes ?: [ CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_SSL_CONNECT_ERROR, CURLE_GOT_NOTHING ]; $errorCodes = array_fill_keys($errorCodes, 1); return function ($retries, AbstractTransferEvent $e) use ($errorCodes) { return isset($errorCodes[(int) $e->getTransferInfo('errno')]); }; }
php
public static function createCurlFilter($errorCodes = null) { // Only use the cURL filter if cURL is loaded. if (!extension_loaded('curl')) { return function () { return false; }; } $errorCodes = $errorCodes ?: [ CURLE_OPERATION_TIMEOUTED, CURLE_COULDNT_RESOLVE_HOST, CURLE_COULDNT_CONNECT, CURLE_SSL_CONNECT_ERROR, CURLE_GOT_NOTHING ]; $errorCodes = array_fill_keys($errorCodes, 1); return function ($retries, AbstractTransferEvent $e) use ($errorCodes) { return isset($errorCodes[(int) $e->getTransferInfo('errno')]); }; }
[ "public", "static", "function", "createCurlFilter", "(", "$", "errorCodes", "=", "null", ")", "{", "// Only use the cURL filter if cURL is loaded.", "if", "(", "!", "extension_loaded", "(", "'curl'", ")", ")", "{", "return", "function", "(", ")", "{", "return", ...
Creates a retry filter based on cURL error codes. @param array $errorCodes Pass an array of curl error codes to override the default list of error codes. @return callable
[ "Creates", "a", "retry", "filter", "based", "on", "cURL", "error", "codes", "." ]
68f89b0b00b8e0dc7978cbbe16cee190e2bed650
https://github.com/guzzle/retry-subscriber/blob/68f89b0b00b8e0dc7978cbbe16cee190e2bed650/src/RetrySubscriber.php#L197-L217
train
jeremyharris/cakephp-lazyload
src/ORM/LazyLoadEntityTrait.php
LazyLoadEntityTrait.has
public function has($property) { foreach ((array)$property as $prop) { $has = $this->_parentHas($prop); if ($has === false) { $has = $this->_lazyLoad($prop); if ($has === null) { return false; } } } return true; }
php
public function has($property) { foreach ((array)$property as $prop) { $has = $this->_parentHas($prop); if ($has === false) { $has = $this->_lazyLoad($prop); if ($has === null) { return false; } } } return true; }
[ "public", "function", "has", "(", "$", "property", ")", "{", "foreach", "(", "(", "array", ")", "$", "property", "as", "$", "prop", ")", "{", "$", "has", "=", "$", "this", "->", "_parentHas", "(", "$", "prop", ")", ";", "if", "(", "$", "has", "...
Overrides has method to account for a lazy loaded property @param string|array $property Property @return bool
[ "Overrides", "has", "method", "to", "account", "for", "a", "lazy", "loaded", "property" ]
9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0
https://github.com/jeremyharris/cakephp-lazyload/blob/9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0/src/ORM/LazyLoadEntityTrait.php#L61-L75
train
jeremyharris/cakephp-lazyload
src/ORM/LazyLoadEntityTrait.php
LazyLoadEntityTrait.unsetProperty
public function unsetProperty($property) { $property = (array)$property; foreach ($property as $prop) { $this->_unsetProperties[] = $prop; } return Entity::unsetProperty($property); }
php
public function unsetProperty($property) { $property = (array)$property; foreach ($property as $prop) { $this->_unsetProperties[] = $prop; } return Entity::unsetProperty($property); }
[ "public", "function", "unsetProperty", "(", "$", "property", ")", "{", "$", "property", "=", "(", "array", ")", "$", "property", ";", "foreach", "(", "$", "property", "as", "$", "prop", ")", "{", "$", "this", "->", "_unsetProperties", "[", "]", "=", ...
Unsets a property, marking it as not to be lazily loaded in the future @param array|string $property Property @return $this
[ "Unsets", "a", "property", "marking", "it", "as", "not", "to", "be", "lazily", "loaded", "in", "the", "future" ]
9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0
https://github.com/jeremyharris/cakephp-lazyload/blob/9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0/src/ORM/LazyLoadEntityTrait.php#L94-L102
train
jeremyharris/cakephp-lazyload
src/ORM/LazyLoadEntityTrait.php
LazyLoadEntityTrait._lazyLoad
protected function _lazyLoad($property) { // check if the property has been unset at some point if (array_search($property, $this->_unsetProperties) !== false) { return null; } // check if the property was set as null to begin with if (array_key_exists($property, $this->_properties)) { return $this->_properties[$property]; } $repository = $this->_repository($property); if (!($repository instanceof RepositoryInterface)) { return null; } $association = $repository ->associations() ->getByProperty($property); if ($association === null) { return null; } $repository->loadInto($this, [$association->getName()]); // check if the association didn't exist and therefore didn't load if (!isset($this->_properties[$property])) { return null; } return $this->_properties[$property]; }
php
protected function _lazyLoad($property) { // check if the property has been unset at some point if (array_search($property, $this->_unsetProperties) !== false) { return null; } // check if the property was set as null to begin with if (array_key_exists($property, $this->_properties)) { return $this->_properties[$property]; } $repository = $this->_repository($property); if (!($repository instanceof RepositoryInterface)) { return null; } $association = $repository ->associations() ->getByProperty($property); if ($association === null) { return null; } $repository->loadInto($this, [$association->getName()]); // check if the association didn't exist and therefore didn't load if (!isset($this->_properties[$property])) { return null; } return $this->_properties[$property]; }
[ "protected", "function", "_lazyLoad", "(", "$", "property", ")", "{", "// check if the property has been unset at some point", "if", "(", "array_search", "(", "$", "property", ",", "$", "this", "->", "_unsetProperties", ")", "!==", "false", ")", "{", "return", "nu...
Lazy loads association data onto the entity @param string $property Property @return mixed
[ "Lazy", "loads", "association", "data", "onto", "the", "entity" ]
9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0
https://github.com/jeremyharris/cakephp-lazyload/blob/9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0/src/ORM/LazyLoadEntityTrait.php#L110-L143
train
jeremyharris/cakephp-lazyload
src/ORM/LazyLoadEntityTrait.php
LazyLoadEntityTrait._repository
protected function _repository() { $source = $this->getSource(); if ($source === null) { list(, $class) = namespaceSplit(get_class($this)); $source = Inflector::pluralize($class); } return TableRegistry::getTableLocator()->get($source); }
php
protected function _repository() { $source = $this->getSource(); if ($source === null) { list(, $class) = namespaceSplit(get_class($this)); $source = Inflector::pluralize($class); } return TableRegistry::getTableLocator()->get($source); }
[ "protected", "function", "_repository", "(", ")", "{", "$", "source", "=", "$", "this", "->", "getSource", "(", ")", ";", "if", "(", "$", "source", "===", "null", ")", "{", "list", "(", ",", "$", "class", ")", "=", "namespaceSplit", "(", "get_class",...
Gets the repository for this entity @return Table
[ "Gets", "the", "repository", "for", "this", "entity" ]
9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0
https://github.com/jeremyharris/cakephp-lazyload/blob/9c4298a2aec0317e2d3223bbaa8d583fc69eb6a0/src/ORM/LazyLoadEntityTrait.php#L150-L159
train
joomla-framework/database
src/Mysql/MysqlImporter.php
MysqlImporter.getKeySql
protected function getKeySql($columns) { // TODO Error checking on array and element types. $kNonUnique = (string) $columns[0]['Non_unique']; $kName = (string) $columns[0]['Key_name']; $kColumn = (string) $columns[0]['Column_name']; $prefix = ''; if ($kName === 'PRIMARY') { $prefix = 'PRIMARY '; } elseif ($kNonUnique == 0) { $prefix = 'UNIQUE '; } $nColumns = \count($columns); $kColumns = array(); if ($nColumns === 1) { $kColumns[] = $this->db->quoteName($kColumn); } else { foreach ($columns as $column) { $kColumns[] = (string) $column['Column_name']; } } $sql = $prefix . 'KEY ' . ($kName !== 'PRIMARY' ? $this->db->quoteName($kName) : '') . ' (' . implode(',', $kColumns) . ')'; return $sql; }
php
protected function getKeySql($columns) { // TODO Error checking on array and element types. $kNonUnique = (string) $columns[0]['Non_unique']; $kName = (string) $columns[0]['Key_name']; $kColumn = (string) $columns[0]['Column_name']; $prefix = ''; if ($kName === 'PRIMARY') { $prefix = 'PRIMARY '; } elseif ($kNonUnique == 0) { $prefix = 'UNIQUE '; } $nColumns = \count($columns); $kColumns = array(); if ($nColumns === 1) { $kColumns[] = $this->db->quoteName($kColumn); } else { foreach ($columns as $column) { $kColumns[] = (string) $column['Column_name']; } } $sql = $prefix . 'KEY ' . ($kName !== 'PRIMARY' ? $this->db->quoteName($kName) : '') . ' (' . implode(',', $kColumns) . ')'; return $sql; }
[ "protected", "function", "getKeySql", "(", "$", "columns", ")", "{", "// TODO Error checking on array and element types.", "$", "kNonUnique", "=", "(", "string", ")", "$", "columns", "[", "0", "]", "[", "'Non_unique'", "]", ";", "$", "kName", "=", "(", "string...
Get the SQL syntax for a key. @param array $columns An array of SimpleXMLElement objects comprising the key. @return string @since 1.0
[ "Get", "the", "SQL", "syntax", "for", "a", "key", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/Mysql/MysqlImporter.php#L338-L375
train
joomla-framework/database
src/DatabaseDriver.php
DatabaseDriver.getServerType
public function getServerType() { if (empty($this->serverType)) { $name = $this->getName(); if (stristr($name, 'mysql') !== false) { $this->serverType = 'mysql'; } elseif (stristr($name, 'postgre') !== false) { $this->serverType = 'postgresql'; } elseif (stristr($name, 'pgsql') !== false) { $this->serverType = 'postgresql'; } elseif (stristr($name, 'oracle') !== false) { $this->serverType = 'oracle'; } elseif (stristr($name, 'sqlite') !== false) { $this->serverType = 'sqlite'; } elseif (stristr($name, 'sqlsrv') !== false) { $this->serverType = 'mssql'; } elseif (stristr($name, 'sqlazure') !== false) { $this->serverType = 'mssql'; } elseif (stristr($name, 'mssql') !== false) { $this->serverType = 'mssql'; } else { $this->serverType = $name; } } return $this->serverType; }
php
public function getServerType() { if (empty($this->serverType)) { $name = $this->getName(); if (stristr($name, 'mysql') !== false) { $this->serverType = 'mysql'; } elseif (stristr($name, 'postgre') !== false) { $this->serverType = 'postgresql'; } elseif (stristr($name, 'pgsql') !== false) { $this->serverType = 'postgresql'; } elseif (stristr($name, 'oracle') !== false) { $this->serverType = 'oracle'; } elseif (stristr($name, 'sqlite') !== false) { $this->serverType = 'sqlite'; } elseif (stristr($name, 'sqlsrv') !== false) { $this->serverType = 'mssql'; } elseif (stristr($name, 'sqlazure') !== false) { $this->serverType = 'mssql'; } elseif (stristr($name, 'mssql') !== false) { $this->serverType = 'mssql'; } else { $this->serverType = $name; } } return $this->serverType; }
[ "public", "function", "getServerType", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "serverType", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "if", "(", "stristr", "(", "$", "name", ",", "'mysql'", ...
Get the server family type. If $this->serverType is not set it will attempt guessing the server family type from the driver name. If this is not possible the driver name will be returned instead. @return string @since 1.4.0
[ "Get", "the", "server", "family", "type", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseDriver.php#L735-L780
train
joomla-framework/database
src/DatabaseDriver.php
DatabaseDriver.getQuery
public function getQuery($new = false) { if ($new) { // Derive the class name from the driver. $class = '\\Joomla\\Database\\' . ucfirst($this->name) . '\\' . ucfirst($this->name) . 'Query'; // Make sure we have a query class for this driver. if (!class_exists($class)) { // If it doesn't exist we are at an impasse so throw an exception. throw new Exception\UnsupportedAdapterException('Database Query Class not found.'); } return new $class($this); } return $this->sql; }
php
public function getQuery($new = false) { if ($new) { // Derive the class name from the driver. $class = '\\Joomla\\Database\\' . ucfirst($this->name) . '\\' . ucfirst($this->name) . 'Query'; // Make sure we have a query class for this driver. if (!class_exists($class)) { // If it doesn't exist we are at an impasse so throw an exception. throw new Exception\UnsupportedAdapterException('Database Query Class not found.'); } return new $class($this); } return $this->sql; }
[ "public", "function", "getQuery", "(", "$", "new", "=", "false", ")", "{", "if", "(", "$", "new", ")", "{", "// Derive the class name from the driver.", "$", "class", "=", "'\\\\Joomla\\\\Database\\\\'", ".", "ucfirst", "(", "$", "this", "->", "name", ")", "...
Get the current query object or a new DatabaseQuery object. @param boolean $new False to return the current query object, True to return a new DatabaseQuery object. @return DatabaseQuery The current query object or a new object extending the DatabaseQuery class. @since 1.0 @throws \RuntimeException
[ "Get", "the", "current", "query", "object", "or", "a", "new", "DatabaseQuery", "object", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseDriver.php#L881-L899
train
joomla-framework/database
src/DatabaseDriver.php
DatabaseDriver.quoteNameString
protected function quoteNameString($name, $asSinglePart = false) { $q = $this->nameQuote . $this->nameQuote; // Double quote reserved keyword $name = str_replace($q[1], $q[1] . $q[1], $name); if ($asSinglePart) { return $q[0] . $name . $q[1]; } return $q[0] . str_replace('.', "$q[1].$q[0]", $name) . $q[1]; }
php
protected function quoteNameString($name, $asSinglePart = false) { $q = $this->nameQuote . $this->nameQuote; // Double quote reserved keyword $name = str_replace($q[1], $q[1] . $q[1], $name); if ($asSinglePart) { return $q[0] . $name . $q[1]; } return $q[0] . str_replace('.', "$q[1].$q[0]", $name) . $q[1]; }
[ "protected", "function", "quoteNameString", "(", "$", "name", ",", "$", "asSinglePart", "=", "false", ")", "{", "$", "q", "=", "$", "this", "->", "nameQuote", ".", "$", "this", "->", "nameQuote", ";", "// Double quote reserved keyword", "$", "name", "=", "...
Quote string coming from quoteName call. @param string $name Identifier name to be quoted. @param boolean $asSinglePart Treat the name as a single part of the identifier. @return string Quoted identifier string. @since 1.7.0
[ "Quote", "string", "coming", "from", "quoteName", "call", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseDriver.php#L1548-L1561
train
joomla-framework/database
src/DatabaseDriver.php
DatabaseDriver.setDebug
public function setDebug($level) { $previous = $this->debug; $this->debug = (bool) $level; return $previous; }
php
public function setDebug($level) { $previous = $this->debug; $this->debug = (bool) $level; return $previous; }
[ "public", "function", "setDebug", "(", "$", "level", ")", "{", "$", "previous", "=", "$", "this", "->", "debug", ";", "$", "this", "->", "debug", "=", "(", "bool", ")", "$", "level", ";", "return", "$", "previous", ";", "}" ]
Sets the database debugging state for the driver. @param boolean $level True to enable debugging. @return boolean The old debugging level. @since 1.0
[ "Sets", "the", "database", "debugging", "state", "for", "the", "driver", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseDriver.php#L1739-L1745
train
joomla-framework/database
src/Mysqli/MysqliDriver.php
MysqliDriver.setUtf
public function setUtf() { // If UTF is not supported return false immediately if (!$this->utf) { return false; } // Make sure we're connected to the server $this->connect(); // Which charset should I use, plain utf8 or multibyte utf8mb4? $charset = $this->utf8mb4 && $this->options['utf8mb4'] ? 'utf8mb4' : 'utf8'; $result = @$this->connection->set_charset($charset); /* * If I could not set the utf8mb4 charset then the server doesn't support utf8mb4 despite claiming otherwise. This happens on old MySQL * server versions (less than 5.5.3) using the mysqlnd PHP driver. Since mysqlnd masks the server version and reports only its own we * can not be sure if the server actually does support UTF-8 Multibyte (i.e. it's MySQL 5.5.3 or later). Since the utf8mb4 charset is * undefined in this case we catch the error and determine that utf8mb4 is not supported! */ if (!$result && $this->utf8mb4 && $this->options['utf8mb4']) { $this->utf8mb4 = false; $result = @$this->connection->set_charset('utf8'); } return $result; }
php
public function setUtf() { // If UTF is not supported return false immediately if (!$this->utf) { return false; } // Make sure we're connected to the server $this->connect(); // Which charset should I use, plain utf8 or multibyte utf8mb4? $charset = $this->utf8mb4 && $this->options['utf8mb4'] ? 'utf8mb4' : 'utf8'; $result = @$this->connection->set_charset($charset); /* * If I could not set the utf8mb4 charset then the server doesn't support utf8mb4 despite claiming otherwise. This happens on old MySQL * server versions (less than 5.5.3) using the mysqlnd PHP driver. Since mysqlnd masks the server version and reports only its own we * can not be sure if the server actually does support UTF-8 Multibyte (i.e. it's MySQL 5.5.3 or later). Since the utf8mb4 charset is * undefined in this case we catch the error and determine that utf8mb4 is not supported! */ if (!$result && $this->utf8mb4 && $this->options['utf8mb4']) { $this->utf8mb4 = false; $result = @$this->connection->set_charset('utf8'); } return $result; }
[ "public", "function", "setUtf", "(", ")", "{", "// If UTF is not supported return false immediately", "if", "(", "!", "$", "this", "->", "utf", ")", "{", "return", "false", ";", "}", "// Make sure we're connected to the server", "$", "this", "->", "connect", "(", ...
Set the connection to use UTF-8 character encoding. @return boolean True on success. @since 1.0
[ "Set", "the", "connection", "to", "use", "UTF", "-", "8", "character", "encoding", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/Mysqli/MysqliDriver.php#L800-L829
train
joomla-framework/database
src/Mysqli/MysqliDriver.php
MysqliDriver.executeUnpreparedQuery
protected function executeUnpreparedQuery($sql) { $this->connect(); $cursor = $this->connection->query($sql); // If an error occurred handle it. if (!$cursor) { $this->errorNum = (int) $this->connection->errno; $this->errorMsg = (string) $this->connection->error; // Check if the server was disconnected. if (!$this->connected()) { try { // Attempt to reconnect. $this->connection = null; $this->connect(); } catch (ConnectionFailureException $e) { // If connect fails, ignore that exception and throw the normal exception. $this->log( Log\LogLevel::ERROR, 'Database query failed (error #{code}): {message}; Failed query: {sql}', array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql) ); throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum); } // Since we were able to reconnect, run the query again. return $this->executeUnpreparedQuery($sql); } // The server was not disconnected. $this->log( Log\LogLevel::ERROR, 'Database query failed (error #{code}): {message}; Failed query: {sql}', array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql) ); throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum); } $this->freeResult($cursor); return true; }
php
protected function executeUnpreparedQuery($sql) { $this->connect(); $cursor = $this->connection->query($sql); // If an error occurred handle it. if (!$cursor) { $this->errorNum = (int) $this->connection->errno; $this->errorMsg = (string) $this->connection->error; // Check if the server was disconnected. if (!$this->connected()) { try { // Attempt to reconnect. $this->connection = null; $this->connect(); } catch (ConnectionFailureException $e) { // If connect fails, ignore that exception and throw the normal exception. $this->log( Log\LogLevel::ERROR, 'Database query failed (error #{code}): {message}; Failed query: {sql}', array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql) ); throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum); } // Since we were able to reconnect, run the query again. return $this->executeUnpreparedQuery($sql); } // The server was not disconnected. $this->log( Log\LogLevel::ERROR, 'Database query failed (error #{code}): {message}; Failed query: {sql}', array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql) ); throw new ExecutionFailureException($sql, $this->errorMsg, $this->errorNum); } $this->freeResult($cursor); return true; }
[ "protected", "function", "executeUnpreparedQuery", "(", "$", "sql", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "$", "cursor", "=", "$", "this", "->", "connection", "->", "query", "(", "$", "sql", ")", ";", "// If an error occurred handle it.", ...
Internal method to execute queries which cannot be run as prepared statements. @param string $sql SQL statement to execute. @return boolean @since 1.5.0
[ "Internal", "method", "to", "execute", "queries", "which", "cannot", "be", "run", "as", "prepared", "statements", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/Mysqli/MysqliDriver.php#L931-L981
train
joomla-framework/database
src/Sqlsrv/SqlsrvQuery.php
SqlsrvQuery.charLength
public function charLength($field, $operator = null, $condition = null) { return 'DATALENGTH(' . $field . ')' . (isset($operator, $condition) ? ' ' . $operator . ' ' . $condition : ''); }
php
public function charLength($field, $operator = null, $condition = null) { return 'DATALENGTH(' . $field . ')' . (isset($operator, $condition) ? ' ' . $operator . ' ' . $condition : ''); }
[ "public", "function", "charLength", "(", "$", "field", ",", "$", "operator", "=", "null", ",", "$", "condition", "=", "null", ")", "{", "return", "'DATALENGTH('", ".", "$", "field", ".", "')'", ".", "(", "isset", "(", "$", "operator", ",", "$", "cond...
Gets the function to determine the length of a character string. @param string $field A value. @param string $operator Comparison operator between charLength integer value and $condition @param string $condition Integer value to compare charLength with. @return string The required char length call. @since 1.0
[ "Gets", "the", "function", "to", "determine", "the", "length", "of", "a", "character", "string", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/Sqlsrv/SqlsrvQuery.php#L226-L229
train
joomla-framework/database
src/Pgsql/PgsqlDriver.php
PgsqlDriver.showTables
public function showTables() { $query = $this->getQuery(true) ->select('table_name') ->from('information_schema.tables') ->where('table_type=' . $this->quote('BASE TABLE')) ->where('table_schema NOT IN (' . $this->quote('pg_catalog') . ', ' . $this->quote('information_schema') . ' )'); $this->setQuery($query); return $this->loadColumn(); }
php
public function showTables() { $query = $this->getQuery(true) ->select('table_name') ->from('information_schema.tables') ->where('table_type=' . $this->quote('BASE TABLE')) ->where('table_schema NOT IN (' . $this->quote('pg_catalog') . ', ' . $this->quote('information_schema') . ' )'); $this->setQuery($query); return $this->loadColumn(); }
[ "public", "function", "showTables", "(", ")", "{", "$", "query", "=", "$", "this", "->", "getQuery", "(", "true", ")", "->", "select", "(", "'table_name'", ")", "->", "from", "(", "'information_schema.tables'", ")", "->", "where", "(", "'table_type='", "."...
Returns an array containing database's table list. @return array The database's table list. @since 1.5.0
[ "Returns", "an", "array", "containing", "database", "s", "table", "list", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/Pgsql/PgsqlDriver.php#L723-L734
train
joomla-framework/database
src/Pgsql/PgsqlDriver.php
PgsqlDriver.getCreateDbQuery
public function getCreateDbQuery($options, $utf) { $query = 'CREATE DATABASE ' . $this->quoteName($options->db_name) . ' OWNER ' . $this->quoteName($options->db_user); if ($utf) { $query .= ' ENCODING ' . $this->quote('UTF-8'); } return $query; }
php
public function getCreateDbQuery($options, $utf) { $query = 'CREATE DATABASE ' . $this->quoteName($options->db_name) . ' OWNER ' . $this->quoteName($options->db_user); if ($utf) { $query .= ' ENCODING ' . $this->quote('UTF-8'); } return $query; }
[ "public", "function", "getCreateDbQuery", "(", "$", "options", ",", "$", "utf", ")", "{", "$", "query", "=", "'CREATE DATABASE '", ".", "$", "this", "->", "quoteName", "(", "$", "options", "->", "db_name", ")", ".", "' OWNER '", ".", "$", "this", "->", ...
Get the query string to create new Database in correct PostgreSQL syntax. @param object $options object coming from "initialise" function to pass user and database name to database driver. @param boolean $utf True if the database supports the UTF-8 character set, not used in PostgreSQL "CREATE DATABASE" query. @return string The query that creates database, owned by $options['user'] @since 1.5.0
[ "Get", "the", "query", "string", "to", "create", "new", "Database", "in", "correct", "PostgreSQL", "syntax", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/Pgsql/PgsqlDriver.php#L793-L803
train
joomla-framework/database
src/DatabaseExporter.php
DatabaseExporter.from
public function from($from) { if (\is_string($from)) { $this->from = array($from); } elseif (\is_array($from)) { $this->from = $from; } else { throw new \Exception('The exporter requires either a single table name or array of table names'); } return $this; }
php
public function from($from) { if (\is_string($from)) { $this->from = array($from); } elseif (\is_array($from)) { $this->from = $from; } else { throw new \Exception('The exporter requires either a single table name or array of table names'); } return $this; }
[ "public", "function", "from", "(", "$", "from", ")", "{", "if", "(", "\\", "is_string", "(", "$", "from", ")", ")", "{", "$", "this", "->", "from", "=", "array", "(", "$", "from", ")", ";", "}", "elseif", "(", "\\", "is_array", "(", "$", "from"...
Specifies a list of table names to export. @param mixed $from The name of a single table, or an array of the table names to export. @return DatabaseExporter Method supports chaining. @since 1.0 @throws \Exception if input is not a string or array.
[ "Specifies", "a", "list", "of", "table", "names", "to", "export", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseExporter.php#L170-L186
train
joomla-framework/database
src/DatabaseExporter.php
DatabaseExporter.getGenericTableName
protected function getGenericTableName($table) { $prefix = $this->db->getPrefix(); // Replace the magic prefix if found. $table = preg_replace("|^$prefix|", '#__', $table); return $table; }
php
protected function getGenericTableName($table) { $prefix = $this->db->getPrefix(); // Replace the magic prefix if found. $table = preg_replace("|^$prefix|", '#__', $table); return $table; }
[ "protected", "function", "getGenericTableName", "(", "$", "table", ")", "{", "$", "prefix", "=", "$", "this", "->", "db", "->", "getPrefix", "(", ")", ";", "// Replace the magic prefix if found.", "$", "table", "=", "preg_replace", "(", "\"|^$prefix|\"", ",", ...
Get the generic name of the table, converting the database prefix to the wildcard string. @param string $table The name of the table. @return string The name of the table with the database prefix replaced with #__. @since 1.0
[ "Get", "the", "generic", "name", "of", "the", "table", "converting", "the", "database", "prefix", "to", "the", "wildcard", "string", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseExporter.php#L197-L205
train
joomla-framework/database
src/DatabaseIterator.php
DatabaseIterator.next
public function next() { // Set the default key as being the number of fetched object $this->key = $this->fetched; // Try to get an object $this->current = $this->fetchObject(); // If an object has been found if ($this->current) { // Set the key as being the indexed column (if it exists) if (isset($this->current->{$this->column})) { $this->key = $this->current->{$this->column}; } // Update the number of fetched object $this->fetched++; } }
php
public function next() { // Set the default key as being the number of fetched object $this->key = $this->fetched; // Try to get an object $this->current = $this->fetchObject(); // If an object has been found if ($this->current) { // Set the key as being the indexed column (if it exists) if (isset($this->current->{$this->column})) { $this->key = $this->current->{$this->column}; } // Update the number of fetched object $this->fetched++; } }
[ "public", "function", "next", "(", ")", "{", "// Set the default key as being the number of fetched object", "$", "this", "->", "key", "=", "$", "this", "->", "fetched", ";", "// Try to get an object", "$", "this", "->", "current", "=", "$", "this", "->", "fetchOb...
Moves forward to the next result from the SQL query. @return void @see Iterator::next() @since 1.0
[ "Moves", "forward", "to", "the", "next", "result", "from", "the", "SQL", "query", "." ]
90a6b42fec66f735e5e871d1fb2a8202c2a3216f
https://github.com/joomla-framework/database/blob/90a6b42fec66f735e5e871d1fb2a8202c2a3216f/src/DatabaseIterator.php#L147-L167
train