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
21,800
PHPPowertools/HTML5
src/PowerTools/HTML5/Parser/Tokenizer.php
HTML5_Parser_Tokenizer.parseError
protected function parseError($msg) { $args = func_get_args(); if (count($args) > 1) { array_shift($args); $msg = vsprintf($msg, $args); } $line = $this->scanner->currentLine(); $col = $this->scanner->columnOffset(); $this->events->parseError($msg, $line, $col); return false; }
php
protected function parseError($msg) { $args = func_get_args(); if (count($args) > 1) { array_shift($args); $msg = vsprintf($msg, $args); } $line = $this->scanner->currentLine(); $col = $this->scanner->columnOffset(); $this->events->parseError($msg, $line, $col); return false; }
[ "protected", "function", "parseError", "(", "$", "msg", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "args", ")", ">", "1", ")", "{", "array_shift", "(", "$", "args", ")", ";", "$", "msg", "=", "vsprintf", "(", "$", "msg", ",", "$", "args", ")", ";", "}", "$", "line", "=", "$", "this", "->", "scanner", "->", "currentLine", "(", ")", ";", "$", "col", "=", "$", "this", "->", "scanner", "->", "columnOffset", "(", ")", ";", "$", "this", "->", "events", "->", "parseError", "(", "$", "msg", ",", "$", "line", ",", "$", "col", ")", ";", "return", "false", ";", "}" ]
Emit a parse error. A parse error always returns false because it never consumes any characters.
[ "Emit", "a", "parse", "error", "." ]
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/Tokenizer.php#L1013-L1025
21,801
PHPPowertools/HTML5
src/PowerTools/HTML5/Parser/Tokenizer.php
HTML5_Parser_Tokenizer.decodeCharacterReference
protected function decodeCharacterReference($inAttribute = false) { // If it fails this, it's definitely not an entity. if ($this->scanner->current() != '&') { return false; } // Next char after &. $tok = $this->scanner->next(); $entity = ''; $start = $this->scanner->position(); if ($tok == false) { return '&'; } // These indicate not an entity. We return just // the &. if (strspn($tok, static::WHITE . "&<") == 1) { // $this->scanner->next(); return '&'; } // Numeric entity if ($tok == '#') { $tok = $this->scanner->next(); // Hexidecimal encoding. // X[0-9a-fA-F]+; // x[0-9a-fA-F]+; if ($tok == 'x' || $tok == 'X') { $tok = $this->scanner->next(); // Consume x // Convert from hex code to char. $hex = $this->scanner->getHex(); if (empty($hex)) { $this->parseError("Expected &#xHEX;, got &#x%s", $tok); // We unconsume because we don't know what parser rules might // be in effect for the remaining chars. For example. '&#>' // might result in a specific parsing rule inside of tag // contexts, while not inside of pcdata context. $this->scanner->unconsume(2); return '&'; } $entity = HTML5_Parser_CharacterReference::lookupHex($hex); } // Decimal encoding. // [0-9]+; else { // Convert from decimal to char. $numeric = $this->scanner->getNumeric(); if ($numeric === false) { $this->parseError("Expected &#DIGITS;, got &#%s", $tok); $this->scanner->unconsume(2); return '&'; } $entity = HTML5_Parser_CharacterReference::lookupDecimal($numeric); } } // String entity. else { // Attempt to consume a string up to a ';'. // [a-zA-Z0-9]+; $cname = $this->scanner->getAsciiAlpha(); $entity = HTML5_Parser_CharacterReference::lookupName($cname); if ($entity == null) { $this->parseError("No match in entity table for '%s'", $entity); } } // The scanner has advanced the cursor for us. $tok = $this->scanner->current(); // We have an entity. We're done here. if ($tok == ';') { $this->scanner->next(); return $entity; } // If in an attribute, then failing to match ; means unconsume the // entire string. Otherwise, failure to match is an error. if ($inAttribute) { $this->scanner->unconsume($this->scanner->position() - $start); return '&'; } $this->parseError("Expected &ENTITY;, got &ENTITY%s (no trailing ;) ", $tok); return '&' . $entity; }
php
protected function decodeCharacterReference($inAttribute = false) { // If it fails this, it's definitely not an entity. if ($this->scanner->current() != '&') { return false; } // Next char after &. $tok = $this->scanner->next(); $entity = ''; $start = $this->scanner->position(); if ($tok == false) { return '&'; } // These indicate not an entity. We return just // the &. if (strspn($tok, static::WHITE . "&<") == 1) { // $this->scanner->next(); return '&'; } // Numeric entity if ($tok == '#') { $tok = $this->scanner->next(); // Hexidecimal encoding. // X[0-9a-fA-F]+; // x[0-9a-fA-F]+; if ($tok == 'x' || $tok == 'X') { $tok = $this->scanner->next(); // Consume x // Convert from hex code to char. $hex = $this->scanner->getHex(); if (empty($hex)) { $this->parseError("Expected &#xHEX;, got &#x%s", $tok); // We unconsume because we don't know what parser rules might // be in effect for the remaining chars. For example. '&#>' // might result in a specific parsing rule inside of tag // contexts, while not inside of pcdata context. $this->scanner->unconsume(2); return '&'; } $entity = HTML5_Parser_CharacterReference::lookupHex($hex); } // Decimal encoding. // [0-9]+; else { // Convert from decimal to char. $numeric = $this->scanner->getNumeric(); if ($numeric === false) { $this->parseError("Expected &#DIGITS;, got &#%s", $tok); $this->scanner->unconsume(2); return '&'; } $entity = HTML5_Parser_CharacterReference::lookupDecimal($numeric); } } // String entity. else { // Attempt to consume a string up to a ';'. // [a-zA-Z0-9]+; $cname = $this->scanner->getAsciiAlpha(); $entity = HTML5_Parser_CharacterReference::lookupName($cname); if ($entity == null) { $this->parseError("No match in entity table for '%s'", $entity); } } // The scanner has advanced the cursor for us. $tok = $this->scanner->current(); // We have an entity. We're done here. if ($tok == ';') { $this->scanner->next(); return $entity; } // If in an attribute, then failing to match ; means unconsume the // entire string. Otherwise, failure to match is an error. if ($inAttribute) { $this->scanner->unconsume($this->scanner->position() - $start); return '&'; } $this->parseError("Expected &ENTITY;, got &ENTITY%s (no trailing ;) ", $tok); return '&' . $entity; }
[ "protected", "function", "decodeCharacterReference", "(", "$", "inAttribute", "=", "false", ")", "{", "// If it fails this, it's definitely not an entity.", "if", "(", "$", "this", "->", "scanner", "->", "current", "(", ")", "!=", "'&'", ")", "{", "return", "false", ";", "}", "// Next char after &.", "$", "tok", "=", "$", "this", "->", "scanner", "->", "next", "(", ")", ";", "$", "entity", "=", "''", ";", "$", "start", "=", "$", "this", "->", "scanner", "->", "position", "(", ")", ";", "if", "(", "$", "tok", "==", "false", ")", "{", "return", "'&'", ";", "}", "// These indicate not an entity. We return just", "// the &.", "if", "(", "strspn", "(", "$", "tok", ",", "static", "::", "WHITE", ".", "\"&<\"", ")", "==", "1", ")", "{", "// $this->scanner->next();", "return", "'&'", ";", "}", "// Numeric entity", "if", "(", "$", "tok", "==", "'#'", ")", "{", "$", "tok", "=", "$", "this", "->", "scanner", "->", "next", "(", ")", ";", "// Hexidecimal encoding.", "// X[0-9a-fA-F]+;", "// x[0-9a-fA-F]+;", "if", "(", "$", "tok", "==", "'x'", "||", "$", "tok", "==", "'X'", ")", "{", "$", "tok", "=", "$", "this", "->", "scanner", "->", "next", "(", ")", ";", "// Consume x", "// Convert from hex code to char.", "$", "hex", "=", "$", "this", "->", "scanner", "->", "getHex", "(", ")", ";", "if", "(", "empty", "(", "$", "hex", ")", ")", "{", "$", "this", "->", "parseError", "(", "\"Expected &#xHEX;, got &#x%s\"", ",", "$", "tok", ")", ";", "// We unconsume because we don't know what parser rules might", "// be in effect for the remaining chars. For example. '&#>'", "// might result in a specific parsing rule inside of tag", "// contexts, while not inside of pcdata context.", "$", "this", "->", "scanner", "->", "unconsume", "(", "2", ")", ";", "return", "'&'", ";", "}", "$", "entity", "=", "HTML5_Parser_CharacterReference", "::", "lookupHex", "(", "$", "hex", ")", ";", "}", "// Decimal encoding.", "// [0-9]+;", "else", "{", "// Convert from decimal to char.", "$", "numeric", "=", "$", "this", "->", "scanner", "->", "getNumeric", "(", ")", ";", "if", "(", "$", "numeric", "===", "false", ")", "{", "$", "this", "->", "parseError", "(", "\"Expected &#DIGITS;, got &#%s\"", ",", "$", "tok", ")", ";", "$", "this", "->", "scanner", "->", "unconsume", "(", "2", ")", ";", "return", "'&'", ";", "}", "$", "entity", "=", "HTML5_Parser_CharacterReference", "::", "lookupDecimal", "(", "$", "numeric", ")", ";", "}", "}", "// String entity.", "else", "{", "// Attempt to consume a string up to a ';'.", "// [a-zA-Z0-9]+;", "$", "cname", "=", "$", "this", "->", "scanner", "->", "getAsciiAlpha", "(", ")", ";", "$", "entity", "=", "HTML5_Parser_CharacterReference", "::", "lookupName", "(", "$", "cname", ")", ";", "if", "(", "$", "entity", "==", "null", ")", "{", "$", "this", "->", "parseError", "(", "\"No match in entity table for '%s'\"", ",", "$", "entity", ")", ";", "}", "}", "// The scanner has advanced the cursor for us.", "$", "tok", "=", "$", "this", "->", "scanner", "->", "current", "(", ")", ";", "// We have an entity. We're done here.", "if", "(", "$", "tok", "==", "';'", ")", "{", "$", "this", "->", "scanner", "->", "next", "(", ")", ";", "return", "$", "entity", ";", "}", "// If in an attribute, then failing to match ; means unconsume the", "// entire string. Otherwise, failure to match is an error.", "if", "(", "$", "inAttribute", ")", "{", "$", "this", "->", "scanner", "->", "unconsume", "(", "$", "this", "->", "scanner", "->", "position", "(", ")", "-", "$", "start", ")", ";", "return", "'&'", ";", "}", "$", "this", "->", "parseError", "(", "\"Expected &ENTITY;, got &ENTITY%s (no trailing ;) \"", ",", "$", "tok", ")", ";", "return", "'&'", ".", "$", "entity", ";", "}" ]
Decode a character reference and return the string. Returns false if the entity could not be found. If $inAttribute is set to true, a bare & will be returned as-is. @param boolean $inAttribute Set to true if the text is inside of an attribute value. false otherwise.
[ "Decode", "a", "character", "reference", "and", "return", "the", "string", "." ]
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Parser/Tokenizer.php#L1037-L1122
21,802
wenbinye/PhalconX
src/Helper/ClassHelper.php
ClassHelper.splitName
public static function splitName($class) { $pos = strrpos($class, '\\'); if ($pos === false) { return [null, $class]; } else { return [substr($class, 0, $pos), substr($class, $pos+1)]; } }
php
public static function splitName($class) { $pos = strrpos($class, '\\'); if ($pos === false) { return [null, $class]; } else { return [substr($class, 0, $pos), substr($class, $pos+1)]; } }
[ "public", "static", "function", "splitName", "(", "$", "class", ")", "{", "$", "pos", "=", "strrpos", "(", "$", "class", ",", "'\\\\'", ")", ";", "if", "(", "$", "pos", "===", "false", ")", "{", "return", "[", "null", ",", "$", "class", "]", ";", "}", "else", "{", "return", "[", "substr", "(", "$", "class", ",", "0", ",", "$", "pos", ")", ",", "substr", "(", "$", "class", ",", "$", "pos", "+", "1", ")", "]", ";", "}", "}" ]
Splits class name to namespace and class name @param string $class @return array
[ "Splits", "class", "name", "to", "namespace", "and", "class", "name" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/ClassHelper.php#L47-L55
21,803
weew/http
src/Weew/Http/HttpRequest.php
HttpRequest.getParameter
public function getParameter($key, $default = null) { $value = $this->getUrl()->getQuery()->get($key); if ($value === null) { $value = $this->getData()->get($key, $default); } return $value; }
php
public function getParameter($key, $default = null) { $value = $this->getUrl()->getQuery()->get($key); if ($value === null) { $value = $this->getData()->get($key, $default); } return $value; }
[ "public", "function", "getParameter", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "value", "=", "$", "this", "->", "getUrl", "(", ")", "->", "getQuery", "(", ")", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "value", "===", "null", ")", "{", "$", "value", "=", "$", "this", "->", "getData", "(", ")", "->", "get", "(", "$", "key", ",", "$", "default", ")", ";", "}", "return", "$", "value", ";", "}" ]
Retrieve a value from url query or message body. @param string $key @param null $default @return mixed
[ "Retrieve", "a", "value", "from", "url", "query", "or", "message", "body", "." ]
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpRequest.php#L314-L322
21,804
weew/http
src/Weew/Http/HttpRequest.php
HttpRequest.setDefaults
protected function setDefaults() { if ($this->getAccept() === null) { $this->setDefaultAccept(); } if ($this->getContentType() === null) { $this->setDefaultContentType(); } }
php
protected function setDefaults() { if ($this->getAccept() === null) { $this->setDefaultAccept(); } if ($this->getContentType() === null) { $this->setDefaultContentType(); } }
[ "protected", "function", "setDefaults", "(", ")", "{", "if", "(", "$", "this", "->", "getAccept", "(", ")", "===", "null", ")", "{", "$", "this", "->", "setDefaultAccept", "(", ")", ";", "}", "if", "(", "$", "this", "->", "getContentType", "(", ")", "===", "null", ")", "{", "$", "this", "->", "setDefaultContentType", "(", ")", ";", "}", "}" ]
Use this as hook to extend your custom request.
[ "Use", "this", "as", "hook", "to", "extend", "your", "custom", "request", "." ]
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpRequest.php#L344-L352
21,805
wenbinye/PhalconX
src/Helper/ClassParser.php
ClassParser.getImports
public function getImports() { $imports = []; $tokens = token_get_all(file_get_contents($this->file)); reset($tokens); $token = ''; while ($token !== false) { $token = next($tokens); if (!is_array($token)) { continue; } if ($token[0] === T_USE) { $stmt = $this->parseUseStatement($tokens); $imports += $stmt; } elseif ($token[0] === T_CLASS) { break; } } return $imports; }
php
public function getImports() { $imports = []; $tokens = token_get_all(file_get_contents($this->file)); reset($tokens); $token = ''; while ($token !== false) { $token = next($tokens); if (!is_array($token)) { continue; } if ($token[0] === T_USE) { $stmt = $this->parseUseStatement($tokens); $imports += $stmt; } elseif ($token[0] === T_CLASS) { break; } } return $imports; }
[ "public", "function", "getImports", "(", ")", "{", "$", "imports", "=", "[", "]", ";", "$", "tokens", "=", "token_get_all", "(", "file_get_contents", "(", "$", "this", "->", "file", ")", ")", ";", "reset", "(", "$", "tokens", ")", ";", "$", "token", "=", "''", ";", "while", "(", "$", "token", "!==", "false", ")", "{", "$", "token", "=", "next", "(", "$", "tokens", ")", ";", "if", "(", "!", "is_array", "(", "$", "token", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "token", "[", "0", "]", "===", "T_USE", ")", "{", "$", "stmt", "=", "$", "this", "->", "parseUseStatement", "(", "$", "tokens", ")", ";", "$", "imports", "+=", "$", "stmt", ";", "}", "elseif", "(", "$", "token", "[", "0", "]", "===", "T_CLASS", ")", "{", "break", ";", "}", "}", "return", "$", "imports", ";", "}" ]
Gets all imported classes @return array
[ "Gets", "all", "imported", "classes" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/ClassParser.php#L57-L76
21,806
zicht/z
src/Zicht/Tool/Container/Task.php
Task.compile
public function compile(Buffer $buffer) { parent::compile($buffer); if (substr($this->getName(), 0, 1) !== '_') { $buffer ->writeln('try {') ->indent(1) ->writeln('$z->addCommand(') ->indent(1) ->write('new \Zicht\Tool\Command\TaskCommand(') ->asPhp($this->getName()) ->raw(', ') ->asPhp($this->getArguments(true)) ->raw(', ') ->asPhp($this->getOptions()) ->raw(', ') ->asPhp($this->taskDef['flags']) ->raw(', ') ->asPhp($this->getHelp() ? $this->getHelp() : "(no help available for this task)") ->raw(')')->eol() ->indent(-1) ->writeln(');') ->indent(-1) ->writeln('} catch (\Exception $e) {') ->indent(1) ->writeln('throw new \Zicht\Tool\Container\ConfigurationException("Error while initializing task \'' . $this->getName() . '\'", 0, $e);') ->indent(-1) ->writeln('}') ; } }
php
public function compile(Buffer $buffer) { parent::compile($buffer); if (substr($this->getName(), 0, 1) !== '_') { $buffer ->writeln('try {') ->indent(1) ->writeln('$z->addCommand(') ->indent(1) ->write('new \Zicht\Tool\Command\TaskCommand(') ->asPhp($this->getName()) ->raw(', ') ->asPhp($this->getArguments(true)) ->raw(', ') ->asPhp($this->getOptions()) ->raw(', ') ->asPhp($this->taskDef['flags']) ->raw(', ') ->asPhp($this->getHelp() ? $this->getHelp() : "(no help available for this task)") ->raw(')')->eol() ->indent(-1) ->writeln(');') ->indent(-1) ->writeln('} catch (\Exception $e) {') ->indent(1) ->writeln('throw new \Zicht\Tool\Container\ConfigurationException("Error while initializing task \'' . $this->getName() . '\'", 0, $e);') ->indent(-1) ->writeln('}') ; } }
[ "public", "function", "compile", "(", "Buffer", "$", "buffer", ")", "{", "parent", "::", "compile", "(", "$", "buffer", ")", ";", "if", "(", "substr", "(", "$", "this", "->", "getName", "(", ")", ",", "0", ",", "1", ")", "!==", "'_'", ")", "{", "$", "buffer", "->", "writeln", "(", "'try {'", ")", "->", "indent", "(", "1", ")", "->", "writeln", "(", "'$z->addCommand('", ")", "->", "indent", "(", "1", ")", "->", "write", "(", "'new \\Zicht\\Tool\\Command\\TaskCommand('", ")", "->", "asPhp", "(", "$", "this", "->", "getName", "(", ")", ")", "->", "raw", "(", "', '", ")", "->", "asPhp", "(", "$", "this", "->", "getArguments", "(", "true", ")", ")", "->", "raw", "(", "', '", ")", "->", "asPhp", "(", "$", "this", "->", "getOptions", "(", ")", ")", "->", "raw", "(", "', '", ")", "->", "asPhp", "(", "$", "this", "->", "taskDef", "[", "'flags'", "]", ")", "->", "raw", "(", "', '", ")", "->", "asPhp", "(", "$", "this", "->", "getHelp", "(", ")", "?", "$", "this", "->", "getHelp", "(", ")", ":", "\"(no help available for this task)\"", ")", "->", "raw", "(", "')'", ")", "->", "eol", "(", ")", "->", "indent", "(", "-", "1", ")", "->", "writeln", "(", "');'", ")", "->", "indent", "(", "-", "1", ")", "->", "writeln", "(", "'} catch (\\Exception $e) {'", ")", "->", "indent", "(", "1", ")", "->", "writeln", "(", "'throw new \\Zicht\\Tool\\Container\\ConfigurationException(\"Error while initializing task \\''", ".", "$", "this", "->", "getName", "(", ")", ".", "'\\'\", 0, $e);'", ")", "->", "indent", "(", "-", "1", ")", "->", "writeln", "(", "'}'", ")", ";", "}", "}" ]
Compiles the task initialization code into the buffer. @param \Zicht\Tool\Script\Buffer $buffer @return void
[ "Compiles", "the", "task", "initialization", "code", "into", "the", "buffer", "." ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Task.php#L63-L93
21,807
heidelpay/PhpDoc
src/phpDocumentor/Compiler/Pass/PackageTreeBuilder.php
PackageTreeBuilder.execute
public function execute(ProjectDescriptor $project) { $rootPackageDescriptor = new PackageDescriptor(); $rootPackageDescriptor->setName('\\'); $project->getIndexes()->set('packages', new Collection()); $project->getIndexes()->packages['\\'] = $rootPackageDescriptor; foreach ($project->getFiles() as $file) { $this->addElementsOfTypeToPackage($project, array($file), 'files'); $this->addElementsOfTypeToPackage($project, $file->getConstants()->getAll(), 'constants'); $this->addElementsOfTypeToPackage($project, $file->getFunctions()->getAll(), 'functions'); $this->addElementsOfTypeToPackage($project, $file->getClasses()->getAll(), 'classes'); $this->addElementsOfTypeToPackage($project, $file->getInterfaces()->getAll(), 'interfaces'); $this->addElementsOfTypeToPackage($project, $file->getTraits()->getAll(), 'traits'); } }
php
public function execute(ProjectDescriptor $project) { $rootPackageDescriptor = new PackageDescriptor(); $rootPackageDescriptor->setName('\\'); $project->getIndexes()->set('packages', new Collection()); $project->getIndexes()->packages['\\'] = $rootPackageDescriptor; foreach ($project->getFiles() as $file) { $this->addElementsOfTypeToPackage($project, array($file), 'files'); $this->addElementsOfTypeToPackage($project, $file->getConstants()->getAll(), 'constants'); $this->addElementsOfTypeToPackage($project, $file->getFunctions()->getAll(), 'functions'); $this->addElementsOfTypeToPackage($project, $file->getClasses()->getAll(), 'classes'); $this->addElementsOfTypeToPackage($project, $file->getInterfaces()->getAll(), 'interfaces'); $this->addElementsOfTypeToPackage($project, $file->getTraits()->getAll(), 'traits'); } }
[ "public", "function", "execute", "(", "ProjectDescriptor", "$", "project", ")", "{", "$", "rootPackageDescriptor", "=", "new", "PackageDescriptor", "(", ")", ";", "$", "rootPackageDescriptor", "->", "setName", "(", "'\\\\'", ")", ";", "$", "project", "->", "getIndexes", "(", ")", "->", "set", "(", "'packages'", ",", "new", "Collection", "(", ")", ")", ";", "$", "project", "->", "getIndexes", "(", ")", "->", "packages", "[", "'\\\\'", "]", "=", "$", "rootPackageDescriptor", ";", "foreach", "(", "$", "project", "->", "getFiles", "(", ")", "as", "$", "file", ")", "{", "$", "this", "->", "addElementsOfTypeToPackage", "(", "$", "project", ",", "array", "(", "$", "file", ")", ",", "'files'", ")", ";", "$", "this", "->", "addElementsOfTypeToPackage", "(", "$", "project", ",", "$", "file", "->", "getConstants", "(", ")", "->", "getAll", "(", ")", ",", "'constants'", ")", ";", "$", "this", "->", "addElementsOfTypeToPackage", "(", "$", "project", ",", "$", "file", "->", "getFunctions", "(", ")", "->", "getAll", "(", ")", ",", "'functions'", ")", ";", "$", "this", "->", "addElementsOfTypeToPackage", "(", "$", "project", ",", "$", "file", "->", "getClasses", "(", ")", "->", "getAll", "(", ")", ",", "'classes'", ")", ";", "$", "this", "->", "addElementsOfTypeToPackage", "(", "$", "project", ",", "$", "file", "->", "getInterfaces", "(", ")", "->", "getAll", "(", ")", ",", "'interfaces'", ")", ";", "$", "this", "->", "addElementsOfTypeToPackage", "(", "$", "project", ",", "$", "file", "->", "getTraits", "(", ")", "->", "getAll", "(", ")", ",", "'traits'", ")", ";", "}", "}" ]
Compiles a 'packages' index on the project and create all Package Descriptors necessary. @param ProjectDescriptor $project @return void
[ "Compiles", "a", "packages", "index", "on", "the", "project", "and", "create", "all", "Package", "Descriptors", "necessary", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/PackageTreeBuilder.php#L49-L64
21,808
heidelpay/PhpDoc
src/phpDocumentor/Compiler/Pass/PackageTreeBuilder.php
PackageTreeBuilder.addElementsOfTypeToPackage
protected function addElementsOfTypeToPackage(ProjectDescriptor $project, array $elements, $type) { /** @var DescriptorAbstract $element */ foreach ($elements as $element) { $packageName = ''; $packageTags = $element->getTags()->get('package'); if ($packageTags instanceof Collection) { $packageTag = $packageTags->getIterator()->current(); if ($packageTag instanceof TagDescriptor) { $packageName = $packageTag->getDescription(); } } $subpackageCollection = $element->getTags()->get('subpackage'); if ($subpackageCollection instanceof Collection && $subpackageCollection->count() > 0) { $subpackageTag = $subpackageCollection->getIterator()->current(); if ($subpackageTag instanceof TagDescriptor) { $packageName .= '\\' . $subpackageTag->getDescription(); } } // ensure consistency by trimming the slash prefix and then re-appending it. $packageIndexName = '\\' . ltrim($packageName, '\\'); if (!isset($project->getIndexes()->packages[$packageIndexName])) { $this->createPackageDescriptorTree($project, $packageName); } /** @var PackageDescriptor $package */ $package = $project->getIndexes()->packages[$packageIndexName]; // replace textual representation with an object representation $element->setPackage($package); // add element to package $getter = 'get'.ucfirst($type); /** @var Collection $collection */ $collection = $package->$getter(); $collection->add($element); } }
php
protected function addElementsOfTypeToPackage(ProjectDescriptor $project, array $elements, $type) { /** @var DescriptorAbstract $element */ foreach ($elements as $element) { $packageName = ''; $packageTags = $element->getTags()->get('package'); if ($packageTags instanceof Collection) { $packageTag = $packageTags->getIterator()->current(); if ($packageTag instanceof TagDescriptor) { $packageName = $packageTag->getDescription(); } } $subpackageCollection = $element->getTags()->get('subpackage'); if ($subpackageCollection instanceof Collection && $subpackageCollection->count() > 0) { $subpackageTag = $subpackageCollection->getIterator()->current(); if ($subpackageTag instanceof TagDescriptor) { $packageName .= '\\' . $subpackageTag->getDescription(); } } // ensure consistency by trimming the slash prefix and then re-appending it. $packageIndexName = '\\' . ltrim($packageName, '\\'); if (!isset($project->getIndexes()->packages[$packageIndexName])) { $this->createPackageDescriptorTree($project, $packageName); } /** @var PackageDescriptor $package */ $package = $project->getIndexes()->packages[$packageIndexName]; // replace textual representation with an object representation $element->setPackage($package); // add element to package $getter = 'get'.ucfirst($type); /** @var Collection $collection */ $collection = $package->$getter(); $collection->add($element); } }
[ "protected", "function", "addElementsOfTypeToPackage", "(", "ProjectDescriptor", "$", "project", ",", "array", "$", "elements", ",", "$", "type", ")", "{", "/** @var DescriptorAbstract $element */", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "$", "packageName", "=", "''", ";", "$", "packageTags", "=", "$", "element", "->", "getTags", "(", ")", "->", "get", "(", "'package'", ")", ";", "if", "(", "$", "packageTags", "instanceof", "Collection", ")", "{", "$", "packageTag", "=", "$", "packageTags", "->", "getIterator", "(", ")", "->", "current", "(", ")", ";", "if", "(", "$", "packageTag", "instanceof", "TagDescriptor", ")", "{", "$", "packageName", "=", "$", "packageTag", "->", "getDescription", "(", ")", ";", "}", "}", "$", "subpackageCollection", "=", "$", "element", "->", "getTags", "(", ")", "->", "get", "(", "'subpackage'", ")", ";", "if", "(", "$", "subpackageCollection", "instanceof", "Collection", "&&", "$", "subpackageCollection", "->", "count", "(", ")", ">", "0", ")", "{", "$", "subpackageTag", "=", "$", "subpackageCollection", "->", "getIterator", "(", ")", "->", "current", "(", ")", ";", "if", "(", "$", "subpackageTag", "instanceof", "TagDescriptor", ")", "{", "$", "packageName", ".=", "'\\\\'", ".", "$", "subpackageTag", "->", "getDescription", "(", ")", ";", "}", "}", "// ensure consistency by trimming the slash prefix and then re-appending it.", "$", "packageIndexName", "=", "'\\\\'", ".", "ltrim", "(", "$", "packageName", ",", "'\\\\'", ")", ";", "if", "(", "!", "isset", "(", "$", "project", "->", "getIndexes", "(", ")", "->", "packages", "[", "$", "packageIndexName", "]", ")", ")", "{", "$", "this", "->", "createPackageDescriptorTree", "(", "$", "project", ",", "$", "packageName", ")", ";", "}", "/** @var PackageDescriptor $package */", "$", "package", "=", "$", "project", "->", "getIndexes", "(", ")", "->", "packages", "[", "$", "packageIndexName", "]", ";", "// replace textual representation with an object representation", "$", "element", "->", "setPackage", "(", "$", "package", ")", ";", "// add element to package", "$", "getter", "=", "'get'", ".", "ucfirst", "(", "$", "type", ")", ";", "/** @var Collection $collection */", "$", "collection", "=", "$", "package", "->", "$", "getter", "(", ")", ";", "$", "collection", "->", "add", "(", "$", "element", ")", ";", "}", "}" ]
Adds the given elements of a specific type to their respective Package Descriptors. This method will assign the given elements to the package as registered in the package field of that element. If a package does not exist yet it will automatically be created. @param ProjectDescriptor $project @param DescriptorAbstract[] $elements Series of elements to add to their respective package. @param string $type Declares which field of the package will be populated with the given series of elements. This name will be transformed to a getter which must exist. Out of performance considerations will no effort be done to verify whether the provided type is valid. @return void
[ "Adds", "the", "given", "elements", "of", "a", "specific", "type", "to", "their", "respective", "Package", "Descriptors", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/PackageTreeBuilder.php#L80-L120
21,809
platformsh/platformsh-oauth2-php
src/Provider/Platformsh.php
Platformsh.requiresTfa
private function requiresTfa(ResponseInterface $response) { return substr($response->getStatusCode(), 0, 1) === '4' && $response->hasHeader(self::TFA_HEADER); }
php
private function requiresTfa(ResponseInterface $response) { return substr($response->getStatusCode(), 0, 1) === '4' && $response->hasHeader(self::TFA_HEADER); }
[ "private", "function", "requiresTfa", "(", "ResponseInterface", "$", "response", ")", "{", "return", "substr", "(", "$", "response", "->", "getStatusCode", "(", ")", ",", "0", ",", "1", ")", "===", "'4'", "&&", "$", "response", "->", "hasHeader", "(", "self", "::", "TFA_HEADER", ")", ";", "}" ]
Check whether the response requires two-factor authentication. @param \Psr\Http\Message\ResponseInterface $response @return bool
[ "Check", "whether", "the", "response", "requires", "two", "-", "factor", "authentication", "." ]
c5056b818f326e8ee358521224ac7f803d1e9d6b
https://github.com/platformsh/platformsh-oauth2-php/blob/c5056b818f326e8ee358521224ac7f803d1e9d6b/src/Provider/Platformsh.php#L128-L131
21,810
surebert/surebert-framework
src/sb/Controller/HTTP.php
HTTP.unsetCookie
public function unsetCookie($name, $path = '/') { setcookie($name, '', time() - 86400, '/', '', 0); if (isset($_COOKIE) && isset($_COOKIE[$name])) { unset($_COOKIE[$name]); } if (isset($this->request->cookie[$name])) { unset($this->request->cookie[$name]); } }
php
public function unsetCookie($name, $path = '/') { setcookie($name, '', time() - 86400, '/', '', 0); if (isset($_COOKIE) && isset($_COOKIE[$name])) { unset($_COOKIE[$name]); } if (isset($this->request->cookie[$name])) { unset($this->request->cookie[$name]); } }
[ "public", "function", "unsetCookie", "(", "$", "name", ",", "$", "path", "=", "'/'", ")", "{", "setcookie", "(", "$", "name", ",", "''", ",", "time", "(", ")", "-", "86400", ",", "'/'", ",", "''", ",", "0", ")", ";", "if", "(", "isset", "(", "$", "_COOKIE", ")", "&&", "isset", "(", "$", "_COOKIE", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "_COOKIE", "[", "$", "name", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "request", "->", "cookie", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "request", "->", "cookie", "[", "$", "name", "]", ")", ";", "}", "}" ]
Unsets a cookie value by setting it to expire @param string $name The cookie name @param string path The path to clear, defaults to /
[ "Unsets", "a", "cookie", "value", "by", "setting", "it", "to", "expire" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTTP.php#L79-L88
21,811
surebert/surebert-framework
src/sb/Controller/HTTP.php
HTTP.sendError
public function sendError($error_num, $err_str = '') { if (empty($err_str)) { switch ($error_num) { case 400: $err_str = 'Bad Request'; break; case 401: $err_str = 'Unauthorized'; break; case 403: $err_str = 'Forbidden'; break; case 404: $err_str = 'Not Found'; break; case 405: $err_str = 'Method Not Allowed'; break; case 410: $err_str = 'Gone'; break; case 415: $err_str = 'Unsupported Media Type'; break; case 500: $err_str = 'Internal Server Error'; break; case 501: $err_str = 'Not Implemented'; break; } } $this->sendHeader("HTTP/1.0 $error_num $err_str"); }
php
public function sendError($error_num, $err_str = '') { if (empty($err_str)) { switch ($error_num) { case 400: $err_str = 'Bad Request'; break; case 401: $err_str = 'Unauthorized'; break; case 403: $err_str = 'Forbidden'; break; case 404: $err_str = 'Not Found'; break; case 405: $err_str = 'Method Not Allowed'; break; case 410: $err_str = 'Gone'; break; case 415: $err_str = 'Unsupported Media Type'; break; case 500: $err_str = 'Internal Server Error'; break; case 501: $err_str = 'Not Implemented'; break; } } $this->sendHeader("HTTP/1.0 $error_num $err_str"); }
[ "public", "function", "sendError", "(", "$", "error_num", ",", "$", "err_str", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "err_str", ")", ")", "{", "switch", "(", "$", "error_num", ")", "{", "case", "400", ":", "$", "err_str", "=", "'Bad Request'", ";", "break", ";", "case", "401", ":", "$", "err_str", "=", "'Unauthorized'", ";", "break", ";", "case", "403", ":", "$", "err_str", "=", "'Forbidden'", ";", "break", ";", "case", "404", ":", "$", "err_str", "=", "'Not Found'", ";", "break", ";", "case", "405", ":", "$", "err_str", "=", "'Method Not Allowed'", ";", "break", ";", "case", "410", ":", "$", "err_str", "=", "'Gone'", ";", "break", ";", "case", "415", ":", "$", "err_str", "=", "'Unsupported Media Type'", ";", "break", ";", "case", "500", ":", "$", "err_str", "=", "'Internal Server Error'", ";", "break", ";", "case", "501", ":", "$", "err_str", "=", "'Not Implemented'", ";", "break", ";", "}", "}", "$", "this", "->", "sendHeader", "(", "\"HTTP/1.0 $error_num $err_str\"", ")", ";", "}" ]
Send an http error header @param integer $error_num The number of the error as found http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html @param string $err_str The error string to send, defaults sent for 400, 401, 403, 404, 405, 410, 415, 500, 501 unless specified
[ "Send", "an", "http", "error", "header" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTTP.php#L119-L162
21,812
surebert/surebert-framework
src/sb/Controller/HTTP.php
HTTP.requireBasicAuth
public function requireBasicAuth($check_auth = '', $realm = 'Please enter your username and password') { $authorized = false; if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="' . $realm . '"'); header('HTTP/1.0 401 Unauthorized'); echo 'You must authenticate to continue'; } else { if (is_callable($check_auth)) { $authorized = $check_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); } if (!$authorized) { session_unset(); unset($_SERVER['PHP_AUTH_USER']); return $this->requireBasicAuth($check_auth, $realm); } } return $authorized; }
php
public function requireBasicAuth($check_auth = '', $realm = 'Please enter your username and password') { $authorized = false; if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="' . $realm . '"'); header('HTTP/1.0 401 Unauthorized'); echo 'You must authenticate to continue'; } else { if (is_callable($check_auth)) { $authorized = $check_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); } if (!$authorized) { session_unset(); unset($_SERVER['PHP_AUTH_USER']); return $this->requireBasicAuth($check_auth, $realm); } } return $authorized; }
[ "public", "function", "requireBasicAuth", "(", "$", "check_auth", "=", "''", ",", "$", "realm", "=", "'Please enter your username and password'", ")", "{", "$", "authorized", "=", "false", ";", "if", "(", "!", "isset", "(", "$", "_SERVER", "[", "'PHP_AUTH_USER'", "]", ")", ")", "{", "header", "(", "'WWW-Authenticate: Basic realm=\"'", ".", "$", "realm", ".", "'\"'", ")", ";", "header", "(", "'HTTP/1.0 401 Unauthorized'", ")", ";", "echo", "'You must authenticate to continue'", ";", "}", "else", "{", "if", "(", "is_callable", "(", "$", "check_auth", ")", ")", "{", "$", "authorized", "=", "$", "check_auth", "(", "$", "_SERVER", "[", "'PHP_AUTH_USER'", "]", ",", "$", "_SERVER", "[", "'PHP_AUTH_PW'", "]", ")", ";", "}", "if", "(", "!", "$", "authorized", ")", "{", "session_unset", "(", ")", ";", "unset", "(", "$", "_SERVER", "[", "'PHP_AUTH_USER'", "]", ")", ";", "return", "$", "this", "->", "requireBasicAuth", "(", "$", "check_auth", ",", "$", "realm", ")", ";", "}", "}", "return", "$", "authorized", ";", "}" ]
Added option for requesting basic auth. ONLY USE OVER SSL @param callable $check_auth the callable that determines success or not @param string $realm the realm beings used @return boolean
[ "Added", "option", "for", "requesting", "basic", "auth", ".", "ONLY", "USE", "OVER", "SSL" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/HTTP.php#L295-L317
21,813
wenbinye/PhalconX
src/Di/FactoryDefault.php
FactoryDefault.autoload
public function autoload(array $autoloads, $provider, $options = []) { foreach ($autoloads as $name => $alias) { if (is_int($name)) { $name = $alias; } if (empty($name)) { throw new \InvalidArgumentException("Cannot not autoload empty service"); } if (!empty($options['prefix'])) { $alias = $options['prefix'] . ucfirst($alias); } $shared = true; if (isset($options['shared'])) { if (is_array($options['shared'])) { $shared = in_array($name, $options['shared']); } else { $shared = $options['shared']; } } elseif (isset($options['instances'])) { $shared = !in_array($name, $options['instances']); } $this->set($alias, function () use ($name, $provider) { if (!is_object($provider)) { $provider = $this->getShared($provider); } return $provider->provide($name, func_get_args()); }, $shared); } return $this; }
php
public function autoload(array $autoloads, $provider, $options = []) { foreach ($autoloads as $name => $alias) { if (is_int($name)) { $name = $alias; } if (empty($name)) { throw new \InvalidArgumentException("Cannot not autoload empty service"); } if (!empty($options['prefix'])) { $alias = $options['prefix'] . ucfirst($alias); } $shared = true; if (isset($options['shared'])) { if (is_array($options['shared'])) { $shared = in_array($name, $options['shared']); } else { $shared = $options['shared']; } } elseif (isset($options['instances'])) { $shared = !in_array($name, $options['instances']); } $this->set($alias, function () use ($name, $provider) { if (!is_object($provider)) { $provider = $this->getShared($provider); } return $provider->provide($name, func_get_args()); }, $shared); } return $this; }
[ "public", "function", "autoload", "(", "array", "$", "autoloads", ",", "$", "provider", ",", "$", "options", "=", "[", "]", ")", "{", "foreach", "(", "$", "autoloads", "as", "$", "name", "=>", "$", "alias", ")", "{", "if", "(", "is_int", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "alias", ";", "}", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Cannot not autoload empty service\"", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'prefix'", "]", ")", ")", "{", "$", "alias", "=", "$", "options", "[", "'prefix'", "]", ".", "ucfirst", "(", "$", "alias", ")", ";", "}", "$", "shared", "=", "true", ";", "if", "(", "isset", "(", "$", "options", "[", "'shared'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "options", "[", "'shared'", "]", ")", ")", "{", "$", "shared", "=", "in_array", "(", "$", "name", ",", "$", "options", "[", "'shared'", "]", ")", ";", "}", "else", "{", "$", "shared", "=", "$", "options", "[", "'shared'", "]", ";", "}", "}", "elseif", "(", "isset", "(", "$", "options", "[", "'instances'", "]", ")", ")", "{", "$", "shared", "=", "!", "in_array", "(", "$", "name", ",", "$", "options", "[", "'instances'", "]", ")", ";", "}", "$", "this", "->", "set", "(", "$", "alias", ",", "function", "(", ")", "use", "(", "$", "name", ",", "$", "provider", ")", "{", "if", "(", "!", "is_object", "(", "$", "provider", ")", ")", "{", "$", "provider", "=", "$", "this", "->", "getShared", "(", "$", "provider", ")", ";", "}", "return", "$", "provider", "->", "provide", "(", "$", "name", ",", "func_get_args", "(", ")", ")", ";", "}", ",", "$", "shared", ")", ";", "}", "return", "$", "this", ";", "}" ]
mark autoload service definition from service provider @param array $autoloads name of service. service alias @param string|ServiceProvider $provider service provider @param array options: shared, instances, prefix
[ "mark", "autoload", "service", "definition", "from", "service", "provider" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Di/FactoryDefault.php#L78-L108
21,814
wenbinye/PhalconX
src/Di/FactoryDefault.php
FactoryDefault.load
public function load($provider, $options = null) { if (!is_object($provider)) { $provider = $this->getShared($provider); } $names = $provider->getNames(); if (isset($options['aliases'])) { $services = $this->createServiceAliases($names, $options['aliases']); unset($options['aliases']); } else { $services = $names; } return $this->autoload($services, $provider, $options); }
php
public function load($provider, $options = null) { if (!is_object($provider)) { $provider = $this->getShared($provider); } $names = $provider->getNames(); if (isset($options['aliases'])) { $services = $this->createServiceAliases($names, $options['aliases']); unset($options['aliases']); } else { $services = $names; } return $this->autoload($services, $provider, $options); }
[ "public", "function", "load", "(", "$", "provider", ",", "$", "options", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "provider", ")", ")", "{", "$", "provider", "=", "$", "this", "->", "getShared", "(", "$", "provider", ")", ";", "}", "$", "names", "=", "$", "provider", "->", "getNames", "(", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'aliases'", "]", ")", ")", "{", "$", "services", "=", "$", "this", "->", "createServiceAliases", "(", "$", "names", ",", "$", "options", "[", "'aliases'", "]", ")", ";", "unset", "(", "$", "options", "[", "'aliases'", "]", ")", ";", "}", "else", "{", "$", "services", "=", "$", "names", ";", "}", "return", "$", "this", "->", "autoload", "(", "$", "services", ",", "$", "provider", ",", "$", "options", ")", ";", "}" ]
load all service definition from service provider @param string|ServiceProvider $provider service provider @param array $options non-shared service names - aliases - shared - instances - prefix
[ "load", "all", "service", "definition", "from", "service", "provider" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Di/FactoryDefault.php#L120-L133
21,815
nabab/bbn
src/bbn/appui/observer.php
observer.get_file
private static function get_file(): string { if ( null === self::$path ){ if ( \defined('BBN_DATA_PATH') ){ self::$path = BBN_DATA_PATH; } else{ self::$path = __DIR__.'/'; } } return self::$path.'plugins/appui-cron/appui-observer.txt'; }
php
private static function get_file(): string { if ( null === self::$path ){ if ( \defined('BBN_DATA_PATH') ){ self::$path = BBN_DATA_PATH; } else{ self::$path = __DIR__.'/'; } } return self::$path.'plugins/appui-cron/appui-observer.txt'; }
[ "private", "static", "function", "get_file", "(", ")", ":", "string", "{", "if", "(", "null", "===", "self", "::", "$", "path", ")", "{", "if", "(", "\\", "defined", "(", "'BBN_DATA_PATH'", ")", ")", "{", "self", "::", "$", "path", "=", "BBN_DATA_PATH", ";", "}", "else", "{", "self", "::", "$", "path", "=", "__DIR__", ".", "'/'", ";", "}", "}", "return", "self", "::", "$", "path", ".", "'plugins/appui-cron/appui-observer.txt'", ";", "}" ]
Returns the observer txt file's full path. @return string
[ "Returns", "the", "observer", "txt", "file", "s", "full", "path", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L48-L59
21,816
nabab/bbn
src/bbn/appui/observer.php
observer._get_id
private function _get_id(string $request, $params): ?string { if ( $this->check() ){ if ( $params ){ return $this->db->select_one('bbn_observers', 'id', [ 'id_string' => $this->_get_id_string($request, $params) ]); } return $this->db->get_one(" SELECT id FROM bbn_observers WHERE `request` LIKE ? AND `params` IS NULL AND `public` = 1", $request); } return null; }
php
private function _get_id(string $request, $params): ?string { if ( $this->check() ){ if ( $params ){ return $this->db->select_one('bbn_observers', 'id', [ 'id_string' => $this->_get_id_string($request, $params) ]); } return $this->db->get_one(" SELECT id FROM bbn_observers WHERE `request` LIKE ? AND `params` IS NULL AND `public` = 1", $request); } return null; }
[ "private", "function", "_get_id", "(", "string", "$", "request", ",", "$", "params", ")", ":", "?", "string", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "if", "(", "$", "params", ")", "{", "return", "$", "this", "->", "db", "->", "select_one", "(", "'bbn_observers'", ",", "'id'", ",", "[", "'id_string'", "=>", "$", "this", "->", "_get_id_string", "(", "$", "request", ",", "$", "params", ")", "]", ")", ";", "}", "return", "$", "this", "->", "db", "->", "get_one", "(", "\"\n SELECT id\n FROM bbn_observers\n WHERE `request` LIKE ?\n AND `params` IS NULL\n AND `public` = 1\"", ",", "$", "request", ")", ";", "}", "return", "null", ";", "}" ]
Returns the ID of an observer with public = 1 and with similar request and params. @param string $request @param string $params @return null|string
[ "Returns", "the", "ID", "of", "an", "observer", "with", "public", "=", "1", "and", "with", "similar", "request", "and", "params", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L121-L138
21,817
nabab/bbn
src/bbn/appui/observer.php
observer._get_id_from_user
private function _get_id_from_user(string $request, $params): ?string { if ( $this->id_user && $this->check() ){ $sql = ' SELECT `o`.`id` FROM bbn_observers AS `o` LEFT JOIN bbn_observers AS `ro` ON `o`.`id_alias` = `ro`.`id` WHERE `o`.`id_user` = ? AND ( ( `o`.`request` LIKE ? AND `o`.`params` '.($params ? 'LIKE ?' : 'IS NULL').' ) OR ( `ro`.`request` LIKE ? AND `ro`.`params` '.($params ? 'LIKE ?' : 'IS NULL').' ) )'; $args = [hex2bin($this->id_user), $request, $request]; if ( $params ){ array_splice($args, 2, 0, $params); array_push($args, $params); } return $this->db->get_one($sql, $args); } return null; }
php
private function _get_id_from_user(string $request, $params): ?string { if ( $this->id_user && $this->check() ){ $sql = ' SELECT `o`.`id` FROM bbn_observers AS `o` LEFT JOIN bbn_observers AS `ro` ON `o`.`id_alias` = `ro`.`id` WHERE `o`.`id_user` = ? AND ( ( `o`.`request` LIKE ? AND `o`.`params` '.($params ? 'LIKE ?' : 'IS NULL').' ) OR ( `ro`.`request` LIKE ? AND `ro`.`params` '.($params ? 'LIKE ?' : 'IS NULL').' ) )'; $args = [hex2bin($this->id_user), $request, $request]; if ( $params ){ array_splice($args, 2, 0, $params); array_push($args, $params); } return $this->db->get_one($sql, $args); } return null; }
[ "private", "function", "_get_id_from_user", "(", "string", "$", "request", ",", "$", "params", ")", ":", "?", "string", "{", "if", "(", "$", "this", "->", "id_user", "&&", "$", "this", "->", "check", "(", ")", ")", "{", "$", "sql", "=", "'\n SELECT `o`.`id`\n FROM bbn_observers AS `o`\n LEFT JOIN bbn_observers AS `ro`\n ON `o`.`id_alias` = `ro`.`id`\n WHERE `o`.`id_user` = ?\n AND (\n (\n `o`.`request` LIKE ?\n AND `o`.`params` '", ".", "(", "$", "params", "?", "'LIKE ?'", ":", "'IS NULL'", ")", ".", "'\n )\n OR (\n `ro`.`request` LIKE ?\n AND `ro`.`params` '", ".", "(", "$", "params", "?", "'LIKE ?'", ":", "'IS NULL'", ")", ".", "'\n )\n )'", ";", "$", "args", "=", "[", "hex2bin", "(", "$", "this", "->", "id_user", ")", ",", "$", "request", ",", "$", "request", "]", ";", "if", "(", "$", "params", ")", "{", "array_splice", "(", "$", "args", ",", "2", ",", "0", ",", "$", "params", ")", ";", "array_push", "(", "$", "args", ",", "$", "params", ")", ";", "}", "return", "$", "this", "->", "db", "->", "get_one", "(", "$", "sql", ",", "$", "args", ")", ";", "}", "return", "null", ";", "}" ]
Returns the ID of an observer for the current user and with similar request and params. @param string $request @param string $params @return null|string
[ "Returns", "the", "ID", "of", "an", "observer", "for", "the", "current", "user", "and", "with", "similar", "request", "and", "params", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L147-L174
21,818
nabab/bbn
src/bbn/appui/observer.php
observer._update_next
private function _update_next($id): bool { $id_alias = $this->db->select_one('bbn_observers', 'id_alias', ['id' => $id]); return $this->db->query(<<<MYSQL UPDATE bbn_observers SET next = NOW() + INTERVAL frequency SECOND WHERE id = ? MYSQL , hex2bin($id_alias ?: $id)) ? true : false; }
php
private function _update_next($id): bool { $id_alias = $this->db->select_one('bbn_observers', 'id_alias', ['id' => $id]); return $this->db->query(<<<MYSQL UPDATE bbn_observers SET next = NOW() + INTERVAL frequency SECOND WHERE id = ? MYSQL , hex2bin($id_alias ?: $id)) ? true : false; }
[ "private", "function", "_update_next", "(", "$", "id", ")", ":", "bool", "{", "$", "id_alias", "=", "$", "this", "->", "db", "->", "select_one", "(", "'bbn_observers'", ",", "'id_alias'", ",", "[", "'id'", "=>", "$", "id", "]", ")", ";", "return", "$", "this", "->", "db", "->", "query", "(", "<<<MYSQL\n UPDATE bbn_observers\n SET next = NOW() + INTERVAL frequency SECOND\n WHERE id = ?\nMYSQL", ",", "hex2bin", "(", "$", "id_alias", "?", ":", "$", "id", ")", ")", "?", "true", ":", "false", ";", "}" ]
Sets the time of next execution in the observer's main row. @param $id @return bbn\db\query|int
[ "Sets", "the", "time", "of", "next", "execution", "in", "the", "observer", "s", "main", "row", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L194-L204
21,819
nabab/bbn
src/bbn/appui/observer.php
observer.check_result
public function check_result($id) { if ( $d = $this->get($id) ){ $t = new bbn\util\timer(); $t->start(); $res = $this->_exec($d['request'], $d['params']); $duration = (int)ceil($t->stop() * 1000); if ( $res !== $d['result'] ){ $this->db->update('bbn_observers', [ 'result' => $res, 'duration' => $duration ], [ 'id' => $id ]); return false; } return true; } }
php
public function check_result($id) { if ( $d = $this->get($id) ){ $t = new bbn\util\timer(); $t->start(); $res = $this->_exec($d['request'], $d['params']); $duration = (int)ceil($t->stop() * 1000); if ( $res !== $d['result'] ){ $this->db->update('bbn_observers', [ 'result' => $res, 'duration' => $duration ], [ 'id' => $id ]); return false; } return true; } }
[ "public", "function", "check_result", "(", "$", "id", ")", "{", "if", "(", "$", "d", "=", "$", "this", "->", "get", "(", "$", "id", ")", ")", "{", "$", "t", "=", "new", "bbn", "\\", "util", "\\", "timer", "(", ")", ";", "$", "t", "->", "start", "(", ")", ";", "$", "res", "=", "$", "this", "->", "_exec", "(", "$", "d", "[", "'request'", "]", ",", "$", "d", "[", "'params'", "]", ")", ";", "$", "duration", "=", "(", "int", ")", "ceil", "(", "$", "t", "->", "stop", "(", ")", "*", "1000", ")", ";", "if", "(", "$", "res", "!==", "$", "d", "[", "'result'", "]", ")", "{", "$", "this", "->", "db", "->", "update", "(", "'bbn_observers'", ",", "[", "'result'", "=>", "$", "res", ",", "'duration'", "=>", "$", "duration", "]", ",", "[", "'id'", "=>", "$", "id", "]", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}", "}" ]
Confronts the current result with the one kept in database. @param $id @return bool
[ "Confronts", "the", "current", "result", "with", "the", "one", "kept", "in", "database", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L223-L241
21,820
nabab/bbn
src/bbn/appui/observer.php
observer.add
public function add(array $cfg): ?string { if ( $this->id_user && (null !== $cfg['request']) && $this->check() ){ $t = new bbn\util\timer(); $t->start(); if ( is_string($cfg['request']) ){ $params = self::sanitize_params($cfg['params'] ?? []); $request = trim($cfg['request']); } else if ( is_array($cfg['request']) ){ $params = null; $request = $cfg['request']; } else{ return null; } $res = $this->_exec($request, $params); $duration = (int)ceil($t->stop() * 1000); if ( is_array($request) ){ $request = json_encode($request); } $id_alias = $this->_get_id($request, $params); //die(var_dump($id_alias, $this->db->last())); // If it is a public observer it will be the id_alias and the main observer if ( !$id_alias && !empty($cfg['public']) && $this->db->insert('bbn_observers', [ 'request' => $request, 'params' => $params ?: null, 'name' => $cfg['name'] ?? null, 'duration' => $duration, 'id_user' => null, 'public' => 1, 'result' => $res ]) ){ $id_alias = $this->db->last_id(); } // Getting the ID of the observer corresponding to current user if ( $id_obs = $this->_get_id_from_user($request, $params) ){ // $this->check_result($id_obs); return $id_obs; } else if ( $id_alias ){ if ( $this->db->insert('bbn_observers', [ 'id_user' => $this->id_user, 'public' => 0, 'id_alias' => $id_alias, 'next' => null, 'result' => $res ]) ){ return $this->db->last_id(); } } else{ if ( $this->db->insert('bbn_observers', [ 'request' => $request, 'params' => $params ?: null, 'name' => $cfg['name'] ?? null, 'duration' => $duration, 'id_user' => $this->id_user, 'public' => 0, 'result' => $res ]) ){ return $this->db->last_id(); } } } return null; }
php
public function add(array $cfg): ?string { if ( $this->id_user && (null !== $cfg['request']) && $this->check() ){ $t = new bbn\util\timer(); $t->start(); if ( is_string($cfg['request']) ){ $params = self::sanitize_params($cfg['params'] ?? []); $request = trim($cfg['request']); } else if ( is_array($cfg['request']) ){ $params = null; $request = $cfg['request']; } else{ return null; } $res = $this->_exec($request, $params); $duration = (int)ceil($t->stop() * 1000); if ( is_array($request) ){ $request = json_encode($request); } $id_alias = $this->_get_id($request, $params); //die(var_dump($id_alias, $this->db->last())); // If it is a public observer it will be the id_alias and the main observer if ( !$id_alias && !empty($cfg['public']) && $this->db->insert('bbn_observers', [ 'request' => $request, 'params' => $params ?: null, 'name' => $cfg['name'] ?? null, 'duration' => $duration, 'id_user' => null, 'public' => 1, 'result' => $res ]) ){ $id_alias = $this->db->last_id(); } // Getting the ID of the observer corresponding to current user if ( $id_obs = $this->_get_id_from_user($request, $params) ){ // $this->check_result($id_obs); return $id_obs; } else if ( $id_alias ){ if ( $this->db->insert('bbn_observers', [ 'id_user' => $this->id_user, 'public' => 0, 'id_alias' => $id_alias, 'next' => null, 'result' => $res ]) ){ return $this->db->last_id(); } } else{ if ( $this->db->insert('bbn_observers', [ 'request' => $request, 'params' => $params ?: null, 'name' => $cfg['name'] ?? null, 'duration' => $duration, 'id_user' => $this->id_user, 'public' => 0, 'result' => $res ]) ){ return $this->db->last_id(); } } } return null; }
[ "public", "function", "add", "(", "array", "$", "cfg", ")", ":", "?", "string", "{", "if", "(", "$", "this", "->", "id_user", "&&", "(", "null", "!==", "$", "cfg", "[", "'request'", "]", ")", "&&", "$", "this", "->", "check", "(", ")", ")", "{", "$", "t", "=", "new", "bbn", "\\", "util", "\\", "timer", "(", ")", ";", "$", "t", "->", "start", "(", ")", ";", "if", "(", "is_string", "(", "$", "cfg", "[", "'request'", "]", ")", ")", "{", "$", "params", "=", "self", "::", "sanitize_params", "(", "$", "cfg", "[", "'params'", "]", "??", "[", "]", ")", ";", "$", "request", "=", "trim", "(", "$", "cfg", "[", "'request'", "]", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "cfg", "[", "'request'", "]", ")", ")", "{", "$", "params", "=", "null", ";", "$", "request", "=", "$", "cfg", "[", "'request'", "]", ";", "}", "else", "{", "return", "null", ";", "}", "$", "res", "=", "$", "this", "->", "_exec", "(", "$", "request", ",", "$", "params", ")", ";", "$", "duration", "=", "(", "int", ")", "ceil", "(", "$", "t", "->", "stop", "(", ")", "*", "1000", ")", ";", "if", "(", "is_array", "(", "$", "request", ")", ")", "{", "$", "request", "=", "json_encode", "(", "$", "request", ")", ";", "}", "$", "id_alias", "=", "$", "this", "->", "_get_id", "(", "$", "request", ",", "$", "params", ")", ";", "//die(var_dump($id_alias, $this->db->last()));", "// If it is a public observer it will be the id_alias and the main observer", "if", "(", "!", "$", "id_alias", "&&", "!", "empty", "(", "$", "cfg", "[", "'public'", "]", ")", "&&", "$", "this", "->", "db", "->", "insert", "(", "'bbn_observers'", ",", "[", "'request'", "=>", "$", "request", ",", "'params'", "=>", "$", "params", "?", ":", "null", ",", "'name'", "=>", "$", "cfg", "[", "'name'", "]", "??", "null", ",", "'duration'", "=>", "$", "duration", ",", "'id_user'", "=>", "null", ",", "'public'", "=>", "1", ",", "'result'", "=>", "$", "res", "]", ")", ")", "{", "$", "id_alias", "=", "$", "this", "->", "db", "->", "last_id", "(", ")", ";", "}", "// Getting the ID of the observer corresponding to current user", "if", "(", "$", "id_obs", "=", "$", "this", "->", "_get_id_from_user", "(", "$", "request", ",", "$", "params", ")", ")", "{", "//", "$", "this", "->", "check_result", "(", "$", "id_obs", ")", ";", "return", "$", "id_obs", ";", "}", "else", "if", "(", "$", "id_alias", ")", "{", "if", "(", "$", "this", "->", "db", "->", "insert", "(", "'bbn_observers'", ",", "[", "'id_user'", "=>", "$", "this", "->", "id_user", ",", "'public'", "=>", "0", ",", "'id_alias'", "=>", "$", "id_alias", ",", "'next'", "=>", "null", ",", "'result'", "=>", "$", "res", "]", ")", ")", "{", "return", "$", "this", "->", "db", "->", "last_id", "(", ")", ";", "}", "}", "else", "{", "if", "(", "$", "this", "->", "db", "->", "insert", "(", "'bbn_observers'", ",", "[", "'request'", "=>", "$", "request", ",", "'params'", "=>", "$", "params", "?", ":", "null", ",", "'name'", "=>", "$", "cfg", "[", "'name'", "]", "??", "null", ",", "'duration'", "=>", "$", "duration", ",", "'id_user'", "=>", "$", "this", "->", "id_user", ",", "'public'", "=>", "0", ",", "'result'", "=>", "$", "res", "]", ")", ")", "{", "return", "$", "this", "->", "db", "->", "last_id", "(", ")", ";", "}", "}", "}", "return", "null", ";", "}" ]
Adds a new observer and returns its id or the id of an existing one. @param array $cfg @return null|string
[ "Adds", "a", "new", "observer", "and", "returns", "its", "id", "or", "the", "id", "of", "an", "existing", "one", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L249-L324
21,821
nabab/bbn
src/bbn/appui/observer.php
observer.user_delete
public function user_delete($id): int { if ( property_exists($this, 'user') && $this->check() ){ return $this->db->delete('bbn_observers', ['id' => $id, 'id_user' => $this->user]); } return 0; }
php
public function user_delete($id): int { if ( property_exists($this, 'user') && $this->check() ){ return $this->db->delete('bbn_observers', ['id' => $id, 'id_user' => $this->user]); } return 0; }
[ "public", "function", "user_delete", "(", "$", "id", ")", ":", "int", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'user'", ")", "&&", "$", "this", "->", "check", "(", ")", ")", "{", "return", "$", "this", "->", "db", "->", "delete", "(", "'bbn_observers'", ",", "[", "'id'", "=>", "$", "id", ",", "'id_user'", "=>", "$", "this", "->", "user", "]", ")", ";", "}", "return", "0", ";", "}" ]
Deletes the given observer for the current user @param string $id @return int
[ "Deletes", "the", "given", "observer", "for", "the", "current", "user" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/observer.php#L403-L409
21,822
odiaseo/pagebuilder
src/PageBuilder/View/Helper/PageBuilder.php
PageBuilder.applyFormats
protected function applyFormats($data) { if ($this->getOptions()->getOutputFormatters()) { foreach ($this->getOptions()->getOutputFormatters() as $formatter) { if ($formatter instanceof FormatterInterface) { /** @var $formatter \PageBuilder\FormatterInterface */ $data = $formatter->format($data); } elseif (is_callable($formatter)) { $data = $formatter($data, $this->serviceManager); } } } return $data; }
php
protected function applyFormats($data) { if ($this->getOptions()->getOutputFormatters()) { foreach ($this->getOptions()->getOutputFormatters() as $formatter) { if ($formatter instanceof FormatterInterface) { /** @var $formatter \PageBuilder\FormatterInterface */ $data = $formatter->format($data); } elseif (is_callable($formatter)) { $data = $formatter($data, $this->serviceManager); } } } return $data; }
[ "protected", "function", "applyFormats", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getOutputFormatters", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "getOptions", "(", ")", "->", "getOutputFormatters", "(", ")", "as", "$", "formatter", ")", "{", "if", "(", "$", "formatter", "instanceof", "FormatterInterface", ")", "{", "/** @var $formatter \\PageBuilder\\FormatterInterface */", "$", "data", "=", "$", "formatter", "->", "format", "(", "$", "data", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "formatter", ")", ")", "{", "$", "data", "=", "$", "formatter", "(", "$", "data", ",", "$", "this", "->", "serviceManager", ")", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
Apply formatter using the formatters in the order they were defined @param $data @return string
[ "Apply", "formatter", "using", "the", "formatters", "in", "the", "order", "they", "were", "defined" ]
88ef7cccf305368561307efe4ca07fac8e5774f3
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/View/Helper/PageBuilder.php#L334-L349
21,823
lokhman/silex-tools
src/Silex/Application/ToolsTrait.php
ToolsTrait.redirectToRoute
public function redirectToRoute($route, array $parameters = [], $status = 302) { return new RedirectResponse($this['url_generator']->generate($route, $parameters), $status); }
php
public function redirectToRoute($route, array $parameters = [], $status = 302) { return new RedirectResponse($this['url_generator']->generate($route, $parameters), $status); }
[ "public", "function", "redirectToRoute", "(", "$", "route", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "status", "=", "302", ")", "{", "return", "new", "RedirectResponse", "(", "$", "this", "[", "'url_generator'", "]", "->", "generate", "(", "$", "route", ",", "$", "parameters", ")", ",", "$", "status", ")", ";", "}" ]
Redirects the user to route with the given parameters. @param string $route The name of the route @param mixed $parameters An array of parameters @param int $status The status code (302 by default) @return RedirectResponse
[ "Redirects", "the", "user", "to", "route", "with", "the", "given", "parameters", "." ]
91e84099479beb4e866abc88a55ed1e457a8a9e9
https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Application/ToolsTrait.php#L54-L57
21,824
lokhman/silex-tools
src/Silex/Application/ToolsTrait.php
ToolsTrait.forward
public function forward($uri, $method, array $parameters = []) { $request = Request::create($uri, $method, $parameters); return $this->handle($request, HttpKernelInterface::SUB_REQUEST); }
php
public function forward($uri, $method, array $parameters = []) { $request = Request::create($uri, $method, $parameters); return $this->handle($request, HttpKernelInterface::SUB_REQUEST); }
[ "public", "function", "forward", "(", "$", "uri", ",", "$", "method", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "request", "=", "Request", "::", "create", "(", "$", "uri", ",", "$", "method", ",", "$", "parameters", ")", ";", "return", "$", "this", "->", "handle", "(", "$", "request", ",", "HttpKernelInterface", "::", "SUB_REQUEST", ")", ";", "}" ]
Forward the request to another controller by the URI. @param string $uri @param string $method @param array $parameters @return Symfony\Component\HttpFoundation\Response
[ "Forward", "the", "request", "to", "another", "controller", "by", "the", "URI", "." ]
91e84099479beb4e866abc88a55ed1e457a8a9e9
https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Application/ToolsTrait.php#L68-L73
21,825
lokhman/silex-tools
src/Silex/Application/ToolsTrait.php
ToolsTrait.forwardToRoute
public function forwardToRoute($route, $method, array $parameters = []) { return $this->forward($this['url_generator']->generate($route, $parameters), $method); }
php
public function forwardToRoute($route, $method, array $parameters = []) { return $this->forward($this['url_generator']->generate($route, $parameters), $method); }
[ "public", "function", "forwardToRoute", "(", "$", "route", ",", "$", "method", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "forward", "(", "$", "this", "[", "'url_generator'", "]", "->", "generate", "(", "$", "route", ",", "$", "parameters", ")", ",", "$", "method", ")", ";", "}" ]
Forward the request to another controller by the route name. @param string $route @param string $method @param array $parameters @return Symfony\Component\HttpFoundation\Response
[ "Forward", "the", "request", "to", "another", "controller", "by", "the", "route", "name", "." ]
91e84099479beb4e866abc88a55ed1e457a8a9e9
https://github.com/lokhman/silex-tools/blob/91e84099479beb4e866abc88a55ed1e457a8a9e9/src/Silex/Application/ToolsTrait.php#L84-L87
21,826
sabre-io/cs
lib/ControlSpaces.php
ControlSpaces.fixControlStructure
private function fixControlStructure(Tokens $tokens, $index) { // Ensure a single whitespace if (!$tokens[$index - 1]->isWhitespace() || $tokens[$index - 1]->isWhitespace($this->singleLineWhitespaceOptions)) { $tokens->ensureWhitespaceAtIndex($index - 1, 1, ' '); } }
php
private function fixControlStructure(Tokens $tokens, $index) { // Ensure a single whitespace if (!$tokens[$index - 1]->isWhitespace() || $tokens[$index - 1]->isWhitespace($this->singleLineWhitespaceOptions)) { $tokens->ensureWhitespaceAtIndex($index - 1, 1, ' '); } }
[ "private", "function", "fixControlStructure", "(", "Tokens", "$", "tokens", ",", "$", "index", ")", "{", "// Ensure a single whitespace", "if", "(", "!", "$", "tokens", "[", "$", "index", "-", "1", "]", "->", "isWhitespace", "(", ")", "||", "$", "tokens", "[", "$", "index", "-", "1", "]", "->", "isWhitespace", "(", "$", "this", "->", "singleLineWhitespaceOptions", ")", ")", "{", "$", "tokens", "->", "ensureWhitespaceAtIndex", "(", "$", "index", "-", "1", ",", "1", ",", "' '", ")", ";", "}", "}" ]
Fixes whitespaces around braces of a control structure. @param Tokens $tokens tokens to handle @param int $index index of token
[ "Fixes", "whitespaces", "around", "braces", "of", "a", "control", "structure", "." ]
a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/ControlSpaces.php#L88-L95
21,827
sabre-io/cs
lib/ControlSpaces.php
ControlSpaces.getControlStructureTokens
private function getControlStructureTokens() { static $tokens = null; if (null === $tokens) { $tokens = [ T_IF, T_ELSEIF, T_FOR, T_FOREACH, T_WHILE, T_DO, T_CATCH, T_SWITCH, T_DECLARE, ]; } return $tokens; }
php
private function getControlStructureTokens() { static $tokens = null; if (null === $tokens) { $tokens = [ T_IF, T_ELSEIF, T_FOR, T_FOREACH, T_WHILE, T_DO, T_CATCH, T_SWITCH, T_DECLARE, ]; } return $tokens; }
[ "private", "function", "getControlStructureTokens", "(", ")", "{", "static", "$", "tokens", "=", "null", ";", "if", "(", "null", "===", "$", "tokens", ")", "{", "$", "tokens", "=", "[", "T_IF", ",", "T_ELSEIF", ",", "T_FOR", ",", "T_FOREACH", ",", "T_WHILE", ",", "T_DO", ",", "T_CATCH", ",", "T_SWITCH", ",", "T_DECLARE", ",", "]", ";", "}", "return", "$", "tokens", ";", "}" ]
Gets the name of control structure tokens. @staticvar string[] $tokens Token names. @return string[] Token names.
[ "Gets", "the", "name", "of", "control", "structure", "tokens", "." ]
a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86
https://github.com/sabre-io/cs/blob/a4c57e213bf3f5e7d6b29a2f70d1ca4b0dce6d86/lib/ControlSpaces.php#L104-L123
21,828
AOEpeople/Aoe_Layout
app/code/local/Aoe/Layout/Block/Widget/Tabs.php
Aoe_Layout_Block_Widget_Tabs.addTab
public function addTab($tabId, $tab) { parent::addTab($tabId, $tab); if ($this->_tabs[$tabId] instanceof Mage_Core_Block_Abstract && $this->_tabs[$tabId]->getParentBlock() === null) { $this->append($this->_tabs[$tabId]); } return $this; }
php
public function addTab($tabId, $tab) { parent::addTab($tabId, $tab); if ($this->_tabs[$tabId] instanceof Mage_Core_Block_Abstract && $this->_tabs[$tabId]->getParentBlock() === null) { $this->append($this->_tabs[$tabId]); } return $this; }
[ "public", "function", "addTab", "(", "$", "tabId", ",", "$", "tab", ")", "{", "parent", "::", "addTab", "(", "$", "tabId", ",", "$", "tab", ")", ";", "if", "(", "$", "this", "->", "_tabs", "[", "$", "tabId", "]", "instanceof", "Mage_Core_Block_Abstract", "&&", "$", "this", "->", "_tabs", "[", "$", "tabId", "]", "->", "getParentBlock", "(", ")", "===", "null", ")", "{", "$", "this", "->", "append", "(", "$", "this", "->", "_tabs", "[", "$", "tabId", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add new tab @param string $tabId @param array|Varien_Object $tab @return Mage_Adminhtml_Block_Widget_Tabs
[ "Add", "new", "tab" ]
d88ba3406cf12dbaf09548477133c3cb27d155ed
https://github.com/AOEpeople/Aoe_Layout/blob/d88ba3406cf12dbaf09548477133c3cb27d155ed/app/code/local/Aoe/Layout/Block/Widget/Tabs.php#L15-L24
21,829
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.buildSourceTableMigration
public function buildSourceTableMigration($name) { $path = $this->getMigrationPath($name); $migration = $this->getTableMigrationName($name); $contents = view('_hierarchy::migrations.table', [ 'table' => source_table_name($name), 'migration' => $migration ])->render(); $this->write($path, $contents); return $this->getMigrationClassPath($migration); }
php
public function buildSourceTableMigration($name) { $path = $this->getMigrationPath($name); $migration = $this->getTableMigrationName($name); $contents = view('_hierarchy::migrations.table', [ 'table' => source_table_name($name), 'migration' => $migration ])->render(); $this->write($path, $contents); return $this->getMigrationClassPath($migration); }
[ "public", "function", "buildSourceTableMigration", "(", "$", "name", ")", "{", "$", "path", "=", "$", "this", "->", "getMigrationPath", "(", "$", "name", ")", ";", "$", "migration", "=", "$", "this", "->", "getTableMigrationName", "(", "$", "name", ")", ";", "$", "contents", "=", "view", "(", "'_hierarchy::migrations.table'", ",", "[", "'table'", "=>", "source_table_name", "(", "$", "name", ")", ",", "'migration'", "=>", "$", "migration", "]", ")", "->", "render", "(", ")", ";", "$", "this", "->", "write", "(", "$", "path", ",", "$", "contents", ")", ";", "return", "$", "this", "->", "getMigrationClassPath", "(", "$", "migration", ")", ";", "}" ]
Builds a source table migration @param string $name @return string
[ "Builds", "a", "source", "table", "migration" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L81-L94
21,830
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.destroySourceTableMigration
public function destroySourceTableMigration($name, array $fields) { $path = $this->getMigrationPath($name); $this->delete($path); foreach ($fields as $field) { $this->destroyFieldMigrationForTable($field, $name); } }
php
public function destroySourceTableMigration($name, array $fields) { $path = $this->getMigrationPath($name); $this->delete($path); foreach ($fields as $field) { $this->destroyFieldMigrationForTable($field, $name); } }
[ "public", "function", "destroySourceTableMigration", "(", "$", "name", ",", "array", "$", "fields", ")", "{", "$", "path", "=", "$", "this", "->", "getMigrationPath", "(", "$", "name", ")", ";", "$", "this", "->", "delete", "(", "$", "path", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "this", "->", "destroyFieldMigrationForTable", "(", "$", "field", ",", "$", "name", ")", ";", "}", "}" ]
Destroy a source table migration @param string $name @param array $fields
[ "Destroy", "a", "source", "table", "migration" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L102-L112
21,831
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.buildFieldMigrationForTable
public function buildFieldMigrationForTable($name, $type, $indexed, $tableName) { $path = $this->getMigrationPath($tableName, $name); $migration = $this->getTableFieldMigrationName($name, $tableName); $contents = view('_hierarchy::migrations.field', [ 'field' => $name, 'table' => source_table_name($tableName), 'migration' => $migration, 'type' => $this->getColumnType($type), 'indexed' => $indexed ])->render(); $this->write($path, $contents); return $this->getMigrationClassPath($migration); }
php
public function buildFieldMigrationForTable($name, $type, $indexed, $tableName) { $path = $this->getMigrationPath($tableName, $name); $migration = $this->getTableFieldMigrationName($name, $tableName); $contents = view('_hierarchy::migrations.field', [ 'field' => $name, 'table' => source_table_name($tableName), 'migration' => $migration, 'type' => $this->getColumnType($type), 'indexed' => $indexed ])->render(); $this->write($path, $contents); return $this->getMigrationClassPath($migration); }
[ "public", "function", "buildFieldMigrationForTable", "(", "$", "name", ",", "$", "type", ",", "$", "indexed", ",", "$", "tableName", ")", "{", "$", "path", "=", "$", "this", "->", "getMigrationPath", "(", "$", "tableName", ",", "$", "name", ")", ";", "$", "migration", "=", "$", "this", "->", "getTableFieldMigrationName", "(", "$", "name", ",", "$", "tableName", ")", ";", "$", "contents", "=", "view", "(", "'_hierarchy::migrations.field'", ",", "[", "'field'", "=>", "$", "name", ",", "'table'", "=>", "source_table_name", "(", "$", "tableName", ")", ",", "'migration'", "=>", "$", "migration", ",", "'type'", "=>", "$", "this", "->", "getColumnType", "(", "$", "type", ")", ",", "'indexed'", "=>", "$", "indexed", "]", ")", "->", "render", "(", ")", ";", "$", "this", "->", "write", "(", "$", "path", ",", "$", "contents", ")", ";", "return", "$", "this", "->", "getMigrationClassPath", "(", "$", "migration", ")", ";", "}" ]
Builds a field migration for a table @param string $name @param string $type @param bool $indexed @param string $tableName @return string
[ "Builds", "a", "field", "migration", "for", "a", "table" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L123-L139
21,832
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.destroyFieldMigrationForTable
public function destroyFieldMigrationForTable($name, $tableName) { $path = $this->getMigrationPath($tableName, $name); $this->delete($path); }
php
public function destroyFieldMigrationForTable($name, $tableName) { $path = $this->getMigrationPath($tableName, $name); $this->delete($path); }
[ "public", "function", "destroyFieldMigrationForTable", "(", "$", "name", ",", "$", "tableName", ")", "{", "$", "path", "=", "$", "this", "->", "getMigrationPath", "(", "$", "tableName", ",", "$", "name", ")", ";", "$", "this", "->", "delete", "(", "$", "path", ")", ";", "}" ]
Destroys a field migration for a table @param string $name @param string $tableName
[ "Destroys", "a", "field", "migration", "for", "a", "table" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L147-L152
21,833
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.getTableFieldMigrationName
public function getTableFieldMigrationName($name, $tableName) { return sprintf( MigrationBuilder::PATTERN_FIELD, ucfirst($name), ucfirst($tableName) ); }
php
public function getTableFieldMigrationName($name, $tableName) { return sprintf( MigrationBuilder::PATTERN_FIELD, ucfirst($name), ucfirst($tableName) ); }
[ "public", "function", "getTableFieldMigrationName", "(", "$", "name", ",", "$", "tableName", ")", "{", "return", "sprintf", "(", "MigrationBuilder", "::", "PATTERN_FIELD", ",", "ucfirst", "(", "$", "name", ")", ",", "ucfirst", "(", "$", "tableName", ")", ")", ";", "}" ]
Returns the migration name for a field in table @param string $name @param string $tableName @return string
[ "Returns", "the", "migration", "name", "for", "a", "field", "in", "table" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L175-L182
21,834
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.getMigrationPath
public function getMigrationPath($table, $field = null) { $name = is_null($field) ? $this->getTableMigrationName($table) : $this->getTableFieldMigrationName($field, $table); return sprintf( $this->getBasePath() . '/%s.php', $name); }
php
public function getMigrationPath($table, $field = null) { $name = is_null($field) ? $this->getTableMigrationName($table) : $this->getTableFieldMigrationName($field, $table); return sprintf( $this->getBasePath() . '/%s.php', $name); }
[ "public", "function", "getMigrationPath", "(", "$", "table", ",", "$", "field", "=", "null", ")", "{", "$", "name", "=", "is_null", "(", "$", "field", ")", "?", "$", "this", "->", "getTableMigrationName", "(", "$", "table", ")", ":", "$", "this", "->", "getTableFieldMigrationName", "(", "$", "field", ",", "$", "table", ")", ";", "return", "sprintf", "(", "$", "this", "->", "getBasePath", "(", ")", ".", "'/%s.php'", ",", "$", "name", ")", ";", "}" ]
Returns the path for the migration @param string $table @param string|null $field @return string
[ "Returns", "the", "path", "for", "the", "migration" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L201-L210
21,835
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.getMigrationClassPathByKey
public function getMigrationClassPathByKey($table, $field = null) { $name = is_null($field) ? $this->getTableMigrationName($table) : $this->getTableFieldMigrationName($field, $table); return $this->getMigrationClassPath($name); }
php
public function getMigrationClassPathByKey($table, $field = null) { $name = is_null($field) ? $this->getTableMigrationName($table) : $this->getTableFieldMigrationName($field, $table); return $this->getMigrationClassPath($name); }
[ "public", "function", "getMigrationClassPathByKey", "(", "$", "table", ",", "$", "field", "=", "null", ")", "{", "$", "name", "=", "is_null", "(", "$", "field", ")", "?", "$", "this", "->", "getTableMigrationName", "(", "$", "table", ")", ":", "$", "this", "->", "getTableFieldMigrationName", "(", "$", "field", ",", "$", "table", ")", ";", "return", "$", "this", "->", "getMigrationClassPath", "(", "$", "name", ")", ";", "}" ]
Returns the migration class path by key @param string $table @param string|null $field @return string
[ "Returns", "the", "migration", "class", "path", "by", "key" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L230-L237
21,836
NuclearCMS/Hierarchy
src/Builders/MigrationBuilder.php
MigrationBuilder.getColumnType
public function getColumnType($type) { if (array_key_exists($type, $this->typeMap)) { return $this->typeMap[$type]; } return $this->defaultType; }
php
public function getColumnType($type) { if (array_key_exists($type, $this->typeMap)) { return $this->typeMap[$type]; } return $this->defaultType; }
[ "public", "function", "getColumnType", "(", "$", "type", ")", "{", "if", "(", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "typeMap", ")", ")", "{", "return", "$", "this", "->", "typeMap", "[", "$", "type", "]", ";", "}", "return", "$", "this", "->", "defaultType", ";", "}" ]
Returns the column type for key @param string $type @return string
[ "Returns", "the", "column", "type", "for", "key" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/MigrationBuilder.php#L245-L253
21,837
xiewulong/yii2-fileupload
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php
ClassLoader.addPrefix
public function addPrefix($prefix, $paths) { if (!$prefix) { foreach ((array) $paths as $path) { $this->fallbackDirs[] = $path; } return; } if (isset($this->prefixes[$prefix])) { $this->prefixes[$prefix] = array_merge( $this->prefixes[$prefix], (array) $paths ); } else { $this->prefixes[$prefix] = (array) $paths; } }
php
public function addPrefix($prefix, $paths) { if (!$prefix) { foreach ((array) $paths as $path) { $this->fallbackDirs[] = $path; } return; } if (isset($this->prefixes[$prefix])) { $this->prefixes[$prefix] = array_merge( $this->prefixes[$prefix], (array) $paths ); } else { $this->prefixes[$prefix] = (array) $paths; } }
[ "public", "function", "addPrefix", "(", "$", "prefix", ",", "$", "paths", ")", "{", "if", "(", "!", "$", "prefix", ")", "{", "foreach", "(", "(", "array", ")", "$", "paths", "as", "$", "path", ")", "{", "$", "this", "->", "fallbackDirs", "[", "]", "=", "$", "path", ";", "}", "return", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "prefixes", "[", "$", "prefix", "]", ")", ")", "{", "$", "this", "->", "prefixes", "[", "$", "prefix", "]", "=", "array_merge", "(", "$", "this", "->", "prefixes", "[", "$", "prefix", "]", ",", "(", "array", ")", "$", "paths", ")", ";", "}", "else", "{", "$", "this", "->", "prefixes", "[", "$", "prefix", "]", "=", "(", "array", ")", "$", "paths", ";", "}", "}" ]
Registers a set of classes @param string $prefix The classes prefix @param array|string $paths The location(s) of the classes
[ "Registers", "a", "set", "of", "classes" ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php#L84-L101
21,838
mothership-ec/composer
src/Composer/Repository/RepositoryManager.php
RepositoryManager.findPackages
public function findPackages($name, $version) { $packages = array(); foreach ($this->repositories as $repository) { $packages = array_merge($packages, $repository->findPackages($name, $version)); } return $packages; }
php
public function findPackages($name, $version) { $packages = array(); foreach ($this->repositories as $repository) { $packages = array_merge($packages, $repository->findPackages($name, $version)); } return $packages; }
[ "public", "function", "findPackages", "(", "$", "name", ",", "$", "version", ")", "{", "$", "packages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "repositories", "as", "$", "repository", ")", "{", "$", "packages", "=", "array_merge", "(", "$", "packages", ",", "$", "repository", "->", "findPackages", "(", "$", "name", ",", "$", "version", ")", ")", ";", "}", "return", "$", "packages", ";", "}" ]
Searches for all packages matching a name and optionally a version in managed repositories. @param string $name package name @param string $version package version @return array
[ "Searches", "for", "all", "packages", "matching", "a", "name", "and", "optionally", "a", "version", "in", "managed", "repositories", "." ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/RepositoryManager.php#L67-L76
21,839
mothership-ec/composer
src/Composer/Repository/RepositoryManager.php
RepositoryManager.createRepository
public function createRepository($type, $config) { if (!isset($this->repositoryClasses[$type])) { throw new \InvalidArgumentException('Repository type is not registered: '.$type); } $class = $this->repositoryClasses[$type]; return new $class($config, $this->io, $this->config, $this->eventDispatcher); }
php
public function createRepository($type, $config) { if (!isset($this->repositoryClasses[$type])) { throw new \InvalidArgumentException('Repository type is not registered: '.$type); } $class = $this->repositoryClasses[$type]; return new $class($config, $this->io, $this->config, $this->eventDispatcher); }
[ "public", "function", "createRepository", "(", "$", "type", ",", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "repositoryClasses", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Repository type is not registered: '", ".", "$", "type", ")", ";", "}", "$", "class", "=", "$", "this", "->", "repositoryClasses", "[", "$", "type", "]", ";", "return", "new", "$", "class", "(", "$", "config", ",", "$", "this", "->", "io", ",", "$", "this", "->", "config", ",", "$", "this", "->", "eventDispatcher", ")", ";", "}" ]
Returns a new repository for a specific installation type. @param string $type repository type @param array $config repository configuration @return RepositoryInterface @throws \InvalidArgumentException if repository for provided type is not registered
[ "Returns", "a", "new", "repository", "for", "a", "specific", "installation", "type", "." ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/RepositoryManager.php#L96-L105
21,840
yuncms/yii2-authentication
backend/controllers/AuthenticationController.php
AuthenticationController.actionIndex
public function actionIndex() { $searchModel = Yii::createObject(AuthenticationSearch::className()); $dataProvider = $searchModel->search(Yii::$app->request->get()); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
php
public function actionIndex() { $searchModel = Yii::createObject(AuthenticationSearch::className()); $dataProvider = $searchModel->search(Yii::$app->request->get()); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "Yii", "::", "createObject", "(", "AuthenticationSearch", "::", "className", "(", ")", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", "request", "->", "get", "(", ")", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
Lists all Authentication models. @return mixed
[ "Lists", "all", "Authentication", "models", "." ]
02b70f7d2587480edb6dcc18ce256db662f1ed0d
https://github.com/yuncms/yii2-authentication/blob/02b70f7d2587480edb6dcc18ce256db662f1ed0d/backend/controllers/AuthenticationController.php#L40-L49
21,841
inhere/php-librarys
src/DI/CallableResolver.php
CallableResolver.resolve
public function resolve($toResolve) { if (\is_callable($toResolve)) { return $toResolve; } if (!\is_string($toResolve)) { $this->assertCallable($toResolve); } // check for slim callable as "class:method" if (preg_match(self::CALLABLE_PATTERN, $toResolve, $matches)) { $resolved = $this->resolveCallable($matches[1], $matches[2]); $this->assertCallable($resolved); return $resolved; } $resolved = $this->resolveCallable($toResolve); $this->assertCallable($resolved); return $resolved; }
php
public function resolve($toResolve) { if (\is_callable($toResolve)) { return $toResolve; } if (!\is_string($toResolve)) { $this->assertCallable($toResolve); } // check for slim callable as "class:method" if (preg_match(self::CALLABLE_PATTERN, $toResolve, $matches)) { $resolved = $this->resolveCallable($matches[1], $matches[2]); $this->assertCallable($resolved); return $resolved; } $resolved = $this->resolveCallable($toResolve); $this->assertCallable($resolved); return $resolved; }
[ "public", "function", "resolve", "(", "$", "toResolve", ")", "{", "if", "(", "\\", "is_callable", "(", "$", "toResolve", ")", ")", "{", "return", "$", "toResolve", ";", "}", "if", "(", "!", "\\", "is_string", "(", "$", "toResolve", ")", ")", "{", "$", "this", "->", "assertCallable", "(", "$", "toResolve", ")", ";", "}", "// check for slim callable as \"class:method\"", "if", "(", "preg_match", "(", "self", "::", "CALLABLE_PATTERN", ",", "$", "toResolve", ",", "$", "matches", ")", ")", "{", "$", "resolved", "=", "$", "this", "->", "resolveCallable", "(", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "2", "]", ")", ";", "$", "this", "->", "assertCallable", "(", "$", "resolved", ")", ";", "return", "$", "resolved", ";", "}", "$", "resolved", "=", "$", "this", "->", "resolveCallable", "(", "$", "toResolve", ")", ";", "$", "this", "->", "assertCallable", "(", "$", "resolved", ")", ";", "return", "$", "resolved", ";", "}" ]
Resolve toResolve into a closure that that the router can dispatch. If toResolve is of the format 'class:method', then try to extract 'class' from the container otherwise instantiate it and then dispatch 'method'. @param mixed $toResolve @return callable @throws RuntimeException if the callable does not exist @throws RuntimeException if the callable is not resolvable
[ "Resolve", "toResolve", "into", "a", "closure", "that", "that", "the", "router", "can", "dispatch", "." ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/DI/CallableResolver.php#L50-L72
21,842
GrupaZero/api
src/Gzero/Api/Controller/ApiController.php
ApiController.respondTransformer
protected function respondTransformer($data, $code, TransformerAbstract $transformer, array $headers = []) { if ($data === null) { // If we have empty result return $this->respond( [ 'data' => [] ], $code, $headers ); } if ($data instanceof LengthAwarePaginator) { // If we have paginated collection $resource = new Collection($data->items(), $transformer); return $this->respond( [ 'meta' => [ 'total' => $data->total(), 'perPage' => $data->perPage(), 'currentPage' => $data->currentPage(), 'lastPage' => $data->lastPage(), 'link' => \URL::current() ], 'params' => $this->processor->getProcessedFields(), 'data' => $this->getSerializer()->createData($resource)->toArray() ], $code, $headers ); } elseif ($data instanceof LaravelCollection) { // Collection without pagination $resource = new Collection($data, $transformer); return $this->respond( [ 'data' => $this->getSerializer()->createData($resource)->toArray() ], $code, $headers ); } else { // Single entity $resource = new Item($data, $transformer); return $this->respond( $this->getSerializer()->createData($resource)->toArray(), $code, $headers ); } }
php
protected function respondTransformer($data, $code, TransformerAbstract $transformer, array $headers = []) { if ($data === null) { // If we have empty result return $this->respond( [ 'data' => [] ], $code, $headers ); } if ($data instanceof LengthAwarePaginator) { // If we have paginated collection $resource = new Collection($data->items(), $transformer); return $this->respond( [ 'meta' => [ 'total' => $data->total(), 'perPage' => $data->perPage(), 'currentPage' => $data->currentPage(), 'lastPage' => $data->lastPage(), 'link' => \URL::current() ], 'params' => $this->processor->getProcessedFields(), 'data' => $this->getSerializer()->createData($resource)->toArray() ], $code, $headers ); } elseif ($data instanceof LaravelCollection) { // Collection without pagination $resource = new Collection($data, $transformer); return $this->respond( [ 'data' => $this->getSerializer()->createData($resource)->toArray() ], $code, $headers ); } else { // Single entity $resource = new Item($data, $transformer); return $this->respond( $this->getSerializer()->createData($resource)->toArray(), $code, $headers ); } }
[ "protected", "function", "respondTransformer", "(", "$", "data", ",", "$", "code", ",", "TransformerAbstract", "$", "transformer", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "$", "data", "===", "null", ")", "{", "// If we have empty result", "return", "$", "this", "->", "respond", "(", "[", "'data'", "=>", "[", "]", "]", ",", "$", "code", ",", "$", "headers", ")", ";", "}", "if", "(", "$", "data", "instanceof", "LengthAwarePaginator", ")", "{", "// If we have paginated collection", "$", "resource", "=", "new", "Collection", "(", "$", "data", "->", "items", "(", ")", ",", "$", "transformer", ")", ";", "return", "$", "this", "->", "respond", "(", "[", "'meta'", "=>", "[", "'total'", "=>", "$", "data", "->", "total", "(", ")", ",", "'perPage'", "=>", "$", "data", "->", "perPage", "(", ")", ",", "'currentPage'", "=>", "$", "data", "->", "currentPage", "(", ")", ",", "'lastPage'", "=>", "$", "data", "->", "lastPage", "(", ")", ",", "'link'", "=>", "\\", "URL", "::", "current", "(", ")", "]", ",", "'params'", "=>", "$", "this", "->", "processor", "->", "getProcessedFields", "(", ")", ",", "'data'", "=>", "$", "this", "->", "getSerializer", "(", ")", "->", "createData", "(", "$", "resource", ")", "->", "toArray", "(", ")", "]", ",", "$", "code", ",", "$", "headers", ")", ";", "}", "elseif", "(", "$", "data", "instanceof", "LaravelCollection", ")", "{", "// Collection without pagination", "$", "resource", "=", "new", "Collection", "(", "$", "data", ",", "$", "transformer", ")", ";", "return", "$", "this", "->", "respond", "(", "[", "'data'", "=>", "$", "this", "->", "getSerializer", "(", ")", "->", "createData", "(", "$", "resource", ")", "->", "toArray", "(", ")", "]", ",", "$", "code", ",", "$", "headers", ")", ";", "}", "else", "{", "// Single entity", "$", "resource", "=", "new", "Item", "(", "$", "data", ",", "$", "transformer", ")", ";", "return", "$", "this", "->", "respond", "(", "$", "this", "->", "getSerializer", "(", ")", "->", "createData", "(", "$", "resource", ")", "->", "toArray", "(", ")", ",", "$", "code", ",", "$", "headers", ")", ";", "}", "}" ]
Return transformed response in json format @param mixed $data Response data @param int $code Response code @param TransformerAbstract $transformer Transformer class @param array $headers HTTP headers @return \Illuminate\Http\JsonResponse
[ "Return", "transformed", "response", "in", "json", "format" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/ApiController.php#L69-L115
21,843
GrupaZero/api
src/Gzero/Api/Controller/ApiController.php
ApiController.respondWithSuccess
protected function respondWithSuccess($data, TransformerAbstract $transformer = null, array $headers = []) { if ($transformer) { return $this->respondTransformer($data, SymfonyResponse::HTTP_OK, $transformer, $headers); } return $this->respondWithSimpleSuccess($data); }
php
protected function respondWithSuccess($data, TransformerAbstract $transformer = null, array $headers = []) { if ($transformer) { return $this->respondTransformer($data, SymfonyResponse::HTTP_OK, $transformer, $headers); } return $this->respondWithSimpleSuccess($data); }
[ "protected", "function", "respondWithSuccess", "(", "$", "data", ",", "TransformerAbstract", "$", "transformer", "=", "null", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "$", "transformer", ")", "{", "return", "$", "this", "->", "respondTransformer", "(", "$", "data", ",", "SymfonyResponse", "::", "HTTP_OK", ",", "$", "transformer", ",", "$", "headers", ")", ";", "}", "return", "$", "this", "->", "respondWithSimpleSuccess", "(", "$", "data", ")", ";", "}" ]
Return success response in json format @param mixed $data Response data @param TransformerAbstract $transformer Transformer class @param array $headers HTTP Header @return mixed
[ "Return", "success", "response", "in", "json", "format" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/ApiController.php#L126-L132
21,844
GrupaZero/api
src/Gzero/Api/Controller/ApiController.php
ApiController.respondWithError
protected function respondWithError( $message = 'Bad Request', $code = SymfonyResponse::HTTP_BAD_REQUEST, array $headers = [] ) { return abort($code, $message, $headers); }
php
protected function respondWithError( $message = 'Bad Request', $code = SymfonyResponse::HTTP_BAD_REQUEST, array $headers = [] ) { return abort($code, $message, $headers); }
[ "protected", "function", "respondWithError", "(", "$", "message", "=", "'Bad Request'", ",", "$", "code", "=", "SymfonyResponse", "::", "HTTP_BAD_REQUEST", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "return", "abort", "(", "$", "code", ",", "$", "message", ",", "$", "headers", ")", ";", "}" ]
Return server error response in json format @param string $message Custom error message @param int $code Error code @param array $headers HTTP headers @return mixed
[ "Return", "server", "error", "response", "in", "json", "format" ]
fc544bb6057274e9d5e7b617346c3f854ea5effd
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/ApiController.php#L156-L162
21,845
kenphp/ken
src/Http/BaseMiddleware.php
BaseMiddleware.next
final protected function next(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { if ($this->_next) { return $this->_next->process($request, $handler); } return $handler->handle($request); }
php
final protected function next(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { if ($this->_next) { return $this->_next->process($request, $handler); } return $handler->handle($request); }
[ "final", "protected", "function", "next", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "if", "(", "$", "this", "->", "_next", ")", "{", "return", "$", "this", "->", "_next", "->", "process", "(", "$", "request", ",", "$", "handler", ")", ";", "}", "return", "$", "handler", "->", "handle", "(", "$", "request", ")", ";", "}" ]
Pass request to the next middleware. If there are no next middleware, it will pass the request to the handler @param ServerRequestInterface $request @param RequestHandlerInterface $handler @return ResponseInterface
[ "Pass", "request", "to", "the", "next", "middleware", ".", "If", "there", "are", "no", "next", "middleware", "it", "will", "pass", "the", "request", "to", "the", "handler" ]
c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb
https://github.com/kenphp/ken/blob/c454a86f0ab55c52c88e9bff5bc6fb4e7bd9e0eb/src/Http/BaseMiddleware.php#L44-L49
21,846
josegonzalez/cakephp-sanction
View/Helper/ClearanceHelper.php
ClearanceHelper.parse
public function parse($currentRoute, $permit) { $route = $permit['route']; $count = count($route); if ($count == 0) { return false; } foreach ($route as $key => $value) { if (isset($currentRoute[$key])) { $values = (is_array($value)) ? $value : array($value); foreach ($values as $k => $v) { if ($currentRoute[$key] == $v) { $count--; } } } } return $count == 0; }
php
public function parse($currentRoute, $permit) { $route = $permit['route']; $count = count($route); if ($count == 0) { return false; } foreach ($route as $key => $value) { if (isset($currentRoute[$key])) { $values = (is_array($value)) ? $value : array($value); foreach ($values as $k => $v) { if ($currentRoute[$key] == $v) { $count--; } } } } return $count == 0; }
[ "public", "function", "parse", "(", "$", "currentRoute", ",", "$", "permit", ")", "{", "$", "route", "=", "$", "permit", "[", "'route'", "]", ";", "$", "count", "=", "count", "(", "$", "route", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "route", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "currentRoute", "[", "$", "key", "]", ")", ")", "{", "$", "values", "=", "(", "is_array", "(", "$", "value", ")", ")", "?", "$", "value", ":", "array", "(", "$", "value", ")", ";", "foreach", "(", "$", "values", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "currentRoute", "[", "$", "key", "]", "==", "$", "v", ")", "{", "$", "count", "--", ";", "}", "}", "}", "}", "return", "$", "count", "==", "0", ";", "}" ]
Parses the passed route against a rule @param string $currentRoute route being testing @param string $permit Permit variable that contains a route being tested against @return void @author Jose Diaz-Gonzalez
[ "Parses", "the", "passed", "route", "against", "a", "rule" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/View/Helper/ClearanceHelper.php#L128-L147
21,847
josegonzalez/cakephp-sanction
View/Helper/ClearanceHelper.php
ClearanceHelper.execute
public function execute($route, $title, $url = null, $options = array(), $confirmMessage = false) { if (empty($route['rules'])) { return $this->Html->link($title, $url, $options, $confirmMessage); } if (isset($route['rules']['deny'])) { return ($route['rules']['deny'] == true) ? null : $this->Html->link($title, $url, $options, $confirmMessage); } if (!isset($route['rules']['auth'])) { return $this->Html->link($title, $url, $options, $confirmMessage); } if (is_bool($route['rules']['auth'])) { $isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}"); if ($route['rules']['auth'] == true && !$isAuthed) { return; } if ($route['rules']['auth'] == false && $isAuthed) { return; } return $this->Html->link($title, $url, $options, $confirmMessage); } $count = count($route['rules']['auth']); if ($count == 0) { return $this->Html->link($title, $url, $options, $confirmMessage); } if (($user = $this->Session->read("{$this->settings['path']}")) == false) { return; } foreach ($route['rules']['auth'] as $field => $value) { if (strpos($field, '.') !== false) { $field = '/' . str_replace('.', '/', $field); } if ($field[0] == "/") { $values = (array)Set::extract($field, $user); foreach ($value as $condition) { if (in_array($condition, $values)) { $count--; } } } else { if ($user[$field] == $value) { $count--; } } } return ($count != 0) ? null : $this->Html->link($title, $url, $options, $confirmMessage); }
php
public function execute($route, $title, $url = null, $options = array(), $confirmMessage = false) { if (empty($route['rules'])) { return $this->Html->link($title, $url, $options, $confirmMessage); } if (isset($route['rules']['deny'])) { return ($route['rules']['deny'] == true) ? null : $this->Html->link($title, $url, $options, $confirmMessage); } if (!isset($route['rules']['auth'])) { return $this->Html->link($title, $url, $options, $confirmMessage); } if (is_bool($route['rules']['auth'])) { $isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}"); if ($route['rules']['auth'] == true && !$isAuthed) { return; } if ($route['rules']['auth'] == false && $isAuthed) { return; } return $this->Html->link($title, $url, $options, $confirmMessage); } $count = count($route['rules']['auth']); if ($count == 0) { return $this->Html->link($title, $url, $options, $confirmMessage); } if (($user = $this->Session->read("{$this->settings['path']}")) == false) { return; } foreach ($route['rules']['auth'] as $field => $value) { if (strpos($field, '.') !== false) { $field = '/' . str_replace('.', '/', $field); } if ($field[0] == "/") { $values = (array)Set::extract($field, $user); foreach ($value as $condition) { if (in_array($condition, $values)) { $count--; } } } else { if ($user[$field] == $value) { $count--; } } } return ($count != 0) ? null : $this->Html->link($title, $url, $options, $confirmMessage); }
[ "public", "function", "execute", "(", "$", "route", ",", "$", "title", ",", "$", "url", "=", "null", ",", "$", "options", "=", "array", "(", ")", ",", "$", "confirmMessage", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "route", "[", "'rules'", "]", ")", ")", "{", "return", "$", "this", "->", "Html", "->", "link", "(", "$", "title", ",", "$", "url", ",", "$", "options", ",", "$", "confirmMessage", ")", ";", "}", "if", "(", "isset", "(", "$", "route", "[", "'rules'", "]", "[", "'deny'", "]", ")", ")", "{", "return", "(", "$", "route", "[", "'rules'", "]", "[", "'deny'", "]", "==", "true", ")", "?", "null", ":", "$", "this", "->", "Html", "->", "link", "(", "$", "title", ",", "$", "url", ",", "$", "options", ",", "$", "confirmMessage", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ")", "{", "return", "$", "this", "->", "Html", "->", "link", "(", "$", "title", ",", "$", "url", ",", "$", "options", ",", "$", "confirmMessage", ")", ";", "}", "if", "(", "is_bool", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ")", "{", "$", "isAuthed", "=", "$", "this", "->", "Session", "->", "read", "(", "\"{$this->settings['path']}.{$this->settings['check']}\"", ")", ";", "if", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", "==", "true", "&&", "!", "$", "isAuthed", ")", "{", "return", ";", "}", "if", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", "==", "false", "&&", "$", "isAuthed", ")", "{", "return", ";", "}", "return", "$", "this", "->", "Html", "->", "link", "(", "$", "title", ",", "$", "url", ",", "$", "options", ",", "$", "confirmMessage", ")", ";", "}", "$", "count", "=", "count", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "return", "$", "this", "->", "Html", "->", "link", "(", "$", "title", ",", "$", "url", ",", "$", "options", ",", "$", "confirmMessage", ")", ";", "}", "if", "(", "(", "$", "user", "=", "$", "this", "->", "Session", "->", "read", "(", "\"{$this->settings['path']}\"", ")", ")", "==", "false", ")", "{", "return", ";", "}", "foreach", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "field", ",", "'.'", ")", "!==", "false", ")", "{", "$", "field", "=", "'/'", ".", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "field", ")", ";", "}", "if", "(", "$", "field", "[", "0", "]", "==", "\"/\"", ")", "{", "$", "values", "=", "(", "array", ")", "Set", "::", "extract", "(", "$", "field", ",", "$", "user", ")", ";", "foreach", "(", "$", "value", "as", "$", "condition", ")", "{", "if", "(", "in_array", "(", "$", "condition", ",", "$", "values", ")", ")", "{", "$", "count", "--", ";", "}", "}", "}", "else", "{", "if", "(", "$", "user", "[", "$", "field", "]", "==", "$", "value", ")", "{", "$", "count", "--", ";", "}", "}", "}", "return", "(", "$", "count", "!=", "0", ")", "?", "null", ":", "$", "this", "->", "Html", "->", "link", "(", "$", "title", ",", "$", "url", ",", "$", "options", ",", "$", "confirmMessage", ")", ";", "}" ]
Executes the route based on it's rules @param string $route route being executed @param string $title The content to be wrapped by <a> tags. @param mixed $url Cake-relative URL or array of URL parameters, or external URL (starts with http://) @param array $options Array of HTML attributes. @param string $confirmMessage JavaScript confirmation message. @return string An `<a />` element. @author Jose Diaz-Gonzalez
[ "Executes", "the", "route", "based", "on", "it", "s", "rules" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/View/Helper/ClearanceHelper.php#L160-L214
21,848
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.store
public function store( $id, $data, $attributes = array() ) { $metaStorage = $this->getMetaDataStorage(); $metaStorage->lock(); $metaData = $this->getMetaData( $metaStorage ); foreach( $this->storageStack as $storageConf ) { call_user_func( array( $this->properties['options']->replacementStrategy, 'store' ), $storageConf, $metaData, $id, $data, $attributes ); } $metaStorage->storeMetaData( $metaData ); $metaStorage->unlock(); }
php
public function store( $id, $data, $attributes = array() ) { $metaStorage = $this->getMetaDataStorage(); $metaStorage->lock(); $metaData = $this->getMetaData( $metaStorage ); foreach( $this->storageStack as $storageConf ) { call_user_func( array( $this->properties['options']->replacementStrategy, 'store' ), $storageConf, $metaData, $id, $data, $attributes ); } $metaStorage->storeMetaData( $metaData ); $metaStorage->unlock(); }
[ "public", "function", "store", "(", "$", "id", ",", "$", "data", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "metaStorage", "=", "$", "this", "->", "getMetaDataStorage", "(", ")", ";", "$", "metaStorage", "->", "lock", "(", ")", ";", "$", "metaData", "=", "$", "this", "->", "getMetaData", "(", "$", "metaStorage", ")", ";", "foreach", "(", "$", "this", "->", "storageStack", "as", "$", "storageConf", ")", "{", "call_user_func", "(", "array", "(", "$", "this", "->", "properties", "[", "'options'", "]", "->", "replacementStrategy", ",", "'store'", ")", ",", "$", "storageConf", ",", "$", "metaData", ",", "$", "id", ",", "$", "data", ",", "$", "attributes", ")", ";", "}", "$", "metaStorage", "->", "storeMetaData", "(", "$", "metaData", ")", ";", "$", "metaStorage", "->", "unlock", "(", ")", ";", "}" ]
Stores data in the cache stack. This method will store the given data across the complete stack. It can afterwards be restored using the {@link ezcCacheStack::restore()} method and be deleted through the {@link ezcCacheStack::delete()} method. The data that can be stored in the cache depends on the configured storages. Usually it is save to store arrays and scalars. However, some caches support objects or do not even support arrays. You need to make sure that the inner caches of the stack *all* support the data you want to store! The $attributes array is optional and can be used to describe the stack further. @param string $id @param mixed $data @param array $attributes
[ "Stores", "data", "in", "the", "cache", "stack", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L207-L231
21,849
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.getMetaData
private function getMetaData( ezcCacheStackMetaDataStorage $metaStorage ) { $metaData = $metaStorage->restoreMetaData(); if ( $metaData === null ) { $metaData = call_user_func( array( $this->properties['options']->replacementStrategy, 'createMetaData' ) ); } return $metaData; }
php
private function getMetaData( ezcCacheStackMetaDataStorage $metaStorage ) { $metaData = $metaStorage->restoreMetaData(); if ( $metaData === null ) { $metaData = call_user_func( array( $this->properties['options']->replacementStrategy, 'createMetaData' ) ); } return $metaData; }
[ "private", "function", "getMetaData", "(", "ezcCacheStackMetaDataStorage", "$", "metaStorage", ")", "{", "$", "metaData", "=", "$", "metaStorage", "->", "restoreMetaData", "(", ")", ";", "if", "(", "$", "metaData", "===", "null", ")", "{", "$", "metaData", "=", "call_user_func", "(", "array", "(", "$", "this", "->", "properties", "[", "'options'", "]", "->", "replacementStrategy", ",", "'createMetaData'", ")", ")", ";", "}", "return", "$", "metaData", ";", "}" ]
Returns the meta data to use. Returns the meta data to use with the configured {@link ezcCacheStackStackReplacementStrategy}. @param ezcCacheStackMetaDataStorage $metaStorage @return ezcCacheMetaData
[ "Returns", "the", "meta", "data", "to", "use", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L242-L257
21,850
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.restore
public function restore( $id, $attributes = array(), $search = false ) { $metaStorage = $this->getMetaDataStorage(); $metaStorage->lock(); $metaData = $this->getMetaData( $metaStorage ); $item = false; foreach ( $this->storageStack as $storageConf ) { $item = call_user_func( array( $this->properties['options']->replacementStrategy, 'restore' ), $storageConf, $metaData, $id, $attributes, $search ); if ( $item !== false ) { if ( $this->properties['options']->bubbleUpOnRestore ) { $this->bubbleUp( $id, $attributes, $item, $storageConf, $metaData ); } // Found, so end. break; } } $metaStorage->storeMetaData( $metaData ); $metaStorage->unlock(); return $item; }
php
public function restore( $id, $attributes = array(), $search = false ) { $metaStorage = $this->getMetaDataStorage(); $metaStorage->lock(); $metaData = $this->getMetaData( $metaStorage ); $item = false; foreach ( $this->storageStack as $storageConf ) { $item = call_user_func( array( $this->properties['options']->replacementStrategy, 'restore' ), $storageConf, $metaData, $id, $attributes, $search ); if ( $item !== false ) { if ( $this->properties['options']->bubbleUpOnRestore ) { $this->bubbleUp( $id, $attributes, $item, $storageConf, $metaData ); } // Found, so end. break; } } $metaStorage->storeMetaData( $metaData ); $metaStorage->unlock(); return $item; }
[ "public", "function", "restore", "(", "$", "id", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "metaStorage", "=", "$", "this", "->", "getMetaDataStorage", "(", ")", ";", "$", "metaStorage", "->", "lock", "(", ")", ";", "$", "metaData", "=", "$", "this", "->", "getMetaData", "(", "$", "metaStorage", ")", ";", "$", "item", "=", "false", ";", "foreach", "(", "$", "this", "->", "storageStack", "as", "$", "storageConf", ")", "{", "$", "item", "=", "call_user_func", "(", "array", "(", "$", "this", "->", "properties", "[", "'options'", "]", "->", "replacementStrategy", ",", "'restore'", ")", ",", "$", "storageConf", ",", "$", "metaData", ",", "$", "id", ",", "$", "attributes", ",", "$", "search", ")", ";", "if", "(", "$", "item", "!==", "false", ")", "{", "if", "(", "$", "this", "->", "properties", "[", "'options'", "]", "->", "bubbleUpOnRestore", ")", "{", "$", "this", "->", "bubbleUp", "(", "$", "id", ",", "$", "attributes", ",", "$", "item", ",", "$", "storageConf", ",", "$", "metaData", ")", ";", "}", "// Found, so end.", "break", ";", "}", "}", "$", "metaStorage", "->", "storeMetaData", "(", "$", "metaData", ")", ";", "$", "metaStorage", "->", "unlock", "(", ")", ";", "return", "$", "item", ";", "}" ]
Restores an item from the stack. This method tries to restore an item from the cache stack and returns the found data, if any. If no data is found, boolean false is returned. Given the ID of an object will restore exactly the desired object. If additional $attributes are given, this may speed up the restore process for some caches. If only attributes are given, the $search parameter makes sense, since it will instruct the inner cach storages to search their content for the given attribute combination and will restore the first item found. However, this process is much slower then restoring with an ID and therefore is not recommended. @param string $id @param array $attributes @param bool $search @return mixed The restored data or false on failure.
[ "Restores", "an", "item", "from", "the", "stack", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L277-L313
21,851
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.delete
public function delete( $id = null, $attributes = array(), $search = false ) { $metaStorage = $this->getMetaDataStorage(); $metaStorage->lock(); $metaData = $metaStorage->restoreMetaData(); $deletedIds = array(); foreach ( $this->storageStack as $storageConf ) { $deletedIds = array_merge( $deletedIds, call_user_func( array( $this->properties['options']->replacementStrategy, 'delete' ), $storageConf, $metaData, $id, $attributes, $search ) ); } $metaStorage->storeMetaData( $metaData ); $metaStorage->unlock(); return array_unique( $deletedIds ); }
php
public function delete( $id = null, $attributes = array(), $search = false ) { $metaStorage = $this->getMetaDataStorage(); $metaStorage->lock(); $metaData = $metaStorage->restoreMetaData(); $deletedIds = array(); foreach ( $this->storageStack as $storageConf ) { $deletedIds = array_merge( $deletedIds, call_user_func( array( $this->properties['options']->replacementStrategy, 'delete' ), $storageConf, $metaData, $id, $attributes, $search ) ); } $metaStorage->storeMetaData( $metaData ); $metaStorage->unlock(); return array_unique( $deletedIds ); }
[ "public", "function", "delete", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "metaStorage", "=", "$", "this", "->", "getMetaDataStorage", "(", ")", ";", "$", "metaStorage", "->", "lock", "(", ")", ";", "$", "metaData", "=", "$", "metaStorage", "->", "restoreMetaData", "(", ")", ";", "$", "deletedIds", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "storageStack", "as", "$", "storageConf", ")", "{", "$", "deletedIds", "=", "array_merge", "(", "$", "deletedIds", ",", "call_user_func", "(", "array", "(", "$", "this", "->", "properties", "[", "'options'", "]", "->", "replacementStrategy", ",", "'delete'", ")", ",", "$", "storageConf", ",", "$", "metaData", ",", "$", "id", ",", "$", "attributes", ",", "$", "search", ")", ")", ";", "}", "$", "metaStorage", "->", "storeMetaData", "(", "$", "metaData", ")", ";", "$", "metaStorage", "->", "unlock", "(", ")", ";", "return", "array_unique", "(", "$", "deletedIds", ")", ";", "}" ]
Deletes an item from the stack. This method deletes an item from the cache stack. The item will afterwards no more be stored in any of the inner cache storages. Giving the ID of the cache item will delete exactly 1 desired item. Giving an attribute array, describing the desired item in more detail, can speed up the deletion in some caches. Giving null as the ID and just an attribibute array, with the $search attribute in addition, will delete *all* items that comply to the attributes from all storages. This might be much slower than just deleting a single item. Deleting items from a cache stack is not recommended at all. Instead, items should expire on their own or be overwritten with more actual data. The method returns an array containing all deleted item IDs. @param string $id @param array $attributes @param bool $search @return array(string)
[ "Deletes", "an", "item", "from", "the", "stack", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L372-L402
21,852
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.getMetaDataStorage
private function getMetaDataStorage() { $metaStorage = $this->options->metaStorage; if ( $metaStorage === null ) { $metaStorage = reset( $this->storageStack )->storage; if ( !( $metaStorage instanceof ezcCacheStackMetaDataStorage ) ) { throw new ezcBaseValueException( 'metaStorage', $metaStorage, 'ezcCacheStackMetaDataStorage', 'top of storage stack' ); } } return $metaStorage; }
php
private function getMetaDataStorage() { $metaStorage = $this->options->metaStorage; if ( $metaStorage === null ) { $metaStorage = reset( $this->storageStack )->storage; if ( !( $metaStorage instanceof ezcCacheStackMetaDataStorage ) ) { throw new ezcBaseValueException( 'metaStorage', $metaStorage, 'ezcCacheStackMetaDataStorage', 'top of storage stack' ); } } return $metaStorage; }
[ "private", "function", "getMetaDataStorage", "(", ")", "{", "$", "metaStorage", "=", "$", "this", "->", "options", "->", "metaStorage", ";", "if", "(", "$", "metaStorage", "===", "null", ")", "{", "$", "metaStorage", "=", "reset", "(", "$", "this", "->", "storageStack", ")", "->", "storage", ";", "if", "(", "!", "(", "$", "metaStorage", "instanceof", "ezcCacheStackMetaDataStorage", ")", ")", "{", "throw", "new", "ezcBaseValueException", "(", "'metaStorage'", ",", "$", "metaStorage", ",", "'ezcCacheStackMetaDataStorage'", ",", "'top of storage stack'", ")", ";", "}", "}", "return", "$", "metaStorage", ";", "}" ]
Returns the meta data storage to be used. Determines the meta data storage to be used by the stack and returns it. @return ezcCacheStackMetaData
[ "Returns", "the", "meta", "data", "storage", "to", "be", "used", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L411-L428
21,853
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.countDataItems
public function countDataItems( $id = null, $attributes = array() ) { $sum = 0; foreach( $this->storageStack as $storageConf ) { $sum += $storageConf->storage->countDataItems( $id, $attributes ); } return $sum; }
php
public function countDataItems( $id = null, $attributes = array() ) { $sum = 0; foreach( $this->storageStack as $storageConf ) { $sum += $storageConf->storage->countDataItems( $id, $attributes ); } return $sum; }
[ "public", "function", "countDataItems", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "sum", "=", "0", ";", "foreach", "(", "$", "this", "->", "storageStack", "as", "$", "storageConf", ")", "{", "$", "sum", "+=", "$", "storageConf", "->", "storage", "->", "countDataItems", "(", "$", "id", ",", "$", "attributes", ")", ";", "}", "return", "$", "sum", ";", "}" ]
Counts how many items are stored, fulfilling certain criteria. This method counts how many data items fulfilling the given criteria are stored overall. Note: The items of all contained storages are counted independantly and summarized. @param string $id @param array $attributes @return int
[ "Counts", "how", "many", "items", "are", "stored", "fulfilling", "certain", "criteria", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L441-L449
21,854
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.getRemainingLifetime
public function getRemainingLifetime( $id, $attributes = array() ) { foreach ( $this->storageStack as $storageConf ) { $lifetime = $storageConf->storage->getRemainingLifetime( $id, $attributes ); if ( $lifetime > 0 ) { return $lifetime; } } return 0; }
php
public function getRemainingLifetime( $id, $attributes = array() ) { foreach ( $this->storageStack as $storageConf ) { $lifetime = $storageConf->storage->getRemainingLifetime( $id, $attributes ); if ( $lifetime > 0 ) { return $lifetime; } } return 0; }
[ "public", "function", "getRemainingLifetime", "(", "$", "id", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "storageStack", "as", "$", "storageConf", ")", "{", "$", "lifetime", "=", "$", "storageConf", "->", "storage", "->", "getRemainingLifetime", "(", "$", "id", ",", "$", "attributes", ")", ";", "if", "(", "$", "lifetime", ">", "0", ")", "{", "return", "$", "lifetime", ";", "}", "}", "return", "0", ";", "}" ]
Returns the remaining lifetime for the given item ID. This method returns the lifetime in seconds for the item identified by $item and optionally described by $attributes. Definining the $attributes might lead to faster results with some caches. The first internal storage that is found for the data item is chosen to detemine the lifetime. If no storage contains the item or the item is outdated in all found caches, 0 is returned. @param string $id @param array $attributes @return int
[ "Returns", "the", "remaining", "lifetime", "for", "the", "given", "item", "ID", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L466-L480
21,855
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.pushStorage
public function pushStorage( ezcCacheStackStorageConfiguration $storageConf ) { if ( isset( $this->storageIdMap[$storageConf->id] ) ) { throw new ezcCacheStackIdAlreadyUsedException( $storageConf->id ); } if ( in_array( $storageConf->storage, $this->storageIdMap, true ) ) { throw new ezcCacheStackStorageUsedTwiceException( $storageConf->storage ); } array_unshift( $this->storageStack, $storageConf ); $this->storageIdMap[$storageConf->id] = $storageConf->storage; }
php
public function pushStorage( ezcCacheStackStorageConfiguration $storageConf ) { if ( isset( $this->storageIdMap[$storageConf->id] ) ) { throw new ezcCacheStackIdAlreadyUsedException( $storageConf->id ); } if ( in_array( $storageConf->storage, $this->storageIdMap, true ) ) { throw new ezcCacheStackStorageUsedTwiceException( $storageConf->storage ); } array_unshift( $this->storageStack, $storageConf ); $this->storageIdMap[$storageConf->id] = $storageConf->storage; }
[ "public", "function", "pushStorage", "(", "ezcCacheStackStorageConfiguration", "$", "storageConf", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "storageIdMap", "[", "$", "storageConf", "->", "id", "]", ")", ")", "{", "throw", "new", "ezcCacheStackIdAlreadyUsedException", "(", "$", "storageConf", "->", "id", ")", ";", "}", "if", "(", "in_array", "(", "$", "storageConf", "->", "storage", ",", "$", "this", "->", "storageIdMap", ",", "true", ")", ")", "{", "throw", "new", "ezcCacheStackStorageUsedTwiceException", "(", "$", "storageConf", "->", "storage", ")", ";", "}", "array_unshift", "(", "$", "this", "->", "storageStack", ",", "$", "storageConf", ")", ";", "$", "this", "->", "storageIdMap", "[", "$", "storageConf", "->", "id", "]", "=", "$", "storageConf", "->", "storage", ";", "}" ]
Add a storage to the top of the stack. This method is used to add a new storage to the top of the cache. The $storageConf of type {@link ezcCacheStackStorageConfiguration} consists of the actual {@link ezcCacheStackableStorage} and other information. Most importantly, the configuration object contains an ID, which must be unique within the whole storage. The itemLimit setting determines how many items might be stored in the storage at all. freeRate determines which fraction of itemLimit will be freed by the {@link ezcCacheStackStackReplacementStrategy} of the stack, when the storage runs full. @param ezcCacheStackStorageConfiguration $storageConf
[ "Add", "a", "storage", "to", "the", "top", "of", "the", "stack", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L498-L514
21,856
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php
ezcCacheStack.popStorage
public function popStorage() { if ( count( $this->storageStack ) === 0 ) { throw new ezcCacheStackUnderflowException(); } $storageConf = array_shift( $this->storageStack ); unset( $this->storageIdMap[$storageConf->id] ); return $storageConf; }
php
public function popStorage() { if ( count( $this->storageStack ) === 0 ) { throw new ezcCacheStackUnderflowException(); } $storageConf = array_shift( $this->storageStack ); unset( $this->storageIdMap[$storageConf->id] ); return $storageConf; }
[ "public", "function", "popStorage", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "storageStack", ")", "===", "0", ")", "{", "throw", "new", "ezcCacheStackUnderflowException", "(", ")", ";", "}", "$", "storageConf", "=", "array_shift", "(", "$", "this", "->", "storageStack", ")", ";", "unset", "(", "$", "this", "->", "storageIdMap", "[", "$", "storageConf", "->", "id", "]", ")", ";", "return", "$", "storageConf", ";", "}" ]
Removes a storage from the top of the stack. This method can be used to remove the top most {@link ezcCacheStackableStorage} from the stack. This is commonly done to remove caches or to insert new ones into lower positions. In both cases, it is recommended to {@link ezcCacheStack::reset()} the whole cache afterwards to avoid any kind of inconsistency. @return ezcCacheStackStorageConfiguration @throws ezcCacheStackUnderflowException if called on an empty stack.
[ "Removes", "a", "storage", "from", "the", "top", "of", "the", "stack", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/stack.php#L530-L539
21,857
fccn/oai-pmh-core
src/libs/xml_creater.php
ANDS_XML.create_request
public function create_request($par_array) { //debug_var_dump('par_array', $par_array); $request = $this->addChild($this->doc->documentElement, "request", $this->request_url()); foreach ($par_array as $key => $value) { $request->setAttribute($key, $value); } }
php
public function create_request($par_array) { //debug_var_dump('par_array', $par_array); $request = $this->addChild($this->doc->documentElement, "request", $this->request_url()); foreach ($par_array as $key => $value) { $request->setAttribute($key, $value); } }
[ "public", "function", "create_request", "(", "$", "par_array", ")", "{", "//debug_var_dump('par_array', $par_array);", "$", "request", "=", "$", "this", "->", "addChild", "(", "$", "this", "->", "doc", "->", "documentElement", ",", "\"request\"", ",", "$", "this", "->", "request_url", "(", ")", ")", ";", "foreach", "(", "$", "par_array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "request", "->", "setAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Create an OAI request node. @param $par_array Type: array The attributes of a request node. They describe the verb of the request and other associated parameters used in the request. Keys of the array define attributes, and values are their content.
[ "Create", "an", "OAI", "request", "node", "." ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/libs/xml_creater.php#L253-L260
21,858
fccn/oai-pmh-core
src/libs/xml_creater.php
ANDS_Response_XML.create_resumpToken
public function create_resumpToken($token, $expirationdatetime, $num_rows, $cursor=null) { $resump_node = $this->addChild($this->verbNode, "resumptionToken", $token); if (isset($expirationdatetime)) { $resump_node->setAttribute("expirationDate", $expirationdatetime); } $resump_node->setAttribute("completeListSize", $num_rows); $resump_node->setAttribute("cursor", $cursor); }
php
public function create_resumpToken($token, $expirationdatetime, $num_rows, $cursor=null) { $resump_node = $this->addChild($this->verbNode, "resumptionToken", $token); if (isset($expirationdatetime)) { $resump_node->setAttribute("expirationDate", $expirationdatetime); } $resump_node->setAttribute("completeListSize", $num_rows); $resump_node->setAttribute("cursor", $cursor); }
[ "public", "function", "create_resumpToken", "(", "$", "token", ",", "$", "expirationdatetime", ",", "$", "num_rows", ",", "$", "cursor", "=", "null", ")", "{", "$", "resump_node", "=", "$", "this", "->", "addChild", "(", "$", "this", "->", "verbNode", ",", "\"resumptionToken\"", ",", "$", "token", ")", ";", "if", "(", "isset", "(", "$", "expirationdatetime", ")", ")", "{", "$", "resump_node", "->", "setAttribute", "(", "\"expirationDate\"", ",", "$", "expirationdatetime", ")", ";", "}", "$", "resump_node", "->", "setAttribute", "(", "\"completeListSize\"", ",", "$", "num_rows", ")", ";", "$", "resump_node", "->", "setAttribute", "(", "\"cursor\"", ",", "$", "cursor", ")", ";", "}" ]
If there are too many records request could not finished a resumpToken is generated to let harvester know \param $token Type: string. A random number created somewhere? \param $expirationdatetime Type: string. A string representing time. \param $num_rows Type: integer. Number of records retrieved. \param $cursor Type: string. Cursor can be used for database to retrieve next time.
[ "If", "there", "are", "too", "many", "records", "request", "could", "not", "finished", "a", "resumpToken", "is", "generated", "to", "let", "harvester", "know" ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/libs/xml_creater.php#L397-L405
21,859
SporkCode/Spork
src/Mvc/Listener/AccessDeniedStrategy.php
AccessDeniedStrategy.detectAccessDenied
public function detectAccessDenied(MvcEvent $event) { $response = $event->getResponse(); if ($response->getStatusCode() == 403) { $event->setError('Access Denied'); $event->stopPropagation(true); } }
php
public function detectAccessDenied(MvcEvent $event) { $response = $event->getResponse(); if ($response->getStatusCode() == 403) { $event->setError('Access Denied'); $event->stopPropagation(true); } }
[ "public", "function", "detectAccessDenied", "(", "MvcEvent", "$", "event", ")", "{", "$", "response", "=", "$", "event", "->", "getResponse", "(", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "==", "403", ")", "{", "$", "event", "->", "setError", "(", "'Access Denied'", ")", ";", "$", "event", "->", "stopPropagation", "(", "true", ")", ";", "}", "}" ]
If response status code is 403 set error state and stop event propagation @param MvcEvent $event
[ "If", "response", "status", "code", "is", "403", "set", "error", "state", "and", "stop", "event", "propagation" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/AccessDeniedStrategy.php#L133-L140
21,860
SporkCode/Spork
src/Mvc/Listener/AccessDeniedStrategy.php
AccessDeniedStrategy.injectAccessDeniedViewModel
public function injectAccessDeniedViewModel(MvcEvent $event) { $this->config($event); $result = $event->getResult(); if ($result instanceof ResponseInterface) { return; } $response = $event->getResponse(); if ($response->getStatusCode() != 403) { return; } $model = new ViewModel(); $model->setTemplate($this->template); if ($this->renderLayout == true) { $layout = $event->getViewModel(); $layout->addChild($model); } else { $model->setTerminal(true); $event->setViewModel($model); } }
php
public function injectAccessDeniedViewModel(MvcEvent $event) { $this->config($event); $result = $event->getResult(); if ($result instanceof ResponseInterface) { return; } $response = $event->getResponse(); if ($response->getStatusCode() != 403) { return; } $model = new ViewModel(); $model->setTemplate($this->template); if ($this->renderLayout == true) { $layout = $event->getViewModel(); $layout->addChild($model); } else { $model->setTerminal(true); $event->setViewModel($model); } }
[ "public", "function", "injectAccessDeniedViewModel", "(", "MvcEvent", "$", "event", ")", "{", "$", "this", "->", "config", "(", "$", "event", ")", ";", "$", "result", "=", "$", "event", "->", "getResult", "(", ")", ";", "if", "(", "$", "result", "instanceof", "ResponseInterface", ")", "{", "return", ";", "}", "$", "response", "=", "$", "event", "->", "getResponse", "(", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!=", "403", ")", "{", "return", ";", "}", "$", "model", "=", "new", "ViewModel", "(", ")", ";", "$", "model", "->", "setTemplate", "(", "$", "this", "->", "template", ")", ";", "if", "(", "$", "this", "->", "renderLayout", "==", "true", ")", "{", "$", "layout", "=", "$", "event", "->", "getViewModel", "(", ")", ";", "$", "layout", "->", "addChild", "(", "$", "model", ")", ";", "}", "else", "{", "$", "model", "->", "setTerminal", "(", "true", ")", ";", "$", "event", "->", "setViewModel", "(", "$", "model", ")", ";", "}", "}" ]
Inject access denied View Model is response status is 403 @param MvcEvent $event
[ "Inject", "access", "denied", "View", "Model", "is", "response", "status", "is", "403" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/AccessDeniedStrategy.php#L147-L173
21,861
SporkCode/Spork
src/Mvc/Listener/AccessDeniedStrategy.php
AccessDeniedStrategy.config
protected function config(MvcEvent $event) { $appConfig = $event->getApplication()->getServiceManager()->get('config'); $config = array_key_exists(self::CONFIG_KEY, $appConfig) ? $appConfig[self::CONFIG_KEY] : array(); if (array_key_exists('template', $config)) { $this->setTemplate($config['template']); } if (array_key_exists('renderLayout', $config)) { $this->setRenderLayout($config['renderLayout']); } }
php
protected function config(MvcEvent $event) { $appConfig = $event->getApplication()->getServiceManager()->get('config'); $config = array_key_exists(self::CONFIG_KEY, $appConfig) ? $appConfig[self::CONFIG_KEY] : array(); if (array_key_exists('template', $config)) { $this->setTemplate($config['template']); } if (array_key_exists('renderLayout', $config)) { $this->setRenderLayout($config['renderLayout']); } }
[ "protected", "function", "config", "(", "MvcEvent", "$", "event", ")", "{", "$", "appConfig", "=", "$", "event", "->", "getApplication", "(", ")", "->", "getServiceManager", "(", ")", "->", "get", "(", "'config'", ")", ";", "$", "config", "=", "array_key_exists", "(", "self", "::", "CONFIG_KEY", ",", "$", "appConfig", ")", "?", "$", "appConfig", "[", "self", "::", "CONFIG_KEY", "]", ":", "array", "(", ")", ";", "if", "(", "array_key_exists", "(", "'template'", ",", "$", "config", ")", ")", "{", "$", "this", "->", "setTemplate", "(", "$", "config", "[", "'template'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'renderLayout'", ",", "$", "config", ")", ")", "{", "$", "this", "->", "setRenderLayout", "(", "$", "config", "[", "'renderLayout'", "]", ")", ";", "}", "}" ]
Set configuration options from application configuration @param MvcEvent $event
[ "Set", "configuration", "options", "from", "application", "configuration" ]
7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a
https://github.com/SporkCode/Spork/blob/7f569efdc0ceb4a9c1c7a8b648b6a7ed50d2088a/src/Mvc/Listener/AccessDeniedStrategy.php#L180-L192
21,862
shabbyrobe/amiss
src/Functions.php
Functions.keyValue
public static function keyValue($list, $keyProperty=null, $valueProperty=null) { $index = array(); foreach ($list as $i) { if ($keyProperty) { if (!$valueProperty) { throw new \InvalidArgumentException("Must set value property if setting key property"); } $index[$i->$keyProperty] = $i->$valueProperty; } else { $key = current($i); next($i); $value = current($i); $index[$key] = $value; } } return $index; }
php
public static function keyValue($list, $keyProperty=null, $valueProperty=null) { $index = array(); foreach ($list as $i) { if ($keyProperty) { if (!$valueProperty) { throw new \InvalidArgumentException("Must set value property if setting key property"); } $index[$i->$keyProperty] = $i->$valueProperty; } else { $key = current($i); next($i); $value = current($i); $index[$key] = $value; } } return $index; }
[ "public", "static", "function", "keyValue", "(", "$", "list", ",", "$", "keyProperty", "=", "null", ",", "$", "valueProperty", "=", "null", ")", "{", "$", "index", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "i", ")", "{", "if", "(", "$", "keyProperty", ")", "{", "if", "(", "!", "$", "valueProperty", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Must set value property if setting key property\"", ")", ";", "}", "$", "index", "[", "$", "i", "->", "$", "keyProperty", "]", "=", "$", "i", "->", "$", "valueProperty", ";", "}", "else", "{", "$", "key", "=", "current", "(", "$", "i", ")", ";", "next", "(", "$", "i", ")", ";", "$", "value", "=", "current", "(", "$", "i", ")", ";", "$", "index", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "index", ";", "}" ]
Create a one-dimensional associative array from a list of objects, or a list of 2-tuples. @param object[]|array $list @param string $keyProperty @param string $valueProperty @return array
[ "Create", "a", "one", "-", "dimensional", "associative", "array", "from", "a", "list", "of", "objects", "or", "a", "list", "of", "2", "-", "tuples", "." ]
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Functions.php#L14-L32
21,863
nabab/bbn
src/bbn/user/session.php
session._get_value
private function _get_value($args){ if ( $this->id ){ $var =& $this->data; foreach ( $args as $a ){ if ( !isset($var[$a]) ){ return null; } $var =& $var[$a]; } return $var; } }
php
private function _get_value($args){ if ( $this->id ){ $var =& $this->data; foreach ( $args as $a ){ if ( !isset($var[$a]) ){ return null; } $var =& $var[$a]; } return $var; } }
[ "private", "function", "_get_value", "(", "$", "args", ")", "{", "if", "(", "$", "this", "->", "id", ")", "{", "$", "var", "=", "&", "$", "this", "->", "data", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "if", "(", "!", "isset", "(", "$", "var", "[", "$", "a", "]", ")", ")", "{", "return", "null", ";", "}", "$", "var", "=", "&", "$", "var", "[", "$", "a", "]", ";", "}", "return", "$", "var", ";", "}", "}" ]
Gets a reference to the part of the data corresponding to an array of indexes ```php $this->_get_value(['index1', 'index2']) // Will return the content of $this->data['index1']['index2'] ``` @param $args @return null
[ "Gets", "a", "reference", "to", "the", "part", "of", "the", "data", "corresponding", "to", "an", "array", "of", "indexes" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/session.php#L54-L65
21,864
zicht/z
src/Zicht/Tool/Container/Declaration.php
Declaration.compileBody
protected function compileBody(Buffer $buffer) { $buffer->write('return '); $this->expr->compile($buffer); $buffer->raw(';'); }
php
protected function compileBody(Buffer $buffer) { $buffer->write('return '); $this->expr->compile($buffer); $buffer->raw(';'); }
[ "protected", "function", "compileBody", "(", "Buffer", "$", "buffer", ")", "{", "$", "buffer", "->", "write", "(", "'return '", ")", ";", "$", "this", "->", "expr", "->", "compile", "(", "$", "buffer", ")", ";", "$", "buffer", "->", "raw", "(", "';'", ")", ";", "}" ]
Compiles the definition body @param \Zicht\Tool\Script\Buffer $buffer @return void
[ "Compiles", "the", "definition", "body" ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Container/Declaration.php#L53-L58
21,865
surebert/surebert-framework
src/sb/Controller/JSON/RPC2/Server.php
Server.useEncryption
public function useEncryption($key) { $this->encryptor = new \sb\Encryption\ForTransmission($key); $this->encryption_key = $key; //decrypt cookies if sent foreach (\sb\Gateway::$cookie as $k => $v) { \sb\Gateway::$cookie[$k] = $this->encryptor->decrypt($v); } }
php
public function useEncryption($key) { $this->encryptor = new \sb\Encryption\ForTransmission($key); $this->encryption_key = $key; //decrypt cookies if sent foreach (\sb\Gateway::$cookie as $k => $v) { \sb\Gateway::$cookie[$k] = $this->encryptor->decrypt($v); } }
[ "public", "function", "useEncryption", "(", "$", "key", ")", "{", "$", "this", "->", "encryptor", "=", "new", "\\", "sb", "\\", "Encryption", "\\", "ForTransmission", "(", "$", "key", ")", ";", "$", "this", "->", "encryption_key", "=", "$", "key", ";", "//decrypt cookies if sent", "foreach", "(", "\\", "sb", "\\", "Gateway", "::", "$", "cookie", "as", "$", "k", "=>", "$", "v", ")", "{", "\\", "sb", "\\", "Gateway", "::", "$", "cookie", "[", "$", "k", "]", "=", "$", "this", "->", "encryptor", "->", "decrypt", "(", "$", "v", ")", ";", "}", "}" ]
Sets the key that data is encrypted with and turns on encryption, the client must use the same key @param $key String
[ "Sets", "the", "key", "that", "data", "is", "encrypted", "with", "and", "turns", "on", "encryption", "the", "client", "must", "use", "the", "same", "key" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/JSON/RPC2/Server.php#L86-L95
21,866
surebert/surebert-framework
src/sb/Controller/JSON/RPC2/Server.php
Server.getMethods
public function getMethods($html = true) { $arr = Array(); foreach($this->served_classes as $class){ foreach (\get_class_methods($class) as $method) { $reflect = new \ReflectionMethod($class, $method); if ($reflect) { if($class == $this){ $docs = $reflect->getDocComment(); $servable = false; if (!empty($docs)) { if (\preg_match("~@servable (true|false)~", $docs, $match)) { $servable = $match[1] == 'true' ? true : false; } } } else if($reflect->isPublic()){ $servable = true; } if (!$servable) { continue; } $params = $reflect->getParameters(); $ps = Array(); foreach ($params as $param) { $ps[] = '$' . $param->getName(); } $key = $method . '(' . implode(', ', $ps) . ')'; $arr[$key] = $reflect->getDocComment(); } } } if ($html == false) { return $arr; } else { return $this->methodsToHtml($arr); } }
php
public function getMethods($html = true) { $arr = Array(); foreach($this->served_classes as $class){ foreach (\get_class_methods($class) as $method) { $reflect = new \ReflectionMethod($class, $method); if ($reflect) { if($class == $this){ $docs = $reflect->getDocComment(); $servable = false; if (!empty($docs)) { if (\preg_match("~@servable (true|false)~", $docs, $match)) { $servable = $match[1] == 'true' ? true : false; } } } else if($reflect->isPublic()){ $servable = true; } if (!$servable) { continue; } $params = $reflect->getParameters(); $ps = Array(); foreach ($params as $param) { $ps[] = '$' . $param->getName(); } $key = $method . '(' . implode(', ', $ps) . ')'; $arr[$key] = $reflect->getDocComment(); } } } if ($html == false) { return $arr; } else { return $this->methodsToHtml($arr); } }
[ "public", "function", "getMethods", "(", "$", "html", "=", "true", ")", "{", "$", "arr", "=", "Array", "(", ")", ";", "foreach", "(", "$", "this", "->", "served_classes", "as", "$", "class", ")", "{", "foreach", "(", "\\", "get_class_methods", "(", "$", "class", ")", "as", "$", "method", ")", "{", "$", "reflect", "=", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "$", "method", ")", ";", "if", "(", "$", "reflect", ")", "{", "if", "(", "$", "class", "==", "$", "this", ")", "{", "$", "docs", "=", "$", "reflect", "->", "getDocComment", "(", ")", ";", "$", "servable", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "docs", ")", ")", "{", "if", "(", "\\", "preg_match", "(", "\"~@servable (true|false)~\"", ",", "$", "docs", ",", "$", "match", ")", ")", "{", "$", "servable", "=", "$", "match", "[", "1", "]", "==", "'true'", "?", "true", ":", "false", ";", "}", "}", "}", "else", "if", "(", "$", "reflect", "->", "isPublic", "(", ")", ")", "{", "$", "servable", "=", "true", ";", "}", "if", "(", "!", "$", "servable", ")", "{", "continue", ";", "}", "$", "params", "=", "$", "reflect", "->", "getParameters", "(", ")", ";", "$", "ps", "=", "Array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "ps", "[", "]", "=", "'$'", ".", "$", "param", "->", "getName", "(", ")", ";", "}", "$", "key", "=", "$", "method", ".", "'('", ".", "implode", "(", "', '", ",", "$", "ps", ")", ".", "')'", ";", "$", "arr", "[", "$", "key", "]", "=", "$", "reflect", "->", "getDocComment", "(", ")", ";", "}", "}", "}", "if", "(", "$", "html", "==", "false", ")", "{", "return", "$", "arr", ";", "}", "else", "{", "return", "$", "this", "->", "methodsToHtml", "(", "$", "arr", ")", ";", "}", "}" ]
Get the methods available for this \sb\JSON\RPC2_Server instance @return Array - Object once json_encoded @servable true
[ "Get", "the", "methods", "available", "for", "this", "\\", "sb", "\\", "JSON", "\\", "RPC2_Server", "instance" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/JSON/RPC2/Server.php#L102-L149
21,867
surebert/surebert-framework
src/sb/Controller/JSON/RPC2/Server.php
Server.getPhpdoc
protected function getPhpdoc($method) { $reflect = false; foreach($this->served_classes as $class){ if (\method_exists($class, $method)) { $reflect = new \ReflectionMethod($class, $method); break; } } $response = new \stdClass(); if(!$reflect){ $response->error = new \sb\JSON\RPC2\Error(); $response->error->code = -32602; $response->error->message = "Invalid method parameters"; return $response; } $response->phpdoc = $reflect->getDocComment(); if (\preg_match("~@return (.*?) (.*?)\*/$~s", $response->phpdoc, $match)) { $response->return_type = $match[1]; } else { $response->return_type = 'n/a'; } return $response; }
php
protected function getPhpdoc($method) { $reflect = false; foreach($this->served_classes as $class){ if (\method_exists($class, $method)) { $reflect = new \ReflectionMethod($class, $method); break; } } $response = new \stdClass(); if(!$reflect){ $response->error = new \sb\JSON\RPC2\Error(); $response->error->code = -32602; $response->error->message = "Invalid method parameters"; return $response; } $response->phpdoc = $reflect->getDocComment(); if (\preg_match("~@return (.*?) (.*?)\*/$~s", $response->phpdoc, $match)) { $response->return_type = $match[1]; } else { $response->return_type = 'n/a'; } return $response; }
[ "protected", "function", "getPhpdoc", "(", "$", "method", ")", "{", "$", "reflect", "=", "false", ";", "foreach", "(", "$", "this", "->", "served_classes", "as", "$", "class", ")", "{", "if", "(", "\\", "method_exists", "(", "$", "class", ",", "$", "method", ")", ")", "{", "$", "reflect", "=", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "$", "method", ")", ";", "break", ";", "}", "}", "$", "response", "=", "new", "\\", "stdClass", "(", ")", ";", "if", "(", "!", "$", "reflect", ")", "{", "$", "response", "->", "error", "=", "new", "\\", "sb", "\\", "JSON", "\\", "RPC2", "\\", "Error", "(", ")", ";", "$", "response", "->", "error", "->", "code", "=", "-", "32602", ";", "$", "response", "->", "error", "->", "message", "=", "\"Invalid method parameters\"", ";", "return", "$", "response", ";", "}", "$", "response", "->", "phpdoc", "=", "$", "reflect", "->", "getDocComment", "(", ")", ";", "if", "(", "\\", "preg_match", "(", "\"~@return (.*?) (.*?)\\*/$~s\"", ",", "$", "response", "->", "phpdoc", ",", "$", "match", ")", ")", "{", "$", "response", "->", "return_type", "=", "$", "match", "[", "1", "]", ";", "}", "else", "{", "$", "response", "->", "return_type", "=", "'n/a'", ";", "}", "return", "$", "response", ";", "}" ]
Get php doc and return_type for method by name @param string $name The name of the method to grab the docs for @return Object with return_type and phpdoc property
[ "Get", "php", "doc", "and", "return_type", "for", "method", "by", "name" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/JSON/RPC2/Server.php#L156-L187
21,868
surebert/surebert-framework
src/sb/Controller/JSON/RPC2/Server.php
Server.methodsToHtml
protected function methodsToHtml($methods) { $html = '<style type="text/css"> li{background-color:#c8c8d4;} h1{ font-size:1.0em; padding:3px 0 3px 10px; color:white; background-color:#8181bd; } pre{ color:#1d1d4d; } </style><ol>'; //sorting method alphabetically ksort($methods); foreach ($methods as $method => $comments) { $html .= '<li><h1>$server->' . $method . ';</h1><pre>' . str_repeat("&nbsp;", 4) . $comments . '</pre></li>'; } $html .= '</ol>'; return $html; }
php
protected function methodsToHtml($methods) { $html = '<style type="text/css"> li{background-color:#c8c8d4;} h1{ font-size:1.0em; padding:3px 0 3px 10px; color:white; background-color:#8181bd; } pre{ color:#1d1d4d; } </style><ol>'; //sorting method alphabetically ksort($methods); foreach ($methods as $method => $comments) { $html .= '<li><h1>$server->' . $method . ';</h1><pre>' . str_repeat("&nbsp;", 4) . $comments . '</pre></li>'; } $html .= '</ol>'; return $html; }
[ "protected", "function", "methodsToHtml", "(", "$", "methods", ")", "{", "$", "html", "=", "'<style type=\"text/css\">\n li{background-color:#c8c8d4;}\n\n h1{\n font-size:1.0em;\n padding:3px 0 3px 10px;\n color:white;\n background-color:#8181bd;\n }\n\n pre{\n color:#1d1d4d;\n }\n </style><ol>'", ";", "//sorting method alphabetically", "ksort", "(", "$", "methods", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", "=>", "$", "comments", ")", "{", "$", "html", ".=", "'<li><h1>$server->'", ".", "$", "method", ".", "';</h1><pre>'", ".", "str_repeat", "(", "\"&nbsp;\"", ",", "4", ")", ".", "$", "comments", ".", "'</pre></li>'", ";", "}", "$", "html", ".=", "'</ol>'", ";", "return", "$", "html", ";", "}" ]
Coverts the methods served into an HTML string @param $arr @return string HTML
[ "Coverts", "the", "methods", "served", "into", "an", "HTML", "string" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/JSON/RPC2/Server.php#L194-L221
21,869
mekras/atompub
src/Element/Collection.php
Collection.getAcceptedTypes
public function getAcceptedTypes() { return $this->getCachedProperty( 'accept', function () { $result = []; /** @var \DOMNodeList $nodes */ // No REQUIRED — no exception. $nodes = $this->query('app:accept'); foreach ($nodes as $value) { $result[] = trim($value->textContent); } return $result; } ); }
php
public function getAcceptedTypes() { return $this->getCachedProperty( 'accept', function () { $result = []; /** @var \DOMNodeList $nodes */ // No REQUIRED — no exception. $nodes = $this->query('app:accept'); foreach ($nodes as $value) { $result[] = trim($value->textContent); } return $result; } ); }
[ "public", "function", "getAcceptedTypes", "(", ")", "{", "return", "$", "this", "->", "getCachedProperty", "(", "'accept'", ",", "function", "(", ")", "{", "$", "result", "=", "[", "]", ";", "/** @var \\DOMNodeList $nodes */", "// No REQUIRED — no exception.", "$", "nodes", "=", "$", "this", "->", "query", "(", "'app:accept'", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "value", ")", "{", "$", "result", "[", "]", "=", "trim", "(", "$", "value", "->", "textContent", ")", ";", "}", "return", "$", "result", ";", "}", ")", ";", "}" ]
Return types of representations accepted by the Collection. @return string[] @since 1.0
[ "Return", "types", "of", "representations", "accepted", "by", "the", "Collection", "." ]
cfc9aab97cff7a822b720e1dd84ef16733183dbb
https://github.com/mekras/atompub/blob/cfc9aab97cff7a822b720e1dd84ef16733183dbb/src/Element/Collection.php#L56-L72
21,870
mekras/atompub
src/Element/Collection.php
Collection.setAcceptedTypes
public function setAcceptedTypes(array $types) { /** @var \DOMNodeList $nodes */ // No REQUIRED — no exception. $nodes = $this->query('app:accept'); foreach ($nodes as $node) { $this->getDomElement()->removeChild($node); } foreach ($types as $type) { $element = $this->getDomElement()->ownerDocument ->createElementNS($this->ns(), 'accept', $type); $this->getDomElement()->appendChild($element); } $this->setCachedProperty('accept', $types); }
php
public function setAcceptedTypes(array $types) { /** @var \DOMNodeList $nodes */ // No REQUIRED — no exception. $nodes = $this->query('app:accept'); foreach ($nodes as $node) { $this->getDomElement()->removeChild($node); } foreach ($types as $type) { $element = $this->getDomElement()->ownerDocument ->createElementNS($this->ns(), 'accept', $type); $this->getDomElement()->appendChild($element); } $this->setCachedProperty('accept', $types); }
[ "public", "function", "setAcceptedTypes", "(", "array", "$", "types", ")", "{", "/** @var \\DOMNodeList $nodes */", "// No REQUIRED — no exception.", "$", "nodes", "=", "$", "this", "->", "query", "(", "'app:accept'", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "this", "->", "getDomElement", "(", ")", "->", "removeChild", "(", "$", "node", ")", ";", "}", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "element", "=", "$", "this", "->", "getDomElement", "(", ")", "->", "ownerDocument", "->", "createElementNS", "(", "$", "this", "->", "ns", "(", ")", ",", "'accept'", ",", "$", "type", ")", ";", "$", "this", "->", "getDomElement", "(", ")", "->", "appendChild", "(", "$", "element", ")", ";", "}", "$", "this", "->", "setCachedProperty", "(", "'accept'", ",", "$", "types", ")", ";", "}" ]
Set types of representations accepted by the Collection. @param string[] $types @since 1.0
[ "Set", "types", "of", "representations", "accepted", "by", "the", "Collection", "." ]
cfc9aab97cff7a822b720e1dd84ef16733183dbb
https://github.com/mekras/atompub/blob/cfc9aab97cff7a822b720e1dd84ef16733183dbb/src/Element/Collection.php#L81-L95
21,871
WellCommerce/AppBundle
Controller/RedirectingController.php
RedirectingController.removeTrailingSlashAction
public function removeTrailingSlashAction(Request $request) { $pathInfo = $request->getPathInfo(); $requestUri = $request->getRequestUri(); $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri); return $this->redirect($url, 301); }
php
public function removeTrailingSlashAction(Request $request) { $pathInfo = $request->getPathInfo(); $requestUri = $request->getRequestUri(); $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri); return $this->redirect($url, 301); }
[ "public", "function", "removeTrailingSlashAction", "(", "Request", "$", "request", ")", "{", "$", "pathInfo", "=", "$", "request", "->", "getPathInfo", "(", ")", ";", "$", "requestUri", "=", "$", "request", "->", "getRequestUri", "(", ")", ";", "$", "url", "=", "str_replace", "(", "$", "pathInfo", ",", "rtrim", "(", "$", "pathInfo", ",", "' /'", ")", ",", "$", "requestUri", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "url", ",", "301", ")", ";", "}" ]
Action used to remove trailing slash in url @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse
[ "Action", "used", "to", "remove", "trailing", "slash", "in", "url" ]
2add687d1c898dd0b24afd611d896e3811a0eac3
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Controller/RedirectingController.php#L32-L40
21,872
antaresproject/notifications
src/Http/Presenters/IndexPresenter.php
IndexPresenter.edit
public function edit($eloquent, $locale) { $this->breadcrumb->onEdit($eloquent); $form = $this->getForm($eloquent); return $this->view('edit', compact('form')); }
php
public function edit($eloquent, $locale) { $this->breadcrumb->onEdit($eloquent); $form = $this->getForm($eloquent); return $this->view('edit', compact('form')); }
[ "public", "function", "edit", "(", "$", "eloquent", ",", "$", "locale", ")", "{", "$", "this", "->", "breadcrumb", "->", "onEdit", "(", "$", "eloquent", ")", ";", "$", "form", "=", "$", "this", "->", "getForm", "(", "$", "eloquent", ")", ";", "return", "$", "this", "->", "view", "(", "'edit'", ",", "compact", "(", "'form'", ")", ")", ";", "}" ]
shows form edit job @param Model $eloquent @param String $locale @return View
[ "shows", "form", "edit", "job" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Presenters/IndexPresenter.php#L82-L87
21,873
antaresproject/notifications
src/Http/Presenters/IndexPresenter.php
IndexPresenter.getForm
public function getForm($eloquent, $type = null) { $classname = $eloquent->classname; $model = $eloquent->contents->first(); $configuration = [ 'content' => $model !== null ? $model->content : null, 'title' => $model !== null ? $model->title : '', 'type' => $eloquent->exists ? $eloquent->type->name : '', 'form_name' => $eloquent->name ]; $notification = app($classname ?: Notification::class); $fluent = new Fluent(array_merge($configuration, array_except($eloquent->toArray(), ['type']))); if (!is_null($fluent->type) && $type) { $fluent->type = $type; } return $this->form($fluent, $notification); }
php
public function getForm($eloquent, $type = null) { $classname = $eloquent->classname; $model = $eloquent->contents->first(); $configuration = [ 'content' => $model !== null ? $model->content : null, 'title' => $model !== null ? $model->title : '', 'type' => $eloquent->exists ? $eloquent->type->name : '', 'form_name' => $eloquent->name ]; $notification = app($classname ?: Notification::class); $fluent = new Fluent(array_merge($configuration, array_except($eloquent->toArray(), ['type']))); if (!is_null($fluent->type) && $type) { $fluent->type = $type; } return $this->form($fluent, $notification); }
[ "public", "function", "getForm", "(", "$", "eloquent", ",", "$", "type", "=", "null", ")", "{", "$", "classname", "=", "$", "eloquent", "->", "classname", ";", "$", "model", "=", "$", "eloquent", "->", "contents", "->", "first", "(", ")", ";", "$", "configuration", "=", "[", "'content'", "=>", "$", "model", "!==", "null", "?", "$", "model", "->", "content", ":", "null", ",", "'title'", "=>", "$", "model", "!==", "null", "?", "$", "model", "->", "title", ":", "''", ",", "'type'", "=>", "$", "eloquent", "->", "exists", "?", "$", "eloquent", "->", "type", "->", "name", ":", "''", ",", "'form_name'", "=>", "$", "eloquent", "->", "name", "]", ";", "$", "notification", "=", "app", "(", "$", "classname", "?", ":", "Notification", "::", "class", ")", ";", "$", "fluent", "=", "new", "Fluent", "(", "array_merge", "(", "$", "configuration", ",", "array_except", "(", "$", "eloquent", "->", "toArray", "(", ")", ",", "[", "'type'", "]", ")", ")", ")", ";", "if", "(", "!", "is_null", "(", "$", "fluent", "->", "type", ")", "&&", "$", "type", ")", "{", "$", "fluent", "->", "type", "=", "$", "type", ";", "}", "return", "$", "this", "->", "form", "(", "$", "fluent", ",", "$", "notification", ")", ";", "}" ]
gets form instance @param Model $eloquent @return FormBuilder @throws Exception
[ "gets", "form", "instance" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Presenters/IndexPresenter.php#L96-L114
21,874
antaresproject/notifications
src/Http/Presenters/IndexPresenter.php
IndexPresenter.form
protected function form(Fluent $fluent, $notification = null) { publish('notifications', 'scripts.resources-default'); Event::fire('antares.forms', 'notification.' . $fluent->form_name); $fluent->type = $fluent->type === '' ? 'email' : $fluent->type; return new Form($notification, $fluent); }
php
protected function form(Fluent $fluent, $notification = null) { publish('notifications', 'scripts.resources-default'); Event::fire('antares.forms', 'notification.' . $fluent->form_name); $fluent->type = $fluent->type === '' ? 'email' : $fluent->type; return new Form($notification, $fluent); }
[ "protected", "function", "form", "(", "Fluent", "$", "fluent", ",", "$", "notification", "=", "null", ")", "{", "publish", "(", "'notifications'", ",", "'scripts.resources-default'", ")", ";", "Event", "::", "fire", "(", "'antares.forms'", ",", "'notification.'", ".", "$", "fluent", "->", "form_name", ")", ";", "$", "fluent", "->", "type", "=", "$", "fluent", "->", "type", "===", "''", "?", "'email'", ":", "$", "fluent", "->", "type", ";", "return", "new", "Form", "(", "$", "notification", ",", "$", "fluent", ")", ";", "}" ]
gets instance of command form @param Fluent $fluent @param mixed $notification @return FormBuilder
[ "gets", "instance", "of", "command", "form" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Presenters/IndexPresenter.php#L123-L130
21,875
antaresproject/notifications
src/Http/Presenters/IndexPresenter.php
IndexPresenter.create
public function create(Model $model, $type = null) { $this->breadcrumb->onCreate($type); $form = $this->getForm($model, $type)->onCreate(); return $this->view('create', ['form' => $form]); }
php
public function create(Model $model, $type = null) { $this->breadcrumb->onCreate($type); $form = $this->getForm($model, $type)->onCreate(); return $this->view('create', ['form' => $form]); }
[ "public", "function", "create", "(", "Model", "$", "model", ",", "$", "type", "=", "null", ")", "{", "$", "this", "->", "breadcrumb", "->", "onCreate", "(", "$", "type", ")", ";", "$", "form", "=", "$", "this", "->", "getForm", "(", "$", "model", ",", "$", "type", ")", "->", "onCreate", "(", ")", ";", "return", "$", "this", "->", "view", "(", "'create'", ",", "[", "'form'", "=>", "$", "form", "]", ")", ";", "}" ]
create new notification notification @param Model $model @param String $type @return View
[ "create", "new", "notification", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Presenters/IndexPresenter.php#L150-L156
21,876
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.edit
public function edit($id, $locale, IndexListener $listener) { app('antares.asset')->container('antares/foundation::application')->add('ckeditor', '/packages/ckeditor/ckeditor.js', ['webpack_forms_basic']); $model = $this->repository->findByLocale($id, $locale); if (is_null($model)) { throw new ModelNotFoundException('Model not found'); } return $this->presenter->edit($model, $locale); }
php
public function edit($id, $locale, IndexListener $listener) { app('antares.asset')->container('antares/foundation::application')->add('ckeditor', '/packages/ckeditor/ckeditor.js', ['webpack_forms_basic']); $model = $this->repository->findByLocale($id, $locale); if (is_null($model)) { throw new ModelNotFoundException('Model not found'); } return $this->presenter->edit($model, $locale); }
[ "public", "function", "edit", "(", "$", "id", ",", "$", "locale", ",", "IndexListener", "$", "listener", ")", "{", "app", "(", "'antares.asset'", ")", "->", "container", "(", "'antares/foundation::application'", ")", "->", "add", "(", "'ckeditor'", ",", "'/packages/ckeditor/ckeditor.js'", ",", "[", "'webpack_forms_basic'", "]", ")", ";", "$", "model", "=", "$", "this", "->", "repository", "->", "findByLocale", "(", "$", "id", ",", "$", "locale", ")", ";", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "throw", "new", "ModelNotFoundException", "(", "'Model not found'", ")", ";", "}", "return", "$", "this", "->", "presenter", "->", "edit", "(", "$", "model", ",", "$", "locale", ")", ";", "}" ]
shows edit form @param mixed $id @param String $locale @param IndexListener $listener @return View
[ "shows", "edit", "form" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L89-L97
21,877
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.update
public function update(IndexListener $listener) { $id = Input::get('id'); $model = $this->repository->find($id); $form = $this->presenter->getForm($model); if (!$form->isValid()) { return $listener->updateValidationFailed($id, $form->getMessageBag()); } try { $this->repository->updateNotification($id, Input::all()); } catch (Exception $ex) { return $listener->updateFailed(); } return $listener->updateSuccess(); }
php
public function update(IndexListener $listener) { $id = Input::get('id'); $model = $this->repository->find($id); $form = $this->presenter->getForm($model); if (!$form->isValid()) { return $listener->updateValidationFailed($id, $form->getMessageBag()); } try { $this->repository->updateNotification($id, Input::all()); } catch (Exception $ex) { return $listener->updateFailed(); } return $listener->updateSuccess(); }
[ "public", "function", "update", "(", "IndexListener", "$", "listener", ")", "{", "$", "id", "=", "Input", "::", "get", "(", "'id'", ")", ";", "$", "model", "=", "$", "this", "->", "repository", "->", "find", "(", "$", "id", ")", ";", "$", "form", "=", "$", "this", "->", "presenter", "->", "getForm", "(", "$", "model", ")", ";", "if", "(", "!", "$", "form", "->", "isValid", "(", ")", ")", "{", "return", "$", "listener", "->", "updateValidationFailed", "(", "$", "id", ",", "$", "form", "->", "getMessageBag", "(", ")", ")", ";", "}", "try", "{", "$", "this", "->", "repository", "->", "updateNotification", "(", "$", "id", ",", "Input", "::", "all", "(", ")", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "listener", "->", "updateFailed", "(", ")", ";", "}", "return", "$", "listener", "->", "updateSuccess", "(", ")", ";", "}" ]
updates notification notification @param IndexListener $listener @return RedirectResponse
[ "updates", "notification", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L105-L120
21,878
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.preview
public function preview() { $inputs = Input::all(); $content = str_replace("&#39;", '"', $inputs['content']); $content = $this->variablesAdapter->get($content); if( isset($inputs['subject']) ) { $subject = str_replace("&#39;", '"', $inputs['subject']); $subject = $this->variablesAdapter->get($subject); array_set($inputs, 'subject', $subject); } preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); $view = str_replace($matches[0], $matches[1], $content); if (array_get($inputs, 'type') === 'email') { event('antares.notifier.before_send_email', [&$view]); } $brandTemplate = BrandOptions::query()->where('brand_id', brand_id())->first(); $header = str_replace('</head>', '<style>' . $brandTemplate->styles . '</style></head>', $brandTemplate->header); $html = preg_replace("/<body[^>]*>(.*?)<\/body>/is", '<body>' . $view . '</body>', $header . $brandTemplate->footer); array_set($inputs, 'content', $html); return $this->presenter->preview($inputs); }
php
public function preview() { $inputs = Input::all(); $content = str_replace("&#39;", '"', $inputs['content']); $content = $this->variablesAdapter->get($content); if( isset($inputs['subject']) ) { $subject = str_replace("&#39;", '"', $inputs['subject']); $subject = $this->variablesAdapter->get($subject); array_set($inputs, 'subject', $subject); } preg_match_all('/\[\[(.*?)\]\]/', $content, $matches); $view = str_replace($matches[0], $matches[1], $content); if (array_get($inputs, 'type') === 'email') { event('antares.notifier.before_send_email', [&$view]); } $brandTemplate = BrandOptions::query()->where('brand_id', brand_id())->first(); $header = str_replace('</head>', '<style>' . $brandTemplate->styles . '</style></head>', $brandTemplate->header); $html = preg_replace("/<body[^>]*>(.*?)<\/body>/is", '<body>' . $view . '</body>', $header . $brandTemplate->footer); array_set($inputs, 'content', $html); return $this->presenter->preview($inputs); }
[ "public", "function", "preview", "(", ")", "{", "$", "inputs", "=", "Input", "::", "all", "(", ")", ";", "$", "content", "=", "str_replace", "(", "\"&#39;\"", ",", "'\"'", ",", "$", "inputs", "[", "'content'", "]", ")", ";", "$", "content", "=", "$", "this", "->", "variablesAdapter", "->", "get", "(", "$", "content", ")", ";", "if", "(", "isset", "(", "$", "inputs", "[", "'subject'", "]", ")", ")", "{", "$", "subject", "=", "str_replace", "(", "\"&#39;\"", ",", "'\"'", ",", "$", "inputs", "[", "'subject'", "]", ")", ";", "$", "subject", "=", "$", "this", "->", "variablesAdapter", "->", "get", "(", "$", "subject", ")", ";", "array_set", "(", "$", "inputs", ",", "'subject'", ",", "$", "subject", ")", ";", "}", "preg_match_all", "(", "'/\\[\\[(.*?)\\]\\]/'", ",", "$", "content", ",", "$", "matches", ")", ";", "$", "view", "=", "str_replace", "(", "$", "matches", "[", "0", "]", ",", "$", "matches", "[", "1", "]", ",", "$", "content", ")", ";", "if", "(", "array_get", "(", "$", "inputs", ",", "'type'", ")", "===", "'email'", ")", "{", "event", "(", "'antares.notifier.before_send_email'", ",", "[", "&", "$", "view", "]", ")", ";", "}", "$", "brandTemplate", "=", "BrandOptions", "::", "query", "(", ")", "->", "where", "(", "'brand_id'", ",", "brand_id", "(", ")", ")", "->", "first", "(", ")", ";", "$", "header", "=", "str_replace", "(", "'</head>'", ",", "'<style>'", ".", "$", "brandTemplate", "->", "styles", ".", "'</style></head>'", ",", "$", "brandTemplate", "->", "header", ")", ";", "$", "html", "=", "preg_replace", "(", "\"/<body[^>]*>(.*?)<\\/body>/is\"", ",", "'<body>'", ".", "$", "view", ".", "'</body>'", ",", "$", "header", ".", "$", "brandTemplate", "->", "footer", ")", ";", "array_set", "(", "$", "inputs", ",", "'content'", ",", "$", "html", ")", ";", "return", "$", "this", "->", "presenter", "->", "preview", "(", "$", "inputs", ")", ";", "}" ]
preview notification notification @return View
[ "preview", "notification", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L180-L207
21,879
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.changeStatus
public function changeStatus(IndexListener $listener, $id) { $model = $this->repository->find($id); if (is_null($model)) { return $listener->changeStatusFailed(); } $model->active = $model->active ? 0 : 1; $model->save(); return $listener->changeStatusSuccess(); }
php
public function changeStatus(IndexListener $listener, $id) { $model = $this->repository->find($id); if (is_null($model)) { return $listener->changeStatusFailed(); } $model->active = $model->active ? 0 : 1; $model->save(); return $listener->changeStatusSuccess(); }
[ "public", "function", "changeStatus", "(", "IndexListener", "$", "listener", ",", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "repository", "->", "find", "(", "$", "id", ")", ";", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "return", "$", "listener", "->", "changeStatusFailed", "(", ")", ";", "}", "$", "model", "->", "active", "=", "$", "model", "->", "active", "?", "0", ":", "1", ";", "$", "model", "->", "save", "(", ")", ";", "return", "$", "listener", "->", "changeStatusSuccess", "(", ")", ";", "}" ]
change notification notification status @param IndexListener $listener @param mixed $id @return RedirectResponse
[ "change", "notification", "notification", "status" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L216-L225
21,880
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.create
public function create($type = null) { app('antares.asset')->container('antares/foundation::application')->add('ckeditor', '/packages/ckeditor/ckeditor.js', ['webpack_forms_basic']); return $this->presenter->create($this->repository->makeModel()->getModel(), $type); }
php
public function create($type = null) { app('antares.asset')->container('antares/foundation::application')->add('ckeditor', '/packages/ckeditor/ckeditor.js', ['webpack_forms_basic']); return $this->presenter->create($this->repository->makeModel()->getModel(), $type); }
[ "public", "function", "create", "(", "$", "type", "=", "null", ")", "{", "app", "(", "'antares.asset'", ")", "->", "container", "(", "'antares/foundation::application'", ")", "->", "add", "(", "'ckeditor'", ",", "'/packages/ckeditor/ckeditor.js'", ",", "[", "'webpack_forms_basic'", "]", ")", ";", "return", "$", "this", "->", "presenter", "->", "create", "(", "$", "this", "->", "repository", "->", "makeModel", "(", ")", "->", "getModel", "(", ")", ",", "$", "type", ")", ";", "}" ]
Create notification notification form @param String $type @return View
[ "Create", "notification", "notification", "form" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L233-L237
21,881
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.store
public function store(IndexListener $listener) { $model = $this->repository->makeModel()->getModel(); $form = $this->presenter->getForm($model)->onCreate(); if (!$form->isValid()) { return $listener->storeValidationFailed($form->getMessageBag()); } try { $this->repository->store(Input::all()); } catch (Exception $ex) { return $listener->createFailed(); } return $listener->createSuccess(); }
php
public function store(IndexListener $listener) { $model = $this->repository->makeModel()->getModel(); $form = $this->presenter->getForm($model)->onCreate(); if (!$form->isValid()) { return $listener->storeValidationFailed($form->getMessageBag()); } try { $this->repository->store(Input::all()); } catch (Exception $ex) { return $listener->createFailed(); } return $listener->createSuccess(); }
[ "public", "function", "store", "(", "IndexListener", "$", "listener", ")", "{", "$", "model", "=", "$", "this", "->", "repository", "->", "makeModel", "(", ")", "->", "getModel", "(", ")", ";", "$", "form", "=", "$", "this", "->", "presenter", "->", "getForm", "(", "$", "model", ")", "->", "onCreate", "(", ")", ";", "if", "(", "!", "$", "form", "->", "isValid", "(", ")", ")", "{", "return", "$", "listener", "->", "storeValidationFailed", "(", "$", "form", "->", "getMessageBag", "(", ")", ")", ";", "}", "try", "{", "$", "this", "->", "repository", "->", "store", "(", "Input", "::", "all", "(", ")", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "listener", "->", "createFailed", "(", ")", ";", "}", "return", "$", "listener", "->", "createSuccess", "(", ")", ";", "}" ]
store new notification notification @param IndexListener $listener @return RedirectResponse
[ "store", "new", "notification", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L245-L258
21,882
antaresproject/notifications
src/Processor/IndexProcessor.php
IndexProcessor.delete
public function delete($id, IndexListener $listener) { try { $model = $this->repository->makeModel()->findOrFail($id); $model->delete(); return $listener->deleteSuccess(); } catch (Exception $ex) { return $listener->deleteFailed(); } }
php
public function delete($id, IndexListener $listener) { try { $model = $this->repository->makeModel()->findOrFail($id); $model->delete(); return $listener->deleteSuccess(); } catch (Exception $ex) { return $listener->deleteFailed(); } }
[ "public", "function", "delete", "(", "$", "id", ",", "IndexListener", "$", "listener", ")", "{", "try", "{", "$", "model", "=", "$", "this", "->", "repository", "->", "makeModel", "(", ")", "->", "findOrFail", "(", "$", "id", ")", ";", "$", "model", "->", "delete", "(", ")", ";", "return", "$", "listener", "->", "deleteSuccess", "(", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "listener", "->", "deleteFailed", "(", ")", ";", "}", "}" ]
deletes custom notification @param mixed $id @param IndexListener $listener @return RedirectResponse
[ "deletes", "custom", "notification" ]
60de743477b7e9cbb51de66da5fd9461adc9dd8a
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Processor/IndexProcessor.php#L267-L276
21,883
i-lateral/silverstripe-modeladminplus
src/ModelAdminPlus.php
ModelAdminPlus.getExportFields
public function getExportFields() { $export_fields = Config::inst()->get( $this->modelClass, self::EXPORT_FIELDS ); if (isset($export_fields) && is_array($export_fields)) { $fields = $export_fields; } else { $fields = parent::getExportFields(); } $this->extend("updateExportFields", $fields); return $fields; }
php
public function getExportFields() { $export_fields = Config::inst()->get( $this->modelClass, self::EXPORT_FIELDS ); if (isset($export_fields) && is_array($export_fields)) { $fields = $export_fields; } else { $fields = parent::getExportFields(); } $this->extend("updateExportFields", $fields); return $fields; }
[ "public", "function", "getExportFields", "(", ")", "{", "$", "export_fields", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "$", "this", "->", "modelClass", ",", "self", "::", "EXPORT_FIELDS", ")", ";", "if", "(", "isset", "(", "$", "export_fields", ")", "&&", "is_array", "(", "$", "export_fields", ")", ")", "{", "$", "fields", "=", "$", "export_fields", ";", "}", "else", "{", "$", "fields", "=", "parent", "::", "getExportFields", "(", ")", ";", "}", "$", "this", "->", "extend", "(", "\"updateExportFields\"", ",", "$", "fields", ")", ";", "return", "$", "fields", ";", "}" ]
Get the default export fields for the current model. First this checks if there is an `export_fields` config variable set on the model class, if not, it reverts to the default behaviour. @return array
[ "Get", "the", "default", "export", "fields", "for", "the", "current", "model", "." ]
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/ModelAdminPlus.php#L118-L134
21,884
i-lateral/silverstripe-modeladminplus
src/ModelAdminPlus.php
ModelAdminPlus.getSearchSessionName
public function getSearchSessionName() { $curr = $this->sanitiseClassName(self::class); $model = $this->sanitiseClassName($this->modelClass); return $curr . "." . $model; }
php
public function getSearchSessionName() { $curr = $this->sanitiseClassName(self::class); $model = $this->sanitiseClassName($this->modelClass); return $curr . "." . $model; }
[ "public", "function", "getSearchSessionName", "(", ")", "{", "$", "curr", "=", "$", "this", "->", "sanitiseClassName", "(", "self", "::", "class", ")", ";", "$", "model", "=", "$", "this", "->", "sanitiseClassName", "(", "$", "this", "->", "modelClass", ")", ";", "return", "$", "curr", ".", "\".\"", ".", "$", "model", ";", "}" ]
Get the name of the session to be useed by this model admin's search form. @return string
[ "Get", "the", "name", "of", "the", "session", "to", "be", "useed", "by", "this", "model", "admin", "s", "search", "form", "." ]
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/ModelAdminPlus.php#L142-L147
21,885
i-lateral/silverstripe-modeladminplus
src/ModelAdminPlus.php
ModelAdminPlus.getEditForm
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $grid_field = $form ->Fields() ->fieldByName($this->sanitiseClassName($this->modelClass)); // Add bulk editing to gridfield $manager = new BulkManager(); $manager->removeBulkAction(UnlinkHandler::class); $config = $grid_field->getConfig(); $config ->removeComponentsByType(GridFieldPaginator::class) ->addComponent($manager) ->addComponent(new GridFieldConfigurablePaginator()); // Switch to custom filter header $config ->removeComponentsByType(SSGridFieldFilterHeader::class) ->addComponent(new GridFieldFilterHeader( false, function ($context) { $this->extend('updateSearchContext', $context); }, function ($form) { $this->extend('updateSearchForm', $form); } )); if (!$this->showSearchForm || (is_array($this->showSearchForm) && !in_array($this->modelClass, $this->showSearchForm)) ) { $config->removeComponentsByType(GridFieldFilterHeader::class); } if ($this->config()->auto_convert_dates) { GridFieldDateFinder::create($grid_field)->convertDateFields(); } return $form; }
php
public function getEditForm($id = null, $fields = null) { $form = parent::getEditForm($id, $fields); $grid_field = $form ->Fields() ->fieldByName($this->sanitiseClassName($this->modelClass)); // Add bulk editing to gridfield $manager = new BulkManager(); $manager->removeBulkAction(UnlinkHandler::class); $config = $grid_field->getConfig(); $config ->removeComponentsByType(GridFieldPaginator::class) ->addComponent($manager) ->addComponent(new GridFieldConfigurablePaginator()); // Switch to custom filter header $config ->removeComponentsByType(SSGridFieldFilterHeader::class) ->addComponent(new GridFieldFilterHeader( false, function ($context) { $this->extend('updateSearchContext', $context); }, function ($form) { $this->extend('updateSearchForm', $form); } )); if (!$this->showSearchForm || (is_array($this->showSearchForm) && !in_array($this->modelClass, $this->showSearchForm)) ) { $config->removeComponentsByType(GridFieldFilterHeader::class); } if ($this->config()->auto_convert_dates) { GridFieldDateFinder::create($grid_field)->convertDateFields(); } return $form; }
[ "public", "function", "getEditForm", "(", "$", "id", "=", "null", ",", "$", "fields", "=", "null", ")", "{", "$", "form", "=", "parent", "::", "getEditForm", "(", "$", "id", ",", "$", "fields", ")", ";", "$", "grid_field", "=", "$", "form", "->", "Fields", "(", ")", "->", "fieldByName", "(", "$", "this", "->", "sanitiseClassName", "(", "$", "this", "->", "modelClass", ")", ")", ";", "// Add bulk editing to gridfield", "$", "manager", "=", "new", "BulkManager", "(", ")", ";", "$", "manager", "->", "removeBulkAction", "(", "UnlinkHandler", "::", "class", ")", ";", "$", "config", "=", "$", "grid_field", "->", "getConfig", "(", ")", ";", "$", "config", "->", "removeComponentsByType", "(", "GridFieldPaginator", "::", "class", ")", "->", "addComponent", "(", "$", "manager", ")", "->", "addComponent", "(", "new", "GridFieldConfigurablePaginator", "(", ")", ")", ";", "// Switch to custom filter header", "$", "config", "->", "removeComponentsByType", "(", "SSGridFieldFilterHeader", "::", "class", ")", "->", "addComponent", "(", "new", "GridFieldFilterHeader", "(", "false", ",", "function", "(", "$", "context", ")", "{", "$", "this", "->", "extend", "(", "'updateSearchContext'", ",", "$", "context", ")", ";", "}", ",", "function", "(", "$", "form", ")", "{", "$", "this", "->", "extend", "(", "'updateSearchForm'", ",", "$", "form", ")", ";", "}", ")", ")", ";", "if", "(", "!", "$", "this", "->", "showSearchForm", "||", "(", "is_array", "(", "$", "this", "->", "showSearchForm", ")", "&&", "!", "in_array", "(", "$", "this", "->", "modelClass", ",", "$", "this", "->", "showSearchForm", ")", ")", ")", "{", "$", "config", "->", "removeComponentsByType", "(", "GridFieldFilterHeader", "::", "class", ")", ";", "}", "if", "(", "$", "this", "->", "config", "(", ")", "->", "auto_convert_dates", ")", "{", "GridFieldDateFinder", "::", "create", "(", "$", "grid_field", ")", "->", "convertDateFields", "(", ")", ";", "}", "return", "$", "form", ";", "}" ]
Add bulk editor to Edit Form @param int|null $id @param FieldList $fields @return Form A Form object
[ "Add", "bulk", "editor", "to", "Edit", "Form" ]
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/ModelAdminPlus.php#L210-L252
21,886
surebert/surebert-framework
src/sb/Cache/Hash.php
Hash.store
public function store($key, $data, $lifetime = 0) { if ($lifetime != 0) { $lifetime = \time() + $lifetime; } $data = array($lifetime, $data); $this->hash[$key] = $data; if ($key != $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return true; }
php
public function store($key, $data, $lifetime = 0) { if ($lifetime != 0) { $lifetime = \time() + $lifetime; } $data = array($lifetime, $data); $this->hash[$key] = $data; if ($key != $this->catalog_key) { $this->catalogKeyAdd($key, $lifetime); } return true; }
[ "public", "function", "store", "(", "$", "key", ",", "$", "data", ",", "$", "lifetime", "=", "0", ")", "{", "if", "(", "$", "lifetime", "!=", "0", ")", "{", "$", "lifetime", "=", "\\", "time", "(", ")", "+", "$", "lifetime", ";", "}", "$", "data", "=", "array", "(", "$", "lifetime", ",", "$", "data", ")", ";", "$", "this", "->", "hash", "[", "$", "key", "]", "=", "$", "data", ";", "if", "(", "$", "key", "!=", "$", "this", "->", "catalog_key", ")", "{", "$", "this", "->", "catalogKeyAdd", "(", "$", "key", ",", "$", "lifetime", ")", ";", "}", "return", "true", ";", "}" ]
Store the cache data in memcache
[ "Store", "the", "cache", "data", "in", "memcache" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Hash.php#L48-L64
21,887
surebert/surebert-framework
src/sb/Cache/Hash.php
Hash.fetch
public function fetch($key) { if (!\array_key_exists($key, $this->hash)) { return false; } $data = $this->hash[$key]; //check to see if it expired if ($data && ($data[0] == 0 || \time() <= $data[0])) { return $data[1]; } else { $this->delete($key); return false; } }
php
public function fetch($key) { if (!\array_key_exists($key, $this->hash)) { return false; } $data = $this->hash[$key]; //check to see if it expired if ($data && ($data[0] == 0 || \time() <= $data[0])) { return $data[1]; } else { $this->delete($key); return false; } }
[ "public", "function", "fetch", "(", "$", "key", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "hash", ")", ")", "{", "return", "false", ";", "}", "$", "data", "=", "$", "this", "->", "hash", "[", "$", "key", "]", ";", "//check to see if it expired", "if", "(", "$", "data", "&&", "(", "$", "data", "[", "0", "]", "==", "0", "||", "\\", "time", "(", ")", "<=", "$", "data", "[", "0", "]", ")", ")", "{", "return", "$", "data", "[", "1", "]", ";", "}", "else", "{", "$", "this", "->", "delete", "(", "$", "key", ")", ";", "return", "false", ";", "}", "}" ]
Fetches the cache from memcache
[ "Fetches", "the", "cache", "from", "memcache" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Hash.php#L69-L85
21,888
surebert/surebert-framework
src/sb/Cache/Hash.php
Hash.delete
public function delete($key) { $deleted = false; $catalog = \array_keys($this->getKeys()); foreach ($catalog as $k) { if ($k == $key) { unset($this->hash[$key]); if ($delete) { $this->catalogKeyDelete($k); $deleted = true; } } } return $deleted; }
php
public function delete($key) { $deleted = false; $catalog = \array_keys($this->getKeys()); foreach ($catalog as $k) { if ($k == $key) { unset($this->hash[$key]); if ($delete) { $this->catalogKeyDelete($k); $deleted = true; } } } return $deleted; }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "$", "deleted", "=", "false", ";", "$", "catalog", "=", "\\", "array_keys", "(", "$", "this", "->", "getKeys", "(", ")", ")", ";", "foreach", "(", "$", "catalog", "as", "$", "k", ")", "{", "if", "(", "$", "k", "==", "$", "key", ")", "{", "unset", "(", "$", "this", "->", "hash", "[", "$", "key", "]", ")", ";", "if", "(", "$", "delete", ")", "{", "$", "this", "->", "catalogKeyDelete", "(", "$", "k", ")", ";", "$", "deleted", "=", "true", ";", "}", "}", "}", "return", "$", "deleted", ";", "}" ]
Deletes cache data
[ "Deletes", "cache", "data" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Cache/Hash.php#L90-L108
21,889
VincentChalnot/SidusDataGridBundle
Model/Column.php
Column.renderValue
public function renderValue($object, array $options = []): string { $options = array_merge( ['column' => $this, 'object' => $object], $this->getFormattingOptions(), $options ); $accessor = PropertyAccess::createPropertyAccessor(); try { $value = $accessor->getValue($object, $this->getPropertyPath()); } catch (UnexpectedTypeException $e) { return ''; } return $this->getValueRenderer()->renderValue($value, $options); }
php
public function renderValue($object, array $options = []): string { $options = array_merge( ['column' => $this, 'object' => $object], $this->getFormattingOptions(), $options ); $accessor = PropertyAccess::createPropertyAccessor(); try { $value = $accessor->getValue($object, $this->getPropertyPath()); } catch (UnexpectedTypeException $e) { return ''; } return $this->getValueRenderer()->renderValue($value, $options); }
[ "public", "function", "renderValue", "(", "$", "object", ",", "array", "$", "options", "=", "[", "]", ")", ":", "string", "{", "$", "options", "=", "array_merge", "(", "[", "'column'", "=>", "$", "this", ",", "'object'", "=>", "$", "object", "]", ",", "$", "this", "->", "getFormattingOptions", "(", ")", ",", "$", "options", ")", ";", "$", "accessor", "=", "PropertyAccess", "::", "createPropertyAccessor", "(", ")", ";", "try", "{", "$", "value", "=", "$", "accessor", "->", "getValue", "(", "$", "object", ",", "$", "this", "->", "getPropertyPath", "(", ")", ")", ";", "}", "catch", "(", "UnexpectedTypeException", "$", "e", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "getValueRenderer", "(", ")", "->", "renderValue", "(", "$", "value", ",", "$", "options", ")", ";", "}" ]
Render column for a given result @param mixed $object @param array $options @return string
[ "Render", "column", "for", "a", "given", "result" ]
aa929113e2208ed335f514d2891affaf7fddf3f6
https://github.com/VincentChalnot/SidusDataGridBundle/blob/aa929113e2208ed335f514d2891affaf7fddf3f6/Model/Column.php#L249-L264
21,890
surebert/surebert-framework
src/sb/Logger/FileSystem.php
FileSystem.getLogPath
protected function getLogPath($log) { $dir = $this->log_root.'/'.$log.'/'; if(!is_dir($dir)){ mkdir($dir, 0777, true); } return $dir; }
php
protected function getLogPath($log) { $dir = $this->log_root.'/'.$log.'/'; if(!is_dir($dir)){ mkdir($dir, 0777, true); } return $dir; }
[ "protected", "function", "getLogPath", "(", "$", "log", ")", "{", "$", "dir", "=", "$", "this", "->", "log_root", ".", "'/'", ".", "$", "log", ".", "'/'", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Grabs the log path based on the type of log @param $log Sting the log type. Should be in the $enabled_logs array @return string The path to the log directory to be used
[ "Grabs", "the", "log", "path", "based", "on", "the", "type", "of", "log" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/FileSystem.php#L40-L50
21,891
surebert/surebert-framework
src/sb/Logger/FileSystem.php
FileSystem.write
protected function write($data, $log_type) { return file_put_contents($this->getLogPath($log_type) .date('Y_m_d').'.log', "\n\n".\date('Y/m/d H:i:s') ."\t".$this->agent_str ."\n".$data, \FILE_APPEND); }
php
protected function write($data, $log_type) { return file_put_contents($this->getLogPath($log_type) .date('Y_m_d').'.log', "\n\n".\date('Y/m/d H:i:s') ."\t".$this->agent_str ."\n".$data, \FILE_APPEND); }
[ "protected", "function", "write", "(", "$", "data", ",", "$", "log_type", ")", "{", "return", "file_put_contents", "(", "$", "this", "->", "getLogPath", "(", "$", "log_type", ")", ".", "date", "(", "'Y_m_d'", ")", ".", "'.log'", ",", "\"\\n\\n\"", ".", "\\", "date", "(", "'Y/m/d H:i:s'", ")", ".", "\"\\t\"", ".", "$", "this", "->", "agent_str", ".", "\"\\n\"", ".", "$", "data", ",", "\\", "FILE_APPEND", ")", ";", "}" ]
Writes the data to file @param string $data The data to be written @param string $log_type The log_type being written to @return boolean If the data was written or not
[ "Writes", "the", "data", "to", "file" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Logger/FileSystem.php#L58-L64
21,892
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.remove
function remove($header) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($header); foreach ($this->_headers as $idx => $header) { if ($header->getName() == $name) unset($this->_headers[$idx]); } return $this; }
php
function remove($header) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($header); foreach ($this->_headers as $idx => $header) { if ($header->getName() == $name) unset($this->_headers[$idx]); } return $this; }
[ "function", "remove", "(", "$", "header", ")", "{", "$", "normalizer", "=", "new", "HeaderCaseNormalizer", "(", ")", ";", "$", "name", "=", "$", "normalizer", "->", "normalize", "(", "$", "header", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "idx", "=>", "$", "header", ")", "{", "if", "(", "$", "header", "->", "getName", "(", ")", "==", "$", "name", ")", "unset", "(", "$", "this", "->", "_headers", "[", "$", "idx", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a header by name @chainable
[ "Remove", "a", "header", "by", "name" ]
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L40-L51
21,893
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.value
function value($name, $default = false) { $values = $this->values($name); return count($values) ? $values[0] : $default; }
php
function value($name, $default = false) { $values = $this->values($name); return count($values) ? $values[0] : $default; }
[ "function", "value", "(", "$", "name", ",", "$", "default", "=", "false", ")", "{", "$", "values", "=", "$", "this", "->", "values", "(", "$", "name", ")", ";", "return", "count", "(", "$", "values", ")", "?", "$", "values", "[", "0", "]", ":", "$", "default", ";", "}" ]
Gets a single header value @return string
[ "Gets", "a", "single", "header", "value" ]
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L72-L76
21,894
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.values
function values($name) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($name); $values = array(); foreach ($this->_headers as $header) { if ($header->getName() == $name) { $values[] = $header->getValue(); } } return $values; }
php
function values($name) { $normalizer = new HeaderCaseNormalizer(); $name = $normalizer->normalize($name); $values = array(); foreach ($this->_headers as $header) { if ($header->getName() == $name) { $values[] = $header->getValue(); } } return $values; }
[ "function", "values", "(", "$", "name", ")", "{", "$", "normalizer", "=", "new", "HeaderCaseNormalizer", "(", ")", ";", "$", "name", "=", "$", "normalizer", "->", "normalize", "(", "$", "name", ")", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "header", ")", "{", "if", "(", "$", "header", "->", "getName", "(", ")", "==", "$", "name", ")", "{", "$", "values", "[", "]", "=", "$", "header", "->", "getValue", "(", ")", ";", "}", "}", "return", "$", "values", ";", "}" ]
Gets an array of the values for a header @return array
[ "Gets", "an", "array", "of", "the", "values", "for", "a", "header" ]
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L82-L95
21,895
99designs/ergo-http
src/HeaderCollection.php
HeaderCollection.toArray
function toArray($crlf = true) { $headers = array(); foreach ($this->_headers as $header) { $string = $header->__toString(); $headers[] = $crlf ? $string : rtrim($string); } return $headers; }
php
function toArray($crlf = true) { $headers = array(); foreach ($this->_headers as $header) { $string = $header->__toString(); $headers[] = $crlf ? $string : rtrim($string); } return $headers; }
[ "function", "toArray", "(", "$", "crlf", "=", "true", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "header", ")", "{", "$", "string", "=", "$", "header", "->", "__toString", "(", ")", ";", "$", "headers", "[", "]", "=", "$", "crlf", "?", "$", "string", ":", "rtrim", "(", "$", "string", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Returns an array of the string versions of headers @return array
[ "Returns", "an", "array", "of", "the", "string", "versions", "of", "headers" ]
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/HeaderCollection.php#L101-L111
21,896
brick/di
src/Container.php
Container.has
public function has(string $key) : bool { if (isset($this->items[$key])) { return true; } try { $class = new \ReflectionClass($key); } catch (\ReflectionException $e) { return false; } $classes = $this->reflectionTools->getClassHierarchy($class); foreach ($classes as $class) { if ($this->injectionPolicy->isClassInjected($class)) { $this->bind($key); // @todo allow to configure scope (singleton) with annotations return true; } } return false; }
php
public function has(string $key) : bool { if (isset($this->items[$key])) { return true; } try { $class = new \ReflectionClass($key); } catch (\ReflectionException $e) { return false; } $classes = $this->reflectionTools->getClassHierarchy($class); foreach ($classes as $class) { if ($this->injectionPolicy->isClassInjected($class)) { $this->bind($key); // @todo allow to configure scope (singleton) with annotations return true; } } return false; }
[ "public", "function", "has", "(", "string", "$", "key", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "this", "->", "items", "[", "$", "key", "]", ")", ")", "{", "return", "true", ";", "}", "try", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "key", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "return", "false", ";", "}", "$", "classes", "=", "$", "this", "->", "reflectionTools", "->", "getClassHierarchy", "(", "$", "class", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "$", "this", "->", "injectionPolicy", "->", "isClassInjected", "(", "$", "class", ")", ")", "{", "$", "this", "->", "bind", "(", "$", "key", ")", ";", "// @todo allow to configure scope (singleton) with annotations", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether the container has the given key. @param string $key The key, class or interface name. @return bool
[ "Returns", "whether", "the", "container", "has", "the", "given", "key", "." ]
6ced82ab3623b8f1470317d38cbd2de855e7aa3d
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L94-L117
21,897
brick/di
src/Container.php
Container.set
public function set(string $key, $value) : Container { $this->items[$key] = $value; return $this; }
php
public function set(string $key, $value) : Container { $this->items[$key] = $value; return $this; }
[ "public", "function", "set", "(", "string", "$", "key", ",", "$", "value", ")", ":", "Container", "{", "$", "this", "->", "items", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Sets a single value. The value will be returned as is when requested with get(). @param string $key The key, class or interface name. @param mixed $value The value to set. @return Container
[ "Sets", "a", "single", "value", "." ]
6ced82ab3623b8f1470317d38cbd2de855e7aa3d
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L153-L158
21,898
brick/di
src/Container.php
Container.bind
public function bind(string $key, $target = null) : BindingDefinition { return $this->items[$key] = new BindingDefinition($target ?? $key); }
php
public function bind(string $key, $target = null) : BindingDefinition { return $this->items[$key] = new BindingDefinition($target ?? $key); }
[ "public", "function", "bind", "(", "string", "$", "key", ",", "$", "target", "=", "null", ")", ":", "BindingDefinition", "{", "return", "$", "this", "->", "items", "[", "$", "key", "]", "=", "new", "BindingDefinition", "(", "$", "target", "??", "$", "key", ")", ";", "}" ]
Binds a key to a class name to be instantiated, or to a closure to be invoked. By default, the key is bound to itself, so these two lines of code are equivalent; $container->bind('Class\Name'); $container->bind('Class\Name', 'Class\Name'); It can be used to bind an interface to a class to be instantiated: $container->bind('Interface\Name', 'Class\Name'); The key can also be bound to a closure to return any value: $container->bind('Class\Or\Interface\Name', function() { return new Class\Name(); }); If the key is an interface name, the target must be the name of a class implementing this interface, or a closure returning an instance of such class. If the key is a class name, the target must be the name of the class or one of its subclasses, or a closure returning an instance of this class. Any parameters required by the class constructor or the closure will be automatically resolved when possible using type-hinted classes or interfaces. Additional parameters can be passed as an associative array using the with() method: $container->bind('Interface\Name', 'Class\Name')->with([ 'username' => 'admin', 'password' => new Ref('config.password') ]); Fixed parameters can be provided as is, and references to container keys can be provided by wrapping the key in a `Ref` object. See `BindingDefinition::with()` for more information. Note: not use bind() to attach an existing object instance. Use set() instead. @param string $key The key, class or interface name. @param \Closure|string|null $target The class name or closure to bind. Optional if the key is the class name. @return BindingDefinition
[ "Binds", "a", "key", "to", "a", "class", "name", "to", "be", "instantiated", "or", "to", "a", "closure", "to", "be", "invoked", "." ]
6ced82ab3623b8f1470317d38cbd2de855e7aa3d
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L219-L222
21,899
brick/di
src/Container.php
Container.alias
public function alias(string $key, string $targetKey) : AliasDefinition { return $this->items[$key] = new AliasDefinition($targetKey); }
php
public function alias(string $key, string $targetKey) : AliasDefinition { return $this->items[$key] = new AliasDefinition($targetKey); }
[ "public", "function", "alias", "(", "string", "$", "key", ",", "string", "$", "targetKey", ")", ":", "AliasDefinition", "{", "return", "$", "this", "->", "items", "[", "$", "key", "]", "=", "new", "AliasDefinition", "(", "$", "targetKey", ")", ";", "}" ]
Creates an alias from one key to another. This method can be used for use cases as simple as: $container->alias('my.alias', 'my.service'); This is particularly useful when you have already registered a class by its name, but now want to make it resolvable through an interface name it implements as well: $container->bind('Class\Name'); $container->alias('Interface\Name', 'Class\Name'); An alias always queries the current value by default, unless you change its scope, which may be used for advanced use cases, such as creating singletons out of a prototype: $container->bind('Class\Name')->in(new Scope\Prototype()); $container->alias('my.shared.instance', 'Class\Name')->in(new Scope\Singleton()); @param string $key The key, class or interface name. @param string $targetKey The target key. @return \Brick\Di\Definition\AliasDefinition
[ "Creates", "an", "alias", "from", "one", "key", "to", "another", "." ]
6ced82ab3623b8f1470317d38cbd2de855e7aa3d
https://github.com/brick/di/blob/6ced82ab3623b8f1470317d38cbd2de855e7aa3d/src/Container.php#L248-L251