id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
8,900
Solve/Solve
SolveConsole/Controllers/GenController.php
GenController.cvAction
public function cvAction() { $params = array(); $params['name'] = ucfirst($this->getFirstParamOrAsk('Enter controller\'s name')); $params['app'] = ucfirst($this->ask('App to generate controller', 'Frontend')); $this->createCV($params); }
php
public function cvAction() { $params = array(); $params['name'] = ucfirst($this->getFirstParamOrAsk('Enter controller\'s name')); $params['app'] = ucfirst($this->ask('App to generate controller', 'Frontend')); $this->createCV($params); }
[ "public", "function", "cvAction", "(", ")", "{", "$", "params", "=", "array", "(", ")", ";", "$", "params", "[", "'name'", "]", "=", "ucfirst", "(", "$", "this", "->", "getFirstParamOrAsk", "(", "'Enter controller\\'s name'", ")", ")", ";", "$", "params", "[", "'app'", "]", "=", "ucfirst", "(", "$", "this", "->", "ask", "(", "'App to generate controller'", ",", "'Frontend'", ")", ")", ";", "$", "this", "->", "createCV", "(", "$", "params", ")", ";", "}" ]
Generates controller and view structure for it
[ "Generates", "controller", "and", "view", "structure", "for", "it" ]
b2ac834c37831ba6049dafa28255d32b4ea0bf1d
https://github.com/Solve/Solve/blob/b2ac834c37831ba6049dafa28255d32b4ea0bf1d/SolveConsole/Controllers/GenController.php#L50-L56
8,901
Solve/Solve
SolveConsole/Controllers/GenController.php
GenController.appAction
public function appAction() { $name = ucfirst($this->getFirstParamOrAsk('Enter application\'s name'));; FSService::makeWritable(DC::getEnvironment()->getApplicationRoot() . $name); $this->createCV(array( 'name' => 'Index', 'app' => $name, )); $appPath = DC::getEnvironment()->getApplicationRoot() . $name . '/'; $this->safeCreateFromTemplate($appPath . 'Views/_layout.slot', '_view_layout', array('app'=>$name)); $this->safeCreateFromTemplate($appPath . 'config.yml', '_app_config', array('app'=>$name)); $config = DC::getProjectConfig(); if (!$config->has('applications/'.strtolower($name))) { $config->set('applications/'.strtolower($name), strtolower($name)); $this->notify('added information to project.yml', '+ config'); $config->save(); } }
php
public function appAction() { $name = ucfirst($this->getFirstParamOrAsk('Enter application\'s name'));; FSService::makeWritable(DC::getEnvironment()->getApplicationRoot() . $name); $this->createCV(array( 'name' => 'Index', 'app' => $name, )); $appPath = DC::getEnvironment()->getApplicationRoot() . $name . '/'; $this->safeCreateFromTemplate($appPath . 'Views/_layout.slot', '_view_layout', array('app'=>$name)); $this->safeCreateFromTemplate($appPath . 'config.yml', '_app_config', array('app'=>$name)); $config = DC::getProjectConfig(); if (!$config->has('applications/'.strtolower($name))) { $config->set('applications/'.strtolower($name), strtolower($name)); $this->notify('added information to project.yml', '+ config'); $config->save(); } }
[ "public", "function", "appAction", "(", ")", "{", "$", "name", "=", "ucfirst", "(", "$", "this", "->", "getFirstParamOrAsk", "(", "'Enter application\\'s name'", ")", ")", ";", ";", "FSService", "::", "makeWritable", "(", "DC", "::", "getEnvironment", "(", ")", "->", "getApplicationRoot", "(", ")", ".", "$", "name", ")", ";", "$", "this", "->", "createCV", "(", "array", "(", "'name'", "=>", "'Index'", ",", "'app'", "=>", "$", "name", ",", ")", ")", ";", "$", "appPath", "=", "DC", "::", "getEnvironment", "(", ")", "->", "getApplicationRoot", "(", ")", ".", "$", "name", ".", "'/'", ";", "$", "this", "->", "safeCreateFromTemplate", "(", "$", "appPath", ".", "'Views/_layout.slot'", ",", "'_view_layout'", ",", "array", "(", "'app'", "=>", "$", "name", ")", ")", ";", "$", "this", "->", "safeCreateFromTemplate", "(", "$", "appPath", ".", "'config.yml'", ",", "'_app_config'", ",", "array", "(", "'app'", "=>", "$", "name", ")", ")", ";", "$", "config", "=", "DC", "::", "getProjectConfig", "(", ")", ";", "if", "(", "!", "$", "config", "->", "has", "(", "'applications/'", ".", "strtolower", "(", "$", "name", ")", ")", ")", "{", "$", "config", "->", "set", "(", "'applications/'", ".", "strtolower", "(", "$", "name", ")", ",", "strtolower", "(", "$", "name", ")", ")", ";", "$", "this", "->", "notify", "(", "'added information to project.yml'", ",", "'+ config'", ")", ";", "$", "config", "->", "save", "(", ")", ";", "}", "}" ]
Generates new application @throws \Exception
[ "Generates", "new", "application" ]
b2ac834c37831ba6049dafa28255d32b4ea0bf1d
https://github.com/Solve/Solve/blob/b2ac834c37831ba6049dafa28255d32b4ea0bf1d/SolveConsole/Controllers/GenController.php#L73-L89
8,902
bytic/database
src/Result.php
Result.fetchResults
public function fetchResults() { if (count($this->results) == 0) { while ($result = $this->fetchResult()) { $this->results[] = $result; } } return $this->results; }
php
public function fetchResults() { if (count($this->results) == 0) { while ($result = $this->fetchResult()) { $this->results[] = $result; } } return $this->results; }
[ "public", "function", "fetchResults", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "results", ")", "==", "0", ")", "{", "while", "(", "$", "result", "=", "$", "this", "->", "fetchResult", "(", ")", ")", "{", "$", "this", "->", "results", "[", "]", "=", "$", "result", ";", "}", "}", "return", "$", "this", "->", "results", ";", "}" ]
Fetches all rows from current result set @return array
[ "Fetches", "all", "rows", "from", "current", "result", "set" ]
186a7f1ae4fe2d8fa79acc34c06cfacd91488fa4
https://github.com/bytic/database/blob/186a7f1ae4fe2d8fa79acc34c06cfacd91488fa4/src/Result.php#L72-L81
8,903
bytic/database
src/Result.php
Result.fetchResult
public function fetchResult() { if ($this->checkValid()) { try { return $this->getAdapter()->fetchAssoc($this->resultSQL); } catch (Exception $e) { $e->log(); } } return false; }
php
public function fetchResult() { if ($this->checkValid()) { try { return $this->getAdapter()->fetchAssoc($this->resultSQL); } catch (Exception $e) { $e->log(); } } return false; }
[ "public", "function", "fetchResult", "(", ")", "{", "if", "(", "$", "this", "->", "checkValid", "(", ")", ")", "{", "try", "{", "return", "$", "this", "->", "getAdapter", "(", ")", "->", "fetchAssoc", "(", "$", "this", "->", "resultSQL", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "e", "->", "log", "(", ")", ";", "}", "}", "return", "false", ";", "}" ]
Fetches row from current result set @return bool|array
[ "Fetches", "row", "from", "current", "result", "set" ]
186a7f1ae4fe2d8fa79acc34c06cfacd91488fa4
https://github.com/bytic/database/blob/186a7f1ae4fe2d8fa79acc34c06cfacd91488fa4/src/Result.php#L87-L98
8,904
wb-crowdfusion/wb-lib
classes/utils/TweetUtils.php
TweetUtils.linkify
public static function linkify($tweet, $target = '_blank') { if ($target == null) { $target = '_blank'; } $tweet = preg_replace_callback( "#(^|[\n ])@([a-z0-9_-]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="https://twitter.com/%s" target="%s" class="user"><span>@</span>%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); $tweet = preg_replace_callback( "#(^|[\n ])\#([a-z0-9_-]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="https://twitter.com/search?q=%%23%s" target="%s" class="hashtag"><span>#</span>%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); $tweet = preg_replace_callback( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="%s" target="%s" class="link">%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); $tweet = preg_replace_callback( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="http://%s" target="%s" class="link">%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); return $tweet; }
php
public static function linkify($tweet, $target = '_blank') { if ($target == null) { $target = '_blank'; } $tweet = preg_replace_callback( "#(^|[\n ])@([a-z0-9_-]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="https://twitter.com/%s" target="%s" class="user"><span>@</span>%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); $tweet = preg_replace_callback( "#(^|[\n ])\#([a-z0-9_-]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="https://twitter.com/search?q=%%23%s" target="%s" class="hashtag"><span>#</span>%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); $tweet = preg_replace_callback( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="%s" target="%s" class="link">%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); $tweet = preg_replace_callback( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", function ($matches) use ($target) { return sprintf('%s<a href="http://%s" target="%s" class="link">%s</a>', $matches[1], $matches[2], $target, $matches[2]); }, $tweet ); return $tweet; }
[ "public", "static", "function", "linkify", "(", "$", "tweet", ",", "$", "target", "=", "'_blank'", ")", "{", "if", "(", "$", "target", "==", "null", ")", "{", "$", "target", "=", "'_blank'", ";", "}", "$", "tweet", "=", "preg_replace_callback", "(", "\"#(^|[\\n ])@([a-z0-9_-]*)#is\"", ",", "function", "(", "$", "matches", ")", "use", "(", "$", "target", ")", "{", "return", "sprintf", "(", "'%s<a href=\"https://twitter.com/%s\" target=\"%s\" class=\"user\"><span>@</span>%s</a>'", ",", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ",", "$", "target", ",", "$", "matches", "[", "2", "]", ")", ";", "}", ",", "$", "tweet", ")", ";", "$", "tweet", "=", "preg_replace_callback", "(", "\"#(^|[\\n ])\\#([a-z0-9_-]*)#is\"", ",", "function", "(", "$", "matches", ")", "use", "(", "$", "target", ")", "{", "return", "sprintf", "(", "'%s<a href=\"https://twitter.com/search?q=%%23%s\" target=\"%s\" class=\"hashtag\"><span>#</span>%s</a>'", ",", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ",", "$", "target", ",", "$", "matches", "[", "2", "]", ")", ";", "}", ",", "$", "tweet", ")", ";", "$", "tweet", "=", "preg_replace_callback", "(", "\"#(^|[\\n ])([\\w]+?://[\\w]+[^ \\\"\\n\\r\\t<]*)#is\"", ",", "function", "(", "$", "matches", ")", "use", "(", "$", "target", ")", "{", "return", "sprintf", "(", "'%s<a href=\"%s\" target=\"%s\" class=\"link\">%s</a>'", ",", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ",", "$", "target", ",", "$", "matches", "[", "2", "]", ")", ";", "}", ",", "$", "tweet", ")", ";", "$", "tweet", "=", "preg_replace_callback", "(", "\"#(^|[\\n ])((www|ftp)\\.[^ \\\"\\t\\n\\r<]*)#is\"", ",", "function", "(", "$", "matches", ")", "use", "(", "$", "target", ")", "{", "return", "sprintf", "(", "'%s<a href=\"http://%s\" target=\"%s\" class=\"link\">%s</a>'", ",", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ",", "$", "target", ",", "$", "matches", "[", "2", "]", ")", ";", "}", ",", "$", "tweet", ")", ";", "return", "$", "tweet", ";", "}" ]
Linkifies all users, hashtags and urls in a tweet. @param string $tweet @param string $target @return string
[ "Linkifies", "all", "users", "hashtags", "and", "urls", "in", "a", "tweet", "." ]
972b0f1d4aa2fa538ee6c6b436ac84849a579326
https://github.com/wb-crowdfusion/wb-lib/blob/972b0f1d4aa2fa538ee6c6b436ac84849a579326/classes/utils/TweetUtils.php#L12-L51
8,905
joomlatools/joomlatools-platform-categories
site/components/com_categories/views/category/view.html.php
CategoriesViewCategory.addFeed
protected function addFeed() { if ($this->params->get('show_feed_link', 1) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } }
php
protected function addFeed() { if ($this->params->get('show_feed_link', 1) == 1) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } }
[ "protected", "function", "addFeed", "(", ")", "{", "if", "(", "$", "this", "->", "params", "->", "get", "(", "'show_feed_link'", ",", "1", ")", "==", "1", ")", "{", "$", "link", "=", "'&format=feed&limitstart='", ";", "$", "attribs", "=", "array", "(", "'type'", "=>", "'application/rss+xml'", ",", "'title'", "=>", "'RSS 2.0'", ")", ";", "$", "this", "->", "document", "->", "addHeadLink", "(", "JRoute", "::", "_", "(", "$", "link", ".", "'&type=rss'", ")", ",", "'alternate'", ",", "'rel'", ",", "$", "attribs", ")", ";", "$", "attribs", "=", "array", "(", "'type'", "=>", "'application/atom+xml'", ",", "'title'", "=>", "'Atom 1.0'", ")", ";", "$", "this", "->", "document", "->", "addHeadLink", "(", "JRoute", "::", "_", "(", "$", "link", ".", "'&type=atom'", ")", ",", "'alternate'", ",", "'rel'", ",", "$", "attribs", ")", ";", "}", "}" ]
Method to add an alternative feed link to a category layout. @return void @since 3.2
[ "Method", "to", "add", "an", "alternative", "feed", "link", "to", "a", "category", "layout", "." ]
9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350
https://github.com/joomlatools/joomlatools-platform-categories/blob/9fe50b6c4ebe6ebfcf98e50067922fcf4a76d350/site/components/com_categories/views/category/view.html.php#L299-L309
8,906
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.fromDate
static function fromDate($date = false) { $format = count(explode(" ", $date)) > 1 ? Settings\DefaultDateSettings::$defaultDateTimeFromat : Settings\DefaultDateSettings::$defaultDateFromat; return ($date) ? static::createFromFormat($format, $date) : new self(); }
php
static function fromDate($date = false) { $format = count(explode(" ", $date)) > 1 ? Settings\DefaultDateSettings::$defaultDateTimeFromat : Settings\DefaultDateSettings::$defaultDateFromat; return ($date) ? static::createFromFormat($format, $date) : new self(); }
[ "static", "function", "fromDate", "(", "$", "date", "=", "false", ")", "{", "$", "format", "=", "count", "(", "explode", "(", "\" \"", ",", "$", "date", ")", ")", ">", "1", "?", "Settings", "\\", "DefaultDateSettings", "::", "$", "defaultDateTimeFromat", ":", "Settings", "\\", "DefaultDateSettings", "::", "$", "defaultDateFromat", ";", "return", "(", "$", "date", ")", "?", "static", "::", "createFromFormat", "(", "$", "format", ",", "$", "date", ")", ":", "new", "self", "(", ")", ";", "}" ]
Create an instance from a short date or short date time formatted string @param string $date <p>Date to create instance from</p> @return Date @see Settings\DefaultDateSettings
[ "Create", "an", "instance", "from", "a", "short", "date", "or", "short", "date", "time", "formatted", "string" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L205-L209
8,907
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.formatTimestamp
static function formatTimestamp($timestamp = 'now', $format = false) { $dateObj = static::createFromTimestamp($timestamp); return $dateObj->format($format ? : Settings\DefaultDateSettings::$defaultDateTimeFromat); }
php
static function formatTimestamp($timestamp = 'now', $format = false) { $dateObj = static::createFromTimestamp($timestamp); return $dateObj->format($format ? : Settings\DefaultDateSettings::$defaultDateTimeFromat); }
[ "static", "function", "formatTimestamp", "(", "$", "timestamp", "=", "'now'", ",", "$", "format", "=", "false", ")", "{", "$", "dateObj", "=", "static", "::", "createFromTimestamp", "(", "$", "timestamp", ")", ";", "return", "$", "dateObj", "->", "format", "(", "$", "format", "?", ":", "Settings", "\\", "DefaultDateSettings", "::", "$", "defaultDateTimeFromat", ")", ";", "}" ]
Format a timestamp @param type $timestamp [optional] <p>Timestamp to be formatted, defaults to now</p> @param string $format <p>The format that the passed in timestamp should be in. Defaults to DefaultDateSettings::$defaultDateTimeFromat</p> @return string @see Settings\DefaultDateSettings
[ "Format", "a", "timestamp" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L230-L234
8,908
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.mysqlToDateTime
static function mysqlToDateTime($mysqlDate = false) { return static::createFromFormat(static::$mysqlFormat, $mysqlDate)->format(Settings\DefaultDateSettings::$defaultDateTimeFromat); }
php
static function mysqlToDateTime($mysqlDate = false) { return static::createFromFormat(static::$mysqlFormat, $mysqlDate)->format(Settings\DefaultDateSettings::$defaultDateTimeFromat); }
[ "static", "function", "mysqlToDateTime", "(", "$", "mysqlDate", "=", "false", ")", "{", "return", "static", "::", "createFromFormat", "(", "static", "::", "$", "mysqlFormat", ",", "$", "mysqlDate", ")", "->", "format", "(", "Settings", "\\", "DefaultDateSettings", "::", "$", "defaultDateTimeFromat", ")", ";", "}" ]
Converts a MySql formatted date to a default date time string @param type $mysqlDate <p>Mysql date to convert</p> @return string Default date time string @see Settings\DefaultDateSettings
[ "Converts", "a", "MySql", "formatted", "date", "to", "a", "default", "date", "time", "string" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L263-L266
8,909
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.getDaysDiff
static function getDaysDiff($startDate, $endDate, Settings\DateSettings $settings = null) { $format = $settings ? $settings->dateFromat : Settings\DefaultDateSettings::$defaultDateFromat; $start = self::createFromFormat($format, $startDate); $end = self::createFromFormat($format, $endDate); return $start && $end ? $start->diff($end)->format('%r%d') : false; }
php
static function getDaysDiff($startDate, $endDate, Settings\DateSettings $settings = null) { $format = $settings ? $settings->dateFromat : Settings\DefaultDateSettings::$defaultDateFromat; $start = self::createFromFormat($format, $startDate); $end = self::createFromFormat($format, $endDate); return $start && $end ? $start->diff($end)->format('%r%d') : false; }
[ "static", "function", "getDaysDiff", "(", "$", "startDate", ",", "$", "endDate", ",", "Settings", "\\", "DateSettings", "$", "settings", "=", "null", ")", "{", "$", "format", "=", "$", "settings", "?", "$", "settings", "->", "dateFromat", ":", "Settings", "\\", "DefaultDateSettings", "::", "$", "defaultDateFromat", ";", "$", "start", "=", "self", "::", "createFromFormat", "(", "$", "format", ",", "$", "startDate", ")", ";", "$", "end", "=", "self", "::", "createFromFormat", "(", "$", "format", ",", "$", "endDate", ")", ";", "return", "$", "start", "&&", "$", "end", "?", "$", "start", "->", "diff", "(", "$", "end", ")", "->", "format", "(", "'%r%d'", ")", ":", "false", ";", "}" ]
Compare the difference in days between to dates. Dates are formatted as dateTime strings @param string $startDate The start date @param string $endDate The end date @param Settings\DateSettings $settings [optional] <p>A DateSettings object representing the formats to use.</p> @return int|false Nmber of day difference or false on failure
[ "Compare", "the", "difference", "in", "days", "between", "to", "dates", ".", "Dates", "are", "formatted", "as", "dateTime", "strings" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L277-L283
8,910
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.createFromTimestamp
static function createFromTimestamp($timestamp, $settings = null) { $settings = is_null($settings) ? new Settings\DateSettings() : $settings; $dateObj = new Date('now', $settings); if (is_long($timestamp)) { $dateObj = new Date('@'.$timestamp); } return $dateObj; }
php
static function createFromTimestamp($timestamp, $settings = null) { $settings = is_null($settings) ? new Settings\DateSettings() : $settings; $dateObj = new Date('now', $settings); if (is_long($timestamp)) { $dateObj = new Date('@'.$timestamp); } return $dateObj; }
[ "static", "function", "createFromTimestamp", "(", "$", "timestamp", ",", "$", "settings", "=", "null", ")", "{", "$", "settings", "=", "is_null", "(", "$", "settings", ")", "?", "new", "Settings", "\\", "DateSettings", "(", ")", ":", "$", "settings", ";", "$", "dateObj", "=", "new", "Date", "(", "'now'", ",", "$", "settings", ")", ";", "if", "(", "is_long", "(", "$", "timestamp", ")", ")", "{", "$", "dateObj", "=", "new", "Date", "(", "'@'", ".", "$", "timestamp", ")", ";", "}", "return", "$", "dateObj", ";", "}" ]
Create an instance from a timestamp @param type $timestamp [optional] <p>Timestamp to be formatted, defaults to now</p> @param Settings\DateSettings $settings [optional] <p>A DateSettings object representing the formats to use. @return date @see Settings\DefaultDateSettings
[ "Create", "an", "instance", "from", "a", "timestamp" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L337-L345
8,911
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.isTimezoneInDST
static function isTimezoneInDST($timeZone) { $tz = is_string($timeZone) ? new \DateTimeZone($timeZone) : $timeZone; $trans = $tz->getTransitions(); return ((count($trans) && $trans[count($trans) - 1]['ts'] > time())); }
php
static function isTimezoneInDST($timeZone) { $tz = is_string($timeZone) ? new \DateTimeZone($timeZone) : $timeZone; $trans = $tz->getTransitions(); return ((count($trans) && $trans[count($trans) - 1]['ts'] > time())); }
[ "static", "function", "isTimezoneInDST", "(", "$", "timeZone", ")", "{", "$", "tz", "=", "is_string", "(", "$", "timeZone", ")", "?", "new", "\\", "DateTimeZone", "(", "$", "timeZone", ")", ":", "$", "timeZone", ";", "$", "trans", "=", "$", "tz", "->", "getTransitions", "(", ")", ";", "return", "(", "(", "count", "(", "$", "trans", ")", "&&", "$", "trans", "[", "count", "(", "$", "trans", ")", "-", "1", "]", "[", "'ts'", "]", ">", "time", "(", ")", ")", ")", ";", "}" ]
Determin if a timezone is in daylight savings @param \DateTimeZone|string $timeZone <p>Can be a string name of a time zone or \DateTimeZone instace</p> @return bool True if the given time zone is currently in daylight savings @link http://www.php.net/manual/en/timezones.php Valid time zones @link http://www.php.net/manual/en/class.datetimezone.php
[ "Determin", "if", "a", "timezone", "is", "in", "daylight", "savings" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L355-L360
8,912
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.daysOfTheWeek
static function daysOfTheWeek($startFrom = 'Monday', $format = 'l') { $result = []; $start = new self($startFrom); $interval = \DateInterval::createFromDateString('1 day'); $recurrences = 6; foreach (new \DatePeriod($start, $interval, $recurrences) as $date) { $result[] = $date->format($format); } return $result; }
php
static function daysOfTheWeek($startFrom = 'Monday', $format = 'l') { $result = []; $start = new self($startFrom); $interval = \DateInterval::createFromDateString('1 day'); $recurrences = 6; foreach (new \DatePeriod($start, $interval, $recurrences) as $date) { $result[] = $date->format($format); } return $result; }
[ "static", "function", "daysOfTheWeek", "(", "$", "startFrom", "=", "'Monday'", ",", "$", "format", "=", "'l'", ")", "{", "$", "result", "=", "[", "]", ";", "$", "start", "=", "new", "self", "(", "$", "startFrom", ")", ";", "$", "interval", "=", "\\", "DateInterval", "::", "createFromDateString", "(", "'1 day'", ")", ";", "$", "recurrences", "=", "6", ";", "foreach", "(", "new", "\\", "DatePeriod", "(", "$", "start", ",", "$", "interval", ",", "$", "recurrences", ")", "as", "$", "date", ")", "{", "$", "result", "[", "]", "=", "$", "date", "->", "format", "(", "$", "format", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns and array of all the days in a week @param string $startFrom [optional]<p>Day to start from. eg Monday will return an array starting witht the first element as Monday and the last as Sunday @param type $format [optional]<p>Format to return the days as. eg l will return full names eg Monday, N will return 1 for Monday 7 for Sunday, D will return Mon to Sun</p> @return array <p>The array containing all the days of the week in the specified format</p> @link http://www.php.net/manual/en/datetime.formats.php Date and Time Formats
[ "Returns", "and", "array", "of", "all", "the", "days", "in", "a", "week" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L370-L380
8,913
guru-digital/framework-types
GDM/Framework/Types/Date.php
Date.monthsOfTheYear
static function monthsOfTheYear($format = "F") { $result = []; $start = new self('January this year'); $interval = new \DateInterval('P1M'); $recurrences = 11; foreach (new \DatePeriod($start, $interval, $recurrences) as $date) { $result[] = $date->format($format); } return $result; }
php
static function monthsOfTheYear($format = "F") { $result = []; $start = new self('January this year'); $interval = new \DateInterval('P1M'); $recurrences = 11; foreach (new \DatePeriod($start, $interval, $recurrences) as $date) { $result[] = $date->format($format); } return $result; }
[ "static", "function", "monthsOfTheYear", "(", "$", "format", "=", "\"F\"", ")", "{", "$", "result", "=", "[", "]", ";", "$", "start", "=", "new", "self", "(", "'January this year'", ")", ";", "$", "interval", "=", "new", "\\", "DateInterval", "(", "'P1M'", ")", ";", "$", "recurrences", "=", "11", ";", "foreach", "(", "new", "\\", "DatePeriod", "(", "$", "start", ",", "$", "interval", ",", "$", "recurrences", ")", "as", "$", "date", ")", "{", "$", "result", "[", "]", "=", "$", "date", "->", "format", "(", "$", "format", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns and array of all the months in a year @param type $format [optional]<p>Format to return the days as. eg F will return full textual representation of each month, such as January or March, M will return short textual representation of each month, three letters Jan through Dec</p> @return array <p>The array containing all the months of the year in the specified format</p> @link http://www.php.net/manual/en/datetime.formats.php Date and Time Formats
[ "Returns", "and", "array", "of", "all", "the", "months", "in", "a", "year" ]
f14e9b1e6cc2571414ba7d561bb205644e28e17d
https://github.com/guru-digital/framework-types/blob/f14e9b1e6cc2571414ba7d561bb205644e28e17d/GDM/Framework/Types/Date.php#L389-L399
8,914
webmaniacs-net/lib-uri
lib/File.php
File.getName
public function getName($os = null) { if ($os === null) { if (strstr(strtoupper(php_uname()), "WIN")) $os = self::OS_WINDOWS; elseif (strstr(strtoupper(php_uname()), "MACOS")) $os = self::OS_MAC; else $os = self::OS_UNIX; } $host = $this->getHost(); $filename = $this->getPath(); if ($filename{0} === '/' && $os == self::OS_WINDOWS) { $filename = substr($filename, 1); } if ($os == self::OS_WINDOWS) { $filename = str_replace('/', '\\', $filename); } if ($os == self::OS_WINDOWS) { if ($host && $host !== 'localhost') return sprintf('\\\\%s\%s', $host, $filename); else return $filename; } else { return $this->buildStr(); } }
php
public function getName($os = null) { if ($os === null) { if (strstr(strtoupper(php_uname()), "WIN")) $os = self::OS_WINDOWS; elseif (strstr(strtoupper(php_uname()), "MACOS")) $os = self::OS_MAC; else $os = self::OS_UNIX; } $host = $this->getHost(); $filename = $this->getPath(); if ($filename{0} === '/' && $os == self::OS_WINDOWS) { $filename = substr($filename, 1); } if ($os == self::OS_WINDOWS) { $filename = str_replace('/', '\\', $filename); } if ($os == self::OS_WINDOWS) { if ($host && $host !== 'localhost') return sprintf('\\\\%s\%s', $host, $filename); else return $filename; } else { return $this->buildStr(); } }
[ "public", "function", "getName", "(", "$", "os", "=", "null", ")", "{", "if", "(", "$", "os", "===", "null", ")", "{", "if", "(", "strstr", "(", "strtoupper", "(", "php_uname", "(", ")", ")", ",", "\"WIN\"", ")", ")", "$", "os", "=", "self", "::", "OS_WINDOWS", ";", "elseif", "(", "strstr", "(", "strtoupper", "(", "php_uname", "(", ")", ")", ",", "\"MACOS\"", ")", ")", "$", "os", "=", "self", "::", "OS_MAC", ";", "else", "$", "os", "=", "self", "::", "OS_UNIX", ";", "}", "$", "host", "=", "$", "this", "->", "getHost", "(", ")", ";", "$", "filename", "=", "$", "this", "->", "getPath", "(", ")", ";", "if", "(", "$", "filename", "{", "0", "}", "===", "'/'", "&&", "$", "os", "==", "self", "::", "OS_WINDOWS", ")", "{", "$", "filename", "=", "substr", "(", "$", "filename", ",", "1", ")", ";", "}", "if", "(", "$", "os", "==", "self", "::", "OS_WINDOWS", ")", "{", "$", "filename", "=", "str_replace", "(", "'/'", ",", "'\\\\'", ",", "$", "filename", ")", ";", "}", "if", "(", "$", "os", "==", "self", "::", "OS_WINDOWS", ")", "{", "if", "(", "$", "host", "&&", "$", "host", "!==", "'localhost'", ")", "return", "sprintf", "(", "'\\\\\\\\%s\\%s'", ",", "$", "host", ",", "$", "filename", ")", ";", "else", "return", "$", "filename", ";", "}", "else", "{", "return", "$", "this", "->", "buildStr", "(", ")", ";", "}", "}" ]
Get legacy file string name @return string
[ "Get", "legacy", "file", "string", "name" ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/File.php#L27-L50
8,915
webmaniacs-net/lib-uri
lib/File.php
File.getDirectory
public function getDirectory() { $dir = clone $this; $dir->path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($this->path)); if (!$dir->path) $dir->path = '/'; return $dir; }
php
public function getDirectory() { $dir = clone $this; $dir->path = str_replace(DIRECTORY_SEPARATOR, '/', dirname($this->path)); if (!$dir->path) $dir->path = '/'; return $dir; }
[ "public", "function", "getDirectory", "(", ")", "{", "$", "dir", "=", "clone", "$", "this", ";", "$", "dir", "->", "path", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "dirname", "(", "$", "this", "->", "path", ")", ")", ";", "if", "(", "!", "$", "dir", "->", "path", ")", "$", "dir", "->", "path", "=", "'/'", ";", "return", "$", "dir", ";", "}" ]
Get directory file uri return File
[ "Get", "directory", "file", "uri" ]
19c8293ba54ba37e6e0a43b41c0f8e597e28a922
https://github.com/webmaniacs-net/lib-uri/blob/19c8293ba54ba37e6e0a43b41c0f8e597e28a922/lib/File.php#L57-L64
8,916
Arcavias/ext-zend
lib/custom/src/MW/Common/Criteria/Expression/Combine/Lucene.php
MW_Common_Criteria_Expression_Combine_Lucene.toString
public function toString( array $types, array $translations = array(), array $plugins = array() ) { $query = new Zend_Search_Lucene_Search_Query_Boolean(); foreach( $this->_expressions as $expr ) { if( ( $itemstr = $expr->toString( $types, $translations, $plugins ) ) !== '' ) { $query->addSubquery( $itemstr, self::$_operators[$this->_operator] ); } } return $query; }
php
public function toString( array $types, array $translations = array(), array $plugins = array() ) { $query = new Zend_Search_Lucene_Search_Query_Boolean(); foreach( $this->_expressions as $expr ) { if( ( $itemstr = $expr->toString( $types, $translations, $plugins ) ) !== '' ) { $query->addSubquery( $itemstr, self::$_operators[$this->_operator] ); } } return $query; }
[ "public", "function", "toString", "(", "array", "$", "types", ",", "array", "$", "translations", "=", "array", "(", ")", ",", "array", "$", "plugins", "=", "array", "(", ")", ")", "{", "$", "query", "=", "new", "Zend_Search_Lucene_Search_Query_Boolean", "(", ")", ";", "foreach", "(", "$", "this", "->", "_expressions", "as", "$", "expr", ")", "{", "if", "(", "(", "$", "itemstr", "=", "$", "expr", "->", "toString", "(", "$", "types", ",", "$", "translations", ",", "$", "plugins", ")", ")", "!==", "''", ")", "{", "$", "query", "->", "addSubquery", "(", "$", "itemstr", ",", "self", "::", "$", "_operators", "[", "$", "this", "->", "_operator", "]", ")", ";", "}", "}", "return", "$", "query", ";", "}" ]
Generates a Lucene object from the expression objects. @param array $names Associative list of variable or column names as keys and their corresponding types @param array $translations Associative list of variable or column names that should be translated @param array $plugins Associative list of item names and plugins implementing MW_Common_Criteria_Plugin_Interface @return Zend_Search_Lucene_Search_Query_MultiTerm Combined search objects
[ "Generates", "a", "Lucene", "object", "from", "the", "expression", "objects", "." ]
1d2adc81ae0091a70f1053e0f095d55e656a3c96
https://github.com/Arcavias/ext-zend/blob/1d2adc81ae0091a70f1053e0f095d55e656a3c96/lib/custom/src/MW/Common/Criteria/Expression/Combine/Lucene.php#L84-L96
8,917
zodream/wechat
src/AccessToken.php
AccessToken.token
public function token() { $key = 'WeChatToken'.$this->get('appid'); if (Factory::cache()->has($key)) { return Factory::cache()->get($key); } $args = $this->getToken()->json(); if (!is_array($args)) { throw new Exception('HTTP ERROR!'); } if (!array_key_exists('access_token', $args)) { throw new Exception(isset($args['errmsg']) ? $args['errmsg'] : 'GET ACCESS TOKEN ERROR!'); } Factory::cache()->set($key, $args['access_token'], $args['expires_in']); return $args['access_token']; }
php
public function token() { $key = 'WeChatToken'.$this->get('appid'); if (Factory::cache()->has($key)) { return Factory::cache()->get($key); } $args = $this->getToken()->json(); if (!is_array($args)) { throw new Exception('HTTP ERROR!'); } if (!array_key_exists('access_token', $args)) { throw new Exception(isset($args['errmsg']) ? $args['errmsg'] : 'GET ACCESS TOKEN ERROR!'); } Factory::cache()->set($key, $args['access_token'], $args['expires_in']); return $args['access_token']; }
[ "public", "function", "token", "(", ")", "{", "$", "key", "=", "'WeChatToken'", ".", "$", "this", "->", "get", "(", "'appid'", ")", ";", "if", "(", "Factory", "::", "cache", "(", ")", "->", "has", "(", "$", "key", ")", ")", "{", "return", "Factory", "::", "cache", "(", ")", "->", "get", "(", "$", "key", ")", ";", "}", "$", "args", "=", "$", "this", "->", "getToken", "(", ")", "->", "json", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "args", ")", ")", "{", "throw", "new", "Exception", "(", "'HTTP ERROR!'", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'access_token'", ",", "$", "args", ")", ")", "{", "throw", "new", "Exception", "(", "isset", "(", "$", "args", "[", "'errmsg'", "]", ")", "?", "$", "args", "[", "'errmsg'", "]", ":", "'GET ACCESS TOKEN ERROR!'", ")", ";", "}", "Factory", "::", "cache", "(", ")", "->", "set", "(", "$", "key", ",", "$", "args", "[", "'access_token'", "]", ",", "$", "args", "[", "'expires_in'", "]", ")", ";", "return", "$", "args", "[", "'access_token'", "]", ";", "}" ]
GET ACCESS TOKEN AND SAVE CACHE @return string @throws \Exception
[ "GET", "ACCESS", "TOKEN", "AND", "SAVE", "CACHE" ]
ca61a2f39a749673b3863eb48bd5ddc0130b3b06
https://github.com/zodream/wechat/blob/ca61a2f39a749673b3863eb48bd5ddc0130b3b06/src/AccessToken.php#L34-L49
8,918
budkit/budkit-framework
src/Budkit/Session/repository/Database.php
Database.read
public function read($splash, $session, $sessionId) { $database = $this->database; //$token = (string) $input->getCookie($sessId); $statement = $database->where("session_agent", $database->quote($splash['agent'])) ->where("session_ip", $database->quote($splash['ip'])) ->where("session_host", $database->quote($splash['domain'])) ->where("session_key", $database->quote($sessionId)) ->select("*")->from($session->table)->prepare(); $result = $statement->execute(); //Do we have a session that fits this criteria in the db? if not destroy if ((int)$result->rowCount() < 1) { $session->destroy($sessionId); return false; //will lead to re-creation } $object = $result->fetchObject(); return $object; }
php
public function read($splash, $session, $sessionId) { $database = $this->database; //$token = (string) $input->getCookie($sessId); $statement = $database->where("session_agent", $database->quote($splash['agent'])) ->where("session_ip", $database->quote($splash['ip'])) ->where("session_host", $database->quote($splash['domain'])) ->where("session_key", $database->quote($sessionId)) ->select("*")->from($session->table)->prepare(); $result = $statement->execute(); //Do we have a session that fits this criteria in the db? if not destroy if ((int)$result->rowCount() < 1) { $session->destroy($sessionId); return false; //will lead to re-creation } $object = $result->fetchObject(); return $object; }
[ "public", "function", "read", "(", "$", "splash", ",", "$", "session", ",", "$", "sessionId", ")", "{", "$", "database", "=", "$", "this", "->", "database", ";", "//$token = (string) $input->getCookie($sessId);", "$", "statement", "=", "$", "database", "->", "where", "(", "\"session_agent\"", ",", "$", "database", "->", "quote", "(", "$", "splash", "[", "'agent'", "]", ")", ")", "->", "where", "(", "\"session_ip\"", ",", "$", "database", "->", "quote", "(", "$", "splash", "[", "'ip'", "]", ")", ")", "->", "where", "(", "\"session_host\"", ",", "$", "database", "->", "quote", "(", "$", "splash", "[", "'domain'", "]", ")", ")", "->", "where", "(", "\"session_key\"", ",", "$", "database", "->", "quote", "(", "$", "sessionId", ")", ")", "->", "select", "(", "\"*\"", ")", "->", "from", "(", "$", "session", "->", "table", ")", "->", "prepare", "(", ")", ";", "$", "result", "=", "$", "statement", "->", "execute", "(", ")", ";", "//Do we have a session that fits this criteria in the db? if not destroy", "if", "(", "(", "int", ")", "$", "result", "->", "rowCount", "(", ")", "<", "1", ")", "{", "$", "session", "->", "destroy", "(", "$", "sessionId", ")", ";", "return", "false", ";", "//will lead to re-creation", "}", "$", "object", "=", "$", "result", "->", "fetchObject", "(", ")", ";", "return", "$", "object", ";", "}" ]
Read the session from the database @param type $splash @param type $session @param type $sessionId @return boolean
[ "Read", "the", "session", "from", "the", "database" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/repository/Database.php#L44-L67
8,919
budkit/budkit-framework
src/Budkit/Session/repository/Database.php
Database.update
public function update($update, $session, $sessionId) { $database = $this->database; if (isset($update["session_registry"])) { $update["session_registry"] = $database->quote($update["session_registry"]); } //now update the session; $database->update($session->table, $update, array("session_key" => $database->quote($sessionId))); return true; }
php
public function update($update, $session, $sessionId) { $database = $this->database; if (isset($update["session_registry"])) { $update["session_registry"] = $database->quote($update["session_registry"]); } //now update the session; $database->update($session->table, $update, array("session_key" => $database->quote($sessionId))); return true; }
[ "public", "function", "update", "(", "$", "update", ",", "$", "session", ",", "$", "sessionId", ")", "{", "$", "database", "=", "$", "this", "->", "database", ";", "if", "(", "isset", "(", "$", "update", "[", "\"session_registry\"", "]", ")", ")", "{", "$", "update", "[", "\"session_registry\"", "]", "=", "$", "database", "->", "quote", "(", "$", "update", "[", "\"session_registry\"", "]", ")", ";", "}", "//now update the session;", "$", "database", "->", "update", "(", "$", "session", "->", "table", ",", "$", "update", ",", "array", "(", "\"session_key\"", "=>", "$", "database", "->", "quote", "(", "$", "sessionId", ")", ")", ")", ";", "return", "true", ";", "}" ]
Updates session data in the database; @param type $userdata @param type $session @param type $sessionId
[ "Updates", "session", "data", "in", "the", "database", ";" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/repository/Database.php#L76-L88
8,920
budkit/budkit-framework
src/Budkit/Session/repository/Database.php
Database.delete
public function delete($where, $session) { $database = $this->database; if (isset($where["session_key"])) { $where["session_key"] = $database->quote($where["session_key"]); } $database->delete($session->table, $where); return true; }
php
public function delete($where, $session) { $database = $this->database; if (isset($where["session_key"])) { $where["session_key"] = $database->quote($where["session_key"]); } $database->delete($session->table, $where); return true; }
[ "public", "function", "delete", "(", "$", "where", ",", "$", "session", ")", "{", "$", "database", "=", "$", "this", "->", "database", ";", "if", "(", "isset", "(", "$", "where", "[", "\"session_key\"", "]", ")", ")", "{", "$", "where", "[", "\"session_key\"", "]", "=", "$", "database", "->", "quote", "(", "$", "where", "[", "\"session_key\"", "]", ")", ";", "}", "$", "database", "->", "delete", "(", "$", "session", "->", "table", ",", "$", "where", ")", ";", "return", "true", ";", "}" ]
Deletes session data from the database @param type $where @param type $session @return boolean
[ "Deletes", "session", "data", "from", "the", "database" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/repository/Database.php#L97-L108
8,921
budkit/budkit-framework
src/Budkit/Session/repository/Database.php
Database.write
public function write($userdata, $splash, $session, $sessionId, $expiry) { $database = $this->database; $database->insert($session->table, array( "session_key" => $database->quote($sessionId), "session_ip" => $database->quote($splash['ip']), "session_host" => $database->quote($splash['domain']), "session_agent" => $database->quote($splash['agent']), "session_token" => $database->quote($splash['token']), "session_expires" => $expiry, "session_lastactive" => time(), "session_registry" => $database->quote($userdata) )); }
php
public function write($userdata, $splash, $session, $sessionId, $expiry) { $database = $this->database; $database->insert($session->table, array( "session_key" => $database->quote($sessionId), "session_ip" => $database->quote($splash['ip']), "session_host" => $database->quote($splash['domain']), "session_agent" => $database->quote($splash['agent']), "session_token" => $database->quote($splash['token']), "session_expires" => $expiry, "session_lastactive" => time(), "session_registry" => $database->quote($userdata) )); }
[ "public", "function", "write", "(", "$", "userdata", ",", "$", "splash", ",", "$", "session", ",", "$", "sessionId", ",", "$", "expiry", ")", "{", "$", "database", "=", "$", "this", "->", "database", ";", "$", "database", "->", "insert", "(", "$", "session", "->", "table", ",", "array", "(", "\"session_key\"", "=>", "$", "database", "->", "quote", "(", "$", "sessionId", ")", ",", "\"session_ip\"", "=>", "$", "database", "->", "quote", "(", "$", "splash", "[", "'ip'", "]", ")", ",", "\"session_host\"", "=>", "$", "database", "->", "quote", "(", "$", "splash", "[", "'domain'", "]", ")", ",", "\"session_agent\"", "=>", "$", "database", "->", "quote", "(", "$", "splash", "[", "'agent'", "]", ")", ",", "\"session_token\"", "=>", "$", "database", "->", "quote", "(", "$", "splash", "[", "'token'", "]", ")", ",", "\"session_expires\"", "=>", "$", "expiry", ",", "\"session_lastactive\"", "=>", "time", "(", ")", ",", "\"session_registry\"", "=>", "$", "database", "->", "quote", "(", "$", "userdata", ")", ")", ")", ";", "}" ]
Writes session data to the database store @param type $userdata @param type $splash @param type $session @param type $sessionId @param type $expiry
[ "Writes", "session", "data", "to", "the", "database", "store" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Session/repository/Database.php#L119-L134
8,922
mszewcz/php-light-framework
src/Image/Server.php
Server.parseRequestUri
private function parseRequestUri(): void { $requestUri = $this->baseClass->getRequestUri(); $path = \explode('/', $requestUri); $pathCnt = \count($path); if ($pathCnt > 0) { $file = \array_pop($path); $path = \sprintf('%%DOCUMENT_ROOT%%%s%s', \implode(DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR); $path = $this->baseClass->parsePath($path); $file = \explode('.', $file); $ext = ''; if (\count($file) > 1) { $ext = \array_pop($file); } $file = \explode('__', \implode('.', $file)); $resizeParams = []; if (\count($file) > 1) { $resizeParams = $this->parseResizeParams(\explode('_', $file[1])); } $file = $file[0]; $this->uriParams['path'] = $path; $this->uriParams['file'] = $file; $this->uriParams['extension'] = $ext; $this->uriParams['resize-params'] = $resizeParams; } }
php
private function parseRequestUri(): void { $requestUri = $this->baseClass->getRequestUri(); $path = \explode('/', $requestUri); $pathCnt = \count($path); if ($pathCnt > 0) { $file = \array_pop($path); $path = \sprintf('%%DOCUMENT_ROOT%%%s%s', \implode(DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR); $path = $this->baseClass->parsePath($path); $file = \explode('.', $file); $ext = ''; if (\count($file) > 1) { $ext = \array_pop($file); } $file = \explode('__', \implode('.', $file)); $resizeParams = []; if (\count($file) > 1) { $resizeParams = $this->parseResizeParams(\explode('_', $file[1])); } $file = $file[0]; $this->uriParams['path'] = $path; $this->uriParams['file'] = $file; $this->uriParams['extension'] = $ext; $this->uriParams['resize-params'] = $resizeParams; } }
[ "private", "function", "parseRequestUri", "(", ")", ":", "void", "{", "$", "requestUri", "=", "$", "this", "->", "baseClass", "->", "getRequestUri", "(", ")", ";", "$", "path", "=", "\\", "explode", "(", "'/'", ",", "$", "requestUri", ")", ";", "$", "pathCnt", "=", "\\", "count", "(", "$", "path", ")", ";", "if", "(", "$", "pathCnt", ">", "0", ")", "{", "$", "file", "=", "\\", "array_pop", "(", "$", "path", ")", ";", "$", "path", "=", "\\", "sprintf", "(", "'%%DOCUMENT_ROOT%%%s%s'", ",", "\\", "implode", "(", "DIRECTORY_SEPARATOR", ",", "$", "path", ")", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "path", "=", "$", "this", "->", "baseClass", "->", "parsePath", "(", "$", "path", ")", ";", "$", "file", "=", "\\", "explode", "(", "'.'", ",", "$", "file", ")", ";", "$", "ext", "=", "''", ";", "if", "(", "\\", "count", "(", "$", "file", ")", ">", "1", ")", "{", "$", "ext", "=", "\\", "array_pop", "(", "$", "file", ")", ";", "}", "$", "file", "=", "\\", "explode", "(", "'__'", ",", "\\", "implode", "(", "'.'", ",", "$", "file", ")", ")", ";", "$", "resizeParams", "=", "[", "]", ";", "if", "(", "\\", "count", "(", "$", "file", ")", ">", "1", ")", "{", "$", "resizeParams", "=", "$", "this", "->", "parseResizeParams", "(", "\\", "explode", "(", "'_'", ",", "$", "file", "[", "1", "]", ")", ")", ";", "}", "$", "file", "=", "$", "file", "[", "0", "]", ";", "$", "this", "->", "uriParams", "[", "'path'", "]", "=", "$", "path", ";", "$", "this", "->", "uriParams", "[", "'file'", "]", "=", "$", "file", ";", "$", "this", "->", "uriParams", "[", "'extension'", "]", "=", "$", "ext", ";", "$", "this", "->", "uriParams", "[", "'resize-params'", "]", "=", "$", "resizeParams", ";", "}", "}" ]
Parses request uri
[ "Parses", "request", "uri" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Image/Server.php#L47-L78
8,923
mszewcz/php-light-framework
src/Image/Server.php
Server.parseResizeParams
private function parseResizeParams(array $params = []): array { $resizeParams = []; foreach ($params as $param) { \preg_match('/^('.\implode('|', $this->allowedResizeParams).')([0-9]+)$/', $param, $matches); if (isset($matches[1]) && isset($matches[2])) { $resizeParams[$matches[1]] = (int)$matches[2]; if ($matches[1] == 'gs') { $resizeParams[$matches[1]] = ((int)$matches[2] === 1); } } } return $resizeParams; }
php
private function parseResizeParams(array $params = []): array { $resizeParams = []; foreach ($params as $param) { \preg_match('/^('.\implode('|', $this->allowedResizeParams).')([0-9]+)$/', $param, $matches); if (isset($matches[1]) && isset($matches[2])) { $resizeParams[$matches[1]] = (int)$matches[2]; if ($matches[1] == 'gs') { $resizeParams[$matches[1]] = ((int)$matches[2] === 1); } } } return $resizeParams; }
[ "private", "function", "parseResizeParams", "(", "array", "$", "params", "=", "[", "]", ")", ":", "array", "{", "$", "resizeParams", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "\\", "preg_match", "(", "'/^('", ".", "\\", "implode", "(", "'|'", ",", "$", "this", "->", "allowedResizeParams", ")", ".", "')([0-9]+)$/'", ",", "$", "param", ",", "$", "matches", ")", ";", "if", "(", "isset", "(", "$", "matches", "[", "1", "]", ")", "&&", "isset", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "$", "resizeParams", "[", "$", "matches", "[", "1", "]", "]", "=", "(", "int", ")", "$", "matches", "[", "2", "]", ";", "if", "(", "$", "matches", "[", "1", "]", "==", "'gs'", ")", "{", "$", "resizeParams", "[", "$", "matches", "[", "1", "]", "]", "=", "(", "(", "int", ")", "$", "matches", "[", "2", "]", "===", "1", ")", ";", "}", "}", "}", "return", "$", "resizeParams", ";", "}" ]
Parses resize params @param array $params @return array
[ "Parses", "resize", "params" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Image/Server.php#L86-L100
8,924
mszewcz/php-light-framework
src/Image/Server.php
Server.getResizeParamsString
private function getResizeParamsString(): string { $ret = ''; foreach ($this->uriParams['resize-params'] as $param => $value) { $ret .= \sprintf('_%s%s', $param, $value); } return $ret !== '' ? \sprintf('_%s', $ret) : ''; }
php
private function getResizeParamsString(): string { $ret = ''; foreach ($this->uriParams['resize-params'] as $param => $value) { $ret .= \sprintf('_%s%s', $param, $value); } return $ret !== '' ? \sprintf('_%s', $ret) : ''; }
[ "private", "function", "getResizeParamsString", "(", ")", ":", "string", "{", "$", "ret", "=", "''", ";", "foreach", "(", "$", "this", "->", "uriParams", "[", "'resize-params'", "]", "as", "$", "param", "=>", "$", "value", ")", "{", "$", "ret", ".=", "\\", "sprintf", "(", "'_%s%s'", ",", "$", "param", ",", "$", "value", ")", ";", "}", "return", "$", "ret", "!==", "''", "?", "\\", "sprintf", "(", "'_%s'", ",", "$", "ret", ")", ":", "''", ";", "}" ]
Returns resize params string @return string
[ "Returns", "resize", "params", "string" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Image/Server.php#L107-L114
8,925
mszewcz/php-light-framework
src/Image/Server.php
Server.sendCachingHeaders
private function sendCachingHeaders(string $imagePath = ''): void { $ifModifiedSince = ''; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $ifModifiedSince = \preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); } $mdate = \gmdate('D, d M Y H:i:s', \filemtime($imagePath)).' GMT'; if ($ifModifiedSince == $mdate) { \header($this->serverProtocol.' 304 Not Modified', true, 304); die(); } \header($this->serverProtocol.' 200 OK', true, 200); \header('Last-Modified: '.$mdate); $maxAge = $this->baseClass->Image->Server->cacheTime; $maxAgeHeader = 'Cache-Control: no-transform,public,max-age='.$maxAge; if ($maxAge == 0) { $maxAgeHeader = 'Cache-Control: max-age=0, no-cache, no-store'; } \header($maxAgeHeader); \header('Expires: '.\gmdate('D, d M Y H:i:s', \time() + $maxAge).' GMT'); }
php
private function sendCachingHeaders(string $imagePath = ''): void { $ifModifiedSince = ''; if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $ifModifiedSince = \preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']); } $mdate = \gmdate('D, d M Y H:i:s', \filemtime($imagePath)).' GMT'; if ($ifModifiedSince == $mdate) { \header($this->serverProtocol.' 304 Not Modified', true, 304); die(); } \header($this->serverProtocol.' 200 OK', true, 200); \header('Last-Modified: '.$mdate); $maxAge = $this->baseClass->Image->Server->cacheTime; $maxAgeHeader = 'Cache-Control: no-transform,public,max-age='.$maxAge; if ($maxAge == 0) { $maxAgeHeader = 'Cache-Control: max-age=0, no-cache, no-store'; } \header($maxAgeHeader); \header('Expires: '.\gmdate('D, d M Y H:i:s', \time() + $maxAge).' GMT'); }
[ "private", "function", "sendCachingHeaders", "(", "string", "$", "imagePath", "=", "''", ")", ":", "void", "{", "$", "ifModifiedSince", "=", "''", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", ")", ")", "{", "$", "ifModifiedSince", "=", "\\", "preg_replace", "(", "'/;.*$/'", ",", "''", ",", "$", "_SERVER", "[", "'HTTP_IF_MODIFIED_SINCE'", "]", ")", ";", "}", "$", "mdate", "=", "\\", "gmdate", "(", "'D, d M Y H:i:s'", ",", "\\", "filemtime", "(", "$", "imagePath", ")", ")", ".", "' GMT'", ";", "if", "(", "$", "ifModifiedSince", "==", "$", "mdate", ")", "{", "\\", "header", "(", "$", "this", "->", "serverProtocol", ".", "' 304 Not Modified'", ",", "true", ",", "304", ")", ";", "die", "(", ")", ";", "}", "\\", "header", "(", "$", "this", "->", "serverProtocol", ".", "' 200 OK'", ",", "true", ",", "200", ")", ";", "\\", "header", "(", "'Last-Modified: '", ".", "$", "mdate", ")", ";", "$", "maxAge", "=", "$", "this", "->", "baseClass", "->", "Image", "->", "Server", "->", "cacheTime", ";", "$", "maxAgeHeader", "=", "'Cache-Control: no-transform,public,max-age='", ".", "$", "maxAge", ";", "if", "(", "$", "maxAge", "==", "0", ")", "{", "$", "maxAgeHeader", "=", "'Cache-Control: max-age=0, no-cache, no-store'", ";", "}", "\\", "header", "(", "$", "maxAgeHeader", ")", ";", "\\", "header", "(", "'Expires: '", ".", "\\", "gmdate", "(", "'D, d M Y H:i:s'", ",", "\\", "time", "(", ")", "+", "$", "maxAge", ")", ".", "' GMT'", ")", ";", "}" ]
Sends caching headers @param string $imagePath
[ "Sends", "caching", "headers" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Image/Server.php#L145-L169
8,926
mszewcz/php-light-framework
src/Image/Server.php
Server.outputImage
private function outputImage(string $imagePath = ''): void { $fPointer = \fopen($imagePath, 'rb'); $this->sendCachingHeaders($imagePath); \header('Content-Type: '.$this->getImageContentType()); \header('Content-Length: '.\filesize($imagePath)); \fpassthru($fPointer); \fclose($fPointer); die(); }
php
private function outputImage(string $imagePath = ''): void { $fPointer = \fopen($imagePath, 'rb'); $this->sendCachingHeaders($imagePath); \header('Content-Type: '.$this->getImageContentType()); \header('Content-Length: '.\filesize($imagePath)); \fpassthru($fPointer); \fclose($fPointer); die(); }
[ "private", "function", "outputImage", "(", "string", "$", "imagePath", "=", "''", ")", ":", "void", "{", "$", "fPointer", "=", "\\", "fopen", "(", "$", "imagePath", ",", "'rb'", ")", ";", "$", "this", "->", "sendCachingHeaders", "(", "$", "imagePath", ")", ";", "\\", "header", "(", "'Content-Type: '", ".", "$", "this", "->", "getImageContentType", "(", ")", ")", ";", "\\", "header", "(", "'Content-Length: '", ".", "\\", "filesize", "(", "$", "imagePath", ")", ")", ";", "\\", "fpassthru", "(", "$", "fPointer", ")", ";", "\\", "fclose", "(", "$", "fPointer", ")", ";", "die", "(", ")", ";", "}" ]
Reads image from disk and outputs it @param string $imagePath
[ "Reads", "image", "from", "disk", "and", "outputs", "it" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Image/Server.php#L176-L185
8,927
mszewcz/php-light-framework
src/Image/Server.php
Server.serveImage
private function serveImage(): void { if (empty($this->uriParams)) { \header($this->serverProtocol.' 500 Internal Server Error', true, 500); die(); } $requestFilePath = \sprintf( '%s%s%s.%s', $this->uriParams['path'], $this->uriParams['file'], $this->getResizeParamsString(), $this->uriParams['extension'] ); $originalFilePath = \sprintf( '%s%s.%s', $this->uriParams['path'], $this->uriParams['file'], $this->uriParams['extension'] ); if (File::exists($requestFilePath)) { $this->outputImage($requestFilePath); } if (File::exists($originalFilePath)) { if ($this->baseClass->Image->Server->checkRefererBeforeResize === true) { if (!\preg_match('|^'.$this->baseClass->getServerName().'|i', $this->baseClass->getReferer())) { \header($this->serverProtocol.' 403 Forbidden', true, 403); die(); } } $options = $this->uriParams['resize-params']; $options['quality'] = $this->baseClass->Image->Resizer->defaultQuality; try { Resizer::resize($originalFilePath, $requestFilePath, $options); } catch (\Exception $e) { \header($this->serverProtocol.' 500 Internal Server Error', true, 500); die(); } $this->outputImage($requestFilePath); } \header($this->serverProtocol.' 404 Not Found', true, 404); die(); }
php
private function serveImage(): void { if (empty($this->uriParams)) { \header($this->serverProtocol.' 500 Internal Server Error', true, 500); die(); } $requestFilePath = \sprintf( '%s%s%s.%s', $this->uriParams['path'], $this->uriParams['file'], $this->getResizeParamsString(), $this->uriParams['extension'] ); $originalFilePath = \sprintf( '%s%s.%s', $this->uriParams['path'], $this->uriParams['file'], $this->uriParams['extension'] ); if (File::exists($requestFilePath)) { $this->outputImage($requestFilePath); } if (File::exists($originalFilePath)) { if ($this->baseClass->Image->Server->checkRefererBeforeResize === true) { if (!\preg_match('|^'.$this->baseClass->getServerName().'|i', $this->baseClass->getReferer())) { \header($this->serverProtocol.' 403 Forbidden', true, 403); die(); } } $options = $this->uriParams['resize-params']; $options['quality'] = $this->baseClass->Image->Resizer->defaultQuality; try { Resizer::resize($originalFilePath, $requestFilePath, $options); } catch (\Exception $e) { \header($this->serverProtocol.' 500 Internal Server Error', true, 500); die(); } $this->outputImage($requestFilePath); } \header($this->serverProtocol.' 404 Not Found', true, 404); die(); }
[ "private", "function", "serveImage", "(", ")", ":", "void", "{", "if", "(", "empty", "(", "$", "this", "->", "uriParams", ")", ")", "{", "\\", "header", "(", "$", "this", "->", "serverProtocol", ".", "' 500 Internal Server Error'", ",", "true", ",", "500", ")", ";", "die", "(", ")", ";", "}", "$", "requestFilePath", "=", "\\", "sprintf", "(", "'%s%s%s.%s'", ",", "$", "this", "->", "uriParams", "[", "'path'", "]", ",", "$", "this", "->", "uriParams", "[", "'file'", "]", ",", "$", "this", "->", "getResizeParamsString", "(", ")", ",", "$", "this", "->", "uriParams", "[", "'extension'", "]", ")", ";", "$", "originalFilePath", "=", "\\", "sprintf", "(", "'%s%s.%s'", ",", "$", "this", "->", "uriParams", "[", "'path'", "]", ",", "$", "this", "->", "uriParams", "[", "'file'", "]", ",", "$", "this", "->", "uriParams", "[", "'extension'", "]", ")", ";", "if", "(", "File", "::", "exists", "(", "$", "requestFilePath", ")", ")", "{", "$", "this", "->", "outputImage", "(", "$", "requestFilePath", ")", ";", "}", "if", "(", "File", "::", "exists", "(", "$", "originalFilePath", ")", ")", "{", "if", "(", "$", "this", "->", "baseClass", "->", "Image", "->", "Server", "->", "checkRefererBeforeResize", "===", "true", ")", "{", "if", "(", "!", "\\", "preg_match", "(", "'|^'", ".", "$", "this", "->", "baseClass", "->", "getServerName", "(", ")", ".", "'|i'", ",", "$", "this", "->", "baseClass", "->", "getReferer", "(", ")", ")", ")", "{", "\\", "header", "(", "$", "this", "->", "serverProtocol", ".", "' 403 Forbidden'", ",", "true", ",", "403", ")", ";", "die", "(", ")", ";", "}", "}", "$", "options", "=", "$", "this", "->", "uriParams", "[", "'resize-params'", "]", ";", "$", "options", "[", "'quality'", "]", "=", "$", "this", "->", "baseClass", "->", "Image", "->", "Resizer", "->", "defaultQuality", ";", "try", "{", "Resizer", "::", "resize", "(", "$", "originalFilePath", ",", "$", "requestFilePath", ",", "$", "options", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "\\", "header", "(", "$", "this", "->", "serverProtocol", ".", "' 500 Internal Server Error'", ",", "true", ",", "500", ")", ";", "die", "(", ")", ";", "}", "$", "this", "->", "outputImage", "(", "$", "requestFilePath", ")", ";", "}", "\\", "header", "(", "$", "this", "->", "serverProtocol", ".", "' 404 Not Found'", ",", "true", ",", "404", ")", ";", "die", "(", ")", ";", "}" ]
Serves image. If no REQUEST_URI found sends 500 Internal Server Error header. If no image is found sends 404 Not found header. If image needs resizing or grayscale converting - it applies transformations and returns it, otherwise returns original one. @return void
[ "Serves", "image", ".", "If", "no", "REQUEST_URI", "found", "sends", "500", "Internal", "Server", "Error", "header", ".", "If", "no", "image", "is", "found", "sends", "404", "Not", "found", "header", ".", "If", "image", "needs", "resizing", "or", "grayscale", "converting", "-", "it", "applies", "transformations", "and", "returns", "it", "otherwise", "returns", "original", "one", "." ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Image/Server.php#L195-L241
8,928
zugoripls/laravel-framework
src/Illuminate/Queue/Worker.php
Worker.runNextJobForDaemon
protected function runNextJobForDaemon($connectionName, $queue, $delay, $sleep, $maxTries) { try { $this->pop($connectionName, $queue, $delay, $sleep, $maxTries); } catch (Exception $e) { if ($this->exceptions) $this->exceptions->report($e); } }
php
protected function runNextJobForDaemon($connectionName, $queue, $delay, $sleep, $maxTries) { try { $this->pop($connectionName, $queue, $delay, $sleep, $maxTries); } catch (Exception $e) { if ($this->exceptions) $this->exceptions->report($e); } }
[ "protected", "function", "runNextJobForDaemon", "(", "$", "connectionName", ",", "$", "queue", ",", "$", "delay", ",", "$", "sleep", ",", "$", "maxTries", ")", "{", "try", "{", "$", "this", "->", "pop", "(", "$", "connectionName", ",", "$", "queue", ",", "$", "delay", ",", "$", "sleep", ",", "$", "maxTries", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "exceptions", ")", "$", "this", "->", "exceptions", "->", "report", "(", "$", "e", ")", ";", "}", "}" ]
Run the next job for the daemon worker. @param string $connectionName @param string $queue @param int $delay @param int $sleep @param int $maxTries @return void
[ "Run", "the", "next", "job", "for", "the", "daemon", "worker", "." ]
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Queue/Worker.php#L109-L119
8,929
tacowordpress/util
src/Util/Theme.php
Theme.media
public static function media($path, $size) { // Which image size was requested? global $_wp_additional_image_sizes; $image_size = $_wp_additional_image_sizes[$size]; // Get the path info $pathinfo = pathinfo($path); $fname = $pathinfo['basename']; $fext = $pathinfo['extension']; $dir = $pathinfo['dirname']; $fdir = realpath(str_replace('//', '/', ABSPATH.$dir)).'/'; // Filename without any size suffix or extension (e.g. without -144x200.jpg) $fname_prefix = preg_replace('/(?:-\d+x\d+)?\.'.$fext.'$/i', '', $fname); $out_fname = sprintf( '%s-%sx%s.%s', $fname_prefix, $image_size['width'], $image_size['height'], $fext ); // See if the file that we're predicting exists // If so, we can avoid a call to the database $fpath = $fdir.$out_fname; if(file_exists($fpath)) { return sprintf( '%s/%s', $pathinfo['dirname'], $out_fname ); } // Can't find the file? Figure out the correct path from the database global $wpdb; $guid = site_url().$dir.'/'.$fname_prefix.'.'.$fext; $prepared = $wpdb->prepare( "SELECT pm.meta_value FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON p.ID = pm.post_id WHERE p.guid = %s AND pm.meta_key = '_wp_attachment_metadata' LIMIT 1", $guid ); $row = $wpdb->get_row($prepared); if(is_object($row)) { $meta = unserialize($row->meta_value); if(isset($meta['sizes'][$size]['file'])) { $meta_fname = $meta['sizes'][$size]['file']; return sprintf( '%s/%s', $pathinfo['dirname'], $meta_fname ); } } // Still nothing? Just return the path given return $path; }
php
public static function media($path, $size) { // Which image size was requested? global $_wp_additional_image_sizes; $image_size = $_wp_additional_image_sizes[$size]; // Get the path info $pathinfo = pathinfo($path); $fname = $pathinfo['basename']; $fext = $pathinfo['extension']; $dir = $pathinfo['dirname']; $fdir = realpath(str_replace('//', '/', ABSPATH.$dir)).'/'; // Filename without any size suffix or extension (e.g. without -144x200.jpg) $fname_prefix = preg_replace('/(?:-\d+x\d+)?\.'.$fext.'$/i', '', $fname); $out_fname = sprintf( '%s-%sx%s.%s', $fname_prefix, $image_size['width'], $image_size['height'], $fext ); // See if the file that we're predicting exists // If so, we can avoid a call to the database $fpath = $fdir.$out_fname; if(file_exists($fpath)) { return sprintf( '%s/%s', $pathinfo['dirname'], $out_fname ); } // Can't find the file? Figure out the correct path from the database global $wpdb; $guid = site_url().$dir.'/'.$fname_prefix.'.'.$fext; $prepared = $wpdb->prepare( "SELECT pm.meta_value FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON p.ID = pm.post_id WHERE p.guid = %s AND pm.meta_key = '_wp_attachment_metadata' LIMIT 1", $guid ); $row = $wpdb->get_row($prepared); if(is_object($row)) { $meta = unserialize($row->meta_value); if(isset($meta['sizes'][$size]['file'])) { $meta_fname = $meta['sizes'][$size]['file']; return sprintf( '%s/%s', $pathinfo['dirname'], $meta_fname ); } } // Still nothing? Just return the path given return $path; }
[ "public", "static", "function", "media", "(", "$", "path", ",", "$", "size", ")", "{", "// Which image size was requested?", "global", "$", "_wp_additional_image_sizes", ";", "$", "image_size", "=", "$", "_wp_additional_image_sizes", "[", "$", "size", "]", ";", "// Get the path info", "$", "pathinfo", "=", "pathinfo", "(", "$", "path", ")", ";", "$", "fname", "=", "$", "pathinfo", "[", "'basename'", "]", ";", "$", "fext", "=", "$", "pathinfo", "[", "'extension'", "]", ";", "$", "dir", "=", "$", "pathinfo", "[", "'dirname'", "]", ";", "$", "fdir", "=", "realpath", "(", "str_replace", "(", "'//'", ",", "'/'", ",", "ABSPATH", ".", "$", "dir", ")", ")", ".", "'/'", ";", "// Filename without any size suffix or extension (e.g. without -144x200.jpg)", "$", "fname_prefix", "=", "preg_replace", "(", "'/(?:-\\d+x\\d+)?\\.'", ".", "$", "fext", ".", "'$/i'", ",", "''", ",", "$", "fname", ")", ";", "$", "out_fname", "=", "sprintf", "(", "'%s-%sx%s.%s'", ",", "$", "fname_prefix", ",", "$", "image_size", "[", "'width'", "]", ",", "$", "image_size", "[", "'height'", "]", ",", "$", "fext", ")", ";", "// See if the file that we're predicting exists", "// If so, we can avoid a call to the database", "$", "fpath", "=", "$", "fdir", ".", "$", "out_fname", ";", "if", "(", "file_exists", "(", "$", "fpath", ")", ")", "{", "return", "sprintf", "(", "'%s/%s'", ",", "$", "pathinfo", "[", "'dirname'", "]", ",", "$", "out_fname", ")", ";", "}", "// Can't find the file? Figure out the correct path from the database", "global", "$", "wpdb", ";", "$", "guid", "=", "site_url", "(", ")", ".", "$", "dir", ".", "'/'", ".", "$", "fname_prefix", ".", "'.'", ".", "$", "fext", ";", "$", "prepared", "=", "$", "wpdb", "->", "prepare", "(", "\"SELECT\n pm.meta_value\n FROM $wpdb->posts p\n INNER JOIN $wpdb->postmeta pm\n ON p.ID = pm.post_id\n WHERE p.guid = %s\n AND pm.meta_key = '_wp_attachment_metadata'\n LIMIT 1\"", ",", "$", "guid", ")", ";", "$", "row", "=", "$", "wpdb", "->", "get_row", "(", "$", "prepared", ")", ";", "if", "(", "is_object", "(", "$", "row", ")", ")", "{", "$", "meta", "=", "unserialize", "(", "$", "row", "->", "meta_value", ")", ";", "if", "(", "isset", "(", "$", "meta", "[", "'sizes'", "]", "[", "$", "size", "]", "[", "'file'", "]", ")", ")", "{", "$", "meta_fname", "=", "$", "meta", "[", "'sizes'", "]", "[", "$", "size", "]", "[", "'file'", "]", ";", "return", "sprintf", "(", "'%s/%s'", ",", "$", "pathinfo", "[", "'dirname'", "]", ",", "$", "meta_fname", ")", ";", "}", "}", "// Still nothing? Just return the path given", "return", "$", "path", ";", "}" ]
Get URL for an image in the media library @param string $path @param string $size (size keys that you've passed to add_image_size) @return string Relative URL
[ "Get", "URL", "for", "an", "image", "in", "the", "media", "library" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Theme.php#L27-L89
8,930
tacowordpress/util
src/Util/Theme.php
Theme.asset
public static function asset($relative_path, $include_version=true) { $clean_relative_path = preg_replace('/^[\/_]+/', '', $relative_path); return sprintf( '%s/_/%s%s', THEME_URL, $clean_relative_path, ($include_version) ? THEME_SUFFIX : null ); }
php
public static function asset($relative_path, $include_version=true) { $clean_relative_path = preg_replace('/^[\/_]+/', '', $relative_path); return sprintf( '%s/_/%s%s', THEME_URL, $clean_relative_path, ($include_version) ? THEME_SUFFIX : null ); }
[ "public", "static", "function", "asset", "(", "$", "relative_path", ",", "$", "include_version", "=", "true", ")", "{", "$", "clean_relative_path", "=", "preg_replace", "(", "'/^[\\/_]+/'", ",", "''", ",", "$", "relative_path", ")", ";", "return", "sprintf", "(", "'%s/_/%s%s'", ",", "THEME_URL", ",", "$", "clean_relative_path", ",", "(", "$", "include_version", ")", "?", "THEME_SUFFIX", ":", "null", ")", ";", "}" ]
Get the asset path @param string $relative_path @param bool $include_version @return string
[ "Get", "the", "asset", "path" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Theme.php#L98-L106
8,931
tacowordpress/util
src/Util/Theme.php
Theme.optionsLink
public static function optionsLink($description=null, $display_inline=false) { if(!(is_user_logged_in() && current_user_can('manage_options'))) return null; if(is_null($description)) { $description = 'this'; } $options = AppOption::getInstance(); return self::editLink($options->ID, 'app-option', $description.' in options', $display_inline); }
php
public static function optionsLink($description=null, $display_inline=false) { if(!(is_user_logged_in() && current_user_can('manage_options'))) return null; if(is_null($description)) { $description = 'this'; } $options = AppOption::getInstance(); return self::editLink($options->ID, 'app-option', $description.' in options', $display_inline); }
[ "public", "static", "function", "optionsLink", "(", "$", "description", "=", "null", ",", "$", "display_inline", "=", "false", ")", "{", "if", "(", "!", "(", "is_user_logged_in", "(", ")", "&&", "current_user_can", "(", "'manage_options'", ")", ")", ")", "return", "null", ";", "if", "(", "is_null", "(", "$", "description", ")", ")", "{", "$", "description", "=", "'this'", ";", "}", "$", "options", "=", "AppOption", "::", "getInstance", "(", ")", ";", "return", "self", "::", "editLink", "(", "$", "options", "->", "ID", ",", "'app-option'", ",", "$", "description", ".", "' in options'", ",", "$", "display_inline", ")", ";", "}" ]
Get App Options link when admin is logged in @param string $description @param bool $display_inline @return string
[ "Get", "App", "Options", "link", "when", "admin", "is", "logged", "in" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Theme.php#L206-L214
8,932
tacowordpress/util
src/Util/Theme.php
Theme.pageTitle
public static function pageTitle() { $short_site_name = Config::get()->site_name; $separator = self::pageTitleSeparator(); $title = wp_title(null, false); // From an SEO/SEM perspective, appending the site name to the title is // superfluous if the title already contains some form of the site name, as // may be the case with press releases and other news-related posts $title_has_site_name = (strpos($title, $short_site_name) !== false); if(!empty($title) && $title_has_site_name) { return $title; } $site_name = get_bloginfo('name'); if(!empty($title)) { return $title.$separator.$site_name; } global $post; $this_post = $post; // Create Taco post only if $post is not already a Taco object if(!is_subclass_of($post, 'Taco\Base')) { $this_post = \Taco\Post\Factory::create($post); } $page_title_taxonomy = $this_post->pageTitleTaxonomy(); if(Config::get()->use_yoast) { $yoast_title = $this_post->getSafe('_yoast_wpseo_title'); $yoast_title_has_site_name = preg_match('/'.$site_name.'$/', $yoast_title); if(!empty($yoast_title) && $yoast_title_has_site_name) { return $yoast_title; } if(!empty($yoast_title)) { return $yoast_title.$separator.$site_name; } } if(empty($page_title_taxonomy)) { return $this_post->getTheTitle().$separator.$site_name; } $term_name = null; $terms = $this_post->getTerms($page_title_taxonomy); if(!empty($terms)) { $primary_term_id = $this_post->{'_yoast_wpseo_primary_'.$page_title_taxonomy}; $term = (!empty($primary_term_id)) ? $terms[$primary_term_id] : reset($terms); $term_name = $separator.$term->name; } return $this_post->getTheTitle().$term_name.$separator.$site_name; }
php
public static function pageTitle() { $short_site_name = Config::get()->site_name; $separator = self::pageTitleSeparator(); $title = wp_title(null, false); // From an SEO/SEM perspective, appending the site name to the title is // superfluous if the title already contains some form of the site name, as // may be the case with press releases and other news-related posts $title_has_site_name = (strpos($title, $short_site_name) !== false); if(!empty($title) && $title_has_site_name) { return $title; } $site_name = get_bloginfo('name'); if(!empty($title)) { return $title.$separator.$site_name; } global $post; $this_post = $post; // Create Taco post only if $post is not already a Taco object if(!is_subclass_of($post, 'Taco\Base')) { $this_post = \Taco\Post\Factory::create($post); } $page_title_taxonomy = $this_post->pageTitleTaxonomy(); if(Config::get()->use_yoast) { $yoast_title = $this_post->getSafe('_yoast_wpseo_title'); $yoast_title_has_site_name = preg_match('/'.$site_name.'$/', $yoast_title); if(!empty($yoast_title) && $yoast_title_has_site_name) { return $yoast_title; } if(!empty($yoast_title)) { return $yoast_title.$separator.$site_name; } } if(empty($page_title_taxonomy)) { return $this_post->getTheTitle().$separator.$site_name; } $term_name = null; $terms = $this_post->getTerms($page_title_taxonomy); if(!empty($terms)) { $primary_term_id = $this_post->{'_yoast_wpseo_primary_'.$page_title_taxonomy}; $term = (!empty($primary_term_id)) ? $terms[$primary_term_id] : reset($terms); $term_name = $separator.$term->name; } return $this_post->getTheTitle().$term_name.$separator.$site_name; }
[ "public", "static", "function", "pageTitle", "(", ")", "{", "$", "short_site_name", "=", "Config", "::", "get", "(", ")", "->", "site_name", ";", "$", "separator", "=", "self", "::", "pageTitleSeparator", "(", ")", ";", "$", "title", "=", "wp_title", "(", "null", ",", "false", ")", ";", "// From an SEO/SEM perspective, appending the site name to the title is", "// superfluous if the title already contains some form of the site name, as", "// may be the case with press releases and other news-related posts", "$", "title_has_site_name", "=", "(", "strpos", "(", "$", "title", ",", "$", "short_site_name", ")", "!==", "false", ")", ";", "if", "(", "!", "empty", "(", "$", "title", ")", "&&", "$", "title_has_site_name", ")", "{", "return", "$", "title", ";", "}", "$", "site_name", "=", "get_bloginfo", "(", "'name'", ")", ";", "if", "(", "!", "empty", "(", "$", "title", ")", ")", "{", "return", "$", "title", ".", "$", "separator", ".", "$", "site_name", ";", "}", "global", "$", "post", ";", "$", "this_post", "=", "$", "post", ";", "// Create Taco post only if $post is not already a Taco object", "if", "(", "!", "is_subclass_of", "(", "$", "post", ",", "'Taco\\Base'", ")", ")", "{", "$", "this_post", "=", "\\", "Taco", "\\", "Post", "\\", "Factory", "::", "create", "(", "$", "post", ")", ";", "}", "$", "page_title_taxonomy", "=", "$", "this_post", "->", "pageTitleTaxonomy", "(", ")", ";", "if", "(", "Config", "::", "get", "(", ")", "->", "use_yoast", ")", "{", "$", "yoast_title", "=", "$", "this_post", "->", "getSafe", "(", "'_yoast_wpseo_title'", ")", ";", "$", "yoast_title_has_site_name", "=", "preg_match", "(", "'/'", ".", "$", "site_name", ".", "'$/'", ",", "$", "yoast_title", ")", ";", "if", "(", "!", "empty", "(", "$", "yoast_title", ")", "&&", "$", "yoast_title_has_site_name", ")", "{", "return", "$", "yoast_title", ";", "}", "if", "(", "!", "empty", "(", "$", "yoast_title", ")", ")", "{", "return", "$", "yoast_title", ".", "$", "separator", ".", "$", "site_name", ";", "}", "}", "if", "(", "empty", "(", "$", "page_title_taxonomy", ")", ")", "{", "return", "$", "this_post", "->", "getTheTitle", "(", ")", ".", "$", "separator", ".", "$", "site_name", ";", "}", "$", "term_name", "=", "null", ";", "$", "terms", "=", "$", "this_post", "->", "getTerms", "(", "$", "page_title_taxonomy", ")", ";", "if", "(", "!", "empty", "(", "$", "terms", ")", ")", "{", "$", "primary_term_id", "=", "$", "this_post", "->", "{", "'_yoast_wpseo_primary_'", ".", "$", "page_title_taxonomy", "}", ";", "$", "term", "=", "(", "!", "empty", "(", "$", "primary_term_id", ")", ")", "?", "$", "terms", "[", "$", "primary_term_id", "]", ":", "reset", "(", "$", "terms", ")", ";", "$", "term_name", "=", "$", "separator", ".", "$", "term", "->", "name", ";", "}", "return", "$", "this_post", "->", "getTheTitle", "(", ")", ".", "$", "term_name", ".", "$", "separator", ".", "$", "site_name", ";", "}" ]
Get the page title @return string
[ "Get", "the", "page", "title" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Theme.php#L221-L275
8,933
tacowordpress/util
src/Util/Theme.php
Theme.pageMeta
public static function pageMeta() { $title = wp_title(null, false); // If the title is not empty, we can assume that we're not bypassing // WordPress routing, and therefore Yoast will give us all the meta tags if(!empty($title)) return null; global $post; $this_post = $post; // Create Taco post only if $post is not already a Taco object if(!is_subclass_of($post, 'Taco\Base')) { $this_post = \Taco\Post\Factory::create($post, false); } if(!Obj::iterable($this_post)) return null; $description = null; if(Config::get()->use_yoast) { $description = $this_post->getSafe('_yoast_wpseo_metadesc'); } if(empty($description)) { $description = strip_tags($this_post->getTheExcerpt()); } $image = (Config::get()->use_yoast) ? $this_post->{'_yoast_wpseo_opengraph-image'} : null; return View::make('meta-tags', [ 'title' => self::pageTitle(), 'description' => trim($description), 'image' => $image, 'full_url' => URL_REQUEST, 'site_name' => get_bloginfo('name'), 'separator' => self::pageTitleSeparator(), ]); }
php
public static function pageMeta() { $title = wp_title(null, false); // If the title is not empty, we can assume that we're not bypassing // WordPress routing, and therefore Yoast will give us all the meta tags if(!empty($title)) return null; global $post; $this_post = $post; // Create Taco post only if $post is not already a Taco object if(!is_subclass_of($post, 'Taco\Base')) { $this_post = \Taco\Post\Factory::create($post, false); } if(!Obj::iterable($this_post)) return null; $description = null; if(Config::get()->use_yoast) { $description = $this_post->getSafe('_yoast_wpseo_metadesc'); } if(empty($description)) { $description = strip_tags($this_post->getTheExcerpt()); } $image = (Config::get()->use_yoast) ? $this_post->{'_yoast_wpseo_opengraph-image'} : null; return View::make('meta-tags', [ 'title' => self::pageTitle(), 'description' => trim($description), 'image' => $image, 'full_url' => URL_REQUEST, 'site_name' => get_bloginfo('name'), 'separator' => self::pageTitleSeparator(), ]); }
[ "public", "static", "function", "pageMeta", "(", ")", "{", "$", "title", "=", "wp_title", "(", "null", ",", "false", ")", ";", "// If the title is not empty, we can assume that we're not bypassing", "// WordPress routing, and therefore Yoast will give us all the meta tags", "if", "(", "!", "empty", "(", "$", "title", ")", ")", "return", "null", ";", "global", "$", "post", ";", "$", "this_post", "=", "$", "post", ";", "// Create Taco post only if $post is not already a Taco object", "if", "(", "!", "is_subclass_of", "(", "$", "post", ",", "'Taco\\Base'", ")", ")", "{", "$", "this_post", "=", "\\", "Taco", "\\", "Post", "\\", "Factory", "::", "create", "(", "$", "post", ",", "false", ")", ";", "}", "if", "(", "!", "Obj", "::", "iterable", "(", "$", "this_post", ")", ")", "return", "null", ";", "$", "description", "=", "null", ";", "if", "(", "Config", "::", "get", "(", ")", "->", "use_yoast", ")", "{", "$", "description", "=", "$", "this_post", "->", "getSafe", "(", "'_yoast_wpseo_metadesc'", ")", ";", "}", "if", "(", "empty", "(", "$", "description", ")", ")", "{", "$", "description", "=", "strip_tags", "(", "$", "this_post", "->", "getTheExcerpt", "(", ")", ")", ";", "}", "$", "image", "=", "(", "Config", "::", "get", "(", ")", "->", "use_yoast", ")", "?", "$", "this_post", "->", "{", "'_yoast_wpseo_opengraph-image'", "}", ":", "null", ";", "return", "View", "::", "make", "(", "'meta-tags'", ",", "[", "'title'", "=>", "self", "::", "pageTitle", "(", ")", ",", "'description'", "=>", "trim", "(", "$", "description", ")", ",", "'image'", "=>", "$", "image", ",", "'full_url'", "=>", "URL_REQUEST", ",", "'site_name'", "=>", "get_bloginfo", "(", "'name'", ")", ",", "'separator'", "=>", "self", "::", "pageTitleSeparator", "(", ")", ",", "]", ")", ";", "}" ]
Get the page meta tags @return string
[ "Get", "the", "page", "meta", "tags" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Theme.php#L293-L330
8,934
tacowordpress/util
src/Util/Theme.php
Theme.appIcons
public static function appIcons() { $config = Config::instance(); $icons_directory = THEME_DIRECTORY.'/'.$config->app_icons_directory; $icons_url = THEME_URL.'/'.$config->app_icons_directory; if(!file_exists($icons_directory)) return null; $files = scandir($icons_directory); if(!Arr::iterable($files)) return null; // Icon files should start with one of these, and be delimited by hyphens $icon_types = ['apple', 'android', 'favicon']; $paths = []; foreach($files as $file) { if(!preg_match('/\.png$/', $file)) continue; // Get size from image name preg_match('/(\d+x\d+)/', $file, $sizes); if(!Arr::iterable($sizes)) continue; $size = reset($sizes); $icon_type = reset(explode('-', $file)); if(!in_array($icon_type, $icon_types)) continue; $file_path = $icons_url.'/'.$file; $paths[] = View::make('meta/icon-'.$icon_type, [ 'file' => $file_path, 'size' => $size, ]); } $paths[] = View::make('meta/icon-favicon-ico', [ 'file' => $icons_url.'/favicon.ico', ]); return join('', $paths); }
php
public static function appIcons() { $config = Config::instance(); $icons_directory = THEME_DIRECTORY.'/'.$config->app_icons_directory; $icons_url = THEME_URL.'/'.$config->app_icons_directory; if(!file_exists($icons_directory)) return null; $files = scandir($icons_directory); if(!Arr::iterable($files)) return null; // Icon files should start with one of these, and be delimited by hyphens $icon_types = ['apple', 'android', 'favicon']; $paths = []; foreach($files as $file) { if(!preg_match('/\.png$/', $file)) continue; // Get size from image name preg_match('/(\d+x\d+)/', $file, $sizes); if(!Arr::iterable($sizes)) continue; $size = reset($sizes); $icon_type = reset(explode('-', $file)); if(!in_array($icon_type, $icon_types)) continue; $file_path = $icons_url.'/'.$file; $paths[] = View::make('meta/icon-'.$icon_type, [ 'file' => $file_path, 'size' => $size, ]); } $paths[] = View::make('meta/icon-favicon-ico', [ 'file' => $icons_url.'/favicon.ico', ]); return join('', $paths); }
[ "public", "static", "function", "appIcons", "(", ")", "{", "$", "config", "=", "Config", "::", "instance", "(", ")", ";", "$", "icons_directory", "=", "THEME_DIRECTORY", ".", "'/'", ".", "$", "config", "->", "app_icons_directory", ";", "$", "icons_url", "=", "THEME_URL", ".", "'/'", ".", "$", "config", "->", "app_icons_directory", ";", "if", "(", "!", "file_exists", "(", "$", "icons_directory", ")", ")", "return", "null", ";", "$", "files", "=", "scandir", "(", "$", "icons_directory", ")", ";", "if", "(", "!", "Arr", "::", "iterable", "(", "$", "files", ")", ")", "return", "null", ";", "// Icon files should start with one of these, and be delimited by hyphens", "$", "icon_types", "=", "[", "'apple'", ",", "'android'", ",", "'favicon'", "]", ";", "$", "paths", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "!", "preg_match", "(", "'/\\.png$/'", ",", "$", "file", ")", ")", "continue", ";", "// Get size from image name", "preg_match", "(", "'/(\\d+x\\d+)/'", ",", "$", "file", ",", "$", "sizes", ")", ";", "if", "(", "!", "Arr", "::", "iterable", "(", "$", "sizes", ")", ")", "continue", ";", "$", "size", "=", "reset", "(", "$", "sizes", ")", ";", "$", "icon_type", "=", "reset", "(", "explode", "(", "'-'", ",", "$", "file", ")", ")", ";", "if", "(", "!", "in_array", "(", "$", "icon_type", ",", "$", "icon_types", ")", ")", "continue", ";", "$", "file_path", "=", "$", "icons_url", ".", "'/'", ".", "$", "file", ";", "$", "paths", "[", "]", "=", "View", "::", "make", "(", "'meta/icon-'", ".", "$", "icon_type", ",", "[", "'file'", "=>", "$", "file_path", ",", "'size'", "=>", "$", "size", ",", "]", ")", ";", "}", "$", "paths", "[", "]", "=", "View", "::", "make", "(", "'meta/icon-favicon-ico'", ",", "[", "'file'", "=>", "$", "icons_url", ".", "'/favicon.ico'", ",", "]", ")", ";", "return", "join", "(", "''", ",", "$", "paths", ")", ";", "}" ]
Get HTML for all icons @link http://www.favicon-generator.org/ @return string
[ "Get", "HTML", "for", "all", "icons" ]
a27f6f1c3f96a908c7480f359fd44028e89f26c3
https://github.com/tacowordpress/util/blob/a27f6f1c3f96a908c7480f359fd44028e89f26c3/src/Util/Theme.php#L338-L373
8,935
chenwenzhang/initially-rpc
src/Initially/Rpc/Proxy/BuilderAbstract.php
BuilderAbstract.create
public function create($interface) { if (!Util::existsDirWritable($this->config->getProxyRootDir())) { throw new InitiallyRpcException("Proxy builder error: proxy class root dir not to be write"); } $this->interface = $interface; $this->reflectionInterfaceAndCheck(); $this->service = $this->config->getServiceByKey($this->interface); $info = $this->parseProxyClassInfo(); $dir = $this->getProxyClassDirAndCreate($info->getNamespace()); $file = sprintf("%s/%s.php", $dir, $info->getClassName()); $methodString = ""; foreach ($this->refectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { $methodString .= $this->buildMethod($method); } $useString = ""; $this->useList = array_unique($this->useList); foreach ($this->useList as $value) { $useString .= "use {$value};" . PHP_EOL; } $replaces = array( $info->getNamespace(), $useString, $this->refectionClass->getDocComment(), $info->getClassName(), sprintf("\\%s", $this->refectionClass->getName()), str_replace("\\", "\\\\", $this->refectionClass->getName()), $methodString ); $content = str_replace(self::CLASS_TPL_SEARCHES, $replaces, $this->template->getClassTemplate()); if (!@file_put_contents($file, $content)) { throw new InitiallyRpcException("Proxy builder error: proxy class code write failed"); } $this->clear(); }
php
public function create($interface) { if (!Util::existsDirWritable($this->config->getProxyRootDir())) { throw new InitiallyRpcException("Proxy builder error: proxy class root dir not to be write"); } $this->interface = $interface; $this->reflectionInterfaceAndCheck(); $this->service = $this->config->getServiceByKey($this->interface); $info = $this->parseProxyClassInfo(); $dir = $this->getProxyClassDirAndCreate($info->getNamespace()); $file = sprintf("%s/%s.php", $dir, $info->getClassName()); $methodString = ""; foreach ($this->refectionClass->getMethods(ReflectionMethod::IS_PUBLIC) as $method) { $methodString .= $this->buildMethod($method); } $useString = ""; $this->useList = array_unique($this->useList); foreach ($this->useList as $value) { $useString .= "use {$value};" . PHP_EOL; } $replaces = array( $info->getNamespace(), $useString, $this->refectionClass->getDocComment(), $info->getClassName(), sprintf("\\%s", $this->refectionClass->getName()), str_replace("\\", "\\\\", $this->refectionClass->getName()), $methodString ); $content = str_replace(self::CLASS_TPL_SEARCHES, $replaces, $this->template->getClassTemplate()); if (!@file_put_contents($file, $content)) { throw new InitiallyRpcException("Proxy builder error: proxy class code write failed"); } $this->clear(); }
[ "public", "function", "create", "(", "$", "interface", ")", "{", "if", "(", "!", "Util", "::", "existsDirWritable", "(", "$", "this", "->", "config", "->", "getProxyRootDir", "(", ")", ")", ")", "{", "throw", "new", "InitiallyRpcException", "(", "\"Proxy builder error: proxy class root dir not to be write\"", ")", ";", "}", "$", "this", "->", "interface", "=", "$", "interface", ";", "$", "this", "->", "reflectionInterfaceAndCheck", "(", ")", ";", "$", "this", "->", "service", "=", "$", "this", "->", "config", "->", "getServiceByKey", "(", "$", "this", "->", "interface", ")", ";", "$", "info", "=", "$", "this", "->", "parseProxyClassInfo", "(", ")", ";", "$", "dir", "=", "$", "this", "->", "getProxyClassDirAndCreate", "(", "$", "info", "->", "getNamespace", "(", ")", ")", ";", "$", "file", "=", "sprintf", "(", "\"%s/%s.php\"", ",", "$", "dir", ",", "$", "info", "->", "getClassName", "(", ")", ")", ";", "$", "methodString", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "refectionClass", "->", "getMethods", "(", "ReflectionMethod", "::", "IS_PUBLIC", ")", "as", "$", "method", ")", "{", "$", "methodString", ".=", "$", "this", "->", "buildMethod", "(", "$", "method", ")", ";", "}", "$", "useString", "=", "\"\"", ";", "$", "this", "->", "useList", "=", "array_unique", "(", "$", "this", "->", "useList", ")", ";", "foreach", "(", "$", "this", "->", "useList", "as", "$", "value", ")", "{", "$", "useString", ".=", "\"use {$value};\"", ".", "PHP_EOL", ";", "}", "$", "replaces", "=", "array", "(", "$", "info", "->", "getNamespace", "(", ")", ",", "$", "useString", ",", "$", "this", "->", "refectionClass", "->", "getDocComment", "(", ")", ",", "$", "info", "->", "getClassName", "(", ")", ",", "sprintf", "(", "\"\\\\%s\"", ",", "$", "this", "->", "refectionClass", "->", "getName", "(", ")", ")", ",", "str_replace", "(", "\"\\\\\"", ",", "\"\\\\\\\\\"", ",", "$", "this", "->", "refectionClass", "->", "getName", "(", ")", ")", ",", "$", "methodString", ")", ";", "$", "content", "=", "str_replace", "(", "self", "::", "CLASS_TPL_SEARCHES", ",", "$", "replaces", ",", "$", "this", "->", "template", "->", "getClassTemplate", "(", ")", ")", ";", "if", "(", "!", "@", "file_put_contents", "(", "$", "file", ",", "$", "content", ")", ")", "{", "throw", "new", "InitiallyRpcException", "(", "\"Proxy builder error: proxy class code write failed\"", ")", ";", "}", "$", "this", "->", "clear", "(", ")", ";", "}" ]
Create proxy class @param string $interface @throws InitiallyRpcException
[ "Create", "proxy", "class" ]
43d56eb3749bedd3f4ee83e57676f7bb6b89e682
https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Proxy/BuilderAbstract.php#L80-L119
8,936
chenwenzhang/initially-rpc
src/Initially/Rpc/Proxy/BuilderAbstract.php
BuilderAbstract.parseProxyClassInfo
protected function parseProxyClassInfo() { $arr = explode("\\", $this->interface); $name = array_pop($arr); $matches = array(); if (!preg_match($this->getClassNameRule(), $name, $matches)) { throw new InitiallyRpcException("Proxy builder error: interface name must ending of '{$this->interfaceEndOf}' like 'DemoService{$this->interfaceEndOf}'"); } $replace = $this->config->getReplace(); $replaceKey = $this->service->getReplaceKey(); if (!empty($arr) && !empty($replace) && isset($replace[$replaceKey])) { foreach ($arr as $key => $value) { if (isset($replace[$replaceKey][$value])) { $arr[$key] = $replace[$replaceKey][$value]; } } } $namespace = implode("\\", $arr); $info = new ProxyClassInfo(); $info->setNamespace($namespace); $info->setClassName($matches[1]); return $info; }
php
protected function parseProxyClassInfo() { $arr = explode("\\", $this->interface); $name = array_pop($arr); $matches = array(); if (!preg_match($this->getClassNameRule(), $name, $matches)) { throw new InitiallyRpcException("Proxy builder error: interface name must ending of '{$this->interfaceEndOf}' like 'DemoService{$this->interfaceEndOf}'"); } $replace = $this->config->getReplace(); $replaceKey = $this->service->getReplaceKey(); if (!empty($arr) && !empty($replace) && isset($replace[$replaceKey])) { foreach ($arr as $key => $value) { if (isset($replace[$replaceKey][$value])) { $arr[$key] = $replace[$replaceKey][$value]; } } } $namespace = implode("\\", $arr); $info = new ProxyClassInfo(); $info->setNamespace($namespace); $info->setClassName($matches[1]); return $info; }
[ "protected", "function", "parseProxyClassInfo", "(", ")", "{", "$", "arr", "=", "explode", "(", "\"\\\\\"", ",", "$", "this", "->", "interface", ")", ";", "$", "name", "=", "array_pop", "(", "$", "arr", ")", ";", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "!", "preg_match", "(", "$", "this", "->", "getClassNameRule", "(", ")", ",", "$", "name", ",", "$", "matches", ")", ")", "{", "throw", "new", "InitiallyRpcException", "(", "\"Proxy builder error: interface name must ending of '{$this->interfaceEndOf}' like 'DemoService{$this->interfaceEndOf}'\"", ")", ";", "}", "$", "replace", "=", "$", "this", "->", "config", "->", "getReplace", "(", ")", ";", "$", "replaceKey", "=", "$", "this", "->", "service", "->", "getReplaceKey", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "arr", ")", "&&", "!", "empty", "(", "$", "replace", ")", "&&", "isset", "(", "$", "replace", "[", "$", "replaceKey", "]", ")", ")", "{", "foreach", "(", "$", "arr", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "replace", "[", "$", "replaceKey", "]", "[", "$", "value", "]", ")", ")", "{", "$", "arr", "[", "$", "key", "]", "=", "$", "replace", "[", "$", "replaceKey", "]", "[", "$", "value", "]", ";", "}", "}", "}", "$", "namespace", "=", "implode", "(", "\"\\\\\"", ",", "$", "arr", ")", ";", "$", "info", "=", "new", "ProxyClassInfo", "(", ")", ";", "$", "info", "->", "setNamespace", "(", "$", "namespace", ")", ";", "$", "info", "->", "setClassName", "(", "$", "matches", "[", "1", "]", ")", ";", "return", "$", "info", ";", "}" ]
Parse interface info @return ProxyClassInfo @throws InitiallyRpcException
[ "Parse", "interface", "info" ]
43d56eb3749bedd3f4ee83e57676f7bb6b89e682
https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Proxy/BuilderAbstract.php#L138-L163
8,937
chenwenzhang/initially-rpc
src/Initially/Rpc/Proxy/BuilderAbstract.php
BuilderAbstract.getProxyClassDirAndCreate
protected function getProxyClassDirAndCreate($namespace) { $path = str_replace("\\", DIRECTORY_SEPARATOR, $namespace); $dir = $this->config->getProxyRootDir() . DIRECTORY_SEPARATOR . $path; if (!Util::createDirIfNotExists($dir)) { throw new InitiallyRpcException("Proxy builder error: get proxy class dir and create it"); } return $dir; }
php
protected function getProxyClassDirAndCreate($namespace) { $path = str_replace("\\", DIRECTORY_SEPARATOR, $namespace); $dir = $this->config->getProxyRootDir() . DIRECTORY_SEPARATOR . $path; if (!Util::createDirIfNotExists($dir)) { throw new InitiallyRpcException("Proxy builder error: get proxy class dir and create it"); } return $dir; }
[ "protected", "function", "getProxyClassDirAndCreate", "(", "$", "namespace", ")", "{", "$", "path", "=", "str_replace", "(", "\"\\\\\"", ",", "DIRECTORY_SEPARATOR", ",", "$", "namespace", ")", ";", "$", "dir", "=", "$", "this", "->", "config", "->", "getProxyRootDir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "path", ";", "if", "(", "!", "Util", "::", "createDirIfNotExists", "(", "$", "dir", ")", ")", "{", "throw", "new", "InitiallyRpcException", "(", "\"Proxy builder error: get proxy class dir and create it\"", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Get proxy class dir and create it @param string $namespace @return string @throws InitiallyRpcException
[ "Get", "proxy", "class", "dir", "and", "create", "it" ]
43d56eb3749bedd3f4ee83e57676f7bb6b89e682
https://github.com/chenwenzhang/initially-rpc/blob/43d56eb3749bedd3f4ee83e57676f7bb6b89e682/src/Initially/Rpc/Proxy/BuilderAbstract.php#L172-L181
8,938
kettari/tallanto-client-api-bundle
Api/Method/TallantoCreateContactMethod.php
TallantoCreateContactMethod.getResult
public function getResult() { $arrayData = $this->decode( $this->getResponse() ->getBody() ->getContents() ); if (is_array($arrayData) && count($arrayData)) { $singleItem = reset($arrayData); } else { throw new ResponseDecodeException('Response has bad format.'); } return new Contact($singleItem); }
php
public function getResult() { $arrayData = $this->decode( $this->getResponse() ->getBody() ->getContents() ); if (is_array($arrayData) && count($arrayData)) { $singleItem = reset($arrayData); } else { throw new ResponseDecodeException('Response has bad format.'); } return new Contact($singleItem); }
[ "public", "function", "getResult", "(", ")", "{", "$", "arrayData", "=", "$", "this", "->", "decode", "(", "$", "this", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ")", ";", "if", "(", "is_array", "(", "$", "arrayData", ")", "&&", "count", "(", "$", "arrayData", ")", ")", "{", "$", "singleItem", "=", "reset", "(", "$", "arrayData", ")", ";", "}", "else", "{", "throw", "new", "ResponseDecodeException", "(", "'Response has bad format.'", ")", ";", "}", "return", "new", "Contact", "(", "$", "singleItem", ")", ";", "}" ]
Returns useful result of operation. @return \Tallanto\Api\Entity\Contact @throws \Tallanto\ClientApiBundle\Exception\ResponseDecodeException
[ "Returns", "useful", "result", "of", "operation", "." ]
09863d2b0fed306cc1218ed602ba6c6ad461c3da
https://github.com/kettari/tallanto-client-api-bundle/blob/09863d2b0fed306cc1218ed602ba6c6ad461c3da/Api/Method/TallantoCreateContactMethod.php#L61-L75
8,939
kettari/tallanto-client-api-bundle
Api/Method/TallantoCreateContactMethod.php
TallantoCreateContactMethod.decode
private function decode($json) { $decodedResult = json_decode($json, true); if (JSON_ERROR_NONE != json_last_error()) { throw new ResponseDecodeException('JSON error: '.json_last_error_msg()); } return $decodedResult; }
php
private function decode($json) { $decodedResult = json_decode($json, true); if (JSON_ERROR_NONE != json_last_error()) { throw new ResponseDecodeException('JSON error: '.json_last_error_msg()); } return $decodedResult; }
[ "private", "function", "decode", "(", "$", "json", ")", "{", "$", "decodedResult", "=", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "JSON_ERROR_NONE", "!=", "json_last_error", "(", ")", ")", "{", "throw", "new", "ResponseDecodeException", "(", "'JSON error: '", ".", "json_last_error_msg", "(", ")", ")", ";", "}", "return", "$", "decodedResult", ";", "}" ]
Parses and validates request parameters. @param $json @return array @throws \Tallanto\ClientApiBundle\Exception\ResponseDecodeException
[ "Parses", "and", "validates", "request", "parameters", "." ]
09863d2b0fed306cc1218ed602ba6c6ad461c3da
https://github.com/kettari/tallanto-client-api-bundle/blob/09863d2b0fed306cc1218ed602ba6c6ad461c3da/Api/Method/TallantoCreateContactMethod.php#L84-L92
8,940
traceguide/api-php
lib/Client/ClientRuntime.php
ClientRuntime.flushIfNeeded
protected function flushIfNeeded() { if (!$this->_enabled) { return; } $now = $this->_util->nowMicros(); $delta = $now - $this->_lastFlushMicros; // Set a bound on maximum flush frequency if ($delta < $this->_minFlushPeriodMicros) { return; } // Set a bound of minimum flush frequency if ($delta > $this->_maxFlushPeriodMicros) { $this->flush(); return; } // Look for a trigger that a flush is warranted if (count($this->_logRecords) >= $this->_options["max_log_records"]) { $this->flush(); return; } if (count($this->_spanRecords) >= $this->_options["max_span_records"]) { $this->flush(); return; } }
php
protected function flushIfNeeded() { if (!$this->_enabled) { return; } $now = $this->_util->nowMicros(); $delta = $now - $this->_lastFlushMicros; // Set a bound on maximum flush frequency if ($delta < $this->_minFlushPeriodMicros) { return; } // Set a bound of minimum flush frequency if ($delta > $this->_maxFlushPeriodMicros) { $this->flush(); return; } // Look for a trigger that a flush is warranted if (count($this->_logRecords) >= $this->_options["max_log_records"]) { $this->flush(); return; } if (count($this->_spanRecords) >= $this->_options["max_span_records"]) { $this->flush(); return; } }
[ "protected", "function", "flushIfNeeded", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_enabled", ")", "{", "return", ";", "}", "$", "now", "=", "$", "this", "->", "_util", "->", "nowMicros", "(", ")", ";", "$", "delta", "=", "$", "now", "-", "$", "this", "->", "_lastFlushMicros", ";", "// Set a bound on maximum flush frequency", "if", "(", "$", "delta", "<", "$", "this", "->", "_minFlushPeriodMicros", ")", "{", "return", ";", "}", "// Set a bound of minimum flush frequency", "if", "(", "$", "delta", ">", "$", "this", "->", "_maxFlushPeriodMicros", ")", "{", "$", "this", "->", "flush", "(", ")", ";", "return", ";", "}", "// Look for a trigger that a flush is warranted", "if", "(", "count", "(", "$", "this", "->", "_logRecords", ")", ">=", "$", "this", "->", "_options", "[", "\"max_log_records\"", "]", ")", "{", "$", "this", "->", "flush", "(", ")", ";", "return", ";", "}", "if", "(", "count", "(", "$", "this", "->", "_spanRecords", ")", ">=", "$", "this", "->", "_options", "[", "\"max_span_records\"", "]", ")", "{", "$", "this", "->", "flush", "(", ")", ";", "return", ";", "}", "}" ]
new data comes in by calling this method.
[ "new", "data", "comes", "in", "by", "calling", "this", "method", "." ]
05d7958732b0e82a7b33bf55db4ef1b1fc6a9136
https://github.com/traceguide/api-php/blob/05d7958732b0e82a7b33bf55db4ef1b1fc6a9136/lib/Client/ClientRuntime.php#L254-L282
8,941
traceguide/api-php
lib/Client/ClientRuntime.php
ClientRuntime._log
public function _log($level, $fmt, $allArgs) { // The $allArgs variable contains the $fmt string array_shift($allArgs); $text = vsprintf($fmt, $allArgs); $this->_rawLogRecord(array( 'level' => $level, 'message' => $text, ), $allArgs); $this->flushIfNeeded(); return $text; }
php
public function _log($level, $fmt, $allArgs) { // The $allArgs variable contains the $fmt string array_shift($allArgs); $text = vsprintf($fmt, $allArgs); $this->_rawLogRecord(array( 'level' => $level, 'message' => $text, ), $allArgs); $this->flushIfNeeded(); return $text; }
[ "public", "function", "_log", "(", "$", "level", ",", "$", "fmt", ",", "$", "allArgs", ")", "{", "// The $allArgs variable contains the $fmt string", "array_shift", "(", "$", "allArgs", ")", ";", "$", "text", "=", "vsprintf", "(", "$", "fmt", ",", "$", "allArgs", ")", ";", "$", "this", "->", "_rawLogRecord", "(", "array", "(", "'level'", "=>", "$", "level", ",", "'message'", "=>", "$", "text", ",", ")", ",", "$", "allArgs", ")", ";", "$", "this", "->", "flushIfNeeded", "(", ")", ";", "return", "$", "text", ";", "}" ]
For internal use only.
[ "For", "internal", "use", "only", "." ]
05d7958732b0e82a7b33bf55db4ef1b1fc6a9136
https://github.com/traceguide/api-php/blob/05d7958732b0e82a7b33bf55db4ef1b1fc6a9136/lib/Client/ClientRuntime.php#L426-L438
8,942
routegroup/native-media
src/Upload/Storage.php
Storage.setFilename
protected function setFilename($filename) { $parts = explode('.', $filename); $extension = array_pop($parts); $name = time() . '-' . str_slug(str_random(35)); return "{$name}.{$extension}"; }
php
protected function setFilename($filename) { $parts = explode('.', $filename); $extension = array_pop($parts); $name = time() . '-' . str_slug(str_random(35)); return "{$name}.{$extension}"; }
[ "protected", "function", "setFilename", "(", "$", "filename", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "filename", ")", ";", "$", "extension", "=", "array_pop", "(", "$", "parts", ")", ";", "$", "name", "=", "time", "(", ")", ".", "'-'", ".", "str_slug", "(", "str_random", "(", "35", ")", ")", ";", "return", "\"{$name}.{$extension}\"", ";", "}" ]
Change filename. @param string $filename @return string
[ "Change", "filename", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Upload/Storage.php#L61-L70
8,943
expressly/php-common
src/Subscriber/CustomerMigrationSubscriber.php
CustomerMigrationSubscriber.getPopup
public function getPopup(CustomerMigrateEvent $event) { $route = $this->routeProvider->customer_migrate_popup; $route->setParameters(array( 'uuid' => $event->getUuid() )); $response = $route->process(function ($request) use ($event) { $request->addHeader($event->getBasicHeader()); }); $event->setResponse($response); }
php
public function getPopup(CustomerMigrateEvent $event) { $route = $this->routeProvider->customer_migrate_popup; $route->setParameters(array( 'uuid' => $event->getUuid() )); $response = $route->process(function ($request) use ($event) { $request->addHeader($event->getBasicHeader()); }); $event->setResponse($response); }
[ "public", "function", "getPopup", "(", "CustomerMigrateEvent", "$", "event", ")", "{", "$", "route", "=", "$", "this", "->", "routeProvider", "->", "customer_migrate_popup", ";", "$", "route", "->", "setParameters", "(", "array", "(", "'uuid'", "=>", "$", "event", "->", "getUuid", "(", ")", ")", ")", ";", "$", "response", "=", "$", "route", "->", "process", "(", "function", "(", "$", "request", ")", "use", "(", "$", "event", ")", "{", "$", "request", "->", "addHeader", "(", "$", "event", "->", "getBasicHeader", "(", ")", ")", ";", "}", ")", ";", "$", "event", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
Initial request of migrate customer request flow Response filled with HTML to display to the user; requires user action to continue @codeCoverageIgnore
[ "Initial", "request", "of", "migrate", "customer", "request", "flow", "Response", "filled", "with", "HTML", "to", "display", "to", "the", "user", ";", "requires", "user", "action", "to", "continue" ]
033bf74ad31c586823354f54b0f2234889567f8b
https://github.com/expressly/php-common/blob/033bf74ad31c586823354f54b0f2234889567f8b/src/Subscriber/CustomerMigrationSubscriber.php#L38-L50
8,944
expressly/php-common
src/Subscriber/CustomerMigrationSubscriber.php
CustomerMigrationSubscriber.onSuccess
public function onSuccess(CustomerMigrateEvent $event) { $route = $this->routeProvider->customer_migrate_success; $route->setParameters(array( 'uuid' => $event->getUuid() )); $response = $route->process(function ($request) use ($event) { $request->addHeader($event->getBasicHeader()); $request->setContent(array( 'status' => $event->getStatus() )); }); $event->setResponse($response); }
php
public function onSuccess(CustomerMigrateEvent $event) { $route = $this->routeProvider->customer_migrate_success; $route->setParameters(array( 'uuid' => $event->getUuid() )); $response = $route->process(function ($request) use ($event) { $request->addHeader($event->getBasicHeader()); $request->setContent(array( 'status' => $event->getStatus() )); }); $event->setResponse($response); }
[ "public", "function", "onSuccess", "(", "CustomerMigrateEvent", "$", "event", ")", "{", "$", "route", "=", "$", "this", "->", "routeProvider", "->", "customer_migrate_success", ";", "$", "route", "->", "setParameters", "(", "array", "(", "'uuid'", "=>", "$", "event", "->", "getUuid", "(", ")", ")", ")", ";", "$", "response", "=", "$", "route", "->", "process", "(", "function", "(", "$", "request", ")", "use", "(", "$", "event", ")", "{", "$", "request", "->", "addHeader", "(", "$", "event", "->", "getBasicHeader", "(", ")", ")", ";", "$", "request", "->", "setContent", "(", "array", "(", "'status'", "=>", "$", "event", "->", "getStatus", "(", ")", ")", ")", ";", "}", ")", ";", "$", "event", "->", "setResponse", "(", "$", "response", ")", ";", "}" ]
Additional third request to notify the application that we've added the user successfully @codeCoverageIgnore
[ "Additional", "third", "request", "to", "notify", "the", "application", "that", "we", "ve", "added", "the", "user", "successfully" ]
033bf74ad31c586823354f54b0f2234889567f8b
https://github.com/expressly/php-common/blob/033bf74ad31c586823354f54b0f2234889567f8b/src/Subscriber/CustomerMigrationSubscriber.php#L75-L91
8,945
jmpantoja/planb-utils
src/Beautifier/Format/DataFormat.php
DataFormat.getFormattedValue
private function getFormattedValue(): string { return (string) is_numeric($this->value) ? $this->value : sprintf('"%s"', $this->value); }
php
private function getFormattedValue(): string { return (string) is_numeric($this->value) ? $this->value : sprintf('"%s"', $this->value); }
[ "private", "function", "getFormattedValue", "(", ")", ":", "string", "{", "return", "(", "string", ")", "is_numeric", "(", "$", "this", "->", "value", ")", "?", "$", "this", "->", "value", ":", "sprintf", "(", "'\"%s\"'", ",", "$", "this", "->", "value", ")", ";", "}" ]
Devuelve el atributo value con formato @return string
[ "Devuelve", "el", "atributo", "value", "con", "formato" ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Beautifier/Format/DataFormat.php#L133-L138
8,946
InnoGr/FivePercent-Api
src/SMD/Loader/ChainLoader.php
ChainLoader.loadActions
public function loadActions() { $actions = new ActionCollection(); foreach ($this->loaders as $loader) { $childActions = $loader->loadActions(); $actions->addActions($childActions); } return $actions; }
php
public function loadActions() { $actions = new ActionCollection(); foreach ($this->loaders as $loader) { $childActions = $loader->loadActions(); $actions->addActions($childActions); } return $actions; }
[ "public", "function", "loadActions", "(", ")", "{", "$", "actions", "=", "new", "ActionCollection", "(", ")", ";", "foreach", "(", "$", "this", "->", "loaders", "as", "$", "loader", ")", "{", "$", "childActions", "=", "$", "loader", "->", "loadActions", "(", ")", ";", "$", "actions", "->", "addActions", "(", "$", "childActions", ")", ";", "}", "return", "$", "actions", ";", "}" ]
Get all actions @return \FivePercent\Component\Api\SMD\Action\ActionCollectionInterface
[ "Get", "all", "actions" ]
57b78ddc3c9d91a7139c276711e5792824ceab9c
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/SMD/Loader/ChainLoader.php#L59-L70
8,947
Jinxes/layton
Layton/App.php
App.map
public function map($methods, $match, $callback) { return $this->routeService->attach($methods, $match, $callback); }
php
public function map($methods, $match, $callback) { return $this->routeService->attach($methods, $match, $callback); }
[ "public", "function", "map", "(", "$", "methods", ",", "$", "match", ",", "$", "callback", ")", "{", "return", "$", "this", "->", "routeService", "->", "attach", "(", "$", "methods", ",", "$", "match", ",", "$", "callback", ")", ";", "}" ]
Regist a HEAD http route. @param string $method @param string $match @param callback $callable @return Route
[ "Regist", "a", "HEAD", "http", "route", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L77-L80
8,948
Jinxes/layton
Layton/App.php
App.group
public function group($match, $callback) { $group = new RouteGroup($this->container, $match); $callback($group); return $group; }
php
public function group($match, $callback) { $group = new RouteGroup($this->container, $match); $callback($group); return $group; }
[ "public", "function", "group", "(", "$", "match", ",", "$", "callback", ")", "{", "$", "group", "=", "new", "RouteGroup", "(", "$", "this", "->", "container", ",", "$", "match", ")", ";", "$", "callback", "(", "$", "group", ")", ";", "return", "$", "group", ";", "}" ]
Route group. @param string $match @param callback $callback @return RouteGroup
[ "Route", "group", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L98-L103
8,949
Jinxes/layton
Layton/App.php
App.start
public function start() { $routeMethodSep = '>'; $storage = $this->routeService->getStorage(); foreach ($storage as $match => $route) { if (($matched = $this->matchHttpRequest($match)) !== false) { if (!in_array($this->request->getMethod(), $route->methods)) { throw new MethodNotAllowedException(); } $this->request->withAttributes($matched); $middleWares = new MiddleWares($this->getMiddleWareFromRoute($route)); $decorators = $route->decorators; if (\is_string($route->callback)) { if (strpos($route->callback, $routeMethodSep) !== false) { list($controller, $method) = explode($routeMethodSep, $route->callback); return $this->connectMiddlewares($controller, $method, $middleWares, $decorators); } } return $this->connectMiddlewares($route->callback, '__invoke', $middleWares, $decorators); } } throw new NotFoundException(); }
php
public function start() { $routeMethodSep = '>'; $storage = $this->routeService->getStorage(); foreach ($storage as $match => $route) { if (($matched = $this->matchHttpRequest($match)) !== false) { if (!in_array($this->request->getMethod(), $route->methods)) { throw new MethodNotAllowedException(); } $this->request->withAttributes($matched); $middleWares = new MiddleWares($this->getMiddleWareFromRoute($route)); $decorators = $route->decorators; if (\is_string($route->callback)) { if (strpos($route->callback, $routeMethodSep) !== false) { list($controller, $method) = explode($routeMethodSep, $route->callback); return $this->connectMiddlewares($controller, $method, $middleWares, $decorators); } } return $this->connectMiddlewares($route->callback, '__invoke', $middleWares, $decorators); } } throw new NotFoundException(); }
[ "public", "function", "start", "(", ")", "{", "$", "routeMethodSep", "=", "'>'", ";", "$", "storage", "=", "$", "this", "->", "routeService", "->", "getStorage", "(", ")", ";", "foreach", "(", "$", "storage", "as", "$", "match", "=>", "$", "route", ")", "{", "if", "(", "(", "$", "matched", "=", "$", "this", "->", "matchHttpRequest", "(", "$", "match", ")", ")", "!==", "false", ")", "{", "if", "(", "!", "in_array", "(", "$", "this", "->", "request", "->", "getMethod", "(", ")", ",", "$", "route", "->", "methods", ")", ")", "{", "throw", "new", "MethodNotAllowedException", "(", ")", ";", "}", "$", "this", "->", "request", "->", "withAttributes", "(", "$", "matched", ")", ";", "$", "middleWares", "=", "new", "MiddleWares", "(", "$", "this", "->", "getMiddleWareFromRoute", "(", "$", "route", ")", ")", ";", "$", "decorators", "=", "$", "route", "->", "decorators", ";", "if", "(", "\\", "is_string", "(", "$", "route", "->", "callback", ")", ")", "{", "if", "(", "strpos", "(", "$", "route", "->", "callback", ",", "$", "routeMethodSep", ")", "!==", "false", ")", "{", "list", "(", "$", "controller", ",", "$", "method", ")", "=", "explode", "(", "$", "routeMethodSep", ",", "$", "route", "->", "callback", ")", ";", "return", "$", "this", "->", "connectMiddlewares", "(", "$", "controller", ",", "$", "method", ",", "$", "middleWares", ",", "$", "decorators", ")", ";", "}", "}", "return", "$", "this", "->", "connectMiddlewares", "(", "$", "route", "->", "callback", ",", "'__invoke'", ",", "$", "middleWares", ",", "$", "decorators", ")", ";", "}", "}", "throw", "new", "NotFoundException", "(", ")", ";", "}" ]
Match routers and call the callback. @throws NotFoundException @throws MethodNotAllowedException
[ "Match", "routers", "and", "call", "the", "callback", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L111-L137
8,950
Jinxes/layton
Layton/App.php
App.connectMiddlewares
public function connectMiddlewares($controller, $method, MiddleWares $middleWares, $decorators = []) { $isClosure = is_callable($controller); if ($middleWares->valid()) { if ($isClosure) { $next = $this->getInvokeMiddlewareNext($controller, $middleWares, $decorators); } else { $next = $this->getControllerMiddlewareNext($controller, $method, $middleWares, $decorators); } $middleWares->withNextArgs($next); $response = $this->injectionClass($middleWares->current(), 'handle', $middleWares->getNextArgs()); } else { if ($isClosure) { $controller = $this->closureBinder($controller); $response = $this->injectionClosure($controller, $decorators); } else { $response = $this->injectionClass($controller, $method, [], $decorators); } } if ($response instanceof Response) { $this->sendByResponse($response); } }
php
public function connectMiddlewares($controller, $method, MiddleWares $middleWares, $decorators = []) { $isClosure = is_callable($controller); if ($middleWares->valid()) { if ($isClosure) { $next = $this->getInvokeMiddlewareNext($controller, $middleWares, $decorators); } else { $next = $this->getControllerMiddlewareNext($controller, $method, $middleWares, $decorators); } $middleWares->withNextArgs($next); $response = $this->injectionClass($middleWares->current(), 'handle', $middleWares->getNextArgs()); } else { if ($isClosure) { $controller = $this->closureBinder($controller); $response = $this->injectionClosure($controller, $decorators); } else { $response = $this->injectionClass($controller, $method, [], $decorators); } } if ($response instanceof Response) { $this->sendByResponse($response); } }
[ "public", "function", "connectMiddlewares", "(", "$", "controller", ",", "$", "method", ",", "MiddleWares", "$", "middleWares", ",", "$", "decorators", "=", "[", "]", ")", "{", "$", "isClosure", "=", "is_callable", "(", "$", "controller", ")", ";", "if", "(", "$", "middleWares", "->", "valid", "(", ")", ")", "{", "if", "(", "$", "isClosure", ")", "{", "$", "next", "=", "$", "this", "->", "getInvokeMiddlewareNext", "(", "$", "controller", ",", "$", "middleWares", ",", "$", "decorators", ")", ";", "}", "else", "{", "$", "next", "=", "$", "this", "->", "getControllerMiddlewareNext", "(", "$", "controller", ",", "$", "method", ",", "$", "middleWares", ",", "$", "decorators", ")", ";", "}", "$", "middleWares", "->", "withNextArgs", "(", "$", "next", ")", ";", "$", "response", "=", "$", "this", "->", "injectionClass", "(", "$", "middleWares", "->", "current", "(", ")", ",", "'handle'", ",", "$", "middleWares", "->", "getNextArgs", "(", ")", ")", ";", "}", "else", "{", "if", "(", "$", "isClosure", ")", "{", "$", "controller", "=", "$", "this", "->", "closureBinder", "(", "$", "controller", ")", ";", "$", "response", "=", "$", "this", "->", "injectionClosure", "(", "$", "controller", ",", "$", "decorators", ")", ";", "}", "else", "{", "$", "response", "=", "$", "this", "->", "injectionClass", "(", "$", "controller", ",", "$", "method", ",", "[", "]", ",", "$", "decorators", ")", ";", "}", "}", "if", "(", "$", "response", "instanceof", "Response", ")", "{", "$", "this", "->", "sendByResponse", "(", "$", "response", ")", ";", "}", "}" ]
Call middlewares and controller. @param callback $controller @param string $method @param MiddleWares $middleWares
[ "Call", "middlewares", "and", "controller", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L180-L203
8,951
Jinxes/layton
Layton/App.php
App.injectionClosure
public function injectionClosure($controller, $decorators, $args = []) { foreach ($decorators as $decorator) { $controller = $decorator( $this->closureWrapper($controller) ); } return $this->container->dependentService->call($controller, $args); }
php
public function injectionClosure($controller, $decorators, $args = []) { foreach ($decorators as $decorator) { $controller = $decorator( $this->closureWrapper($controller) ); } return $this->container->dependentService->call($controller, $args); }
[ "public", "function", "injectionClosure", "(", "$", "controller", ",", "$", "decorators", ",", "$", "args", "=", "[", "]", ")", "{", "foreach", "(", "$", "decorators", "as", "$", "decorator", ")", "{", "$", "controller", "=", "$", "decorator", "(", "$", "this", "->", "closureWrapper", "(", "$", "controller", ")", ")", ";", "}", "return", "$", "this", "->", "container", "->", "dependentService", "->", "call", "(", "$", "controller", ",", "$", "args", ")", ";", "}" ]
Injection Types for Closure. @param callback $controller @param array $args @return mixed
[ "Injection", "Types", "for", "Closure", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L213-L221
8,952
Jinxes/layton
Layton/App.php
App.getMiddleWareFromRoute
private function getMiddleWareFromRoute(Route $route) { if (!$route->group) { return $route->middleWare; } $groupMiddleWare = $this->getMiddleWareFromGroup($route->group); return \array_merge($groupMiddleWare, $route->middleWare); }
php
private function getMiddleWareFromRoute(Route $route) { if (!$route->group) { return $route->middleWare; } $groupMiddleWare = $this->getMiddleWareFromGroup($route->group); return \array_merge($groupMiddleWare, $route->middleWare); }
[ "private", "function", "getMiddleWareFromRoute", "(", "Route", "$", "route", ")", "{", "if", "(", "!", "$", "route", "->", "group", ")", "{", "return", "$", "route", "->", "middleWare", ";", "}", "$", "groupMiddleWare", "=", "$", "this", "->", "getMiddleWareFromGroup", "(", "$", "route", "->", "group", ")", ";", "return", "\\", "array_merge", "(", "$", "groupMiddleWare", ",", "$", "route", "->", "middleWare", ")", ";", "}" ]
Get middle ware from Route @param Route $route @return array
[ "Get", "middle", "ware", "from", "Route" ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L340-L347
8,953
Jinxes/layton
Layton/App.php
App.getMiddleWareFromGroup
private function getMiddleWareFromGroup(RouteGroup $group, array $middleWareList = []) { if ($group->middleWare) { $middleWareList = \array_merge($group->middleWare, $middleWareList); } if (\is_null($group->parentGroup)) { return $middleWareList; } return $this->getMiddleWareFromGroup($group->parentGroup, $middleWareList); }
php
private function getMiddleWareFromGroup(RouteGroup $group, array $middleWareList = []) { if ($group->middleWare) { $middleWareList = \array_merge($group->middleWare, $middleWareList); } if (\is_null($group->parentGroup)) { return $middleWareList; } return $this->getMiddleWareFromGroup($group->parentGroup, $middleWareList); }
[ "private", "function", "getMiddleWareFromGroup", "(", "RouteGroup", "$", "group", ",", "array", "$", "middleWareList", "=", "[", "]", ")", "{", "if", "(", "$", "group", "->", "middleWare", ")", "{", "$", "middleWareList", "=", "\\", "array_merge", "(", "$", "group", "->", "middleWare", ",", "$", "middleWareList", ")", ";", "}", "if", "(", "\\", "is_null", "(", "$", "group", "->", "parentGroup", ")", ")", "{", "return", "$", "middleWareList", ";", "}", "return", "$", "this", "->", "getMiddleWareFromGroup", "(", "$", "group", "->", "parentGroup", ",", "$", "middleWareList", ")", ";", "}" ]
Merge all middlewares from group and parent-group. @param RouteGroup $group The first route group. @param array $middleWareList Swap of middlewares. @return array All middlewares.
[ "Merge", "all", "middlewares", "from", "group", "and", "parent", "-", "group", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L357-L366
8,954
Jinxes/layton
Layton/App.php
App.matchHttpRequest
private function matchHttpRequest($pattern) { $pattern = $this->replaceKeyWorlds($pattern); \preg_match_all('/\<(.*?)\>/iu', $pattern, $attrKeys); \array_shift($attrKeys); $attrKeys = $attrKeys[0]; $pathInfo = $this->request->server->get('path-info', '/'); $pattern = $this->replacePatternKeyword($pattern); $regexp = '/^'. $pattern .'\/?$/'; if (\preg_match($regexp, $pathInfo, $matched)) { \array_shift($matched); $result = []; foreach ($attrKeys as $num => $key) { $result[$key] = $matched[$num]; } return $result; } return false; }
php
private function matchHttpRequest($pattern) { $pattern = $this->replaceKeyWorlds($pattern); \preg_match_all('/\<(.*?)\>/iu', $pattern, $attrKeys); \array_shift($attrKeys); $attrKeys = $attrKeys[0]; $pathInfo = $this->request->server->get('path-info', '/'); $pattern = $this->replacePatternKeyword($pattern); $regexp = '/^'. $pattern .'\/?$/'; if (\preg_match($regexp, $pathInfo, $matched)) { \array_shift($matched); $result = []; foreach ($attrKeys as $num => $key) { $result[$key] = $matched[$num]; } return $result; } return false; }
[ "private", "function", "matchHttpRequest", "(", "$", "pattern", ")", "{", "$", "pattern", "=", "$", "this", "->", "replaceKeyWorlds", "(", "$", "pattern", ")", ";", "\\", "preg_match_all", "(", "'/\\<(.*?)\\>/iu'", ",", "$", "pattern", ",", "$", "attrKeys", ")", ";", "\\", "array_shift", "(", "$", "attrKeys", ")", ";", "$", "attrKeys", "=", "$", "attrKeys", "[", "0", "]", ";", "$", "pathInfo", "=", "$", "this", "->", "request", "->", "server", "->", "get", "(", "'path-info'", ",", "'/'", ")", ";", "$", "pattern", "=", "$", "this", "->", "replacePatternKeyword", "(", "$", "pattern", ")", ";", "$", "regexp", "=", "'/^'", ".", "$", "pattern", ".", "'\\/?$/'", ";", "if", "(", "\\", "preg_match", "(", "$", "regexp", ",", "$", "pathInfo", ",", "$", "matched", ")", ")", "{", "\\", "array_shift", "(", "$", "matched", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "attrKeys", "as", "$", "num", "=>", "$", "key", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "matched", "[", "$", "num", "]", ";", "}", "return", "$", "result", ";", "}", "return", "false", ";", "}" ]
Match route storage by request url and return params. @param string $url @return array|false
[ "Match", "route", "storage", "by", "request", "url", "and", "return", "params", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L375-L394
8,955
Jinxes/layton
Layton/App.php
App.sendBody
public function sendBody(Response $response) { $body = $response->getBody(); $body->rewind(); echo $body->getContents(); return $response; }
php
public function sendBody(Response $response) { $body = $response->getBody(); $body->rewind(); echo $body->getContents(); return $response; }
[ "public", "function", "sendBody", "(", "Response", "$", "response", ")", "{", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "body", "->", "rewind", "(", ")", ";", "echo", "$", "body", "->", "getContents", "(", ")", ";", "return", "$", "response", ";", "}" ]
Sends body for the current web response. @return $this
[ "Sends", "body", "for", "the", "current", "web", "response", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/App.php#L460-L466
8,956
eureka-framework/component-string
src/Strings/Strings.php
Strings.strpos
public function strpos($needle, $offset = 0) { $function = static::$functions[(int) static::$useMbstring]['strpos']; return $function($this->string, $needle, $offset); }
php
public function strpos($needle, $offset = 0) { $function = static::$functions[(int) static::$useMbstring]['strpos']; return $function($this->string, $needle, $offset); }
[ "public", "function", "strpos", "(", "$", "needle", ",", "$", "offset", "=", "0", ")", "{", "$", "function", "=", "static", "::", "$", "functions", "[", "(", "int", ")", "static", "::", "$", "useMbstring", "]", "[", "'strpos'", "]", ";", "return", "$", "function", "(", "$", "this", "->", "string", ",", "$", "needle", ",", "$", "offset", ")", ";", "}" ]
Strpos function. Use mbstring extension if loaded. @param string $needle The string to find in haystack. @param int $offset The search offset. If it is not specified, 0 is used. @return mixed False if not found, else position.
[ "Strpos", "function", ".", "Use", "mbstring", "extension", "if", "loaded", "." ]
9500d8ec4ba6b41f7a65354f90ec89844f0bdccd
https://github.com/eureka-framework/component-string/blob/9500d8ec4ba6b41f7a65354f90ec89844f0bdccd/src/Strings/Strings.php#L118-L123
8,957
eureka-framework/component-string
src/Strings/Strings.php
Strings.substr
public function substr($start = 0, $length = null) { $function = static::$functions[(int) static::$useMbstring]['substr']; return new self($function($this->string, $start, $length)); }
php
public function substr($start = 0, $length = null) { $function = static::$functions[(int) static::$useMbstring]['substr']; return new self($function($this->string, $start, $length)); }
[ "public", "function", "substr", "(", "$", "start", "=", "0", ",", "$", "length", "=", "null", ")", "{", "$", "function", "=", "static", "::", "$", "functions", "[", "(", "int", ")", "static", "::", "$", "useMbstring", "]", "[", "'substr'", "]", ";", "return", "new", "self", "(", "$", "function", "(", "$", "this", "->", "string", ",", "$", "start", ",", "$", "length", ")", ")", ";", "}" ]
Substring function. Use mbstring extension if loaded. @param integer $start @param integer $length @return Strings Part of string.
[ "Substring", "function", ".", "Use", "mbstring", "extension", "if", "loaded", "." ]
9500d8ec4ba6b41f7a65354f90ec89844f0bdccd
https://github.com/eureka-framework/component-string/blob/9500d8ec4ba6b41f7a65354f90ec89844f0bdccd/src/Strings/Strings.php#L132-L137
8,958
eureka-framework/component-string
src/Strings/Strings.php
Strings.strip
public function strip() { $this->noAccent() ->trim() ->toLower() ->replace(array_keys(static::$charStrip), array_values(static::$charStrip)) ->pregReplace(array('#[^a-z0-9-]#S', '#-+#S'), array('', '-')); return $this; }
php
public function strip() { $this->noAccent() ->trim() ->toLower() ->replace(array_keys(static::$charStrip), array_values(static::$charStrip)) ->pregReplace(array('#[^a-z0-9-]#S', '#-+#S'), array('', '-')); return $this; }
[ "public", "function", "strip", "(", ")", "{", "$", "this", "->", "noAccent", "(", ")", "->", "trim", "(", ")", "->", "toLower", "(", ")", "->", "replace", "(", "array_keys", "(", "static", "::", "$", "charStrip", ")", ",", "array_values", "(", "static", "::", "$", "charStrip", ")", ")", "->", "pregReplace", "(", "array", "(", "'#[^a-z0-9-]#S'", ",", "'#-+#S'", ")", ",", "array", "(", "''", ",", "'-'", ")", ")", ";", "return", "$", "this", ";", "}" ]
Strip string and remove accent and non basic characters. @return self
[ "Strip", "string", "and", "remove", "accent", "and", "non", "basic", "characters", "." ]
9500d8ec4ba6b41f7a65354f90ec89844f0bdccd
https://github.com/eureka-framework/component-string/blob/9500d8ec4ba6b41f7a65354f90ec89844f0bdccd/src/Strings/Strings.php#L265-L274
8,959
eureka-framework/component-string
src/Strings/Strings.php
Strings.concat
public function concat($string, $prepend = false) { $this->string = $prepend ? (string) $string . $this->string : $this->string . (string) $string; return $this; }
php
public function concat($string, $prepend = false) { $this->string = $prepend ? (string) $string . $this->string : $this->string . (string) $string; return $this; }
[ "public", "function", "concat", "(", "$", "string", ",", "$", "prepend", "=", "false", ")", "{", "$", "this", "->", "string", "=", "$", "prepend", "?", "(", "string", ")", "$", "string", ".", "$", "this", "->", "string", ":", "$", "this", "->", "string", ".", "(", "string", ")", "$", "string", ";", "return", "$", "this", ";", "}" ]
Concat string with current string. @param string $string String to concat @param bool $prepend Boolean @return self
[ "Concat", "string", "with", "current", "string", "." ]
9500d8ec4ba6b41f7a65354f90ec89844f0bdccd
https://github.com/eureka-framework/component-string/blob/9500d8ec4ba6b41f7a65354f90ec89844f0bdccd/src/Strings/Strings.php#L350-L355
8,960
eureka-framework/component-string
src/Strings/Strings.php
Strings.pregReplace
public function pregReplace($pattern, $replace, $limit = -1, &$count = null) { $this->string = preg_replace($pattern, $replace, $this->string, $limit, $count); return $this; }
php
public function pregReplace($pattern, $replace, $limit = -1, &$count = null) { $this->string = preg_replace($pattern, $replace, $this->string, $limit, $count); return $this; }
[ "public", "function", "pregReplace", "(", "$", "pattern", ",", "$", "replace", ",", "$", "limit", "=", "-", "1", ",", "&", "$", "count", "=", "null", ")", "{", "$", "this", "->", "string", "=", "preg_replace", "(", "$", "pattern", ",", "$", "replace", ",", "$", "this", "->", "string", ",", "$", "limit", ",", "$", "count", ")", ";", "return", "$", "this", ";", "}" ]
Preg replace text in string. @param string $pattern @param string $replace @param int $limit @param int $count @return self
[ "Preg", "replace", "text", "in", "string", "." ]
9500d8ec4ba6b41f7a65354f90ec89844f0bdccd
https://github.com/eureka-framework/component-string/blob/9500d8ec4ba6b41f7a65354f90ec89844f0bdccd/src/Strings/Strings.php#L366-L371
8,961
eureka-framework/component-string
src/Strings/Strings.php
Strings.replace
public function replace($search, $replace, &$count = null) { $this->string = str_replace($search, $replace, $this->string, $count); return $this; }
php
public function replace($search, $replace, &$count = null) { $this->string = str_replace($search, $replace, $this->string, $count); return $this; }
[ "public", "function", "replace", "(", "$", "search", ",", "$", "replace", ",", "&", "$", "count", "=", "null", ")", "{", "$", "this", "->", "string", "=", "str_replace", "(", "$", "search", ",", "$", "replace", ",", "$", "this", "->", "string", ",", "$", "count", ")", ";", "return", "$", "this", ";", "}" ]
Replace text in string. @param string|array $search @param string|array $replace @param int $count @return self
[ "Replace", "text", "in", "string", "." ]
9500d8ec4ba6b41f7a65354f90ec89844f0bdccd
https://github.com/eureka-framework/component-string/blob/9500d8ec4ba6b41f7a65354f90ec89844f0bdccd/src/Strings/Strings.php#L381-L386
8,962
web-operational-kit/uri
src/Components/Query.php
Query.withParameter
public function withParameter($name, $value) { $query = clone $this; $query->setParameter($name, $value); return $query; }
php
public function withParameter($name, $value) { $query = clone $this; $query->setParameter($name, $value); return $query; }
[ "public", "function", "withParameter", "(", "$", "name", ",", "$", "value", ")", "{", "$", "query", "=", "clone", "$", "this", ";", "$", "query", "->", "setParameter", "(", "$", "name", ",", "$", "value", ")", ";", "return", "$", "query", ";", "}" ]
Get a new Query with a specified parameter @param string $name Parameter's name @param mixed $value Parameter's value @return Query Return a new Query with the specified param
[ "Get", "a", "new", "Query", "with", "a", "specified", "parameter" ]
5712ca924109a0ac6a443c1fe9f497514bd48768
https://github.com/web-operational-kit/uri/blob/5712ca924109a0ac6a443c1fe9f497514bd48768/src/Components/Query.php#L83-L90
8,963
Hexmedia/TimeFormatter-Bundle
Templating/Helper/TimeFormatterHelper.php
TimeFormatterHelper.formatNormal
private function formatNormal(\DateInterval $diff) { $str = ''; $first = null; $second = null; $val = 0; if ($diff->y > 0) { $str = "year"; $val = $diff->y; } else if ($diff->m > 0) { $str = "month"; $val = $diff->m; } else if ($diff->d > 0) { $str = "day"; $first = array('after' => "tomorrow", 'before' => "yesterday"); $val = $diff->d; } else if ($diff->h > 0) { $str = "hour"; $val = $diff->h; } else if ($diff->i == 30) { var_dump($diff->invert); return $diff->invert ? $this->translator->trans("next half hour") : $this->translator->trans("half hour ago"); } else if ($diff->i > 0) { $str = "minute"; $val = $diff->i; } else if ($diff->s > 0) { $str = "second"; $val = $diff->s; } $id = "%" . $str . "s%"; if ($diff->invert) { return $this->translator->transChoice( ($first && isset($first['after']) ? $first['after'] : "next " . $str) . "|" . ($second && isset($second['after']) ? $second['after'] : "next " . $id . " " . $str . "s"), $val, array( $id => $val )); } else { return $this->translator->transChoice( ($first && isset($first['before']) ? $first['before'] : ($str == "hour" ? 'an' : 'a') . ' ' . $str . ' ago') . "|" . ($second && isset($second['before']) ? $second['before'] : $id . " " . $str . "s ago"), $val, array( $id => $val )); } }
php
private function formatNormal(\DateInterval $diff) { $str = ''; $first = null; $second = null; $val = 0; if ($diff->y > 0) { $str = "year"; $val = $diff->y; } else if ($diff->m > 0) { $str = "month"; $val = $diff->m; } else if ($diff->d > 0) { $str = "day"; $first = array('after' => "tomorrow", 'before' => "yesterday"); $val = $diff->d; } else if ($diff->h > 0) { $str = "hour"; $val = $diff->h; } else if ($diff->i == 30) { var_dump($diff->invert); return $diff->invert ? $this->translator->trans("next half hour") : $this->translator->trans("half hour ago"); } else if ($diff->i > 0) { $str = "minute"; $val = $diff->i; } else if ($diff->s > 0) { $str = "second"; $val = $diff->s; } $id = "%" . $str . "s%"; if ($diff->invert) { return $this->translator->transChoice( ($first && isset($first['after']) ? $first['after'] : "next " . $str) . "|" . ($second && isset($second['after']) ? $second['after'] : "next " . $id . " " . $str . "s"), $val, array( $id => $val )); } else { return $this->translator->transChoice( ($first && isset($first['before']) ? $first['before'] : ($str == "hour" ? 'an' : 'a') . ' ' . $str . ' ago') . "|" . ($second && isset($second['before']) ? $second['before'] : $id . " " . $str . "s ago"), $val, array( $id => $val )); } }
[ "private", "function", "formatNormal", "(", "\\", "DateInterval", "$", "diff", ")", "{", "$", "str", "=", "''", ";", "$", "first", "=", "null", ";", "$", "second", "=", "null", ";", "$", "val", "=", "0", ";", "if", "(", "$", "diff", "->", "y", ">", "0", ")", "{", "$", "str", "=", "\"year\"", ";", "$", "val", "=", "$", "diff", "->", "y", ";", "}", "else", "if", "(", "$", "diff", "->", "m", ">", "0", ")", "{", "$", "str", "=", "\"month\"", ";", "$", "val", "=", "$", "diff", "->", "m", ";", "}", "else", "if", "(", "$", "diff", "->", "d", ">", "0", ")", "{", "$", "str", "=", "\"day\"", ";", "$", "first", "=", "array", "(", "'after'", "=>", "\"tomorrow\"", ",", "'before'", "=>", "\"yesterday\"", ")", ";", "$", "val", "=", "$", "diff", "->", "d", ";", "}", "else", "if", "(", "$", "diff", "->", "h", ">", "0", ")", "{", "$", "str", "=", "\"hour\"", ";", "$", "val", "=", "$", "diff", "->", "h", ";", "}", "else", "if", "(", "$", "diff", "->", "i", "==", "30", ")", "{", "var_dump", "(", "$", "diff", "->", "invert", ")", ";", "return", "$", "diff", "->", "invert", "?", "$", "this", "->", "translator", "->", "trans", "(", "\"next half hour\"", ")", ":", "$", "this", "->", "translator", "->", "trans", "(", "\"half hour ago\"", ")", ";", "}", "else", "if", "(", "$", "diff", "->", "i", ">", "0", ")", "{", "$", "str", "=", "\"minute\"", ";", "$", "val", "=", "$", "diff", "->", "i", ";", "}", "else", "if", "(", "$", "diff", "->", "s", ">", "0", ")", "{", "$", "str", "=", "\"second\"", ";", "$", "val", "=", "$", "diff", "->", "s", ";", "}", "$", "id", "=", "\"%\"", ".", "$", "str", ".", "\"s%\"", ";", "if", "(", "$", "diff", "->", "invert", ")", "{", "return", "$", "this", "->", "translator", "->", "transChoice", "(", "(", "$", "first", "&&", "isset", "(", "$", "first", "[", "'after'", "]", ")", "?", "$", "first", "[", "'after'", "]", ":", "\"next \"", ".", "$", "str", ")", ".", "\"|\"", ".", "(", "$", "second", "&&", "isset", "(", "$", "second", "[", "'after'", "]", ")", "?", "$", "second", "[", "'after'", "]", ":", "\"next \"", ".", "$", "id", ".", "\" \"", ".", "$", "str", ".", "\"s\"", ")", ",", "$", "val", ",", "array", "(", "$", "id", "=>", "$", "val", ")", ")", ";", "}", "else", "{", "return", "$", "this", "->", "translator", "->", "transChoice", "(", "(", "$", "first", "&&", "isset", "(", "$", "first", "[", "'before'", "]", ")", "?", "$", "first", "[", "'before'", "]", ":", "(", "$", "str", "==", "\"hour\"", "?", "'an'", ":", "'a'", ")", ".", "' '", ".", "$", "str", ".", "' ago'", ")", ".", "\"|\"", ".", "(", "$", "second", "&&", "isset", "(", "$", "second", "[", "'before'", "]", ")", "?", "$", "second", "[", "'before'", "]", ":", "$", "id", ".", "\" \"", ".", "$", "str", ".", "\"s ago\"", ")", ",", "$", "val", ",", "array", "(", "$", "id", "=>", "$", "val", ")", ")", ";", "}", "}" ]
Formating using default format. @param \DateInterval $diff @return string
[ "Formating", "using", "default", "format", "." ]
f55bfc1273e8e4521cd4abdceddaf2219154e8cb
https://github.com/Hexmedia/TimeFormatter-Bundle/blob/f55bfc1273e8e4521cd4abdceddaf2219154e8cb/Templating/Helper/TimeFormatterHelper.php#L81-L127
8,964
Hexmedia/TimeFormatter-Bundle
Templating/Helper/TimeFormatterHelper.php
TimeFormatterHelper.formatSimple
private function formatSimple(\DateInterval $diff) { $str = ''; $pre = ''; if ($diff->y > 0 || $diff->m > 0 || $diff->d == 1 || $diff->h == 1) { return $this->formatNormal($diff); } else if ($diff->d > 0) { $str = "few days"; } else if ($diff->h > 0) { $str = "few hours"; } else if ($diff->i < 2) { $str = "minute"; $pre = "a "; } else if ($diff->i < 20) { $str = "15 minutes"; } else if ($diff->i < 40) { $str = "half hour"; } else if ($diff->i < 60) { $str = "hour"; $pre = "an "; } return $this->translator->trans($diff->invert ? "next " . $str : $pre . $str . " ago"); }
php
private function formatSimple(\DateInterval $diff) { $str = ''; $pre = ''; if ($diff->y > 0 || $diff->m > 0 || $diff->d == 1 || $diff->h == 1) { return $this->formatNormal($diff); } else if ($diff->d > 0) { $str = "few days"; } else if ($diff->h > 0) { $str = "few hours"; } else if ($diff->i < 2) { $str = "minute"; $pre = "a "; } else if ($diff->i < 20) { $str = "15 minutes"; } else if ($diff->i < 40) { $str = "half hour"; } else if ($diff->i < 60) { $str = "hour"; $pre = "an "; } return $this->translator->trans($diff->invert ? "next " . $str : $pre . $str . " ago"); }
[ "private", "function", "formatSimple", "(", "\\", "DateInterval", "$", "diff", ")", "{", "$", "str", "=", "''", ";", "$", "pre", "=", "''", ";", "if", "(", "$", "diff", "->", "y", ">", "0", "||", "$", "diff", "->", "m", ">", "0", "||", "$", "diff", "->", "d", "==", "1", "||", "$", "diff", "->", "h", "==", "1", ")", "{", "return", "$", "this", "->", "formatNormal", "(", "$", "diff", ")", ";", "}", "else", "if", "(", "$", "diff", "->", "d", ">", "0", ")", "{", "$", "str", "=", "\"few days\"", ";", "}", "else", "if", "(", "$", "diff", "->", "h", ">", "0", ")", "{", "$", "str", "=", "\"few hours\"", ";", "}", "else", "if", "(", "$", "diff", "->", "i", "<", "2", ")", "{", "$", "str", "=", "\"minute\"", ";", "$", "pre", "=", "\"a \"", ";", "}", "else", "if", "(", "$", "diff", "->", "i", "<", "20", ")", "{", "$", "str", "=", "\"15 minutes\"", ";", "}", "else", "if", "(", "$", "diff", "->", "i", "<", "40", ")", "{", "$", "str", "=", "\"half hour\"", ";", "}", "else", "if", "(", "$", "diff", "->", "i", "<", "60", ")", "{", "$", "str", "=", "\"hour\"", ";", "$", "pre", "=", "\"an \"", ";", "}", "return", "$", "this", "->", "translator", "->", "trans", "(", "$", "diff", "->", "invert", "?", "\"next \"", ".", "$", "str", ":", "$", "pre", ".", "$", "str", ".", "\" ago\"", ")", ";", "}" ]
Formating using simple format. @param \DateInterval $diff @return string
[ "Formating", "using", "simple", "format", "." ]
f55bfc1273e8e4521cd4abdceddaf2219154e8cb
https://github.com/Hexmedia/TimeFormatter-Bundle/blob/f55bfc1273e8e4521cd4abdceddaf2219154e8cb/Templating/Helper/TimeFormatterHelper.php#L136-L159
8,965
Hexmedia/TimeFormatter-Bundle
Templating/Helper/TimeFormatterHelper.php
TimeFormatterHelper.convertFormat
private function convertFormat($time, $dateFormat) { if (!($time instanceof \DateTime)) { if (is_numeric($time)) { $transformer = new DateTimeToTimestampTransformer(); $time = $transformer->reverseTransform($time); } else { $transformer = new DateTimeToStringTransformer(null, null, $dateFormat); $time = $transformer->reverseTransform($time); } } return $time; }
php
private function convertFormat($time, $dateFormat) { if (!($time instanceof \DateTime)) { if (is_numeric($time)) { $transformer = new DateTimeToTimestampTransformer(); $time = $transformer->reverseTransform($time); } else { $transformer = new DateTimeToStringTransformer(null, null, $dateFormat); $time = $transformer->reverseTransform($time); } } return $time; }
[ "private", "function", "convertFormat", "(", "$", "time", ",", "$", "dateFormat", ")", "{", "if", "(", "!", "(", "$", "time", "instanceof", "\\", "DateTime", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "time", ")", ")", "{", "$", "transformer", "=", "new", "DateTimeToTimestampTransformer", "(", ")", ";", "$", "time", "=", "$", "transformer", "->", "reverseTransform", "(", "$", "time", ")", ";", "}", "else", "{", "$", "transformer", "=", "new", "DateTimeToStringTransformer", "(", "null", ",", "null", ",", "$", "dateFormat", ")", ";", "$", "time", "=", "$", "transformer", "->", "reverseTransform", "(", "$", "time", ")", ";", "}", "}", "return", "$", "time", ";", "}" ]
Converting date format to expected by methods @param \DateTime|string|int $time @param string $dateFormat @return \DateTime
[ "Converting", "date", "format", "to", "expected", "by", "methods" ]
f55bfc1273e8e4521cd4abdceddaf2219154e8cb
https://github.com/Hexmedia/TimeFormatter-Bundle/blob/f55bfc1273e8e4521cd4abdceddaf2219154e8cb/Templating/Helper/TimeFormatterHelper.php#L169-L182
8,966
bseries/base_social
models/InstagramMedia.php
InstagramMedia.cover
public function cover($entity, array $options = []) { $options += ['internal' => false]; $result = [ 'type' => $entity->raw['type'], 'title' => $entity->title() ]; if ($options['internal']) { return ['url' => 'instagram://' . $entity->id()] + $result; } if (!$url = static::_url($entity->raw)) { return false; } return compact('url') + $result; }
php
public function cover($entity, array $options = []) { $options += ['internal' => false]; $result = [ 'type' => $entity->raw['type'], 'title' => $entity->title() ]; if ($options['internal']) { return ['url' => 'instagram://' . $entity->id()] + $result; } if (!$url = static::_url($entity->raw)) { return false; } return compact('url') + $result; }
[ "public", "function", "cover", "(", "$", "entity", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'internal'", "=>", "false", "]", ";", "$", "result", "=", "[", "'type'", "=>", "$", "entity", "->", "raw", "[", "'type'", "]", ",", "'title'", "=>", "$", "entity", "->", "title", "(", ")", "]", ";", "if", "(", "$", "options", "[", "'internal'", "]", ")", "{", "return", "[", "'url'", "=>", "'instagram://'", ".", "$", "entity", "->", "id", "(", ")", "]", "+", "$", "result", ";", "}", "if", "(", "!", "$", "url", "=", "static", "::", "_url", "(", "$", "entity", "->", "raw", ")", ")", "{", "return", "false", ";", "}", "return", "compact", "(", "'url'", ")", "+", "$", "result", ";", "}" ]
Chooses highest resolution possible.
[ "Chooses", "highest", "resolution", "possible", "." ]
a5c4859b0efc9285e7a1fb8a4ff8b59ce01660c0
https://github.com/bseries/base_social/blob/a5c4859b0efc9285e7a1fb8a4ff8b59ce01660c0/models/InstagramMedia.php#L54-L68
8,967
las93/attila
Attila/core/Entity.php
Entity.hasMany
public function hasMany($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity, array $aOptions = array()) { $this->_aJoins[$sEntityJoinName] = function($mParameters = null) use ($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity) { if (!isset($this->$sEntityJoinName)) { $oOrm = new Orm; $oOrm->select(array('*')) ->from($sEntityJoinName); if ($mParameters) { $aWhere[$sForeignKeyName] = $mParameters; } else { $sMethodName = 'get_'.$sPrimaryKeyName; $aWhere[$sForeignKeyName] = $this->$sMethodName(); } $this->$sEntityJoinName = $oOrm->where($aWhere) ->load(false, $sNamespaceEntity.'\\'); } return $this->$sEntityJoinName; }; if (isset($aOptions['foreignKey']) && !isset($this->_aForeignKey[$sEntityJoinName])) { $this->_aForeignKey[$sEntityJoinName] = array( 'primary_key' => $sPrimaryKeyName, 'entity_join_name' => $sEntityJoinName, 'foreign_key_name' => $sForeignKeyName, 'foreign_key_options' => $aOptions['foreignKey'], 'has_one' => 0 ); } }
php
public function hasMany($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity, array $aOptions = array()) { $this->_aJoins[$sEntityJoinName] = function($mParameters = null) use ($sPrimaryKeyName, $sEntityJoinName, $sForeignKeyName, $sNamespaceEntity) { if (!isset($this->$sEntityJoinName)) { $oOrm = new Orm; $oOrm->select(array('*')) ->from($sEntityJoinName); if ($mParameters) { $aWhere[$sForeignKeyName] = $mParameters; } else { $sMethodName = 'get_'.$sPrimaryKeyName; $aWhere[$sForeignKeyName] = $this->$sMethodName(); } $this->$sEntityJoinName = $oOrm->where($aWhere) ->load(false, $sNamespaceEntity.'\\'); } return $this->$sEntityJoinName; }; if (isset($aOptions['foreignKey']) && !isset($this->_aForeignKey[$sEntityJoinName])) { $this->_aForeignKey[$sEntityJoinName] = array( 'primary_key' => $sPrimaryKeyName, 'entity_join_name' => $sEntityJoinName, 'foreign_key_name' => $sForeignKeyName, 'foreign_key_options' => $aOptions['foreignKey'], 'has_one' => 0 ); } }
[ "public", "function", "hasMany", "(", "$", "sPrimaryKeyName", ",", "$", "sEntityJoinName", ",", "$", "sForeignKeyName", ",", "$", "sNamespaceEntity", ",", "array", "$", "aOptions", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_aJoins", "[", "$", "sEntityJoinName", "]", "=", "function", "(", "$", "mParameters", "=", "null", ")", "use", "(", "$", "sPrimaryKeyName", ",", "$", "sEntityJoinName", ",", "$", "sForeignKeyName", ",", "$", "sNamespaceEntity", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "$", "sEntityJoinName", ")", ")", "{", "$", "oOrm", "=", "new", "Orm", ";", "$", "oOrm", "->", "select", "(", "array", "(", "'*'", ")", ")", "->", "from", "(", "$", "sEntityJoinName", ")", ";", "if", "(", "$", "mParameters", ")", "{", "$", "aWhere", "[", "$", "sForeignKeyName", "]", "=", "$", "mParameters", ";", "}", "else", "{", "$", "sMethodName", "=", "'get_'", ".", "$", "sPrimaryKeyName", ";", "$", "aWhere", "[", "$", "sForeignKeyName", "]", "=", "$", "this", "->", "$", "sMethodName", "(", ")", ";", "}", "$", "this", "->", "$", "sEntityJoinName", "=", "$", "oOrm", "->", "where", "(", "$", "aWhere", ")", "->", "load", "(", "false", ",", "$", "sNamespaceEntity", ".", "'\\\\'", ")", ";", "}", "return", "$", "this", "->", "$", "sEntityJoinName", ";", "}", ";", "if", "(", "isset", "(", "$", "aOptions", "[", "'foreignKey'", "]", ")", "&&", "!", "isset", "(", "$", "this", "->", "_aForeignKey", "[", "$", "sEntityJoinName", "]", ")", ")", "{", "$", "this", "->", "_aForeignKey", "[", "$", "sEntityJoinName", "]", "=", "array", "(", "'primary_key'", "=>", "$", "sPrimaryKeyName", ",", "'entity_join_name'", "=>", "$", "sEntityJoinName", ",", "'foreign_key_name'", "=>", "$", "sForeignKeyName", ",", "'foreign_key_options'", "=>", "$", "aOptions", "[", "'foreignKey'", "]", ",", "'has_one'", "=>", "0", ")", ";", "}", "}" ]
create a join in one to many @access public @param string $sPrimaryKeyName @param string $sEntityJoinName @param string $sForeignKeyName @param string $sNamespaceEntity @param array $aOptions @return array
[ "create", "a", "join", "in", "one", "to", "many" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/core/Entity.php#L443-L482
8,968
Sparhandy/CodingStandard
src/phpcs/Production/Sniffs/Commenting/MethodDocBlockHasDescriptionSniff.php
MethodDocBlockHasDescriptionSniff.hasMethodDocBlockDescription
private function hasMethodDocBlockDescription(File $sniffedFile, $index) { $indexOfOpeningDocBlock = $sniffedFile->findPrevious([T_DOC_COMMENT_OPEN_TAG], $index); $indexOfClosingDocBlock = $sniffedFile->findPrevious([T_DOC_COMMENT_CLOSE_TAG], $index); $hasDescription = false; for ($i = $indexOfOpeningDocBlock + 1; $i < $indexOfClosingDocBlock; $i++) { if (!$this->isCommentWhitespaceToken($sniffedFile, $i) && !$this->isCommentStartToken($sniffedFile, $i)) { $hasDescription = $this->isCommentTextToken($sniffedFile, $i); break; } } return $hasDescription; }
php
private function hasMethodDocBlockDescription(File $sniffedFile, $index) { $indexOfOpeningDocBlock = $sniffedFile->findPrevious([T_DOC_COMMENT_OPEN_TAG], $index); $indexOfClosingDocBlock = $sniffedFile->findPrevious([T_DOC_COMMENT_CLOSE_TAG], $index); $hasDescription = false; for ($i = $indexOfOpeningDocBlock + 1; $i < $indexOfClosingDocBlock; $i++) { if (!$this->isCommentWhitespaceToken($sniffedFile, $i) && !$this->isCommentStartToken($sniffedFile, $i)) { $hasDescription = $this->isCommentTextToken($sniffedFile, $i); break; } } return $hasDescription; }
[ "private", "function", "hasMethodDocBlockDescription", "(", "File", "$", "sniffedFile", ",", "$", "index", ")", "{", "$", "indexOfOpeningDocBlock", "=", "$", "sniffedFile", "->", "findPrevious", "(", "[", "T_DOC_COMMENT_OPEN_TAG", "]", ",", "$", "index", ")", ";", "$", "indexOfClosingDocBlock", "=", "$", "sniffedFile", "->", "findPrevious", "(", "[", "T_DOC_COMMENT_CLOSE_TAG", "]", ",", "$", "index", ")", ";", "$", "hasDescription", "=", "false", ";", "for", "(", "$", "i", "=", "$", "indexOfOpeningDocBlock", "+", "1", ";", "$", "i", "<", "$", "indexOfClosingDocBlock", ";", "$", "i", "++", ")", "{", "if", "(", "!", "$", "this", "->", "isCommentWhitespaceToken", "(", "$", "sniffedFile", ",", "$", "i", ")", "&&", "!", "$", "this", "->", "isCommentStartToken", "(", "$", "sniffedFile", ",", "$", "i", ")", ")", "{", "$", "hasDescription", "=", "$", "this", "->", "isCommentTextToken", "(", "$", "sniffedFile", ",", "$", "i", ")", ";", "break", ";", "}", "}", "return", "$", "hasDescription", ";", "}" ]
Checks if the methods docblock contains a description. @param File $sniffedFile file to be checked @param int $index position of current token in token list @return bool
[ "Checks", "if", "the", "methods", "docblock", "contains", "a", "description", "." ]
519a0b0a4dc172b118bac1f22a25badfbf993b87
https://github.com/Sparhandy/CodingStandard/blob/519a0b0a4dc172b118bac1f22a25badfbf993b87/src/phpcs/Production/Sniffs/Commenting/MethodDocBlockHasDescriptionSniff.php#L43-L59
8,969
Sparhandy/CodingStandard
src/phpcs/Production/Sniffs/Commenting/MethodDocBlockHasDescriptionSniff.php
MethodDocBlockHasDescriptionSniff.needsMethodDocBlockDescription
private function needsMethodDocBlockDescription(File $sniffedFile, $index) { $methodName = $sniffedFile->getDeclarationName($index); $isSpecialMethod = $this->methodIsAccessor($methodName); $isDataProvider = $this->methodIsDataProvider($methodName); return !$isSpecialMethod && !$isDataProvider && !$this->isTestMethod($sniffedFile, $index); }
php
private function needsMethodDocBlockDescription(File $sniffedFile, $index) { $methodName = $sniffedFile->getDeclarationName($index); $isSpecialMethod = $this->methodIsAccessor($methodName); $isDataProvider = $this->methodIsDataProvider($methodName); return !$isSpecialMethod && !$isDataProvider && !$this->isTestMethod($sniffedFile, $index); }
[ "private", "function", "needsMethodDocBlockDescription", "(", "File", "$", "sniffedFile", ",", "$", "index", ")", "{", "$", "methodName", "=", "$", "sniffedFile", "->", "getDeclarationName", "(", "$", "index", ")", ";", "$", "isSpecialMethod", "=", "$", "this", "->", "methodIsAccessor", "(", "$", "methodName", ")", ";", "$", "isDataProvider", "=", "$", "this", "->", "methodIsDataProvider", "(", "$", "methodName", ")", ";", "return", "!", "$", "isSpecialMethod", "&&", "!", "$", "isDataProvider", "&&", "!", "$", "this", "->", "isTestMethod", "(", "$", "sniffedFile", ",", "$", "index", ")", ";", "}" ]
Checks if the method annotation is in need of a description. @param File $sniffedFile file to be checked @param int $index position of current token in token list @return bool
[ "Checks", "if", "the", "method", "annotation", "is", "in", "need", "of", "a", "description", "." ]
519a0b0a4dc172b118bac1f22a25badfbf993b87
https://github.com/Sparhandy/CodingStandard/blob/519a0b0a4dc172b118bac1f22a25badfbf993b87/src/phpcs/Production/Sniffs/Commenting/MethodDocBlockHasDescriptionSniff.php#L69-L76
8,970
sirgrimorum/crudgenerator
src/CrudGenerator.php
CrudGenerator.create
public static function create($config, $simple = false) { //$config = CrudGenerator::translateConfig($config); if (request()->has('_itemRelSel')) { list($itemsRelSelCampo, $itemsRelSelId) = explode("|", request()->_itemRelSel); foreach ($config['campos'] as $clave => $relacion) { if ($clave != $itemsRelSelCampo) { unset($config['campos'][$clave]); } } } if (!CrudGenerator::checkPermission($config)) { return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]); } $modelo = strtolower(class_basename($config["modelo"])); $config = CrudGenerator::loadTodosFromConfig($config); if (!$simple) { $js_section = config("sirgrimorum.crudgenerator.js_section"); $css_section = config("sirgrimorum.crudgenerator.css_section"); } else { $js_section = ""; $css_section = ""; } if ($config['url'] == "Sirgrimorum_CrudAdministrator") { $config['url'] = route("sirgrimorum_modelo::store", ["modelo" => $modelo]); if (\Lang::has('crudgenerator::' . $modelo . '.labels.create')) { $config['botones'] = trans("crudgenerator::$modelo.labels.create"); } else { $config['botones'] = trans("crudgenerator::admin.layout.crear"); } } if (request()->has('_itemRelSel')) { $view = View::make('sirgrimorum::crudgen.templates.relationshipssel_simple', [ 'config' => $config, 'datoId' => $itemsRelSelId, 'columna' => $itemsRelSelCampo, 'tabla' => (new $config['campos'][$itemsRelSelCampo]['modelo'])->getTable(), 'datos' => $config['campos'][$itemsRelSelCampo], 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo ]); } else { $view = View::make('sirgrimorum::crudgen.create', [ 'config' => $config, 'tieneHtml' => CrudGenerator::hasTipo($config, ['html','article']), 'tieneDate' => CrudGenerator::hasTipo($config, ['date', 'datetime', 'time']), 'tieneSlider' => CrudGenerator::hasTipo($config, 'slider'), 'tieneSelect' => CrudGenerator::hasTipo($config, ['select', 'relationship', 'relationships']), 'tieneSearch' => CrudGenerator::hasTipo($config, [ 'relationshipssel']), 'tieneFile' => CrudGenerator::hasTipo($config, [ 'file', 'files']), 'tieneJson' => CrudGenerator::hasTipo($config, [ 'json']), 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo ]); } return $view->render(); }
php
public static function create($config, $simple = false) { //$config = CrudGenerator::translateConfig($config); if (request()->has('_itemRelSel')) { list($itemsRelSelCampo, $itemsRelSelId) = explode("|", request()->_itemRelSel); foreach ($config['campos'] as $clave => $relacion) { if ($clave != $itemsRelSelCampo) { unset($config['campos'][$clave]); } } } if (!CrudGenerator::checkPermission($config)) { return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]); } $modelo = strtolower(class_basename($config["modelo"])); $config = CrudGenerator::loadTodosFromConfig($config); if (!$simple) { $js_section = config("sirgrimorum.crudgenerator.js_section"); $css_section = config("sirgrimorum.crudgenerator.css_section"); } else { $js_section = ""; $css_section = ""; } if ($config['url'] == "Sirgrimorum_CrudAdministrator") { $config['url'] = route("sirgrimorum_modelo::store", ["modelo" => $modelo]); if (\Lang::has('crudgenerator::' . $modelo . '.labels.create')) { $config['botones'] = trans("crudgenerator::$modelo.labels.create"); } else { $config['botones'] = trans("crudgenerator::admin.layout.crear"); } } if (request()->has('_itemRelSel')) { $view = View::make('sirgrimorum::crudgen.templates.relationshipssel_simple', [ 'config' => $config, 'datoId' => $itemsRelSelId, 'columna' => $itemsRelSelCampo, 'tabla' => (new $config['campos'][$itemsRelSelCampo]['modelo'])->getTable(), 'datos' => $config['campos'][$itemsRelSelCampo], 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo ]); } else { $view = View::make('sirgrimorum::crudgen.create', [ 'config' => $config, 'tieneHtml' => CrudGenerator::hasTipo($config, ['html','article']), 'tieneDate' => CrudGenerator::hasTipo($config, ['date', 'datetime', 'time']), 'tieneSlider' => CrudGenerator::hasTipo($config, 'slider'), 'tieneSelect' => CrudGenerator::hasTipo($config, ['select', 'relationship', 'relationships']), 'tieneSearch' => CrudGenerator::hasTipo($config, [ 'relationshipssel']), 'tieneFile' => CrudGenerator::hasTipo($config, [ 'file', 'files']), 'tieneJson' => CrudGenerator::hasTipo($config, [ 'json']), 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo ]); } return $view->render(); }
[ "public", "static", "function", "create", "(", "$", "config", ",", "$", "simple", "=", "false", ")", "{", "//$config = CrudGenerator::translateConfig($config);\r", "if", "(", "request", "(", ")", "->", "has", "(", "'_itemRelSel'", ")", ")", "{", "list", "(", "$", "itemsRelSelCampo", ",", "$", "itemsRelSelId", ")", "=", "explode", "(", "\"|\"", ",", "request", "(", ")", "->", "_itemRelSel", ")", ";", "foreach", "(", "$", "config", "[", "'campos'", "]", "as", "$", "clave", "=>", "$", "relacion", ")", "{", "if", "(", "$", "clave", "!=", "$", "itemsRelSelCampo", ")", "{", "unset", "(", "$", "config", "[", "'campos'", "]", "[", "$", "clave", "]", ")", ";", "}", "}", "}", "if", "(", "!", "CrudGenerator", "::", "checkPermission", "(", "$", "config", ")", ")", "{", "return", "View", "::", "make", "(", "'sirgrimorum::crudgen.error'", ",", "[", "'message'", "=>", "trans", "(", "'crudgenerator::admin.messages.permission'", ")", "]", ")", ";", "}", "$", "modelo", "=", "strtolower", "(", "class_basename", "(", "$", "config", "[", "\"modelo\"", "]", ")", ")", ";", "$", "config", "=", "CrudGenerator", "::", "loadTodosFromConfig", "(", "$", "config", ")", ";", "if", "(", "!", "$", "simple", ")", "{", "$", "js_section", "=", "config", "(", "\"sirgrimorum.crudgenerator.js_section\"", ")", ";", "$", "css_section", "=", "config", "(", "\"sirgrimorum.crudgenerator.css_section\"", ")", ";", "}", "else", "{", "$", "js_section", "=", "\"\"", ";", "$", "css_section", "=", "\"\"", ";", "}", "if", "(", "$", "config", "[", "'url'", "]", "==", "\"Sirgrimorum_CrudAdministrator\"", ")", "{", "$", "config", "[", "'url'", "]", "=", "route", "(", "\"sirgrimorum_modelo::store\"", ",", "[", "\"modelo\"", "=>", "$", "modelo", "]", ")", ";", "if", "(", "\\", "Lang", "::", "has", "(", "'crudgenerator::'", ".", "$", "modelo", ".", "'.labels.create'", ")", ")", "{", "$", "config", "[", "'botones'", "]", "=", "trans", "(", "\"crudgenerator::$modelo.labels.create\"", ")", ";", "}", "else", "{", "$", "config", "[", "'botones'", "]", "=", "trans", "(", "\"crudgenerator::admin.layout.crear\"", ")", ";", "}", "}", "if", "(", "request", "(", ")", "->", "has", "(", "'_itemRelSel'", ")", ")", "{", "$", "view", "=", "View", "::", "make", "(", "'sirgrimorum::crudgen.templates.relationshipssel_simple'", ",", "[", "'config'", "=>", "$", "config", ",", "'datoId'", "=>", "$", "itemsRelSelId", ",", "'columna'", "=>", "$", "itemsRelSelCampo", ",", "'tabla'", "=>", "(", "new", "$", "config", "[", "'campos'", "]", "[", "$", "itemsRelSelCampo", "]", "[", "'modelo'", "]", ")", "->", "getTable", "(", ")", ",", "'datos'", "=>", "$", "config", "[", "'campos'", "]", "[", "$", "itemsRelSelCampo", "]", ",", "'js_section'", "=>", "$", "js_section", ",", "'css_section'", "=>", "$", "css_section", ",", "'modelo'", "=>", "$", "modelo", "]", ")", ";", "}", "else", "{", "$", "view", "=", "View", "::", "make", "(", "'sirgrimorum::crudgen.create'", ",", "[", "'config'", "=>", "$", "config", ",", "'tieneHtml'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'html'", ",", "'article'", "]", ")", ",", "'tieneDate'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'date'", ",", "'datetime'", ",", "'time'", "]", ")", ",", "'tieneSlider'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "'slider'", ")", ",", "'tieneSelect'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'select'", ",", "'relationship'", ",", "'relationships'", "]", ")", ",", "'tieneSearch'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'relationshipssel'", "]", ")", ",", "'tieneFile'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'file'", ",", "'files'", "]", ")", ",", "'tieneJson'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'json'", "]", ")", ",", "'js_section'", "=>", "$", "js_section", ",", "'css_section'", "=>", "$", "css_section", ",", "'modelo'", "=>", "$", "modelo", "]", ")", ";", "}", "return", "$", "view", "->", "render", "(", ")", ";", "}" ]
Generate create view for a model @param array $config Configuration array @param boolean $simple Optional True for a simple view (just the form) @return string Create form in HTML
[ "Generate", "create", "view", "for", "a", "model" ]
4431e9991a705689be50c4367776dc611bffb863
https://github.com/sirgrimorum/crudgenerator/blob/4431e9991a705689be50c4367776dc611bffb863/src/CrudGenerator.php#L41-L99
8,971
sirgrimorum/crudgenerator
src/CrudGenerator.php
CrudGenerator.show
public static function show($config, $id = null, $simple = false, $registro = null) { //$config = CrudGenerator::translateConfig($config); $modelo = strtolower(class_basename($config["modelo"])); if ($registro == null) { $modeloM = ucfirst($config['modelo']); if ($id == null) { $registro = $modeloM::first(); } elseif (is_object($id)) { $registro = $id; $id = $registro->getKey(); } else { $registro = $modeloM::find($id); } } if (!CrudGenerator::checkPermission($config, $registro->getKey())) { return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]); } if (!$simple) { $js_section = config("sirgrimorum.crudgenerator.js_section"); $css_section = config("sirgrimorum.crudgenerator.css_section"); } else { $js_section = ""; $css_section = ""; } $view = View::make('sirgrimorum::crudgen.show', array( 'config' => $config, 'registro' => $registro, 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo )); return $view->render(); }
php
public static function show($config, $id = null, $simple = false, $registro = null) { //$config = CrudGenerator::translateConfig($config); $modelo = strtolower(class_basename($config["modelo"])); if ($registro == null) { $modeloM = ucfirst($config['modelo']); if ($id == null) { $registro = $modeloM::first(); } elseif (is_object($id)) { $registro = $id; $id = $registro->getKey(); } else { $registro = $modeloM::find($id); } } if (!CrudGenerator::checkPermission($config, $registro->getKey())) { return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]); } if (!$simple) { $js_section = config("sirgrimorum.crudgenerator.js_section"); $css_section = config("sirgrimorum.crudgenerator.css_section"); } else { $js_section = ""; $css_section = ""; } $view = View::make('sirgrimorum::crudgen.show', array( 'config' => $config, 'registro' => $registro, 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo )); return $view->render(); }
[ "public", "static", "function", "show", "(", "$", "config", ",", "$", "id", "=", "null", ",", "$", "simple", "=", "false", ",", "$", "registro", "=", "null", ")", "{", "//$config = CrudGenerator::translateConfig($config);\r", "$", "modelo", "=", "strtolower", "(", "class_basename", "(", "$", "config", "[", "\"modelo\"", "]", ")", ")", ";", "if", "(", "$", "registro", "==", "null", ")", "{", "$", "modeloM", "=", "ucfirst", "(", "$", "config", "[", "'modelo'", "]", ")", ";", "if", "(", "$", "id", "==", "null", ")", "{", "$", "registro", "=", "$", "modeloM", "::", "first", "(", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "id", ")", ")", "{", "$", "registro", "=", "$", "id", ";", "$", "id", "=", "$", "registro", "->", "getKey", "(", ")", ";", "}", "else", "{", "$", "registro", "=", "$", "modeloM", "::", "find", "(", "$", "id", ")", ";", "}", "}", "if", "(", "!", "CrudGenerator", "::", "checkPermission", "(", "$", "config", ",", "$", "registro", "->", "getKey", "(", ")", ")", ")", "{", "return", "View", "::", "make", "(", "'sirgrimorum::crudgen.error'", ",", "[", "'message'", "=>", "trans", "(", "'crudgenerator::admin.messages.permission'", ")", "]", ")", ";", "}", "if", "(", "!", "$", "simple", ")", "{", "$", "js_section", "=", "config", "(", "\"sirgrimorum.crudgenerator.js_section\"", ")", ";", "$", "css_section", "=", "config", "(", "\"sirgrimorum.crudgenerator.css_section\"", ")", ";", "}", "else", "{", "$", "js_section", "=", "\"\"", ";", "$", "css_section", "=", "\"\"", ";", "}", "$", "view", "=", "View", "::", "make", "(", "'sirgrimorum::crudgen.show'", ",", "array", "(", "'config'", "=>", "$", "config", ",", "'registro'", "=>", "$", "registro", ",", "'js_section'", "=>", "$", "js_section", ",", "'css_section'", "=>", "$", "css_section", ",", "'modelo'", "=>", "$", "modelo", ")", ")", ";", "return", "$", "view", "->", "render", "(", ")", ";", "}" ]
Generate view to show a model @param array $config Configuration array @param integer $id Key of the object @param boolean $simple Optional True for a simple view (just the form) @param Model $registro Optional The Object @return string the Object in html
[ "Generate", "view", "to", "show", "a", "model" ]
4431e9991a705689be50c4367776dc611bffb863
https://github.com/sirgrimorum/crudgenerator/blob/4431e9991a705689be50c4367776dc611bffb863/src/CrudGenerator.php#L109-L141
8,972
sirgrimorum/crudgenerator
src/CrudGenerator.php
CrudGenerator.edit
public static function edit($config, $id = null, $simple = false, $registro = null) { //$config = CrudGenerator::translateConfig($config); $modelo = strtolower(class_basename($config["modelo"])); $config = CrudGenerator::loadTodosFromConfig($config); if ($registro == null) { $modeloM = ucfirst($config['modelo']); if ($id == null) { $registro = $modeloM::first(); } elseif (is_object($id)) { $registro = $id; $id = $registro->getKey(); } else { $registro = $modeloM::find($id); } } if (!CrudGenerator::checkPermission($config, $registro->getKey())) { return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]); } if ($config['url'] == "Sirgrimorum_CrudAdministrator") { $config['url'] = route("sirgrimorum_modelo::update", ["modelo" => $modelo, "registro" => $registro->id]); if (\Lang::has('crudgenerator::' . $modelo . '.labels.edit')) { $config['botones'] = trans("crudgenerator::$modelo.labels.edit"); } else { $config['botones'] = trans("crudgenerator::admin.layout.editar"); } } if (!$simple) { $js_section = config("sirgrimorum.crudgenerator.js_section"); $css_section = config("sirgrimorum.crudgenerator.css_section"); } else { $js_section = ""; $css_section = ""; } $view = View::make('sirgrimorum::crudgen.edit', [ 'config' => $config, 'registro' => $registro, 'tieneHtml' => CrudGenerator::hasTipo($config, ['html','article']), 'tieneDate' => CrudGenerator::hasTipo($config, ['date', 'datetime', 'time']), 'tieneSlider' => CrudGenerator::hasTipo($config, 'slider'), 'tieneSelect' => CrudGenerator::hasTipo($config, ['select', 'relationship', 'relationships']), 'tieneSearch' => CrudGenerator::hasTipo($config, [ 'relationshipssel']), 'tieneFile' => CrudGenerator::hasTipo($config, [ 'file', 'files']), 'tieneJson' => CrudGenerator::hasTipo($config, [ 'json']), 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo ]); return $view->render(); }
php
public static function edit($config, $id = null, $simple = false, $registro = null) { //$config = CrudGenerator::translateConfig($config); $modelo = strtolower(class_basename($config["modelo"])); $config = CrudGenerator::loadTodosFromConfig($config); if ($registro == null) { $modeloM = ucfirst($config['modelo']); if ($id == null) { $registro = $modeloM::first(); } elseif (is_object($id)) { $registro = $id; $id = $registro->getKey(); } else { $registro = $modeloM::find($id); } } if (!CrudGenerator::checkPermission($config, $registro->getKey())) { return View::make('sirgrimorum::crudgen.error', ['message' => trans('crudgenerator::admin.messages.permission')]); } if ($config['url'] == "Sirgrimorum_CrudAdministrator") { $config['url'] = route("sirgrimorum_modelo::update", ["modelo" => $modelo, "registro" => $registro->id]); if (\Lang::has('crudgenerator::' . $modelo . '.labels.edit')) { $config['botones'] = trans("crudgenerator::$modelo.labels.edit"); } else { $config['botones'] = trans("crudgenerator::admin.layout.editar"); } } if (!$simple) { $js_section = config("sirgrimorum.crudgenerator.js_section"); $css_section = config("sirgrimorum.crudgenerator.css_section"); } else { $js_section = ""; $css_section = ""; } $view = View::make('sirgrimorum::crudgen.edit', [ 'config' => $config, 'registro' => $registro, 'tieneHtml' => CrudGenerator::hasTipo($config, ['html','article']), 'tieneDate' => CrudGenerator::hasTipo($config, ['date', 'datetime', 'time']), 'tieneSlider' => CrudGenerator::hasTipo($config, 'slider'), 'tieneSelect' => CrudGenerator::hasTipo($config, ['select', 'relationship', 'relationships']), 'tieneSearch' => CrudGenerator::hasTipo($config, [ 'relationshipssel']), 'tieneFile' => CrudGenerator::hasTipo($config, [ 'file', 'files']), 'tieneJson' => CrudGenerator::hasTipo($config, [ 'json']), 'js_section' => $js_section, 'css_section' => $css_section, 'modelo' => $modelo ]); return $view->render(); }
[ "public", "static", "function", "edit", "(", "$", "config", ",", "$", "id", "=", "null", ",", "$", "simple", "=", "false", ",", "$", "registro", "=", "null", ")", "{", "//$config = CrudGenerator::translateConfig($config);\r", "$", "modelo", "=", "strtolower", "(", "class_basename", "(", "$", "config", "[", "\"modelo\"", "]", ")", ")", ";", "$", "config", "=", "CrudGenerator", "::", "loadTodosFromConfig", "(", "$", "config", ")", ";", "if", "(", "$", "registro", "==", "null", ")", "{", "$", "modeloM", "=", "ucfirst", "(", "$", "config", "[", "'modelo'", "]", ")", ";", "if", "(", "$", "id", "==", "null", ")", "{", "$", "registro", "=", "$", "modeloM", "::", "first", "(", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "id", ")", ")", "{", "$", "registro", "=", "$", "id", ";", "$", "id", "=", "$", "registro", "->", "getKey", "(", ")", ";", "}", "else", "{", "$", "registro", "=", "$", "modeloM", "::", "find", "(", "$", "id", ")", ";", "}", "}", "if", "(", "!", "CrudGenerator", "::", "checkPermission", "(", "$", "config", ",", "$", "registro", "->", "getKey", "(", ")", ")", ")", "{", "return", "View", "::", "make", "(", "'sirgrimorum::crudgen.error'", ",", "[", "'message'", "=>", "trans", "(", "'crudgenerator::admin.messages.permission'", ")", "]", ")", ";", "}", "if", "(", "$", "config", "[", "'url'", "]", "==", "\"Sirgrimorum_CrudAdministrator\"", ")", "{", "$", "config", "[", "'url'", "]", "=", "route", "(", "\"sirgrimorum_modelo::update\"", ",", "[", "\"modelo\"", "=>", "$", "modelo", ",", "\"registro\"", "=>", "$", "registro", "->", "id", "]", ")", ";", "if", "(", "\\", "Lang", "::", "has", "(", "'crudgenerator::'", ".", "$", "modelo", ".", "'.labels.edit'", ")", ")", "{", "$", "config", "[", "'botones'", "]", "=", "trans", "(", "\"crudgenerator::$modelo.labels.edit\"", ")", ";", "}", "else", "{", "$", "config", "[", "'botones'", "]", "=", "trans", "(", "\"crudgenerator::admin.layout.editar\"", ")", ";", "}", "}", "if", "(", "!", "$", "simple", ")", "{", "$", "js_section", "=", "config", "(", "\"sirgrimorum.crudgenerator.js_section\"", ")", ";", "$", "css_section", "=", "config", "(", "\"sirgrimorum.crudgenerator.css_section\"", ")", ";", "}", "else", "{", "$", "js_section", "=", "\"\"", ";", "$", "css_section", "=", "\"\"", ";", "}", "$", "view", "=", "View", "::", "make", "(", "'sirgrimorum::crudgen.edit'", ",", "[", "'config'", "=>", "$", "config", ",", "'registro'", "=>", "$", "registro", ",", "'tieneHtml'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'html'", ",", "'article'", "]", ")", ",", "'tieneDate'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'date'", ",", "'datetime'", ",", "'time'", "]", ")", ",", "'tieneSlider'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "'slider'", ")", ",", "'tieneSelect'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'select'", ",", "'relationship'", ",", "'relationships'", "]", ")", ",", "'tieneSearch'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'relationshipssel'", "]", ")", ",", "'tieneFile'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'file'", ",", "'files'", "]", ")", ",", "'tieneJson'", "=>", "CrudGenerator", "::", "hasTipo", "(", "$", "config", ",", "[", "'json'", "]", ")", ",", "'js_section'", "=>", "$", "js_section", ",", "'css_section'", "=>", "$", "css_section", ",", "'modelo'", "=>", "$", "modelo", "]", ")", ";", "return", "$", "view", "->", "render", "(", ")", ";", "}" ]
Generate de edit view of a model @param array $config Configuration array @param integer $id Key of the object @param boolean $simple Optional True for a simple view (just the form) @param Model $registro Optional The object @return HTML Edit form
[ "Generate", "de", "edit", "view", "of", "a", "model" ]
4431e9991a705689be50c4367776dc611bffb863
https://github.com/sirgrimorum/crudgenerator/blob/4431e9991a705689be50c4367776dc611bffb863/src/CrudGenerator.php#L151-L200
8,973
oroinc/OroChainProcessorComponent
ProcessorBagConfigBuilder.php
ProcessorBagConfigBuilder.addGroup
public function addGroup($group, $action, $priority = 0) { $this->assertNotFrozen(); if (!empty($this->initialData[self::GROUPS][$action])) { foreach ($this->initialData[self::GROUPS][$action] as $existingGroup => $existingPriority) { if ($group !== $existingGroup && $priority === $existingPriority) { throw new \InvalidArgumentException( \sprintf( 'The priority %s cannot be used for the group "%s"' . ' because the group with this priority already exists.' . ' Existing group: "%s". Action: "%s".', $priority, $group, $existingGroup, $action ) ); } } } $this->initialData[self::GROUPS][$action][$group] = $priority; }
php
public function addGroup($group, $action, $priority = 0) { $this->assertNotFrozen(); if (!empty($this->initialData[self::GROUPS][$action])) { foreach ($this->initialData[self::GROUPS][$action] as $existingGroup => $existingPriority) { if ($group !== $existingGroup && $priority === $existingPriority) { throw new \InvalidArgumentException( \sprintf( 'The priority %s cannot be used for the group "%s"' . ' because the group with this priority already exists.' . ' Existing group: "%s". Action: "%s".', $priority, $group, $existingGroup, $action ) ); } } } $this->initialData[self::GROUPS][$action][$group] = $priority; }
[ "public", "function", "addGroup", "(", "$", "group", ",", "$", "action", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "assertNotFrozen", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "initialData", "[", "self", "::", "GROUPS", "]", "[", "$", "action", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "initialData", "[", "self", "::", "GROUPS", "]", "[", "$", "action", "]", "as", "$", "existingGroup", "=>", "$", "existingPriority", ")", "{", "if", "(", "$", "group", "!==", "$", "existingGroup", "&&", "$", "priority", "===", "$", "existingPriority", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\\", "sprintf", "(", "'The priority %s cannot be used for the group \"%s\"'", ".", "' because the group with this priority already exists.'", ".", "' Existing group: \"%s\". Action: \"%s\".'", ",", "$", "priority", ",", "$", "group", ",", "$", "existingGroup", ",", "$", "action", ")", ")", ";", "}", "}", "}", "$", "this", "->", "initialData", "[", "self", "::", "GROUPS", "]", "[", "$", "action", "]", "[", "$", "group", "]", "=", "$", "priority", ";", "}" ]
Registers a processing group. @param string $group @param string $action @param int $priority
[ "Registers", "a", "processing", "group", "." ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/ProcessorBagConfigBuilder.php#L67-L90
8,974
oroinc/OroChainProcessorComponent
ProcessorBagConfigBuilder.php
ProcessorBagConfigBuilder.addProcessor
public function addProcessor($processorId, array $attributes, $action = null, $group = null, $priority = 0) { $this->assertNotFrozen(); if (null === $action) { $action = self::NO_ACTION; } if (!empty($group)) { $attributes[self::GROUP_ATTRIBUTE] = $group; } $this->initialData[self::PROCESSORS][$action][$priority][] = [$processorId, $attributes]; }
php
public function addProcessor($processorId, array $attributes, $action = null, $group = null, $priority = 0) { $this->assertNotFrozen(); if (null === $action) { $action = self::NO_ACTION; } if (!empty($group)) { $attributes[self::GROUP_ATTRIBUTE] = $group; } $this->initialData[self::PROCESSORS][$action][$priority][] = [$processorId, $attributes]; }
[ "public", "function", "addProcessor", "(", "$", "processorId", ",", "array", "$", "attributes", ",", "$", "action", "=", "null", ",", "$", "group", "=", "null", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "assertNotFrozen", "(", ")", ";", "if", "(", "null", "===", "$", "action", ")", "{", "$", "action", "=", "self", "::", "NO_ACTION", ";", "}", "if", "(", "!", "empty", "(", "$", "group", ")", ")", "{", "$", "attributes", "[", "self", "::", "GROUP_ATTRIBUTE", "]", "=", "$", "group", ";", "}", "$", "this", "->", "initialData", "[", "self", "::", "PROCESSORS", "]", "[", "$", "action", "]", "[", "$", "priority", "]", "[", "]", "=", "[", "$", "processorId", ",", "$", "attributes", "]", ";", "}" ]
Registers a processor. @param string $processorId @param array $attributes @param string|null $action @param string|null $group @param int $priority
[ "Registers", "a", "processor", "." ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/ProcessorBagConfigBuilder.php#L101-L113
8,975
oroinc/OroChainProcessorComponent
ProcessorBagConfigBuilder.php
ProcessorBagConfigBuilder.sortByPriorityAndFlatten
private function sortByPriorityAndFlatten(array $items) { if (!empty($items)) { \krsort($items); $items = \array_merge(...$items); } return $items; }
php
private function sortByPriorityAndFlatten(array $items) { if (!empty($items)) { \krsort($items); $items = \array_merge(...$items); } return $items; }
[ "private", "function", "sortByPriorityAndFlatten", "(", "array", "$", "items", ")", "{", "if", "(", "!", "empty", "(", "$", "items", ")", ")", "{", "\\", "krsort", "(", "$", "items", ")", ";", "$", "items", "=", "\\", "array_merge", "(", "...", "$", "items", ")", ";", "}", "return", "$", "items", ";", "}" ]
Sorts the given groups of items by priority and returns flatten array of sorted items. The higher the priority, the earlier item is added to the result array. @param array $items [priority => [item, ...], ...] @return array [item, ...]
[ "Sorts", "the", "given", "groups", "of", "items", "by", "priority", "and", "returns", "flatten", "array", "of", "sorted", "items", ".", "The", "higher", "the", "priority", "the", "earlier", "item", "is", "added", "to", "the", "result", "array", "." ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/ProcessorBagConfigBuilder.php#L234-L242
8,976
oroinc/OroChainProcessorComponent
ProcessorBagConfigBuilder.php
ProcessorBagConfigBuilder.calculatePriority
private static function calculatePriority($processorPriority, $groupPriority = null) { if (null === $groupPriority) { if ($processorPriority < 0) { $processorPriority += self::getIntervalPriority(-255, -255) + 1; } else { $processorPriority += self::getIntervalPriority(255, 255) + 2; } } else { if ($groupPriority < -255 || $groupPriority > 255) { throw new \RangeException( \sprintf( 'The value %d is not valid priority of a group. It must be between -255 and 255.', $groupPriority ) ); } if ($processorPriority < -255 || $processorPriority > 255) { throw new \RangeException( \sprintf( 'The value %d is not valid priority of a processor. It must be between -255 and 255.', $processorPriority ) ); } } return self::getIntervalPriority($processorPriority, $groupPriority); }
php
private static function calculatePriority($processorPriority, $groupPriority = null) { if (null === $groupPriority) { if ($processorPriority < 0) { $processorPriority += self::getIntervalPriority(-255, -255) + 1; } else { $processorPriority += self::getIntervalPriority(255, 255) + 2; } } else { if ($groupPriority < -255 || $groupPriority > 255) { throw new \RangeException( \sprintf( 'The value %d is not valid priority of a group. It must be between -255 and 255.', $groupPriority ) ); } if ($processorPriority < -255 || $processorPriority > 255) { throw new \RangeException( \sprintf( 'The value %d is not valid priority of a processor. It must be between -255 and 255.', $processorPriority ) ); } } return self::getIntervalPriority($processorPriority, $groupPriority); }
[ "private", "static", "function", "calculatePriority", "(", "$", "processorPriority", ",", "$", "groupPriority", "=", "null", ")", "{", "if", "(", "null", "===", "$", "groupPriority", ")", "{", "if", "(", "$", "processorPriority", "<", "0", ")", "{", "$", "processorPriority", "+=", "self", "::", "getIntervalPriority", "(", "-", "255", ",", "-", "255", ")", "+", "1", ";", "}", "else", "{", "$", "processorPriority", "+=", "self", "::", "getIntervalPriority", "(", "255", ",", "255", ")", "+", "2", ";", "}", "}", "else", "{", "if", "(", "$", "groupPriority", "<", "-", "255", "||", "$", "groupPriority", ">", "255", ")", "{", "throw", "new", "\\", "RangeException", "(", "\\", "sprintf", "(", "'The value %d is not valid priority of a group. It must be between -255 and 255.'", ",", "$", "groupPriority", ")", ")", ";", "}", "if", "(", "$", "processorPriority", "<", "-", "255", "||", "$", "processorPriority", ">", "255", ")", "{", "throw", "new", "\\", "RangeException", "(", "\\", "sprintf", "(", "'The value %d is not valid priority of a processor. It must be between -255 and 255.'", ",", "$", "processorPriority", ")", ")", ";", "}", "}", "return", "self", "::", "getIntervalPriority", "(", "$", "processorPriority", ",", "$", "groupPriority", ")", ";", "}" ]
Calculates an internal priority of a processor based on its priority and a priority of its group. @param int $processorPriority @param int|null $groupPriority @return int
[ "Calculates", "an", "internal", "priority", "of", "a", "processor", "based", "on", "its", "priority", "and", "a", "priority", "of", "its", "group", "." ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/ProcessorBagConfigBuilder.php#L252-L280
8,977
phlexible/phlexible
src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php
Siteroot.getTitle
public function getTitle($language = null) { $fallbackLanguage = key($this->titles); if ($language === null) { $language = $fallbackLanguage; } if (!empty($this->titles[$language])) { return $this->titles[$language]; } if (!empty($this->titles[$fallbackLanguage])) { return $this->titles[$fallbackLanguage]; } $title = false; try { $defaultUrl = $this->getDefaultUrl(); if ($defaultUrl) { $title = $defaultUrl->getHostname(); } } catch (\Exception $e) { } if (!$title) { return '(No title)'; } return $title; }
php
public function getTitle($language = null) { $fallbackLanguage = key($this->titles); if ($language === null) { $language = $fallbackLanguage; } if (!empty($this->titles[$language])) { return $this->titles[$language]; } if (!empty($this->titles[$fallbackLanguage])) { return $this->titles[$fallbackLanguage]; } $title = false; try { $defaultUrl = $this->getDefaultUrl(); if ($defaultUrl) { $title = $defaultUrl->getHostname(); } } catch (\Exception $e) { } if (!$title) { return '(No title)'; } return $title; }
[ "public", "function", "getTitle", "(", "$", "language", "=", "null", ")", "{", "$", "fallbackLanguage", "=", "key", "(", "$", "this", "->", "titles", ")", ";", "if", "(", "$", "language", "===", "null", ")", "{", "$", "language", "=", "$", "fallbackLanguage", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "titles", "[", "$", "language", "]", ")", ")", "{", "return", "$", "this", "->", "titles", "[", "$", "language", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "titles", "[", "$", "fallbackLanguage", "]", ")", ")", "{", "return", "$", "this", "->", "titles", "[", "$", "fallbackLanguage", "]", ";", "}", "$", "title", "=", "false", ";", "try", "{", "$", "defaultUrl", "=", "$", "this", "->", "getDefaultUrl", "(", ")", ";", "if", "(", "$", "defaultUrl", ")", "{", "$", "title", "=", "$", "defaultUrl", "->", "getHostname", "(", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "if", "(", "!", "$", "title", ")", "{", "return", "'(No title)'", ";", "}", "return", "$", "title", ";", "}" ]
Return siteroot title. @param string $language @return string
[ "Return", "siteroot", "title", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php#L263-L293
8,978
phlexible/phlexible
src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php
Siteroot.getSpecialTidsForLanguage
public function getSpecialTidsForLanguage($language = null) { $specialTids = []; foreach ($this->specialTids as $specialTid) { if ($specialTid['language'] === $language || $specialTid['language'] === null) { $specialTids[$specialTid['name']] = $specialTid['treeId']; } } return $specialTids; }
php
public function getSpecialTidsForLanguage($language = null) { $specialTids = []; foreach ($this->specialTids as $specialTid) { if ($specialTid['language'] === $language || $specialTid['language'] === null) { $specialTids[$specialTid['name']] = $specialTid['treeId']; } } return $specialTids; }
[ "public", "function", "getSpecialTidsForLanguage", "(", "$", "language", "=", "null", ")", "{", "$", "specialTids", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "specialTids", "as", "$", "specialTid", ")", "{", "if", "(", "$", "specialTid", "[", "'language'", "]", "===", "$", "language", "||", "$", "specialTid", "[", "'language'", "]", "===", "null", ")", "{", "$", "specialTids", "[", "$", "specialTid", "[", "'name'", "]", "]", "=", "$", "specialTid", "[", "'treeId'", "]", ";", "}", "}", "return", "$", "specialTids", ";", "}" ]
Return special tids for a language. @param string $language @return array
[ "Return", "special", "tids", "for", "a", "language", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php#L362-L373
8,979
phlexible/phlexible
src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php
Siteroot.getSpecialTid
public function getSpecialTid($language, $key) { $languageSpecialTids = $this->getSpecialTidsForLanguage($language); if (!empty($languageSpecialTids[$key])) { return $languageSpecialTids[$key]; } return null; }
php
public function getSpecialTid($language, $key) { $languageSpecialTids = $this->getSpecialTidsForLanguage($language); if (!empty($languageSpecialTids[$key])) { return $languageSpecialTids[$key]; } return null; }
[ "public", "function", "getSpecialTid", "(", "$", "language", ",", "$", "key", ")", "{", "$", "languageSpecialTids", "=", "$", "this", "->", "getSpecialTidsForLanguage", "(", "$", "language", ")", ";", "if", "(", "!", "empty", "(", "$", "languageSpecialTids", "[", "$", "key", "]", ")", ")", "{", "return", "$", "languageSpecialTids", "[", "$", "key", "]", ";", "}", "return", "null", ";", "}" ]
Return a special tid. @param string $language @param string $key @return string
[ "Return", "a", "special", "tid", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php#L383-L392
8,980
phlexible/phlexible
src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php
Siteroot.getDefaultUrl
public function getDefaultUrl($language = null) { foreach ($this->urls as $url) { if ($url->isDefault()) { return $url; } } return null; }
php
public function getDefaultUrl($language = null) { foreach ($this->urls as $url) { if ($url->isDefault()) { return $url; } } return null; }
[ "public", "function", "getDefaultUrl", "(", "$", "language", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "urls", "as", "$", "url", ")", "{", "if", "(", "$", "url", "->", "isDefault", "(", ")", ")", "{", "return", "$", "url", ";", "}", "}", "return", "null", ";", "}" ]
Return the default url. @param string $language @return Url
[ "Return", "the", "default", "url", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/SiterootBundle/Entity/Siteroot.php#L439-L448
8,981
WellCommerce/DataSet
Context/SelectContext.php
SelectContext.makeOptions
private function makeOptions(array $result) { $options = (null !== $this->options['default_option']) ? [0 => $this->options['default_option']] : []; foreach ($result as $row) { $this->makeOption($row, $options); } return $options; }
php
private function makeOptions(array $result) { $options = (null !== $this->options['default_option']) ? [0 => $this->options['default_option']] : []; foreach ($result as $row) { $this->makeOption($row, $options); } return $options; }
[ "private", "function", "makeOptions", "(", "array", "$", "result", ")", "{", "$", "options", "=", "(", "null", "!==", "$", "this", "->", "options", "[", "'default_option'", "]", ")", "?", "[", "0", "=>", "$", "this", "->", "options", "[", "'default_option'", "]", "]", ":", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "row", ")", "{", "$", "this", "->", "makeOption", "(", "$", "row", ",", "$", "options", ")", ";", "}", "return", "$", "options", ";", "}" ]
Processes dataset rows as select options @param array $result @return array
[ "Processes", "dataset", "rows", "as", "select", "options" ]
18720dc5416f245d22c502ceafce1a1b2db2b905
https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Context/SelectContext.php#L45-L54
8,982
WellCommerce/DataSet
Context/SelectContext.php
SelectContext.makeOption
private function makeOption($row, &$options) { $value = $this->propertyAccessor->getValue($row, "[{$this->options['value_column']}]"); $label = $this->propertyAccessor->getValue($row, "[{$this->options['label_column']}]"); $options[$value] = $label; }
php
private function makeOption($row, &$options) { $value = $this->propertyAccessor->getValue($row, "[{$this->options['value_column']}]"); $label = $this->propertyAccessor->getValue($row, "[{$this->options['label_column']}]"); $options[$value] = $label; }
[ "private", "function", "makeOption", "(", "$", "row", ",", "&", "$", "options", ")", "{", "$", "value", "=", "$", "this", "->", "propertyAccessor", "->", "getValue", "(", "$", "row", ",", "\"[{$this->options['value_column']}]\"", ")", ";", "$", "label", "=", "$", "this", "->", "propertyAccessor", "->", "getValue", "(", "$", "row", ",", "\"[{$this->options['label_column']}]\"", ")", ";", "$", "options", "[", "$", "value", "]", "=", "$", "label", ";", "}" ]
Processes single row @param $row @param $options
[ "Processes", "single", "row" ]
18720dc5416f245d22c502ceafce1a1b2db2b905
https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Context/SelectContext.php#L62-L67
8,983
DevGroup-ru/dotplant-entity-structure
src/controllers/EntityManageController.php
EntityManageController.actionGetContextId
public function actionGetContextId() { if (false === Yii::$app->request->isAjax) { throw new NotFoundHttpException( Yii::t('dotplant.entity.structure', 'Page not found') ); } Yii::$app->response->format = Response::FORMAT_JSON; $structureId = Yii::$app->request->post('structure_id'); return BaseStructure::find()->select('context_id')->where(['id' => $structureId])->scalar(); }
php
public function actionGetContextId() { if (false === Yii::$app->request->isAjax) { throw new NotFoundHttpException( Yii::t('dotplant.entity.structure', 'Page not found') ); } Yii::$app->response->format = Response::FORMAT_JSON; $structureId = Yii::$app->request->post('structure_id'); return BaseStructure::find()->select('context_id')->where(['id' => $structureId])->scalar(); }
[ "public", "function", "actionGetContextId", "(", ")", "{", "if", "(", "false", "===", "Yii", "::", "$", "app", "->", "request", "->", "isAjax", ")", "{", "throw", "new", "NotFoundHttpException", "(", "Yii", "::", "t", "(", "'dotplant.entity.structure'", ",", "'Page not found'", ")", ")", ";", "}", "Yii", "::", "$", "app", "->", "response", "->", "format", "=", "Response", "::", "FORMAT_JSON", ";", "$", "structureId", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'structure_id'", ")", ";", "return", "BaseStructure", "::", "find", "(", ")", "->", "select", "(", "'context_id'", ")", "->", "where", "(", "[", "'id'", "=>", "$", "structureId", "]", ")", "->", "scalar", "(", ")", ";", "}" ]
Returns context_id according to given Entity id @return false|null|string @throws NotFoundHttpException
[ "Returns", "context_id", "according", "to", "given", "Entity", "id" ]
43e3354b5ebf9171e9afef38d82dccb02357bfed
https://github.com/DevGroup-ru/dotplant-entity-structure/blob/43e3354b5ebf9171e9afef38d82dccb02357bfed/src/controllers/EntityManageController.php#L87-L97
8,984
zepi/turbo-base
Zepi/Web/UserInterface/src/Renderer/Layout.php
Layout.render
public function render(AbstractContainer $container) { $template = $container->getTemplateKey(); return $this->templatesManager->renderTemplate($template, array( 'layoutRenderer' => $this, 'container' => $container )); }
php
public function render(AbstractContainer $container) { $template = $container->getTemplateKey(); return $this->templatesManager->renderTemplate($template, array( 'layoutRenderer' => $this, 'container' => $container )); }
[ "public", "function", "render", "(", "AbstractContainer", "$", "container", ")", "{", "$", "template", "=", "$", "container", "->", "getTemplateKey", "(", ")", ";", "return", "$", "this", "->", "templatesManager", "->", "renderTemplate", "(", "$", "template", ",", "array", "(", "'layoutRenderer'", "=>", "$", "this", ",", "'container'", "=>", "$", "container", ")", ")", ";", "}" ]
Renders the given abstract container element and returns the html code for the given container. @access public @param \Zepi\Web\UserInterface\Layout\AbstractContainer $container @return string
[ "Renders", "the", "given", "abstract", "container", "element", "and", "returns", "the", "html", "code", "for", "the", "given", "container", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/UserInterface/src/Renderer/Layout.php#L80-L88
8,985
konservs/brilliant.framework
libraries/MVC/BControllerFieldList.php
BControllerField_list.prepare
public function prepare(){ if(is_array($this->params['items'])){ $this->items=array(); foreach($this->params['items'] as $k=>$v){ $this->items[$k]=$v; } } }
php
public function prepare(){ if(is_array($this->params['items'])){ $this->items=array(); foreach($this->params['items'] as $k=>$v){ $this->items[$k]=$v; } } }
[ "public", "function", "prepare", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "params", "[", "'items'", "]", ")", ")", "{", "$", "this", "->", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "params", "[", "'items'", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "items", "[", "$", "k", "]", "=", "$", "v", ";", "}", "}", "}" ]
Init control with start value
[ "Init", "control", "with", "start", "value" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/MVC/BControllerFieldList.php#L31-L38
8,986
sgtlambda/jvwp
src/Templates.php
Templates.extendTwig
private static function extendTwig (\Twig_Environment $twig_Environment) { $twig_Environment->addFilter(new \Twig_SimpleFilter('__', function ($text, $domain = 'default') { return __($text, $domain); })); $twig_Environment->addExtension(new SlugifyExtension(Slugify::create())); }
php
private static function extendTwig (\Twig_Environment $twig_Environment) { $twig_Environment->addFilter(new \Twig_SimpleFilter('__', function ($text, $domain = 'default') { return __($text, $domain); })); $twig_Environment->addExtension(new SlugifyExtension(Slugify::create())); }
[ "private", "static", "function", "extendTwig", "(", "\\", "Twig_Environment", "$", "twig_Environment", ")", "{", "$", "twig_Environment", "->", "addFilter", "(", "new", "\\", "Twig_SimpleFilter", "(", "'__'", ",", "function", "(", "$", "text", ",", "$", "domain", "=", "'default'", ")", "{", "return", "__", "(", "$", "text", ",", "$", "domain", ")", ";", "}", ")", ")", ";", "$", "twig_Environment", "->", "addExtension", "(", "new", "SlugifyExtension", "(", "Slugify", "::", "create", "(", ")", ")", ")", ";", "}" ]
Adds the WP-specific filters and functions to the twig environment @param \Twig_Environment $twig_Environment
[ "Adds", "the", "WP", "-", "specific", "filters", "and", "functions", "to", "the", "twig", "environment" ]
85dba59281216ccb9cff580d26063d304350bbe0
https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/Templates.php#L32-L38
8,987
Webiny/BackupService
src/Webiny/BackupService/Lib/S3.php
S3.upload
public function upload($sourceFile, $destinationFile) { Service::$log->msg('Upload to S3 started: ' . $sourceFile); $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/' . $destinationFile; $this->s3Instance->multipartUpload($this->s3Config->Bucket, $destinationFile, $sourceFile, 3); Service::$log->msg('Upload ended'); return $destinationFile; }
php
public function upload($sourceFile, $destinationFile) { Service::$log->msg('Upload to S3 started: ' . $sourceFile); $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/' . $destinationFile; $this->s3Instance->multipartUpload($this->s3Config->Bucket, $destinationFile, $sourceFile, 3); Service::$log->msg('Upload ended'); return $destinationFile; }
[ "public", "function", "upload", "(", "$", "sourceFile", ",", "$", "destinationFile", ")", "{", "Service", "::", "$", "log", "->", "msg", "(", "'Upload to S3 started: '", ".", "$", "sourceFile", ")", ";", "$", "destinationFile", "=", "rtrim", "(", "$", "this", "->", "s3Config", "->", "RemotePath", ",", "'/'", ")", ".", "'/'", ".", "$", "destinationFile", ";", "$", "this", "->", "s3Instance", "->", "multipartUpload", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFile", ",", "$", "sourceFile", ",", "3", ")", ";", "Service", "::", "$", "log", "->", "msg", "(", "'Upload ended'", ")", ";", "return", "$", "destinationFile", ";", "}" ]
Upload the give file to S3. @param string $sourceFile Path to the source file. @param string $destinationFile Name of the file on S3. @return string
[ "Upload", "the", "give", "file", "to", "S3", "." ]
9728ddaa67e5703ac7898a6f69a0ad14ac37a256
https://github.com/Webiny/BackupService/blob/9728ddaa67e5703ac7898a6f69a0ad14ac37a256/src/Webiny/BackupService/Lib/S3.php#L52-L60
8,988
Webiny/BackupService
src/Webiny/BackupService/Lib/S3.php
S3.moveOldBackup
public function moveOldBackup() { Service::$log->msg('S3: moving old backups'); // remove the 2-day file $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old'; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFile)) { $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFile); } // copy current 1-day file to 2-day $sourceFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old'; $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old'; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $sourceFile)) { $this->s3Instance->copyObject($this->s3Config->Bucket, $sourceFile, $this->s3Config->Bucket, $destinationFile); } // remove the old 1-day file $destinationFileTemp = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old'; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFileTemp)) { $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFileTemp); } Service::$log->msg('S3: moving old backups done'); return $destinationFile; }
php
public function moveOldBackup() { Service::$log->msg('S3: moving old backups'); // remove the 2-day file $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old'; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFile)) { $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFile); } // copy current 1-day file to 2-day $sourceFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old'; $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/backup-2days-old'; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $sourceFile)) { $this->s3Instance->copyObject($this->s3Config->Bucket, $sourceFile, $this->s3Config->Bucket, $destinationFile); } // remove the old 1-day file $destinationFileTemp = rtrim($this->s3Config->RemotePath, '/') . '/backup-1day-old'; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFileTemp)) { $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFileTemp); } Service::$log->msg('S3: moving old backups done'); return $destinationFile; }
[ "public", "function", "moveOldBackup", "(", ")", "{", "Service", "::", "$", "log", "->", "msg", "(", "'S3: moving old backups'", ")", ";", "// remove the 2-day file", "$", "destinationFile", "=", "rtrim", "(", "$", "this", "->", "s3Config", "->", "RemotePath", ",", "'/'", ")", ".", "'/backup-2days-old'", ";", "if", "(", "$", "this", "->", "s3Instance", "->", "doesObjectExist", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFile", ")", ")", "{", "$", "this", "->", "s3Instance", "->", "deleteObject", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFile", ")", ";", "}", "// copy current 1-day file to 2-day", "$", "sourceFile", "=", "rtrim", "(", "$", "this", "->", "s3Config", "->", "RemotePath", ",", "'/'", ")", ".", "'/backup-1day-old'", ";", "$", "destinationFile", "=", "rtrim", "(", "$", "this", "->", "s3Config", "->", "RemotePath", ",", "'/'", ")", ".", "'/backup-2days-old'", ";", "if", "(", "$", "this", "->", "s3Instance", "->", "doesObjectExist", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "sourceFile", ")", ")", "{", "$", "this", "->", "s3Instance", "->", "copyObject", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "sourceFile", ",", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFile", ")", ";", "}", "// remove the old 1-day file", "$", "destinationFileTemp", "=", "rtrim", "(", "$", "this", "->", "s3Config", "->", "RemotePath", ",", "'/'", ")", ".", "'/backup-1day-old'", ";", "if", "(", "$", "this", "->", "s3Instance", "->", "doesObjectExist", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFileTemp", ")", ")", "{", "$", "this", "->", "s3Instance", "->", "deleteObject", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFileTemp", ")", ";", "}", "Service", "::", "$", "log", "->", "msg", "(", "'S3: moving old backups done'", ")", ";", "return", "$", "destinationFile", ";", "}" ]
Moves around the current backups on S3 and does some cleanup before new backups are created.
[ "Moves", "around", "the", "current", "backups", "on", "S3", "and", "does", "some", "cleanup", "before", "new", "backups", "are", "created", "." ]
9728ddaa67e5703ac7898a6f69a0ad14ac37a256
https://github.com/Webiny/BackupService/blob/9728ddaa67e5703ac7898a6f69a0ad14ac37a256/src/Webiny/BackupService/Lib/S3.php#L65-L91
8,989
Webiny/BackupService
src/Webiny/BackupService/Lib/S3.php
S3.deleteBackup
public function deleteBackup($backupName) { Service::$log->msg('S3: deleting backup ' . $backupName); $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/' . $backupName; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFile)) { $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFile); } Service::$log->msg('S3: backup deleted ' . $backupName); }
php
public function deleteBackup($backupName) { Service::$log->msg('S3: deleting backup ' . $backupName); $destinationFile = rtrim($this->s3Config->RemotePath, '/') . '/' . $backupName; if ($this->s3Instance->doesObjectExist($this->s3Config->Bucket, $destinationFile)) { $this->s3Instance->deleteObject($this->s3Config->Bucket, $destinationFile); } Service::$log->msg('S3: backup deleted ' . $backupName); }
[ "public", "function", "deleteBackup", "(", "$", "backupName", ")", "{", "Service", "::", "$", "log", "->", "msg", "(", "'S3: deleting backup '", ".", "$", "backupName", ")", ";", "$", "destinationFile", "=", "rtrim", "(", "$", "this", "->", "s3Config", "->", "RemotePath", ",", "'/'", ")", ".", "'/'", ".", "$", "backupName", ";", "if", "(", "$", "this", "->", "s3Instance", "->", "doesObjectExist", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFile", ")", ")", "{", "$", "this", "->", "s3Instance", "->", "deleteObject", "(", "$", "this", "->", "s3Config", "->", "Bucket", ",", "$", "destinationFile", ")", ";", "}", "Service", "::", "$", "log", "->", "msg", "(", "'S3: backup deleted '", ".", "$", "backupName", ")", ";", "}" ]
Deletes a given backup from the S3 bucket. @param string $backupName Backup filename on S3.
[ "Deletes", "a", "given", "backup", "from", "the", "S3", "bucket", "." ]
9728ddaa67e5703ac7898a6f69a0ad14ac37a256
https://github.com/Webiny/BackupService/blob/9728ddaa67e5703ac7898a6f69a0ad14ac37a256/src/Webiny/BackupService/Lib/S3.php#L98-L108
8,990
synapsestudios/synapse-base
src/Synapse/User/UserRolePivotMapper.php
UserRolePivotMapper.findRoleNamesByUserId
public function findRoleNamesByUserId($userId) { $query = $this->getSqlObject() ->select() ->join('user_roles', 'user_roles.id = pvt_roles_users.role_id', ['name']) ->where(['user_id' => $userId]); $results = $this->execute($query)->toArray(); return Arr::pluck($results, 'name'); }
php
public function findRoleNamesByUserId($userId) { $query = $this->getSqlObject() ->select() ->join('user_roles', 'user_roles.id = pvt_roles_users.role_id', ['name']) ->where(['user_id' => $userId]); $results = $this->execute($query)->toArray(); return Arr::pluck($results, 'name'); }
[ "public", "function", "findRoleNamesByUserId", "(", "$", "userId", ")", "{", "$", "query", "=", "$", "this", "->", "getSqlObject", "(", ")", "->", "select", "(", ")", "->", "join", "(", "'user_roles'", ",", "'user_roles.id = pvt_roles_users.role_id'", ",", "[", "'name'", "]", ")", "->", "where", "(", "[", "'user_id'", "=>", "$", "userId", "]", ")", ";", "$", "results", "=", "$", "this", "->", "execute", "(", "$", "query", ")", "->", "toArray", "(", ")", ";", "return", "Arr", "::", "pluck", "(", "$", "results", ",", "'name'", ")", ";", "}" ]
Find roles for a user by user ID @param string $userId @return array Array of role names
[ "Find", "roles", "for", "a", "user", "by", "user", "ID" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/User/UserRolePivotMapper.php#L38-L48
8,991
synapsestudios/synapse-base
src/Synapse/User/UserRolePivotMapper.php
UserRolePivotMapper.addRoleForUser
public function addRoleForUser($userId, $roleName) { $roleIdExpression = new Expression( '(SELECT `id` from `user_roles` WHERE `name` = ?)', $roleName ); $query = $this->getSqlObject() ->insert() ->values([ 'user_id' => $userId, 'role_id' => $roleIdExpression, ]); $this->execute($query); }
php
public function addRoleForUser($userId, $roleName) { $roleIdExpression = new Expression( '(SELECT `id` from `user_roles` WHERE `name` = ?)', $roleName ); $query = $this->getSqlObject() ->insert() ->values([ 'user_id' => $userId, 'role_id' => $roleIdExpression, ]); $this->execute($query); }
[ "public", "function", "addRoleForUser", "(", "$", "userId", ",", "$", "roleName", ")", "{", "$", "roleIdExpression", "=", "new", "Expression", "(", "'(SELECT `id` from `user_roles` WHERE `name` = ?)'", ",", "$", "roleName", ")", ";", "$", "query", "=", "$", "this", "->", "getSqlObject", "(", ")", "->", "insert", "(", ")", "->", "values", "(", "[", "'user_id'", "=>", "$", "userId", ",", "'role_id'", "=>", "$", "roleIdExpression", ",", "]", ")", ";", "$", "this", "->", "execute", "(", "$", "query", ")", ";", "}" ]
Add a given role to the given user id @param int $userId @param string $roleName
[ "Add", "a", "given", "role", "to", "the", "given", "user", "id" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/User/UserRolePivotMapper.php#L56-L71
8,992
anklimsk/cakephp-config-plugin
Model/Behavior/InitConfigBehavior.php
InitConfigBehavior.setup
public function setup(Model $model, $config = []) { if (!isset($this->settings[$model->alias])) { $this->settings[$model->alias] = [ 'pluginName' => null, 'checkPath' => null, 'configFile' => null, 'path' => null, ]; } $this->settings[$model->alias] = array_merge($this->settings[$model->alias], $config); extract($this->settings[$model->alias]); $this->_initConfig = new InitConfig($pluginName, $checkPath, $configFile); if (!empty($path)) { $this->_initConfig->path = $path; } $this->_initConfig->initConfig(); }
php
public function setup(Model $model, $config = []) { if (!isset($this->settings[$model->alias])) { $this->settings[$model->alias] = [ 'pluginName' => null, 'checkPath' => null, 'configFile' => null, 'path' => null, ]; } $this->settings[$model->alias] = array_merge($this->settings[$model->alias], $config); extract($this->settings[$model->alias]); $this->_initConfig = new InitConfig($pluginName, $checkPath, $configFile); if (!empty($path)) { $this->_initConfig->path = $path; } $this->_initConfig->initConfig(); }
[ "public", "function", "setup", "(", "Model", "$", "model", ",", "$", "config", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", ")", ")", "{", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "=", "[", "'pluginName'", "=>", "null", ",", "'checkPath'", "=>", "null", ",", "'configFile'", "=>", "null", ",", "'path'", "=>", "null", ",", "]", ";", "}", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", "=", "array_merge", "(", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", ",", "$", "config", ")", ";", "extract", "(", "$", "this", "->", "settings", "[", "$", "model", "->", "alias", "]", ")", ";", "$", "this", "->", "_initConfig", "=", "new", "InitConfig", "(", "$", "pluginName", ",", "$", "checkPath", ",", "$", "configFile", ")", ";", "if", "(", "!", "empty", "(", "$", "path", ")", ")", "{", "$", "this", "->", "_initConfig", "->", "path", "=", "$", "path", ";", "}", "$", "this", "->", "_initConfig", "->", "initConfig", "(", ")", ";", "}" ]
Setup this behavior with the specified configuration settings. Actions: - Initialization configuration of plugin. @param Model $model Model using this behavior @param array $config Configuration settings for $model @return void
[ "Setup", "this", "behavior", "with", "the", "specified", "configuration", "settings", "." ]
9659709541950470908f15860327cdd9f1d4e662
https://github.com/anklimsk/cakephp-config-plugin/blob/9659709541950470908f15860327cdd9f1d4e662/Model/Behavior/InitConfigBehavior.php#L41-L58
8,993
LaBlog/LaBlog
src/controllers/CategoryController.php
CategoryController.showCategory
public function showCategory($category, $pagenumber = 1) { if (!$this->category->exists($category)) { return \Response::view($this->theme.'.404', array('global' => $this->global), 404); } $categoryObject = $this->category->getCategory($category); $parent = $this->category->getParentCategory($category); $subCategories = $this->category->getSubCategories($category); $posts = $this->post->getAll($category); $viewParamaters = array( 'global' => $this->global, 'category' => $categoryObject, 'parent' => $parent, 'subCategories' => $subCategories, 'posts' => $posts, 'pageNumber' => $pagenumber ); return \View::make($this->theme.'.category', $viewParamaters); }
php
public function showCategory($category, $pagenumber = 1) { if (!$this->category->exists($category)) { return \Response::view($this->theme.'.404', array('global' => $this->global), 404); } $categoryObject = $this->category->getCategory($category); $parent = $this->category->getParentCategory($category); $subCategories = $this->category->getSubCategories($category); $posts = $this->post->getAll($category); $viewParamaters = array( 'global' => $this->global, 'category' => $categoryObject, 'parent' => $parent, 'subCategories' => $subCategories, 'posts' => $posts, 'pageNumber' => $pagenumber ); return \View::make($this->theme.'.category', $viewParamaters); }
[ "public", "function", "showCategory", "(", "$", "category", ",", "$", "pagenumber", "=", "1", ")", "{", "if", "(", "!", "$", "this", "->", "category", "->", "exists", "(", "$", "category", ")", ")", "{", "return", "\\", "Response", "::", "view", "(", "$", "this", "->", "theme", ".", "'.404'", ",", "array", "(", "'global'", "=>", "$", "this", "->", "global", ")", ",", "404", ")", ";", "}", "$", "categoryObject", "=", "$", "this", "->", "category", "->", "getCategory", "(", "$", "category", ")", ";", "$", "parent", "=", "$", "this", "->", "category", "->", "getParentCategory", "(", "$", "category", ")", ";", "$", "subCategories", "=", "$", "this", "->", "category", "->", "getSubCategories", "(", "$", "category", ")", ";", "$", "posts", "=", "$", "this", "->", "post", "->", "getAll", "(", "$", "category", ")", ";", "$", "viewParamaters", "=", "array", "(", "'global'", "=>", "$", "this", "->", "global", ",", "'category'", "=>", "$", "categoryObject", ",", "'parent'", "=>", "$", "parent", ",", "'subCategories'", "=>", "$", "subCategories", ",", "'posts'", "=>", "$", "posts", ",", "'pageNumber'", "=>", "$", "pagenumber", ")", ";", "return", "\\", "View", "::", "make", "(", "$", "this", "->", "theme", ".", "'.category'", ",", "$", "viewParamaters", ")", ";", "}" ]
Show a category. @param string $category The category to show. @return \View
[ "Show", "a", "category", "." ]
d23f7848bd9a3993cbb5913d967626e9914a009c
https://github.com/LaBlog/LaBlog/blob/d23f7848bd9a3993cbb5913d967626e9914a009c/src/controllers/CategoryController.php#L40-L61
8,994
tekton-php/support
illuminate/support/Str.php
Str.after
public static function after($subject, $search) { if ($search == '') { return $subject; } $pos = strpos($subject, $search); if ($pos === false) { return $subject; } return substr($subject, $pos + strlen($search)); }
php
public static function after($subject, $search) { if ($search == '') { return $subject; } $pos = strpos($subject, $search); if ($pos === false) { return $subject; } return substr($subject, $pos + strlen($search)); }
[ "public", "static", "function", "after", "(", "$", "subject", ",", "$", "search", ")", "{", "if", "(", "$", "search", "==", "''", ")", "{", "return", "$", "subject", ";", "}", "$", "pos", "=", "strpos", "(", "$", "subject", ",", "$", "search", ")", ";", "if", "(", "$", "pos", "===", "false", ")", "{", "return", "$", "subject", ";", "}", "return", "substr", "(", "$", "subject", ",", "$", "pos", "+", "strlen", "(", "$", "search", ")", ")", ";", "}" ]
Return the remainder of a string after a given value. @param string $subject @param string $search @return string
[ "Return", "the", "remainder", "of", "a", "string", "after", "a", "given", "value", "." ]
615b9f19ab66ebc2aa49aaccff12b1fc3b9266b5
https://github.com/tekton-php/support/blob/615b9f19ab66ebc2aa49aaccff12b1fc3b9266b5/illuminate/support/Str.php#L39-L52
8,995
synapsestudios/synapse-base
src/Synapse/Stdlib/Arr.php
Arr.flatten
public static function flatten($array) { $is_assoc = Arr::isAssoc($array); $flat = []; foreach ($array as $key => $value) { if (is_array($value)) { $flat = array_merge($flat, Arr::flatten($value)); } else { if ($is_assoc) { $flat[$key] = $value; } else { $flat[] = $value; } } } return $flat; }
php
public static function flatten($array) { $is_assoc = Arr::isAssoc($array); $flat = []; foreach ($array as $key => $value) { if (is_array($value)) { $flat = array_merge($flat, Arr::flatten($value)); } else { if ($is_assoc) { $flat[$key] = $value; } else { $flat[] = $value; } } } return $flat; }
[ "public", "static", "function", "flatten", "(", "$", "array", ")", "{", "$", "is_assoc", "=", "Arr", "::", "isAssoc", "(", "$", "array", ")", ";", "$", "flat", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "flat", "=", "array_merge", "(", "$", "flat", ",", "Arr", "::", "flatten", "(", "$", "value", ")", ")", ";", "}", "else", "{", "if", "(", "$", "is_assoc", ")", "{", "$", "flat", "[", "$", "key", "]", "=", "$", "value", ";", "}", "else", "{", "$", "flat", "[", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "flat", ";", "}" ]
Convert a multi-dimensional array into a single-dimensional array. $array = array('set' => array('one' => 'something'), 'two' => 'other'); // Flatten the array $array = Arr::flatten($array); // The array will now be array('one' => 'something', 'two' => 'other'); [!!] The keys of array values will be discarded. @param array $array array to flatten @return array @since 3.0.6
[ "Convert", "a", "multi", "-", "dimensional", "array", "into", "a", "single", "-", "dimensional", "array", "." ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Stdlib/Arr.php#L540-L558
8,996
phlexible/phlexible
src/Phlexible/Bundle/AccessControlBundle/SecurityProvider/UserSecurityProvider.php
UserSecurityProvider.resolveName
public function resolveName($securityType, $securityId) { if ($securityType !== $this->userClass) { return null; } return $this->userManager->find($securityId)->getDisplayName(); }
php
public function resolveName($securityType, $securityId) { if ($securityType !== $this->userClass) { return null; } return $this->userManager->find($securityId)->getDisplayName(); }
[ "public", "function", "resolveName", "(", "$", "securityType", ",", "$", "securityId", ")", "{", "if", "(", "$", "securityType", "!==", "$", "this", "->", "userClass", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "userManager", "->", "find", "(", "$", "securityId", ")", "->", "getDisplayName", "(", ")", ";", "}" ]
Return security name. @param string $securityType @param string $securityId @return string
[ "Return", "security", "name", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/AccessControlBundle/SecurityProvider/UserSecurityProvider.php#L53-L60
8,997
phlexible/phlexible
src/Phlexible/Bundle/AccessControlBundle/SecurityProvider/UserSecurityProvider.php
UserSecurityProvider.getAll
public function getAll($query, $limit, $offset) { // TODO: user query $users = $this->userManager->findBy(array(), array('lastname' => 'ASC'), $limit, $offset); $data = array(); foreach ($users as $user) { $data[] = array( 'securityType' => get_class($user), 'securityId' => $user->getId(), 'securityName' => $user->getDisplayName(), ); } return array( 'total' => $this->userManager->countAll(), 'data' => $data, ); }
php
public function getAll($query, $limit, $offset) { // TODO: user query $users = $this->userManager->findBy(array(), array('lastname' => 'ASC'), $limit, $offset); $data = array(); foreach ($users as $user) { $data[] = array( 'securityType' => get_class($user), 'securityId' => $user->getId(), 'securityName' => $user->getDisplayName(), ); } return array( 'total' => $this->userManager->countAll(), 'data' => $data, ); }
[ "public", "function", "getAll", "(", "$", "query", ",", "$", "limit", ",", "$", "offset", ")", "{", "// TODO: user query", "$", "users", "=", "$", "this", "->", "userManager", "->", "findBy", "(", "array", "(", ")", ",", "array", "(", "'lastname'", "=>", "'ASC'", ")", ",", "$", "limit", ",", "$", "offset", ")", ";", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "data", "[", "]", "=", "array", "(", "'securityType'", "=>", "get_class", "(", "$", "user", ")", ",", "'securityId'", "=>", "$", "user", "->", "getId", "(", ")", ",", "'securityName'", "=>", "$", "user", "->", "getDisplayName", "(", ")", ",", ")", ";", "}", "return", "array", "(", "'total'", "=>", "$", "this", "->", "userManager", "->", "countAll", "(", ")", ",", "'data'", "=>", "$", "data", ",", ")", ";", "}" ]
Return users. @param string $query @param int $limit @param int $offset @return array
[ "Return", "users", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/AccessControlBundle/SecurityProvider/UserSecurityProvider.php#L71-L89
8,998
JumpGateio/Database
src/JumpGate/Database/Collections/SupportCollection.php
SupportCollection.insertAfter
public function insertAfter($value, $afterKey) { $chunk = $this->splice($afterKey + 1); return $this->items = $this->put($afterKey + 1, $value) ->merge($chunk) ->all(); }
php
public function insertAfter($value, $afterKey) { $chunk = $this->splice($afterKey + 1); return $this->items = $this->put($afterKey + 1, $value) ->merge($chunk) ->all(); }
[ "public", "function", "insertAfter", "(", "$", "value", ",", "$", "afterKey", ")", "{", "$", "chunk", "=", "$", "this", "->", "splice", "(", "$", "afterKey", "+", "1", ")", ";", "return", "$", "this", "->", "items", "=", "$", "this", "->", "put", "(", "$", "afterKey", "+", "1", ",", "$", "value", ")", "->", "merge", "(", "$", "chunk", ")", "->", "all", "(", ")", ";", "}" ]
Insert into a collection after the given key. Should be able to do this with methods that already exist on collection. @param mixed $value @param int $afterKey @return Collection
[ "Insert", "into", "a", "collection", "after", "the", "given", "key", "." ]
0d857a1fa85a66dfe380ab153feaa3b167339822
https://github.com/JumpGateio/Database/blob/0d857a1fa85a66dfe380ab153feaa3b167339822/src/JumpGate/Database/Collections/SupportCollection.php#L80-L87
8,999
jaredtking/jaqb
src/Query/Traits/OrderBy.php
OrderBy.orderBy
public function orderBy($fields, $direction = false) { $this->orderBy->addFields($fields, $direction); return $this; }
php
public function orderBy($fields, $direction = false) { $this->orderBy->addFields($fields, $direction); return $this; }
[ "public", "function", "orderBy", "(", "$", "fields", ",", "$", "direction", "=", "false", ")", "{", "$", "this", "->", "orderBy", "->", "addFields", "(", "$", "fields", ",", "$", "direction", ")", ";", "return", "$", "this", ";", "}" ]
Sets the order for the query. @param string|array $fields @param string $direction @return self
[ "Sets", "the", "order", "for", "the", "query", "." ]
04a853b530fcc12a9863349d3d0da6377d1b9995
https://github.com/jaredtking/jaqb/blob/04a853b530fcc12a9863349d3d0da6377d1b9995/src/Query/Traits/OrderBy.php#L20-L25