repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yuncms/framework
src/notifications/ChannelManager.php
ChannelManager.has
public function has($id, $checkInstance = false) { return $checkInstance ? isset($this->_channels[$id]) : isset($this->_definitions[$id]); }
php
public function has($id, $checkInstance = false) { return $checkInstance ? isset($this->_channels[$id]) : isset($this->_definitions[$id]); }
[ "public", "function", "has", "(", "$", "id", ",", "$", "checkInstance", "=", "false", ")", "{", "return", "$", "checkInstance", "?", "isset", "(", "$", "this", "->", "_channels", "[", "$", "id", "]", ")", ":", "isset", "(", "$", "this", "->", "_definitions", "[", "$", "id", "]", ")", ";", "}" ]
Returns a value indicating whether the locator has the specified channel definition or has instantiated the channel. This method may return different results depending on the value of `$checkInstance`. - If `$checkInstance` is false (default), the method will return a value indicating whether the locator has the specified channel definition. - If `$checkInstance` is true, the method will return a value indicating whether the locator has instantiated the specified channel. @param string $id channel ID (e.g. `local`). @param bool $checkInstance whether the method should check if the channel is shared and instantiated. @return bool whether the locator has the specified channel definition or has instantiated the channel. @see set()
[ "Returns", "a", "value", "indicating", "whether", "the", "locator", "has", "the", "specified", "channel", "definition", "or", "has", "instantiated", "the", "channel", ".", "This", "method", "may", "return", "different", "results", "depending", "on", "the", "value", "of", "$checkInstance", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/ChannelManager.php#L106-L109
yuncms/framework
src/notifications/ChannelManager.php
ChannelManager.setChannels
public function setChannels($channels) { foreach ($channels as $id => $channel) { $this->set($id, $channel); } }
php
public function setChannels($channels) { foreach ($channels as $id => $channel) { $this->set($id, $channel); } }
[ "public", "function", "setChannels", "(", "$", "channels", ")", "{", "foreach", "(", "$", "channels", "as", "$", "id", "=>", "$", "channel", ")", "{", "$", "this", "->", "set", "(", "$", "id", ",", "$", "channel", ")", ";", "}", "}" ]
Registers a set of channel definitions in this locator. This is the bulk version of [[set()]]. The parameter should be an array whose keys are channel IDs and values the corresponding channel definitions. For more details on how to specify channel IDs and definitions, please refer to [[set()]]. If a channel definition with the same ID already exists, it will be overwritten. The following is an example for registering two channel definitions: ```php [ 'local' => [ 'class' => 'yuncms\NotificationManager\channels\Local', ], ] ``` @param array $channels channel definitions or instances @throws InvalidConfigException
[ "Registers", "a", "set", "of", "channel", "definitions", "in", "this", "locator", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/ChannelManager.php#L250-L255
yuncms/framework
src/notifications/ChannelManager.php
ChannelManager.send
public function send($notifiables, $notifications) { if (!is_array($notifiables)) { $notifiables = [$notifiables]; } if (!is_array($notifications)) { $notifications = [$notifications]; } foreach ($notifiables as $notifiable) { $channels = array_intersect($notifiable->viaChannels(), array_keys($this->getChannels(true))); foreach ($notifications as $notification) { if (!$notifiable->shouldReceiveNotification($notification)) { continue; } $notification->id = StringHelper::ObjectId(); $channels = array_intersect($channels, $notification->broadcastOn()); foreach ($channels as $channel) { $this->get($channel)->send($notifiable, $notification); } } } }
php
public function send($notifiables, $notifications) { if (!is_array($notifiables)) { $notifiables = [$notifiables]; } if (!is_array($notifications)) { $notifications = [$notifications]; } foreach ($notifiables as $notifiable) { $channels = array_intersect($notifiable->viaChannels(), array_keys($this->getChannels(true))); foreach ($notifications as $notification) { if (!$notifiable->shouldReceiveNotification($notification)) { continue; } $notification->id = StringHelper::ObjectId(); $channels = array_intersect($channels, $notification->broadcastOn()); foreach ($channels as $channel) { $this->get($channel)->send($notifiable, $notification); } } } }
[ "public", "function", "send", "(", "$", "notifiables", ",", "$", "notifications", ")", "{", "if", "(", "!", "is_array", "(", "$", "notifiables", ")", ")", "{", "$", "notifiables", "=", "[", "$", "notifiables", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "notifications", ")", ")", "{", "$", "notifications", "=", "[", "$", "notifications", "]", ";", "}", "foreach", "(", "$", "notifiables", "as", "$", "notifiable", ")", "{", "$", "channels", "=", "array_intersect", "(", "$", "notifiable", "->", "viaChannels", "(", ")", ",", "array_keys", "(", "$", "this", "->", "getChannels", "(", "true", ")", ")", ")", ";", "foreach", "(", "$", "notifications", "as", "$", "notification", ")", "{", "if", "(", "!", "$", "notifiable", "->", "shouldReceiveNotification", "(", "$", "notification", ")", ")", "{", "continue", ";", "}", "$", "notification", "->", "id", "=", "StringHelper", "::", "ObjectId", "(", ")", ";", "$", "channels", "=", "array_intersect", "(", "$", "channels", ",", "$", "notification", "->", "broadcastOn", "(", ")", ")", ";", "foreach", "(", "$", "channels", "as", "$", "channel", ")", "{", "$", "this", "->", "get", "(", "$", "channel", ")", "->", "send", "(", "$", "notifiable", ",", "$", "notification", ")", ";", "}", "}", "}", "}" ]
通过可用渠道将给定的通知发送给给定的可通知实体。您可以传递数组以便将多个通知发送给多个收件人。 @param NotifiableInterface|NotifiableInterface[] $notifiables 可以收到给定通知的收件人。 @param Notification|Notification[] $notifications 应该交付的通知。 @return void @throws InvalidConfigException
[ "通过可用渠道将给定的通知发送给给定的可通知实体。您可以传递数组以便将多个通知发送给多个收件人。" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/ChannelManager.php#L265-L286
Chill-project/Main
Search/SearchProvider.php
SearchProvider.getByOrder
public function getByOrder() { //sort the array uasort($this->searchServices, function(SearchInterface $a, SearchInterface $b) { if ($a->getOrder() == $b->getOrder()) { return 0; } return ($a->getOrder() < $b->getOrder()) ? -1 : 1; }); return $this->searchServices; }
php
public function getByOrder() { //sort the array uasort($this->searchServices, function(SearchInterface $a, SearchInterface $b) { if ($a->getOrder() == $b->getOrder()) { return 0; } return ($a->getOrder() < $b->getOrder()) ? -1 : 1; }); return $this->searchServices; }
[ "public", "function", "getByOrder", "(", ")", "{", "//sort the array", "uasort", "(", "$", "this", "->", "searchServices", ",", "function", "(", "SearchInterface", "$", "a", ",", "SearchInterface", "$", "b", ")", "{", "if", "(", "$", "a", "->", "getOrder", "(", ")", "==", "$", "b", "->", "getOrder", "(", ")", ")", "{", "return", "0", ";", "}", "return", "(", "$", "a", "->", "getOrder", "(", ")", "<", "$", "b", "->", "getOrder", "(", ")", ")", "?", "-", "1", ":", "1", ";", "}", ")", ";", "return", "$", "this", "->", "searchServices", ";", "}" ]
/* return search services in an array, ordered by the order key (defined in service definition) the conflicts in keys (twice the same order) are resolved within the compiler : the function will preserve all services defined (if two services have the same order, the will increment the order of the second one. @return SearchInterface[], with an int as array key
[ "/", "*", "return", "search", "services", "in", "an", "array", "ordered", "by", "the", "order", "key", "(", "defined", "in", "service", "definition", ")", "the", "conflicts", "in", "keys", "(", "twice", "the", "same", "order", ")", "are", "resolved", "within", "the", "compiler", ":", "the", "function", "will", "preserve", "all", "services", "defined", "(", "if", "two", "services", "have", "the", "same", "order", "the", "will", "increment", "the", "order", "of", "the", "second", "one", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L33-L44
Chill-project/Main
Search/SearchProvider.php
SearchProvider.parse
public function parse($pattern) { //reset must be extracted $this->mustBeExtracted = array(); //filter to lower and remove accentued $filteredPattern = mb_strtolower($this->remove_accents($pattern)); $terms = $this->extractTerms($filteredPattern); $terms['_domain'] = $this->extractDomain($filteredPattern); $terms['_default'] = $this->extractDefault($filteredPattern); return $terms; }
php
public function parse($pattern) { //reset must be extracted $this->mustBeExtracted = array(); //filter to lower and remove accentued $filteredPattern = mb_strtolower($this->remove_accents($pattern)); $terms = $this->extractTerms($filteredPattern); $terms['_domain'] = $this->extractDomain($filteredPattern); $terms['_default'] = $this->extractDefault($filteredPattern); return $terms; }
[ "public", "function", "parse", "(", "$", "pattern", ")", "{", "//reset must be extracted", "$", "this", "->", "mustBeExtracted", "=", "array", "(", ")", ";", "//filter to lower and remove accentued", "$", "filteredPattern", "=", "mb_strtolower", "(", "$", "this", "->", "remove_accents", "(", "$", "pattern", ")", ")", ";", "$", "terms", "=", "$", "this", "->", "extractTerms", "(", "$", "filteredPattern", ")", ";", "$", "terms", "[", "'_domain'", "]", "=", "$", "this", "->", "extractDomain", "(", "$", "filteredPattern", ")", ";", "$", "terms", "[", "'_default'", "]", "=", "$", "this", "->", "extractDefault", "(", "$", "filteredPattern", ")", ";", "return", "$", "terms", ";", "}" ]
parse the search string to extract domain and terms @param string $pattern @return string[] an array where the keys are _domain, _default (residual terms) or term
[ "parse", "the", "search", "string", "to", "extract", "domain", "and", "terms" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L52-L64
Chill-project/Main
Search/SearchProvider.php
SearchProvider.getSearchResults
public function getSearchResults($pattern, $start = 0, $limit = 50) { $terms = $this->parse($pattern); $results = array(); //sort searchServices by order $sortedSearchServices = array(); foreach($this->searchServices as $service) { $sortedSearchServices[$service->getOrder()] = $service; } if ($terms['_domain'] !== NULL) { foreach ($sortedSearchServices as $service) { if ($service->supports($terms['_domain'])) { $results[] = $service->renderResult($terms, $start, $limit); } } if (count($results) === 0) { throw new UnknowSearchDomainException($terms['_domain']); } } else { // no domain provided, we use default search foreach($sortedSearchServices as $service) { if ($service->isActiveByDefault()) { $results[] = $service->renderResult($terms, $start, $limit); } } } //sort array ksort($results); return $results; }
php
public function getSearchResults($pattern, $start = 0, $limit = 50) { $terms = $this->parse($pattern); $results = array(); //sort searchServices by order $sortedSearchServices = array(); foreach($this->searchServices as $service) { $sortedSearchServices[$service->getOrder()] = $service; } if ($terms['_domain'] !== NULL) { foreach ($sortedSearchServices as $service) { if ($service->supports($terms['_domain'])) { $results[] = $service->renderResult($terms, $start, $limit); } } if (count($results) === 0) { throw new UnknowSearchDomainException($terms['_domain']); } } else { // no domain provided, we use default search foreach($sortedSearchServices as $service) { if ($service->isActiveByDefault()) { $results[] = $service->renderResult($terms, $start, $limit); } } } //sort array ksort($results); return $results; }
[ "public", "function", "getSearchResults", "(", "$", "pattern", ",", "$", "start", "=", "0", ",", "$", "limit", "=", "50", ")", "{", "$", "terms", "=", "$", "this", "->", "parse", "(", "$", "pattern", ")", ";", "$", "results", "=", "array", "(", ")", ";", "//sort searchServices by order", "$", "sortedSearchServices", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "searchServices", "as", "$", "service", ")", "{", "$", "sortedSearchServices", "[", "$", "service", "->", "getOrder", "(", ")", "]", "=", "$", "service", ";", "}", "if", "(", "$", "terms", "[", "'_domain'", "]", "!==", "NULL", ")", "{", "foreach", "(", "$", "sortedSearchServices", "as", "$", "service", ")", "{", "if", "(", "$", "service", "->", "supports", "(", "$", "terms", "[", "'_domain'", "]", ")", ")", "{", "$", "results", "[", "]", "=", "$", "service", "->", "renderResult", "(", "$", "terms", ",", "$", "start", ",", "$", "limit", ")", ";", "}", "}", "if", "(", "count", "(", "$", "results", ")", "===", "0", ")", "{", "throw", "new", "UnknowSearchDomainException", "(", "$", "terms", "[", "'_domain'", "]", ")", ";", "}", "}", "else", "{", "// no domain provided, we use default search", "foreach", "(", "$", "sortedSearchServices", "as", "$", "service", ")", "{", "if", "(", "$", "service", "->", "isActiveByDefault", "(", ")", ")", "{", "$", "results", "[", "]", "=", "$", "service", "->", "renderResult", "(", "$", "terms", ",", "$", "start", ",", "$", "limit", ")", ";", "}", "}", "}", "//sort array", "ksort", "(", "$", "results", ")", ";", "return", "$", "results", ";", "}" ]
search through services which supports domain and give results as html string @param string $pattern @param number $start @param number $limit @return array of html results @throws UnknowSearchDomainException if the domain is unknow
[ "search", "through", "services", "which", "supports", "domain", "and", "give", "results", "as", "html", "string" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L129-L162
Chill-project/Main
Search/SearchProvider.php
SearchProvider.getByName
public function getByName($name) { if (isset($this->searchServices[$name])) { return $this->searchServices[$name]; } else { throw new UnknowSearchNameException($name); } }
php
public function getByName($name) { if (isset($this->searchServices[$name])) { return $this->searchServices[$name]; } else { throw new UnknowSearchNameException($name); } }
[ "public", "function", "getByName", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "searchServices", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "searchServices", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "UnknowSearchNameException", "(", "$", "name", ")", ";", "}", "}" ]
return search services with a specific name, defined in service definition. @return SearchInterface @throws UnknowSearchNameException if not exists
[ "return", "search", "services", "with", "a", "specific", "name", "defined", "in", "service", "definition", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L184-L191
Chill-project/Main
Search/SearchProvider.php
SearchProvider.remove_accents
private function remove_accents($string) { if (!preg_match('/[\x80-\xff]/', $string)) return $string; //if ($this->seems_utf8($string)) { // remove from wordpress: we use only UTF-8 if (true) { $chars = array( // Decompositions for Latin-1 Supplement chr(194) . chr(170) => 'a', chr(194) . chr(186) => 'o', chr(195) . chr(128) => 'A', chr(195) . chr(129) => 'A', chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A', chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A', chr(195) . chr(134) => 'AE', chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E', chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E', chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I', chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I', chr(195) . chr(143) => 'I', chr(195) . chr(144) => 'D', chr(195) . chr(145) => 'N', chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O', chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O', chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U', chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U', chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y', chr(195) . chr(158) => 'TH', chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a', chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a', chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a', chr(195) . chr(165) => 'a', chr(195) . chr(166) => 'ae', chr(195) . chr(167) => 'c', chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e', chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e', chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i', chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i', chr(195) . chr(176) => 'd', chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o', chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o', chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o', chr(195) . chr(184) => 'o', chr(195) . chr(185) => 'u', chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u', chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y', chr(195) . chr(190) => 'th', chr(195) . chr(191) => 'y', chr(195) . chr(152) => 'O', // Decompositions for Latin Extended-A chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a', chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a', chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a', chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c', chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c', chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c', chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c', chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd', chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd', chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e', chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e', chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e', chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e', chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e', chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g', chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g', chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g', chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g', chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h', chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h', chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i', chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i', chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i', chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i', chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i', chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij', chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j', chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k', chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L', chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L', chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L', chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L', chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L', chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N', chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N', chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N', chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N', chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N', chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o', chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o', chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o', chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe', chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r', chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r', chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r', chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's', chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's', chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's', chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's', chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't', chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't', chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't', chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u', chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u', chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u', chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u', chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u', chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u', chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w', chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y', chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z', chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z', chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z', chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's', // Decompositions for Latin Extended-B chr(200) . chr(152) => 'S', chr(200) . chr(153) => 's', chr(200) . chr(154) => 'T', chr(200) . chr(155) => 't', // Euro Sign chr(226) . chr(130) . chr(172) => 'E', // GBP (Pound) Sign chr(194) . chr(163) => '', // Vowels with diacritic (Vietnamese) // unmarked chr(198) . chr(160) => 'O', chr(198) . chr(161) => 'o', chr(198) . chr(175) => 'U', chr(198) . chr(176) => 'u', // grave accent chr(225) . chr(186) . chr(166) => 'A', chr(225) . chr(186) . chr(167) => 'a', chr(225) . chr(186) . chr(176) => 'A', chr(225) . chr(186) . chr(177) => 'a', chr(225) . chr(187) . chr(128) => 'E', chr(225) . chr(187) . chr(129) => 'e', chr(225) . chr(187) . chr(146) => 'O', chr(225) . chr(187) . chr(147) => 'o', chr(225) . chr(187) . chr(156) => 'O', chr(225) . chr(187) . chr(157) => 'o', chr(225) . chr(187) . chr(170) => 'U', chr(225) . chr(187) . chr(171) => 'u', chr(225) . chr(187) . chr(178) => 'Y', chr(225) . chr(187) . chr(179) => 'y', // hook chr(225) . chr(186) . chr(162) => 'A', chr(225) . chr(186) . chr(163) => 'a', chr(225) . chr(186) . chr(168) => 'A', chr(225) . chr(186) . chr(169) => 'a', chr(225) . chr(186) . chr(178) => 'A', chr(225) . chr(186) . chr(179) => 'a', chr(225) . chr(186) . chr(186) => 'E', chr(225) . chr(186) . chr(187) => 'e', chr(225) . chr(187) . chr(130) => 'E', chr(225) . chr(187) . chr(131) => 'e', chr(225) . chr(187) . chr(136) => 'I', chr(225) . chr(187) . chr(137) => 'i', chr(225) . chr(187) . chr(142) => 'O', chr(225) . chr(187) . chr(143) => 'o', chr(225) . chr(187) . chr(148) => 'O', chr(225) . chr(187) . chr(149) => 'o', chr(225) . chr(187) . chr(158) => 'O', chr(225) . chr(187) . chr(159) => 'o', chr(225) . chr(187) . chr(166) => 'U', chr(225) . chr(187) . chr(167) => 'u', chr(225) . chr(187) . chr(172) => 'U', chr(225) . chr(187) . chr(173) => 'u', chr(225) . chr(187) . chr(182) => 'Y', chr(225) . chr(187) . chr(183) => 'y', // tilde chr(225) . chr(186) . chr(170) => 'A', chr(225) . chr(186) . chr(171) => 'a', chr(225) . chr(186) . chr(180) => 'A', chr(225) . chr(186) . chr(181) => 'a', chr(225) . chr(186) . chr(188) => 'E', chr(225) . chr(186) . chr(189) => 'e', chr(225) . chr(187) . chr(132) => 'E', chr(225) . chr(187) . chr(133) => 'e', chr(225) . chr(187) . chr(150) => 'O', chr(225) . chr(187) . chr(151) => 'o', chr(225) . chr(187) . chr(160) => 'O', chr(225) . chr(187) . chr(161) => 'o', chr(225) . chr(187) . chr(174) => 'U', chr(225) . chr(187) . chr(175) => 'u', chr(225) . chr(187) . chr(184) => 'Y', chr(225) . chr(187) . chr(185) => 'y', // acute accent chr(225) . chr(186) . chr(164) => 'A', chr(225) . chr(186) . chr(165) => 'a', chr(225) . chr(186) . chr(174) => 'A', chr(225) . chr(186) . chr(175) => 'a', chr(225) . chr(186) . chr(190) => 'E', chr(225) . chr(186) . chr(191) => 'e', chr(225) . chr(187) . chr(144) => 'O', chr(225) . chr(187) . chr(145) => 'o', chr(225) . chr(187) . chr(154) => 'O', chr(225) . chr(187) . chr(155) => 'o', chr(225) . chr(187) . chr(168) => 'U', chr(225) . chr(187) . chr(169) => 'u', // dot below chr(225) . chr(186) . chr(160) => 'A', chr(225) . chr(186) . chr(161) => 'a', chr(225) . chr(186) . chr(172) => 'A', chr(225) . chr(186) . chr(173) => 'a', chr(225) . chr(186) . chr(182) => 'A', chr(225) . chr(186) . chr(183) => 'a', chr(225) . chr(186) . chr(184) => 'E', chr(225) . chr(186) . chr(185) => 'e', chr(225) . chr(187) . chr(134) => 'E', chr(225) . chr(187) . chr(135) => 'e', chr(225) . chr(187) . chr(138) => 'I', chr(225) . chr(187) . chr(139) => 'i', chr(225) . chr(187) . chr(140) => 'O', chr(225) . chr(187) . chr(141) => 'o', chr(225) . chr(187) . chr(152) => 'O', chr(225) . chr(187) . chr(153) => 'o', chr(225) . chr(187) . chr(162) => 'O', chr(225) . chr(187) . chr(163) => 'o', chr(225) . chr(187) . chr(164) => 'U', chr(225) . chr(187) . chr(165) => 'u', chr(225) . chr(187) . chr(176) => 'U', chr(225) . chr(187) . chr(177) => 'u', chr(225) . chr(187) . chr(180) => 'Y', chr(225) . chr(187) . chr(181) => 'y', // Vowels with diacritic (Chinese, Hanyu Pinyin) chr(201) . chr(145) => 'a', // macron chr(199) . chr(149) => 'U', chr(199) . chr(150) => 'u', // acute accent chr(199) . chr(151) => 'U', chr(199) . chr(152) => 'u', // caron chr(199) . chr(141) => 'A', chr(199) . chr(142) => 'a', chr(199) . chr(143) => 'I', chr(199) . chr(144) => 'i', chr(199) . chr(145) => 'O', chr(199) . chr(146) => 'o', chr(199) . chr(147) => 'U', chr(199) . chr(148) => 'u', chr(199) . chr(153) => 'U', chr(199) . chr(154) => 'u', // grave accent chr(199) . chr(155) => 'U', chr(199) . chr(156) => 'u', ); // Used for locale-specific rules /* remove from wordpress $locale = get_locale(); if ('de_DE' == $locale) { $chars[chr(195) . chr(132)] = 'Ae'; $chars[chr(195) . chr(164)] = 'ae'; $chars[chr(195) . chr(150)] = 'Oe'; $chars[chr(195) . chr(182)] = 'oe'; $chars[chr(195) . chr(156)] = 'Ue'; $chars[chr(195) . chr(188)] = 'ue'; $chars[chr(195) . chr(159)] = 'ss'; } elseif ('da_DK' === $locale) { $chars[chr(195) . chr(134)] = 'Ae'; $chars[chr(195) . chr(166)] = 'ae'; $chars[chr(195) . chr(152)] = 'Oe'; $chars[chr(195) . chr(184)] = 'oe'; $chars[chr(195) . chr(133)] = 'Aa'; $chars[chr(195) . chr(165)] = 'aa'; }*/ $string = strtr($string, $chars); } /* remove from wordpress: we use only utf 8 * else { // Assume ISO-8859-1 if not UTF-8 $chars['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158) . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194) . chr(195) . chr(196) . chr(197) . chr(199) . chr(200) . chr(201) . chr(202) . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210) . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) . chr(217) . chr(218) . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227) . chr(228) . chr(229) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235) . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243) . chr(244) . chr(245) . chr(246) . chr(248) . chr(249) . chr(250) . chr(251) . chr(252) . chr(253) . chr(255); $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; $string = strtr($string, $chars['in'], $chars['out']); $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); $string = str_replace($double_chars['in'], $double_chars['out'], $string); } */ return $string; }
php
private function remove_accents($string) { if (!preg_match('/[\x80-\xff]/', $string)) return $string; //if ($this->seems_utf8($string)) { // remove from wordpress: we use only UTF-8 if (true) { $chars = array( // Decompositions for Latin-1 Supplement chr(194) . chr(170) => 'a', chr(194) . chr(186) => 'o', chr(195) . chr(128) => 'A', chr(195) . chr(129) => 'A', chr(195) . chr(130) => 'A', chr(195) . chr(131) => 'A', chr(195) . chr(132) => 'A', chr(195) . chr(133) => 'A', chr(195) . chr(134) => 'AE', chr(195) . chr(135) => 'C', chr(195) . chr(136) => 'E', chr(195) . chr(137) => 'E', chr(195) . chr(138) => 'E', chr(195) . chr(139) => 'E', chr(195) . chr(140) => 'I', chr(195) . chr(141) => 'I', chr(195) . chr(142) => 'I', chr(195) . chr(143) => 'I', chr(195) . chr(144) => 'D', chr(195) . chr(145) => 'N', chr(195) . chr(146) => 'O', chr(195) . chr(147) => 'O', chr(195) . chr(148) => 'O', chr(195) . chr(149) => 'O', chr(195) . chr(150) => 'O', chr(195) . chr(153) => 'U', chr(195) . chr(154) => 'U', chr(195) . chr(155) => 'U', chr(195) . chr(156) => 'U', chr(195) . chr(157) => 'Y', chr(195) . chr(158) => 'TH', chr(195) . chr(159) => 's', chr(195) . chr(160) => 'a', chr(195) . chr(161) => 'a', chr(195) . chr(162) => 'a', chr(195) . chr(163) => 'a', chr(195) . chr(164) => 'a', chr(195) . chr(165) => 'a', chr(195) . chr(166) => 'ae', chr(195) . chr(167) => 'c', chr(195) . chr(168) => 'e', chr(195) . chr(169) => 'e', chr(195) . chr(170) => 'e', chr(195) . chr(171) => 'e', chr(195) . chr(172) => 'i', chr(195) . chr(173) => 'i', chr(195) . chr(174) => 'i', chr(195) . chr(175) => 'i', chr(195) . chr(176) => 'd', chr(195) . chr(177) => 'n', chr(195) . chr(178) => 'o', chr(195) . chr(179) => 'o', chr(195) . chr(180) => 'o', chr(195) . chr(181) => 'o', chr(195) . chr(182) => 'o', chr(195) . chr(184) => 'o', chr(195) . chr(185) => 'u', chr(195) . chr(186) => 'u', chr(195) . chr(187) => 'u', chr(195) . chr(188) => 'u', chr(195) . chr(189) => 'y', chr(195) . chr(190) => 'th', chr(195) . chr(191) => 'y', chr(195) . chr(152) => 'O', // Decompositions for Latin Extended-A chr(196) . chr(128) => 'A', chr(196) . chr(129) => 'a', chr(196) . chr(130) => 'A', chr(196) . chr(131) => 'a', chr(196) . chr(132) => 'A', chr(196) . chr(133) => 'a', chr(196) . chr(134) => 'C', chr(196) . chr(135) => 'c', chr(196) . chr(136) => 'C', chr(196) . chr(137) => 'c', chr(196) . chr(138) => 'C', chr(196) . chr(139) => 'c', chr(196) . chr(140) => 'C', chr(196) . chr(141) => 'c', chr(196) . chr(142) => 'D', chr(196) . chr(143) => 'd', chr(196) . chr(144) => 'D', chr(196) . chr(145) => 'd', chr(196) . chr(146) => 'E', chr(196) . chr(147) => 'e', chr(196) . chr(148) => 'E', chr(196) . chr(149) => 'e', chr(196) . chr(150) => 'E', chr(196) . chr(151) => 'e', chr(196) . chr(152) => 'E', chr(196) . chr(153) => 'e', chr(196) . chr(154) => 'E', chr(196) . chr(155) => 'e', chr(196) . chr(156) => 'G', chr(196) . chr(157) => 'g', chr(196) . chr(158) => 'G', chr(196) . chr(159) => 'g', chr(196) . chr(160) => 'G', chr(196) . chr(161) => 'g', chr(196) . chr(162) => 'G', chr(196) . chr(163) => 'g', chr(196) . chr(164) => 'H', chr(196) . chr(165) => 'h', chr(196) . chr(166) => 'H', chr(196) . chr(167) => 'h', chr(196) . chr(168) => 'I', chr(196) . chr(169) => 'i', chr(196) . chr(170) => 'I', chr(196) . chr(171) => 'i', chr(196) . chr(172) => 'I', chr(196) . chr(173) => 'i', chr(196) . chr(174) => 'I', chr(196) . chr(175) => 'i', chr(196) . chr(176) => 'I', chr(196) . chr(177) => 'i', chr(196) . chr(178) => 'IJ', chr(196) . chr(179) => 'ij', chr(196) . chr(180) => 'J', chr(196) . chr(181) => 'j', chr(196) . chr(182) => 'K', chr(196) . chr(183) => 'k', chr(196) . chr(184) => 'k', chr(196) . chr(185) => 'L', chr(196) . chr(186) => 'l', chr(196) . chr(187) => 'L', chr(196) . chr(188) => 'l', chr(196) . chr(189) => 'L', chr(196) . chr(190) => 'l', chr(196) . chr(191) => 'L', chr(197) . chr(128) => 'l', chr(197) . chr(129) => 'L', chr(197) . chr(130) => 'l', chr(197) . chr(131) => 'N', chr(197) . chr(132) => 'n', chr(197) . chr(133) => 'N', chr(197) . chr(134) => 'n', chr(197) . chr(135) => 'N', chr(197) . chr(136) => 'n', chr(197) . chr(137) => 'N', chr(197) . chr(138) => 'n', chr(197) . chr(139) => 'N', chr(197) . chr(140) => 'O', chr(197) . chr(141) => 'o', chr(197) . chr(142) => 'O', chr(197) . chr(143) => 'o', chr(197) . chr(144) => 'O', chr(197) . chr(145) => 'o', chr(197) . chr(146) => 'OE', chr(197) . chr(147) => 'oe', chr(197) . chr(148) => 'R', chr(197) . chr(149) => 'r', chr(197) . chr(150) => 'R', chr(197) . chr(151) => 'r', chr(197) . chr(152) => 'R', chr(197) . chr(153) => 'r', chr(197) . chr(154) => 'S', chr(197) . chr(155) => 's', chr(197) . chr(156) => 'S', chr(197) . chr(157) => 's', chr(197) . chr(158) => 'S', chr(197) . chr(159) => 's', chr(197) . chr(160) => 'S', chr(197) . chr(161) => 's', chr(197) . chr(162) => 'T', chr(197) . chr(163) => 't', chr(197) . chr(164) => 'T', chr(197) . chr(165) => 't', chr(197) . chr(166) => 'T', chr(197) . chr(167) => 't', chr(197) . chr(168) => 'U', chr(197) . chr(169) => 'u', chr(197) . chr(170) => 'U', chr(197) . chr(171) => 'u', chr(197) . chr(172) => 'U', chr(197) . chr(173) => 'u', chr(197) . chr(174) => 'U', chr(197) . chr(175) => 'u', chr(197) . chr(176) => 'U', chr(197) . chr(177) => 'u', chr(197) . chr(178) => 'U', chr(197) . chr(179) => 'u', chr(197) . chr(180) => 'W', chr(197) . chr(181) => 'w', chr(197) . chr(182) => 'Y', chr(197) . chr(183) => 'y', chr(197) . chr(184) => 'Y', chr(197) . chr(185) => 'Z', chr(197) . chr(186) => 'z', chr(197) . chr(187) => 'Z', chr(197) . chr(188) => 'z', chr(197) . chr(189) => 'Z', chr(197) . chr(190) => 'z', chr(197) . chr(191) => 's', // Decompositions for Latin Extended-B chr(200) . chr(152) => 'S', chr(200) . chr(153) => 's', chr(200) . chr(154) => 'T', chr(200) . chr(155) => 't', // Euro Sign chr(226) . chr(130) . chr(172) => 'E', // GBP (Pound) Sign chr(194) . chr(163) => '', // Vowels with diacritic (Vietnamese) // unmarked chr(198) . chr(160) => 'O', chr(198) . chr(161) => 'o', chr(198) . chr(175) => 'U', chr(198) . chr(176) => 'u', // grave accent chr(225) . chr(186) . chr(166) => 'A', chr(225) . chr(186) . chr(167) => 'a', chr(225) . chr(186) . chr(176) => 'A', chr(225) . chr(186) . chr(177) => 'a', chr(225) . chr(187) . chr(128) => 'E', chr(225) . chr(187) . chr(129) => 'e', chr(225) . chr(187) . chr(146) => 'O', chr(225) . chr(187) . chr(147) => 'o', chr(225) . chr(187) . chr(156) => 'O', chr(225) . chr(187) . chr(157) => 'o', chr(225) . chr(187) . chr(170) => 'U', chr(225) . chr(187) . chr(171) => 'u', chr(225) . chr(187) . chr(178) => 'Y', chr(225) . chr(187) . chr(179) => 'y', // hook chr(225) . chr(186) . chr(162) => 'A', chr(225) . chr(186) . chr(163) => 'a', chr(225) . chr(186) . chr(168) => 'A', chr(225) . chr(186) . chr(169) => 'a', chr(225) . chr(186) . chr(178) => 'A', chr(225) . chr(186) . chr(179) => 'a', chr(225) . chr(186) . chr(186) => 'E', chr(225) . chr(186) . chr(187) => 'e', chr(225) . chr(187) . chr(130) => 'E', chr(225) . chr(187) . chr(131) => 'e', chr(225) . chr(187) . chr(136) => 'I', chr(225) . chr(187) . chr(137) => 'i', chr(225) . chr(187) . chr(142) => 'O', chr(225) . chr(187) . chr(143) => 'o', chr(225) . chr(187) . chr(148) => 'O', chr(225) . chr(187) . chr(149) => 'o', chr(225) . chr(187) . chr(158) => 'O', chr(225) . chr(187) . chr(159) => 'o', chr(225) . chr(187) . chr(166) => 'U', chr(225) . chr(187) . chr(167) => 'u', chr(225) . chr(187) . chr(172) => 'U', chr(225) . chr(187) . chr(173) => 'u', chr(225) . chr(187) . chr(182) => 'Y', chr(225) . chr(187) . chr(183) => 'y', // tilde chr(225) . chr(186) . chr(170) => 'A', chr(225) . chr(186) . chr(171) => 'a', chr(225) . chr(186) . chr(180) => 'A', chr(225) . chr(186) . chr(181) => 'a', chr(225) . chr(186) . chr(188) => 'E', chr(225) . chr(186) . chr(189) => 'e', chr(225) . chr(187) . chr(132) => 'E', chr(225) . chr(187) . chr(133) => 'e', chr(225) . chr(187) . chr(150) => 'O', chr(225) . chr(187) . chr(151) => 'o', chr(225) . chr(187) . chr(160) => 'O', chr(225) . chr(187) . chr(161) => 'o', chr(225) . chr(187) . chr(174) => 'U', chr(225) . chr(187) . chr(175) => 'u', chr(225) . chr(187) . chr(184) => 'Y', chr(225) . chr(187) . chr(185) => 'y', // acute accent chr(225) . chr(186) . chr(164) => 'A', chr(225) . chr(186) . chr(165) => 'a', chr(225) . chr(186) . chr(174) => 'A', chr(225) . chr(186) . chr(175) => 'a', chr(225) . chr(186) . chr(190) => 'E', chr(225) . chr(186) . chr(191) => 'e', chr(225) . chr(187) . chr(144) => 'O', chr(225) . chr(187) . chr(145) => 'o', chr(225) . chr(187) . chr(154) => 'O', chr(225) . chr(187) . chr(155) => 'o', chr(225) . chr(187) . chr(168) => 'U', chr(225) . chr(187) . chr(169) => 'u', // dot below chr(225) . chr(186) . chr(160) => 'A', chr(225) . chr(186) . chr(161) => 'a', chr(225) . chr(186) . chr(172) => 'A', chr(225) . chr(186) . chr(173) => 'a', chr(225) . chr(186) . chr(182) => 'A', chr(225) . chr(186) . chr(183) => 'a', chr(225) . chr(186) . chr(184) => 'E', chr(225) . chr(186) . chr(185) => 'e', chr(225) . chr(187) . chr(134) => 'E', chr(225) . chr(187) . chr(135) => 'e', chr(225) . chr(187) . chr(138) => 'I', chr(225) . chr(187) . chr(139) => 'i', chr(225) . chr(187) . chr(140) => 'O', chr(225) . chr(187) . chr(141) => 'o', chr(225) . chr(187) . chr(152) => 'O', chr(225) . chr(187) . chr(153) => 'o', chr(225) . chr(187) . chr(162) => 'O', chr(225) . chr(187) . chr(163) => 'o', chr(225) . chr(187) . chr(164) => 'U', chr(225) . chr(187) . chr(165) => 'u', chr(225) . chr(187) . chr(176) => 'U', chr(225) . chr(187) . chr(177) => 'u', chr(225) . chr(187) . chr(180) => 'Y', chr(225) . chr(187) . chr(181) => 'y', // Vowels with diacritic (Chinese, Hanyu Pinyin) chr(201) . chr(145) => 'a', // macron chr(199) . chr(149) => 'U', chr(199) . chr(150) => 'u', // acute accent chr(199) . chr(151) => 'U', chr(199) . chr(152) => 'u', // caron chr(199) . chr(141) => 'A', chr(199) . chr(142) => 'a', chr(199) . chr(143) => 'I', chr(199) . chr(144) => 'i', chr(199) . chr(145) => 'O', chr(199) . chr(146) => 'o', chr(199) . chr(147) => 'U', chr(199) . chr(148) => 'u', chr(199) . chr(153) => 'U', chr(199) . chr(154) => 'u', // grave accent chr(199) . chr(155) => 'U', chr(199) . chr(156) => 'u', ); // Used for locale-specific rules /* remove from wordpress $locale = get_locale(); if ('de_DE' == $locale) { $chars[chr(195) . chr(132)] = 'Ae'; $chars[chr(195) . chr(164)] = 'ae'; $chars[chr(195) . chr(150)] = 'Oe'; $chars[chr(195) . chr(182)] = 'oe'; $chars[chr(195) . chr(156)] = 'Ue'; $chars[chr(195) . chr(188)] = 'ue'; $chars[chr(195) . chr(159)] = 'ss'; } elseif ('da_DK' === $locale) { $chars[chr(195) . chr(134)] = 'Ae'; $chars[chr(195) . chr(166)] = 'ae'; $chars[chr(195) . chr(152)] = 'Oe'; $chars[chr(195) . chr(184)] = 'oe'; $chars[chr(195) . chr(133)] = 'Aa'; $chars[chr(195) . chr(165)] = 'aa'; }*/ $string = strtr($string, $chars); } /* remove from wordpress: we use only utf 8 * else { // Assume ISO-8859-1 if not UTF-8 $chars['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158) . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194) . chr(195) . chr(196) . chr(197) . chr(199) . chr(200) . chr(201) . chr(202) . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210) . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) . chr(217) . chr(218) . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227) . chr(228) . chr(229) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235) . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243) . chr(244) . chr(245) . chr(246) . chr(248) . chr(249) . chr(250) . chr(251) . chr(252) . chr(253) . chr(255); $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"; $string = strtr($string, $chars['in'], $chars['out']); $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254)); $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th'); $string = str_replace($double_chars['in'], $double_chars['out'], $string); } */ return $string; }
[ "private", "function", "remove_accents", "(", "$", "string", ")", "{", "if", "(", "!", "preg_match", "(", "'/[\\x80-\\xff]/'", ",", "$", "string", ")", ")", "return", "$", "string", ";", "//if ($this->seems_utf8($string)) { // remove from wordpress: we use only UTF-8", "if", "(", "true", ")", "{", "$", "chars", "=", "array", "(", "// Decompositions for Latin-1 Supplement", "chr", "(", "194", ")", ".", "chr", "(", "170", ")", "=>", "'a'", ",", "chr", "(", "194", ")", ".", "chr", "(", "186", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "128", ")", "=>", "'A'", ",", "chr", "(", "195", ")", ".", "chr", "(", "129", ")", "=>", "'A'", ",", "chr", "(", "195", ")", ".", "chr", "(", "130", ")", "=>", "'A'", ",", "chr", "(", "195", ")", ".", "chr", "(", "131", ")", "=>", "'A'", ",", "chr", "(", "195", ")", ".", "chr", "(", "132", ")", "=>", "'A'", ",", "chr", "(", "195", ")", ".", "chr", "(", "133", ")", "=>", "'A'", ",", "chr", "(", "195", ")", ".", "chr", "(", "134", ")", "=>", "'AE'", ",", "chr", "(", "195", ")", ".", "chr", "(", "135", ")", "=>", "'C'", ",", "chr", "(", "195", ")", ".", "chr", "(", "136", ")", "=>", "'E'", ",", "chr", "(", "195", ")", ".", "chr", "(", "137", ")", "=>", "'E'", ",", "chr", "(", "195", ")", ".", "chr", "(", "138", ")", "=>", "'E'", ",", "chr", "(", "195", ")", ".", "chr", "(", "139", ")", "=>", "'E'", ",", "chr", "(", "195", ")", ".", "chr", "(", "140", ")", "=>", "'I'", ",", "chr", "(", "195", ")", ".", "chr", "(", "141", ")", "=>", "'I'", ",", "chr", "(", "195", ")", ".", "chr", "(", "142", ")", "=>", "'I'", ",", "chr", "(", "195", ")", ".", "chr", "(", "143", ")", "=>", "'I'", ",", "chr", "(", "195", ")", ".", "chr", "(", "144", ")", "=>", "'D'", ",", "chr", "(", "195", ")", ".", "chr", "(", "145", ")", "=>", "'N'", ",", "chr", "(", "195", ")", ".", "chr", "(", "146", ")", "=>", "'O'", ",", "chr", "(", "195", ")", ".", "chr", "(", "147", ")", "=>", "'O'", ",", "chr", "(", "195", ")", ".", "chr", "(", "148", ")", "=>", "'O'", ",", "chr", "(", "195", ")", ".", "chr", "(", "149", ")", "=>", "'O'", ",", "chr", "(", "195", ")", ".", "chr", "(", "150", ")", "=>", "'O'", ",", "chr", "(", "195", ")", ".", "chr", "(", "153", ")", "=>", "'U'", ",", "chr", "(", "195", ")", ".", "chr", "(", "154", ")", "=>", "'U'", ",", "chr", "(", "195", ")", ".", "chr", "(", "155", ")", "=>", "'U'", ",", "chr", "(", "195", ")", ".", "chr", "(", "156", ")", "=>", "'U'", ",", "chr", "(", "195", ")", ".", "chr", "(", "157", ")", "=>", "'Y'", ",", "chr", "(", "195", ")", ".", "chr", "(", "158", ")", "=>", "'TH'", ",", "chr", "(", "195", ")", ".", "chr", "(", "159", ")", "=>", "'s'", ",", "chr", "(", "195", ")", ".", "chr", "(", "160", ")", "=>", "'a'", ",", "chr", "(", "195", ")", ".", "chr", "(", "161", ")", "=>", "'a'", ",", "chr", "(", "195", ")", ".", "chr", "(", "162", ")", "=>", "'a'", ",", "chr", "(", "195", ")", ".", "chr", "(", "163", ")", "=>", "'a'", ",", "chr", "(", "195", ")", ".", "chr", "(", "164", ")", "=>", "'a'", ",", "chr", "(", "195", ")", ".", "chr", "(", "165", ")", "=>", "'a'", ",", "chr", "(", "195", ")", ".", "chr", "(", "166", ")", "=>", "'ae'", ",", "chr", "(", "195", ")", ".", "chr", "(", "167", ")", "=>", "'c'", ",", "chr", "(", "195", ")", ".", "chr", "(", "168", ")", "=>", "'e'", ",", "chr", "(", "195", ")", ".", "chr", "(", "169", ")", "=>", "'e'", ",", "chr", "(", "195", ")", ".", "chr", "(", "170", ")", "=>", "'e'", ",", "chr", "(", "195", ")", ".", "chr", "(", "171", ")", "=>", "'e'", ",", "chr", "(", "195", ")", ".", "chr", "(", "172", ")", "=>", "'i'", ",", "chr", "(", "195", ")", ".", "chr", "(", "173", ")", "=>", "'i'", ",", "chr", "(", "195", ")", ".", "chr", "(", "174", ")", "=>", "'i'", ",", "chr", "(", "195", ")", ".", "chr", "(", "175", ")", "=>", "'i'", ",", "chr", "(", "195", ")", ".", "chr", "(", "176", ")", "=>", "'d'", ",", "chr", "(", "195", ")", ".", "chr", "(", "177", ")", "=>", "'n'", ",", "chr", "(", "195", ")", ".", "chr", "(", "178", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "179", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "180", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "181", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "182", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "184", ")", "=>", "'o'", ",", "chr", "(", "195", ")", ".", "chr", "(", "185", ")", "=>", "'u'", ",", "chr", "(", "195", ")", ".", "chr", "(", "186", ")", "=>", "'u'", ",", "chr", "(", "195", ")", ".", "chr", "(", "187", ")", "=>", "'u'", ",", "chr", "(", "195", ")", ".", "chr", "(", "188", ")", "=>", "'u'", ",", "chr", "(", "195", ")", ".", "chr", "(", "189", ")", "=>", "'y'", ",", "chr", "(", "195", ")", ".", "chr", "(", "190", ")", "=>", "'th'", ",", "chr", "(", "195", ")", ".", "chr", "(", "191", ")", "=>", "'y'", ",", "chr", "(", "195", ")", ".", "chr", "(", "152", ")", "=>", "'O'", ",", "// Decompositions for Latin Extended-A", "chr", "(", "196", ")", ".", "chr", "(", "128", ")", "=>", "'A'", ",", "chr", "(", "196", ")", ".", "chr", "(", "129", ")", "=>", "'a'", ",", "chr", "(", "196", ")", ".", "chr", "(", "130", ")", "=>", "'A'", ",", "chr", "(", "196", ")", ".", "chr", "(", "131", ")", "=>", "'a'", ",", "chr", "(", "196", ")", ".", "chr", "(", "132", ")", "=>", "'A'", ",", "chr", "(", "196", ")", ".", "chr", "(", "133", ")", "=>", "'a'", ",", "chr", "(", "196", ")", ".", "chr", "(", "134", ")", "=>", "'C'", ",", "chr", "(", "196", ")", ".", "chr", "(", "135", ")", "=>", "'c'", ",", "chr", "(", "196", ")", ".", "chr", "(", "136", ")", "=>", "'C'", ",", "chr", "(", "196", ")", ".", "chr", "(", "137", ")", "=>", "'c'", ",", "chr", "(", "196", ")", ".", "chr", "(", "138", ")", "=>", "'C'", ",", "chr", "(", "196", ")", ".", "chr", "(", "139", ")", "=>", "'c'", ",", "chr", "(", "196", ")", ".", "chr", "(", "140", ")", "=>", "'C'", ",", "chr", "(", "196", ")", ".", "chr", "(", "141", ")", "=>", "'c'", ",", "chr", "(", "196", ")", ".", "chr", "(", "142", ")", "=>", "'D'", ",", "chr", "(", "196", ")", ".", "chr", "(", "143", ")", "=>", "'d'", ",", "chr", "(", "196", ")", ".", "chr", "(", "144", ")", "=>", "'D'", ",", "chr", "(", "196", ")", ".", "chr", "(", "145", ")", "=>", "'d'", ",", "chr", "(", "196", ")", ".", "chr", "(", "146", ")", "=>", "'E'", ",", "chr", "(", "196", ")", ".", "chr", "(", "147", ")", "=>", "'e'", ",", "chr", "(", "196", ")", ".", "chr", "(", "148", ")", "=>", "'E'", ",", "chr", "(", "196", ")", ".", "chr", "(", "149", ")", "=>", "'e'", ",", "chr", "(", "196", ")", ".", "chr", "(", "150", ")", "=>", "'E'", ",", "chr", "(", "196", ")", ".", "chr", "(", "151", ")", "=>", "'e'", ",", "chr", "(", "196", ")", ".", "chr", "(", "152", ")", "=>", "'E'", ",", "chr", "(", "196", ")", ".", "chr", "(", "153", ")", "=>", "'e'", ",", "chr", "(", "196", ")", ".", "chr", "(", "154", ")", "=>", "'E'", ",", "chr", "(", "196", ")", ".", "chr", "(", "155", ")", "=>", "'e'", ",", "chr", "(", "196", ")", ".", "chr", "(", "156", ")", "=>", "'G'", ",", "chr", "(", "196", ")", ".", "chr", "(", "157", ")", "=>", "'g'", ",", "chr", "(", "196", ")", ".", "chr", "(", "158", ")", "=>", "'G'", ",", "chr", "(", "196", ")", ".", "chr", "(", "159", ")", "=>", "'g'", ",", "chr", "(", "196", ")", ".", "chr", "(", "160", ")", "=>", "'G'", ",", "chr", "(", "196", ")", ".", "chr", "(", "161", ")", "=>", "'g'", ",", "chr", "(", "196", ")", ".", "chr", "(", "162", ")", "=>", "'G'", ",", "chr", "(", "196", ")", ".", "chr", "(", "163", ")", "=>", "'g'", ",", "chr", "(", "196", ")", ".", "chr", "(", "164", ")", "=>", "'H'", ",", "chr", "(", "196", ")", ".", "chr", "(", "165", ")", "=>", "'h'", ",", "chr", "(", "196", ")", ".", "chr", "(", "166", ")", "=>", "'H'", ",", "chr", "(", "196", ")", ".", "chr", "(", "167", ")", "=>", "'h'", ",", "chr", "(", "196", ")", ".", "chr", "(", "168", ")", "=>", "'I'", ",", "chr", "(", "196", ")", ".", "chr", "(", "169", ")", "=>", "'i'", ",", "chr", "(", "196", ")", ".", "chr", "(", "170", ")", "=>", "'I'", ",", "chr", "(", "196", ")", ".", "chr", "(", "171", ")", "=>", "'i'", ",", "chr", "(", "196", ")", ".", "chr", "(", "172", ")", "=>", "'I'", ",", "chr", "(", "196", ")", ".", "chr", "(", "173", ")", "=>", "'i'", ",", "chr", "(", "196", ")", ".", "chr", "(", "174", ")", "=>", "'I'", ",", "chr", "(", "196", ")", ".", "chr", "(", "175", ")", "=>", "'i'", ",", "chr", "(", "196", ")", ".", "chr", "(", "176", ")", "=>", "'I'", ",", "chr", "(", "196", ")", ".", "chr", "(", "177", ")", "=>", "'i'", ",", "chr", "(", "196", ")", ".", "chr", "(", "178", ")", "=>", "'IJ'", ",", "chr", "(", "196", ")", ".", "chr", "(", "179", ")", "=>", "'ij'", ",", "chr", "(", "196", ")", ".", "chr", "(", "180", ")", "=>", "'J'", ",", "chr", "(", "196", ")", ".", "chr", "(", "181", ")", "=>", "'j'", ",", "chr", "(", "196", ")", ".", "chr", "(", "182", ")", "=>", "'K'", ",", "chr", "(", "196", ")", ".", "chr", "(", "183", ")", "=>", "'k'", ",", "chr", "(", "196", ")", ".", "chr", "(", "184", ")", "=>", "'k'", ",", "chr", "(", "196", ")", ".", "chr", "(", "185", ")", "=>", "'L'", ",", "chr", "(", "196", ")", ".", "chr", "(", "186", ")", "=>", "'l'", ",", "chr", "(", "196", ")", ".", "chr", "(", "187", ")", "=>", "'L'", ",", "chr", "(", "196", ")", ".", "chr", "(", "188", ")", "=>", "'l'", ",", "chr", "(", "196", ")", ".", "chr", "(", "189", ")", "=>", "'L'", ",", "chr", "(", "196", ")", ".", "chr", "(", "190", ")", "=>", "'l'", ",", "chr", "(", "196", ")", ".", "chr", "(", "191", ")", "=>", "'L'", ",", "chr", "(", "197", ")", ".", "chr", "(", "128", ")", "=>", "'l'", ",", "chr", "(", "197", ")", ".", "chr", "(", "129", ")", "=>", "'L'", ",", "chr", "(", "197", ")", ".", "chr", "(", "130", ")", "=>", "'l'", ",", "chr", "(", "197", ")", ".", "chr", "(", "131", ")", "=>", "'N'", ",", "chr", "(", "197", ")", ".", "chr", "(", "132", ")", "=>", "'n'", ",", "chr", "(", "197", ")", ".", "chr", "(", "133", ")", "=>", "'N'", ",", "chr", "(", "197", ")", ".", "chr", "(", "134", ")", "=>", "'n'", ",", "chr", "(", "197", ")", ".", "chr", "(", "135", ")", "=>", "'N'", ",", "chr", "(", "197", ")", ".", "chr", "(", "136", ")", "=>", "'n'", ",", "chr", "(", "197", ")", ".", "chr", "(", "137", ")", "=>", "'N'", ",", "chr", "(", "197", ")", ".", "chr", "(", "138", ")", "=>", "'n'", ",", "chr", "(", "197", ")", ".", "chr", "(", "139", ")", "=>", "'N'", ",", "chr", "(", "197", ")", ".", "chr", "(", "140", ")", "=>", "'O'", ",", "chr", "(", "197", ")", ".", "chr", "(", "141", ")", "=>", "'o'", ",", "chr", "(", "197", ")", ".", "chr", "(", "142", ")", "=>", "'O'", ",", "chr", "(", "197", ")", ".", "chr", "(", "143", ")", "=>", "'o'", ",", "chr", "(", "197", ")", ".", "chr", "(", "144", ")", "=>", "'O'", ",", "chr", "(", "197", ")", ".", "chr", "(", "145", ")", "=>", "'o'", ",", "chr", "(", "197", ")", ".", "chr", "(", "146", ")", "=>", "'OE'", ",", "chr", "(", "197", ")", ".", "chr", "(", "147", ")", "=>", "'oe'", ",", "chr", "(", "197", ")", ".", "chr", "(", "148", ")", "=>", "'R'", ",", "chr", "(", "197", ")", ".", "chr", "(", "149", ")", "=>", "'r'", ",", "chr", "(", "197", ")", ".", "chr", "(", "150", ")", "=>", "'R'", ",", "chr", "(", "197", ")", ".", "chr", "(", "151", ")", "=>", "'r'", ",", "chr", "(", "197", ")", ".", "chr", "(", "152", ")", "=>", "'R'", ",", "chr", "(", "197", ")", ".", "chr", "(", "153", ")", "=>", "'r'", ",", "chr", "(", "197", ")", ".", "chr", "(", "154", ")", "=>", "'S'", ",", "chr", "(", "197", ")", ".", "chr", "(", "155", ")", "=>", "'s'", ",", "chr", "(", "197", ")", ".", "chr", "(", "156", ")", "=>", "'S'", ",", "chr", "(", "197", ")", ".", "chr", "(", "157", ")", "=>", "'s'", ",", "chr", "(", "197", ")", ".", "chr", "(", "158", ")", "=>", "'S'", ",", "chr", "(", "197", ")", ".", "chr", "(", "159", ")", "=>", "'s'", ",", "chr", "(", "197", ")", ".", "chr", "(", "160", ")", "=>", "'S'", ",", "chr", "(", "197", ")", ".", "chr", "(", "161", ")", "=>", "'s'", ",", "chr", "(", "197", ")", ".", "chr", "(", "162", ")", "=>", "'T'", ",", "chr", "(", "197", ")", ".", "chr", "(", "163", ")", "=>", "'t'", ",", "chr", "(", "197", ")", ".", "chr", "(", "164", ")", "=>", "'T'", ",", "chr", "(", "197", ")", ".", "chr", "(", "165", ")", "=>", "'t'", ",", "chr", "(", "197", ")", ".", "chr", "(", "166", ")", "=>", "'T'", ",", "chr", "(", "197", ")", ".", "chr", "(", "167", ")", "=>", "'t'", ",", "chr", "(", "197", ")", ".", "chr", "(", "168", ")", "=>", "'U'", ",", "chr", "(", "197", ")", ".", "chr", "(", "169", ")", "=>", "'u'", ",", "chr", "(", "197", ")", ".", "chr", "(", "170", ")", "=>", "'U'", ",", "chr", "(", "197", ")", ".", "chr", "(", "171", ")", "=>", "'u'", ",", "chr", "(", "197", ")", ".", "chr", "(", "172", ")", "=>", "'U'", ",", "chr", "(", "197", ")", ".", "chr", "(", "173", ")", "=>", "'u'", ",", "chr", "(", "197", ")", ".", "chr", "(", "174", ")", "=>", "'U'", ",", "chr", "(", "197", ")", ".", "chr", "(", "175", ")", "=>", "'u'", ",", "chr", "(", "197", ")", ".", "chr", "(", "176", ")", "=>", "'U'", ",", "chr", "(", "197", ")", ".", "chr", "(", "177", ")", "=>", "'u'", ",", "chr", "(", "197", ")", ".", "chr", "(", "178", ")", "=>", "'U'", ",", "chr", "(", "197", ")", ".", "chr", "(", "179", ")", "=>", "'u'", ",", "chr", "(", "197", ")", ".", "chr", "(", "180", ")", "=>", "'W'", ",", "chr", "(", "197", ")", ".", "chr", "(", "181", ")", "=>", "'w'", ",", "chr", "(", "197", ")", ".", "chr", "(", "182", ")", "=>", "'Y'", ",", "chr", "(", "197", ")", ".", "chr", "(", "183", ")", "=>", "'y'", ",", "chr", "(", "197", ")", ".", "chr", "(", "184", ")", "=>", "'Y'", ",", "chr", "(", "197", ")", ".", "chr", "(", "185", ")", "=>", "'Z'", ",", "chr", "(", "197", ")", ".", "chr", "(", "186", ")", "=>", "'z'", ",", "chr", "(", "197", ")", ".", "chr", "(", "187", ")", "=>", "'Z'", ",", "chr", "(", "197", ")", ".", "chr", "(", "188", ")", "=>", "'z'", ",", "chr", "(", "197", ")", ".", "chr", "(", "189", ")", "=>", "'Z'", ",", "chr", "(", "197", ")", ".", "chr", "(", "190", ")", "=>", "'z'", ",", "chr", "(", "197", ")", ".", "chr", "(", "191", ")", "=>", "'s'", ",", "// Decompositions for Latin Extended-B", "chr", "(", "200", ")", ".", "chr", "(", "152", ")", "=>", "'S'", ",", "chr", "(", "200", ")", ".", "chr", "(", "153", ")", "=>", "'s'", ",", "chr", "(", "200", ")", ".", "chr", "(", "154", ")", "=>", "'T'", ",", "chr", "(", "200", ")", ".", "chr", "(", "155", ")", "=>", "'t'", ",", "// Euro Sign", "chr", "(", "226", ")", ".", "chr", "(", "130", ")", ".", "chr", "(", "172", ")", "=>", "'E'", ",", "// GBP (Pound) Sign", "chr", "(", "194", ")", ".", "chr", "(", "163", ")", "=>", "''", ",", "// Vowels with diacritic (Vietnamese)", "// unmarked", "chr", "(", "198", ")", ".", "chr", "(", "160", ")", "=>", "'O'", ",", "chr", "(", "198", ")", ".", "chr", "(", "161", ")", "=>", "'o'", ",", "chr", "(", "198", ")", ".", "chr", "(", "175", ")", "=>", "'U'", ",", "chr", "(", "198", ")", ".", "chr", "(", "176", ")", "=>", "'u'", ",", "// grave accent", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "166", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "167", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "176", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "177", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "128", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "129", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "146", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "147", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "156", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "157", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "170", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "171", ")", "=>", "'u'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "178", ")", "=>", "'Y'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "179", ")", "=>", "'y'", ",", "// hook", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "162", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "163", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "168", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "169", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "178", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "179", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "186", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "187", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "130", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "131", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "136", ")", "=>", "'I'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "137", ")", "=>", "'i'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "142", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "143", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "148", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "149", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "158", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "159", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "166", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "167", ")", "=>", "'u'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "172", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "173", ")", "=>", "'u'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "182", ")", "=>", "'Y'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "183", ")", "=>", "'y'", ",", "// tilde", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "170", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "171", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "180", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "181", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "188", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "189", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "132", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "133", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "150", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "151", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "160", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "161", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "174", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "175", ")", "=>", "'u'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "184", ")", "=>", "'Y'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "185", ")", "=>", "'y'", ",", "// acute accent", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "164", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "165", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "174", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "175", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "190", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "191", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "144", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "145", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "154", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "155", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "168", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "169", ")", "=>", "'u'", ",", "// dot below", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "160", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "161", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "172", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "173", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "182", ")", "=>", "'A'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "183", ")", "=>", "'a'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "184", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "186", ")", ".", "chr", "(", "185", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "134", ")", "=>", "'E'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "135", ")", "=>", "'e'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "138", ")", "=>", "'I'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "139", ")", "=>", "'i'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "140", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "141", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "152", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "153", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "162", ")", "=>", "'O'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "163", ")", "=>", "'o'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "164", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "165", ")", "=>", "'u'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "176", ")", "=>", "'U'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "177", ")", "=>", "'u'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "180", ")", "=>", "'Y'", ",", "chr", "(", "225", ")", ".", "chr", "(", "187", ")", ".", "chr", "(", "181", ")", "=>", "'y'", ",", "// Vowels with diacritic (Chinese, Hanyu Pinyin)", "chr", "(", "201", ")", ".", "chr", "(", "145", ")", "=>", "'a'", ",", "// macron", "chr", "(", "199", ")", ".", "chr", "(", "149", ")", "=>", "'U'", ",", "chr", "(", "199", ")", ".", "chr", "(", "150", ")", "=>", "'u'", ",", "// acute accent", "chr", "(", "199", ")", ".", "chr", "(", "151", ")", "=>", "'U'", ",", "chr", "(", "199", ")", ".", "chr", "(", "152", ")", "=>", "'u'", ",", "// caron", "chr", "(", "199", ")", ".", "chr", "(", "141", ")", "=>", "'A'", ",", "chr", "(", "199", ")", ".", "chr", "(", "142", ")", "=>", "'a'", ",", "chr", "(", "199", ")", ".", "chr", "(", "143", ")", "=>", "'I'", ",", "chr", "(", "199", ")", ".", "chr", "(", "144", ")", "=>", "'i'", ",", "chr", "(", "199", ")", ".", "chr", "(", "145", ")", "=>", "'O'", ",", "chr", "(", "199", ")", ".", "chr", "(", "146", ")", "=>", "'o'", ",", "chr", "(", "199", ")", ".", "chr", "(", "147", ")", "=>", "'U'", ",", "chr", "(", "199", ")", ".", "chr", "(", "148", ")", "=>", "'u'", ",", "chr", "(", "199", ")", ".", "chr", "(", "153", ")", "=>", "'U'", ",", "chr", "(", "199", ")", ".", "chr", "(", "154", ")", "=>", "'u'", ",", "// grave accent", "chr", "(", "199", ")", ".", "chr", "(", "155", ")", "=>", "'U'", ",", "chr", "(", "199", ")", ".", "chr", "(", "156", ")", "=>", "'u'", ",", ")", ";", "// Used for locale-specific rules", "/* remove from wordpress\n $locale = get_locale();\n\n if ('de_DE' == $locale) {\n $chars[chr(195) . chr(132)] = 'Ae';\n $chars[chr(195) . chr(164)] = 'ae';\n $chars[chr(195) . chr(150)] = 'Oe';\n $chars[chr(195) . chr(182)] = 'oe';\n $chars[chr(195) . chr(156)] = 'Ue';\n $chars[chr(195) . chr(188)] = 'ue';\n $chars[chr(195) . chr(159)] = 'ss';\n } elseif ('da_DK' === $locale) {\n $chars[chr(195) . chr(134)] = 'Ae';\n $chars[chr(195) . chr(166)] = 'ae';\n $chars[chr(195) . chr(152)] = 'Oe';\n $chars[chr(195) . chr(184)] = 'oe';\n $chars[chr(195) . chr(133)] = 'Aa';\n $chars[chr(195) . chr(165)] = 'aa';\n }*/", "$", "string", "=", "strtr", "(", "$", "string", ",", "$", "chars", ")", ";", "}", "/* remove from wordpress: we use only utf 8\n * else {\n \n // Assume ISO-8859-1 if not UTF-8\n $chars['in'] = chr(128) . chr(131) . chr(138) . chr(142) . chr(154) . chr(158)\n . chr(159) . chr(162) . chr(165) . chr(181) . chr(192) . chr(193) . chr(194)\n . chr(195) . chr(196) . chr(197) . chr(199) . chr(200) . chr(201) . chr(202)\n . chr(203) . chr(204) . chr(205) . chr(206) . chr(207) . chr(209) . chr(210)\n . chr(211) . chr(212) . chr(213) . chr(214) . chr(216) . chr(217) . chr(218)\n . chr(219) . chr(220) . chr(221) . chr(224) . chr(225) . chr(226) . chr(227)\n . chr(228) . chr(229) . chr(231) . chr(232) . chr(233) . chr(234) . chr(235)\n . chr(236) . chr(237) . chr(238) . chr(239) . chr(241) . chr(242) . chr(243)\n . chr(244) . chr(245) . chr(246) . chr(248) . chr(249) . chr(250) . chr(251)\n . chr(252) . chr(253) . chr(255);\n\n $chars['out'] = \"EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy\";\n\n $string = strtr($string, $chars['in'], $chars['out']);\n $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));\n $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');\n $string = str_replace($double_chars['in'], $double_chars['out'], $string);\n } */", "return", "$", "string", ";", "}" ]
Converts all accent characters to ASCII characters. If there are no accent characters, then the string given is just returned. Imported from wordpress : https://core.trac.wordpress.org/browser/tags/4.1/src/wp-includes/formatting.php?order=name @param string $string Text that might have accent characters @return string Filtered string with replaced "nice" characters. @license GNU GPLv2 : https://core.trac.wordpress.org/browser/tags/4.1/src/license.txt
[ "Converts", "all", "accent", "characters", "to", "ASCII", "characters", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/SearchProvider.php#L209-L438
studiowbe/html
src/Attributes.php
Attributes.addClass
public function addClass($classname) { $classArr = $this->getClassArray(); $classArr[] = $classname; return $this->setClassArray($classArr); }
php
public function addClass($classname) { $classArr = $this->getClassArray(); $classArr[] = $classname; return $this->setClassArray($classArr); }
[ "public", "function", "addClass", "(", "$", "classname", ")", "{", "$", "classArr", "=", "$", "this", "->", "getClassArray", "(", ")", ";", "$", "classArr", "[", "]", "=", "$", "classname", ";", "return", "$", "this", "->", "setClassArray", "(", "$", "classArr", ")", ";", "}" ]
Add a class @param string $classname @return \Studiow\HTML\Attributes
[ "Add", "a", "class" ]
train
https://github.com/studiowbe/html/blob/860a6d4ff85bc25df5b9e0293d7ff916db8e01af/src/Attributes.php#L43-L48
studiowbe/html
src/Attributes.php
Attributes.removeClass
public function removeClass($classname) { $classArr = array_diff($this->getClassArray(), [$classname]); return $this->setClassArray($classArr); }
php
public function removeClass($classname) { $classArr = array_diff($this->getClassArray(), [$classname]); return $this->setClassArray($classArr); }
[ "public", "function", "removeClass", "(", "$", "classname", ")", "{", "$", "classArr", "=", "array_diff", "(", "$", "this", "->", "getClassArray", "(", ")", ",", "[", "$", "classname", "]", ")", ";", "return", "$", "this", "->", "setClassArray", "(", "$", "classArr", ")", ";", "}" ]
Remove a class @param string $classname @return \Studiow\HTML\Attributes
[ "Remove", "a", "class" ]
train
https://github.com/studiowbe/html/blob/860a6d4ff85bc25df5b9e0293d7ff916db8e01af/src/Attributes.php#L55-L59
lode/fem
src/session.php
session.create
public static function create($type=null) { $type = self::check_type($type); self::destroy($type); self::start($type); }
php
public static function create($type=null) { $type = self::check_type($type); self::destroy($type); self::start($type); }
[ "public", "static", "function", "create", "(", "$", "type", "=", "null", ")", "{", "$", "type", "=", "self", "::", "check_type", "(", "$", "type", ")", ";", "self", "::", "destroy", "(", "$", "type", ")", ";", "self", "::", "start", "(", "$", "type", ")", ";", "}" ]
create a new session, destroying any current session use this when you want to *start* tracking a user @param string $type one of the ::TYPE_* consts optional, defaults to ::TYPE_CONTINUOUS @return void
[ "create", "a", "new", "session", "destroying", "any", "current", "session", "use", "this", "when", "you", "want", "to", "*", "start", "*", "tracking", "a", "user" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L80-L85
lode/fem
src/session.php
session.keep
public static function keep($type=null) { $type = self::check_type($type); if (self::cookie_exists($type)) { self::start($type); } }
php
public static function keep($type=null) { $type = self::check_type($type); if (self::cookie_exists($type)) { self::start($type); } }
[ "public", "static", "function", "keep", "(", "$", "type", "=", "null", ")", "{", "$", "type", "=", "self", "::", "check_type", "(", "$", "type", ")", ";", "if", "(", "self", "::", "cookie_exists", "(", "$", "type", ")", ")", "{", "self", "::", "start", "(", "$", "type", ")", ";", "}", "}" ]
keep a current session active use this when you want to start using a session in the current request @note this does *not* create a new session if one doesn't already exist @see ::start() if you always want to create a new one anyway @param string $type one of the ::TYPE_* consts optional, defaults to ::TYPE_CONTINUOUS @return void
[ "keep", "a", "current", "session", "active", "use", "this", "when", "you", "want", "to", "start", "using", "a", "session", "in", "the", "current", "request" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L98-L104
lode/fem
src/session.php
session.is_active
public static function is_active() { if (session_status() != PHP_SESSION_ACTIVE) { return false; } if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) { return false; } return true; }
php
public static function is_active() { if (session_status() != PHP_SESSION_ACTIVE) { return false; } if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) { return false; } return true; }
[ "public", "static", "function", "is_active", "(", ")", "{", "if", "(", "session_status", "(", ")", "!=", "PHP_SESSION_ACTIVE", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "_SESSION", "[", "'_session_type'", "]", ")", "||", "empty", "(", "$", "_SESSION", "[", "'_session_last_active'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
wrapper for session_status() which returns a boolean @return boolean
[ "wrapper", "for", "session_status", "()", "which", "returns", "a", "boolean" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L111-L120
lode/fem
src/session.php
session.start
public static function start($type=null) { if (self::is_active()) { return; } $type = self::check_type($type); $cookie = self::get_cookie_settings($type); session_set_cookie_params($cookie['duration'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['http_only']); session_name($cookie['name']); session_start(); // prevent garbage collection before the session expires ini_set('session.gc_maxlifetime', $cookie['duration']); if (empty($_SESSION['_session_type'])) { // prevent session fixation session_regenerate_id($delete=true); $_SESSION = []; $_SESSION['_session_type'] = $type; } else { if (self::is_valid() == false) { self::destroy(); return; } self::regenerate_id($interval_based=true); // keep session active during activity self::update_cookie_expiration($type); } $request = bootstrap::get_library('request'); $_SESSION['_session_fingerprint'] = $request::get_fingerprint(); $_SESSION['_session_last_active'] = time(); }
php
public static function start($type=null) { if (self::is_active()) { return; } $type = self::check_type($type); $cookie = self::get_cookie_settings($type); session_set_cookie_params($cookie['duration'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['http_only']); session_name($cookie['name']); session_start(); // prevent garbage collection before the session expires ini_set('session.gc_maxlifetime', $cookie['duration']); if (empty($_SESSION['_session_type'])) { // prevent session fixation session_regenerate_id($delete=true); $_SESSION = []; $_SESSION['_session_type'] = $type; } else { if (self::is_valid() == false) { self::destroy(); return; } self::regenerate_id($interval_based=true); // keep session active during activity self::update_cookie_expiration($type); } $request = bootstrap::get_library('request'); $_SESSION['_session_fingerprint'] = $request::get_fingerprint(); $_SESSION['_session_last_active'] = time(); }
[ "public", "static", "function", "start", "(", "$", "type", "=", "null", ")", "{", "if", "(", "self", "::", "is_active", "(", ")", ")", "{", "return", ";", "}", "$", "type", "=", "self", "::", "check_type", "(", "$", "type", ")", ";", "$", "cookie", "=", "self", "::", "get_cookie_settings", "(", "$", "type", ")", ";", "session_set_cookie_params", "(", "$", "cookie", "[", "'duration'", "]", ",", "$", "cookie", "[", "'path'", "]", ",", "$", "cookie", "[", "'domain'", "]", ",", "$", "cookie", "[", "'secure'", "]", ",", "$", "cookie", "[", "'http_only'", "]", ")", ";", "session_name", "(", "$", "cookie", "[", "'name'", "]", ")", ";", "session_start", "(", ")", ";", "// prevent garbage collection before the session expires", "ini_set", "(", "'session.gc_maxlifetime'", ",", "$", "cookie", "[", "'duration'", "]", ")", ";", "if", "(", "empty", "(", "$", "_SESSION", "[", "'_session_type'", "]", ")", ")", "{", "// prevent session fixation", "session_regenerate_id", "(", "$", "delete", "=", "true", ")", ";", "$", "_SESSION", "=", "[", "]", ";", "$", "_SESSION", "[", "'_session_type'", "]", "=", "$", "type", ";", "}", "else", "{", "if", "(", "self", "::", "is_valid", "(", ")", "==", "false", ")", "{", "self", "::", "destroy", "(", ")", ";", "return", ";", "}", "self", "::", "regenerate_id", "(", "$", "interval_based", "=", "true", ")", ";", "// keep session active during activity", "self", "::", "update_cookie_expiration", "(", "$", "type", ")", ";", "}", "$", "request", "=", "bootstrap", "::", "get_library", "(", "'request'", ")", ";", "$", "_SESSION", "[", "'_session_fingerprint'", "]", "=", "$", "request", "::", "get_fingerprint", "(", ")", ";", "$", "_SESSION", "[", "'_session_last_active'", "]", "=", "time", "(", ")", ";", "}" ]
wrapper for the native session_start() with added security measures: - sets the cookie arguments - prevents session fixation - validates sessions - regenerates ids on an interval @param string $type one of the ::TYPE_* consts optional, defaults to ::TYPE_CONTINUOUS @return void
[ "wrapper", "for", "the", "native", "session_start", "()", "with", "added", "security", "measures", ":", "-", "sets", "the", "cookie", "arguments", "-", "prevents", "session", "fixation", "-", "validates", "sessions", "-", "regenerates", "ids", "on", "an", "interval" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L133-L171
lode/fem
src/session.php
session.regenerate_id
public static function regenerate_id($interval_based=false) { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } $fresh_enough = ($_SESSION['_session_last_active'] > (time() - self::INTERVAL_REFRESH)); if ($fresh_enough && $interval_based) { return; } if (!empty($_SESSION['_session_expire_at'])) { return; } // delay deleting the old session so ajax calls can continue $_SESSION['_session_expire_at'] = (time() + self::TIMESPAN_EXPIRE); session_write_close(); session_regenerate_id(); // we're in the new session now, which copied all old data unset($_SESSION['_session_expire_at']); }
php
public static function regenerate_id($interval_based=false) { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } $fresh_enough = ($_SESSION['_session_last_active'] > (time() - self::INTERVAL_REFRESH)); if ($fresh_enough && $interval_based) { return; } if (!empty($_SESSION['_session_expire_at'])) { return; } // delay deleting the old session so ajax calls can continue $_SESSION['_session_expire_at'] = (time() + self::TIMESPAN_EXPIRE); session_write_close(); session_regenerate_id(); // we're in the new session now, which copied all old data unset($_SESSION['_session_expire_at']); }
[ "public", "static", "function", "regenerate_id", "(", "$", "interval_based", "=", "false", ")", "{", "if", "(", "self", "::", "is_active", "(", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'inactive session'", ")", ";", "}", "$", "fresh_enough", "=", "(", "$", "_SESSION", "[", "'_session_last_active'", "]", ">", "(", "time", "(", ")", "-", "self", "::", "INTERVAL_REFRESH", ")", ")", ";", "if", "(", "$", "fresh_enough", "&&", "$", "interval_based", ")", "{", "return", ";", "}", "if", "(", "!", "empty", "(", "$", "_SESSION", "[", "'_session_expire_at'", "]", ")", ")", "{", "return", ";", "}", "// delay deleting the old session so ajax calls can continue", "$", "_SESSION", "[", "'_session_expire_at'", "]", "=", "(", "time", "(", ")", "+", "self", "::", "TIMESPAN_EXPIRE", ")", ";", "session_write_close", "(", ")", ";", "session_regenerate_id", "(", ")", ";", "// we're in the new session now, which copied all old data", "unset", "(", "$", "_SESSION", "[", "'_session_expire_at'", "]", ")", ";", "}" ]
wrapper for the native session_regenerate_id() when $interval_based is set to true .. .. regeneration only happens at certain intervals of a sessions lifetime .. .. to keep a small attack window the old session is marked to expire instead of deleted at once .. .. this to allow running ajax requests to continue to use the old session .. @see ::TIMESPAN_EXPIRE and ::is_valid() @param boolean $interval_based @return void
[ "wrapper", "for", "the", "native", "session_regenerate_id", "()" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L203-L225
lode/fem
src/session.php
session.set_user_id
public static function set_user_id($user_id) { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } $_SESSION['_session_user_id'] = $user_id; }
php
public static function set_user_id($user_id) { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } $_SESSION['_session_user_id'] = $user_id; }
[ "public", "static", "function", "set_user_id", "(", "$", "user_id", ")", "{", "if", "(", "self", "::", "is_active", "(", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'inactive session'", ")", ";", "}", "$", "_SESSION", "[", "'_session_user_id'", "]", "=", "$", "user_id", ";", "}" ]
connects a user to the current session once a user is connected, ::is_valid() will validate it @param int $user_id
[ "connects", "a", "user", "to", "the", "current", "session", "once", "a", "user", "is", "connected", "::", "is_valid", "()", "will", "validate", "it" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L249-L256
lode/fem
src/session.php
session.is_loggedin
public static function is_loggedin() { if (self::is_active() == false) { return false; } if (self::get_user_id() == false) { return false; } return true; }
php
public static function is_loggedin() { if (self::is_active() == false) { return false; } if (self::get_user_id() == false) { return false; } return true; }
[ "public", "static", "function", "is_loggedin", "(", ")", "{", "if", "(", "self", "::", "is_active", "(", ")", "==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "self", "::", "get_user_id", "(", ")", "==", "false", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
checks whether the current user is logged in i.e. whether the session has a user attached via ::set_user_id() @return boolean
[ "checks", "whether", "the", "current", "user", "is", "logged", "in", "i", ".", "e", ".", "whether", "the", "session", "has", "a", "user", "attached", "via", "::", "set_user_id", "()" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L264-L273
lode/fem
src/session.php
session.force_loggedin
public static function force_loggedin() { if (self::is_loggedin() == false) { $request = bootstrap::get_library('request'); $request::redirect(self::$login_url); } return true; }
php
public static function force_loggedin() { if (self::is_loggedin() == false) { $request = bootstrap::get_library('request'); $request::redirect(self::$login_url); } return true; }
[ "public", "static", "function", "force_loggedin", "(", ")", "{", "if", "(", "self", "::", "is_loggedin", "(", ")", "==", "false", ")", "{", "$", "request", "=", "bootstrap", "::", "get_library", "(", "'request'", ")", ";", "$", "request", "::", "redirect", "(", "self", "::", "$", "login_url", ")", ";", "}", "return", "true", ";", "}" ]
redirects the user to the login page when it is not logged in @see ::is_loggedin() for the check @see ::$login_url for the redirection @return boolean|void returns true when loggedin, redirects otherwise
[ "redirects", "the", "user", "to", "the", "login", "page", "when", "it", "is", "not", "logged", "in", "@see", "::", "is_loggedin", "()", "for", "the", "check", "@see", "::", "$login_url", "for", "the", "redirection" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L282-L289
lode/fem
src/session.php
session.is_valid
private static function is_valid() { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } if (self::validate() == false) { return false; } if (self::challenge() == false) { return false; } if (is_callable(self::$validation_callback)) { if (call_user_func(self::$validation_callback) == false) { return false; } } return true; }
php
private static function is_valid() { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } if (self::validate() == false) { return false; } if (self::challenge() == false) { return false; } if (is_callable(self::$validation_callback)) { if (call_user_func(self::$validation_callback) == false) { return false; } } return true; }
[ "private", "static", "function", "is_valid", "(", ")", "{", "if", "(", "self", "::", "is_active", "(", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'inactive session'", ")", ";", "}", "if", "(", "self", "::", "validate", "(", ")", "==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "self", "::", "challenge", "(", ")", "==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "is_callable", "(", "self", "::", "$", "validation_callback", ")", ")", "{", "if", "(", "call_user_func", "(", "self", "::", "$", "validation_callback", ")", "==", "false", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
wrapper for all kinds of validation methods @see ::validate(), ::challenge() and user::validate_session() @return boolean
[ "wrapper", "for", "all", "kinds", "of", "validation", "methods", "@see", "::", "validate", "()", "::", "challenge", "()", "and", "user", "::", "validate_session", "()" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L297-L317
lode/fem
src/session.php
session.validate
private static function validate() { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) { return false; } // throw away expired (replaced) sessions if (!empty($_SESSION['_session_expire_at']) && $_SESSION['_session_expire_at'] < time()) { return false; } // last_active short enough ago $type_duration = self::$type_durations[ $_SESSION['_session_type'] ]; $active_enough = ($_SESSION['_session_last_active'] > (time() - $type_duration)); if ($active_enough == false) { return false; } return true; }
php
private static function validate() { if (self::is_active() == false) { $exception = bootstrap::get_library('exception'); throw new $exception('inactive session'); } if (empty($_SESSION['_session_type']) || empty($_SESSION['_session_last_active'])) { return false; } // throw away expired (replaced) sessions if (!empty($_SESSION['_session_expire_at']) && $_SESSION['_session_expire_at'] < time()) { return false; } // last_active short enough ago $type_duration = self::$type_durations[ $_SESSION['_session_type'] ]; $active_enough = ($_SESSION['_session_last_active'] > (time() - $type_duration)); if ($active_enough == false) { return false; } return true; }
[ "private", "static", "function", "validate", "(", ")", "{", "if", "(", "self", "::", "is_active", "(", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'inactive session'", ")", ";", "}", "if", "(", "empty", "(", "$", "_SESSION", "[", "'_session_type'", "]", ")", "||", "empty", "(", "$", "_SESSION", "[", "'_session_last_active'", "]", ")", ")", "{", "return", "false", ";", "}", "// throw away expired (replaced) sessions", "if", "(", "!", "empty", "(", "$", "_SESSION", "[", "'_session_expire_at'", "]", ")", "&&", "$", "_SESSION", "[", "'_session_expire_at'", "]", "<", "time", "(", ")", ")", "{", "return", "false", ";", "}", "// last_active short enough ago", "$", "type_duration", "=", "self", "::", "$", "type_durations", "[", "$", "_SESSION", "[", "'_session_type'", "]", "]", ";", "$", "active_enough", "=", "(", "$", "_SESSION", "[", "'_session_last_active'", "]", ">", "(", "time", "(", ")", "-", "$", "type_duration", ")", ")", ";", "if", "(", "$", "active_enough", "==", "false", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
checks whether the session is still valid to continue on this mainly checks the duration, and delayed deletions @return boolean
[ "checks", "whether", "the", "session", "is", "still", "valid", "to", "continue", "on", "this", "mainly", "checks", "the", "duration", "and", "delayed", "deletions" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L325-L348
lode/fem
src/session.php
session.challenge
private static function challenge() { $exception = bootstrap::get_library('exception'); if (self::is_active() == false) { throw new $exception('inactive session'); } if (empty($_SESSION['_session_fingerprint'])) { throw new $exception('cannot challenge a fresh session'); } $request = bootstrap::get_library('request'); $old_fingerprint = $_SESSION['_session_fingerprint']; $new_fingerprint = $request::get_fingerprint(); $score = self::calculate_fingerprint_score($old_fingerprint, $new_fingerprint); if ($score > 1.5) { return false; } return true; }
php
private static function challenge() { $exception = bootstrap::get_library('exception'); if (self::is_active() == false) { throw new $exception('inactive session'); } if (empty($_SESSION['_session_fingerprint'])) { throw new $exception('cannot challenge a fresh session'); } $request = bootstrap::get_library('request'); $old_fingerprint = $_SESSION['_session_fingerprint']; $new_fingerprint = $request::get_fingerprint(); $score = self::calculate_fingerprint_score($old_fingerprint, $new_fingerprint); if ($score > 1.5) { return false; } return true; }
[ "private", "static", "function", "challenge", "(", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "if", "(", "self", "::", "is_active", "(", ")", "==", "false", ")", "{", "throw", "new", "$", "exception", "(", "'inactive session'", ")", ";", "}", "if", "(", "empty", "(", "$", "_SESSION", "[", "'_session_fingerprint'", "]", ")", ")", "{", "throw", "new", "$", "exception", "(", "'cannot challenge a fresh session'", ")", ";", "}", "$", "request", "=", "bootstrap", "::", "get_library", "(", "'request'", ")", ";", "$", "old_fingerprint", "=", "$", "_SESSION", "[", "'_session_fingerprint'", "]", ";", "$", "new_fingerprint", "=", "$", "request", "::", "get_fingerprint", "(", ")", ";", "$", "score", "=", "self", "::", "calculate_fingerprint_score", "(", "$", "old_fingerprint", ",", "$", "new_fingerprint", ")", ";", "if", "(", "$", "score", ">", "1.5", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
challenge the session's fingerprint this is a balanced check for similar user-agent / ip-address data a like a spam filter, the challenge only fails when the score is too high @return boolean false meaning the session should not be trusted
[ "challenge", "the", "session", "s", "fingerprint", "this", "is", "a", "balanced", "check", "for", "similar", "user", "-", "agent", "/", "ip", "-", "address", "data", "a", "like", "a", "spam", "filter", "the", "challenge", "only", "fails", "when", "the", "score", "is", "too", "high" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L357-L378
lode/fem
src/session.php
session.calculate_fingerprint_score
private static function calculate_fingerprint_score($old_fingerprint, $new_fingerprint) { $score = 0; foreach ($new_fingerprint as $key => $new_value) { if (isset($old_fingerprint[$key]) == false) { // tampered data $score = 100; break; } $old_value = $old_fingerprint[$key]; if (empty($old_value) && empty($new_value)) { continue; } similar_text($old_value, $new_value, $similarity); if ($similarity < 70) { $score += 1.5; } elseif ($similarity < 80) { $score += 1; } elseif ($similarity < 90) { $score += 0.5; } } return $score; }
php
private static function calculate_fingerprint_score($old_fingerprint, $new_fingerprint) { $score = 0; foreach ($new_fingerprint as $key => $new_value) { if (isset($old_fingerprint[$key]) == false) { // tampered data $score = 100; break; } $old_value = $old_fingerprint[$key]; if (empty($old_value) && empty($new_value)) { continue; } similar_text($old_value, $new_value, $similarity); if ($similarity < 70) { $score += 1.5; } elseif ($similarity < 80) { $score += 1; } elseif ($similarity < 90) { $score += 0.5; } } return $score; }
[ "private", "static", "function", "calculate_fingerprint_score", "(", "$", "old_fingerprint", ",", "$", "new_fingerprint", ")", "{", "$", "score", "=", "0", ";", "foreach", "(", "$", "new_fingerprint", "as", "$", "key", "=>", "$", "new_value", ")", "{", "if", "(", "isset", "(", "$", "old_fingerprint", "[", "$", "key", "]", ")", "==", "false", ")", "{", "// tampered data", "$", "score", "=", "100", ";", "break", ";", "}", "$", "old_value", "=", "$", "old_fingerprint", "[", "$", "key", "]", ";", "if", "(", "empty", "(", "$", "old_value", ")", "&&", "empty", "(", "$", "new_value", ")", ")", "{", "continue", ";", "}", "similar_text", "(", "$", "old_value", ",", "$", "new_value", ",", "$", "similarity", ")", ";", "if", "(", "$", "similarity", "<", "70", ")", "{", "$", "score", "+=", "1.5", ";", "}", "elseif", "(", "$", "similarity", "<", "80", ")", "{", "$", "score", "+=", "1", ";", "}", "elseif", "(", "$", "similarity", "<", "90", ")", "{", "$", "score", "+=", "0.5", ";", "}", "}", "return", "$", "score", ";", "}" ]
calculates a weighed difference between old and new challenge data challenge data is produced by \alsvanzelf\fem\request::get_fingerprint() a score somewhere between 1 and 3 should be the threshold for turning bad when a score of 100 is returned, it should be treated as definitely bad @param array $previous_data from the previous request @param array $current_data fresh from this request @return float
[ "calculates", "a", "weighed", "difference", "between", "old", "and", "new", "challenge", "data", "challenge", "data", "is", "produced", "by", "\\", "alsvanzelf", "\\", "fem", "\\", "request", "::", "get_fingerprint", "()" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L391-L418
lode/fem
src/session.php
session.check_type
private static function check_type($type=null) { if (is_null($type)) { return self::TYPE_CONTINUOUS; } if (isset(self::$type_durations[$type]) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('unknown session type'); } return $type; }
php
private static function check_type($type=null) { if (is_null($type)) { return self::TYPE_CONTINUOUS; } if (isset(self::$type_durations[$type]) == false) { $exception = bootstrap::get_library('exception'); throw new $exception('unknown session type'); } return $type; }
[ "private", "static", "function", "check_type", "(", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "return", "self", "::", "TYPE_CONTINUOUS", ";", "}", "if", "(", "isset", "(", "self", "::", "$", "type_durations", "[", "$", "type", "]", ")", "==", "false", ")", "{", "$", "exception", "=", "bootstrap", "::", "get_library", "(", "'exception'", ")", ";", "throw", "new", "$", "exception", "(", "'unknown session type'", ")", ";", "}", "return", "$", "type", ";", "}" ]
returns the same type as the input, except when: - null, it returns the default ::TYPE_CONTINUOUS - not one of the allowed types, it throws an exception @param string $type one of the ::TYPE_* consts @return string|exception
[ "returns", "the", "same", "type", "as", "the", "input", "except", "when", ":", "-", "null", "it", "returns", "the", "default", "::", "TYPE_CONTINUOUS", "-", "not", "one", "of", "the", "allowed", "types", "it", "throws", "an", "exception" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L428-L439
lode/fem
src/session.php
session.get_cookie_name
private static function get_cookie_name($type=null) { if (is_null($type)) { $type = $_SESSION['_session_type']; } return self::COOKIE_NAME_PREFIX.'-'.$type; }
php
private static function get_cookie_name($type=null) { if (is_null($type)) { $type = $_SESSION['_session_type']; } return self::COOKIE_NAME_PREFIX.'-'.$type; }
[ "private", "static", "function", "get_cookie_name", "(", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "$", "type", "=", "$", "_SESSION", "[", "'_session_type'", "]", ";", "}", "return", "self", "::", "COOKIE_NAME_PREFIX", ".", "'-'", ".", "$", "type", ";", "}" ]
generates a key for the session cookie @param string $type one of the ::TYPE_* consts defaults to the type of the current session @return string a concatenation of the base (see ::COOKIE_NAME_PREFIX) and the type i.e. prefix + '-temporary'
[ "generates", "a", "key", "for", "the", "session", "cookie" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L449-L455
lode/fem
src/session.php
session.get_cookie_settings
private static function get_cookie_settings($type) { $name = self::get_cookie_name($type); $duration = self::$type_durations[$type]; $domain = $_SERVER['SERVER_NAME']; $path = '/'; $secure = !empty($_SERVER['HTTPS']) ? true : false; $http_only = true; return [ 'name' => $name, 'duration' => $duration, 'domain' => $domain, 'path' => $path, 'secure' => $secure, 'http_only' => $http_only, ]; }
php
private static function get_cookie_settings($type) { $name = self::get_cookie_name($type); $duration = self::$type_durations[$type]; $domain = $_SERVER['SERVER_NAME']; $path = '/'; $secure = !empty($_SERVER['HTTPS']) ? true : false; $http_only = true; return [ 'name' => $name, 'duration' => $duration, 'domain' => $domain, 'path' => $path, 'secure' => $secure, 'http_only' => $http_only, ]; }
[ "private", "static", "function", "get_cookie_settings", "(", "$", "type", ")", "{", "$", "name", "=", "self", "::", "get_cookie_name", "(", "$", "type", ")", ";", "$", "duration", "=", "self", "::", "$", "type_durations", "[", "$", "type", "]", ";", "$", "domain", "=", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ";", "$", "path", "=", "'/'", ";", "$", "secure", "=", "!", "empty", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "?", "true", ":", "false", ";", "$", "http_only", "=", "true", ";", "return", "[", "'name'", "=>", "$", "name", ",", "'duration'", "=>", "$", "duration", ",", "'domain'", "=>", "$", "domain", ",", "'path'", "=>", "$", "path", ",", "'secure'", "=>", "$", "secure", ",", "'http_only'", "=>", "$", "http_only", ",", "]", ";", "}" ]
returns all keys needed for session cookie management @param string $type one of the ::TYPE_* consts @return array keys 'name', 'duration', 'domain', 'path', 'secure', 'http_only'
[ "returns", "all", "keys", "needed", "for", "session", "cookie", "management" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L463-L479
lode/fem
src/session.php
session.destroy_cookie
private static function destroy_cookie($type=null) { if (is_null($type)) { foreach (self::$type_durations as $type => $null) { self::destroy_cookie($type); } return; } if (self::cookie_exists($type) == false) { return; } self::update_cookie_expiration($type, $expire_now=true); $cookie_name = self::get_cookie_name($type); unset($_COOKIE[$cookie_name]); }
php
private static function destroy_cookie($type=null) { if (is_null($type)) { foreach (self::$type_durations as $type => $null) { self::destroy_cookie($type); } return; } if (self::cookie_exists($type) == false) { return; } self::update_cookie_expiration($type, $expire_now=true); $cookie_name = self::get_cookie_name($type); unset($_COOKIE[$cookie_name]); }
[ "private", "static", "function", "destroy_cookie", "(", "$", "type", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "foreach", "(", "self", "::", "$", "type_durations", "as", "$", "type", "=>", "$", "null", ")", "{", "self", "::", "destroy_cookie", "(", "$", "type", ")", ";", "}", "return", ";", "}", "if", "(", "self", "::", "cookie_exists", "(", "$", "type", ")", "==", "false", ")", "{", "return", ";", "}", "self", "::", "update_cookie_expiration", "(", "$", "type", ",", "$", "expire_now", "=", "true", ")", ";", "$", "cookie_name", "=", "self", "::", "get_cookie_name", "(", "$", "type", ")", ";", "unset", "(", "$", "_COOKIE", "[", "$", "cookie_name", "]", ")", ";", "}" ]
throws away the session cookie @param string $type one of the ::TYPE_* consts if null, defaults to removing cookies for all possible types @return void
[ "throws", "away", "the", "session", "cookie" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L500-L516
lode/fem
src/session.php
session.update_cookie_expiration
private static function update_cookie_expiration($type, $expire_now=false) { $params = self::get_cookie_settings($type); $value = session_id(); $expire = (time() + $params['duration']); if ($expire_now) { $value = null; $expire = (time() - 604800); // one week ago } setcookie($params['name'], $value, $expire, $params['path'], $params['domain'], $params['secure'], $params['http_only']); }
php
private static function update_cookie_expiration($type, $expire_now=false) { $params = self::get_cookie_settings($type); $value = session_id(); $expire = (time() + $params['duration']); if ($expire_now) { $value = null; $expire = (time() - 604800); // one week ago } setcookie($params['name'], $value, $expire, $params['path'], $params['domain'], $params['secure'], $params['http_only']); }
[ "private", "static", "function", "update_cookie_expiration", "(", "$", "type", ",", "$", "expire_now", "=", "false", ")", "{", "$", "params", "=", "self", "::", "get_cookie_settings", "(", "$", "type", ")", ";", "$", "value", "=", "session_id", "(", ")", ";", "$", "expire", "=", "(", "time", "(", ")", "+", "$", "params", "[", "'duration'", "]", ")", ";", "if", "(", "$", "expire_now", ")", "{", "$", "value", "=", "null", ";", "$", "expire", "=", "(", "time", "(", ")", "-", "604800", ")", ";", "// one week ago", "}", "setcookie", "(", "$", "params", "[", "'name'", "]", ",", "$", "value", ",", "$", "expire", ",", "$", "params", "[", "'path'", "]", ",", "$", "params", "[", "'domain'", "]", ",", "$", "params", "[", "'secure'", "]", ",", "$", "params", "[", "'http_only'", "]", ")", ";", "}" ]
updates the cookies expiration with the type's duration useful to keep the cookie active after each user activity set $expire_now to true to remove the cookie @param string $type one of the ::TYPE_* consts @param boolean $expire_now default false @return void
[ "updates", "the", "cookies", "expiration", "with", "the", "type", "s", "duration", "useful", "to", "keep", "the", "cookie", "active", "after", "each", "user", "activity" ]
train
https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/session.php#L528-L539
webforge-labs/psc-cms
lib/Psc/UI/HTMLTag.php
HTMLTag.getAttributes
public function getAttributes() { $attributes = parent::getAttributes(); /* wir fügen den namespace hinzu wenn es nötig ist */ if (isset($attributes['class']) && ($namespace = $this->getOption('css.namespace')) != '') { $attributes['class'] = array_map(array('\Psc\UI\UI','getClass'), $attributes['class']); } return $attributes; }
php
public function getAttributes() { $attributes = parent::getAttributes(); /* wir fügen den namespace hinzu wenn es nötig ist */ if (isset($attributes['class']) && ($namespace = $this->getOption('css.namespace')) != '') { $attributes['class'] = array_map(array('\Psc\UI\UI','getClass'), $attributes['class']); } return $attributes; }
[ "public", "function", "getAttributes", "(", ")", "{", "$", "attributes", "=", "parent", "::", "getAttributes", "(", ")", ";", "/* wir fügen den namespace hinzu wenn es nötig ist */", "if", "(", "isset", "(", "$", "attributes", "[", "'class'", "]", ")", "&&", "(", "$", "namespace", "=", "$", "this", "->", "getOption", "(", "'css.namespace'", ")", ")", "!=", "''", ")", "{", "$", "attributes", "[", "'class'", "]", "=", "array_map", "(", "array", "(", "'\\Psc\\UI\\UI'", ",", "'getClass'", ")", ",", "$", "attributes", "[", "'class'", "]", ")", ";", "}", "return", "$", "attributes", ";", "}" ]
Gibt die Attribute des Tags zurück Fügt jeder Klasse des Tags einen namespace hinzu, sofern die klasse mit \Psc anfängt
[ "Gibt", "die", "Attribute", "des", "Tags", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/UI/HTMLTag.php#L19-L26
sebastiaanluca/laravel-unbreakable-migrations
src/Migration.php
Migration.connect
protected function connect() : void { if (! $this->isLaravel()) { throw new Exception('This migrator must be ran from inside a Laravel application.'); } $this->manager = app('db'); $this->database = $this->manager->connection(); $this->schema = $this->database->getSchemaBuilder(); }
php
protected function connect() : void { if (! $this->isLaravel()) { throw new Exception('This migrator must be ran from inside a Laravel application.'); } $this->manager = app('db'); $this->database = $this->manager->connection(); $this->schema = $this->database->getSchemaBuilder(); }
[ "protected", "function", "connect", "(", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "isLaravel", "(", ")", ")", "{", "throw", "new", "Exception", "(", "'This migrator must be ran from inside a Laravel application.'", ")", ";", "}", "$", "this", "->", "manager", "=", "app", "(", "'db'", ")", ";", "$", "this", "->", "database", "=", "$", "this", "->", "manager", "->", "connection", "(", ")", ";", "$", "this", "->", "schema", "=", "$", "this", "->", "database", "->", "getSchemaBuilder", "(", ")", ";", "}" ]
Check the database connection and use of the Laravel framework. @return void @throws \Exception
[ "Check", "the", "database", "connection", "and", "use", "of", "the", "Laravel", "framework", "." ]
train
https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L93-L102
sebastiaanluca/laravel-unbreakable-migrations
src/Migration.php
Migration.handleException
protected function handleException($exception) : void { $previous = $exception->getPrevious(); if ($exception instanceof QueryException) { throw new $exception($exception->getMessage(), $exception->getBindings(), $previous); } throw new $exception($exception->getMessage(), $previous); }
php
protected function handleException($exception) : void { $previous = $exception->getPrevious(); if ($exception instanceof QueryException) { throw new $exception($exception->getMessage(), $exception->getBindings(), $previous); } throw new $exception($exception->getMessage(), $previous); }
[ "protected", "function", "handleException", "(", "$", "exception", ")", ":", "void", "{", "$", "previous", "=", "$", "exception", "->", "getPrevious", "(", ")", ";", "if", "(", "$", "exception", "instanceof", "QueryException", ")", "{", "throw", "new", "$", "exception", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "$", "exception", "->", "getBindings", "(", ")", ",", "$", "previous", ")", ";", "}", "throw", "new", "$", "exception", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "$", "previous", ")", ";", "}" ]
Handle an exception. @param \Exception $exception @return void
[ "Handle", "an", "exception", "." ]
train
https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L111-L120
sebastiaanluca/laravel-unbreakable-migrations
src/Migration.php
Migration.dropColumn
protected function dropColumn(string $tableName, string $column) : void { // Check for its existence before dropping if (! $this->schema->hasColumn($tableName, $column)) { return; } $this->schema->table($tableName, function (Blueprint $table) use ($column) { $table->dropColumn($column); }); }
php
protected function dropColumn(string $tableName, string $column) : void { // Check for its existence before dropping if (! $this->schema->hasColumn($tableName, $column)) { return; } $this->schema->table($tableName, function (Blueprint $table) use ($column) { $table->dropColumn($column); }); }
[ "protected", "function", "dropColumn", "(", "string", "$", "tableName", ",", "string", "$", "column", ")", ":", "void", "{", "// Check for its existence before dropping", "if", "(", "!", "$", "this", "->", "schema", "->", "hasColumn", "(", "$", "tableName", ",", "$", "column", ")", ")", "{", "return", ";", "}", "$", "this", "->", "schema", "->", "table", "(", "$", "tableName", ",", "function", "(", "Blueprint", "$", "table", ")", "use", "(", "$", "column", ")", "{", "$", "table", "->", "dropColumn", "(", "$", "column", ")", ";", "}", ")", ";", "}" ]
Safely drop a column from a table. @param string $tableName @param string $column @return void
[ "Safely", "drop", "a", "column", "from", "a", "table", "." ]
train
https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L130-L140
sebastiaanluca/laravel-unbreakable-migrations
src/Migration.php
Migration.drop
protected function drop($tables, bool $ignoreKeyConstraints = false) : void { if ($ignoreKeyConstraints) { $this->database->statement('SET FOREIGN_KEY_CHECKS=0;'); } if (! is_array($tables)) { $tables = [$tables]; } foreach ($tables as $table) { if ($this->tableExists($table)) { $this->schema->drop($table); } } if ($ignoreKeyConstraints) { $this->database->statement('SET FOREIGN_KEY_CHECKS=1;'); } }
php
protected function drop($tables, bool $ignoreKeyConstraints = false) : void { if ($ignoreKeyConstraints) { $this->database->statement('SET FOREIGN_KEY_CHECKS=0;'); } if (! is_array($tables)) { $tables = [$tables]; } foreach ($tables as $table) { if ($this->tableExists($table)) { $this->schema->drop($table); } } if ($ignoreKeyConstraints) { $this->database->statement('SET FOREIGN_KEY_CHECKS=1;'); } }
[ "protected", "function", "drop", "(", "$", "tables", ",", "bool", "$", "ignoreKeyConstraints", "=", "false", ")", ":", "void", "{", "if", "(", "$", "ignoreKeyConstraints", ")", "{", "$", "this", "->", "database", "->", "statement", "(", "'SET FOREIGN_KEY_CHECKS=0;'", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "tables", ")", ")", "{", "$", "tables", "=", "[", "$", "tables", "]", ";", "}", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "if", "(", "$", "this", "->", "tableExists", "(", "$", "table", ")", ")", "{", "$", "this", "->", "schema", "->", "drop", "(", "$", "table", ")", ";", "}", "}", "if", "(", "$", "ignoreKeyConstraints", ")", "{", "$", "this", "->", "database", "->", "statement", "(", "'SET FOREIGN_KEY_CHECKS=1;'", ")", ";", "}", "}" ]
Safely drop a table. @param array|string $tables @param bool $ignoreKeyConstraints @return void
[ "Safely", "drop", "a", "table", "." ]
train
https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L150-L169
sebastiaanluca/laravel-unbreakable-migrations
src/Migration.php
Migration.dropAllTables
protected function dropAllTables(bool $ignoreKeyConstraints = false) : void { $this->drop($this->tables, $ignoreKeyConstraints); }
php
protected function dropAllTables(bool $ignoreKeyConstraints = false) : void { $this->drop($this->tables, $ignoreKeyConstraints); }
[ "protected", "function", "dropAllTables", "(", "bool", "$", "ignoreKeyConstraints", "=", "false", ")", ":", "void", "{", "$", "this", "->", "drop", "(", "$", "this", "->", "tables", ",", "$", "ignoreKeyConstraints", ")", ";", "}" ]
Safely drop all tables. @param bool $ignoreKeyConstraints @return void
[ "Safely", "drop", "all", "tables", "." ]
train
https://github.com/sebastiaanluca/laravel-unbreakable-migrations/blob/3c831b204770b80c97351c3b881dcbf924236a13/src/Migration.php#L178-L181
ClanCats/Core
src/classes/CCServer.php
CCServer._init
public static function _init() { // create new instance from default input CCServer::$_instance = CCIn::create( $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER ); // unset default http holder to safe mem //unset( $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES ); }
php
public static function _init() { // create new instance from default input CCServer::$_instance = CCIn::create( $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER ); // unset default http holder to safe mem //unset( $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES ); }
[ "public", "static", "function", "_init", "(", ")", "{", "// create new instance from default input", "CCServer", "::", "$", "_instance", "=", "CCIn", "::", "create", "(", "$", "_GET", ",", "$", "_POST", ",", "$", "_COOKIE", ",", "$", "_FILES", ",", "$", "_SERVER", ")", ";", "// unset default http holder to safe mem", "//unset( $_GET, $_POST, $_COOKIE, $_SERVER, $_FILES );", "}" ]
The initial call of the CCServer get all Superglobals and assigns them to itself as an holder. @return void
[ "The", "initial", "call", "of", "the", "CCServer", "get", "all", "Superglobals", "and", "assigns", "them", "to", "itself", "as", "an", "holder", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCServer.php#L21-L28
phug-php/formatter
src/Phug/Formatter/AbstractFormat.php
AbstractFormat.setFormatter
public function setFormatter(Formatter $formatter) { $this->formatter = $formatter; $format = $this; return $this ->setOptionsRecursive($formatter->getOptions()) ->registerHelper( 'dependencies_storage', $formatter->getOption('dependencies_storage') )->registerHelper( 'helper_prefix', static::class.'::' )->provideHelper( 'get_helper', [ 'dependencies_storage', 'helper_prefix', function ($dependenciesStorage, $prefix) use ($format) { return function ($name) use ($dependenciesStorage, $prefix, $format) { if (!isset($$dependenciesStorage)) { return $format->getHelper($name); } $storage = $$dependenciesStorage; if (!array_key_exists($prefix.$name, $storage) && !isset($storage[$prefix.$name]) ) { throw new \Exception( var_export($name, true). ' dependency not found in the namespace: '. var_export($prefix, true) ); } return $storage[$prefix.$name]; }; }, ] ); }
php
public function setFormatter(Formatter $formatter) { $this->formatter = $formatter; $format = $this; return $this ->setOptionsRecursive($formatter->getOptions()) ->registerHelper( 'dependencies_storage', $formatter->getOption('dependencies_storage') )->registerHelper( 'helper_prefix', static::class.'::' )->provideHelper( 'get_helper', [ 'dependencies_storage', 'helper_prefix', function ($dependenciesStorage, $prefix) use ($format) { return function ($name) use ($dependenciesStorage, $prefix, $format) { if (!isset($$dependenciesStorage)) { return $format->getHelper($name); } $storage = $$dependenciesStorage; if (!array_key_exists($prefix.$name, $storage) && !isset($storage[$prefix.$name]) ) { throw new \Exception( var_export($name, true). ' dependency not found in the namespace: '. var_export($prefix, true) ); } return $storage[$prefix.$name]; }; }, ] ); }
[ "public", "function", "setFormatter", "(", "Formatter", "$", "formatter", ")", "{", "$", "this", "->", "formatter", "=", "$", "formatter", ";", "$", "format", "=", "$", "this", ";", "return", "$", "this", "->", "setOptionsRecursive", "(", "$", "formatter", "->", "getOptions", "(", ")", ")", "->", "registerHelper", "(", "'dependencies_storage'", ",", "$", "formatter", "->", "getOption", "(", "'dependencies_storage'", ")", ")", "->", "registerHelper", "(", "'helper_prefix'", ",", "static", "::", "class", ".", "'::'", ")", "->", "provideHelper", "(", "'get_helper'", ",", "[", "'dependencies_storage'", ",", "'helper_prefix'", ",", "function", "(", "$", "dependenciesStorage", ",", "$", "prefix", ")", "use", "(", "$", "format", ")", "{", "return", "function", "(", "$", "name", ")", "use", "(", "$", "dependenciesStorage", ",", "$", "prefix", ",", "$", "format", ")", "{", "if", "(", "!", "isset", "(", "$", "$", "dependenciesStorage", ")", ")", "{", "return", "$", "format", "->", "getHelper", "(", "$", "name", ")", ";", "}", "$", "storage", "=", "$", "$", "dependenciesStorage", ";", "if", "(", "!", "array_key_exists", "(", "$", "prefix", ".", "$", "name", ",", "$", "storage", ")", "&&", "!", "isset", "(", "$", "storage", "[", "$", "prefix", ".", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "var_export", "(", "$", "name", ",", "true", ")", ".", "' dependency not found in the namespace: '", ".", "var_export", "(", "$", "prefix", ",", "true", ")", ")", ";", "}", "return", "$", "storage", "[", "$", "prefix", ".", "$", "name", "]", ";", "}", ";", "}", ",", "]", ")", ";", "}" ]
@param Formatter $formatter @return $this
[ "@param", "Formatter", "$formatter" ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/AbstractFormat.php#L152-L193
phug-php/formatter
src/Phug/Formatter/AbstractFormat.php
AbstractFormat.format
public function format($element, $noDebug = false) { if (is_string($element)) { return $element; } $debug = $this->getOption('debug') && !$noDebug; foreach ($this->getOption('element_handlers') as $className => $handler) { if (is_a($element, $className)) { $elementCode = $handler($element); $debugCode = $debug ? $this->getDebugInfo($element) : ''; $glue = mb_strlen($debugCode) && in_array(mb_substr($elementCode, 0, 1), ["\n", "\r"]) ? "\n" : ''; return $debugCode.$glue.$elementCode; } } return ''; }
php
public function format($element, $noDebug = false) { if (is_string($element)) { return $element; } $debug = $this->getOption('debug') && !$noDebug; foreach ($this->getOption('element_handlers') as $className => $handler) { if (is_a($element, $className)) { $elementCode = $handler($element); $debugCode = $debug ? $this->getDebugInfo($element) : ''; $glue = mb_strlen($debugCode) && in_array(mb_substr($elementCode, 0, 1), ["\n", "\r"]) ? "\n" : ''; return $debugCode.$glue.$elementCode; } } return ''; }
[ "public", "function", "format", "(", "$", "element", ",", "$", "noDebug", "=", "false", ")", "{", "if", "(", "is_string", "(", "$", "element", ")", ")", "{", "return", "$", "element", ";", "}", "$", "debug", "=", "$", "this", "->", "getOption", "(", "'debug'", ")", "&&", "!", "$", "noDebug", ";", "foreach", "(", "$", "this", "->", "getOption", "(", "'element_handlers'", ")", "as", "$", "className", "=>", "$", "handler", ")", "{", "if", "(", "is_a", "(", "$", "element", ",", "$", "className", ")", ")", "{", "$", "elementCode", "=", "$", "handler", "(", "$", "element", ")", ";", "$", "debugCode", "=", "$", "debug", "?", "$", "this", "->", "getDebugInfo", "(", "$", "element", ")", ":", "''", ";", "$", "glue", "=", "mb_strlen", "(", "$", "debugCode", ")", "&&", "in_array", "(", "mb_substr", "(", "$", "elementCode", ",", "0", ",", "1", ")", ",", "[", "\"\\n\"", ",", "\"\\r\"", "]", ")", "?", "\"\\n\"", ":", "''", ";", "return", "$", "debugCode", ".", "$", "glue", ".", "$", "elementCode", ";", "}", "}", "return", "''", ";", "}" ]
@param string|ElementInterface $element @param bool $noDebug @param $element @return string
[ "@param", "string|ElementInterface", "$element", "@param", "bool", "$noDebug", "@param", "$element" ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/AbstractFormat.php#L232-L252
phug-php/formatter
src/Phug/Formatter/AbstractFormat.php
AbstractFormat.formatCode
public function formatCode($code, $checked, $noTransformation = false) { if (!$noTransformation) { $code = $this->pattern( 'transform_code', $this->pattern( 'transform_expression', $this->pattern('transform_raw_code', $code) ) ); } return (new Joiner($this->handleTokens( $code, $checked )))->join(''); }
php
public function formatCode($code, $checked, $noTransformation = false) { if (!$noTransformation) { $code = $this->pattern( 'transform_code', $this->pattern( 'transform_expression', $this->pattern('transform_raw_code', $code) ) ); } return (new Joiner($this->handleTokens( $code, $checked )))->join(''); }
[ "public", "function", "formatCode", "(", "$", "code", ",", "$", "checked", ",", "$", "noTransformation", "=", "false", ")", "{", "if", "(", "!", "$", "noTransformation", ")", "{", "$", "code", "=", "$", "this", "->", "pattern", "(", "'transform_code'", ",", "$", "this", "->", "pattern", "(", "'transform_expression'", ",", "$", "this", "->", "pattern", "(", "'transform_raw_code'", ",", "$", "code", ")", ")", ")", ";", "}", "return", "(", "new", "Joiner", "(", "$", "this", "->", "handleTokens", "(", "$", "code", ",", "$", "checked", ")", ")", ")", "->", "join", "(", "''", ")", ";", "}" ]
Format a code with transform_expression and tokens handlers. @param string $code @param bool $checked @param bool $noTransformation @return string
[ "Format", "a", "code", "with", "transform_expression", "and", "tokens", "handlers", "." ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/AbstractFormat.php#L412-L428
phug-php/formatter
src/Phug/Formatter/AbstractFormat.php
AbstractFormat.formatKeywordElement
protected function formatKeywordElement(KeywordElement $element) { $name = $element->getName(); $keyword = $this->getOption(['keywords', $name]); $result = call_user_func($keyword, $element->getValue(), $element, $name); if (is_string($result)) { $result = ['begin' => $result]; } if (!is_array($result) && !($result instanceof \ArrayAccess)) { $this->throwException( "The keyword $name returned an invalid value type, string or array was expected.", $element ); } foreach (['begin', 'end'] as $key) { $result[$key] = (isset($result[$key.'Php']) ? "<?php\n".$result[$key.'Php']."\n?>" : '' ).(isset($result[$key]) ? $result[$key] : '' ); } return implode('', array_filter([ $result['begin'], $this->formatElementChildren($element), $result['end'], ])); }
php
protected function formatKeywordElement(KeywordElement $element) { $name = $element->getName(); $keyword = $this->getOption(['keywords', $name]); $result = call_user_func($keyword, $element->getValue(), $element, $name); if (is_string($result)) { $result = ['begin' => $result]; } if (!is_array($result) && !($result instanceof \ArrayAccess)) { $this->throwException( "The keyword $name returned an invalid value type, string or array was expected.", $element ); } foreach (['begin', 'end'] as $key) { $result[$key] = (isset($result[$key.'Php']) ? "<?php\n".$result[$key.'Php']."\n?>" : '' ).(isset($result[$key]) ? $result[$key] : '' ); } return implode('', array_filter([ $result['begin'], $this->formatElementChildren($element), $result['end'], ])); }
[ "protected", "function", "formatKeywordElement", "(", "KeywordElement", "$", "element", ")", "{", "$", "name", "=", "$", "element", "->", "getName", "(", ")", ";", "$", "keyword", "=", "$", "this", "->", "getOption", "(", "[", "'keywords'", ",", "$", "name", "]", ")", ";", "$", "result", "=", "call_user_func", "(", "$", "keyword", ",", "$", "element", "->", "getValue", "(", ")", ",", "$", "element", ",", "$", "name", ")", ";", "if", "(", "is_string", "(", "$", "result", ")", ")", "{", "$", "result", "=", "[", "'begin'", "=>", "$", "result", "]", ";", "}", "if", "(", "!", "is_array", "(", "$", "result", ")", "&&", "!", "(", "$", "result", "instanceof", "\\", "ArrayAccess", ")", ")", "{", "$", "this", "->", "throwException", "(", "\"The keyword $name returned an invalid value type, string or array was expected.\"", ",", "$", "element", ")", ";", "}", "foreach", "(", "[", "'begin'", ",", "'end'", "]", "as", "$", "key", ")", "{", "$", "result", "[", "$", "key", "]", "=", "(", "isset", "(", "$", "result", "[", "$", "key", ".", "'Php'", "]", ")", "?", "\"<?php\\n\"", ".", "$", "result", "[", "$", "key", ".", "'Php'", "]", ".", "\"\\n?>\"", ":", "''", ")", ".", "(", "isset", "(", "$", "result", "[", "$", "key", "]", ")", "?", "$", "result", "[", "$", "key", "]", ":", "''", ")", ";", "}", "return", "implode", "(", "''", ",", "array_filter", "(", "[", "$", "result", "[", "'begin'", "]", ",", "$", "this", "->", "formatElementChildren", "(", "$", "element", ")", ",", "$", "result", "[", "'end'", "]", ",", "]", ")", ")", ";", "}" ]
@param KeywordElement $element @return string
[ "@param", "KeywordElement", "$element" ]
train
https://github.com/phug-php/formatter/blob/3f9286a169a0d45b8b8acc1fae64e880ebdb567e/src/Phug/Formatter/AbstractFormat.php#L508-L540
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent.install
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { parent::install($repo, $package); $this->_installAutoloader($package); $this->_copyAssets($package); }
php
public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { parent::install($repo, $package); $this->_installAutoloader($package); $this->_copyAssets($package); }
[ "public", "function", "install", "(", "InstalledRepositoryInterface", "$", "repo", ",", "PackageInterface", "$", "package", ")", "{", "parent", "::", "install", "(", "$", "repo", ",", "$", "package", ")", ";", "$", "this", "->", "_installAutoloader", "(", "$", "package", ")", ";", "$", "this", "->", "_copyAssets", "(", "$", "package", ")", ";", "}" ]
Installs specific package. @param InstalledRepositoryInterface $repo repository in which to check @param PackageInterface $package package instance @throws InvalidArgumentException
[ "Installs", "specific", "package", "." ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L33-L39
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent.update
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { $this->_removeAutoloader($target); parent::update($repo, $initial, $target); $this->_installAutoloader($target); $this->_copyAssets($target); }
php
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { $this->_removeAutoloader($target); parent::update($repo, $initial, $target); $this->_installAutoloader($target); $this->_copyAssets($target); }
[ "public", "function", "update", "(", "InstalledRepositoryInterface", "$", "repo", ",", "PackageInterface", "$", "initial", ",", "PackageInterface", "$", "target", ")", "{", "$", "this", "->", "_removeAutoloader", "(", "$", "target", ")", ";", "parent", "::", "update", "(", "$", "repo", ",", "$", "initial", ",", "$", "target", ")", ";", "$", "this", "->", "_installAutoloader", "(", "$", "target", ")", ";", "$", "this", "->", "_copyAssets", "(", "$", "target", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L44-L52
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent._installAutoloader
protected function _installAutoloader(PackageInterface $package) { $path = $this->_getAutoloaderPath($package); $manifest = $this->_getKoowaManifest($package); if(!file_exists($path)) { $platform = $this->_isPlatform(); $classname = $platform ? 'Nooku\Library\ObjectManager' : 'KObjectManager'; $bootstrap = $platform ? '' : 'KoowaAutoloader::bootstrap();'; list($vendor, ) = explode('/', $package->getPrettyName()); $component = (string) $manifest->name; $contents = <<<EOL <?php /** * This file has been generated automatically by Composer. Any changes to this file will not persist. * You can override this autoloader by supplying an autoload.php file in the root of the relevant component. **/ $bootstrap $classname::getInstance() ->getObject('lib:object.bootstrapper') ->registerComponent( '$component', __DIR__, '$vendor' ); EOL; file_put_contents($path, $contents); } }
php
protected function _installAutoloader(PackageInterface $package) { $path = $this->_getAutoloaderPath($package); $manifest = $this->_getKoowaManifest($package); if(!file_exists($path)) { $platform = $this->_isPlatform(); $classname = $platform ? 'Nooku\Library\ObjectManager' : 'KObjectManager'; $bootstrap = $platform ? '' : 'KoowaAutoloader::bootstrap();'; list($vendor, ) = explode('/', $package->getPrettyName()); $component = (string) $manifest->name; $contents = <<<EOL <?php /** * This file has been generated automatically by Composer. Any changes to this file will not persist. * You can override this autoloader by supplying an autoload.php file in the root of the relevant component. **/ $bootstrap $classname::getInstance() ->getObject('lib:object.bootstrapper') ->registerComponent( '$component', __DIR__, '$vendor' ); EOL; file_put_contents($path, $contents); } }
[ "protected", "function", "_installAutoloader", "(", "PackageInterface", "$", "package", ")", "{", "$", "path", "=", "$", "this", "->", "_getAutoloaderPath", "(", "$", "package", ")", ";", "$", "manifest", "=", "$", "this", "->", "_getKoowaManifest", "(", "$", "package", ")", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "$", "platform", "=", "$", "this", "->", "_isPlatform", "(", ")", ";", "$", "classname", "=", "$", "platform", "?", "'Nooku\\Library\\ObjectManager'", ":", "'KObjectManager'", ";", "$", "bootstrap", "=", "$", "platform", "?", "''", ":", "'KoowaAutoloader::bootstrap();'", ";", "list", "(", "$", "vendor", ",", ")", "=", "explode", "(", "'/'", ",", "$", "package", "->", "getPrettyName", "(", ")", ")", ";", "$", "component", "=", "(", "string", ")", "$", "manifest", "->", "name", ";", "$", "contents", "=", " <<<EOL\n<?php\n/**\n * This file has been generated automatically by Composer. Any changes to this file will not persist.\n * You can override this autoloader by supplying an autoload.php file in the root of the relevant component.\n **/\n\n$bootstrap\n\n$classname::getInstance()\n ->getObject('lib:object.bootstrapper')\n ->registerComponent(\n '$component',\n __DIR__,\n '$vendor'\n );\nEOL", ";", "file_put_contents", "(", "$", "path", ",", "$", "contents", ")", ";", "}", "}" ]
Installs the default autoloader if no autoloader is supplied. @param PackageInterface $package
[ "Installs", "the", "default", "autoloader", "if", "no", "autoloader", "is", "supplied", "." ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L58-L92
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent._removeAutoloader
protected function _removeAutoloader(PackageInterface $package) { $path = $this->_getAutoloaderPath($package); if(file_exists($path)) { $contents = file_get_contents($path); if (strpos($contents, 'This file has been generated automatically by Composer.') !== false) { unlink($path); } } }
php
protected function _removeAutoloader(PackageInterface $package) { $path = $this->_getAutoloaderPath($package); if(file_exists($path)) { $contents = file_get_contents($path); if (strpos($contents, 'This file has been generated automatically by Composer.') !== false) { unlink($path); } } }
[ "protected", "function", "_removeAutoloader", "(", "PackageInterface", "$", "package", ")", "{", "$", "path", "=", "$", "this", "->", "_getAutoloaderPath", "(", "$", "package", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "contents", "=", "file_get_contents", "(", "$", "path", ")", ";", "if", "(", "strpos", "(", "$", "contents", ",", "'This file has been generated automatically by Composer.'", ")", "!==", "false", ")", "{", "unlink", "(", "$", "path", ")", ";", "}", "}", "}" ]
Removes the autoloader for the given package if it was generated automatically. @param PackageInterface $package
[ "Removes", "the", "autoloader", "for", "the", "given", "package", "if", "it", "was", "generated", "automatically", "." ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L99-L111
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent._getKoowaManifest
protected function _getKoowaManifest(PackageInterface $package) { $path = $this->getInstallPath($package); $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME); $iterator = new \RecursiveIteratorIterator($directory); $regex = new \RegexIterator($iterator, '/koowa-component\.xml/', \RegexIterator::GET_MATCH); $files = iterator_to_array($regex); if (empty($files)) { return false; } $manifests = array_keys($files); $manifest = simplexml_load_file($manifests[0]); if (!($manifest instanceof \SimpleXMLElement)) { throw new \InvalidArgumentException( 'Failed to load `koowa-component.xml` manifest for package `'.$package->getPrettyName().'`.' ); } return $manifest; }
php
protected function _getKoowaManifest(PackageInterface $package) { $path = $this->getInstallPath($package); $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME); $iterator = new \RecursiveIteratorIterator($directory); $regex = new \RegexIterator($iterator, '/koowa-component\.xml/', \RegexIterator::GET_MATCH); $files = iterator_to_array($regex); if (empty($files)) { return false; } $manifests = array_keys($files); $manifest = simplexml_load_file($manifests[0]); if (!($manifest instanceof \SimpleXMLElement)) { throw new \InvalidArgumentException( 'Failed to load `koowa-component.xml` manifest for package `'.$package->getPrettyName().'`.' ); } return $manifest; }
[ "protected", "function", "_getKoowaManifest", "(", "PackageInterface", "$", "package", ")", "{", "$", "path", "=", "$", "this", "->", "getInstallPath", "(", "$", "package", ")", ";", "$", "directory", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "path", ",", "\\", "RecursiveDirectoryIterator", "::", "KEY_AS_PATHNAME", ")", ";", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "$", "directory", ")", ";", "$", "regex", "=", "new", "\\", "RegexIterator", "(", "$", "iterator", ",", "'/koowa-component\\.xml/'", ",", "\\", "RegexIterator", "::", "GET_MATCH", ")", ";", "$", "files", "=", "iterator_to_array", "(", "$", "regex", ")", ";", "if", "(", "empty", "(", "$", "files", ")", ")", "{", "return", "false", ";", "}", "$", "manifests", "=", "array_keys", "(", "$", "files", ")", ";", "$", "manifest", "=", "simplexml_load_file", "(", "$", "manifests", "[", "0", "]", ")", ";", "if", "(", "!", "(", "$", "manifest", "instanceof", "\\", "SimpleXMLElement", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Failed to load `koowa-component.xml` manifest for package `'", ".", "$", "package", "->", "getPrettyName", "(", ")", ".", "'`.'", ")", ";", "}", "return", "$", "manifest", ";", "}" ]
Attempts to locate and initialize the koowa-component.xml manifest @param PackageInterface $package @return bool|\SimpleXMLElement Instance of SimpleXMLElement or false on failure @throws `InvalidArgumentException` on failure to load the XML manifest
[ "Attempts", "to", "locate", "and", "initialize", "the", "koowa", "-", "component", ".", "xml", "manifest" ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L120-L143
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent._copyAssets
protected function _copyAssets(PackageInterface $package) { $path = rtrim($this->getInstallPath($package), '/'); $asset_path = $path.'/resources/assets'; $vendor_dir = dirname(dirname($path)); // Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+ $is_joomla = is_dir(dirname($vendor_dir).'/joomla') || is_dir(dirname($vendor_dir).'/libraries/joomla'); if ($is_joomla && is_dir($asset_path)) { $manifest = $this->_getKoowaManifest($package); $root = is_dir(dirname($vendor_dir).'/joomla') ? dirname(dirname($vendor_dir)) : dirname($vendor_dir); $destination = $root.'/media/koowa/com_'.$manifest->name; $this->_copyDirectory($asset_path, $destination); } }
php
protected function _copyAssets(PackageInterface $package) { $path = rtrim($this->getInstallPath($package), '/'); $asset_path = $path.'/resources/assets'; $vendor_dir = dirname(dirname($path)); // Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+ $is_joomla = is_dir(dirname($vendor_dir).'/joomla') || is_dir(dirname($vendor_dir).'/libraries/joomla'); if ($is_joomla && is_dir($asset_path)) { $manifest = $this->_getKoowaManifest($package); $root = is_dir(dirname($vendor_dir).'/joomla') ? dirname(dirname($vendor_dir)) : dirname($vendor_dir); $destination = $root.'/media/koowa/com_'.$manifest->name; $this->_copyDirectory($asset_path, $destination); } }
[ "protected", "function", "_copyAssets", "(", "PackageInterface", "$", "package", ")", "{", "$", "path", "=", "rtrim", "(", "$", "this", "->", "getInstallPath", "(", "$", "package", ")", ",", "'/'", ")", ";", "$", "asset_path", "=", "$", "path", ".", "'/resources/assets'", ";", "$", "vendor_dir", "=", "dirname", "(", "dirname", "(", "$", "path", ")", ")", ";", "// Check for libraries/joomla. vendor directory sits in libraries/ folder in Joomla 3.4+", "$", "is_joomla", "=", "is_dir", "(", "dirname", "(", "$", "vendor_dir", ")", ".", "'/joomla'", ")", "||", "is_dir", "(", "dirname", "(", "$", "vendor_dir", ")", ".", "'/libraries/joomla'", ")", ";", "if", "(", "$", "is_joomla", "&&", "is_dir", "(", "$", "asset_path", ")", ")", "{", "$", "manifest", "=", "$", "this", "->", "_getKoowaManifest", "(", "$", "package", ")", ";", "$", "root", "=", "is_dir", "(", "dirname", "(", "$", "vendor_dir", ")", ".", "'/joomla'", ")", "?", "dirname", "(", "dirname", "(", "$", "vendor_dir", ")", ")", ":", "dirname", "(", "$", "vendor_dir", ")", ";", "$", "destination", "=", "$", "root", ".", "'/media/koowa/com_'", ".", "$", "manifest", "->", "name", ";", "$", "this", "->", "_copyDirectory", "(", "$", "asset_path", ",", "$", "destination", ")", ";", "}", "}" ]
Copy assets into the media folder if the installation is running in a Joomla context @param PackageInterface $package
[ "Copy", "assets", "into", "the", "media", "folder", "if", "the", "installation", "is", "running", "in", "a", "Joomla", "context" ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L184-L202
nooku/nooku-installer
src/Nooku/Composer/Installer/NookuComponent.php
NookuComponent._copyDirectory
protected function _copyDirectory($source, $target) { $result = false; if (!is_dir($target)) { $result = mkdir($target, 0755, true); } else { // Clear directory $iter = new \RecursiveDirectoryIterator($target); foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f) { if ($f->isDir()) { if (!in_array($f->getFilename(), array('.', '..'))) { rmdir($f->getPathname()); } } else { unlink($f->getPathname()); } } } if (is_dir($target)) { $result = true; // needed for empty directories $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $f) { if ($f->isDir()) { $path = $target.'/'.$iterator->getSubPathName(); if (!is_dir($path)) { $result = mkdir($path); } } else { $result = copy($f, $target.'/'.$iterator->getSubPathName()); } if ($result === false) { break; } } } return $result; }
php
protected function _copyDirectory($source, $target) { $result = false; if (!is_dir($target)) { $result = mkdir($target, 0755, true); } else { // Clear directory $iter = new \RecursiveDirectoryIterator($target); foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f) { if ($f->isDir()) { if (!in_array($f->getFilename(), array('.', '..'))) { rmdir($f->getPathname()); } } else { unlink($f->getPathname()); } } } if (is_dir($target)) { $result = true; // needed for empty directories $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $f) { if ($f->isDir()) { $path = $target.'/'.$iterator->getSubPathName(); if (!is_dir($path)) { $result = mkdir($path); } } else { $result = copy($f, $target.'/'.$iterator->getSubPathName()); } if ($result === false) { break; } } } return $result; }
[ "protected", "function", "_copyDirectory", "(", "$", "source", ",", "$", "target", ")", "{", "$", "result", "=", "false", ";", "if", "(", "!", "is_dir", "(", "$", "target", ")", ")", "{", "$", "result", "=", "mkdir", "(", "$", "target", ",", "0755", ",", "true", ")", ";", "}", "else", "{", "// Clear directory", "$", "iter", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "target", ")", ";", "foreach", "(", "new", "\\", "RecursiveIteratorIterator", "(", "$", "iter", ",", "\\", "RecursiveIteratorIterator", "::", "CHILD_FIRST", ")", "as", "$", "f", ")", "{", "if", "(", "$", "f", "->", "isDir", "(", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "f", "->", "getFilename", "(", ")", ",", "array", "(", "'.'", ",", "'..'", ")", ")", ")", "{", "rmdir", "(", "$", "f", "->", "getPathname", "(", ")", ")", ";", "}", "}", "else", "{", "unlink", "(", "$", "f", "->", "getPathname", "(", ")", ")", ";", "}", "}", "}", "if", "(", "is_dir", "(", "$", "target", ")", ")", "{", "$", "result", "=", "true", ";", "// needed for empty directories", "$", "iterator", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "source", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "f", ")", "{", "if", "(", "$", "f", "->", "isDir", "(", ")", ")", "{", "$", "path", "=", "$", "target", ".", "'/'", ".", "$", "iterator", "->", "getSubPathName", "(", ")", ";", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "$", "result", "=", "mkdir", "(", "$", "path", ")", ";", "}", "}", "else", "{", "$", "result", "=", "copy", "(", "$", "f", ",", "$", "target", ".", "'/'", ".", "$", "iterator", "->", "getSubPathName", "(", ")", ")", ";", "}", "if", "(", "$", "result", "===", "false", ")", "{", "break", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Copy source folder into target. Clears the target folder first. @param $source @param $target @return bool
[ "Copy", "source", "folder", "into", "target", ".", "Clears", "the", "target", "folder", "first", "." ]
train
https://github.com/nooku/nooku-installer/blob/2aa82ed08983bccd51905426cfff4980ba960d89/src/Nooku/Composer/Installer/NookuComponent.php#L211-L257
VincentChalnot/SidusEAVFilterBundle
Filter/EAVFilterHelper.php
EAVFilterHelper.getEAVAttributeQueryBuilder
public function getEAVAttributeQueryBuilder( EAVQueryBuilderInterface $eavQueryBuilder, FamilyInterface $family, $attributePath, $enforceFamilyCondition = true ): AttributeQueryBuilderInterface { $attributeQueryBuilder = null; $attribute = null; /** * @var AttributeInterface $attribute * @var AttributeQueryBuilderInterface $attributeQueryBuilder */ foreach (explode('.', $attributePath) as $attributeCode) { if (null !== $attribute) { // This means we're in a nested attribute $families = $attribute->getOption('allowed_families', []); if (1 !== \count($families)) { throw new \UnexpectedValueException( "Bad 'allowed_families' configuration for attribute {$attribute->getCode()}" ); } $family = $this->familyRegistry->getFamily(reset($families)); $eavQueryBuilder = $attributeQueryBuilder->join(); } $attribute = $family->getAttribute($attributeCode); $attributeQueryBuilder = $eavQueryBuilder->attribute($attribute, $enforceFamilyCondition); } return $attributeQueryBuilder; }
php
public function getEAVAttributeQueryBuilder( EAVQueryBuilderInterface $eavQueryBuilder, FamilyInterface $family, $attributePath, $enforceFamilyCondition = true ): AttributeQueryBuilderInterface { $attributeQueryBuilder = null; $attribute = null; /** * @var AttributeInterface $attribute * @var AttributeQueryBuilderInterface $attributeQueryBuilder */ foreach (explode('.', $attributePath) as $attributeCode) { if (null !== $attribute) { // This means we're in a nested attribute $families = $attribute->getOption('allowed_families', []); if (1 !== \count($families)) { throw new \UnexpectedValueException( "Bad 'allowed_families' configuration for attribute {$attribute->getCode()}" ); } $family = $this->familyRegistry->getFamily(reset($families)); $eavQueryBuilder = $attributeQueryBuilder->join(); } $attribute = $family->getAttribute($attributeCode); $attributeQueryBuilder = $eavQueryBuilder->attribute($attribute, $enforceFamilyCondition); } return $attributeQueryBuilder; }
[ "public", "function", "getEAVAttributeQueryBuilder", "(", "EAVQueryBuilderInterface", "$", "eavQueryBuilder", ",", "FamilyInterface", "$", "family", ",", "$", "attributePath", ",", "$", "enforceFamilyCondition", "=", "true", ")", ":", "AttributeQueryBuilderInterface", "{", "$", "attributeQueryBuilder", "=", "null", ";", "$", "attribute", "=", "null", ";", "/**\n * @var AttributeInterface $attribute\n * @var AttributeQueryBuilderInterface $attributeQueryBuilder\n */", "foreach", "(", "explode", "(", "'.'", ",", "$", "attributePath", ")", "as", "$", "attributeCode", ")", "{", "if", "(", "null", "!==", "$", "attribute", ")", "{", "// This means we're in a nested attribute", "$", "families", "=", "$", "attribute", "->", "getOption", "(", "'allowed_families'", ",", "[", "]", ")", ";", "if", "(", "1", "!==", "\\", "count", "(", "$", "families", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Bad 'allowed_families' configuration for attribute {$attribute->getCode()}\"", ")", ";", "}", "$", "family", "=", "$", "this", "->", "familyRegistry", "->", "getFamily", "(", "reset", "(", "$", "families", ")", ")", ";", "$", "eavQueryBuilder", "=", "$", "attributeQueryBuilder", "->", "join", "(", ")", ";", "}", "$", "attribute", "=", "$", "family", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "$", "attributeQueryBuilder", "=", "$", "eavQueryBuilder", "->", "attribute", "(", "$", "attribute", ",", "$", "enforceFamilyCondition", ")", ";", "}", "return", "$", "attributeQueryBuilder", ";", "}" ]
@param EAVQueryBuilderInterface $eavQueryBuilder @param FamilyInterface $family @param string $attributePath @param bool $enforceFamilyCondition @throws \UnexpectedValueException @return AttributeQueryBuilderInterface
[ "@param", "EAVQueryBuilderInterface", "$eavQueryBuilder", "@param", "FamilyInterface", "$family", "@param", "string", "$attributePath", "@param", "bool", "$enforceFamilyCondition" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/EAVFilterHelper.php#L39-L67
VincentChalnot/SidusEAVFilterBundle
Filter/EAVFilterHelper.php
EAVFilterHelper.getEAVAttributes
public function getEAVAttributes(FamilyInterface $family, array $attributePaths): array { $attributes = []; foreach ($attributePaths as $attributePath) { $attribute = null; /** @var AttributeInterface $attribute */ foreach (explode('.', $attributePath) as $attributeCode) { if (null !== $attribute) { // This means we're in a nested attribute $families = $attribute->getOption('allowed_families', []); if (1 !== \count($families)) { throw new \UnexpectedValueException( "Bad 'allowed_families' configuration for attribute {$attribute->getCode()}" ); } $family = $this->familyRegistry->getFamily(reset($families)); $attribute = $family->getAttribute($attributeCode); // No check on attribute existence: crash } else { // else we're at root level $attribute = $family->getAttribute($attributeCode); } } if ($attribute) { $attributes[] = $attribute; } } return $attributes; }
php
public function getEAVAttributes(FamilyInterface $family, array $attributePaths): array { $attributes = []; foreach ($attributePaths as $attributePath) { $attribute = null; /** @var AttributeInterface $attribute */ foreach (explode('.', $attributePath) as $attributeCode) { if (null !== $attribute) { // This means we're in a nested attribute $families = $attribute->getOption('allowed_families', []); if (1 !== \count($families)) { throw new \UnexpectedValueException( "Bad 'allowed_families' configuration for attribute {$attribute->getCode()}" ); } $family = $this->familyRegistry->getFamily(reset($families)); $attribute = $family->getAttribute($attributeCode); // No check on attribute existence: crash } else { // else we're at root level $attribute = $family->getAttribute($attributeCode); } } if ($attribute) { $attributes[] = $attribute; } } return $attributes; }
[ "public", "function", "getEAVAttributes", "(", "FamilyInterface", "$", "family", ",", "array", "$", "attributePaths", ")", ":", "array", "{", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "attributePaths", "as", "$", "attributePath", ")", "{", "$", "attribute", "=", "null", ";", "/** @var AttributeInterface $attribute */", "foreach", "(", "explode", "(", "'.'", ",", "$", "attributePath", ")", "as", "$", "attributeCode", ")", "{", "if", "(", "null", "!==", "$", "attribute", ")", "{", "// This means we're in a nested attribute", "$", "families", "=", "$", "attribute", "->", "getOption", "(", "'allowed_families'", ",", "[", "]", ")", ";", "if", "(", "1", "!==", "\\", "count", "(", "$", "families", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Bad 'allowed_families' configuration for attribute {$attribute->getCode()}\"", ")", ";", "}", "$", "family", "=", "$", "this", "->", "familyRegistry", "->", "getFamily", "(", "reset", "(", "$", "families", ")", ")", ";", "$", "attribute", "=", "$", "family", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "// No check on attribute existence: crash", "}", "else", "{", "// else we're at root level", "$", "attribute", "=", "$", "family", "->", "getAttribute", "(", "$", "attributeCode", ")", ";", "}", "}", "if", "(", "$", "attribute", ")", "{", "$", "attributes", "[", "]", "=", "$", "attribute", ";", "}", "}", "return", "$", "attributes", ";", "}" ]
@param FamilyInterface $family @param array $attributePaths @throws \UnexpectedValueException @throws MissingAttributeException @throws MissingFamilyException @return AttributeInterface[]
[ "@param", "FamilyInterface", "$family", "@param", "array", "$attributePaths" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/EAVFilterHelper.php#L79-L106
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/File/Count.php
Zend_Validate_File_Count.setMin
public function setMin($min) { if (is_array($min) and isset($min['min'])) { $min = $min['min']; } if (!is_string($min) and !is_numeric($min)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $min = (integer) $min; if (($this->_max !== null) && ($min > $this->_max)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum file count, but $min >" . " {$this->_max}"); } $this->_min = $min; return $this; }
php
public function setMin($min) { if (is_array($min) and isset($min['min'])) { $min = $min['min']; } if (!is_string($min) and !is_numeric($min)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception ('Invalid options to validator provided'); } $min = (integer) $min; if (($this->_max !== null) && ($min > $this->_max)) { require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("The minimum must be less than or equal to the maximum file count, but $min >" . " {$this->_max}"); } $this->_min = $min; return $this; }
[ "public", "function", "setMin", "(", "$", "min", ")", "{", "if", "(", "is_array", "(", "$", "min", ")", "and", "isset", "(", "$", "min", "[", "'min'", "]", ")", ")", "{", "$", "min", "=", "$", "min", "[", "'min'", "]", ";", "}", "if", "(", "!", "is_string", "(", "$", "min", ")", "and", "!", "is_numeric", "(", "$", "min", ")", ")", "{", "require_once", "'Zend/Validate/Exception.php'", ";", "throw", "new", "Zend_Validate_Exception", "(", "'Invalid options to validator provided'", ")", ";", "}", "$", "min", "=", "(", "integer", ")", "$", "min", ";", "if", "(", "(", "$", "this", "->", "_max", "!==", "null", ")", "&&", "(", "$", "min", ">", "$", "this", "->", "_max", ")", ")", "{", "require_once", "'Zend/Validate/Exception.php'", ";", "throw", "new", "Zend_Validate_Exception", "(", "\"The minimum must be less than or equal to the maximum file count, but $min >\"", ".", "\" {$this->_max}\"", ")", ";", "}", "$", "this", "->", "_min", "=", "$", "min", ";", "return", "$", "this", ";", "}" ]
Sets the minimum file count @param integer|array $min The minimum file count @return Zend_Validate_File_Count Provides a fluent interface @throws Zend_Validate_Exception When min is greater than max
[ "Sets", "the", "minimum", "file", "count" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Count.php#L150-L170
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/File/Count.php
Zend_Validate_File_Count.isValid
public function isValid($value, $file = null) { $this->addFile($value); $this->_count = count($this->_files); if (($this->_max !== null) && ($this->_count > $this->_max)) { return $this->_throw($file, self::TOO_MUCH); } if (($this->_min !== null) && ($this->_count < $this->_min)) { return $this->_throw($file, self::TOO_LESS); } return true; }
php
public function isValid($value, $file = null) { $this->addFile($value); $this->_count = count($this->_files); if (($this->_max !== null) && ($this->_count > $this->_max)) { return $this->_throw($file, self::TOO_MUCH); } if (($this->_min !== null) && ($this->_count < $this->_min)) { return $this->_throw($file, self::TOO_LESS); } return true; }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "file", "=", "null", ")", "{", "$", "this", "->", "addFile", "(", "$", "value", ")", ";", "$", "this", "->", "_count", "=", "count", "(", "$", "this", "->", "_files", ")", ";", "if", "(", "(", "$", "this", "->", "_max", "!==", "null", ")", "&&", "(", "$", "this", "->", "_count", ">", "$", "this", "->", "_max", ")", ")", "{", "return", "$", "this", "->", "_throw", "(", "$", "file", ",", "self", "::", "TOO_MUCH", ")", ";", "}", "if", "(", "(", "$", "this", "->", "_min", "!==", "null", ")", "&&", "(", "$", "this", "->", "_count", "<", "$", "this", "->", "_min", ")", ")", "{", "return", "$", "this", "->", "_throw", "(", "$", "file", ",", "self", "::", "TOO_LESS", ")", ";", "}", "return", "true", ";", "}" ]
Defined by Zend_Validate_Interface Returns true if and only if the file count of all checked files is at least min and not bigger than max (when max is not null). Attention: When checking with set min you must give all files with the first call, otherwise you will get an false. @param string|array $value Filenames to check for count @param array $file File data from Zend_File_Transfer @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/File/Count.php#L244-L257
ClanCats/Core
src/bundles/Database/Model/Relation.php
Model_Relation.collection_query
protected function collection_query( &$collection ) { $local_keys = array(); foreach( $collection as $item ) { $local_keys[] = $item->raw( $this->local_key ); } // set the correct collection where $this->query->wheres = array(); $this->query->where( $this->foreign_key, 'in', $local_keys ); $this->query->group_result( $this->foreign_key ); $this->query->limit( null ); }
php
protected function collection_query( &$collection ) { $local_keys = array(); foreach( $collection as $item ) { $local_keys[] = $item->raw( $this->local_key ); } // set the correct collection where $this->query->wheres = array(); $this->query->where( $this->foreign_key, 'in', $local_keys ); $this->query->group_result( $this->foreign_key ); $this->query->limit( null ); }
[ "protected", "function", "collection_query", "(", "&", "$", "collection", ")", "{", "$", "local_keys", "=", "array", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "item", ")", "{", "$", "local_keys", "[", "]", "=", "$", "item", "->", "raw", "(", "$", "this", "->", "local_key", ")", ";", "}", "// set the correct collection where", "$", "this", "->", "query", "->", "wheres", "=", "array", "(", ")", ";", "$", "this", "->", "query", "->", "where", "(", "$", "this", "->", "foreign_key", ",", "'in'", ",", "$", "local_keys", ")", ";", "$", "this", "->", "query", "->", "group_result", "(", "$", "this", "->", "foreign_key", ")", ";", "$", "this", "->", "query", "->", "limit", "(", "null", ")", ";", "}" ]
Prepare the query with collection select @param array $collection @return void
[ "Prepare", "the", "query", "with", "collection", "select" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model/Relation.php#L142-L157
ClanCats/Core
src/bundles/Database/Model/Relation.php
Model_Relation.collection_assign
public function collection_assign( $relation, &$collection, $callback = null ) { // make the query $this->collection_query( $collection ); call_user_func_array( $callback, array( &$this->query ) ); // get the reults $results = $this->query->run(); foreach( $collection as $item ) { if ( $this->singleton ) { $item->raw_set( $relation, reset( $results[ $item->raw( $this->local_key ) ] ) ); } else { $item->raw_set( $relation, $results[ $item->raw( $this->local_key ) ] ); } } }
php
public function collection_assign( $relation, &$collection, $callback = null ) { // make the query $this->collection_query( $collection ); call_user_func_array( $callback, array( &$this->query ) ); // get the reults $results = $this->query->run(); foreach( $collection as $item ) { if ( $this->singleton ) { $item->raw_set( $relation, reset( $results[ $item->raw( $this->local_key ) ] ) ); } else { $item->raw_set( $relation, $results[ $item->raw( $this->local_key ) ] ); } } }
[ "public", "function", "collection_assign", "(", "$", "relation", ",", "&", "$", "collection", ",", "$", "callback", "=", "null", ")", "{", "// make the query", "$", "this", "->", "collection_query", "(", "$", "collection", ")", ";", "call_user_func_array", "(", "$", "callback", ",", "array", "(", "&", "$", "this", "->", "query", ")", ")", ";", "// get the reults", "$", "results", "=", "$", "this", "->", "query", "->", "run", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "item", ")", "{", "if", "(", "$", "this", "->", "singleton", ")", "{", "$", "item", "->", "raw_set", "(", "$", "relation", ",", "reset", "(", "$", "results", "[", "$", "item", "->", "raw", "(", "$", "this", "->", "local_key", ")", "]", ")", ")", ";", "}", "else", "{", "$", "item", "->", "raw_set", "(", "$", "relation", ",", "$", "results", "[", "$", "item", "->", "raw", "(", "$", "this", "->", "local_key", ")", "]", ")", ";", "}", "}", "}" ]
Prepare the query with collection select @param string $relation @param array $collection @param callback $callback @return void
[ "Prepare", "the", "query", "with", "collection", "select" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Database/Model/Relation.php#L167-L188
webforge-labs/psc-cms
lib/PHPWord/PHPWord/Section/Table.php
PHPWord_Section_Table.addCell
public function addCell($width, $style = null) { $cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style); $i = count($this->_rows) - 1; $this->_rows[$i][] = $cell; return $cell; }
php
public function addCell($width, $style = null) { $cell = new PHPWord_Section_Table_Cell($this->_insideOf, $this->_pCount, $width, $style); $i = count($this->_rows) - 1; $this->_rows[$i][] = $cell; return $cell; }
[ "public", "function", "addCell", "(", "$", "width", ",", "$", "style", "=", "null", ")", "{", "$", "cell", "=", "new", "PHPWord_Section_Table_Cell", "(", "$", "this", "->", "_insideOf", ",", "$", "this", "->", "_pCount", ",", "$", "width", ",", "$", "style", ")", ";", "$", "i", "=", "count", "(", "$", "this", "->", "_rows", ")", "-", "1", ";", "$", "this", "->", "_rows", "[", "$", "i", "]", "[", "]", "=", "$", "cell", ";", "return", "$", "cell", ";", "}" ]
Add a cell @param int $width @param mixed $style @return PHPWord_Section_Table_Cell
[ "Add", "a", "cell" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/PHPWord/PHPWord/Section/Table.php#L118-L123
gevans/phaker
lib/Phaker/Generator/Internet.php
Internet.safe_email
public function safe_email($name = NULL) { $tlds = array('org', 'com', 'net'); return implode('@', array($this->user_name($name), 'example.'.$tlds[array_rand($tlds)])); }
php
public function safe_email($name = NULL) { $tlds = array('org', 'com', 'net'); return implode('@', array($this->user_name($name), 'example.'.$tlds[array_rand($tlds)])); }
[ "public", "function", "safe_email", "(", "$", "name", "=", "NULL", ")", "{", "$", "tlds", "=", "array", "(", "'org'", ",", "'com'", ",", "'net'", ")", ";", "return", "implode", "(", "'@'", ",", "array", "(", "$", "this", "->", "user_name", "(", "$", "name", ")", ",", "'example.'", ".", "$", "tlds", "[", "array_rand", "(", "$", "tlds", ")", "]", ")", ")", ";", "}" ]
Generate a safe email address ending with example.tld, with a TLD of org, com, or net only. @param string $name User name @return string
[ "Generate", "a", "safe", "email", "address", "ending", "with", "example", ".", "tld", "with", "a", "TLD", "of", "org", "com", "or", "net", "only", "." ]
train
https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Internet.php#L45-L49
gevans/phaker
lib/Phaker/Generator/Internet.php
Internet.user_name
public function user_name($name = NULL) { $delim = array('.', '_'); if ($name) { $names = preg_split('/[^\w]+/', $name, NULL, PREG_SPLIT_NO_EMPTY); shuffle($names); return implode($delim[array_rand($delim)], $names); } if (mt_rand(0, 1)) { $name = preg_replace('/\W/', '', \Phaker::name()->first_name); } else { $names = preg_replace('/\W/', '', array(\Phaker::name()->first_name, \Phaker::name()->last_name)); $name = implode($delim[array_rand($delim)], $names); } return static::fix_umlauts(strtolower($name)); }
php
public function user_name($name = NULL) { $delim = array('.', '_'); if ($name) { $names = preg_split('/[^\w]+/', $name, NULL, PREG_SPLIT_NO_EMPTY); shuffle($names); return implode($delim[array_rand($delim)], $names); } if (mt_rand(0, 1)) { $name = preg_replace('/\W/', '', \Phaker::name()->first_name); } else { $names = preg_replace('/\W/', '', array(\Phaker::name()->first_name, \Phaker::name()->last_name)); $name = implode($delim[array_rand($delim)], $names); } return static::fix_umlauts(strtolower($name)); }
[ "public", "function", "user_name", "(", "$", "name", "=", "NULL", ")", "{", "$", "delim", "=", "array", "(", "'.'", ",", "'_'", ")", ";", "if", "(", "$", "name", ")", "{", "$", "names", "=", "preg_split", "(", "'/[^\\w]+/'", ",", "$", "name", ",", "NULL", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "shuffle", "(", "$", "names", ")", ";", "return", "implode", "(", "$", "delim", "[", "array_rand", "(", "$", "delim", ")", "]", ",", "$", "names", ")", ";", "}", "if", "(", "mt_rand", "(", "0", ",", "1", ")", ")", "{", "$", "name", "=", "preg_replace", "(", "'/\\W/'", ",", "''", ",", "\\", "Phaker", "::", "name", "(", ")", "->", "first_name", ")", ";", "}", "else", "{", "$", "names", "=", "preg_replace", "(", "'/\\W/'", ",", "''", ",", "array", "(", "\\", "Phaker", "::", "name", "(", ")", "->", "first_name", ",", "\\", "Phaker", "::", "name", "(", ")", "->", "last_name", ")", ")", ";", "$", "name", "=", "implode", "(", "$", "delim", "[", "array_rand", "(", "$", "delim", ")", "]", ",", "$", "names", ")", ";", "}", "return", "static", "::", "fix_umlauts", "(", "strtolower", "(", "$", "name", ")", ")", ";", "}" ]
Generate a lowercase user name from a full or partial name. echo $internet->user_name('Dr. Seuss'); // => "dr.seuss" @param string $name User name @return string
[ "Generate", "a", "lowercase", "user", "name", "from", "a", "full", "or", "partial", "name", "." ]
train
https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Internet.php#L59-L81
gevans/phaker
lib/Phaker/Generator/Internet.php
Internet.fix_umlauts
public static function fix_umlauts($string) { return str_ireplace(array('ä', 'ö', 'ü', 'ß'), array('ae', 'oe', 'ue', 'ss'), $string); }
php
public static function fix_umlauts($string) { return str_ireplace(array('ä', 'ö', 'ü', 'ß'), array('ae', 'oe', 'ue', 'ss'), $string); }
[ "public", "static", "function", "fix_umlauts", "(", "$", "string", ")", "{", "return", "str_ireplace", "(", "array", "(", "'ä',", " ", "ö', ", "'", "', '", "ß", "), a", "r", "r", "y('ae", "'", ", 'o", "e", ", 'u", "e", ", 's", "s", "), $", "s", "t", "i", "ng);", "", "", "}" ]
Convert umlauts and other characters for safe use in URLs, email addresses, user names, etc. @return string
[ "Convert", "umlauts", "and", "other", "characters", "for", "safe", "use", "in", "URLs", "email", "addresses", "user", "names", "etc", "." ]
train
https://github.com/gevans/phaker/blob/b99f4a20a09188c219649127655e980d1e983274/lib/Phaker/Generator/Internet.php#L154-L157
ClanCats/Core
src/classes/CCLog.php
CCLog.write
public static function write() { if ( empty( static::$_data ) ) { return; } $buffer = date("H:i:s")." - ".CCServer::method().' '.CCServer::server('REQUEST_URI')."\n"; $buffer .= implode( "\n", static::$_data ); CCFile::append( CCStorage::path( 'logs/'.date( 'Y-m' ).'/'.date( 'd' ).'.log' ), $buffer."\n" ); // clear static::clear(); }
php
public static function write() { if ( empty( static::$_data ) ) { return; } $buffer = date("H:i:s")." - ".CCServer::method().' '.CCServer::server('REQUEST_URI')."\n"; $buffer .= implode( "\n", static::$_data ); CCFile::append( CCStorage::path( 'logs/'.date( 'Y-m' ).'/'.date( 'd' ).'.log' ), $buffer."\n" ); // clear static::clear(); }
[ "public", "static", "function", "write", "(", ")", "{", "if", "(", "empty", "(", "static", "::", "$", "_data", ")", ")", "{", "return", ";", "}", "$", "buffer", "=", "date", "(", "\"H:i:s\"", ")", ".", "\" - \"", ".", "CCServer", "::", "method", "(", ")", ".", "' '", ".", "CCServer", "::", "server", "(", "'REQUEST_URI'", ")", ".", "\"\\n\"", ";", "$", "buffer", ".=", "implode", "(", "\"\\n\"", ",", "static", "::", "$", "_data", ")", ";", "CCFile", "::", "append", "(", "CCStorage", "::", "path", "(", "'logs/'", ".", "date", "(", "'Y-m'", ")", ".", "'/'", ".", "date", "(", "'d'", ")", ".", "'.log'", ")", ",", "$", "buffer", ".", "\"\\n\"", ")", ";", "// clear", "static", "::", "clear", "(", ")", ";", "}" ]
write the log down to disk @return void
[ "write", "the", "log", "down", "to", "disk" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCLog.php#L81-L95
TheBigBrainsCompany/TbbcRestUtilBundle
DependencyInjection/TbbcRestUtilExtension.php
TbbcRestUtilExtension.load
public function load(array $configs, ContainerBuilder $container) { $processor = new Processor(); $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('error.xml'); // factories loading if (true === (bool) $config['error']['use_bundled_factories']) { $loader->load('error_factories.xml'); } $container->setParameter('tbbc_rest_util.error_resolver_service_id', $config['error']['error_resolver']); // mapping configuration $this->configureErrorExceptionMapping($config, $container); }
php
public function load(array $configs, ContainerBuilder $container) { $processor = new Processor(); $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('error.xml'); // factories loading if (true === (bool) $config['error']['use_bundled_factories']) { $loader->load('error_factories.xml'); } $container->setParameter('tbbc_rest_util.error_resolver_service_id', $config['error']['error_resolver']); // mapping configuration $this->configureErrorExceptionMapping($config, $container); }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "configuration", "=", "new", "Configuration", "(", ")", ";", "$", "config", "=", "$", "processor", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'error.xml'", ")", ";", "// factories loading\r", "if", "(", "true", "===", "(", "bool", ")", "$", "config", "[", "'error'", "]", "[", "'use_bundled_factories'", "]", ")", "{", "$", "loader", "->", "load", "(", "'error_factories.xml'", ")", ";", "}", "$", "container", "->", "setParameter", "(", "'tbbc_rest_util.error_resolver_service_id'", ",", "$", "config", "[", "'error'", "]", "[", "'error_resolver'", "]", ")", ";", "// mapping configuration\r", "$", "this", "->", "configureErrorExceptionMapping", "(", "$", "config", ",", "$", "container", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/TheBigBrainsCompany/TbbcRestUtilBundle/blob/48c0598a94a4f6b3883d349d8f134138e8bc6d7c/DependencyInjection/TbbcRestUtilExtension.php#L30-L50
ClanCats/Core
src/bundles/UI/Table.php
Table.row
public function row( $data = array(), $attr = array() ) { $this->data[] = $this->_repair_row( $data, $attr ); return $this; }
php
public function row( $data = array(), $attr = array() ) { $this->data[] = $this->_repair_row( $data, $attr ); return $this; }
[ "public", "function", "row", "(", "$", "data", "=", "array", "(", ")", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "this", "->", "data", "[", "]", "=", "$", "this", "->", "_repair_row", "(", "$", "data", ",", "$", "attr", ")", ";", "return", "$", "this", ";", "}" ]
add a new row
[ "add", "a", "new", "row" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Table.php#L52-L54
ClanCats/Core
src/bundles/UI/Table.php
Table.header
public function header( $data = array(), $attr = array() ) { $this->header = $this->_repair_row( $data, $attr ); return $this; }
php
public function header( $data = array(), $attr = array() ) { $this->header = $this->_repair_row( $data, $attr ); return $this; }
[ "public", "function", "header", "(", "$", "data", "=", "array", "(", ")", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "this", "->", "header", "=", "$", "this", "->", "_repair_row", "(", "$", "data", ",", "$", "attr", ")", ";", "return", "$", "this", ";", "}" ]
set the header
[ "set", "the", "header" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Table.php#L59-L61
ClanCats/Core
src/bundles/UI/Table.php
Table._repair_row
private function _repair_row( $data = array(), $attr = array() ) { $row = array(); foreach( $data as $key => $value ) { if ( !$value instanceof HTML || ( $value->name != 'td' && $value->name != 'th' ) ) { $value = static::cell( (string) $value ); } if ( is_string( $key ) ) { $row[$key] = $value; } else { $row[] = $value; } } return array( $row, $attr ); }
php
private function _repair_row( $data = array(), $attr = array() ) { $row = array(); foreach( $data as $key => $value ) { if ( !$value instanceof HTML || ( $value->name != 'td' && $value->name != 'th' ) ) { $value = static::cell( (string) $value ); } if ( is_string( $key ) ) { $row[$key] = $value; } else { $row[] = $value; } } return array( $row, $attr ); }
[ "private", "function", "_repair_row", "(", "$", "data", "=", "array", "(", ")", ",", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "row", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "value", "instanceof", "HTML", "||", "(", "$", "value", "->", "name", "!=", "'td'", "&&", "$", "value", "->", "name", "!=", "'th'", ")", ")", "{", "$", "value", "=", "static", "::", "cell", "(", "(", "string", ")", "$", "value", ")", ";", "}", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "row", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "$", "row", "[", "]", "=", "$", "value", ";", "}", "}", "return", "array", "(", "$", "row", ",", "$", "attr", ")", ";", "}" ]
repair a row for rendering
[ "repair", "a", "row", "for", "rendering" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Table.php#L66-L79
ClanCats/Core
src/bundles/UI/Table.php
Table.render
public function render() { $buffer = ''; if ( !empty( $this->header ) ) { $buffer .= '<tr'.HTML::attr( $this->header[1] ).'>'; foreach( $this->header[0] as $head ) { $head->name = 'th'; $buffer .= $head->render(); } $buffer .= '</tr>'; foreach( $this->data as $row ) { $buffer .= '<tr'.HTML::attr( $row[1] ).'>'; foreach( $this->header[0] as $key => $value ) { $buffer .= HTML::tag( 'td', $row[0][$key]->value, $row[0][$key]->attr ); } $buffer .= '</tr>'; } } else { foreach( $this->data as $row ) { $buffer .= '<tr'.HTML::attr( $row[1] ).'>'; foreach( $row[0] as $value ) { $buffer .= $value->render(); } $buffer .= '</tr>'; } } $this->element->value = $buffer; return $this->element->render(); }
php
public function render() { $buffer = ''; if ( !empty( $this->header ) ) { $buffer .= '<tr'.HTML::attr( $this->header[1] ).'>'; foreach( $this->header[0] as $head ) { $head->name = 'th'; $buffer .= $head->render(); } $buffer .= '</tr>'; foreach( $this->data as $row ) { $buffer .= '<tr'.HTML::attr( $row[1] ).'>'; foreach( $this->header[0] as $key => $value ) { $buffer .= HTML::tag( 'td', $row[0][$key]->value, $row[0][$key]->attr ); } $buffer .= '</tr>'; } } else { foreach( $this->data as $row ) { $buffer .= '<tr'.HTML::attr( $row[1] ).'>'; foreach( $row[0] as $value ) { $buffer .= $value->render(); } $buffer .= '</tr>'; } } $this->element->value = $buffer; return $this->element->render(); }
[ "public", "function", "render", "(", ")", "{", "$", "buffer", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "header", ")", ")", "{", "$", "buffer", ".=", "'<tr'", ".", "HTML", "::", "attr", "(", "$", "this", "->", "header", "[", "1", "]", ")", ".", "'>'", ";", "foreach", "(", "$", "this", "->", "header", "[", "0", "]", "as", "$", "head", ")", "{", "$", "head", "->", "name", "=", "'th'", ";", "$", "buffer", ".=", "$", "head", "->", "render", "(", ")", ";", "}", "$", "buffer", ".=", "'</tr>'", ";", "foreach", "(", "$", "this", "->", "data", "as", "$", "row", ")", "{", "$", "buffer", ".=", "'<tr'", ".", "HTML", "::", "attr", "(", "$", "row", "[", "1", "]", ")", ".", "'>'", ";", "foreach", "(", "$", "this", "->", "header", "[", "0", "]", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "buffer", ".=", "HTML", "::", "tag", "(", "'td'", ",", "$", "row", "[", "0", "]", "[", "$", "key", "]", "->", "value", ",", "$", "row", "[", "0", "]", "[", "$", "key", "]", "->", "attr", ")", ";", "}", "$", "buffer", ".=", "'</tr>'", ";", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "row", ")", "{", "$", "buffer", ".=", "'<tr'", ".", "HTML", "::", "attr", "(", "$", "row", "[", "1", "]", ")", ".", "'>'", ";", "foreach", "(", "$", "row", "[", "0", "]", "as", "$", "value", ")", "{", "$", "buffer", ".=", "$", "value", "->", "render", "(", ")", ";", "}", "$", "buffer", ".=", "'</tr>'", ";", "}", "}", "$", "this", "->", "element", "->", "value", "=", "$", "buffer", ";", "return", "$", "this", "->", "element", "->", "render", "(", ")", ";", "}" ]
generate the output
[ "generate", "the", "output" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/Table.php#L91-L124
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header/Itunes.php
Zend_Feed_Builder_Header_Itunes.setCategories
public function setCategories(array $categories) { $nb = count($categories); if (0 === $nb) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set at least one itunes category"); } if ($nb > 3) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set at most three itunes categories"); } foreach ($categories as $i => $category) { if (empty($category['main'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set the main category (category #$i)"); } } $this->offsetSet('category', $categories); return $this; }
php
public function setCategories(array $categories) { $nb = count($categories); if (0 === $nb) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set at least one itunes category"); } if ($nb > 3) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set at most three itunes categories"); } foreach ($categories as $i => $category) { if (empty($category['main'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set the main category (category #$i)"); } } $this->offsetSet('category', $categories); return $this; }
[ "public", "function", "setCategories", "(", "array", "$", "categories", ")", "{", "$", "nb", "=", "count", "(", "$", "categories", ")", ";", "if", "(", "0", "===", "$", "nb", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set at least one itunes category\"", ")", ";", "}", "if", "(", "$", "nb", ">", "3", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set at most three itunes categories\"", ")", ";", "}", "foreach", "(", "$", "categories", "as", "$", "i", "=>", "$", "category", ")", "{", "if", "(", "empty", "(", "$", "category", "[", "'main'", "]", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set the main category (category #$i)\"", ")", ";", "}", "}", "$", "this", "->", "offsetSet", "(", "'category'", ",", "$", "categories", ")", ";", "return", "$", "this", ";", "}" ]
Sets the categories column and in iTunes Music Store Browse $categories must conform to the following format: <code> array(array('main' => 'main category', 'sub' => 'sub category' // optionnal ), // up to 3 rows ) </code> @param array $categories @return Zend_Feed_Builder_Header_Itunes @throws Zend_Feed_Builder_Exception
[ "Sets", "the", "categories", "column", "and", "in", "iTunes", "Music", "Store", "Browse", "$categories", "must", "conform", "to", "the", "following", "format", ":", "<code", ">", "array", "(", "array", "(", "main", "=", ">", "main", "category", "sub", "=", ">", "sub", "category", "//", "optionnal", ")", "//", "up", "to", "3", "rows", ")", "<", "/", "code", ">" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header/Itunes.php#L62-L90
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header/Itunes.php
Zend_Feed_Builder_Header_Itunes.setOwner
public function setOwner($name = '', $email = '') { if (!empty($email)) { /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($email)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the itunes owner's email property"); } } $this->offsetSet('owner', array('name' => $name, 'email' => $email)); return $this; }
php
public function setOwner($name = '', $email = '') { if (!empty($email)) { /** * @see Zend_Validate_EmailAddress */ require_once 'Zend/Validate/EmailAddress.php'; $validate = new Zend_Validate_EmailAddress(); if (!$validate->isValid($email)) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the itunes owner's email property"); } } $this->offsetSet('owner', array('name' => $name, 'email' => $email)); return $this; }
[ "public", "function", "setOwner", "(", "$", "name", "=", "''", ",", "$", "email", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "email", ")", ")", "{", "/**\n \t * @see Zend_Validate_EmailAddress\n \t */", "require_once", "'Zend/Validate/EmailAddress.php'", ";", "$", "validate", "=", "new", "Zend_Validate_EmailAddress", "(", ")", ";", "if", "(", "!", "$", "validate", "->", "isValid", "(", "$", "email", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set a valid email address into the itunes owner's email property\"", ")", ";", "}", "}", "$", "this", "->", "offsetSet", "(", "'owner'", ",", "array", "(", "'name'", "=>", "$", "name", ",", "'email'", "=>", "$", "email", ")", ")", ";", "return", "$", "this", ";", "}" ]
Sets the owner of the postcast @param string $name default to the feed's author value @param string $email default to the feed's email value @return Zend_Feed_Builder_Header_Itunes @throws Zend_Feed_Builder_Exception
[ "Sets", "the", "owner", "of", "the", "postcast" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header/Itunes.php#L112-L130
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header/Itunes.php
Zend_Feed_Builder_Header_Itunes.setBlock
public function setBlock($block) { $block = strtolower($block); if (!in_array($block, array('yes', 'no'))) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set yes or no to the itunes block property"); } $this->offsetSet('block', $block); return $this; }
php
public function setBlock($block) { $block = strtolower($block); if (!in_array($block, array('yes', 'no'))) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set yes or no to the itunes block property"); } $this->offsetSet('block', $block); return $this; }
[ "public", "function", "setBlock", "(", "$", "block", ")", "{", "$", "block", "=", "strtolower", "(", "$", "block", ")", ";", "if", "(", "!", "in_array", "(", "$", "block", ",", "array", "(", "'yes'", ",", "'no'", ")", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set yes or no to the itunes block property\"", ")", ";", "}", "$", "this", "->", "offsetSet", "(", "'block'", ",", "$", "block", ")", ";", "return", "$", "this", ";", "}" ]
Prevent a feed from appearing @param string $block can be 'yes' or 'no' @return Zend_Feed_Builder_Header_Itunes @throws Zend_Feed_Builder_Exception
[ "Prevent", "a", "feed", "from", "appearing" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header/Itunes.php#L178-L190
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Header/Itunes.php
Zend_Feed_Builder_Header_Itunes.setExplicit
public function setExplicit($explicit) { $explicit = strtolower($explicit); if (!in_array($explicit, array('yes', 'no', 'clean'))) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set yes, no or clean to the itunes explicit property"); } $this->offsetSet('explicit', $explicit); return $this; }
php
public function setExplicit($explicit) { $explicit = strtolower($explicit); if (!in_array($explicit, array('yes', 'no', 'clean'))) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to set yes, no or clean to the itunes explicit property"); } $this->offsetSet('explicit', $explicit); return $this; }
[ "public", "function", "setExplicit", "(", "$", "explicit", ")", "{", "$", "explicit", "=", "strtolower", "(", "$", "explicit", ")", ";", "if", "(", "!", "in_array", "(", "$", "explicit", ",", "array", "(", "'yes'", ",", "'no'", ",", "'clean'", ")", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to set yes, no or clean to the itunes explicit property\"", ")", ";", "}", "$", "this", "->", "offsetSet", "(", "'explicit'", ",", "$", "explicit", ")", ";", "return", "$", "this", ";", "}" ]
Configuration of the parental advisory graphic @param string $explicit can be 'yes', 'no' or 'clean' @return Zend_Feed_Builder_Header_Itunes @throws Zend_Feed_Builder_Exception
[ "Configuration", "of", "the", "parental", "advisory", "graphic" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Header/Itunes.php#L199-L211
webforge-labs/psc-cms
lib/Psc/PHPUnit/InvokedAtMethodIndexMatcher.php
InvokedAtMethodIndexMatcher.verify
public function verify() { if ($this->currentIndex < $this->sequenceIndex) { throw new PHPUnit_Framework_ExpectationFailedException( sprintf( "The expected invocation at method '%s' index %d was never reached.", $this->method, $this->sequenceIndex ) ); } }
php
public function verify() { if ($this->currentIndex < $this->sequenceIndex) { throw new PHPUnit_Framework_ExpectationFailedException( sprintf( "The expected invocation at method '%s' index %d was never reached.", $this->method, $this->sequenceIndex ) ); } }
[ "public", "function", "verify", "(", ")", "{", "if", "(", "$", "this", "->", "currentIndex", "<", "$", "this", "->", "sequenceIndex", ")", "{", "throw", "new", "PHPUnit_Framework_ExpectationFailedException", "(", "sprintf", "(", "\"The expected invocation at method '%s' index %d was never reached.\"", ",", "$", "this", "->", "method", ",", "$", "this", "->", "sequenceIndex", ")", ")", ";", "}", "}" ]
Verifies that the current expectation is valid. If everything is OK the code should just return, if not it must throw an exception. @throws PHPUnit_Framework_ExpectationFailedException
[ "Verifies", "that", "the", "current", "expectation", "is", "valid", ".", "If", "everything", "is", "OK", "the", "code", "should", "just", "return", "if", "not", "it", "must", "throw", "an", "exception", "." ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/PHPUnit/InvokedAtMethodIndexMatcher.php#L132-L144
AydinHassan/cli-md-renderer
src/Renderer/HeaderRenderer.php
HeaderRenderer.render
public function render(AbstractBlock $block, CliRenderer $renderer) { if (!($block instanceof Heading)) { throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block))); } $level = $block->getLevel(); $text = $renderer->renderInlines($block->children()); return sprintf( "\n%s %s\n", $renderer->style(str_repeat('#', $level), 'dark_gray'), $renderer->style($text, ['bold', 'cyan']) ); }
php
public function render(AbstractBlock $block, CliRenderer $renderer) { if (!($block instanceof Heading)) { throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block))); } $level = $block->getLevel(); $text = $renderer->renderInlines($block->children()); return sprintf( "\n%s %s\n", $renderer->style(str_repeat('#', $level), 'dark_gray'), $renderer->style($text, ['bold', 'cyan']) ); }
[ "public", "function", "render", "(", "AbstractBlock", "$", "block", ",", "CliRenderer", "$", "renderer", ")", "{", "if", "(", "!", "(", "$", "block", "instanceof", "Heading", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Incompatible block type: \"%s\"'", ",", "get_class", "(", "$", "block", ")", ")", ")", ";", "}", "$", "level", "=", "$", "block", "->", "getLevel", "(", ")", ";", "$", "text", "=", "$", "renderer", "->", "renderInlines", "(", "$", "block", "->", "children", "(", ")", ")", ";", "return", "sprintf", "(", "\"\\n%s %s\\n\"", ",", "$", "renderer", "->", "style", "(", "str_repeat", "(", "'#'", ",", "$", "level", ")", ",", "'dark_gray'", ")", ",", "$", "renderer", "->", "style", "(", "$", "text", ",", "[", "'bold'", ",", "'cyan'", "]", ")", ")", ";", "}" ]
@param AbstractBlock $block @param CliRenderer $renderer @return string
[ "@param", "AbstractBlock", "$block", "@param", "CliRenderer", "$renderer" ]
train
https://github.com/AydinHassan/cli-md-renderer/blob/521f9ace2aeadd58bf8a3910704be8360f5bd7b2/src/Renderer/HeaderRenderer.php#L23-L37
alanpich/slender
src/Core/ModuleLoader/ModuleLoader.php
ModuleLoader.addConfig
public function addConfig(array $conf = array()) { $appConfig =& $this->config; // Iterate through new top-level keys foreach ($conf as $key => $value) { // If doesnt exist yet, create it if (!isset($appConfig[$key])) { $appConfig[$key] = $value; continue; } // If it exists, and is already an array if (is_array($appConfig[$key])) { $mergedArray = array_merge_recursive($appConfig[$key], $value); $appConfig[$key] = $mergedArray; continue; } //@TODO check for iterators? // Just set the value already! $appConfig[$key] = $value; } }
php
public function addConfig(array $conf = array()) { $appConfig =& $this->config; // Iterate through new top-level keys foreach ($conf as $key => $value) { // If doesnt exist yet, create it if (!isset($appConfig[$key])) { $appConfig[$key] = $value; continue; } // If it exists, and is already an array if (is_array($appConfig[$key])) { $mergedArray = array_merge_recursive($appConfig[$key], $value); $appConfig[$key] = $mergedArray; continue; } //@TODO check for iterators? // Just set the value already! $appConfig[$key] = $value; } }
[ "public", "function", "addConfig", "(", "array", "$", "conf", "=", "array", "(", ")", ")", "{", "$", "appConfig", "=", "&", "$", "this", "->", "config", ";", "// Iterate through new top-level keys", "foreach", "(", "$", "conf", "as", "$", "key", "=>", "$", "value", ")", "{", "// If doesnt exist yet, create it", "if", "(", "!", "isset", "(", "$", "appConfig", "[", "$", "key", "]", ")", ")", "{", "$", "appConfig", "[", "$", "key", "]", "=", "$", "value", ";", "continue", ";", "}", "// If it exists, and is already an array", "if", "(", "is_array", "(", "$", "appConfig", "[", "$", "key", "]", ")", ")", "{", "$", "mergedArray", "=", "array_merge_recursive", "(", "$", "appConfig", "[", "$", "key", "]", ",", "$", "value", ")", ";", "$", "appConfig", "[", "$", "key", "]", "=", "$", "mergedArray", ";", "continue", ";", "}", "//@TODO check for iterators?", "// Just set the value already!", "$", "appConfig", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Recursively merge array of settings into app config. This is needed because \Slim\ConfigurationHander doesn't seem to like recursing... @param array $conf
[ "Recursively", "merge", "array", "of", "settings", "into", "app", "config", ".", "This", "is", "needed", "because", "\\", "Slim", "\\", "ConfigurationHander", "doesn", "t", "seem", "to", "like", "recursing", "..." ]
train
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ModuleLoader/ModuleLoader.php#L143-L168
alanpich/slender
src/Core/ModuleLoader/ModuleLoader.php
ModuleLoader.setupAutoloaders
protected function setupAutoloaders($modulePath, array $mConf) { if (isset($mConf['autoload']['psr-4'])) { foreach ($mConf['autoload']['psr-4'] as $ns => $path) { $path = $modulePath . DIRECTORY_SEPARATOR . preg_replace("/^\\.\\//", "", $path); $this->classLoader->registerNamespace($ns, $path, 'psr-4'); } } }
php
protected function setupAutoloaders($modulePath, array $mConf) { if (isset($mConf['autoload']['psr-4'])) { foreach ($mConf['autoload']['psr-4'] as $ns => $path) { $path = $modulePath . DIRECTORY_SEPARATOR . preg_replace("/^\\.\\//", "", $path); $this->classLoader->registerNamespace($ns, $path, 'psr-4'); } } }
[ "protected", "function", "setupAutoloaders", "(", "$", "modulePath", ",", "array", "$", "mConf", ")", "{", "if", "(", "isset", "(", "$", "mConf", "[", "'autoload'", "]", "[", "'psr-4'", "]", ")", ")", "{", "foreach", "(", "$", "mConf", "[", "'autoload'", "]", "[", "'psr-4'", "]", "as", "$", "ns", "=>", "$", "path", ")", "{", "$", "path", "=", "$", "modulePath", ".", "DIRECTORY_SEPARATOR", ".", "preg_replace", "(", "\"/^\\\\.\\\\//\"", ",", "\"\"", ",", "$", "path", ")", ";", "$", "this", "->", "classLoader", "->", "registerNamespace", "(", "$", "ns", ",", "$", "path", ",", "'psr-4'", ")", ";", "}", "}", "}" ]
Copy autoloader settings to global collection ready for registering
[ "Copy", "autoloader", "settings", "to", "global", "collection", "ready", "for", "registering" ]
train
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ModuleLoader/ModuleLoader.php#L175-L183
maniaplanet/matchmaking-lobby
MatchMakingLobby/Services/PlayerInfo.php
PlayerInfo.CleanUp
static function CleanUp() { $limit = new \DateTime('-30 minutes'); foreach(self::$instances as $login => $player) if($player->awaySince && $player->awaySince < $limit) unset(self::$instances[$login]); }
php
static function CleanUp() { $limit = new \DateTime('-30 minutes'); foreach(self::$instances as $login => $player) if($player->awaySince && $player->awaySince < $limit) unset(self::$instances[$login]); }
[ "static", "function", "CleanUp", "(", ")", "{", "$", "limit", "=", "new", "\\", "DateTime", "(", "'-30 minutes'", ")", ";", "foreach", "(", "self", "::", "$", "instances", "as", "$", "login", "=>", "$", "player", ")", "if", "(", "$", "player", "->", "awaySince", "&&", "$", "player", "->", "awaySince", "<", "$", "limit", ")", "unset", "(", "self", "::", "$", "instances", "[", "$", "login", "]", ")", ";", "}" ]
Destroy players disconnected for more than 1 hour
[ "Destroy", "players", "disconnected", "for", "more", "than", "1", "hour" ]
train
https://github.com/maniaplanet/matchmaking-lobby/blob/384f22cdd2cfb0204a071810549eaf1eb01d8b7f/MatchMakingLobby/Services/PlayerInfo.php#L88-L93
limen/php-jobs
src/Contracts/BaseJob.php
BaseJob.failed
protected function failed() { $retryCount = $this->model->getTriedCount() + 1; if ($retryCount >= $this->getMaxRetryCount()) { $this->model->setStatus(JobsConst::JOB_STATUS_FAILED); } else { $this->model->setStatus(JobsConst::JOB_STATUS_WAITING_RETRY); $this->model->setTryAt($this->getNextTryTime()); } $this->model->setTriedCount($retryCount); return $this->model->persist(); }
php
protected function failed() { $retryCount = $this->model->getTriedCount() + 1; if ($retryCount >= $this->getMaxRetryCount()) { $this->model->setStatus(JobsConst::JOB_STATUS_FAILED); } else { $this->model->setStatus(JobsConst::JOB_STATUS_WAITING_RETRY); $this->model->setTryAt($this->getNextTryTime()); } $this->model->setTriedCount($retryCount); return $this->model->persist(); }
[ "protected", "function", "failed", "(", ")", "{", "$", "retryCount", "=", "$", "this", "->", "model", "->", "getTriedCount", "(", ")", "+", "1", ";", "if", "(", "$", "retryCount", ">=", "$", "this", "->", "getMaxRetryCount", "(", ")", ")", "{", "$", "this", "->", "model", "->", "setStatus", "(", "JobsConst", "::", "JOB_STATUS_FAILED", ")", ";", "}", "else", "{", "$", "this", "->", "model", "->", "setStatus", "(", "JobsConst", "::", "JOB_STATUS_WAITING_RETRY", ")", ";", "$", "this", "->", "model", "->", "setTryAt", "(", "$", "this", "->", "getNextTryTime", "(", ")", ")", ";", "}", "$", "this", "->", "model", "->", "setTriedCount", "(", "$", "retryCount", ")", ";", "return", "$", "this", "->", "model", "->", "persist", "(", ")", ";", "}" ]
After failed we need to update tried count and check whether the tried count have reached to max retry count
[ "After", "failed", "we", "need", "to", "update", "tried", "count", "and", "check", "whether", "the", "tried", "count", "have", "reached", "to", "max", "retry", "count" ]
train
https://github.com/limen/php-jobs/blob/525f4082b49a7a3e69acb4cea3a622244f1616b9/src/Contracts/BaseJob.php#L236-L249
CakeCMS/Core
src/Cms.php
Cms.mergeConfig
public static function mergeConfig($key, $config) { $values = Hash::merge((array) Configure::read($key), $config); Configure::write($key, $values); return $values; }
php
public static function mergeConfig($key, $config) { $values = Hash::merge((array) Configure::read($key), $config); Configure::write($key, $values); return $values; }
[ "public", "static", "function", "mergeConfig", "(", "$", "key", ",", "$", "config", ")", "{", "$", "values", "=", "Hash", "::", "merge", "(", "(", "array", ")", "Configure", "::", "read", "(", "$", "key", ")", ",", "$", "config", ")", ";", "Configure", "::", "write", "(", "$", "key", ",", "$", "values", ")", ";", "return", "$", "values", ";", "}" ]
Merge configure values by key. @param string $key @param array|string $config @return array|mixed
[ "Merge", "configure", "values", "by", "key", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Cms.php#L56-L62
CakeCMS/Core
src/Cms.php
Cms._initPaths
protected function _initPaths() { $path = Path::getInstance(); $path->setRoot(ROOT); // Setup all webroot paths $path->set('webroot', Configure::read('App.wwwRoot')); foreach ((array) Plugin::loaded() as $name) { $plgPath = Plugin::path($name) . '/' . Configure::read('App.webroot') . '/'; $path->set('webroot', FS::clean($plgPath), Path::MOD_APPEND); } // Setup applicatiojn paths $paths = Configure::read('App.paths'); foreach ($paths as $alias => $_paths) { $path->set($alias, $_paths); } return $path; }
php
protected function _initPaths() { $path = Path::getInstance(); $path->setRoot(ROOT); // Setup all webroot paths $path->set('webroot', Configure::read('App.wwwRoot')); foreach ((array) Plugin::loaded() as $name) { $plgPath = Plugin::path($name) . '/' . Configure::read('App.webroot') . '/'; $path->set('webroot', FS::clean($plgPath), Path::MOD_APPEND); } // Setup applicatiojn paths $paths = Configure::read('App.paths'); foreach ($paths as $alias => $_paths) { $path->set($alias, $_paths); } return $path; }
[ "protected", "function", "_initPaths", "(", ")", "{", "$", "path", "=", "Path", "::", "getInstance", "(", ")", ";", "$", "path", "->", "setRoot", "(", "ROOT", ")", ";", "// Setup all webroot paths", "$", "path", "->", "set", "(", "'webroot'", ",", "Configure", "::", "read", "(", "'App.wwwRoot'", ")", ")", ";", "foreach", "(", "(", "array", ")", "Plugin", "::", "loaded", "(", ")", "as", "$", "name", ")", "{", "$", "plgPath", "=", "Plugin", "::", "path", "(", "$", "name", ")", ".", "'/'", ".", "Configure", "::", "read", "(", "'App.webroot'", ")", ".", "'/'", ";", "$", "path", "->", "set", "(", "'webroot'", ",", "FS", "::", "clean", "(", "$", "plgPath", ")", ",", "Path", "::", "MOD_APPEND", ")", ";", "}", "// Setup applicatiojn paths", "$", "paths", "=", "Configure", "::", "read", "(", "'App.paths'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "alias", "=>", "$", "_paths", ")", "{", "$", "path", "->", "set", "(", "$", "alias", ",", "$", "_paths", ")", ";", "}", "return", "$", "path", ";", "}" ]
Init base paths. @return Path @throws \JBZoo\Path\Exception
[ "Init", "base", "paths", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Cms.php#L86-L105
yuncms/framework
src/i18n/I18N.php
I18N.initTranslations
public function initTranslations() { $manifestFile = Yii::getAlias('@vendor/yuncms/translates.php'); if (is_file($manifestFile)) { $manifest = require($manifestFile); $this->translations = ArrayHelper::merge($manifest, $this->translations); } }
php
public function initTranslations() { $manifestFile = Yii::getAlias('@vendor/yuncms/translates.php'); if (is_file($manifestFile)) { $manifest = require($manifestFile); $this->translations = ArrayHelper::merge($manifest, $this->translations); } }
[ "public", "function", "initTranslations", "(", ")", "{", "$", "manifestFile", "=", "Yii", "::", "getAlias", "(", "'@vendor/yuncms/translates.php'", ")", ";", "if", "(", "is_file", "(", "$", "manifestFile", ")", ")", "{", "$", "manifest", "=", "require", "(", "$", "manifestFile", ")", ";", "$", "this", "->", "translations", "=", "ArrayHelper", "::", "merge", "(", "$", "manifest", ",", "$", "this", "->", "translations", ")", ";", "}", "}" ]
处理默认翻译清单
[ "处理默认翻译清单" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/i18n/I18N.php#L45-L52
vi-kon/laravel-auth
src/ViKon/Auth/Middleware/HasAccessMiddleware.php
HasAccessMiddleware.handle
public function handle(Request $request, Closure $next) { $action = $this->container->make('router')->current()->getAction(); if (array_key_exists('group', $action)) { $action['groups'] = $action['group']; } if (array_key_exists('role', $action)) { $action['roles'] = $action['role']; } if (array_key_exists('permission', $action)) { $action['permissions'] = $action['permission']; } // Check user access only if least one role or permission is added to current route if (array_key_exists('roles', $action) || array_key_exists('permissions', $action)) { $url = $this->container->make('url'); $config = $this->container->make('config'); $redirect = $this->container->make('redirect'); // If user is not authenticated redirect to login route if (!$this->keeper->check()) { return $redirect->guest($url->route($config->get('vi-kon.auth.login.route'))); } // Get roles and permissions $groups = Arr::get($action, 'groups', []); $roles = Arr::get($action, 'roles', []); $permissions = Arr::get($action, 'permissions', []); /** @noinspection ArrayCastingEquivalentInspection */ if (!is_array($groups)) { $groups = [$groups]; } /** @noinspection ArrayCastingEquivalentInspection */ if (!is_array($roles)) { $roles = [$roles]; } /** @noinspection ArrayCastingEquivalentInspection */ if (!is_array($permissions)) { $permissions = [$permissions]; } // If user is authenticated but has no permission to access given route then redirect to 403 route if ($this->keeper->hasGroups($groups) !== true || $this->keeper->hasRoles($roles) !== true || $this->keeper->hasPermissions($permissions) !== true ) { $router = $this->container->make('router'); $log = $this->container->make('log'); $currentRoute = $router->current(); $log->notice('User has no access to page', [ 'user' => $this->keeper->user()->toArray(), 'permissions' => $permissions, 'roles' => $roles, 'groups' => $groups, 'route' => $currentRoute->getName(), ]); throw new AccessDeniedHttpException(); } } return $next($request); }
php
public function handle(Request $request, Closure $next) { $action = $this->container->make('router')->current()->getAction(); if (array_key_exists('group', $action)) { $action['groups'] = $action['group']; } if (array_key_exists('role', $action)) { $action['roles'] = $action['role']; } if (array_key_exists('permission', $action)) { $action['permissions'] = $action['permission']; } // Check user access only if least one role or permission is added to current route if (array_key_exists('roles', $action) || array_key_exists('permissions', $action)) { $url = $this->container->make('url'); $config = $this->container->make('config'); $redirect = $this->container->make('redirect'); // If user is not authenticated redirect to login route if (!$this->keeper->check()) { return $redirect->guest($url->route($config->get('vi-kon.auth.login.route'))); } // Get roles and permissions $groups = Arr::get($action, 'groups', []); $roles = Arr::get($action, 'roles', []); $permissions = Arr::get($action, 'permissions', []); /** @noinspection ArrayCastingEquivalentInspection */ if (!is_array($groups)) { $groups = [$groups]; } /** @noinspection ArrayCastingEquivalentInspection */ if (!is_array($roles)) { $roles = [$roles]; } /** @noinspection ArrayCastingEquivalentInspection */ if (!is_array($permissions)) { $permissions = [$permissions]; } // If user is authenticated but has no permission to access given route then redirect to 403 route if ($this->keeper->hasGroups($groups) !== true || $this->keeper->hasRoles($roles) !== true || $this->keeper->hasPermissions($permissions) !== true ) { $router = $this->container->make('router'); $log = $this->container->make('log'); $currentRoute = $router->current(); $log->notice('User has no access to page', [ 'user' => $this->keeper->user()->toArray(), 'permissions' => $permissions, 'roles' => $roles, 'groups' => $groups, 'route' => $currentRoute->getName(), ]); throw new AccessDeniedHttpException(); } } return $next($request); }
[ "public", "function", "handle", "(", "Request", "$", "request", ",", "Closure", "$", "next", ")", "{", "$", "action", "=", "$", "this", "->", "container", "->", "make", "(", "'router'", ")", "->", "current", "(", ")", "->", "getAction", "(", ")", ";", "if", "(", "array_key_exists", "(", "'group'", ",", "$", "action", ")", ")", "{", "$", "action", "[", "'groups'", "]", "=", "$", "action", "[", "'group'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'role'", ",", "$", "action", ")", ")", "{", "$", "action", "[", "'roles'", "]", "=", "$", "action", "[", "'role'", "]", ";", "}", "if", "(", "array_key_exists", "(", "'permission'", ",", "$", "action", ")", ")", "{", "$", "action", "[", "'permissions'", "]", "=", "$", "action", "[", "'permission'", "]", ";", "}", "// Check user access only if least one role or permission is added to current route", "if", "(", "array_key_exists", "(", "'roles'", ",", "$", "action", ")", "||", "array_key_exists", "(", "'permissions'", ",", "$", "action", ")", ")", "{", "$", "url", "=", "$", "this", "->", "container", "->", "make", "(", "'url'", ")", ";", "$", "config", "=", "$", "this", "->", "container", "->", "make", "(", "'config'", ")", ";", "$", "redirect", "=", "$", "this", "->", "container", "->", "make", "(", "'redirect'", ")", ";", "// If user is not authenticated redirect to login route", "if", "(", "!", "$", "this", "->", "keeper", "->", "check", "(", ")", ")", "{", "return", "$", "redirect", "->", "guest", "(", "$", "url", "->", "route", "(", "$", "config", "->", "get", "(", "'vi-kon.auth.login.route'", ")", ")", ")", ";", "}", "// Get roles and permissions", "$", "groups", "=", "Arr", "::", "get", "(", "$", "action", ",", "'groups'", ",", "[", "]", ")", ";", "$", "roles", "=", "Arr", "::", "get", "(", "$", "action", ",", "'roles'", ",", "[", "]", ")", ";", "$", "permissions", "=", "Arr", "::", "get", "(", "$", "action", ",", "'permissions'", ",", "[", "]", ")", ";", "/** @noinspection ArrayCastingEquivalentInspection */", "if", "(", "!", "is_array", "(", "$", "groups", ")", ")", "{", "$", "groups", "=", "[", "$", "groups", "]", ";", "}", "/** @noinspection ArrayCastingEquivalentInspection */", "if", "(", "!", "is_array", "(", "$", "roles", ")", ")", "{", "$", "roles", "=", "[", "$", "roles", "]", ";", "}", "/** @noinspection ArrayCastingEquivalentInspection */", "if", "(", "!", "is_array", "(", "$", "permissions", ")", ")", "{", "$", "permissions", "=", "[", "$", "permissions", "]", ";", "}", "// If user is authenticated but has no permission to access given route then redirect to 403 route", "if", "(", "$", "this", "->", "keeper", "->", "hasGroups", "(", "$", "groups", ")", "!==", "true", "||", "$", "this", "->", "keeper", "->", "hasRoles", "(", "$", "roles", ")", "!==", "true", "||", "$", "this", "->", "keeper", "->", "hasPermissions", "(", "$", "permissions", ")", "!==", "true", ")", "{", "$", "router", "=", "$", "this", "->", "container", "->", "make", "(", "'router'", ")", ";", "$", "log", "=", "$", "this", "->", "container", "->", "make", "(", "'log'", ")", ";", "$", "currentRoute", "=", "$", "router", "->", "current", "(", ")", ";", "$", "log", "->", "notice", "(", "'User has no access to page'", ",", "[", "'user'", "=>", "$", "this", "->", "keeper", "->", "user", "(", ")", "->", "toArray", "(", ")", ",", "'permissions'", "=>", "$", "permissions", ",", "'roles'", "=>", "$", "roles", ",", "'groups'", "=>", "$", "groups", ",", "'route'", "=>", "$", "currentRoute", "->", "getName", "(", ")", ",", "]", ")", ";", "throw", "new", "AccessDeniedHttpException", "(", ")", ";", "}", "}", "return", "$", "next", "(", "$", "request", ")", ";", "}" ]
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return \Illuminate\Http\RedirectResponse|mixed
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/ViKon/Auth/Middleware/HasAccessMiddleware.php#L45-L111
anime-db/app-bundle
src/Command/TaskSchedulerCommand.php
TaskSchedulerCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { // exit if disabled if (!$this->getContainer()->getParameter('task_scheduler.enabled')) { return true; } // path to php executable $finder = new PhpExecutableFinder(); $console = $finder->find().' '.$this->getContainer()->getParameter('kernel.root_dir').'/console'; /* @var $em EntityManager */ $em = $this->getContainer()->get('doctrine')->getManager(); /* @var $repository TaskRepository */ $repository = $em->getRepository('AnimeDbAppBundle:Task'); $output->writeln('Task Scheduler'); while (true) { $task = $repository->getNextTask(); // task is exists if ($task instanceof Task) { $output->writeln(sprintf('Run <info>%s</info>', $task->getCommand())); if (defined('PHP_WINDOWS_VERSION_BUILD')) { pclose(popen('start /b '.$console.' '.$task->getCommand().' >nul 2>&1', 'r')); } else { exec($console.' '.$task->getCommand().' >/dev/null 2>&1 &'); } // update information on starting $task->executed(); $em->persist($task); $em->flush($task); } // standby for the next task $time = $repository->getWaitingTime(); if ($time) { $output->writeln(sprintf('Wait <comment>%s</comment> s.', $time)); sleep($time); } unset($task); gc_collect_cycles(); } return true; }
php
protected function execute(InputInterface $input, OutputInterface $output) { // exit if disabled if (!$this->getContainer()->getParameter('task_scheduler.enabled')) { return true; } // path to php executable $finder = new PhpExecutableFinder(); $console = $finder->find().' '.$this->getContainer()->getParameter('kernel.root_dir').'/console'; /* @var $em EntityManager */ $em = $this->getContainer()->get('doctrine')->getManager(); /* @var $repository TaskRepository */ $repository = $em->getRepository('AnimeDbAppBundle:Task'); $output->writeln('Task Scheduler'); while (true) { $task = $repository->getNextTask(); // task is exists if ($task instanceof Task) { $output->writeln(sprintf('Run <info>%s</info>', $task->getCommand())); if (defined('PHP_WINDOWS_VERSION_BUILD')) { pclose(popen('start /b '.$console.' '.$task->getCommand().' >nul 2>&1', 'r')); } else { exec($console.' '.$task->getCommand().' >/dev/null 2>&1 &'); } // update information on starting $task->executed(); $em->persist($task); $em->flush($task); } // standby for the next task $time = $repository->getWaitingTime(); if ($time) { $output->writeln(sprintf('Wait <comment>%s</comment> s.', $time)); sleep($time); } unset($task); gc_collect_cycles(); } return true; }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// exit if disabled", "if", "(", "!", "$", "this", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'task_scheduler.enabled'", ")", ")", "{", "return", "true", ";", "}", "// path to php executable", "$", "finder", "=", "new", "PhpExecutableFinder", "(", ")", ";", "$", "console", "=", "$", "finder", "->", "find", "(", ")", ".", "' '", ".", "$", "this", "->", "getContainer", "(", ")", "->", "getParameter", "(", "'kernel.root_dir'", ")", ".", "'/console'", ";", "/* @var $em EntityManager */", "$", "em", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'doctrine'", ")", "->", "getManager", "(", ")", ";", "/* @var $repository TaskRepository */", "$", "repository", "=", "$", "em", "->", "getRepository", "(", "'AnimeDbAppBundle:Task'", ")", ";", "$", "output", "->", "writeln", "(", "'Task Scheduler'", ")", ";", "while", "(", "true", ")", "{", "$", "task", "=", "$", "repository", "->", "getNextTask", "(", ")", ";", "// task is exists", "if", "(", "$", "task", "instanceof", "Task", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'Run <info>%s</info>'", ",", "$", "task", "->", "getCommand", "(", ")", ")", ")", ";", "if", "(", "defined", "(", "'PHP_WINDOWS_VERSION_BUILD'", ")", ")", "{", "pclose", "(", "popen", "(", "'start /b '", ".", "$", "console", ".", "' '", ".", "$", "task", "->", "getCommand", "(", ")", ".", "' >nul 2>&1'", ",", "'r'", ")", ")", ";", "}", "else", "{", "exec", "(", "$", "console", ".", "' '", ".", "$", "task", "->", "getCommand", "(", ")", ".", "' >/dev/null 2>&1 &'", ")", ";", "}", "// update information on starting", "$", "task", "->", "executed", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "task", ")", ";", "$", "em", "->", "flush", "(", "$", "task", ")", ";", "}", "// standby for the next task", "$", "time", "=", "$", "repository", "->", "getWaitingTime", "(", ")", ";", "if", "(", "$", "time", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'Wait <comment>%s</comment> s.'", ",", "$", "time", ")", ")", ";", "sleep", "(", "$", "time", ")", ";", "}", "unset", "(", "$", "task", ")", ";", "gc_collect_cycles", "(", ")", ";", "}", "return", "true", ";", "}" ]
@param InputInterface $input @param OutputInterface $output @return bool
[ "@param", "InputInterface", "$input", "@param", "OutputInterface", "$output" ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Command/TaskSchedulerCommand.php#L33-L82
anime-db/app-bundle
src/Entity/Task.php
Task.executed
public function executed() { $this->setLastRun(new \DateTime()); if (!$this->getModify()) { $this->setStatus(self::STATUS_DISABLED); } if ($this->getStatus() == self::STATUS_ENABLED) { // find near time task launch $next_run = $this->getNextRun(); do { // failed to compute time of next run if ($next_run->modify($this->getModify()) === false) { $this->setModify(''); $this->setStatus(self::STATUS_DISABLED); break; } } while ($next_run->getTimestamp() <= time()); $this->setNextRun($next_run); } }
php
public function executed() { $this->setLastRun(new \DateTime()); if (!$this->getModify()) { $this->setStatus(self::STATUS_DISABLED); } if ($this->getStatus() == self::STATUS_ENABLED) { // find near time task launch $next_run = $this->getNextRun(); do { // failed to compute time of next run if ($next_run->modify($this->getModify()) === false) { $this->setModify(''); $this->setStatus(self::STATUS_DISABLED); break; } } while ($next_run->getTimestamp() <= time()); $this->setNextRun($next_run); } }
[ "public", "function", "executed", "(", ")", "{", "$", "this", "->", "setLastRun", "(", "new", "\\", "DateTime", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "getModify", "(", ")", ")", "{", "$", "this", "->", "setStatus", "(", "self", "::", "STATUS_DISABLED", ")", ";", "}", "if", "(", "$", "this", "->", "getStatus", "(", ")", "==", "self", "::", "STATUS_ENABLED", ")", "{", "// find near time task launch", "$", "next_run", "=", "$", "this", "->", "getNextRun", "(", ")", ";", "do", "{", "// failed to compute time of next run", "if", "(", "$", "next_run", "->", "modify", "(", "$", "this", "->", "getModify", "(", ")", ")", "===", "false", ")", "{", "$", "this", "->", "setModify", "(", "''", ")", ";", "$", "this", "->", "setStatus", "(", "self", "::", "STATUS_DISABLED", ")", ";", "break", ";", "}", "}", "while", "(", "$", "next_run", "->", "getTimestamp", "(", ")", "<=", "time", "(", ")", ")", ";", "$", "this", "->", "setNextRun", "(", "$", "next_run", ")", ";", "}", "}" ]
Update task after execution.
[ "Update", "task", "after", "execution", "." ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Entity/Task.php#L243-L262
alanpich/slender
src/Core/ModuleResolver/NamespaceResolver.php
NamespaceResolver.getPath
public function getPath($module) { // treat $module as a namespace $class = $module."\\SlenderModule"; // Try to find class for path if (class_exists($class) ) { $reflector = new \ReflectionClass($class); $interfaces = $reflector->getInterfaceNames(); if (is_string($interfaces)) { $interfaces = array($interfaces); } if (in_array('Slender\Interfaces\ModulePathProviderInterface',$interfaces)) { return call_user_func(array($class,'getModulePath')); } } // Give up return false; }
php
public function getPath($module) { // treat $module as a namespace $class = $module."\\SlenderModule"; // Try to find class for path if (class_exists($class) ) { $reflector = new \ReflectionClass($class); $interfaces = $reflector->getInterfaceNames(); if (is_string($interfaces)) { $interfaces = array($interfaces); } if (in_array('Slender\Interfaces\ModulePathProviderInterface',$interfaces)) { return call_user_func(array($class,'getModulePath')); } } // Give up return false; }
[ "public", "function", "getPath", "(", "$", "module", ")", "{", "// treat $module as a namespace", "$", "class", "=", "$", "module", ".", "\"\\\\SlenderModule\"", ";", "// Try to find class for path", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "reflector", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "interfaces", "=", "$", "reflector", "->", "getInterfaceNames", "(", ")", ";", "if", "(", "is_string", "(", "$", "interfaces", ")", ")", "{", "$", "interfaces", "=", "array", "(", "$", "interfaces", ")", ";", "}", "if", "(", "in_array", "(", "'Slender\\Interfaces\\ModulePathProviderInterface'", ",", "$", "interfaces", ")", ")", "{", "return", "call_user_func", "(", "array", "(", "$", "class", ",", "'getModulePath'", ")", ")", ";", "}", "}", "// Give up", "return", "false", ";", "}" ]
Return the path to Module $module, or false if not found @param string $module Module name or Namespace @return string|false
[ "Return", "the", "path", "to", "Module", "$module", "or", "false", "if", "not", "found" ]
train
https://github.com/alanpich/slender/blob/247f5c08af20cda95b116eb5d9f6f623d61e8a8a/src/Core/ModuleResolver/NamespaceResolver.php#L45-L64
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.getLastLogin
public function getLastLogin($format = null) { if ($this->last_login === null) { return null; } if ($this->last_login === '0000-00-00 00:00:00') { // while technically this is not a default value of null, // this seems to be closest in meaning. return null; } try { $dt = new DateTime($this->last_login); } catch (Exception $x) { throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_login, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; } if (strpos($format, '%') !== false) { return strftime($format, $dt->format('U')); } return $dt->format($format); }
php
public function getLastLogin($format = null) { if ($this->last_login === null) { return null; } if ($this->last_login === '0000-00-00 00:00:00') { // while technically this is not a default value of null, // this seems to be closest in meaning. return null; } try { $dt = new DateTime($this->last_login); } catch (Exception $x) { throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->last_login, true), $x); } if ($format === null) { // Because propel.useDateTimeClass is true, we return a DateTime object. return $dt; } if (strpos($format, '%') !== false) { return strftime($format, $dt->format('U')); } return $dt->format($format); }
[ "public", "function", "getLastLogin", "(", "$", "format", "=", "null", ")", "{", "if", "(", "$", "this", "->", "last_login", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "last_login", "===", "'0000-00-00 00:00:00'", ")", "{", "// while technically this is not a default value of null,", "// this seems to be closest in meaning.", "return", "null", ";", "}", "try", "{", "$", "dt", "=", "new", "DateTime", "(", "$", "this", "->", "last_login", ")", ";", "}", "catch", "(", "Exception", "$", "x", ")", "{", "throw", "new", "PropelException", "(", "\"Internally stored date/time/timestamp value could not be converted to DateTime: \"", ".", "var_export", "(", "$", "this", "->", "last_login", ",", "true", ")", ",", "$", "x", ")", ";", "}", "if", "(", "$", "format", "===", "null", ")", "{", "// Because propel.useDateTimeClass is true, we return a DateTime object.", "return", "$", "dt", ";", "}", "if", "(", "strpos", "(", "$", "format", ",", "'%'", ")", "!==", "false", ")", "{", "return", "strftime", "(", "$", "format", ",", "$", "dt", "->", "format", "(", "'U'", ")", ")", ";", "}", "return", "$", "dt", "->", "format", "(", "$", "format", ")", ";", "}" ]
Get the [optionally formatted] temporal [last_login] column value. @param string $format The date/time format string (either date()-style or strftime()-style). If format is null, then the raw DateTime object will be returned. @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null, and 0 if column value is 0000-00-00 00:00:00 @throws PropelException - if unable to parse/validate the date/time value.
[ "Get", "the", "[", "optionally", "formatted", "]", "temporal", "[", "last_login", "]", "column", "value", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L312-L341
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setUsername
public function setUsername($v) { if ($v !== null) { $v = (string) $v; } if ($this->username !== $v) { $this->username = $v; $this->modifiedColumns[] = UserPeer::USERNAME; } return $this; }
php
public function setUsername($v) { if ($v !== null) { $v = (string) $v; } if ($this->username !== $v) { $this->username = $v; $this->modifiedColumns[] = UserPeer::USERNAME; } return $this; }
[ "public", "function", "setUsername", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "username", "!==", "$", "v", ")", "{", "$", "this", "->", "username", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "USERNAME", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [username] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "username", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L392-L405
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setPassword
public function setPassword($v) { if ($v !== null) { $v = (string) $v; } if ($this->password !== $v) { $this->password = $v; $this->modifiedColumns[] = UserPeer::PASSWORD; } return $this; }
php
public function setPassword($v) { if ($v !== null) { $v = (string) $v; } if ($this->password !== $v) { $this->password = $v; $this->modifiedColumns[] = UserPeer::PASSWORD; } return $this; }
[ "public", "function", "setPassword", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "password", "!==", "$", "v", ")", "{", "$", "this", "->", "password", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "PASSWORD", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [password] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "password", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L413-L426
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setSalt
public function setSalt($v) { if ($v !== null) { $v = (string) $v; } if ($this->salt !== $v) { $this->salt = $v; $this->modifiedColumns[] = UserPeer::SALT; } return $this; }
php
public function setSalt($v) { if ($v !== null) { $v = (string) $v; } if ($this->salt !== $v) { $this->salt = $v; $this->modifiedColumns[] = UserPeer::SALT; } return $this; }
[ "public", "function", "setSalt", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "salt", "!==", "$", "v", ")", "{", "$", "this", "->", "salt", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "SALT", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [salt] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "salt", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L434-L447
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setFirstname
public function setFirstname($v) { if ($v !== null) { $v = (string) $v; } if ($this->firstname !== $v) { $this->firstname = $v; $this->modifiedColumns[] = UserPeer::FIRSTNAME; } return $this; }
php
public function setFirstname($v) { if ($v !== null) { $v = (string) $v; } if ($this->firstname !== $v) { $this->firstname = $v; $this->modifiedColumns[] = UserPeer::FIRSTNAME; } return $this; }
[ "public", "function", "setFirstname", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "firstname", "!==", "$", "v", ")", "{", "$", "this", "->", "firstname", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "FIRSTNAME", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [firstname] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "firstname", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L455-L468
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setLastname
public function setLastname($v) { if ($v !== null) { $v = (string) $v; } if ($this->lastname !== $v) { $this->lastname = $v; $this->modifiedColumns[] = UserPeer::LASTNAME; } return $this; }
php
public function setLastname($v) { if ($v !== null) { $v = (string) $v; } if ($this->lastname !== $v) { $this->lastname = $v; $this->modifiedColumns[] = UserPeer::LASTNAME; } return $this; }
[ "public", "function", "setLastname", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "lastname", "!==", "$", "v", ")", "{", "$", "this", "->", "lastname", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "LASTNAME", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [lastname] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "lastname", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L476-L489
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setEmail
public function setEmail($v) { if ($v !== null) { $v = (string) $v; } if ($this->email !== $v) { $this->email = $v; $this->modifiedColumns[] = UserPeer::EMAIL; } return $this; }
php
public function setEmail($v) { if ($v !== null) { $v = (string) $v; } if ($this->email !== $v) { $this->email = $v; $this->modifiedColumns[] = UserPeer::EMAIL; } return $this; }
[ "public", "function", "setEmail", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "email", "!==", "$", "v", ")", "{", "$", "this", "->", "email", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "EMAIL", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [email] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "email", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L497-L510
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setPhone
public function setPhone($v) { if ($v !== null) { $v = (string) $v; } if ($this->phone !== $v) { $this->phone = $v; $this->modifiedColumns[] = UserPeer::PHONE; } return $this; }
php
public function setPhone($v) { if ($v !== null) { $v = (string) $v; } if ($this->phone !== $v) { $this->phone = $v; $this->modifiedColumns[] = UserPeer::PHONE; } return $this; }
[ "public", "function", "setPhone", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "phone", "!==", "$", "v", ")", "{", "$", "this", "->", "phone", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "PHONE", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [phone] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "phone", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L518-L531
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setMemo
public function setMemo($v) { if ($v !== null) { $v = (string) $v; } if ($this->memo !== $v) { $this->memo = $v; $this->modifiedColumns[] = UserPeer::MEMO; } return $this; }
php
public function setMemo($v) { if ($v !== null) { $v = (string) $v; } if ($this->memo !== $v) { $this->memo = $v; $this->modifiedColumns[] = UserPeer::MEMO; } return $this; }
[ "public", "function", "setMemo", "(", "$", "v", ")", "{", "if", "(", "$", "v", "!==", "null", ")", "{", "$", "v", "=", "(", "string", ")", "$", "v", ";", "}", "if", "(", "$", "this", "->", "memo", "!==", "$", "v", ")", "{", "$", "this", "->", "memo", "=", "$", "v", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "MEMO", ";", "}", "return", "$", "this", ";", "}" ]
Set the value of [memo] column. @param string $v new value @return User The current object (for fluent API support)
[ "Set", "the", "value", "of", "[", "memo", "]", "column", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L539-L552
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setLastLogin
public function setLastLogin($v) { $dt = PropelDateTime::newInstance($v, null, 'DateTime'); if ($this->last_login !== null || $dt !== null) { $currentDateAsString = ($this->last_login !== null && $tmpDt = new DateTime($this->last_login)) ? $tmpDt->format('Y-m-d H:i:s') : null; $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; if ($currentDateAsString !== $newDateAsString) { $this->last_login = $newDateAsString; $this->modifiedColumns[] = UserPeer::LAST_LOGIN; } } // if either are not null return $this; }
php
public function setLastLogin($v) { $dt = PropelDateTime::newInstance($v, null, 'DateTime'); if ($this->last_login !== null || $dt !== null) { $currentDateAsString = ($this->last_login !== null && $tmpDt = new DateTime($this->last_login)) ? $tmpDt->format('Y-m-d H:i:s') : null; $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null; if ($currentDateAsString !== $newDateAsString) { $this->last_login = $newDateAsString; $this->modifiedColumns[] = UserPeer::LAST_LOGIN; } } // if either are not null return $this; }
[ "public", "function", "setLastLogin", "(", "$", "v", ")", "{", "$", "dt", "=", "PropelDateTime", "::", "newInstance", "(", "$", "v", ",", "null", ",", "'DateTime'", ")", ";", "if", "(", "$", "this", "->", "last_login", "!==", "null", "||", "$", "dt", "!==", "null", ")", "{", "$", "currentDateAsString", "=", "(", "$", "this", "->", "last_login", "!==", "null", "&&", "$", "tmpDt", "=", "new", "DateTime", "(", "$", "this", "->", "last_login", ")", ")", "?", "$", "tmpDt", "->", "format", "(", "'Y-m-d H:i:s'", ")", ":", "null", ";", "$", "newDateAsString", "=", "$", "dt", "?", "$", "dt", "->", "format", "(", "'Y-m-d H:i:s'", ")", ":", "null", ";", "if", "(", "$", "currentDateAsString", "!==", "$", "newDateAsString", ")", "{", "$", "this", "->", "last_login", "=", "$", "newDateAsString", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "LAST_LOGIN", ";", "}", "}", "// if either are not null", "return", "$", "this", ";", "}" ]
Sets the value of [last_login] column to a normalized version of the date/time value specified. @param mixed $v string, integer (timestamp), or DateTime value. Empty strings are treated as null. @return User The current object (for fluent API support)
[ "Sets", "the", "value", "of", "[", "last_login", "]", "column", "to", "a", "normalized", "version", "of", "the", "date", "/", "time", "value", "specified", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L590-L604
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.hasOnlyDefaultValues
public function hasOnlyDefaultValues() { if ($this->notification_change !== true) { return false; } if ($this->notification_error !== true) { return false; } // otherwise, everything was equal, so return true return true; }
php
public function hasOnlyDefaultValues() { if ($this->notification_change !== true) { return false; } if ($this->notification_error !== true) { return false; } // otherwise, everything was equal, so return true return true; }
[ "public", "function", "hasOnlyDefaultValues", "(", ")", "{", "if", "(", "$", "this", "->", "notification_change", "!==", "true", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "notification_error", "!==", "true", ")", "{", "return", "false", ";", "}", "// otherwise, everything was equal, so return true", "return", "true", ";", "}" ]
Indicates whether the columns in this object are only set to default values. This method can be used in conjunction with isModified() to indicate whether an object is both modified _and_ has some values set which are non-default. @return boolean Whether the columns in this object are only been set with default values.
[ "Indicates", "whether", "the", "columns", "in", "this", "object", "are", "only", "set", "to", "default", "values", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L672-L684
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.hydrate
public function hydrate($row, $startcol = 0, $rehydrate = false) { try { $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->username = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->password = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->salt = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->firstname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->lastname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->email = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->phone = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->memo = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; $this->activated = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null; $this->last_login = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; $this->notification_change = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; $this->notification_error = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; $this->resetModified(); $this->setNew(false); if ($rehydrate) { $this->ensureConsistency(); } $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 13; // 13 = UserPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating User object", $e); } }
php
public function hydrate($row, $startcol = 0, $rehydrate = false) { try { $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->username = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->password = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; $this->salt = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->firstname = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->lastname = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null; $this->email = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null; $this->phone = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null; $this->memo = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null; $this->activated = ($row[$startcol + 9] !== null) ? (boolean) $row[$startcol + 9] : null; $this->last_login = ($row[$startcol + 10] !== null) ? (string) $row[$startcol + 10] : null; $this->notification_change = ($row[$startcol + 11] !== null) ? (boolean) $row[$startcol + 11] : null; $this->notification_error = ($row[$startcol + 12] !== null) ? (boolean) $row[$startcol + 12] : null; $this->resetModified(); $this->setNew(false); if ($rehydrate) { $this->ensureConsistency(); } $this->postHydrate($row, $startcol, $rehydrate); return $startcol + 13; // 13 = UserPeer::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating User object", $e); } }
[ "public", "function", "hydrate", "(", "$", "row", ",", "$", "startcol", "=", "0", ",", "$", "rehydrate", "=", "false", ")", "{", "try", "{", "$", "this", "->", "id", "=", "(", "$", "row", "[", "$", "startcol", "+", "0", "]", "!==", "null", ")", "?", "(", "int", ")", "$", "row", "[", "$", "startcol", "+", "0", "]", ":", "null", ";", "$", "this", "->", "username", "=", "(", "$", "row", "[", "$", "startcol", "+", "1", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "1", "]", ":", "null", ";", "$", "this", "->", "password", "=", "(", "$", "row", "[", "$", "startcol", "+", "2", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "2", "]", ":", "null", ";", "$", "this", "->", "salt", "=", "(", "$", "row", "[", "$", "startcol", "+", "3", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "3", "]", ":", "null", ";", "$", "this", "->", "firstname", "=", "(", "$", "row", "[", "$", "startcol", "+", "4", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "4", "]", ":", "null", ";", "$", "this", "->", "lastname", "=", "(", "$", "row", "[", "$", "startcol", "+", "5", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "5", "]", ":", "null", ";", "$", "this", "->", "email", "=", "(", "$", "row", "[", "$", "startcol", "+", "6", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "6", "]", ":", "null", ";", "$", "this", "->", "phone", "=", "(", "$", "row", "[", "$", "startcol", "+", "7", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "7", "]", ":", "null", ";", "$", "this", "->", "memo", "=", "(", "$", "row", "[", "$", "startcol", "+", "8", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "8", "]", ":", "null", ";", "$", "this", "->", "activated", "=", "(", "$", "row", "[", "$", "startcol", "+", "9", "]", "!==", "null", ")", "?", "(", "boolean", ")", "$", "row", "[", "$", "startcol", "+", "9", "]", ":", "null", ";", "$", "this", "->", "last_login", "=", "(", "$", "row", "[", "$", "startcol", "+", "10", "]", "!==", "null", ")", "?", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "10", "]", ":", "null", ";", "$", "this", "->", "notification_change", "=", "(", "$", "row", "[", "$", "startcol", "+", "11", "]", "!==", "null", ")", "?", "(", "boolean", ")", "$", "row", "[", "$", "startcol", "+", "11", "]", ":", "null", ";", "$", "this", "->", "notification_error", "=", "(", "$", "row", "[", "$", "startcol", "+", "12", "]", "!==", "null", ")", "?", "(", "boolean", ")", "$", "row", "[", "$", "startcol", "+", "12", "]", ":", "null", ";", "$", "this", "->", "resetModified", "(", ")", ";", "$", "this", "->", "setNew", "(", "false", ")", ";", "if", "(", "$", "rehydrate", ")", "{", "$", "this", "->", "ensureConsistency", "(", ")", ";", "}", "$", "this", "->", "postHydrate", "(", "$", "row", ",", "$", "startcol", ",", "$", "rehydrate", ")", ";", "return", "$", "startcol", "+", "13", ";", "// 13 = UserPeer::NUM_HYDRATE_COLUMNS.", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "\"Error populating User object\"", ",", "$", "e", ")", ";", "}", "}" ]
Hydrates (populates) the object variables with values from the database resultset. An offset (0-based "start column") is specified so that objects can be hydrated with a subset of the columns in the resultset rows. This is needed, for example, for results of JOIN queries where the resultset row includes columns from two or more tables. @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM) @param int $startcol 0-based offset column which indicates which resultset column to start with. @param boolean $rehydrate Whether this object is being re-hydrated from the database. @return int next starting column @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
[ "Hydrates", "(", "populates", ")", "the", "object", "variables", "with", "values", "from", "the", "database", "resultset", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L700-L731
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.doSave
protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->userCustomerRelationsScheduledForDeletion !== null) { if (!$this->userCustomerRelationsScheduledForDeletion->isEmpty()) { UserCustomerRelationQuery::create() ->filterByPrimaryKeys($this->userCustomerRelationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->userCustomerRelationsScheduledForDeletion = null; } } if ($this->collUserCustomerRelations !== null) { foreach ($this->collUserCustomerRelations as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->userRolesScheduledForDeletion !== null) { if (!$this->userRolesScheduledForDeletion->isEmpty()) { UserRoleQuery::create() ->filterByPrimaryKeys($this->userRolesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->userRolesScheduledForDeletion = null; } } if ($this->collUserRoles !== null) { foreach ($this->collUserRoles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
php
protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->userCustomerRelationsScheduledForDeletion !== null) { if (!$this->userCustomerRelationsScheduledForDeletion->isEmpty()) { UserCustomerRelationQuery::create() ->filterByPrimaryKeys($this->userCustomerRelationsScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->userCustomerRelationsScheduledForDeletion = null; } } if ($this->collUserCustomerRelations !== null) { foreach ($this->collUserCustomerRelations as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } if ($this->userRolesScheduledForDeletion !== null) { if (!$this->userRolesScheduledForDeletion->isEmpty()) { UserRoleQuery::create() ->filterByPrimaryKeys($this->userRolesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); $this->userRolesScheduledForDeletion = null; } } if ($this->collUserRoles !== null) { foreach ($this->collUserRoles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
[ "protected", "function", "doSave", "(", "PropelPDO", "$", "con", ")", "{", "$", "affectedRows", "=", "0", ";", "// initialize var to track total num of affected rows", "if", "(", "!", "$", "this", "->", "alreadyInSave", ")", "{", "$", "this", "->", "alreadyInSave", "=", "true", ";", "if", "(", "$", "this", "->", "isNew", "(", ")", "||", "$", "this", "->", "isModified", "(", ")", ")", "{", "// persist changes", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "$", "this", "->", "doInsert", "(", "$", "con", ")", ";", "}", "else", "{", "$", "this", "->", "doUpdate", "(", "$", "con", ")", ";", "}", "$", "affectedRows", "+=", "1", ";", "$", "this", "->", "resetModified", "(", ")", ";", "}", "if", "(", "$", "this", "->", "userCustomerRelationsScheduledForDeletion", "!==", "null", ")", "{", "if", "(", "!", "$", "this", "->", "userCustomerRelationsScheduledForDeletion", "->", "isEmpty", "(", ")", ")", "{", "UserCustomerRelationQuery", "::", "create", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "this", "->", "userCustomerRelationsScheduledForDeletion", "->", "getPrimaryKeys", "(", "false", ")", ")", "->", "delete", "(", "$", "con", ")", ";", "$", "this", "->", "userCustomerRelationsScheduledForDeletion", "=", "null", ";", "}", "}", "if", "(", "$", "this", "->", "collUserCustomerRelations", "!==", "null", ")", "{", "foreach", "(", "$", "this", "->", "collUserCustomerRelations", "as", "$", "referrerFK", ")", "{", "if", "(", "!", "$", "referrerFK", "->", "isDeleted", "(", ")", "&&", "(", "$", "referrerFK", "->", "isNew", "(", ")", "||", "$", "referrerFK", "->", "isModified", "(", ")", ")", ")", "{", "$", "affectedRows", "+=", "$", "referrerFK", "->", "save", "(", "$", "con", ")", ";", "}", "}", "}", "if", "(", "$", "this", "->", "userRolesScheduledForDeletion", "!==", "null", ")", "{", "if", "(", "!", "$", "this", "->", "userRolesScheduledForDeletion", "->", "isEmpty", "(", ")", ")", "{", "UserRoleQuery", "::", "create", "(", ")", "->", "filterByPrimaryKeys", "(", "$", "this", "->", "userRolesScheduledForDeletion", "->", "getPrimaryKeys", "(", "false", ")", ")", "->", "delete", "(", "$", "con", ")", ";", "$", "this", "->", "userRolesScheduledForDeletion", "=", "null", ";", "}", "}", "if", "(", "$", "this", "->", "collUserRoles", "!==", "null", ")", "{", "foreach", "(", "$", "this", "->", "collUserRoles", "as", "$", "referrerFK", ")", "{", "if", "(", "!", "$", "referrerFK", "->", "isDeleted", "(", ")", "&&", "(", "$", "referrerFK", "->", "isNew", "(", ")", "||", "$", "referrerFK", "->", "isModified", "(", ")", ")", ")", "{", "$", "affectedRows", "+=", "$", "referrerFK", "->", "save", "(", "$", "con", ")", ";", "}", "}", "}", "$", "this", "->", "alreadyInSave", "=", "false", ";", "}", "return", "$", "affectedRows", ";", "}" ]
Performs the work of inserting or updating the row in the database. If the object is new, it inserts it; otherwise an update is performed. All related objects are also updated in this method. @param PropelPDO $con @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. @throws PropelException @see save()
[ "Performs", "the", "work", "of", "inserting", "or", "updating", "the", "row", "in", "the", "database", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L899-L955
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.doInsert
protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = UserPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(UserPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(UserPeer::USERNAME)) { $modifiedColumns[':p' . $index++] = '`username`'; } if ($this->isColumnModified(UserPeer::PASSWORD)) { $modifiedColumns[':p' . $index++] = '`password`'; } if ($this->isColumnModified(UserPeer::SALT)) { $modifiedColumns[':p' . $index++] = '`salt`'; } if ($this->isColumnModified(UserPeer::FIRSTNAME)) { $modifiedColumns[':p' . $index++] = '`firstname`'; } if ($this->isColumnModified(UserPeer::LASTNAME)) { $modifiedColumns[':p' . $index++] = '`lastname`'; } if ($this->isColumnModified(UserPeer::EMAIL)) { $modifiedColumns[':p' . $index++] = '`email`'; } if ($this->isColumnModified(UserPeer::PHONE)) { $modifiedColumns[':p' . $index++] = '`phone`'; } if ($this->isColumnModified(UserPeer::MEMO)) { $modifiedColumns[':p' . $index++] = '`memo`'; } if ($this->isColumnModified(UserPeer::ACTIVATED)) { $modifiedColumns[':p' . $index++] = '`activated`'; } if ($this->isColumnModified(UserPeer::LAST_LOGIN)) { $modifiedColumns[':p' . $index++] = '`last_login`'; } if ($this->isColumnModified(UserPeer::NOTIFICATION_CHANGE)) { $modifiedColumns[':p' . $index++] = '`notification_change`'; } if ($this->isColumnModified(UserPeer::NOTIFICATION_ERROR)) { $modifiedColumns[':p' . $index++] = '`notification_error`'; } $sql = sprintf( 'INSERT INTO `user` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; case '`username`': $stmt->bindValue($identifier, $this->username, PDO::PARAM_STR); break; case '`password`': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; case '`salt`': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; case '`firstname`': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; case '`lastname`': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; case '`email`': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; case '`phone`': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; case '`memo`': $stmt->bindValue($identifier, $this->memo, PDO::PARAM_STR); break; case '`activated`': $stmt->bindValue($identifier, (int) $this->activated, PDO::PARAM_INT); break; case '`last_login`': $stmt->bindValue($identifier, $this->last_login, PDO::PARAM_STR); break; case '`notification_change`': $stmt->bindValue($identifier, (int) $this->notification_change, PDO::PARAM_INT); break; case '`notification_error`': $stmt->bindValue($identifier, (int) $this->notification_error, PDO::PARAM_INT); break; } } $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
php
protected function doInsert(PropelPDO $con) { $modifiedColumns = array(); $index = 0; $this->modifiedColumns[] = UserPeer::ID; if (null !== $this->id) { throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserPeer::ID . ')'); } // check the columns in natural order for more readable SQL queries if ($this->isColumnModified(UserPeer::ID)) { $modifiedColumns[':p' . $index++] = '`id`'; } if ($this->isColumnModified(UserPeer::USERNAME)) { $modifiedColumns[':p' . $index++] = '`username`'; } if ($this->isColumnModified(UserPeer::PASSWORD)) { $modifiedColumns[':p' . $index++] = '`password`'; } if ($this->isColumnModified(UserPeer::SALT)) { $modifiedColumns[':p' . $index++] = '`salt`'; } if ($this->isColumnModified(UserPeer::FIRSTNAME)) { $modifiedColumns[':p' . $index++] = '`firstname`'; } if ($this->isColumnModified(UserPeer::LASTNAME)) { $modifiedColumns[':p' . $index++] = '`lastname`'; } if ($this->isColumnModified(UserPeer::EMAIL)) { $modifiedColumns[':p' . $index++] = '`email`'; } if ($this->isColumnModified(UserPeer::PHONE)) { $modifiedColumns[':p' . $index++] = '`phone`'; } if ($this->isColumnModified(UserPeer::MEMO)) { $modifiedColumns[':p' . $index++] = '`memo`'; } if ($this->isColumnModified(UserPeer::ACTIVATED)) { $modifiedColumns[':p' . $index++] = '`activated`'; } if ($this->isColumnModified(UserPeer::LAST_LOGIN)) { $modifiedColumns[':p' . $index++] = '`last_login`'; } if ($this->isColumnModified(UserPeer::NOTIFICATION_CHANGE)) { $modifiedColumns[':p' . $index++] = '`notification_change`'; } if ($this->isColumnModified(UserPeer::NOTIFICATION_ERROR)) { $modifiedColumns[':p' . $index++] = '`notification_error`'; } $sql = sprintf( 'INSERT INTO `user` (%s) VALUES (%s)', implode(', ', $modifiedColumns), implode(', ', array_keys($modifiedColumns)) ); try { $stmt = $con->prepare($sql); foreach ($modifiedColumns as $identifier => $columnName) { switch ($columnName) { case '`id`': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; case '`username`': $stmt->bindValue($identifier, $this->username, PDO::PARAM_STR); break; case '`password`': $stmt->bindValue($identifier, $this->password, PDO::PARAM_STR); break; case '`salt`': $stmt->bindValue($identifier, $this->salt, PDO::PARAM_STR); break; case '`firstname`': $stmt->bindValue($identifier, $this->firstname, PDO::PARAM_STR); break; case '`lastname`': $stmt->bindValue($identifier, $this->lastname, PDO::PARAM_STR); break; case '`email`': $stmt->bindValue($identifier, $this->email, PDO::PARAM_STR); break; case '`phone`': $stmt->bindValue($identifier, $this->phone, PDO::PARAM_STR); break; case '`memo`': $stmt->bindValue($identifier, $this->memo, PDO::PARAM_STR); break; case '`activated`': $stmt->bindValue($identifier, (int) $this->activated, PDO::PARAM_INT); break; case '`last_login`': $stmt->bindValue($identifier, $this->last_login, PDO::PARAM_STR); break; case '`notification_change`': $stmt->bindValue($identifier, (int) $this->notification_change, PDO::PARAM_INT); break; case '`notification_error`': $stmt->bindValue($identifier, (int) $this->notification_error, PDO::PARAM_INT); break; } } $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e); } try { $pk = $con->lastInsertId(); } catch (Exception $e) { throw new PropelException('Unable to get autoincrement id.', $e); } $this->setId($pk); $this->setNew(false); }
[ "protected", "function", "doInsert", "(", "PropelPDO", "$", "con", ")", "{", "$", "modifiedColumns", "=", "array", "(", ")", ";", "$", "index", "=", "0", ";", "$", "this", "->", "modifiedColumns", "[", "]", "=", "UserPeer", "::", "ID", ";", "if", "(", "null", "!==", "$", "this", "->", "id", ")", "{", "throw", "new", "PropelException", "(", "'Cannot insert a value for auto-increment primary key ('", ".", "UserPeer", "::", "ID", ".", "')'", ")", ";", "}", "// check the columns in natural order for more readable SQL queries", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "ID", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`id`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "USERNAME", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`username`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "PASSWORD", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`password`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "SALT", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`salt`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "FIRSTNAME", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`firstname`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "LASTNAME", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`lastname`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "EMAIL", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`email`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "PHONE", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`phone`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "MEMO", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`memo`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "ACTIVATED", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`activated`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "LAST_LOGIN", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`last_login`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "NOTIFICATION_CHANGE", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`notification_change`'", ";", "}", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "NOTIFICATION_ERROR", ")", ")", "{", "$", "modifiedColumns", "[", "':p'", ".", "$", "index", "++", "]", "=", "'`notification_error`'", ";", "}", "$", "sql", "=", "sprintf", "(", "'INSERT INTO `user` (%s) VALUES (%s)'", ",", "implode", "(", "', '", ",", "$", "modifiedColumns", ")", ",", "implode", "(", "', '", ",", "array_keys", "(", "$", "modifiedColumns", ")", ")", ")", ";", "try", "{", "$", "stmt", "=", "$", "con", "->", "prepare", "(", "$", "sql", ")", ";", "foreach", "(", "$", "modifiedColumns", "as", "$", "identifier", "=>", "$", "columnName", ")", "{", "switch", "(", "$", "columnName", ")", "{", "case", "'`id`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "id", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "case", "'`username`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "username", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`password`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "password", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`salt`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "salt", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`firstname`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "firstname", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`lastname`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "lastname", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`email`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "email", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`phone`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "phone", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`memo`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "memo", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`activated`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "(", "int", ")", "$", "this", "->", "activated", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "case", "'`last_login`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "$", "this", "->", "last_login", ",", "PDO", "::", "PARAM_STR", ")", ";", "break", ";", "case", "'`notification_change`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "(", "int", ")", "$", "this", "->", "notification_change", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "case", "'`notification_error`'", ":", "$", "stmt", "->", "bindValue", "(", "$", "identifier", ",", "(", "int", ")", "$", "this", "->", "notification_error", ",", "PDO", "::", "PARAM_INT", ")", ";", "break", ";", "}", "}", "$", "stmt", "->", "execute", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "Propel", "::", "log", "(", "$", "e", "->", "getMessage", "(", ")", ",", "Propel", "::", "LOG_ERR", ")", ";", "throw", "new", "PropelException", "(", "sprintf", "(", "'Unable to execute INSERT statement [%s]'", ",", "$", "sql", ")", ",", "$", "e", ")", ";", "}", "try", "{", "$", "pk", "=", "$", "con", "->", "lastInsertId", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "PropelException", "(", "'Unable to get autoincrement id.'", ",", "$", "e", ")", ";", "}", "$", "this", "->", "setId", "(", "$", "pk", ")", ";", "$", "this", "->", "setNew", "(", "false", ")", ";", "}" ]
Insert the row in the database. @param PropelPDO $con @throws PropelException @see doSave()
[ "Insert", "the", "row", "in", "the", "database", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L965-L1081
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.getByPosition
public function getByPosition($pos) { switch ($pos) { case 0: return $this->getId(); break; case 1: return $this->getUsername(); break; case 2: return $this->getPassword(); break; case 3: return $this->getSalt(); break; case 4: return $this->getFirstname(); break; case 5: return $this->getLastname(); break; case 6: return $this->getEmail(); break; case 7: return $this->getPhone(); break; case 8: return $this->getMemo(); break; case 9: return $this->getActivated(); break; case 10: return $this->getLastLogin(); break; case 11: return $this->getNotificationChange(); break; case 12: return $this->getNotificationError(); break; default: return null; break; } // switch() }
php
public function getByPosition($pos) { switch ($pos) { case 0: return $this->getId(); break; case 1: return $this->getUsername(); break; case 2: return $this->getPassword(); break; case 3: return $this->getSalt(); break; case 4: return $this->getFirstname(); break; case 5: return $this->getLastname(); break; case 6: return $this->getEmail(); break; case 7: return $this->getPhone(); break; case 8: return $this->getMemo(); break; case 9: return $this->getActivated(); break; case 10: return $this->getLastLogin(); break; case 11: return $this->getNotificationChange(); break; case 12: return $this->getNotificationError(); break; default: return null; break; } // switch() }
[ "public", "function", "getByPosition", "(", "$", "pos", ")", "{", "switch", "(", "$", "pos", ")", "{", "case", "0", ":", "return", "$", "this", "->", "getId", "(", ")", ";", "break", ";", "case", "1", ":", "return", "$", "this", "->", "getUsername", "(", ")", ";", "break", ";", "case", "2", ":", "return", "$", "this", "->", "getPassword", "(", ")", ";", "break", ";", "case", "3", ":", "return", "$", "this", "->", "getSalt", "(", ")", ";", "break", ";", "case", "4", ":", "return", "$", "this", "->", "getFirstname", "(", ")", ";", "break", ";", "case", "5", ":", "return", "$", "this", "->", "getLastname", "(", ")", ";", "break", ";", "case", "6", ":", "return", "$", "this", "->", "getEmail", "(", ")", ";", "break", ";", "case", "7", ":", "return", "$", "this", "->", "getPhone", "(", ")", ";", "break", ";", "case", "8", ":", "return", "$", "this", "->", "getMemo", "(", ")", ";", "break", ";", "case", "9", ":", "return", "$", "this", "->", "getActivated", "(", ")", ";", "break", ";", "case", "10", ":", "return", "$", "this", "->", "getLastLogin", "(", ")", ";", "break", ";", "case", "11", ":", "return", "$", "this", "->", "getNotificationChange", "(", ")", ";", "break", ";", "case", "12", ":", "return", "$", "this", "->", "getNotificationError", "(", ")", ";", "break", ";", "default", ":", "return", "null", ";", "break", ";", "}", "// switch()", "}" ]
Retrieves a field from the object by Position as specified in the xml schema. Zero-based. @param int $pos position in xml schema @return mixed Value of field at $pos
[ "Retrieves", "a", "field", "from", "the", "object", "by", "Position", "as", "specified", "in", "the", "xml", "schema", ".", "Zero", "-", "based", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1212-L1258
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.toArray
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['User'][$this->getPrimaryKey()])) { return '*RECURSION*'; } $alreadyDumpedObjects['User'][$this->getPrimaryKey()] = true; $keys = UserPeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getUsername(), $keys[2] => $this->getPassword(), $keys[3] => $this->getSalt(), $keys[4] => $this->getFirstname(), $keys[5] => $this->getLastname(), $keys[6] => $this->getEmail(), $keys[7] => $this->getPhone(), $keys[8] => $this->getMemo(), $keys[9] => $this->getActivated(), $keys[10] => $this->getLastLogin(), $keys[11] => $this->getNotificationChange(), $keys[12] => $this->getNotificationError(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->collUserCustomerRelations) { $result['UserCustomerRelations'] = $this->collUserCustomerRelations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collUserRoles) { $result['UserRoles'] = $this->collUserRoles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } return $result; }
php
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) { if (isset($alreadyDumpedObjects['User'][$this->getPrimaryKey()])) { return '*RECURSION*'; } $alreadyDumpedObjects['User'][$this->getPrimaryKey()] = true; $keys = UserPeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getUsername(), $keys[2] => $this->getPassword(), $keys[3] => $this->getSalt(), $keys[4] => $this->getFirstname(), $keys[5] => $this->getLastname(), $keys[6] => $this->getEmail(), $keys[7] => $this->getPhone(), $keys[8] => $this->getMemo(), $keys[9] => $this->getActivated(), $keys[10] => $this->getLastLogin(), $keys[11] => $this->getNotificationChange(), $keys[12] => $this->getNotificationError(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { $result[$key] = $virtualColumn; } if ($includeForeignObjects) { if (null !== $this->collUserCustomerRelations) { $result['UserCustomerRelations'] = $this->collUserCustomerRelations->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collUserRoles) { $result['UserRoles'] = $this->collUserRoles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } return $result; }
[ "public", "function", "toArray", "(", "$", "keyType", "=", "BasePeer", "::", "TYPE_PHPNAME", ",", "$", "includeLazyLoadColumns", "=", "true", ",", "$", "alreadyDumpedObjects", "=", "array", "(", ")", ",", "$", "includeForeignObjects", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "alreadyDumpedObjects", "[", "'User'", "]", "[", "$", "this", "->", "getPrimaryKey", "(", ")", "]", ")", ")", "{", "return", "'*RECURSION*'", ";", "}", "$", "alreadyDumpedObjects", "[", "'User'", "]", "[", "$", "this", "->", "getPrimaryKey", "(", ")", "]", "=", "true", ";", "$", "keys", "=", "UserPeer", "::", "getFieldNames", "(", "$", "keyType", ")", ";", "$", "result", "=", "array", "(", "$", "keys", "[", "0", "]", "=>", "$", "this", "->", "getId", "(", ")", ",", "$", "keys", "[", "1", "]", "=>", "$", "this", "->", "getUsername", "(", ")", ",", "$", "keys", "[", "2", "]", "=>", "$", "this", "->", "getPassword", "(", ")", ",", "$", "keys", "[", "3", "]", "=>", "$", "this", "->", "getSalt", "(", ")", ",", "$", "keys", "[", "4", "]", "=>", "$", "this", "->", "getFirstname", "(", ")", ",", "$", "keys", "[", "5", "]", "=>", "$", "this", "->", "getLastname", "(", ")", ",", "$", "keys", "[", "6", "]", "=>", "$", "this", "->", "getEmail", "(", ")", ",", "$", "keys", "[", "7", "]", "=>", "$", "this", "->", "getPhone", "(", ")", ",", "$", "keys", "[", "8", "]", "=>", "$", "this", "->", "getMemo", "(", ")", ",", "$", "keys", "[", "9", "]", "=>", "$", "this", "->", "getActivated", "(", ")", ",", "$", "keys", "[", "10", "]", "=>", "$", "this", "->", "getLastLogin", "(", ")", ",", "$", "keys", "[", "11", "]", "=>", "$", "this", "->", "getNotificationChange", "(", ")", ",", "$", "keys", "[", "12", "]", "=>", "$", "this", "->", "getNotificationError", "(", ")", ",", ")", ";", "$", "virtualColumns", "=", "$", "this", "->", "virtualColumns", ";", "foreach", "(", "$", "virtualColumns", "as", "$", "key", "=>", "$", "virtualColumn", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "virtualColumn", ";", "}", "if", "(", "$", "includeForeignObjects", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collUserCustomerRelations", ")", "{", "$", "result", "[", "'UserCustomerRelations'", "]", "=", "$", "this", "->", "collUserCustomerRelations", "->", "toArray", "(", "null", ",", "true", ",", "$", "keyType", ",", "$", "includeLazyLoadColumns", ",", "$", "alreadyDumpedObjects", ")", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "collUserRoles", ")", "{", "$", "result", "[", "'UserRoles'", "]", "=", "$", "this", "->", "collUserRoles", "->", "toArray", "(", "null", ",", "true", ",", "$", "keyType", ",", "$", "includeLazyLoadColumns", ",", "$", "alreadyDumpedObjects", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Exports the object as an array. You can specify the key type of the array by passing one of the class type constants. @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. Defaults to BasePeer::TYPE_PHPNAME. @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true. @param array $alreadyDumpedObjects List of objects to skip to avoid recursion @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. @return array an associative array containing the field names (as keys) and field values
[ "Exports", "the", "object", "as", "an", "array", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1275-L1312
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.setByPosition
public function setByPosition($pos, $value) { switch ($pos) { case 0: $this->setId($value); break; case 1: $this->setUsername($value); break; case 2: $this->setPassword($value); break; case 3: $this->setSalt($value); break; case 4: $this->setFirstname($value); break; case 5: $this->setLastname($value); break; case 6: $this->setEmail($value); break; case 7: $this->setPhone($value); break; case 8: $this->setMemo($value); break; case 9: $this->setActivated($value); break; case 10: $this->setLastLogin($value); break; case 11: $this->setNotificationChange($value); break; case 12: $this->setNotificationError($value); break; } // switch() }
php
public function setByPosition($pos, $value) { switch ($pos) { case 0: $this->setId($value); break; case 1: $this->setUsername($value); break; case 2: $this->setPassword($value); break; case 3: $this->setSalt($value); break; case 4: $this->setFirstname($value); break; case 5: $this->setLastname($value); break; case 6: $this->setEmail($value); break; case 7: $this->setPhone($value); break; case 8: $this->setMemo($value); break; case 9: $this->setActivated($value); break; case 10: $this->setLastLogin($value); break; case 11: $this->setNotificationChange($value); break; case 12: $this->setNotificationError($value); break; } // switch() }
[ "public", "function", "setByPosition", "(", "$", "pos", ",", "$", "value", ")", "{", "switch", "(", "$", "pos", ")", "{", "case", "0", ":", "$", "this", "->", "setId", "(", "$", "value", ")", ";", "break", ";", "case", "1", ":", "$", "this", "->", "setUsername", "(", "$", "value", ")", ";", "break", ";", "case", "2", ":", "$", "this", "->", "setPassword", "(", "$", "value", ")", ";", "break", ";", "case", "3", ":", "$", "this", "->", "setSalt", "(", "$", "value", ")", ";", "break", ";", "case", "4", ":", "$", "this", "->", "setFirstname", "(", "$", "value", ")", ";", "break", ";", "case", "5", ":", "$", "this", "->", "setLastname", "(", "$", "value", ")", ";", "break", ";", "case", "6", ":", "$", "this", "->", "setEmail", "(", "$", "value", ")", ";", "break", ";", "case", "7", ":", "$", "this", "->", "setPhone", "(", "$", "value", ")", ";", "break", ";", "case", "8", ":", "$", "this", "->", "setMemo", "(", "$", "value", ")", ";", "break", ";", "case", "9", ":", "$", "this", "->", "setActivated", "(", "$", "value", ")", ";", "break", ";", "case", "10", ":", "$", "this", "->", "setLastLogin", "(", "$", "value", ")", ";", "break", ";", "case", "11", ":", "$", "this", "->", "setNotificationChange", "(", "$", "value", ")", ";", "break", ";", "case", "12", ":", "$", "this", "->", "setNotificationError", "(", "$", "value", ")", ";", "break", ";", "}", "// switch()", "}" ]
Sets a field from the object by Position as specified in the xml schema. Zero-based. @param int $pos position in xml schema @param mixed $value field value @return void
[ "Sets", "a", "field", "from", "the", "object", "by", "Position", "as", "specified", "in", "the", "xml", "schema", ".", "Zero", "-", "based", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1340-L1383
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.fromArray
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = UserPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setUsername($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setPassword($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setSalt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setFirstname($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setLastname($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setEmail($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setPhone($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setMemo($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setActivated($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setLastLogin($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setNotificationChange($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setNotificationError($arr[$keys[12]]); }
php
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = UserPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setUsername($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setPassword($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setSalt($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setFirstname($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setLastname($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setEmail($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setPhone($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setMemo($arr[$keys[8]]); if (array_key_exists($keys[9], $arr)) $this->setActivated($arr[$keys[9]]); if (array_key_exists($keys[10], $arr)) $this->setLastLogin($arr[$keys[10]]); if (array_key_exists($keys[11], $arr)) $this->setNotificationChange($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setNotificationError($arr[$keys[12]]); }
[ "public", "function", "fromArray", "(", "$", "arr", ",", "$", "keyType", "=", "BasePeer", "::", "TYPE_PHPNAME", ")", "{", "$", "keys", "=", "UserPeer", "::", "getFieldNames", "(", "$", "keyType", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "0", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setId", "(", "$", "arr", "[", "$", "keys", "[", "0", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "1", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setUsername", "(", "$", "arr", "[", "$", "keys", "[", "1", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "2", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setPassword", "(", "$", "arr", "[", "$", "keys", "[", "2", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "3", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setSalt", "(", "$", "arr", "[", "$", "keys", "[", "3", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "4", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setFirstname", "(", "$", "arr", "[", "$", "keys", "[", "4", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "5", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setLastname", "(", "$", "arr", "[", "$", "keys", "[", "5", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "6", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setEmail", "(", "$", "arr", "[", "$", "keys", "[", "6", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "7", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setPhone", "(", "$", "arr", "[", "$", "keys", "[", "7", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "8", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setMemo", "(", "$", "arr", "[", "$", "keys", "[", "8", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "9", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setActivated", "(", "$", "arr", "[", "$", "keys", "[", "9", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "10", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setLastLogin", "(", "$", "arr", "[", "$", "keys", "[", "10", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "11", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setNotificationChange", "(", "$", "arr", "[", "$", "keys", "[", "11", "]", "]", ")", ";", "if", "(", "array_key_exists", "(", "$", "keys", "[", "12", "]", ",", "$", "arr", ")", ")", "$", "this", "->", "setNotificationError", "(", "$", "arr", "[", "$", "keys", "[", "12", "]", "]", ")", ";", "}" ]
Populates the object using an array. This is particularly useful when populating an object from one of the request arrays (e.g. $_POST). This method goes through the column names, checking to see whether a matching key exists in populated array. If so the setByName() method is called for that column. You can specify the key type of the array by additionally passing one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. The default key type is the column's BasePeer::TYPE_PHPNAME @param array $arr An array to populate the object from. @param string $keyType The type of keys the array uses. @return void
[ "Populates", "the", "object", "using", "an", "array", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1402-L1419
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.buildCriteria
public function buildCriteria() { $criteria = new Criteria(UserPeer::DATABASE_NAME); if ($this->isColumnModified(UserPeer::ID)) $criteria->add(UserPeer::ID, $this->id); if ($this->isColumnModified(UserPeer::USERNAME)) $criteria->add(UserPeer::USERNAME, $this->username); if ($this->isColumnModified(UserPeer::PASSWORD)) $criteria->add(UserPeer::PASSWORD, $this->password); if ($this->isColumnModified(UserPeer::SALT)) $criteria->add(UserPeer::SALT, $this->salt); if ($this->isColumnModified(UserPeer::FIRSTNAME)) $criteria->add(UserPeer::FIRSTNAME, $this->firstname); if ($this->isColumnModified(UserPeer::LASTNAME)) $criteria->add(UserPeer::LASTNAME, $this->lastname); if ($this->isColumnModified(UserPeer::EMAIL)) $criteria->add(UserPeer::EMAIL, $this->email); if ($this->isColumnModified(UserPeer::PHONE)) $criteria->add(UserPeer::PHONE, $this->phone); if ($this->isColumnModified(UserPeer::MEMO)) $criteria->add(UserPeer::MEMO, $this->memo); if ($this->isColumnModified(UserPeer::ACTIVATED)) $criteria->add(UserPeer::ACTIVATED, $this->activated); if ($this->isColumnModified(UserPeer::LAST_LOGIN)) $criteria->add(UserPeer::LAST_LOGIN, $this->last_login); if ($this->isColumnModified(UserPeer::NOTIFICATION_CHANGE)) $criteria->add(UserPeer::NOTIFICATION_CHANGE, $this->notification_change); if ($this->isColumnModified(UserPeer::NOTIFICATION_ERROR)) $criteria->add(UserPeer::NOTIFICATION_ERROR, $this->notification_error); return $criteria; }
php
public function buildCriteria() { $criteria = new Criteria(UserPeer::DATABASE_NAME); if ($this->isColumnModified(UserPeer::ID)) $criteria->add(UserPeer::ID, $this->id); if ($this->isColumnModified(UserPeer::USERNAME)) $criteria->add(UserPeer::USERNAME, $this->username); if ($this->isColumnModified(UserPeer::PASSWORD)) $criteria->add(UserPeer::PASSWORD, $this->password); if ($this->isColumnModified(UserPeer::SALT)) $criteria->add(UserPeer::SALT, $this->salt); if ($this->isColumnModified(UserPeer::FIRSTNAME)) $criteria->add(UserPeer::FIRSTNAME, $this->firstname); if ($this->isColumnModified(UserPeer::LASTNAME)) $criteria->add(UserPeer::LASTNAME, $this->lastname); if ($this->isColumnModified(UserPeer::EMAIL)) $criteria->add(UserPeer::EMAIL, $this->email); if ($this->isColumnModified(UserPeer::PHONE)) $criteria->add(UserPeer::PHONE, $this->phone); if ($this->isColumnModified(UserPeer::MEMO)) $criteria->add(UserPeer::MEMO, $this->memo); if ($this->isColumnModified(UserPeer::ACTIVATED)) $criteria->add(UserPeer::ACTIVATED, $this->activated); if ($this->isColumnModified(UserPeer::LAST_LOGIN)) $criteria->add(UserPeer::LAST_LOGIN, $this->last_login); if ($this->isColumnModified(UserPeer::NOTIFICATION_CHANGE)) $criteria->add(UserPeer::NOTIFICATION_CHANGE, $this->notification_change); if ($this->isColumnModified(UserPeer::NOTIFICATION_ERROR)) $criteria->add(UserPeer::NOTIFICATION_ERROR, $this->notification_error); return $criteria; }
[ "public", "function", "buildCriteria", "(", ")", "{", "$", "criteria", "=", "new", "Criteria", "(", "UserPeer", "::", "DATABASE_NAME", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "ID", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "ID", ",", "$", "this", "->", "id", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "USERNAME", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "USERNAME", ",", "$", "this", "->", "username", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "PASSWORD", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "PASSWORD", ",", "$", "this", "->", "password", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "SALT", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "SALT", ",", "$", "this", "->", "salt", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "FIRSTNAME", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "FIRSTNAME", ",", "$", "this", "->", "firstname", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "LASTNAME", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "LASTNAME", ",", "$", "this", "->", "lastname", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "EMAIL", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "EMAIL", ",", "$", "this", "->", "email", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "PHONE", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "PHONE", ",", "$", "this", "->", "phone", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "MEMO", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "MEMO", ",", "$", "this", "->", "memo", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "ACTIVATED", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "ACTIVATED", ",", "$", "this", "->", "activated", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "LAST_LOGIN", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "LAST_LOGIN", ",", "$", "this", "->", "last_login", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "NOTIFICATION_CHANGE", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "NOTIFICATION_CHANGE", ",", "$", "this", "->", "notification_change", ")", ";", "if", "(", "$", "this", "->", "isColumnModified", "(", "UserPeer", "::", "NOTIFICATION_ERROR", ")", ")", "$", "criteria", "->", "add", "(", "UserPeer", "::", "NOTIFICATION_ERROR", ",", "$", "this", "->", "notification_error", ")", ";", "return", "$", "criteria", ";", "}" ]
Build a Criteria object containing the values of all modified columns in this object. @return Criteria The Criteria object containing all modified values.
[ "Build", "a", "Criteria", "object", "containing", "the", "values", "of", "all", "modified", "columns", "in", "this", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1426-L1445
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.copyInto
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setUsername($this->getUsername()); $copyObj->setPassword($this->getPassword()); $copyObj->setSalt($this->getSalt()); $copyObj->setFirstname($this->getFirstname()); $copyObj->setLastname($this->getLastname()); $copyObj->setEmail($this->getEmail()); $copyObj->setPhone($this->getPhone()); $copyObj->setMemo($this->getMemo()); $copyObj->setActivated($this->getActivated()); $copyObj->setLastLogin($this->getLastLogin()); $copyObj->setNotificationChange($this->getNotificationChange()); $copyObj->setNotificationError($this->getNotificationError()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); // store object hash to prevent cycle $this->startCopy = true; foreach ($this->getUserCustomerRelations() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addUserCustomerRelation($relObj->copy($deepCopy)); } } foreach ($this->getUserRoles() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addUserRole($relObj->copy($deepCopy)); } } //unflag object copy $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } }
php
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setUsername($this->getUsername()); $copyObj->setPassword($this->getPassword()); $copyObj->setSalt($this->getSalt()); $copyObj->setFirstname($this->getFirstname()); $copyObj->setLastname($this->getLastname()); $copyObj->setEmail($this->getEmail()); $copyObj->setPhone($this->getPhone()); $copyObj->setMemo($this->getMemo()); $copyObj->setActivated($this->getActivated()); $copyObj->setLastLogin($this->getLastLogin()); $copyObj->setNotificationChange($this->getNotificationChange()); $copyObj->setNotificationError($this->getNotificationError()); if ($deepCopy && !$this->startCopy) { // important: temporarily setNew(false) because this affects the behavior of // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); // store object hash to prevent cycle $this->startCopy = true; foreach ($this->getUserCustomerRelations() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addUserCustomerRelation($relObj->copy($deepCopy)); } } foreach ($this->getUserRoles() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves $copyObj->addUserRole($relObj->copy($deepCopy)); } } //unflag object copy $this->startCopy = false; } // if ($deepCopy) if ($makeNew) { $copyObj->setNew(true); $copyObj->setId(NULL); // this is a auto-increment column, so set to default value } }
[ "public", "function", "copyInto", "(", "$", "copyObj", ",", "$", "deepCopy", "=", "false", ",", "$", "makeNew", "=", "true", ")", "{", "$", "copyObj", "->", "setUsername", "(", "$", "this", "->", "getUsername", "(", ")", ")", ";", "$", "copyObj", "->", "setPassword", "(", "$", "this", "->", "getPassword", "(", ")", ")", ";", "$", "copyObj", "->", "setSalt", "(", "$", "this", "->", "getSalt", "(", ")", ")", ";", "$", "copyObj", "->", "setFirstname", "(", "$", "this", "->", "getFirstname", "(", ")", ")", ";", "$", "copyObj", "->", "setLastname", "(", "$", "this", "->", "getLastname", "(", ")", ")", ";", "$", "copyObj", "->", "setEmail", "(", "$", "this", "->", "getEmail", "(", ")", ")", ";", "$", "copyObj", "->", "setPhone", "(", "$", "this", "->", "getPhone", "(", ")", ")", ";", "$", "copyObj", "->", "setMemo", "(", "$", "this", "->", "getMemo", "(", ")", ")", ";", "$", "copyObj", "->", "setActivated", "(", "$", "this", "->", "getActivated", "(", ")", ")", ";", "$", "copyObj", "->", "setLastLogin", "(", "$", "this", "->", "getLastLogin", "(", ")", ")", ";", "$", "copyObj", "->", "setNotificationChange", "(", "$", "this", "->", "getNotificationChange", "(", ")", ")", ";", "$", "copyObj", "->", "setNotificationError", "(", "$", "this", "->", "getNotificationError", "(", ")", ")", ";", "if", "(", "$", "deepCopy", "&&", "!", "$", "this", "->", "startCopy", ")", "{", "// important: temporarily setNew(false) because this affects the behavior of", "// the getter/setter methods for fkey referrer objects.", "$", "copyObj", "->", "setNew", "(", "false", ")", ";", "// store object hash to prevent cycle", "$", "this", "->", "startCopy", "=", "true", ";", "foreach", "(", "$", "this", "->", "getUserCustomerRelations", "(", ")", "as", "$", "relObj", ")", "{", "if", "(", "$", "relObj", "!==", "$", "this", ")", "{", "// ensure that we don't try to copy a reference to ourselves", "$", "copyObj", "->", "addUserCustomerRelation", "(", "$", "relObj", "->", "copy", "(", "$", "deepCopy", ")", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "getUserRoles", "(", ")", "as", "$", "relObj", ")", "{", "if", "(", "$", "relObj", "!==", "$", "this", ")", "{", "// ensure that we don't try to copy a reference to ourselves", "$", "copyObj", "->", "addUserRole", "(", "$", "relObj", "->", "copy", "(", "$", "deepCopy", ")", ")", ";", "}", "}", "//unflag object copy", "$", "this", "->", "startCopy", "=", "false", ";", "}", "// if ($deepCopy)", "if", "(", "$", "makeNew", ")", "{", "$", "copyObj", "->", "setNew", "(", "true", ")", ";", "$", "copyObj", "->", "setId", "(", "NULL", ")", ";", "// this is a auto-increment column, so set to default value", "}", "}" ]
Sets contents of passed object to values from current object. If desired, this method can also make copies of all associated (fkey referrers) objects. @param object $copyObj An object of User (or compatible) type. @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. @throws PropelException
[ "Sets", "contents", "of", "passed", "object", "to", "values", "from", "current", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1504-L1546
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.getUserCustomerRelations
public function getUserCustomerRelations($criteria = null, PropelPDO $con = null) { $partial = $this->collUserCustomerRelationsPartial && !$this->isNew(); if (null === $this->collUserCustomerRelations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUserCustomerRelations) { // return empty collection $this->initUserCustomerRelations(); } else { $collUserCustomerRelations = UserCustomerRelationQuery::create(null, $criteria) ->filterByUser($this) ->find($con); if (null !== $criteria) { if (false !== $this->collUserCustomerRelationsPartial && count($collUserCustomerRelations)) { $this->initUserCustomerRelations(false); foreach ($collUserCustomerRelations as $obj) { if (false == $this->collUserCustomerRelations->contains($obj)) { $this->collUserCustomerRelations->append($obj); } } $this->collUserCustomerRelationsPartial = true; } $collUserCustomerRelations->getInternalIterator()->rewind(); return $collUserCustomerRelations; } if ($partial && $this->collUserCustomerRelations) { foreach ($this->collUserCustomerRelations as $obj) { if ($obj->isNew()) { $collUserCustomerRelations[] = $obj; } } } $this->collUserCustomerRelations = $collUserCustomerRelations; $this->collUserCustomerRelationsPartial = false; } } return $this->collUserCustomerRelations; }
php
public function getUserCustomerRelations($criteria = null, PropelPDO $con = null) { $partial = $this->collUserCustomerRelationsPartial && !$this->isNew(); if (null === $this->collUserCustomerRelations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUserCustomerRelations) { // return empty collection $this->initUserCustomerRelations(); } else { $collUserCustomerRelations = UserCustomerRelationQuery::create(null, $criteria) ->filterByUser($this) ->find($con); if (null !== $criteria) { if (false !== $this->collUserCustomerRelationsPartial && count($collUserCustomerRelations)) { $this->initUserCustomerRelations(false); foreach ($collUserCustomerRelations as $obj) { if (false == $this->collUserCustomerRelations->contains($obj)) { $this->collUserCustomerRelations->append($obj); } } $this->collUserCustomerRelationsPartial = true; } $collUserCustomerRelations->getInternalIterator()->rewind(); return $collUserCustomerRelations; } if ($partial && $this->collUserCustomerRelations) { foreach ($this->collUserCustomerRelations as $obj) { if ($obj->isNew()) { $collUserCustomerRelations[] = $obj; } } } $this->collUserCustomerRelations = $collUserCustomerRelations; $this->collUserCustomerRelationsPartial = false; } } return $this->collUserCustomerRelations; }
[ "public", "function", "getUserCustomerRelations", "(", "$", "criteria", "=", "null", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collUserCustomerRelationsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collUserCustomerRelations", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collUserCustomerRelations", ")", "{", "// return empty collection", "$", "this", "->", "initUserCustomerRelations", "(", ")", ";", "}", "else", "{", "$", "collUserCustomerRelations", "=", "UserCustomerRelationQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByUser", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collUserCustomerRelationsPartial", "&&", "count", "(", "$", "collUserCustomerRelations", ")", ")", "{", "$", "this", "->", "initUserCustomerRelations", "(", "false", ")", ";", "foreach", "(", "$", "collUserCustomerRelations", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collUserCustomerRelations", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collUserCustomerRelations", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collUserCustomerRelationsPartial", "=", "true", ";", "}", "$", "collUserCustomerRelations", "->", "getInternalIterator", "(", ")", "->", "rewind", "(", ")", ";", "return", "$", "collUserCustomerRelations", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collUserCustomerRelations", ")", "{", "foreach", "(", "$", "this", "->", "collUserCustomerRelations", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collUserCustomerRelations", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collUserCustomerRelations", "=", "$", "collUserCustomerRelations", ";", "$", "this", "->", "collUserCustomerRelationsPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collUserCustomerRelations", ";", "}" ]
Gets an array of UserCustomerRelation objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this User is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param PropelPDO $con optional connection object @return PropelObjectCollection|UserCustomerRelation[] List of UserCustomerRelation objects @throws PropelException
[ "Gets", "an", "array", "of", "UserCustomerRelation", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1669-L1712
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.countUserCustomerRelations
public function countUserCustomerRelations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collUserCustomerRelationsPartial && !$this->isNew(); if (null === $this->collUserCustomerRelations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUserCustomerRelations) { return 0; } if ($partial && !$criteria) { return count($this->getUserCustomerRelations()); } $query = UserCustomerRelationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByUser($this) ->count($con); } return count($this->collUserCustomerRelations); }
php
public function countUserCustomerRelations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collUserCustomerRelationsPartial && !$this->isNew(); if (null === $this->collUserCustomerRelations || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUserCustomerRelations) { return 0; } if ($partial && !$criteria) { return count($this->getUserCustomerRelations()); } $query = UserCustomerRelationQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByUser($this) ->count($con); } return count($this->collUserCustomerRelations); }
[ "public", "function", "countUserCustomerRelations", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collUserCustomerRelationsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collUserCustomerRelations", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collUserCustomerRelations", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getUserCustomerRelations", "(", ")", ")", ";", "}", "$", "query", "=", "UserCustomerRelationQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByUser", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collUserCustomerRelations", ")", ";", "}" ]
Returns the number of related UserCustomerRelation objects. @param Criteria $criteria @param boolean $distinct @param PropelPDO $con @return int Count of related UserCustomerRelation objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "UserCustomerRelation", "objects", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1755-L1777