repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
taion809/GuerrillaMail
src/GuerrillaMail/GuerrillaMail.php
GuerrillaMail.forgetMe
public function forgetMe($email_address) { $action = "forget_me"; $options = array( 'email_addr' => $email_address, 'sid_token' => $this->sid_token ); return $this->client->post($action, $options); }
php
public function forgetMe($email_address) { $action = "forget_me"; $options = array( 'email_addr' => $email_address, 'sid_token' => $this->sid_token ); return $this->client->post($action, $options); }
[ "public", "function", "forgetMe", "(", "$", "email_address", ")", "{", "$", "action", "=", "\"forget_me\"", ";", "$", "options", "=", "array", "(", "'email_addr'", "=>", "$", "email_address", ",", "'sid_token'", "=>", "$", "this", "->", "sid_token", ")", "...
Forget users email and sid_token @param $email_address @return bool
[ "Forget", "users", "email", "and", "sid_token" ]
a0b3c7c605a0d0572f57caddc589206598f4266f
https://github.com/taion809/GuerrillaMail/blob/a0b3c7c605a0d0572f57caddc589206598f4266f/src/GuerrillaMail/GuerrillaMail.php#L148-L157
train
thisdata/thisdata-php
src/Endpoint/EventsEndpoint.php
EventsEndpoint.trackLogIn
public function trackLogIn($ip, array $user, $userAgent = null, array $source = null, array $session = null, array $device = null) { $this->trackEvent(self::VERB_LOG_IN, $ip, $user, $userAgent, $source, $session, $device); }
php
public function trackLogIn($ip, array $user, $userAgent = null, array $source = null, array $session = null, array $device = null) { $this->trackEvent(self::VERB_LOG_IN, $ip, $user, $userAgent, $source, $session, $device); }
[ "public", "function", "trackLogIn", "(", "$", "ip", ",", "array", "$", "user", ",", "$", "userAgent", "=", "null", ",", "array", "$", "source", "=", "null", ",", "array", "$", "session", "=", "null", ",", "array", "$", "device", "=", "null", ")", "...
Track the successful authentication of a client. @param string $ip The IP address of the client logging in @param array $user An array containing id, and optionally name, email, mobile @param string|null $userAgent The browser user agent of the client logging in @param array|null $source Source details (e.g. for multi-tenanted applications) @param array|null $session Extra information that provides useful context about the session, for example the session ID, or some cookie information @param array|null $device Information about the device being used
[ "Track", "the", "successful", "authentication", "of", "a", "client", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Endpoint/EventsEndpoint.php#L30-L33
train
thisdata/thisdata-php
src/Endpoint/EventsEndpoint.php
EventsEndpoint.trackLogInDenied
public function trackLogInDenied($ip, array $user = null, $userAgent = null, array $source = null, array $session = null, array $device = null) { $this->trackEvent(self::VERB_LOG_IN_DENIED, $ip, $user, $userAgent, $source, $session, $device); }
php
public function trackLogInDenied($ip, array $user = null, $userAgent = null, array $source = null, array $session = null, array $device = null) { $this->trackEvent(self::VERB_LOG_IN_DENIED, $ip, $user, $userAgent, $source, $session, $device); }
[ "public", "function", "trackLogInDenied", "(", "$", "ip", ",", "array", "$", "user", "=", "null", ",", "$", "userAgent", "=", "null", ",", "array", "$", "source", "=", "null", ",", "array", "$", "session", "=", "null", ",", "array", "$", "device", "=...
Track the unsuccessful authentication of a client. @param string $ip The IP address of the client logging in @param array|null $user An optional array containing id, and optionally name, email, mobile. @param string|null $userAgent The browser user agent of the client logging in @param array|null $source Source details (e.g. for multi-tenanted applications) @param array|null $session Extra information that provides useful context about the session, for example the session ID, or some cookie information @param array|null $device Information about the device being used
[ "Track", "the", "unsuccessful", "authentication", "of", "a", "client", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Endpoint/EventsEndpoint.php#L45-L48
train
thisdata/thisdata-php
src/Endpoint/EventsEndpoint.php
EventsEndpoint.trackEvent
public function trackEvent($verb, $ip, array $user = null, $userAgent = null, array $source = null, array $session = null, array $device = null) { $event = [ self::PARAM_VERB => $verb, self::PARAM_IP => $ip ]; if (!is_null($userAgent)) { $event[self::PARAM_USER_AGENT] = $userAgent; } if (!is_null($user)) { $event[self::PARAM_USER] = array_filter([ self::PARAM_USER__ID => $this->findValue(self::PARAM_USER__ID, $user), self::PARAM_USER__NAME => $this->findValue(self::PARAM_USER__NAME, $user), self::PARAM_USER__EMAIL => $this->findValue(self::PARAM_USER__EMAIL, $user), self::PARAM_USER__MOBILE => $this->findValue(self::PARAM_USER__MOBILE, $user), self::PARAM_USER__AUTHENTICATED => $this->findValue(self::PARAM_USER__AUTHENTICATED, $user), ]); } if (!is_null($source)) { $event[self::PARAM_SOURCE] = array_filter([ self::PARAM_SOURCE__NAME => $this->findValue(self::PARAM_SOURCE__NAME, $source), self::PARAM_SOURCE__LOGO_URL => $this->findValue(self::PARAM_SOURCE__LOGO_URL, $source) ]); } // Add information about the session // First, the session ID if it's passed $event[self::PARAM_SESSION] = array_filter([ self::PARAM_SESSION__ID => $this->findValue(self::PARAM_SESSION__ID, $session) ]); // Then pull the TD cookie if its present if (isset($_COOKIE[ThisData::TD_COOKIE_NAME])) { $event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_ID] = $_COOKIE[ThisData::TD_COOKIE_NAME]; } // Then whether we expect the JS Cookie at all if ($this->configuration[Builder::CONF_EXPECT_JS_COOKIE]) { $event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_EXPECTED] = $this->configuration[Builder::CONF_EXPECT_JS_COOKIE]; } if (!is_null($device)) { $event[self::PARAM_DEVICE] = array_filter([ self::PARAM_DEVICE__ID => $this->findValue(self::PARAM_DEVICE__ID, $device) ]); } $this->execute('POST', ThisData::ENDPOINT_EVENTS, array_filter($event)); }
php
public function trackEvent($verb, $ip, array $user = null, $userAgent = null, array $source = null, array $session = null, array $device = null) { $event = [ self::PARAM_VERB => $verb, self::PARAM_IP => $ip ]; if (!is_null($userAgent)) { $event[self::PARAM_USER_AGENT] = $userAgent; } if (!is_null($user)) { $event[self::PARAM_USER] = array_filter([ self::PARAM_USER__ID => $this->findValue(self::PARAM_USER__ID, $user), self::PARAM_USER__NAME => $this->findValue(self::PARAM_USER__NAME, $user), self::PARAM_USER__EMAIL => $this->findValue(self::PARAM_USER__EMAIL, $user), self::PARAM_USER__MOBILE => $this->findValue(self::PARAM_USER__MOBILE, $user), self::PARAM_USER__AUTHENTICATED => $this->findValue(self::PARAM_USER__AUTHENTICATED, $user), ]); } if (!is_null($source)) { $event[self::PARAM_SOURCE] = array_filter([ self::PARAM_SOURCE__NAME => $this->findValue(self::PARAM_SOURCE__NAME, $source), self::PARAM_SOURCE__LOGO_URL => $this->findValue(self::PARAM_SOURCE__LOGO_URL, $source) ]); } // Add information about the session // First, the session ID if it's passed $event[self::PARAM_SESSION] = array_filter([ self::PARAM_SESSION__ID => $this->findValue(self::PARAM_SESSION__ID, $session) ]); // Then pull the TD cookie if its present if (isset($_COOKIE[ThisData::TD_COOKIE_NAME])) { $event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_ID] = $_COOKIE[ThisData::TD_COOKIE_NAME]; } // Then whether we expect the JS Cookie at all if ($this->configuration[Builder::CONF_EXPECT_JS_COOKIE]) { $event[self::PARAM_SESSION][self::PARAM_SESSION__TD_COOKIE_EXPECTED] = $this->configuration[Builder::CONF_EXPECT_JS_COOKIE]; } if (!is_null($device)) { $event[self::PARAM_DEVICE] = array_filter([ self::PARAM_DEVICE__ID => $this->findValue(self::PARAM_DEVICE__ID, $device) ]); } $this->execute('POST', ThisData::ENDPOINT_EVENTS, array_filter($event)); }
[ "public", "function", "trackEvent", "(", "$", "verb", ",", "$", "ip", ",", "array", "$", "user", "=", "null", ",", "$", "userAgent", "=", "null", ",", "array", "$", "source", "=", "null", ",", "array", "$", "session", "=", "null", ",", "array", "$"...
Tracks an event using the ThisData API. @param string $verb Describes what the User did, using an English present tense verb @param string $ip The IP address of the client logging in @param array|null $user An optional array containing id, and optionally name, email, mobile. @param string|null $userAgent The browser user agent of the client logging in @param array|null $source Source details (e.g. for multi-tenanted applications) @param array|null $session Extra information that provides useful context about the session, for example the session ID, or some cookie information @param array|null $device Information about the device being used @see AbstractEndpoint Predefined VERB_ constants
[ "Tracks", "an", "event", "using", "the", "ThisData", "API", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Endpoint/EventsEndpoint.php#L61-L108
train
thisdata/thisdata-php
src/Endpoint/EventsEndpoint.php
EventsEndpoint.getEvents
public function getEvents(array $options = null) { $url = ThisData::ENDPOINT_EVENTS; if (!is_null($options)) { $url .= '?' . http_build_query($options); } $response = $this->synchronousExecute('GET', $url); return json_decode($response->getBody(), TRUE); }
php
public function getEvents(array $options = null) { $url = ThisData::ENDPOINT_EVENTS; if (!is_null($options)) { $url .= '?' . http_build_query($options); } $response = $this->synchronousExecute('GET', $url); return json_decode($response->getBody(), TRUE); }
[ "public", "function", "getEvents", "(", "array", "$", "options", "=", "null", ")", "{", "$", "url", "=", "ThisData", "::", "ENDPOINT_EVENTS", ";", "if", "(", "!", "is_null", "(", "$", "options", ")", ")", "{", "$", "url", ".=", "'?'", ".", "http_buil...
Fetches events from the ThisData API. @param array|null $options An array of request parameters for filtering and paginating over events @see http://help.thisdata.com/docs/v1getevents for request parameters @return array An array of arrays
[ "Fetches", "events", "from", "the", "ThisData", "API", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Endpoint/EventsEndpoint.php#L116-L124
train
contao-community-alliance/translator
src/TranslatorInitializer.php
TranslatorInitializer.initialize
public function initialize(TranslatorInterface $translator) { $event = new CreateTranslatorEvent($translator); $this->eventDispatcher->dispatch($event::NAME, $event); return $translator; }
php
public function initialize(TranslatorInterface $translator) { $event = new CreateTranslatorEvent($translator); $this->eventDispatcher->dispatch($event::NAME, $event); return $translator; }
[ "public", "function", "initialize", "(", "TranslatorInterface", "$", "translator", ")", "{", "$", "event", "=", "new", "CreateTranslatorEvent", "(", "$", "translator", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "$", "event", "::", ...
Initialize the translator. @param TranslatorInterface $translator The translator being initiliazed. @return TranslatorInterface
[ "Initialize", "the", "translator", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/TranslatorInitializer.php#L58-L64
train
nyeholt/silverstripe-news
code/pages/NewsArticle.php
NewsArticle.onBeforeWrite
public function onBeforeWrite() { parent::onBeforeWrite(); // dummy initial date if (!$this->OriginalPublishedDate) { // @TODO Fix this to be correctly localized!! $this->OriginalPublishedDate = date('Y-m-d 12:00:00'); } $parent = $this->Parent(); // just in case we've been moved, update our section $section = $this->findSection(); $this->NewsSectionID = $section->ID; $newlyCreated = $section->ID == $parent->ID; $changedPublishDate = $this->isChanged('OriginalPublishedDate', 2); if (($changedPublishDate || $newlyCreated) && ($section->AutoFiling || $section->FilingMode)) { if (!$this->Created) { $this->Created = date('Y-m-d H:i:s'); } $pp = $this->PartitionParent(); if ($pp->ID != $this->ParentID) { $this->ParentID = $pp->ID; } } }
php
public function onBeforeWrite() { parent::onBeforeWrite(); // dummy initial date if (!$this->OriginalPublishedDate) { // @TODO Fix this to be correctly localized!! $this->OriginalPublishedDate = date('Y-m-d 12:00:00'); } $parent = $this->Parent(); // just in case we've been moved, update our section $section = $this->findSection(); $this->NewsSectionID = $section->ID; $newlyCreated = $section->ID == $parent->ID; $changedPublishDate = $this->isChanged('OriginalPublishedDate', 2); if (($changedPublishDate || $newlyCreated) && ($section->AutoFiling || $section->FilingMode)) { if (!$this->Created) { $this->Created = date('Y-m-d H:i:s'); } $pp = $this->PartitionParent(); if ($pp->ID != $this->ParentID) { $this->ParentID = $pp->ID; } } }
[ "public", "function", "onBeforeWrite", "(", ")", "{", "parent", "::", "onBeforeWrite", "(", ")", ";", "// dummy initial date", "if", "(", "!", "$", "this", "->", "OriginalPublishedDate", ")", "{", "// @TODO Fix this to be correctly localized!!", "$", "this", "->", ...
When the article is saved, and this article's section dictates that it needs to be filed, then do so
[ "When", "the", "article", "is", "saved", "and", "this", "article", "s", "section", "dictates", "that", "it", "needs", "to", "be", "filed", "then", "do", "so" ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsArticle.php#L64-L92
train
nyeholt/silverstripe-news
code/pages/NewsArticle.php
NewsArticle.publishSection
protected function publishSection() { $parent = DataObject::get_by_id('NewsHolder', $this->ParentID); while ($parent && $parent instanceof NewsHolder) { if (!$parent->isPublished()) { $parent->doPublish(); } $parent = $parent->Parent(); } }
php
protected function publishSection() { $parent = DataObject::get_by_id('NewsHolder', $this->ParentID); while ($parent && $parent instanceof NewsHolder) { if (!$parent->isPublished()) { $parent->doPublish(); } $parent = $parent->Parent(); } }
[ "protected", "function", "publishSection", "(", ")", "{", "$", "parent", "=", "DataObject", "::", "get_by_id", "(", "'NewsHolder'", ",", "$", "this", "->", "ParentID", ")", ";", "while", "(", "$", "parent", "&&", "$", "parent", "instanceof", "NewsHolder", ...
Ensure's the section is published. We need to do it both before and after publish because of some quirks with folders not existing on one but existing on the other depending on the order of writing the objects
[ "Ensure", "s", "the", "section", "is", "published", "." ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsArticle.php#L113-L121
train
nyeholt/silverstripe-news
code/pages/NewsArticle.php
NewsArticle.Link
public function Link($action='') { if (strlen($this->ExternalURL) && !strlen($this->Content)) { // redirect away return $this->ExternalURL; } if ($this->InternalFile()->ID) { $file = $this->InternalFile(); return $file->Link($action); } return parent::Link($action); }
php
public function Link($action='') { if (strlen($this->ExternalURL) && !strlen($this->Content)) { // redirect away return $this->ExternalURL; } if ($this->InternalFile()->ID) { $file = $this->InternalFile(); return $file->Link($action); } return parent::Link($action); }
[ "public", "function", "Link", "(", "$", "action", "=", "''", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "ExternalURL", ")", "&&", "!", "strlen", "(", "$", "this", "->", "Content", ")", ")", "{", "// redirect away", "return", "$", "this", ...
Link to the news article. If it has an external URL set, or a file, link to that instead. @param String $action @return String
[ "Link", "to", "the", "news", "article", ".", "If", "it", "has", "an", "external", "URL", "set", "or", "a", "file", "link", "to", "that", "instead", "." ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsArticle.php#L172-L182
train
nyeholt/silverstripe-news
code/pages/NewsArticle.php
NewsArticle.pagesAffectedByChanges
public function pagesAffectedByChanges() { $parent = $this->Parent(); $urls = array($this->Link()); // add all parent (holders) while($parent && $parent->ParentID > -1 && $parent instanceof NewsHolder) { $urls[] = $parent->Link(); $parent = $parent->Parent(); } $this->extend('updatePagesAffectedByChanges', $urls); return $urls; }
php
public function pagesAffectedByChanges() { $parent = $this->Parent(); $urls = array($this->Link()); // add all parent (holders) while($parent && $parent->ParentID > -1 && $parent instanceof NewsHolder) { $urls[] = $parent->Link(); $parent = $parent->Parent(); } $this->extend('updatePagesAffectedByChanges', $urls); return $urls; }
[ "public", "function", "pagesAffectedByChanges", "(", ")", "{", "$", "parent", "=", "$", "this", "->", "Parent", "(", ")", ";", "$", "urls", "=", "array", "(", "$", "this", "->", "Link", "(", ")", ")", ";", "// add all parent (holders)", "while", "(", "...
Pages to update cache file for static publisher @return Array
[ "Pages", "to", "update", "cache", "file", "for", "static", "publisher" ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsArticle.php#L190-L203
train
tinymighty/skinny
includes/Layout.php
Layout.renderZone
protected function renderZone($zone, $args=array()){ $sep = isset($args['seperator']) ? $args['seperator'] : ' '; if($this->debug===true){ echo "\n\n".'<!-- Template Zone: '.$zone.' -->'; } $content = ''; if(isset($this->content[$zone])){ foreach($this->content[$zone] as $item){ switch($item['type']){ case 'hook': //method will be called with two arrays as arguments //the first is the args passed to this method (ie. in a template call to $this->insert() ) //the second are the args passed when the hook was bound $content .= call_user_func_array($item['hook'], array($args, $item['arguments'])); break; case 'html': $content .= $sep . (string) $item['html']; break; case 'template': $content .= $this->renderTemplate($item['template'], $item['params']); break; case 'zone': $content .= $this->renderZone($item['zone'], $item['params']); break; } } } //content from #movetoskin and #skintemplate if( \Skinny::hasContent($zone) ){ foreach(\Skinny::getContent($zone) as $item){ //pre-rendered html from #movetoskin if(isset($item['html'])){ if($this->debug===true){ $content.='<!--Skinny:MoveToSkin: '.$template.'-->'; } $content .= $sep . $item['html']; } else //a template name to render if(isset($item['template'])){ if($this->debug===true){ $content.='<!--Skinny:Template (via #skintemplate): '.$item['template'].'-->'; } $content .= $this->renderTemplate( $item['template'], $item['params'] ); } } } return $content; }
php
protected function renderZone($zone, $args=array()){ $sep = isset($args['seperator']) ? $args['seperator'] : ' '; if($this->debug===true){ echo "\n\n".'<!-- Template Zone: '.$zone.' -->'; } $content = ''; if(isset($this->content[$zone])){ foreach($this->content[$zone] as $item){ switch($item['type']){ case 'hook': //method will be called with two arrays as arguments //the first is the args passed to this method (ie. in a template call to $this->insert() ) //the second are the args passed when the hook was bound $content .= call_user_func_array($item['hook'], array($args, $item['arguments'])); break; case 'html': $content .= $sep . (string) $item['html']; break; case 'template': $content .= $this->renderTemplate($item['template'], $item['params']); break; case 'zone': $content .= $this->renderZone($item['zone'], $item['params']); break; } } } //content from #movetoskin and #skintemplate if( \Skinny::hasContent($zone) ){ foreach(\Skinny::getContent($zone) as $item){ //pre-rendered html from #movetoskin if(isset($item['html'])){ if($this->debug===true){ $content.='<!--Skinny:MoveToSkin: '.$template.'-->'; } $content .= $sep . $item['html']; } else //a template name to render if(isset($item['template'])){ if($this->debug===true){ $content.='<!--Skinny:Template (via #skintemplate): '.$item['template'].'-->'; } $content .= $this->renderTemplate( $item['template'], $item['params'] ); } } } return $content; }
[ "protected", "function", "renderZone", "(", "$", "zone", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "sep", "=", "isset", "(", "$", "args", "[", "'seperator'", "]", ")", "?", "$", "args", "[", "'seperator'", "]", ":", "' '", ";", "if...
Render zone content, optionally passing arguments to provide to object methods
[ "Render", "zone", "content", "optionally", "passing", "arguments", "to", "provide", "to", "object", "methods" ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Layout.php#L121-L173
train
tinymighty/skinny
includes/Layout.php
Layout.addHookTo
public function addHookTo($zone, $hook, Array $args=array()){ if(!isset($this->content[$zone])){ $this->content[$zone] = array(); } //allow just a string reference to a method on this skin object if (!is_array($hook) && method_exists($this, $hook)) { $hook = array($this, $hook); } if (!is_callable($hook, false, $callbable_name)) { throw new \Exception('Invalid skin content hook for zone:'.$zone.' (Hook callback was: '.$callbable_name.')'); } $this->content[$zone][] = array('type'=>'hook', 'hook'=>$hook, 'arguments'=>$args); }
php
public function addHookTo($zone, $hook, Array $args=array()){ if(!isset($this->content[$zone])){ $this->content[$zone] = array(); } //allow just a string reference to a method on this skin object if (!is_array($hook) && method_exists($this, $hook)) { $hook = array($this, $hook); } if (!is_callable($hook, false, $callbable_name)) { throw new \Exception('Invalid skin content hook for zone:'.$zone.' (Hook callback was: '.$callbable_name.')'); } $this->content[$zone][] = array('type'=>'hook', 'hook'=>$hook, 'arguments'=>$args); }
[ "public", "function", "addHookTo", "(", "$", "zone", ",", "$", "hook", ",", "Array", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "content", "[", "$", "zone", "]", ")", ")", "{", "$", "this", ...
Add the result of a function callback to a zone eg. add('before:content', array('methodName', $obj)) add('before:content', 'methodOnThisObject')
[ "Add", "the", "result", "of", "a", "function", "callback", "to", "a", "zone" ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Layout.php#L183-L195
train
tinymighty/skinny
includes/Layout.php
Layout.addTemplateTo
public function addTemplateTo($zone, $template, Array $params=array()){ if(!isset($this->content[$zone])) $this->content[$zone] = array(); $this->content[$zone][] = array('type'=>'template', 'template'=>$template, 'params'=>$params); }
php
public function addTemplateTo($zone, $template, Array $params=array()){ if(!isset($this->content[$zone])) $this->content[$zone] = array(); $this->content[$zone][] = array('type'=>'template', 'template'=>$template, 'params'=>$params); }
[ "public", "function", "addTemplateTo", "(", "$", "zone", ",", "$", "template", ",", "Array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "content", "[", "$", "zone", "]", ")", ")", "$", "this"...
Render the output of a template to a zone eg. add('before:content', 'template-name')
[ "Render", "the", "output", "of", "a", "template", "to", "a", "zone" ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Layout.php#L202-L206
train
tinymighty/skinny
includes/Layout.php
Layout.addHTMLTo
public function addHTMLTo($zone, $content){ if(!isset($this->content[$zone])) $this->content[$zone] = array(); $this->content[$zone][] = array('type'=>'html', 'html'=>$content); }
php
public function addHTMLTo($zone, $content){ if(!isset($this->content[$zone])) $this->content[$zone] = array(); $this->content[$zone][] = array('type'=>'html', 'html'=>$content); }
[ "public", "function", "addHTMLTo", "(", "$", "zone", ",", "$", "content", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "content", "[", "$", "zone", "]", ")", ")", "$", "this", "->", "content", "[", "$", "zone", "]", "=", "array", ...
Add html content to a zone eg. add('before:content', '<h2>Some html content</h2>')
[ "Add", "html", "content", "to", "a", "zone" ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Layout.php#L213-L217
train
tinymighty/skinny
includes/Layout.php
Layout.addZoneTo
public function addZoneTo($zone, $name, Array $params=array()){ if(!isset($this->content[$zone])) $this->content[$zone] = array(); $this->content[$zone][] = array('type'=>'zone', 'zone'=>$name, 'params'=>$params); }
php
public function addZoneTo($zone, $name, Array $params=array()){ if(!isset($this->content[$zone])) $this->content[$zone] = array(); $this->content[$zone][] = array('type'=>'zone', 'zone'=>$name, 'params'=>$params); }
[ "public", "function", "addZoneTo", "(", "$", "zone", ",", "$", "name", ",", "Array", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "content", "[", "$", "zone", "]", ")", ")", "$", "this", "->"...
Add a zone to a zone. Allows adding zones without editing template files. eg. add('before:content', 'zone name')
[ "Add", "a", "zone", "to", "a", "zone", ".", "Allows", "adding", "zones", "without", "editing", "template", "files", "." ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Layout.php#L224-L228
train
irazasyed/laravel-identicon
src/Irazasyed/LaravelIdenticon/Identicon.php
Identicon.displayImage
public function displayImage($string, $size = 64, $color = null, $backgroundColor = null) { $imageData = $this->getImageData($string, $size, $color, $backgroundColor); return Response::make($imageData, 200, ['Content-Type' => 'image/png']); }
php
public function displayImage($string, $size = 64, $color = null, $backgroundColor = null) { $imageData = $this->getImageData($string, $size, $color, $backgroundColor); return Response::make($imageData, 200, ['Content-Type' => 'image/png']); }
[ "public", "function", "displayImage", "(", "$", "string", ",", "$", "size", "=", "64", ",", "$", "color", "=", "null", ",", "$", "backgroundColor", "=", "null", ")", "{", "$", "imageData", "=", "$", "this", "->", "getImageData", "(", "$", "string", "...
Laravel Response Wrapper to Display an Identicon image. @param string $string @param int $size @param string $color @param string $backgroundColor @return \Response Display Identicon PNG Image.
[ "Laravel", "Response", "Wrapper", "to", "Display", "an", "Identicon", "image", "." ]
e6b649413c88d17227daa78674ba76f0dd31fa89
https://github.com/irazasyed/laravel-identicon/blob/e6b649413c88d17227daa78674ba76f0dd31fa89/src/Irazasyed/LaravelIdenticon/Identicon.php#L19-L24
train
nyeholt/silverstripe-solr
code/model/SolrResultSet.php
SolrResultSet.getResult
public function getResult() { if (!$this->result && $this->response && $this->response->getHttpStatus() >= 200 && $this->response->getHttpStatus() < 300) { // decode the response $this->result = json_decode($this->response->getRawResponse()); } return $this->result; }
php
public function getResult() { if (!$this->result && $this->response && $this->response->getHttpStatus() >= 200 && $this->response->getHttpStatus() < 300) { // decode the response $this->result = json_decode($this->response->getRawResponse()); } return $this->result; }
[ "public", "function", "getResult", "(", ")", "{", "if", "(", "!", "$", "this", "->", "result", "&&", "$", "this", "->", "response", "&&", "$", "this", "->", "response", "->", "getHttpStatus", "(", ")", ">=", "200", "&&", "$", "this", "->", "response"...
Gets the raw result set as an object graph. This is effectively the results as sent from solre
[ "Gets", "the", "raw", "result", "set", "as", "an", "object", "graph", "." ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/model/SolrResultSet.php#L102-L109
train
nyeholt/silverstripe-solr
code/model/SolrResultSet.php
SolrResultSet.inflateRawResult
protected function inflateRawResult($doc, $convertToObject = true) { $field = SolrSearchService::SERIALIZED_OBJECT . '_t'; if (isset($doc->$field) && $convertToObject) { $raw = unserialize($doc->$field); if (isset($raw['SS_TYPE'])) { $class = $raw['SS_TYPE']; $object = Injector::inst()->create($class); $object->update($raw); $object->ID = str_replace(SolrSearchService::RAW_DATA_KEY, '', $doc->id); return $object; } return ArrayData::create($raw); } $data = array( 'ID' => str_replace(SolrSearchService::RAW_DATA_KEY, '', $doc->id), ); if (isset($doc->attr_SS_URL[0])) { $data['Link'] = $doc->attr_SS_URL[0]; } if (isset($doc->title)) { $data['Title'] = $doc->title; } if (isset($doc->title_as)) { $data['Title'] = $doc->title_as; } foreach ($doc as $key => $val) { if ($key != 'attr_SS_URL') { $name = null; if (strpos($key, 'attr_') === 0) { $name = str_replace('attr_', '', $key); } else if (preg_match('/(.*?)_('. implode('|', self::$solr_attrs) .')$/', $key, $matches)) { $name = $matches[1]; } $val = $doc->$key; if (is_array($val) && count($val) == 1) { $data[$name] = $val[0]; } else { $data[$name] = $val; } } } return ArrayData::create($data); }
php
protected function inflateRawResult($doc, $convertToObject = true) { $field = SolrSearchService::SERIALIZED_OBJECT . '_t'; if (isset($doc->$field) && $convertToObject) { $raw = unserialize($doc->$field); if (isset($raw['SS_TYPE'])) { $class = $raw['SS_TYPE']; $object = Injector::inst()->create($class); $object->update($raw); $object->ID = str_replace(SolrSearchService::RAW_DATA_KEY, '', $doc->id); return $object; } return ArrayData::create($raw); } $data = array( 'ID' => str_replace(SolrSearchService::RAW_DATA_KEY, '', $doc->id), ); if (isset($doc->attr_SS_URL[0])) { $data['Link'] = $doc->attr_SS_URL[0]; } if (isset($doc->title)) { $data['Title'] = $doc->title; } if (isset($doc->title_as)) { $data['Title'] = $doc->title_as; } foreach ($doc as $key => $val) { if ($key != 'attr_SS_URL') { $name = null; if (strpos($key, 'attr_') === 0) { $name = str_replace('attr_', '', $key); } else if (preg_match('/(.*?)_('. implode('|', self::$solr_attrs) .')$/', $key, $matches)) { $name = $matches[1]; } $val = $doc->$key; if (is_array($val) && count($val) == 1) { $data[$name] = $val[0]; } else { $data[$name] = $val; } } } return ArrayData::create($data); }
[ "protected", "function", "inflateRawResult", "(", "$", "doc", ",", "$", "convertToObject", "=", "true", ")", "{", "$", "field", "=", "SolrSearchService", "::", "SERIALIZED_OBJECT", ".", "'_t'", ";", "if", "(", "isset", "(", "$", "doc", "->", "$", "field", ...
Inflate a raw result into an object of a particular type If the raw result has a SolrSearchService::SERIALIZED_OBJECT field, and convertToObject is true, that serialized data will be used to create a new object of type $doc['SS_TYPE'] @param array $doc @param boolean $convertToObject
[ "Inflate", "a", "raw", "result", "into", "an", "object", "of", "a", "particular", "type" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/model/SolrResultSet.php#L232-L286
train
nyeholt/silverstripe-solr
code/model/SolrResultSet.php
SolrResultSet.getFacets
public function getFacets() { if ($this->returnedFacets) { return $this->returnedFacets; } $result = $this->getResult(); if (!isset($result->facet_counts)) { return; } if (isset($result->facet_counts->exception)) { // $this->logger->error($result->facet_counts->exception) return array(); } $elems = $result->facet_counts->facet_fields; $facets = array(); foreach ($elems as $field => $values) { $elemVals = array(); foreach ($values as $vname => $vcount) { if ($vname == '_empty_') { continue; } $r = new stdClass; $r->Name = $vname; $r->Query = $vname; $r->Count = $vcount; $elemVals[] = $r; } $facets[$field] = $elemVals; } // see if there's any query facets for things too $query_elems = $result->facet_counts->facet_queries; if ($query_elems) { foreach ($query_elems as $vname => $count) { if ($vname == '_empty_') { continue; } list($field, $query) = explode(':', $vname); $r = new stdClass; $r->Type = 'query'; $r->Name = $vname; $r->Query = $query; $r->Count = $count; $existing = isset($facets[$field]) ? $facets[$field] : array(); $existing[] = $r; $facets[$field] = $existing; } } $this->returnedFacets = $facets; return $this->returnedFacets; }
php
public function getFacets() { if ($this->returnedFacets) { return $this->returnedFacets; } $result = $this->getResult(); if (!isset($result->facet_counts)) { return; } if (isset($result->facet_counts->exception)) { // $this->logger->error($result->facet_counts->exception) return array(); } $elems = $result->facet_counts->facet_fields; $facets = array(); foreach ($elems as $field => $values) { $elemVals = array(); foreach ($values as $vname => $vcount) { if ($vname == '_empty_') { continue; } $r = new stdClass; $r->Name = $vname; $r->Query = $vname; $r->Count = $vcount; $elemVals[] = $r; } $facets[$field] = $elemVals; } // see if there's any query facets for things too $query_elems = $result->facet_counts->facet_queries; if ($query_elems) { foreach ($query_elems as $vname => $count) { if ($vname == '_empty_') { continue; } list($field, $query) = explode(':', $vname); $r = new stdClass; $r->Type = 'query'; $r->Name = $vname; $r->Query = $query; $r->Count = $count; $existing = isset($facets[$field]) ? $facets[$field] : array(); $existing[] = $r; $facets[$field] = $existing; } } $this->returnedFacets = $facets; return $this->returnedFacets; }
[ "public", "function", "getFacets", "(", ")", "{", "if", "(", "$", "this", "->", "returnedFacets", ")", "{", "return", "$", "this", "->", "returnedFacets", ";", "}", "$", "result", "=", "$", "this", "->", "getResult", "(", ")", ";", "if", "(", "!", ...
Gets the details about facets found in this query @return array An array of facet values in the format array( 'field_name' => stdClass { name, count } )
[ "Gets", "the", "details", "about", "facets", "found", "in", "this", "query" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/model/SolrResultSet.php#L302-L359
train
php-xapi/symfony-serializer
src/Serializer.php
Serializer.createSerializer
public static function createSerializer() { $normalizers = array( new AccountNormalizer(), new ActorNormalizer(), new AttachmentNormalizer(), new ContextNormalizer(), new ContextActivitiesNormalizer(), new DefinitionNormalizer(), new DocumentDataNormalizer(), new ExtensionsNormalizer(), new InteractionComponentNormalizer(), new LanguageMapNormalizer(), new ObjectNormalizer(), new ResultNormalizer(), new StatementNormalizer(), new StatementResultNormalizer(), new TimestampNormalizer(), new VerbNormalizer(), new ArrayDenormalizer(), new FilterNullValueNormalizer(new PropertyNormalizer()), new PropertyNormalizer(), ); $encoders = array( new JsonEncoder(), ); return new SymfonySerializer($normalizers, $encoders); }
php
public static function createSerializer() { $normalizers = array( new AccountNormalizer(), new ActorNormalizer(), new AttachmentNormalizer(), new ContextNormalizer(), new ContextActivitiesNormalizer(), new DefinitionNormalizer(), new DocumentDataNormalizer(), new ExtensionsNormalizer(), new InteractionComponentNormalizer(), new LanguageMapNormalizer(), new ObjectNormalizer(), new ResultNormalizer(), new StatementNormalizer(), new StatementResultNormalizer(), new TimestampNormalizer(), new VerbNormalizer(), new ArrayDenormalizer(), new FilterNullValueNormalizer(new PropertyNormalizer()), new PropertyNormalizer(), ); $encoders = array( new JsonEncoder(), ); return new SymfonySerializer($normalizers, $encoders); }
[ "public", "static", "function", "createSerializer", "(", ")", "{", "$", "normalizers", "=", "array", "(", "new", "AccountNormalizer", "(", ")", ",", "new", "ActorNormalizer", "(", ")", ",", "new", "AttachmentNormalizer", "(", ")", ",", "new", "ContextNormalize...
Creates a new Serializer. @return SerializerInterface The Serializer
[ "Creates", "a", "new", "Serializer", "." ]
d363aaa98171d3e4d4a541f7b921d3f95ffab897
https://github.com/php-xapi/symfony-serializer/blob/d363aaa98171d3e4d4a541f7b921d3f95ffab897/src/Serializer.php#L50-L78
train
orchestral/control
src/Http/Controllers/AuthorizationController.php
AuthorizationController.sync
public function sync(Authorization $processor, $vendor, $package = null) { return $processor->sync($this, $vendor, $package); }
php
public function sync(Authorization $processor, $vendor, $package = null) { return $processor->sync($this, $vendor, $package); }
[ "public", "function", "sync", "(", "Authorization", "$", "processor", ",", "$", "vendor", ",", "$", "package", "=", "null", ")", "{", "return", "$", "processor", "->", "sync", "(", "$", "this", ",", "$", "vendor", ",", "$", "package", ")", ";", "}" ]
Get sync roles action. @param \Orchestra\Control\Processors\Authorization $processor @param string $vendor @param string|null $package @return mixed
[ "Get", "sync", "roles", "action", "." ]
7c23db19373adbb0fe44491af12f370ba6547d2a
https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Http/Controllers/AuthorizationController.php#L57-L60
train
orchestral/control
src/Http/Controllers/AuthorizationController.php
AuthorizationController.updateSucceed
public function updateSucceed($metric) { \resolve(Synchronizer::class)->handle(); $message = \trans('orchestra/control::response.acls.update'); return $this->redirectWithMessage( \handles("orchestra::control/acl?name={$metric}"), $message ); }
php
public function updateSucceed($metric) { \resolve(Synchronizer::class)->handle(); $message = \trans('orchestra/control::response.acls.update'); return $this->redirectWithMessage( \handles("orchestra::control/acl?name={$metric}"), $message ); }
[ "public", "function", "updateSucceed", "(", "$", "metric", ")", "{", "\\", "resolve", "(", "Synchronizer", "::", "class", ")", "->", "handle", "(", ")", ";", "$", "message", "=", "\\", "trans", "(", "'orchestra/control::response.acls.update'", ")", ";", "ret...
Response when ACL is updated. @param string $metric @return mixed
[ "Response", "when", "ACL", "is", "updated", "." ]
7c23db19373adbb0fe44491af12f370ba6547d2a
https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Http/Controllers/AuthorizationController.php#L83-L92
train
PlasmaPHP/core
src/Types/AbstractTypeExtension.php
AbstractTypeExtension.canHandleType
function canHandleType($value, ?\Plasma\ColumnDefinitionInterface $column): bool { $cb = $this->filter; return $cb($value, $column); }
php
function canHandleType($value, ?\Plasma\ColumnDefinitionInterface $column): bool { $cb = $this->filter; return $cb($value, $column); }
[ "function", "canHandleType", "(", "$", "value", ",", "?", "\\", "Plasma", "\\", "ColumnDefinitionInterface", "$", "column", ")", ":", "bool", "{", "$", "cb", "=", "$", "this", "->", "filter", ";", "return", "$", "cb", "(", "$", "value", ",", "$", "co...
Whether the type extension can handle the conversion of the passed value. Before this method is used, the common types are checked first. `class` -> `interface` -> `type` -> this. @param mixed $value @param \Plasma\ColumnDefinitionInterface|null $column @return bool
[ "Whether", "the", "type", "extension", "can", "handle", "the", "conversion", "of", "the", "passed", "value", ".", "Before", "this", "method", "is", "used", "the", "common", "types", "are", "checked", "first", ".", "class", "-", ">", "interface", "-", ">", ...
ce9b1a206e3777f3cf884eec5eee686a073ddfb2
https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/Types/AbstractTypeExtension.php#L51-L54
train
QuickenLoans/mcp-common
src/Time/TimePoint.php
TimePoint.compare
public function compare(TimePoint $timepoint) { $first = $this->date; $second = $this->timePointToDateTime($timepoint); if ($first < $second) { return -1; } if ($first > $second) { return 1; } return 0; }
php
public function compare(TimePoint $timepoint) { $first = $this->date; $second = $this->timePointToDateTime($timepoint); if ($first < $second) { return -1; } if ($first > $second) { return 1; } return 0; }
[ "public", "function", "compare", "(", "TimePoint", "$", "timepoint", ")", "{", "$", "first", "=", "$", "this", "->", "date", ";", "$", "second", "=", "$", "this", "->", "timePointToDateTime", "(", "$", "timepoint", ")", ";", "if", "(", "$", "first", ...
Compares two points in time @param TimePoint $timepoint The point in time to compare $this with. @return int Returns -1, 0 or 1 if $this is less than, equal to or greater than $timepoint respectively.
[ "Compares", "two", "points", "in", "time" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/Time/TimePoint.php#L143-L154
train
craigh411/FileUploader
src/FileUploader.php
FileUploader.file
public function file(UploadedFile $file) { $this->file = $file; $this->filename = $file->getClientOriginalName(); $this->sanitizeFilename(); return $this; }
php
public function file(UploadedFile $file) { $this->file = $file; $this->filename = $file->getClientOriginalName(); $this->sanitizeFilename(); return $this; }
[ "public", "function", "file", "(", "UploadedFile", "$", "file", ")", "{", "$", "this", "->", "file", "=", "$", "file", ";", "$", "this", "->", "filename", "=", "$", "file", "->", "getClientOriginalName", "(", ")", ";", "$", "this", "->", "sanitizeFilen...
Sets the uploaded file to be validated and moved @param UploadedFile $file @return mixed
[ "Sets", "the", "uploaded", "file", "to", "be", "validated", "and", "moved" ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L46-L53
train
craigh411/FileUploader
src/FileUploader.php
FileUploader.move
public function move() { // Make sure the filename is unique if makeFilenameUnique is set to true if($this->makeFilenameUnique) { $this->getUniqueFilename(); } if($this->_validate()) { // Validation passed so create any directories and move the tmp file to the specified location. $this->_createDirs(); if($this->file->isValid()) { // This will also perform some validations on the upload. $this->file->move($this->uploadDir, $this->filename); } else { throw new Exception($this->file->getErrorMessage()); } } return $this->getUploadPath(); }
php
public function move() { // Make sure the filename is unique if makeFilenameUnique is set to true if($this->makeFilenameUnique) { $this->getUniqueFilename(); } if($this->_validate()) { // Validation passed so create any directories and move the tmp file to the specified location. $this->_createDirs(); if($this->file->isValid()) { // This will also perform some validations on the upload. $this->file->move($this->uploadDir, $this->filename); } else { throw new Exception($this->file->getErrorMessage()); } } return $this->getUploadPath(); }
[ "public", "function", "move", "(", ")", "{", "// Make sure the filename is unique if makeFilenameUnique is set to true", "if", "(", "$", "this", "->", "makeFilenameUnique", ")", "{", "$", "this", "->", "getUniqueFilename", "(", ")", ";", "}", "if", "(", "$", "this...
Validates and moves the uploaded file to it's destination @return String
[ "Validates", "and", "moves", "the", "uploaded", "file", "to", "it", "s", "destination" ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L94-L117
train
craigh411/FileUploader
src/FileUploader.php
FileUploader.getUniqueFilename
public function getUniqueFilename() { $pathInfo = pathinfo($this->filename); $filename = $pathInfo['filename']; $extension = $pathInfo['extension']; $increment = 1; while($this->fileExists($filename . "_" . $increment, $extension)) { $increment++; } $this->filename = $filename . "_" . $increment . '.' . $extension; return $this; }
php
public function getUniqueFilename() { $pathInfo = pathinfo($this->filename); $filename = $pathInfo['filename']; $extension = $pathInfo['extension']; $increment = 1; while($this->fileExists($filename . "_" . $increment, $extension)) { $increment++; } $this->filename = $filename . "_" . $increment . '.' . $extension; return $this; }
[ "public", "function", "getUniqueFilename", "(", ")", "{", "$", "pathInfo", "=", "pathinfo", "(", "$", "this", "->", "filename", ")", ";", "$", "filename", "=", "$", "pathInfo", "[", "'filename'", "]", ";", "$", "extension", "=", "$", "pathInfo", "[", "...
Returns a unique file name for the upload by appending a sequential number. Checks to make sure file doesn't exist before returning a name. @return String
[ "Returns", "a", "unique", "file", "name", "for", "the", "upload", "by", "appending", "a", "sequential", "number", ".", "Checks", "to", "make", "sure", "file", "doesn", "t", "exist", "before", "returning", "a", "name", "." ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L123-L136
train
craigh411/FileUploader
src/FileUploader.php
FileUploader._validate
private function _validate() { $this->checkOverwritePermission(); $this->checkHasValidUploadDirectory(); $this->checkFileSize(); $this->checkFileTypeIsAllowed(); $this->checkFileTypeIsNotBlocked(); return true; }
php
private function _validate() { $this->checkOverwritePermission(); $this->checkHasValidUploadDirectory(); $this->checkFileSize(); $this->checkFileTypeIsAllowed(); $this->checkFileTypeIsNotBlocked(); return true; }
[ "private", "function", "_validate", "(", ")", "{", "$", "this", "->", "checkOverwritePermission", "(", ")", ";", "$", "this", "->", "checkHasValidUploadDirectory", "(", ")", ";", "$", "this", "->", "checkFileSize", "(", ")", ";", "$", "this", "->", "checkF...
Validates the upload against the specified options. @return bool @throws DirectoryNotFoundException @throws FileSizeTooLargeException @throws InvalidFileTypeException @throws NoOverwritePermissionException
[ "Validates", "the", "upload", "against", "the", "specified", "options", "." ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L146-L155
train
craigh411/FileUploader
src/FileUploader.php
FileUploader.checkFileTypeIsAllowed
private function checkFileTypeIsAllowed() { if(count($this->allowedMimeTypes) > 0) { if(! in_array($this->file->getMimeType(), $this->allowedMimeTypes)) { throw new InvalidFileTypeException("Invalid File Type: " . $this->file->getMimeType() . " has not been allowed"); } } }
php
private function checkFileTypeIsAllowed() { if(count($this->allowedMimeTypes) > 0) { if(! in_array($this->file->getMimeType(), $this->allowedMimeTypes)) { throw new InvalidFileTypeException("Invalid File Type: " . $this->file->getMimeType() . " has not been allowed"); } } }
[ "private", "function", "checkFileTypeIsAllowed", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "allowedMimeTypes", ")", ">", "0", ")", "{", "if", "(", "!", "in_array", "(", "$", "this", "->", "file", "->", "getMimeType", "(", ")", ",", "...
Checks that the file type is allowed, if none specified then all non-blocked file types will be accepted @throws InvalidFileTypeException
[ "Checks", "that", "the", "file", "type", "is", "allowed", "if", "none", "specified", "then", "all", "non", "-", "blocked", "file", "types", "will", "be", "accepted" ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L238-L247
train
craigh411/FileUploader
src/FileUploader.php
FileUploader.checkFileTypeIsNotBlocked
private function checkFileTypeIsNotBlocked() { if(in_array($this->file->getMimeType(), $this->blockedMimeTypes)) { throw new InvalidFileTypeException("Invalid File Type: " . $this->file->getMimeType() . " type has been blocked"); } }
php
private function checkFileTypeIsNotBlocked() { if(in_array($this->file->getMimeType(), $this->blockedMimeTypes)) { throw new InvalidFileTypeException("Invalid File Type: " . $this->file->getMimeType() . " type has been blocked"); } }
[ "private", "function", "checkFileTypeIsNotBlocked", "(", ")", "{", "if", "(", "in_array", "(", "$", "this", "->", "file", "->", "getMimeType", "(", ")", ",", "$", "this", "->", "blockedMimeTypes", ")", ")", "{", "throw", "new", "InvalidFileTypeException", "(...
Validate blocked MIME types, this can be used instead of allowed_mime_types, to block uploads of specific file types. @throws InvalidFileTypeException
[ "Validate", "blocked", "MIME", "types", "this", "can", "be", "used", "instead", "of", "allowed_mime_types", "to", "block", "uploads", "of", "specific", "file", "types", "." ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L255-L261
train
craigh411/FileUploader
src/FileUploader.php
FileUploader.uploadDir
public function uploadDir($dir) { $this->uploadDir = $dir; if(! $this->hasTrailingSlash()) { $this->uploadDir .= "/"; } return $this; }
php
public function uploadDir($dir) { $this->uploadDir = $dir; if(! $this->hasTrailingSlash()) { $this->uploadDir .= "/"; } return $this; }
[ "public", "function", "uploadDir", "(", "$", "dir", ")", "{", "$", "this", "->", "uploadDir", "=", "$", "dir", ";", "if", "(", "!", "$", "this", "->", "hasTrailingSlash", "(", ")", ")", "{", "$", "this", "->", "uploadDir", ".=", "\"/\"", ";", "}", ...
Sets the upload directory @param string $path @return FileUploader
[ "Sets", "the", "upload", "directory" ]
ffafed24875140012b5d703416cfd804bc3f80d0
https://github.com/craigh411/FileUploader/blob/ffafed24875140012b5d703416cfd804bc3f80d0/src/FileUploader.php#L268-L277
train
ynloultratech/graphql-bundle
src/Behat/Context/GraphQLContext.php
GraphQLContext.theOperationInFile
public function theOperationInFile($filename) { $queryFile = sprintf('%s%s%s', self::$currentFeatureFile->getPath(), DIRECTORY_SEPARATOR, $filename); if (file_exists($queryFile)) { $file = new File($queryFile); $this->client->setGraphQL(file_get_contents($file->getPathname())); } else { throw new FileNotFoundException(null, 0, null, $queryFile); } }
php
public function theOperationInFile($filename) { $queryFile = sprintf('%s%s%s', self::$currentFeatureFile->getPath(), DIRECTORY_SEPARATOR, $filename); if (file_exists($queryFile)) { $file = new File($queryFile); $this->client->setGraphQL(file_get_contents($file->getPathname())); } else { throw new FileNotFoundException(null, 0, null, $queryFile); } }
[ "public", "function", "theOperationInFile", "(", "$", "filename", ")", "{", "$", "queryFile", "=", "sprintf", "(", "'%s%s%s'", ",", "self", "::", "$", "currentFeatureFile", "->", "getPath", "(", ")", ",", "DIRECTORY_SEPARATOR", ",", "$", "filename", ")", ";"...
Find for a file to read the GraphQL query the file must not contains more than one query Example: Given the operation in file 'some_query.graphql' @Given /^the operation in file "([^"]*)"$/
[ "Find", "for", "a", "file", "to", "read", "the", "GraphQL", "query", "the", "file", "must", "not", "contains", "more", "than", "one", "query" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Context/GraphQLContext.php#L92-L101
train
ynloultratech/graphql-bundle
src/Behat/Context/GraphQLContext.php
GraphQLContext.theOperationNamedInFile
public function theOperationNamedInFile($queryName, $file) { // TODO: add support for fragments // if a fragment is not used in some operation in the same file a error is thrown $this->theOperationInFile($file); $this->operationName = $queryName; if ($this->client->getGraphQL()) { // remove non necessary operations to avoid errors with unsettled variables $pattern = '/(query|mutation|subscription)\s+(?!'.$queryName.'\s*[\({])(.+\n)+}\n*/'; $this->client->setGraphQL(preg_replace($pattern, null, $this->client->getGraphQL())); } if ($queryName) { if (strpos($this->client->getGraphQL(), $queryName) === false) { throw new \RuntimeException(sprintf('Does not exist any operation called "%s" in "%s"', $queryName, $file)); } } }
php
public function theOperationNamedInFile($queryName, $file) { // TODO: add support for fragments // if a fragment is not used in some operation in the same file a error is thrown $this->theOperationInFile($file); $this->operationName = $queryName; if ($this->client->getGraphQL()) { // remove non necessary operations to avoid errors with unsettled variables $pattern = '/(query|mutation|subscription)\s+(?!'.$queryName.'\s*[\({])(.+\n)+}\n*/'; $this->client->setGraphQL(preg_replace($pattern, null, $this->client->getGraphQL())); } if ($queryName) { if (strpos($this->client->getGraphQL(), $queryName) === false) { throw new \RuntimeException(sprintf('Does not exist any operation called "%s" in "%s"', $queryName, $file)); } } }
[ "public", "function", "theOperationNamedInFile", "(", "$", "queryName", ",", "$", "file", ")", "{", "// TODO: add support for fragments", "// if a fragment is not used in some operation in the same file a error is thrown", "$", "this", "->", "theOperationInFile", "(", "$", "fil...
Find for specific query name in given file. The file can contain multiple named queries. Example: Given the operation named "GetUser" in file 'queries.graphql' @Given /^the operation named "([^"]*)" in file "([^"]*)"$/
[ "Find", "for", "specific", "query", "name", "in", "given", "file", ".", "The", "file", "can", "contain", "multiple", "named", "queries", "." ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Context/GraphQLContext.php#L111-L129
train
ynloultratech/graphql-bundle
src/Behat/Context/GraphQLContext.php
GraphQLContext.setVariableEqualTo
public function setVariableEqualTo($path, $value) { $accessor = new PropertyAccessor(); $variables = $this->client->getVariables(); $accessor->setValue($variables, sprintf("[%s]", $path), $value); $this->client->setVariables($variables); }
php
public function setVariableEqualTo($path, $value) { $accessor = new PropertyAccessor(); $variables = $this->client->getVariables(); $accessor->setValue($variables, sprintf("[%s]", $path), $value); $this->client->setVariables($variables); }
[ "public", "function", "setVariableEqualTo", "(", "$", "path", ",", "$", "value", ")", "{", "$", "accessor", "=", "new", "PropertyAccessor", "(", ")", ";", "$", "variables", "=", "$", "this", "->", "client", "->", "getVariables", "(", ")", ";", "$", "ac...
Set query variable with scalar value before run the given query Example: And variable "username" is "admin" Example: And variable "limit" is 2 Example: And variable "visible" is true Example: And variable "orderBy" is { [{field:'login', direction: 'DESC'}] } @Given /^variable "([^"]*)" is "?([^"]*)"?$/
[ "Set", "query", "variable", "with", "scalar", "value", "before", "run", "the", "given", "query" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Context/GraphQLContext.php#L168-L174
train
ynloultratech/graphql-bundle
src/Behat/Context/GraphQLContext.php
GraphQLContext.debugLastQuery
public function debugLastQuery() { if ($this->client->getGraphQL()) { /** @var Response $response */ $response = $this->client->getResponse(); $content = $response->getContent(); $json = @json_decode($content, true); $error = $response->getStatusCode() >= 400; if ($json && isset($json['errors'])) { $error = true; } $bg = $error ? 41 : 42; print_r("\n\n"); print_r("\033[{$bg}m-------------------- RESPONSE ----------------------\033[0m\n\n"); print_r(sprintf("STATUS: [%s] %s \n", $response->getStatusCode(), Response::$statusTexts[$response->getStatusCode()] ?? 'Unknown Status')); if ($json) { $output = json_encode($json, JSON_PRETTY_PRINT); } else { $output = $content; } print_r($output); print_r("\n\n"); print_r("\033[46m------------------- VARIABLES-----------------------\033[0m\n\n"); $variables = $this->client->getVariables() ?? null; print_r(json_encode($variables, JSON_PRETTY_PRINT)); $query = $this->client->getGraphQL() ?? null; $type = 'QUERY'; if (preg_match('/^\s*mutation/', $query)) { $type = 'MUTATION'; } print_r("\n\n\033[43m----------------------- $type ---------------------\033[0m\n\n"); print_r($query ?? null); print_r("\n\n"); print_r("-----------------------------------------------------\n\n"); ob_flush(); } else { throw new \RuntimeException('Does not exist any executed query on current test, try use this method after "send" the query.'); } }
php
public function debugLastQuery() { if ($this->client->getGraphQL()) { /** @var Response $response */ $response = $this->client->getResponse(); $content = $response->getContent(); $json = @json_decode($content, true); $error = $response->getStatusCode() >= 400; if ($json && isset($json['errors'])) { $error = true; } $bg = $error ? 41 : 42; print_r("\n\n"); print_r("\033[{$bg}m-------------------- RESPONSE ----------------------\033[0m\n\n"); print_r(sprintf("STATUS: [%s] %s \n", $response->getStatusCode(), Response::$statusTexts[$response->getStatusCode()] ?? 'Unknown Status')); if ($json) { $output = json_encode($json, JSON_PRETTY_PRINT); } else { $output = $content; } print_r($output); print_r("\n\n"); print_r("\033[46m------------------- VARIABLES-----------------------\033[0m\n\n"); $variables = $this->client->getVariables() ?? null; print_r(json_encode($variables, JSON_PRETTY_PRINT)); $query = $this->client->getGraphQL() ?? null; $type = 'QUERY'; if (preg_match('/^\s*mutation/', $query)) { $type = 'MUTATION'; } print_r("\n\n\033[43m----------------------- $type ---------------------\033[0m\n\n"); print_r($query ?? null); print_r("\n\n"); print_r("-----------------------------------------------------\n\n"); ob_flush(); } else { throw new \RuntimeException('Does not exist any executed query on current test, try use this method after "send" the query.'); } }
[ "public", "function", "debugLastQuery", "(", ")", "{", "if", "(", "$", "this", "->", "client", "->", "getGraphQL", "(", ")", ")", "{", "/** @var Response $response */", "$", "response", "=", "$", "this", "->", "client", "->", "getResponse", "(", ")", ";", ...
Print helpful debug information for latest executed query @Then debug last query
[ "Print", "helpful", "debug", "information", "for", "latest", "executed", "query" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Context/GraphQLContext.php#L205-L252
train
contao-community-alliance/translator
src/Contao/ContaoTranslatorFactory.php
ContaoTranslatorFactory.createService
public function createService() { $translator = new TranslatorChain(); $translator->add(new LangArrayTranslator($this->dispatcher)); $initializer = new TranslatorInitializer($this->dispatcher); return $initializer->initialize($translator); }
php
public function createService() { $translator = new TranslatorChain(); $translator->add(new LangArrayTranslator($this->dispatcher)); $initializer = new TranslatorInitializer($this->dispatcher); return $initializer->initialize($translator); }
[ "public", "function", "createService", "(", ")", "{", "$", "translator", "=", "new", "TranslatorChain", "(", ")", ";", "$", "translator", "->", "add", "(", "new", "LangArrayTranslator", "(", "$", "this", "->", "dispatcher", ")", ")", ";", "$", "initializer...
Create the translator service. @return \ContaoCommunityAlliance\Translator\TranslatorInterface
[ "Create", "the", "translator", "service", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/Contao/ContaoTranslatorFactory.php#L52-L61
train
tlapnet/report
src/Bridges/Nette/Components/Render/SubreportRenderControl.php
SubreportRenderControl.load
private function load(): void { // Skip if it's already loaded if ($this->state === self::STATE_LOADED) return; // Attach parameters (only if we have some) if ($this->parameters !== []) { // Attach parameters to form $this['parametersForm']->setDefaults($this->parameters); // Attach parameters to subreport $this->subreport->attach($this->parameters); } // Compile (fetch data) $this->subreport->compile(); // Preprocess (only if it is not already) if (!$this->subreport->isState(Subreport::STATE_PREPROCESSED)) { $this->subreport->preprocess(); } // Change inner state $this->state = self::STATE_LOADED; }
php
private function load(): void { // Skip if it's already loaded if ($this->state === self::STATE_LOADED) return; // Attach parameters (only if we have some) if ($this->parameters !== []) { // Attach parameters to form $this['parametersForm']->setDefaults($this->parameters); // Attach parameters to subreport $this->subreport->attach($this->parameters); } // Compile (fetch data) $this->subreport->compile(); // Preprocess (only if it is not already) if (!$this->subreport->isState(Subreport::STATE_PREPROCESSED)) { $this->subreport->preprocess(); } // Change inner state $this->state = self::STATE_LOADED; }
[ "private", "function", "load", "(", ")", ":", "void", "{", "// Skip if it's already loaded", "if", "(", "$", "this", "->", "state", "===", "self", "::", "STATE_LOADED", ")", "return", ";", "// Attach parameters (only if we have some)", "if", "(", "$", "this", "-...
Compile, preprocess and attach subreport
[ "Compile", "preprocess", "and", "attach", "subreport" ]
6852caf0d78422888795432242128d9ce6c491e2
https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Bridges/Nette/Components/Render/SubreportRenderControl.php#L116-L140
train
ekyna/Dpd
src/Pudo/Client.php
Client.call
public function call(string $method, array $arguments): Response { try { return $this->request('GET', $method, [ 'query' => $arguments ]); } catch (\Exception $e) { throw new ClientException($e->getMessage(), $e->getCode(), $e); } }
php
public function call(string $method, array $arguments): Response { try { return $this->request('GET', $method, [ 'query' => $arguments ]); } catch (\Exception $e) { throw new ClientException($e->getMessage(), $e->getCode(), $e); } }
[ "public", "function", "call", "(", "string", "$", "method", ",", "array", "$", "arguments", ")", ":", "Response", "{", "try", "{", "return", "$", "this", "->", "request", "(", "'GET'", ",", "$", "method", ",", "[", "'query'", "=>", "$", "arguments", ...
Performs the http call. @param string $method @param array $arguments @return Response @throws ClientException
[ "Performs", "the", "http", "call", "." ]
67eabcff840b310021d5ca7ebb824fa7d7cb700b
https://github.com/ekyna/Dpd/blob/67eabcff840b310021d5ca7ebb824fa7d7cb700b/src/Pudo/Client.php#L84-L93
train
thisdata/thisdata-php
src/Client.php
Client.getHandlerStack
protected function getHandlerStack() { $handlerStack = HandlerStack::create($this->getHandler()); $this->configureHandlerStack($handlerStack); return $handlerStack; }
php
protected function getHandlerStack() { $handlerStack = HandlerStack::create($this->getHandler()); $this->configureHandlerStack($handlerStack); return $handlerStack; }
[ "protected", "function", "getHandlerStack", "(", ")", "{", "$", "handlerStack", "=", "HandlerStack", "::", "create", "(", "$", "this", "->", "getHandler", "(", ")", ")", ";", "$", "this", "->", "configureHandlerStack", "(", "$", "handlerStack", ")", ";", "...
Return the stack of handlers and middlewares responsible for processing requests. @return HandlerStack
[ "Return", "the", "stack", "of", "handlers", "and", "middlewares", "responsible", "for", "processing", "requests", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Client.php#L82-L89
train
thisdata/thisdata-php
src/Client.php
Client.getApiKeyMiddleware
protected function getApiKeyMiddleware() { $handleRequest = function (RequestInterface $request) { return $request->withUri(Uri::withQueryValue( $request->getUri(), static::PARAM_API_KEY, $this->apiKey )); }; return Middleware::mapRequest($handleRequest); }
php
protected function getApiKeyMiddleware() { $handleRequest = function (RequestInterface $request) { return $request->withUri(Uri::withQueryValue( $request->getUri(), static::PARAM_API_KEY, $this->apiKey )); }; return Middleware::mapRequest($handleRequest); }
[ "protected", "function", "getApiKeyMiddleware", "(", ")", "{", "$", "handleRequest", "=", "function", "(", "RequestInterface", "$", "request", ")", "{", "return", "$", "request", "->", "withUri", "(", "Uri", "::", "withQueryValue", "(", "$", "request", "->", ...
Return the Guzzle Middleware responsible for ensuring the API key is always present in a request. @return callable
[ "Return", "the", "Guzzle", "Middleware", "responsible", "for", "ensuring", "the", "API", "key", "is", "always", "present", "in", "a", "request", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/Client.php#L107-L118
train
figdice/figdice
src/figdice/classes/tags/TagFigTrans.php
TagFigTrans.fig_trans
private function fig_trans(Context $context) { //If a @source attribute is specified, and is equal to //the view's target language, then don't bother translating: //just render the contents. //However, even if the fig:trans tag does not specify a "source" attribute, //we may look up the optional default trans source attribute //defined at the template level. $source = $this->getAttribute('source', $context->getView()->defaultTransSource); //The $key is also needed in logging below, even if //source = view's language, in case of missing value, //so this is a good time to read it. $key = $this->getAttribute('key', null); $dictionaryName = $this->getAttribute('dict', null); // Do we have a dictionary ? $dictionary = $context->getDictionary($dictionaryName); // Maybe not, but at this stage it is not important, I only need // to know its source $dicSource = ($dictionary ? $dictionary->getSource() : null); if ( ( (null == $source) && //no source on the trans tag ($dicSource == $context->getView()->getLanguage()) ) || ($source == $context->getView()->getLanguage()) ) { $context->pushDoNotRenderFigParams(); $value = $this->renderChildren($context /*Do not render fig:param immediate children */); $context->popDoNotRenderFigParams(); } else { //Cross-language dictionary mechanism: if(null == $key) { //Missing @key attribute : consider the text contents as the key. //throw new SyntaxErrorException($this->getCurrentFile()->getFilename(), $this->xmlLineNumber, $this->name, 'Missing @key attribute.'); $key = $this->renderChildren($context); } //Ask current context to translate key: $value = $context->translate($key, $dictionaryName); } //Fetch the parameters specified as immediate children //of the macro call : <fig:param name="" value=""/> //TODO: Currently, the <fig:param> of a macro call cannot hold any fig:cond or fig:case conditions. $arguments = array(); foreach ($this->children as $child) { if($child instanceof ViewElementTag) { if($child->name == $context->view->figNamespace . 'param') { //If param is specified with an immediate value="" attribute : if(isset($child->attributes['value'])) { $arguments[$child->attributes['name']] = $this->evaluate($context, $child->attributes['value']); } //otherwise, the actual value is not scalar but is //a nodeset in itself. Let's pre-render it and use it as text for the argument. else { $arguments[$child->attributes['name']] = $child->render($context); } } } } //We must now perform the replacements of the parameters of the translation, //which are written in the shape : {paramName} //and are specified as extra attributes of the fig:trans tag, or child fig:param tags //(fig:params override inline attributes). $matches = array(); while(preg_match('/{([^}]+)}/', $value, $matches)) { $attributeName = $matches[1]; //If there is a corresponding fig:param, use it: if(array_key_exists($attributeName, $arguments)) { $attributeValue = $arguments[$attributeName]; } //Otherwise, use the inline attribute. else { $attributeValue = $this->evalAttribute($context, $attributeName); } $value = str_replace('{' . $attributeName . '}', $attributeValue, $value); } //If the translated value is empty (ie. we did find an entry in the proper dictionary file, //but this entry has an empty value), it means that the entry remains to be translated by the person in charge. //So in the meantime we output the key. if($value == '') { $value = $key; // TODO: One might want to be notified, either by an exception or another mechanism (Context logging?). } return $value; }
php
private function fig_trans(Context $context) { //If a @source attribute is specified, and is equal to //the view's target language, then don't bother translating: //just render the contents. //However, even if the fig:trans tag does not specify a "source" attribute, //we may look up the optional default trans source attribute //defined at the template level. $source = $this->getAttribute('source', $context->getView()->defaultTransSource); //The $key is also needed in logging below, even if //source = view's language, in case of missing value, //so this is a good time to read it. $key = $this->getAttribute('key', null); $dictionaryName = $this->getAttribute('dict', null); // Do we have a dictionary ? $dictionary = $context->getDictionary($dictionaryName); // Maybe not, but at this stage it is not important, I only need // to know its source $dicSource = ($dictionary ? $dictionary->getSource() : null); if ( ( (null == $source) && //no source on the trans tag ($dicSource == $context->getView()->getLanguage()) ) || ($source == $context->getView()->getLanguage()) ) { $context->pushDoNotRenderFigParams(); $value = $this->renderChildren($context /*Do not render fig:param immediate children */); $context->popDoNotRenderFigParams(); } else { //Cross-language dictionary mechanism: if(null == $key) { //Missing @key attribute : consider the text contents as the key. //throw new SyntaxErrorException($this->getCurrentFile()->getFilename(), $this->xmlLineNumber, $this->name, 'Missing @key attribute.'); $key = $this->renderChildren($context); } //Ask current context to translate key: $value = $context->translate($key, $dictionaryName); } //Fetch the parameters specified as immediate children //of the macro call : <fig:param name="" value=""/> //TODO: Currently, the <fig:param> of a macro call cannot hold any fig:cond or fig:case conditions. $arguments = array(); foreach ($this->children as $child) { if($child instanceof ViewElementTag) { if($child->name == $context->view->figNamespace . 'param') { //If param is specified with an immediate value="" attribute : if(isset($child->attributes['value'])) { $arguments[$child->attributes['name']] = $this->evaluate($context, $child->attributes['value']); } //otherwise, the actual value is not scalar but is //a nodeset in itself. Let's pre-render it and use it as text for the argument. else { $arguments[$child->attributes['name']] = $child->render($context); } } } } //We must now perform the replacements of the parameters of the translation, //which are written in the shape : {paramName} //and are specified as extra attributes of the fig:trans tag, or child fig:param tags //(fig:params override inline attributes). $matches = array(); while(preg_match('/{([^}]+)}/', $value, $matches)) { $attributeName = $matches[1]; //If there is a corresponding fig:param, use it: if(array_key_exists($attributeName, $arguments)) { $attributeValue = $arguments[$attributeName]; } //Otherwise, use the inline attribute. else { $attributeValue = $this->evalAttribute($context, $attributeName); } $value = str_replace('{' . $attributeName . '}', $attributeValue, $value); } //If the translated value is empty (ie. we did find an entry in the proper dictionary file, //but this entry has an empty value), it means that the entry remains to be translated by the person in charge. //So in the meantime we output the key. if($value == '') { $value = $key; // TODO: One might want to be notified, either by an exception or another mechanism (Context logging?). } return $value; }
[ "private", "function", "fig_trans", "(", "Context", "$", "context", ")", "{", "//If a @source attribute is specified, and is equal to", "//the view's target language, then don't bother translating:", "//just render the contents.", "//However, even if the fig:trans tag does not specify a \"so...
Translates a caption given its key and dictionary name. @param Context $context @return string @throws DictionaryEntryNotFoundException @throws DictionaryNotFoundException @throws \figdice\exceptions\RenderingException
[ "Translates", "a", "caption", "given", "its", "key", "and", "dictionary", "name", "." ]
896bbe3aec365c416e368dcc6b888a6cf1832afc
https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/tags/TagFigTrans.php#L37-L127
train
QuickenLoans/mcp-common
src/GUID.php
GUID.createFromHex
public static function createFromHex($hexString): ?GUID { $hexString = str_replace(static::$searchChars, static::$replaceChars, $hexString); if (!preg_match('/^[0-9A-Fa-f]{32}$/', $hexString)) { return null; } $bin = pack('H*', $hexString); if (!static::validate($bin)) { return null; } return new static($bin); }
php
public static function createFromHex($hexString): ?GUID { $hexString = str_replace(static::$searchChars, static::$replaceChars, $hexString); if (!preg_match('/^[0-9A-Fa-f]{32}$/', $hexString)) { return null; } $bin = pack('H*', $hexString); if (!static::validate($bin)) { return null; } return new static($bin); }
[ "public", "static", "function", "createFromHex", "(", "$", "hexString", ")", ":", "?", "GUID", "{", "$", "hexString", "=", "str_replace", "(", "static", "::", "$", "searchChars", ",", "static", "::", "$", "replaceChars", ",", "$", "hexString", ")", ";", ...
Creates a GUID object from a "hex string" This accepts a strings such as "{9a39ed24-1752-4459-9ac2-6b0e8f0dcec7}" and generates a GUID object. Note that this validates the input string and if validation fails it will return null. @param string $hexString @return GUID|null
[ "Creates", "a", "GUID", "object", "from", "a", "hex", "string" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/GUID.php#L69-L82
train
QuickenLoans/mcp-common
src/GUID.php
GUID.create
public static function create(): GUID { $guid = \random_bytes(16); // Reset version byte to version 4 (0100) $guid[6] = chr(ord($guid[6]) & 0x0f | 0x40); $guid[8] = chr(ord($guid[8]) & 0x3f | 0x80); return new static($guid); }
php
public static function create(): GUID { $guid = \random_bytes(16); // Reset version byte to version 4 (0100) $guid[6] = chr(ord($guid[6]) & 0x0f | 0x40); $guid[8] = chr(ord($guid[8]) & 0x3f | 0x80); return new static($guid); }
[ "public", "static", "function", "create", "(", ")", ":", "GUID", "{", "$", "guid", "=", "\\", "random_bytes", "(", "16", ")", ";", "// Reset version byte to version 4 (0100)", "$", "guid", "[", "6", "]", "=", "chr", "(", "ord", "(", "$", "guid", "[", "...
Creates a new V4 UUID @return GUID
[ "Creates", "a", "new", "V4", "UUID" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/GUID.php#L122-L132
train
QuickenLoans/mcp-common
src/GUID.php
GUID.validate
protected static function validate($guid) { if (ByteString::strlen($guid) !== 16) { return false; } $byte = $guid[6]; $byte = (ord($byte) & 0xF0) >> 4; if ($byte !== 4) { return false; } $byte = $guid[8]; $byte = (ord($byte) & 0xC0); if ($byte !== 0x80) { return false; } return true; }
php
protected static function validate($guid) { if (ByteString::strlen($guid) !== 16) { return false; } $byte = $guid[6]; $byte = (ord($byte) & 0xF0) >> 4; if ($byte !== 4) { return false; } $byte = $guid[8]; $byte = (ord($byte) & 0xC0); if ($byte !== 0x80) { return false; } return true; }
[ "protected", "static", "function", "validate", "(", "$", "guid", ")", "{", "if", "(", "ByteString", "::", "strlen", "(", "$", "guid", ")", "!==", "16", ")", "{", "return", "false", ";", "}", "$", "byte", "=", "$", "guid", "[", "6", "]", ";", "$",...
Validates the given string is a correct byte stream for a GUID. This does some seemingly crazy things, but basically it validates that the given value will be within the set of possible GUID's that GUID::create() can produce. @param string $guid @return bool
[ "Validates", "the", "given", "string", "is", "a", "correct", "byte", "stream", "for", "a", "GUID", "." ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/GUID.php#L144-L165
train
QuickenLoans/mcp-common
src/GUID.php
GUID.format
public function format($format = self::STANDARD) { $hexStr = strtolower($this->asHex()); $parts = [ substr($hexStr, 0, 8), substr($hexStr, 8, 4), substr($hexStr, 12, 4), substr($hexStr, 16, 4), substr($hexStr, 20) ]; if ($format & self::UPPERCASE) { $parts = array_map(function ($v) { return strtoupper($v); }, $parts); } $separator = ''; if ($format & self::HYPHENATED) { $separator = self::SEPERATOR_HYPHEN; } $formatted = implode($separator, $parts); if ($format & self::BRACES) { $formatted = sprintf('{%s}', $formatted); } return $formatted; }
php
public function format($format = self::STANDARD) { $hexStr = strtolower($this->asHex()); $parts = [ substr($hexStr, 0, 8), substr($hexStr, 8, 4), substr($hexStr, 12, 4), substr($hexStr, 16, 4), substr($hexStr, 20) ]; if ($format & self::UPPERCASE) { $parts = array_map(function ($v) { return strtoupper($v); }, $parts); } $separator = ''; if ($format & self::HYPHENATED) { $separator = self::SEPERATOR_HYPHEN; } $formatted = implode($separator, $parts); if ($format & self::BRACES) { $formatted = sprintf('{%s}', $formatted); } return $formatted; }
[ "public", "function", "format", "(", "$", "format", "=", "self", "::", "STANDARD", ")", "{", "$", "hexStr", "=", "strtolower", "(", "$", "this", "->", "asHex", "(", ")", ")", ";", "$", "parts", "=", "[", "substr", "(", "$", "hexStr", ",", "0", ",...
Outputs a 'formatted' version of the GUID string The formatting will currently output something like "{74EC705A-AD08-42A6-BCC5-5B9F93FAB0F4}" as the GUID representation. Example: ```php $guid = GUID::createFromHex('9a39ed24-1752-4459-9ac2-6b0e8f0dcec7'); echo $guid->format(); 9a39ed24175244599ac26b0e8f0dcec7 echo $guid->format(GUID::FORMAT_BRACES | GUID::FORMAT_UPPERCASE); {9a39ed24175244599ac26b0e8f0dcec7} echo $guid->format(0); 9a39ed24175244599ac26b0e8f0dcec7 ``` @param int $format @return string
[ "Outputs", "a", "formatted", "version", "of", "the", "GUID", "string" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/GUID.php#L200-L230
train
QuickenLoans/mcp-common
src/GUID.php
GUID.asHex
public function asHex() { $normalizer = function ($val) { return str_pad(strtoupper(dechex($val)), 2, '0', STR_PAD_LEFT); }; $out = unpack('C*', $this->guid); $out = array_map($normalizer, $out); $out = implode('', $out); return $out; }
php
public function asHex() { $normalizer = function ($val) { return str_pad(strtoupper(dechex($val)), 2, '0', STR_PAD_LEFT); }; $out = unpack('C*', $this->guid); $out = array_map($normalizer, $out); $out = implode('', $out); return $out; }
[ "public", "function", "asHex", "(", ")", "{", "$", "normalizer", "=", "function", "(", "$", "val", ")", "{", "return", "str_pad", "(", "strtoupper", "(", "dechex", "(", "$", "val", ")", ")", ",", "2", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}",...
Outputs the guid as a straight hex string The string will look something like "74EC705AAD0842A6BCC55B9F93FAB0F4". Example: ```php $guid = GUID::createFromHex('9a39ed24-1752-4459-9ac2-6b0e8f0dcec7'); echo $guid->asHex(); 9A39ED24175244599AC26B0E8F0DCEC7 ``` @return string
[ "Outputs", "the", "guid", "as", "a", "straight", "hex", "string" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/GUID.php#L296-L307
train
joomla-framework/console
src/Command/AbstractCommand.php
AbstractCommand.getSynopsis
public function getSynopsis(bool $short = false): string { $key = $short ? 'short' : 'long'; if (!isset($this->synopsis[$key])) { $this->synopsis[$key] = trim(sprintf('%s %s', $this->getName(), $this->getDefinition()->getSynopsis($short))); } return $this->synopsis[$key]; }
php
public function getSynopsis(bool $short = false): string { $key = $short ? 'short' : 'long'; if (!isset($this->synopsis[$key])) { $this->synopsis[$key] = trim(sprintf('%s %s', $this->getName(), $this->getDefinition()->getSynopsis($short))); } return $this->synopsis[$key]; }
[ "public", "function", "getSynopsis", "(", "bool", "$", "short", "=", "false", ")", ":", "string", "{", "$", "key", "=", "$", "short", "?", "'short'", ":", "'long'", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "synopsis", "[", "$", "key", ...
Get the command's synopsis. @param boolean $short Flag indicating whether the short or long version of the synopsis should be returned @return string @since __DEPLOY_VERSION__
[ "Get", "the", "command", "s", "synopsis", "." ]
b8ab98ec0fab96002b22399dea8c2ff206a87380
https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Command/AbstractCommand.php#L381-L391
train
joomla-framework/console
src/Command/AbstractCommand.php
AbstractCommand.setDefinition
public function setDefinition($definition) { if ($definition instanceof InputDefinition) { $this->definition = $definition; } else { $this->definition->setDefinition($definition); } $this->applicationDefinitionMerged = false; }
php
public function setDefinition($definition) { if ($definition instanceof InputDefinition) { $this->definition = $definition; } else { $this->definition->setDefinition($definition); } $this->applicationDefinitionMerged = false; }
[ "public", "function", "setDefinition", "(", "$", "definition", ")", "{", "if", "(", "$", "definition", "instanceof", "InputDefinition", ")", "{", "$", "this", "->", "definition", "=", "$", "definition", ";", "}", "else", "{", "$", "this", "->", "definition...
Sets the input definition for the command. @param array|InputDefinition $definition Either an InputDefinition object or an array of objects to write to the definition. @return void @since __DEPLOY_VERSION__
[ "Sets", "the", "input", "definition", "for", "the", "command", "." ]
b8ab98ec0fab96002b22399dea8c2ff206a87380
https://github.com/joomla-framework/console/blob/b8ab98ec0fab96002b22399dea8c2ff206a87380/src/Command/AbstractCommand.php#L508-L520
train
ynloultratech/graphql-bundle
src/Behat/Deprecation/DeprecationAdviser.php
DeprecationAdviser.dump
public function dump() { $message = ''; if (!empty($this->warnings)) { uasort( $this->warnings, function ($a, $b) { if (count($a) === count($b)) { return 0; } return (count($a) > count($b)) ? -1 : 1; } ); foreach ($this->warnings as $message => $warnings) { $count = count($warnings); print_r(sprintf("\n\033[0;30m\033[43m %sx: %s\033[0m\n", $count, $message)); } } return $message; }
php
public function dump() { $message = ''; if (!empty($this->warnings)) { uasort( $this->warnings, function ($a, $b) { if (count($a) === count($b)) { return 0; } return (count($a) > count($b)) ? -1 : 1; } ); foreach ($this->warnings as $message => $warnings) { $count = count($warnings); print_r(sprintf("\n\033[0;30m\033[43m %sx: %s\033[0m\n", $count, $message)); } } return $message; }
[ "public", "function", "dump", "(", ")", "{", "$", "message", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "warnings", ")", ")", "{", "uasort", "(", "$", "this", "->", "warnings", ",", "function", "(", "$", "a", ",", "$", "b"...
Dump all warning ordered by amount of times triggered
[ "Dump", "all", "warning", "ordered", "by", "amount", "of", "times", "triggered" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Behat/Deprecation/DeprecationAdviser.php#L47-L69
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.read
public function read($path) { $data = $this->readJson($path); $this->validator()->validate($data); return $this->createConfiguration($data); }
php
public function read($path) { $data = $this->readJson($path); $this->validator()->validate($data); return $this->createConfiguration($data); }
[ "public", "function", "read", "(", "$", "path", ")", "{", "$", "data", "=", "$", "this", "->", "readJson", "(", "$", "path", ")", ";", "$", "this", "->", "validator", "(", ")", "->", "validate", "(", "$", "data", ")", ";", "return", "$", "this", ...
Read a Composer configuration file. @param string $path The configuration file path. @return Configuration The parsed configuration. @throws ConfigurationExceptionInterface If there is a problem reading the configuration.
[ "Read", "a", "Composer", "configuration", "file", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L69-L75
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.readJson
protected function readJson($path) { $jsonData = @file_get_contents($path); if (false === $jsonData) { throw new ConfigurationReadException($path); } $data = json_decode($jsonData); $jsonError = json_last_error(); if (JSON_ERROR_NONE !== $jsonError) { throw new InvalidJsonException($path, $jsonError); } return new ObjectAccess($data); }
php
protected function readJson($path) { $jsonData = @file_get_contents($path); if (false === $jsonData) { throw new ConfigurationReadException($path); } $data = json_decode($jsonData); $jsonError = json_last_error(); if (JSON_ERROR_NONE !== $jsonError) { throw new InvalidJsonException($path, $jsonError); } return new ObjectAccess($data); }
[ "protected", "function", "readJson", "(", "$", "path", ")", "{", "$", "jsonData", "=", "@", "file_get_contents", "(", "$", "path", ")", ";", "if", "(", "false", "===", "$", "jsonData", ")", "{", "throw", "new", "ConfigurationReadException", "(", "$", "pa...
Read JSON data from the supplied path. @param string $path The path to read from. @return ObjectAccess The parsed data. @throws ConfigurationExceptionInterface If there is a problem reading the data.
[ "Read", "JSON", "data", "from", "the", "supplied", "path", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L85-L100
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createConfiguration
protected function createConfiguration(ObjectAccess $data) { $autoloadData = new ObjectAccess( $data->getDefault('autoload', (object) array()) ); return new Configuration( $data->getDefault('name'), $data->getDefault('description'), $data->getDefault('version'), $data->getDefault('type'), $data->getDefault('keywords'), $data->getDefault('homepage'), $this->createTime($data->getDefault('time')), $this->arrayize($data->getDefault('license')), $this->createAuthors($data->getDefault('authors')), $this->createSupport($data->getDefault('support')), $this->objectToArray($data->getDefault('require')), $this->objectToArray($data->getDefault('require-dev')), $this->objectToArray($data->getDefault('conflict')), $this->objectToArray($data->getDefault('replace')), $this->objectToArray($data->getDefault('provide')), $this->objectToArray($data->getDefault('suggest')), $this->createAutoloadPsr($autoloadData->getDefault('psr-4')), $this->createAutoloadPsr($autoloadData->getDefault('psr-0')), $autoloadData->getDefault('classmap'), $autoloadData->getDefault('files'), $data->getDefault('include-path'), $data->getDefault('target-dir'), $this->createStability($data->getDefault('minimum-stability')), $data->getDefault('prefer-stable'), $this->createRepositories((array) $data->getDefault('repositories')), $this->createProjectConfiguration($data->getDefault('config')), $this->createScripts($data->getDefault('scripts')), $data->getDefault('extra'), $data->getDefault('bin'), $this->createArchiveConfiguration($data->getDefault('archive')), $data->data() ); }
php
protected function createConfiguration(ObjectAccess $data) { $autoloadData = new ObjectAccess( $data->getDefault('autoload', (object) array()) ); return new Configuration( $data->getDefault('name'), $data->getDefault('description'), $data->getDefault('version'), $data->getDefault('type'), $data->getDefault('keywords'), $data->getDefault('homepage'), $this->createTime($data->getDefault('time')), $this->arrayize($data->getDefault('license')), $this->createAuthors($data->getDefault('authors')), $this->createSupport($data->getDefault('support')), $this->objectToArray($data->getDefault('require')), $this->objectToArray($data->getDefault('require-dev')), $this->objectToArray($data->getDefault('conflict')), $this->objectToArray($data->getDefault('replace')), $this->objectToArray($data->getDefault('provide')), $this->objectToArray($data->getDefault('suggest')), $this->createAutoloadPsr($autoloadData->getDefault('psr-4')), $this->createAutoloadPsr($autoloadData->getDefault('psr-0')), $autoloadData->getDefault('classmap'), $autoloadData->getDefault('files'), $data->getDefault('include-path'), $data->getDefault('target-dir'), $this->createStability($data->getDefault('minimum-stability')), $data->getDefault('prefer-stable'), $this->createRepositories((array) $data->getDefault('repositories')), $this->createProjectConfiguration($data->getDefault('config')), $this->createScripts($data->getDefault('scripts')), $data->getDefault('extra'), $data->getDefault('bin'), $this->createArchiveConfiguration($data->getDefault('archive')), $data->data() ); }
[ "protected", "function", "createConfiguration", "(", "ObjectAccess", "$", "data", ")", "{", "$", "autoloadData", "=", "new", "ObjectAccess", "(", "$", "data", "->", "getDefault", "(", "'autoload'", ",", "(", "object", ")", "array", "(", ")", ")", ")", ";",...
Create a configuration object from the supplied JSON data. @param ObjectAccess $data The parsed JSON data. @return Configuration The newly created configuration object.
[ "Create", "a", "configuration", "object", "from", "the", "supplied", "JSON", "data", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L109-L148
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createAuthors
protected function createAuthors(array $authors = null) { if (null !== $authors) { foreach ($authors as $index => $author) { $authors[$index] = $this->createAuthor( new ObjectAccess($author) ); } } return $authors; }
php
protected function createAuthors(array $authors = null) { if (null !== $authors) { foreach ($authors as $index => $author) { $authors[$index] = $this->createAuthor( new ObjectAccess($author) ); } } return $authors; }
[ "protected", "function", "createAuthors", "(", "array", "$", "authors", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "authors", ")", "{", "foreach", "(", "$", "authors", "as", "$", "index", "=>", "$", "author", ")", "{", "$", "authors", "[",...
Create an author list from the supplied raw value. @param array|null $authors The raw author list data. @return array<integer,Author>|null The newly created author list.
[ "Create", "an", "author", "list", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L173-L184
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createAuthor
protected function createAuthor(ObjectAccess $author) { return new Author( $author->get('name'), $author->getDefault('email'), $author->getDefault('homepage'), $author->getDefault('role'), $author->data() ); }
php
protected function createAuthor(ObjectAccess $author) { return new Author( $author->get('name'), $author->getDefault('email'), $author->getDefault('homepage'), $author->getDefault('role'), $author->data() ); }
[ "protected", "function", "createAuthor", "(", "ObjectAccess", "$", "author", ")", "{", "return", "new", "Author", "(", "$", "author", "->", "get", "(", "'name'", ")", ",", "$", "author", "->", "getDefault", "(", "'email'", ")", ",", "$", "author", "->", ...
Create an author from the supplied raw value. @param ObjectAccess $author The raw author data. @return Author The newly created author.
[ "Create", "an", "author", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L193-L202
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createSupport
protected function createSupport(stdClass $support = null) { if (null !== $support) { $supportData = new ObjectAccess($support); $support = new SupportInformation( $supportData->getDefault('email'), $supportData->getDefault('issues'), $supportData->getDefault('forum'), $supportData->getDefault('wiki'), $supportData->getDefault('irc'), $supportData->getDefault('source'), $supportData->data() ); } return $support; }
php
protected function createSupport(stdClass $support = null) { if (null !== $support) { $supportData = new ObjectAccess($support); $support = new SupportInformation( $supportData->getDefault('email'), $supportData->getDefault('issues'), $supportData->getDefault('forum'), $supportData->getDefault('wiki'), $supportData->getDefault('irc'), $supportData->getDefault('source'), $supportData->data() ); } return $support; }
[ "protected", "function", "createSupport", "(", "stdClass", "$", "support", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "support", ")", "{", "$", "supportData", "=", "new", "ObjectAccess", "(", "$", "support", ")", ";", "$", "support", "=", "n...
Create a support information object from the supplied raw value. @param stdClass|null $support The raw support information. @return SupportInformation|null The newly created support information object.
[ "Create", "a", "support", "information", "object", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L211-L227
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createAutoloadPsr
protected function createAutoloadPsr(stdClass $autoloadPsr = null) { if (null !== $autoloadPsr) { $autoloadPsr = $this->objectToArray($autoloadPsr); foreach ($autoloadPsr as $namespace => $paths) { $autoloadPsr[$namespace] = $this->arrayize($paths); } } return $autoloadPsr; }
php
protected function createAutoloadPsr(stdClass $autoloadPsr = null) { if (null !== $autoloadPsr) { $autoloadPsr = $this->objectToArray($autoloadPsr); foreach ($autoloadPsr as $namespace => $paths) { $autoloadPsr[$namespace] = $this->arrayize($paths); } } return $autoloadPsr; }
[ "protected", "function", "createAutoloadPsr", "(", "stdClass", "$", "autoloadPsr", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "autoloadPsr", ")", "{", "$", "autoloadPsr", "=", "$", "this", "->", "objectToArray", "(", "$", "autoloadPsr", ")", ";"...
Create PSR-style autoload information from the supplied raw value. This method currently works for both PSR-0 and PSR-4 data. @param stdClass|null $autoloadPsr The raw PSR autoload data. @return array<string,array<integer,string>>|null The newly created PSR autoload information.
[ "Create", "PSR", "-", "style", "autoload", "information", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L238-L248
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createStability
protected function createStability($stability) { if (null !== $stability) { $stability = Stability::memberByValue($stability, false); } return $stability; }
php
protected function createStability($stability) { if (null !== $stability) { $stability = Stability::memberByValue($stability, false); } return $stability; }
[ "protected", "function", "createStability", "(", "$", "stability", ")", "{", "if", "(", "null", "!==", "$", "stability", ")", "{", "$", "stability", "=", "Stability", "::", "memberByValue", "(", "$", "stability", ",", "false", ")", ";", "}", "return", "$...
Create a stability enumeration from the supplied raw data. @param string|null $stability The raw stability data. @return Stability|null The newly created stability enumeration.
[ "Create", "a", "stability", "enumeration", "from", "the", "supplied", "raw", "data", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L257-L264
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createRepositories
protected function createRepositories(array $repositories = null) { if (null !== $repositories) { foreach ($repositories as $index => $repository) { $repositories[$index] = $this->createRepository( new ObjectAccess($repository) ); } } return $repositories; }
php
protected function createRepositories(array $repositories = null) { if (null !== $repositories) { foreach ($repositories as $index => $repository) { $repositories[$index] = $this->createRepository( new ObjectAccess($repository) ); } } return $repositories; }
[ "protected", "function", "createRepositories", "(", "array", "$", "repositories", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "repositories", ")", "{", "foreach", "(", "$", "repositories", "as", "$", "index", "=>", "$", "repository", ")", "{", ...
Create a repository list from the supplied raw value. @param array|null $repositories The raw repository list data. @return array<integer,RepositoryInterface>|null The newly created repository list.
[ "Create", "a", "repository", "list", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L273-L284
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createRepository
protected function createRepository(ObjectAccess $repository) { if ($repository->exists('packagist')) { return new PackagistRepository( $repository->get('packagist'), $repository->data() ); } $type = $repository->get('type'); if ('package' === $type) { $repository = new PackageRepository( $this->objectToArray($repository->get('package')), $this->objectToArray($repository->getDefault('options')), $repository->data() ); } else { $repository = new Repository( $type, $repository->getDefault('url'), $this->objectToArray($repository->getDefault('options')), $repository->data() ); } return $repository; }
php
protected function createRepository(ObjectAccess $repository) { if ($repository->exists('packagist')) { return new PackagistRepository( $repository->get('packagist'), $repository->data() ); } $type = $repository->get('type'); if ('package' === $type) { $repository = new PackageRepository( $this->objectToArray($repository->get('package')), $this->objectToArray($repository->getDefault('options')), $repository->data() ); } else { $repository = new Repository( $type, $repository->getDefault('url'), $this->objectToArray($repository->getDefault('options')), $repository->data() ); } return $repository; }
[ "protected", "function", "createRepository", "(", "ObjectAccess", "$", "repository", ")", "{", "if", "(", "$", "repository", "->", "exists", "(", "'packagist'", ")", ")", "{", "return", "new", "PackagistRepository", "(", "$", "repository", "->", "get", "(", ...
Create a repository from the supplied raw value. @param ObjectAccess $repository The raw repository data. @return RepositoryInterface The newly created repository.
[ "Create", "a", "repository", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L293-L320
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createProjectConfiguration
protected function createProjectConfiguration(stdClass $config = null) { if (null === $config) { return new ProjectConfiguration( null, null, null, null, null, null, null, $this->defaultCacheDir() ); } $configData = new ObjectAccess($config); $cacheDir = $configData->getDefault('cache-dir'); if (null === $cacheDir) { $cacheDir = $this->defaultCacheDir(); } return new ProjectConfiguration( $configData->getDefault('process-timeout'), $configData->getDefault('use-include-path'), $this->createInstallationMethod( $configData->getDefault('preferred-install') ), $configData->getDefault('github-protocols'), $this->objectToArray($configData->getDefault('github-oauth')), $configData->getDefault('vendor-dir'), $configData->getDefault('bin-dir'), $cacheDir, $configData->getDefault('cache-files-dir'), $configData->getDefault('cache-repo-dir'), $configData->getDefault('cache-vcs-dir'), $configData->getDefault('cache-files-ttl'), $configData->getDefault('cache-files-maxsize'), $configData->getDefault('prepend-autoloader'), $configData->getDefault('autoloader-suffix'), $configData->getDefault('optimize-autoloader'), $configData->getDefault('github-domains'), $configData->getDefault('notify-on-install'), $this->createVcsChangePolicy( $configData->getDefault('discard-changes') ), $configData->data() ); }
php
protected function createProjectConfiguration(stdClass $config = null) { if (null === $config) { return new ProjectConfiguration( null, null, null, null, null, null, null, $this->defaultCacheDir() ); } $configData = new ObjectAccess($config); $cacheDir = $configData->getDefault('cache-dir'); if (null === $cacheDir) { $cacheDir = $this->defaultCacheDir(); } return new ProjectConfiguration( $configData->getDefault('process-timeout'), $configData->getDefault('use-include-path'), $this->createInstallationMethod( $configData->getDefault('preferred-install') ), $configData->getDefault('github-protocols'), $this->objectToArray($configData->getDefault('github-oauth')), $configData->getDefault('vendor-dir'), $configData->getDefault('bin-dir'), $cacheDir, $configData->getDefault('cache-files-dir'), $configData->getDefault('cache-repo-dir'), $configData->getDefault('cache-vcs-dir'), $configData->getDefault('cache-files-ttl'), $configData->getDefault('cache-files-maxsize'), $configData->getDefault('prepend-autoloader'), $configData->getDefault('autoloader-suffix'), $configData->getDefault('optimize-autoloader'), $configData->getDefault('github-domains'), $configData->getDefault('notify-on-install'), $this->createVcsChangePolicy( $configData->getDefault('discard-changes') ), $configData->data() ); }
[ "protected", "function", "createProjectConfiguration", "(", "stdClass", "$", "config", "=", "null", ")", "{", "if", "(", "null", "===", "$", "config", ")", "{", "return", "new", "ProjectConfiguration", "(", "null", ",", "null", ",", "null", ",", "null", ",...
Create a project configuration object from the supplied raw value. @param stdClass|null $config The raw project configuration data. @return ProjectConfiguration The newly created project configuration object.
[ "Create", "a", "project", "configuration", "object", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L329-L377
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.defaultCacheDir
protected function defaultCacheDir() { $cacheDir = getenv('COMPOSER_CACHE_DIR'); if ($cacheDir) { return $cacheDir; } $home = getenv('COMPOSER_HOME'); $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); if (!$home) { if ($isWindows) { if ($envAppData = getenv('APPDATA')) { $home = strtr($envAppData, '\\', '/') . '/Composer'; } } elseif ($envHome = getenv('HOME')) { $home = rtrim($envHome, '/') . '/.composer'; } } if ($home && !$cacheDir) { if ($isWindows) { if ($cacheDir = getenv('LOCALAPPDATA')) { $cacheDir .= '/Composer'; } else { $cacheDir = $home . '/cache'; } $cacheDir = strtr($cacheDir, '\\', '/'); } else { $cacheDir = $home . '/cache'; } } if (!$cacheDir) { return null; } return $cacheDir; }
php
protected function defaultCacheDir() { $cacheDir = getenv('COMPOSER_CACHE_DIR'); if ($cacheDir) { return $cacheDir; } $home = getenv('COMPOSER_HOME'); $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); if (!$home) { if ($isWindows) { if ($envAppData = getenv('APPDATA')) { $home = strtr($envAppData, '\\', '/') . '/Composer'; } } elseif ($envHome = getenv('HOME')) { $home = rtrim($envHome, '/') . '/.composer'; } } if ($home && !$cacheDir) { if ($isWindows) { if ($cacheDir = getenv('LOCALAPPDATA')) { $cacheDir .= '/Composer'; } else { $cacheDir = $home . '/cache'; } $cacheDir = strtr($cacheDir, '\\', '/'); } else { $cacheDir = $home . '/cache'; } } if (!$cacheDir) { return null; } return $cacheDir; }
[ "protected", "function", "defaultCacheDir", "(", ")", "{", "$", "cacheDir", "=", "getenv", "(", "'COMPOSER_CACHE_DIR'", ")", ";", "if", "(", "$", "cacheDir", ")", "{", "return", "$", "cacheDir", ";", "}", "$", "home", "=", "getenv", "(", "'COMPOSER_HOME'",...
Get the default cache directory for the current environment. @return string|null The default cache directory, or null if the cache directory could not be determined.
[ "Get", "the", "default", "cache", "directory", "for", "the", "current", "environment", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L384-L423
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createInstallationMethod
protected function createInstallationMethod($method) { if (is_string($method)) { return InstallationMethod::memberByValue($method, false); } if (is_object($method)) { $methods = array(); foreach ($method as $project => $projectMethod) { $methods[$project] = InstallationMethod::memberByValue($projectMethod, false); } return $methods; } return null; }
php
protected function createInstallationMethod($method) { if (is_string($method)) { return InstallationMethod::memberByValue($method, false); } if (is_object($method)) { $methods = array(); foreach ($method as $project => $projectMethod) { $methods[$project] = InstallationMethod::memberByValue($projectMethod, false); } return $methods; } return null; }
[ "protected", "function", "createInstallationMethod", "(", "$", "method", ")", "{", "if", "(", "is_string", "(", "$", "method", ")", ")", "{", "return", "InstallationMethod", "::", "memberByValue", "(", "$", "method", ",", "false", ")", ";", "}", "if", "(",...
Create a installation method enumeration from the supplied raw data. @param string|stdClass|null $method The raw installation method data. @return InstallationMethod|array<string,InstallationMethod>|null The processed installation method.
[ "Create", "a", "installation", "method", "enumeration", "from", "the", "supplied", "raw", "data", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L432-L450
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createVcsChangePolicy
protected function createVcsChangePolicy($policy) { if (null !== $policy) { $policy = VcsChangePolicy::memberByValue($policy, false); } return $policy; }
php
protected function createVcsChangePolicy($policy) { if (null !== $policy) { $policy = VcsChangePolicy::memberByValue($policy, false); } return $policy; }
[ "protected", "function", "createVcsChangePolicy", "(", "$", "policy", ")", "{", "if", "(", "null", "!==", "$", "policy", ")", "{", "$", "policy", "=", "VcsChangePolicy", "::", "memberByValue", "(", "$", "policy", ",", "false", ")", ";", "}", "return", "$...
Create a VCS change policy enumeration from the supplied raw data. @param string|null $policy The raw VCS change policy data. @return VcsChangePolicy|null The newly created VCS change policy enumeration.
[ "Create", "a", "VCS", "change", "policy", "enumeration", "from", "the", "supplied", "raw", "data", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L459-L466
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createScripts
protected function createScripts(stdClass $scripts = null) { if (null !== $scripts) { $scriptsData = new ObjectAccess($scripts); $scripts = new ScriptConfiguration( $this->arrayize($scriptsData->getDefault('pre-install-cmd')), $this->arrayize($scriptsData->getDefault('post-install-cmd')), $this->arrayize($scriptsData->getDefault('pre-update-cmd')), $this->arrayize($scriptsData->getDefault('post-update-cmd')), $this->arrayize($scriptsData->getDefault('pre-status-cmd')), $this->arrayize($scriptsData->getDefault('post-status-cmd')), $this->arrayize($scriptsData->getDefault('pre-package-install')), $this->arrayize($scriptsData->getDefault('post-package-install')), $this->arrayize($scriptsData->getDefault('pre-package-update')), $this->arrayize($scriptsData->getDefault('post-package-update')), $this->arrayize($scriptsData->getDefault('pre-package-uninstall')), $this->arrayize($scriptsData->getDefault('post-package-uninstall')), $this->arrayize($scriptsData->getDefault('pre-autoload-dump')), $this->arrayize($scriptsData->getDefault('post-autoload-dump')), $this->arrayize($scriptsData->getDefault('post-root-package-install')), $this->arrayize($scriptsData->getDefault('post-create-project-cmd')), $scriptsData->data() ); } return $scripts; }
php
protected function createScripts(stdClass $scripts = null) { if (null !== $scripts) { $scriptsData = new ObjectAccess($scripts); $scripts = new ScriptConfiguration( $this->arrayize($scriptsData->getDefault('pre-install-cmd')), $this->arrayize($scriptsData->getDefault('post-install-cmd')), $this->arrayize($scriptsData->getDefault('pre-update-cmd')), $this->arrayize($scriptsData->getDefault('post-update-cmd')), $this->arrayize($scriptsData->getDefault('pre-status-cmd')), $this->arrayize($scriptsData->getDefault('post-status-cmd')), $this->arrayize($scriptsData->getDefault('pre-package-install')), $this->arrayize($scriptsData->getDefault('post-package-install')), $this->arrayize($scriptsData->getDefault('pre-package-update')), $this->arrayize($scriptsData->getDefault('post-package-update')), $this->arrayize($scriptsData->getDefault('pre-package-uninstall')), $this->arrayize($scriptsData->getDefault('post-package-uninstall')), $this->arrayize($scriptsData->getDefault('pre-autoload-dump')), $this->arrayize($scriptsData->getDefault('post-autoload-dump')), $this->arrayize($scriptsData->getDefault('post-root-package-install')), $this->arrayize($scriptsData->getDefault('post-create-project-cmd')), $scriptsData->data() ); } return $scripts; }
[ "protected", "function", "createScripts", "(", "stdClass", "$", "scripts", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "scripts", ")", "{", "$", "scriptsData", "=", "new", "ObjectAccess", "(", "$", "scripts", ")", ";", "$", "scripts", "=", "n...
Create a script configuration object from the supplied raw value. @param stdClass|null $scripts The raw script configuration data. @return ScriptConfiguration|null The newly created script configuration object.
[ "Create", "a", "script", "configuration", "object", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L475-L501
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.createArchiveConfiguration
protected function createArchiveConfiguration(stdClass $archive = null) { if (null !== $archive) { $archiveData = new ObjectAccess($archive); $archive = new ArchiveConfiguration( $archiveData->getDefault('exclude'), $archiveData->data() ); } return $archive; }
php
protected function createArchiveConfiguration(stdClass $archive = null) { if (null !== $archive) { $archiveData = new ObjectAccess($archive); $archive = new ArchiveConfiguration( $archiveData->getDefault('exclude'), $archiveData->data() ); } return $archive; }
[ "protected", "function", "createArchiveConfiguration", "(", "stdClass", "$", "archive", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "archive", ")", "{", "$", "archiveData", "=", "new", "ObjectAccess", "(", "$", "archive", ")", ";", "$", "archive"...
Create an archive configuration object from the supplied raw value. @param stdClass|null $archive The raw archive configuration data. @return ArchiveConfiguration|null The newly created archive configuration object.
[ "Create", "an", "archive", "configuration", "object", "from", "the", "supplied", "raw", "value", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L510-L521
train
eloquent/composer-config-reader
src/ConfigurationReader.php
ConfigurationReader.objectToArray
protected function objectToArray(stdClass $data = null) { if (null !== $data) { $data = (array) $data; foreach ($data as $key => $value) { if ($value instanceof stdClass) { $data[$key] = $this->objectToArray($value); } } } return $data; }
php
protected function objectToArray(stdClass $data = null) { if (null !== $data) { $data = (array) $data; foreach ($data as $key => $value) { if ($value instanceof stdClass) { $data[$key] = $this->objectToArray($value); } } } return $data; }
[ "protected", "function", "objectToArray", "(", "stdClass", "$", "data", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "data", ")", "{", "$", "data", "=", "(", "array", ")", "$", "data", ";", "foreach", "(", "$", "data", "as", "$", "key", ...
Recursively convert the supplied object to an associative array. @param stdClass|null $data The object to convert. @return array<string,mixed> The converted associative array.
[ "Recursively", "convert", "the", "supplied", "object", "to", "an", "associative", "array", "." ]
ee83a1cad8f68508f05b30c376003045a7cdfcd8
https://github.com/eloquent/composer-config-reader/blob/ee83a1cad8f68508f05b30c376003045a7cdfcd8/src/ConfigurationReader.php#L530-L542
train
tinymighty/skinny
includes/Template.php
Template.execute
final function execute() { //parse content first, to allow for any ADDTEMPLATE items $content = $this->parseContent($this->data['bodycontent']); if( !$this->getLayoutClass() ){ throw new \Exception('No layout class defined.'); } $layoutClass = $this->getLayoutClass(); $layout = new $layoutClass($this->getSkin(), $this); //set up standard content zones //head element (including opening body tag) $layout->addHTMLTo('head', $this->html('headelement') ); //the logo image defined in LocalSettings $layout->addHTMLTo('logo', $this->data['logopath']); $layout->addHTMLTo('prepend:body', $this->html( 'prebodyhtml' )); //the article title if($this->showTitle){ $layout->addHTMLTo('content-container.class', 'has-title'); $layout->addHTMLTo('title-html', $this->data['title']); } //article content $layout->addHTMLTo('content-html', $content); //the site notice if( !empty($this->data['sitenotice'])){ $layout->addHTMLTo('site-notice', $this->data['sitenotice']); } //the site tagline, if there is one if($this->showTagline){ $layout->addHTMLTo('content-container.class', 'has-tagline'); $layout->addHTMLTo('tagline', $this->getMsg('tagline') ); } $breadcrumbTrees = $this->breadcrumbs(); $layout->addTemplateTo('breadcrumbs', 'breadcrumbs', array('trees' => $breadcrumbTrees) ); // if(\Skinny::hasContent('toc')){ // $layout->addHTMLTo('toc', (\Skinny::getContent('toc')[0]['html'])); // } // if ( $this->data['dataAfterContent'] ) { // $layout->addHTMLTo('append:content', $this->data['dataAfterContent']); // } //the contents of Mediawiki:Sidebar // $layout->addTemplate('classic-sidebar', 'classic-sidebar', array( // 'sections'=>$this->data['sidebar'] // )); // //list of language variants // $layout->addTemplate('language-variants', 'language-variants', array( // 'variants'=>$this->data['language_urls'] // )); //page footer $layout->addHookTo('footer-links', array($this,'getFooterLinks')); $layout->addHookTo('footer-icons', array($this,'getFooterIcons')); //mediawiki needs this to inject script tags after the footer $layout->addHookTo('append:body', array($this,'afterFooter')); $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode(); //allow skins to set up before render $this->initialize(); echo $layout->render(); // $this->printTrail(); }
php
final function execute() { //parse content first, to allow for any ADDTEMPLATE items $content = $this->parseContent($this->data['bodycontent']); if( !$this->getLayoutClass() ){ throw new \Exception('No layout class defined.'); } $layoutClass = $this->getLayoutClass(); $layout = new $layoutClass($this->getSkin(), $this); //set up standard content zones //head element (including opening body tag) $layout->addHTMLTo('head', $this->html('headelement') ); //the logo image defined in LocalSettings $layout->addHTMLTo('logo', $this->data['logopath']); $layout->addHTMLTo('prepend:body', $this->html( 'prebodyhtml' )); //the article title if($this->showTitle){ $layout->addHTMLTo('content-container.class', 'has-title'); $layout->addHTMLTo('title-html', $this->data['title']); } //article content $layout->addHTMLTo('content-html', $content); //the site notice if( !empty($this->data['sitenotice'])){ $layout->addHTMLTo('site-notice', $this->data['sitenotice']); } //the site tagline, if there is one if($this->showTagline){ $layout->addHTMLTo('content-container.class', 'has-tagline'); $layout->addHTMLTo('tagline', $this->getMsg('tagline') ); } $breadcrumbTrees = $this->breadcrumbs(); $layout->addTemplateTo('breadcrumbs', 'breadcrumbs', array('trees' => $breadcrumbTrees) ); // if(\Skinny::hasContent('toc')){ // $layout->addHTMLTo('toc', (\Skinny::getContent('toc')[0]['html'])); // } // if ( $this->data['dataAfterContent'] ) { // $layout->addHTMLTo('append:content', $this->data['dataAfterContent']); // } //the contents of Mediawiki:Sidebar // $layout->addTemplate('classic-sidebar', 'classic-sidebar', array( // 'sections'=>$this->data['sidebar'] // )); // //list of language variants // $layout->addTemplate('language-variants', 'language-variants', array( // 'variants'=>$this->data['language_urls'] // )); //page footer $layout->addHookTo('footer-links', array($this,'getFooterLinks')); $layout->addHookTo('footer-icons', array($this,'getFooterIcons')); //mediawiki needs this to inject script tags after the footer $layout->addHookTo('append:body', array($this,'afterFooter')); $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode(); //allow skins to set up before render $this->initialize(); echo $layout->render(); // $this->printTrail(); }
[ "final", "function", "execute", "(", ")", "{", "//parse content first, to allow for any ADDTEMPLATE items", "$", "content", "=", "$", "this", "->", "parseContent", "(", "$", "this", "->", "data", "[", "'bodycontent'", "]", ")", ";", "if", "(", "!", "$", "this"...
This is called by MediaWiki to render the skin.
[ "This", "is", "called", "by", "MediaWiki", "to", "render", "the", "skin", "." ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Template.php#L51-L115
train
tinymighty/skinny
includes/Template.php
Template.transclude
function transclude($string){ echo $GLOBALS['wgParser']->parse('{{'.$string.'}}', $this->getSkin()->getRelevantTitle(), new ParserOptions)->getText(); }
php
function transclude($string){ echo $GLOBALS['wgParser']->parse('{{'.$string.'}}', $this->getSkin()->getRelevantTitle(), new ParserOptions)->getText(); }
[ "function", "transclude", "(", "$", "string", ")", "{", "echo", "$", "GLOBALS", "[", "'wgParser'", "]", "->", "parse", "(", "'{{'", ".", "$", "string", ".", "'}}'", ",", "$", "this", "->", "getSkin", "(", ")", "->", "getRelevantTitle", "(", ")", ",",...
Transclude a MediaWiki page
[ "Transclude", "a", "MediaWiki", "page" ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Template.php#L122-L124
train
tinymighty/skinny
includes/Template.php
Template.parseContent
public function parseContent( $html ){ $pattern = '~<p>ADDTEMPLATE\(([\w_:-]*)\):([\w_-]+):ETALPMETDDA<\/p>~m'; if( preg_match_all($pattern, $html, $matches, PREG_SET_ORDER) ){ foreach($matches as $match){ //if a zone is specified, attach the template if(!empty($match[1])){ $this->getLayout()->addTemplateTo($match[1], $match[2]); $html = str_replace($match[0], '', $html); }else{ //otherwise inject the template inline into the wikitext $html = str_replace($match[0], $this->getLayout()->renderTemplate($match[2]), $html); } } } return $html; }
php
public function parseContent( $html ){ $pattern = '~<p>ADDTEMPLATE\(([\w_:-]*)\):([\w_-]+):ETALPMETDDA<\/p>~m'; if( preg_match_all($pattern, $html, $matches, PREG_SET_ORDER) ){ foreach($matches as $match){ //if a zone is specified, attach the template if(!empty($match[1])){ $this->getLayout()->addTemplateTo($match[1], $match[2]); $html = str_replace($match[0], '', $html); }else{ //otherwise inject the template inline into the wikitext $html = str_replace($match[0], $this->getLayout()->renderTemplate($match[2]), $html); } } } return $html; }
[ "public", "function", "parseContent", "(", "$", "html", ")", "{", "$", "pattern", "=", "'~<p>ADDTEMPLATE\\(([\\w_:-]*)\\):([\\w_-]+):ETALPMETDDA<\\/p>~m'", ";", "if", "(", "preg_match_all", "(", "$", "pattern", ",", "$", "html", ",", "$", "matches", ",", "PREG_SET...
parse the bodytext and insert any templates added by the skintemplate parser function
[ "parse", "the", "bodytext", "and", "insert", "any", "templates", "added", "by", "the", "skintemplate", "parser", "function" ]
c653369c68e61522e6a22a729182a49f070cff21
https://github.com/tinymighty/skinny/blob/c653369c68e61522e6a22a729182a49f070cff21/includes/Template.php#L128-L143
train
ynloultratech/graphql-bundle
src/Resolver/ResolverExecutor.php
ResolverExecutor.arrayToObject
private function arrayToObject(array $data, FieldsAwareDefinitionInterface $definition) { $class = null; if ($definition instanceof ClassAwareDefinitionInterface) { $class = $definition->getClass(); } //normalize data foreach ($data as $fieldName => &$value) { if (!$definition->hasField($fieldName)) { continue; } $fieldDefinition = $definition->getField($fieldName); $value = $this->normalizeValue($value, $fieldDefinition->getType()); } unset($value); //instantiate object if (class_exists($class)) { $object = new $class(); } else { $object = $data; } //populate object foreach ($data as $key => $value) { if (!$definition->hasField($key)) { continue; } $fieldDefinition = $definition->getField($key); if (\is_array($value) && $this->endpoint->hasType($fieldDefinition->getType())) { $childType = $this->endpoint->getType($fieldDefinition->getType()); if ($childType instanceof FieldsAwareDefinitionInterface) { $value = $this->arrayToObject($value, $childType); } } $this->setObjectValue($object, $fieldDefinition, $value); } return $object; }
php
private function arrayToObject(array $data, FieldsAwareDefinitionInterface $definition) { $class = null; if ($definition instanceof ClassAwareDefinitionInterface) { $class = $definition->getClass(); } //normalize data foreach ($data as $fieldName => &$value) { if (!$definition->hasField($fieldName)) { continue; } $fieldDefinition = $definition->getField($fieldName); $value = $this->normalizeValue($value, $fieldDefinition->getType()); } unset($value); //instantiate object if (class_exists($class)) { $object = new $class(); } else { $object = $data; } //populate object foreach ($data as $key => $value) { if (!$definition->hasField($key)) { continue; } $fieldDefinition = $definition->getField($key); if (\is_array($value) && $this->endpoint->hasType($fieldDefinition->getType())) { $childType = $this->endpoint->getType($fieldDefinition->getType()); if ($childType instanceof FieldsAwareDefinitionInterface) { $value = $this->arrayToObject($value, $childType); } } $this->setObjectValue($object, $fieldDefinition, $value); } return $object; }
[ "private", "function", "arrayToObject", "(", "array", "$", "data", ",", "FieldsAwareDefinitionInterface", "$", "definition", ")", "{", "$", "class", "=", "null", ";", "if", "(", "$", "definition", "instanceof", "ClassAwareDefinitionInterface", ")", "{", "$", "cl...
Convert a array into object using given definition @param array $data data to populate the object @param FieldsAwareDefinitionInterface $definition object definition @return mixed
[ "Convert", "a", "array", "into", "object", "using", "given", "definition" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Resolver/ResolverExecutor.php#L403-L445
train
freddiedfre/AfricasTalkingLaravel5
src/AfricasTalkingGateway.php
AfricasTalkingGateway.getUserData
public function getUserData() { $username = $this->_username; $this->_requestUrl = self::USER_DATA_URL.'?username='.$username; $this->executeGet(); if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_OK ) { $responseObject = json_decode($this->_responseBody); return $responseObject->UserData; } throw new AfricasTalkingGatewayException($this->_responseBody); }
php
public function getUserData() { $username = $this->_username; $this->_requestUrl = self::USER_DATA_URL.'?username='.$username; $this->executeGet(); if ( $this->_responseInfo['http_code'] == self::HTTP_CODE_OK ) { $responseObject = json_decode($this->_responseBody); return $responseObject->UserData; } throw new AfricasTalkingGatewayException($this->_responseBody); }
[ "public", "function", "getUserData", "(", ")", "{", "$", "username", "=", "$", "this", "->", "_username", ";", "$", "this", "->", "_requestUrl", "=", "self", "::", "USER_DATA_URL", ".", "'?username='", ".", "$", "username", ";", "$", "this", "->", "execu...
User info method
[ "User", "info", "method" ]
212be67d43c33ee4c1f20f629282458ad2016021
https://github.com/freddiedfre/AfricasTalkingLaravel5/blob/212be67d43c33ee4c1f20f629282458ad2016021/src/AfricasTalkingGateway.php#L288-L300
train
psbhanu/whatsapi
src/Clients/MGP25.php
MGP25.processAllMessages
private function processAllMessages() { $processed = []; $receivers = $this->receivers(); $messages = $this->manager->getMessages(); foreach ($receivers as $receiver) { foreach ($messages as $index => $message) { $this->composition($receiver, $message); $id = $this->sendMessage($receiver, $message); $copy = new stdClass(); $copy->id = $id; $copy->type = $message->type; $copy->sender = $this->account['number']; $copy->nickname = $this->account['nickname']; $copy->to = implode(', ', (array) $receiver); $copy->message = $message; if(isset($message->file) && !$message->hash) { $copy->message->hash = $messages[$index]->hash = base64_encode(hash_file("sha256", $message->file, true)); } foreach ($this->manager->getInjectedVars() as $key => $value) { $copy->$key = $value; } $processed[] = $copy; } } $this->broadcast = false; $this->manager->clear(); return $processed; }
php
private function processAllMessages() { $processed = []; $receivers = $this->receivers(); $messages = $this->manager->getMessages(); foreach ($receivers as $receiver) { foreach ($messages as $index => $message) { $this->composition($receiver, $message); $id = $this->sendMessage($receiver, $message); $copy = new stdClass(); $copy->id = $id; $copy->type = $message->type; $copy->sender = $this->account['number']; $copy->nickname = $this->account['nickname']; $copy->to = implode(', ', (array) $receiver); $copy->message = $message; if(isset($message->file) && !$message->hash) { $copy->message->hash = $messages[$index]->hash = base64_encode(hash_file("sha256", $message->file, true)); } foreach ($this->manager->getInjectedVars() as $key => $value) { $copy->$key = $value; } $processed[] = $copy; } } $this->broadcast = false; $this->manager->clear(); return $processed; }
[ "private", "function", "processAllMessages", "(", ")", "{", "$", "processed", "=", "[", "]", ";", "$", "receivers", "=", "$", "this", "->", "receivers", "(", ")", ";", "$", "messages", "=", "$", "this", "->", "manager", "->", "getMessages", "(", ")", ...
Process all messages types @return array
[ "Process", "all", "messages", "types" ]
be34f35bb5e0fd3c6f2196260865bef65c1240c2
https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Clients/MGP25.php#L154-L198
train
psbhanu/whatsapi
src/Clients/MGP25.php
MGP25.sendMessage
private function sendMessage($receiver, $message) { $id = null; switch ($message->type) { case 'text': $id = $this->broadcast ? $this->gateway()->sendBroadcastMessage($receiver, $message->message) : $this->gateway()->sendMessage($receiver, $message->message); break; case 'image': $id = $this->broadcast ? $this->gateway()->sendBroadcastImage($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption) : $this->gateway()->sendMessageImage($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption); break; case 'audio': $id = $this->broadcast ? $this->gateway()->sendBroadcastAudio($receiver, $message->file, false, $message->filesize, $message->hash) : $this->gateway()->sendMessageAudio($receiver, $message->file, false, $message->filesize, $message->hash); break; case 'video': $id = $this->broadcast ? $this->gateway()->sendBroadcastVideo($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption) : $this->gateway()->sendMessageVideo($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption); break; case 'location': $id = $this->broadcast ? $this->gateway()->sendBroadcastLocation($receiver, $message->longitude, $message->latitude, $message->caption, $message->url) : $this->gateway()->sendMessageLocation($receiver, $message->longitude, $message->latitude, $message->caption, $message->url); break; case 'vcard': $id = $this->broadcast ? $this->gateway()->sendBroadcastVcard($receiver, $message->name, $message->vcard->show()) : $this->gateway()->sendVcard($receiver, $message->name, $message->vcard->show()); break; default: break; } while ($this->gateway()->pollMessage()); return $id; }
php
private function sendMessage($receiver, $message) { $id = null; switch ($message->type) { case 'text': $id = $this->broadcast ? $this->gateway()->sendBroadcastMessage($receiver, $message->message) : $this->gateway()->sendMessage($receiver, $message->message); break; case 'image': $id = $this->broadcast ? $this->gateway()->sendBroadcastImage($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption) : $this->gateway()->sendMessageImage($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption); break; case 'audio': $id = $this->broadcast ? $this->gateway()->sendBroadcastAudio($receiver, $message->file, false, $message->filesize, $message->hash) : $this->gateway()->sendMessageAudio($receiver, $message->file, false, $message->filesize, $message->hash); break; case 'video': $id = $this->broadcast ? $this->gateway()->sendBroadcastVideo($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption) : $this->gateway()->sendMessageVideo($receiver, $message->file, false, $message->filesize, $message->hash, $message->caption); break; case 'location': $id = $this->broadcast ? $this->gateway()->sendBroadcastLocation($receiver, $message->longitude, $message->latitude, $message->caption, $message->url) : $this->gateway()->sendMessageLocation($receiver, $message->longitude, $message->latitude, $message->caption, $message->url); break; case 'vcard': $id = $this->broadcast ? $this->gateway()->sendBroadcastVcard($receiver, $message->name, $message->vcard->show()) : $this->gateway()->sendVcard($receiver, $message->name, $message->vcard->show()); break; default: break; } while ($this->gateway()->pollMessage()); return $id; }
[ "private", "function", "sendMessage", "(", "$", "receiver", ",", "$", "message", ")", "{", "$", "id", "=", "null", ";", "switch", "(", "$", "message", "->", "type", ")", "{", "case", "'text'", ":", "$", "id", "=", "$", "this", "->", "broadcast", "?...
Select the best way to send messages and send them returning the MessageID @param string|array $receiver @param stdClass $message @return string
[ "Select", "the", "best", "way", "to", "send", "messages", "and", "send", "them", "returning", "the", "MessageID" ]
be34f35bb5e0fd3c6f2196260865bef65c1240c2
https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Clients/MGP25.php#L207-L251
train
psbhanu/whatsapi
src/Clients/MGP25.php
MGP25.receivers
private function receivers() { if(count($this->manager->getReceivers()) <= 10) { return $this->manager->getReceivers(); } $this->broadcast = true; $receivers = []; $allReceivers = $this->manager->getReceivers(); while (count($allReceivers)) { $target = []; $count = 1; while ($count <= $this->config['broadcast-limit'] && count($allReceivers)) { $target[] = array_shift($allReceivers); $count++; } $receivers[] = $target; } return $receivers; }
php
private function receivers() { if(count($this->manager->getReceivers()) <= 10) { return $this->manager->getReceivers(); } $this->broadcast = true; $receivers = []; $allReceivers = $this->manager->getReceivers(); while (count($allReceivers)) { $target = []; $count = 1; while ($count <= $this->config['broadcast-limit'] && count($allReceivers)) { $target[] = array_shift($allReceivers); $count++; } $receivers[] = $target; } return $receivers; }
[ "private", "function", "receivers", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "manager", "->", "getReceivers", "(", ")", ")", "<=", "10", ")", "{", "return", "$", "this", "->", "manager", "->", "getReceivers", "(", ")", ";", "}", "...
Set receivers in a broadcast array if needed @return array
[ "Set", "receivers", "in", "a", "broadcast", "array", "if", "needed" ]
be34f35bb5e0fd3c6f2196260865bef65c1240c2
https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Clients/MGP25.php#L258-L287
train
psbhanu/whatsapi
src/Clients/MGP25.php
MGP25.composition
private function composition($receiver, stdClass $message) { if(!$this->broadcast) { $this->typing($receiver); sleep($this->manager->composition($message)); $this->paused($receiver); } }
php
private function composition($receiver, stdClass $message) { if(!$this->broadcast) { $this->typing($receiver); sleep($this->manager->composition($message)); $this->paused($receiver); } }
[ "private", "function", "composition", "(", "$", "receiver", ",", "stdClass", "$", "message", ")", "{", "if", "(", "!", "$", "this", "->", "broadcast", ")", "{", "$", "this", "->", "typing", "(", "$", "receiver", ")", ";", "sleep", "(", "$", "this", ...
Smart composition before sending messages @param string|array $receiver @param stdClass $message @return void
[ "Smart", "composition", "before", "sending", "messages" ]
be34f35bb5e0fd3c6f2196260865bef65c1240c2
https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Clients/MGP25.php#L296-L306
train
psbhanu/whatsapi
src/Clients/MGP25.php
MGP25.connectAndLogin
public function connectAndLogin() { if(!$this->connected) { $account = $this->config["default"]; $this->whatsProt->connect(); $this->whatsProt->loginWithPassword($this->password); $this->whatsProt->sendGetClientConfig(); $this->whatsProt->sendGetServerProperties(); $this->whatsProt->sendGetGroups(); $this->whatsProt->sendGetBroadcastLists(); $this->whatsProt->sendGetPrivacyBlockedList(); $this->whatsProt->sendAvailableForChat($this->config["accounts"][$account]['nickname']); $this->connected = true; } }
php
public function connectAndLogin() { if(!$this->connected) { $account = $this->config["default"]; $this->whatsProt->connect(); $this->whatsProt->loginWithPassword($this->password); $this->whatsProt->sendGetClientConfig(); $this->whatsProt->sendGetServerProperties(); $this->whatsProt->sendGetGroups(); $this->whatsProt->sendGetBroadcastLists(); $this->whatsProt->sendGetPrivacyBlockedList(); $this->whatsProt->sendAvailableForChat($this->config["accounts"][$account]['nickname']); $this->connected = true; } }
[ "public", "function", "connectAndLogin", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "$", "account", "=", "$", "this", "->", "config", "[", "\"default\"", "]", ";", "$", "this", "->", "whatsProt", "->", "connect", "(", ")...
Connect to Whatsapp server and Login @return void
[ "Connect", "to", "Whatsapp", "server", "and", "Login" ]
be34f35bb5e0fd3c6f2196260865bef65c1240c2
https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Clients/MGP25.php#L430-L446
train
psbhanu/whatsapi
src/Clients/MGP25.php
MGP25.logoutAndDisconnect
public function logoutAndDisconnect() { if($this->connected) { // Adds some delay defore disconnect sleep(rand(1, 2)); $this->offline(); $this->whatsProt->disconnect(); $this->connected = false; } }
php
public function logoutAndDisconnect() { if($this->connected) { // Adds some delay defore disconnect sleep(rand(1, 2)); $this->offline(); $this->whatsProt->disconnect(); $this->connected = false; } }
[ "public", "function", "logoutAndDisconnect", "(", ")", "{", "if", "(", "$", "this", "->", "connected", ")", "{", "// Adds some delay defore disconnect", "sleep", "(", "rand", "(", "1", ",", "2", ")", ")", ";", "$", "this", "->", "offline", "(", ")", ";",...
Logout and disconnect from Whatsapp server @return void
[ "Logout", "and", "disconnect", "from", "Whatsapp", "server" ]
be34f35bb5e0fd3c6f2196260865bef65c1240c2
https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Clients/MGP25.php#L453-L465
train
nyeholt/silverstripe-news
code/pages/NewsHolder.php
NewsHolder.getCMSFields
public function getCMSFields() { $fields = parent::getCMSFields(); $modes = array( '' => 'No filing', 'day' => '/Year/Month/Day', 'month' => '/Year/Month', 'year' => '/Year' ); $fields->addFieldToTab('Root.Main', new DropdownField('FilingMode', _t('NewsHolder.FILING_MODE', 'File into'), $modes), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('FileBy', _t('NewsHolder.FILE_BY', 'File by'), array('Published' => 'Published', 'Created' => 'Created')), 'Content'); $fields->addFieldToTab('Root.Main', new CheckboxField('PrimaryNewsSection', _t('NewsHolder.PRIMARY_SECTION', 'Is this a primary news section?'), true), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('OrderBy', _t('NewsHolder.ORDER_BY', 'Order by'), array('OriginalPublishedDate' => 'Published', 'Created' => 'Created')), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('OrderDir', _t('NewsHolder.ORDER_DIR', 'Order direction'), array('DESC' => 'Descending date', 'ASC' => 'Ascending date')), 'Content'); $this->extend('updateNewsHolderCMSFields', $fields); return $fields; }
php
public function getCMSFields() { $fields = parent::getCMSFields(); $modes = array( '' => 'No filing', 'day' => '/Year/Month/Day', 'month' => '/Year/Month', 'year' => '/Year' ); $fields->addFieldToTab('Root.Main', new DropdownField('FilingMode', _t('NewsHolder.FILING_MODE', 'File into'), $modes), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('FileBy', _t('NewsHolder.FILE_BY', 'File by'), array('Published' => 'Published', 'Created' => 'Created')), 'Content'); $fields->addFieldToTab('Root.Main', new CheckboxField('PrimaryNewsSection', _t('NewsHolder.PRIMARY_SECTION', 'Is this a primary news section?'), true), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('OrderBy', _t('NewsHolder.ORDER_BY', 'Order by'), array('OriginalPublishedDate' => 'Published', 'Created' => 'Created')), 'Content'); $fields->addFieldToTab('Root.Main', new DropdownField('OrderDir', _t('NewsHolder.ORDER_DIR', 'Order direction'), array('DESC' => 'Descending date', 'ASC' => 'Ascending date')), 'Content'); $this->extend('updateNewsHolderCMSFields', $fields); return $fields; }
[ "public", "function", "getCMSFields", "(", ")", "{", "$", "fields", "=", "parent", "::", "getCMSFields", "(", ")", ";", "$", "modes", "=", "array", "(", "''", "=>", "'No filing'", ",", "'day'", "=>", "'/Year/Month/Day'", ",", "'month'", "=>", "'/Year/Month...
Gets the fields to display for this news holder in the CMS @return FieldSet
[ "Gets", "the", "fields", "to", "display", "for", "this", "news", "holder", "in", "the", "CMS" ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsHolder.php#L57-L76
train
nyeholt/silverstripe-news
code/pages/NewsHolder.php
NewsHolder.Articles
public function Articles($number=null) { if (!$number) { $number = $this->numberToDisplay; } $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; if ($start < 0) { $start = 0; } $articles = null; $filter = null; if ($this->PrimaryNewsSection) { // get all where the holder = me $filter = array('NewsSectionID' => $this->ID); } else { $subholders = $this->SubSections(); if ($subholders) { $subholders->push($this); } else { $subholders = null; } if ($subholders && $subholders->Count()) { $ids = $subholders->column('ID'); $filter = array('ParentID' => $ids); } else { $filter = array('ParentID' => (int) $this->ID); } } $orderBy = strlen($this->OrderBy) ? $this->OrderBy : 'OriginalPublishedDate'; $dir = strlen($this->OrderDir) ? $this->OrderDir : 'DESC'; if (!in_array($dir, array('ASC', 'DESC'))) { $dir = 'DESC'; } $articles = NewsArticle::get()->filter($filter)->sort(array($orderBy => $dir))->limit($number, $start); $entries = PaginatedList::create($articles); $entries->setPaginationFromQuery($articles->dataQuery()->query()); return $entries; }
php
public function Articles($number=null) { if (!$number) { $number = $this->numberToDisplay; } $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; if ($start < 0) { $start = 0; } $articles = null; $filter = null; if ($this->PrimaryNewsSection) { // get all where the holder = me $filter = array('NewsSectionID' => $this->ID); } else { $subholders = $this->SubSections(); if ($subholders) { $subholders->push($this); } else { $subholders = null; } if ($subholders && $subholders->Count()) { $ids = $subholders->column('ID'); $filter = array('ParentID' => $ids); } else { $filter = array('ParentID' => (int) $this->ID); } } $orderBy = strlen($this->OrderBy) ? $this->OrderBy : 'OriginalPublishedDate'; $dir = strlen($this->OrderDir) ? $this->OrderDir : 'DESC'; if (!in_array($dir, array('ASC', 'DESC'))) { $dir = 'DESC'; } $articles = NewsArticle::get()->filter($filter)->sort(array($orderBy => $dir))->limit($number, $start); $entries = PaginatedList::create($articles); $entries->setPaginationFromQuery($articles->dataQuery()->query()); return $entries; }
[ "public", "function", "Articles", "(", "$", "number", "=", "null", ")", "{", "if", "(", "!", "$", "number", ")", "{", "$", "number", "=", "$", "this", "->", "numberToDisplay", ";", "}", "$", "start", "=", "isset", "(", "$", "_REQUEST", "[", "'start...
Returns a list of articles within this news holder. If there are sub-newsholders, it will return all the articles from there also @return DataObjectSet
[ "Returns", "a", "list", "of", "articles", "within", "this", "news", "holder", "." ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsHolder.php#L95-L137
train
nyeholt/silverstripe-news
code/pages/NewsHolder.php
NewsHolder.SubSections
public function SubSections($allChildren=true) { $subs = null; $childHolders = NewsHolder::get()->filter('ParentID', $this->ID); if ($childHolders && $childHolders->count()) { $subs = new ArrayList(); foreach ($childHolders as $holder) { $subs->push($holder); if ($allChildren === true) { // see if there's any children to include $subSub = $holder->SubSections(); if ($subSub) { $subs->merge($subSub); } } } } return $subs; }
php
public function SubSections($allChildren=true) { $subs = null; $childHolders = NewsHolder::get()->filter('ParentID', $this->ID); if ($childHolders && $childHolders->count()) { $subs = new ArrayList(); foreach ($childHolders as $holder) { $subs->push($holder); if ($allChildren === true) { // see if there's any children to include $subSub = $holder->SubSections(); if ($subSub) { $subs->merge($subSub); } } } } return $subs; }
[ "public", "function", "SubSections", "(", "$", "allChildren", "=", "true", ")", "{", "$", "subs", "=", "null", ";", "$", "childHolders", "=", "NewsHolder", "::", "get", "(", ")", "->", "filter", "(", "'ParentID'", ",", "$", "this", "->", "ID", ")", "...
Returns a list of sub news sections, if available @return DataObjectSet
[ "Returns", "a", "list", "of", "sub", "news", "sections", "if", "available" ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsHolder.php#L144-L163
train
nyeholt/silverstripe-news
code/pages/NewsHolder.php
NewsHolder.getPartitionedHolderForArticle
public function getPartitionedHolderForArticle($article) { if ($this->FileBy == 'Published' && $article->OriginalPublishedDate) { $date = $article->OriginalPublishedDate; } else if ($this->hasField($this->FileBy)) { $field = $this->FileBy; $date = $this->$field; } else { $date = $article->Created; } $year = date('Y', strtotime($date)); $month = date('M', strtotime($date)); $day = date('d', strtotime($date)); $yearFolder = $this->dateFolder($year); if (!$yearFolder) { throw new Exception("Failed retrieving folder"); } if ($this->FilingMode == 'year') { return $yearFolder; } $monthFolder = $yearFolder->dateFolder($month); if (!$monthFolder) { throw new Exception("Failed retrieving folder"); } if ($this->FilingMode == 'month') { return $monthFolder; } $dayFolder = $monthFolder->dateFolder($day); if (!$dayFolder) { throw new Exception("Failed retrieving folder"); } return $dayFolder; }
php
public function getPartitionedHolderForArticle($article) { if ($this->FileBy == 'Published' && $article->OriginalPublishedDate) { $date = $article->OriginalPublishedDate; } else if ($this->hasField($this->FileBy)) { $field = $this->FileBy; $date = $this->$field; } else { $date = $article->Created; } $year = date('Y', strtotime($date)); $month = date('M', strtotime($date)); $day = date('d', strtotime($date)); $yearFolder = $this->dateFolder($year); if (!$yearFolder) { throw new Exception("Failed retrieving folder"); } if ($this->FilingMode == 'year') { return $yearFolder; } $monthFolder = $yearFolder->dateFolder($month); if (!$monthFolder) { throw new Exception("Failed retrieving folder"); } if ($this->FilingMode == 'month') { return $monthFolder; } $dayFolder = $monthFolder->dateFolder($day); if (!$dayFolder) { throw new Exception("Failed retrieving folder"); } return $dayFolder; }
[ "public", "function", "getPartitionedHolderForArticle", "(", "$", "article", ")", "{", "if", "(", "$", "this", "->", "FileBy", "==", "'Published'", "&&", "$", "article", "->", "OriginalPublishedDate", ")", "{", "$", "date", "=", "$", "article", "->", "Origin...
Gets an appropriate sub article holder for the given article page @param Page $article
[ "Gets", "an", "appropriate", "sub", "article", "holder", "for", "the", "given", "article", "page" ]
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsHolder.php#L192-L230
train
nyeholt/silverstripe-news
code/pages/NewsHolder.php
NewsHolder.TotalChildArticles
public function TotalChildArticles($number = null) { if (!$number) { $number = $this->numberToDisplay; } $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; if ($start < 0) { $start = 0; } $articles = NewsArticle::get('NewsArticle', '', '"OriginalPublishedDate" DESC, "ID" DESC', '', $start . ',' . $number) ->filter(array('ID' => $this->getDescendantIDList())); $entries = PaginatedList::create($articles); $entries->setPaginationFromQuery($articles->dataQuery()->query()); return $entries; }
php
public function TotalChildArticles($number = null) { if (!$number) { $number = $this->numberToDisplay; } $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; if ($start < 0) { $start = 0; } $articles = NewsArticle::get('NewsArticle', '', '"OriginalPublishedDate" DESC, "ID" DESC', '', $start . ',' . $number) ->filter(array('ID' => $this->getDescendantIDList())); $entries = PaginatedList::create($articles); $entries->setPaginationFromQuery($articles->dataQuery()->query()); return $entries; }
[ "public", "function", "TotalChildArticles", "(", "$", "number", "=", "null", ")", "{", "if", "(", "!", "$", "number", ")", "{", "$", "number", "=", "$", "this", "->", "numberToDisplay", ";", "}", "$", "start", "=", "isset", "(", "$", "_REQUEST", "[",...
We do not want to use NewsHolder->SubSections because this splits the paginations into the categories the articles are in which means the pagination will not work or will display multiple times @return Array
[ "We", "do", "not", "want", "to", "use", "NewsHolder", "-", ">", "SubSections", "because", "this", "splits", "the", "paginations", "into", "the", "categories", "the", "articles", "are", "in", "which", "means", "the", "pagination", "will", "not", "work", "or",...
e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0
https://github.com/nyeholt/silverstripe-news/blob/e5f23ebdc4dddf056f64db9e88ae3bf1b7bcebc0/code/pages/NewsHolder.php#L275-L290
train
ynloultratech/graphql-bundle
src/Type/Loader/TypeAutoLoader.php
TypeAutoLoader.autoloadTypes
public function autoloadTypes() { //loaded and static if (self::$loaded) { return; } if (!$this->kernel->isDebug() && $this->loadFromCacheCache()) { self::$loaded = true; return; } self::$loaded = true; foreach ($this->kernel->getBundles() as $bundle) { $path = $bundle->getPath().'/Type'; if (file_exists($path)) { $this->registerBundleTypes($path, $bundle->getNamespace()); } } if (Kernel::VERSION_ID >= 40000) { $path = $this->kernel->getRootDir().'/Type'; if (file_exists($path)) { $this->registerBundleTypes($path, 'App'); } } $this->saveCache(); }
php
public function autoloadTypes() { //loaded and static if (self::$loaded) { return; } if (!$this->kernel->isDebug() && $this->loadFromCacheCache()) { self::$loaded = true; return; } self::$loaded = true; foreach ($this->kernel->getBundles() as $bundle) { $path = $bundle->getPath().'/Type'; if (file_exists($path)) { $this->registerBundleTypes($path, $bundle->getNamespace()); } } if (Kernel::VERSION_ID >= 40000) { $path = $this->kernel->getRootDir().'/Type'; if (file_exists($path)) { $this->registerBundleTypes($path, 'App'); } } $this->saveCache(); }
[ "public", "function", "autoloadTypes", "(", ")", "{", "//loaded and static", "if", "(", "self", "::", "$", "loaded", ")", "{", "return", ";", "}", "if", "(", "!", "$", "this", "->", "kernel", "->", "isDebug", "(", ")", "&&", "$", "this", "->", "loadF...
Autoload all registered types
[ "Autoload", "all", "registered", "types" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Type/Loader/TypeAutoLoader.php#L37-L67
train
ynloultratech/graphql-bundle
src/Type/Loader/TypeAutoLoader.php
TypeAutoLoader.registerBundleTypes
protected function registerBundleTypes($path, $namespace) { $finder = new Finder(); foreach ($finder->in($path)->name('/Type.php$/')->getIterator() as $file) { $className = preg_replace('/.php$/', null, $file->getFilename()); if ($file->getRelativePath()) { $subNamespace = str_replace('/', '\\', $file->getRelativePath()); $fullyClassName = $namespace.'\\Type\\'.$subNamespace.'\\'.$className; } else { $fullyClassName = $namespace.'\\Type\\'.$className; } if (class_exists($fullyClassName)) { $ref = new \ReflectionClass($fullyClassName); if ($ref->isSubclassOf(Type::class) && $ref->isInstantiable()) { $requiredParams = false; foreach ($ref->getConstructor()->getParameters() as $parameter) { if ($parameter->getClass() && $parameter->getClass()->implementsInterface(DefinitionInterface::class)) { continue 2; } } if ($requiredParams) { $error = sprintf('The graphql type defined in class "%s" is not instantiable because has some required parameters in the constructor.', $fullyClassName); throw new \LogicException($error); } /** @var Type $instance */ $instance = $ref->newInstance(); TypeRegistry::addTypeMapping($instance->name, $fullyClassName); } } } }
php
protected function registerBundleTypes($path, $namespace) { $finder = new Finder(); foreach ($finder->in($path)->name('/Type.php$/')->getIterator() as $file) { $className = preg_replace('/.php$/', null, $file->getFilename()); if ($file->getRelativePath()) { $subNamespace = str_replace('/', '\\', $file->getRelativePath()); $fullyClassName = $namespace.'\\Type\\'.$subNamespace.'\\'.$className; } else { $fullyClassName = $namespace.'\\Type\\'.$className; } if (class_exists($fullyClassName)) { $ref = new \ReflectionClass($fullyClassName); if ($ref->isSubclassOf(Type::class) && $ref->isInstantiable()) { $requiredParams = false; foreach ($ref->getConstructor()->getParameters() as $parameter) { if ($parameter->getClass() && $parameter->getClass()->implementsInterface(DefinitionInterface::class)) { continue 2; } } if ($requiredParams) { $error = sprintf('The graphql type defined in class "%s" is not instantiable because has some required parameters in the constructor.', $fullyClassName); throw new \LogicException($error); } /** @var Type $instance */ $instance = $ref->newInstance(); TypeRegistry::addTypeMapping($instance->name, $fullyClassName); } } } }
[ "protected", "function", "registerBundleTypes", "(", "$", "path", ",", "$", "namespace", ")", "{", "$", "finder", "=", "new", "Finder", "(", ")", ";", "foreach", "(", "$", "finder", "->", "in", "(", "$", "path", ")", "->", "name", "(", "'/Type.php$/'",...
Register all GraphQL types for given path @param string $path @param string $namespace @throws \ReflectionException
[ "Register", "all", "GraphQL", "types", "for", "given", "path" ]
390aa1ca77cf00ae02688839ea4fca1026954501
https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Type/Loader/TypeAutoLoader.php#L77-L110
train
QuickenLoans/mcp-common
src/Time/TimeUtil.php
TimeUtil.dateTimeToTimePoint
private function dateTimeToTimePoint(DateTime $date) { // missing or offset only timezone? correct to UTC if (!$date->getTimezone() instanceof DateTimeZone || preg_match('#^[+-]{1}[0-9]{2}:?[0-9]{2}$#', $date->getTimezone()->getName())) { $date->setTimezone(new DateTimeZone('UTC')); } try { // DateTime::createFromFormat() will create an invalid DateTimeZone object when the timezone is an offset // (-05:00, for example) instead of a named timezone. By recreating the DateTimeZone object, we can expose // this problem and ensure that a valid DateTimeZone object is always set. $timezone = new DateTimeZone($date->getTimezone()->getName()); } catch (Exception $e) { // @codeCoverageIgnoreStart $date->setTimezone(new DateTimeZone('UTC')); // @codeCoverageIgnoreEnd } return new TimePoint( (int) $date->format('Y'), (int) $date->format('m'), (int) $date->format('d'), (int) $date->format('H'), (int) $date->format('i'), (int) $date->format('s'), $date->getTimezone()->getName(), (int) $date->format('u') ); }
php
private function dateTimeToTimePoint(DateTime $date) { // missing or offset only timezone? correct to UTC if (!$date->getTimezone() instanceof DateTimeZone || preg_match('#^[+-]{1}[0-9]{2}:?[0-9]{2}$#', $date->getTimezone()->getName())) { $date->setTimezone(new DateTimeZone('UTC')); } try { // DateTime::createFromFormat() will create an invalid DateTimeZone object when the timezone is an offset // (-05:00, for example) instead of a named timezone. By recreating the DateTimeZone object, we can expose // this problem and ensure that a valid DateTimeZone object is always set. $timezone = new DateTimeZone($date->getTimezone()->getName()); } catch (Exception $e) { // @codeCoverageIgnoreStart $date->setTimezone(new DateTimeZone('UTC')); // @codeCoverageIgnoreEnd } return new TimePoint( (int) $date->format('Y'), (int) $date->format('m'), (int) $date->format('d'), (int) $date->format('H'), (int) $date->format('i'), (int) $date->format('s'), $date->getTimezone()->getName(), (int) $date->format('u') ); }
[ "private", "function", "dateTimeToTimePoint", "(", "DateTime", "$", "date", ")", "{", "// missing or offset only timezone? correct to UTC", "if", "(", "!", "$", "date", "->", "getTimezone", "(", ")", "instanceof", "DateTimeZone", "||", "preg_match", "(", "'#^[+-]{1}[0...
Convert a DateTime to a TimePoint Note that, if the DateTime includes fractional seconds, that precision will be lost as the TimePoint object does not support the inclusion of fractional seconds. @param DateTime $date @return TimePoint
[ "Convert", "a", "DateTime", "to", "a", "TimePoint" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/Time/TimeUtil.php#L62-L90
train
QuickenLoans/mcp-common
src/Time/TimeUtil.php
TimeUtil.dateIntervalToIntervalSpec
private function dateIntervalToIntervalSpec(DateInterval $interval) { $date = sprintf('%uY%uM%uD', $interval->y, $interval->m, $interval->d); $time = sprintf('%uH%uM%uS', $interval->h, $interval->i, $interval->s); // build extra spec $extra = ''; if ($interval->invert) { $extra .= 'I'; } if ($interval->days) { $extra .= $interval->days . 'D'; } if (strlen($extra) > 0) { $extra = '-' . $extra; } return sprintf('P%sT%s%s', $date, $time, $extra); }
php
private function dateIntervalToIntervalSpec(DateInterval $interval) { $date = sprintf('%uY%uM%uD', $interval->y, $interval->m, $interval->d); $time = sprintf('%uH%uM%uS', $interval->h, $interval->i, $interval->s); // build extra spec $extra = ''; if ($interval->invert) { $extra .= 'I'; } if ($interval->days) { $extra .= $interval->days . 'D'; } if (strlen($extra) > 0) { $extra = '-' . $extra; } return sprintf('P%sT%s%s', $date, $time, $extra); }
[ "private", "function", "dateIntervalToIntervalSpec", "(", "DateInterval", "$", "interval", ")", "{", "$", "date", "=", "sprintf", "(", "'%uY%uM%uD'", ",", "$", "interval", "->", "y", ",", "$", "interval", "->", "m", ",", "$", "interval", "->", "d", ")", ...
Create a Dateinterval spec from DateInterval properties @param DateInterval $interval @return string
[ "Create", "a", "Dateinterval", "spec", "from", "DateInterval", "properties" ]
46ca6e2c5c9df4ec102808f8494ad1774f190021
https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/Time/TimeUtil.php#L99-L119
train
contao-community-alliance/translator
src/StaticTranslator.php
StaticTranslator.sortPluralizedCompare
protected static function sortPluralizedCompare($a, $b) { if ($a == $b) { return 0; } $rangeA = explode(':', $a); $rangeB = explode(':', $b); // Both range starts provided. if (isset($rangeA[0]) && isset($rangeB[0])) { return strcmp($rangeA[0], $rangeB[0]); } // Only second range has a starting point. if (!isset($rangeA[0]) && isset($rangeB[0])) { return -1; } // Only first range has a starting point. if (isset($rangeA[0]) && !isset($rangeB[0])) { return 1; } // Both are an open start range. if (isset($rangeA[1]) && isset($rangeB[1])) { return strcmp($rangeA[1], $rangeB[1]); } // Only second range is open => First is first. if (!isset($rangeA[1]) && isset($rangeB[1])) { return 1; } // Only first range is open => Second is first. if (isset($rangeA[1]) && !isset($rangeB[1])) { return -1; } // Just here to make the IDEs happy - is already handled above as early exit point. return 0; }
php
protected static function sortPluralizedCompare($a, $b) { if ($a == $b) { return 0; } $rangeA = explode(':', $a); $rangeB = explode(':', $b); // Both range starts provided. if (isset($rangeA[0]) && isset($rangeB[0])) { return strcmp($rangeA[0], $rangeB[0]); } // Only second range has a starting point. if (!isset($rangeA[0]) && isset($rangeB[0])) { return -1; } // Only first range has a starting point. if (isset($rangeA[0]) && !isset($rangeB[0])) { return 1; } // Both are an open start range. if (isset($rangeA[1]) && isset($rangeB[1])) { return strcmp($rangeA[1], $rangeB[1]); } // Only second range is open => First is first. if (!isset($rangeA[1]) && isset($rangeB[1])) { return 1; } // Only first range is open => Second is first. if (isset($rangeA[1]) && !isset($rangeB[1])) { return -1; } // Just here to make the IDEs happy - is already handled above as early exit point. return 0; }
[ "protected", "static", "function", "sortPluralizedCompare", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "$", "a", "==", "$", "b", ")", "{", "return", "0", ";", "}", "$", "rangeA", "=", "explode", "(", "':'", ",", "$", "a", ")", ";", "$",...
Compare function for the pluralization array to be used as sorting callback. See documentation of usort in the php manual for details. @param string $a The first value. @param string $b The second value. @return int @SuppressWarnings(PHPMD.ShortVariable) @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)
[ "Compare", "function", "for", "the", "pluralization", "array", "to", "be", "used", "as", "sorting", "callback", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/StaticTranslator.php#L56-L97
train
contao-community-alliance/translator
src/StaticTranslator.php
StaticTranslator.setValuePluralized
public function setValuePluralized($string, $value, $min = null, $max = null, $domain = null, $locale = null) { if (!$domain) { $domain = 'default'; } if (!$locale) { $locale = 'default'; } if (!(isset($this->values[$locale]) && is_array($this->values[$locale]))) { $this->values[$locale] = array(); } if (!(isset($this->values[$locale][$domain]) && is_array($this->values[$locale][$domain]))) { $this->values[$locale][$domain] = array(); } if (isset($this->values[$locale][$domain][$string]) && is_array($this->values[$locale][$domain][$string])) { $lang = $this->values[$locale][$domain][$string]; } else { // NOTE: we kill any value previously stored as there is no way to tell which value to use. $lang = array(); } $lang[$this->determineKey($min, $max)] = $value; $lang = $this->sortPluralized($lang); $this->setValue($string, $lang, $domain, $locale); return $this; }
php
public function setValuePluralized($string, $value, $min = null, $max = null, $domain = null, $locale = null) { if (!$domain) { $domain = 'default'; } if (!$locale) { $locale = 'default'; } if (!(isset($this->values[$locale]) && is_array($this->values[$locale]))) { $this->values[$locale] = array(); } if (!(isset($this->values[$locale][$domain]) && is_array($this->values[$locale][$domain]))) { $this->values[$locale][$domain] = array(); } if (isset($this->values[$locale][$domain][$string]) && is_array($this->values[$locale][$domain][$string])) { $lang = $this->values[$locale][$domain][$string]; } else { // NOTE: we kill any value previously stored as there is no way to tell which value to use. $lang = array(); } $lang[$this->determineKey($min, $max)] = $value; $lang = $this->sortPluralized($lang); $this->setValue($string, $lang, $domain, $locale); return $this; }
[ "public", "function", "setValuePluralized", "(", "$", "string", ",", "$", "value", ",", "$", "min", "=", "null", ",", "$", "max", "=", "null", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "!", "$", "domai...
Set a pluralized value in the translator. @param string $string The translation string. @param string $value The translation value. @param int|null $min The minimum value of the range (optional - defaults to null). @param int|null $max The maximum value of the range (optional - defaults to null). @param string $domain The domain (optional - defaults to null). @param string $locale The locale (optional - defaults to null). @return StaticTranslator
[ "Set", "a", "pluralized", "value", "in", "the", "translator", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/StaticTranslator.php#L116-L148
train
contao-community-alliance/translator
src/StaticTranslator.php
StaticTranslator.determineKey
protected function determineKey($min, $max) { $minGiven = ($min !== null); $maxGiven = ($max !== null); if (!$minGiven && !$maxGiven) { throw new InvalidArgumentException('You must specify a valid value for min, max or both.'); } if ($minGiven && !$maxGiven) { // Open end range. return $min . ':'; } elseif (!$minGiven && $maxGiven) { // Open start range. return ':' . $max; } if ($min === $max) { // Exact number. return $min; } // Full defined range. return $min . ':' . $max; }
php
protected function determineKey($min, $max) { $minGiven = ($min !== null); $maxGiven = ($max !== null); if (!$minGiven && !$maxGiven) { throw new InvalidArgumentException('You must specify a valid value for min, max or both.'); } if ($minGiven && !$maxGiven) { // Open end range. return $min . ':'; } elseif (!$minGiven && $maxGiven) { // Open start range. return ':' . $max; } if ($min === $max) { // Exact number. return $min; } // Full defined range. return $min . ':' . $max; }
[ "protected", "function", "determineKey", "(", "$", "min", ",", "$", "max", ")", "{", "$", "minGiven", "=", "(", "$", "min", "!==", "null", ")", ";", "$", "maxGiven", "=", "(", "$", "max", "!==", "null", ")", ";", "if", "(", "!", "$", "minGiven", ...
Determine the correct pluralization key. @param int|null $min The minimum value. @param int|null $max The maximum value. @return string @throws InvalidArgumentException When both, min and max, are null.
[ "Determine", "the", "correct", "pluralization", "key", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/StaticTranslator.php#L161-L185
train
contao-community-alliance/translator
src/StaticTranslator.php
StaticTranslator.setValue
public function setValue($string, $value, $domain = null, $locale = null) { if (!$domain) { $domain = 'default'; } if (!$locale) { $locale = 'default'; } if (!(isset($this->values[$locale]) && is_array($this->values[$locale]))) { $this->values[$locale] = array(); } if (!(isset($this->values[$locale][$domain]) && is_array($this->values[$locale][$domain]))) { $this->values[$locale][$domain] = array(); } $this->values[$locale][$domain][$string] = $value; return $this; }
php
public function setValue($string, $value, $domain = null, $locale = null) { if (!$domain) { $domain = 'default'; } if (!$locale) { $locale = 'default'; } if (!(isset($this->values[$locale]) && is_array($this->values[$locale]))) { $this->values[$locale] = array(); } if (!(isset($this->values[$locale][$domain]) && is_array($this->values[$locale][$domain]))) { $this->values[$locale][$domain] = array(); } $this->values[$locale][$domain][$string] = $value; return $this; }
[ "public", "function", "setValue", "(", "$", "string", ",", "$", "value", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "!", "$", "domain", ")", "{", "$", "domain", "=", "'default'", ";", "}", "if", "(", ...
Set a translation value in the translator. @param string $string The string to translate. @param mixed $value The value to store. @param string $domain The domain to use. @param string $locale The locale (otherwise the current default locale will get used). @return StaticTranslator
[ "Set", "a", "translation", "value", "in", "the", "translator", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/StaticTranslator.php#L214-L235
train
contao-community-alliance/translator
src/StaticTranslator.php
StaticTranslator.getValue
protected function getValue($string, $domain, $locale) { if (!$domain) { $domain = 'default'; } if (!$locale) { $locale = 'default'; } if (!isset($this->values[$locale][$domain][$string])) { return $string; } return $this->values[$locale][$domain][$string]; }
php
protected function getValue($string, $domain, $locale) { if (!$domain) { $domain = 'default'; } if (!$locale) { $locale = 'default'; } if (!isset($this->values[$locale][$domain][$string])) { return $string; } return $this->values[$locale][$domain][$string]; }
[ "protected", "function", "getValue", "(", "$", "string", ",", "$", "domain", ",", "$", "locale", ")", "{", "if", "(", "!", "$", "domain", ")", "{", "$", "domain", "=", "'default'", ";", "}", "if", "(", "!", "$", "locale", ")", "{", "$", "locale",...
Retrieve the value. @param string $string The string to translate. @param string $domain The domain to use. @param string $locale The locale (otherwise the current default locale will get used). @return mixed
[ "Retrieve", "the", "value", "." ]
daa920897510c10ee400b29c83840a866c17623a
https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/StaticTranslator.php#L248-L263
train
thisdata/thisdata-php
src/ThisData.php
ThisData.getOrCreateEndpoint
private function getOrCreateEndpoint($endpoint) { if (!array_key_exists($endpoint, $this->endpoints)) { if (!array_key_exists($endpoint, self::$endpointClassMap)) { throw new \Exception(sprintf('Unknown endpoint "%s"', $endpoint)); } $endpointClass = self::$endpointClassMap[$endpoint]; $this->endpoints[$endpoint] = $this->createEndpoint($endpointClass); } return $this->endpoints[$endpoint]; }
php
private function getOrCreateEndpoint($endpoint) { if (!array_key_exists($endpoint, $this->endpoints)) { if (!array_key_exists($endpoint, self::$endpointClassMap)) { throw new \Exception(sprintf('Unknown endpoint "%s"', $endpoint)); } $endpointClass = self::$endpointClassMap[$endpoint]; $this->endpoints[$endpoint] = $this->createEndpoint($endpointClass); } return $this->endpoints[$endpoint]; }
[ "private", "function", "getOrCreateEndpoint", "(", "$", "endpoint", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "endpoint", ",", "$", "this", "->", "endpoints", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "endpoint", ",", "se...
Create or return an cached instance of the requested endpoint. @param string $endpoint @return object @throws \Exception
[ "Create", "or", "return", "an", "cached", "instance", "of", "the", "requested", "endpoint", "." ]
1b3144e6308d6a07a5d1d66b2a20df821edf6f99
https://github.com/thisdata/thisdata-php/blob/1b3144e6308d6a07a5d1d66b2a20df821edf6f99/src/ThisData.php#L87-L99
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.getQueryBuilder
public function getQueryBuilder($type='default') { return isset($this->queryBuilders[$type]) ? Injector::inst()->create($this->queryBuilders[$type]) : Injector::inst()->create($this->queryBuilders['default']); }
php
public function getQueryBuilder($type='default') { return isset($this->queryBuilders[$type]) ? Injector::inst()->create($this->queryBuilders[$type]) : Injector::inst()->create($this->queryBuilders['default']); }
[ "public", "function", "getQueryBuilder", "(", "$", "type", "=", "'default'", ")", "{", "return", "isset", "(", "$", "this", "->", "queryBuilders", "[", "$", "type", "]", ")", "?", "Injector", "::", "inst", "(", ")", "->", "create", "(", "$", "this", ...
Gets the query builder for the given search type @param string $type @return SolrQueryBuilder
[ "Gets", "the", "query", "builder", "for", "the", "given", "search", "type" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L155-L157
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.index
public function index($dataObject, $stage=null, $fieldBoost = array()) { $document = $this->convertObjectToDocument($dataObject, $stage, $fieldBoost); if ($document) { try { $this->getSolr()->addDocument($document); $this->getSolr()->commit(); // optimize every so often if (mt_rand(0, 100) == 42) { $this->getSolr()->optimize(); } } catch (Exception $ie) { SS_Log::log($ie, SS_Log::ERR); } } }
php
public function index($dataObject, $stage=null, $fieldBoost = array()) { $document = $this->convertObjectToDocument($dataObject, $stage, $fieldBoost); if ($document) { try { $this->getSolr()->addDocument($document); $this->getSolr()->commit(); // optimize every so often if (mt_rand(0, 100) == 42) { $this->getSolr()->optimize(); } } catch (Exception $ie) { SS_Log::log($ie, SS_Log::ERR); } } }
[ "public", "function", "index", "(", "$", "dataObject", ",", "$", "stage", "=", "null", ",", "$", "fieldBoost", "=", "array", "(", ")", ")", "{", "$", "document", "=", "$", "this", "->", "convertObjectToDocument", "(", "$", "dataObject", ",", "$", "stag...
Assuming here that we're indexing a stdClass object with an ID field that is a unique identifier Note that the structur eof the object array must be array( 'FieldName' => array( 'Type' => 'Fieldtype (eg date, string, int)', 'Value' => 'Actualvalue' ) ) You should include a field named 'ID' that dictates the ID of the object, and a field named 'ClassName' that is the name of the document's type @param DataObject $object The object being indexed @param String $stage If we're indexing for a particular stage or not.
[ "Assuming", "here", "that", "we", "re", "indexing", "a", "stdClass", "object", "with", "an", "ID", "field", "that", "is", "a", "unique", "identifier" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L182-L199
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.objectToFields
protected function objectToFields($dataObject) { $ret = array(); $fields = Config::inst()->get($dataObject->ClassName, 'db'); $fields['Created'] = 'SS_Datetime'; $fields['LastEdited'] = 'SS_Datetime'; $ret['ClassName'] = array('Type' => 'Varchar', 'Value' => $dataObject->class); $ret['SS_ID'] = array('Type' => 'Int', 'Value' => $dataObject->ID); foreach ($fields as $name => $type) { if (preg_match('/^(\w+)\(/', $type, $match)) { $type = $match[1]; } // Just index everything; the query can figure out what to exclude... ! $value = $dataObject->$name; if ($type == 'MultiValueField' && $value instanceof MultiValueField) { $value = $value->getValues(); } $ret[$name] = array('Type' => $type, 'Value' => $value); } $rels = Config::inst()->get($dataObject->ClassName, 'has_one'); if($rels) foreach(array_keys($rels) as $rel) { $ret["{$rel}ID"] = array( 'Type' => 'ForeignKey', 'Value' => $dataObject->{$rel . "ID"} ); } if ($dataObject->hasMethod('additionalSolrValues')) { $extras = $dataObject->invokeWithExtensions('additionalSolrValues'); if ($extras && is_array($extras)) { foreach ($extras as $add) { foreach ($add as $k => $v) { $ret[$k] = array( 'Type' => $this->mapper->mapValueToType($k, $v), 'Value' => $v, ); } } } } return $ret; }
php
protected function objectToFields($dataObject) { $ret = array(); $fields = Config::inst()->get($dataObject->ClassName, 'db'); $fields['Created'] = 'SS_Datetime'; $fields['LastEdited'] = 'SS_Datetime'; $ret['ClassName'] = array('Type' => 'Varchar', 'Value' => $dataObject->class); $ret['SS_ID'] = array('Type' => 'Int', 'Value' => $dataObject->ID); foreach ($fields as $name => $type) { if (preg_match('/^(\w+)\(/', $type, $match)) { $type = $match[1]; } // Just index everything; the query can figure out what to exclude... ! $value = $dataObject->$name; if ($type == 'MultiValueField' && $value instanceof MultiValueField) { $value = $value->getValues(); } $ret[$name] = array('Type' => $type, 'Value' => $value); } $rels = Config::inst()->get($dataObject->ClassName, 'has_one'); if($rels) foreach(array_keys($rels) as $rel) { $ret["{$rel}ID"] = array( 'Type' => 'ForeignKey', 'Value' => $dataObject->{$rel . "ID"} ); } if ($dataObject->hasMethod('additionalSolrValues')) { $extras = $dataObject->invokeWithExtensions('additionalSolrValues'); if ($extras && is_array($extras)) { foreach ($extras as $add) { foreach ($add as $k => $v) { $ret[$k] = array( 'Type' => $this->mapper->mapValueToType($k, $v), 'Value' => $v, ); } } } } return $ret; }
[ "protected", "function", "objectToFields", "(", "$", "dataObject", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "fields", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "$", "dataObject", "->", "ClassName", ",", "'db'", ")", ";",...
Pull out all the fields that should be indexed for a particular object This mapping is done to make it easier to @param DataObject $dataObject @return array
[ "Pull", "out", "all", "the", "fields", "that", "should", "be", "indexed", "for", "a", "particular", "object" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L400-L449
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.unindex
public function unindex($typeOrId) { $id = $typeOrId; if (is_object($typeOrId)) { $type = $typeOrId->class; // get_class($type); $id = $type . '_' . $typeOrId->ID; } else { $id = self::RAW_DATA_KEY . $id; } try { // delete all published/non-published versions of this item, so delete _* too $this->getSolr()->deleteByQuery('id:' . $id); $this->getSolr()->deleteByQuery('id:' . $id .'_*'); $this->getSolr()->commit(); } catch (Exception $ie) { SS_Log::log($ie, SS_Log::ERR); } }
php
public function unindex($typeOrId) { $id = $typeOrId; if (is_object($typeOrId)) { $type = $typeOrId->class; // get_class($type); $id = $type . '_' . $typeOrId->ID; } else { $id = self::RAW_DATA_KEY . $id; } try { // delete all published/non-published versions of this item, so delete _* too $this->getSolr()->deleteByQuery('id:' . $id); $this->getSolr()->deleteByQuery('id:' . $id .'_*'); $this->getSolr()->commit(); } catch (Exception $ie) { SS_Log::log($ie, SS_Log::ERR); } }
[ "public", "function", "unindex", "(", "$", "typeOrId", ")", "{", "$", "id", "=", "$", "typeOrId", ";", "if", "(", "is_object", "(", "$", "typeOrId", ")", ")", "{", "$", "type", "=", "$", "typeOrId", "->", "class", ";", "// get_class($type);", "$", "i...
Delete a data object from the index @param DataObject $object
[ "Delete", "a", "data", "object", "from", "the", "index" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L456-L474
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.parseSearch
public function parseSearch($query, $type='default') { // if there's a colon in the search, assume that the user is doing a custom power search if (strpos($query, ':')) { return $query; } if (isset($this->queryBuilders[$type])) { return $this->queryBuilders[$type]->parse($query); } $lucene = implode(':' . $query . ' OR ', self::$default_query_fields) . ':' . $query; return $lucene; }
php
public function parseSearch($query, $type='default') { // if there's a colon in the search, assume that the user is doing a custom power search if (strpos($query, ':')) { return $query; } if (isset($this->queryBuilders[$type])) { return $this->queryBuilders[$type]->parse($query); } $lucene = implode(':' . $query . ' OR ', self::$default_query_fields) . ':' . $query; return $lucene; }
[ "public", "function", "parseSearch", "(", "$", "query", ",", "$", "type", "=", "'default'", ")", "{", "// if there's a colon in the search, assume that the user is doing a custom power search", "if", "(", "strpos", "(", "$", "query", ",", "':'", ")", ")", "{", "retu...
Parse a raw user search string into a query appropriate for execution. @param String $query
[ "Parse", "a", "raw", "user", "search", "string", "into", "a", "query", "appropriate", "for", "execution", "." ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L482-L494
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.query
public function query($query, $offset = 0, $limit = 20, $params = array(), $andWith = array()) { if (is_string($query)) { $builder = $this->getQueryBuilder('default'); $builder->baseQuery($query); $query = $builder; } // be very specific about the subsite support :). if (ClassInfo::exists('Subsite')) { $query->andWith('SubsiteID_i', Subsite::currentSubsiteID()); } // add the stage details in - we should probably use an extension mechanism for this, // but for now this will have to do. @TODO Refactor this.... $stage = Versioned::current_stage(); if (!$stage && !(isset($params['ignore_stage']) && $params['ignore_stage'])) { // default to searching live content only $stage = 'Live'; } if(!isset($params['ignore_stage']) || !$params['ignore_stage']) { $query->addFilter('SS_Stage_ms', $stage); } if($andWith) { foreach($andWith as $field => $value) { $query->andWith($field, $value); } } $extraParams = $query->getParams(); $params = array_merge($params, $extraParams); $query = $query->toString(); $response = null; $rawResponse = null; $solr = $this->getSolr(); $key = null; if ($this->cache) { $key = md5($query.$offset.$limit.serialize($params)); if ($rawResponse = $this->cache->load($key)) { $response = new Apache_Solr_Response( $rawResponse, // we fake the following headers... :o array( 'HTTP/1.1 200 OK', 'Content-Type: text/plain; charset=utf-8' ), $solr->getCreateDocuments(), $solr->getCollapseSingleValueArrays() ); } } if (!$response) { // Execute the query and log any errors on failure, always displaying the search results to the user. if ($this->isConnected()) { try { $response = $this->getSolr()->search($query, $offset, $limit, $params); } catch(Exception $e) { SS_Log::log($e, SS_Log::WARN); } } } $queryParams = new stdClass(); $queryParams->offset = $offset; $queryParams->limit = $limit; $queryParams->params = $params; $results = new SolrResultSet($query, $response, $queryParams, $this); if ($this->cache && !$rawResponse && $key && $response) { $this->cache->save($response->getRawResponse(), $key, array(), $this->cacheTime); } return $results; }
php
public function query($query, $offset = 0, $limit = 20, $params = array(), $andWith = array()) { if (is_string($query)) { $builder = $this->getQueryBuilder('default'); $builder->baseQuery($query); $query = $builder; } // be very specific about the subsite support :). if (ClassInfo::exists('Subsite')) { $query->andWith('SubsiteID_i', Subsite::currentSubsiteID()); } // add the stage details in - we should probably use an extension mechanism for this, // but for now this will have to do. @TODO Refactor this.... $stage = Versioned::current_stage(); if (!$stage && !(isset($params['ignore_stage']) && $params['ignore_stage'])) { // default to searching live content only $stage = 'Live'; } if(!isset($params['ignore_stage']) || !$params['ignore_stage']) { $query->addFilter('SS_Stage_ms', $stage); } if($andWith) { foreach($andWith as $field => $value) { $query->andWith($field, $value); } } $extraParams = $query->getParams(); $params = array_merge($params, $extraParams); $query = $query->toString(); $response = null; $rawResponse = null; $solr = $this->getSolr(); $key = null; if ($this->cache) { $key = md5($query.$offset.$limit.serialize($params)); if ($rawResponse = $this->cache->load($key)) { $response = new Apache_Solr_Response( $rawResponse, // we fake the following headers... :o array( 'HTTP/1.1 200 OK', 'Content-Type: text/plain; charset=utf-8' ), $solr->getCreateDocuments(), $solr->getCollapseSingleValueArrays() ); } } if (!$response) { // Execute the query and log any errors on failure, always displaying the search results to the user. if ($this->isConnected()) { try { $response = $this->getSolr()->search($query, $offset, $limit, $params); } catch(Exception $e) { SS_Log::log($e, SS_Log::WARN); } } } $queryParams = new stdClass(); $queryParams->offset = $offset; $queryParams->limit = $limit; $queryParams->params = $params; $results = new SolrResultSet($query, $response, $queryParams, $this); if ($this->cache && !$rawResponse && $key && $response) { $this->cache->save($response->getRawResponse(), $key, array(), $this->cacheTime); } return $results; }
[ "public", "function", "query", "(", "$", "query", ",", "$", "offset", "=", "0", ",", "$", "limit", "=", "20", ",", "$", "params", "=", "array", "(", ")", ",", "$", "andWith", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", ...
Perform a raw query against the search index, returning a SolrResultSet object that can be used to extract a more complete result set @param String $query The lucene query to execute. @param int $page What result page are we on? @param int $limit How many items to limit the query to return @param array $params A set of parameters to be passed along with the query @param array $andWith A set of extra and with terms to add to the query @return SolrResultSet
[ "Perform", "a", "raw", "query", "against", "the", "search", "index", "returning", "a", "SolrResultSet", "object", "that", "can", "be", "used", "to", "extract", "a", "more", "complete", "result", "set" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L512-L591
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.getFacetsForFields
public function getFacetsForFields($fields, $number=10) { if (!is_array($fields)) { $fields = array($fields); } return $this->query('*', 0, 1, array('facet' => 'true', 'facet.field' => $fields, 'facet.limit' => 10, 'facet.mincount' => 1)); }
php
public function getFacetsForFields($fields, $number=10) { if (!is_array($fields)) { $fields = array($fields); } return $this->query('*', 0, 1, array('facet' => 'true', 'facet.field' => $fields, 'facet.limit' => 10, 'facet.mincount' => 1)); }
[ "public", "function", "getFacetsForFields", "(", "$", "fields", ",", "$", "number", "=", "10", ")", "{", "if", "(", "!", "is_array", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "array", "(", "$", "fields", ")", ";", "}", "return", "$", ...
Method used to return details about the facets stored for content, if any, for an empty query. Note - if you're wanting to perform actual queries using faceting information, please manually add the faceting information into the $params array during the query! This method is purely for convenience! @param $fields An array of fields to get facet information for
[ "Method", "used", "to", "return", "details", "about", "the", "facets", "stored", "for", "content", "if", "any", "for", "an", "empty", "query", "." ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L604-L610
train
nyeholt/silverstripe-solr
code/service/SolrSearchService.php
SolrSearchService.getSolr
public function getSolr() { if (!$this->client) { if (!$this->solrTransport) { $this->solrTransport = new Apache_Solr_HttpTransport_Curl; } $this->client = new Apache_Solr_Service(self::$solr_details['host'], self::$solr_details['port'], self::$solr_details['context'], $this->solrTransport); } return $this->client; }
php
public function getSolr() { if (!$this->client) { if (!$this->solrTransport) { $this->solrTransport = new Apache_Solr_HttpTransport_Curl; } $this->client = new Apache_Solr_Service(self::$solr_details['host'], self::$solr_details['port'], self::$solr_details['context'], $this->solrTransport); } return $this->client; }
[ "public", "function", "getSolr", "(", ")", "{", "if", "(", "!", "$", "this", "->", "client", ")", "{", "if", "(", "!", "$", "this", "->", "solrTransport", ")", "{", "$", "this", "->", "solrTransport", "=", "new", "Apache_Solr_HttpTransport_Curl", ";", ...
Get the solr service client @return Apache_Solr_Service
[ "Get", "the", "solr", "service", "client" ]
a573df88167ba9b2bec51e2660a4edfdad446fcf
https://github.com/nyeholt/silverstripe-solr/blob/a573df88167ba9b2bec51e2660a4edfdad446fcf/code/service/SolrSearchService.php#L619-L628
train