id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
207,900
getgrav/grav
system/src/Grav/Console/Cli/InstallCommand.php
InstallCommand.gitclone
private function gitclone() { $this->output->writeln(''); $this->output->writeln('<green>Cloning Bits</green>'); $this->output->writeln('============'); $this->output->writeln(''); foreach ($this->config['git'] as $repo => $data) { $this->destination = rtrim($thi...
php
private function gitclone() { $this->output->writeln(''); $this->output->writeln('<green>Cloning Bits</green>'); $this->output->writeln('============'); $this->output->writeln(''); foreach ($this->config['git'] as $repo => $data) { $this->destination = rtrim($thi...
[ "private", "function", "gitclone", "(", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "''", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "'<green>Cloning Bits</green>'", ")", ";", "$", "this", "->", "output", "->", "writeln...
Clones from Git
[ "Clones", "from", "Git" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Console/Cli/InstallCommand.php#L102-L129
207,901
getgrav/grav
system/src/Grav/Common/Inflector.php
Inflector.underscorize
public static function underscorize($word) { $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $word); $regex2 = preg_replace('/([a-zd])([A-Z])/', '\1_\2', $regex1); $regex3 = preg_replace('/[^A-Z^a-z^0-9]+/', '_', $regex2); return strtolower($regex3); }
php
public static function underscorize($word) { $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1_\2', $word); $regex2 = preg_replace('/([a-zd])([A-Z])/', '\1_\2', $regex1); $regex3 = preg_replace('/[^A-Z^a-z^0-9]+/', '_', $regex2); return strtolower($regex3); }
[ "public", "static", "function", "underscorize", "(", "$", "word", ")", "{", "$", "regex1", "=", "preg_replace", "(", "'/([A-Z]+)([A-Z][a-z])/'", ",", "'\\1_\\2'", ",", "$", "word", ")", ";", "$", "regex2", "=", "preg_replace", "(", "'/([a-zd])([A-Z])/'", ",", ...
Converts a word "into_it_s_underscored_version" Convert any "CamelCased" or "ordinary Word" into an "underscored_word". This can be really useful for creating friendly URLs. @param string $word Word to underscore @return string Underscored word
[ "Converts", "a", "word", "into_it_s_underscored_version" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Inflector.php#L168-L175
207,902
getgrav/grav
system/src/Grav/Common/Inflector.php
Inflector.hyphenize
public static function hyphenize($word) { $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1-\2', $word); $regex2 = preg_replace('/([a-z])([A-Z])/', '\1-\2', $regex1); $regex3 = preg_replace('/([0-9])([A-Z])/', '\1-\2', $regex2); $regex4 = preg_replace('/[^A-Z^a-z^0-9]+/', '-', $re...
php
public static function hyphenize($word) { $regex1 = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\1-\2', $word); $regex2 = preg_replace('/([a-z])([A-Z])/', '\1-\2', $regex1); $regex3 = preg_replace('/([0-9])([A-Z])/', '\1-\2', $regex2); $regex4 = preg_replace('/[^A-Z^a-z^0-9]+/', '-', $re...
[ "public", "static", "function", "hyphenize", "(", "$", "word", ")", "{", "$", "regex1", "=", "preg_replace", "(", "'/([A-Z]+)([A-Z][a-z])/'", ",", "'\\1-\\2'", ",", "$", "word", ")", ";", "$", "regex2", "=", "preg_replace", "(", "'/([a-z])([A-Z])/'", ",", "'...
Converts a word "into-it-s-hyphenated-version" Convert any "CamelCased" or "ordinary Word" into an "hyphenated-word". This can be really useful for creating friendly URLs. @param string $word Word to hyphenate @return string hyphenized word
[ "Converts", "a", "word", "into", "-", "it", "-", "s", "-", "hyphenated", "-", "version" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Inflector.php#L189-L197
207,903
getgrav/grav
system/src/Grav/Common/Inflector.php
Inflector.ordinalize
public static function ordinalize($number) { static::init(); if (\in_array($number % 100, range(11, 13), true)) { return $number . static::$ordinals['default']; } switch ($number % 10) { case 1: return $number . static::$ordinals['first']; ...
php
public static function ordinalize($number) { static::init(); if (\in_array($number % 100, range(11, 13), true)) { return $number . static::$ordinals['default']; } switch ($number % 10) { case 1: return $number . static::$ordinals['first']; ...
[ "public", "static", "function", "ordinalize", "(", "$", "number", ")", "{", "static", "::", "init", "(", ")", ";", "if", "(", "\\", "in_array", "(", "$", "number", "%", "100", ",", "range", "(", "11", ",", "13", ")", ",", "true", ")", ")", "{", ...
Converts number to its ordinal English form. This method converts 13 to 13th, 2 to 2nd ... @param int $number Number to get its ordinal value @return string Ordinal representation of given string.
[ "Converts", "number", "to", "its", "ordinal", "English", "form", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Inflector.php#L285-L303
207,904
getgrav/grav
system/src/Grav/Common/Inflector.php
Inflector.monthize
public static function monthize($days) { $now = new \DateTime(); $end = new \DateTime(); $duration = new \DateInterval("P{$days}D"); $diff = $end->add($duration)->diff($now); // handle years if ($diff->y > 0) { $diff->m += 12 * $diff->y; } ...
php
public static function monthize($days) { $now = new \DateTime(); $end = new \DateTime(); $duration = new \DateInterval("P{$days}D"); $diff = $end->add($duration)->diff($now); // handle years if ($diff->y > 0) { $diff->m += 12 * $diff->y; } ...
[ "public", "static", "function", "monthize", "(", "$", "days", ")", "{", "$", "now", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "end", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "duration", "=", "new", "\\", "DateInterval", "(", "\"P{$...
Converts a number of days to a number of months @param int $days @return int
[ "Converts", "a", "number", "of", "days", "to", "a", "number", "of", "months" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Inflector.php#L312-L327
207,905
getgrav/grav
system/src/Grav/Common/Iterator.php
Iterator.nth
public function nth($key) { $items = array_keys($this->items); return isset($items[$key]) ? $this->offsetGet($items[$key]) : false; }
php
public function nth($key) { $items = array_keys($this->items); return isset($items[$key]) ? $this->offsetGet($items[$key]) : false; }
[ "public", "function", "nth", "(", "$", "key", ")", "{", "$", "items", "=", "array_keys", "(", "$", "this", "->", "items", ")", ";", "return", "isset", "(", "$", "items", "[", "$", "key", "]", ")", "?", "$", "this", "->", "offsetGet", "(", "$", ...
Return nth item. @param int $key @return mixed|bool
[ "Return", "nth", "item", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Iterator.php#L90-L95
207,906
getgrav/grav
system/src/Grav/Common/Iterator.php
Iterator.random
public function random($num = 1) { $count = \count($this->items); if ($num > $count) { $num = $count; } $this->items = array_intersect_key($this->items, array_flip((array)array_rand($this->items, $num))); return $this; }
php
public function random($num = 1) { $count = \count($this->items); if ($num > $count) { $num = $count; } $this->items = array_intersect_key($this->items, array_flip((array)array_rand($this->items, $num))); return $this; }
[ "public", "function", "random", "(", "$", "num", "=", "1", ")", "{", "$", "count", "=", "\\", "count", "(", "$", "this", "->", "items", ")", ";", "if", "(", "$", "num", ">", "$", "count", ")", "{", "$", "num", "=", "$", "count", ";", "}", "...
Pick one or more random entries. @param int $num Specifies how many entries should be picked. @return $this
[ "Pick", "one", "or", "more", "random", "entries", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Iterator.php#L191-L201
207,907
getgrav/grav
system/src/Grav/Common/Iterator.php
Iterator.append
public function append($items) { if ($items instanceof static) { $items = $items->toArray(); } $this->items = array_merge($this->items, (array)$items); return $this; }
php
public function append($items) { if ($items instanceof static) { $items = $items->toArray(); } $this->items = array_merge($this->items, (array)$items); return $this; }
[ "public", "function", "append", "(", "$", "items", ")", "{", "if", "(", "$", "items", "instanceof", "static", ")", "{", "$", "items", "=", "$", "items", "->", "toArray", "(", ")", ";", "}", "$", "this", "->", "items", "=", "array_merge", "(", "$", ...
Append new elements to the list. @param array|Iterator $items Items to be appended. Existing keys will be overridden with the new values. @return $this
[ "Append", "new", "elements", "to", "the", "list", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Iterator.php#L210-L218
207,908
getgrav/grav
system/src/Grav/Common/Iterator.php
Iterator.filter
public function filter(callable $callback = null) { foreach ($this->items as $key => $value) { if ( (!$callback && !(bool)$value) || ($callback && !$callback($value, $key)) ) { unset($this->items[$key]); } } ...
php
public function filter(callable $callback = null) { foreach ($this->items as $key => $value) { if ( (!$callback && !(bool)$value) || ($callback && !$callback($value, $key)) ) { unset($this->items[$key]); } } ...
[ "public", "function", "filter", "(", "callable", "$", "callback", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "(", "!", "$", "callback", "&&", "!", "(", "bool", ")"...
Filter elements from the list @param callable|null $callback A function the receives ($value, $key) and must return a boolean to indicate filter status @return $this
[ "Filter", "elements", "from", "the", "list" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Iterator.php#L228-L240
207,909
getgrav/grav
system/src/Grav/Common/Iterator.php
Iterator.sort
public function sort(callable $callback = null, $desc = false) { if (!$callback || !\is_callable($callback)) { return $this; } $items = $this->items; uasort($items, $callback); return !$desc ? $items : array_reverse($items, true); }
php
public function sort(callable $callback = null, $desc = false) { if (!$callback || !\is_callable($callback)) { return $this; } $items = $this->items; uasort($items, $callback); return !$desc ? $items : array_reverse($items, true); }
[ "public", "function", "sort", "(", "callable", "$", "callback", "=", "null", ",", "$", "desc", "=", "false", ")", "{", "if", "(", "!", "$", "callback", "||", "!", "\\", "is_callable", "(", "$", "callback", ")", ")", "{", "return", "$", "this", ";",...
Sorts elements from the list and returns a copy of the list in the proper order @param callable|null $callback @param bool $desc @return $this|array @internal param bool $asc
[ "Sorts", "elements", "from", "the", "list", "and", "returns", "a", "copy", "of", "the", "list", "in", "the", "proper", "order" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Iterator.php#L254-L264
207,910
getgrav/grav
system/src/Grav/Common/User/Traits/UserTrait.php
UserTrait.authenticate
public function authenticate(string $password): bool { $hash = $this->get('hashed_password'); $isHashed = null !== $hash; if (!$isHashed) { // If there is no hashed password, fake verify with default hash. $hash = Grav::instance()['config']->get('system.security.defa...
php
public function authenticate(string $password): bool { $hash = $this->get('hashed_password'); $isHashed = null !== $hash; if (!$isHashed) { // If there is no hashed password, fake verify with default hash. $hash = Grav::instance()['config']->get('system.security.defa...
[ "public", "function", "authenticate", "(", "string", "$", "password", ")", ":", "bool", "{", "$", "hash", "=", "$", "this", "->", "get", "(", "'hashed_password'", ")", ";", "$", "isHashed", "=", "null", "!==", "$", "hash", ";", "if", "(", "!", "$", ...
Authenticate user. If user password needs to be updated, new information will be saved. @param string $password Plaintext password. @return bool
[ "Authenticate", "user", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/Traits/UserTrait.php#L27-L59
207,911
getgrav/grav
system/src/Grav/Common/User/Traits/UserTrait.php
UserTrait.authorize
public function authorize(string $action, string $scope = null): bool { if (!$this->get('authenticated')) { return false; } if ($this->get('state', 'enabled') !== 'enabled') { return false; } if (null !== $scope) { $action = $scope . '.' ...
php
public function authorize(string $action, string $scope = null): bool { if (!$this->get('authenticated')) { return false; } if ($this->get('state', 'enabled') !== 'enabled') { return false; } if (null !== $scope) { $action = $scope . '.' ...
[ "public", "function", "authorize", "(", "string", "$", "action", ",", "string", "$", "scope", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "get", "(", "'authenticated'", ")", ")", "{", "return", "false", ";", "}", "if", "(...
Checks user authorization to the action. @param string $action @param string|null $scope @return bool
[ "Checks", "user", "authorization", "to", "the", "action", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/Traits/UserTrait.php#L68-L103
207,912
getgrav/grav
system/src/Grav/Common/User/Traits/UserTrait.php
UserTrait.getAvatarImage
public function getAvatarImage(): ?ImageMedium { $avatars = $this->get('avatar'); if (\is_array($avatars) && $avatars) { $avatar = array_shift($avatars); $media = $this->getMedia(); $name = $avatar['name'] ?? null; $image = $name ? $media[$name] : nu...
php
public function getAvatarImage(): ?ImageMedium { $avatars = $this->get('avatar'); if (\is_array($avatars) && $avatars) { $avatar = array_shift($avatars); $media = $this->getMedia(); $name = $avatar['name'] ?? null; $image = $name ? $media[$name] : nu...
[ "public", "function", "getAvatarImage", "(", ")", ":", "?", "ImageMedium", "{", "$", "avatars", "=", "$", "this", "->", "get", "(", "'avatar'", ")", ";", "if", "(", "\\", "is_array", "(", "$", "avatars", ")", "&&", "$", "avatars", ")", "{", "$", "a...
Return media object for the User's avatar. Note: if there's no local avatar image for the user, you should call getAvatarUrl() to get the external avatar URL. @return ImageMedium|null
[ "Return", "media", "object", "for", "the", "User", "s", "avatar", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/Traits/UserTrait.php#L112-L128
207,913
getgrav/grav
system/src/Grav/Common/User/Traits/UserTrait.php
UserTrait.getAvatarUrl
public function getAvatarUrl(): string { // Try to locate avatar image. $avatar = $this->getAvatarImage(); if ($avatar) { return $avatar->url(); } // Try if avatar is a sting (URL). $avatar = $this->get('avatar'); if (\is_string($avatar)) { ...
php
public function getAvatarUrl(): string { // Try to locate avatar image. $avatar = $this->getAvatarImage(); if ($avatar) { return $avatar->url(); } // Try if avatar is a sting (URL). $avatar = $this->get('avatar'); if (\is_string($avatar)) { ...
[ "public", "function", "getAvatarUrl", "(", ")", ":", "string", "{", "// Try to locate avatar image.", "$", "avatar", "=", "$", "this", "->", "getAvatarImage", "(", ")", ";", "if", "(", "$", "avatar", ")", "{", "return", "$", "avatar", "->", "url", "(", "...
Return the User's avatar URL @return string
[ "Return", "the", "User", "s", "avatar", "URL" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/User/Traits/UserTrait.php#L135-L165
207,914
getgrav/grav
system/src/Grav/Common/Helpers/Truncator.php
Truncator.truncateWords
public static function truncateWords($html, $limit = 0, $ellipsis = '') { if ($limit <= 0) { return $html; } $doc = self::htmlToDomDocument($html); $container = $doc->getElementsByTagName('div')->item(0); $container = $container->parentNode->removeChild($containe...
php
public static function truncateWords($html, $limit = 0, $ellipsis = '') { if ($limit <= 0) { return $html; } $doc = self::htmlToDomDocument($html); $container = $doc->getElementsByTagName('div')->item(0); $container = $container->parentNode->removeChild($containe...
[ "public", "static", "function", "truncateWords", "(", "$", "html", ",", "$", "limit", "=", "0", ",", "$", "ellipsis", "=", "''", ")", "{", "if", "(", "$", "limit", "<=", "0", ")", "{", "return", "$", "html", ";", "}", "$", "doc", "=", "self", "...
Safely truncates HTML by a given number of words. @param string $html Input HTML. @param int $limit Limit to how many words we preserve. @param string $ellipsis String to use as ellipsis (if any). @return string Safe truncated HTML.
[ "Safely", "truncates", "HTML", "by", "a", "given", "number", "of", "words", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Helpers/Truncator.php#L38-L87
207,915
getgrav/grav
system/src/Grav/Common/Helpers/Truncator.php
Truncator.truncateLetters
public static function truncateLetters($html, $limit = 0, $ellipsis = '') { if ($limit <= 0) { return $html; } $doc = self::htmlToDomDocument($html); $container = $doc->getElementsByTagName('div')->item(0); $container = $container->parentNode->removeChild($contai...
php
public static function truncateLetters($html, $limit = 0, $ellipsis = '') { if ($limit <= 0) { return $html; } $doc = self::htmlToDomDocument($html); $container = $doc->getElementsByTagName('div')->item(0); $container = $container->parentNode->removeChild($contai...
[ "public", "static", "function", "truncateLetters", "(", "$", "html", ",", "$", "limit", "=", "0", ",", "$", "ellipsis", "=", "''", ")", "{", "if", "(", "$", "limit", "<=", "0", ")", "{", "return", "$", "html", ";", "}", "$", "doc", "=", "self", ...
Safely truncates HTML by a given number of letters. @param string $html Input HTML. @param int $limit Limit to how many letters we preserve. @param string $ellipsis String to use as ellipsis (if any). @return string Safe truncated HTML.
[ "Safely", "truncates", "HTML", "by", "a", "given", "number", "of", "letters", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Helpers/Truncator.php#L96-L134
207,916
getgrav/grav
system/src/Grav/Common/Helpers/Truncator.php
Truncator.htmlToDomDocument
public static function htmlToDomDocument($html) { if (!$html) { $html = ''; } // Transform multibyte entities which otherwise display incorrectly. $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); // Internal errors enabled as HTML5 not fully support...
php
public static function htmlToDomDocument($html) { if (!$html) { $html = ''; } // Transform multibyte entities which otherwise display incorrectly. $html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'); // Internal errors enabled as HTML5 not fully support...
[ "public", "static", "function", "htmlToDomDocument", "(", "$", "html", ")", "{", "if", "(", "!", "$", "html", ")", "{", "$", "html", "=", "''", ";", "}", "// Transform multibyte entities which otherwise display incorrectly.", "$", "html", "=", "mb_convert_encoding...
Builds a DOMDocument object from a string containing HTML. @param string $html HTML to load @returns DOMDocument Returns a DOMDocument object.
[ "Builds", "a", "DOMDocument", "object", "from", "a", "string", "containing", "HTML", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Helpers/Truncator.php#L141-L159
207,917
getgrav/grav
system/src/Grav/Common/Helpers/Truncator.php
Truncator.removeProceedingNodes
private static function removeProceedingNodes($domNode, $topNode) { $nextNode = $domNode->nextSibling; if ($nextNode !== null) { self::removeProceedingNodes($nextNode, $topNode); $domNode->parentNode->removeChild($nextNode); } else { //scan upwards till w...
php
private static function removeProceedingNodes($domNode, $topNode) { $nextNode = $domNode->nextSibling; if ($nextNode !== null) { self::removeProceedingNodes($nextNode, $topNode); $domNode->parentNode->removeChild($nextNode); } else { //scan upwards till w...
[ "private", "static", "function", "removeProceedingNodes", "(", "$", "domNode", ",", "$", "topNode", ")", "{", "$", "nextNode", "=", "$", "domNode", "->", "nextSibling", ";", "if", "(", "$", "nextNode", "!==", "null", ")", "{", "self", "::", "removeProceedi...
Removes all nodes after the current node. @param DOMNode|DOMElement $domNode @param DOMNode|DOMElement $topNode @return void
[ "Removes", "all", "nodes", "after", "the", "current", "node", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Helpers/Truncator.php#L167-L187
207,918
getgrav/grav
system/src/Grav/Common/Helpers/Truncator.php
Truncator.getCleanedHTML
private static function getCleanedHTML(DOMDocument $doc, $container) { while ($doc->firstChild) { $doc->removeChild($doc->firstChild); } while ($container->firstChild ) { $doc->appendChild($container->firstChild); } $html = trim($doc->saveHTML()); ...
php
private static function getCleanedHTML(DOMDocument $doc, $container) { while ($doc->firstChild) { $doc->removeChild($doc->firstChild); } while ($container->firstChild ) { $doc->appendChild($container->firstChild); } $html = trim($doc->saveHTML()); ...
[ "private", "static", "function", "getCleanedHTML", "(", "DOMDocument", "$", "doc", ",", "$", "container", ")", "{", "while", "(", "$", "doc", "->", "firstChild", ")", "{", "$", "doc", "->", "removeChild", "(", "$", "doc", "->", "firstChild", ")", ";", ...
Clean extra code @param DOMDocument $doc @param $container @return string
[ "Clean", "extra", "code" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Helpers/Truncator.php#L196-L208
207,919
getgrav/grav
system/src/Grav/Common/Helpers/Truncator.php
Truncator.insertEllipsis
private static function insertEllipsis($domNode, $ellipsis) { $avoid = array('a', 'strong', 'em', 'h1', 'h2', 'h3', 'h4', 'h5'); //html tags to avoid appending the ellipsis to if ($domNode->parentNode->parentNode !== null && in_array($domNode->parentNode->nodeName, $avoid, true)) { // A...
php
private static function insertEllipsis($domNode, $ellipsis) { $avoid = array('a', 'strong', 'em', 'h1', 'h2', 'h3', 'h4', 'h5'); //html tags to avoid appending the ellipsis to if ($domNode->parentNode->parentNode !== null && in_array($domNode->parentNode->nodeName, $avoid, true)) { // A...
[ "private", "static", "function", "insertEllipsis", "(", "$", "domNode", ",", "$", "ellipsis", ")", "{", "$", "avoid", "=", "array", "(", "'a'", ",", "'strong'", ",", "'em'", ",", "'h1'", ",", "'h2'", ",", "'h3'", ",", "'h4'", ",", "'h5'", ")", ";", ...
Inserts an ellipsis @param DOMNode|DOMElement $domNode Element to insert after. @param string $ellipsis Text used to suffix our document. @return void
[ "Inserts", "an", "ellipsis" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Helpers/Truncator.php#L216-L234
207,920
getgrav/grav
system/src/Grav/Common/Page/Medium/MediumFactory.php
MediumFactory.fromFile
public static function fromFile($file, array $params = []) { if (!file_exists($file)) { return null; } $parts = pathinfo($file); $path = $parts['dirname']; $filename = $parts['basename']; $ext = $parts['extension']; $basename = $parts['filename'];...
php
public static function fromFile($file, array $params = []) { if (!file_exists($file)) { return null; } $parts = pathinfo($file); $path = $parts['dirname']; $filename = $parts['basename']; $ext = $parts['extension']; $basename = $parts['filename'];...
[ "public", "static", "function", "fromFile", "(", "$", "file", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", ")", ")", "{", "return", "null", ";", "}", "$", "parts", "=", "pathinfo", "(", "$...
Create Medium from a file @param string $file @param array $params @return Medium
[ "Create", "Medium", "from", "a", "file" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/MediumFactory.php#L25-L69
207,921
getgrav/grav
system/src/Grav/Common/Page/Medium/MediumFactory.php
MediumFactory.fromUploadedFile
public static function fromUploadedFile(FormFlashFile $uploadedFile, array $params = []) { $parts = pathinfo($uploadedFile->getClientFilename()); $filename = $parts['basename']; $ext = $parts['extension']; $basename = $parts['filename']; $file = $uploadedFile->getTmpFile(); ...
php
public static function fromUploadedFile(FormFlashFile $uploadedFile, array $params = []) { $parts = pathinfo($uploadedFile->getClientFilename()); $filename = $parts['basename']; $ext = $parts['extension']; $basename = $parts['filename']; $file = $uploadedFile->getTmpFile(); ...
[ "public", "static", "function", "fromUploadedFile", "(", "FormFlashFile", "$", "uploadedFile", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "parts", "=", "pathinfo", "(", "$", "uploadedFile", "->", "getClientFilename", "(", ")", ")", ";", "$"...
Create Medium from an uploaded file @param FormFlashFile $uploadedFile @param array $params @return Medium
[ "Create", "Medium", "from", "an", "uploaded", "file" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/MediumFactory.php#L78-L119
207,922
getgrav/grav
system/src/Grav/Common/Page/Medium/MediumFactory.php
MediumFactory.fromArray
public static function fromArray(array $items = [], Blueprint $blueprint = null) { $type = $items['type'] ?? null; switch ($type) { case 'image': return new ImageMedium($items, $blueprint); case 'thumbnail': return new ThumbnailImageMedium($it...
php
public static function fromArray(array $items = [], Blueprint $blueprint = null) { $type = $items['type'] ?? null; switch ($type) { case 'image': return new ImageMedium($items, $blueprint); case 'thumbnail': return new ThumbnailImageMedium($it...
[ "public", "static", "function", "fromArray", "(", "array", "$", "items", "=", "[", "]", ",", "Blueprint", "$", "blueprint", "=", "null", ")", "{", "$", "type", "=", "$", "items", "[", "'type'", "]", "??", "null", ";", "switch", "(", "$", "type", ")...
Create Medium from array of parameters @param array $items @param Blueprint|null $blueprint @return Medium
[ "Create", "Medium", "from", "array", "of", "parameters" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/MediumFactory.php#L128-L147
207,923
getgrav/grav
system/src/Grav/Common/Page/Medium/MediumFactory.php
MediumFactory.scaledFromMedium
public static function scaledFromMedium($medium, $from, $to) { if (! $medium instanceof ImageMedium) { return $medium; } if ($to > $from) { return $medium; } $ratio = $to / $from; $width = $medium->get('width') * $ratio; $height = $me...
php
public static function scaledFromMedium($medium, $from, $to) { if (! $medium instanceof ImageMedium) { return $medium; } if ($to > $from) { return $medium; } $ratio = $to / $from; $width = $medium->get('width') * $ratio; $height = $me...
[ "public", "static", "function", "scaledFromMedium", "(", "$", "medium", ",", "$", "from", ",", "$", "to", ")", "{", "if", "(", "!", "$", "medium", "instanceof", "ImageMedium", ")", "{", "return", "$", "medium", ";", "}", "if", "(", "$", "to", ">", ...
Create a new ImageMedium by scaling another ImageMedium object. @param ImageMedium $medium @param int $from @param int $to @return Medium|array
[ "Create", "a", "new", "ImageMedium", "by", "scaling", "another", "ImageMedium", "object", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/MediumFactory.php#L157-L191
207,924
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.init
public function init() { $default = $this->config->get('system.languages.default_lang'); if (isset($default) && $this->validate($default)) { $this->default = $default; } else { $this->default = reset($this->languages); } $this->page_extensions = null;...
php
public function init() { $default = $this->config->get('system.languages.default_lang'); if (isset($default) && $this->validate($default)) { $this->default = $default; } else { $this->default = reset($this->languages); } $this->page_extensions = null;...
[ "public", "function", "init", "(", ")", "{", "$", "default", "=", "$", "this", "->", "config", "->", "get", "(", "'system.languages.default_lang'", ")", ";", "if", "(", "isset", "(", "$", "default", ")", "&&", "$", "this", "->", "validate", "(", "$", ...
Initialize the default and enabled languages
[ "Initialize", "the", "default", "and", "enabled", "languages" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L52-L66
207,925
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.getAvailable
public function getAvailable() { $languagesArray = $this->languages; //Make local copy $languagesArray = array_map(function($value) { return preg_quote($value); }, $languagesArray); sort($languagesArray); return implode('|', array_reverse($languagesArray)); ...
php
public function getAvailable() { $languagesArray = $this->languages; //Make local copy $languagesArray = array_map(function($value) { return preg_quote($value); }, $languagesArray); sort($languagesArray); return implode('|', array_reverse($languagesArray)); ...
[ "public", "function", "getAvailable", "(", ")", "{", "$", "languagesArray", "=", "$", "this", "->", "languages", ";", "//Make local copy", "$", "languagesArray", "=", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "preg_quote", "(", "$"...
Gets a pipe-separated string of available languages @return string
[ "Gets", "a", "pipe", "-", "separated", "string", "of", "available", "languages" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L104-L115
207,926
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.setActive
public function setActive($lang) { if ($this->validate($lang)) { $this->active = $lang; return $lang; } return false; }
php
public function setActive($lang) { if ($this->validate($lang)) { $this->active = $lang; return $lang; } return false; }
[ "public", "function", "setActive", "(", "$", "lang", ")", "{", "if", "(", "$", "this", "->", "validate", "(", "$", "lang", ")", ")", "{", "$", "this", "->", "active", "=", "$", "lang", ";", "return", "$", "lang", ";", "}", "return", "false", ";",...
Sets active language manually @param string $lang @return string|bool
[ "Sets", "active", "language", "manually" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L172-L181
207,927
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.setActiveFromUri
public function setActiveFromUri($uri) { $regex = '/(^\/(' . $this->getAvailable() . '))(?:\/|\?|$)/i'; // if languages set if ($this->enabled()) { // Try setting language from prefix of URL (/en/blah/blah). if (preg_match($regex, $uri, $matches)) { $...
php
public function setActiveFromUri($uri) { $regex = '/(^\/(' . $this->getAvailable() . '))(?:\/|\?|$)/i'; // if languages set if ($this->enabled()) { // Try setting language from prefix of URL (/en/blah/blah). if (preg_match($regex, $uri, $matches)) { $...
[ "public", "function", "setActiveFromUri", "(", "$", "uri", ")", "{", "$", "regex", "=", "'/(^\\/('", ".", "$", "this", "->", "getAvailable", "(", ")", ".", "'))(?:\\/|\\?|$)/i'", ";", "// if languages set", "if", "(", "$", "this", "->", "enabled", "(", ")"...
Sets the active language based on the first part of the URL @param string $uri @return string
[ "Sets", "the", "active", "language", "based", "on", "the", "first", "part", "of", "the", "URL" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L190-L234
207,928
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.getLanguageURLPrefix
public function getLanguageURLPrefix($lang = null) { // if active lang is not passed in, use current active if (!$lang) { $lang = $this->getLanguage(); } return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : ''; }
php
public function getLanguageURLPrefix($lang = null) { // if active lang is not passed in, use current active if (!$lang) { $lang = $this->getLanguage(); } return $this->isIncludeDefaultLanguage($lang) ? '/' . $lang : ''; }
[ "public", "function", "getLanguageURLPrefix", "(", "$", "lang", "=", "null", ")", "{", "// if active lang is not passed in, use current active", "if", "(", "!", "$", "lang", ")", "{", "$", "lang", "=", "$", "this", "->", "getLanguage", "(", ")", ";", "}", "r...
Get's a URL prefix based on configuration @param string|null $lang @return string
[ "Get", "s", "a", "URL", "prefix", "based", "on", "configuration" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L242-L250
207,929
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.isIncludeDefaultLanguage
public function isIncludeDefaultLanguage($lang = null) { // if active lang is not passed in, use current active if (!$lang) { $lang = $this->getLanguage(); } return !($this->default === $lang && $this->config->get('system.languages.include_default_lang') === false); ...
php
public function isIncludeDefaultLanguage($lang = null) { // if active lang is not passed in, use current active if (!$lang) { $lang = $this->getLanguage(); } return !($this->default === $lang && $this->config->get('system.languages.include_default_lang') === false); ...
[ "public", "function", "isIncludeDefaultLanguage", "(", "$", "lang", "=", "null", ")", "{", "// if active lang is not passed in, use current active", "if", "(", "!", "$", "lang", ")", "{", "$", "lang", "=", "$", "this", "->", "getLanguage", "(", ")", ";", "}", ...
Test to see if language is default and language should be included in the URL @param string|null $lang @return bool
[ "Test", "to", "see", "if", "language", "is", "default", "and", "language", "should", "be", "included", "in", "the", "URL" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L258-L266
207,930
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.getFallbackPageExtensions
public function getFallbackPageExtensions($file_ext = null) { if (empty($this->page_extensions)) { if (!$file_ext) { $file_ext = CONTENT_EXT; } if ($this->enabled()) { $valid_lang_extensions = []; foreach ($this->languages ...
php
public function getFallbackPageExtensions($file_ext = null) { if (empty($this->page_extensions)) { if (!$file_ext) { $file_ext = CONTENT_EXT; } if ($this->enabled()) { $valid_lang_extensions = []; foreach ($this->languages ...
[ "public", "function", "getFallbackPageExtensions", "(", "$", "file_ext", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "page_extensions", ")", ")", "{", "if", "(", "!", "$", "file_ext", ")", "{", "$", "file_ext", "=", "CONTENT_EXT", ...
Gets an array of valid extensions with active first, then fallback extensions @param string|null $file_ext @return array
[ "Gets", "an", "array", "of", "valid", "extensions", "with", "active", "first", "then", "fallback", "extensions" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L286-L320
207,931
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.getFallbackLanguages
public function getFallbackLanguages() { if (empty($this->fallback_languages)) { if ($this->enabled()) { $fallback_languages = $this->languages; if ($this->active) { $active_extension = $this->active; $key = \array_search($...
php
public function getFallbackLanguages() { if (empty($this->fallback_languages)) { if ($this->enabled()) { $fallback_languages = $this->languages; if ($this->active) { $active_extension = $this->active; $key = \array_search($...
[ "public", "function", "getFallbackLanguages", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "fallback_languages", ")", ")", "{", "if", "(", "$", "this", "->", "enabled", "(", ")", ")", "{", "$", "fallback_languages", "=", "$", "this", "->"...
Gets an array of languages with active first, then fallback languages @return array
[ "Gets", "an", "array", "of", "languages", "with", "active", "first", "then", "fallback", "languages" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L343-L362
207,932
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.translate
public function translate($args, array $languages = null, $array_support = false, $html_out = false) { if (\is_array($args)) { $lookup = array_shift($args); } else { $lookup = $args; $args = []; } if ($this->config->get('system.languages.translati...
php
public function translate($args, array $languages = null, $array_support = false, $html_out = false) { if (\is_array($args)) { $lookup = array_shift($args); } else { $lookup = $args; $args = []; } if ($this->config->get('system.languages.translati...
[ "public", "function", "translate", "(", "$", "args", ",", "array", "$", "languages", "=", "null", ",", "$", "array_support", "=", "false", ",", "$", "html_out", "=", "false", ")", "{", "if", "(", "\\", "is_array", "(", "$", "args", ")", ")", "{", "...
Translate a key and possibly arguments into a string using current lang and fallbacks @param string|array $args The first argument is the lookup key value Other arguments can be passed and replaced in the translation with sprintf syntax @param array $languages @param bool $array_support @param bool $html_out @...
[ "Translate", "a", "key", "and", "possibly", "arguments", "into", "a", "string", "using", "current", "lang", "and", "fallbacks" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L387-L427
207,933
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.getTranslation
public function getTranslation($lang, $key, $array_support = false) { $translation = Grav::instance()['languages']->get($lang . '.' . $key, null); if (!$array_support && is_array($translation)) { return (string)array_shift($translation); } return $translation; }
php
public function getTranslation($lang, $key, $array_support = false) { $translation = Grav::instance()['languages']->get($lang . '.' . $key, null); if (!$array_support && is_array($translation)) { return (string)array_shift($translation); } return $translation; }
[ "public", "function", "getTranslation", "(", "$", "lang", ",", "$", "key", ",", "$", "array_support", "=", "false", ")", "{", "$", "translation", "=", "Grav", "::", "instance", "(", ")", "[", "'languages'", "]", "->", "get", "(", "$", "lang", ".", "'...
Lookup the translation text for a given lang and key @param string $lang lang code @param string $key key to lookup with @param bool $array_support @return string
[ "Lookup", "the", "translation", "text", "for", "a", "given", "lang", "and", "key" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L478-L486
207,934
getgrav/grav
system/src/Grav/Common/Language/Language.php
Language.getBrowserLanguages
public function getBrowserLanguages($accept_langs = []) { user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, no longer used', E_USER_DEPRECATED); if (empty($this->http_accept_language)) { if (empty($accept_langs) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { ...
php
public function getBrowserLanguages($accept_langs = []) { user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, no longer used', E_USER_DEPRECATED); if (empty($this->http_accept_language)) { if (empty($accept_langs) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { ...
[ "public", "function", "getBrowserLanguages", "(", "$", "accept_langs", "=", "[", "]", ")", "{", "user_error", "(", "__CLASS__", ".", "'::'", ".", "__FUNCTION__", ".", "'() is deprecated since Grav 1.6, no longer used'", ",", "E_USER_DEPRECATED", ")", ";", "if", "(",...
Get the browser accepted languages @param array $accept_langs @return array @deprecated 1.6 No longer used - using content negotiation.
[ "Get", "the", "browser", "accepted", "languages" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Language/Language.php#L495-L523
207,935
getgrav/grav
system/src/Grav/Framework/Flex/FlexCollection.php
FlexCollection.getCachedMethods
public static function getCachedMethods(): array { return [ 'getTypePrefix' => true, 'getType' => true, 'getFlexDirectory' => true, 'getCacheKey' => true, 'getCacheChecksum' => true, 'getTimestamp' => true, 'hasProperty' => ...
php
public static function getCachedMethods(): array { return [ 'getTypePrefix' => true, 'getType' => true, 'getFlexDirectory' => true, 'getCacheKey' => true, 'getCacheChecksum' => true, 'getTimestamp' => true, 'hasProperty' => ...
[ "public", "static", "function", "getCachedMethods", "(", ")", ":", "array", "{", "return", "[", "'getTypePrefix'", "=>", "true", ",", "'getType'", "=>", "true", ",", "'getFlexDirectory'", "=>", "true", ",", "'getCacheKey'", "=>", "true", ",", "'getCacheChecksum'...
Get list of cached methods. @return array Returns a list of methods with their caching information.
[ "Get", "list", "of", "cached", "methods", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexCollection.php#L47-L67
207,936
getgrav/grav
system/src/Grav/Framework/Flex/FlexCollection.php
FlexCollection.createFrom
protected function createFrom(array $elements, $keyField = null) { $collection = new static($elements, $this->_flexDirectory); $collection->setKeyField($keyField ?: $this->_keyField); return $collection; }
php
protected function createFrom(array $elements, $keyField = null) { $collection = new static($elements, $this->_flexDirectory); $collection->setKeyField($keyField ?: $this->_keyField); return $collection; }
[ "protected", "function", "createFrom", "(", "array", "$", "elements", ",", "$", "keyField", "=", "null", ")", "{", "$", "collection", "=", "new", "static", "(", "$", "elements", ",", "$", "this", "->", "_flexDirectory", ")", ";", "$", "collection", "->",...
Creates a new instance from the specified elements. This method is provided for derived classes to specify how a new instance should be created when constructor semantics have changed. @param array $elements Elements. @param string|null $keyField @return static @throws \InvalidArgumentException
[ "Creates", "a", "new", "instance", "from", "the", "specified", "elements", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Flex/FlexCollection.php#L463-L469
207,937
getgrav/grav
system/src/Grav/Framework/Form/FormFlash.php
FormFlash.addUploadedFile
public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string { $tmp_dir = $this->getTmpDir(); $tmp_name = Utils::generateRandomString(12); $name = $upload->getClientFilename(); // Prepare upload data for later save $data = ...
php
public function addUploadedFile(UploadedFileInterface $upload, string $field = null, array $crop = null): string { $tmp_dir = $this->getTmpDir(); $tmp_name = Utils::generateRandomString(12); $name = $upload->getClientFilename(); // Prepare upload data for later save $data = ...
[ "public", "function", "addUploadedFile", "(", "UploadedFileInterface", "$", "upload", ",", "string", "$", "field", "=", "null", ",", "array", "$", "crop", "=", "null", ")", ":", "string", "{", "$", "tmp_dir", "=", "$", "this", "->", "getTmpDir", "(", ")"...
Add uploaded file to the form flash. @param UploadedFileInterface $upload @param string|null $field @param array|null $crop @return string Return name of the file
[ "Add", "uploaded", "file", "to", "the", "form", "flash", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/FormFlash.php#L235-L255
207,938
getgrav/grav
system/src/Grav/Framework/Form/FormFlash.php
FormFlash.addFile
public function addFile(string $filename, string $field, array $crop = null): bool { if (!file_exists($filename)) { throw new \RuntimeException("File not found: {$filename}"); } // Prepare upload data for later save $data = [ 'name' => basename($filename), ...
php
public function addFile(string $filename, string $field, array $crop = null): bool { if (!file_exists($filename)) { throw new \RuntimeException("File not found: {$filename}"); } // Prepare upload data for later save $data = [ 'name' => basename($filename), ...
[ "public", "function", "addFile", "(", "string", "$", "filename", ",", "string", "$", "field", ",", "array", "$", "crop", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "file_exists", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\", "...
Add existing file to the form flash. @param string $filename @param string $field @param array $crop @return bool
[ "Add", "existing", "file", "to", "the", "form", "flash", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/FormFlash.php#L266-L282
207,939
getgrav/grav
system/src/Grav/Framework/Form/FormFlash.php
FormFlash.removeFile
public function removeFile(string $name, string $field = null): bool { if (!$name) { return false; } $field = $field ?: 'undefined'; $upload = $this->files[$field][$name] ?? null; if (null !== $upload) { $this->removeTmpFile($upload['tmp_name'] ?? ''...
php
public function removeFile(string $name, string $field = null): bool { if (!$name) { return false; } $field = $field ?: 'undefined'; $upload = $this->files[$field][$name] ?? null; if (null !== $upload) { $this->removeTmpFile($upload['tmp_name'] ?? ''...
[ "public", "function", "removeFile", "(", "string", "$", "name", ",", "string", "$", "field", "=", "null", ")", ":", "bool", "{", "if", "(", "!", "$", "name", ")", "{", "return", "false", ";", "}", "$", "field", "=", "$", "field", "?", ":", "'unde...
Remove any file from form flash. @param string $name @param string $field @return bool
[ "Remove", "any", "file", "from", "form", "flash", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/FormFlash.php#L291-L318
207,940
getgrav/grav
system/src/Grav/Framework/Form/FormFlash.php
FormFlash.clearFiles
public function clearFiles() { foreach ($this->files as $field => $files) { foreach ($files as $name => $upload) { $this->removeTmpFile($upload['tmp_name'] ?? ''); } } $this->files = []; }
php
public function clearFiles() { foreach ($this->files as $field => $files) { foreach ($files as $name => $upload) { $this->removeTmpFile($upload['tmp_name'] ?? ''); } } $this->files = []; }
[ "public", "function", "clearFiles", "(", ")", "{", "foreach", "(", "$", "this", "->", "files", "as", "$", "field", "=>", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "name", "=>", "$", "upload", ")", "{", "$", "this", "->", "r...
Clear form flash from all uploaded files.
[ "Clear", "form", "flash", "from", "all", "uploaded", "files", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Framework/Form/FormFlash.php#L323-L332
207,941
getgrav/grav
system/src/Grav/Common/Twig/Twig.php
Twig.processTemplate
public function processTemplate($template, $vars = []) { // override the twig header vars for local resolution $this->grav->fireEvent('onTwigTemplateVariables'); $vars += $this->twig_vars; try { $output = $this->twig->render($template, $vars); } catch (\Twig_Erro...
php
public function processTemplate($template, $vars = []) { // override the twig header vars for local resolution $this->grav->fireEvent('onTwigTemplateVariables'); $vars += $this->twig_vars; try { $output = $this->twig->render($template, $vars); } catch (\Twig_Erro...
[ "public", "function", "processTemplate", "(", "$", "template", ",", "$", "vars", "=", "[", "]", ")", "{", "// override the twig header vars for local resolution", "$", "this", "->", "grav", "->", "fireEvent", "(", "'onTwigTemplateVariables'", ")", ";", "$", "vars"...
Process a Twig template directly by using a template name and optional array of variables @param string $template template to render with @param array $vars Optional variables @return string
[ "Process", "a", "Twig", "template", "directly", "by", "using", "a", "template", "name", "and", "optional", "array", "of", "variables" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/Twig.php#L307-L321
207,942
getgrav/grav
system/src/Grav/Common/Twig/Twig.php
Twig.processString
public function processString($string, array $vars = []) { // override the twig header vars for local resolution $this->grav->fireEvent('onTwigStringVariables'); $vars += $this->twig_vars; $name = '@Var:' . $string; $this->setTemplate($name, $string); try { ...
php
public function processString($string, array $vars = []) { // override the twig header vars for local resolution $this->grav->fireEvent('onTwigStringVariables'); $vars += $this->twig_vars; $name = '@Var:' . $string; $this->setTemplate($name, $string); try { ...
[ "public", "function", "processString", "(", "$", "string", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "// override the twig header vars for local resolution", "$", "this", "->", "grav", "->", "fireEvent", "(", "'onTwigStringVariables'", ")", ";", "$", "...
Process a Twig template directly by using a Twig string and optional array of variables @param string $string string to render. @param array $vars Optional variables @return string
[ "Process", "a", "Twig", "template", "directly", "by", "using", "a", "Twig", "string", "and", "optional", "array", "of", "variables" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/Twig.php#L333-L349
207,943
getgrav/grav
system/src/Grav/Common/Twig/Twig.php
Twig.processSite
public function processSite($format = null, array $vars = []) { // set the page now its been processed $this->grav->fireEvent('onTwigSiteVariables'); $pages = $this->grav['pages']; $page = $this->grav['page']; $content = $page->content(); $twig_vars = $this->twig_var...
php
public function processSite($format = null, array $vars = []) { // set the page now its been processed $this->grav->fireEvent('onTwigSiteVariables'); $pages = $this->grav['pages']; $page = $this->grav['page']; $content = $page->content(); $twig_vars = $this->twig_var...
[ "public", "function", "processSite", "(", "$", "format", "=", "null", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "// set the page now its been processed", "$", "this", "->", "grav", "->", "fireEvent", "(", "'onTwigSiteVariables'", ")", ";", "$", "pa...
Twig process that renders the site layout. This is the main twig process that renders the overall page and handles all the layout for the site display. @param string $format Output format (defaults to HTML). @return string the rendered output @throws \RuntimeException
[ "Twig", "process", "that", "renders", "the", "site", "layout", ".", "This", "is", "the", "main", "twig", "process", "that", "renders", "the", "overall", "page", "and", "handles", "all", "the", "layout", "for", "the", "site", "display", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/Twig.php#L360-L405
207,944
getgrav/grav
system/src/Grav/Common/Twig/Twig.php
Twig.setAutoescape
public function setAutoescape($state) { if (!$state) { user_error(__CLASS__ . '::' . __FUNCTION__ . '(false) is deprecated since Grav 1.5', E_USER_DEPRECATED); } $this->autoescape = (bool) $state; }
php
public function setAutoescape($state) { if (!$state) { user_error(__CLASS__ . '::' . __FUNCTION__ . '(false) is deprecated since Grav 1.5', E_USER_DEPRECATED); } $this->autoescape = (bool) $state; }
[ "public", "function", "setAutoescape", "(", "$", "state", ")", "{", "if", "(", "!", "$", "state", ")", "{", "user_error", "(", "__CLASS__", ".", "'::'", ".", "__FUNCTION__", ".", "'(false) is deprecated since Grav 1.5'", ",", "E_USER_DEPRECATED", ")", ";", "}"...
Overrides the autoescape setting @param bool $state @deprecated 1.5 Auto-escape should always be turned on to protect against XSS issues (can be disabled per template file).
[ "Overrides", "the", "autoescape", "setting" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Twig/Twig.php#L446-L453
207,945
getgrav/grav
system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
LegacyAssetsTrait.addDeferJs
public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head') { user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use dynamic method with [\'loading\' => \'defer\']', E_USER_DEPRECATED); return $this->addJs($asset, $priority, $pipeline, 'defer', ...
php
public function addDeferJs($asset, $priority = 10, $pipeline = true, $group = 'head') { user_error(__CLASS__ . '::' . __FUNCTION__ . '() is deprecated since Grav 1.6, use dynamic method with [\'loading\' => \'defer\']', E_USER_DEPRECATED); return $this->addJs($asset, $priority, $pipeline, 'defer', ...
[ "public", "function", "addDeferJs", "(", "$", "asset", ",", "$", "priority", "=", "10", ",", "$", "pipeline", "=", "true", ",", "$", "group", "=", "'head'", ")", "{", "user_error", "(", "__CLASS__", ".", "'::'", ".", "__FUNCTION__", ".", "'() is deprecat...
Convenience wrapper for deferred loading of JavaScript @param string|array $asset @param int $priority @param bool $pipeline @param string $group name of the group @return \Grav\Common\Assets @deprecated Please use dynamic method with ['loading' => 'defer'].
[ "Convenience", "wrapper", "for", "deferred", "loading", "of", "JavaScript" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php#L118-L123
207,946
getgrav/grav
system/src/Grav/Common/GPM/Upgrader.php
Upgrader.minPHPVersion
public function minPHPVersion() { if (null === $this->min_php) { $this->min_php = $this->remote->getMinPHPVersion(); } return $this->min_php; }
php
public function minPHPVersion() { if (null === $this->min_php) { $this->min_php = $this->remote->getMinPHPVersion(); } return $this->min_php; }
[ "public", "function", "minPHPVersion", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "min_php", ")", "{", "$", "this", "->", "min_php", "=", "$", "this", "->", "remote", "->", "getMinPHPVersion", "(", ")", ";", "}", "return", "$", "this...
Get minimum PHP version from remote @return null
[ "Get", "minimum", "PHP", "version", "from", "remote" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/GPM/Upgrader.php#L114-L120
207,947
getgrav/grav
system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php
ThumbnailImageMedium.bubble
protected function bubble($method, array $arguments = [], $testLinked = true) { if (!$testLinked || $this->linked) { return $this->parent ? call_user_func_array(array($this->parent, $method), $arguments) : $this; } return call_user_func_array(array($this, 'parent::' . $method), ...
php
protected function bubble($method, array $arguments = [], $testLinked = true) { if (!$testLinked || $this->linked) { return $this->parent ? call_user_func_array(array($this->parent, $method), $arguments) : $this; } return call_user_func_array(array($this, 'parent::' . $method), ...
[ "protected", "function", "bubble", "(", "$", "method", ",", "array", "$", "arguments", "=", "[", "]", ",", "$", "testLinked", "=", "true", ")", "{", "if", "(", "!", "$", "testLinked", "||", "$", "this", "->", "linked", ")", "{", "return", "$", "thi...
Bubble a function call up to either the superclass function or the parent Medium instance @param string $method @param array $arguments @param bool $testLinked @return Medium
[ "Bubble", "a", "function", "call", "up", "to", "either", "the", "superclass", "function", "or", "the", "parent", "Medium", "instance" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Page/Medium/ThumbnailImageMedium.php#L124-L131
207,948
getgrav/grav
system/src/Grav/Common/Taxonomy.php
Taxonomy.addTaxonomy
public function addTaxonomy(PageInterface $page, $page_taxonomy = null) { if (!$page_taxonomy) { $page_taxonomy = $page->taxonomy(); } if (empty($page_taxonomy) || !$page->published()) { return; } /** @var Config $config */ $config = $this->g...
php
public function addTaxonomy(PageInterface $page, $page_taxonomy = null) { if (!$page_taxonomy) { $page_taxonomy = $page->taxonomy(); } if (empty($page_taxonomy) || !$page->published()) { return; } /** @var Config $config */ $config = $this->g...
[ "public", "function", "addTaxonomy", "(", "PageInterface", "$", "page", ",", "$", "page_taxonomy", "=", "null", ")", "{", "if", "(", "!", "$", "page_taxonomy", ")", "{", "$", "page_taxonomy", "=", "$", "page", "->", "taxonomy", "(", ")", ";", "}", "if"...
Takes an individual page and processes the taxonomies configured in its header. It then adds those taxonomies to the map @param PageInterface $page the page to process @param array $page_taxonomy
[ "Takes", "an", "individual", "page", "and", "processes", "the", "taxonomies", "configured", "in", "its", "header", ".", "It", "then", "adds", "those", "taxonomies", "to", "the", "map" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Taxonomy.php#L56-L77
207,949
getgrav/grav
system/src/Grav/Common/Taxonomy.php
Taxonomy.findTaxonomy
public function findTaxonomy($taxonomies, $operator = 'and') { $matches = []; $results = []; foreach ((array)$taxonomies as $taxonomy => $items) { foreach ((array)$items as $item) { if (isset($this->taxonomy_map[$taxonomy][$item])) { $matches[...
php
public function findTaxonomy($taxonomies, $operator = 'and') { $matches = []; $results = []; foreach ((array)$taxonomies as $taxonomy => $items) { foreach ((array)$items as $item) { if (isset($this->taxonomy_map[$taxonomy][$item])) { $matches[...
[ "public", "function", "findTaxonomy", "(", "$", "taxonomies", ",", "$", "operator", "=", "'and'", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "results", "=", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "taxonomies", "as", "$", "ta...
Returns a new Page object with the sub-pages containing all the values set for a particular taxonomy. @param array $taxonomies taxonomies to search, eg ['tag'=>['animal','cat']] @param string $operator can be 'or' or 'and' (defaults to 'and') @return Collection Collection object set to contain matches foun...
[ "Returns", "a", "new", "Page", "object", "with", "the", "sub", "-", "pages", "containing", "all", "the", "values", "set", "for", "a", "particular", "taxonomy", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Taxonomy.php#L88-L115
207,950
getgrav/grav
system/src/Grav/Common/Taxonomy.php
Taxonomy.getTaxonomyItemKeys
public function getTaxonomyItemKeys($taxonomy) { return isset($this->taxonomy_map[$taxonomy]) ? array_keys($this->taxonomy_map[$taxonomy]) : []; }
php
public function getTaxonomyItemKeys($taxonomy) { return isset($this->taxonomy_map[$taxonomy]) ? array_keys($this->taxonomy_map[$taxonomy]) : []; }
[ "public", "function", "getTaxonomyItemKeys", "(", "$", "taxonomy", ")", "{", "return", "isset", "(", "$", "this", "->", "taxonomy_map", "[", "$", "taxonomy", "]", ")", "?", "array_keys", "(", "$", "this", "->", "taxonomy_map", "[", "$", "taxonomy", "]", ...
Gets item keys per taxonomy @param string $taxonomy taxonomy name @return array keys of this taxonomy
[ "Gets", "item", "keys", "per", "taxonomy" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Taxonomy.php#L140-L143
207,951
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.initializeWithUrlAndRootPath
public function initializeWithUrlAndRootPath($url, $root_path) { $this->initializeWithUrl($url); $this->root_path = $root_path; return $this; }
php
public function initializeWithUrlAndRootPath($url, $root_path) { $this->initializeWithUrl($url); $this->root_path = $root_path; return $this; }
[ "public", "function", "initializeWithUrlAndRootPath", "(", "$", "url", ",", "$", "root_path", ")", "{", "$", "this", "->", "initializeWithUrl", "(", "$", "url", ")", ";", "$", "this", "->", "root_path", "=", "$", "root_path", ";", "return", "$", "this", ...
Initialize the URI class by providing url and root_path arguments @param string $url @param string $root_path @return $this
[ "Initialize", "the", "URI", "class", "by", "providing", "url", "and", "root_path", "arguments" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L96-L102
207,952
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.paths
public function paths($id = null) { if ($id !== null) { return $this->paths[$id]; } return $this->paths; }
php
public function paths($id = null) { if ($id !== null) { return $this->paths[$id]; } return $this->paths; }
[ "public", "function", "paths", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", "!==", "null", ")", "{", "return", "$", "this", "->", "paths", "[", "$", "id", "]", ";", "}", "return", "$", "this", "->", "paths", ";", "}" ]
Return URI path. @param string $id @return string|string[]
[ "Return", "URI", "path", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L219-L226
207,953
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.route
public function route($absolute = false, $domain = false) { return ($absolute ? $this->rootUrl($domain) : '') . '/' . implode('/', $this->paths); }
php
public function route($absolute = false, $domain = false) { return ($absolute ? $this->rootUrl($domain) : '') . '/' . implode('/', $this->paths); }
[ "public", "function", "route", "(", "$", "absolute", "=", "false", ",", "$", "domain", "=", "false", ")", "{", "return", "(", "$", "absolute", "?", "$", "this", "->", "rootUrl", "(", "$", "domain", ")", ":", "''", ")", ".", "'/'", ".", "implode", ...
Return route to the current URI. By default route doesn't include base path. @param bool $absolute True to include full path. @param bool $domain True to include domain. Works only if first parameter is also true. @return string
[ "Return", "route", "to", "the", "current", "URI", ".", "By", "default", "route", "doesn", "t", "include", "base", "path", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L236-L239
207,954
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.query
public function query($id = null, $raw = false) { if ($id !== null) { return $this->queries[$id] ?? null; } if ($raw) { return $this->queries; } if (!$this->queries) { return ''; } return http_build_query($this->queries);...
php
public function query($id = null, $raw = false) { if ($id !== null) { return $this->queries[$id] ?? null; } if ($raw) { return $this->queries; } if (!$this->queries) { return ''; } return http_build_query($this->queries);...
[ "public", "function", "query", "(", "$", "id", "=", "null", ",", "$", "raw", "=", "false", ")", "{", "if", "(", "$", "id", "!==", "null", ")", "{", "return", "$", "this", "->", "queries", "[", "$", "id", "]", "??", "null", ";", "}", "if", "("...
Return full query string or a single query attribute. @param string $id Optional attribute. Get a single query attribute if set @param bool $raw If true and $id is not set, return the full query array. Otherwise return the query string @return string|array Returns an array if $id = null and $raw = true
[ "Return", "full", "query", "string", "or", "a", "single", "query", "attribute", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L249-L264
207,955
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.params
public function params($id = null, $array = false) { $config = Grav::instance()['config']; $sep = $config->get('system.param_sep'); $params = null; if ($id === null) { if ($array) { return $this->params; } $output = []; ...
php
public function params($id = null, $array = false) { $config = Grav::instance()['config']; $sep = $config->get('system.param_sep'); $params = null; if ($id === null) { if ($array) { return $this->params; } $output = []; ...
[ "public", "function", "params", "(", "$", "id", "=", "null", ",", "$", "array", "=", "false", ")", "{", "$", "config", "=", "Grav", "::", "instance", "(", ")", "[", "'config'", "]", ";", "$", "sep", "=", "$", "config", "->", "get", "(", "'system....
Return all or a single query parameter as a URI compatible string. @param string $id Optional parameter name. @param boolean $array return the array format or not @return null|string|array
[ "Return", "all", "or", "a", "single", "query", "parameter", "as", "a", "URI", "compatible", "string", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L274-L297
207,956
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.param
public function param($id) { if (isset($this->params[$id])) { return html_entity_decode(rawurldecode($this->params[$id])); } return false; }
php
public function param($id) { if (isset($this->params[$id])) { return html_entity_decode(rawurldecode($this->params[$id])); } return false; }
[ "public", "function", "param", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "params", "[", "$", "id", "]", ")", ")", "{", "return", "html_entity_decode", "(", "rawurldecode", "(", "$", "this", "->", "params", "[", "$", "id"...
Get URI parameter. @param string $id @return bool|string
[ "Get", "URI", "parameter", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L306-L313
207,957
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.url
public function url($include_host = false) { if ($include_host) { return $this->url; } $url = str_replace($this->base, '', rtrim($this->url, '/')); return $url ?: '/'; }
php
public function url($include_host = false) { if ($include_host) { return $this->url; } $url = str_replace($this->base, '', rtrim($this->url, '/')); return $url ?: '/'; }
[ "public", "function", "url", "(", "$", "include_host", "=", "false", ")", "{", "if", "(", "$", "include_host", ")", "{", "return", "$", "this", "->", "url", ";", "}", "$", "url", "=", "str_replace", "(", "$", "this", "->", "base", ",", "''", ",", ...
Return URL. @param bool $include_host Include hostname. @return string
[ "Return", "URL", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L337-L346
207,958
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.scheme
public function scheme($raw = false) { if (!$raw) { $scheme = ''; if ($this->scheme) { $scheme = $this->scheme . '://'; } elseif ($this->host) { $scheme = '//'; } return $scheme; } return $this->sch...
php
public function scheme($raw = false) { if (!$raw) { $scheme = ''; if ($this->scheme) { $scheme = $this->scheme . '://'; } elseif ($this->host) { $scheme = '//'; } return $scheme; } return $this->sch...
[ "public", "function", "scheme", "(", "$", "raw", "=", "false", ")", "{", "if", "(", "!", "$", "raw", ")", "{", "$", "scheme", "=", "''", ";", "if", "(", "$", "this", "->", "scheme", ")", "{", "$", "scheme", "=", "$", "this", "->", "scheme", "...
Return the scheme of the URI @param bool $raw @return string The scheme of the URI
[ "Return", "the", "scheme", "of", "the", "URI" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L391-L405
207,959
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.port
public function port($raw = false) { $port = $this->port; // If not in raw mode and port is not set, figure it out from scheme. if (!$raw && $port === null) { if ($this->scheme === 'http') { $this->port = 80; } elseif ($this->scheme === 'https') { ...
php
public function port($raw = false) { $port = $this->port; // If not in raw mode and port is not set, figure it out from scheme. if (!$raw && $port === null) { if ($this->scheme === 'http') { $this->port = 80; } elseif ($this->scheme === 'https') { ...
[ "public", "function", "port", "(", "$", "raw", "=", "false", ")", "{", "$", "port", "=", "$", "this", "->", "port", ";", "// If not in raw mode and port is not set, figure it out from scheme.", "if", "(", "!", "$", "raw", "&&", "$", "port", "===", "null", ")...
Return the port number if it can be figured out @param bool $raw @return int|null
[ "Return", "the", "port", "number", "if", "it", "can", "be", "figured", "out" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L424-L437
207,960
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.uri
public function uri($include_root = true) { if ($include_root) { return $this->uri; } return str_replace($this->root_path, '', $this->uri); }
php
public function uri($include_root = true) { if ($include_root) { return $this->uri; } return str_replace($this->root_path, '', $this->uri); }
[ "public", "function", "uri", "(", "$", "include_root", "=", "true", ")", "{", "if", "(", "$", "include_root", ")", "{", "return", "$", "this", "->", "uri", ";", "}", "return", "str_replace", "(", "$", "this", "->", "root_path", ",", "''", ",", "$", ...
Return the full uri @param bool $include_root @return mixed
[ "Return", "the", "full", "uri" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L486-L493
207,961
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.baseIncludingLanguage
public function baseIncludingLanguage() { $grav = Grav::instance(); /** @var Pages $pages */ $pages = $grav['pages']; return $pages->baseUrl(null, false); }
php
public function baseIncludingLanguage() { $grav = Grav::instance(); /** @var Pages $pages */ $pages = $grav['pages']; return $pages->baseUrl(null, false); }
[ "public", "function", "baseIncludingLanguage", "(", ")", "{", "$", "grav", "=", "Grav", "::", "instance", "(", ")", ";", "/** @var Pages $pages */", "$", "pages", "=", "$", "grav", "[", "'pages'", "]", ";", "return", "$", "pages", "->", "baseUrl", "(", "...
Return the base relative URL including the language prefix or the base relative url if multi-language is not enabled @return String The base of the URI
[ "Return", "the", "base", "relative", "URL", "including", "the", "language", "prefix", "or", "the", "base", "relative", "url", "if", "multi", "-", "language", "is", "not", "enabled" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L511-L519
207,962
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.rootUrl
public function rootUrl($include_host = false) { if ($include_host) { return $this->root; } return str_replace($this->base, '', $this->root); }
php
public function rootUrl($include_host = false) { if ($include_host) { return $this->root; } return str_replace($this->base, '', $this->root); }
[ "public", "function", "rootUrl", "(", "$", "include_host", "=", "false", ")", "{", "if", "(", "$", "include_host", ")", "{", "return", "$", "this", "->", "root", ";", "}", "return", "str_replace", "(", "$", "this", "->", "base", ",", "''", ",", "$", ...
Return root URL to the site. @param bool $include_host Include hostname. @return mixed
[ "Return", "root", "URL", "to", "the", "site", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L528-L535
207,963
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.referrer
public function referrer($default = null, $attributes = null) { $referrer = $_SERVER['HTTP_REFERER'] ?? null; // Check that referrer came from our site. $root = $this->rootUrl(true); if ($referrer) { // Referrer should always have host set and it should come from the sam...
php
public function referrer($default = null, $attributes = null) { $referrer = $_SERVER['HTTP_REFERER'] ?? null; // Check that referrer came from our site. $root = $this->rootUrl(true); if ($referrer) { // Referrer should always have host set and it should come from the sam...
[ "public", "function", "referrer", "(", "$", "default", "=", "null", ",", "$", "attributes", "=", "null", ")", "{", "$", "referrer", "=", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", "??", "null", ";", "// Check that referrer came from our site.", "$", "root", ...
Return relative path to the referrer defaulting to current or given page. @param string $default @param string $attributes @return string
[ "Return", "relative", "path", "to", "the", "referrer", "defaulting", "to", "current", "or", "given", "page", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L555-L578
207,964
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.ip
public static function ip() { if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); } elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_X_FORWARDED')) { $ip = getenv('HTTP_X_FORWARDED'); ...
php
public static function ip() { if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); } elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); } elseif (getenv('HTTP_X_FORWARDED')) { $ip = getenv('HTTP_X_FORWARDED'); ...
[ "public", "static", "function", "ip", "(", ")", "{", "if", "(", "getenv", "(", "'HTTP_CLIENT_IP'", ")", ")", "{", "$", "ip", "=", "getenv", "(", "'HTTP_CLIENT_IP'", ")", ";", "}", "elseif", "(", "getenv", "(", "'HTTP_X_FORWARDED_FOR'", ")", ")", "{", "...
Return the IP address of the current user @return string ip address
[ "Return", "the", "IP", "address", "of", "the", "current", "user" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L628-L647
207,965
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.getCurrentRoute
public static function getCurrentRoute() { if (!static::$currentRoute) { $uri = Grav::instance()['uri']; static::$currentRoute = RouteFactory::createFromParts($uri->toArray()); } return static::$currentRoute; }
php
public static function getCurrentRoute() { if (!static::$currentRoute) { $uri = Grav::instance()['uri']; static::$currentRoute = RouteFactory::createFromParts($uri->toArray()); } return static::$currentRoute; }
[ "public", "static", "function", "getCurrentRoute", "(", ")", "{", "if", "(", "!", "static", "::", "$", "currentRoute", ")", "{", "$", "uri", "=", "Grav", "::", "instance", "(", ")", "[", "'uri'", "]", ";", "static", "::", "$", "currentRoute", "=", "R...
Returns current route. @return \Grav\Framework\Route\Route
[ "Returns", "current", "route", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L668-L676
207,966
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.addNonce
public static function addNonce($url, $action, $nonceParamName = 'nonce') { $fake = $url && strpos($url, '/') === 0; if ($fake) { $url = 'http://domain.com' . $url; } $uri = new static($url); $parts = $uri->toArray(); $nonce = Utils::getNonce($action); ...
php
public static function addNonce($url, $action, $nonceParamName = 'nonce') { $fake = $url && strpos($url, '/') === 0; if ($fake) { $url = 'http://domain.com' . $url; } $uri = new static($url); $parts = $uri->toArray(); $nonce = Utils::getNonce($action); ...
[ "public", "static", "function", "addNonce", "(", "$", "url", ",", "$", "action", ",", "$", "nonceParamName", "=", "'nonce'", ")", "{", "$", "fake", "=", "$", "url", "&&", "strpos", "(", "$", "url", ",", "'/'", ")", "===", "0", ";", "if", "(", "$"...
Adds the nonce to a URL for a specific action @param string $url the url @param string $action the action @param string $nonceParamName the param name to use @return string the url with the nonce
[ "Adds", "the", "nonce", "to", "a", "URL", "for", "a", "specific", "action" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L1056-L1073
207,967
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.cleanPath
public static function cleanPath($path) { $regex = '/(\/)\/+/'; $path = str_replace(['\\', '/ /'], '/', $path); $path = preg_replace($regex,'$1',$path); return $path; }
php
public static function cleanPath($path) { $regex = '/(\/)\/+/'; $path = str_replace(['\\', '/ /'], '/', $path); $path = preg_replace($regex,'$1',$path); return $path; }
[ "public", "static", "function", "cleanPath", "(", "$", "path", ")", "{", "$", "regex", "=", "'/(\\/)\\/+/'", ";", "$", "path", "=", "str_replace", "(", "[", "'\\\\'", ",", "'/ /'", "]", ",", "'/'", ",", "$", "path", ")", ";", "$", "path", "=", "pre...
Removes extra double slashes and fixes back-slashes @param string $path @return mixed|string
[ "Removes", "extra", "double", "slashes", "and", "fixes", "back", "-", "slashes" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L1097-L1104
207,968
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.getContentType
public function getContentType($short = true) { if (isset($_SERVER['CONTENT_TYPE'])) { $content_type = $_SERVER['CONTENT_TYPE']; if ($short) { return Utils::substrToString($content_type,';'); } return $content_type; } return nul...
php
public function getContentType($short = true) { if (isset($_SERVER['CONTENT_TYPE'])) { $content_type = $_SERVER['CONTENT_TYPE']; if ($short) { return Utils::substrToString($content_type,';'); } return $content_type; } return nul...
[ "public", "function", "getContentType", "(", "$", "short", "=", "true", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'CONTENT_TYPE'", "]", ")", ")", "{", "$", "content_type", "=", "$", "_SERVER", "[", "'CONTENT_TYPE'", "]", ";", "if", "(", ...
Get content type from request @param bool $short @return null|string
[ "Get", "content", "type", "from", "request" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L1328-L1338
207,969
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.isValidExtension
public function isValidExtension($extension) { $valid_page_types = implode('|', Grav::instance()['config']->get('system.pages.types')); // Strip the file extension for valid page types if (preg_match('/(' . $valid_page_types . ')/', $extension)) { return true; } ...
php
public function isValidExtension($extension) { $valid_page_types = implode('|', Grav::instance()['config']->get('system.pages.types')); // Strip the file extension for valid page types if (preg_match('/(' . $valid_page_types . ')/', $extension)) { return true; } ...
[ "public", "function", "isValidExtension", "(", "$", "extension", ")", "{", "$", "valid_page_types", "=", "implode", "(", "'|'", ",", "Grav", "::", "instance", "(", ")", "[", "'config'", "]", "->", "get", "(", "'system.pages.types'", ")", ")", ";", "// Stri...
Check if this is a valid Grav extension @param $extension @return bool
[ "Check", "if", "this", "is", "a", "valid", "Grav", "extension" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L1346-L1355
207,970
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.buildRootPath
private function buildRootPath() { // In Windows script path uses backslash, convert it: $scriptPath = str_replace('\\', '/', $_SERVER['PHP_SELF']); $rootPath = str_replace(' ', '%20', rtrim(substr($scriptPath, 0, strpos($scriptPath, 'index.php')), '/')); return $rootPath; }
php
private function buildRootPath() { // In Windows script path uses backslash, convert it: $scriptPath = str_replace('\\', '/', $_SERVER['PHP_SELF']); $rootPath = str_replace(' ', '%20', rtrim(substr($scriptPath, 0, strpos($scriptPath, 'index.php')), '/')); return $rootPath; }
[ "private", "function", "buildRootPath", "(", ")", "{", "// In Windows script path uses backslash, convert it:", "$", "scriptPath", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "_SERVER", "[", "'PHP_SELF'", "]", ")", ";", "$", "rootPath", "=", "str_repl...
Get the Grav Root Path @return string
[ "Get", "the", "Grav", "Root", "Path" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L1387-L1394
207,971
getgrav/grav
system/src/Grav/Common/Uri.php
Uri.processParams
private function processParams($uri, $delimiter = ':') { if (strpos($uri, $delimiter) !== false) { preg_match_all(static::paramsRegex(), $uri, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $param = explode($delimiter, $match[1]); if (count...
php
private function processParams($uri, $delimiter = ':') { if (strpos($uri, $delimiter) !== false) { preg_match_all(static::paramsRegex(), $uri, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $param = explode($delimiter, $match[1]); if (count...
[ "private", "function", "processParams", "(", "$", "uri", ",", "$", "delimiter", "=", "':'", ")", "{", "if", "(", "strpos", "(", "$", "uri", ",", "$", "delimiter", ")", "!==", "false", ")", "{", "preg_match_all", "(", "static", "::", "paramsRegex", "(",...
Process any params based in this URL, supports any valid delimiter @param string $uri @param string $delimiter @return string
[ "Process", "any", "params", "based", "in", "this", "URL", "supports", "any", "valid", "delimiter" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Uri.php#L1414-L1429
207,972
getgrav/grav
system/src/Grav/Common/Scheduler/Scheduler.php
Scheduler.getAllJobs
public function getAllJobs() { list($background, $foreground) = $this->loadSavedJobs()->getQueuedJobs(true); return array_merge($background, $foreground); }
php
public function getAllJobs() { list($background, $foreground) = $this->loadSavedJobs()->getQueuedJobs(true); return array_merge($background, $foreground); }
[ "public", "function", "getAllJobs", "(", ")", "{", "list", "(", "$", "background", ",", "$", "foreground", ")", "=", "$", "this", "->", "loadSavedJobs", "(", ")", "->", "getQueuedJobs", "(", "true", ")", ";", "return", "array_merge", "(", "$", "backgroun...
Get all jobs if they are disabled or not as one array @return array
[ "Get", "all", "jobs", "if", "they", "are", "disabled", "or", "not", "as", "one", "array" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L111-L116
207,973
getgrav/grav
system/src/Grav/Common/Scheduler/Scheduler.php
Scheduler.addFunction
public function addFunction(callable $fn, $args = [], $id = null) { $job = new Job($fn, $args, $id); $this->queueJob($job->configure($this->config)); return $job; }
php
public function addFunction(callable $fn, $args = [], $id = null) { $job = new Job($fn, $args, $id); $this->queueJob($job->configure($this->config)); return $job; }
[ "public", "function", "addFunction", "(", "callable", "$", "fn", ",", "$", "args", "=", "[", "]", ",", "$", "id", "=", "null", ")", "{", "$", "job", "=", "new", "Job", "(", "$", "fn", ",", "$", "args", ",", "$", "id", ")", ";", "$", "this", ...
Queues a PHP function execution. @param callable $fn The function to execute @param array $args Optional arguments to pass to the php script @param string $id Optional custom identifier @return Job
[ "Queues", "a", "PHP", "function", "execution", "." ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L126-L132
207,974
getgrav/grav
system/src/Grav/Common/Scheduler/Scheduler.php
Scheduler.getCronCommand
public function getCronCommand() { $phpBinaryFinder = new PhpExecutableFinder(); $php = $phpBinaryFinder->find(); $command = 'cd ' . str_replace(' ', '\ ', GRAV_ROOT) . ';' . $php . ' bin/grav scheduler'; return "(crontab -l; echo \"* * * * * {$command} 1>> /dev/null 2>&1\") | cront...
php
public function getCronCommand() { $phpBinaryFinder = new PhpExecutableFinder(); $php = $phpBinaryFinder->find(); $command = 'cd ' . str_replace(' ', '\ ', GRAV_ROOT) . ';' . $php . ' bin/grav scheduler'; return "(crontab -l; echo \"* * * * * {$command} 1>> /dev/null 2>&1\") | cront...
[ "public", "function", "getCronCommand", "(", ")", "{", "$", "phpBinaryFinder", "=", "new", "PhpExecutableFinder", "(", ")", ";", "$", "php", "=", "$", "phpBinaryFinder", "->", "find", "(", ")", ";", "$", "command", "=", "'cd '", ".", "str_replace", "(", ...
Helper to get the full Cron command @return string
[ "Helper", "to", "get", "the", "full", "Cron", "command" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L233-L240
207,975
getgrav/grav
system/src/Grav/Common/Scheduler/Scheduler.php
Scheduler.isCrontabSetup
public function isCrontabSetup() { $process = new Process('crontab -l'); $process->run(); if ($process->isSuccessful()) { $output = $process->getOutput(); return preg_match('$bin\/grav schedule$', $output) ? 1 : 0; } $error = $process->getErrorOutpu...
php
public function isCrontabSetup() { $process = new Process('crontab -l'); $process->run(); if ($process->isSuccessful()) { $output = $process->getOutput(); return preg_match('$bin\/grav schedule$', $output) ? 1 : 0; } $error = $process->getErrorOutpu...
[ "public", "function", "isCrontabSetup", "(", ")", "{", "$", "process", "=", "new", "Process", "(", "'crontab -l'", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "$", "output...
Helper to determine if cron job is setup @return int
[ "Helper", "to", "determine", "if", "cron", "job", "is", "setup" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L247-L261
207,976
getgrav/grav
system/src/Grav/Common/Scheduler/Scheduler.php
Scheduler.saveJobStates
private function saveJobStates() { $now = time(); $new_states = []; foreach ($this->jobs_run as $job) { if ($job->isSuccessful()) { $new_states[$job->getId()] = ['state' => 'success', 'last-run' => $now]; $this->pushExecutedJob($job); ...
php
private function saveJobStates() { $now = time(); $new_states = []; foreach ($this->jobs_run as $job) { if ($job->isSuccessful()) { $new_states[$job->getId()] = ['state' => 'success', 'last-run' => $now]; $this->pushExecutedJob($job); ...
[ "private", "function", "saveJobStates", "(", ")", "{", "$", "now", "=", "time", "(", ")", ";", "$", "new_states", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "jobs_run", "as", "$", "job", ")", "{", "if", "(", "$", "job", "->", "isSucce...
Save job states to statys file
[ "Save", "job", "states", "to", "statys", "file" ]
1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72
https://github.com/getgrav/grav/blob/1a41e00a4f0f5d17b6c0ce5150a5d656a8c5be72/system/src/Grav/Common/Scheduler/Scheduler.php#L276-L293
207,977
walkor/Workerman
Protocols/Http.php
Http.getRequestSize
protected static function getRequestSize($header, $method) { if($method === 'GET' || $method === 'OPTIONS' || $method === 'HEAD') { return strlen($header) + 4; } $match = array(); if (preg_match("/\r\nContent-Length: ?(\d+)/i", $header, $match)) { $content_len...
php
protected static function getRequestSize($header, $method) { if($method === 'GET' || $method === 'OPTIONS' || $method === 'HEAD') { return strlen($header) + 4; } $match = array(); if (preg_match("/\r\nContent-Length: ?(\d+)/i", $header, $match)) { $content_len...
[ "protected", "static", "function", "getRequestSize", "(", "$", "header", ",", "$", "method", ")", "{", "if", "(", "$", "method", "===", "'GET'", "||", "$", "method", "===", "'OPTIONS'", "||", "$", "method", "===", "'HEAD'", ")", "{", "return", "strlen", ...
Get whole size of the request includes the request headers and request body. @param string $header The request headers @param string $method The request method @return integer
[ "Get", "whole", "size", "of", "the", "request", "includes", "the", "request", "headers", "and", "request", "body", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L66-L77
207,978
walkor/Workerman
Protocols/Http.php
Http.encode
public static function encode($content, TcpConnection $connection) { // Default http-code. if (!isset(HttpCache::$header['Http-Code'])) { $header = "HTTP/1.1 200 OK\r\n"; } else { $header = HttpCache::$header['Http-Code'] . "\r\n"; unset(HttpCache::$header...
php
public static function encode($content, TcpConnection $connection) { // Default http-code. if (!isset(HttpCache::$header['Http-Code'])) { $header = "HTTP/1.1 200 OK\r\n"; } else { $header = HttpCache::$header['Http-Code'] . "\r\n"; unset(HttpCache::$header...
[ "public", "static", "function", "encode", "(", "$", "content", ",", "TcpConnection", "$", "connection", ")", "{", "// Default http-code.", "if", "(", "!", "isset", "(", "HttpCache", "::", "$", "header", "[", "'Http-Code'", "]", ")", ")", "{", "$", "header"...
Http encode. @param string $content @param TcpConnection $connection @return string
[ "Http", "encode", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L235-L272
207,979
walkor/Workerman
Protocols/Http.php
Http.tryGcSessions
public static function tryGcSessions() { if (HttpCache::$sessionGcProbability <= 0 || HttpCache::$sessionGcDivisor <= 0 || rand(1, HttpCache::$sessionGcDivisor) > HttpCache::$sessionGcProbability) { return; } $time_now = time(); foreach(glob(H...
php
public static function tryGcSessions() { if (HttpCache::$sessionGcProbability <= 0 || HttpCache::$sessionGcDivisor <= 0 || rand(1, HttpCache::$sessionGcDivisor) > HttpCache::$sessionGcProbability) { return; } $time_now = time(); foreach(glob(H...
[ "public", "static", "function", "tryGcSessions", "(", ")", "{", "if", "(", "HttpCache", "::", "$", "sessionGcProbability", "<=", "0", "||", "HttpCache", "::", "$", "sessionGcDivisor", "<=", "0", "||", "rand", "(", "1", ",", "HttpCache", "::", "$", "session...
Try GC sessions. @return void
[ "Try", "GC", "sessions", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Http.php#L591-L605
207,980
walkor/Workerman
WebServer.php
WebServer.addRoot
public function addRoot($domain, $config) { if (is_string($config)) { $config = array('root' => $config); } $this->serverRoot[$domain] = $config; }
php
public function addRoot($domain, $config) { if (is_string($config)) { $config = array('root' => $config); } $this->serverRoot[$domain] = $config; }
[ "public", "function", "addRoot", "(", "$", "domain", ",", "$", "config", ")", "{", "if", "(", "is_string", "(", "$", "config", ")", ")", "{", "$", "config", "=", "array", "(", "'root'", "=>", "$", "config", ")", ";", "}", "$", "this", "->", "serv...
Add virtual host. @param string $domain @param string $config @return void
[ "Add", "virtual", "host", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/WebServer.php#L53-L59
207,981
walkor/Workerman
WebServer.php
WebServer.run
public function run() { $this->_onWorkerStart = $this->onWorkerStart; $this->onWorkerStart = array($this, 'onWorkerStart'); $this->onMessage = array($this, 'onMessage'); parent::run(); }
php
public function run() { $this->_onWorkerStart = $this->onWorkerStart; $this->onWorkerStart = array($this, 'onWorkerStart'); $this->onMessage = array($this, 'onMessage'); parent::run(); }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "_onWorkerStart", "=", "$", "this", "->", "onWorkerStart", ";", "$", "this", "->", "onWorkerStart", "=", "array", "(", "$", "this", ",", "'onWorkerStart'", ")", ";", "$", "this", "->", "onM...
Run webserver instance. @see Workerman.Worker::run()
[ "Run", "webserver", "instance", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/WebServer.php#L79-L85
207,982
walkor/Workerman
WebServer.php
WebServer.onWorkerStart
public function onWorkerStart() { if (empty($this->serverRoot)) { Worker::safeEcho(new \Exception('server root not set, please use WebServer::addRoot($domain, $root_path) to set server root path')); exit(250); } // Init mimeMap. $this->initMimeTypeMap(); ...
php
public function onWorkerStart() { if (empty($this->serverRoot)) { Worker::safeEcho(new \Exception('server root not set, please use WebServer::addRoot($domain, $root_path) to set server root path')); exit(250); } // Init mimeMap. $this->initMimeTypeMap(); ...
[ "public", "function", "onWorkerStart", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "serverRoot", ")", ")", "{", "Worker", "::", "safeEcho", "(", "new", "\\", "Exception", "(", "'server root not set, please use WebServer::addRoot($domain, $root_path) t...
Emit when process start. @throws \Exception
[ "Emit", "when", "process", "start", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/WebServer.php#L92-L114
207,983
walkor/Workerman
WebServer.php
WebServer.initMimeTypeMap
public function initMimeTypeMap() { $mime_file = Http::getMimeTypesFile(); if (!is_file($mime_file)) { $this->log("$mime_file mime.type file not fond"); return; } $items = file($mime_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (!is_array($...
php
public function initMimeTypeMap() { $mime_file = Http::getMimeTypesFile(); if (!is_file($mime_file)) { $this->log("$mime_file mime.type file not fond"); return; } $items = file($mime_file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); if (!is_array($...
[ "public", "function", "initMimeTypeMap", "(", ")", "{", "$", "mime_file", "=", "Http", "::", "getMimeTypesFile", "(", ")", ";", "if", "(", "!", "is_file", "(", "$", "mime_file", ")", ")", "{", "$", "this", "->", "log", "(", "\"$mime_file mime.type file not...
Init mime map. @return void
[ "Init", "mime", "map", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/WebServer.php#L121-L143
207,984
walkor/Workerman
Connection/AsyncTcpConnection.php
AsyncTcpConnection.emitError
protected function emitError($code, $msg) { $this->_status = self::STATUS_CLOSING; if ($this->onError) { try { call_user_func($this->onError, $this, $code, $msg); } catch (\Exception $e) { Worker::log($e); exit(250); ...
php
protected function emitError($code, $msg) { $this->_status = self::STATUS_CLOSING; if ($this->onError) { try { call_user_func($this->onError, $this, $code, $msg); } catch (\Exception $e) { Worker::log($e); exit(250); ...
[ "protected", "function", "emitError", "(", "$", "code", ",", "$", "msg", ")", "{", "$", "this", "->", "_status", "=", "self", "::", "STATUS_CLOSING", ";", "if", "(", "$", "this", "->", "onError", ")", "{", "try", "{", "call_user_func", "(", "$", "thi...
Try to emit onError callback. @param int $code @param string $msg @return void
[ "Try", "to", "emit", "onError", "callback", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/AsyncTcpConnection.php#L267-L281
207,985
walkor/Workerman
Events/Select.php
Select.tick
protected function tick() { while (!$this->_scheduler->isEmpty()) { $scheduler_data = $this->_scheduler->top(); $timer_id = $scheduler_data['data']; $next_run_time = -$scheduler_data['priority']; $time_now = microtime(true)...
php
protected function tick() { while (!$this->_scheduler->isEmpty()) { $scheduler_data = $this->_scheduler->top(); $timer_id = $scheduler_data['data']; $next_run_time = -$scheduler_data['priority']; $time_now = microtime(true)...
[ "protected", "function", "tick", "(", ")", "{", "while", "(", "!", "$", "this", "->", "_scheduler", "->", "isEmpty", "(", ")", ")", "{", "$", "scheduler_data", "=", "$", "this", "->", "_scheduler", "->", "top", "(", ")", ";", "$", "timer_id", "=", ...
Tick for timer. @return void
[ "Tick", "for", "timer", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Events/Select.php#L218-L248
207,986
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.getRemoteIp
public function getRemoteIp() { $pos = strrpos($this->_remoteAddress, ':'); if ($pos) { return substr($this->_remoteAddress, 0, $pos); } return ''; }
php
public function getRemoteIp() { $pos = strrpos($this->_remoteAddress, ':'); if ($pos) { return substr($this->_remoteAddress, 0, $pos); } return ''; }
[ "public", "function", "getRemoteIp", "(", ")", "{", "$", "pos", "=", "strrpos", "(", "$", "this", "->", "_remoteAddress", ",", "':'", ")", ";", "if", "(", "$", "pos", ")", "{", "return", "substr", "(", "$", "this", "->", "_remoteAddress", ",", "0", ...
Get remote IP. @return string
[ "Get", "remote", "IP", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L425-L432
207,987
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.getLocalIp
public function getLocalIp() { $address = $this->getLocalAddress(); $pos = strrpos($address, ':'); if (!$pos) { return ''; } return substr($address, 0, $pos); }
php
public function getLocalIp() { $address = $this->getLocalAddress(); $pos = strrpos($address, ':'); if (!$pos) { return ''; } return substr($address, 0, $pos); }
[ "public", "function", "getLocalIp", "(", ")", "{", "$", "address", "=", "$", "this", "->", "getLocalAddress", "(", ")", ";", "$", "pos", "=", "strrpos", "(", "$", "address", ",", "':'", ")", ";", "if", "(", "!", "$", "pos", ")", "{", "return", "'...
Get local IP. @return string
[ "Get", "local", "IP", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L462-L470
207,988
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.getLocalPort
public function getLocalPort() { $address = $this->getLocalAddress(); $pos = strrpos($address, ':'); if (!$pos) { return 0; } return (int)substr(strrchr($address, ':'), 1); }
php
public function getLocalPort() { $address = $this->getLocalAddress(); $pos = strrpos($address, ':'); if (!$pos) { return 0; } return (int)substr(strrchr($address, ':'), 1); }
[ "public", "function", "getLocalPort", "(", ")", "{", "$", "address", "=", "$", "this", "->", "getLocalAddress", "(", ")", ";", "$", "pos", "=", "strrpos", "(", "$", "address", ",", "':'", ")", ";", "if", "(", "!", "$", "pos", ")", "{", "return", ...
Get local port. @return int
[ "Get", "local", "port", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L477-L485
207,989
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.pauseRecv
public function pauseRecv() { Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ); $this->_isPaused = true; }
php
public function pauseRecv() { Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ); $this->_isPaused = true; }
[ "public", "function", "pauseRecv", "(", ")", "{", "Worker", "::", "$", "globalEvent", "->", "del", "(", "$", "this", "->", "_socket", ",", "EventInterface", "::", "EV_READ", ")", ";", "$", "this", "->", "_isPaused", "=", "true", ";", "}" ]
Pauses the reading of data. That is onMessage will not be emitted. Useful to throttle back an upload. @return void
[ "Pauses", "the", "reading", "of", "data", ".", "That", "is", "onMessage", "will", "not", "be", "emitted", ".", "Useful", "to", "throttle", "back", "an", "upload", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L548-L552
207,990
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.resumeRecv
public function resumeRecv() { if ($this->_isPaused === true) { Worker::$globalEvent->add($this->_socket, EventInterface::EV_READ, array($this, 'baseRead')); $this->_isPaused = false; $this->baseRead($this->_socket, false); } }
php
public function resumeRecv() { if ($this->_isPaused === true) { Worker::$globalEvent->add($this->_socket, EventInterface::EV_READ, array($this, 'baseRead')); $this->_isPaused = false; $this->baseRead($this->_socket, false); } }
[ "public", "function", "resumeRecv", "(", ")", "{", "if", "(", "$", "this", "->", "_isPaused", "===", "true", ")", "{", "Worker", "::", "$", "globalEvent", "->", "add", "(", "$", "this", "->", "_socket", ",", "EventInterface", "::", "EV_READ", ",", "arr...
Resumes reading after a call to pauseRecv. @return void
[ "Resumes", "reading", "after", "a", "call", "to", "pauseRecv", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L559-L566
207,991
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.baseWrite
public function baseWrite() { set_error_handler(function(){}); if ($this->transport === 'ssl') { $len = fwrite($this->_socket, $this->_sendBuffer, 8192); } else { $len = fwrite($this->_socket, $this->_sendBuffer); } restore_error_handler(); if ...
php
public function baseWrite() { set_error_handler(function(){}); if ($this->transport === 'ssl') { $len = fwrite($this->_socket, $this->_sendBuffer, 8192); } else { $len = fwrite($this->_socket, $this->_sendBuffer); } restore_error_handler(); if ...
[ "public", "function", "baseWrite", "(", ")", "{", "set_error_handler", "(", "function", "(", ")", "{", "}", ")", ";", "if", "(", "$", "this", "->", "transport", "===", "'ssl'", ")", "{", "$", "len", "=", "fwrite", "(", "$", "this", "->", "_socket", ...
Base write handler. @return void|bool
[ "Base", "write", "handler", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L698-L735
207,992
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.doSslHandshake
public function doSslHandshake($socket){ if (feof($socket)) { $this->destroy(); return false; } $async = $this instanceof AsyncTcpConnection; /** * We disabled ssl3 because https://blog.qualys.com/ssllabs/2014/10/15/ssl-3-is-dead-killed-by-the-...
php
public function doSslHandshake($socket){ if (feof($socket)) { $this->destroy(); return false; } $async = $this instanceof AsyncTcpConnection; /** * We disabled ssl3 because https://blog.qualys.com/ssllabs/2014/10/15/ssl-3-is-dead-killed-by-the-...
[ "public", "function", "doSslHandshake", "(", "$", "socket", ")", "{", "if", "(", "feof", "(", "$", "socket", ")", ")", "{", "$", "this", "->", "destroy", "(", ")", ";", "return", "false", ";", "}", "$", "async", "=", "$", "this", "instanceof", "Asy...
SSL handshake. @param $socket @return bool
[ "SSL", "handshake", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L743-L794
207,993
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.pipe
public function pipe($dest) { $source = $this; $this->onMessage = function ($source, $data) use ($dest) { $dest->send($data); }; $this->onClose = function ($source) use ($dest) { $dest->destroy(); }; $dest->onBufferFull ...
php
public function pipe($dest) { $source = $this; $this->onMessage = function ($source, $data) use ($dest) { $dest->send($data); }; $this->onClose = function ($source) use ($dest) { $dest->destroy(); }; $dest->onBufferFull ...
[ "public", "function", "pipe", "(", "$", "dest", ")", "{", "$", "source", "=", "$", "this", ";", "$", "this", "->", "onMessage", "=", "function", "(", "$", "source", ",", "$", "data", ")", "use", "(", "$", "dest", ")", "{", "$", "dest", "->", "s...
This method pulls all the data out of a readable stream, and writes it to the supplied destination. @param TcpConnection $dest @return void
[ "This", "method", "pulls", "all", "the", "data", "out", "of", "a", "readable", "stream", "and", "writes", "it", "to", "the", "supplied", "destination", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L802-L817
207,994
walkor/Workerman
Connection/TcpConnection.php
TcpConnection.destroy
public function destroy() { // Avoid repeated calls. if ($this->_status === self::STATUS_CLOSED) { return; } // Remove event listener. Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ); Worker::$globalEvent->del($this->_socket, EventInterf...
php
public function destroy() { // Avoid repeated calls. if ($this->_status === self::STATUS_CLOSED) { return; } // Remove event listener. Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ); Worker::$globalEvent->del($this->_socket, EventInterf...
[ "public", "function", "destroy", "(", ")", "{", "// Avoid repeated calls.", "if", "(", "$", "this", "->", "_status", "===", "self", "::", "STATUS_CLOSED", ")", "{", "return", ";", "}", "// Remove event listener.", "Worker", "::", "$", "globalEvent", "->", "del...
Destroy connection. @return void
[ "Destroy", "connection", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Connection/TcpConnection.php#L926-L976
207,995
walkor/Workerman
Protocols/Websocket.php
Websocket.parseHttpHeader
protected static function parseHttpHeader($buffer) { // Parse headers. list($http_header, ) = explode("\r\n\r\n", $buffer, 2); $header_data = explode("\r\n", $http_header); if ($_SERVER) { $_SERVER = array(); } list($_SERVER['REQUEST_METHOD'], $_SERVER['...
php
protected static function parseHttpHeader($buffer) { // Parse headers. list($http_header, ) = explode("\r\n\r\n", $buffer, 2); $header_data = explode("\r\n", $http_header); if ($_SERVER) { $_SERVER = array(); } list($_SERVER['REQUEST_METHOD'], $_SERVER['...
[ "protected", "static", "function", "parseHttpHeader", "(", "$", "buffer", ")", "{", "// Parse headers.", "list", "(", "$", "http_header", ",", ")", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "buffer", ",", "2", ")", ";", "$", "header_data", "=", "e...
Parse http header. @param string $buffer @return void
[ "Parse", "http", "header", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Protocols/Websocket.php#L456-L503
207,996
walkor/Workerman
Worker.php
Worker.getSingleLineTotalLength
public static function getSingleLineTotalLength() { $total_length = 0; foreach(static::getUiColumns() as $column_name => $prop){ $key = '_max' . ucfirst(strtolower($column_name)) . 'NameLength'; $total_length += static::$$key + static::UI_SAFE_LENGTH; } //ke...
php
public static function getSingleLineTotalLength() { $total_length = 0; foreach(static::getUiColumns() as $column_name => $prop){ $key = '_max' . ucfirst(strtolower($column_name)) . 'NameLength'; $total_length += static::$$key + static::UI_SAFE_LENGTH; } //ke...
[ "public", "static", "function", "getSingleLineTotalLength", "(", ")", "{", "$", "total_length", "=", "0", ";", "foreach", "(", "static", "::", "getUiColumns", "(", ")", "as", "$", "column_name", "=>", "$", "prop", ")", "{", "$", "key", "=", "'_max'", "."...
Get single line total length for ui @return int
[ "Get", "single", "line", "total", "length", "for", "ui" ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L793-L807
207,997
walkor/Workerman
Worker.php
Worker.daemonize
protected static function daemonize() { if (!static::$daemonize || static::$_OS !== OS_TYPE_LINUX) { return; } umask(0); $pid = pcntl_fork(); if (-1 === $pid) { throw new Exception('fork fail'); } elseif ($pid > 0) { exit(0); ...
php
protected static function daemonize() { if (!static::$daemonize || static::$_OS !== OS_TYPE_LINUX) { return; } umask(0); $pid = pcntl_fork(); if (-1 === $pid) { throw new Exception('fork fail'); } elseif ($pid > 0) { exit(0); ...
[ "protected", "static", "function", "daemonize", "(", ")", "{", "if", "(", "!", "static", "::", "$", "daemonize", "||", "static", "::", "$", "_OS", "!==", "OS_TYPE_LINUX", ")", "{", "return", ";", "}", "umask", "(", "0", ")", ";", "$", "pid", "=", "...
Run as deamon mode. @throws Exception
[ "Run", "as", "deamon", "mode", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L1152-L1174
207,998
walkor/Workerman
Worker.php
Worker.resetStd
public static function resetStd() { if (!static::$daemonize || static::$_OS !== OS_TYPE_LINUX) { return; } global $STDOUT, $STDERR; $handle = fopen(static::$stdoutFile, "a"); if ($handle) { unset($handle); set_error_handler(function(){}); ...
php
public static function resetStd() { if (!static::$daemonize || static::$_OS !== OS_TYPE_LINUX) { return; } global $STDOUT, $STDERR; $handle = fopen(static::$stdoutFile, "a"); if ($handle) { unset($handle); set_error_handler(function(){}); ...
[ "public", "static", "function", "resetStd", "(", ")", "{", "if", "(", "!", "static", "::", "$", "daemonize", "||", "static", "::", "$", "_OS", "!==", "OS_TYPE_LINUX", ")", "{", "return", ";", "}", "global", "$", "STDOUT", ",", "$", "STDERR", ";", "$"...
Redirect standard input and output. @throws Exception
[ "Redirect", "standard", "input", "and", "output", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L1181-L1204
207,999
walkor/Workerman
Worker.php
Worker.getAllWorkerPids
protected static function getAllWorkerPids() { $pid_array = array(); foreach (static::$_pidMap as $worker_pid_array) { foreach ($worker_pid_array as $worker_pid) { $pid_array[$worker_pid] = $worker_pid; } } return $pid_array; }
php
protected static function getAllWorkerPids() { $pid_array = array(); foreach (static::$_pidMap as $worker_pid_array) { foreach ($worker_pid_array as $worker_pid) { $pid_array[$worker_pid] = $worker_pid; } } return $pid_array; }
[ "protected", "static", "function", "getAllWorkerPids", "(", ")", "{", "$", "pid_array", "=", "array", "(", ")", ";", "foreach", "(", "static", "::", "$", "_pidMap", "as", "$", "worker_pid_array", ")", "{", "foreach", "(", "$", "worker_pid_array", "as", "$"...
Get all pids of worker processes. @return array
[ "Get", "all", "pids", "of", "worker", "processes", "." ]
13649907f05014fcfffcfccaef01e63ad3339351
https://github.com/walkor/Workerman/blob/13649907f05014fcfffcfccaef01e63ad3339351/Worker.php#L1273-L1282