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
225,700
peterkahl/Chinese-Master
src/ChineseMaster.php
ChineseMaster.simp2trad
public static function simp2trad($str) { if (empty($str)) { throw new Exception('Argument str cannot be empty'); } $charArray = array_flip(self::$trad2simple); $ords = self::utf8ToUnicode($str); foreach ($ords as $k => $val) { if (array_key_exists($val, $charArray)) { $ords[$k] = $charArray[$val]; } else { $ords[$k] = $val; } } return self::unicodeToUtf8($ords); }
php
public static function simp2trad($str) { if (empty($str)) { throw new Exception('Argument str cannot be empty'); } $charArray = array_flip(self::$trad2simple); $ords = self::utf8ToUnicode($str); foreach ($ords as $k => $val) { if (array_key_exists($val, $charArray)) { $ords[$k] = $charArray[$val]; } else { $ords[$k] = $val; } } return self::unicodeToUtf8($ords); }
[ "public", "static", "function", "simp2trad", "(", "$", "str", ")", "{", "if", "(", "empty", "(", "$", "str", ")", ")", "{", "throw", "new", "Exception", "(", "'Argument str cannot be empty'", ")", ";", "}", "$", "charArray", "=", "array_flip", "(", "self", "::", "$", "trad2simple", ")", ";", "$", "ords", "=", "self", "::", "utf8ToUnicode", "(", "$", "str", ")", ";", "foreach", "(", "$", "ords", "as", "$", "k", "=>", "$", "val", ")", "{", "if", "(", "array_key_exists", "(", "$", "val", ",", "$", "charArray", ")", ")", "{", "$", "ords", "[", "$", "k", "]", "=", "$", "charArray", "[", "$", "val", "]", ";", "}", "else", "{", "$", "ords", "[", "$", "k", "]", "=", "$", "val", ";", "}", "}", "return", "self", "::", "unicodeToUtf8", "(", "$", "ords", ")", ";", "}" ]
Converts simplified to traditional. @param string
[ "Converts", "simplified", "to", "traditional", "." ]
31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c
https://github.com/peterkahl/Chinese-Master/blob/31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c/src/ChineseMaster.php#L78-L93
225,701
peterkahl/Chinese-Master
src/ChineseMaster.php
ChineseMaster.unicodeToUtf8
private static function unicodeToUtf8($arr) { $dest = ''; foreach ($arr as $src) { $dest .= self::utf8($src); } return $dest; }
php
private static function unicodeToUtf8($arr) { $dest = ''; foreach ($arr as $src) { $dest .= self::utf8($src); } return $dest; }
[ "private", "static", "function", "unicodeToUtf8", "(", "$", "arr", ")", "{", "$", "dest", "=", "''", ";", "foreach", "(", "$", "arr", "as", "$", "src", ")", "{", "$", "dest", ".=", "self", "::", "utf8", "(", "$", "src", ")", ";", "}", "return", "$", "dest", ";", "}" ]
Takes an array of integers representing the Unicode characters and returns a UTF-8 string.
[ "Takes", "an", "array", "of", "integers", "representing", "the", "Unicode", "characters", "and", "returns", "a", "UTF", "-", "8", "string", "." ]
31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c
https://github.com/peterkahl/Chinese-Master/blob/31e82bbcddcd9e2e5fa12db8d2e1026a1a0dbe9c/src/ChineseMaster.php#L117-L123
225,702
svilborg/guzzle-encoding-com
src/Gencoding/Guzzle/Encoding/Common/EncodingRequest.php
EncodingRequest.setDomQuery
public function setDomQuery($userid, $userkey, $action) { $request = $this->appendChild($this->createElement('query')); // add action, userid and userkey params $userid = $this->createElement('userid', $userid); $userkey = $this->createElement('userkey', $userkey); $action = $this->createElement('action', $action); $request->appendChild($userid); $request->appendChild($userkey); $request->appendChild($action); return $request; }
php
public function setDomQuery($userid, $userkey, $action) { $request = $this->appendChild($this->createElement('query')); // add action, userid and userkey params $userid = $this->createElement('userid', $userid); $userkey = $this->createElement('userkey', $userkey); $action = $this->createElement('action', $action); $request->appendChild($userid); $request->appendChild($userkey); $request->appendChild($action); return $request; }
[ "public", "function", "setDomQuery", "(", "$", "userid", ",", "$", "userkey", ",", "$", "action", ")", "{", "$", "request", "=", "$", "this", "->", "appendChild", "(", "$", "this", "->", "createElement", "(", "'query'", ")", ")", ";", "// add action, userid and userkey params", "$", "userid", "=", "$", "this", "->", "createElement", "(", "'userid'", ",", "$", "userid", ")", ";", "$", "userkey", "=", "$", "this", "->", "createElement", "(", "'userkey'", ",", "$", "userkey", ")", ";", "$", "action", "=", "$", "this", "->", "createElement", "(", "'action'", ",", "$", "action", ")", ";", "$", "request", "->", "appendChild", "(", "$", "userid", ")", ";", "$", "request", "->", "appendChild", "(", "$", "userkey", ")", ";", "$", "request", "->", "appendChild", "(", "$", "action", ")", ";", "return", "$", "request", ";", "}" ]
Set Query & Auth Params @param string $userid User Id @param string $userkey User Key @param string $action Action Name @return DOMNode
[ "Set", "Query", "&", "Auth", "Params" ]
0f42505e85013d1753502c0f3d0aa8955fb24cce
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Common/EncodingRequest.php#L32-L46
225,703
cmsgears/module-cart
common/services/resources/OrderItemService.php
OrderItemService.createFromCartItem
public function createFromCartItem( $order, $cartItem, $config = [] ) { $model = $this->getModelObject(); // Set Attributes $model->orderId = $order->id; $model->createdBy = $order->creator->id; // Copy from Cart Item $model->copyForUpdateFrom( $cartItem, [ 'primaryUnitId', 'purchasingUnitId', 'quantityUnitId', 'weightUnitId', 'volumeUnitId', 'lengthUnitId', 'parentId', 'parentType', 'name', 'price', 'primary', 'purchase', 'quantity', 'total', 'weight', 'volume', 'length', 'width', 'height', 'radius' ] ); $model->save(); // Return OrderItem return $model; }
php
public function createFromCartItem( $order, $cartItem, $config = [] ) { $model = $this->getModelObject(); // Set Attributes $model->orderId = $order->id; $model->createdBy = $order->creator->id; // Copy from Cart Item $model->copyForUpdateFrom( $cartItem, [ 'primaryUnitId', 'purchasingUnitId', 'quantityUnitId', 'weightUnitId', 'volumeUnitId', 'lengthUnitId', 'parentId', 'parentType', 'name', 'price', 'primary', 'purchase', 'quantity', 'total', 'weight', 'volume', 'length', 'width', 'height', 'radius' ] ); $model->save(); // Return OrderItem return $model; }
[ "public", "function", "createFromCartItem", "(", "$", "order", ",", "$", "cartItem", ",", "$", "config", "=", "[", "]", ")", "{", "$", "model", "=", "$", "this", "->", "getModelObject", "(", ")", ";", "// Set Attributes", "$", "model", "->", "orderId", "=", "$", "order", "->", "id", ";", "$", "model", "->", "createdBy", "=", "$", "order", "->", "creator", "->", "id", ";", "// Copy from Cart Item", "$", "model", "->", "copyForUpdateFrom", "(", "$", "cartItem", ",", "[", "'primaryUnitId'", ",", "'purchasingUnitId'", ",", "'quantityUnitId'", ",", "'weightUnitId'", ",", "'volumeUnitId'", ",", "'lengthUnitId'", ",", "'parentId'", ",", "'parentType'", ",", "'name'", ",", "'price'", ",", "'primary'", ",", "'purchase'", ",", "'quantity'", ",", "'total'", ",", "'weight'", ",", "'volume'", ",", "'length'", ",", "'width'", ",", "'height'", ",", "'radius'", "]", ")", ";", "$", "model", "->", "save", "(", ")", ";", "// Return OrderItem", "return", "$", "model", ";", "}" ]
Create Order Item from cart item
[ "Create", "Order", "Item", "from", "cart", "item" ]
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/services/resources/OrderItemService.php#L82-L97
225,704
nails/module-barcode
barcode/controllers/Barcode.php
Barcode.serveFromCache
protected function serveFromCache($cacheFile, $hit = true) { /** * Cache object exists, set the appropriate headers and return the * contents of the file. **/ $_stats = stat($this->cacheDir . $cacheFile); // Set cache headers $this->setCacheHeaders($_stats[9], $cacheFile, $hit); header('Content-Type: image/png', true); // -------------------------------------------------------------------------- // Send the contents of the file to the browser echo file_get_contents($this->cacheDir . $cacheFile); /** * Kill script, th, th, that's all folks. * Stop the output class from hijacking our headers and * setting an incorrect Content-Type **/ exit(0); }
php
protected function serveFromCache($cacheFile, $hit = true) { /** * Cache object exists, set the appropriate headers and return the * contents of the file. **/ $_stats = stat($this->cacheDir . $cacheFile); // Set cache headers $this->setCacheHeaders($_stats[9], $cacheFile, $hit); header('Content-Type: image/png', true); // -------------------------------------------------------------------------- // Send the contents of the file to the browser echo file_get_contents($this->cacheDir . $cacheFile); /** * Kill script, th, th, that's all folks. * Stop the output class from hijacking our headers and * setting an incorrect Content-Type **/ exit(0); }
[ "protected", "function", "serveFromCache", "(", "$", "cacheFile", ",", "$", "hit", "=", "true", ")", "{", "/**\n * Cache object exists, set the appropriate headers and return the\n * contents of the file.\n **/", "$", "_stats", "=", "stat", "(", "$", "this", "->", "cacheDir", ".", "$", "cacheFile", ")", ";", "// Set cache headers", "$", "this", "->", "setCacheHeaders", "(", "$", "_stats", "[", "9", "]", ",", "$", "cacheFile", ",", "$", "hit", ")", ";", "header", "(", "'Content-Type: image/png'", ",", "true", ")", ";", "// --------------------------------------------------------------------------", "// Send the contents of the file to the browser", "echo", "file_get_contents", "(", "$", "this", "->", "cacheDir", ".", "$", "cacheFile", ")", ";", "/**\n * Kill script, th, th, that's all folks.\n * Stop the output class from hijacking our headers and\n * setting an incorrect Content-Type\n **/", "exit", "(", "0", ")", ";", "}" ]
Serve a file from the cache, setting headers as we go then halt execution @param string $cacheFile The cache file's filename @param boolean $hit Whether this was a cache hit or not @return void
[ "Serve", "a", "file", "from", "the", "cache", "setting", "headers", "as", "we", "go", "then", "halt", "execution" ]
c8c9dbb5b458edc5d58d80c1350819a66036cfdb
https://github.com/nails/module-barcode/blob/c8c9dbb5b458edc5d58d80c1350819a66036cfdb/barcode/controllers/Barcode.php#L48-L74
225,705
nails/module-barcode
barcode/controllers/Barcode.php
Barcode.setCacheHeaders
protected function setCacheHeaders($lastModified, $file, $hit) { // Set some flags $this->cacheHeadersSet = true; $this->cacheHeadersMaxAge = 31536000; // 1 year $this->cacheHeadersLastModified = $lastModified; $this->cacheHeadersExpires = time() + $this->cacheHeadersMaxAge; $this->cacheHeadersFile = $file; $this->cacheHeadersHit = $hit ? 'HIT' : 'MISS'; // -------------------------------------------------------------------------- header('Cache-Control: max-age=' . $this->cacheHeadersMaxAge . ', must-revalidate', true); header('Last-Modified: ' . date('r', $this->cacheHeadersLastModified), true); header('Expires: ' . date('r', $this->cacheHeadersExpires), true); header('ETag: "' . md5($this->cacheHeadersFile) . '"', true); header('X-CDN-CACHE: ' . $this->cacheHeadersHit, true); }
php
protected function setCacheHeaders($lastModified, $file, $hit) { // Set some flags $this->cacheHeadersSet = true; $this->cacheHeadersMaxAge = 31536000; // 1 year $this->cacheHeadersLastModified = $lastModified; $this->cacheHeadersExpires = time() + $this->cacheHeadersMaxAge; $this->cacheHeadersFile = $file; $this->cacheHeadersHit = $hit ? 'HIT' : 'MISS'; // -------------------------------------------------------------------------- header('Cache-Control: max-age=' . $this->cacheHeadersMaxAge . ', must-revalidate', true); header('Last-Modified: ' . date('r', $this->cacheHeadersLastModified), true); header('Expires: ' . date('r', $this->cacheHeadersExpires), true); header('ETag: "' . md5($this->cacheHeadersFile) . '"', true); header('X-CDN-CACHE: ' . $this->cacheHeadersHit, true); }
[ "protected", "function", "setCacheHeaders", "(", "$", "lastModified", ",", "$", "file", ",", "$", "hit", ")", "{", "// Set some flags", "$", "this", "->", "cacheHeadersSet", "=", "true", ";", "$", "this", "->", "cacheHeadersMaxAge", "=", "31536000", ";", "// 1 year", "$", "this", "->", "cacheHeadersLastModified", "=", "$", "lastModified", ";", "$", "this", "->", "cacheHeadersExpires", "=", "time", "(", ")", "+", "$", "this", "->", "cacheHeadersMaxAge", ";", "$", "this", "->", "cacheHeadersFile", "=", "$", "file", ";", "$", "this", "->", "cacheHeadersHit", "=", "$", "hit", "?", "'HIT'", ":", "'MISS'", ";", "// --------------------------------------------------------------------------", "header", "(", "'Cache-Control: max-age='", ".", "$", "this", "->", "cacheHeadersMaxAge", ".", "', must-revalidate'", ",", "true", ")", ";", "header", "(", "'Last-Modified: '", ".", "date", "(", "'r'", ",", "$", "this", "->", "cacheHeadersLastModified", ")", ",", "true", ")", ";", "header", "(", "'Expires: '", ".", "date", "(", "'r'", ",", "$", "this", "->", "cacheHeadersExpires", ")", ",", "true", ")", ";", "header", "(", "'ETag: \"'", ".", "md5", "(", "$", "this", "->", "cacheHeadersFile", ")", ".", "'\"'", ",", "true", ")", ";", "header", "(", "'X-CDN-CACHE: '", ".", "$", "this", "->", "cacheHeadersHit", ",", "true", ")", ";", "}" ]
Set the correct cache headers @param string $lastModified The time the source file was last modified @param string $file The filename @param boolean $hit Whether this was a cache hit or not
[ "Set", "the", "correct", "cache", "headers" ]
c8c9dbb5b458edc5d58d80c1350819a66036cfdb
https://github.com/nails/module-barcode/blob/c8c9dbb5b458edc5d58d80c1350819a66036cfdb/barcode/controllers/Barcode.php#L84-L101
225,706
nails/module-barcode
barcode/controllers/Barcode.php
Barcode.serveNotModified
protected function serveNotModified($file) { if (function_exists('apache_request_headers')) { $headers = apache_request_headers(); } elseif ($this->input->server('HTTP_IF_NONE_MATCH')) { $headers = array(); $headers['If-None-Match'] = $this->input->server('HTTP_IF_NONE_MATCH'); } elseif (isset($_SERVER)) { /** * Can we work the headers out for ourself? * Credit: http://www.php.net/manual/en/function.apache-request-headers.php#70810 **/ $headers = array(); $rxHttp = '/\AHTTP_/'; foreach ($_SERVER as $key => $val) { if (preg_match($rxHttp, $key)) { $arhKey = preg_replace($rxHttp, '', $key); $rxMatches = array(); /** * Do some nasty string manipulations to restore the original letter case * this should work in most cases **/ $rxMatches = explode('_', $arhKey); if (count($rxMatches) > 0 && strlen($arhKey) > 2) { foreach ($rxMatches as $ak_key => $ak_val) { $rxMatches[$ak_key] = ucfirst($ak_val); } $arhKey = implode('-', $rxMatches); } $headers[$arhKey] = $val; } } } else { // Give up. return false; } if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == '"' . md5($file) . '"') { header($this->input->server('SERVER_PROTOCOL') . ' 304 Not Modified', true, 304); return true; } // -------------------------------------------------------------------------- return false; }
php
protected function serveNotModified($file) { if (function_exists('apache_request_headers')) { $headers = apache_request_headers(); } elseif ($this->input->server('HTTP_IF_NONE_MATCH')) { $headers = array(); $headers['If-None-Match'] = $this->input->server('HTTP_IF_NONE_MATCH'); } elseif (isset($_SERVER)) { /** * Can we work the headers out for ourself? * Credit: http://www.php.net/manual/en/function.apache-request-headers.php#70810 **/ $headers = array(); $rxHttp = '/\AHTTP_/'; foreach ($_SERVER as $key => $val) { if (preg_match($rxHttp, $key)) { $arhKey = preg_replace($rxHttp, '', $key); $rxMatches = array(); /** * Do some nasty string manipulations to restore the original letter case * this should work in most cases **/ $rxMatches = explode('_', $arhKey); if (count($rxMatches) > 0 && strlen($arhKey) > 2) { foreach ($rxMatches as $ak_key => $ak_val) { $rxMatches[$ak_key] = ucfirst($ak_val); } $arhKey = implode('-', $rxMatches); } $headers[$arhKey] = $val; } } } else { // Give up. return false; } if (isset($headers['If-None-Match']) && $headers['If-None-Match'] == '"' . md5($file) . '"') { header($this->input->server('SERVER_PROTOCOL') . ' 304 Not Modified', true, 304); return true; } // -------------------------------------------------------------------------- return false; }
[ "protected", "function", "serveNotModified", "(", "$", "file", ")", "{", "if", "(", "function_exists", "(", "'apache_request_headers'", ")", ")", "{", "$", "headers", "=", "apache_request_headers", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "input", "->", "server", "(", "'HTTP_IF_NONE_MATCH'", ")", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "$", "headers", "[", "'If-None-Match'", "]", "=", "$", "this", "->", "input", "->", "server", "(", "'HTTP_IF_NONE_MATCH'", ")", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", ")", ")", "{", "/**\n * Can we work the headers out for ourself?\n * Credit: http://www.php.net/manual/en/function.apache-request-headers.php#70810\n **/", "$", "headers", "=", "array", "(", ")", ";", "$", "rxHttp", "=", "'/\\AHTTP_/'", ";", "foreach", "(", "$", "_SERVER", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "preg_match", "(", "$", "rxHttp", ",", "$", "key", ")", ")", "{", "$", "arhKey", "=", "preg_replace", "(", "$", "rxHttp", ",", "''", ",", "$", "key", ")", ";", "$", "rxMatches", "=", "array", "(", ")", ";", "/**\n * Do some nasty string manipulations to restore the original letter case\n * this should work in most cases\n **/", "$", "rxMatches", "=", "explode", "(", "'_'", ",", "$", "arhKey", ")", ";", "if", "(", "count", "(", "$", "rxMatches", ")", ">", "0", "&&", "strlen", "(", "$", "arhKey", ")", ">", "2", ")", "{", "foreach", "(", "$", "rxMatches", "as", "$", "ak_key", "=>", "$", "ak_val", ")", "{", "$", "rxMatches", "[", "$", "ak_key", "]", "=", "ucfirst", "(", "$", "ak_val", ")", ";", "}", "$", "arhKey", "=", "implode", "(", "'-'", ",", "$", "rxMatches", ")", ";", "}", "$", "headers", "[", "$", "arhKey", "]", "=", "$", "val", ";", "}", "}", "}", "else", "{", "// Give up.", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "headers", "[", "'If-None-Match'", "]", ")", "&&", "$", "headers", "[", "'If-None-Match'", "]", "==", "'\"'", ".", "md5", "(", "$", "file", ")", ".", "'\"'", ")", "{", "header", "(", "$", "this", "->", "input", "->", "server", "(", "'SERVER_PROTOCOL'", ")", ".", "' 304 Not Modified'", ",", "true", ",", "304", ")", ";", "return", "true", ";", "}", "// --------------------------------------------------------------------------", "return", "false", ";", "}" ]
Serve the "not modified" headers, if appropriate @param string $file The file to server headers for @return boolean
[ "Serve", "the", "not", "modified", "headers", "if", "appropriate" ]
c8c9dbb5b458edc5d58d80c1350819a66036cfdb
https://github.com/nails/module-barcode/blob/c8c9dbb5b458edc5d58d80c1350819a66036cfdb/barcode/controllers/Barcode.php#L143-L206
225,707
cmsgears/module-notify
common/services/resources/AnnouncementService.php
AnnouncementService.getRecentByAdmin
public function getRecentByAdmin( $limit = 5, $config = [] ) { $modelClass = static::$modelClass; $modelTable = $this->getModelTable(); $siteId = Yii::$app->core->siteId; $config[ 'conditions' ][] = "$modelTable.access >=" . Announcement::ACCESS_APP_ADMIN; return $modelClass::find() ->where( $config[ 'conditions' ] ) ->andWhere( [ 'siteId' => $siteId, 'status' => $modelClass::STATUS_ACTIVE ] ) ->limit( $limit ) ->orderBy( 'createdAt DESC' ) ->all(); }
php
public function getRecentByAdmin( $limit = 5, $config = [] ) { $modelClass = static::$modelClass; $modelTable = $this->getModelTable(); $siteId = Yii::$app->core->siteId; $config[ 'conditions' ][] = "$modelTable.access >=" . Announcement::ACCESS_APP_ADMIN; return $modelClass::find() ->where( $config[ 'conditions' ] ) ->andWhere( [ 'siteId' => $siteId, 'status' => $modelClass::STATUS_ACTIVE ] ) ->limit( $limit ) ->orderBy( 'createdAt DESC' ) ->all(); }
[ "public", "function", "getRecentByAdmin", "(", "$", "limit", "=", "5", ",", "$", "config", "=", "[", "]", ")", "{", "$", "modelClass", "=", "static", "::", "$", "modelClass", ";", "$", "modelTable", "=", "$", "this", "->", "getModelTable", "(", ")", ";", "$", "siteId", "=", "Yii", "::", "$", "app", "->", "core", "->", "siteId", ";", "$", "config", "[", "'conditions'", "]", "[", "]", "=", "\"$modelTable.access >=\"", ".", "Announcement", "::", "ACCESS_APP_ADMIN", ";", "return", "$", "modelClass", "::", "find", "(", ")", "->", "where", "(", "$", "config", "[", "'conditions'", "]", ")", "->", "andWhere", "(", "[", "'siteId'", "=>", "$", "siteId", ",", "'status'", "=>", "$", "modelClass", "::", "STATUS_ACTIVE", "]", ")", "->", "limit", "(", "$", "limit", ")", "->", "orderBy", "(", "'createdAt DESC'", ")", "->", "all", "(", ")", ";", "}" ]
It returns the most recent announcements that can be displayed on Admin. @param integer $limit @param array $config @return \cmsgears\notify\common\models\resources\Announcement
[ "It", "returns", "the", "most", "recent", "announcements", "that", "can", "be", "displayed", "on", "Admin", "." ]
2cca001d47dc4615c49cc704f0a3f8b0baf03cf6
https://github.com/cmsgears/module-notify/blob/2cca001d47dc4615c49cc704f0a3f8b0baf03cf6/common/services/resources/AnnouncementService.php#L245-L260
225,708
railken/amethyst-price-rule
src/PriceRules/ExpressionPriceRule.php
ExpressionPriceRule.calculate
public function calculate(PriceRule $priceRule, float $price, array $options = []) { $payload = $priceRule->payload; $options = (object) $options; $parser = new StdMathParser(); if (!isset($payload->expression)) { throw new Exceptions\PriceRuleWrongPayloadException('Missing expression in payload'); } if (!isset($options->vars)) { throw new Exceptions\PriceRuleWrongOptionsException('Missing vars in options'); } $ast = $parser->parse($payload->expression); $evaluator = new Evaluator(); $evaluator->setVariables(array_merge(['x' => $price], $options->vars)); return floatval($ast->accept($evaluator)); }
php
public function calculate(PriceRule $priceRule, float $price, array $options = []) { $payload = $priceRule->payload; $options = (object) $options; $parser = new StdMathParser(); if (!isset($payload->expression)) { throw new Exceptions\PriceRuleWrongPayloadException('Missing expression in payload'); } if (!isset($options->vars)) { throw new Exceptions\PriceRuleWrongOptionsException('Missing vars in options'); } $ast = $parser->parse($payload->expression); $evaluator = new Evaluator(); $evaluator->setVariables(array_merge(['x' => $price], $options->vars)); return floatval($ast->accept($evaluator)); }
[ "public", "function", "calculate", "(", "PriceRule", "$", "priceRule", ",", "float", "$", "price", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "payload", "=", "$", "priceRule", "->", "payload", ";", "$", "options", "=", "(", "object", ")", "$", "options", ";", "$", "parser", "=", "new", "StdMathParser", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "payload", "->", "expression", ")", ")", "{", "throw", "new", "Exceptions", "\\", "PriceRuleWrongPayloadException", "(", "'Missing expression in payload'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "->", "vars", ")", ")", "{", "throw", "new", "Exceptions", "\\", "PriceRuleWrongOptionsException", "(", "'Missing vars in options'", ")", ";", "}", "$", "ast", "=", "$", "parser", "->", "parse", "(", "$", "payload", "->", "expression", ")", ";", "$", "evaluator", "=", "new", "Evaluator", "(", ")", ";", "$", "evaluator", "->", "setVariables", "(", "array_merge", "(", "[", "'x'", "=>", "$", "price", "]", ",", "$", "options", "->", "vars", ")", ")", ";", "return", "floatval", "(", "$", "ast", "->", "accept", "(", "$", "evaluator", ")", ")", ";", "}" ]
Given the base priceRule calculate the final price. @param PriceRule $priceRule @param float $price @param array $options @return float
[ "Given", "the", "base", "priceRule", "calculate", "the", "final", "price", "." ]
cdcdab58f61d85faa99525d7087ce1abd1a8388a
https://github.com/railken/amethyst-price-rule/blob/cdcdab58f61d85faa99525d7087ce1abd1a8388a/src/PriceRules/ExpressionPriceRule.php#L22-L43
225,709
975L/PaymentBundle
Twig/PaymentButton.php
PaymentButton.paymentButton
public function paymentButton(Environment $environment, $text = null, $amount = null, $currency = null, $style = 'btn btn-lg btn-primary') { return $environment->render('@c975LPayment/fragments/paymentButton.html.twig', array( 'text' => $text, 'amount' => $amount, 'currency' => strtolower($currency), 'style' => $style, )); }
php
public function paymentButton(Environment $environment, $text = null, $amount = null, $currency = null, $style = 'btn btn-lg btn-primary') { return $environment->render('@c975LPayment/fragments/paymentButton.html.twig', array( 'text' => $text, 'amount' => $amount, 'currency' => strtolower($currency), 'style' => $style, )); }
[ "public", "function", "paymentButton", "(", "Environment", "$", "environment", ",", "$", "text", "=", "null", ",", "$", "amount", "=", "null", ",", "$", "currency", "=", "null", ",", "$", "style", "=", "'btn btn-lg btn-primary'", ")", "{", "return", "$", "environment", "->", "render", "(", "'@c975LPayment/fragments/paymentButton.html.twig'", ",", "array", "(", "'text'", "=>", "$", "text", ",", "'amount'", "=>", "$", "amount", ",", "'currency'", "=>", "strtolower", "(", "$", "currency", ")", ",", "'style'", "=>", "$", "style", ",", ")", ")", ";", "}" ]
Returns xhtml code for Payment button @return string
[ "Returns", "xhtml", "code", "for", "Payment", "button" ]
da3beb13842aea6a3dc278eeb565f519040995b7
https://github.com/975L/PaymentBundle/blob/da3beb13842aea6a3dc278eeb565f519040995b7/Twig/PaymentButton.php#L41-L49
225,710
PureBilling/PureMachineSDK
src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php
StoreHelper.createClass
public static function createClass( $class, $data ) { if (!class_exists($class)) { return null; } $ref = new \ReflectionClass($class); if ($ref->isAbstract()) { return null; } $store = new $class($data); return $store; }
php
public static function createClass( $class, $data ) { if (!class_exists($class)) { return null; } $ref = new \ReflectionClass($class); if ($ref->isAbstract()) { return null; } $store = new $class($data); return $store; }
[ "public", "static", "function", "createClass", "(", "$", "class", ",", "$", "data", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "return", "null", ";", "}", "$", "ref", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "if", "(", "$", "ref", "->", "isAbstract", "(", ")", ")", "{", "return", "null", ";", "}", "$", "store", "=", "new", "$", "class", "(", "$", "data", ")", ";", "return", "$", "store", ";", "}" ]
Create a class if exists and not abstract
[ "Create", "a", "class", "if", "exists", "and", "not", "abstract" ]
1cd3b6a629cbc913513a5d043e6423d1836d5177
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php#L92-L107
225,711
PureBilling/PureMachineSDK
src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php
StoreHelper.getStoreClass
public static function getStoreClass($inValue, array $defaultClassName) { //Get the class inside the values if ($inValue && isset($inValue->_className) && class_exists($inValue->_className)) { return $inValue->_className; } //We take it from the array if there is only one if (count($defaultClassName) == 1 && class_exists($defaultClassName[0])) { return $defaultClassName[0]; } //Multiple options, using type to decide the store class if (count($defaultClassName) > 1) { $matchedClasses = []; foreach ($defaultClassName as $defaultClassNameItem) { $matches = static::matchType($inValue, $defaultClassNameItem); if ($matches) $matchedClasses[] = $matches; } // If only 1 has matched, we use this definition class if (count($matchedClasses)==1) { return $matchedClasses[0]; } } return null; }
php
public static function getStoreClass($inValue, array $defaultClassName) { //Get the class inside the values if ($inValue && isset($inValue->_className) && class_exists($inValue->_className)) { return $inValue->_className; } //We take it from the array if there is only one if (count($defaultClassName) == 1 && class_exists($defaultClassName[0])) { return $defaultClassName[0]; } //Multiple options, using type to decide the store class if (count($defaultClassName) > 1) { $matchedClasses = []; foreach ($defaultClassName as $defaultClassNameItem) { $matches = static::matchType($inValue, $defaultClassNameItem); if ($matches) $matchedClasses[] = $matches; } // If only 1 has matched, we use this definition class if (count($matchedClasses)==1) { return $matchedClasses[0]; } } return null; }
[ "public", "static", "function", "getStoreClass", "(", "$", "inValue", ",", "array", "$", "defaultClassName", ")", "{", "//Get the class inside the values", "if", "(", "$", "inValue", "&&", "isset", "(", "$", "inValue", "->", "_className", ")", "&&", "class_exists", "(", "$", "inValue", "->", "_className", ")", ")", "{", "return", "$", "inValue", "->", "_className", ";", "}", "//We take it from the array if there is only one", "if", "(", "count", "(", "$", "defaultClassName", ")", "==", "1", "&&", "class_exists", "(", "$", "defaultClassName", "[", "0", "]", ")", ")", "{", "return", "$", "defaultClassName", "[", "0", "]", ";", "}", "//Multiple options, using type to decide the store class", "if", "(", "count", "(", "$", "defaultClassName", ")", ">", "1", ")", "{", "$", "matchedClasses", "=", "[", "]", ";", "foreach", "(", "$", "defaultClassName", "as", "$", "defaultClassNameItem", ")", "{", "$", "matches", "=", "static", "::", "matchType", "(", "$", "inValue", ",", "$", "defaultClassNameItem", ")", ";", "if", "(", "$", "matches", ")", "$", "matchedClasses", "[", "]", "=", "$", "matches", ";", "}", "// If only 1 has matched, we use this definition class", "if", "(", "count", "(", "$", "matchedClasses", ")", "==", "1", ")", "{", "return", "$", "matchedClasses", "[", "0", "]", ";", "}", "}", "return", "null", ";", "}" ]
return a string that represent a store. Look first inside the $inValue. If mot, take if from the definition and check if class exists in definition @param array $definition
[ "return", "a", "string", "that", "represent", "a", "store", "." ]
1cd3b6a629cbc913513a5d043e6423d1836d5177
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php#L119-L146
225,712
PureBilling/PureMachineSDK
src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php
StoreHelper.matchType
public static function matchType($inValue, $className) { if ($inValue instanceof \stdClass) { $inValueKeys = array_keys(get_object_vars($inValue)); if (in_array('_type', $inValueKeys)) { $tempStore = new $className(); $tempStoreType = $tempStore->get_type(); if ($tempStoreType===$inValue->_type) return $className; } } return null; }
php
public static function matchType($inValue, $className) { if ($inValue instanceof \stdClass) { $inValueKeys = array_keys(get_object_vars($inValue)); if (in_array('_type', $inValueKeys)) { $tempStore = new $className(); $tempStoreType = $tempStore->get_type(); if ($tempStoreType===$inValue->_type) return $className; } } return null; }
[ "public", "static", "function", "matchType", "(", "$", "inValue", ",", "$", "className", ")", "{", "if", "(", "$", "inValue", "instanceof", "\\", "stdClass", ")", "{", "$", "inValueKeys", "=", "array_keys", "(", "get_object_vars", "(", "$", "inValue", ")", ")", ";", "if", "(", "in_array", "(", "'_type'", ",", "$", "inValueKeys", ")", ")", "{", "$", "tempStore", "=", "new", "$", "className", "(", ")", ";", "$", "tempStoreType", "=", "$", "tempStore", "->", "get_type", "(", ")", ";", "if", "(", "$", "tempStoreType", "===", "$", "inValue", "->", "_type", ")", "return", "$", "className", ";", "}", "}", "return", "null", ";", "}" ]
Use the _type in value to detect if matches with an array of classes given @param $inValue @param $className @return mixed
[ "Use", "the", "_type", "in", "value", "to", "detect", "if", "matches", "with", "an", "array", "of", "classes", "given" ]
1cd3b6a629cbc913513a5d043e6423d1836d5177
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php#L156-L167
225,713
PureBilling/PureMachineSDK
src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php
StoreHelper.checkStoreClass
public static function checkStoreClass($store, array $storeClasses, array $allowedId) { if (is_string($store) && strstr($store, '_')) { list($prefix, $id) = explode('_', $store); if (in_array($prefix, $allowedId)) { return true; } return false; } if (in_array(get_class($store), $storeClasses)) return true; return false; }
php
public static function checkStoreClass($store, array $storeClasses, array $allowedId) { if (is_string($store) && strstr($store, '_')) { list($prefix, $id) = explode('_', $store); if (in_array($prefix, $allowedId)) { return true; } return false; } if (in_array(get_class($store), $storeClasses)) return true; return false; }
[ "public", "static", "function", "checkStoreClass", "(", "$", "store", ",", "array", "$", "storeClasses", ",", "array", "$", "allowedId", ")", "{", "if", "(", "is_string", "(", "$", "store", ")", "&&", "strstr", "(", "$", "store", ",", "'_'", ")", ")", "{", "list", "(", "$", "prefix", ",", "$", "id", ")", "=", "explode", "(", "'_'", ",", "$", "store", ")", ";", "if", "(", "in_array", "(", "$", "prefix", ",", "$", "allowedId", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "if", "(", "in_array", "(", "get_class", "(", "$", "store", ")", ",", "$", "storeClasses", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Check if the store class type is part of declared classes in storeClasses.
[ "Check", "if", "the", "store", "class", "type", "is", "part", "of", "declared", "classes", "in", "storeClasses", "." ]
1cd3b6a629cbc913513a5d043e6423d1836d5177
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Store/Base/StoreHelper.php#L173-L187
225,714
Eve-PHP/Framework
src/Cli/Generate.php
Generate.copy
public function copy($source, $destination) { $contents = $this('file', $source)->getContent(); $template = $this->engine->compile($contents); $code = $template($this->schema); $code = str_replace('\\\\', '\\', $code); $code = str_replace('\}', '}', $code); $code = str_replace('\{', '{', $code); $code = str_replace('{ ', '{', $code); $code = preg_replace('/\n\s*\n\s*\n/', "\n\n", $code); Index::info('Installing to' . $destination); $this('file', $destination)->setContent($code); return $this; }
php
public function copy($source, $destination) { $contents = $this('file', $source)->getContent(); $template = $this->engine->compile($contents); $code = $template($this->schema); $code = str_replace('\\\\', '\\', $code); $code = str_replace('\}', '}', $code); $code = str_replace('\{', '{', $code); $code = str_replace('{ ', '{', $code); $code = preg_replace('/\n\s*\n\s*\n/', "\n\n", $code); Index::info('Installing to' . $destination); $this('file', $destination)->setContent($code); return $this; }
[ "public", "function", "copy", "(", "$", "source", ",", "$", "destination", ")", "{", "$", "contents", "=", "$", "this", "(", "'file'", ",", "$", "source", ")", "->", "getContent", "(", ")", ";", "$", "template", "=", "$", "this", "->", "engine", "->", "compile", "(", "$", "contents", ")", ";", "$", "code", "=", "$", "template", "(", "$", "this", "->", "schema", ")", ";", "$", "code", "=", "str_replace", "(", "'\\\\\\\\'", ",", "'\\\\'", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "'\\}'", ",", "'}'", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "'\\{'", ",", "'{'", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "'{ '", ",", "'{'", ",", "$", "code", ")", ";", "$", "code", "=", "preg_replace", "(", "'/\\n\\s*\\n\\s*\\n/'", ",", "\"\\n\\n\"", ",", "$", "code", ")", ";", "Index", "::", "info", "(", "'Installing to'", ".", "$", "destination", ")", ";", "$", "this", "(", "'file'", ",", "$", "destination", ")", "->", "setContent", "(", "$", "code", ")", ";", "return", "$", "this", ";", "}" ]
Copy the contents from to @return Eve\Framework\Cli\Generate
[ "Copy", "the", "contents", "from", "to" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Cli/Generate.php#L515-L532
225,715
Erebot/API
src/Event/Match/CollectionAbstract.php
CollectionAbstract.&
public function & add($filter) { $filters = func_get_args(); foreach ($filters as $filter) { if (!($filter instanceof \Erebot\Interfaces\Event\Match)) { throw new \Erebot\InvalidValueException('Not a valid matcher'); } if (!in_array($filter, $this->submatchers, true)) { $this->submatchers[] = $filter; } } return $this; }
php
public function & add($filter) { $filters = func_get_args(); foreach ($filters as $filter) { if (!($filter instanceof \Erebot\Interfaces\Event\Match)) { throw new \Erebot\InvalidValueException('Not a valid matcher'); } if (!in_array($filter, $this->submatchers, true)) { $this->submatchers[] = $filter; } } return $this; }
[ "public", "function", "&", "add", "(", "$", "filter", ")", "{", "$", "filters", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "(", "$", "filter", "instanceof", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Match", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Not a valid matcher'", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "filter", ",", "$", "this", "->", "submatchers", ",", "true", ")", ")", "{", "$", "this", "->", "submatchers", "[", "]", "=", "$", "filter", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds one or more subfilters to this filter. \retval Erebot::Event::Match::CollectionAbstract Returns this instance, so that multiple calls to Erebot::Event::Match::CollectionAbstract::add() can be chained up together. \param $filter,... One or more filters to add as subfilters of this filter. Duplicates are silently ignored.
[ "Adds", "one", "or", "more", "subfilters", "to", "this", "filter", "." ]
0bff8d2048ace141aca0a536b931cf9a0186e1e3
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Event/Match/CollectionAbstract.php#L105-L117
225,716
Erebot/API
src/Event/Match/CollectionAbstract.php
CollectionAbstract.&
public function & remove($filter) { $filters = func_get_args(); foreach ($filters as $filter) { if (!($filter instanceof \Erebot\Interfaces\Event\Match)) { throw new \Erebot\InvalidValueException('Not a valid matcher'); } $key = array_search($filter, $this->submatchers, true); if ($key !== false) { unset($this->submatchers[$key]); } } return $this; }
php
public function & remove($filter) { $filters = func_get_args(); foreach ($filters as $filter) { if (!($filter instanceof \Erebot\Interfaces\Event\Match)) { throw new \Erebot\InvalidValueException('Not a valid matcher'); } $key = array_search($filter, $this->submatchers, true); if ($key !== false) { unset($this->submatchers[$key]); } } return $this; }
[ "public", "function", "&", "remove", "(", "$", "filter", ")", "{", "$", "filters", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "(", "$", "filter", "instanceof", "\\", "Erebot", "\\", "Interfaces", "\\", "Event", "\\", "Match", ")", ")", "{", "throw", "new", "\\", "Erebot", "\\", "InvalidValueException", "(", "'Not a valid matcher'", ")", ";", "}", "$", "key", "=", "array_search", "(", "$", "filter", ",", "$", "this", "->", "submatchers", ",", "true", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "submatchers", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Removes one or more subfilters from this filter. \retval Erebot::Event::Match::CollectionAbstract Returns this instance, so that multiple calls to Erebot::Event::Match::CollectionAbstract::remove() can be chained up together. \param $filter,... One or more filters to remove from this filter's subfilters. Filters which are not currently subfilters of this filter are silently ignored.
[ "Removes", "one", "or", "more", "subfilters", "from", "this", "filter", "." ]
0bff8d2048ace141aca0a536b931cf9a0186e1e3
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Event/Match/CollectionAbstract.php#L132-L145
225,717
SetBased/php-abc-form-louver
src/Control/SlatControlFactory.php
SlatControlFactory.createFormControl
public function createFormControl(ComplexControl $parentControl, string $slatJointName, ?string $controlName = null): Control { $control = $this->slatJoints[$slatJointName]->createControl($controlName ?? $slatJointName); $parentControl->addFormControl($control); return $control; }
php
public function createFormControl(ComplexControl $parentControl, string $slatJointName, ?string $controlName = null): Control { $control = $this->slatJoints[$slatJointName]->createControl($controlName ?? $slatJointName); $parentControl->addFormControl($control); return $control; }
[ "public", "function", "createFormControl", "(", "ComplexControl", "$", "parentControl", ",", "string", "$", "slatJointName", ",", "?", "string", "$", "controlName", "=", "null", ")", ":", "Control", "{", "$", "control", "=", "$", "this", "->", "slatJoints", "[", "$", "slatJointName", "]", "->", "createControl", "(", "$", "controlName", "??", "$", "slatJointName", ")", ";", "$", "parentControl", "->", "addFormControl", "(", "$", "control", ")", ";", "return", "$", "control", ";", "}" ]
Creates a form control using a slat joint and returns the created form control. @param ComplexControl $parentControl The parent form control for the created form control. @param string $slatJointName The name of the slat joint. @param string|null $controlName The name of the created form control. If null the form control will have the same name as the slat joint. Use '' for an empty name (should only be used if the created form control is a complex form control). @return Control
[ "Creates", "a", "form", "control", "using", "a", "slat", "joint", "and", "returns", "the", "created", "form", "control", "." ]
59ff07a59da4ba90ef9665a8893559cd66d37233
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/SlatControlFactory.php#L70-L78
225,718
SetBased/php-abc-form-louver
src/Control/SlatControlFactory.php
SlatControlFactory.getHtmlColumnGroup
public function getHtmlColumnGroup(): string { $ret = ''; foreach ($this->slatJoints as $factory) { $ret .= $factory->getHtmlCol(); } $ret .= '<col/>'; return $ret; }
php
public function getHtmlColumnGroup(): string { $ret = ''; foreach ($this->slatJoints as $factory) { $ret .= $factory->getHtmlCol(); } $ret .= '<col/>'; return $ret; }
[ "public", "function", "getHtmlColumnGroup", "(", ")", ":", "string", "{", "$", "ret", "=", "''", ";", "foreach", "(", "$", "this", "->", "slatJoints", "as", "$", "factory", ")", "{", "$", "ret", ".=", "$", "factory", "->", "getHtmlCol", "(", ")", ";", "}", "$", "ret", ".=", "'<col/>'", ";", "return", "$", "ret", ";", "}" ]
Returns the inner HTML code of the colgroup element of the table form control. @return string
[ "Returns", "the", "inner", "HTML", "code", "of", "the", "colgroup", "element", "of", "the", "table", "form", "control", "." ]
59ff07a59da4ba90ef9665a8893559cd66d37233
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/SlatControlFactory.php#L144-L155
225,719
SetBased/php-abc-form-louver
src/Control/SlatControlFactory.php
SlatControlFactory.getHtmlHeader
public function getHtmlHeader(): string { $ret = Html::generateTag('tr', ['class' => [OverviewTable::$class, 'header']]); foreach ($this->slatJoints as $factory) { $ret .= $factory->getHtmlColumnHeader(); } $ret .= '<th class="error"></th>'; $ret .= '</tr>'; if ($this->filter) { $ret .= Html::generateTag('tr', ['class' => [OverviewTable::$class, 'filter']]); foreach ($this->slatJoints as $factory) { $ret .= $factory->getHtmlColumnFilter(); } $ret .= '<th class="error"></th>'; $ret .= '</tr>'; } return $ret; }
php
public function getHtmlHeader(): string { $ret = Html::generateTag('tr', ['class' => [OverviewTable::$class, 'header']]); foreach ($this->slatJoints as $factory) { $ret .= $factory->getHtmlColumnHeader(); } $ret .= '<th class="error"></th>'; $ret .= '</tr>'; if ($this->filter) { $ret .= Html::generateTag('tr', ['class' => [OverviewTable::$class, 'filter']]); foreach ($this->slatJoints as $factory) { $ret .= $factory->getHtmlColumnFilter(); } $ret .= '<th class="error"></th>'; $ret .= '</tr>'; } return $ret; }
[ "public", "function", "getHtmlHeader", "(", ")", ":", "string", "{", "$", "ret", "=", "Html", "::", "generateTag", "(", "'tr'", ",", "[", "'class'", "=>", "[", "OverviewTable", "::", "$", "class", ",", "'header'", "]", "]", ")", ";", "foreach", "(", "$", "this", "->", "slatJoints", "as", "$", "factory", ")", "{", "$", "ret", ".=", "$", "factory", "->", "getHtmlColumnHeader", "(", ")", ";", "}", "$", "ret", ".=", "'<th class=\"error\"></th>'", ";", "$", "ret", ".=", "'</tr>'", ";", "if", "(", "$", "this", "->", "filter", ")", "{", "$", "ret", ".=", "Html", "::", "generateTag", "(", "'tr'", ",", "[", "'class'", "=>", "[", "OverviewTable", "::", "$", "class", ",", "'filter'", "]", "]", ")", ";", "foreach", "(", "$", "this", "->", "slatJoints", "as", "$", "factory", ")", "{", "$", "ret", ".=", "$", "factory", "->", "getHtmlColumnFilter", "(", ")", ";", "}", "$", "ret", ".=", "'<th class=\"error\"></th>'", ";", "$", "ret", ".=", "'</tr>'", ";", "}", "return", "$", "ret", ";", "}" ]
Returns the inner HTML code of the thead element of the table form control. @return string
[ "Returns", "the", "inner", "HTML", "code", "of", "the", "thead", "element", "of", "the", "table", "form", "control", "." ]
59ff07a59da4ba90ef9665a8893559cd66d37233
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/SlatControlFactory.php#L163-L185
225,720
SetBased/php-abc-form-louver
src/Control/SlatControlFactory.php
SlatControlFactory.getOrdinal
public function getOrdinal(string $slatJointName): int { $ordinal = 0; $key = null; foreach ($this->slatJoints as $key => $slat_joint) { if ($key==$slatJointName) break; $ordinal += $slat_joint->getColSpan(); } if ($key!=$slatJointName) { throw new LogicException("SlatJoint '%s' not found.", $slatJointName); } return $ordinal; }
php
public function getOrdinal(string $slatJointName): int { $ordinal = 0; $key = null; foreach ($this->slatJoints as $key => $slat_joint) { if ($key==$slatJointName) break; $ordinal += $slat_joint->getColSpan(); } if ($key!=$slatJointName) { throw new LogicException("SlatJoint '%s' not found.", $slatJointName); } return $ordinal; }
[ "public", "function", "getOrdinal", "(", "string", "$", "slatJointName", ")", ":", "int", "{", "$", "ordinal", "=", "0", ";", "$", "key", "=", "null", ";", "foreach", "(", "$", "this", "->", "slatJoints", "as", "$", "key", "=>", "$", "slat_joint", ")", "{", "if", "(", "$", "key", "==", "$", "slatJointName", ")", "break", ";", "$", "ordinal", "+=", "$", "slat_joint", "->", "getColSpan", "(", ")", ";", "}", "if", "(", "$", "key", "!=", "$", "slatJointName", ")", "{", "throw", "new", "LogicException", "(", "\"SlatJoint '%s' not found.\"", ",", "$", "slatJointName", ")", ";", "}", "return", "$", "ordinal", ";", "}" ]
Returns the 0-indexed ordinal of a slat joint in the underlying table of the louver form control. @param string $slatJointName The name of the slat joint. @return int @throws LogicException
[ "Returns", "the", "0", "-", "indexed", "ordinal", "of", "a", "slat", "joint", "in", "the", "underlying", "table", "of", "the", "louver", "form", "control", "." ]
59ff07a59da4ba90ef9665a8893559cd66d37233
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/SlatControlFactory.php#L208-L225
225,721
MASNathan/Object
src/SuperObject.php
SuperObject.set
public function set($key, $value) { // If a child is an associative array or an stdClass we convert it as well if ((is_array($value) && (bool) count(array_filter(array_keys($value), 'is_string'))) || (is_object($value) && get_class($value) == 'stdClass')) { $value = new self($value); } elseif (is_array($value) && empty($value)) { $value = new self(); } $this->data->$key = $value; return $this; }
php
public function set($key, $value) { // If a child is an associative array or an stdClass we convert it as well if ((is_array($value) && (bool) count(array_filter(array_keys($value), 'is_string'))) || (is_object($value) && get_class($value) == 'stdClass')) { $value = new self($value); } elseif (is_array($value) && empty($value)) { $value = new self(); } $this->data->$key = $value; return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "// If a child is an associative array or an stdClass we convert it as well", "if", "(", "(", "is_array", "(", "$", "value", ")", "&&", "(", "bool", ")", "count", "(", "array_filter", "(", "array_keys", "(", "$", "value", ")", ",", "'is_string'", ")", ")", ")", "||", "(", "is_object", "(", "$", "value", ")", "&&", "get_class", "(", "$", "value", ")", "==", "'stdClass'", ")", ")", "{", "$", "value", "=", "new", "self", "(", "$", "value", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", "&&", "empty", "(", "$", "value", ")", ")", "{", "$", "value", "=", "new", "self", "(", ")", ";", "}", "$", "this", "->", "data", "->", "$", "key", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets a value to the requested key @param string $key Key @param mixed $value Value
[ "Sets", "a", "value", "to", "the", "requested", "key" ]
19154ddce8ef371bf97901fe17a3a09cfb54aff1
https://github.com/MASNathan/Object/blob/19154ddce8ef371bf97901fe17a3a09cfb54aff1/src/SuperObject.php#L70-L81
225,722
MASNathan/Object
src/SuperObject.php
SuperObject.toArray
public function toArray($convertRecursively = true) { if ($convertRecursively) { // We use the json serializer as help to recursively convert the Object instances return json_decode(json_encode($this), true); } else { return (array) $this->data; } }
php
public function toArray($convertRecursively = true) { if ($convertRecursively) { // We use the json serializer as help to recursively convert the Object instances return json_decode(json_encode($this), true); } else { return (array) $this->data; } }
[ "public", "function", "toArray", "(", "$", "convertRecursively", "=", "true", ")", "{", "if", "(", "$", "convertRecursively", ")", "{", "// We use the json serializer as help to recursively convert the Object instances", "return", "json_decode", "(", "json_encode", "(", "$", "this", ")", ",", "true", ")", ";", "}", "else", "{", "return", "(", "array", ")", "$", "this", "->", "data", ";", "}", "}" ]
Recursively converts all the Object instances to array @return array
[ "Recursively", "converts", "all", "the", "Object", "instances", "to", "array" ]
19154ddce8ef371bf97901fe17a3a09cfb54aff1
https://github.com/MASNathan/Object/blob/19154ddce8ef371bf97901fe17a3a09cfb54aff1/src/SuperObject.php#L229-L237
225,723
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Compiler/CoreInitializationPass.php
CoreInitializationPass.process
public function process(ContainerBuilder $container) { // Connect to database and build manifest $frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path'); $_GET['flush'] = 1; require_once $frameworkPath . '/core/Core.php'; if(class_exists('TestRunner')) { // 3.x compat \TestRunner::use_test_manifest(); } else { \SapphireTest::use_test_manifest(); } unset($_GET['flush']); // Remove the error handler so that PHPUnit can add its own restore_error_handler(); }
php
public function process(ContainerBuilder $container) { // Connect to database and build manifest $frameworkPath = $container->getParameter('behat.silverstripe_extension.framework_path'); $_GET['flush'] = 1; require_once $frameworkPath . '/core/Core.php'; if(class_exists('TestRunner')) { // 3.x compat \TestRunner::use_test_manifest(); } else { \SapphireTest::use_test_manifest(); } unset($_GET['flush']); // Remove the error handler so that PHPUnit can add its own restore_error_handler(); }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "// Connect to database and build manifest", "$", "frameworkPath", "=", "$", "container", "->", "getParameter", "(", "'behat.silverstripe_extension.framework_path'", ")", ";", "$", "_GET", "[", "'flush'", "]", "=", "1", ";", "require_once", "$", "frameworkPath", ".", "'/core/Core.php'", ";", "if", "(", "class_exists", "(", "'TestRunner'", ")", ")", "{", "// 3.x compat", "\\", "TestRunner", "::", "use_test_manifest", "(", ")", ";", "}", "else", "{", "\\", "SapphireTest", "::", "use_test_manifest", "(", ")", ";", "}", "unset", "(", "$", "_GET", "[", "'flush'", "]", ")", ";", "// Remove the error handler so that PHPUnit can add its own", "restore_error_handler", "(", ")", ";", "}" ]
Loads kernel file. @param ContainerBuilder $container
[ "Loads", "kernel", "file", "." ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Compiler/CoreInitializationPass.php#L18-L36
225,724
stubbles/stubbles-input
src/main/php/filter/RangeFilter.php
RangeFilter.wrap
public static function wrap(Filter $filter, Range $range = null) { if (null === $range) { return $filter; } return new self($filter, $range); }
php
public static function wrap(Filter $filter, Range $range = null) { if (null === $range) { return $filter; } return new self($filter, $range); }
[ "public", "static", "function", "wrap", "(", "Filter", "$", "filter", ",", "Range", "$", "range", "=", "null", ")", "{", "if", "(", "null", "===", "$", "range", ")", "{", "return", "$", "filter", ";", "}", "return", "new", "self", "(", "$", "filter", ",", "$", "range", ")", ";", "}" ]
utility method that wraps given filter with given range @param \stubbles\input\Filter $filter decorated filter @param \stubbles\input\filter\range\Range $range range definition @return \stubbles\input\Filter
[ "utility", "method", "that", "wraps", "given", "filter", "with", "given", "range" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/RangeFilter.php#L52-L59
225,725
DrNixx/yii2-onix
src/system/DateIntervalHelper.php
DateIntervalHelper.totalDays
public static function totalDays($interval) { if ($interval->days !== false) { return $interval->days; } else { return $interval->d + self::totalMonths($interval) * 30; } }
php
public static function totalDays($interval) { if ($interval->days !== false) { return $interval->days; } else { return $interval->d + self::totalMonths($interval) * 30; } }
[ "public", "static", "function", "totalDays", "(", "$", "interval", ")", "{", "if", "(", "$", "interval", "->", "days", "!==", "false", ")", "{", "return", "$", "interval", "->", "days", ";", "}", "else", "{", "return", "$", "interval", "->", "d", "+", "self", "::", "totalMonths", "(", "$", "interval", ")", "*", "30", ";", "}", "}" ]
Total days in interval @param \DateInterval $interval @return int
[ "Total", "days", "in", "interval" ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/system/DateIntervalHelper.php#L52-L59
225,726
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/SilverStripeContext.php
SilverStripeContext.getRegionObj
public function getRegionObj($region) { // Try to find regions directly by CSS selector. try { $regionObj = $this->getSession()->getPage()->find( 'css', // Escape CSS selector (false !== strpos($region, "'")) ? str_replace("'", "\'", $region) : $region ); if($regionObj) { return $regionObj; } } catch(\Symfony\Component\CssSelector\Exception\SyntaxErrorException $e) { // fall through to next case } // Fall back to region identified by data-title. // Only apply if no double quotes exist in search string, // which would break the CSS selector. if(false === strpos($region, '"')) { $regionObj = $this->getSession()->getPage()->find( 'css', '[data-title="' . $region . '"]' ); if($regionObj) { return $regionObj; } } // Look for named region if(!$this->regionMap) { throw new \LogicException("Cannot find 'region_map' in the behat.yml"); } if(!array_key_exists($region, $this->regionMap)) { throw new \LogicException("Cannot find the specified region in the behat.yml"); } $regionObj = $this->getSession()->getPage()->find('css', $region); if(!$regionObj) { throw new ElementNotFoundException("Cannot find the specified region on the page"); } return $regionObj; }
php
public function getRegionObj($region) { // Try to find regions directly by CSS selector. try { $regionObj = $this->getSession()->getPage()->find( 'css', // Escape CSS selector (false !== strpos($region, "'")) ? str_replace("'", "\'", $region) : $region ); if($regionObj) { return $regionObj; } } catch(\Symfony\Component\CssSelector\Exception\SyntaxErrorException $e) { // fall through to next case } // Fall back to region identified by data-title. // Only apply if no double quotes exist in search string, // which would break the CSS selector. if(false === strpos($region, '"')) { $regionObj = $this->getSession()->getPage()->find( 'css', '[data-title="' . $region . '"]' ); if($regionObj) { return $regionObj; } } // Look for named region if(!$this->regionMap) { throw new \LogicException("Cannot find 'region_map' in the behat.yml"); } if(!array_key_exists($region, $this->regionMap)) { throw new \LogicException("Cannot find the specified region in the behat.yml"); } $regionObj = $this->getSession()->getPage()->find('css', $region); if(!$regionObj) { throw new ElementNotFoundException("Cannot find the specified region on the page"); } return $regionObj; }
[ "public", "function", "getRegionObj", "(", "$", "region", ")", "{", "// Try to find regions directly by CSS selector.", "try", "{", "$", "regionObj", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", "->", "find", "(", "'css'", ",", "// Escape CSS selector", "(", "false", "!==", "strpos", "(", "$", "region", ",", "\"'\"", ")", ")", "?", "str_replace", "(", "\"'\"", ",", "\"\\'\"", ",", "$", "region", ")", ":", "$", "region", ")", ";", "if", "(", "$", "regionObj", ")", "{", "return", "$", "regionObj", ";", "}", "}", "catch", "(", "\\", "Symfony", "\\", "Component", "\\", "CssSelector", "\\", "Exception", "\\", "SyntaxErrorException", "$", "e", ")", "{", "// fall through to next case", "}", "// Fall back to region identified by data-title.", "// Only apply if no double quotes exist in search string,", "// which would break the CSS selector.", "if", "(", "false", "===", "strpos", "(", "$", "region", ",", "'\"'", ")", ")", "{", "$", "regionObj", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", "->", "find", "(", "'css'", ",", "'[data-title=\"'", ".", "$", "region", ".", "'\"]'", ")", ";", "if", "(", "$", "regionObj", ")", "{", "return", "$", "regionObj", ";", "}", "}", "// Look for named region", "if", "(", "!", "$", "this", "->", "regionMap", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Cannot find 'region_map' in the behat.yml\"", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "region", ",", "$", "this", "->", "regionMap", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "\"Cannot find the specified region in the behat.yml\"", ")", ";", "}", "$", "regionObj", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", "->", "find", "(", "'css'", ",", "$", "region", ")", ";", "if", "(", "!", "$", "regionObj", ")", "{", "throw", "new", "ElementNotFoundException", "(", "\"Cannot find the specified region on the page\"", ")", ";", "}", "return", "$", "regionObj", ";", "}" ]
Returns MinkElement based off region defined in .yml file. Also supports direct CSS selectors and regions identified by a "data-title" attribute. When using the "data-title" attribute, ensure not to include double quotes. @param String $region Region name or CSS selector @return MinkElement|null
[ "Returns", "MinkElement", "based", "off", "region", "defined", "in", ".", "yml", "file", ".", "Also", "supports", "direct", "CSS", "selectors", "and", "regions", "identified", "by", "a", "data", "-", "title", "attribute", ".", "When", "using", "the", "data", "-", "title", "attribute", "ensure", "not", "to", "include", "double", "quotes", "." ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php#L139-L180
225,727
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/SilverStripeContext.php
SilverStripeContext.parseUrl
public function parseUrl($url) { $url = parse_url($url); $url['vars'] = array(); if (!isset($url['fragment'])) { $url['fragment'] = null; } if (isset($url['query'])) { parse_str($url['query'], $url['vars']); } return $url; }
php
public function parseUrl($url) { $url = parse_url($url); $url['vars'] = array(); if (!isset($url['fragment'])) { $url['fragment'] = null; } if (isset($url['query'])) { parse_str($url['query'], $url['vars']); } return $url; }
[ "public", "function", "parseUrl", "(", "$", "url", ")", "{", "$", "url", "=", "parse_url", "(", "$", "url", ")", ";", "$", "url", "[", "'vars'", "]", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "url", "[", "'fragment'", "]", ")", ")", "{", "$", "url", "[", "'fragment'", "]", "=", "null", ";", "}", "if", "(", "isset", "(", "$", "url", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "url", "[", "'query'", "]", ",", "$", "url", "[", "'vars'", "]", ")", ";", "}", "return", "$", "url", ";", "}" ]
Parses given URL and returns its components @param $url @return array|mixed Parsed URL
[ "Parses", "given", "URL", "and", "returns", "its", "components" ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php#L243-L254
225,728
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/SilverStripeContext.php
SilverStripeContext.joinUrlParts
public function joinUrlParts() { if (0 === func_num_args()) { throw new \InvalidArgumentException('Need at least one argument'); } $parts = func_get_args(); $trimSlashes = function(&$part) { $part = trim($part, '/'); }; array_walk($parts, $trimSlashes); return implode('/', $parts); }
php
public function joinUrlParts() { if (0 === func_num_args()) { throw new \InvalidArgumentException('Need at least one argument'); } $parts = func_get_args(); $trimSlashes = function(&$part) { $part = trim($part, '/'); }; array_walk($parts, $trimSlashes); return implode('/', $parts); }
[ "public", "function", "joinUrlParts", "(", ")", "{", "if", "(", "0", "===", "func_num_args", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Need at least one argument'", ")", ";", "}", "$", "parts", "=", "func_get_args", "(", ")", ";", "$", "trimSlashes", "=", "function", "(", "&", "$", "part", ")", "{", "$", "part", "=", "trim", "(", "$", "part", ",", "'/'", ")", ";", "}", ";", "array_walk", "(", "$", "parts", ",", "$", "trimSlashes", ")", ";", "return", "implode", "(", "'/'", ",", "$", "parts", ")", ";", "}" ]
Joins URL parts into an URL using forward slash. Forward slash usages are normalised to one between parts. This method takes variable number of parameters. @param $... @return string @throws \InvalidArgumentException
[ "Joins", "URL", "parts", "into", "an", "URL", "using", "forward", "slash", ".", "Forward", "slash", "usages", "are", "normalised", "to", "one", "between", "parts", ".", "This", "method", "takes", "variable", "number", "of", "parameters", "." ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php#L305-L317
225,729
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/SilverStripeContext.php
SilverStripeContext.selectOption
public function selectOption($select, $option) { // Find field $field = $this ->getSession() ->getPage() ->findField($this->fixStepArgument($select)); // If field is visible then select it as per normal if($field && $field->isVisible()) { parent::selectOption($select, $option); } else { $this->selectOptionWithJavascript($select, $option); } }
php
public function selectOption($select, $option) { // Find field $field = $this ->getSession() ->getPage() ->findField($this->fixStepArgument($select)); // If field is visible then select it as per normal if($field && $field->isVisible()) { parent::selectOption($select, $option); } else { $this->selectOptionWithJavascript($select, $option); } }
[ "public", "function", "selectOption", "(", "$", "select", ",", "$", "option", ")", "{", "// Find field", "$", "field", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", "->", "findField", "(", "$", "this", "->", "fixStepArgument", "(", "$", "select", ")", ")", ";", "// If field is visible then select it as per normal", "if", "(", "$", "field", "&&", "$", "field", "->", "isVisible", "(", ")", ")", "{", "parent", "::", "selectOption", "(", "$", "select", ",", "$", "option", ")", ";", "}", "else", "{", "$", "this", "->", "selectOptionWithJavascript", "(", "$", "select", ",", "$", "option", ")", ";", "}", "}" ]
Selects option in select field with specified id|name|label|value. @override /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)"$/
[ "Selects", "option", "in", "select", "field", "with", "specified", "id|name|label|value", "." ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php#L436-L449
225,730
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/SilverStripeContext.php
SilverStripeContext.selectOptionWithJavascript
public function selectOptionWithJavascript($select, $option) { $select = $this->fixStepArgument($select); $option = $this->fixStepArgument($option); $page = $this->getSession()->getPage(); // Find field $field = $page->findField($select); if (null === $field) { throw new ElementNotFoundException($this->getSession(), 'form field', 'id|name|label|value', $select); } // Find option $opt = $field->find('named', array( 'option', $this->getSession()->getSelectorsHandler()->xpathLiteral($option) )); if (null === $opt) { throw new ElementNotFoundException($this->getSession(), 'select option', 'value|text', $option); } // Merge new option in with old handling both multiselect and single select $value = $field->getValue(); $newValue = $opt->getAttribute('value'); if(is_array($value)) { if(!in_array($newValue, $value)) $value[] = $newValue; } else { $value = $newValue; } $valueEncoded = json_encode($value); // Inject this value via javascript $fieldID = $field->getAttribute('ID'); $script = <<<EOS (function($) { $("#$fieldID") .val($valueEncoded) .change() .trigger('liszt:updated') .trigger('chosen:updated'); })(jQuery); EOS; $this->getSession()->getDriver()->executeScript($script); }
php
public function selectOptionWithJavascript($select, $option) { $select = $this->fixStepArgument($select); $option = $this->fixStepArgument($option); $page = $this->getSession()->getPage(); // Find field $field = $page->findField($select); if (null === $field) { throw new ElementNotFoundException($this->getSession(), 'form field', 'id|name|label|value', $select); } // Find option $opt = $field->find('named', array( 'option', $this->getSession()->getSelectorsHandler()->xpathLiteral($option) )); if (null === $opt) { throw new ElementNotFoundException($this->getSession(), 'select option', 'value|text', $option); } // Merge new option in with old handling both multiselect and single select $value = $field->getValue(); $newValue = $opt->getAttribute('value'); if(is_array($value)) { if(!in_array($newValue, $value)) $value[] = $newValue; } else { $value = $newValue; } $valueEncoded = json_encode($value); // Inject this value via javascript $fieldID = $field->getAttribute('ID'); $script = <<<EOS (function($) { $("#$fieldID") .val($valueEncoded) .change() .trigger('liszt:updated') .trigger('chosen:updated'); })(jQuery); EOS; $this->getSession()->getDriver()->executeScript($script); }
[ "public", "function", "selectOptionWithJavascript", "(", "$", "select", ",", "$", "option", ")", "{", "$", "select", "=", "$", "this", "->", "fixStepArgument", "(", "$", "select", ")", ";", "$", "option", "=", "$", "this", "->", "fixStepArgument", "(", "$", "option", ")", ";", "$", "page", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "// Find field", "$", "field", "=", "$", "page", "->", "findField", "(", "$", "select", ")", ";", "if", "(", "null", "===", "$", "field", ")", "{", "throw", "new", "ElementNotFoundException", "(", "$", "this", "->", "getSession", "(", ")", ",", "'form field'", ",", "'id|name|label|value'", ",", "$", "select", ")", ";", "}", "// Find option", "$", "opt", "=", "$", "field", "->", "find", "(", "'named'", ",", "array", "(", "'option'", ",", "$", "this", "->", "getSession", "(", ")", "->", "getSelectorsHandler", "(", ")", "->", "xpathLiteral", "(", "$", "option", ")", ")", ")", ";", "if", "(", "null", "===", "$", "opt", ")", "{", "throw", "new", "ElementNotFoundException", "(", "$", "this", "->", "getSession", "(", ")", ",", "'select option'", ",", "'value|text'", ",", "$", "option", ")", ";", "}", "// Merge new option in with old handling both multiselect and single select", "$", "value", "=", "$", "field", "->", "getValue", "(", ")", ";", "$", "newValue", "=", "$", "opt", "->", "getAttribute", "(", "'value'", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "newValue", ",", "$", "value", ")", ")", "$", "value", "[", "]", "=", "$", "newValue", ";", "}", "else", "{", "$", "value", "=", "$", "newValue", ";", "}", "$", "valueEncoded", "=", "json_encode", "(", "$", "value", ")", ";", "// Inject this value via javascript", "$", "fieldID", "=", "$", "field", "->", "getAttribute", "(", "'ID'", ")", ";", "$", "script", "=", " <<<EOS\n\t\t\t(function($) {\n\t\t\t\t$(\"#$fieldID\")\n\t\t\t\t\t.val($valueEncoded)\n\t\t\t\t\t.change()\n\t\t\t\t\t.trigger('liszt:updated')\n\t\t\t\t\t.trigger('chosen:updated');\n\t\t\t})(jQuery);\nEOS", ";", "$", "this", "->", "getSession", "(", ")", "->", "getDriver", "(", ")", "->", "executeScript", "(", "$", "script", ")", ";", "}" ]
Selects option in select field with specified id|name|label|value using javascript This method uses javascript to allow selection of options that may be overridden by javascript libraries, and thus hide the element. @When /^(?:|I )select "(?P<option>(?:[^"]|\\")*)" from "(?P<select>(?:[^"]|\\")*)" with javascript$/
[ "Selects", "option", "in", "select", "field", "with", "specified", "id|name|label|value", "using", "javascript", "This", "method", "uses", "javascript", "to", "allow", "selection", "of", "options", "that", "may", "be", "overridden", "by", "javascript", "libraries", "and", "thus", "hide", "the", "element", "." ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php#L458-L499
225,731
edineibauer/helpers
public/src/Helpers/Helper.php
Helper.corAuxiliar
public static function corAuxiliar($name) { $style = str_replace("#", "", $name); $style = strlen($style) === 3 ? $style[0] . $style[0] . $style[1] . $style[1] . $style[2] . $style[2] : $style; $todo = hexdec($style[0] . $style[1]) + hexdec($style[2] . $style[3]) + hexdec($style[4] . $style[5]) - 550; if ($todo > 0): //cor clara $base = round($todo / 60); return "#{$base}{$base}{$base}"; else: //cor escura return "#FFF"; endif; }
php
public static function corAuxiliar($name) { $style = str_replace("#", "", $name); $style = strlen($style) === 3 ? $style[0] . $style[0] . $style[1] . $style[1] . $style[2] . $style[2] : $style; $todo = hexdec($style[0] . $style[1]) + hexdec($style[2] . $style[3]) + hexdec($style[4] . $style[5]) - 550; if ($todo > 0): //cor clara $base = round($todo / 60); return "#{$base}{$base}{$base}"; else: //cor escura return "#FFF"; endif; }
[ "public", "static", "function", "corAuxiliar", "(", "$", "name", ")", "{", "$", "style", "=", "str_replace", "(", "\"#\"", ",", "\"\"", ",", "$", "name", ")", ";", "$", "style", "=", "strlen", "(", "$", "style", ")", "===", "3", "?", "$", "style", "[", "0", "]", ".", "$", "style", "[", "0", "]", ".", "$", "style", "[", "1", "]", ".", "$", "style", "[", "1", "]", ".", "$", "style", "[", "2", "]", ".", "$", "style", "[", "2", "]", ":", "$", "style", ";", "$", "todo", "=", "hexdec", "(", "$", "style", "[", "0", "]", ".", "$", "style", "[", "1", "]", ")", "+", "hexdec", "(", "$", "style", "[", "2", "]", ".", "$", "style", "[", "3", "]", ")", "+", "hexdec", "(", "$", "style", "[", "4", "]", ".", "$", "style", "[", "5", "]", ")", "-", "550", ";", "if", "(", "$", "todo", ">", "0", ")", ":", "//cor clara", "$", "base", "=", "round", "(", "$", "todo", "/", "60", ")", ";", "return", "\"#{$base}{$base}{$base}\"", ";", "else", ":", "//cor escura", "return", "\"#FFF\"", ";", "endif", ";", "}" ]
retorna cor auxiliar inversa em hexadecimal @param STRING $name = hexadecimal color @return STRING = cor de resalte à $name
[ "retorna", "cor", "auxiliar", "inversa", "em", "hexadecimal" ]
3ed14fec3a8f2f282107f79f6bd1ca11e6882300
https://github.com/edineibauer/helpers/blob/3ed14fec3a8f2f282107f79f6bd1ca11e6882300/public/src/Helpers/Helper.php#L20-L33
225,732
cmsgears/module-cms
frontend/controllers/post/DefaultController.php
DefaultController.updateStatus
protected function updateStatus( $post, $status ) { // Update Post Status $this->modelService->updateStatus( $post, $status ); return $this->checkStatus( $post ); }
php
protected function updateStatus( $post, $status ) { // Update Post Status $this->modelService->updateStatus( $post, $status ); return $this->checkStatus( $post ); }
[ "protected", "function", "updateStatus", "(", "$", "post", ",", "$", "status", ")", "{", "// Update Post Status", "$", "this", "->", "modelService", "->", "updateStatus", "(", "$", "post", ",", "$", "status", ")", ";", "return", "$", "this", "->", "checkStatus", "(", "$", "post", ")", ";", "}" ]
Update post status and redirect to the last step filled by user.
[ "Update", "post", "status", "and", "redirect", "to", "the", "last", "step", "filled", "by", "user", "." ]
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/frontend/controllers/post/DefaultController.php#L432-L438
225,733
railken/amethyst-work
src/Workers/FileWorker.php
FileWorker.execute
public function execute(Work $work, stdClass $payload, array $data = []) { $generator = $this->manager->getRepository()->findOneById($payload->data->id); $result = $this->manager->generate($generator, $data); }
php
public function execute(Work $work, stdClass $payload, array $data = []) { $generator = $this->manager->getRepository()->findOneById($payload->data->id); $result = $this->manager->generate($generator, $data); }
[ "public", "function", "execute", "(", "Work", "$", "work", ",", "stdClass", "$", "payload", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "generator", "=", "$", "this", "->", "manager", "->", "getRepository", "(", ")", "->", "findOneById", "(", "$", "payload", "->", "data", "->", "id", ")", ";", "$", "result", "=", "$", "this", "->", "manager", "->", "generate", "(", "$", "generator", ",", "$", "data", ")", ";", "}" ]
Dispatch a work. @param Work $work @param array $data
[ "Dispatch", "a", "work", "." ]
ea1d4316a86395da5796b3aee291f8ebe4882aeb
https://github.com/railken/amethyst-work/blob/ea1d4316a86395da5796b3aee291f8ebe4882aeb/src/Workers/FileWorker.php#L30-L35
225,734
bytic/form
src/Renderer/AbstractRenderer.php
AbstractRenderer.renderMessages
public function renderMessages() { $return = ''; $messages = $this->getForm()->getMessages(); foreach ($messages as $type => $lines) { if ($type == "error") { $return .= ErrorsHelper::render($lines); } else { $return .= MessagesHelper::render($lines, $type); } } return $return; }
php
public function renderMessages() { $return = ''; $messages = $this->getForm()->getMessages(); foreach ($messages as $type => $lines) { if ($type == "error") { $return .= ErrorsHelper::render($lines); } else { $return .= MessagesHelper::render($lines, $type); } } return $return; }
[ "public", "function", "renderMessages", "(", ")", "{", "$", "return", "=", "''", ";", "$", "messages", "=", "$", "this", "->", "getForm", "(", ")", "->", "getMessages", "(", ")", ";", "foreach", "(", "$", "messages", "as", "$", "type", "=>", "$", "lines", ")", "{", "if", "(", "$", "type", "==", "\"error\"", ")", "{", "$", "return", ".=", "ErrorsHelper", "::", "render", "(", "$", "lines", ")", ";", "}", "else", "{", "$", "return", ".=", "MessagesHelper", "::", "render", "(", "$", "lines", ",", "$", "type", ")", ";", "}", "}", "return", "$", "return", ";", "}" ]
The errors are rendered using the Errors View Helper @return string
[ "The", "errors", "are", "rendered", "using", "the", "Errors", "View", "Helper" ]
eb0fcb950b912c15f6fde6974e75d61eaaa06248
https://github.com/bytic/form/blob/eb0fcb950b912c15f6fde6974e75d61eaaa06248/src/Renderer/AbstractRenderer.php#L137-L150
225,735
SetBased/php-abc-form-louver
src/Control/SlatControl.php
SlatControl.getHtmlErrorCell
protected function getHtmlErrorCell(): string { $ret = ''; if (!$this->isValid()) { $error_messages = $this->getErrorMessages(true); $ret .= '<td class="error">'; if (!empty($error_messages)) { foreach ($error_messages as $message) { $ret .= Html::txt2Html($message); $ret .= '<br/>'; } } $ret .= '</td>'; } else { $ret .= '<td class="error"></td>'; } return $ret; }
php
protected function getHtmlErrorCell(): string { $ret = ''; if (!$this->isValid()) { $error_messages = $this->getErrorMessages(true); $ret .= '<td class="error">'; if (!empty($error_messages)) { foreach ($error_messages as $message) { $ret .= Html::txt2Html($message); $ret .= '<br/>'; } } $ret .= '</td>'; } else { $ret .= '<td class="error"></td>'; } return $ret; }
[ "protected", "function", "getHtmlErrorCell", "(", ")", ":", "string", "{", "$", "ret", "=", "''", ";", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "{", "$", "error_messages", "=", "$", "this", "->", "getErrorMessages", "(", "true", ")", ";", "$", "ret", ".=", "'<td class=\"error\">'", ";", "if", "(", "!", "empty", "(", "$", "error_messages", ")", ")", "{", "foreach", "(", "$", "error_messages", "as", "$", "message", ")", "{", "$", "ret", ".=", "Html", "::", "txt2Html", "(", "$", "message", ")", ";", "$", "ret", ".=", "'<br/>'", ";", "}", "}", "$", "ret", ".=", "'</td>'", ";", "}", "else", "{", "$", "ret", ".=", "'<td class=\"error\"></td>'", ";", "}", "return", "$", "ret", ";", "}" ]
Returns a table cell with the errors messages of all form controls at this row. @return string
[ "Returns", "a", "table", "cell", "with", "the", "errors", "messages", "of", "all", "form", "controls", "at", "this", "row", "." ]
59ff07a59da4ba90ef9665a8893559cd66d37233
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/SlatControl.php#L108-L133
225,736
bytic/Common
src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php
UsersControllerTrait.afterLoginRedirect
public function afterLoginRedirect() { $redirect = $this->getRequest()->query->get( 'redirect', $this->Url()->default() ); $this->flashRedirect( $this->getModelManager()->getMessage('login-success'), $redirect, 'success', 'index' ); }
php
public function afterLoginRedirect() { $redirect = $this->getRequest()->query->get( 'redirect', $this->Url()->default() ); $this->flashRedirect( $this->getModelManager()->getMessage('login-success'), $redirect, 'success', 'index' ); }
[ "public", "function", "afterLoginRedirect", "(", ")", "{", "$", "redirect", "=", "$", "this", "->", "getRequest", "(", ")", "->", "query", "->", "get", "(", "'redirect'", ",", "$", "this", "->", "Url", "(", ")", "->", "default", "(", ")", ")", ";", "$", "this", "->", "flashRedirect", "(", "$", "this", "->", "getModelManager", "(", ")", "->", "getMessage", "(", "'login-success'", ")", ",", "$", "redirect", ",", "'success'", ",", "'index'", ")", ";", "}" ]
Redirect after login
[ "Redirect", "after", "login" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php#L58-L71
225,737
bytic/Common
src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php
UsersControllerTrait.setLoginMeta
protected function setLoginMeta($action) { $label = $this->getModelManager()->getLabel($action . '-title'); $urlMethod = 'get' . ucfirst($action) . 'URL'; $this->getView()->Breadcrumbs() ->addItem($label, $this->_getUser()->getManager()->$urlMethod()); $this->getView()->Meta()->prependTitle($label); }
php
protected function setLoginMeta($action) { $label = $this->getModelManager()->getLabel($action . '-title'); $urlMethod = 'get' . ucfirst($action) . 'URL'; $this->getView()->Breadcrumbs() ->addItem($label, $this->_getUser()->getManager()->$urlMethod()); $this->getView()->Meta()->prependTitle($label); }
[ "protected", "function", "setLoginMeta", "(", "$", "action", ")", "{", "$", "label", "=", "$", "this", "->", "getModelManager", "(", ")", "->", "getLabel", "(", "$", "action", ".", "'-title'", ")", ";", "$", "urlMethod", "=", "'get'", ".", "ucfirst", "(", "$", "action", ")", ".", "'URL'", ";", "$", "this", "->", "getView", "(", ")", "->", "Breadcrumbs", "(", ")", "->", "addItem", "(", "$", "label", ",", "$", "this", "->", "_getUser", "(", ")", "->", "getManager", "(", ")", "->", "$", "urlMethod", "(", ")", ")", ";", "$", "this", "->", "getView", "(", ")", "->", "Meta", "(", ")", "->", "prependTitle", "(", "$", "label", ")", ";", "}" ]
Set Login Meta @param string $action Action name @return void
[ "Set", "Login", "Meta" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php#L80-L88
225,738
bytic/Common
src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php
UsersControllerTrait.loginWith
public function loginWith() { $providerName = $_REQUEST["provider"]; $redirect = $_GET['redirect']; $userProfile = $this->getAuthProvider()->authenticate($providerName); if ($userProfile instanceof Exception) { $this->getView()->set('exception', $userProfile); } else { $userExist = User_Logins::instance()->getUserByProvider($providerName, $userProfile->identifier); if (!$userExist) { $this->redirect( $this->getModelManager()->getOAuthLinkURL([ 'provider' => $providerName, 'redirect' => $redirect ])); } $userExist->doAuthentication(); $this->afterLoginRedirect(); } }
php
public function loginWith() { $providerName = $_REQUEST["provider"]; $redirect = $_GET['redirect']; $userProfile = $this->getAuthProvider()->authenticate($providerName); if ($userProfile instanceof Exception) { $this->getView()->set('exception', $userProfile); } else { $userExist = User_Logins::instance()->getUserByProvider($providerName, $userProfile->identifier); if (!$userExist) { $this->redirect( $this->getModelManager()->getOAuthLinkURL([ 'provider' => $providerName, 'redirect' => $redirect ])); } $userExist->doAuthentication(); $this->afterLoginRedirect(); } }
[ "public", "function", "loginWith", "(", ")", "{", "$", "providerName", "=", "$", "_REQUEST", "[", "\"provider\"", "]", ";", "$", "redirect", "=", "$", "_GET", "[", "'redirect'", "]", ";", "$", "userProfile", "=", "$", "this", "->", "getAuthProvider", "(", ")", "->", "authenticate", "(", "$", "providerName", ")", ";", "if", "(", "$", "userProfile", "instanceof", "Exception", ")", "{", "$", "this", "->", "getView", "(", ")", "->", "set", "(", "'exception'", ",", "$", "userProfile", ")", ";", "}", "else", "{", "$", "userExist", "=", "User_Logins", "::", "instance", "(", ")", "->", "getUserByProvider", "(", "$", "providerName", ",", "$", "userProfile", "->", "identifier", ")", ";", "if", "(", "!", "$", "userExist", ")", "{", "$", "this", "->", "redirect", "(", "$", "this", "->", "getModelManager", "(", ")", "->", "getOAuthLinkURL", "(", "[", "'provider'", "=>", "$", "providerName", ",", "'redirect'", "=>", "$", "redirect", "]", ")", ")", ";", "}", "$", "userExist", "->", "doAuthentication", "(", ")", ";", "$", "this", "->", "afterLoginRedirect", "(", ")", ";", "}", "}" ]
Login with Auth Provider
[ "Login", "with", "Auth", "Provider" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php#L93-L117
225,739
bytic/Common
src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php
UsersControllerTrait.oAuthLink
public function oAuthLink() { $providerName = $_REQUEST["provider"]; $userProfile = $this->getAuthProvider()->authenticate($providerName); $this->_getUser()->first_name = $userProfile->firstName; $this->_getUser()->last_name = $userProfile->lastName; $this->_getUser()->email = $userProfile->email; foreach (['login', 'register'] as $_action) { $form = $this->_getUser()->getForm($_action); if ($form->execute()) { $userLogin = User_Logins::instance()->getNew(); $userLogin->id_user = $this->_getUser()->id; $userLogin->provider_name = $providerName; $userLogin->provider_uid = $userProfile->identifier; $userLogin->insert(); $this->{'after' . ucfirst($_action) . 'Redirect'}(); } $this->forms[$_action] = $form; } $this->setLoginMeta('login'); }
php
public function oAuthLink() { $providerName = $_REQUEST["provider"]; $userProfile = $this->getAuthProvider()->authenticate($providerName); $this->_getUser()->first_name = $userProfile->firstName; $this->_getUser()->last_name = $userProfile->lastName; $this->_getUser()->email = $userProfile->email; foreach (['login', 'register'] as $_action) { $form = $this->_getUser()->getForm($_action); if ($form->execute()) { $userLogin = User_Logins::instance()->getNew(); $userLogin->id_user = $this->_getUser()->id; $userLogin->provider_name = $providerName; $userLogin->provider_uid = $userProfile->identifier; $userLogin->insert(); $this->{'after' . ucfirst($_action) . 'Redirect'}(); } $this->forms[$_action] = $form; } $this->setLoginMeta('login'); }
[ "public", "function", "oAuthLink", "(", ")", "{", "$", "providerName", "=", "$", "_REQUEST", "[", "\"provider\"", "]", ";", "$", "userProfile", "=", "$", "this", "->", "getAuthProvider", "(", ")", "->", "authenticate", "(", "$", "providerName", ")", ";", "$", "this", "->", "_getUser", "(", ")", "->", "first_name", "=", "$", "userProfile", "->", "firstName", ";", "$", "this", "->", "_getUser", "(", ")", "->", "last_name", "=", "$", "userProfile", "->", "lastName", ";", "$", "this", "->", "_getUser", "(", ")", "->", "email", "=", "$", "userProfile", "->", "email", ";", "foreach", "(", "[", "'login'", ",", "'register'", "]", "as", "$", "_action", ")", "{", "$", "form", "=", "$", "this", "->", "_getUser", "(", ")", "->", "getForm", "(", "$", "_action", ")", ";", "if", "(", "$", "form", "->", "execute", "(", ")", ")", "{", "$", "userLogin", "=", "User_Logins", "::", "instance", "(", ")", "->", "getNew", "(", ")", ";", "$", "userLogin", "->", "id_user", "=", "$", "this", "->", "_getUser", "(", ")", "->", "id", ";", "$", "userLogin", "->", "provider_name", "=", "$", "providerName", ";", "$", "userLogin", "->", "provider_uid", "=", "$", "userProfile", "->", "identifier", ";", "$", "userLogin", "->", "insert", "(", ")", ";", "$", "this", "->", "{", "'after'", ".", "ucfirst", "(", "$", "_action", ")", ".", "'Redirect'", "}", "(", ")", ";", "}", "$", "this", "->", "forms", "[", "$", "_action", "]", "=", "$", "form", ";", "}", "$", "this", "->", "setLoginMeta", "(", "'login'", ")", ";", "}" ]
Link an OAuth to existing user
[ "Link", "an", "OAuth", "to", "existing", "user" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php#L139-L165
225,740
bytic/Common
src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php
UsersControllerTrait.profile
public function profile() { $formsProfile = $this->_getUser()->getForm('profile'); if ($formsProfile->execute()) { $redirect = $this->getRequest()->query->get( 'redirect', $this->getModelManager()->getProfileURL() ); $this->flashRedirect( $this->getModelManager()->getMessage('profile.success'), $redirect ); } $this->forms['profile'] = $formsProfile; $this->setLoginMeta('profile'); }
php
public function profile() { $formsProfile = $this->_getUser()->getForm('profile'); if ($formsProfile->execute()) { $redirect = $this->getRequest()->query->get( 'redirect', $this->getModelManager()->getProfileURL() ); $this->flashRedirect( $this->getModelManager()->getMessage('profile.success'), $redirect ); } $this->forms['profile'] = $formsProfile; $this->setLoginMeta('profile'); }
[ "public", "function", "profile", "(", ")", "{", "$", "formsProfile", "=", "$", "this", "->", "_getUser", "(", ")", "->", "getForm", "(", "'profile'", ")", ";", "if", "(", "$", "formsProfile", "->", "execute", "(", ")", ")", "{", "$", "redirect", "=", "$", "this", "->", "getRequest", "(", ")", "->", "query", "->", "get", "(", "'redirect'", ",", "$", "this", "->", "getModelManager", "(", ")", "->", "getProfileURL", "(", ")", ")", ";", "$", "this", "->", "flashRedirect", "(", "$", "this", "->", "getModelManager", "(", ")", "->", "getMessage", "(", "'profile.success'", ")", ",", "$", "redirect", ")", ";", "}", "$", "this", "->", "forms", "[", "'profile'", "]", "=", "$", "formsProfile", ";", "$", "this", "->", "setLoginMeta", "(", "'profile'", ")", ";", "}" ]
User Profile Page
[ "User", "Profile", "Page" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Application/Modules/Frontend/Controllers/Traits/UsersControllerTrait.php#L212-L228
225,741
charlesportwoodii/rpq-client
src/Job.php
Job.cancel
public function cancel() { if ($this->id === null) { return false; } $key = $this->queue->generateListKey(); $id = "$key:" . $this->id; // Delete the job from the current and scheduled queue, then remove the job details from Redis $result = $this->queue->getClient()->getRedis()->multi() ->zrem($key) ->zrem($key . '-scheduled') ->del($id) ->hset(\date('Y-m-d') . '_cancel', (string)\time(), \json_encode([ 'class' => $this->getWorkerClass(), 'args' => $this->getArgs(), 'priority' => (float)$this->getPriority(), 'id' => $this->getId() ])) ->exec(); $this->workerClass = null; $this->args = []; $this->retry = null; $this->priority = null; return $result[0] === true || $result[1] === true; }
php
public function cancel() { if ($this->id === null) { return false; } $key = $this->queue->generateListKey(); $id = "$key:" . $this->id; // Delete the job from the current and scheduled queue, then remove the job details from Redis $result = $this->queue->getClient()->getRedis()->multi() ->zrem($key) ->zrem($key . '-scheduled') ->del($id) ->hset(\date('Y-m-d') . '_cancel', (string)\time(), \json_encode([ 'class' => $this->getWorkerClass(), 'args' => $this->getArgs(), 'priority' => (float)$this->getPriority(), 'id' => $this->getId() ])) ->exec(); $this->workerClass = null; $this->args = []; $this->retry = null; $this->priority = null; return $result[0] === true || $result[1] === true; }
[ "public", "function", "cancel", "(", ")", "{", "if", "(", "$", "this", "->", "id", "===", "null", ")", "{", "return", "false", ";", "}", "$", "key", "=", "$", "this", "->", "queue", "->", "generateListKey", "(", ")", ";", "$", "id", "=", "\"$key:\"", ".", "$", "this", "->", "id", ";", "// Delete the job from the current and scheduled queue, then remove the job details from Redis", "$", "result", "=", "$", "this", "->", "queue", "->", "getClient", "(", ")", "->", "getRedis", "(", ")", "->", "multi", "(", ")", "->", "zrem", "(", "$", "key", ")", "->", "zrem", "(", "$", "key", ".", "'-scheduled'", ")", "->", "del", "(", "$", "id", ")", "->", "hset", "(", "\\", "date", "(", "'Y-m-d'", ")", ".", "'_cancel'", ",", "(", "string", ")", "\\", "time", "(", ")", ",", "\\", "json_encode", "(", "[", "'class'", "=>", "$", "this", "->", "getWorkerClass", "(", ")", ",", "'args'", "=>", "$", "this", "->", "getArgs", "(", ")", ",", "'priority'", "=>", "(", "float", ")", "$", "this", "->", "getPriority", "(", ")", ",", "'id'", "=>", "$", "this", "->", "getId", "(", ")", "]", ")", ")", "->", "exec", "(", ")", ";", "$", "this", "->", "workerClass", "=", "null", ";", "$", "this", "->", "args", "=", "[", "]", ";", "$", "this", "->", "retry", "=", "null", ";", "$", "this", "->", "priority", "=", "null", ";", "return", "$", "result", "[", "0", "]", "===", "true", "||", "$", "result", "[", "1", "]", "===", "true", ";", "}" ]
Cancels a job from executing @return boolean
[ "Cancels", "a", "job", "from", "executing" ]
9419cfe5c30d35ea54ce8faba7545daea2312e0f
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Job.php#L145-L173
225,742
charlesportwoodii/rpq-client
src/Job.php
Job.retry
public function retry($backOffTime = null) { $retry = $this->getRetry(); // Log the retry $this->queue->getClient()->getRedis()->hset(\date('Y-m-d') . '_retry', (string)\time(), \json_encode([ 'class' => $this->getWorkerClass(), 'args' => $this->getArgs(), 'retry' => \gettype($retry) === 'boolean' ? (bool)$retry : (int)($retry - 1), 'priority' => (float)$this->getPriority(), 'id' => $this->getId() ])); return $this->queue->push( $this->getWorkerClass(), $this->getArgs(), \gettype($retry) === 'boolean' ? (bool)$retry : (int)($retry - 1), (float)$this->getPriority(), \time() + $backOffTime ?? 0, $this->getId() ); }
php
public function retry($backOffTime = null) { $retry = $this->getRetry(); // Log the retry $this->queue->getClient()->getRedis()->hset(\date('Y-m-d') . '_retry', (string)\time(), \json_encode([ 'class' => $this->getWorkerClass(), 'args' => $this->getArgs(), 'retry' => \gettype($retry) === 'boolean' ? (bool)$retry : (int)($retry - 1), 'priority' => (float)$this->getPriority(), 'id' => $this->getId() ])); return $this->queue->push( $this->getWorkerClass(), $this->getArgs(), \gettype($retry) === 'boolean' ? (bool)$retry : (int)($retry - 1), (float)$this->getPriority(), \time() + $backOffTime ?? 0, $this->getId() ); }
[ "public", "function", "retry", "(", "$", "backOffTime", "=", "null", ")", "{", "$", "retry", "=", "$", "this", "->", "getRetry", "(", ")", ";", "// Log the retry", "$", "this", "->", "queue", "->", "getClient", "(", ")", "->", "getRedis", "(", ")", "->", "hset", "(", "\\", "date", "(", "'Y-m-d'", ")", ".", "'_retry'", ",", "(", "string", ")", "\\", "time", "(", ")", ",", "\\", "json_encode", "(", "[", "'class'", "=>", "$", "this", "->", "getWorkerClass", "(", ")", ",", "'args'", "=>", "$", "this", "->", "getArgs", "(", ")", ",", "'retry'", "=>", "\\", "gettype", "(", "$", "retry", ")", "===", "'boolean'", "?", "(", "bool", ")", "$", "retry", ":", "(", "int", ")", "(", "$", "retry", "-", "1", ")", ",", "'priority'", "=>", "(", "float", ")", "$", "this", "->", "getPriority", "(", ")", ",", "'id'", "=>", "$", "this", "->", "getId", "(", ")", "]", ")", ")", ";", "return", "$", "this", "->", "queue", "->", "push", "(", "$", "this", "->", "getWorkerClass", "(", ")", ",", "$", "this", "->", "getArgs", "(", ")", ",", "\\", "gettype", "(", "$", "retry", ")", "===", "'boolean'", "?", "(", "bool", ")", "$", "retry", ":", "(", "int", ")", "(", "$", "retry", "-", "1", ")", ",", "(", "float", ")", "$", "this", "->", "getPriority", "(", ")", ",", "\\", "time", "(", ")", "+", "$", "backOffTime", "??", "0", ",", "$", "this", "->", "getId", "(", ")", ")", ";", "}" ]
Retries a job @param int $backOffTime @return boolean
[ "Retries", "a", "job" ]
9419cfe5c30d35ea54ce8faba7545daea2312e0f
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Job.php#L181-L202
225,743
charlesportwoodii/rpq-client
src/Job.php
Job.end
public function end() { $key = $this->queue->generateListKey(); $key = "$key:" . $this->id; $retry = $this->getRetry(); $result = $this->queue->getClient()->getRedis()->multi() ->del($key) ->hset(\date('Y-m-d') . '_pass', (string)\time(), \json_encode([ 'class' => $this->getWorkerClass(), 'args' => $this->getArgs(), 'retry' => \gettype($retry) === 'boolean' ? (bool)$retry : (int)($retry - 1), 'priority' => (float)$this->getPriority(), 'id' => $this->getId() ])) ->exec(); return $result[0]; }
php
public function end() { $key = $this->queue->generateListKey(); $key = "$key:" . $this->id; $retry = $this->getRetry(); $result = $this->queue->getClient()->getRedis()->multi() ->del($key) ->hset(\date('Y-m-d') . '_pass', (string)\time(), \json_encode([ 'class' => $this->getWorkerClass(), 'args' => $this->getArgs(), 'retry' => \gettype($retry) === 'boolean' ? (bool)$retry : (int)($retry - 1), 'priority' => (float)$this->getPriority(), 'id' => $this->getId() ])) ->exec(); return $result[0]; }
[ "public", "function", "end", "(", ")", "{", "$", "key", "=", "$", "this", "->", "queue", "->", "generateListKey", "(", ")", ";", "$", "key", "=", "\"$key:\"", ".", "$", "this", "->", "id", ";", "$", "retry", "=", "$", "this", "->", "getRetry", "(", ")", ";", "$", "result", "=", "$", "this", "->", "queue", "->", "getClient", "(", ")", "->", "getRedis", "(", ")", "->", "multi", "(", ")", "->", "del", "(", "$", "key", ")", "->", "hset", "(", "\\", "date", "(", "'Y-m-d'", ")", ".", "'_pass'", ",", "(", "string", ")", "\\", "time", "(", ")", ",", "\\", "json_encode", "(", "[", "'class'", "=>", "$", "this", "->", "getWorkerClass", "(", ")", ",", "'args'", "=>", "$", "this", "->", "getArgs", "(", ")", ",", "'retry'", "=>", "\\", "gettype", "(", "$", "retry", ")", "===", "'boolean'", "?", "(", "bool", ")", "$", "retry", ":", "(", "int", ")", "(", "$", "retry", "-", "1", ")", ",", "'priority'", "=>", "(", "float", ")", "$", "this", "->", "getPriority", "(", ")", ",", "'id'", "=>", "$", "this", "->", "getId", "(", ")", "]", ")", ")", "->", "exec", "(", ")", ";", "return", "$", "result", "[", "0", "]", ";", "}" ]
Ends a job and marks it as completed @return boolean
[ "Ends", "a", "job", "and", "marks", "it", "as", "completed" ]
9419cfe5c30d35ea54ce8faba7545daea2312e0f
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Job.php#L209-L227
225,744
charlesportwoodii/rpq-client
src/Job.php
Job.hydrate
private function hydrate() { $key = $this->queue->generateListKey(); $job = $this->queue->getClient()->getRedis()->hGetAll("$key:" . $this->id); if (empty($job)) { throw new JobNotFoundException('Unable to fetch job details from Redis.'); } $this->workerClass = $job['workerClass']; $this->args = \json_decode($job['args'], true); $this->priority = $job['priority']; $r = \explode(':', $job['retry']); if ($r[0] === 'boolean') { $this->retry = (bool)$r[1]; } elseif ($r[0] === 'integer') { $this->retry = (int)$r[1]; } }
php
private function hydrate() { $key = $this->queue->generateListKey(); $job = $this->queue->getClient()->getRedis()->hGetAll("$key:" . $this->id); if (empty($job)) { throw new JobNotFoundException('Unable to fetch job details from Redis.'); } $this->workerClass = $job['workerClass']; $this->args = \json_decode($job['args'], true); $this->priority = $job['priority']; $r = \explode(':', $job['retry']); if ($r[0] === 'boolean') { $this->retry = (bool)$r[1]; } elseif ($r[0] === 'integer') { $this->retry = (int)$r[1]; } }
[ "private", "function", "hydrate", "(", ")", "{", "$", "key", "=", "$", "this", "->", "queue", "->", "generateListKey", "(", ")", ";", "$", "job", "=", "$", "this", "->", "queue", "->", "getClient", "(", ")", "->", "getRedis", "(", ")", "->", "hGetAll", "(", "\"$key:\"", ".", "$", "this", "->", "id", ")", ";", "if", "(", "empty", "(", "$", "job", ")", ")", "{", "throw", "new", "JobNotFoundException", "(", "'Unable to fetch job details from Redis.'", ")", ";", "}", "$", "this", "->", "workerClass", "=", "$", "job", "[", "'workerClass'", "]", ";", "$", "this", "->", "args", "=", "\\", "json_decode", "(", "$", "job", "[", "'args'", "]", ",", "true", ")", ";", "$", "this", "->", "priority", "=", "$", "job", "[", "'priority'", "]", ";", "$", "r", "=", "\\", "explode", "(", "':'", ",", "$", "job", "[", "'retry'", "]", ")", ";", "if", "(", "$", "r", "[", "0", "]", "===", "'boolean'", ")", "{", "$", "this", "->", "retry", "=", "(", "bool", ")", "$", "r", "[", "1", "]", ";", "}", "elseif", "(", "$", "r", "[", "0", "]", "===", "'integer'", ")", "{", "$", "this", "->", "retry", "=", "(", "int", ")", "$", "r", "[", "1", "]", ";", "}", "}" ]
Hydrates the model by pulling data from Redis
[ "Hydrates", "the", "model", "by", "pulling", "data", "from", "Redis" ]
9419cfe5c30d35ea54ce8faba7545daea2312e0f
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Job.php#L257-L276
225,745
ricardopedias/report-collection
src/Libs/Reader.php
Reader.createFromArray
public static function createFromArray(array $array) : Reader { $classname = \get_called_class(); // para permitir abstração $instance = new $classname; $instance->type = 'array'; $instance->buffer = $array; return $instance; }
php
public static function createFromArray(array $array) : Reader { $classname = \get_called_class(); // para permitir abstração $instance = new $classname; $instance->type = 'array'; $instance->buffer = $array; return $instance; }
[ "public", "static", "function", "createFromArray", "(", "array", "$", "array", ")", ":", "Reader", "{", "$", "classname", "=", "\\", "get_called_class", "(", ")", ";", "// para permitir abstração", "$", "instance", "=", "new", "$", "classname", ";", "$", "instance", "->", "type", "=", "'array'", ";", "$", "instance", "->", "buffer", "=", "$", "array", ";", "return", "$", "instance", ";", "}" ]
Importa os dados a partir de um array @param array $array @return ReportCollection\Libs\Reader
[ "Importa", "os", "dados", "a", "partir", "de", "um", "array" ]
8536e2c48f83fa12b5cea20737d50da20945b71d
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/Reader.php#L45-L53
225,746
ricardopedias/report-collection
src/Libs/Reader.php
Reader.toArray
public function toArray() : array { if($this->data !== null) { return $this->data; } if ($this->type == 'spreadsheet') { $this->data = $this->parseDataFromSpreadsheet($this->buffer, $this->extension); } else { $this->data = $this->parseDataFromArray($this->buffer); } return $this->data; }
php
public function toArray() : array { if($this->data !== null) { return $this->data; } if ($this->type == 'spreadsheet') { $this->data = $this->parseDataFromSpreadsheet($this->buffer, $this->extension); } else { $this->data = $this->parseDataFromArray($this->buffer); } return $this->data; }
[ "public", "function", "toArray", "(", ")", ":", "array", "{", "if", "(", "$", "this", "->", "data", "!==", "null", ")", "{", "return", "$", "this", "->", "data", ";", "}", "if", "(", "$", "this", "->", "type", "==", "'spreadsheet'", ")", "{", "$", "this", "->", "data", "=", "$", "this", "->", "parseDataFromSpreadsheet", "(", "$", "this", "->", "buffer", ",", "$", "this", "->", "extension", ")", ";", "}", "else", "{", "$", "this", "->", "data", "=", "$", "this", "->", "parseDataFromArray", "(", "$", "this", "->", "buffer", ")", ";", "}", "return", "$", "this", "->", "data", ";", "}" ]
Devolve os dados em forma de array. @return array
[ "Devolve", "os", "dados", "em", "forma", "de", "array", "." ]
8536e2c48f83fa12b5cea20737d50da20945b71d
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/Reader.php#L285-L299
225,747
cmsgears/module-cart
common/models/resources/Cart.php
Cart.getCartTotal
public function getCartTotal( $precision = 2 ) { $items = $this->activeItems; $total = 0; foreach( $items as $item ) { if( $item->keep ) { $total += $item->getTotalPrice(); } } return round( $total, $precision ); }
php
public function getCartTotal( $precision = 2 ) { $items = $this->activeItems; $total = 0; foreach( $items as $item ) { if( $item->keep ) { $total += $item->getTotalPrice(); } } return round( $total, $precision ); }
[ "public", "function", "getCartTotal", "(", "$", "precision", "=", "2", ")", "{", "$", "items", "=", "$", "this", "->", "activeItems", ";", "$", "total", "=", "0", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "keep", ")", "{", "$", "total", "+=", "$", "item", "->", "getTotalPrice", "(", ")", ";", "}", "}", "return", "round", "(", "$", "total", ",", "$", "precision", ")", ";", "}" ]
Returns the total value of cart. @param integer $precision @return float
[ "Returns", "the", "total", "value", "of", "cart", "." ]
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Cart.php#L238-L253
225,748
cmsgears/module-cart
common/models/resources/Cart.php
Cart.getActiveCount
public function getActiveCount( $type = 'purchase' ) { if( !in_array( $type, [ 'primary', 'purchase', 'quantity', 'weight', 'volume' ] ) ) { return 0; } $cartItems = $this->activeItems; $count = 0; foreach ( $cartItems as $cartItem ) { if( $cartItem->keep ) { $count += $cartItem->$type; } } return $count; }
php
public function getActiveCount( $type = 'purchase' ) { if( !in_array( $type, [ 'primary', 'purchase', 'quantity', 'weight', 'volume' ] ) ) { return 0; } $cartItems = $this->activeItems; $count = 0; foreach ( $cartItems as $cartItem ) { if( $cartItem->keep ) { $count += $cartItem->$type; } } return $count; }
[ "public", "function", "getActiveCount", "(", "$", "type", "=", "'purchase'", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "[", "'primary'", ",", "'purchase'", ",", "'quantity'", ",", "'weight'", ",", "'volume'", "]", ")", ")", "{", "return", "0", ";", "}", "$", "cartItems", "=", "$", "this", "->", "activeItems", ";", "$", "count", "=", "0", ";", "foreach", "(", "$", "cartItems", "as", "$", "cartItem", ")", "{", "if", "(", "$", "cartItem", "->", "keep", ")", "{", "$", "count", "+=", "$", "cartItem", "->", "$", "type", ";", "}", "}", "return", "$", "count", ";", "}" ]
Returns the total items in cart. It accepts $type having column name among primary, purchase, quantity, weight and volume. @param string $type @return float
[ "Returns", "the", "total", "items", "in", "cart", "." ]
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Cart.php#L263-L282
225,749
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderContainer
public function renderContainer( $config = [] ) { $containerView = CodeGenUtil::isAbsolutePath( $this->containerView, true ) ? $this->containerView : "$this->template/$this->containerView"; return $this->render( $containerView, [ 'widget' => $this ] ); }
php
public function renderContainer( $config = [] ) { $containerView = CodeGenUtil::isAbsolutePath( $this->containerView, true ) ? $this->containerView : "$this->template/$this->containerView"; return $this->render( $containerView, [ 'widget' => $this ] ); }
[ "public", "function", "renderContainer", "(", "$", "config", "=", "[", "]", ")", "{", "$", "containerView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "containerView", ",", "true", ")", "?", "$", "this", "->", "containerView", ":", "\"$this->template/$this->containerView\"", ";", "return", "$", "this", "->", "render", "(", "$", "containerView", ",", "[", "'widget'", "=>", "$", "this", "]", ")", ";", "}" ]
Generate and return the HTML of container. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "container", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L196-L201
225,750
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderDragger
public function renderDragger( $config = [] ) { $draggerView = CodeGenUtil::isAbsolutePath( $this->draggerView, true ) ? $this->draggerView : "$this->template/$this->draggerView"; return $this->render( $draggerView, [ 'widget' => $this ] ); }
php
public function renderDragger( $config = [] ) { $draggerView = CodeGenUtil::isAbsolutePath( $this->draggerView, true ) ? $this->draggerView : "$this->template/$this->draggerView"; return $this->render( $draggerView, [ 'widget' => $this ] ); }
[ "public", "function", "renderDragger", "(", "$", "config", "=", "[", "]", ")", "{", "$", "draggerView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "draggerView", ",", "true", ")", "?", "$", "this", "->", "draggerView", ":", "\"$this->template/$this->draggerView\"", ";", "return", "$", "this", "->", "render", "(", "$", "draggerView", ",", "[", "'widget'", "=>", "$", "this", "]", ")", ";", "}" ]
Generate and return the HTML of file dragger having drag area. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "file", "dragger", "having", "drag", "area", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L209-L214
225,751
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderChooser
public function renderChooser( $config = [] ) { $chooserView = CodeGenUtil::isAbsolutePath( $this->chooserView, true ) ? $this->chooserView : "$this->template/$this->chooserView"; return $this->render( $chooserView, [ 'widget' => $this ] ); }
php
public function renderChooser( $config = [] ) { $chooserView = CodeGenUtil::isAbsolutePath( $this->chooserView, true ) ? $this->chooserView : "$this->template/$this->chooserView"; return $this->render( $chooserView, [ 'widget' => $this ] ); }
[ "public", "function", "renderChooser", "(", "$", "config", "=", "[", "]", ")", "{", "$", "chooserView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "chooserView", ",", "true", ")", "?", "$", "this", "->", "chooserView", ":", "\"$this->template/$this->chooserView\"", ";", "return", "$", "this", "->", "render", "(", "$", "chooserView", ",", "[", "'widget'", "=>", "$", "this", "]", ")", ";", "}" ]
Generate and return the HTML of file chooser element. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "file", "chooser", "element", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L222-L227
225,752
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderPreloader
public function renderPreloader( $config = [] ) { $preloaderView = CodeGenUtil::isAbsolutePath( $this->preloaderView, true ) ? $this->preloaderView : "$this->template/$this->preloaderView"; return $this->render( $preloaderView, [ 'widget' => $this ] ); }
php
public function renderPreloader( $config = [] ) { $preloaderView = CodeGenUtil::isAbsolutePath( $this->preloaderView, true ) ? $this->preloaderView : "$this->template/$this->preloaderView"; return $this->render( $preloaderView, [ 'widget' => $this ] ); }
[ "public", "function", "renderPreloader", "(", "$", "config", "=", "[", "]", ")", "{", "$", "preloaderView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "preloaderView", ",", "true", ")", "?", "$", "this", "->", "preloaderView", ":", "\"$this->template/$this->preloaderView\"", ";", "return", "$", "this", "->", "render", "(", "$", "preloaderView", ",", "[", "'widget'", "=>", "$", "this", "]", ")", ";", "}" ]
Generate and return the HTML of pre-loader used to show upload progress. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "pre", "-", "loader", "used", "to", "show", "upload", "progress", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L235-L240
225,753
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderInfo
public function renderInfo( $config = [] ) { $infoView = CodeGenUtil::isAbsolutePath( $this->infoView, true ) ? $this->infoView : "$this->template/$this->infoView"; return $this->render( $infoView, [ 'widget' => $this ] ); }
php
public function renderInfo( $config = [] ) { $infoView = CodeGenUtil::isAbsolutePath( $this->infoView, true ) ? $this->infoView : "$this->template/$this->infoView"; return $this->render( $infoView, [ 'widget' => $this ] ); }
[ "public", "function", "renderInfo", "(", "$", "config", "=", "[", "]", ")", "{", "$", "infoView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "infoView", ",", "true", ")", "?", "$", "this", "->", "infoView", ":", "\"$this->template/$this->infoView\"", ";", "return", "$", "this", "->", "render", "(", "$", "infoView", ",", "[", "'widget'", "=>", "$", "this", "]", ")", ";", "}" ]
Generate and return the HTML of info having fields required to store file. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "info", "having", "fields", "required", "to", "store", "file", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L248-L253
225,754
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderFields
public function renderFields( $config = [] ) { $fieldsView = CodeGenUtil::isAbsolutePath( $this->fieldsView, true ) ? $this->fieldsView : "$this->template/$this->fieldsView"; return $this->render( $fieldsView, [ 'widget' => $this ] ); }
php
public function renderFields( $config = [] ) { $fieldsView = CodeGenUtil::isAbsolutePath( $this->fieldsView, true ) ? $this->fieldsView : "$this->template/$this->fieldsView"; return $this->render( $fieldsView, [ 'widget' => $this ] ); }
[ "public", "function", "renderFields", "(", "$", "config", "=", "[", "]", ")", "{", "$", "fieldsView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "fieldsView", ",", "true", ")", "?", "$", "this", "->", "fieldsView", ":", "\"$this->template/$this->fieldsView\"", ";", "return", "$", "this", "->", "render", "(", "$", "fieldsView", ",", "[", "'widget'", "=>", "$", "this", "]", ")", ";", "}" ]
Generate and return the HTML of fields. These fields will submit additional data required for file. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "fields", ".", "These", "fields", "will", "submit", "additional", "data", "required", "for", "file", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L261-L266
225,755
cmsgears/plugin-file-manager
widgets/FileUploader.php
FileUploader.renderForm
public function renderForm( $config = [], $html = [] ) { $formView = CodeGenUtil::isAbsolutePath( $this->formView, true ) ? $this->formView : "$this->template/$this->formView"; return $this->render( $formView, [ 'widget' => $this, 'infoHtml' => $html[ 'infoHtml' ], 'fieldsHtml' => $html[ 'fieldsHtml' ] ] ); }
php
public function renderForm( $config = [], $html = [] ) { $formView = CodeGenUtil::isAbsolutePath( $this->formView, true ) ? $this->formView : "$this->template/$this->formView"; return $this->render( $formView, [ 'widget' => $this, 'infoHtml' => $html[ 'infoHtml' ], 'fieldsHtml' => $html[ 'fieldsHtml' ] ] ); }
[ "public", "function", "renderForm", "(", "$", "config", "=", "[", "]", ",", "$", "html", "=", "[", "]", ")", "{", "$", "formView", "=", "CodeGenUtil", "::", "isAbsolutePath", "(", "$", "this", "->", "formView", ",", "true", ")", "?", "$", "this", "->", "formView", ":", "\"$this->template/$this->formView\"", ";", "return", "$", "this", "->", "render", "(", "$", "formView", ",", "[", "'widget'", "=>", "$", "this", ",", "'infoHtml'", "=>", "$", "html", "[", "'infoHtml'", "]", ",", "'fieldsHtml'", "=>", "$", "html", "[", "'fieldsHtml'", "]", "]", ")", ";", "}" ]
Generate and return the HTML of form to submit the uploaded file. @param array $config @return string
[ "Generate", "and", "return", "the", "HTML", "of", "form", "to", "submit", "the", "uploaded", "file", "." ]
aad2a109b4c6126efabcadfb38762cd240a60bc5
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/widgets/FileUploader.php#L274-L283
225,756
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/FixtureContext.php
FixtureContext.stepThereAreTheFollowingRecords
public function stepThereAreTheFollowingRecords($dataObject, PyStringNode $string) { $yaml = array_merge(array($dataObject . ':'), $string->getLines()); $yaml = implode("\n ", $yaml); // Save fixtures into database // TODO Run prepareAsset() for each File and Folder record $yamlFixture = new \YamlFixture($yaml); $yamlFixture->writeInto($this->getFixtureFactory()); }
php
public function stepThereAreTheFollowingRecords($dataObject, PyStringNode $string) { $yaml = array_merge(array($dataObject . ':'), $string->getLines()); $yaml = implode("\n ", $yaml); // Save fixtures into database // TODO Run prepareAsset() for each File and Folder record $yamlFixture = new \YamlFixture($yaml); $yamlFixture->writeInto($this->getFixtureFactory()); }
[ "public", "function", "stepThereAreTheFollowingRecords", "(", "$", "dataObject", ",", "PyStringNode", "$", "string", ")", "{", "$", "yaml", "=", "array_merge", "(", "array", "(", "$", "dataObject", ".", "':'", ")", ",", "$", "string", "->", "getLines", "(", ")", ")", ";", "$", "yaml", "=", "implode", "(", "\"\\n \"", ",", "$", "yaml", ")", ";", "// Save fixtures into database", "// TODO Run prepareAsset() for each File and Folder record", "$", "yamlFixture", "=", "new", "\\", "YamlFixture", "(", "$", "yaml", ")", ";", "$", "yamlFixture", "->", "writeInto", "(", "$", "this", "->", "getFixtureFactory", "(", ")", ")", ";", "}" ]
Accepts YAML fixture definitions similar to the ones used in SilverStripe unit testing. Example: Given there are the following member records: member1: Email: member1@test.com member2: Email: member2@test.com @Given /^there are the following ([^\s]*) records$/
[ "Accepts", "YAML", "fixture", "definitions", "similar", "to", "the", "ones", "used", "in", "SilverStripe", "unit", "testing", "." ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/FixtureContext.php#L368-L376
225,757
jeffreyguo/SS-Behat-quicksetup
src/SilverStripe/BehatExtension/Context/FixtureContext.php
FixtureContext.prepareFixture
protected function prepareFixture($class, $identifier, $data = array()) { if($class == 'File' || is_subclass_of($class, 'File')) { $data = $this->prepareAsset($class, $identifier, $data); } return $data; }
php
protected function prepareFixture($class, $identifier, $data = array()) { if($class == 'File' || is_subclass_of($class, 'File')) { $data = $this->prepareAsset($class, $identifier, $data); } return $data; }
[ "protected", "function", "prepareFixture", "(", "$", "class", ",", "$", "identifier", ",", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "$", "class", "==", "'File'", "||", "is_subclass_of", "(", "$", "class", ",", "'File'", ")", ")", "{", "$", "data", "=", "$", "this", "->", "prepareAsset", "(", "$", "class", ",", "$", "identifier", ",", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}" ]
Prepares a fixture for use @param string $class @param string $identifier @param array $data @return array Prepared $data with additional injected fields
[ "Prepares", "a", "fixture", "for", "use" ]
a5172f3a94dc2b364df5c2758a8a1df4f026168e
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/FixtureContext.php#L541-L546
225,758
edineibauer/helpers
public/src/Helpers/Date.php
Date.checkWhichPart
private function checkWhichPart(int $dado, int $position) { if ($dado > 12) { $current = $this->setDateInfo('dia', 'ano'); if ($current) { $this->data[$current] = $dado; $this->position[$current] = $position; } } else { $current = $this->setDateInfo('mes', 'dia', 'ano'); if ($current) { $this->data[$current] = $dado; $this->position[$current] = $position; } } }
php
private function checkWhichPart(int $dado, int $position) { if ($dado > 12) { $current = $this->setDateInfo('dia', 'ano'); if ($current) { $this->data[$current] = $dado; $this->position[$current] = $position; } } else { $current = $this->setDateInfo('mes', 'dia', 'ano'); if ($current) { $this->data[$current] = $dado; $this->position[$current] = $position; } } }
[ "private", "function", "checkWhichPart", "(", "int", "$", "dado", ",", "int", "$", "position", ")", "{", "if", "(", "$", "dado", ">", "12", ")", "{", "$", "current", "=", "$", "this", "->", "setDateInfo", "(", "'dia'", ",", "'ano'", ")", ";", "if", "(", "$", "current", ")", "{", "$", "this", "->", "data", "[", "$", "current", "]", "=", "$", "dado", ";", "$", "this", "->", "position", "[", "$", "current", "]", "=", "$", "position", ";", "}", "}", "else", "{", "$", "current", "=", "$", "this", "->", "setDateInfo", "(", "'mes'", ",", "'dia'", ",", "'ano'", ")", ";", "if", "(", "$", "current", ")", "{", "$", "this", "->", "data", "[", "$", "current", "]", "=", "$", "dado", ";", "$", "this", "->", "position", "[", "$", "current", "]", "=", "$", "position", ";", "}", "}", "}" ]
filtra para determinar onde aplicar este valor inteiro. @param int $position @param int $dado
[ "filtra", "para", "determinar", "onde", "aplicar", "este", "valor", "inteiro", "." ]
3ed14fec3a8f2f282107f79f6bd1ca11e6882300
https://github.com/edineibauer/helpers/blob/3ed14fec3a8f2f282107f79f6bd1ca11e6882300/public/src/Helpers/Date.php#L115-L130
225,759
nails/module-event
src/Service/Event.php
Event.addType
public function addType($mSlug, $sLabel = '', $sDescription = '', $aHooks = []) { if (empty($mSlug)) { return false; } if (is_string($mSlug)) { $this->aEventTypes[$mSlug] = new \stdClass(); $this->aEventTypes[$mSlug]->slug = $mSlug; $this->aEventTypes[$mSlug]->label = $sLabel; $this->aEventTypes[$mSlug]->description = $sDescription; $this->aEventTypes[$mSlug]->hooks = $aHooks; } else { if (empty($mSlug->slug)) { return false; } $this->aEventTypes[$mSlug->slug] = new \stdClass(); $this->aEventTypes[$mSlug->slug]->slug = $mSlug->slug; $this->aEventTypes[$mSlug->slug]->label = $mSlug->label; $this->aEventTypes[$mSlug->slug]->description = $mSlug->description; $this->aEventTypes[$mSlug->slug]->hooks = $mSlug->hooks; } return true; }
php
public function addType($mSlug, $sLabel = '', $sDescription = '', $aHooks = []) { if (empty($mSlug)) { return false; } if (is_string($mSlug)) { $this->aEventTypes[$mSlug] = new \stdClass(); $this->aEventTypes[$mSlug]->slug = $mSlug; $this->aEventTypes[$mSlug]->label = $sLabel; $this->aEventTypes[$mSlug]->description = $sDescription; $this->aEventTypes[$mSlug]->hooks = $aHooks; } else { if (empty($mSlug->slug)) { return false; } $this->aEventTypes[$mSlug->slug] = new \stdClass(); $this->aEventTypes[$mSlug->slug]->slug = $mSlug->slug; $this->aEventTypes[$mSlug->slug]->label = $mSlug->label; $this->aEventTypes[$mSlug->slug]->description = $mSlug->description; $this->aEventTypes[$mSlug->slug]->hooks = $mSlug->hooks; } return true; }
[ "public", "function", "addType", "(", "$", "mSlug", ",", "$", "sLabel", "=", "''", ",", "$", "sDescription", "=", "''", ",", "$", "aHooks", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "mSlug", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_string", "(", "$", "mSlug", ")", ")", "{", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "]", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "]", "->", "slug", "=", "$", "mSlug", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "]", "->", "label", "=", "$", "sLabel", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "]", "->", "description", "=", "$", "sDescription", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "]", "->", "hooks", "=", "$", "aHooks", ";", "}", "else", "{", "if", "(", "empty", "(", "$", "mSlug", "->", "slug", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "->", "slug", "]", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "->", "slug", "]", "->", "slug", "=", "$", "mSlug", "->", "slug", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "->", "slug", "]", "->", "label", "=", "$", "mSlug", "->", "label", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "->", "slug", "]", "->", "description", "=", "$", "mSlug", "->", "description", ";", "$", "this", "->", "aEventTypes", "[", "$", "mSlug", "->", "slug", "]", "->", "hooks", "=", "$", "mSlug", "->", "hooks", ";", "}", "return", "true", ";", "}" ]
Adds a new event type to the stack @param mixed $mSlug The event's slug; calling code refers to events by this value. Alternatively pass a stdClass to set all values. @param string $sLabel The human friendly name to give the event @param string $sDescription The human friendly description of the event's purpose @param array $aHooks An array of hooks to fire when an event is fired @return boolean
[ "Adds", "a", "new", "event", "type", "to", "the", "stack" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L94-L122
225,760
nails/module-event
src/Service/Event.php
Event.destroy
public function destroy($iId) { if (empty($iId)) { $this->setError('Event ID not defined.'); return false; } // ------------------------------------------------------------------------- // Perform delete $oDb = Factory::service('Database'); $oDb->where('id', $iId); $oDb->delete($this->sTable); if ($oDb->affected_rows()) { return true; } else { $this->setError('Event failed to delete'); return false; } }
php
public function destroy($iId) { if (empty($iId)) { $this->setError('Event ID not defined.'); return false; } // ------------------------------------------------------------------------- // Perform delete $oDb = Factory::service('Database'); $oDb->where('id', $iId); $oDb->delete($this->sTable); if ($oDb->affected_rows()) { return true; } else { $this->setError('Event failed to delete'); return false; } }
[ "public", "function", "destroy", "(", "$", "iId", ")", "{", "if", "(", "empty", "(", "$", "iId", ")", ")", "{", "$", "this", "->", "setError", "(", "'Event ID not defined.'", ")", ";", "return", "false", ";", "}", "// -------------------------------------------------------------------------", "// Perform delete", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "where", "(", "'id'", ",", "$", "iId", ")", ";", "$", "oDb", "->", "delete", "(", "$", "this", "->", "sTable", ")", ";", "if", "(", "$", "oDb", "->", "affected_rows", "(", ")", ")", "{", "return", "true", ";", "}", "else", "{", "$", "this", "->", "setError", "(", "'Event failed to delete'", ")", ";", "return", "false", ";", "}", "}" ]
Destroys an event object @param integer $iId The event ID @return boolean
[ "Destroys", "an", "event", "object" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L264-L284
225,761
nails/module-event
src/Service/Event.php
Event.getAllRawQuery
public function getAllRawQuery($iPage = null, $iPerPage = null, $aData = []) { // Fetch all objects from the table $oDb = Factory::service('Database'); $oDb->select($this->sTableAlias . '.*'); $oDb->select('ue.email,u.first_name,u.last_name,u.profile_img,u.gender'); // Apply common items; pass $aData $this->getCountCommonEvent($aData); // -------------------------------------------------------------------------- // Facilitate pagination if (!is_null($iPage)) { /** * Adjust the page variable, reduce by one so that the offset is calculated * correctly. Make sure we don't go into negative numbers */ $iPage--; $iPage = $iPage < 0 ? 0 : $iPage; // Work out what the offset should be $iPerPage = is_null($iPerPage) ? 50 : (int) $iPerPage; $iOffset = $iPage * $iPerPage; $oDb->limit($iPerPage, $iOffset); } return $oDb->get($this->sTable . ' ' . $this->sTableAlias); }
php
public function getAllRawQuery($iPage = null, $iPerPage = null, $aData = []) { // Fetch all objects from the table $oDb = Factory::service('Database'); $oDb->select($this->sTableAlias . '.*'); $oDb->select('ue.email,u.first_name,u.last_name,u.profile_img,u.gender'); // Apply common items; pass $aData $this->getCountCommonEvent($aData); // -------------------------------------------------------------------------- // Facilitate pagination if (!is_null($iPage)) { /** * Adjust the page variable, reduce by one so that the offset is calculated * correctly. Make sure we don't go into negative numbers */ $iPage--; $iPage = $iPage < 0 ? 0 : $iPage; // Work out what the offset should be $iPerPage = is_null($iPerPage) ? 50 : (int) $iPerPage; $iOffset = $iPage * $iPerPage; $oDb->limit($iPerPage, $iOffset); } return $oDb->get($this->sTable . ' ' . $this->sTableAlias); }
[ "public", "function", "getAllRawQuery", "(", "$", "iPage", "=", "null", ",", "$", "iPerPage", "=", "null", ",", "$", "aData", "=", "[", "]", ")", "{", "// Fetch all objects from the table", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "$", "oDb", "->", "select", "(", "$", "this", "->", "sTableAlias", ".", "'.*'", ")", ";", "$", "oDb", "->", "select", "(", "'ue.email,u.first_name,u.last_name,u.profile_img,u.gender'", ")", ";", "// Apply common items; pass $aData", "$", "this", "->", "getCountCommonEvent", "(", "$", "aData", ")", ";", "// --------------------------------------------------------------------------", "// Facilitate pagination", "if", "(", "!", "is_null", "(", "$", "iPage", ")", ")", "{", "/**\n * Adjust the page variable, reduce by one so that the offset is calculated\n * correctly. Make sure we don't go into negative numbers\n */", "$", "iPage", "--", ";", "$", "iPage", "=", "$", "iPage", "<", "0", "?", "0", ":", "$", "iPage", ";", "// Work out what the offset should be", "$", "iPerPage", "=", "is_null", "(", "$", "iPerPage", ")", "?", "50", ":", "(", "int", ")", "$", "iPerPage", ";", "$", "iOffset", "=", "$", "iPage", "*", "$", "iPerPage", ";", "$", "oDb", "->", "limit", "(", "$", "iPerPage", ",", "$", "iOffset", ")", ";", "}", "return", "$", "oDb", "->", "get", "(", "$", "this", "->", "sTable", ".", "' '", ".", "$", "this", "->", "sTableAlias", ")", ";", "}" ]
Returns all event objects. @param integer $iPage The page of objects to return @param integer $iPerPage The number of objects per page @param array $aData Any data to pass to getCountCommon @return object
[ "Returns", "all", "event", "objects", "." ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L297-L328
225,762
nails/module-event
src/Service/Event.php
Event.countAll
public function countAll($aData) { $this->getCountCommonEvent($aData); $oDb = Factory::service('Database'); return $oDb->count_all_results($this->sTable . ' ' . $this->sTableAlias); }
php
public function countAll($aData) { $this->getCountCommonEvent($aData); $oDb = Factory::service('Database'); return $oDb->count_all_results($this->sTable . ' ' . $this->sTableAlias); }
[ "public", "function", "countAll", "(", "$", "aData", ")", "{", "$", "this", "->", "getCountCommonEvent", "(", "$", "aData", ")", ";", "$", "oDb", "=", "Factory", "::", "service", "(", "'Database'", ")", ";", "return", "$", "oDb", "->", "count_all_results", "(", "$", "this", "->", "sTable", ".", "' '", ".", "$", "this", "->", "sTableAlias", ")", ";", "}" ]
Count the total number of events for a certain query @param $aData @return int
[ "Count", "the", "total", "number", "of", "events", "for", "a", "certain", "query" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L400-L405
225,763
nails/module-event
src/Service/Event.php
Event.getById
public function getById($iId) { $aEvents = $this->getAll([ 'where' => [ [$this->sTableAlias . '.id', $iId], ], ]); if (!$aEvents) { return false; } return $aEvents[0]; }
php
public function getById($iId) { $aEvents = $this->getAll([ 'where' => [ [$this->sTableAlias . '.id', $iId], ], ]); if (!$aEvents) { return false; } return $aEvents[0]; }
[ "public", "function", "getById", "(", "$", "iId", ")", "{", "$", "aEvents", "=", "$", "this", "->", "getAll", "(", "[", "'where'", "=>", "[", "[", "$", "this", "->", "sTableAlias", ".", "'.id'", ",", "$", "iId", "]", ",", "]", ",", "]", ")", ";", "if", "(", "!", "$", "aEvents", ")", "{", "return", "false", ";", "}", "return", "$", "aEvents", "[", "0", "]", ";", "}" ]
Return an individual event @param integer $iId The event's ID @return mixed stdClass on success, false on failure
[ "Return", "an", "individual", "event" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L416-L429
225,764
nails/module-event
src/Service/Event.php
Event.getByType
public function getByType($sType) { $aEvents = $this->getAll([ 'where' => [ [$this->sTableAlias . '.type', $sType], ], ]); if (!$aEvents) { return false; } return $aEvents[0]; }
php
public function getByType($sType) { $aEvents = $this->getAll([ 'where' => [ [$this->sTableAlias . '.type', $sType], ], ]); if (!$aEvents) { return false; } return $aEvents[0]; }
[ "public", "function", "getByType", "(", "$", "sType", ")", "{", "$", "aEvents", "=", "$", "this", "->", "getAll", "(", "[", "'where'", "=>", "[", "[", "$", "this", "->", "sTableAlias", ".", "'.type'", ",", "$", "sType", "]", ",", "]", ",", "]", ")", ";", "if", "(", "!", "$", "aEvents", ")", "{", "return", "false", ";", "}", "return", "$", "aEvents", "[", "0", "]", ";", "}" ]
Returns events of a particular type @param string $sType The type of event to return @return boolean|array
[ "Returns", "events", "of", "a", "particular", "type" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L440-L453
225,765
nails/module-event
src/Service/Event.php
Event.getByUser
public function getByUser($iUserId) { $aEvents = $this->getAll([ 'where' => [ [$this->sTableAlias . '.created_by', $iUserId], ], ]); if (!$aEvents) { return false; } return $aEvents[0]; }
php
public function getByUser($iUserId) { $aEvents = $this->getAll([ 'where' => [ [$this->sTableAlias . '.created_by', $iUserId], ], ]); if (!$aEvents) { return false; } return $aEvents[0]; }
[ "public", "function", "getByUser", "(", "$", "iUserId", ")", "{", "$", "aEvents", "=", "$", "this", "->", "getAll", "(", "[", "'where'", "=>", "[", "[", "$", "this", "->", "sTableAlias", ".", "'.created_by'", ",", "$", "iUserId", "]", ",", "]", ",", "]", ")", ";", "if", "(", "!", "$", "aEvents", ")", "{", "return", "false", ";", "}", "return", "$", "aEvents", "[", "0", "]", ";", "}" ]
Returns events created by a user @param integer $iUserId The ID of the user @return boolean|array
[ "Returns", "events", "created", "by", "a", "user" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L464-L477
225,766
nails/module-event
src/Service/Event.php
Event.getTypeBySlug
public function getTypeBySlug($sSlug) { return isset($this->aEventTypes[$sSlug]) ? $this->aEventTypes[$sSlug] : false; }
php
public function getTypeBySlug($sSlug) { return isset($this->aEventTypes[$sSlug]) ? $this->aEventTypes[$sSlug] : false; }
[ "public", "function", "getTypeBySlug", "(", "$", "sSlug", ")", "{", "return", "isset", "(", "$", "this", "->", "aEventTypes", "[", "$", "sSlug", "]", ")", "?", "$", "this", "->", "aEventTypes", "[", "$", "sSlug", "]", ":", "false", ";", "}" ]
Get an individual type of event @param string $sSlug The event's slug @return mixed stdClass on success, false on failure
[ "Get", "an", "individual", "type", "of", "event" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L499-L502
225,767
nails/module-event
src/Service/Event.php
Event.getAllTypesFlat
public function getAllTypesFlat() { $aTypes = $this->getAllTypes(); $aOut = []; foreach ($aTypes as $oType) { $aOut[$oType->slug] = $oType->label ? $oType->label : title_case(str_replace('_', ' ', $oType->slug)); } return $aOut; }
php
public function getAllTypesFlat() { $aTypes = $this->getAllTypes(); $aOut = []; foreach ($aTypes as $oType) { $aOut[$oType->slug] = $oType->label ? $oType->label : title_case(str_replace('_', ' ', $oType->slug)); } return $aOut; }
[ "public", "function", "getAllTypesFlat", "(", ")", "{", "$", "aTypes", "=", "$", "this", "->", "getAllTypes", "(", ")", ";", "$", "aOut", "=", "[", "]", ";", "foreach", "(", "$", "aTypes", "as", "$", "oType", ")", "{", "$", "aOut", "[", "$", "oType", "->", "slug", "]", "=", "$", "oType", "->", "label", "?", "$", "oType", "->", "label", ":", "title_case", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "oType", "->", "slug", ")", ")", ";", "}", "return", "$", "aOut", ";", "}" ]
Get the differing types of event as a flat array @return array
[ "Get", "the", "differing", "types", "of", "event", "as", "a", "flat", "array" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L510-L520
225,768
nails/module-event
src/Service/Event.php
Event.formatObject
protected function formatObject(&$oObj) { // Ints $oObj->ref = $oObj->ref ? (int) $oObj->ref : null; // Type $temp = $this->getTypeBySlug($oObj->type); if (empty($temp)) { $temp = new \stdClass(); $temp->slug = $oObj->type; $temp->label = ''; $temp->description = ''; $temp->hooks = []; } $oObj->type = $temp; // Data $oObj->data = json_decode($oObj->data); // User $oObj->user = new \stdClass(); $oObj->user->id = $oObj->created_by; $oObj->user->email = $oObj->email; $oObj->user->first_name = $oObj->first_name; $oObj->user->last_name = $oObj->last_name; $oObj->user->profile_img = $oObj->profile_img; $oObj->user->gender = $oObj->gender; unset($oObj->created_by); unset($oObj->email); unset($oObj->first_name); unset($oObj->last_name); unset($oObj->profile_img); unset($oObj->gender); }
php
protected function formatObject(&$oObj) { // Ints $oObj->ref = $oObj->ref ? (int) $oObj->ref : null; // Type $temp = $this->getTypeBySlug($oObj->type); if (empty($temp)) { $temp = new \stdClass(); $temp->slug = $oObj->type; $temp->label = ''; $temp->description = ''; $temp->hooks = []; } $oObj->type = $temp; // Data $oObj->data = json_decode($oObj->data); // User $oObj->user = new \stdClass(); $oObj->user->id = $oObj->created_by; $oObj->user->email = $oObj->email; $oObj->user->first_name = $oObj->first_name; $oObj->user->last_name = $oObj->last_name; $oObj->user->profile_img = $oObj->profile_img; $oObj->user->gender = $oObj->gender; unset($oObj->created_by); unset($oObj->email); unset($oObj->first_name); unset($oObj->last_name); unset($oObj->profile_img); unset($oObj->gender); }
[ "protected", "function", "formatObject", "(", "&", "$", "oObj", ")", "{", "// Ints", "$", "oObj", "->", "ref", "=", "$", "oObj", "->", "ref", "?", "(", "int", ")", "$", "oObj", "->", "ref", ":", "null", ";", "// Type", "$", "temp", "=", "$", "this", "->", "getTypeBySlug", "(", "$", "oObj", "->", "type", ")", ";", "if", "(", "empty", "(", "$", "temp", ")", ")", "{", "$", "temp", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "temp", "->", "slug", "=", "$", "oObj", "->", "type", ";", "$", "temp", "->", "label", "=", "''", ";", "$", "temp", "->", "description", "=", "''", ";", "$", "temp", "->", "hooks", "=", "[", "]", ";", "}", "$", "oObj", "->", "type", "=", "$", "temp", ";", "// Data", "$", "oObj", "->", "data", "=", "json_decode", "(", "$", "oObj", "->", "data", ")", ";", "// User", "$", "oObj", "->", "user", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "oObj", "->", "user", "->", "id", "=", "$", "oObj", "->", "created_by", ";", "$", "oObj", "->", "user", "->", "email", "=", "$", "oObj", "->", "email", ";", "$", "oObj", "->", "user", "->", "first_name", "=", "$", "oObj", "->", "first_name", ";", "$", "oObj", "->", "user", "->", "last_name", "=", "$", "oObj", "->", "last_name", ";", "$", "oObj", "->", "user", "->", "profile_img", "=", "$", "oObj", "->", "profile_img", ";", "$", "oObj", "->", "user", "->", "gender", "=", "$", "oObj", "->", "gender", ";", "unset", "(", "$", "oObj", "->", "created_by", ")", ";", "unset", "(", "$", "oObj", "->", "email", ")", ";", "unset", "(", "$", "oObj", "->", "first_name", ")", ";", "unset", "(", "$", "oObj", "->", "last_name", ")", ";", "unset", "(", "$", "oObj", "->", "profile_img", ")", ";", "unset", "(", "$", "oObj", "->", "gender", ")", ";", "}" ]
Formats an event object @param \stdClass $oObj The event object to format @return void
[ "Formats", "an", "event", "object" ]
6e5f7ff3decb722a0b182bf72b1db462a5030285
https://github.com/nails/module-event/blob/6e5f7ff3decb722a0b182bf72b1db462a5030285/src/Service/Event.php#L531-L568
225,769
Innmind/Filesystem
src/MediaType/MediaType.php
MediaType.topLevels
public static function topLevels(): SetInterface { if (self::$topLevels === null) { self::$topLevels = (new Set('string')) ->add('application') ->add('audio') ->add('font') ->add('example') ->add('image') ->add('message') ->add('model') ->add('multipart') ->add('text') ->add('video'); } return self::$topLevels; }
php
public static function topLevels(): SetInterface { if (self::$topLevels === null) { self::$topLevels = (new Set('string')) ->add('application') ->add('audio') ->add('font') ->add('example') ->add('image') ->add('message') ->add('model') ->add('multipart') ->add('text') ->add('video'); } return self::$topLevels; }
[ "public", "static", "function", "topLevels", "(", ")", ":", "SetInterface", "{", "if", "(", "self", "::", "$", "topLevels", "===", "null", ")", "{", "self", "::", "$", "topLevels", "=", "(", "new", "Set", "(", "'string'", ")", ")", "->", "add", "(", "'application'", ")", "->", "add", "(", "'audio'", ")", "->", "add", "(", "'font'", ")", "->", "add", "(", "'example'", ")", "->", "add", "(", "'image'", ")", "->", "add", "(", "'message'", ")", "->", "add", "(", "'model'", ")", "->", "add", "(", "'multipart'", ")", "->", "add", "(", "'text'", ")", "->", "add", "(", "'video'", ")", ";", "}", "return", "self", "::", "$", "topLevels", ";", "}" ]
List of allowed top levels @return SetInterface<string>
[ "List", "of", "allowed", "top", "levels" ]
21700d8424bc88e99fd5c612c5316613e4c45a3b
https://github.com/Innmind/Filesystem/blob/21700d8424bc88e99fd5c612c5316613e4c45a3b/src/MediaType/MediaType.php#L96-L113
225,770
Innmind/Filesystem
src/MediaType/MediaType.php
MediaType.fromString
public static function fromString(string $string): self { $string = new Str($string); $pattern = sprintf( '~%s/[\w\-.]+(\+\w+)?([;,] [\w\-.]+=[\w\-.]+)?~', self::topLevels()->join('|') ); if (!$string->matches($pattern)) { throw new InvalidMediaTypeString; } $splits = $string->pregSplit('~[;,] ?~'); $matches = $splits ->get(0) ->capture(sprintf( '~^(?<topLevel>%s)/(?<subType>[\w\-.]+)(\+(?<suffix>\w+))?$~', self::topLevels()->join('|') )); $topLevel = $matches->get('topLevel'); $subType = $matches->get('subType'); $suffix = $matches->contains('suffix') ? $matches->get('suffix') : ''; $params = new Map('string', Parameter::class); $splits ->drop(1) ->foreach(function(Str $param) use (&$params) { $matches = $param->capture( '~^(?<key>[\w\-.]+)=(?<value>[\w\-.]+)$~' ); $params = $params->put( (string) $matches->get('key'), new Parameter\Parameter( (string) $matches->get('key'), (string) $matches->get('value') ) ); }); return new self( (string) $topLevel, (string) $subType, (string) $suffix, $params ); }
php
public static function fromString(string $string): self { $string = new Str($string); $pattern = sprintf( '~%s/[\w\-.]+(\+\w+)?([;,] [\w\-.]+=[\w\-.]+)?~', self::topLevels()->join('|') ); if (!$string->matches($pattern)) { throw new InvalidMediaTypeString; } $splits = $string->pregSplit('~[;,] ?~'); $matches = $splits ->get(0) ->capture(sprintf( '~^(?<topLevel>%s)/(?<subType>[\w\-.]+)(\+(?<suffix>\w+))?$~', self::topLevels()->join('|') )); $topLevel = $matches->get('topLevel'); $subType = $matches->get('subType'); $suffix = $matches->contains('suffix') ? $matches->get('suffix') : ''; $params = new Map('string', Parameter::class); $splits ->drop(1) ->foreach(function(Str $param) use (&$params) { $matches = $param->capture( '~^(?<key>[\w\-.]+)=(?<value>[\w\-.]+)$~' ); $params = $params->put( (string) $matches->get('key'), new Parameter\Parameter( (string) $matches->get('key'), (string) $matches->get('value') ) ); }); return new self( (string) $topLevel, (string) $subType, (string) $suffix, $params ); }
[ "public", "static", "function", "fromString", "(", "string", "$", "string", ")", ":", "self", "{", "$", "string", "=", "new", "Str", "(", "$", "string", ")", ";", "$", "pattern", "=", "sprintf", "(", "'~%s/[\\w\\-.]+(\\+\\w+)?([;,] [\\w\\-.]+=[\\w\\-.]+)?~'", ",", "self", "::", "topLevels", "(", ")", "->", "join", "(", "'|'", ")", ")", ";", "if", "(", "!", "$", "string", "->", "matches", "(", "$", "pattern", ")", ")", "{", "throw", "new", "InvalidMediaTypeString", ";", "}", "$", "splits", "=", "$", "string", "->", "pregSplit", "(", "'~[;,] ?~'", ")", ";", "$", "matches", "=", "$", "splits", "->", "get", "(", "0", ")", "->", "capture", "(", "sprintf", "(", "'~^(?<topLevel>%s)/(?<subType>[\\w\\-.]+)(\\+(?<suffix>\\w+))?$~'", ",", "self", "::", "topLevels", "(", ")", "->", "join", "(", "'|'", ")", ")", ")", ";", "$", "topLevel", "=", "$", "matches", "->", "get", "(", "'topLevel'", ")", ";", "$", "subType", "=", "$", "matches", "->", "get", "(", "'subType'", ")", ";", "$", "suffix", "=", "$", "matches", "->", "contains", "(", "'suffix'", ")", "?", "$", "matches", "->", "get", "(", "'suffix'", ")", ":", "''", ";", "$", "params", "=", "new", "Map", "(", "'string'", ",", "Parameter", "::", "class", ")", ";", "$", "splits", "->", "drop", "(", "1", ")", "->", "foreach", "(", "function", "(", "Str", "$", "param", ")", "use", "(", "&", "$", "params", ")", "{", "$", "matches", "=", "$", "param", "->", "capture", "(", "'~^(?<key>[\\w\\-.]+)=(?<value>[\\w\\-.]+)$~'", ")", ";", "$", "params", "=", "$", "params", "->", "put", "(", "(", "string", ")", "$", "matches", "->", "get", "(", "'key'", ")", ",", "new", "Parameter", "\\", "Parameter", "(", "(", "string", ")", "$", "matches", "->", "get", "(", "'key'", ")", ",", "(", "string", ")", "$", "matches", "->", "get", "(", "'value'", ")", ")", ")", ";", "}", ")", ";", "return", "new", "self", "(", "(", "string", ")", "$", "topLevel", ",", "(", "string", ")", "$", "subType", ",", "(", "string", ")", "$", "suffix", ",", "$", "params", ")", ";", "}" ]
Build an object out of a string @param string $string @return self
[ "Build", "an", "object", "out", "of", "a", "string" ]
21700d8424bc88e99fd5c612c5316613e4c45a3b
https://github.com/Innmind/Filesystem/blob/21700d8424bc88e99fd5c612c5316613e4c45a3b/src/MediaType/MediaType.php#L122-L169
225,771
svilborg/guzzle-encoding-com
src/Gencoding/Guzzle/Encoding/Notifications.php
Notifications.parse
public function parse() { $notification = (isset($_POST) && isset($_POST["xml"])) ? $_POST["xml"] : null; if (! $notification) { throw new \Exception('Notification error', 5000); } return new \SimpleXMLElement($notification); }
php
public function parse() { $notification = (isset($_POST) && isset($_POST["xml"])) ? $_POST["xml"] : null; if (! $notification) { throw new \Exception('Notification error', 5000); } return new \SimpleXMLElement($notification); }
[ "public", "function", "parse", "(", ")", "{", "$", "notification", "=", "(", "isset", "(", "$", "_POST", ")", "&&", "isset", "(", "$", "_POST", "[", "\"xml\"", "]", ")", ")", "?", "$", "_POST", "[", "\"xml\"", "]", ":", "null", ";", "if", "(", "!", "$", "notification", ")", "{", "throw", "new", "\\", "Exception", "(", "'Notification error'", ",", "5000", ")", ";", "}", "return", "new", "\\", "SimpleXMLElement", "(", "$", "notification", ")", ";", "}" ]
Parse the notifications @throws \Exception @return SimpleXMLElement
[ "Parse", "the", "notifications" ]
0f42505e85013d1753502c0f3d0aa8955fb24cce
https://github.com/svilborg/guzzle-encoding-com/blob/0f42505e85013d1753502c0f3d0aa8955fb24cce/src/Gencoding/Guzzle/Encoding/Notifications.php#L16-L24
225,772
Eve-PHP/Framework
src/Cli/Index.php
Index.input
public static function input($question, $default = null) { echo $question.': '; $handle = fopen ('php://stdin', 'r'); $answer = fgets($handle); fclose($handle); $answer = trim($answer); if(!$answer) { $answer = $default; } return $answer; }
php
public static function input($question, $default = null) { echo $question.': '; $handle = fopen ('php://stdin', 'r'); $answer = fgets($handle); fclose($handle); $answer = trim($answer); if(!$answer) { $answer = $default; } return $answer; }
[ "public", "static", "function", "input", "(", "$", "question", ",", "$", "default", "=", "null", ")", "{", "echo", "$", "question", ".", "': '", ";", "$", "handle", "=", "fopen", "(", "'php://stdin'", ",", "'r'", ")", ";", "$", "answer", "=", "fgets", "(", "$", "handle", ")", ";", "fclose", "(", "$", "handle", ")", ";", "$", "answer", "=", "trim", "(", "$", "answer", ")", ";", "if", "(", "!", "$", "answer", ")", "{", "$", "answer", "=", "$", "default", ";", "}", "return", "$", "answer", ";", "}" ]
Queries the user for an input and returns the results @param string $question The text question @param string|null $default The default answer @return string
[ "Queries", "the", "user", "for", "an", "input", "and", "returns", "the", "results" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Cli/Index.php#L147-L162
225,773
DrNixx/yii2-onix
src/assets/BaseAssetBundle.php
BaseAssetBundle.addLanguage
public function addLanguage($lang = '', $prefix = '', $dir = null, $min = false) { if (empty($lang) || substr($lang, 0, 2) == 'en') { return $this; } $ext = $min ? (YII_DEBUG ? ".min.js" : ".js") : ".js"; $file = "{$prefix}{$lang}{$ext}"; if ($dir === null) { $dir = 'js'; } elseif ($dir === "/") { $dir = ''; } $path = $this->sourcePath . '/' . $dir; if (!Env::fileExists("{$path}/{$file}")) { $lang = Env::getLang($lang); $file = "{$prefix}{$lang}{$ext}"; } if (Env::fileExists("{$path}/{$file}")) { $this->js[] = empty($dir) ? $file : "{$dir}/{$file}"; } return $this; }
php
public function addLanguage($lang = '', $prefix = '', $dir = null, $min = false) { if (empty($lang) || substr($lang, 0, 2) == 'en') { return $this; } $ext = $min ? (YII_DEBUG ? ".min.js" : ".js") : ".js"; $file = "{$prefix}{$lang}{$ext}"; if ($dir === null) { $dir = 'js'; } elseif ($dir === "/") { $dir = ''; } $path = $this->sourcePath . '/' . $dir; if (!Env::fileExists("{$path}/{$file}")) { $lang = Env::getLang($lang); $file = "{$prefix}{$lang}{$ext}"; } if (Env::fileExists("{$path}/{$file}")) { $this->js[] = empty($dir) ? $file : "{$dir}/{$file}"; } return $this; }
[ "public", "function", "addLanguage", "(", "$", "lang", "=", "''", ",", "$", "prefix", "=", "''", ",", "$", "dir", "=", "null", ",", "$", "min", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "lang", ")", "||", "substr", "(", "$", "lang", ",", "0", ",", "2", ")", "==", "'en'", ")", "{", "return", "$", "this", ";", "}", "$", "ext", "=", "$", "min", "?", "(", "YII_DEBUG", "?", "\".min.js\"", ":", "\".js\"", ")", ":", "\".js\"", ";", "$", "file", "=", "\"{$prefix}{$lang}{$ext}\"", ";", "if", "(", "$", "dir", "===", "null", ")", "{", "$", "dir", "=", "'js'", ";", "}", "elseif", "(", "$", "dir", "===", "\"/\"", ")", "{", "$", "dir", "=", "''", ";", "}", "$", "path", "=", "$", "this", "->", "sourcePath", ".", "'/'", ".", "$", "dir", ";", "if", "(", "!", "Env", "::", "fileExists", "(", "\"{$path}/{$file}\"", ")", ")", "{", "$", "lang", "=", "Env", "::", "getLang", "(", "$", "lang", ")", ";", "$", "file", "=", "\"{$prefix}{$lang}{$ext}\"", ";", "}", "if", "(", "Env", "::", "fileExists", "(", "\"{$path}/{$file}\"", ")", ")", "{", "$", "this", "->", "js", "[", "]", "=", "empty", "(", "$", "dir", ")", "?", "$", "file", ":", "\"{$dir}/{$file}\"", ";", "}", "return", "$", "this", ";", "}" ]
Adds a language JS locale file @param string $lang the ISO language code @param string $prefix the language locale file name prefix @param string $dir the language file directory relative to source path @param bool $min whether to auto use minified version @return AssetBundle instance
[ "Adds", "a", "language", "JS", "locale", "file" ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/assets/BaseAssetBundle.php#L75-L100
225,774
nails/module-barcode
src/Service/Generator.php
Generator.save
public function save($sString, $sPath, $iWidth = null, $iHeight = null) { $rImg = $this->generateBarcode($sString, $iWidth, $iHeight); if ($rImg) { imagepng($rImg, $sPath); imagedestroy($rImg); return true; } else { return false; } }
php
public function save($sString, $sPath, $iWidth = null, $iHeight = null) { $rImg = $this->generateBarcode($sString, $iWidth, $iHeight); if ($rImg) { imagepng($rImg, $sPath); imagedestroy($rImg); return true; } else { return false; } }
[ "public", "function", "save", "(", "$", "sString", ",", "$", "sPath", ",", "$", "iWidth", "=", "null", ",", "$", "iHeight", "=", "null", ")", "{", "$", "rImg", "=", "$", "this", "->", "generateBarcode", "(", "$", "sString", ",", "$", "iWidth", ",", "$", "iHeight", ")", ";", "if", "(", "$", "rImg", ")", "{", "imagepng", "(", "$", "rImg", ",", "$", "sPath", ")", ";", "imagedestroy", "(", "$", "rImg", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Saves a barcode to disk @param string $sString The string to encode @param string $sPath Where to save the image @param integer $iWidth The width of the image @param integer $iHeight The height of the image @return boolean
[ "Saves", "a", "barcode", "to", "disk" ]
c8c9dbb5b458edc5d58d80c1350819a66036cfdb
https://github.com/nails/module-barcode/blob/c8c9dbb5b458edc5d58d80c1350819a66036cfdb/src/Service/Generator.php#L179-L194
225,775
nails/module-barcode
src/Service/Generator.php
Generator.show
public function show($sString, $iWidth = null, $iHeight = null) { $rImg = $this->generateBarcode($sString, $iWidth, $iHeight); if ($rImg) { header('Content-Type: image/png'); imagepng($rImg); imagedestroy($rImg); exit(0); } else { return false; } }
php
public function show($sString, $iWidth = null, $iHeight = null) { $rImg = $this->generateBarcode($sString, $iWidth, $iHeight); if ($rImg) { header('Content-Type: image/png'); imagepng($rImg); imagedestroy($rImg); exit(0); } else { return false; } }
[ "public", "function", "show", "(", "$", "sString", ",", "$", "iWidth", "=", "null", ",", "$", "iHeight", "=", "null", ")", "{", "$", "rImg", "=", "$", "this", "->", "generateBarcode", "(", "$", "sString", ",", "$", "iWidth", ",", "$", "iHeight", ")", ";", "if", "(", "$", "rImg", ")", "{", "header", "(", "'Content-Type: image/png'", ")", ";", "imagepng", "(", "$", "rImg", ")", ";", "imagedestroy", "(", "$", "rImg", ")", ";", "exit", "(", "0", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Sends a barcode to the browser as an image @param string $sString The string to encode @param integer $iWidth The width of the image @param integer $iHeight The height of the image @return void
[ "Sends", "a", "barcode", "to", "the", "browser", "as", "an", "image" ]
c8c9dbb5b458edc5d58d80c1350819a66036cfdb
https://github.com/nails/module-barcode/blob/c8c9dbb5b458edc5d58d80c1350819a66036cfdb/src/Service/Generator.php#L205-L220
225,776
nails/module-barcode
src/Service/Generator.php
Generator.base64
public function base64($sString, $iWidth = null, $iHeight = null) { $rImg = $this->generateBarcode($sString, $iWidth, $iHeight); if ($rImg) { ob_start(); imagepng($rImg); $sContents = ob_get_contents(); ob_end_clean(); return base64_encode($sContents); } else { return false; } }
php
public function base64($sString, $iWidth = null, $iHeight = null) { $rImg = $this->generateBarcode($sString, $iWidth, $iHeight); if ($rImg) { ob_start(); imagepng($rImg); $sContents = ob_get_contents(); ob_end_clean(); return base64_encode($sContents); } else { return false; } }
[ "public", "function", "base64", "(", "$", "sString", ",", "$", "iWidth", "=", "null", ",", "$", "iHeight", "=", "null", ")", "{", "$", "rImg", "=", "$", "this", "->", "generateBarcode", "(", "$", "sString", ",", "$", "iWidth", ",", "$", "iHeight", ")", ";", "if", "(", "$", "rImg", ")", "{", "ob_start", "(", ")", ";", "imagepng", "(", "$", "rImg", ")", ";", "$", "sContents", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "base64_encode", "(", "$", "sContents", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Returns the encoded image as a base64 string @param string $sString The string to encode @param integer $iWidth The width of the image @param integer $iHeight The height of the image @return string
[ "Returns", "the", "encoded", "image", "as", "a", "base64", "string" ]
c8c9dbb5b458edc5d58d80c1350819a66036cfdb
https://github.com/nails/module-barcode/blob/c8c9dbb5b458edc5d58d80c1350819a66036cfdb/src/Service/Generator.php#L231-L248
225,777
cmsgears/module-cart
common/services/resources/CartService.php
CartService.getByUserId
public function getByUserId( $userId ) { $modelClass = self::$modelClass; $cart = $modelClass::findByParentIdParentType( $userId, CoreGlobal::TYPE_USER ); if( !isset( $cart ) ) { $cart = $this->createByUserId( $userId ); } return $cart; }
php
public function getByUserId( $userId ) { $modelClass = self::$modelClass; $cart = $modelClass::findByParentIdParentType( $userId, CoreGlobal::TYPE_USER ); if( !isset( $cart ) ) { $cart = $this->createByUserId( $userId ); } return $cart; }
[ "public", "function", "getByUserId", "(", "$", "userId", ")", "{", "$", "modelClass", "=", "self", "::", "$", "modelClass", ";", "$", "cart", "=", "$", "modelClass", "::", "findByParentIdParentType", "(", "$", "userId", ",", "CoreGlobal", "::", "TYPE_USER", ")", ";", "if", "(", "!", "isset", "(", "$", "cart", ")", ")", "{", "$", "cart", "=", "$", "this", "->", "createByUserId", "(", "$", "userId", ")", ";", "}", "return", "$", "cart", ";", "}" ]
Find cart if exist for the given user. If does not exist create, it.
[ "Find", "cart", "if", "exist", "for", "the", "given", "user", ".", "If", "does", "not", "exist", "create", "it", "." ]
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/services/resources/CartService.php#L119-L131
225,778
php-toolkit/sys-utils
src/ProcessUtil.php
ProcessUtil.getPidByFile
public static function getPidByFile(string $file, bool $checkLive = false): int { if ($file && \file_exists($file)) { $pid = (int)\file_get_contents($file); // check live if ($checkLive && self::isRunning($pid)) { return $pid; } \unlink($file); } return 0; }
php
public static function getPidByFile(string $file, bool $checkLive = false): int { if ($file && \file_exists($file)) { $pid = (int)\file_get_contents($file); // check live if ($checkLive && self::isRunning($pid)) { return $pid; } \unlink($file); } return 0; }
[ "public", "static", "function", "getPidByFile", "(", "string", "$", "file", ",", "bool", "$", "checkLive", "=", "false", ")", ":", "int", "{", "if", "(", "$", "file", "&&", "\\", "file_exists", "(", "$", "file", ")", ")", "{", "$", "pid", "=", "(", "int", ")", "\\", "file_get_contents", "(", "$", "file", ")", ";", "// check live", "if", "(", "$", "checkLive", "&&", "self", "::", "isRunning", "(", "$", "pid", ")", ")", "{", "return", "$", "pid", ";", "}", "\\", "unlink", "(", "$", "file", ")", ";", "}", "return", "0", ";", "}" ]
get PID by pid File @param string $file @param bool $checkLive @return int
[ "get", "PID", "by", "pid", "File" ]
cf6ca81efed472ca4457e6f4325fe00398d2d0ca
https://github.com/php-toolkit/sys-utils/blob/cf6ca81efed472ca4457e6f4325fe00398d2d0ca/src/ProcessUtil.php#L473-L487
225,779
php-toolkit/sys-utils
src/ProcessUtil.php
ProcessUtil.run
public static function run(string $command, string $cwd = null): array { return Sys::run($command, $cwd); }
php
public static function run(string $command, string $cwd = null): array { return Sys::run($command, $cwd); }
[ "public", "static", "function", "run", "(", "string", "$", "command", ",", "string", "$", "cwd", "=", "null", ")", ":", "array", "{", "return", "Sys", "::", "run", "(", "$", "command", ",", "$", "cwd", ")", ";", "}" ]
run a command. it is support windows @param string $command @param string|null $cwd @return array @throws \RuntimeException @deprecated Please use Sys::run()
[ "run", "a", "command", ".", "it", "is", "support", "windows" ]
cf6ca81efed472ca4457e6f4325fe00398d2d0ca
https://github.com/php-toolkit/sys-utils/blob/cf6ca81efed472ca4457e6f4325fe00398d2d0ca/src/ProcessUtil.php#L539-L542
225,780
php-toolkit/sys-utils
src/ProcessUtil.php
ProcessUtil.setTitle
public static function setTitle(string $title): bool { if (!$title || 'Darwin' === \PHP_OS) { return false; } if (\function_exists('cli_set_process_title')) { \cli_set_process_title($title); } elseif (\function_exists('setproctitle')) { \setproctitle($title); } if ($error = \error_get_last()) { throw new \RuntimeException($error['message']); } return false; }
php
public static function setTitle(string $title): bool { if (!$title || 'Darwin' === \PHP_OS) { return false; } if (\function_exists('cli_set_process_title')) { \cli_set_process_title($title); } elseif (\function_exists('setproctitle')) { \setproctitle($title); } if ($error = \error_get_last()) { throw new \RuntimeException($error['message']); } return false; }
[ "public", "static", "function", "setTitle", "(", "string", "$", "title", ")", ":", "bool", "{", "if", "(", "!", "$", "title", "||", "'Darwin'", "===", "\\", "PHP_OS", ")", "{", "return", "false", ";", "}", "if", "(", "\\", "function_exists", "(", "'cli_set_process_title'", ")", ")", "{", "\\", "cli_set_process_title", "(", "$", "title", ")", ";", "}", "elseif", "(", "\\", "function_exists", "(", "'setproctitle'", ")", ")", "{", "\\", "setproctitle", "(", "$", "title", ")", ";", "}", "if", "(", "$", "error", "=", "\\", "error_get_last", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "error", "[", "'message'", "]", ")", ";", "}", "return", "false", ";", "}" ]
Set process title. @param string $title @return bool
[ "Set", "process", "title", "." ]
cf6ca81efed472ca4457e6f4325fe00398d2d0ca
https://github.com/php-toolkit/sys-utils/blob/cf6ca81efed472ca4457e6f4325fe00398d2d0ca/src/ProcessUtil.php#L559-L576
225,781
SetBased/php-abc-form
src/Control/CheckboxesControl.php
CheckboxesControl.getSetValuesBase
public function getSetValuesBase(array &$values): void { if ($this->name==='') { $tmp = &$values; } else { $values[$this->name] = []; $tmp = &$values[$this->name]; } foreach ($this->options as $i => $option) { // Get the (database) ID of the option. $key = $option[$this->keyKey]; // Get the original value (i.e. the option is checked or not). $tmp[$key] = (!empty($option[$this->checkedKey])); } }
php
public function getSetValuesBase(array &$values): void { if ($this->name==='') { $tmp = &$values; } else { $values[$this->name] = []; $tmp = &$values[$this->name]; } foreach ($this->options as $i => $option) { // Get the (database) ID of the option. $key = $option[$this->keyKey]; // Get the original value (i.e. the option is checked or not). $tmp[$key] = (!empty($option[$this->checkedKey])); } }
[ "public", "function", "getSetValuesBase", "(", "array", "&", "$", "values", ")", ":", "void", "{", "if", "(", "$", "this", "->", "name", "===", "''", ")", "{", "$", "tmp", "=", "&", "$", "values", ";", "}", "else", "{", "$", "values", "[", "$", "this", "->", "name", "]", "=", "[", "]", ";", "$", "tmp", "=", "&", "$", "values", "[", "$", "this", "->", "name", "]", ";", "}", "foreach", "(", "$", "this", "->", "options", "as", "$", "i", "=>", "$", "option", ")", "{", "// Get the (database) ID of the option.", "$", "key", "=", "$", "option", "[", "$", "this", "->", "keyKey", "]", ";", "// Get the original value (i.e. the option is checked or not).", "$", "tmp", "[", "$", "key", "]", "=", "(", "!", "empty", "(", "$", "option", "[", "$", "this", "->", "checkedKey", "]", ")", ")", ";", "}", "}" ]
Adds the value of checked checkboxes the values with the name of this form control as key. @param array $values The values.
[ "Adds", "the", "value", "of", "checked", "checkboxes", "the", "values", "with", "the", "name", "of", "this", "form", "control", "as", "key", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/CheckboxesControl.php#L158-L178
225,782
SetBased/php-abc-form
src/Control/CheckboxesControl.php
CheckboxesControl.inputAttributes
private function inputAttributes(array $option): array { $attributes = []; if (is_array($this->inputAttributesMap)) { foreach ($this->inputAttributesMap as $key => $name) { if (isset($option[$key])) $attributes[$name] = $option[$key]; } } $attributes['type'] = 'checkbox'; if (!isset($attributes['id'])) $attributes['id'] = Html::getAutoId(); return $attributes; }
php
private function inputAttributes(array $option): array { $attributes = []; if (is_array($this->inputAttributesMap)) { foreach ($this->inputAttributesMap as $key => $name) { if (isset($option[$key])) $attributes[$name] = $option[$key]; } } $attributes['type'] = 'checkbox'; if (!isset($attributes['id'])) $attributes['id'] = Html::getAutoId(); return $attributes; }
[ "private", "function", "inputAttributes", "(", "array", "$", "option", ")", ":", "array", "{", "$", "attributes", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "this", "->", "inputAttributesMap", ")", ")", "{", "foreach", "(", "$", "this", "->", "inputAttributesMap", "as", "$", "key", "=>", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "option", "[", "$", "key", "]", ")", ")", "$", "attributes", "[", "$", "name", "]", "=", "$", "option", "[", "$", "key", "]", ";", "}", "}", "$", "attributes", "[", "'type'", "]", "=", "'checkbox'", ";", "if", "(", "!", "isset", "(", "$", "attributes", "[", "'id'", "]", ")", ")", "$", "attributes", "[", "'id'", "]", "=", "Html", "::", "getAutoId", "(", ")", ";", "return", "$", "attributes", ";", "}" ]
Returns the attributes for the input element. @param array $option The option. @return array
[ "Returns", "the", "attributes", "for", "the", "input", "element", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/CheckboxesControl.php#L464-L481
225,783
kaystrobach/FLOW.Custom
Classes/Aspects/AroundControllerAspect.php
AroundControllerAspect.output
public function output(\Neos\Flow\Aop\JoinPointInterface $joinPoint) { /** @var ActionController $controller */ $controller = $joinPoint->getProxy(); $view = ObjectAccess::getProperty($controller, 'view', true); /** @var \Neos\Flow\Http\Response $response */ $response = $controller->getControllerContext()->getResponse(); if($view instanceof JsendView) { $view->assign('redirectTo', $joinPoint->getMethodArgument('uri')); $response->setContent($view->render()); throw new \Neos\Flow\Mvc\Exception\StopActionException(); } else { return $joinPoint->getAdviceChain()->proceed($joinPoint); } }
php
public function output(\Neos\Flow\Aop\JoinPointInterface $joinPoint) { /** @var ActionController $controller */ $controller = $joinPoint->getProxy(); $view = ObjectAccess::getProperty($controller, 'view', true); /** @var \Neos\Flow\Http\Response $response */ $response = $controller->getControllerContext()->getResponse(); if($view instanceof JsendView) { $view->assign('redirectTo', $joinPoint->getMethodArgument('uri')); $response->setContent($view->render()); throw new \Neos\Flow\Mvc\Exception\StopActionException(); } else { return $joinPoint->getAdviceChain()->proceed($joinPoint); } }
[ "public", "function", "output", "(", "\\", "Neos", "\\", "Flow", "\\", "Aop", "\\", "JoinPointInterface", "$", "joinPoint", ")", "{", "/** @var ActionController $controller */", "$", "controller", "=", "$", "joinPoint", "->", "getProxy", "(", ")", ";", "$", "view", "=", "ObjectAccess", "::", "getProperty", "(", "$", "controller", ",", "'view'", ",", "true", ")", ";", "/** @var \\Neos\\Flow\\Http\\Response $response */", "$", "response", "=", "$", "controller", "->", "getControllerContext", "(", ")", "->", "getResponse", "(", ")", ";", "if", "(", "$", "view", "instanceof", "JsendView", ")", "{", "$", "view", "->", "assign", "(", "'redirectTo'", ",", "$", "joinPoint", "->", "getMethodArgument", "(", "'uri'", ")", ")", ";", "$", "response", "->", "setContent", "(", "$", "view", "->", "render", "(", ")", ")", ";", "throw", "new", "\\", "Neos", "\\", "Flow", "\\", "Mvc", "\\", "Exception", "\\", "StopActionException", "(", ")", ";", "}", "else", "{", "return", "$", "joinPoint", "->", "getAdviceChain", "(", ")", "->", "proceed", "(", "$", "joinPoint", ")", ";", "}", "}" ]
Directly outputs all the data instead of storing it in the buffer @Flow\Around("method(Neos\Flow\Mvc\Controller\AbstractController->redirectToUri())") @throws \Neos\Flow\Mvc\Exception\StopActionException @throws \Neos\Utility\Exception\PropertyNotAccessibleException @param \Neos\Flow\Aop\JoinPointInterface $joinPoint The current join point @return mixed Result of the target method
[ "Directly", "outputs", "all", "the", "data", "instead", "of", "storing", "it", "in", "the", "buffer" ]
873001a46fa0dfbc426edd74af1841cfa7bcf1b9
https://github.com/kaystrobach/FLOW.Custom/blob/873001a46fa0dfbc426edd74af1841cfa7bcf1b9/Classes/Aspects/AroundControllerAspect.php#L29-L45
225,784
DaveRandom/Enum
src/Enum.php
Enum.getClassConstants
private static function getClassConstants(string $className): array { return self::$constantCache[$className] ?? self::$constantCache[$className] = (new \ReflectionClass($className))->getConstants(); }
php
private static function getClassConstants(string $className): array { return self::$constantCache[$className] ?? self::$constantCache[$className] = (new \ReflectionClass($className))->getConstants(); }
[ "private", "static", "function", "getClassConstants", "(", "string", "$", "className", ")", ":", "array", "{", "return", "self", "::", "$", "constantCache", "[", "$", "className", "]", "??", "self", "::", "$", "constantCache", "[", "$", "className", "]", "=", "(", "new", "\\", "ReflectionClass", "(", "$", "className", ")", ")", "->", "getConstants", "(", ")", ";", "}" ]
Get a map of member names to values for the specified class name @param string $className @return array
[ "Get", "a", "map", "of", "member", "names", "to", "values", "for", "the", "specified", "class", "name" ]
52c0388a234eb679f4c9be374ea76bd41763b114
https://github.com/DaveRandom/Enum/blob/52c0388a234eb679f4c9be374ea76bd41763b114/src/Enum.php#L15-L19
225,785
DaveRandom/Enum
src/Enum.php
Enum.parseValue
final public static function parseValue($searchValue, bool $looseComparison = false): string { if (false !== $name = \array_search($searchValue, self::getClassConstants(static::class), !$looseComparison)) { return $name; } throw new \InvalidArgumentException('Unknown enumeration value: ' . $searchValue); }
php
final public static function parseValue($searchValue, bool $looseComparison = false): string { if (false !== $name = \array_search($searchValue, self::getClassConstants(static::class), !$looseComparison)) { return $name; } throw new \InvalidArgumentException('Unknown enumeration value: ' . $searchValue); }
[ "final", "public", "static", "function", "parseValue", "(", "$", "searchValue", ",", "bool", "$", "looseComparison", "=", "false", ")", ":", "string", "{", "if", "(", "false", "!==", "$", "name", "=", "\\", "array_search", "(", "$", "searchValue", ",", "self", "::", "getClassConstants", "(", "static", "::", "class", ")", ",", "!", "$", "looseComparison", ")", ")", "{", "return", "$", "name", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unknown enumeration value: '", ".", "$", "searchValue", ")", ";", "}" ]
Get the name of the first member with the specified value @param mixed $searchValue @param bool $looseComparison @return string
[ "Get", "the", "name", "of", "the", "first", "member", "with", "the", "specified", "value" ]
52c0388a234eb679f4c9be374ea76bd41763b114
https://github.com/DaveRandom/Enum/blob/52c0388a234eb679f4c9be374ea76bd41763b114/src/Enum.php#L49-L56
225,786
DaveRandom/Enum
src/Enum.php
Enum.parseName
final public static function parseName(string $searchName, bool $caseInsensitive = false) { $constants = self::getClassConstants(static::class); if (isset($constants[$searchName])) { return $constants[$searchName]; } if ($caseInsensitive && null !== $key = self::searchArrayCaseInsensitive($constants, $searchName)) { return $constants[$key]; } throw new \InvalidArgumentException('Unknown enumeration member: ' . $searchName); }
php
final public static function parseName(string $searchName, bool $caseInsensitive = false) { $constants = self::getClassConstants(static::class); if (isset($constants[$searchName])) { return $constants[$searchName]; } if ($caseInsensitive && null !== $key = self::searchArrayCaseInsensitive($constants, $searchName)) { return $constants[$key]; } throw new \InvalidArgumentException('Unknown enumeration member: ' . $searchName); }
[ "final", "public", "static", "function", "parseName", "(", "string", "$", "searchName", ",", "bool", "$", "caseInsensitive", "=", "false", ")", "{", "$", "constants", "=", "self", "::", "getClassConstants", "(", "static", "::", "class", ")", ";", "if", "(", "isset", "(", "$", "constants", "[", "$", "searchName", "]", ")", ")", "{", "return", "$", "constants", "[", "$", "searchName", "]", ";", "}", "if", "(", "$", "caseInsensitive", "&&", "null", "!==", "$", "key", "=", "self", "::", "searchArrayCaseInsensitive", "(", "$", "constants", ",", "$", "searchName", ")", ")", "{", "return", "$", "constants", "[", "$", "key", "]", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'Unknown enumeration member: '", ".", "$", "searchName", ")", ";", "}" ]
Get the value of the member with the specified name @param string $searchName @param bool $caseInsensitive @return mixed
[ "Get", "the", "value", "of", "the", "member", "with", "the", "specified", "name" ]
52c0388a234eb679f4c9be374ea76bd41763b114
https://github.com/DaveRandom/Enum/blob/52c0388a234eb679f4c9be374ea76bd41763b114/src/Enum.php#L73-L86
225,787
bytic/Common
src/Records/Traits/HasForms/RecordsTrait.php
RecordsTrait.getFormClassName
public function getFormClassName($type = null) { if (!$type) { $type = $this->getFormTypeDefault(); } $module = $this->getRequest()->getModuleName(); if (strpos($type, 'admin-') !== false) { $module = 'admin'; $type = str_replace('admin-', '', $type); } elseif (strpos($type, 'default-') !== false) { $type = str_replace('default-', '', $type); } $name = ucfirst($module) . '_Forms_'; $name .= $this->getFormClassNameSlug() . '_'; $name .= inflector()->classify($type); return $name; }
php
public function getFormClassName($type = null) { if (!$type) { $type = $this->getFormTypeDefault(); } $module = $this->getRequest()->getModuleName(); if (strpos($type, 'admin-') !== false) { $module = 'admin'; $type = str_replace('admin-', '', $type); } elseif (strpos($type, 'default-') !== false) { $type = str_replace('default-', '', $type); } $name = ucfirst($module) . '_Forms_'; $name .= $this->getFormClassNameSlug() . '_'; $name .= inflector()->classify($type); return $name; }
[ "public", "function", "getFormClassName", "(", "$", "type", "=", "null", ")", "{", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "getFormTypeDefault", "(", ")", ";", "}", "$", "module", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getModuleName", "(", ")", ";", "if", "(", "strpos", "(", "$", "type", ",", "'admin-'", ")", "!==", "false", ")", "{", "$", "module", "=", "'admin'", ";", "$", "type", "=", "str_replace", "(", "'admin-'", ",", "''", ",", "$", "type", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "type", ",", "'default-'", ")", "!==", "false", ")", "{", "$", "type", "=", "str_replace", "(", "'default-'", ",", "''", ",", "$", "type", ")", ";", "}", "$", "name", "=", "ucfirst", "(", "$", "module", ")", ".", "'_Forms_'", ";", "$", "name", ".=", "$", "this", "->", "getFormClassNameSlug", "(", ")", ".", "'_'", ";", "$", "name", ".=", "inflector", "(", ")", "->", "classify", "(", "$", "type", ")", ";", "return", "$", "name", ";", "}" ]
Get Form Class name by type @param string $type Type name @return string
[ "Get", "Form", "Class", "name", "by", "type" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/HasForms/RecordsTrait.php#L39-L58
225,788
bytic/Common
src/Records/Traits/HasForms/RecordsTrait.php
RecordsTrait.initFormClassNameSlug
protected function initFormClassNameSlug() { $slug = \inflector()->singularize( \inflector()->classify($this->getFormClassNameBase()) ); $this->setFormClassNameSlug($slug); }
php
protected function initFormClassNameSlug() { $slug = \inflector()->singularize( \inflector()->classify($this->getFormClassNameBase()) ); $this->setFormClassNameSlug($slug); }
[ "protected", "function", "initFormClassNameSlug", "(", ")", "{", "$", "slug", "=", "\\", "inflector", "(", ")", "->", "singularize", "(", "\\", "inflector", "(", ")", "->", "classify", "(", "$", "this", "->", "getFormClassNameBase", "(", ")", ")", ")", ";", "$", "this", "->", "setFormClassNameSlug", "(", "$", "slug", ")", ";", "}" ]
Init form class name slug @return void
[ "Init", "form", "class", "name", "slug" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/HasForms/RecordsTrait.php#L101-L107
225,789
PureBilling/PureMachineSDK
src/PureMachine/Bundle/SDKBundle/Exception/Exception.php
Exception.searchForFileAndLineCalledFromStack
protected static function searchForFileAndLineCalledFromStack(array $stack) { for ($i=0;$i<count($stack);$i++) { if(array_key_exists("file", $stack[$i]) && array_key_exists("line", $stack[$i])) return $stack[$i]; } return null; }
php
protected static function searchForFileAndLineCalledFromStack(array $stack) { for ($i=0;$i<count($stack);$i++) { if(array_key_exists("file", $stack[$i]) && array_key_exists("line", $stack[$i])) return $stack[$i]; } return null; }
[ "protected", "static", "function", "searchForFileAndLineCalledFromStack", "(", "array", "$", "stack", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "stack", ")", ";", "$", "i", "++", ")", "{", "if", "(", "array_key_exists", "(", "\"file\"", ",", "$", "stack", "[", "$", "i", "]", ")", "&&", "array_key_exists", "(", "\"line\"", ",", "$", "stack", "[", "$", "i", "]", ")", ")", "return", "$", "stack", "[", "$", "i", "]", ";", "}", "return", "null", ";", "}" ]
Search for a valid stack item with file and line not a raw class call. Return the stack item with this data or null in case not stack item found @param array $stack @return array|null
[ "Search", "for", "a", "valid", "stack", "item", "with", "file", "and", "line", "not", "a", "raw", "class", "call", ".", "Return", "the", "stack", "item", "with", "this", "data", "or", "null", "in", "case", "not", "stack", "item", "found" ]
1cd3b6a629cbc913513a5d043e6423d1836d5177
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Exception/Exception.php#L71-L78
225,790
PureBilling/PureMachineSDK
src/PureMachine/Bundle/SDKBundle/Exception/Exception.php
Exception.buildExceptionStore
public static function buildExceptionStore(\Exception $e) { $exceptionStore = new ExceptionStore(); $exceptionStore->setMessage($e->getMessage()); $exceptionStore->setCode($e->getCode()); $exceptionStore->setExceptionClass(get_class($e)); $t = explode('\n', $e->getTraceAsString()); $exceptionStore->setStack($t); $stack = $e->getTrace(); if (count($stack) > 0) { //Setting default unknown values $exceptionStore->setFile("unknown"); $exceptionStore->setLine(0); //Searching for a valid stackItem $stackItem = static::searchForFileAndLineCalledFromStack($stack); if (!is_null($stackItem)) { $exceptionStore->setFile(basename($stackItem['file'],'.php')); $exceptionStore->setLine($stackItem['line']); } } return $exceptionStore; }
php
public static function buildExceptionStore(\Exception $e) { $exceptionStore = new ExceptionStore(); $exceptionStore->setMessage($e->getMessage()); $exceptionStore->setCode($e->getCode()); $exceptionStore->setExceptionClass(get_class($e)); $t = explode('\n', $e->getTraceAsString()); $exceptionStore->setStack($t); $stack = $e->getTrace(); if (count($stack) > 0) { //Setting default unknown values $exceptionStore->setFile("unknown"); $exceptionStore->setLine(0); //Searching for a valid stackItem $stackItem = static::searchForFileAndLineCalledFromStack($stack); if (!is_null($stackItem)) { $exceptionStore->setFile(basename($stackItem['file'],'.php')); $exceptionStore->setLine($stackItem['line']); } } return $exceptionStore; }
[ "public", "static", "function", "buildExceptionStore", "(", "\\", "Exception", "$", "e", ")", "{", "$", "exceptionStore", "=", "new", "ExceptionStore", "(", ")", ";", "$", "exceptionStore", "->", "setMessage", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "exceptionStore", "->", "setCode", "(", "$", "e", "->", "getCode", "(", ")", ")", ";", "$", "exceptionStore", "->", "setExceptionClass", "(", "get_class", "(", "$", "e", ")", ")", ";", "$", "t", "=", "explode", "(", "'\\n'", ",", "$", "e", "->", "getTraceAsString", "(", ")", ")", ";", "$", "exceptionStore", "->", "setStack", "(", "$", "t", ")", ";", "$", "stack", "=", "$", "e", "->", "getTrace", "(", ")", ";", "if", "(", "count", "(", "$", "stack", ")", ">", "0", ")", "{", "//Setting default unknown values", "$", "exceptionStore", "->", "setFile", "(", "\"unknown\"", ")", ";", "$", "exceptionStore", "->", "setLine", "(", "0", ")", ";", "//Searching for a valid stackItem", "$", "stackItem", "=", "static", "::", "searchForFileAndLineCalledFromStack", "(", "$", "stack", ")", ";", "if", "(", "!", "is_null", "(", "$", "stackItem", ")", ")", "{", "$", "exceptionStore", "->", "setFile", "(", "basename", "(", "$", "stackItem", "[", "'file'", "]", ",", "'.php'", ")", ")", ";", "$", "exceptionStore", "->", "setLine", "(", "$", "stackItem", "[", "'line'", "]", ")", ";", "}", "}", "return", "$", "exceptionStore", ";", "}" ]
Build a exceptionStore from a PHP Exception @param \Exception $e
[ "Build", "a", "exceptionStore", "from", "a", "PHP", "Exception" ]
1cd3b6a629cbc913513a5d043e6423d1836d5177
https://github.com/PureBilling/PureMachineSDK/blob/1cd3b6a629cbc913513a5d043e6423d1836d5177/src/PureMachine/Bundle/SDKBundle/Exception/Exception.php#L135-L158
225,791
SetBased/php-abc-form-louver
src/SlatJoint/TableColumnSlatJoint.php
TableColumnSlatJoint.createControl
public function createControl(string $name): Control { $control = new TableColumnControl($name); $control->setTableColumn($this->tableColumn); return $control; }
php
public function createControl(string $name): Control { $control = new TableColumnControl($name); $control->setTableColumn($this->tableColumn); return $control; }
[ "public", "function", "createControl", "(", "string", "$", "name", ")", ":", "Control", "{", "$", "control", "=", "new", "TableColumnControl", "(", "$", "name", ")", ";", "$", "control", "->", "setTableColumn", "(", "$", "this", "->", "tableColumn", ")", ";", "return", "$", "control", ";", "}" ]
Creates and returns a button form control. @param string $name The local name of the button form control. @return Control
[ "Creates", "and", "returns", "a", "button", "form", "control", "." ]
59ff07a59da4ba90ef9665a8893559cd66d37233
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/SlatJoint/TableColumnSlatJoint.php#L40-L46
225,792
phpactor/worse-reference-finder
lib/WorsePlainTextClassDefinitionLocator.php
WorsePlainTextClassDefinitionLocator.resolveImportTable
private function resolveImportTable(Node $node): array { try { return $node->getImportTablesForCurrentScope(); } catch (Exception $e) { } foreach ($node->getDescendantNodes() as $node) { try { $imports = $node->getImportTablesForCurrentScope(); if (empty($imports[0])) { continue; } return $imports; } catch (Exception $e) { } } return [ [], [], [] ]; }
php
private function resolveImportTable(Node $node): array { try { return $node->getImportTablesForCurrentScope(); } catch (Exception $e) { } foreach ($node->getDescendantNodes() as $node) { try { $imports = $node->getImportTablesForCurrentScope(); if (empty($imports[0])) { continue; } return $imports; } catch (Exception $e) { } } return [ [], [], [] ]; }
[ "private", "function", "resolveImportTable", "(", "Node", "$", "node", ")", ":", "array", "{", "try", "{", "return", "$", "node", "->", "getImportTablesForCurrentScope", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "foreach", "(", "$", "node", "->", "getDescendantNodes", "(", ")", "as", "$", "node", ")", "{", "try", "{", "$", "imports", "=", "$", "node", "->", "getImportTablesForCurrentScope", "(", ")", ";", "if", "(", "empty", "(", "$", "imports", "[", "0", "]", ")", ")", "{", "continue", ";", "}", "return", "$", "imports", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "}", "return", "[", "[", "]", ",", "[", "]", ",", "[", "]", "]", ";", "}" ]
Tolerant parser will resolve a docblock comment as the root node, not the node to which the comment belongs. Here we attempt to get the import table from the current node, if that fails then we just do whatever we can to get an import table.
[ "Tolerant", "parser", "will", "resolve", "a", "docblock", "comment", "as", "the", "root", "node", "not", "the", "node", "to", "which", "the", "comment", "belongs", ".", "Here", "we", "attempt", "to", "get", "the", "import", "table", "from", "the", "current", "node", "if", "that", "fails", "then", "we", "just", "do", "whatever", "we", "can", "to", "get", "an", "import", "table", "." ]
78bd0209b34dccbe84ce1e238390cf0f5b86da15
https://github.com/phpactor/worse-reference-finder/blob/78bd0209b34dccbe84ce1e238390cf0f5b86da15/lib/WorsePlainTextClassDefinitionLocator.php#L141-L160
225,793
phpactor/worse-reference-finder
lib/WorsePlainTextClassDefinitionLocator.php
WorsePlainTextClassDefinitionLocator.resolveNamespace
private function resolveNamespace(Node $node) { try { return $this->namespaceFromNode($node); } catch (Exception $e) { } foreach ($node->getDescendantNodes() as $node) { try { return $this->namespaceFromNode($node); } catch (Exception $e) { } } return ''; }
php
private function resolveNamespace(Node $node) { try { return $this->namespaceFromNode($node); } catch (Exception $e) { } foreach ($node->getDescendantNodes() as $node) { try { return $this->namespaceFromNode($node); } catch (Exception $e) { } } return ''; }
[ "private", "function", "resolveNamespace", "(", "Node", "$", "node", ")", "{", "try", "{", "return", "$", "this", "->", "namespaceFromNode", "(", "$", "node", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "foreach", "(", "$", "node", "->", "getDescendantNodes", "(", ")", "as", "$", "node", ")", "{", "try", "{", "return", "$", "this", "->", "namespaceFromNode", "(", "$", "node", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "}", "}", "return", "''", ";", "}" ]
As with resolve import table, we try our best.
[ "As", "with", "resolve", "import", "table", "we", "try", "our", "best", "." ]
78bd0209b34dccbe84ce1e238390cf0f5b86da15
https://github.com/phpactor/worse-reference-finder/blob/78bd0209b34dccbe84ce1e238390cf0f5b86da15/lib/WorsePlainTextClassDefinitionLocator.php#L165-L180
225,794
cmsgears/module-cms
common/utilities/ContentUtil.php
ContentUtil.initPage
public static function initPage( $view, $config = [] ) { $model = isset( $view->params[ 'model' ] ) ? $view->params[ 'model' ] : self::findPage( $view, $config ); if( isset( $model ) ) { $coreProperties = CoreProperties::getInstance(); $cmsProperties = CmsProperties::getInstance(); $content = $model->modelContent; // Page and Content $view->params[ 'model' ] = $model; $view->params[ 'seo' ] = $content; // SEO H1 - Page Summary $view->params[ 'summary' ] = !empty( $content->summary ) ? $content->summary : ( isset( $model->summary ) && !empty( $model->summary ) ? $model->summary : $model->description ); // SEO Meta Tags - Description, Keywords, Robot Text $view->params[ 'desc' ] = isset( $content->seoDescription ) ? $content->seoDescription : $model->description; $view->params[ 'keywords' ] = $content->seoKeywords; $view->params[ 'robot' ] = $content->seoRobot; // SEO - Page Title $siteTitle = $coreProperties->getSiteTitle(); $titleSeparator = $cmsProperties->getTitleSeparator(); $seoName = !empty( $content->seoName ) ? $content->seoName : $model->name; if( $cmsProperties->isSiteTitle() ) { if( $cmsProperties->isAppendTitle() ) { $view->title = "$seoName $titleSeparator $siteTitle"; } else { $view->title = "$siteTitle $titleSeparator $seoName"; } } else { $view->title = $content->seoName; } } }
php
public static function initPage( $view, $config = [] ) { $model = isset( $view->params[ 'model' ] ) ? $view->params[ 'model' ] : self::findPage( $view, $config ); if( isset( $model ) ) { $coreProperties = CoreProperties::getInstance(); $cmsProperties = CmsProperties::getInstance(); $content = $model->modelContent; // Page and Content $view->params[ 'model' ] = $model; $view->params[ 'seo' ] = $content; // SEO H1 - Page Summary $view->params[ 'summary' ] = !empty( $content->summary ) ? $content->summary : ( isset( $model->summary ) && !empty( $model->summary ) ? $model->summary : $model->description ); // SEO Meta Tags - Description, Keywords, Robot Text $view->params[ 'desc' ] = isset( $content->seoDescription ) ? $content->seoDescription : $model->description; $view->params[ 'keywords' ] = $content->seoKeywords; $view->params[ 'robot' ] = $content->seoRobot; // SEO - Page Title $siteTitle = $coreProperties->getSiteTitle(); $titleSeparator = $cmsProperties->getTitleSeparator(); $seoName = !empty( $content->seoName ) ? $content->seoName : $model->name; if( $cmsProperties->isSiteTitle() ) { if( $cmsProperties->isAppendTitle() ) { $view->title = "$seoName $titleSeparator $siteTitle"; } else { $view->title = "$siteTitle $titleSeparator $seoName"; } } else { $view->title = $content->seoName; } } }
[ "public", "static", "function", "initPage", "(", "$", "view", ",", "$", "config", "=", "[", "]", ")", "{", "$", "model", "=", "isset", "(", "$", "view", "->", "params", "[", "'model'", "]", ")", "?", "$", "view", "->", "params", "[", "'model'", "]", ":", "self", "::", "findPage", "(", "$", "view", ",", "$", "config", ")", ";", "if", "(", "isset", "(", "$", "model", ")", ")", "{", "$", "coreProperties", "=", "CoreProperties", "::", "getInstance", "(", ")", ";", "$", "cmsProperties", "=", "CmsProperties", "::", "getInstance", "(", ")", ";", "$", "content", "=", "$", "model", "->", "modelContent", ";", "// Page and Content", "$", "view", "->", "params", "[", "'model'", "]", "=", "$", "model", ";", "$", "view", "->", "params", "[", "'seo'", "]", "=", "$", "content", ";", "// SEO H1 - Page Summary", "$", "view", "->", "params", "[", "'summary'", "]", "=", "!", "empty", "(", "$", "content", "->", "summary", ")", "?", "$", "content", "->", "summary", ":", "(", "isset", "(", "$", "model", "->", "summary", ")", "&&", "!", "empty", "(", "$", "model", "->", "summary", ")", "?", "$", "model", "->", "summary", ":", "$", "model", "->", "description", ")", ";", "// SEO Meta Tags - Description, Keywords, Robot Text", "$", "view", "->", "params", "[", "'desc'", "]", "=", "isset", "(", "$", "content", "->", "seoDescription", ")", "?", "$", "content", "->", "seoDescription", ":", "$", "model", "->", "description", ";", "$", "view", "->", "params", "[", "'keywords'", "]", "=", "$", "content", "->", "seoKeywords", ";", "$", "view", "->", "params", "[", "'robot'", "]", "=", "$", "content", "->", "seoRobot", ";", "// SEO - Page Title", "$", "siteTitle", "=", "$", "coreProperties", "->", "getSiteTitle", "(", ")", ";", "$", "titleSeparator", "=", "$", "cmsProperties", "->", "getTitleSeparator", "(", ")", ";", "$", "seoName", "=", "!", "empty", "(", "$", "content", "->", "seoName", ")", "?", "$", "content", "->", "seoName", ":", "$", "model", "->", "name", ";", "if", "(", "$", "cmsProperties", "->", "isSiteTitle", "(", ")", ")", "{", "if", "(", "$", "cmsProperties", "->", "isAppendTitle", "(", ")", ")", "{", "$", "view", "->", "title", "=", "\"$seoName $titleSeparator $siteTitle\"", ";", "}", "else", "{", "$", "view", "->", "title", "=", "\"$siteTitle $titleSeparator $seoName\"", ";", "}", "}", "else", "{", "$", "view", "->", "title", "=", "$", "content", "->", "seoName", ";", "}", "}", "}" ]
Generates the meta data of Page or Post. @param \yii\web\View $view The current view being rendered by controller. @param array $config - It can pass service, typed and type to detect the model. It can also pass basePath to form ogurl. @return array having page meta data.
[ "Generates", "the", "meta", "data", "of", "Page", "or", "Post", "." ]
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/utilities/ContentUtil.php#L38-L82
225,795
cmsgears/module-cms
common/utilities/ContentUtil.php
ContentUtil.initModelPage
public static function initModelPage( $view, $config = [] ) { $model = isset( $view->params[ 'model' ] ) ? $view->params[ 'model' ] : self::findModel( $config ); if( isset( $model ) ) { $coreProperties = CoreProperties::getInstance(); $cmsProperties = CmsProperties::getInstance(); $seoData = $model->getDataMeta( CoreGlobal::DATA_SEO ); $content = $model->modelContent; // Model $view->params[ 'model' ] = $model; $view->params[ 'content' ] = $content; // SEO H1 - Page Summary $view->params[ 'summary' ] = $content->summary; // SEO Meta Tags - Description, Keywords, Robot Text $view->params[ 'desc' ] = isset( $content->seoDescription ) ? $content->seoDescription : $model->description; $view->params[ 'keywords' ] = $content->seoKeywords; $view->params[ 'robot' ] = $content->seoRobot; // SEO - Page Title $siteTitle = $coreProperties->getSiteTitle(); $titleSeparator = $cmsProperties->getTitleSeparator(); $seoName = !empty( $content->seoName ) ? $content->seoName : $model->name; if( $cmsProperties->isSiteTitle() ) { if( $cmsProperties->isAppendTitle() ) { $view->title = "$seoName $titleSeparator $siteTitle"; } else { $view->title = "$siteTitle $titleSeparator $seoName"; } } else { $view->title = $model->seoName; } } }
php
public static function initModelPage( $view, $config = [] ) { $model = isset( $view->params[ 'model' ] ) ? $view->params[ 'model' ] : self::findModel( $config ); if( isset( $model ) ) { $coreProperties = CoreProperties::getInstance(); $cmsProperties = CmsProperties::getInstance(); $seoData = $model->getDataMeta( CoreGlobal::DATA_SEO ); $content = $model->modelContent; // Model $view->params[ 'model' ] = $model; $view->params[ 'content' ] = $content; // SEO H1 - Page Summary $view->params[ 'summary' ] = $content->summary; // SEO Meta Tags - Description, Keywords, Robot Text $view->params[ 'desc' ] = isset( $content->seoDescription ) ? $content->seoDescription : $model->description; $view->params[ 'keywords' ] = $content->seoKeywords; $view->params[ 'robot' ] = $content->seoRobot; // SEO - Page Title $siteTitle = $coreProperties->getSiteTitle(); $titleSeparator = $cmsProperties->getTitleSeparator(); $seoName = !empty( $content->seoName ) ? $content->seoName : $model->name; if( $cmsProperties->isSiteTitle() ) { if( $cmsProperties->isAppendTitle() ) { $view->title = "$seoName $titleSeparator $siteTitle"; } else { $view->title = "$siteTitle $titleSeparator $seoName"; } } else { $view->title = $model->seoName; } } }
[ "public", "static", "function", "initModelPage", "(", "$", "view", ",", "$", "config", "=", "[", "]", ")", "{", "$", "model", "=", "isset", "(", "$", "view", "->", "params", "[", "'model'", "]", ")", "?", "$", "view", "->", "params", "[", "'model'", "]", ":", "self", "::", "findModel", "(", "$", "config", ")", ";", "if", "(", "isset", "(", "$", "model", ")", ")", "{", "$", "coreProperties", "=", "CoreProperties", "::", "getInstance", "(", ")", ";", "$", "cmsProperties", "=", "CmsProperties", "::", "getInstance", "(", ")", ";", "$", "seoData", "=", "$", "model", "->", "getDataMeta", "(", "CoreGlobal", "::", "DATA_SEO", ")", ";", "$", "content", "=", "$", "model", "->", "modelContent", ";", "// Model", "$", "view", "->", "params", "[", "'model'", "]", "=", "$", "model", ";", "$", "view", "->", "params", "[", "'content'", "]", "=", "$", "content", ";", "// SEO H1 - Page Summary", "$", "view", "->", "params", "[", "'summary'", "]", "=", "$", "content", "->", "summary", ";", "// SEO Meta Tags - Description, Keywords, Robot Text", "$", "view", "->", "params", "[", "'desc'", "]", "=", "isset", "(", "$", "content", "->", "seoDescription", ")", "?", "$", "content", "->", "seoDescription", ":", "$", "model", "->", "description", ";", "$", "view", "->", "params", "[", "'keywords'", "]", "=", "$", "content", "->", "seoKeywords", ";", "$", "view", "->", "params", "[", "'robot'", "]", "=", "$", "content", "->", "seoRobot", ";", "// SEO - Page Title", "$", "siteTitle", "=", "$", "coreProperties", "->", "getSiteTitle", "(", ")", ";", "$", "titleSeparator", "=", "$", "cmsProperties", "->", "getTitleSeparator", "(", ")", ";", "$", "seoName", "=", "!", "empty", "(", "$", "content", "->", "seoName", ")", "?", "$", "content", "->", "seoName", ":", "$", "model", "->", "name", ";", "if", "(", "$", "cmsProperties", "->", "isSiteTitle", "(", ")", ")", "{", "if", "(", "$", "cmsProperties", "->", "isAppendTitle", "(", ")", ")", "{", "$", "view", "->", "title", "=", "\"$seoName $titleSeparator $siteTitle\"", ";", "}", "else", "{", "$", "view", "->", "title", "=", "\"$siteTitle $titleSeparator $seoName\"", ";", "}", "}", "else", "{", "$", "view", "->", "title", "=", "$", "model", "->", "seoName", ";", "}", "}", "}" ]
Generates the meta data of Model using model content. @param \yii\web\View $view The current view being rendered by controller. @param array $config @return array having model meta data.
[ "Generates", "the", "meta", "data", "of", "Model", "using", "model", "content", "." ]
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/utilities/ContentUtil.php#L143-L188
225,796
cmsgears/module-cms
common/utilities/ContentUtil.php
ContentUtil.findPage
public static function findPage( $view, $config = [] ) { $moduleName = $view->context->module->id; $controllerName = Yii::$app->controller->id; $actionName = Yii::$app->controller->action->id; $page = null; // System/Public Pages - Landing, Login, Register, Confirm Account, Activate Account, Forgot Password, Reset Password if( $moduleName == 'core' && $controllerName == 'site' ) { // Landing Page if( $actionName == 'index' ) { $page = self::getPage( 'home' ); } // System Page else { $page = self::getPage( $actionName ); } } // Blog/CMS Pages else if( isset( Yii::$app->request->queryParams[ 'slug' ] ) ) { $type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : CmsGlobal::TYPE_PAGE; $page = self::getPage( Yii::$app->request->queryParams[ 'slug' ], $type ); } return $page; }
php
public static function findPage( $view, $config = [] ) { $moduleName = $view->context->module->id; $controllerName = Yii::$app->controller->id; $actionName = Yii::$app->controller->action->id; $page = null; // System/Public Pages - Landing, Login, Register, Confirm Account, Activate Account, Forgot Password, Reset Password if( $moduleName == 'core' && $controllerName == 'site' ) { // Landing Page if( $actionName == 'index' ) { $page = self::getPage( 'home' ); } // System Page else { $page = self::getPage( $actionName ); } } // Blog/CMS Pages else if( isset( Yii::$app->request->queryParams[ 'slug' ] ) ) { $type = isset( $config[ 'type' ] ) ? $config[ 'type' ] : CmsGlobal::TYPE_PAGE; $page = self::getPage( Yii::$app->request->queryParams[ 'slug' ], $type ); } return $page; }
[ "public", "static", "function", "findPage", "(", "$", "view", ",", "$", "config", "=", "[", "]", ")", "{", "$", "moduleName", "=", "$", "view", "->", "context", "->", "module", "->", "id", ";", "$", "controllerName", "=", "Yii", "::", "$", "app", "->", "controller", "->", "id", ";", "$", "actionName", "=", "Yii", "::", "$", "app", "->", "controller", "->", "action", "->", "id", ";", "$", "page", "=", "null", ";", "// System/Public Pages - Landing, Login, Register, Confirm Account, Activate Account, Forgot Password, Reset Password", "if", "(", "$", "moduleName", "==", "'core'", "&&", "$", "controllerName", "==", "'site'", ")", "{", "// Landing Page", "if", "(", "$", "actionName", "==", "'index'", ")", "{", "$", "page", "=", "self", "::", "getPage", "(", "'home'", ")", ";", "}", "// System Page", "else", "{", "$", "page", "=", "self", "::", "getPage", "(", "$", "actionName", ")", ";", "}", "}", "// Blog/CMS Pages", "else", "if", "(", "isset", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", "[", "'slug'", "]", ")", ")", "{", "$", "type", "=", "isset", "(", "$", "config", "[", "'type'", "]", ")", "?", "$", "config", "[", "'type'", "]", ":", "CmsGlobal", "::", "TYPE_PAGE", ";", "$", "page", "=", "self", "::", "getPage", "(", "Yii", "::", "$", "app", "->", "request", "->", "queryParams", "[", "'slug'", "]", ",", "$", "type", ")", ";", "}", "return", "$", "page", ";", "}" ]
Find and return the view according to the configuration passed to it. @param \yii\web\View $view @param array $config @return \cmsgears\cms\common\models\entities\Content
[ "Find", "and", "return", "the", "view", "according", "to", "the", "configuration", "passed", "to", "it", "." ]
ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8
https://github.com/cmsgears/module-cms/blob/ee35eac3eb8dc9001b2e5dd7dade7f69d9546de8/common/utilities/ContentUtil.php#L197-L228
225,797
OAuth2-Framework/bearer-token-type
BearerToken.php
BearerToken.getTokenFromAuthorizationHeaders
private function getTokenFromAuthorizationHeaders(ServerRequestInterface $request): ?string { $authorization_headers = $request->getHeader('AUTHORIZATION'); foreach ($authorization_headers as $authorization_header) { if (1 === \Safe\preg_match('/'.\preg_quote('Bearer', '/').'\s([a-zA-Z0-9\-_\+~\/\.]+)/', $authorization_header, $matches)) { return $matches[1]; } } return null; }
php
private function getTokenFromAuthorizationHeaders(ServerRequestInterface $request): ?string { $authorization_headers = $request->getHeader('AUTHORIZATION'); foreach ($authorization_headers as $authorization_header) { if (1 === \Safe\preg_match('/'.\preg_quote('Bearer', '/').'\s([a-zA-Z0-9\-_\+~\/\.]+)/', $authorization_header, $matches)) { return $matches[1]; } } return null; }
[ "private", "function", "getTokenFromAuthorizationHeaders", "(", "ServerRequestInterface", "$", "request", ")", ":", "?", "string", "{", "$", "authorization_headers", "=", "$", "request", "->", "getHeader", "(", "'AUTHORIZATION'", ")", ";", "foreach", "(", "$", "authorization_headers", "as", "$", "authorization_header", ")", "{", "if", "(", "1", "===", "\\", "Safe", "\\", "preg_match", "(", "'/'", ".", "\\", "preg_quote", "(", "'Bearer'", ",", "'/'", ")", ".", "'\\s([a-zA-Z0-9\\-_\\+~\\/\\.]+)/'", ",", "$", "authorization_header", ",", "$", "matches", ")", ")", "{", "return", "$", "matches", "[", "1", "]", ";", "}", "}", "return", "null", ";", "}" ]
Get the token from the authorization header.
[ "Get", "the", "token", "from", "the", "authorization", "header", "." ]
faa34838a313fdbd96d0e61bddfc93c441ca2bd3
https://github.com/OAuth2-Framework/bearer-token-type/blob/faa34838a313fdbd96d0e61bddfc93c441ca2bd3/BearerToken.php#L110-L121
225,798
OAuth2-Framework/bearer-token-type
BearerToken.php
BearerToken.getTokenFromRequestBody
private function getTokenFromRequestBody(ServerRequestInterface $request): ?string { try { $parameters = RequestBodyParser::parseFormUrlEncoded($request); return $this->getAccessTokenFromParameters($parameters); } catch (\Exception $e) { return null; } }
php
private function getTokenFromRequestBody(ServerRequestInterface $request): ?string { try { $parameters = RequestBodyParser::parseFormUrlEncoded($request); return $this->getAccessTokenFromParameters($parameters); } catch (\Exception $e) { return null; } }
[ "private", "function", "getTokenFromRequestBody", "(", "ServerRequestInterface", "$", "request", ")", ":", "?", "string", "{", "try", "{", "$", "parameters", "=", "RequestBodyParser", "::", "parseFormUrlEncoded", "(", "$", "request", ")", ";", "return", "$", "this", "->", "getAccessTokenFromParameters", "(", "$", "parameters", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "}" ]
Get the token from the request body.
[ "Get", "the", "token", "from", "the", "request", "body", "." ]
faa34838a313fdbd96d0e61bddfc93c441ca2bd3
https://github.com/OAuth2-Framework/bearer-token-type/blob/faa34838a313fdbd96d0e61bddfc93c441ca2bd3/BearerToken.php#L126-L135
225,799
OAuth2-Framework/bearer-token-type
BearerToken.php
BearerToken.getTokenFromQuery
private function getTokenFromQuery(ServerRequestInterface $request): ?string { $query_params = $request->getQueryParams(); return $this->getAccessTokenFromParameters($query_params); }
php
private function getTokenFromQuery(ServerRequestInterface $request): ?string { $query_params = $request->getQueryParams(); return $this->getAccessTokenFromParameters($query_params); }
[ "private", "function", "getTokenFromQuery", "(", "ServerRequestInterface", "$", "request", ")", ":", "?", "string", "{", "$", "query_params", "=", "$", "request", "->", "getQueryParams", "(", ")", ";", "return", "$", "this", "->", "getAccessTokenFromParameters", "(", "$", "query_params", ")", ";", "}" ]
Get the token from the query string.
[ "Get", "the", "token", "from", "the", "query", "string", "." ]
faa34838a313fdbd96d0e61bddfc93c441ca2bd3
https://github.com/OAuth2-Framework/bearer-token-type/blob/faa34838a313fdbd96d0e61bddfc93c441ca2bd3/BearerToken.php#L140-L145