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
228,000
crossjoin/PreMailer
src/Crossjoin/PreMailer/PreMailerAbstract.php
PreMailerAbstract.prepareText
protected function prepareText(\DOMDocument $doc) { $text = $this->convertHtmlToText($doc->childNodes); $charset = $this->getCharset(); $textLineMaxLength = $this->getOption(self::OPTION_TEXT_LINE_WIDTH); $text = preg_replace_callback('/^([^\n]+)$/m', function($match) use ($charset, $textLineMaxLength) { $break = "\n"; $parts = preg_split('/((?:\(\t[^\t]+\t\))|[^\p{L}\p{N}])/', $match[0], -1, PREG_SPLIT_DELIM_CAPTURE); $return = ""; $brLength = mb_strlen(trim($break, "\r\n"), $charset); $lineLength = $brLength; foreach ($parts as $part) { // Replace character before/after links with a zero width space, // and mark links as non-breakable $breakLongLines = true; if (strpos($part, "\t")) { $part = str_replace("\t", mb_convert_encoding("\xE2\x80\x8C", $charset, "UTF-8"), $part); $breakLongLines = false; } // Get part length $partLength = mb_strlen($part, $charset); // Ignore trailing space characters if this would cause the line break if (($lineLength + $partLength) === ($textLineMaxLength + 1)) { $lastChar = mb_substr($part, -1, 1, $charset); if ($lastChar === " ") { $part = mb_substr($part, 0, -1, $charset); $partLength--; } } // Check if enough chars left to add the part if (($lineLength + $partLength) <= $textLineMaxLength) { $return .= $part; $lineLength += $partLength; // Check if the part is longer than the line (so that we need to break it) } elseif ($partLength > ($textLineMaxLength - $brLength)) { if ($breakLongLines === true) { $addPart = mb_substr($part, 0, ($textLineMaxLength - $lineLength), $charset); $return .= $addPart; $lineLength = $brLength; for ($i = mb_strlen($addPart, $charset), $j = $partLength; $i < $j; $i+=($textLineMaxLength - $brLength)) { $addPart = $break . mb_substr($part, $i, ($textLineMaxLength - $brLength), $charset); $return .= $addPart; $lineLength = mb_strlen($addPart, $charset) - 1; } } else { $return .= $break . trim($part) . $break; $lineLength = $brLength; } // Add a break to add the part in the next line } else { $return .= $break . rtrim($part); $lineLength = $brLength + $partLength; } } return $return; }, $text); $text = preg_replace('/^\s+|\s+$/', '', $text); return $text; }
php
protected function prepareText(\DOMDocument $doc) { $text = $this->convertHtmlToText($doc->childNodes); $charset = $this->getCharset(); $textLineMaxLength = $this->getOption(self::OPTION_TEXT_LINE_WIDTH); $text = preg_replace_callback('/^([^\n]+)$/m', function($match) use ($charset, $textLineMaxLength) { $break = "\n"; $parts = preg_split('/((?:\(\t[^\t]+\t\))|[^\p{L}\p{N}])/', $match[0], -1, PREG_SPLIT_DELIM_CAPTURE); $return = ""; $brLength = mb_strlen(trim($break, "\r\n"), $charset); $lineLength = $brLength; foreach ($parts as $part) { // Replace character before/after links with a zero width space, // and mark links as non-breakable $breakLongLines = true; if (strpos($part, "\t")) { $part = str_replace("\t", mb_convert_encoding("\xE2\x80\x8C", $charset, "UTF-8"), $part); $breakLongLines = false; } // Get part length $partLength = mb_strlen($part, $charset); // Ignore trailing space characters if this would cause the line break if (($lineLength + $partLength) === ($textLineMaxLength + 1)) { $lastChar = mb_substr($part, -1, 1, $charset); if ($lastChar === " ") { $part = mb_substr($part, 0, -1, $charset); $partLength--; } } // Check if enough chars left to add the part if (($lineLength + $partLength) <= $textLineMaxLength) { $return .= $part; $lineLength += $partLength; // Check if the part is longer than the line (so that we need to break it) } elseif ($partLength > ($textLineMaxLength - $brLength)) { if ($breakLongLines === true) { $addPart = mb_substr($part, 0, ($textLineMaxLength - $lineLength), $charset); $return .= $addPart; $lineLength = $brLength; for ($i = mb_strlen($addPart, $charset), $j = $partLength; $i < $j; $i+=($textLineMaxLength - $brLength)) { $addPart = $break . mb_substr($part, $i, ($textLineMaxLength - $brLength), $charset); $return .= $addPart; $lineLength = mb_strlen($addPart, $charset) - 1; } } else { $return .= $break . trim($part) . $break; $lineLength = $brLength; } // Add a break to add the part in the next line } else { $return .= $break . rtrim($part); $lineLength = $brLength + $partLength; } } return $return; }, $text); $text = preg_replace('/^\s+|\s+$/', '', $text); return $text; }
[ "protected", "function", "prepareText", "(", "\\", "DOMDocument", "$", "doc", ")", "{", "$", "text", "=", "$", "this", "->", "convertHtmlToText", "(", "$", "doc", "->", "childNodes", ")", ";", "$", "charset", "=", "$", "this", "->", "getCharset", "(", ")", ";", "$", "textLineMaxLength", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_TEXT_LINE_WIDTH", ")", ";", "$", "text", "=", "preg_replace_callback", "(", "'/^([^\\n]+)$/m'", ",", "function", "(", "$", "match", ")", "use", "(", "$", "charset", ",", "$", "textLineMaxLength", ")", "{", "$", "break", "=", "\"\\n\"", ";", "$", "parts", "=", "preg_split", "(", "'/((?:\\(\\t[^\\t]+\\t\\))|[^\\p{L}\\p{N}])/'", ",", "$", "match", "[", "0", "]", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", ")", ";", "$", "return", "=", "\"\"", ";", "$", "brLength", "=", "mb_strlen", "(", "trim", "(", "$", "break", ",", "\"\\r\\n\"", ")", ",", "$", "charset", ")", ";", "$", "lineLength", "=", "$", "brLength", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "// Replace character before/after links with a zero width space,", "// and mark links as non-breakable", "$", "breakLongLines", "=", "true", ";", "if", "(", "strpos", "(", "$", "part", ",", "\"\\t\"", ")", ")", "{", "$", "part", "=", "str_replace", "(", "\"\\t\"", ",", "mb_convert_encoding", "(", "\"\\xE2\\x80\\x8C\"", ",", "$", "charset", ",", "\"UTF-8\"", ")", ",", "$", "part", ")", ";", "$", "breakLongLines", "=", "false", ";", "}", "// Get part length", "$", "partLength", "=", "mb_strlen", "(", "$", "part", ",", "$", "charset", ")", ";", "// Ignore trailing space characters if this would cause the line break", "if", "(", "(", "$", "lineLength", "+", "$", "partLength", ")", "===", "(", "$", "textLineMaxLength", "+", "1", ")", ")", "{", "$", "lastChar", "=", "mb_substr", "(", "$", "part", ",", "-", "1", ",", "1", ",", "$", "charset", ")", ";", "if", "(", "$", "lastChar", "===", "\" \"", ")", "{", "$", "part", "=", "mb_substr", "(", "$", "part", ",", "0", ",", "-", "1", ",", "$", "charset", ")", ";", "$", "partLength", "--", ";", "}", "}", "// Check if enough chars left to add the part", "if", "(", "(", "$", "lineLength", "+", "$", "partLength", ")", "<=", "$", "textLineMaxLength", ")", "{", "$", "return", ".=", "$", "part", ";", "$", "lineLength", "+=", "$", "partLength", ";", "// Check if the part is longer than the line (so that we need to break it)", "}", "elseif", "(", "$", "partLength", ">", "(", "$", "textLineMaxLength", "-", "$", "brLength", ")", ")", "{", "if", "(", "$", "breakLongLines", "===", "true", ")", "{", "$", "addPart", "=", "mb_substr", "(", "$", "part", ",", "0", ",", "(", "$", "textLineMaxLength", "-", "$", "lineLength", ")", ",", "$", "charset", ")", ";", "$", "return", ".=", "$", "addPart", ";", "$", "lineLength", "=", "$", "brLength", ";", "for", "(", "$", "i", "=", "mb_strlen", "(", "$", "addPart", ",", "$", "charset", ")", ",", "$", "j", "=", "$", "partLength", ";", "$", "i", "<", "$", "j", ";", "$", "i", "+=", "(", "$", "textLineMaxLength", "-", "$", "brLength", ")", ")", "{", "$", "addPart", "=", "$", "break", ".", "mb_substr", "(", "$", "part", ",", "$", "i", ",", "(", "$", "textLineMaxLength", "-", "$", "brLength", ")", ",", "$", "charset", ")", ";", "$", "return", ".=", "$", "addPart", ";", "$", "lineLength", "=", "mb_strlen", "(", "$", "addPart", ",", "$", "charset", ")", "-", "1", ";", "}", "}", "else", "{", "$", "return", ".=", "$", "break", ".", "trim", "(", "$", "part", ")", ".", "$", "break", ";", "$", "lineLength", "=", "$", "brLength", ";", "}", "// Add a break to add the part in the next line", "}", "else", "{", "$", "return", ".=", "$", "break", ".", "rtrim", "(", "$", "part", ")", ";", "$", "lineLength", "=", "$", "brLength", "+", "$", "partLength", ";", "}", "}", "return", "$", "return", ";", "}", ",", "$", "text", ")", ";", "$", "text", "=", "preg_replace", "(", "'/^\\s+|\\s+$/'", ",", "''", ",", "$", "text", ")", ";", "return", "$", "text", ";", "}" ]
Prepares the mail text content. @param \DOMDocument $doc @return string
[ "Prepares", "the", "mail", "text", "content", "." ]
e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561
https://github.com/crossjoin/PreMailer/blob/e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561/src/Crossjoin/PreMailer/PreMailerAbstract.php#L477-L544
228,001
crossjoin/PreMailer
src/Crossjoin/PreMailer/PreMailerAbstract.php
PreMailerAbstract.convertHtmlToText
protected function convertHtmlToText(\DOMNodeList $nodes) { $text = ""; /** @var \DOMElement $node */ foreach ($nodes as $node) { $lineBreaksBefore = 0; $lineBreaksAfter = 0; $lineCharBefore = ""; $lineCharAfter = ""; $prefix = ""; $suffix = ""; if (in_array($node->nodeName, ["h1", "h2", "h3", "h4", "h5", "h6", "h"])) { $lineCharAfter = "="; $lineBreaksAfter = 2; } elseif (in_array($node->nodeName, ["p", "td"])) { $lineBreaksAfter = 2; } elseif (in_array($node->nodeName, ["div"])) { $lineBreaksAfter = 1; } if ($node->nodeName === "h1") { $lineCharBefore = "*"; $lineCharAfter = "*"; } elseif ($node->nodeName === "h2") { $lineCharBefore = "="; } if ($node->nodeName === '#text') { $textContent = html_entity_decode($node->textContent, ENT_COMPAT | ENT_HTML401, $this->getCharset()); // Replace tabs (used to mark links below) and other control characters $textContent = preg_replace("/[\r\n\f\v\t]+/", "", $textContent); if ($textContent !== "") { $text .= $textContent; } } elseif ($node->nodeName === 'a') { $href = ""; if ($node->attributes !== null) { $hrefAttribute = $node->attributes->getNamedItem("href"); if ($hrefAttribute !== null) { $href = (string)$hrefAttribute->nodeValue; } } if ($href !== "") { $suffix = " (\t" . $href . "\t)"; } } elseif ($node->nodeName === 'b' || $node->nodeName === 'strong') { $prefix = "*"; $suffix = "*"; } elseif ($node->nodeName === 'hr') { $text .= str_repeat('-', 75) . "\n\n"; } if ($node->hasChildNodes()) { $text .= str_repeat("\n", $lineBreaksBefore); $addText = $this->convertHtmlToText($node->childNodes); $text .= $prefix; $text .= $lineCharBefore ? str_repeat($lineCharBefore, 75) . "\n" : ""; $text .= $addText; $text .= $lineCharAfter ? "\n" . str_repeat($lineCharAfter, 75) . "\n" : ""; $text .= $suffix; $text .= str_repeat("\n", $lineBreaksAfter); } } // Remove unnecessary white spaces at he beginning/end of lines $text = preg_replace("/(?:^[ \t\f]+([^ \t\f])|([^ \t\f])[ \t\f]+$)/m", "\\1\\2", $text); // Replace multiple line-breaks $text = preg_replace("/[\r\n]{2,}/", "\n\n", $text); return $text; }
php
protected function convertHtmlToText(\DOMNodeList $nodes) { $text = ""; /** @var \DOMElement $node */ foreach ($nodes as $node) { $lineBreaksBefore = 0; $lineBreaksAfter = 0; $lineCharBefore = ""; $lineCharAfter = ""; $prefix = ""; $suffix = ""; if (in_array($node->nodeName, ["h1", "h2", "h3", "h4", "h5", "h6", "h"])) { $lineCharAfter = "="; $lineBreaksAfter = 2; } elseif (in_array($node->nodeName, ["p", "td"])) { $lineBreaksAfter = 2; } elseif (in_array($node->nodeName, ["div"])) { $lineBreaksAfter = 1; } if ($node->nodeName === "h1") { $lineCharBefore = "*"; $lineCharAfter = "*"; } elseif ($node->nodeName === "h2") { $lineCharBefore = "="; } if ($node->nodeName === '#text') { $textContent = html_entity_decode($node->textContent, ENT_COMPAT | ENT_HTML401, $this->getCharset()); // Replace tabs (used to mark links below) and other control characters $textContent = preg_replace("/[\r\n\f\v\t]+/", "", $textContent); if ($textContent !== "") { $text .= $textContent; } } elseif ($node->nodeName === 'a') { $href = ""; if ($node->attributes !== null) { $hrefAttribute = $node->attributes->getNamedItem("href"); if ($hrefAttribute !== null) { $href = (string)$hrefAttribute->nodeValue; } } if ($href !== "") { $suffix = " (\t" . $href . "\t)"; } } elseif ($node->nodeName === 'b' || $node->nodeName === 'strong') { $prefix = "*"; $suffix = "*"; } elseif ($node->nodeName === 'hr') { $text .= str_repeat('-', 75) . "\n\n"; } if ($node->hasChildNodes()) { $text .= str_repeat("\n", $lineBreaksBefore); $addText = $this->convertHtmlToText($node->childNodes); $text .= $prefix; $text .= $lineCharBefore ? str_repeat($lineCharBefore, 75) . "\n" : ""; $text .= $addText; $text .= $lineCharAfter ? "\n" . str_repeat($lineCharAfter, 75) . "\n" : ""; $text .= $suffix; $text .= str_repeat("\n", $lineBreaksAfter); } } // Remove unnecessary white spaces at he beginning/end of lines $text = preg_replace("/(?:^[ \t\f]+([^ \t\f])|([^ \t\f])[ \t\f]+$)/m", "\\1\\2", $text); // Replace multiple line-breaks $text = preg_replace("/[\r\n]{2,}/", "\n\n", $text); return $text; }
[ "protected", "function", "convertHtmlToText", "(", "\\", "DOMNodeList", "$", "nodes", ")", "{", "$", "text", "=", "\"\"", ";", "/** @var \\DOMElement $node */", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "lineBreaksBefore", "=", "0", ";", "$", "lineBreaksAfter", "=", "0", ";", "$", "lineCharBefore", "=", "\"\"", ";", "$", "lineCharAfter", "=", "\"\"", ";", "$", "prefix", "=", "\"\"", ";", "$", "suffix", "=", "\"\"", ";", "if", "(", "in_array", "(", "$", "node", "->", "nodeName", ",", "[", "\"h1\"", ",", "\"h2\"", ",", "\"h3\"", ",", "\"h4\"", ",", "\"h5\"", ",", "\"h6\"", ",", "\"h\"", "]", ")", ")", "{", "$", "lineCharAfter", "=", "\"=\"", ";", "$", "lineBreaksAfter", "=", "2", ";", "}", "elseif", "(", "in_array", "(", "$", "node", "->", "nodeName", ",", "[", "\"p\"", ",", "\"td\"", "]", ")", ")", "{", "$", "lineBreaksAfter", "=", "2", ";", "}", "elseif", "(", "in_array", "(", "$", "node", "->", "nodeName", ",", "[", "\"div\"", "]", ")", ")", "{", "$", "lineBreaksAfter", "=", "1", ";", "}", "if", "(", "$", "node", "->", "nodeName", "===", "\"h1\"", ")", "{", "$", "lineCharBefore", "=", "\"*\"", ";", "$", "lineCharAfter", "=", "\"*\"", ";", "}", "elseif", "(", "$", "node", "->", "nodeName", "===", "\"h2\"", ")", "{", "$", "lineCharBefore", "=", "\"=\"", ";", "}", "if", "(", "$", "node", "->", "nodeName", "===", "'#text'", ")", "{", "$", "textContent", "=", "html_entity_decode", "(", "$", "node", "->", "textContent", ",", "ENT_COMPAT", "|", "ENT_HTML401", ",", "$", "this", "->", "getCharset", "(", ")", ")", ";", "// Replace tabs (used to mark links below) and other control characters", "$", "textContent", "=", "preg_replace", "(", "\"/[\\r\\n\\f\\v\\t]+/\"", ",", "\"\"", ",", "$", "textContent", ")", ";", "if", "(", "$", "textContent", "!==", "\"\"", ")", "{", "$", "text", ".=", "$", "textContent", ";", "}", "}", "elseif", "(", "$", "node", "->", "nodeName", "===", "'a'", ")", "{", "$", "href", "=", "\"\"", ";", "if", "(", "$", "node", "->", "attributes", "!==", "null", ")", "{", "$", "hrefAttribute", "=", "$", "node", "->", "attributes", "->", "getNamedItem", "(", "\"href\"", ")", ";", "if", "(", "$", "hrefAttribute", "!==", "null", ")", "{", "$", "href", "=", "(", "string", ")", "$", "hrefAttribute", "->", "nodeValue", ";", "}", "}", "if", "(", "$", "href", "!==", "\"\"", ")", "{", "$", "suffix", "=", "\" (\\t\"", ".", "$", "href", ".", "\"\\t)\"", ";", "}", "}", "elseif", "(", "$", "node", "->", "nodeName", "===", "'b'", "||", "$", "node", "->", "nodeName", "===", "'strong'", ")", "{", "$", "prefix", "=", "\"*\"", ";", "$", "suffix", "=", "\"*\"", ";", "}", "elseif", "(", "$", "node", "->", "nodeName", "===", "'hr'", ")", "{", "$", "text", ".=", "str_repeat", "(", "'-'", ",", "75", ")", ".", "\"\\n\\n\"", ";", "}", "if", "(", "$", "node", "->", "hasChildNodes", "(", ")", ")", "{", "$", "text", ".=", "str_repeat", "(", "\"\\n\"", ",", "$", "lineBreaksBefore", ")", ";", "$", "addText", "=", "$", "this", "->", "convertHtmlToText", "(", "$", "node", "->", "childNodes", ")", ";", "$", "text", ".=", "$", "prefix", ";", "$", "text", ".=", "$", "lineCharBefore", "?", "str_repeat", "(", "$", "lineCharBefore", ",", "75", ")", ".", "\"\\n\"", ":", "\"\"", ";", "$", "text", ".=", "$", "addText", ";", "$", "text", ".=", "$", "lineCharAfter", "?", "\"\\n\"", ".", "str_repeat", "(", "$", "lineCharAfter", ",", "75", ")", ".", "\"\\n\"", ":", "\"\"", ";", "$", "text", ".=", "$", "suffix", ";", "$", "text", ".=", "str_repeat", "(", "\"\\n\"", ",", "$", "lineBreaksAfter", ")", ";", "}", "}", "// Remove unnecessary white spaces at he beginning/end of lines", "$", "text", "=", "preg_replace", "(", "\"/(?:^[ \\t\\f]+([^ \\t\\f])|([^ \\t\\f])[ \\t\\f]+$)/m\"", ",", "\"\\\\1\\\\2\"", ",", "$", "text", ")", ";", "// Replace multiple line-breaks", "$", "text", "=", "preg_replace", "(", "\"/[\\r\\n]{2,}/\"", ",", "\"\\n\\n\"", ",", "$", "text", ")", ";", "return", "$", "text", ";", "}" ]
Converts HTML tags to text, to create a text version of an HTML document. @param \DOMNodeList $nodes @return string
[ "Converts", "HTML", "tags", "to", "text", "to", "create", "a", "text", "version", "of", "an", "HTML", "document", "." ]
e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561
https://github.com/crossjoin/PreMailer/blob/e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561/src/Crossjoin/PreMailer/PreMailerAbstract.php#L552-L632
228,002
brick/http
src/Request.php
Request.getCurrentRequestHeaders
private static function getCurrentRequestHeaders() : array { $headers = []; if (function_exists('apache_request_headers')) { $requestHeaders = apache_request_headers(); if ($requestHeaders) { foreach ($requestHeaders as $key => $value) { $key = strtolower($key); $headers[$key] = [$value]; } return $headers; } } foreach ($_SERVER as $key => $value) { if (substr($key, 0, 5) === 'HTTP_') { $key = substr($key, 5); } elseif ($key !== 'CONTENT_TYPE' && $key !== 'CONTENT_LENGTH') { continue; } $key = strtolower(str_replace('_', '-', $key)); $headers[$key] = [$value]; } return $headers; }
php
private static function getCurrentRequestHeaders() : array { $headers = []; if (function_exists('apache_request_headers')) { $requestHeaders = apache_request_headers(); if ($requestHeaders) { foreach ($requestHeaders as $key => $value) { $key = strtolower($key); $headers[$key] = [$value]; } return $headers; } } foreach ($_SERVER as $key => $value) { if (substr($key, 0, 5) === 'HTTP_') { $key = substr($key, 5); } elseif ($key !== 'CONTENT_TYPE' && $key !== 'CONTENT_LENGTH') { continue; } $key = strtolower(str_replace('_', '-', $key)); $headers[$key] = [$value]; } return $headers; }
[ "private", "static", "function", "getCurrentRequestHeaders", "(", ")", ":", "array", "{", "$", "headers", "=", "[", "]", ";", "if", "(", "function_exists", "(", "'apache_request_headers'", ")", ")", "{", "$", "requestHeaders", "=", "apache_request_headers", "(", ")", ";", "if", "(", "$", "requestHeaders", ")", "{", "foreach", "(", "$", "requestHeaders", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "strtolower", "(", "$", "key", ")", ";", "$", "headers", "[", "$", "key", "]", "=", "[", "$", "value", "]", ";", "}", "return", "$", "headers", ";", "}", "}", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "substr", "(", "$", "key", ",", "0", ",", "5", ")", "===", "'HTTP_'", ")", "{", "$", "key", "=", "substr", "(", "$", "key", ",", "5", ")", ";", "}", "elseif", "(", "$", "key", "!==", "'CONTENT_TYPE'", "&&", "$", "key", "!==", "'CONTENT_LENGTH'", ")", "{", "continue", ";", "}", "$", "key", "=", "strtolower", "(", "str_replace", "(", "'_'", ",", "'-'", ",", "$", "key", ")", ")", ";", "$", "headers", "[", "$", "key", "]", "=", "[", "$", "value", "]", ";", "}", "return", "$", "headers", ";", "}" ]
Returns the current request headers. The headers are prepared in the format expected by `Message::$headers`: - keys are lowercased - values are arrays of strings @return array
[ "Returns", "the", "current", "request", "headers", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L260-L289
228,003
brick/http
src/Request.php
Request.setQuery
public function setQuery(array $query) : Request { $this->queryString = http_build_query($query); // Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values // have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request. parse_str($this->queryString, $this->query); $this->requestUri = $this->path; if ($this->queryString !== '') { $this->requestUri .= '?' . $this->queryString; } return $this; }
php
public function setQuery(array $query) : Request { $this->queryString = http_build_query($query); // Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values // have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request. parse_str($this->queryString, $this->query); $this->requestUri = $this->path; if ($this->queryString !== '') { $this->requestUri .= '?' . $this->queryString; } return $this; }
[ "public", "function", "setQuery", "(", "array", "$", "query", ")", ":", "Request", "{", "$", "this", "->", "queryString", "=", "http_build_query", "(", "$", "query", ")", ";", "// Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values", "// have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request.", "parse_str", "(", "$", "this", "->", "queryString", ",", "$", "this", "->", "query", ")", ";", "$", "this", "->", "requestUri", "=", "$", "this", "->", "path", ";", "if", "(", "$", "this", "->", "queryString", "!==", "''", ")", "{", "$", "this", "->", "requestUri", ".=", "'?'", ".", "$", "this", "->", "queryString", ";", "}", "return", "$", "this", ";", "}" ]
Sets the query parameters. @param array $query The associative array of parameters. @return static This request.
[ "Sets", "the", "query", "parameters", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L322-L337
228,004
brick/http
src/Request.php
Request.setPost
public function setPost(array $post) : Request { // Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values // have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request. parse_str(http_build_query($post), $this->post); if (! $this->isContentType('multipart/form-data')) { $body = http_build_query($post); $body = new MessageBodyString($body); $this->setBody($body); $this->setHeader('Content-Type', 'x-www-form-urlencoded'); } return $this; }
php
public function setPost(array $post) : Request { // Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values // have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request. parse_str(http_build_query($post), $this->post); if (! $this->isContentType('multipart/form-data')) { $body = http_build_query($post); $body = new MessageBodyString($body); $this->setBody($body); $this->setHeader('Content-Type', 'x-www-form-urlencoded'); } return $this; }
[ "public", "function", "setPost", "(", "array", "$", "post", ")", ":", "Request", "{", "// Ensure that we get a value for getQuery() that's consistent with the query string, and whose scalar values", "// have all been converted to strings, to get a result similar to what we'd get with an incoming HTTP request.", "parse_str", "(", "http_build_query", "(", "$", "post", ")", ",", "$", "this", "->", "post", ")", ";", "if", "(", "!", "$", "this", "->", "isContentType", "(", "'multipart/form-data'", ")", ")", "{", "$", "body", "=", "http_build_query", "(", "$", "post", ")", ";", "$", "body", "=", "new", "MessageBodyString", "(", "$", "body", ")", ";", "$", "this", "->", "setBody", "(", "$", "body", ")", ";", "$", "this", "->", "setHeader", "(", "'Content-Type'", ",", "'x-www-form-urlencoded'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the post parameter. This will set a request body with the URL-encoded data, unless the Content-Type of this request is multipart/form-data, in which case the body is left as is. @param array $post The associative array of parameters. @return static This request.
[ "Sets", "the", "post", "parameter", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L366-L381
228,005
brick/http
src/Request.php
Request.getFile
public function getFile(string $name) : ?UploadedFile { $file = $this->resolvePath($this->files, $name); if ($file instanceof UploadedFile) { return $file; } return null; }
php
public function getFile(string $name) : ?UploadedFile { $file = $this->resolvePath($this->files, $name); if ($file instanceof UploadedFile) { return $file; } return null; }
[ "public", "function", "getFile", "(", "string", "$", "name", ")", ":", "?", "UploadedFile", "{", "$", "file", "=", "$", "this", "->", "resolvePath", "(", "$", "this", "->", "files", ",", "$", "name", ")", ";", "if", "(", "$", "file", "instanceof", "UploadedFile", ")", "{", "return", "$", "file", ";", "}", "return", "null", ";", "}" ]
Returns the uploaded file by the given name. If no uploaded file exists by that name, or if the name maps to an array of uploaded files, this method returns NULL. @param string $name The name of the file input field. @return \Brick\Http\UploadedFile|null The uploaded file, or NULL if not found.
[ "Returns", "the", "uploaded", "file", "by", "the", "given", "name", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L394-L403
228,006
brick/http
src/Request.php
Request.getFiles
public function getFiles(string $name = null) : array { if ($name === null) { return $this->files; } $files = $this->resolvePath($this->files, $name); if ($files instanceof UploadedFile) { return [$files]; } if (is_array($files)) { return array_filter($files, static function ($file) { return $file instanceof UploadedFile; }); } return []; }
php
public function getFiles(string $name = null) : array { if ($name === null) { return $this->files; } $files = $this->resolvePath($this->files, $name); if ($files instanceof UploadedFile) { return [$files]; } if (is_array($files)) { return array_filter($files, static function ($file) { return $file instanceof UploadedFile; }); } return []; }
[ "public", "function", "getFiles", "(", "string", "$", "name", "=", "null", ")", ":", "array", "{", "if", "(", "$", "name", "===", "null", ")", "{", "return", "$", "this", "->", "files", ";", "}", "$", "files", "=", "$", "this", "->", "resolvePath", "(", "$", "this", "->", "files", ",", "$", "name", ")", ";", "if", "(", "$", "files", "instanceof", "UploadedFile", ")", "{", "return", "[", "$", "files", "]", ";", "}", "if", "(", "is_array", "(", "$", "files", ")", ")", "{", "return", "array_filter", "(", "$", "files", ",", "static", "function", "(", "$", "file", ")", "{", "return", "$", "file", "instanceof", "UploadedFile", ";", "}", ")", ";", "}", "return", "[", "]", ";", "}" ]
Returns the uploaded files under the given name. If no uploaded files by that name exist, an empty array is returned. @param string $name The name of the file input fields. @return \Brick\Http\UploadedFile[] The uploaded files.
[ "Returns", "the", "uploaded", "files", "under", "the", "given", "name", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L414-L433
228,007
brick/http
src/Request.php
Request.setCookies
public function setCookies(array $cookies) : Request { $query = http_build_query($cookies); parse_str($query, $this->cookies); if ($cookies) { $cookie = str_replace('&', '; ', $query); $this->setHeader('Cookie', $cookie); } else { $this->removeHeader('Cookie'); } return $this; }
php
public function setCookies(array $cookies) : Request { $query = http_build_query($cookies); parse_str($query, $this->cookies); if ($cookies) { $cookie = str_replace('&', '; ', $query); $this->setHeader('Cookie', $cookie); } else { $this->removeHeader('Cookie'); } return $this; }
[ "public", "function", "setCookies", "(", "array", "$", "cookies", ")", ":", "Request", "{", "$", "query", "=", "http_build_query", "(", "$", "cookies", ")", ";", "parse_str", "(", "$", "query", ",", "$", "this", "->", "cookies", ")", ";", "if", "(", "$", "cookies", ")", "{", "$", "cookie", "=", "str_replace", "(", "'&'", ",", "'; '", ",", "$", "query", ")", ";", "$", "this", "->", "setHeader", "(", "'Cookie'", ",", "$", "cookie", ")", ";", "}", "else", "{", "$", "this", "->", "removeHeader", "(", "'Cookie'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the cookies for this request. All existing cookies will be replaced. @param array $cookies An associative array of cookies. @return static This request.
[ "Sets", "the", "cookies", "for", "this", "request", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L521-L534
228,008
brick/http
src/Request.php
Request.setMethod
public function setMethod(string $method) : Request { $this->method = $this->fixMethodCase($method); return $this; }
php
public function setMethod(string $method) : Request { $this->method = $this->fixMethodCase($method); return $this; }
[ "public", "function", "setMethod", "(", "string", "$", "method", ")", ":", "Request", "{", "$", "this", "->", "method", "=", "$", "this", "->", "fixMethodCase", "(", "$", "method", ")", ";", "return", "$", "this", ";", "}" ]
Sets the request method. If the method case-insensitively matches a standard method, it will be converted to uppercase. @param string $method The new request method. @return static This request.
[ "Sets", "the", "request", "method", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L585-L590
228,009
brick/http
src/Request.php
Request.fixMethodCase
private function fixMethodCase(string $method) : string { $upperMethod = strtoupper($method); $isStandard = in_array($upperMethod, self::$standardMethods, true); return $isStandard ? $upperMethod : $method; }
php
private function fixMethodCase(string $method) : string { $upperMethod = strtoupper($method); $isStandard = in_array($upperMethod, self::$standardMethods, true); return $isStandard ? $upperMethod : $method; }
[ "private", "function", "fixMethodCase", "(", "string", "$", "method", ")", ":", "string", "{", "$", "upperMethod", "=", "strtoupper", "(", "$", "method", ")", ";", "$", "isStandard", "=", "in_array", "(", "$", "upperMethod", ",", "self", "::", "$", "standardMethods", ",", "true", ")", ";", "return", "$", "isStandard", "?", "$", "upperMethod", ":", "$", "method", ";", "}" ]
Fixes a method case. @see \Brick\Http\Request::$standardMethods @param string $method @return string
[ "Fixes", "a", "method", "case", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L628-L634
228,010
brick/http
src/Request.php
Request.setScheme
public function setScheme(string $scheme) : Request { $scheme = strtolower($scheme); if ($scheme === 'http') { $this->isSecure = false; } elseif ($scheme === 'https') { $this->isSecure = true; } else { throw new \InvalidArgumentException('The scheme must be http or https.'); } return $this; }
php
public function setScheme(string $scheme) : Request { $scheme = strtolower($scheme); if ($scheme === 'http') { $this->isSecure = false; } elseif ($scheme === 'https') { $this->isSecure = true; } else { throw new \InvalidArgumentException('The scheme must be http or https.'); } return $this; }
[ "public", "function", "setScheme", "(", "string", "$", "scheme", ")", ":", "Request", "{", "$", "scheme", "=", "strtolower", "(", "$", "scheme", ")", ";", "if", "(", "$", "scheme", "===", "'http'", ")", "{", "$", "this", "->", "isSecure", "=", "false", ";", "}", "elseif", "(", "$", "scheme", "===", "'https'", ")", "{", "$", "this", "->", "isSecure", "=", "true", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The scheme must be http or https.'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the request scheme. @param string $scheme The new request scheme. @return static This request. @throws \InvalidArgumentException If the scheme is not http or https.
[ "Sets", "the", "request", "scheme", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L655-L668
228,011
brick/http
src/Request.php
Request.isHost
public function isHost(string $host, bool $includeSubDomains = false) : bool { $thisHost = strtolower($this->host); $thatHost = strtolower($host); if (! $includeSubDomains) { return $thisHost === $thatHost; } $thisHost = explode('.', $thisHost); $thatHost = explode('.', $thatHost); return array_slice($thisHost, - count($thatHost)) === $thatHost; }
php
public function isHost(string $host, bool $includeSubDomains = false) : bool { $thisHost = strtolower($this->host); $thatHost = strtolower($host); if (! $includeSubDomains) { return $thisHost === $thatHost; } $thisHost = explode('.', $thisHost); $thatHost = explode('.', $thatHost); return array_slice($thisHost, - count($thatHost)) === $thatHost; }
[ "public", "function", "isHost", "(", "string", "$", "host", ",", "bool", "$", "includeSubDomains", "=", "false", ")", ":", "bool", "{", "$", "thisHost", "=", "strtolower", "(", "$", "this", "->", "host", ")", ";", "$", "thatHost", "=", "strtolower", "(", "$", "host", ")", ";", "if", "(", "!", "$", "includeSubDomains", ")", "{", "return", "$", "thisHost", "===", "$", "thatHost", ";", "}", "$", "thisHost", "=", "explode", "(", "'.'", ",", "$", "thisHost", ")", ";", "$", "thatHost", "=", "explode", "(", "'.'", ",", "$", "thatHost", ")", ";", "return", "array_slice", "(", "$", "thisHost", ",", "-", "count", "(", "$", "thatHost", ")", ")", "===", "$", "thatHost", ";", "}" ]
Returns whether the host is on the given domain, or optionally on a sub-domain of it. @todo should be used against getUrl(), which should return a Url object. @param string $host @param bool $includeSubDomains @return bool
[ "Returns", "whether", "the", "host", "is", "on", "the", "given", "domain", "or", "optionally", "on", "a", "sub", "-", "domain", "of", "it", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L702-L715
228,012
brick/http
src/Request.php
Request.updateHostHeader
private function updateHostHeader() : Request { $host = $this->host; $standardPort = $this->isSecure ? 443 : 80; if ($this->port !== $standardPort) { $host .= ':' . $this->port; } return $this->setHeader('Host', $host); }
php
private function updateHostHeader() : Request { $host = $this->host; $standardPort = $this->isSecure ? 443 : 80; if ($this->port !== $standardPort) { $host .= ':' . $this->port; } return $this->setHeader('Host', $host); }
[ "private", "function", "updateHostHeader", "(", ")", ":", "Request", "{", "$", "host", "=", "$", "this", "->", "host", ";", "$", "standardPort", "=", "$", "this", "->", "isSecure", "?", "443", ":", "80", ";", "if", "(", "$", "this", "->", "port", "!==", "$", "standardPort", ")", "{", "$", "host", ".=", "':'", ".", "$", "this", "->", "port", ";", "}", "return", "$", "this", "->", "setHeader", "(", "'Host'", ",", "$", "host", ")", ";", "}" ]
Updates the Host header from the values of host and port. @return static This request.
[ "Updates", "the", "Host", "header", "from", "the", "values", "of", "host", "and", "port", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L764-L774
228,013
brick/http
src/Request.php
Request.setPath
public function setPath(string $path) : Request { if (strpos($path, '?') !== false) { throw new \InvalidArgumentException('The request path must not contain a query string.'); } $this->path = $path; return $this->updateRequestUri(); }
php
public function setPath(string $path) : Request { if (strpos($path, '?') !== false) { throw new \InvalidArgumentException('The request path must not contain a query string.'); } $this->path = $path; return $this->updateRequestUri(); }
[ "public", "function", "setPath", "(", "string", "$", "path", ")", ":", "Request", "{", "if", "(", "strpos", "(", "$", "path", ",", "'?'", ")", "!==", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The request path must not contain a query string.'", ")", ";", "}", "$", "this", "->", "path", "=", "$", "path", ";", "return", "$", "this", "->", "updateRequestUri", "(", ")", ";", "}" ]
Sets the request path. Example: `/user/profile` @param string $path The new request path. @return static This request. @throws \InvalidArgumentException If the path is not valid.
[ "Sets", "the", "request", "path", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L813-L822
228,014
brick/http
src/Request.php
Request.updateRequestUri
private function updateRequestUri() : Request { $this->requestUri = $this->path; if ($this->queryString !== '') { $this->requestUri .= '?' . $this->queryString; } return $this; }
php
private function updateRequestUri() : Request { $this->requestUri = $this->path; if ($this->queryString !== '') { $this->requestUri .= '?' . $this->queryString; } return $this; }
[ "private", "function", "updateRequestUri", "(", ")", ":", "Request", "{", "$", "this", "->", "requestUri", "=", "$", "this", "->", "path", ";", "if", "(", "$", "this", "->", "queryString", "!==", "''", ")", "{", "$", "this", "->", "requestUri", ".=", "'?'", ".", "$", "this", "->", "queryString", ";", "}", "return", "$", "this", ";", "}" ]
Updates the request URI from the values of path and query string. @return static This request.
[ "Updates", "the", "request", "URI", "from", "the", "values", "of", "path", "and", "query", "string", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L858-L867
228,015
brick/http
src/Request.php
Request.setRequestUri
public function setRequestUri(string $requestUri) : Request { $pos = strpos($requestUri, '?'); if ($pos === false) { $this->path = $requestUri; $this->queryString = ''; $this->query = []; } else { $this->path = substr($requestUri, 0, $pos); $this->queryString = substr($requestUri, $pos + 1); if ($this->queryString === '') { $this->query = []; } else { parse_str($this->queryString, $this->query); } } $this->requestUri = $requestUri; return $this; }
php
public function setRequestUri(string $requestUri) : Request { $pos = strpos($requestUri, '?'); if ($pos === false) { $this->path = $requestUri; $this->queryString = ''; $this->query = []; } else { $this->path = substr($requestUri, 0, $pos); $this->queryString = substr($requestUri, $pos + 1); if ($this->queryString === '') { $this->query = []; } else { parse_str($this->queryString, $this->query); } } $this->requestUri = $requestUri; return $this; }
[ "public", "function", "setRequestUri", "(", "string", "$", "requestUri", ")", ":", "Request", "{", "$", "pos", "=", "strpos", "(", "$", "requestUri", ",", "'?'", ")", ";", "if", "(", "$", "pos", "===", "false", ")", "{", "$", "this", "->", "path", "=", "$", "requestUri", ";", "$", "this", "->", "queryString", "=", "''", ";", "$", "this", "->", "query", "=", "[", "]", ";", "}", "else", "{", "$", "this", "->", "path", "=", "substr", "(", "$", "requestUri", ",", "0", ",", "$", "pos", ")", ";", "$", "this", "->", "queryString", "=", "substr", "(", "$", "requestUri", ",", "$", "pos", "+", "1", ")", ";", "if", "(", "$", "this", "->", "queryString", "===", "''", ")", "{", "$", "this", "->", "query", "=", "[", "]", ";", "}", "else", "{", "parse_str", "(", "$", "this", "->", "queryString", ",", "$", "this", "->", "query", ")", ";", "}", "}", "$", "this", "->", "requestUri", "=", "$", "requestUri", ";", "return", "$", "this", ";", "}" ]
Sets the request URI. This will update the request path, query string, and query parameters. @param string $requestUri @return static
[ "Sets", "the", "request", "URI", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L888-L910
228,016
brick/http
src/Request.php
Request.getUrlBase
public function getUrlBase() : string { $url = sprintf('%s://%s', $this->getScheme(), $this->host); $isStandardPort = ($this->port === ($this->isSecure ? 443 : 80)); return $isStandardPort ? $url : $url . ':' . $this->port; }
php
public function getUrlBase() : string { $url = sprintf('%s://%s', $this->getScheme(), $this->host); $isStandardPort = ($this->port === ($this->isSecure ? 443 : 80)); return $isStandardPort ? $url : $url . ':' . $this->port; }
[ "public", "function", "getUrlBase", "(", ")", ":", "string", "{", "$", "url", "=", "sprintf", "(", "'%s://%s'", ",", "$", "this", "->", "getScheme", "(", ")", ",", "$", "this", "->", "host", ")", ";", "$", "isStandardPort", "=", "(", "$", "this", "->", "port", "===", "(", "$", "this", "->", "isSecure", "?", "443", ":", "80", ")", ")", ";", "return", "$", "isStandardPort", "?", "$", "url", ":", "$", "url", ".", "':'", ".", "$", "this", "->", "port", ";", "}" ]
Returns the scheme and host name of this request. @return string The base URL.
[ "Returns", "the", "scheme", "and", "host", "name", "of", "this", "request", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L927-L933
228,017
brick/http
src/Request.php
Request.setUrl
public function setUrl(string $url) : Request { $components = parse_url($url); if ($components === false) { throw new \InvalidArgumentException('The URL provided is not valid.'); } if (! isset($components['scheme'])) { throw new \InvalidArgumentException('The URL must have a scheme.'); } $scheme = strtolower($components['scheme']); if ($scheme !== 'http' && $scheme !== 'https') { throw new \InvalidArgumentException(sprintf('The URL scheme "%s" is not acceptable.', $scheme)); } $isSecure = ($scheme === 'https'); if (! isset($components['host'])) { throw new \InvalidArgumentException('The URL must have a host name.'); } $host = $components['host']; if (isset($components['port'])) { $port = $components['port']; $hostHeader = $host . ':' . $port; } else { $port = ($isSecure ? 443 : 80); $hostHeader = $host; } $this->path = isset($components['path']) ? $components['path'] : '/'; $requestUri = $this->path; if (isset($components['query'])) { $this->queryString = $components['query']; parse_str($this->queryString, $this->query); $requestUri .= '?' . $this->queryString; } else { $this->queryString = ''; $this->query = []; } $this->setHeader('Host', $hostHeader); $this->host = $host; $this->port = $port; $this->isSecure = $isSecure; $this->requestUri = $requestUri; return $this; }
php
public function setUrl(string $url) : Request { $components = parse_url($url); if ($components === false) { throw new \InvalidArgumentException('The URL provided is not valid.'); } if (! isset($components['scheme'])) { throw new \InvalidArgumentException('The URL must have a scheme.'); } $scheme = strtolower($components['scheme']); if ($scheme !== 'http' && $scheme !== 'https') { throw new \InvalidArgumentException(sprintf('The URL scheme "%s" is not acceptable.', $scheme)); } $isSecure = ($scheme === 'https'); if (! isset($components['host'])) { throw new \InvalidArgumentException('The URL must have a host name.'); } $host = $components['host']; if (isset($components['port'])) { $port = $components['port']; $hostHeader = $host . ':' . $port; } else { $port = ($isSecure ? 443 : 80); $hostHeader = $host; } $this->path = isset($components['path']) ? $components['path'] : '/'; $requestUri = $this->path; if (isset($components['query'])) { $this->queryString = $components['query']; parse_str($this->queryString, $this->query); $requestUri .= '?' . $this->queryString; } else { $this->queryString = ''; $this->query = []; } $this->setHeader('Host', $hostHeader); $this->host = $host; $this->port = $port; $this->isSecure = $isSecure; $this->requestUri = $requestUri; return $this; }
[ "public", "function", "setUrl", "(", "string", "$", "url", ")", ":", "Request", "{", "$", "components", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "$", "components", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The URL provided is not valid.'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "components", "[", "'scheme'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The URL must have a scheme.'", ")", ";", "}", "$", "scheme", "=", "strtolower", "(", "$", "components", "[", "'scheme'", "]", ")", ";", "if", "(", "$", "scheme", "!==", "'http'", "&&", "$", "scheme", "!==", "'https'", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The URL scheme \"%s\" is not acceptable.'", ",", "$", "scheme", ")", ")", ";", "}", "$", "isSecure", "=", "(", "$", "scheme", "===", "'https'", ")", ";", "if", "(", "!", "isset", "(", "$", "components", "[", "'host'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The URL must have a host name.'", ")", ";", "}", "$", "host", "=", "$", "components", "[", "'host'", "]", ";", "if", "(", "isset", "(", "$", "components", "[", "'port'", "]", ")", ")", "{", "$", "port", "=", "$", "components", "[", "'port'", "]", ";", "$", "hostHeader", "=", "$", "host", ".", "':'", ".", "$", "port", ";", "}", "else", "{", "$", "port", "=", "(", "$", "isSecure", "?", "443", ":", "80", ")", ";", "$", "hostHeader", "=", "$", "host", ";", "}", "$", "this", "->", "path", "=", "isset", "(", "$", "components", "[", "'path'", "]", ")", "?", "$", "components", "[", "'path'", "]", ":", "'/'", ";", "$", "requestUri", "=", "$", "this", "->", "path", ";", "if", "(", "isset", "(", "$", "components", "[", "'query'", "]", ")", ")", "{", "$", "this", "->", "queryString", "=", "$", "components", "[", "'query'", "]", ";", "parse_str", "(", "$", "this", "->", "queryString", ",", "$", "this", "->", "query", ")", ";", "$", "requestUri", ".=", "'?'", ".", "$", "this", "->", "queryString", ";", "}", "else", "{", "$", "this", "->", "queryString", "=", "''", ";", "$", "this", "->", "query", "=", "[", "]", ";", "}", "$", "this", "->", "setHeader", "(", "'Host'", ",", "$", "hostHeader", ")", ";", "$", "this", "->", "host", "=", "$", "host", ";", "$", "this", "->", "port", "=", "$", "port", ";", "$", "this", "->", "isSecure", "=", "$", "isSecure", ";", "$", "this", "->", "requestUri", "=", "$", "requestUri", ";", "return", "$", "this", ";", "}" ]
Sets the request URL. @param string $url The new URL. @return static This request. @throws \InvalidArgumentException If the URL is not valid.
[ "Sets", "the", "request", "URL", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L944-L998
228,018
brick/http
src/Request.php
Request.getReferer
public function getReferer() : ?Url { $referer = $this->getFirstHeader('Referer'); if ($referer === null) { return null; } try { return new Url($referer); } catch (\InvalidArgumentException $e) { return null; } }
php
public function getReferer() : ?Url { $referer = $this->getFirstHeader('Referer'); if ($referer === null) { return null; } try { return new Url($referer); } catch (\InvalidArgumentException $e) { return null; } }
[ "public", "function", "getReferer", "(", ")", ":", "?", "Url", "{", "$", "referer", "=", "$", "this", "->", "getFirstHeader", "(", "'Referer'", ")", ";", "if", "(", "$", "referer", "===", "null", ")", "{", "return", "null", ";", "}", "try", "{", "return", "new", "Url", "(", "$", "referer", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "return", "null", ";", "}", "}" ]
Returns the Referer URL if it is present and valid, else null. @return Url|null
[ "Returns", "the", "Referer", "URL", "if", "it", "is", "present", "and", "valid", "else", "null", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L1005-L1018
228,019
brick/http
src/Request.php
Request.setSecure
public function setSecure(bool $isSecure) : Request { $isStandardPort = ($this->port === ($this->isSecure ? 443 : 80)); if ($isStandardPort) { $this->port = $isSecure ? 443 : 80; } $this->isSecure = $isSecure; return $this; }
php
public function setSecure(bool $isSecure) : Request { $isStandardPort = ($this->port === ($this->isSecure ? 443 : 80)); if ($isStandardPort) { $this->port = $isSecure ? 443 : 80; } $this->isSecure = $isSecure; return $this; }
[ "public", "function", "setSecure", "(", "bool", "$", "isSecure", ")", ":", "Request", "{", "$", "isStandardPort", "=", "(", "$", "this", "->", "port", "===", "(", "$", "this", "->", "isSecure", "?", "443", ":", "80", ")", ")", ";", "if", "(", "$", "isStandardPort", ")", "{", "$", "this", "->", "port", "=", "$", "isSecure", "?", "443", ":", "80", ";", "}", "$", "this", "->", "isSecure", "=", "$", "isSecure", ";", "return", "$", "this", ";", "}" ]
Sets whether this request is sent over a secure connection. @param bool $isSecure True to mark the request as secure, false to mark it as not secure. @return static This request.
[ "Sets", "whether", "this", "request", "is", "sent", "over", "a", "secure", "connection", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L1037-L1048
228,020
brick/http
src/Request.php
Request.parseHeaderParameters
private function parseHeaderParameters(string $header) : array { $result = []; $values = explode(',', $header); foreach ($values as $parts) { $parameters = []; $parts = explode(';', $parts); $item = trim(array_shift($parts)); if ($item === '') { continue; } foreach ($parts as $part) { if (preg_match('/^\s*([^\=]+)\=(.*?)\s*$/', $part, $matches) === 0) { continue; } $parameters[$matches[1]] = $matches[2]; } $result[$item] = $parameters; } return $result; }
php
private function parseHeaderParameters(string $header) : array { $result = []; $values = explode(',', $header); foreach ($values as $parts) { $parameters = []; $parts = explode(';', $parts); $item = trim(array_shift($parts)); if ($item === '') { continue; } foreach ($parts as $part) { if (preg_match('/^\s*([^\=]+)\=(.*?)\s*$/', $part, $matches) === 0) { continue; } $parameters[$matches[1]] = $matches[2]; } $result[$item] = $parameters; } return $result; }
[ "private", "function", "parseHeaderParameters", "(", "string", "$", "header", ")", ":", "array", "{", "$", "result", "=", "[", "]", ";", "$", "values", "=", "explode", "(", "','", ",", "$", "header", ")", ";", "foreach", "(", "$", "values", "as", "$", "parts", ")", "{", "$", "parameters", "=", "[", "]", ";", "$", "parts", "=", "explode", "(", "';'", ",", "$", "parts", ")", ";", "$", "item", "=", "trim", "(", "array_shift", "(", "$", "parts", ")", ")", ";", "if", "(", "$", "item", "===", "''", ")", "{", "continue", ";", "}", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "if", "(", "preg_match", "(", "'/^\\s*([^\\=]+)\\=(.*?)\\s*$/'", ",", "$", "part", ",", "$", "matches", ")", "===", "0", ")", "{", "continue", ";", "}", "$", "parameters", "[", "$", "matches", "[", "1", "]", "]", "=", "$", "matches", "[", "2", "]", ";", "}", "$", "result", "[", "$", "item", "]", "=", "$", "parameters", ";", "}", "return", "$", "result", ";", "}" ]
Parses a header with multiple values and optional parameters. Example: text/html; charset=utf8, text/xml => ['text/html' => ['charset' => 'utf8'], 'text/xml' => []] @param string $header The header to parse. @return array An associative array of values and theirs parameters.
[ "Parses", "a", "header", "with", "multiple", "values", "and", "optional", "parameters", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Request.php#L1160-L1186
228,021
lawoole/framework
src/Support/Network.php
Network.getLocalHost
public static function getLocalHost() { if ($nets = swoole_get_local_ip()) { foreach ($nets as $net => $host) { if (self::isUsableHost($host)) { return $host; } } } return self::LOCAL_HOST; }
php
public static function getLocalHost() { if ($nets = swoole_get_local_ip()) { foreach ($nets as $net => $host) { if (self::isUsableHost($host)) { return $host; } } } return self::LOCAL_HOST; }
[ "public", "static", "function", "getLocalHost", "(", ")", "{", "if", "(", "$", "nets", "=", "swoole_get_local_ip", "(", ")", ")", "{", "foreach", "(", "$", "nets", "as", "$", "net", "=>", "$", "host", ")", "{", "if", "(", "self", "::", "isUsableHost", "(", "$", "host", ")", ")", "{", "return", "$", "host", ";", "}", "}", "}", "return", "self", "::", "LOCAL_HOST", ";", "}" ]
Get the local host ip. @return string
[ "Get", "the", "local", "host", "ip", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Support/Network.php#L21-L32
228,022
gggeek/ggwebservices
classes/ggphpsoapserver.php
ggPhpSOAPServer.processRequest
function processRequest() { $namespaceURI = 'unknown_namespace_uri'; /// @todo dechunk, correct encoding, check for supported /// http features of the client, etc... $data = $this->RawPostData; $data = $this->inflateRequest( $data ); if ( $data === false ) { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDCOMPRESSIONERROR, self::INVALIDCOMPRESSIONSTRING ) ); } $request = $this->parseRequest( $data ); if ( !is_object( $request ) ) /// @todo use is_a instead { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDREQUESTERROR, self::INVALIDREQUESTSTRING ) ); } else { $this->processRequestObj( $request ); } }
php
function processRequest() { $namespaceURI = 'unknown_namespace_uri'; /// @todo dechunk, correct encoding, check for supported /// http features of the client, etc... $data = $this->RawPostData; $data = $this->inflateRequest( $data ); if ( $data === false ) { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDCOMPRESSIONERROR, self::INVALIDCOMPRESSIONSTRING ) ); } $request = $this->parseRequest( $data ); if ( !is_object( $request ) ) /// @todo use is_a instead { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDREQUESTERROR, self::INVALIDREQUESTSTRING ) ); } else { $this->processRequestObj( $request ); } }
[ "function", "processRequest", "(", ")", "{", "$", "namespaceURI", "=", "'unknown_namespace_uri'", ";", "/// @todo dechunk, correct encoding, check for supported\r", "/// http features of the client, etc...\r", "$", "data", "=", "$", "this", "->", "RawPostData", ";", "$", "data", "=", "$", "this", "->", "inflateRequest", "(", "$", "data", ")", ";", "if", "(", "$", "data", "===", "false", ")", "{", "$", "this", "->", "showResponse", "(", "'unknown_function_name'", ",", "$", "namespaceURI", ",", "new", "ggWebservicesFault", "(", "self", "::", "INVALIDCOMPRESSIONERROR", ",", "self", "::", "INVALIDCOMPRESSIONSTRING", ")", ")", ";", "}", "$", "request", "=", "$", "this", "->", "parseRequest", "(", "$", "data", ")", ";", "if", "(", "!", "is_object", "(", "$", "request", ")", ")", "/// @todo use is_a instead\r", "{", "$", "this", "->", "showResponse", "(", "'unknown_function_name'", ",", "$", "namespaceURI", ",", "new", "ggWebservicesFault", "(", "self", "::", "INVALIDREQUESTERROR", ",", "self", "::", "INVALIDREQUESTSTRING", ")", ")", ";", "}", "else", "{", "$", "this", "->", "processRequestObj", "(", "$", "request", ")", ";", "}", "}" ]
Reimplemented, because we do not recover params in the request obj
[ "Reimplemented", "because", "we", "do", "not", "recover", "params", "in", "the", "request", "obj" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggphpsoapserver.php#L66-L96
228,023
tomwalder/php-appengine-search
src/Search/Index.php
Index.put
public function put($docs) { if($docs instanceof Document) { $this->obj_gateway->put([$docs]); } elseif (is_array($docs)) { $this->obj_gateway->put($docs); } else { throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects'); } }
php
public function put($docs) { if($docs instanceof Document) { $this->obj_gateway->put([$docs]); } elseif (is_array($docs)) { $this->obj_gateway->put($docs); } else { throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects'); } }
[ "public", "function", "put", "(", "$", "docs", ")", "{", "if", "(", "$", "docs", "instanceof", "Document", ")", "{", "$", "this", "->", "obj_gateway", "->", "put", "(", "[", "$", "docs", "]", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "docs", ")", ")", "{", "$", "this", "->", "obj_gateway", "->", "put", "(", "$", "docs", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Parameter must be one or more \\Search\\Document objects'", ")", ";", "}", "}" ]
Put a document into the index @param Document|Document[] $docs
[ "Put", "a", "document", "into", "the", "index" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Index.php#L46-L55
228,024
tomwalder/php-appengine-search
src/Search/Index.php
Index.search
public function search($query) { if($query instanceof Query) { return $this->obj_gateway->search($query); } return $this->obj_gateway->search(new Query((string)$query)); }
php
public function search($query) { if($query instanceof Query) { return $this->obj_gateway->search($query); } return $this->obj_gateway->search(new Query((string)$query)); }
[ "public", "function", "search", "(", "$", "query", ")", "{", "if", "(", "$", "query", "instanceof", "Query", ")", "{", "return", "$", "this", "->", "obj_gateway", "->", "search", "(", "$", "query", ")", ";", "}", "return", "$", "this", "->", "obj_gateway", "->", "search", "(", "new", "Query", "(", "(", "string", ")", "$", "query", ")", ")", ";", "}" ]
Run a basic search query Support simple query strings OR Query objects @param $query @return object
[ "Run", "a", "basic", "search", "query" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Index.php#L65-L71
228,025
tomwalder/php-appengine-search
src/Search/Index.php
Index.delete
public function delete($docs) { if($docs instanceof Document) { $this->obj_gateway->delete([$docs->getId()]); } elseif (is_string($docs)) { $this->obj_gateway->delete([$docs]); } elseif (is_array($docs)) { $arr_doc_ids = []; foreach($docs as $doc){ if($doc instanceof Document) { $arr_doc_ids[] = $doc->getId(); } elseif (is_string($doc)) { $arr_doc_ids[] = $doc; } else { throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects or ID strings'); } } $this->obj_gateway->delete($arr_doc_ids); } else { throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects or ID strings'); } }
php
public function delete($docs) { if($docs instanceof Document) { $this->obj_gateway->delete([$docs->getId()]); } elseif (is_string($docs)) { $this->obj_gateway->delete([$docs]); } elseif (is_array($docs)) { $arr_doc_ids = []; foreach($docs as $doc){ if($doc instanceof Document) { $arr_doc_ids[] = $doc->getId(); } elseif (is_string($doc)) { $arr_doc_ids[] = $doc; } else { throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects or ID strings'); } } $this->obj_gateway->delete($arr_doc_ids); } else { throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects or ID strings'); } }
[ "public", "function", "delete", "(", "$", "docs", ")", "{", "if", "(", "$", "docs", "instanceof", "Document", ")", "{", "$", "this", "->", "obj_gateway", "->", "delete", "(", "[", "$", "docs", "->", "getId", "(", ")", "]", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "docs", ")", ")", "{", "$", "this", "->", "obj_gateway", "->", "delete", "(", "[", "$", "docs", "]", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "docs", ")", ")", "{", "$", "arr_doc_ids", "=", "[", "]", ";", "foreach", "(", "$", "docs", "as", "$", "doc", ")", "{", "if", "(", "$", "doc", "instanceof", "Document", ")", "{", "$", "arr_doc_ids", "[", "]", "=", "$", "doc", "->", "getId", "(", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "doc", ")", ")", "{", "$", "arr_doc_ids", "[", "]", "=", "$", "doc", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Parameter must be one or more \\Search\\Document objects or ID strings'", ")", ";", "}", "}", "$", "this", "->", "obj_gateway", "->", "delete", "(", "$", "arr_doc_ids", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Parameter must be one or more \\Search\\Document objects or ID strings'", ")", ";", "}", "}" ]
Delete one or more documents @param $docs
[ "Delete", "one", "or", "more", "documents" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Index.php#L89-L110
228,026
antaresproject/core
src/foundation/src/Console/Commands/CoreAclCommand.php
CoreAclCommand.getActions
private function getActions(Component $component) { $defaultActions = (array) config('antares/installer::permissions.components.' . $component->name, []); return Action::where('component_id', $component->id)->whereIn('name', $defaultActions)->get(); }
php
private function getActions(Component $component) { $defaultActions = (array) config('antares/installer::permissions.components.' . $component->name, []); return Action::where('component_id', $component->id)->whereIn('name', $defaultActions)->get(); }
[ "private", "function", "getActions", "(", "Component", "$", "component", ")", "{", "$", "defaultActions", "=", "(", "array", ")", "config", "(", "'antares/installer::permissions.components.'", ".", "$", "component", "->", "name", ",", "[", "]", ")", ";", "return", "Action", "::", "where", "(", "'component_id'", ",", "$", "component", "->", "id", ")", "->", "whereIn", "(", "'name'", ",", "$", "defaultActions", ")", "->", "get", "(", ")", ";", "}" ]
Returns actions for the given component. @param Component $component @return Action[]
[ "Returns", "actions", "for", "the", "given", "component", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Console/Commands/CoreAclCommand.php#L56-L60
228,027
gggeek/ggwebservices
classes/gghttprequest.php
ggHTTPRequest._payload
protected function _payload() { $results = array(); foreach( $this->Parameters as $key => $val ) { if ( is_array( $val ) ) { foreach ( $val as $vkey => $vval ) { $results[] = urlencode( $key ) . '[' . urlencode( $vkey ) . ']=' . urlencode( $vval ); } } else { $results[] = urlencode( $key ) . '=' . urlencode( $val ); } } return implode( '&', $results ); }
php
protected function _payload() { $results = array(); foreach( $this->Parameters as $key => $val ) { if ( is_array( $val ) ) { foreach ( $val as $vkey => $vval ) { $results[] = urlencode( $key ) . '[' . urlencode( $vkey ) . ']=' . urlencode( $vval ); } } else { $results[] = urlencode( $key ) . '=' . urlencode( $val ); } } return implode( '&', $results ); }
[ "protected", "function", "_payload", "(", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "Parameters", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "foreach", "(", "$", "val", "as", "$", "vkey", "=>", "$", "vval", ")", "{", "$", "results", "[", "]", "=", "urlencode", "(", "$", "key", ")", ".", "'['", ".", "urlencode", "(", "$", "vkey", ")", ".", "']='", ".", "urlencode", "(", "$", "vval", ")", ";", "}", "}", "else", "{", "$", "results", "[", "]", "=", "urlencode", "(", "$", "key", ")", ".", "'='", ".", "urlencode", "(", "$", "val", ")", ";", "}", "}", "return", "implode", "(", "'&'", ",", "$", "results", ")", ";", "}" ]
the payload can be used in URIS for GETs and in http req bodies for POSTs @todo add support for array params
[ "the", "payload", "can", "be", "used", "in", "URIS", "for", "GETs", "and", "in", "http", "req", "bodies", "for", "POSTs" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/gghttprequest.php#L35-L53
228,028
antaresproject/core
src/components/view/src/Notification/NotificationHandler.php
NotificationHandler.handle
public function handle(AbstractNotificationTemplate $instance) { $type = $instance->getType(); $notifier = $this->getNotifierAdapter($type); if (!$notifier) { return false; } $render = $instance->render(); $view = $render instanceof View ? $render->render() : $render; $title = $instance->getTitle(); $recipients = $instance->getRecipients(); return $notifier->send($view, [], function($m) use($title, $recipients) { $m->to($recipients->pluck('email')->toArray()); $m->subject($title); }); }
php
public function handle(AbstractNotificationTemplate $instance) { $type = $instance->getType(); $notifier = $this->getNotifierAdapter($type); if (!$notifier) { return false; } $render = $instance->render(); $view = $render instanceof View ? $render->render() : $render; $title = $instance->getTitle(); $recipients = $instance->getRecipients(); return $notifier->send($view, [], function($m) use($title, $recipients) { $m->to($recipients->pluck('email')->toArray()); $m->subject($title); }); }
[ "public", "function", "handle", "(", "AbstractNotificationTemplate", "$", "instance", ")", "{", "$", "type", "=", "$", "instance", "->", "getType", "(", ")", ";", "$", "notifier", "=", "$", "this", "->", "getNotifierAdapter", "(", "$", "type", ")", ";", "if", "(", "!", "$", "notifier", ")", "{", "return", "false", ";", "}", "$", "render", "=", "$", "instance", "->", "render", "(", ")", ";", "$", "view", "=", "$", "render", "instanceof", "View", "?", "$", "render", "->", "render", "(", ")", ":", "$", "render", ";", "$", "title", "=", "$", "instance", "->", "getTitle", "(", ")", ";", "$", "recipients", "=", "$", "instance", "->", "getRecipients", "(", ")", ";", "return", "$", "notifier", "->", "send", "(", "$", "view", ",", "[", "]", ",", "function", "(", "$", "m", ")", "use", "(", "$", "title", ",", "$", "recipients", ")", "{", "$", "m", "->", "to", "(", "$", "recipients", "->", "pluck", "(", "'email'", ")", "->", "toArray", "(", ")", ")", ";", "$", "m", "->", "subject", "(", "$", "title", ")", ";", "}", ")", ";", "}" ]
handle notification event @param Notification $instance
[ "handle", "notification", "event" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Notification/NotificationHandler.php#L37-L53
228,029
antaresproject/core
src/components/view/src/Notification/NotificationHandler.php
NotificationHandler.getNotifierAdapter
public function getNotifierAdapter($type) { try { $config = config("antares/notifier::{$type}"); $notifierConfig = $config['adapters'][$config['adapters']['default']]; if (!class_exists($notifierConfig['model'])) { throw new Exception(sprintf('Notifier adapter: %s not exists.', $notifierConfig['model'])); } if (in_array($type, ['email', 'mail'])) { return Foundation::make('antares.notifier.email'); } return Foundation::make("antares.notifier.{$type}"); } catch (Exception $ex) { return false; } }
php
public function getNotifierAdapter($type) { try { $config = config("antares/notifier::{$type}"); $notifierConfig = $config['adapters'][$config['adapters']['default']]; if (!class_exists($notifierConfig['model'])) { throw new Exception(sprintf('Notifier adapter: %s not exists.', $notifierConfig['model'])); } if (in_array($type, ['email', 'mail'])) { return Foundation::make('antares.notifier.email'); } return Foundation::make("antares.notifier.{$type}"); } catch (Exception $ex) { return false; } }
[ "public", "function", "getNotifierAdapter", "(", "$", "type", ")", "{", "try", "{", "$", "config", "=", "config", "(", "\"antares/notifier::{$type}\"", ")", ";", "$", "notifierConfig", "=", "$", "config", "[", "'adapters'", "]", "[", "$", "config", "[", "'adapters'", "]", "[", "'default'", "]", "]", ";", "if", "(", "!", "class_exists", "(", "$", "notifierConfig", "[", "'model'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Notifier adapter: %s not exists.'", ",", "$", "notifierConfig", "[", "'model'", "]", ")", ")", ";", "}", "if", "(", "in_array", "(", "$", "type", ",", "[", "'email'", ",", "'mail'", "]", ")", ")", "{", "return", "Foundation", "::", "make", "(", "'antares.notifier.email'", ")", ";", "}", "return", "Foundation", "::", "make", "(", "\"antares.notifier.{$type}\"", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "false", ";", "}", "}" ]
gets notifier adapter by type @param String $type @return boolean @throws Exception
[ "gets", "notifier", "adapter", "by", "type" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Notification/NotificationHandler.php#L62-L77
228,030
joomla-framework/google-api
src/Data/Adsense.php
Adsense.getAccount
public function getAccount($accountID, $subaccounts = true) { if ($this->isAuthenticated()) { $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . ($subaccounts ? '?tree=true' : ''); $jdata = $this->query($url); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
php
public function getAccount($accountID, $subaccounts = true) { if ($this->isAuthenticated()) { $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . ($subaccounts ? '?tree=true' : ''); $jdata = $this->query($url); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
[ "public", "function", "getAccount", "(", "$", "accountID", ",", "$", "subaccounts", "=", "true", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "url", "=", "'https://www.googleapis.com/adsense/v1.1/accounts/'", ".", "urlencode", "(", "$", "accountID", ")", ".", "(", "$", "subaccounts", "?", "'?tree=true'", ":", "''", ")", ";", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ")", ";", "if", "(", "$", "data", "=", "json_decode", "(", "$", "jdata", "->", "body", ",", "true", ")", ")", "{", "return", "$", "data", ";", "}", "throw", "new", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "return", "false", ";", "}" ]
Method to get an Adsense account's settings from Google @param string $accountID ID of account to get @param boolean $subaccounts Include list of subaccounts @return mixed Data from Google @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "get", "an", "Adsense", "account", "s", "settings", "from", "Google" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Adsense.php#L55-L71
228,031
joomla-framework/google-api
src/Data/Adsense.php
Adsense.listAccounts
public function listAccounts($options = array(), $maxpages = 1) { if ($this->isAuthenticated()) { $next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null; unset($options['nextPageToken']); $url = 'https://www.googleapis.com/adsense/v1.1/accounts?' . http_build_query($options); return $this->listGetData($url, $maxpages, $next); } return false; }
php
public function listAccounts($options = array(), $maxpages = 1) { if ($this->isAuthenticated()) { $next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null; unset($options['nextPageToken']); $url = 'https://www.googleapis.com/adsense/v1.1/accounts?' . http_build_query($options); return $this->listGetData($url, $maxpages, $next); } return false; }
[ "public", "function", "listAccounts", "(", "$", "options", "=", "array", "(", ")", ",", "$", "maxpages", "=", "1", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "next", "=", "array_key_exists", "(", "'nextPageToken'", ",", "$", "options", ")", "?", "$", "options", "[", "'nextPage'", "]", ":", "null", ";", "unset", "(", "$", "options", "[", "'nextPageToken'", "]", ")", ";", "$", "url", "=", "'https://www.googleapis.com/adsense/v1.1/accounts?'", ".", "http_build_query", "(", "$", "options", ")", ";", "return", "$", "this", "->", "listGetData", "(", "$", "url", ",", "$", "maxpages", ",", "$", "next", ")", ";", "}", "return", "false", ";", "}" ]
Method to retrieve a list of AdSense accounts from Google @param array $options Search settings @param integer $maxpages Maximum number of pages of accounts to return @return mixed Data from Google @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "retrieve", "a", "list", "of", "AdSense", "accounts", "from", "Google" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Adsense.php#L84-L96
228,032
joomla-framework/google-api
src/Data/Adsense.php
Adsense.listClients
public function listClients($accountID, $options = array(), $maxpages = 1) { if ($this->isAuthenticated()) { $next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null; unset($options['nextPageToken']); $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . '/adclients?' . http_build_query($options); return $this->listGetData($url, $maxpages, $next); } return false; }
php
public function listClients($accountID, $options = array(), $maxpages = 1) { if ($this->isAuthenticated()) { $next = array_key_exists('nextPageToken', $options) ? $options['nextPage'] : null; unset($options['nextPageToken']); $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . '/adclients?' . http_build_query($options); return $this->listGetData($url, $maxpages, $next); } return false; }
[ "public", "function", "listClients", "(", "$", "accountID", ",", "$", "options", "=", "array", "(", ")", ",", "$", "maxpages", "=", "1", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "next", "=", "array_key_exists", "(", "'nextPageToken'", ",", "$", "options", ")", "?", "$", "options", "[", "'nextPage'", "]", ":", "null", ";", "unset", "(", "$", "options", "[", "'nextPageToken'", "]", ")", ";", "$", "url", "=", "'https://www.googleapis.com/adsense/v1.1/accounts/'", ".", "urlencode", "(", "$", "accountID", ")", ".", "'/adclients?'", ".", "http_build_query", "(", "$", "options", ")", ";", "return", "$", "this", "->", "listGetData", "(", "$", "url", ",", "$", "maxpages", ",", "$", "next", ")", ";", "}", "return", "false", ";", "}" ]
Method to retrieve a list of AdSense clients from Google @param string $accountID ID of account to list the clients from @param array $options Search settings @param integer $maxpages Maximum number of pages of accounts to return @return mixed Data from Google @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "retrieve", "a", "list", "of", "AdSense", "clients", "from", "Google" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Adsense.php#L110-L122
228,033
joomla-framework/google-api
src/Data/Adsense.php
Adsense.getUnit
public function getUnit($accountID, $adclientID, $adunitID) { if ($this->isAuthenticated()) { $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID); $url .= '/adclients/' . urlencode($adclientID) . '/adunits/' . urlencode($adunitID); $jdata = $this->query($url); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
php
public function getUnit($accountID, $adclientID, $adunitID) { if ($this->isAuthenticated()) { $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID); $url .= '/adclients/' . urlencode($adclientID) . '/adunits/' . urlencode($adunitID); $jdata = $this->query($url); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
[ "public", "function", "getUnit", "(", "$", "accountID", ",", "$", "adclientID", ",", "$", "adunitID", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "url", "=", "'https://www.googleapis.com/adsense/v1.1/accounts/'", ".", "urlencode", "(", "$", "accountID", ")", ";", "$", "url", ".=", "'/adclients/'", ".", "urlencode", "(", "$", "adclientID", ")", ".", "'/adunits/'", ".", "urlencode", "(", "$", "adunitID", ")", ";", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ")", ";", "if", "(", "$", "data", "=", "json_decode", "(", "$", "jdata", "->", "body", ",", "true", ")", ")", "{", "return", "$", "data", ";", "}", "throw", "new", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "return", "false", ";", "}" ]
Method to get an AdSense AdUnit @param string $accountID ID of account to get @param string $adclientID ID of client to get @param string $adunitID ID of adunit to get @return mixed Data from Google @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "get", "an", "AdSense", "AdUnit" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Adsense.php#L136-L153
228,034
joomla-framework/google-api
src/Data/Adsense.php
Adsense.generateReport
public function generateReport($accountID, $start, $end = false, $options = array(), $maxpages = 1) { if ($this->isAuthenticated()) { if (\is_int($start)) { $startobj = new DateTime; $startobj->setTimestamp($start); } elseif (\is_string($start)) { $startobj = new DateTime($start); } elseif (is_a($start, 'DateTime')) { $startobj = $start; } else { throw new InvalidArgumentException('Invalid start time.'); } if (!$end) { $endobj = new DateTime; } elseif (\is_int($end)) { $endobj = new DateTime; $endobj->setTimestamp($end); } elseif (\is_string($end)) { $endobj = new DateTime($end); } elseif (is_a($end, 'DateTime')) { $endobj = $end; } else { throw new InvalidArgumentException('Invalid end time.'); } $options['startDate'] = $startobj->format('Y-m-d'); $options['endDate'] = $endobj->format('Y-m-d'); $begin = array_key_exists('startIndex', $options) ? $options['startIndex'] : 0; unset($options['startIndex']); $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . '/reports?' . http_build_query($options); if (strpos($url, '&')) { $url .= '&'; } $i = 0; $data['rows'] = array(); do { $jdata = $this->query($url . 'startIndex=' . \count($data['rows'])); $newdata = json_decode($jdata->body, true); if ($newdata && array_key_exists('rows', $newdata)) { $newdata['rows'] = array_merge($data['rows'], $newdata['rows']); $data = $newdata; } else { throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } $i++; } while (\count($data['rows']) < $data['totalMatchedRows'] && $i < $maxpages); return $data; } return false; }
php
public function generateReport($accountID, $start, $end = false, $options = array(), $maxpages = 1) { if ($this->isAuthenticated()) { if (\is_int($start)) { $startobj = new DateTime; $startobj->setTimestamp($start); } elseif (\is_string($start)) { $startobj = new DateTime($start); } elseif (is_a($start, 'DateTime')) { $startobj = $start; } else { throw new InvalidArgumentException('Invalid start time.'); } if (!$end) { $endobj = new DateTime; } elseif (\is_int($end)) { $endobj = new DateTime; $endobj->setTimestamp($end); } elseif (\is_string($end)) { $endobj = new DateTime($end); } elseif (is_a($end, 'DateTime')) { $endobj = $end; } else { throw new InvalidArgumentException('Invalid end time.'); } $options['startDate'] = $startobj->format('Y-m-d'); $options['endDate'] = $endobj->format('Y-m-d'); $begin = array_key_exists('startIndex', $options) ? $options['startIndex'] : 0; unset($options['startIndex']); $url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode($accountID) . '/reports?' . http_build_query($options); if (strpos($url, '&')) { $url .= '&'; } $i = 0; $data['rows'] = array(); do { $jdata = $this->query($url . 'startIndex=' . \count($data['rows'])); $newdata = json_decode($jdata->body, true); if ($newdata && array_key_exists('rows', $newdata)) { $newdata['rows'] = array_merge($data['rows'], $newdata['rows']); $data = $newdata; } else { throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } $i++; } while (\count($data['rows']) < $data['totalMatchedRows'] && $i < $maxpages); return $data; } return false; }
[ "public", "function", "generateReport", "(", "$", "accountID", ",", "$", "start", ",", "$", "end", "=", "false", ",", "$", "options", "=", "array", "(", ")", ",", "$", "maxpages", "=", "1", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "if", "(", "\\", "is_int", "(", "$", "start", ")", ")", "{", "$", "startobj", "=", "new", "DateTime", ";", "$", "startobj", "->", "setTimestamp", "(", "$", "start", ")", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "start", ")", ")", "{", "$", "startobj", "=", "new", "DateTime", "(", "$", "start", ")", ";", "}", "elseif", "(", "is_a", "(", "$", "start", ",", "'DateTime'", ")", ")", "{", "$", "startobj", "=", "$", "start", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid start time.'", ")", ";", "}", "if", "(", "!", "$", "end", ")", "{", "$", "endobj", "=", "new", "DateTime", ";", "}", "elseif", "(", "\\", "is_int", "(", "$", "end", ")", ")", "{", "$", "endobj", "=", "new", "DateTime", ";", "$", "endobj", "->", "setTimestamp", "(", "$", "end", ")", ";", "}", "elseif", "(", "\\", "is_string", "(", "$", "end", ")", ")", "{", "$", "endobj", "=", "new", "DateTime", "(", "$", "end", ")", ";", "}", "elseif", "(", "is_a", "(", "$", "end", ",", "'DateTime'", ")", ")", "{", "$", "endobj", "=", "$", "end", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid end time.'", ")", ";", "}", "$", "options", "[", "'startDate'", "]", "=", "$", "startobj", "->", "format", "(", "'Y-m-d'", ")", ";", "$", "options", "[", "'endDate'", "]", "=", "$", "endobj", "->", "format", "(", "'Y-m-d'", ")", ";", "$", "begin", "=", "array_key_exists", "(", "'startIndex'", ",", "$", "options", ")", "?", "$", "options", "[", "'startIndex'", "]", ":", "0", ";", "unset", "(", "$", "options", "[", "'startIndex'", "]", ")", ";", "$", "url", "=", "'https://www.googleapis.com/adsense/v1.1/accounts/'", ".", "urlencode", "(", "$", "accountID", ")", ".", "'/reports?'", ".", "http_build_query", "(", "$", "options", ")", ";", "if", "(", "strpos", "(", "$", "url", ",", "'&'", ")", ")", "{", "$", "url", ".=", "'&'", ";", "}", "$", "i", "=", "0", ";", "$", "data", "[", "'rows'", "]", "=", "array", "(", ")", ";", "do", "{", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ".", "'startIndex='", ".", "\\", "count", "(", "$", "data", "[", "'rows'", "]", ")", ")", ";", "$", "newdata", "=", "json_decode", "(", "$", "jdata", "->", "body", ",", "true", ")", ";", "if", "(", "$", "newdata", "&&", "array_key_exists", "(", "'rows'", ",", "$", "newdata", ")", ")", "{", "$", "newdata", "[", "'rows'", "]", "=", "array_merge", "(", "$", "data", "[", "'rows'", "]", ",", "$", "newdata", "[", "'rows'", "]", ")", ";", "$", "data", "=", "$", "newdata", ";", "}", "else", "{", "throw", "new", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "$", "i", "++", ";", "}", "while", "(", "\\", "count", "(", "$", "data", "[", "'rows'", "]", ")", "<", "$", "data", "[", "'totalMatchedRows'", "]", "&&", "$", "i", "<", "$", "maxpages", ")", ";", "return", "$", "data", ";", "}", "return", "false", ";", "}" ]
Method to retrieve a list of AdSense Channel URLs @param string $accountID ID of account @param mixed $start Start day @param mixed $end End day @param array $options Search settings @param integer $maxpages Maximum number of pages of accounts to return @return mixed Data from Google @since 1.0 @throws InvalidArgumentException @throws UnexpectedValueException
[ "Method", "to", "retrieve", "a", "list", "of", "AdSense", "Channel", "URLs" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Adsense.php#L315-L398
228,035
akramfares/rundeck-sdk-php
src/Resources/Resource.php
Resource.get
public function get($action, $alt = "xml") { if (array_key_exists($action, $this->actions)) { if (!in_array($alt, $this->actions[$action])) { throw new \Exception("Invalid Format: ". $alt); } $response = $this->client->get('/'. strtolower(get_class($this)) .'/'.$this->name. '/' .$action, $alt); return $response; } else { throw new \Exception("Invalid Action: ". $action); } }
php
public function get($action, $alt = "xml") { if (array_key_exists($action, $this->actions)) { if (!in_array($alt, $this->actions[$action])) { throw new \Exception("Invalid Format: ". $alt); } $response = $this->client->get('/'. strtolower(get_class($this)) .'/'.$this->name. '/' .$action, $alt); return $response; } else { throw new \Exception("Invalid Action: ". $action); } }
[ "public", "function", "get", "(", "$", "action", ",", "$", "alt", "=", "\"xml\"", ")", "{", "if", "(", "array_key_exists", "(", "$", "action", ",", "$", "this", "->", "actions", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "alt", ",", "$", "this", "->", "actions", "[", "$", "action", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid Format: \"", ".", "$", "alt", ")", ";", "}", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "'/'", ".", "strtolower", "(", "get_class", "(", "$", "this", ")", ")", ".", "'/'", ".", "$", "this", "->", "name", ".", "'/'", ".", "$", "action", ",", "$", "alt", ")", ";", "return", "$", "response", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid Action: \"", ".", "$", "action", ")", ";", "}", "}" ]
Get resource action @param $action @param string $alt xml|json @return array @throws \Exception
[ "Get", "resource", "action" ]
6a806c2830787b875dc8033e5c6883cbcb4b5abd
https://github.com/akramfares/rundeck-sdk-php/blob/6a806c2830787b875dc8033e5c6883cbcb4b5abd/src/Resources/Resource.php#L32-L43
228,036
joomla-framework/google-api
src/Data/Picasa.php
Picasa.listAlbums
public function listAlbums($userID = 'default') { if ($this->isAuthenticated()) { $url = 'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID); $jdata = $this->query($url, null, array('GData-Version' => 2)); $xml = $this->safeXml($jdata->body); if (isset($xml->children()->entry)) { $items = array(); foreach ($xml->children()->entry as $item) { $items[] = new Picasa\Album($item, $this->options, $this->auth); } return $items; } throw new \UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
php
public function listAlbums($userID = 'default') { if ($this->isAuthenticated()) { $url = 'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID); $jdata = $this->query($url, null, array('GData-Version' => 2)); $xml = $this->safeXml($jdata->body); if (isset($xml->children()->entry)) { $items = array(); foreach ($xml->children()->entry as $item) { $items[] = new Picasa\Album($item, $this->options, $this->auth); } return $items; } throw new \UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
[ "public", "function", "listAlbums", "(", "$", "userID", "=", "'default'", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "url", "=", "'https://picasaweb.google.com/data/feed/api/user/'", ".", "urlencode", "(", "$", "userID", ")", ";", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ",", "null", ",", "array", "(", "'GData-Version'", "=>", "2", ")", ")", ";", "$", "xml", "=", "$", "this", "->", "safeXml", "(", "$", "jdata", "->", "body", ")", ";", "if", "(", "isset", "(", "$", "xml", "->", "children", "(", ")", "->", "entry", ")", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "xml", "->", "children", "(", ")", "->", "entry", "as", "$", "item", ")", "{", "$", "items", "[", "]", "=", "new", "Picasa", "\\", "Album", "(", "$", "item", ",", "$", "this", "->", "options", ",", "$", "this", "->", "auth", ")", ";", "}", "return", "$", "items", ";", "}", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "return", "false", ";", "}" ]
Method to retrieve a list of Picasa Albums @param string $userID ID of user @return mixed Data from Google @since 1.0 @throws \UnexpectedValueException
[ "Method", "to", "retrieve", "a", "list", "of", "Picasa", "Albums" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Picasa.php#L51-L75
228,037
joomla-framework/google-api
src/Data/Picasa.php
Picasa.createAlbum
public function createAlbum($userID = 'default', $title = '', $access = 'private', $summary = '', $location = '', $time = false, $keywords = array() ) { if ($this->isAuthenticated()) { $time = $time ? $time : time(); $title = $title != '' ? $title : date('F j, Y'); $xml = new \SimpleXMLElement('<entry></entry>'); $xml->addAttribute('xmlns', 'http://www.w3.org/2005/Atom'); $xml->addChild('title', $title); $xml->addChild('summary', $summary); $xml->addChild('gphoto:location', $location, 'http://schemas.google.com/photos/2007'); $xml->addChild('gphoto:access', $access); $xml->addChild('gphoto:timestamp', $time); $media = $xml->addChild('media:group', '', 'http://search.yahoo.com/mrss/'); $media->addChild('media:keywords', implode($keywords, ', ')); $cat = $xml->addChild('category', ''); $cat->addAttribute('scheme', 'http://schemas.google.com/g/2005#kind'); $cat->addAttribute('term', 'http://schemas.google.com/photos/2007#album'); $url = 'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID); $jdata = $this->query($url, $xml->asXML(), array('GData-Version' => 2, 'Content-type' => 'application/atom+xml'), 'post'); $xml = $this->safeXml($jdata->body); return new Picasa\Album($xml, $this->options, $this->auth); } return false; }
php
public function createAlbum($userID = 'default', $title = '', $access = 'private', $summary = '', $location = '', $time = false, $keywords = array() ) { if ($this->isAuthenticated()) { $time = $time ? $time : time(); $title = $title != '' ? $title : date('F j, Y'); $xml = new \SimpleXMLElement('<entry></entry>'); $xml->addAttribute('xmlns', 'http://www.w3.org/2005/Atom'); $xml->addChild('title', $title); $xml->addChild('summary', $summary); $xml->addChild('gphoto:location', $location, 'http://schemas.google.com/photos/2007'); $xml->addChild('gphoto:access', $access); $xml->addChild('gphoto:timestamp', $time); $media = $xml->addChild('media:group', '', 'http://search.yahoo.com/mrss/'); $media->addChild('media:keywords', implode($keywords, ', ')); $cat = $xml->addChild('category', ''); $cat->addAttribute('scheme', 'http://schemas.google.com/g/2005#kind'); $cat->addAttribute('term', 'http://schemas.google.com/photos/2007#album'); $url = 'https://picasaweb.google.com/data/feed/api/user/' . urlencode($userID); $jdata = $this->query($url, $xml->asXML(), array('GData-Version' => 2, 'Content-type' => 'application/atom+xml'), 'post'); $xml = $this->safeXml($jdata->body); return new Picasa\Album($xml, $this->options, $this->auth); } return false; }
[ "public", "function", "createAlbum", "(", "$", "userID", "=", "'default'", ",", "$", "title", "=", "''", ",", "$", "access", "=", "'private'", ",", "$", "summary", "=", "''", ",", "$", "location", "=", "''", ",", "$", "time", "=", "false", ",", "$", "keywords", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "time", "=", "$", "time", "?", "$", "time", ":", "time", "(", ")", ";", "$", "title", "=", "$", "title", "!=", "''", "?", "$", "title", ":", "date", "(", "'F j, Y'", ")", ";", "$", "xml", "=", "new", "\\", "SimpleXMLElement", "(", "'<entry></entry>'", ")", ";", "$", "xml", "->", "addAttribute", "(", "'xmlns'", ",", "'http://www.w3.org/2005/Atom'", ")", ";", "$", "xml", "->", "addChild", "(", "'title'", ",", "$", "title", ")", ";", "$", "xml", "->", "addChild", "(", "'summary'", ",", "$", "summary", ")", ";", "$", "xml", "->", "addChild", "(", "'gphoto:location'", ",", "$", "location", ",", "'http://schemas.google.com/photos/2007'", ")", ";", "$", "xml", "->", "addChild", "(", "'gphoto:access'", ",", "$", "access", ")", ";", "$", "xml", "->", "addChild", "(", "'gphoto:timestamp'", ",", "$", "time", ")", ";", "$", "media", "=", "$", "xml", "->", "addChild", "(", "'media:group'", ",", "''", ",", "'http://search.yahoo.com/mrss/'", ")", ";", "$", "media", "->", "addChild", "(", "'media:keywords'", ",", "implode", "(", "$", "keywords", ",", "', '", ")", ")", ";", "$", "cat", "=", "$", "xml", "->", "addChild", "(", "'category'", ",", "''", ")", ";", "$", "cat", "->", "addAttribute", "(", "'scheme'", ",", "'http://schemas.google.com/g/2005#kind'", ")", ";", "$", "cat", "->", "addAttribute", "(", "'term'", ",", "'http://schemas.google.com/photos/2007#album'", ")", ";", "$", "url", "=", "'https://picasaweb.google.com/data/feed/api/user/'", ".", "urlencode", "(", "$", "userID", ")", ";", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ",", "$", "xml", "->", "asXML", "(", ")", ",", "array", "(", "'GData-Version'", "=>", "2", ",", "'Content-type'", "=>", "'application/atom+xml'", ")", ",", "'post'", ")", ";", "$", "xml", "=", "$", "this", "->", "safeXml", "(", "$", "jdata", "->", "body", ")", ";", "return", "new", "Picasa", "\\", "Album", "(", "$", "xml", ",", "$", "this", "->", "options", ",", "$", "this", "->", "auth", ")", ";", "}", "return", "false", ";", "}" ]
Method to create a Picasa Album @param string $userID ID of user @param string $title New album title @param string $access New album access settings @param string $summary New album summary @param string $location New album location @param integer $time New album timestamp @param array $keywords New album keywords @return mixed Data from Google. @since 1.0
[ "Method", "to", "create", "a", "Picasa", "Album" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Picasa.php#L92-L122
228,038
antaresproject/core
src/components/support/src/Support/Manager.php
Manager.getDriverName
protected function getDriverName($driverName) { if (false === strpos($driverName, '.')) { $driverName = "{$driverName}.default"; } list($driver, $name) = explode('.', $driverName, 2); $this->checkNameIsNotBlacklisted($name); return [$driver, $name]; }
php
protected function getDriverName($driverName) { if (false === strpos($driverName, '.')) { $driverName = "{$driverName}.default"; } list($driver, $name) = explode('.', $driverName, 2); $this->checkNameIsNotBlacklisted($name); return [$driver, $name]; }
[ "protected", "function", "getDriverName", "(", "$", "driverName", ")", "{", "if", "(", "false", "===", "strpos", "(", "$", "driverName", ",", "'.'", ")", ")", "{", "$", "driverName", "=", "\"{$driverName}.default\"", ";", "}", "list", "(", "$", "driver", ",", "$", "name", ")", "=", "explode", "(", "'.'", ",", "$", "driverName", ",", "2", ")", ";", "$", "this", "->", "checkNameIsNotBlacklisted", "(", "$", "name", ")", ";", "return", "[", "$", "driver", ",", "$", "name", "]", ";", "}" ]
Get driver name. @param string $driverName @return array
[ "Get", "driver", "name", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Manager.php#L90-L102
228,039
antaresproject/core
src/utils/asset/src/AssetPublisher.php
AssetPublisher.getFiles
protected function getFiles($specified) { $specified = (array) $specified; if (php_sapi_name() === 'cli') { return []; } if ($this->extension === null) { return []; } $path = $this->extensionsManager->getExtensionPathByName($this->extension); if (!$path) { return []; } $public = $path . DIRECTORY_SEPARATOR . 'public'; $filesystem = app(Filesystem::class); if (empty($specified)) { return $filesystem->allFiles($public); } $return = []; foreach ($specified as $file) { $target = $public . DIRECTORY_SEPARATOR . $file; if (!file_exists($target) && file_exists(public_path($file))) { $target = public_path($file); } array_push($return, new SplFileInfo($public . DIRECTORY_SEPARATOR . $file, current(explode('/', $file)), $file)); } return $return; }
php
protected function getFiles($specified) { $specified = (array) $specified; if (php_sapi_name() === 'cli') { return []; } if ($this->extension === null) { return []; } $path = $this->extensionsManager->getExtensionPathByName($this->extension); if (!$path) { return []; } $public = $path . DIRECTORY_SEPARATOR . 'public'; $filesystem = app(Filesystem::class); if (empty($specified)) { return $filesystem->allFiles($public); } $return = []; foreach ($specified as $file) { $target = $public . DIRECTORY_SEPARATOR . $file; if (!file_exists($target) && file_exists(public_path($file))) { $target = public_path($file); } array_push($return, new SplFileInfo($public . DIRECTORY_SEPARATOR . $file, current(explode('/', $file)), $file)); } return $return; }
[ "protected", "function", "getFiles", "(", "$", "specified", ")", "{", "$", "specified", "=", "(", "array", ")", "$", "specified", ";", "if", "(", "php_sapi_name", "(", ")", "===", "'cli'", ")", "{", "return", "[", "]", ";", "}", "if", "(", "$", "this", "->", "extension", "===", "null", ")", "{", "return", "[", "]", ";", "}", "$", "path", "=", "$", "this", "->", "extensionsManager", "->", "getExtensionPathByName", "(", "$", "this", "->", "extension", ")", ";", "if", "(", "!", "$", "path", ")", "{", "return", "[", "]", ";", "}", "$", "public", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'public'", ";", "$", "filesystem", "=", "app", "(", "Filesystem", "::", "class", ")", ";", "if", "(", "empty", "(", "$", "specified", ")", ")", "{", "return", "$", "filesystem", "->", "allFiles", "(", "$", "public", ")", ";", "}", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "specified", "as", "$", "file", ")", "{", "$", "target", "=", "$", "public", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ";", "if", "(", "!", "file_exists", "(", "$", "target", ")", "&&", "file_exists", "(", "public_path", "(", "$", "file", ")", ")", ")", "{", "$", "target", "=", "public_path", "(", "$", "file", ")", ";", "}", "array_push", "(", "$", "return", ",", "new", "SplFileInfo", "(", "$", "public", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", ",", "current", "(", "explode", "(", "'/'", ",", "$", "file", ")", ")", ",", "$", "file", ")", ")", ";", "}", "return", "$", "return", ";", "}" ]
get files to publish @param array $specified @return array
[ "get", "files", "to", "publish" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/AssetPublisher.php#L98-L135
228,040
antaresproject/core
src/utils/asset/src/AssetPublisher.php
AssetPublisher.publishAndPropagate
public function publishAndPropagate(array $files = array(), $extension = null, $before = []) { $container = $this->assetFactory->container($this->position); $applicationContainer = $this->assetFactory->container('antares/foundation::application'); if (empty($files)) { return $container; } if (!is_null($extension)) { $this->extension = $extension; } foreach ($files as $file) { $fileRealPath = $file->getRealPath(); if ($fileRealPath !== false) { $name = $this->extension . DIRECTORY_SEPARATOR . $file->getRelativePathname(); $published = $this->symlinker->publish($name, $fileRealPath); if (!in_array($file->getExtension(), ['css', 'js']) or $published === false) { continue; } } else { $published = $file->getRelativePathname(); } $basename = str_replace('\\', '/', $published); $sluggedBaseName = str_slug($file->getBasename()); if ($file->getExtension() === 'css') { $applicationContainer->style($sluggedBaseName, $basename); } else { $container->add($sluggedBaseName, $basename, [], $before); } } return $container; }
php
public function publishAndPropagate(array $files = array(), $extension = null, $before = []) { $container = $this->assetFactory->container($this->position); $applicationContainer = $this->assetFactory->container('antares/foundation::application'); if (empty($files)) { return $container; } if (!is_null($extension)) { $this->extension = $extension; } foreach ($files as $file) { $fileRealPath = $file->getRealPath(); if ($fileRealPath !== false) { $name = $this->extension . DIRECTORY_SEPARATOR . $file->getRelativePathname(); $published = $this->symlinker->publish($name, $fileRealPath); if (!in_array($file->getExtension(), ['css', 'js']) or $published === false) { continue; } } else { $published = $file->getRelativePathname(); } $basename = str_replace('\\', '/', $published); $sluggedBaseName = str_slug($file->getBasename()); if ($file->getExtension() === 'css') { $applicationContainer->style($sluggedBaseName, $basename); } else { $container->add($sluggedBaseName, $basename, [], $before); } } return $container; }
[ "public", "function", "publishAndPropagate", "(", "array", "$", "files", "=", "array", "(", ")", ",", "$", "extension", "=", "null", ",", "$", "before", "=", "[", "]", ")", "{", "$", "container", "=", "$", "this", "->", "assetFactory", "->", "container", "(", "$", "this", "->", "position", ")", ";", "$", "applicationContainer", "=", "$", "this", "->", "assetFactory", "->", "container", "(", "'antares/foundation::application'", ")", ";", "if", "(", "empty", "(", "$", "files", ")", ")", "{", "return", "$", "container", ";", "}", "if", "(", "!", "is_null", "(", "$", "extension", ")", ")", "{", "$", "this", "->", "extension", "=", "$", "extension", ";", "}", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "fileRealPath", "=", "$", "file", "->", "getRealPath", "(", ")", ";", "if", "(", "$", "fileRealPath", "!==", "false", ")", "{", "$", "name", "=", "$", "this", "->", "extension", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", "->", "getRelativePathname", "(", ")", ";", "$", "published", "=", "$", "this", "->", "symlinker", "->", "publish", "(", "$", "name", ",", "$", "fileRealPath", ")", ";", "if", "(", "!", "in_array", "(", "$", "file", "->", "getExtension", "(", ")", ",", "[", "'css'", ",", "'js'", "]", ")", "or", "$", "published", "===", "false", ")", "{", "continue", ";", "}", "}", "else", "{", "$", "published", "=", "$", "file", "->", "getRelativePathname", "(", ")", ";", "}", "$", "basename", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "published", ")", ";", "$", "sluggedBaseName", "=", "str_slug", "(", "$", "file", "->", "getBasename", "(", ")", ")", ";", "if", "(", "$", "file", "->", "getExtension", "(", ")", "===", "'css'", ")", "{", "$", "applicationContainer", "->", "style", "(", "$", "sluggedBaseName", ",", "$", "basename", ")", ";", "}", "else", "{", "$", "container", "->", "add", "(", "$", "sluggedBaseName", ",", "$", "basename", ",", "[", "]", ",", "$", "before", ")", ";", "}", "}", "return", "$", "container", ";", "}" ]
creates symlink as publish and attaches to asset container @param array $files @param String $extension @param array $before @return Asset
[ "creates", "symlink", "as", "publish", "and", "attaches", "to", "asset", "container" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/AssetPublisher.php#L145-L182
228,041
antaresproject/core
src/utils/asset/src/AssetPublisher.php
AssetPublisher.publish
public function publish($extension, $options = null, $before = []) { $files = $this->files($extension, $options, $before); return $this->publishAndPropagate($files, null, $before); }
php
public function publish($extension, $options = null, $before = []) { $files = $this->files($extension, $options, $before); return $this->publishAndPropagate($files, null, $before); }
[ "public", "function", "publish", "(", "$", "extension", ",", "$", "options", "=", "null", ",", "$", "before", "=", "[", "]", ")", "{", "$", "files", "=", "$", "this", "->", "files", "(", "$", "extension", ",", "$", "options", ",", "$", "before", ")", ";", "return", "$", "this", "->", "publishAndPropagate", "(", "$", "files", ",", "null", ",", "$", "before", ")", ";", "}" ]
publish assets depends on extension name @param String $extension @param mixed $options @param array $before @return Asset
[ "publish", "assets", "depends", "on", "extension", "name" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/AssetPublisher.php#L245-L249
228,042
antaresproject/core
src/foundation/src/Traits/PackageValidationTrait.php
PackageValidationTrait.parsePackage
protected function parsePackage($attribute, UploadedFile $value, $parameters) { $name = $value->getClientOriginalName(); $this->directory = $directory = $value->directory; $this->filename = $filename = $value->filename; $this->extension = $extension = File::extension($filename); $this->module = $module = str_replace('.' . $extension, '', $name); if ($value->move($directory, $filename)) { $za = new ZipArchive(); $za->open($directory . DIRECTORY_SEPARATOR . $filename); $list = []; for ($i = 0; $i < $za->numFiles; $i++) { $stat = $za->statIndex($i); $basename = basename($stat['name']); if ($basename == $this->manifestPattern && $za->extractTo($directory, array($za->getNameIndex($i)))) { { $this->manifest = $directory . DIRECTORY_SEPARATOR . $basename; } } $list[] = basename($basename); } $za->close(); } return $list; }
php
protected function parsePackage($attribute, UploadedFile $value, $parameters) { $name = $value->getClientOriginalName(); $this->directory = $directory = $value->directory; $this->filename = $filename = $value->filename; $this->extension = $extension = File::extension($filename); $this->module = $module = str_replace('.' . $extension, '', $name); if ($value->move($directory, $filename)) { $za = new ZipArchive(); $za->open($directory . DIRECTORY_SEPARATOR . $filename); $list = []; for ($i = 0; $i < $za->numFiles; $i++) { $stat = $za->statIndex($i); $basename = basename($stat['name']); if ($basename == $this->manifestPattern && $za->extractTo($directory, array($za->getNameIndex($i)))) { { $this->manifest = $directory . DIRECTORY_SEPARATOR . $basename; } } $list[] = basename($basename); } $za->close(); } return $list; }
[ "protected", "function", "parsePackage", "(", "$", "attribute", ",", "UploadedFile", "$", "value", ",", "$", "parameters", ")", "{", "$", "name", "=", "$", "value", "->", "getClientOriginalName", "(", ")", ";", "$", "this", "->", "directory", "=", "$", "directory", "=", "$", "value", "->", "directory", ";", "$", "this", "->", "filename", "=", "$", "filename", "=", "$", "value", "->", "filename", ";", "$", "this", "->", "extension", "=", "$", "extension", "=", "File", "::", "extension", "(", "$", "filename", ")", ";", "$", "this", "->", "module", "=", "$", "module", "=", "str_replace", "(", "'.'", ".", "$", "extension", ",", "''", ",", "$", "name", ")", ";", "if", "(", "$", "value", "->", "move", "(", "$", "directory", ",", "$", "filename", ")", ")", "{", "$", "za", "=", "new", "ZipArchive", "(", ")", ";", "$", "za", "->", "open", "(", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ")", ";", "$", "list", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "za", "->", "numFiles", ";", "$", "i", "++", ")", "{", "$", "stat", "=", "$", "za", "->", "statIndex", "(", "$", "i", ")", ";", "$", "basename", "=", "basename", "(", "$", "stat", "[", "'name'", "]", ")", ";", "if", "(", "$", "basename", "==", "$", "this", "->", "manifestPattern", "&&", "$", "za", "->", "extractTo", "(", "$", "directory", ",", "array", "(", "$", "za", "->", "getNameIndex", "(", "$", "i", ")", ")", ")", ")", "{", "{", "$", "this", "->", "manifest", "=", "$", "directory", ".", "DIRECTORY_SEPARATOR", ".", "$", "basename", ";", "}", "}", "$", "list", "[", "]", "=", "basename", "(", "$", "basename", ")", ";", "}", "$", "za", "->", "close", "(", ")", ";", "}", "return", "$", "list", ";", "}" ]
parse uploaded package @param array | string $attribute @param \Symfony\Component\HttpFoundation\File\UploadedFile $value @param array | string $parameters
[ "parse", "uploaded", "package" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Traits/PackageValidationTrait.php#L85-L112
228,043
antaresproject/core
src/foundation/src/Traits/PackageValidationTrait.php
PackageValidationTrait.deleteTemporaries
private function deleteTemporaries($directory) { if (is_dir($directory)) { $fileSystem = new Filesystem(); $fileSystem->deleteDirectory($directory, false); } $this->manifest = null; return true; }
php
private function deleteTemporaries($directory) { if (is_dir($directory)) { $fileSystem = new Filesystem(); $fileSystem->deleteDirectory($directory, false); } $this->manifest = null; return true; }
[ "private", "function", "deleteTemporaries", "(", "$", "directory", ")", "{", "if", "(", "is_dir", "(", "$", "directory", ")", ")", "{", "$", "fileSystem", "=", "new", "Filesystem", "(", ")", ";", "$", "fileSystem", "->", "deleteDirectory", "(", "$", "directory", ",", "false", ")", ";", "}", "$", "this", "->", "manifest", "=", "null", ";", "return", "true", ";", "}" ]
deletes temporary uploaded files @param String $directory @param String $filename @return boolean
[ "deletes", "temporary", "uploaded", "files" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Traits/PackageValidationTrait.php#L121-L129
228,044
antaresproject/core
src/foundation/src/Traits/PackageValidationTrait.php
PackageValidationTrait.failure
protected function failure($attribute, $message = null) { $this->deleteTemporaries($this->directory); $this->setCustomMessages([$attribute => trans($message)]); $this->addFailure($attribute, $attribute, []); return false; }
php
protected function failure($attribute, $message = null) { $this->deleteTemporaries($this->directory); $this->setCustomMessages([$attribute => trans($message)]); $this->addFailure($attribute, $attribute, []); return false; }
[ "protected", "function", "failure", "(", "$", "attribute", ",", "$", "message", "=", "null", ")", "{", "$", "this", "->", "deleteTemporaries", "(", "$", "this", "->", "directory", ")", ";", "$", "this", "->", "setCustomMessages", "(", "[", "$", "attribute", "=>", "trans", "(", "$", "message", ")", "]", ")", ";", "$", "this", "->", "addFailure", "(", "$", "attribute", ",", "$", "attribute", ",", "[", "]", ")", ";", "return", "false", ";", "}" ]
failure validation, add custom messages @param array | String $attribute @param String $message @return boolean
[ "failure", "validation", "add", "custom", "messages" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Traits/PackageValidationTrait.php#L148-L154
228,045
antaresproject/core
src/utils/form/src/Controls/CheckboxType.php
CheckboxType.setChecked
public function setChecked(bool $checked) { $this->value = $checked ? $this->getCheckedValue() : $this->getUncheckedValue(); return $this; }
php
public function setChecked(bool $checked) { $this->value = $checked ? $this->getCheckedValue() : $this->getUncheckedValue(); return $this; }
[ "public", "function", "setChecked", "(", "bool", "$", "checked", ")", "{", "$", "this", "->", "value", "=", "$", "checked", "?", "$", "this", "->", "getCheckedValue", "(", ")", ":", "$", "this", "->", "getUncheckedValue", "(", ")", ";", "return", "$", "this", ";", "}" ]
Checks or unchecks the checkbox @param bool $checked @return CheckboxType
[ "Checks", "or", "unchecks", "the", "checkbox" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/form/src/Controls/CheckboxType.php#L62-L66
228,046
antaresproject/core
src/foundation/src/Notifications/Variables/CoreVariablesProvider.php
CoreVariablesProvider.applyVariables
public function applyVariables(ModuleVariables $moduleVariables) : void { $moduleVariables ->modelDefinition('user', User::class, self::defaultUser()) ->setAttributes([ 'id' => 'ID', 'email' => 'Email', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'fullname' => 'Full Name', 'status' => 'Status', ]); $moduleVariables ->modelDefinition('brand', Brands::class, self::defaultBrand()) ->setAttributes([ 'id' => 'ID', 'name' => 'Name', 'status' => 'Status', ]); $moduleVariables->set('site.name', 'Site Name', function() { return memory('site.name'); }); $moduleVariables->set('time', 'Time', function() { return Carbon::now()->format('H:i'); }); $moduleVariables->set('date', 'Date', function() { return Carbon::now()->format('Y-m-d'); }); }
php
public function applyVariables(ModuleVariables $moduleVariables) : void { $moduleVariables ->modelDefinition('user', User::class, self::defaultUser()) ->setAttributes([ 'id' => 'ID', 'email' => 'Email', 'firstname' => 'First Name', 'lastname' => 'Last Name', 'fullname' => 'Full Name', 'status' => 'Status', ]); $moduleVariables ->modelDefinition('brand', Brands::class, self::defaultBrand()) ->setAttributes([ 'id' => 'ID', 'name' => 'Name', 'status' => 'Status', ]); $moduleVariables->set('site.name', 'Site Name', function() { return memory('site.name'); }); $moduleVariables->set('time', 'Time', function() { return Carbon::now()->format('H:i'); }); $moduleVariables->set('date', 'Date', function() { return Carbon::now()->format('Y-m-d'); }); }
[ "public", "function", "applyVariables", "(", "ModuleVariables", "$", "moduleVariables", ")", ":", "void", "{", "$", "moduleVariables", "->", "modelDefinition", "(", "'user'", ",", "User", "::", "class", ",", "self", "::", "defaultUser", "(", ")", ")", "->", "setAttributes", "(", "[", "'id'", "=>", "'ID'", ",", "'email'", "=>", "'Email'", ",", "'firstname'", "=>", "'First Name'", ",", "'lastname'", "=>", "'Last Name'", ",", "'fullname'", "=>", "'Full Name'", ",", "'status'", "=>", "'Status'", ",", "]", ")", ";", "$", "moduleVariables", "->", "modelDefinition", "(", "'brand'", ",", "Brands", "::", "class", ",", "self", "::", "defaultBrand", "(", ")", ")", "->", "setAttributes", "(", "[", "'id'", "=>", "'ID'", ",", "'name'", "=>", "'Name'", ",", "'status'", "=>", "'Status'", ",", "]", ")", ";", "$", "moduleVariables", "->", "set", "(", "'site.name'", ",", "'Site Name'", ",", "function", "(", ")", "{", "return", "memory", "(", "'site.name'", ")", ";", "}", ")", ";", "$", "moduleVariables", "->", "set", "(", "'time'", ",", "'Time'", ",", "function", "(", ")", "{", "return", "Carbon", "::", "now", "(", ")", "->", "format", "(", "'H:i'", ")", ";", "}", ")", ";", "$", "moduleVariables", "->", "set", "(", "'date'", ",", "'Date'", ",", "function", "(", ")", "{", "return", "Carbon", "::", "now", "(", ")", "->", "format", "(", "'Y-m-d'", ")", ";", "}", ")", ";", "}" ]
Applies the variables to the module container. @param ModuleVariables $moduleVariables
[ "Applies", "the", "variables", "to", "the", "module", "container", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Notifications/Variables/CoreVariablesProvider.php#L20-L51
228,047
antaresproject/core
src/components/html/src/HtmlServiceProvider.php
HtmlServiceProvider.registerAntaresFormBuilder
protected function registerAntaresFormBuilder() { $this->app->singleton('Antares\Contracts\Html\Form\Control', 'Antares\Html\Form\Control'); $this->app->singleton('Antares\Contracts\Html\Form\Template', function ($app) { $class = $app->make('config')->get('antares/html::form.presenter', 'Antares\Html\Form\BootstrapThreePresenter'); return $app->make($class); }); $this->app->singleton('antares.form', function ($app) { return new FormFactory($app); }); }
php
protected function registerAntaresFormBuilder() { $this->app->singleton('Antares\Contracts\Html\Form\Control', 'Antares\Html\Form\Control'); $this->app->singleton('Antares\Contracts\Html\Form\Template', function ($app) { $class = $app->make('config')->get('antares/html::form.presenter', 'Antares\Html\Form\BootstrapThreePresenter'); return $app->make($class); }); $this->app->singleton('antares.form', function ($app) { return new FormFactory($app); }); }
[ "protected", "function", "registerAntaresFormBuilder", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'Antares\\Contracts\\Html\\Form\\Control'", ",", "'Antares\\Html\\Form\\Control'", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'Antares\\Contracts\\Html\\Form\\Template'", ",", "function", "(", "$", "app", ")", "{", "$", "class", "=", "$", "app", "->", "make", "(", "'config'", ")", "->", "get", "(", "'antares/html::form.presenter'", ",", "'Antares\\Html\\Form\\BootstrapThreePresenter'", ")", ";", "return", "$", "app", "->", "make", "(", "$", "class", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'antares.form'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "FormFactory", "(", "$", "app", ")", ";", "}", ")", ";", "}" ]
Register the Antares\Form builder instance. @return void
[ "Register", "the", "Antares", "\\", "Form", "builder", "instance", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/HtmlServiceProvider.php#L104-L117
228,048
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.customfield
public function customfield($grid, $name) { if (!extension_active('customfields')) { return; } $category = strtolower(last(explode('\\', get_class($grid->row)))); $customfields = app('customfields')->get(); foreach ($customfields as $classname => $fields) { if (get_class($grid->row) !== $classname) { continue; } foreach ($fields as $field) { if ($field->getName() === $name) { return $this->addCustomfield($grid, $field); } } } $fieldView = \Antares\Customfields\Model\FieldView::query()->where([ 'name' => $name, 'brand_id' => brand_id(), 'category_name' => $category, 'imported' => 0])->first(); if (is_null($fieldView)) { return; } return $this->addCustomfield($grid, $fieldView); }
php
public function customfield($grid, $name) { if (!extension_active('customfields')) { return; } $category = strtolower(last(explode('\\', get_class($grid->row)))); $customfields = app('customfields')->get(); foreach ($customfields as $classname => $fields) { if (get_class($grid->row) !== $classname) { continue; } foreach ($fields as $field) { if ($field->getName() === $name) { return $this->addCustomfield($grid, $field); } } } $fieldView = \Antares\Customfields\Model\FieldView::query()->where([ 'name' => $name, 'brand_id' => brand_id(), 'category_name' => $category, 'imported' => 0])->first(); if (is_null($fieldView)) { return; } return $this->addCustomfield($grid, $fieldView); }
[ "public", "function", "customfield", "(", "$", "grid", ",", "$", "name", ")", "{", "if", "(", "!", "extension_active", "(", "'customfields'", ")", ")", "{", "return", ";", "}", "$", "category", "=", "strtolower", "(", "last", "(", "explode", "(", "'\\\\'", ",", "get_class", "(", "$", "grid", "->", "row", ")", ")", ")", ")", ";", "$", "customfields", "=", "app", "(", "'customfields'", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "customfields", "as", "$", "classname", "=>", "$", "fields", ")", "{", "if", "(", "get_class", "(", "$", "grid", "->", "row", ")", "!==", "$", "classname", ")", "{", "continue", ";", "}", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "$", "field", "->", "getName", "(", ")", "===", "$", "name", ")", "{", "return", "$", "this", "->", "addCustomfield", "(", "$", "grid", ",", "$", "field", ")", ";", "}", "}", "}", "$", "fieldView", "=", "\\", "Antares", "\\", "Customfields", "\\", "Model", "\\", "FieldView", "::", "query", "(", ")", "->", "where", "(", "[", "'name'", "=>", "$", "name", ",", "'brand_id'", "=>", "brand_id", "(", ")", ",", "'category_name'", "=>", "$", "category", ",", "'imported'", "=>", "0", "]", ")", "->", "first", "(", ")", ";", "if", "(", "is_null", "(", "$", "fieldView", ")", ")", "{", "return", ";", "}", "return", "$", "this", "->", "addCustomfield", "(", "$", "grid", ",", "$", "fieldView", ")", ";", "}" ]
Add customfield to form @param Grid $grid @param String $name
[ "Add", "customfield", "to", "form" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L217-L245
228,049
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.addCustomfield
protected function addCustomfield($grid, $field) { if (!$field instanceof \Antares\Customfield\CustomField) { $customfield = with(new \Antares\Customfield\CustomField())->attributes($field); } else { $customfield = $field; } $customfield->setModel($grid->row); $this->add($customfield); if (is_null($grid->rules)) { $grid->rules([]); } $grid->rules(array_merge($grid->rules, $customfield->getRules())); $grid->row->saved(function ($row) use ($customfield) { $customfield->onSave($row); }); }
php
protected function addCustomfield($grid, $field) { if (!$field instanceof \Antares\Customfield\CustomField) { $customfield = with(new \Antares\Customfield\CustomField())->attributes($field); } else { $customfield = $field; } $customfield->setModel($grid->row); $this->add($customfield); if (is_null($grid->rules)) { $grid->rules([]); } $grid->rules(array_merge($grid->rules, $customfield->getRules())); $grid->row->saved(function ($row) use ($customfield) { $customfield->onSave($row); }); }
[ "protected", "function", "addCustomfield", "(", "$", "grid", ",", "$", "field", ")", "{", "if", "(", "!", "$", "field", "instanceof", "\\", "Antares", "\\", "Customfield", "\\", "CustomField", ")", "{", "$", "customfield", "=", "with", "(", "new", "\\", "Antares", "\\", "Customfield", "\\", "CustomField", "(", ")", ")", "->", "attributes", "(", "$", "field", ")", ";", "}", "else", "{", "$", "customfield", "=", "$", "field", ";", "}", "$", "customfield", "->", "setModel", "(", "$", "grid", "->", "row", ")", ";", "$", "this", "->", "add", "(", "$", "customfield", ")", ";", "if", "(", "is_null", "(", "$", "grid", "->", "rules", ")", ")", "{", "$", "grid", "->", "rules", "(", "[", "]", ")", ";", "}", "$", "grid", "->", "rules", "(", "array_merge", "(", "$", "grid", "->", "rules", ",", "$", "customfield", "->", "getRules", "(", ")", ")", ")", ";", "$", "grid", "->", "row", "->", "saved", "(", "function", "(", "$", "row", ")", "use", "(", "$", "customfield", ")", "{", "$", "customfield", "->", "onSave", "(", "$", "row", ")", ";", "}", ")", ";", "}" ]
Add single customfield @param Grid $grid @param \Antares\Customfield\CustomField $field
[ "Add", "single", "customfield" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L253-L270
228,050
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.customfieldsByFieldset
public function customfieldsByFieldset($grid, $name) { if (!extension_active('customfields')) { return; } $customfields = app('customfields')->get(); $items = []; $reserved = []; foreach ($customfields as $classname => $fields) { if (get_class($grid->row) !== $classname) { continue; } foreach ($fields as $field) { if ($field->getFieldset() === $name) { $reserved[] = $field->getName(); $items[] = $field; } } } foreach ($items as $item) { $this->addCustomfield($grid, $item); } $query = \Antares\Customfields\Model\FieldView::query(); if (!empty($reserved)) { $query->whereNotIn('name', $reserved); } $fields = $query->whereHas('fieldFieldset', function ($query) use ($name) { $query->whereHas('fieldset', function ($subquery) use ($name) { $subquery->where('name', $name); }); })->get(); foreach ($fields as $field) { $this->addCustomfield($grid, $field); } return $this; }
php
public function customfieldsByFieldset($grid, $name) { if (!extension_active('customfields')) { return; } $customfields = app('customfields')->get(); $items = []; $reserved = []; foreach ($customfields as $classname => $fields) { if (get_class($grid->row) !== $classname) { continue; } foreach ($fields as $field) { if ($field->getFieldset() === $name) { $reserved[] = $field->getName(); $items[] = $field; } } } foreach ($items as $item) { $this->addCustomfield($grid, $item); } $query = \Antares\Customfields\Model\FieldView::query(); if (!empty($reserved)) { $query->whereNotIn('name', $reserved); } $fields = $query->whereHas('fieldFieldset', function ($query) use ($name) { $query->whereHas('fieldset', function ($subquery) use ($name) { $subquery->where('name', $name); }); })->get(); foreach ($fields as $field) { $this->addCustomfield($grid, $field); } return $this; }
[ "public", "function", "customfieldsByFieldset", "(", "$", "grid", ",", "$", "name", ")", "{", "if", "(", "!", "extension_active", "(", "'customfields'", ")", ")", "{", "return", ";", "}", "$", "customfields", "=", "app", "(", "'customfields'", ")", "->", "get", "(", ")", ";", "$", "items", "=", "[", "]", ";", "$", "reserved", "=", "[", "]", ";", "foreach", "(", "$", "customfields", "as", "$", "classname", "=>", "$", "fields", ")", "{", "if", "(", "get_class", "(", "$", "grid", "->", "row", ")", "!==", "$", "classname", ")", "{", "continue", ";", "}", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "$", "field", "->", "getFieldset", "(", ")", "===", "$", "name", ")", "{", "$", "reserved", "[", "]", "=", "$", "field", "->", "getName", "(", ")", ";", "$", "items", "[", "]", "=", "$", "field", ";", "}", "}", "}", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "this", "->", "addCustomfield", "(", "$", "grid", ",", "$", "item", ")", ";", "}", "$", "query", "=", "\\", "Antares", "\\", "Customfields", "\\", "Model", "\\", "FieldView", "::", "query", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "reserved", ")", ")", "{", "$", "query", "->", "whereNotIn", "(", "'name'", ",", "$", "reserved", ")", ";", "}", "$", "fields", "=", "$", "query", "->", "whereHas", "(", "'fieldFieldset'", ",", "function", "(", "$", "query", ")", "use", "(", "$", "name", ")", "{", "$", "query", "->", "whereHas", "(", "'fieldset'", ",", "function", "(", "$", "subquery", ")", "use", "(", "$", "name", ")", "{", "$", "subquery", "->", "where", "(", "'name'", ",", "$", "name", ")", ";", "}", ")", ";", "}", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "addCustomfield", "(", "$", "grid", ",", "$", "field", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds customfields by fieldset name @param Grid $grid @param String $name @return $this
[ "Adds", "customfields", "by", "fieldset", "name" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L279-L315
228,051
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.add
public function add(Field $control) { $renderable = $control instanceof \Illuminate\Contracts\Support\Renderable; $control->setField(function ($row, $cont, $templates) use ($control, $renderable) { $control = app(Control::class) ->setTemplates($this->control->getTemplates()) ->setPresenter($this->control->getPresenter()); $field = $control->buildFieldByType($cont->type, $row, $cont); $cont->setModel($row); if (($value = $cont->getValue()) !== false) { $field->value($value); } if ($renderable) { return $cont; } return $control->render([], $field); }); $this->controls[] = $control; return $this; }
php
public function add(Field $control) { $renderable = $control instanceof \Illuminate\Contracts\Support\Renderable; $control->setField(function ($row, $cont, $templates) use ($control, $renderable) { $control = app(Control::class) ->setTemplates($this->control->getTemplates()) ->setPresenter($this->control->getPresenter()); $field = $control->buildFieldByType($cont->type, $row, $cont); $cont->setModel($row); if (($value = $cont->getValue()) !== false) { $field->value($value); } if ($renderable) { return $cont; } return $control->render([], $field); }); $this->controls[] = $control; return $this; }
[ "public", "function", "add", "(", "Field", "$", "control", ")", "{", "$", "renderable", "=", "$", "control", "instanceof", "\\", "Illuminate", "\\", "Contracts", "\\", "Support", "\\", "Renderable", ";", "$", "control", "->", "setField", "(", "function", "(", "$", "row", ",", "$", "cont", ",", "$", "templates", ")", "use", "(", "$", "control", ",", "$", "renderable", ")", "{", "$", "control", "=", "app", "(", "Control", "::", "class", ")", "->", "setTemplates", "(", "$", "this", "->", "control", "->", "getTemplates", "(", ")", ")", "->", "setPresenter", "(", "$", "this", "->", "control", "->", "getPresenter", "(", ")", ")", ";", "$", "field", "=", "$", "control", "->", "buildFieldByType", "(", "$", "cont", "->", "type", ",", "$", "row", ",", "$", "cont", ")", ";", "$", "cont", "->", "setModel", "(", "$", "row", ")", ";", "if", "(", "(", "$", "value", "=", "$", "cont", "->", "getValue", "(", ")", ")", "!==", "false", ")", "{", "$", "field", "->", "value", "(", "$", "value", ")", ";", "}", "if", "(", "$", "renderable", ")", "{", "return", "$", "cont", ";", "}", "return", "$", "control", "->", "render", "(", "[", "]", ",", "$", "field", ")", ";", "}", ")", ";", "$", "this", "->", "controls", "[", "]", "=", "$", "control", ";", "return", "$", "this", ";", "}" ]
Add control to controls collection @param \Antares\Html\Form\Field $control @return $this
[ "Add", "control", "to", "controls", "collection" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L335-L361
228,052
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.detachControl
public function detachControl(FieldContract $control) { $name = $control->name; $value = $control->value; foreach ($this->controls as $index => $field) { if ($field->name == $name && $field->value == $value) { unset($this->controls[$index]); unset($this->keyMap[$name]); } } return $this; }
php
public function detachControl(FieldContract $control) { $name = $control->name; $value = $control->value; foreach ($this->controls as $index => $field) { if ($field->name == $name && $field->value == $value) { unset($this->controls[$index]); unset($this->keyMap[$name]); } } return $this; }
[ "public", "function", "detachControl", "(", "FieldContract", "$", "control", ")", "{", "$", "name", "=", "$", "control", "->", "name", ";", "$", "value", "=", "$", "control", "->", "value", ";", "foreach", "(", "$", "this", "->", "controls", "as", "$", "index", "=>", "$", "field", ")", "{", "if", "(", "$", "field", "->", "name", "==", "$", "name", "&&", "$", "field", "->", "value", "==", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "controls", "[", "$", "index", "]", ")", ";", "unset", "(", "$", "this", "->", "keyMap", "[", "$", "name", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Detaches control from controls collection @param FieldContract $control @return Fieldset
[ "Detaches", "control", "from", "controls", "collection" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L427-L438
228,053
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.field
public function field($name) { if (!isset($this->keyMap[$name])) { throw new Exception(sprintf('Unable to find %s named field.', $name)); } return $this->controls[$this->keyMap[$name]]; }
php
public function field($name) { if (!isset($this->keyMap[$name])) { throw new Exception(sprintf('Unable to find %s named field.', $name)); } return $this->controls[$this->keyMap[$name]]; }
[ "public", "function", "field", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "keyMap", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Unable to find %s named field.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "controls", "[", "$", "this", "->", "keyMap", "[", "$", "name", "]", "]", ";", "}" ]
gets field by name @param String $name @return Field @throws Exception
[ "gets", "field", "by", "name" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L470-L476
228,054
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.types
public function types($name) { $return = []; foreach ($this->controls as $control) { if ((method_exists($control, 'getType') ? $control->getType() : $control->type) == $name) { array_push($return, $control); } } return $return; }
php
public function types($name) { $return = []; foreach ($this->controls as $control) { if ((method_exists($control, 'getType') ? $control->getType() : $control->type) == $name) { array_push($return, $control); } } return $return; }
[ "public", "function", "types", "(", "$", "name", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "controls", "as", "$", "control", ")", "{", "if", "(", "(", "method_exists", "(", "$", "control", ",", "'getType'", ")", "?", "$", "control", "->", "getType", "(", ")", ":", "$", "control", "->", "type", ")", "==", "$", "name", ")", "{", "array_push", "(", "$", "return", ",", "$", "control", ")", ";", "}", "}", "return", "$", "return", ";", "}" ]
get control list by type @param String $name @return array
[ "get", "control", "list", "by", "type" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L484-L493
228,055
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.layout
public function layout($layout, $params = []) { $this->layout = $layout; $this->params = $params; return $this; }
php
public function layout($layout, $params = []) { $this->layout = $layout; $this->params = $params; return $this; }
[ "public", "function", "layout", "(", "$", "layout", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "layout", "=", "$", "layout", ";", "$", "this", "->", "params", "=", "$", "params", ";", "return", "$", "this", ";", "}" ]
fieldset layout setter @param String $layout @param array $params @return \Antares\Html\Form\Fieldset
[ "fieldset", "layout", "setter" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L513-L518
228,056
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.render
public function render($row = null) { if (is_null($this->layout)) { throw new Exception('Unable to render fieldset layout. Layout is empty.'); } $attributes = array_merge([ 'controls' => $this->controls, 'name' => $this->name, 'attributes' => $this->attributes, 'row' => $row, 'legend' => $this->legend], $this->params); return view($this->layout)->with($attributes); }
php
public function render($row = null) { if (is_null($this->layout)) { throw new Exception('Unable to render fieldset layout. Layout is empty.'); } $attributes = array_merge([ 'controls' => $this->controls, 'name' => $this->name, 'attributes' => $this->attributes, 'row' => $row, 'legend' => $this->legend], $this->params); return view($this->layout)->with($attributes); }
[ "public", "function", "render", "(", "$", "row", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "layout", ")", ")", "{", "throw", "new", "Exception", "(", "'Unable to render fieldset layout. Layout is empty.'", ")", ";", "}", "$", "attributes", "=", "array_merge", "(", "[", "'controls'", "=>", "$", "this", "->", "controls", ",", "'name'", "=>", "$", "this", "->", "name", ",", "'attributes'", "=>", "$", "this", "->", "attributes", ",", "'row'", "=>", "$", "row", ",", "'legend'", "=>", "$", "this", "->", "legend", "]", ",", "$", "this", "->", "params", ")", ";", "return", "view", "(", "$", "this", "->", "layout", ")", "->", "with", "(", "$", "attributes", ")", ";", "}" ]
renders custom fieldset view @return \Illuminate\View\View
[ "renders", "custom", "fieldset", "view" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L525-L538
228,057
antaresproject/core
src/components/html/src/Form/Fieldset.php
Fieldset.controls
public function controls() { $return = []; foreach ($this->controls as $control) { if (in_array((method_exists($control, 'getType') ? $control->getType() : $control->type), ['button', 'submit'] )) { continue; } array_push($return, $control); } return $return; }
php
public function controls() { $return = []; foreach ($this->controls as $control) { if (in_array((method_exists($control, 'getType') ? $control->getType() : $control->type), ['button', 'submit'] )) { continue; } array_push($return, $control); } return $return; }
[ "public", "function", "controls", "(", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "controls", "as", "$", "control", ")", "{", "if", "(", "in_array", "(", "(", "method_exists", "(", "$", "control", ",", "'getType'", ")", "?", "$", "control", "->", "getType", "(", ")", ":", "$", "control", "->", "type", ")", ",", "[", "'button'", ",", "'submit'", "]", ")", ")", "{", "continue", ";", "}", "array_push", "(", "$", "return", ",", "$", "control", ")", ";", "}", "return", "$", "return", ";", "}" ]
retrives all controls from fieldsets @return array
[ "retrives", "all", "controls", "from", "fieldsets" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Fieldset.php#L545-L556
228,058
antaresproject/core
src/components/memory/resources/database/migrations/2013_04_11_233631_antares_memory_create_schemas_table.php
AntaresMemoryCreateSchemasTable.createInstallationProgressTable
public function createInstallationProgressTable() { Schema::create('tbl_antares_installation', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->text('content')->nullable(); }); }
php
public function createInstallationProgressTable() { Schema::create('tbl_antares_installation', function (Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->text('content')->nullable(); }); }
[ "public", "function", "createInstallationProgressTable", "(", ")", "{", "Schema", "::", "create", "(", "'tbl_antares_installation'", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "increments", "(", "'id'", ")", ";", "$", "table", "->", "string", "(", "'name'", ")", "->", "unique", "(", ")", ";", "$", "table", "->", "text", "(", "'content'", ")", "->", "nullable", "(", ")", ";", "}", ")", ";", "}" ]
CREATE SCHEMAS FOR INSTALLATION PROGRESS
[ "CREATE", "SCHEMAS", "FOR", "INSTALLATION", "PROGRESS" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/resources/database/migrations/2013_04_11_233631_antares_memory_create_schemas_table.php#L258-L265
228,059
antaresproject/core
src/ui/base/src/Navigation/Menu.php
Menu.addItem
public function addItem(string $id, string $label, string $uri = null, string $icon = null, array $attributes = []): Menu { $attributes = Arr::except($attributes, ['label', 'uri']); $this->dispatcher->dispatch(new ItemAdding($id, $this->generateMenuItem($this->menuItem))); if ($icon && Str::startsWith($icon, 'zmdi-')) { $icon = 'zmdi ' . $icon; } if ($icon && !app('antares.request')->shouldMakeApiResponse()) { $label = sprintf('<i class="%s"></i> %s', $icon, $label); } $item = $this->menuItem->addChild($id, array_merge($attributes, [ 'label' => $label, 'uri' => $uri, 'icon' => $icon, ])); $item->setAttributes(array_merge($attributes, ['icon' => $icon])); $item->setExtra('safe_label', true); $this->dispatcher->dispatch(new ItemAdded($id, $this->generateMenuItem($this->menuItem))); return $this; }
php
public function addItem(string $id, string $label, string $uri = null, string $icon = null, array $attributes = []): Menu { $attributes = Arr::except($attributes, ['label', 'uri']); $this->dispatcher->dispatch(new ItemAdding($id, $this->generateMenuItem($this->menuItem))); if ($icon && Str::startsWith($icon, 'zmdi-')) { $icon = 'zmdi ' . $icon; } if ($icon && !app('antares.request')->shouldMakeApiResponse()) { $label = sprintf('<i class="%s"></i> %s', $icon, $label); } $item = $this->menuItem->addChild($id, array_merge($attributes, [ 'label' => $label, 'uri' => $uri, 'icon' => $icon, ])); $item->setAttributes(array_merge($attributes, ['icon' => $icon])); $item->setExtra('safe_label', true); $this->dispatcher->dispatch(new ItemAdded($id, $this->generateMenuItem($this->menuItem))); return $this; }
[ "public", "function", "addItem", "(", "string", "$", "id", ",", "string", "$", "label", ",", "string", "$", "uri", "=", "null", ",", "string", "$", "icon", "=", "null", ",", "array", "$", "attributes", "=", "[", "]", ")", ":", "Menu", "{", "$", "attributes", "=", "Arr", "::", "except", "(", "$", "attributes", ",", "[", "'label'", ",", "'uri'", "]", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "new", "ItemAdding", "(", "$", "id", ",", "$", "this", "->", "generateMenuItem", "(", "$", "this", "->", "menuItem", ")", ")", ")", ";", "if", "(", "$", "icon", "&&", "Str", "::", "startsWith", "(", "$", "icon", ",", "'zmdi-'", ")", ")", "{", "$", "icon", "=", "'zmdi '", ".", "$", "icon", ";", "}", "if", "(", "$", "icon", "&&", "!", "app", "(", "'antares.request'", ")", "->", "shouldMakeApiResponse", "(", ")", ")", "{", "$", "label", "=", "sprintf", "(", "'<i class=\"%s\"></i> %s'", ",", "$", "icon", ",", "$", "label", ")", ";", "}", "$", "item", "=", "$", "this", "->", "menuItem", "->", "addChild", "(", "$", "id", ",", "array_merge", "(", "$", "attributes", ",", "[", "'label'", "=>", "$", "label", ",", "'uri'", "=>", "$", "uri", ",", "'icon'", "=>", "$", "icon", ",", "]", ")", ")", ";", "$", "item", "->", "setAttributes", "(", "array_merge", "(", "$", "attributes", ",", "[", "'icon'", "=>", "$", "icon", "]", ")", ")", ";", "$", "item", "->", "setExtra", "(", "'safe_label'", ",", "true", ")", ";", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "new", "ItemAdded", "(", "$", "id", ",", "$", "this", "->", "generateMenuItem", "(", "$", "this", "->", "menuItem", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Add a new item to the menu. @param string $id @param string $label @param null|string $uri @param null|string $icon @param array $attributes @return Menu
[ "Add", "a", "new", "item", "to", "the", "menu", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/base/src/Navigation/Menu.php#L83-L108
228,060
antaresproject/core
src/ui/base/src/Navigation/Menu.php
Menu.getChild
public function getChild(string $id) { $menuItem = $this->menuItem->getChild($id); return $menuItem ? $this->generateMenuItem($menuItem) : null; }
php
public function getChild(string $id) { $menuItem = $this->menuItem->getChild($id); return $menuItem ? $this->generateMenuItem($menuItem) : null; }
[ "public", "function", "getChild", "(", "string", "$", "id", ")", "{", "$", "menuItem", "=", "$", "this", "->", "menuItem", "->", "getChild", "(", "$", "id", ")", ";", "return", "$", "menuItem", "?", "$", "this", "->", "generateMenuItem", "(", "$", "menuItem", ")", ":", "null", ";", "}" ]
Returns submenu by the given item ID. @param string $id @return Menu|null
[ "Returns", "submenu", "by", "the", "given", "item", "ID", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/base/src/Navigation/Menu.php#L116-L121
228,061
antaresproject/core
src/ui/base/src/Navigation/Menu.php
Menu.generateMenuItem
protected function generateMenuItem(ItemInterface $menuItem): Menu { return new Menu($menuItem, $this->dispatcher, $this->renderer); }
php
protected function generateMenuItem(ItemInterface $menuItem): Menu { return new Menu($menuItem, $this->dispatcher, $this->renderer); }
[ "protected", "function", "generateMenuItem", "(", "ItemInterface", "$", "menuItem", ")", ":", "Menu", "{", "return", "new", "Menu", "(", "$", "menuItem", ",", "$", "this", "->", "dispatcher", ",", "$", "this", "->", "renderer", ")", ";", "}" ]
Returns menu item wrapped by menu object. @param ItemInterface $menuItem @return Menu
[ "Returns", "menu", "item", "wrapped", "by", "menu", "object", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/base/src/Navigation/Menu.php#L139-L142
228,062
lawoole/framework
src/Foundation/Bootstrap/LoadConfigurations.php
LoadConfigurations.loadEnvironmentConfigurations
public function loadEnvironmentConfigurations($app, RepositoryContract $repository) { $configPath = realpath($app->environmentPath()); $files = $this->getConfigurationFilesInPath($configPath); foreach ($files as $scope => $path) { $items = require $path; foreach ($items as $key => $value) { $key = "{$scope}.{$key}"; // We can use a Closure as the value, and it will be called with // the default configuration item. It useful for replace configurations // defined as array or other complex form. if ($value instanceof Closure) { $value = $value($repository->get($key), $app); } // We can specify a deep-level configuration item using the dot in key, // and just to change the item. $repository->set($key, $value); } } }
php
public function loadEnvironmentConfigurations($app, RepositoryContract $repository) { $configPath = realpath($app->environmentPath()); $files = $this->getConfigurationFilesInPath($configPath); foreach ($files as $scope => $path) { $items = require $path; foreach ($items as $key => $value) { $key = "{$scope}.{$key}"; // We can use a Closure as the value, and it will be called with // the default configuration item. It useful for replace configurations // defined as array or other complex form. if ($value instanceof Closure) { $value = $value($repository->get($key), $app); } // We can specify a deep-level configuration item using the dot in key, // and just to change the item. $repository->set($key, $value); } } }
[ "public", "function", "loadEnvironmentConfigurations", "(", "$", "app", ",", "RepositoryContract", "$", "repository", ")", "{", "$", "configPath", "=", "realpath", "(", "$", "app", "->", "environmentPath", "(", ")", ")", ";", "$", "files", "=", "$", "this", "->", "getConfigurationFilesInPath", "(", "$", "configPath", ")", ";", "foreach", "(", "$", "files", "as", "$", "scope", "=>", "$", "path", ")", "{", "$", "items", "=", "require", "$", "path", ";", "foreach", "(", "$", "items", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "\"{$scope}.{$key}\"", ";", "// We can use a Closure as the value, and it will be called with", "// the default configuration item. It useful for replace configurations", "// defined as array or other complex form.", "if", "(", "$", "value", "instanceof", "Closure", ")", "{", "$", "value", "=", "$", "value", "(", "$", "repository", "->", "get", "(", "$", "key", ")", ",", "$", "app", ")", ";", "}", "// We can specify a deep-level configuration item using the dot in key,", "// and just to change the item.", "$", "repository", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "}" ]
Load the environment configuration items. @param \Illuminate\Contracts\Foundation\Application $app @param \Illuminate\Contracts\Config\Repository $repository
[ "Load", "the", "environment", "configuration", "items", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Bootstrap/LoadConfigurations.php#L40-L64
228,063
lawoole/framework
src/Foundation/Bootstrap/LoadConfigurations.php
LoadConfigurations.getConfigurationFilesInPath
protected function getConfigurationFilesInPath($configPath) { $files = []; if (! is_dir($configPath)) { return $files; } foreach (Finder::create()->files()->name('*.php')->depth(0)->in($configPath) as $file) { $files[$file->getBasename('.php')] = $file->getRealPath(); } ksort($files, SORT_NATURAL); return $files; }
php
protected function getConfigurationFilesInPath($configPath) { $files = []; if (! is_dir($configPath)) { return $files; } foreach (Finder::create()->files()->name('*.php')->depth(0)->in($configPath) as $file) { $files[$file->getBasename('.php')] = $file->getRealPath(); } ksort($files, SORT_NATURAL); return $files; }
[ "protected", "function", "getConfigurationFilesInPath", "(", "$", "configPath", ")", "{", "$", "files", "=", "[", "]", ";", "if", "(", "!", "is_dir", "(", "$", "configPath", ")", ")", "{", "return", "$", "files", ";", "}", "foreach", "(", "Finder", "::", "create", "(", ")", "->", "files", "(", ")", "->", "name", "(", "'*.php'", ")", "->", "depth", "(", "0", ")", "->", "in", "(", "$", "configPath", ")", "as", "$", "file", ")", "{", "$", "files", "[", "$", "file", "->", "getBasename", "(", "'.php'", ")", "]", "=", "$", "file", "->", "getRealPath", "(", ")", ";", "}", "ksort", "(", "$", "files", ",", "SORT_NATURAL", ")", ";", "return", "$", "files", ";", "}" ]
Get all of the configuration files in the given directory. @param $configPath @return array
[ "Get", "all", "of", "the", "configuration", "files", "in", "the", "given", "directory", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Bootstrap/LoadConfigurations.php#L83-L98
228,064
antaresproject/core
src/components/model/src/Value/Meta.php
Meta.put
public function put($key, $value = '') { Arr::set($this->attributes, $key, $value); return $this; }
php
public function put($key, $value = '') { Arr::set($this->attributes, $key, $value); return $this; }
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", "=", "''", ")", "{", "Arr", "::", "set", "(", "$", "this", "->", "attributes", ",", "$", "key", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set a value from a key. @param string $key A string of key to add the value. @param mixed $value The value. @return $this
[ "Set", "a", "value", "from", "a", "key", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Value/Meta.php#L49-L54
228,065
antaresproject/core
src/components/model/src/Role.php
Role.getLowerRoles
protected function getLowerRoles(array $elements, $parentId = 0, &$return = []) { foreach ($elements as $element) { if ($element['parent_id'] != $parentId) { continue; } $children = $this->getLowerRoles($elements, $element['id'], $return); if ($children) { foreach ($children as $child) { $return[] = $child['id']; } } $return[] = $element['id']; } return array_filter($return); }
php
protected function getLowerRoles(array $elements, $parentId = 0, &$return = []) { foreach ($elements as $element) { if ($element['parent_id'] != $parentId) { continue; } $children = $this->getLowerRoles($elements, $element['id'], $return); if ($children) { foreach ($children as $child) { $return[] = $child['id']; } } $return[] = $element['id']; } return array_filter($return); }
[ "protected", "function", "getLowerRoles", "(", "array", "$", "elements", ",", "$", "parentId", "=", "0", ",", "&", "$", "return", "=", "[", "]", ")", "{", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "if", "(", "$", "element", "[", "'parent_id'", "]", "!=", "$", "parentId", ")", "{", "continue", ";", "}", "$", "children", "=", "$", "this", "->", "getLowerRoles", "(", "$", "elements", ",", "$", "element", "[", "'id'", "]", ",", "$", "return", ")", ";", "if", "(", "$", "children", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "return", "[", "]", "=", "$", "child", "[", "'id'", "]", ";", "}", "}", "$", "return", "[", "]", "=", "$", "element", "[", "'id'", "]", ";", "}", "return", "array_filter", "(", "$", "return", ")", ";", "}" ]
builds recursive widgets stack @param array $elements @param mixed $parentId @return array
[ "builds", "recursive", "widgets", "stack" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Role.php#L191-L207
228,066
antaresproject/core
src/components/model/src/Role.php
Role.getChilds
public function getChilds($withOwnRole = false) { $id = $this->id; $roles = $this->withTrashed()->orderby('parent_id')->get()->toArray(); $lowerRoles = $this->getLowerRoles($roles, $id); return ($withOwnRole) ? array_merge([$this->id], $lowerRoles) : $lowerRoles; }
php
public function getChilds($withOwnRole = false) { $id = $this->id; $roles = $this->withTrashed()->orderby('parent_id')->get()->toArray(); $lowerRoles = $this->getLowerRoles($roles, $id); return ($withOwnRole) ? array_merge([$this->id], $lowerRoles) : $lowerRoles; }
[ "public", "function", "getChilds", "(", "$", "withOwnRole", "=", "false", ")", "{", "$", "id", "=", "$", "this", "->", "id", ";", "$", "roles", "=", "$", "this", "->", "withTrashed", "(", ")", "->", "orderby", "(", "'parent_id'", ")", "->", "get", "(", ")", "->", "toArray", "(", ")", ";", "$", "lowerRoles", "=", "$", "this", "->", "getLowerRoles", "(", "$", "roles", ",", "$", "id", ")", ";", "return", "(", "$", "withOwnRole", ")", "?", "array_merge", "(", "[", "$", "this", "->", "id", "]", ",", "$", "lowerRoles", ")", ":", "$", "lowerRoles", ";", "}" ]
Gets child roles @param boolean $withOwnRole @return array
[ "Gets", "child", "roles" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Role.php#L215-L221
228,067
marmelab/SonataElasticaBundle
Model/ElasticaModelManager.php
ElasticaModelManager.getNormalizedIdentifier
public function getNormalizedIdentifier($model) { $identifier = $this->baseModelManager->getNormalizedIdentifier($model); if ($identifier === null) { $identifierName = is_array($this->getModelIdentifier(get_class($model))) ? current($this->getModelIdentifier(get_class($model))) : $this->getModelIdentifier(get_class($model)); return $model->{'get'.ucfirst($identifierName)}(); } return $identifier; }
php
public function getNormalizedIdentifier($model) { $identifier = $this->baseModelManager->getNormalizedIdentifier($model); if ($identifier === null) { $identifierName = is_array($this->getModelIdentifier(get_class($model))) ? current($this->getModelIdentifier(get_class($model))) : $this->getModelIdentifier(get_class($model)); return $model->{'get'.ucfirst($identifierName)}(); } return $identifier; }
[ "public", "function", "getNormalizedIdentifier", "(", "$", "model", ")", "{", "$", "identifier", "=", "$", "this", "->", "baseModelManager", "->", "getNormalizedIdentifier", "(", "$", "model", ")", ";", "if", "(", "$", "identifier", "===", "null", ")", "{", "$", "identifierName", "=", "is_array", "(", "$", "this", "->", "getModelIdentifier", "(", "get_class", "(", "$", "model", ")", ")", ")", "?", "current", "(", "$", "this", "->", "getModelIdentifier", "(", "get_class", "(", "$", "model", ")", ")", ")", ":", "$", "this", "->", "getModelIdentifier", "(", "get_class", "(", "$", "model", ")", ")", ";", "return", "$", "model", "->", "{", "'get'", ".", "ucfirst", "(", "$", "identifierName", ")", "}", "(", ")", ";", "}", "return", "$", "identifier", ";", "}" ]
Get the identifiers for this model class as a string. @param object $model @return string a string representation of the identifiers for this instance
[ "Get", "the", "identifiers", "for", "this", "model", "class", "as", "a", "string", "." ]
7b8a2fde72bca7844060fcae6387641478fe7bdc
https://github.com/marmelab/SonataElasticaBundle/blob/7b8a2fde72bca7844060fcae6387641478fe7bdc/Model/ElasticaModelManager.php#L215-L226
228,068
marmelab/SonataElasticaBundle
Model/ElasticaModelManager.php
ElasticaModelManager.getSortParameters
public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid) { return $this->baseModelManager->getSortParameters($fieldDescription, $datagrid); }
php
public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid) { return $this->baseModelManager->getSortParameters($fieldDescription, $datagrid); }
[ "public", "function", "getSortParameters", "(", "FieldDescriptionInterface", "$", "fieldDescription", ",", "DatagridInterface", "$", "datagrid", ")", "{", "return", "$", "this", "->", "baseModelManager", "->", "getSortParameters", "(", "$", "fieldDescription", ",", "$", "datagrid", ")", ";", "}" ]
Returns the parameters used in the columns header @param FieldDescriptionInterface $fieldDescription @param DatagridInterface $datagrid @return array
[ "Returns", "the", "parameters", "used", "in", "the", "columns", "header" ]
7b8a2fde72bca7844060fcae6387641478fe7bdc
https://github.com/marmelab/SonataElasticaBundle/blob/7b8a2fde72bca7844060fcae6387641478fe7bdc/Model/ElasticaModelManager.php#L324-L327
228,069
antaresproject/core
src/ui/components/datatables/src/Datatables.php
Datatables.of
public static function of($builder, $classname = null) { $datatables = app(Datatables::class); $datatables->builder = $builder; $engine = ($builder instanceof QueryBuilder) ? $datatables->usingQueryBuilder($builder) : ($builder instanceof Collection ? $datatables->usingCollection($builder) : $datatables->usingEloquent($builder)); $engine->setCalledClass($classname); return $engine; }
php
public static function of($builder, $classname = null) { $datatables = app(Datatables::class); $datatables->builder = $builder; $engine = ($builder instanceof QueryBuilder) ? $datatables->usingQueryBuilder($builder) : ($builder instanceof Collection ? $datatables->usingCollection($builder) : $datatables->usingEloquent($builder)); $engine->setCalledClass($classname); return $engine; }
[ "public", "static", "function", "of", "(", "$", "builder", ",", "$", "classname", "=", "null", ")", "{", "$", "datatables", "=", "app", "(", "Datatables", "::", "class", ")", ";", "$", "datatables", "->", "builder", "=", "$", "builder", ";", "$", "engine", "=", "(", "$", "builder", "instanceof", "QueryBuilder", ")", "?", "$", "datatables", "->", "usingQueryBuilder", "(", "$", "builder", ")", ":", "(", "$", "builder", "instanceof", "Collection", "?", "$", "datatables", "->", "usingCollection", "(", "$", "builder", ")", ":", "$", "datatables", "->", "usingEloquent", "(", "$", "builder", ")", ")", ";", "$", "engine", "->", "setCalledClass", "(", "$", "classname", ")", ";", "return", "$", "engine", ";", "}" ]
Gets query and returns instance of class. @param mixed $builder @param String $classname @return mixed
[ "Gets", "query", "and", "returns", "instance", "of", "class", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Datatables.php#L64-L71
228,070
antaresproject/core
src/components/model/src/User.php
User.getIsActiveAttribute
public function getIsActiveAttribute() { try { $activity = $this->activity; $lastActivity = ($activity instanceof UserActivity) ? $activity->last_activity : null; $laDate = Carbon::createFromFormat('Y-m-d H:i:s', $lastActivity); return !(Carbon::now()->diffInSeconds($laDate) >= config('antares/users::check_activity_every')); } catch (\Exception $e) { return false; } }
php
public function getIsActiveAttribute() { try { $activity = $this->activity; $lastActivity = ($activity instanceof UserActivity) ? $activity->last_activity : null; $laDate = Carbon::createFromFormat('Y-m-d H:i:s', $lastActivity); return !(Carbon::now()->diffInSeconds($laDate) >= config('antares/users::check_activity_every')); } catch (\Exception $e) { return false; } }
[ "public", "function", "getIsActiveAttribute", "(", ")", "{", "try", "{", "$", "activity", "=", "$", "this", "->", "activity", ";", "$", "lastActivity", "=", "(", "$", "activity", "instanceof", "UserActivity", ")", "?", "$", "activity", "->", "last_activity", ":", "null", ";", "$", "laDate", "=", "Carbon", "::", "createFromFormat", "(", "'Y-m-d H:i:s'", ",", "$", "lastActivity", ")", ";", "return", "!", "(", "Carbon", "::", "now", "(", ")", "->", "diffInSeconds", "(", "$", "laDate", ")", ">=", "config", "(", "'antares/users::check_activity_every'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Check wheter this user is currently active @return bool
[ "Check", "wheter", "this", "user", "is", "currently", "active" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/User.php#L292-L302
228,071
antaresproject/core
src/components/model/src/User.php
User.getLastActivityAttribute
public function getLastActivityAttribute() { $activity = $this->activity; return ($activity instanceof UserActivity) ? Carbon::createFromFormat('Y-m-d H:i:s', $activity->last_activity) : null; }
php
public function getLastActivityAttribute() { $activity = $this->activity; return ($activity instanceof UserActivity) ? Carbon::createFromFormat('Y-m-d H:i:s', $activity->last_activity) : null; }
[ "public", "function", "getLastActivityAttribute", "(", ")", "{", "$", "activity", "=", "$", "this", "->", "activity", ";", "return", "(", "$", "activity", "instanceof", "UserActivity", ")", "?", "Carbon", "::", "createFromFormat", "(", "'Y-m-d H:i:s'", ",", "$", "activity", "->", "last_activity", ")", ":", "null", ";", "}" ]
Get last dateTime of last activity of this user @return null|Carbon
[ "Get", "last", "dateTime", "of", "last", "activity", "of", "this", "user" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/User.php#L321-L326
228,072
antaresproject/core
src/components/model/src/User.php
User.getFullnameAttribute
public function getFullnameAttribute($value) { if (!strlen($this->firstname) and ! strlen($this->lastname)) { return '---'; } return $this->firstname . ' ' . $this->lastname; }
php
public function getFullnameAttribute($value) { if (!strlen($this->firstname) and ! strlen($this->lastname)) { return '---'; } return $this->firstname . ' ' . $this->lastname; }
[ "public", "function", "getFullnameAttribute", "(", "$", "value", ")", "{", "if", "(", "!", "strlen", "(", "$", "this", "->", "firstname", ")", "and", "!", "strlen", "(", "$", "this", "->", "lastname", ")", ")", "{", "return", "'---'", ";", "}", "return", "$", "this", "->", "firstname", ".", "' '", ".", "$", "this", "->", "lastname", ";", "}" ]
Get the user's fullname @param string $value @return string
[ "Get", "the", "user", "s", "fullname" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/User.php#L568-L574
228,073
antaresproject/core
src/components/model/src/User.php
User.getLastLoggedAtAttribute
public function getLastLoggedAtAttribute() { $lastLogin = Logs::where('user_id', $this->id) ->where('name', 'like', 'USERAUTHLISTENER_ONUSERLOGIN') ->orderBy('created_at', 'desc') ->get(['created_at']) ->first(); return ($lastLogin) ? $lastLogin->created_at->diffForHumans() : 'never'; }
php
public function getLastLoggedAtAttribute() { $lastLogin = Logs::where('user_id', $this->id) ->where('name', 'like', 'USERAUTHLISTENER_ONUSERLOGIN') ->orderBy('created_at', 'desc') ->get(['created_at']) ->first(); return ($lastLogin) ? $lastLogin->created_at->diffForHumans() : 'never'; }
[ "public", "function", "getLastLoggedAtAttribute", "(", ")", "{", "$", "lastLogin", "=", "Logs", "::", "where", "(", "'user_id'", ",", "$", "this", "->", "id", ")", "->", "where", "(", "'name'", ",", "'like'", ",", "'USERAUTHLISTENER_ONUSERLOGIN'", ")", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", "->", "get", "(", "[", "'created_at'", "]", ")", "->", "first", "(", ")", ";", "return", "(", "$", "lastLogin", ")", "?", "$", "lastLogin", "->", "created_at", "->", "diffForHumans", "(", ")", ":", "'never'", ";", "}" ]
Getting last logged attribute @return String
[ "Getting", "last", "logged", "attribute" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/User.php#L591-L600
228,074
antaresproject/core
src/components/model/src/User.php
User.getChildAreas
public function getChildAreas() { return $this->roles()->getModel()->newQuery()->select(['area'])->whereIn('id', $this->roles->first() ->getChilds()) ->groupBy('area') ->whereNotNull('area') ->pluck('area')->toArray(); }
php
public function getChildAreas() { return $this->roles()->getModel()->newQuery()->select(['area'])->whereIn('id', $this->roles->first() ->getChilds()) ->groupBy('area') ->whereNotNull('area') ->pluck('area')->toArray(); }
[ "public", "function", "getChildAreas", "(", ")", "{", "return", "$", "this", "->", "roles", "(", ")", "->", "getModel", "(", ")", "->", "newQuery", "(", ")", "->", "select", "(", "[", "'area'", "]", ")", "->", "whereIn", "(", "'id'", ",", "$", "this", "->", "roles", "->", "first", "(", ")", "->", "getChilds", "(", ")", ")", "->", "groupBy", "(", "'area'", ")", "->", "whereNotNull", "(", "'area'", ")", "->", "pluck", "(", "'area'", ")", "->", "toArray", "(", ")", ";", "}" ]
Gets user child areas @return array
[ "Gets", "user", "child", "areas" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/User.php#L618-L625
228,075
gggeek/ggwebservices
classes/ggjsonrpcresponse.php
ggJSONRPCResponse.payload
function payload() { if ( $this->IsFault ) { return json_encode( array( 'result' => null, 'error' => array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString ), 'id' => $this->Id ) ); } else { return json_encode( array( 'result' => $this->Value, 'error' => null, 'id' => $this->Id ) ); } }
php
function payload() { if ( $this->IsFault ) { return json_encode( array( 'result' => null, 'error' => array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString ), 'id' => $this->Id ) ); } else { return json_encode( array( 'result' => $this->Value, 'error' => null, 'id' => $this->Id ) ); } }
[ "function", "payload", "(", ")", "{", "if", "(", "$", "this", "->", "IsFault", ")", "{", "return", "json_encode", "(", "array", "(", "'result'", "=>", "null", ",", "'error'", "=>", "array", "(", "'faultCode'", "=>", "$", "this", "->", "FaultCode", ",", "'faultString'", "=>", "$", "this", "->", "FaultString", ")", ",", "'id'", "=>", "$", "this", "->", "Id", ")", ")", ";", "}", "else", "{", "return", "json_encode", "(", "array", "(", "'result'", "=>", "$", "this", "->", "Value", ",", "'error'", "=>", "null", ",", "'id'", "=>", "$", "this", "->", "Id", ")", ")", ";", "}", "}" ]
Returns the json payload for the response.
[ "Returns", "the", "json", "payload", "for", "the", "response", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggjsonrpcresponse.php#L21-L37
228,076
gggeek/ggwebservices
classes/ggjsonrpcresponse.php
ggJSONRPCResponse.decodeStream
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" ) { $this->decodeStreamCommon( $request, $stream, $headers, $cookies, $statuscode ); /// @todo refuse bad content-types? $results = json_decode( $stream, true ); if ( !is_array($results) || !array_key_exists( 'result', $results ) || !array_key_exists( 'error', $results ) || !array_key_exists( 'id', $results ) ) { // invalid jsonrpc response $this->IsFault = true; $this->FaultCode = self::INVALIDRESPONSEERROR; $this->FaultString = self::INVALIDRESPONSESTRING; } else { $this->Id = $results['id']; /// we should check if id of response is same as id of request, and raise error if not if ( $results['id'] != $request->id() ) { $this->IsFault = true; $this->FaultCode = self::INVALIDIDERROR; $this->FaultString = self::INVALIDIDSTRING; } else if ( $results['error'] === null ) { /// NB: spec is formally strange: what if both error and result are null??? $this->Value = $results['result']; } else { $this->IsFault = true; $error = $results['error']; if ( is_array( $error ) && array_key_exists( 'faultCode', $error ) && array_key_exists( 'faultString', $error ) ) { // since server conforms to our error syntax, we force the types on him, too $this->FaultCode = (int)$error['faultCode']; $this->FaultString = (string)$error['faultString']; } else { $this->FaultCode = self::GENERICRESPONSEERROR; /// @todo we should somehow typecast to string here??? maybe reencode as json? $this->FaultString = $results['error']; } } } }
php
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" ) { $this->decodeStreamCommon( $request, $stream, $headers, $cookies, $statuscode ); /// @todo refuse bad content-types? $results = json_decode( $stream, true ); if ( !is_array($results) || !array_key_exists( 'result', $results ) || !array_key_exists( 'error', $results ) || !array_key_exists( 'id', $results ) ) { // invalid jsonrpc response $this->IsFault = true; $this->FaultCode = self::INVALIDRESPONSEERROR; $this->FaultString = self::INVALIDRESPONSESTRING; } else { $this->Id = $results['id']; /// we should check if id of response is same as id of request, and raise error if not if ( $results['id'] != $request->id() ) { $this->IsFault = true; $this->FaultCode = self::INVALIDIDERROR; $this->FaultString = self::INVALIDIDSTRING; } else if ( $results['error'] === null ) { /// NB: spec is formally strange: what if both error and result are null??? $this->Value = $results['result']; } else { $this->IsFault = true; $error = $results['error']; if ( is_array( $error ) && array_key_exists( 'faultCode', $error ) && array_key_exists( 'faultString', $error ) ) { // since server conforms to our error syntax, we force the types on him, too $this->FaultCode = (int)$error['faultCode']; $this->FaultString = (string)$error['faultString']; } else { $this->FaultCode = self::GENERICRESPONSEERROR; /// @todo we should somehow typecast to string here??? maybe reencode as json? $this->FaultString = $results['error']; } } } }
[ "function", "decodeStream", "(", "$", "request", ",", "$", "stream", ",", "$", "headers", "=", "false", ",", "$", "cookies", "=", "array", "(", ")", ",", "$", "statuscode", "=", "\"200\"", ")", "{", "$", "this", "->", "decodeStreamCommon", "(", "$", "request", ",", "$", "stream", ",", "$", "headers", ",", "$", "cookies", ",", "$", "statuscode", ")", ";", "/// @todo refuse bad content-types?", "$", "results", "=", "json_decode", "(", "$", "stream", ",", "true", ")", ";", "if", "(", "!", "is_array", "(", "$", "results", ")", "||", "!", "array_key_exists", "(", "'result'", ",", "$", "results", ")", "||", "!", "array_key_exists", "(", "'error'", ",", "$", "results", ")", "||", "!", "array_key_exists", "(", "'id'", ",", "$", "results", ")", ")", "{", "// invalid jsonrpc response", "$", "this", "->", "IsFault", "=", "true", ";", "$", "this", "->", "FaultCode", "=", "self", "::", "INVALIDRESPONSEERROR", ";", "$", "this", "->", "FaultString", "=", "self", "::", "INVALIDRESPONSESTRING", ";", "}", "else", "{", "$", "this", "->", "Id", "=", "$", "results", "[", "'id'", "]", ";", "/// we should check if id of response is same as id of request, and raise error if not", "if", "(", "$", "results", "[", "'id'", "]", "!=", "$", "request", "->", "id", "(", ")", ")", "{", "$", "this", "->", "IsFault", "=", "true", ";", "$", "this", "->", "FaultCode", "=", "self", "::", "INVALIDIDERROR", ";", "$", "this", "->", "FaultString", "=", "self", "::", "INVALIDIDSTRING", ";", "}", "else", "if", "(", "$", "results", "[", "'error'", "]", "===", "null", ")", "{", "/// NB: spec is formally strange: what if both error and result are null???", "$", "this", "->", "Value", "=", "$", "results", "[", "'result'", "]", ";", "}", "else", "{", "$", "this", "->", "IsFault", "=", "true", ";", "$", "error", "=", "$", "results", "[", "'error'", "]", ";", "if", "(", "is_array", "(", "$", "error", ")", "&&", "array_key_exists", "(", "'faultCode'", ",", "$", "error", ")", "&&", "array_key_exists", "(", "'faultString'", ",", "$", "error", ")", ")", "{", "// since server conforms to our error syntax, we force the types on him, too", "$", "this", "->", "FaultCode", "=", "(", "int", ")", "$", "error", "[", "'faultCode'", "]", ";", "$", "this", "->", "FaultString", "=", "(", "string", ")", "$", "error", "[", "'faultString'", "]", ";", "}", "else", "{", "$", "this", "->", "FaultCode", "=", "self", "::", "GENERICRESPONSEERROR", ";", "/// @todo we should somehow typecast to string here??? maybe reencode as json?", "$", "this", "->", "FaultString", "=", "$", "results", "[", "'error'", "]", ";", "}", "}", "}", "}" ]
Decodes the JSONRPC response stream. Request is used for matching id. @todo Name is not set to response from request - a bit weird... @param ggJSONRPCRequest $request
[ "Decodes", "the", "JSONRPC", "response", "stream", ".", "Request", "is", "used", "for", "matching", "id", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggjsonrpcresponse.php#L45-L98
228,077
antaresproject/customfields
src/Events/ProcessorHandler.php
ProcessorHandler.onSave
public function onSave(ArrayAccess $parameters, $namespace = null) { $exception = false; if (is_null($namespace)) { return true; } try { $fieldsCollection = $this->field->query()->where('namespace', $namespace)->get(); if ($fieldsCollection->isEmpty()) { return true; } $collection = []; $fieldsCollection->each(function($field) use(&$collection) { if (array_key_exists($field->name, $this->input)) { $collection[$field->id] = $this->input[$field->name]; } }); call_user_func_array([$this, 'save'], [$collection, $parameters->id, $namespace]); } catch (\Exception $e) { $exception = $e; } return $exception === false; }
php
public function onSave(ArrayAccess $parameters, $namespace = null) { $exception = false; if (is_null($namespace)) { return true; } try { $fieldsCollection = $this->field->query()->where('namespace', $namespace)->get(); if ($fieldsCollection->isEmpty()) { return true; } $collection = []; $fieldsCollection->each(function($field) use(&$collection) { if (array_key_exists($field->name, $this->input)) { $collection[$field->id] = $this->input[$field->name]; } }); call_user_func_array([$this, 'save'], [$collection, $parameters->id, $namespace]); } catch (\Exception $e) { $exception = $e; } return $exception === false; }
[ "public", "function", "onSave", "(", "ArrayAccess", "$", "parameters", ",", "$", "namespace", "=", "null", ")", "{", "$", "exception", "=", "false", ";", "if", "(", "is_null", "(", "$", "namespace", ")", ")", "{", "return", "true", ";", "}", "try", "{", "$", "fieldsCollection", "=", "$", "this", "->", "field", "->", "query", "(", ")", "->", "where", "(", "'namespace'", ",", "$", "namespace", ")", "->", "get", "(", ")", ";", "if", "(", "$", "fieldsCollection", "->", "isEmpty", "(", ")", ")", "{", "return", "true", ";", "}", "$", "collection", "=", "[", "]", ";", "$", "fieldsCollection", "->", "each", "(", "function", "(", "$", "field", ")", "use", "(", "&", "$", "collection", ")", "{", "if", "(", "array_key_exists", "(", "$", "field", "->", "name", ",", "$", "this", "->", "input", ")", ")", "{", "$", "collection", "[", "$", "field", "->", "id", "]", "=", "$", "this", "->", "input", "[", "$", "field", "->", "name", "]", ";", "}", "}", ")", ";", "call_user_func_array", "(", "[", "$", "this", ",", "'save'", "]", ",", "[", "$", "collection", ",", "$", "parameters", "->", "id", ",", "$", "namespace", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "exception", "=", "$", "e", ";", "}", "return", "$", "exception", "===", "false", ";", "}" ]
saves data values from customfields @param ArrayAccess $parameters @param String $namespace @return boolean
[ "saves", "data", "values", "from", "customfields" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Events/ProcessorHandler.php#L81-L108
228,078
antaresproject/customfields
src/Events/ProcessorHandler.php
ProcessorHandler.save
protected function save(array $parameters, $foreignId, $namespace = null) { if (empty($parameters)) { return true; } $where = ['user_id' => $this->userId, 'foreign_id' => $foreignId, 'namespace' => $namespace]; foreach ($parameters as $fieldId => $fieldValue) { array_set($where, 'field_id', $fieldId); if ($this->isTabular($fieldValue)) { foreach ($fieldValue as $optionId) { array_set($where, 'option_id', $optionId); $model = $this->resolveModel($where); $model->save(); } } else { $model = $this->resolveModel($where); $model->data = $fieldValue; $model->save(); } } }
php
protected function save(array $parameters, $foreignId, $namespace = null) { if (empty($parameters)) { return true; } $where = ['user_id' => $this->userId, 'foreign_id' => $foreignId, 'namespace' => $namespace]; foreach ($parameters as $fieldId => $fieldValue) { array_set($where, 'field_id', $fieldId); if ($this->isTabular($fieldValue)) { foreach ($fieldValue as $optionId) { array_set($where, 'option_id', $optionId); $model = $this->resolveModel($where); $model->save(); } } else { $model = $this->resolveModel($where); $model->data = $fieldValue; $model->save(); } } }
[ "protected", "function", "save", "(", "array", "$", "parameters", ",", "$", "foreignId", ",", "$", "namespace", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "parameters", ")", ")", "{", "return", "true", ";", "}", "$", "where", "=", "[", "'user_id'", "=>", "$", "this", "->", "userId", ",", "'foreign_id'", "=>", "$", "foreignId", ",", "'namespace'", "=>", "$", "namespace", "]", ";", "foreach", "(", "$", "parameters", "as", "$", "fieldId", "=>", "$", "fieldValue", ")", "{", "array_set", "(", "$", "where", ",", "'field_id'", ",", "$", "fieldId", ")", ";", "if", "(", "$", "this", "->", "isTabular", "(", "$", "fieldValue", ")", ")", "{", "foreach", "(", "$", "fieldValue", "as", "$", "optionId", ")", "{", "array_set", "(", "$", "where", ",", "'option_id'", ",", "$", "optionId", ")", ";", "$", "model", "=", "$", "this", "->", "resolveModel", "(", "$", "where", ")", ";", "$", "model", "->", "save", "(", ")", ";", "}", "}", "else", "{", "$", "model", "=", "$", "this", "->", "resolveModel", "(", "$", "where", ")", ";", "$", "model", "->", "data", "=", "$", "fieldValue", ";", "$", "model", "->", "save", "(", ")", ";", "}", "}", "}" ]
saves collection of data from customfields inputs @param array $parameters @param numeric $foreignId @param String $namespace @return boolean
[ "saves", "collection", "of", "data", "from", "customfields", "inputs" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Events/ProcessorHandler.php#L117-L140
228,079
antaresproject/customfields
src/Events/ProcessorHandler.php
ProcessorHandler.resolveModel
protected function resolveModel(array $where) { $model = $this->fieldData->query()->where($where)->first(); return (is_null($model)) ? $this->fieldData->newInstance($where) : $model; }
php
protected function resolveModel(array $where) { $model = $this->fieldData->query()->where($where)->first(); return (is_null($model)) ? $this->fieldData->newInstance($where) : $model; }
[ "protected", "function", "resolveModel", "(", "array", "$", "where", ")", "{", "$", "model", "=", "$", "this", "->", "fieldData", "->", "query", "(", ")", "->", "where", "(", "$", "where", ")", "->", "first", "(", ")", ";", "return", "(", "is_null", "(", "$", "model", ")", ")", "?", "$", "this", "->", "fieldData", "->", "newInstance", "(", "$", "where", ")", ":", "$", "model", ";", "}" ]
resolve model instance @param array $where @return Eloquent
[ "resolve", "model", "instance" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Events/ProcessorHandler.php#L147-L151
228,080
antaresproject/core
src/foundation/src/Http/Presenters/Presenter.php
Presenter.getScriptsContainers
private function getScriptsContainers() { $container = null; $config = null; foreach (['container', 'app', 'foundation'] as $name) { if (isset($this->{$name}) && is_null($container)) { $container = $this->{$name}->make('antares.asset'); $config = $this->{$name}->make('config'); break; } } if (is_null($container)) { $container = app('antares.asset'); } if (is_null($config)) { $config = app('config'); } return [ 'container' => $container, 'config' => $config ]; }
php
private function getScriptsContainers() { $container = null; $config = null; foreach (['container', 'app', 'foundation'] as $name) { if (isset($this->{$name}) && is_null($container)) { $container = $this->{$name}->make('antares.asset'); $config = $this->{$name}->make('config'); break; } } if (is_null($container)) { $container = app('antares.asset'); } if (is_null($config)) { $config = app('config'); } return [ 'container' => $container, 'config' => $config ]; }
[ "private", "function", "getScriptsContainers", "(", ")", "{", "$", "container", "=", "null", ";", "$", "config", "=", "null", ";", "foreach", "(", "[", "'container'", ",", "'app'", ",", "'foundation'", "]", "as", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "{", "$", "name", "}", ")", "&&", "is_null", "(", "$", "container", ")", ")", "{", "$", "container", "=", "$", "this", "->", "{", "$", "name", "}", "->", "make", "(", "'antares.asset'", ")", ";", "$", "config", "=", "$", "this", "->", "{", "$", "name", "}", "->", "make", "(", "'config'", ")", ";", "break", ";", "}", "}", "if", "(", "is_null", "(", "$", "container", ")", ")", "{", "$", "container", "=", "app", "(", "'antares.asset'", ")", ";", "}", "if", "(", "is_null", "(", "$", "config", ")", ")", "{", "$", "config", "=", "app", "(", "'config'", ")", ";", "}", "return", "[", "'container'", "=>", "$", "container", ",", "'config'", "=>", "$", "config", "]", ";", "}" ]
scripts containers resolver @return array
[ "scripts", "containers", "resolver" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Presenters/Presenter.php#L95-L116
228,081
antaresproject/core
src/foundation/src/Http/Presenters/Presenter.php
Presenter.scripts
protected function scripts($key = null, $position = 'antares/foundation::scripts') { if (!$key) { return false; } $containers = $this->getScriptsContainers(); $config = $containers['config']->get($key); $container = $containers['container']->container(isset($config['position']) ? $config['position'] : $position); if (isset($config['resources']) && !empty($config['resources'])) { foreach ($config['resources'] as $name => $path) { $container->script($name, $path); } } return; }
php
protected function scripts($key = null, $position = 'antares/foundation::scripts') { if (!$key) { return false; } $containers = $this->getScriptsContainers(); $config = $containers['config']->get($key); $container = $containers['container']->container(isset($config['position']) ? $config['position'] : $position); if (isset($config['resources']) && !empty($config['resources'])) { foreach ($config['resources'] as $name => $path) { $container->script($name, $path); } } return; }
[ "protected", "function", "scripts", "(", "$", "key", "=", "null", ",", "$", "position", "=", "'antares/foundation::scripts'", ")", "{", "if", "(", "!", "$", "key", ")", "{", "return", "false", ";", "}", "$", "containers", "=", "$", "this", "->", "getScriptsContainers", "(", ")", ";", "$", "config", "=", "$", "containers", "[", "'config'", "]", "->", "get", "(", "$", "key", ")", ";", "$", "container", "=", "$", "containers", "[", "'container'", "]", "->", "container", "(", "isset", "(", "$", "config", "[", "'position'", "]", ")", "?", "$", "config", "[", "'position'", "]", ":", "$", "position", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'resources'", "]", ")", "&&", "!", "empty", "(", "$", "config", "[", "'resources'", "]", ")", ")", "{", "foreach", "(", "$", "config", "[", "'resources'", "]", "as", "$", "name", "=>", "$", "path", ")", "{", "$", "container", "->", "script", "(", "$", "name", ",", "$", "path", ")", ";", "}", "}", "return", ";", "}" ]
create presenter additional scripts @param String $key @param String $position @return void
[ "create", "presenter", "additional", "scripts" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Presenters/Presenter.php#L125-L140
228,082
antaresproject/core
src/foundation/src/Http/Controllers/Extension/ViewerController.php
ViewerController.updateConfigurationValidationFailed
public function updateConfigurationValidationFailed(array $messages) { if (request()->ajax()) { return response()->json($messages); } $url = URL::previous(); return $this->redirectWithErrors($url, $messages); }
php
public function updateConfigurationValidationFailed(array $messages) { if (request()->ajax()) { return response()->json($messages); } $url = URL::previous(); return $this->redirectWithErrors($url, $messages); }
[ "public", "function", "updateConfigurationValidationFailed", "(", "array", "$", "messages", ")", "{", "if", "(", "request", "(", ")", "->", "ajax", "(", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "$", "messages", ")", ";", "}", "$", "url", "=", "URL", "::", "previous", "(", ")", ";", "return", "$", "this", "->", "redirectWithErrors", "(", "$", "url", ",", "$", "messages", ")", ";", "}" ]
Handles the failed validation for edited configuration. @param array $messages @return mixed
[ "Handles", "the", "failed", "validation", "for", "edited", "configuration", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/Extension/ViewerController.php#L115-L124
228,083
antaresproject/core
src/foundation/src/Http/Controllers/Extension/ViewerController.php
ViewerController.updateConfigurationSuccess
public function updateConfigurationSuccess() { $url = route(area() . '.modules.index'); $message = trans('antares/foundation::response.extensions.configuration-success'); return $this->redirectWithMessage($url, $message); }
php
public function updateConfigurationSuccess() { $url = route(area() . '.modules.index'); $message = trans('antares/foundation::response.extensions.configuration-success'); return $this->redirectWithMessage($url, $message); }
[ "public", "function", "updateConfigurationSuccess", "(", ")", "{", "$", "url", "=", "route", "(", "area", "(", ")", ".", "'.modules.index'", ")", ";", "$", "message", "=", "trans", "(", "'antares/foundation::response.extensions.configuration-success'", ")", ";", "return", "$", "this", "->", "redirectWithMessage", "(", "$", "url", ",", "$", "message", ")", ";", "}" ]
Handles the successfully updated configuration. @return mixed
[ "Handles", "the", "successfully", "updated", "configuration", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/Extension/ViewerController.php#L131-L137
228,084
antaresproject/core
src/foundation/src/Http/Controllers/Extension/ViewerController.php
ViewerController.updateConfigurationFailed
public function updateConfigurationFailed(array $errors) { $url = URL::previous(); $message = trans('antares/foundation::response.extensions.configuration-failed'); return $this->redirectWithMessage($url, $message, 'error'); }
php
public function updateConfigurationFailed(array $errors) { $url = URL::previous(); $message = trans('antares/foundation::response.extensions.configuration-failed'); return $this->redirectWithMessage($url, $message, 'error'); }
[ "public", "function", "updateConfigurationFailed", "(", "array", "$", "errors", ")", "{", "$", "url", "=", "URL", "::", "previous", "(", ")", ";", "$", "message", "=", "trans", "(", "'antares/foundation::response.extensions.configuration-failed'", ")", ";", "return", "$", "this", "->", "redirectWithMessage", "(", "$", "url", ",", "$", "message", ",", "'error'", ")", ";", "}" ]
Handles the failed update configuration. @param array $errors @return mixed
[ "Handles", "the", "failed", "update", "configuration", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/Extension/ViewerController.php#L145-L151
228,085
lawoole/framework
src/Server/ServerManager.php
ServerManager.server
public function server() { if ($this->server != null) { return $this->server; } return $this->server = $this->createServer(); }
php
public function server() { if ($this->server != null) { return $this->server; } return $this->server = $this->createServer(); }
[ "public", "function", "server", "(", ")", "{", "if", "(", "$", "this", "->", "server", "!=", "null", ")", "{", "return", "$", "this", "->", "server", ";", "}", "return", "$", "this", "->", "server", "=", "$", "this", "->", "createServer", "(", ")", ";", "}" ]
Get the server instance. @return \Lawoole\Contracts\Server\Server
[ "Get", "the", "server", "instance", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerManager.php#L55-L62
228,086
antaresproject/core
src/utils/asset/src/Dispatcher.php
Dispatcher.getAssetSandboxSourceUrl
protected function getAssetSandboxSourceUrl(&$source, $group = null) { if (is_null(self::$sandboxPath)) { if (!Foundation::bound('antares.version')) { self::$sandboxPath = ''; } $sandboxMode = app('request')->get('sandbox'); if ($sandboxMode and $group !== 'inline') { $publicPath = Foundation::make('Antares\Updater\Contracts\Requirements')->setVersion($sandboxMode)->getPublicPath(); $path = last(explode(DIRECTORY_SEPARATOR, $publicPath)); $source = $path . '/' . $source; } return false; } return self::$sandboxPath; }
php
protected function getAssetSandboxSourceUrl(&$source, $group = null) { if (is_null(self::$sandboxPath)) { if (!Foundation::bound('antares.version')) { self::$sandboxPath = ''; } $sandboxMode = app('request')->get('sandbox'); if ($sandboxMode and $group !== 'inline') { $publicPath = Foundation::make('Antares\Updater\Contracts\Requirements')->setVersion($sandboxMode)->getPublicPath(); $path = last(explode(DIRECTORY_SEPARATOR, $publicPath)); $source = $path . '/' . $source; } return false; } return self::$sandboxPath; }
[ "protected", "function", "getAssetSandboxSourceUrl", "(", "&", "$", "source", ",", "$", "group", "=", "null", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "sandboxPath", ")", ")", "{", "if", "(", "!", "Foundation", "::", "bound", "(", "'antares.version'", ")", ")", "{", "self", "::", "$", "sandboxPath", "=", "''", ";", "}", "$", "sandboxMode", "=", "app", "(", "'request'", ")", "->", "get", "(", "'sandbox'", ")", ";", "if", "(", "$", "sandboxMode", "and", "$", "group", "!==", "'inline'", ")", "{", "$", "publicPath", "=", "Foundation", "::", "make", "(", "'Antares\\Updater\\Contracts\\Requirements'", ")", "->", "setVersion", "(", "$", "sandboxMode", ")", "->", "getPublicPath", "(", ")", ";", "$", "path", "=", "last", "(", "explode", "(", "DIRECTORY_SEPARATOR", ",", "$", "publicPath", ")", ")", ";", "$", "source", "=", "$", "path", ".", "'/'", ".", "$", "source", ";", "}", "return", "false", ";", "}", "return", "self", "::", "$", "sandboxPath", ";", "}" ]
create asset sandbox source url @param String $source @return boolean
[ "create", "asset", "sandbox", "source", "url" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/Dispatcher.php#L214-L230
228,087
antaresproject/core
src/ui/components/templates/src/Adapter/TemplateAdapter.php
TemplateAdapter.decorate
public function decorate($content = null) { $current = realpath(__DIR__ . '/../') . '/'; $dotted = 'templates.default'; $params = array_merge($this->shared, ['content' => $content]); if (!is_null($this->template)) { $viewPath = str_replace([$current, '/resources/views/', '..'], '', $this->template['path']); $dotted = str_replace(DIRECTORY_SEPARATOR, '.', $viewPath); return view("antares/ui-components::{$dotted}.index", array_merge($params, ['template' => $this->template['package']]))->render(); } return view($this->path, $params)->render(); }
php
public function decorate($content = null) { $current = realpath(__DIR__ . '/../') . '/'; $dotted = 'templates.default'; $params = array_merge($this->shared, ['content' => $content]); if (!is_null($this->template)) { $viewPath = str_replace([$current, '/resources/views/', '..'], '', $this->template['path']); $dotted = str_replace(DIRECTORY_SEPARATOR, '.', $viewPath); return view("antares/ui-components::{$dotted}.index", array_merge($params, ['template' => $this->template['package']]))->render(); } return view($this->path, $params)->render(); }
[ "public", "function", "decorate", "(", "$", "content", "=", "null", ")", "{", "$", "current", "=", "realpath", "(", "__DIR__", ".", "'/../'", ")", ".", "'/'", ";", "$", "dotted", "=", "'templates.default'", ";", "$", "params", "=", "array_merge", "(", "$", "this", "->", "shared", ",", "[", "'content'", "=>", "$", "content", "]", ")", ";", "if", "(", "!", "is_null", "(", "$", "this", "->", "template", ")", ")", "{", "$", "viewPath", "=", "str_replace", "(", "[", "$", "current", ",", "'/resources/views/'", ",", "'..'", "]", ",", "''", ",", "$", "this", "->", "template", "[", "'path'", "]", ")", ";", "$", "dotted", "=", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'.'", ",", "$", "viewPath", ")", ";", "return", "view", "(", "\"antares/ui-components::{$dotted}.index\"", ",", "array_merge", "(", "$", "params", ",", "[", "'template'", "=>", "$", "this", "->", "template", "[", "'package'", "]", "]", ")", ")", "->", "render", "(", ")", ";", "}", "return", "view", "(", "$", "this", "->", "path", ",", "$", "params", ")", "->", "render", "(", ")", ";", "}" ]
resolve template path @param String $content @return String
[ "resolve", "template", "path" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Adapter/TemplateAdapter.php#L73-L84
228,088
antaresproject/core
src/components/model/src/Memory/UserMetaRepository.php
UserMetaRepository.retrieveAll
public function retrieveAll($userId) { if (!isset($this->userMeta[$userId])) { $data = $this->getModel()->where('user_id', '=', $userId)->get(); $this->userMeta[$userId] = $this->processRetrievedData($userId, $data); } return Arr::get($this->userMeta, $userId); }
php
public function retrieveAll($userId) { if (!isset($this->userMeta[$userId])) { $data = $this->getModel()->where('user_id', '=', $userId)->get(); $this->userMeta[$userId] = $this->processRetrievedData($userId, $data); } return Arr::get($this->userMeta, $userId); }
[ "public", "function", "retrieveAll", "(", "$", "userId", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "userMeta", "[", "$", "userId", "]", ")", ")", "{", "$", "data", "=", "$", "this", "->", "getModel", "(", ")", "->", "where", "(", "'user_id'", ",", "'='", ",", "$", "userId", ")", "->", "get", "(", ")", ";", "$", "this", "->", "userMeta", "[", "$", "userId", "]", "=", "$", "this", "->", "processRetrievedData", "(", "$", "userId", ",", "$", "data", ")", ";", "}", "return", "Arr", "::", "get", "(", "$", "this", "->", "userMeta", ",", "$", "userId", ")", ";", "}" ]
Get user metas from database @param string $key @return mixed
[ "Get", "user", "metas", "from", "database" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Memory/UserMetaRepository.php#L203-L210
228,089
tomwalder/php-appengine-search
src/Search/Mapper.php
Mapper.mapExpressions
private function mapExpressions(array $arr_fields, Document $obj_doc) { foreach($arr_fields as $obj_field) { $str_field_name = $obj_field->getName(); $obj_value = $obj_field->getValue(); if(ContentType::GEO === $obj_value->getType()) { $obj_geo = $obj_value->getGeo(); $obj_doc->setExpression($str_field_name, [$obj_geo->getLat(), $obj_geo->getLng()]); } else { if(isset(self::$arr_types_rev[$obj_value->getType()])) { $obj_doc->setExpression($str_field_name, $obj_value->getStringValue()); } else { throw new \InvalidArgumentException('Unknown type mapping from Expressions'); } } } }
php
private function mapExpressions(array $arr_fields, Document $obj_doc) { foreach($arr_fields as $obj_field) { $str_field_name = $obj_field->getName(); $obj_value = $obj_field->getValue(); if(ContentType::GEO === $obj_value->getType()) { $obj_geo = $obj_value->getGeo(); $obj_doc->setExpression($str_field_name, [$obj_geo->getLat(), $obj_geo->getLng()]); } else { if(isset(self::$arr_types_rev[$obj_value->getType()])) { $obj_doc->setExpression($str_field_name, $obj_value->getStringValue()); } else { throw new \InvalidArgumentException('Unknown type mapping from Expressions'); } } } }
[ "private", "function", "mapExpressions", "(", "array", "$", "arr_fields", ",", "Document", "$", "obj_doc", ")", "{", "foreach", "(", "$", "arr_fields", "as", "$", "obj_field", ")", "{", "$", "str_field_name", "=", "$", "obj_field", "->", "getName", "(", ")", ";", "$", "obj_value", "=", "$", "obj_field", "->", "getValue", "(", ")", ";", "if", "(", "ContentType", "::", "GEO", "===", "$", "obj_value", "->", "getType", "(", ")", ")", "{", "$", "obj_geo", "=", "$", "obj_value", "->", "getGeo", "(", ")", ";", "$", "obj_doc", "->", "setExpression", "(", "$", "str_field_name", ",", "[", "$", "obj_geo", "->", "getLat", "(", ")", ",", "$", "obj_geo", "->", "getLng", "(", ")", "]", ")", ";", "}", "else", "{", "if", "(", "isset", "(", "self", "::", "$", "arr_types_rev", "[", "$", "obj_value", "->", "getType", "(", ")", "]", ")", ")", "{", "$", "obj_doc", "->", "setExpression", "(", "$", "str_field_name", ",", "$", "obj_value", "->", "getStringValue", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unknown type mapping from Expressions'", ")", ";", "}", "}", "}", "}" ]
Map expressions into a document @param Field[] $arr_fields @param Document $obj_doc
[ "Map", "expressions", "into", "a", "document" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Mapper.php#L101-L117
228,090
antaresproject/customfields
src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onCustomFieldCreateOrEdit
public function onCustomFieldCreateOrEdit(Model $model) { $this->onList(); Breadcrumbs::register('customfields-create-update', function($breadcrumbs) use($model) { $breadcrumbs->parent('customfields'); $name = $model->exists ? 'Update custom field ' . $model->name : 'Create custom field'; $breadcrumbs->push($name, '#'); }); view()->share('breadcrumbs', Breadcrumbs::render('customfields-create-update')); }
php
public function onCustomFieldCreateOrEdit(Model $model) { $this->onList(); Breadcrumbs::register('customfields-create-update', function($breadcrumbs) use($model) { $breadcrumbs->parent('customfields'); $name = $model->exists ? 'Update custom field ' . $model->name : 'Create custom field'; $breadcrumbs->push($name, '#'); }); view()->share('breadcrumbs', Breadcrumbs::render('customfields-create-update')); }
[ "public", "function", "onCustomFieldCreateOrEdit", "(", "Model", "$", "model", ")", "{", "$", "this", "->", "onList", "(", ")", ";", "Breadcrumbs", "::", "register", "(", "'customfields-create-update'", ",", "function", "(", "$", "breadcrumbs", ")", "use", "(", "$", "model", ")", "{", "$", "breadcrumbs", "->", "parent", "(", "'customfields'", ")", ";", "$", "name", "=", "$", "model", "->", "exists", "?", "'Update custom field '", ".", "$", "model", "->", "name", ":", "'Create custom field'", ";", "$", "breadcrumbs", "->", "push", "(", "$", "name", ",", "'#'", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'customfields-create-update'", ")", ")", ";", "}" ]
when shows edit or create custom field form @param Model $model
[ "when", "shows", "edit", "or", "create", "custom", "field", "form" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Http/Breadcrumb/Breadcrumb.php#L48-L58
228,091
coincheckjp/coincheck-php
lib/Coincheck/BankAccount.php
BankAccount.create
public function create($params = array()) { $arr = array( "bank_name" => $params["bank_name"], "branch_name" => $params["branch_name"], "bank_account_type" => $params["bank_account_type"], "number" => $params["number"], "name" => $params["name"] ); $rawResponse = $this->client->request('post', 'api/bank_accounts', $arr); return $rawResponse; }
php
public function create($params = array()) { $arr = array( "bank_name" => $params["bank_name"], "branch_name" => $params["branch_name"], "bank_account_type" => $params["bank_account_type"], "number" => $params["number"], "name" => $params["name"] ); $rawResponse = $this->client->request('post', 'api/bank_accounts', $arr); return $rawResponse; }
[ "public", "function", "create", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "arr", "=", "array", "(", "\"bank_name\"", "=>", "$", "params", "[", "\"bank_name\"", "]", ",", "\"branch_name\"", "=>", "$", "params", "[", "\"branch_name\"", "]", ",", "\"bank_account_type\"", "=>", "$", "params", "[", "\"bank_account_type\"", "]", ",", "\"number\"", "=>", "$", "params", "[", "\"number\"", "]", ",", "\"name\"", "=>", "$", "params", "[", "\"name\"", "]", ")", ";", "$", "rawResponse", "=", "$", "this", "->", "client", "->", "request", "(", "'post'", ",", "'api/bank_accounts'", ",", "$", "arr", ")", ";", "return", "$", "rawResponse", ";", "}" ]
Create a new BankAccount. @param mixed @return Json Array
[ "Create", "a", "new", "BankAccount", "." ]
5991003cb0ae827697888aeebd0aea0267fad7fa
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/BankAccount.php#L20-L31
228,092
coincheckjp/coincheck-php
lib/Coincheck/BankAccount.php
BankAccount.delete
public function delete($params = array()) { $arr = array( "id" => $params["id"] ); $rawResponse = $this->client->request('delete', 'api/bank_accounts/' . $arr["id"], $arr); return $rawResponse; }
php
public function delete($params = array()) { $arr = array( "id" => $params["id"] ); $rawResponse = $this->client->request('delete', 'api/bank_accounts/' . $arr["id"], $arr); return $rawResponse; }
[ "public", "function", "delete", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "arr", "=", "array", "(", "\"id\"", "=>", "$", "params", "[", "\"id\"", "]", ")", ";", "$", "rawResponse", "=", "$", "this", "->", "client", "->", "request", "(", "'delete'", ",", "'api/bank_accounts/'", ".", "$", "arr", "[", "\"id\"", "]", ",", "$", "arr", ")", ";", "return", "$", "rawResponse", ";", "}" ]
Delete a BankAccount. @param mixed @return Json Array
[ "Delete", "a", "BankAccount", "." ]
5991003cb0ae827697888aeebd0aea0267fad7fa
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/BankAccount.php#L53-L58
228,093
coincheckjp/coincheck-php
lib/Coincheck/Borrow.php
Borrow.repay
public function repay($params = array()) { $arr = array( "id" => $params["id"]); $rawResponse = $this->client->request('post', 'api/lending/borrows/' . $arr['id'] . '/repay', $arr); return $rawResponse; }
php
public function repay($params = array()) { $arr = array( "id" => $params["id"]); $rawResponse = $this->client->request('post', 'api/lending/borrows/' . $arr['id'] . '/repay', $arr); return $rawResponse; }
[ "public", "function", "repay", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "arr", "=", "array", "(", "\"id\"", "=>", "$", "params", "[", "\"id\"", "]", ")", ";", "$", "rawResponse", "=", "$", "this", "->", "client", "->", "request", "(", "'post'", ",", "'api/lending/borrows/'", ".", "$", "arr", "[", "'id'", "]", ".", "'/repay'", ",", "$", "arr", ")", ";", "return", "$", "rawResponse", ";", "}" ]
Based on this id, you can repay. @param mixed @return Json Array
[ "Based", "on", "this", "id", "you", "can", "repay", "." ]
5991003cb0ae827697888aeebd0aea0267fad7fa
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Borrow.php#L49-L54
228,094
lawoole/framework
src/Http/Respondent.php
Respondent.addDateHeaderIfNecessary
protected function addDateHeaderIfNecessary($statusCode, $headerBag) { if ($statusCode >= 200 && $statusCode < 500 && ! $headerBag->has('Date')) { $date = DateTime::createFromFormat('U', time(), new DateTimeZone('UTC')); $headerBag->set('Date', $date->format('D, d M Y H:i:s').' GMT'); } }
php
protected function addDateHeaderIfNecessary($statusCode, $headerBag) { if ($statusCode >= 200 && $statusCode < 500 && ! $headerBag->has('Date')) { $date = DateTime::createFromFormat('U', time(), new DateTimeZone('UTC')); $headerBag->set('Date', $date->format('D, d M Y H:i:s').' GMT'); } }
[ "protected", "function", "addDateHeaderIfNecessary", "(", "$", "statusCode", ",", "$", "headerBag", ")", "{", "if", "(", "$", "statusCode", ">=", "200", "&&", "$", "statusCode", "<", "500", "&&", "!", "$", "headerBag", "->", "has", "(", "'Date'", ")", ")", "{", "$", "date", "=", "DateTime", "::", "createFromFormat", "(", "'U'", ",", "time", "(", ")", ",", "new", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "$", "headerBag", "->", "set", "(", "'Date'", ",", "$", "date", "->", "format", "(", "'D, d M Y H:i:s'", ")", ".", "' GMT'", ")", ";", "}", "}" ]
Add the Date header if it's missing. @see https://tools.ietf.org/html/rfc2616#section-14.18 @param int $statusCode @param \Symfony\Component\HttpFoundation\ResponseHeaderBag $headerBag
[ "Add", "the", "Date", "header", "if", "it", "s", "missing", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/Respondent.php#L75-L82
228,095
lawoole/framework
src/Http/Respondent.php
Respondent.setCookieInResponse
protected function setCookieInResponse(Cookie $cookie) { $method = $cookie->isRaw() ? 'rawcookie' : 'cookie'; $this->response->$method( $cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly() ); }
php
protected function setCookieInResponse(Cookie $cookie) { $method = $cookie->isRaw() ? 'rawcookie' : 'cookie'; $this->response->$method( $cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly() ); }
[ "protected", "function", "setCookieInResponse", "(", "Cookie", "$", "cookie", ")", "{", "$", "method", "=", "$", "cookie", "->", "isRaw", "(", ")", "?", "'rawcookie'", ":", "'cookie'", ";", "$", "this", "->", "response", "->", "$", "method", "(", "$", "cookie", "->", "getName", "(", ")", ",", "$", "cookie", "->", "getValue", "(", ")", ",", "$", "cookie", "->", "getExpiresTime", "(", ")", ",", "$", "cookie", "->", "getPath", "(", ")", ",", "$", "cookie", "->", "getDomain", "(", ")", ",", "$", "cookie", "->", "isSecure", "(", ")", ",", "$", "cookie", "->", "isHttpOnly", "(", ")", ")", ";", "}" ]
Set a cookie in response header. @param \Symfony\Component\HttpFoundation\Cookie $cookie
[ "Set", "a", "cookie", "in", "response", "header", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/Respondent.php#L104-L112
228,096
lawoole/framework
src/Http/Respondent.php
Respondent.sendChunk
public function sendChunk($data, $lastChunk = false) { $this->chunked = true; if ($lastChunk) { $this->response->end($data); } elseif (strlen($data) > 0) { $this->response->write($data); } }
php
public function sendChunk($data, $lastChunk = false) { $this->chunked = true; if ($lastChunk) { $this->response->end($data); } elseif (strlen($data) > 0) { $this->response->write($data); } }
[ "public", "function", "sendChunk", "(", "$", "data", ",", "$", "lastChunk", "=", "false", ")", "{", "$", "this", "->", "chunked", "=", "true", ";", "if", "(", "$", "lastChunk", ")", "{", "$", "this", "->", "response", "->", "end", "(", "$", "data", ")", ";", "}", "elseif", "(", "strlen", "(", "$", "data", ")", ">", "0", ")", "{", "$", "this", "->", "response", "->", "write", "(", "$", "data", ")", ";", "}", "}" ]
Send response body in chunked. @param string $data @param bool $lastChunk
[ "Send", "response", "body", "in", "chunked", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/Respondent.php#L144-L153
228,097
antaresproject/core
src/components/extension/src/Loader.php
Loader.registerExtensionProviders
public function registerExtensionProviders(ExtensionContract $extension) { $filePath = $extension->getPath() . '/providers.php'; if ($this->files->exists($filePath)) { $providers = (array) $this->files->getRequire($filePath); $this->provides($providers); } }
php
public function registerExtensionProviders(ExtensionContract $extension) { $filePath = $extension->getPath() . '/providers.php'; if ($this->files->exists($filePath)) { $providers = (array) $this->files->getRequire($filePath); $this->provides($providers); } }
[ "public", "function", "registerExtensionProviders", "(", "ExtensionContract", "$", "extension", ")", "{", "$", "filePath", "=", "$", "extension", "->", "getPath", "(", ")", ".", "'/providers.php'", ";", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "filePath", ")", ")", "{", "$", "providers", "=", "(", "array", ")", "$", "this", "->", "files", "->", "getRequire", "(", "$", "filePath", ")", ";", "$", "this", "->", "provides", "(", "$", "providers", ")", ";", "}", "}" ]
Registers extension providers. @param ExtensionContract $extension @throws \Exception
[ "Registers", "extension", "providers", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L80-L89
228,098
antaresproject/core
src/components/extension/src/Loader.php
Loader.provides
public function provides(array $provides) { $services = []; foreach ($provides as $provider) { try { if (!isset($this->manifest[$provider])) { $services[$provider] = $this->recompileProvider($provider); } else { $services[$provider] = $this->manifest[$provider]; } } catch (Exception $ex) { Log::error($ex); continue; } } $this->dispatch($services); }
php
public function provides(array $provides) { $services = []; foreach ($provides as $provider) { try { if (!isset($this->manifest[$provider])) { $services[$provider] = $this->recompileProvider($provider); } else { $services[$provider] = $this->manifest[$provider]; } } catch (Exception $ex) { Log::error($ex); continue; } } $this->dispatch($services); }
[ "public", "function", "provides", "(", "array", "$", "provides", ")", "{", "$", "services", "=", "[", "]", ";", "foreach", "(", "$", "provides", "as", "$", "provider", ")", "{", "try", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "manifest", "[", "$", "provider", "]", ")", ")", "{", "$", "services", "[", "$", "provider", "]", "=", "$", "this", "->", "recompileProvider", "(", "$", "provider", ")", ";", "}", "else", "{", "$", "services", "[", "$", "provider", "]", "=", "$", "this", "->", "manifest", "[", "$", "provider", "]", ";", "}", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "Log", "::", "error", "(", "$", "ex", ")", ";", "continue", ";", "}", "}", "$", "this", "->", "dispatch", "(", "$", "services", ")", ";", "}" ]
Load available service providers. @param array $provides @return void
[ "Load", "available", "service", "providers", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L97-L115
228,099
antaresproject/core
src/components/extension/src/Loader.php
Loader.recompileProvider
protected function recompileProvider(string $provider): array { $instance = $this->app->resolveProvider($provider); $type = $instance->isDeferred() ? 'Deferred' : 'Eager'; return $this->{"register{$type}ServiceProvider"}($provider, $instance); }
php
protected function recompileProvider(string $provider): array { $instance = $this->app->resolveProvider($provider); $type = $instance->isDeferred() ? 'Deferred' : 'Eager'; return $this->{"register{$type}ServiceProvider"}($provider, $instance); }
[ "protected", "function", "recompileProvider", "(", "string", "$", "provider", ")", ":", "array", "{", "$", "instance", "=", "$", "this", "->", "app", "->", "resolveProvider", "(", "$", "provider", ")", ";", "$", "type", "=", "$", "instance", "->", "isDeferred", "(", ")", "?", "'Deferred'", ":", "'Eager'", ";", "return", "$", "this", "->", "{", "\"register{$type}ServiceProvider\"", "}", "(", "$", "provider", ",", "$", "instance", ")", ";", "}" ]
Recompile provider by reviewing the class configuration. @param string $provider @return array
[ "Recompile", "provider", "by", "reviewing", "the", "class", "configuration", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L123-L131