id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
600
pgraham/database
src/DatabaseConnection.php
DatabaseConnection.prepare
public function prepare($statement, $driverOpts = null) { if ($driverOpts === null) { $driverOpts = []; } try { $stmt = $this->pdo->prepare($statement, $driverOpts); return new PreparedStatement($stmt, $this->pdo, $this->exceptionAdapter); } catch (PDOException $e) { throw $this->exceptionAdapter->adapt($e, $statement); } }
php
public function prepare($statement, $driverOpts = null) { if ($driverOpts === null) { $driverOpts = []; } try { $stmt = $this->pdo->prepare($statement, $driverOpts); return new PreparedStatement($stmt, $this->pdo, $this->exceptionAdapter); } catch (PDOException $e) { throw $this->exceptionAdapter->adapt($e, $statement); } }
[ "public", "function", "prepare", "(", "$", "statement", ",", "$", "driverOpts", "=", "null", ")", "{", "if", "(", "$", "driverOpts", "===", "null", ")", "{", "$", "driverOpts", "=", "[", "]", ";", "}", "try", "{", "$", "stmt", "=", "$", "this", "->", "pdo", "->", "prepare", "(", "$", "statement", ",", "$", "driverOpts", ")", ";", "return", "new", "PreparedStatement", "(", "$", "stmt", ",", "$", "this", "->", "pdo", ",", "$", "this", "->", "exceptionAdapter", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "$", "this", "->", "exceptionAdapter", "->", "adapt", "(", "$", "e", ",", "$", "statement", ")", ";", "}", "}" ]
Create a prepared statement for the given query. @params string $statement The SQL query to prepare. @params array $driverOpts Options for the prepare statement.
[ "Create", "a", "prepared", "statement", "for", "the", "given", "query", "." ]
b325425da23273536772d4fe62da4b669b78601b
https://github.com/pgraham/database/blob/b325425da23273536772d4fe62da4b669b78601b/src/DatabaseConnection.php#L208-L219
601
pgraham/database
src/DatabaseConnection.php
DatabaseConnection.query
public function query($statement) { try { $stmt = $this->pdo->query($statement); return new QueryResult($stmt, $this->pdo); } catch (PDOException $e) { throw $this->exceptionAdapter->adapt($e, $statement); } }
php
public function query($statement) { try { $stmt = $this->pdo->query($statement); return new QueryResult($stmt, $this->pdo); } catch (PDOException $e) { throw $this->exceptionAdapter->adapt($e, $statement); } }
[ "public", "function", "query", "(", "$", "statement", ")", "{", "try", "{", "$", "stmt", "=", "$", "this", "->", "pdo", "->", "query", "(", "$", "statement", ")", ";", "return", "new", "QueryResult", "(", "$", "stmt", ",", "$", "this", "->", "pdo", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "$", "this", "->", "exceptionAdapter", "->", "adapt", "(", "$", "e", ",", "$", "statement", ")", ";", "}", "}" ]
Issue a one-off SELECT statment. @param string $statement @return QueryResult
[ "Issue", "a", "one", "-", "off", "SELECT", "statment", "." ]
b325425da23273536772d4fe62da4b669b78601b
https://github.com/pgraham/database/blob/b325425da23273536772d4fe62da4b669b78601b/src/DatabaseConnection.php#L227-L234
602
awethemes/database
src/Connection.php
Connection.prepareQuery
protected function prepareQuery( $query, array $bindings ) { if ( false !== strpos( $query, '%' ) && count( $bindings ) > 0 ) { // @codingStandardsIgnoreLine $query = $this->wpdb->prepare( $query, $this->prepareBindings( $bindings ) ); } return $query; }
php
protected function prepareQuery( $query, array $bindings ) { if ( false !== strpos( $query, '%' ) && count( $bindings ) > 0 ) { // @codingStandardsIgnoreLine $query = $this->wpdb->prepare( $query, $this->prepareBindings( $bindings ) ); } return $query; }
[ "protected", "function", "prepareQuery", "(", "$", "query", ",", "array", "$", "bindings", ")", "{", "if", "(", "false", "!==", "strpos", "(", "$", "query", ",", "'%'", ")", "&&", "count", "(", "$", "bindings", ")", ">", "0", ")", "{", "// @codingStandardsIgnoreLine", "$", "query", "=", "$", "this", "->", "wpdb", "->", "prepare", "(", "$", "query", ",", "$", "this", "->", "prepareBindings", "(", "$", "bindings", ")", ")", ";", "}", "return", "$", "query", ";", "}" ]
Prepares a SQL query for safe execution. @param string $query @param array $bindings @return string
[ "Prepares", "a", "SQL", "query", "for", "safe", "execution", "." ]
562177781605196695c87398c1304b4224192a4c
https://github.com/awethemes/database/blob/562177781605196695c87398c1304b4224192a4c/src/Connection.php#L212-L219
603
awethemes/database
src/Connection.php
Connection.setQueryGrammar
public function setQueryGrammar( QueryGrammar $grammar ) { $this->queryGrammar = $grammar; $this->queryGrammar->setTablePrefix( $this->wpdb->prefix ); return $this; }
php
public function setQueryGrammar( QueryGrammar $grammar ) { $this->queryGrammar = $grammar; $this->queryGrammar->setTablePrefix( $this->wpdb->prefix ); return $this; }
[ "public", "function", "setQueryGrammar", "(", "QueryGrammar", "$", "grammar", ")", "{", "$", "this", "->", "queryGrammar", "=", "$", "grammar", ";", "$", "this", "->", "queryGrammar", "->", "setTablePrefix", "(", "$", "this", "->", "wpdb", "->", "prefix", ")", ";", "return", "$", "this", ";", "}" ]
Set the query grammar used by the connection. @param QueryGrammar $grammar @return $this
[ "Set", "the", "query", "grammar", "used", "by", "the", "connection", "." ]
562177781605196695c87398c1304b4224192a4c
https://github.com/awethemes/database/blob/562177781605196695c87398c1304b4224192a4c/src/Connection.php#L488-L494
604
awethemes/database
src/Connection.php
Connection.enableQueryLog
public function enableQueryLog() { $this->loggingQueries = true; if ( ! $this->logger ) { $this->setLogger( new QueryLogger ); } return $this; }
php
public function enableQueryLog() { $this->loggingQueries = true; if ( ! $this->logger ) { $this->setLogger( new QueryLogger ); } return $this; }
[ "public", "function", "enableQueryLog", "(", ")", "{", "$", "this", "->", "loggingQueries", "=", "true", ";", "if", "(", "!", "$", "this", "->", "logger", ")", "{", "$", "this", "->", "setLogger", "(", "new", "QueryLogger", ")", ";", "}", "return", "$", "this", ";", "}" ]
Enable the query log on the connection. @return $this
[ "Enable", "the", "query", "log", "on", "the", "connection", "." ]
562177781605196695c87398c1304b4224192a4c
https://github.com/awethemes/database/blob/562177781605196695c87398c1304b4224192a4c/src/Connection.php#L519-L527
605
chanhong/mvclite
src/MvcError.php
MvcError.add
public function add($id, $msg) { if (isset($this->errors[$id]) && !is_array($this->errors[$id])) $this->errors[$id] = array($msg); else $this->errors[$id][] = $msg; }
php
public function add($id, $msg) { if (isset($this->errors[$id]) && !is_array($this->errors[$id])) $this->errors[$id] = array($msg); else $this->errors[$id][] = $msg; }
[ "public", "function", "add", "(", "$", "id", ",", "$", "msg", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "errors", "[", "$", "id", "]", ")", "&&", "!", "is_array", "(", "$", "this", "->", "errors", "[", "$", "id", "]", ")", ")", "$", "this", "->", "errors", "[", "$", "id", "]", "=", "array", "(", "$", "msg", ")", ";", "else", "$", "this", "->", "errors", "[", "$", "id", "]", "[", "]", "=", "$", "msg", ";", "}" ]
Manually add an error
[ "Manually", "add", "an", "error" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L35-L40
606
chanhong/mvclite
src/MvcError.php
MvcError.css
public function css($header = true) { $out = ''; if (count($this->errors) > 0) { if ($header) $out .= '<style type="text/css" media="screen">'; $out .= "#" . implode(", #", array_keys($this->errors)) . " { {$this->style} }"; if ($header) $out .= '</style>'; } echo $out; }
php
public function css($header = true) { $out = ''; if (count($this->errors) > 0) { if ($header) $out .= '<style type="text/css" media="screen">'; $out .= "#" . implode(", #", array_keys($this->errors)) . " { {$this->style} }"; if ($header) $out .= '</style>'; } echo $out; }
[ "public", "function", "css", "(", "$", "header", "=", "true", ")", "{", "$", "out", "=", "''", ";", "if", "(", "count", "(", "$", "this", "->", "errors", ")", ">", "0", ")", "{", "if", "(", "$", "header", ")", "$", "out", ".=", "'<style type=\"text/css\" media=\"screen\">'", ";", "$", "out", ".=", "\"#\"", ".", "implode", "(", "\", #\"", ",", "array_keys", "(", "$", "this", "->", "errors", ")", ")", ".", "\" { {$this->style} }\"", ";", "if", "(", "$", "header", ")", "$", "out", ".=", "'</style>'", ";", "}", "echo", "$", "out", ";", "}" ]
Outputs the CSS to style the error elements
[ "Outputs", "the", "CSS", "to", "style", "the", "error", "elements" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L54-L64
607
chanhong/mvclite
src/MvcError.php
MvcError.ul
public function ul($class = 'warn') { if (count($this->errors) == 0) return ''; $out = "<ul class='$class'>"; foreach ($this->errors as $error) $out .= "<li>" . implode("</li><li>", $error) . "</li>"; $out .= "</ul>"; return $out; }
php
public function ul($class = 'warn') { if (count($this->errors) == 0) return ''; $out = "<ul class='$class'>"; foreach ($this->errors as $error) $out .= "<li>" . implode("</li><li>", $error) . "</li>"; $out .= "</ul>"; return $out; }
[ "public", "function", "ul", "(", "$", "class", "=", "'warn'", ")", "{", "if", "(", "count", "(", "$", "this", "->", "errors", ")", "==", "0", ")", "return", "''", ";", "$", "out", "=", "\"<ul class='$class'>\"", ";", "foreach", "(", "$", "this", "->", "errors", "as", "$", "error", ")", "$", "out", ".=", "\"<li>\"", ".", "implode", "(", "\"</li><li>\"", ",", "$", "error", ")", ".", "\"</li>\"", ";", "$", "out", ".=", "\"</ul>\"", ";", "return", "$", "out", ";", "}" ]
Returns an unordered list of error messages
[ "Returns", "an", "unordered", "list", "of", "error", "messages" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L67-L77
608
chanhong/mvclite
src/MvcError.php
MvcError.alert
public function alert() { if (count($this->errors) == 0) return ''; $out = ''; foreach ($this->errors as $error) $out .= "<p class='alert error'>" . implode(' ', $error) . "</p>"; return $out; }
php
public function alert() { if (count($this->errors) == 0) return ''; $out = ''; foreach ($this->errors as $error) $out .= "<p class='alert error'>" . implode(' ', $error) . "</p>"; return $out; }
[ "public", "function", "alert", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "errors", ")", "==", "0", ")", "return", "''", ";", "$", "out", "=", "''", ";", "foreach", "(", "$", "this", "->", "errors", "as", "$", "error", ")", "$", "out", ".=", "\"<p class='alert error'>\"", ".", "implode", "(", "' '", ",", "$", "error", ")", ".", "\"</p>\"", ";", "return", "$", "out", ";", "}" ]
Returns error alerts
[ "Returns", "error", "alerts" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L80-L89
609
chanhong/mvclite
src/MvcError.php
MvcError.length
public function length($val, $lower, $upper, $id, $name = null) { if (strlen($val) < $lower) { if (is_null($name)) $name = ucwords($id); $this->add($id, "$name must be at least $lower characters."); return false; } elseif (strlen($val) > $upper) { if (is_null($name)) $name = ucwords($id); $this->add($id, "$name cannot be more than $upper characters long."); return false; } return true; }
php
public function length($val, $lower, $upper, $id, $name = null) { if (strlen($val) < $lower) { if (is_null($name)) $name = ucwords($id); $this->add($id, "$name must be at least $lower characters."); return false; } elseif (strlen($val) > $upper) { if (is_null($name)) $name = ucwords($id); $this->add($id, "$name cannot be more than $upper characters long."); return false; } return true; }
[ "public", "function", "length", "(", "$", "val", ",", "$", "lower", ",", "$", "upper", ",", "$", "id", ",", "$", "name", "=", "null", ")", "{", "if", "(", "strlen", "(", "$", "val", ")", "<", "$", "lower", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "$", "name", "=", "ucwords", "(", "$", "id", ")", ";", "$", "this", "->", "add", "(", "$", "id", ",", "\"$name must be at least $lower characters.\"", ")", ";", "return", "false", ";", "}", "elseif", "(", "strlen", "(", "$", "val", ")", ">", "$", "upper", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "$", "name", "=", "ucwords", "(", "$", "id", ")", ";", "$", "this", "->", "add", "(", "$", "id", ",", "\"$name cannot be more than $upper characters long.\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is a string an appropriate length?
[ "Is", "a", "string", "an", "appropriate", "length?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L118-L133
610
chanhong/mvclite
src/MvcError.php
MvcError.passwords
public function passwords($pass1, $pass2, $id) { if ($pass1 !== $pass2) { $this->add($id, 'The passwords you entered do not match.'); return false; } return true; }
php
public function passwords($pass1, $pass2, $id) { if ($pass1 !== $pass2) { $this->add($id, 'The passwords you entered do not match.'); return false; } return true; }
[ "public", "function", "passwords", "(", "$", "pass1", ",", "$", "pass2", ",", "$", "id", ")", "{", "if", "(", "$", "pass1", "!==", "$", "pass2", ")", "{", "$", "this", "->", "add", "(", "$", "id", ",", "'The passwords you entered do not match.'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Do the passwords match?
[ "Do", "the", "passwords", "match?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L136-L143
611
chanhong/mvclite
src/MvcError.php
MvcError.regex
public function regex($val, $regex, $id, $msg) { if (preg_match($regex, $val) === 0) { $this->add($id, $msg); return false; } return true; }
php
public function regex($val, $regex, $id, $msg) { if (preg_match($regex, $val) === 0) { $this->add($id, $msg); return false; } return true; }
[ "public", "function", "regex", "(", "$", "val", ",", "$", "regex", ",", "$", "id", ",", "$", "msg", ")", "{", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "val", ")", "===", "0", ")", "{", "$", "this", "->", "add", "(", "$", "id", ",", "$", "msg", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Does a value match a given regex?
[ "Does", "a", "value", "match", "a", "given", "regex?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L146-L153
612
chanhong/mvclite
src/MvcError.php
MvcError.email
public function email($val, $id = 'email') { if (!preg_match("/^([_a-z0-9+-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", $val)) { $this->add($id, 'The email address you entered is not valid.'); return false; } return true; }
php
public function email($val, $id = 'email') { if (!preg_match("/^([_a-z0-9+-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/i", $val)) { $this->add($id, 'The email address you entered is not valid.'); return false; } return true; }
[ "public", "function", "email", "(", "$", "val", ",", "$", "id", "=", "'email'", ")", "{", "if", "(", "!", "preg_match", "(", "\"/^([_a-z0-9+-]+)(\\.[_a-z0-9-]+)*@([a-z0-9-]+)(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})$/i\"", ",", "$", "val", ")", ")", "{", "$", "this", "->", "add", "(", "$", "id", ",", "'The email address you entered is not valid.'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is an email address valid?
[ "Is", "an", "email", "address", "valid?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L156-L163
613
chanhong/mvclite
src/MvcError.php
MvcError.date
public function date($val, $id) { if (chkdate($val) === false) { $this->add($id, 'Please enter a valid date'); return false; } return true; }
php
public function date($val, $id) { if (chkdate($val) === false) { $this->add($id, 'Please enter a valid date'); return false; } return true; }
[ "public", "function", "date", "(", "$", "val", ",", "$", "id", ")", "{", "if", "(", "chkdate", "(", "$", "val", ")", "===", "false", ")", "{", "$", "this", "->", "add", "(", "$", "id", ",", "'Please enter a valid date'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is a string a parseable and valid date?
[ "Is", "a", "string", "a", "parseable", "and", "valid", "date?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L166-L173
614
chanhong/mvclite
src/MvcError.php
MvcError.adult
public function adult($val, $id) { if (dater($val) > ( (date('Y') - 18) . date('-m-d H:i:s') )) { $this->add($id, 'You must be at least 18 years old.'); return false; } return true; }
php
public function adult($val, $id) { if (dater($val) > ( (date('Y') - 18) . date('-m-d H:i:s') )) { $this->add($id, 'You must be at least 18 years old.'); return false; } return true; }
[ "public", "function", "adult", "(", "$", "val", ",", "$", "id", ")", "{", "if", "(", "dater", "(", "$", "val", ")", ">", "(", "(", "date", "(", "'Y'", ")", "-", "18", ")", ".", "date", "(", "'-m-d H:i:s'", ")", ")", ")", "{", "$", "this", "->", "add", "(", "$", "id", ",", "'You must be at least 18 years old.'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is a birth date at least 18 years old?
[ "Is", "a", "birth", "date", "at", "least", "18", "years", "old?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L176-L183
615
chanhong/mvclite
src/MvcError.php
MvcError.phone
public function phone($val, $id) { $val = preg_replace('/[^0-9]/', '', $val); if (strlen($val) != 7 && strlen($val) != 10) { $this->add($id, 'Please enter a valid 7 or 10 digit phone number.'); return false; } return true; }
php
public function phone($val, $id) { $val = preg_replace('/[^0-9]/', '', $val); if (strlen($val) != 7 && strlen($val) != 10) { $this->add($id, 'Please enter a valid 7 or 10 digit phone number.'); return false; } return true; }
[ "public", "function", "phone", "(", "$", "val", ",", "$", "id", ")", "{", "$", "val", "=", "preg_replace", "(", "'/[^0-9]/'", ",", "''", ",", "$", "val", ")", ";", "if", "(", "strlen", "(", "$", "val", ")", "!=", "7", "&&", "strlen", "(", "$", "val", ")", "!=", "10", ")", "{", "$", "this", "->", "add", "(", "$", "id", ",", "'Please enter a valid 7 or 10 digit phone number.'", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is a string a valid phone number?
[ "Is", "a", "string", "a", "valid", "phone", "number?" ]
31c52ebf9c435705a3ed9a2e00cebc32705c35f5
https://github.com/chanhong/mvclite/blob/31c52ebf9c435705a3ed9a2e00cebc32705c35f5/src/MvcError.php#L186-L194
616
vincenttouzet/AdminConfigurationBundle
Command/InstallDemoCommand.php
InstallDemoCommand._createValue
private function _createValue($name, $type, $label, $value, $help, $formOptions, $position) { $created = $this->configBuilder->addValue( 'demo', 'demo', $name, $type, $label, $value, $help, $formOptions, $position ); if ($created) { $this->output->writeln(sprintf('<info>Create value %s:%s:%s</info>', 'demo', 'demo', $name)); } else { $this->output->writeln(sprintf('<comment>Value %s:%s:%s already exists.</comment>', 'demo', 'demo', $name)); } }
php
private function _createValue($name, $type, $label, $value, $help, $formOptions, $position) { $created = $this->configBuilder->addValue( 'demo', 'demo', $name, $type, $label, $value, $help, $formOptions, $position ); if ($created) { $this->output->writeln(sprintf('<info>Create value %s:%s:%s</info>', 'demo', 'demo', $name)); } else { $this->output->writeln(sprintf('<comment>Value %s:%s:%s already exists.</comment>', 'demo', 'demo', $name)); } }
[ "private", "function", "_createValue", "(", "$", "name", ",", "$", "type", ",", "$", "label", ",", "$", "value", ",", "$", "help", ",", "$", "formOptions", ",", "$", "position", ")", "{", "$", "created", "=", "$", "this", "->", "configBuilder", "->", "addValue", "(", "'demo'", ",", "'demo'", ",", "$", "name", ",", "$", "type", ",", "$", "label", ",", "$", "value", ",", "$", "help", ",", "$", "formOptions", ",", "$", "position", ")", ";", "if", "(", "$", "created", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'<info>Create value %s:%s:%s</info>'", ",", "'demo'", ",", "'demo'", ",", "$", "name", ")", ")", ";", "}", "else", "{", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'<comment>Value %s:%s:%s already exists.</comment>'", ",", "'demo'", ",", "'demo'", ",", "$", "name", ")", ")", ";", "}", "}" ]
Create a value @param string $name [description] @param string $type [description] @param string $label [description] @param string $value [description] @param string $help [description] @param array $formOptions [description] @param integer $position [description] @return Boolean
[ "Create", "a", "value" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Command/InstallDemoCommand.php#L136-L154
617
laasti/stack
src/Stack.php
Stack.execute
public function execute(Request $request) { $phases = ['prepare', 'respond', 'close']; $response = null; foreach ($phases as $phase) { $key = 0; if ($phase === 'respond' && is_null($response)) { throw new StackException; } else if ($phase === 'close' && $key === 0) { $response->send(); } if ($phase === 'prepare' && count($this->{$phase . 'ableMiddlewares'}) === 0) { throw new StackException('You must at least add one prepareableMiddleware that generates a Response.'); } else if (count($this->{$phase . 'ableMiddlewares'}) === 0) { continue; } $next_middleware_spec = $this->{$phase . 'ableMiddlewares'}[$key]; //Use a while so that middlewares can add other middlewares to execute while ($next_middleware_spec) { //Get the middleware $middleware = array_shift($next_middleware_spec); if (!is_null($response)) { array_unshift($next_middleware_spec, $response); } //Put request as first parameter for the middleware array_unshift($next_middleware_spec, $request); $return = call_user_func_array([$middleware, $phase], $next_middleware_spec); if ($phase === 'prepare' && $return instanceof Response) { $response = $return; break; } else if ($phase === 'respond') { //Reassign response in case it was recreated during that phase $response = $return; } $key++; $next_middleware_spec = isset($this->{$phase . 'ableMiddlewares'}[$key]) ? $this->{$phase . 'ableMiddlewares'}[$key] : false; } } }
php
public function execute(Request $request) { $phases = ['prepare', 'respond', 'close']; $response = null; foreach ($phases as $phase) { $key = 0; if ($phase === 'respond' && is_null($response)) { throw new StackException; } else if ($phase === 'close' && $key === 0) { $response->send(); } if ($phase === 'prepare' && count($this->{$phase . 'ableMiddlewares'}) === 0) { throw new StackException('You must at least add one prepareableMiddleware that generates a Response.'); } else if (count($this->{$phase . 'ableMiddlewares'}) === 0) { continue; } $next_middleware_spec = $this->{$phase . 'ableMiddlewares'}[$key]; //Use a while so that middlewares can add other middlewares to execute while ($next_middleware_spec) { //Get the middleware $middleware = array_shift($next_middleware_spec); if (!is_null($response)) { array_unshift($next_middleware_spec, $response); } //Put request as first parameter for the middleware array_unshift($next_middleware_spec, $request); $return = call_user_func_array([$middleware, $phase], $next_middleware_spec); if ($phase === 'prepare' && $return instanceof Response) { $response = $return; break; } else if ($phase === 'respond') { //Reassign response in case it was recreated during that phase $response = $return; } $key++; $next_middleware_spec = isset($this->{$phase . 'ableMiddlewares'}[$key]) ? $this->{$phase . 'ableMiddlewares'}[$key] : false; } } }
[ "public", "function", "execute", "(", "Request", "$", "request", ")", "{", "$", "phases", "=", "[", "'prepare'", ",", "'respond'", ",", "'close'", "]", ";", "$", "response", "=", "null", ";", "foreach", "(", "$", "phases", "as", "$", "phase", ")", "{", "$", "key", "=", "0", ";", "if", "(", "$", "phase", "===", "'respond'", "&&", "is_null", "(", "$", "response", ")", ")", "{", "throw", "new", "StackException", ";", "}", "else", "if", "(", "$", "phase", "===", "'close'", "&&", "$", "key", "===", "0", ")", "{", "$", "response", "->", "send", "(", ")", ";", "}", "if", "(", "$", "phase", "===", "'prepare'", "&&", "count", "(", "$", "this", "->", "{", "$", "phase", ".", "'ableMiddlewares'", "}", ")", "===", "0", ")", "{", "throw", "new", "StackException", "(", "'You must at least add one prepareableMiddleware that generates a Response.'", ")", ";", "}", "else", "if", "(", "count", "(", "$", "this", "->", "{", "$", "phase", ".", "'ableMiddlewares'", "}", ")", "===", "0", ")", "{", "continue", ";", "}", "$", "next_middleware_spec", "=", "$", "this", "->", "{", "$", "phase", ".", "'ableMiddlewares'", "}", "[", "$", "key", "]", ";", "//Use a while so that middlewares can add other middlewares to execute", "while", "(", "$", "next_middleware_spec", ")", "{", "//Get the middleware", "$", "middleware", "=", "array_shift", "(", "$", "next_middleware_spec", ")", ";", "if", "(", "!", "is_null", "(", "$", "response", ")", ")", "{", "array_unshift", "(", "$", "next_middleware_spec", ",", "$", "response", ")", ";", "}", "//Put request as first parameter for the middleware", "array_unshift", "(", "$", "next_middleware_spec", ",", "$", "request", ")", ";", "$", "return", "=", "call_user_func_array", "(", "[", "$", "middleware", ",", "$", "phase", "]", ",", "$", "next_middleware_spec", ")", ";", "if", "(", "$", "phase", "===", "'prepare'", "&&", "$", "return", "instanceof", "Response", ")", "{", "$", "response", "=", "$", "return", ";", "break", ";", "}", "else", "if", "(", "$", "phase", "===", "'respond'", ")", "{", "//Reassign response in case it was recreated during that phase", "$", "response", "=", "$", "return", ";", "}", "$", "key", "++", ";", "$", "next_middleware_spec", "=", "isset", "(", "$", "this", "->", "{", "$", "phase", ".", "'ableMiddlewares'", "}", "[", "$", "key", "]", ")", "?", "$", "this", "->", "{", "$", "phase", ".", "'ableMiddlewares'", "}", "[", "$", "key", "]", ":", "false", ";", "}", "}", "}" ]
Loops through all registered middlewares until a response is returned. @throws StackException When no response is returned @param Request $request @return Response
[ "Loops", "through", "all", "registered", "middlewares", "until", "a", "response", "is", "returned", "." ]
15bf204b60c85579574449e9a77a1208fd7e5363
https://github.com/laasti/stack/blob/15bf204b60c85579574449e9a77a1208fd7e5363/src/Stack.php#L94-L143
618
laasti/stack
src/Stack.php
Stack.addMiddleware
private function addMiddleware($middleware, $args, $push = true) { $instance = $this->resolve($middleware); $types = $this->getTypes($instance); if (!count($types)) { throw new InvalidArgumentException('The first argument must be an instance of PrepareableInterface, RespondableInterface or CloseableInterface.'); } //Replace middleware definition with instance $args[0] = $instance; foreach ($types as $type) { if ($push) { array_push($this->{$type . 'Middlewares'}, $args); } else { array_unshift($this->{$type . 'Middlewares'}, $args); } } }
php
private function addMiddleware($middleware, $args, $push = true) { $instance = $this->resolve($middleware); $types = $this->getTypes($instance); if (!count($types)) { throw new InvalidArgumentException('The first argument must be an instance of PrepareableInterface, RespondableInterface or CloseableInterface.'); } //Replace middleware definition with instance $args[0] = $instance; foreach ($types as $type) { if ($push) { array_push($this->{$type . 'Middlewares'}, $args); } else { array_unshift($this->{$type . 'Middlewares'}, $args); } } }
[ "private", "function", "addMiddleware", "(", "$", "middleware", ",", "$", "args", ",", "$", "push", "=", "true", ")", "{", "$", "instance", "=", "$", "this", "->", "resolve", "(", "$", "middleware", ")", ";", "$", "types", "=", "$", "this", "->", "getTypes", "(", "$", "instance", ")", ";", "if", "(", "!", "count", "(", "$", "types", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The first argument must be an instance of PrepareableInterface, RespondableInterface or CloseableInterface.'", ")", ";", "}", "//Replace middleware definition with instance", "$", "args", "[", "0", "]", "=", "$", "instance", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "if", "(", "$", "push", ")", "{", "array_push", "(", "$", "this", "->", "{", "$", "type", ".", "'Middlewares'", "}", ",", "$", "args", ")", ";", "}", "else", "{", "array_unshift", "(", "$", "this", "->", "{", "$", "type", ".", "'Middlewares'", "}", ",", "$", "args", ")", ";", "}", "}", "}" ]
Adds a middleware to aggregates @param mixed $middleware @param array $args @param bool $push Whether to push the middleware, false, or unshift, true @throws InvalidArgumentException
[ "Adds", "a", "middleware", "to", "aggregates" ]
15bf204b60c85579574449e9a77a1208fd7e5363
https://github.com/laasti/stack/blob/15bf204b60c85579574449e9a77a1208fd7e5363/src/Stack.php#L152-L173
619
laasti/stack
src/Stack.php
Stack.getTypes
private function getTypes($middleware) { $types = []; if ($middleware instanceof PrepareableInterface) { $types[] = 'prepareable'; } if ($middleware instanceof RespondableInterface) { $types[] = 'respondable'; } if ($middleware instanceof CloseableInterface) { $types[] = 'closeable'; } return $types; }
php
private function getTypes($middleware) { $types = []; if ($middleware instanceof PrepareableInterface) { $types[] = 'prepareable'; } if ($middleware instanceof RespondableInterface) { $types[] = 'respondable'; } if ($middleware instanceof CloseableInterface) { $types[] = 'closeable'; } return $types; }
[ "private", "function", "getTypes", "(", "$", "middleware", ")", "{", "$", "types", "=", "[", "]", ";", "if", "(", "$", "middleware", "instanceof", "PrepareableInterface", ")", "{", "$", "types", "[", "]", "=", "'prepareable'", ";", "}", "if", "(", "$", "middleware", "instanceof", "RespondableInterface", ")", "{", "$", "types", "[", "]", "=", "'respondable'", ";", "}", "if", "(", "$", "middleware", "instanceof", "CloseableInterface", ")", "{", "$", "types", "[", "]", "=", "'closeable'", ";", "}", "return", "$", "types", ";", "}" ]
Returns the applicable types for the middleware @param mixed $middleware @return array
[ "Returns", "the", "applicable", "types", "for", "the", "middleware" ]
15bf204b60c85579574449e9a77a1208fd7e5363
https://github.com/laasti/stack/blob/15bf204b60c85579574449e9a77a1208fd7e5363/src/Stack.php#L180-L195
620
laasti/stack
src/Stack.php
Stack.resolve
private function resolve($definition) { return !is_null($this->resolver) ? $this->resolver->resolve($definition) : $definition; }
php
private function resolve($definition) { return !is_null($this->resolver) ? $this->resolver->resolve($definition) : $definition; }
[ "private", "function", "resolve", "(", "$", "definition", ")", "{", "return", "!", "is_null", "(", "$", "this", "->", "resolver", ")", "?", "$", "this", "->", "resolver", "->", "resolve", "(", "$", "definition", ")", ":", "$", "definition", ";", "}" ]
Resolve the argument to an actual middleware instance @param mixed $definition @return mixed
[ "Resolve", "the", "argument", "to", "an", "actual", "middleware", "instance" ]
15bf204b60c85579574449e9a77a1208fd7e5363
https://github.com/laasti/stack/blob/15bf204b60c85579574449e9a77a1208fd7e5363/src/Stack.php#L202-L205
621
mvccore/ext-form
src/MvcCore/Ext/Form/AddMethods.php
AddMethods.AddError
public function AddError ($errorMsg, $fieldNames = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ $errorMsgUtf8 = iconv( mb_detect_encoding($errorMsg, mb_detect_order(), TRUE), "UTF-8", $errorMsg ); $fieldNamesArr = $fieldNames === NULL ? [] : (gettype($fieldNames) == 'array' ? $fieldNames : [$fieldNames]); $newErrorRec = [strip_tags($errorMsgUtf8), $fieldNamesArr]; if ($fieldNamesArr) { foreach ($fieldNamesArr as $fieldName) { if (isset($this->fields[$fieldName])) { $field = & $this->fields[$fieldName]; $field ->AddError($errorMsgUtf8) ->AddCssClasses('error'); if ($field instanceof \MvcCore\Ext\Forms\IFieldsGroup) $field->AddGroupLabelCssClasses('error'); } } } $this->errors[] = $newErrorRec; $this->result = \MvcCore\Ext\Forms\IForm::RESULT_ERRORS; return $this; }
php
public function AddError ($errorMsg, $fieldNames = NULL) { /** @var $this \MvcCore\Ext\Forms\IForm */ $errorMsgUtf8 = iconv( mb_detect_encoding($errorMsg, mb_detect_order(), TRUE), "UTF-8", $errorMsg ); $fieldNamesArr = $fieldNames === NULL ? [] : (gettype($fieldNames) == 'array' ? $fieldNames : [$fieldNames]); $newErrorRec = [strip_tags($errorMsgUtf8), $fieldNamesArr]; if ($fieldNamesArr) { foreach ($fieldNamesArr as $fieldName) { if (isset($this->fields[$fieldName])) { $field = & $this->fields[$fieldName]; $field ->AddError($errorMsgUtf8) ->AddCssClasses('error'); if ($field instanceof \MvcCore\Ext\Forms\IFieldsGroup) $field->AddGroupLabelCssClasses('error'); } } } $this->errors[] = $newErrorRec; $this->result = \MvcCore\Ext\Forms\IForm::RESULT_ERRORS; return $this; }
[ "public", "function", "AddError", "(", "$", "errorMsg", ",", "$", "fieldNames", "=", "NULL", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "$", "errorMsgUtf8", "=", "iconv", "(", "mb_detect_encoding", "(", "$", "errorMsg", ",", "mb_detect_order", "(", ")", ",", "TRUE", ")", ",", "\"UTF-8\"", ",", "$", "errorMsg", ")", ";", "$", "fieldNamesArr", "=", "$", "fieldNames", "===", "NULL", "?", "[", "]", ":", "(", "gettype", "(", "$", "fieldNames", ")", "==", "'array'", "?", "$", "fieldNames", ":", "[", "$", "fieldNames", "]", ")", ";", "$", "newErrorRec", "=", "[", "strip_tags", "(", "$", "errorMsgUtf8", ")", ",", "$", "fieldNamesArr", "]", ";", "if", "(", "$", "fieldNamesArr", ")", "{", "foreach", "(", "$", "fieldNamesArr", "as", "$", "fieldName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ")", ")", "{", "$", "field", "=", "&", "$", "this", "->", "fields", "[", "$", "fieldName", "]", ";", "$", "field", "->", "AddError", "(", "$", "errorMsgUtf8", ")", "->", "AddCssClasses", "(", "'error'", ")", ";", "if", "(", "$", "field", "instanceof", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IFieldsGroup", ")", "$", "field", "->", "AddGroupLabelCssClasses", "(", "'error'", ")", ";", "}", "}", "}", "$", "this", "->", "errors", "[", "]", "=", "$", "newErrorRec", ";", "$", "this", "->", "result", "=", "\\", "MvcCore", "\\", "Ext", "\\", "Forms", "\\", "IForm", "::", "RESULT_ERRORS", ";", "return", "$", "this", ";", "}" ]
Add form submit error and switch form result to zero - to error state. @param string $errorMsg Any error message, translated if necessary. All html tags from error message will be removed automatically. @param string|array|NULL $fieldNames Optional, field name string or array with field names where error happened. @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Add", "form", "submit", "error", "and", "switch", "form", "result", "to", "zero", "-", "to", "error", "state", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/AddMethods.php#L61-L85
622
mvccore/ext-form
src/MvcCore/Ext/Form/AddMethods.php
AddMethods.&
public function & AddJsSupportFile ( $jsRelativePath = '/fields/custom-type.js', $jsClassName = 'MvcCoreForm.FieldType', $constructorParams = [] ) { /** @var $this \MvcCore\Ext\Forms\IForm */ $this->jsSupportFiles[] = [$jsRelativePath, $jsClassName, $constructorParams]; return $this; }
php
public function & AddJsSupportFile ( $jsRelativePath = '/fields/custom-type.js', $jsClassName = 'MvcCoreForm.FieldType', $constructorParams = [] ) { /** @var $this \MvcCore\Ext\Forms\IForm */ $this->jsSupportFiles[] = [$jsRelativePath, $jsClassName, $constructorParams]; return $this; }
[ "public", "function", "&", "AddJsSupportFile", "(", "$", "jsRelativePath", "=", "'/fields/custom-type.js'", ",", "$", "jsClassName", "=", "'MvcCoreForm.FieldType'", ",", "$", "constructorParams", "=", "[", "]", ")", "{", "/** @var $this \\MvcCore\\Ext\\Forms\\IForm */", "$", "this", "->", "jsSupportFiles", "[", "]", "=", "[", "$", "jsRelativePath", ",", "$", "jsClassName", ",", "$", "constructorParams", "]", ";", "return", "$", "this", ";", "}" ]
Add supporting javascript file. @param string $jsRelativePath Supporting javascript file relative path from protected `\MvcCore\Ext\Form::$jsAssetsRootDir`. @param string $jsClassName Supporting javascript full class name inside supporting file. @param array $constructorParams Supporting javascript constructor params. @return \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm
[ "Add", "supporting", "javascript", "file", "." ]
8d81a3c7326236702f37dc4b9d968907b3230b9f
https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Form/AddMethods.php#L94-L102
623
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php
AbstractStringWrapper.isSupported
public static function isSupported($encoding, $convertEncoding = null) { $supportedEncodings = static::getSupportedEncodings(); if (!in_array(strtoupper($encoding), $supportedEncodings)) { return false; } if ($convertEncoding !== null && !in_array(strtoupper($convertEncoding), $supportedEncodings)) { return false; } return true; }
php
public static function isSupported($encoding, $convertEncoding = null) { $supportedEncodings = static::getSupportedEncodings(); if (!in_array(strtoupper($encoding), $supportedEncodings)) { return false; } if ($convertEncoding !== null && !in_array(strtoupper($convertEncoding), $supportedEncodings)) { return false; } return true; }
[ "public", "static", "function", "isSupported", "(", "$", "encoding", ",", "$", "convertEncoding", "=", "null", ")", "{", "$", "supportedEncodings", "=", "static", "::", "getSupportedEncodings", "(", ")", ";", "if", "(", "!", "in_array", "(", "strtoupper", "(", "$", "encoding", ")", ",", "$", "supportedEncodings", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "convertEncoding", "!==", "null", "&&", "!", "in_array", "(", "strtoupper", "(", "$", "convertEncoding", ")", ",", "$", "supportedEncodings", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if the given character encoding is supported by this wrapper and the character encoding to convert to is also supported. @param string $encoding @param string|null $convertEncoding @return bool
[ "Check", "if", "the", "given", "character", "encoding", "is", "supported", "by", "this", "wrapper", "and", "the", "character", "encoding", "to", "convert", "to", "is", "also", "supported", "." ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php#L37-L50
624
anklimsk/cakephp-basic-functions
Vendor/langcode-conv/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php
AbstractStringWrapper.convert
public function convert($str, $reverse = false) { $encoding = $this->getEncoding(); $convertEncoding = $this->getConvertEncoding(); if ($convertEncoding === null) { throw new Exception\LogicException( 'No convert encoding defined' ); } if ($encoding === $convertEncoding) { return $str; } $from = $reverse ? $convertEncoding : $encoding; $to = $reverse ? $encoding : $convertEncoding; throw new Exception\RuntimeException(sprintf( 'Converting from "%s" to "%s" isn\'t supported by this string wrapper', $from, $to )); }
php
public function convert($str, $reverse = false) { $encoding = $this->getEncoding(); $convertEncoding = $this->getConvertEncoding(); if ($convertEncoding === null) { throw new Exception\LogicException( 'No convert encoding defined' ); } if ($encoding === $convertEncoding) { return $str; } $from = $reverse ? $convertEncoding : $encoding; $to = $reverse ? $encoding : $convertEncoding; throw new Exception\RuntimeException(sprintf( 'Converting from "%s" to "%s" isn\'t supported by this string wrapper', $from, $to )); }
[ "public", "function", "convert", "(", "$", "str", ",", "$", "reverse", "=", "false", ")", "{", "$", "encoding", "=", "$", "this", "->", "getEncoding", "(", ")", ";", "$", "convertEncoding", "=", "$", "this", "->", "getConvertEncoding", "(", ")", ";", "if", "(", "$", "convertEncoding", "===", "null", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'No convert encoding defined'", ")", ";", "}", "if", "(", "$", "encoding", "===", "$", "convertEncoding", ")", "{", "return", "$", "str", ";", "}", "$", "from", "=", "$", "reverse", "?", "$", "convertEncoding", ":", "$", "encoding", ";", "$", "to", "=", "$", "reverse", "?", "$", "encoding", ":", "$", "convertEncoding", ";", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'Converting from \"%s\" to \"%s\" isn\\'t supported by this string wrapper'", ",", "$", "from", ",", "$", "to", ")", ")", ";", "}" ]
Convert a string from defined character encoding to the defined convert encoding @param string $str @param bool $reverse @return string|false
[ "Convert", "a", "string", "from", "defined", "character", "encoding", "to", "the", "defined", "convert", "encoding" ]
7554e8b0b420fd3155593af7bf76b7ccbdc8701e
https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-stdlib/src/StringWrapper/AbstractStringWrapper.php#L115-L136
625
jakecleary/ultrapress-library
src/Ultra/Router/Route.php
Route.page
private static function page($page, array $details) { if(($page === '*' && is_page()) || is_page($page)) { self::loadController($details); exit; } }
php
private static function page($page, array $details) { if(($page === '*' && is_page()) || is_page($page)) { self::loadController($details); exit; } }
[ "private", "static", "function", "page", "(", "$", "page", ",", "array", "$", "details", ")", "{", "if", "(", "(", "$", "page", "===", "'*'", "&&", "is_page", "(", ")", ")", "||", "is_page", "(", "$", "page", ")", ")", "{", "self", "::", "loadController", "(", "$", "details", ")", ";", "exit", ";", "}", "}" ]
Check for a specific page. @param integer/string $page The ID or slug for the page @param array $details Settings for the route
[ "Check", "for", "a", "specific", "page", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Router/Route.php#L109-L116
626
jakecleary/ultrapress-library
src/Ultra/Router/Route.php
Route.search
private static function search($postType, array $details) { $s = isset($_GET['post_type']) ? $_GET['post_type'] : false; if($s === $postType && is_search()) { self::loadController($details); exit; } }
php
private static function search($postType, array $details) { $s = isset($_GET['post_type']) ? $_GET['post_type'] : false; if($s === $postType && is_search()) { self::loadController($details); exit; } }
[ "private", "static", "function", "search", "(", "$", "postType", ",", "array", "$", "details", ")", "{", "$", "s", "=", "isset", "(", "$", "_GET", "[", "'post_type'", "]", ")", "?", "$", "_GET", "[", "'post_type'", "]", ":", "false", ";", "if", "(", "$", "s", "===", "$", "postType", "&&", "is_search", "(", ")", ")", "{", "self", "::", "loadController", "(", "$", "details", ")", ";", "exit", ";", "}", "}" ]
Check if we are loading a search page. @param string $postType Optional. Look for a specific post type @param array $details Settings for the route
[ "Check", "if", "we", "are", "loading", "a", "search", "page", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Router/Route.php#L124-L133
627
jakecleary/ultrapress-library
src/Ultra/Router/Route.php
Route.loadController
private static function loadController($pointer) { // Get the Class/Method to use $controllerData = $pointer['uses']; $parts = explode('@', $controllerData); $controller = "UltraPress\\Controllers\\$parts[0]"; $method = $parts[1]; $obj = new $controller; // Execute the method $obj->$method(); }
php
private static function loadController($pointer) { // Get the Class/Method to use $controllerData = $pointer['uses']; $parts = explode('@', $controllerData); $controller = "UltraPress\\Controllers\\$parts[0]"; $method = $parts[1]; $obj = new $controller; // Execute the method $obj->$method(); }
[ "private", "static", "function", "loadController", "(", "$", "pointer", ")", "{", "// Get the Class/Method to use", "$", "controllerData", "=", "$", "pointer", "[", "'uses'", "]", ";", "$", "parts", "=", "explode", "(", "'@'", ",", "$", "controllerData", ")", ";", "$", "controller", "=", "\"UltraPress\\\\Controllers\\\\$parts[0]\"", ";", "$", "method", "=", "$", "parts", "[", "1", "]", ";", "$", "obj", "=", "new", "$", "controller", ";", "// Execute the method", "$", "obj", "->", "$", "method", "(", ")", ";", "}" ]
Get a controller action from the supplied string. @param string $pointer The 'controller@action string
[ "Get", "a", "controller", "action", "from", "the", "supplied", "string", "." ]
84ca5d1dae8eb16de8c886787575ea41f9332ae2
https://github.com/jakecleary/ultrapress-library/blob/84ca5d1dae8eb16de8c886787575ea41f9332ae2/src/Ultra/Router/Route.php#L155-L166
628
tekkla/core-config
Core/Config/Config.php
Config.&
public function &createStorage(string $storage_name): ConfigStorage { if (isset($this->storage[$storage_name])) { return $this->getStorage($storage_name); } $storage = new ConfigStorage(); $storage->setName($storage_name); $this->storage[$storage_name] = $storage; return $storage; }
php
public function &createStorage(string $storage_name): ConfigStorage { if (isset($this->storage[$storage_name])) { return $this->getStorage($storage_name); } $storage = new ConfigStorage(); $storage->setName($storage_name); $this->storage[$storage_name] = $storage; return $storage; }
[ "public", "function", "&", "createStorage", "(", "string", "$", "storage_name", ")", ":", "ConfigStorage", "{", "if", "(", "isset", "(", "$", "this", "->", "storage", "[", "$", "storage_name", "]", ")", ")", "{", "return", "$", "this", "->", "getStorage", "(", "$", "storage_name", ")", ";", "}", "$", "storage", "=", "new", "ConfigStorage", "(", ")", ";", "$", "storage", "->", "setName", "(", "$", "storage_name", ")", ";", "$", "this", "->", "storage", "[", "$", "storage_name", "]", "=", "$", "storage", ";", "return", "$", "storage", ";", "}" ]
Creates a named config storage object, adds it to the storages list and returns a reference to it. @param string $storage_name Name of storage to create @throws ConfigException @return ConfigStorage
[ "Creates", "a", "named", "config", "storage", "object", "adds", "it", "to", "the", "storages", "list", "and", "returns", "a", "reference", "to", "it", "." ]
7f62be12c40a3de9585c4826f0b71de13204896d
https://github.com/tekkla/core-config/blob/7f62be12c40a3de9585c4826f0b71de13204896d/Core/Config/Config.php#L73-L85
629
tekkla/core-config
Core/Config/Config.php
Config.set
public function set(string $storage_name, string $key, $val) { $this->storage[$storage_name]->set($key, $val); }
php
public function set(string $storage_name, string $key, $val) { $this->storage[$storage_name]->set($key, $val); }
[ "public", "function", "set", "(", "string", "$", "storage_name", ",", "string", "$", "key", ",", "$", "val", ")", "{", "$", "this", "->", "storage", "[", "$", "storage_name", "]", "->", "set", "(", "$", "key", ",", "$", "val", ")", ";", "}" ]
Set a cfg value. @param string $storage_name @param string $key @param mixed $val
[ "Set", "a", "cfg", "value", "." ]
7f62be12c40a3de9585c4826f0b71de13204896d
https://github.com/tekkla/core-config/blob/7f62be12c40a3de9585c4826f0b71de13204896d/Core/Config/Config.php#L142-L145
630
tekkla/core-config
Core/Config/Config.php
Config.exists
public function exists($storage_name, $key = null) { // No app found = false if (!isset($this->storage[$storage_name])) { return false; } // app found and no key requested? true if (!isset($key)) { return true; } // key requested and found? true return isset($this->storage[$storage_name]->{$key}) && !empty($this->storage[$storage_name]->{$key}); }
php
public function exists($storage_name, $key = null) { // No app found = false if (!isset($this->storage[$storage_name])) { return false; } // app found and no key requested? true if (!isset($key)) { return true; } // key requested and found? true return isset($this->storage[$storage_name]->{$key}) && !empty($this->storage[$storage_name]->{$key}); }
[ "public", "function", "exists", "(", "$", "storage_name", ",", "$", "key", "=", "null", ")", "{", "// No app found = false", "if", "(", "!", "isset", "(", "$", "this", "->", "storage", "[", "$", "storage_name", "]", ")", ")", "{", "return", "false", ";", "}", "// app found and no key requested? true", "if", "(", "!", "isset", "(", "$", "key", ")", ")", "{", "return", "true", ";", "}", "// key requested and found? true", "return", "isset", "(", "$", "this", "->", "storage", "[", "$", "storage_name", "]", "->", "{", "$", "key", "}", ")", "&&", "!", "empty", "(", "$", "this", "->", "storage", "[", "$", "storage_name", "]", "->", "{", "$", "key", "}", ")", ";", "}" ]
Checks the state of a cfg setting Returns true for set and false for not set. @param string $storage_name @param string $key @return boolean
[ "Checks", "the", "state", "of", "a", "cfg", "setting" ]
7f62be12c40a3de9585c4826f0b71de13204896d
https://github.com/tekkla/core-config/blob/7f62be12c40a3de9585c4826f0b71de13204896d/Core/Config/Config.php#L157-L171
631
tekkla/core-config
Core/Config/Config.php
Config.load
public function load($refresh = false) { $results = $this->repository->read(); /* @var $config \Core\Config\ConfigObject */ foreach ($results as $config) { $storage = $this->createStorage($config->getStorage()); $storage->set($config->getId(), $config->getValue()); } }
php
public function load($refresh = false) { $results = $this->repository->read(); /* @var $config \Core\Config\ConfigObject */ foreach ($results as $config) { $storage = $this->createStorage($config->getStorage()); $storage->set($config->getId(), $config->getValue()); } }
[ "public", "function", "load", "(", "$", "refresh", "=", "false", ")", "{", "$", "results", "=", "$", "this", "->", "repository", "->", "read", "(", ")", ";", "/* @var $config \\Core\\Config\\ConfigObject */", "foreach", "(", "$", "results", "as", "$", "config", ")", "{", "$", "storage", "=", "$", "this", "->", "createStorage", "(", "$", "config", "->", "getStorage", "(", ")", ")", ";", "$", "storage", "->", "set", "(", "$", "config", "->", "getId", "(", ")", ",", "$", "config", "->", "getValue", "(", ")", ")", ";", "}", "}" ]
Loads config from database @param boolean $refresh Optional flag to force a refresh load of the config that updates the cached config too @return void
[ "Loads", "config", "from", "database" ]
7f62be12c40a3de9585c4826f0b71de13204896d
https://github.com/tekkla/core-config/blob/7f62be12c40a3de9585c4826f0b71de13204896d/Core/Config/Config.php#L181-L190
632
tekkla/core-framework
Core/Framework/Page/Body/Menu/MenuItem.php
MenuItem.setCss
public function setCss($css) { if (is_array($css)) $css = implode(' ', $css); $this->css = $css; return $this; }
php
public function setCss($css) { if (is_array($css)) $css = implode(' ', $css); $this->css = $css; return $this; }
[ "public", "function", "setCss", "(", "$", "css", ")", "{", "if", "(", "is_array", "(", "$", "css", ")", ")", "$", "css", "=", "implode", "(", "' '", ",", "$", "css", ")", ";", "$", "this", "->", "css", "=", "$", "css", ";", "return", "$", "this", ";", "}" ]
Sets css classes to be used in menulink. Argument can an array and will be transformed into a string @param string $css @return MenuItem
[ "Sets", "css", "classes", "to", "be", "used", "in", "menulink", ".", "Argument", "can", "an", "array", "and", "will", "be", "transformed", "into", "a", "string" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Body/Menu/MenuItem.php#L232-L240
633
tekkla/core-framework
Core/Framework/Page/Body/Menu/MenuItem.php
MenuItem.setOption
public function setOption($option, $value = '') { if (is_array($option)) { foreach ($option as $key => $value) { $this->options[$key] = $value; } } else { $this->options[$option] = $value; } return $this; }
php
public function setOption($option, $value = '') { if (is_array($option)) { foreach ($option as $key => $value) { $this->options[$key] = $value; } } else { $this->options[$option] = $value; } return $this; }
[ "public", "function", "setOption", "(", "$", "option", ",", "$", "value", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "option", ")", ")", "{", "foreach", "(", "$", "option", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "options", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "else", "{", "$", "this", "->", "options", "[", "$", "option", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Sets one or more options. @param string|array $option Name of option or assoc array of options. @param mixed $value Optional value when setting only one option. @return MenuItem
[ "Sets", "one", "or", "more", "options", "." ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Page/Body/Menu/MenuItem.php#L252-L264
634
hediet/php-type-reflection
src/Hediet/Types/UnionType.php
UnionType.getName
public function getName(array $options = array()) { $result = ""; foreach ($this->getUnitedTypes() as $type) { if ($result !== "") $result .= "|"; $result .= $type->getName(); } return $result; }
php
public function getName(array $options = array()) { $result = ""; foreach ($this->getUnitedTypes() as $type) { if ($result !== "") $result .= "|"; $result .= $type->getName(); } return $result; }
[ "public", "function", "getName", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "result", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "getUnitedTypes", "(", ")", "as", "$", "type", ")", "{", "if", "(", "$", "result", "!==", "\"\"", ")", "$", "result", ".=", "\"|\"", ";", "$", "result", ".=", "$", "type", "->", "getName", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Gets the name of the union type. This name is canonical, so two equal union types have the same name. @param array $options @return string
[ "Gets", "the", "name", "of", "the", "union", "type", ".", "This", "name", "is", "canonical", "so", "two", "equal", "union", "types", "have", "the", "same", "name", "." ]
4a049c0e35f35cf95769f3823c915a3c41d6a292
https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/UnionType.php#L118-L128
635
ionutmilica/ionix-framework
src/View/ViewFinder.php
ViewFinder.find
public function find($view) { $view = str_replace('.', DIRECTORY_SEPARATOR, $view) . '.php'; foreach ($this->locations as $location) { if (is_file($path = $location.'/'.$view)) { return $path; } } return false; }
php
public function find($view) { $view = str_replace('.', DIRECTORY_SEPARATOR, $view) . '.php'; foreach ($this->locations as $location) { if (is_file($path = $location.'/'.$view)) { return $path; } } return false; }
[ "public", "function", "find", "(", "$", "view", ")", "{", "$", "view", "=", "str_replace", "(", "'.'", ",", "DIRECTORY_SEPARATOR", ",", "$", "view", ")", ".", "'.php'", ";", "foreach", "(", "$", "this", "->", "locations", "as", "$", "location", ")", "{", "if", "(", "is_file", "(", "$", "path", "=", "$", "location", ".", "'/'", ".", "$", "view", ")", ")", "{", "return", "$", "path", ";", "}", "}", "return", "false", ";", "}" ]
Search for the view and return the path @param $view @return bool|string
[ "Search", "for", "the", "view", "and", "return", "the", "path" ]
a0363667ff677f1772bdd9ac9530a9f4710f9321
https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/View/ViewFinder.php#L21-L33
636
cityware/city-snmp
src/MIBS/Extreme/System/Common.php
Common.powerSupplyStatus
public function powerSupplyStatus( $translate = false ) { $states = $this->getSNMP()->walk1d( self::OID_POWER_SUPPLY_STATUS ); if( !$translate ) return $states; return $this->getSNMP()->translate( $states, self::$POWER_SUPPLY_STATES ); }
php
public function powerSupplyStatus( $translate = false ) { $states = $this->getSNMP()->walk1d( self::OID_POWER_SUPPLY_STATUS ); if( !$translate ) return $states; return $this->getSNMP()->translate( $states, self::$POWER_SUPPLY_STATES ); }
[ "public", "function", "powerSupplyStatus", "(", "$", "translate", "=", "false", ")", "{", "$", "states", "=", "$", "this", "->", "getSNMP", "(", ")", "->", "walk1d", "(", "self", "::", "OID_POWER_SUPPLY_STATUS", ")", ";", "if", "(", "!", "$", "translate", ")", "return", "$", "states", ";", "return", "$", "this", "->", "getSNMP", "(", ")", "->", "translate", "(", "$", "states", ",", "self", "::", "$", "POWER_SUPPLY_STATES", ")", ";", "}" ]
Get the identifiers of the power supplies E.g. from a X670V-48x without $translate: [ [1] => 2 [2] => 2 ] E.g. from a X670V-48x with $translate: [ [1] => "presentOK" [2] => "presentOK" ] @param boolean $translate If true, return the string representation via self::$POWER_SUPPLY_STATES @return array Identifiers of the power supplies
[ "Get", "the", "identifiers", "of", "the", "power", "supplies" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Extreme/System/Common.php#L206-L214
637
cityware/city-snmp
src/MIBS/Extreme/System/Common.php
Common.powerSupplySource
public function powerSupplySource( $translate = false ) { $states = $this->getSNMP()->walk1d( self::OID_POWER_SUPPLY_SOURCE ); if( !$translate ) return $states; return $this->getSNMP()->translate( $states, self::$POWER_SUPPLY_SOURCES ); }
php
public function powerSupplySource( $translate = false ) { $states = $this->getSNMP()->walk1d( self::OID_POWER_SUPPLY_SOURCE ); if( !$translate ) return $states; return $this->getSNMP()->translate( $states, self::$POWER_SUPPLY_SOURCES ); }
[ "public", "function", "powerSupplySource", "(", "$", "translate", "=", "false", ")", "{", "$", "states", "=", "$", "this", "->", "getSNMP", "(", ")", "->", "walk1d", "(", "self", "::", "OID_POWER_SUPPLY_SOURCE", ")", ";", "if", "(", "!", "$", "translate", ")", "return", "$", "states", ";", "return", "$", "this", "->", "getSNMP", "(", ")", "->", "translate", "(", "$", "states", ",", "self", "::", "$", "POWER_SUPPLY_SOURCES", ")", ";", "}" ]
The power supply unit input source. @param boolean $translate If true, return the string representation via self::$POWER_SUPPLY_SOURCES @return array The power supply unit input source.
[ "The", "power", "supply", "unit", "input", "source", "." ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Extreme/System/Common.php#L355-L363
638
cityware/city-snmp
src/MIBS/Extreme/System/Common.php
Common.systemPowerState
public function systemPowerState( $translate = false ) { $states = $this->getSNMP()->get( self::OID_SYSTEM_POWER_STATE ); if( !$translate ) return $states; return $this->getSNMP()->translate( $states, self::$POWER_STATES ); }
php
public function systemPowerState( $translate = false ) { $states = $this->getSNMP()->get( self::OID_SYSTEM_POWER_STATE ); if( !$translate ) return $states; return $this->getSNMP()->translate( $states, self::$POWER_STATES ); }
[ "public", "function", "systemPowerState", "(", "$", "translate", "=", "false", ")", "{", "$", "states", "=", "$", "this", "->", "getSNMP", "(", ")", "->", "get", "(", "self", "::", "OID_SYSTEM_POWER_STATE", ")", ";", "if", "(", "!", "$", "translate", ")", "return", "$", "states", ";", "return", "$", "this", "->", "getSNMP", "(", ")", "->", "translate", "(", "$", "states", ",", "self", "::", "$", "POWER_STATES", ")", ";", "}" ]
The system power state @param boolean $translate If true, return the string representation via self::$POWER_STATES @return array The power state.
[ "The", "system", "power", "state" ]
831b7485b6c932a84f081d5ceeb9c5f4e7a8641d
https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Extreme/System/Common.php#L410-L418
639
eosnewmedia/Transformer
src/Transformer/Transformer.php
Transformer.transform
public function transform($returnClass, $config, $values, $local_config = null, $result_type = 'object') { $value = $this->setLocalConfig($local_config)->process($returnClass, $config, $values); $value = $this->converter->convertTo($value, $result_type); return $value; }
php
public function transform($returnClass, $config, $values, $local_config = null, $result_type = 'object') { $value = $this->setLocalConfig($local_config)->process($returnClass, $config, $values); $value = $this->converter->convertTo($value, $result_type); return $value; }
[ "public", "function", "transform", "(", "$", "returnClass", ",", "$", "config", ",", "$", "values", ",", "$", "local_config", "=", "null", ",", "$", "result_type", "=", "'object'", ")", "{", "$", "value", "=", "$", "this", "->", "setLocalConfig", "(", "$", "local_config", ")", "->", "process", "(", "$", "returnClass", ",", "$", "config", ",", "$", "values", ")", ";", "$", "value", "=", "$", "this", "->", "converter", "->", "convertTo", "(", "$", "value", ",", "$", "result_type", ")", ";", "return", "$", "value", ";", "}" ]
This method transforms an array, an object or a json into the needed format. It will validate the structure and the values with reference to a given configuration array. @param object|string $returnClass @param array|object|string $config @param array|object|string $values @param null|array|string|object $local_config @param string $result_type @return array|object|string @throws \Enm\Transformer\Exceptions\TransformerException
[ "This", "method", "transforms", "an", "array", "an", "object", "or", "a", "json", "into", "the", "needed", "format", ".", "It", "will", "validate", "the", "structure", "and", "the", "values", "with", "reference", "to", "a", "given", "configuration", "array", "." ]
61bcf40195fc509074ff6dd38309376f6a98e367
https://github.com/eosnewmedia/Transformer/blob/61bcf40195fc509074ff6dd38309376f6a98e367/src/Transformer/Transformer.php#L28-L35
640
eosnewmedia/Transformer
src/Transformer/Transformer.php
Transformer.reverseTransform
public function reverseTransform($object, $config, $local_config = null, $result_type = 'object') { $value = $this->setLocalConfig($local_config)->reverseProcess($config, $object); $value = $this->converter->convertTo($value, $result_type); return $value; }
php
public function reverseTransform($object, $config, $local_config = null, $result_type = 'object') { $value = $this->setLocalConfig($local_config)->reverseProcess($config, $object); $value = $this->converter->convertTo($value, $result_type); return $value; }
[ "public", "function", "reverseTransform", "(", "$", "object", ",", "$", "config", ",", "$", "local_config", "=", "null", ",", "$", "result_type", "=", "'object'", ")", "{", "$", "value", "=", "$", "this", "->", "setLocalConfig", "(", "$", "local_config", ")", "->", "reverseProcess", "(", "$", "config", ",", "$", "object", ")", ";", "$", "value", "=", "$", "this", "->", "converter", "->", "convertTo", "(", "$", "value", ",", "$", "result_type", ")", ";", "return", "$", "value", ";", "}" ]
This method reverses the transforming. @param object|object|string $object @param array|object|string $config @param null|array|string|object $local_config @param string $result_type @return array|\stdClass|string @throws \Enm\Transformer\Exceptions\TransformerException
[ "This", "method", "reverses", "the", "transforming", "." ]
61bcf40195fc509074ff6dd38309376f6a98e367
https://github.com/eosnewmedia/Transformer/blob/61bcf40195fc509074ff6dd38309376f6a98e367/src/Transformer/Transformer.php#L50-L57
641
eosnewmedia/Transformer
src/Transformer/Transformer.php
Transformer.getEmptyObjectStructureFromConfig
public function getEmptyObjectStructureFromConfig($config, $result_type = 'object') { $value = $this->createEmptyObjectStructure($config); $value = $this->converter->convertTo($value, $result_type); return $value; }
php
public function getEmptyObjectStructureFromConfig($config, $result_type = 'object') { $value = $this->createEmptyObjectStructure($config); $value = $this->converter->convertTo($value, $result_type); return $value; }
[ "public", "function", "getEmptyObjectStructureFromConfig", "(", "$", "config", ",", "$", "result_type", "=", "'object'", ")", "{", "$", "value", "=", "$", "this", "->", "createEmptyObjectStructure", "(", "$", "config", ")", ";", "$", "value", "=", "$", "this", "->", "converter", "->", "convertTo", "(", "$", "value", ",", "$", "result_type", ")", ";", "return", "$", "value", ";", "}" ]
Creates the Structure of an Object with NULL-Values @param array $config @param string $result_type @return array|object|string
[ "Creates", "the", "Structure", "of", "an", "Object", "with", "NULL", "-", "Values" ]
61bcf40195fc509074ff6dd38309376f6a98e367
https://github.com/eosnewmedia/Transformer/blob/61bcf40195fc509074ff6dd38309376f6a98e367/src/Transformer/Transformer.php#L69-L75
642
eosnewmedia/Transformer
src/Transformer/Transformer.php
Transformer.convert
public function convert($value, $to, array $exclude = array(), $max_nesting_level = null) { return $this->converter->convertTo($value, $to, $exclude, $max_nesting_level); }
php
public function convert($value, $to, array $exclude = array(), $max_nesting_level = null) { return $this->converter->convertTo($value, $to, $exclude, $max_nesting_level); }
[ "public", "function", "convert", "(", "$", "value", ",", "$", "to", ",", "array", "$", "exclude", "=", "array", "(", ")", ",", "$", "max_nesting_level", "=", "null", ")", "{", "return", "$", "this", "->", "converter", "->", "convertTo", "(", "$", "value", ",", "$", "to", ",", "$", "exclude", ",", "$", "max_nesting_level", ")", ";", "}" ]
Converts a value to an other format. @param mixed $value @param string $to @param array $exclude @param int $max_nesting_level default value is 30 @return array|object|string
[ "Converts", "a", "value", "to", "an", "other", "format", "." ]
61bcf40195fc509074ff6dd38309376f6a98e367
https://github.com/eosnewmedia/Transformer/blob/61bcf40195fc509074ff6dd38309376f6a98e367/src/Transformer/Transformer.php#L89-L92
643
elastification/php-client
src/Repository/CatRepository.php
CatRepository.aliases
public function aliases() { $request = $this->createRequestInstance(self::CAT_ALIASES, null, null); return $this->client->send($request); }
php
public function aliases() { $request = $this->createRequestInstance(self::CAT_ALIASES, null, null); return $this->client->send($request); }
[ "public", "function", "aliases", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_ALIASES", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets aliases from cat api @return \Elastification\Client\Response\ResponseInterface @author Daniel Wendlandt
[ "Gets", "aliases", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L33-L38
644
elastification/php-client
src/Repository/CatRepository.php
CatRepository.allocation
public function allocation() { $request = $this->createRequestInstance(self::CAT_ALLOCATION, null, null); return $this->client->send($request); }
php
public function allocation() { $request = $this->createRequestInstance(self::CAT_ALLOCATION, null, null); return $this->client->send($request); }
[ "public", "function", "allocation", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_ALLOCATION", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets allocation from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "allocation", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L45-L50
645
elastification/php-client
src/Repository/CatRepository.php
CatRepository.count
public function count() { $request = $this->createRequestInstance(self::CAT_COUNT, null, null); return $this->client->send($request); }
php
public function count() { $request = $this->createRequestInstance(self::CAT_COUNT, null, null); return $this->client->send($request); }
[ "public", "function", "count", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_COUNT", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets count from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "count", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L57-L62
646
elastification/php-client
src/Repository/CatRepository.php
CatRepository.fielddata
public function fielddata() { $request = $this->createRequestInstance(self::CAT_FIELDDATA, null, null); return $this->client->send($request); }
php
public function fielddata() { $request = $this->createRequestInstance(self::CAT_FIELDDATA, null, null); return $this->client->send($request); }
[ "public", "function", "fielddata", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_FIELDDATA", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets fielddata from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "fielddata", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L69-L74
647
elastification/php-client
src/Repository/CatRepository.php
CatRepository.health
public function health() { $request = $this->createRequestInstance(self::CAT_HEALTH, null, null); return $this->client->send($request); }
php
public function health() { $request = $this->createRequestInstance(self::CAT_HEALTH, null, null); return $this->client->send($request); }
[ "public", "function", "health", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_HEALTH", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets health from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "health", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L81-L86
648
elastification/php-client
src/Repository/CatRepository.php
CatRepository.indices
public function indices() { $request = $this->createRequestInstance(self::CAT_INDICES, null, null); return $this->client->send($request); }
php
public function indices() { $request = $this->createRequestInstance(self::CAT_INDICES, null, null); return $this->client->send($request); }
[ "public", "function", "indices", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_INDICES", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets indices from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "indices", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L93-L98
649
elastification/php-client
src/Repository/CatRepository.php
CatRepository.master
public function master() { $request = $this->createRequestInstance(self::CAT_MASTER, null, null); return $this->client->send($request); }
php
public function master() { $request = $this->createRequestInstance(self::CAT_MASTER, null, null); return $this->client->send($request); }
[ "public", "function", "master", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_MASTER", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets master from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "master", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L105-L110
650
elastification/php-client
src/Repository/CatRepository.php
CatRepository.nodes
public function nodes() { $request = $this->createRequestInstance(self::CAT_NODES, null, null); return $this->client->send($request); }
php
public function nodes() { $request = $this->createRequestInstance(self::CAT_NODES, null, null); return $this->client->send($request); }
[ "public", "function", "nodes", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_NODES", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets nodes from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "nodes", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L117-L122
651
elastification/php-client
src/Repository/CatRepository.php
CatRepository.pendingTasks
public function pendingTasks() { $request = $this->createRequestInstance(self::CAT_PENDING_TASKS, null, null); return $this->client->send($request); }
php
public function pendingTasks() { $request = $this->createRequestInstance(self::CAT_PENDING_TASKS, null, null); return $this->client->send($request); }
[ "public", "function", "pendingTasks", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_PENDING_TASKS", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets pending tasks from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "pending", "tasks", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L129-L134
652
elastification/php-client
src/Repository/CatRepository.php
CatRepository.plugins
public function plugins() { $request = $this->createRequestInstance(self::CAT_PLUGINS, null, null); return $this->client->send($request); }
php
public function plugins() { $request = $this->createRequestInstance(self::CAT_PLUGINS, null, null); return $this->client->send($request); }
[ "public", "function", "plugins", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_PLUGINS", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets plugins from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "plugins", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L141-L146
653
elastification/php-client
src/Repository/CatRepository.php
CatRepository.recovery
public function recovery() { $request = $this->createRequestInstance(self::CAT_RECOVERY, null, null); return $this->client->send($request); }
php
public function recovery() { $request = $this->createRequestInstance(self::CAT_RECOVERY, null, null); return $this->client->send($request); }
[ "public", "function", "recovery", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_RECOVERY", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets recovery from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "recovery", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L153-L158
654
elastification/php-client
src/Repository/CatRepository.php
CatRepository.segments
public function segments() { $request = $this->createRequestInstance(self::CAT_SEGMENTS, null, null); return $this->client->send($request); }
php
public function segments() { $request = $this->createRequestInstance(self::CAT_SEGMENTS, null, null); return $this->client->send($request); }
[ "public", "function", "segments", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_SEGMENTS", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets segments from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "segments", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L165-L170
655
elastification/php-client
src/Repository/CatRepository.php
CatRepository.shards
public function shards() { $request = $this->createRequestInstance(self::CAT_SHARDS, null, null); return $this->client->send($request); }
php
public function shards() { $request = $this->createRequestInstance(self::CAT_SHARDS, null, null); return $this->client->send($request); }
[ "public", "function", "shards", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_SHARDS", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets shards from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "shards", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L177-L182
656
elastification/php-client
src/Repository/CatRepository.php
CatRepository.threadPool
public function threadPool() { $request = $this->createRequestInstance(self::CAT_THREAD_POOL, null, null); return $this->client->send($request); }
php
public function threadPool() { $request = $this->createRequestInstance(self::CAT_THREAD_POOL, null, null); return $this->client->send($request); }
[ "public", "function", "threadPool", "(", ")", "{", "$", "request", "=", "$", "this", "->", "createRequestInstance", "(", "self", "::", "CAT_THREAD_POOL", ",", "null", ",", "null", ")", ";", "return", "$", "this", "->", "client", "->", "send", "(", "$", "request", ")", ";", "}" ]
Gets thread pool from cat api @return \Elastification\Client\Response\ResponseInterface
[ "Gets", "thread", "pool", "from", "cat", "api" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L189-L194
657
elastification/php-client
src/Repository/CatRepository.php
CatRepository.getClass
protected function getClass($class) { if(ClientVersionMapInterface::VERSION_V090X === $this->versionFolder) { throw new RepositoryException('Version folder ' . ClientVersionMapInterface::VERSION_V090X . ' is not allowed for cat repository'); } return parent::getClass($class); }
php
protected function getClass($class) { if(ClientVersionMapInterface::VERSION_V090X === $this->versionFolder) { throw new RepositoryException('Version folder ' . ClientVersionMapInterface::VERSION_V090X . ' is not allowed for cat repository'); } return parent::getClass($class); }
[ "protected", "function", "getClass", "(", "$", "class", ")", "{", "if", "(", "ClientVersionMapInterface", "::", "VERSION_V090X", "===", "$", "this", "->", "versionFolder", ")", "{", "throw", "new", "RepositoryException", "(", "'Version folder '", ".", "ClientVersionMapInterface", "::", "VERSION_V090X", ".", "' is not allowed for cat repository'", ")", ";", "}", "return", "parent", "::", "getClass", "(", "$", "class", ")", ";", "}" ]
gets the right class string of a version @param string $class @return string @throws RepositoryException @author Daniel Wendlandt
[ "gets", "the", "right", "class", "string", "of", "a", "version" ]
eb01be0905dd1eba7baa62f84492d82e4b3cae61
https://github.com/elastification/php-client/blob/eb01be0905dd1eba7baa62f84492d82e4b3cae61/src/Repository/CatRepository.php#L205-L213
658
consigliere/components
src/Commands/InstallCommand.php
InstallCommand.installFromFile
protected function installFromFile() { if (!file_exists($path = base_path('components.json'))) { $this->error("File 'components.json' does not exist in your project root."); return; } $components = Json::make($path); $dependencies = $components->get('require', []); foreach ($dependencies as $component) { $component = collect($component); $this->install( $component->get('name'), $component->get('version'), $component->get('type') ); } }
php
protected function installFromFile() { if (!file_exists($path = base_path('components.json'))) { $this->error("File 'components.json' does not exist in your project root."); return; } $components = Json::make($path); $dependencies = $components->get('require', []); foreach ($dependencies as $component) { $component = collect($component); $this->install( $component->get('name'), $component->get('version'), $component->get('type') ); } }
[ "protected", "function", "installFromFile", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "path", "=", "base_path", "(", "'components.json'", ")", ")", ")", "{", "$", "this", "->", "error", "(", "\"File 'components.json' does not exist in your project root.\"", ")", ";", "return", ";", "}", "$", "components", "=", "Json", "::", "make", "(", "$", "path", ")", ";", "$", "dependencies", "=", "$", "components", "->", "get", "(", "'require'", ",", "[", "]", ")", ";", "foreach", "(", "$", "dependencies", "as", "$", "component", ")", "{", "$", "component", "=", "collect", "(", "$", "component", ")", ";", "$", "this", "->", "install", "(", "$", "component", "->", "get", "(", "'name'", ")", ",", "$", "component", "->", "get", "(", "'version'", ")", ",", "$", "component", "->", "get", "(", "'type'", ")", ")", ";", "}", "}" ]
Install components from components.json file.
[ "Install", "components", "from", "components", ".", "json", "file", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Commands/InstallCommand.php#L59-L80
659
consigliere/components
src/Commands/InstallCommand.php
InstallCommand.install
protected function install($name, $version = 'dev-master', $type = 'composer', $tree = false) { $installer = new Installer( $name, $version, $type ?: $this->option('type'), $tree ?: $this->option('tree') ); $installer->setRepository($this->laravel['components']); $installer->setConsole($this); if ($timeout = $this->option('timeout')) { $installer->setTimeout($timeout); } if ($path = $this->option('path')) { $installer->setPath($path); } $installer->run(); if (!$this->option('no-update')) { $this->call('component:update', [ 'component' => $installer->getComponentName(), ]); } }
php
protected function install($name, $version = 'dev-master', $type = 'composer', $tree = false) { $installer = new Installer( $name, $version, $type ?: $this->option('type'), $tree ?: $this->option('tree') ); $installer->setRepository($this->laravel['components']); $installer->setConsole($this); if ($timeout = $this->option('timeout')) { $installer->setTimeout($timeout); } if ($path = $this->option('path')) { $installer->setPath($path); } $installer->run(); if (!$this->option('no-update')) { $this->call('component:update', [ 'component' => $installer->getComponentName(), ]); } }
[ "protected", "function", "install", "(", "$", "name", ",", "$", "version", "=", "'dev-master'", ",", "$", "type", "=", "'composer'", ",", "$", "tree", "=", "false", ")", "{", "$", "installer", "=", "new", "Installer", "(", "$", "name", ",", "$", "version", ",", "$", "type", "?", ":", "$", "this", "->", "option", "(", "'type'", ")", ",", "$", "tree", "?", ":", "$", "this", "->", "option", "(", "'tree'", ")", ")", ";", "$", "installer", "->", "setRepository", "(", "$", "this", "->", "laravel", "[", "'components'", "]", ")", ";", "$", "installer", "->", "setConsole", "(", "$", "this", ")", ";", "if", "(", "$", "timeout", "=", "$", "this", "->", "option", "(", "'timeout'", ")", ")", "{", "$", "installer", "->", "setTimeout", "(", "$", "timeout", ")", ";", "}", "if", "(", "$", "path", "=", "$", "this", "->", "option", "(", "'path'", ")", ")", "{", "$", "installer", "->", "setPath", "(", "$", "path", ")", ";", "}", "$", "installer", "->", "run", "(", ")", ";", "if", "(", "!", "$", "this", "->", "option", "(", "'no-update'", ")", ")", "{", "$", "this", "->", "call", "(", "'component:update'", ",", "[", "'component'", "=>", "$", "installer", "->", "getComponentName", "(", ")", ",", "]", ")", ";", "}", "}" ]
Install the specified component. @param string $name @param string $version @param string $type @param bool $tree
[ "Install", "the", "specified", "component", "." ]
9b08bb111f0b55b0a860ed9c3407eda0d9cc1252
https://github.com/consigliere/components/blob/9b08bb111f0b55b0a860ed9c3407eda0d9cc1252/src/Commands/InstallCommand.php#L90-L118
660
100hz/hive-console
src/Hive/Console/TemplateCommand.php
TemplateCommand.getWebPath
protected function getWebPath($output) { $path = trim(dirname($output), '/'); $count = count(explode('/', $path)); $path = ''; for ($i = 0; $i < $count-1; $i++) { $path.= '/..'; } return $path; }
php
protected function getWebPath($output) { $path = trim(dirname($output), '/'); $count = count(explode('/', $path)); $path = ''; for ($i = 0; $i < $count-1; $i++) { $path.= '/..'; } return $path; }
[ "protected", "function", "getWebPath", "(", "$", "output", ")", "{", "$", "path", "=", "trim", "(", "dirname", "(", "$", "output", ")", ",", "'/'", ")", ";", "$", "count", "=", "count", "(", "explode", "(", "'/'", ",", "$", "path", ")", ")", ";", "$", "path", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", "-", "1", ";", "$", "i", "++", ")", "{", "$", "path", ".=", "'/..'", ";", "}", "return", "$", "path", ";", "}" ]
Computes the relative path within the web root folder. Expects the standard hive-app project layout. @param $output @return string
[ "Computes", "the", "relative", "path", "within", "the", "web", "root", "folder", ".", "Expects", "the", "standard", "hive", "-", "app", "project", "layout", "." ]
368c6716dbc3304a3730d07bf78f26bd3107f5a4
https://github.com/100hz/hive-console/blob/368c6716dbc3304a3730d07bf78f26bd3107f5a4/src/Hive/Console/TemplateCommand.php#L105-L117
661
registripe/registripe-core
code/controllers/EventAttendeeController.php
EventAttendeeController.add
public function add($request) { $tickets = $this->registration->Event()->getAvailableTickets(); $form = $this->AttendeeForm(); // check tickets are actually available if (!$tickets->count()) { return $this->redirect($this->BackURL); } $formHasData = $form->hasSessionData(); $attendee = $this->createAttendee(); // ticket selection in url $ticket = $tickets->byID((int)$request->param('ID')); if($ticket && !$ticket->exists()){ $attendee->TicketID = $ticket->ID; $form->setAllowedTickets( $this->registration->Event()->getAvailableTickets() ); } // ticket is always required if($ticket) { $form->loadDataFrom(array( "TicketID" => $ticket->ID )); }else{ $form->setAllowedTickets( $this->registration->Event()->getAvailableTickets() ); } if(!$formHasData){ // load any default data $form->loadDataFrom($attendee); // automatically populate from previous attendee $this->populatePreviousData($form); } $this->extend("onAdd", $form, $this->registration); return array( 'Title' => $ticket ? $ticket->Title : null, 'Form' => $form ); }
php
public function add($request) { $tickets = $this->registration->Event()->getAvailableTickets(); $form = $this->AttendeeForm(); // check tickets are actually available if (!$tickets->count()) { return $this->redirect($this->BackURL); } $formHasData = $form->hasSessionData(); $attendee = $this->createAttendee(); // ticket selection in url $ticket = $tickets->byID((int)$request->param('ID')); if($ticket && !$ticket->exists()){ $attendee->TicketID = $ticket->ID; $form->setAllowedTickets( $this->registration->Event()->getAvailableTickets() ); } // ticket is always required if($ticket) { $form->loadDataFrom(array( "TicketID" => $ticket->ID )); }else{ $form->setAllowedTickets( $this->registration->Event()->getAvailableTickets() ); } if(!$formHasData){ // load any default data $form->loadDataFrom($attendee); // automatically populate from previous attendee $this->populatePreviousData($form); } $this->extend("onAdd", $form, $this->registration); return array( 'Title' => $ticket ? $ticket->Title : null, 'Form' => $form ); }
[ "public", "function", "add", "(", "$", "request", ")", "{", "$", "tickets", "=", "$", "this", "->", "registration", "->", "Event", "(", ")", "->", "getAvailableTickets", "(", ")", ";", "$", "form", "=", "$", "this", "->", "AttendeeForm", "(", ")", ";", "// check tickets are actually available", "if", "(", "!", "$", "tickets", "->", "count", "(", ")", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "BackURL", ")", ";", "}", "$", "formHasData", "=", "$", "form", "->", "hasSessionData", "(", ")", ";", "$", "attendee", "=", "$", "this", "->", "createAttendee", "(", ")", ";", "// ticket selection in url", "$", "ticket", "=", "$", "tickets", "->", "byID", "(", "(", "int", ")", "$", "request", "->", "param", "(", "'ID'", ")", ")", ";", "if", "(", "$", "ticket", "&&", "!", "$", "ticket", "->", "exists", "(", ")", ")", "{", "$", "attendee", "->", "TicketID", "=", "$", "ticket", "->", "ID", ";", "$", "form", "->", "setAllowedTickets", "(", "$", "this", "->", "registration", "->", "Event", "(", ")", "->", "getAvailableTickets", "(", ")", ")", ";", "}", "// ticket is always required", "if", "(", "$", "ticket", ")", "{", "$", "form", "->", "loadDataFrom", "(", "array", "(", "\"TicketID\"", "=>", "$", "ticket", "->", "ID", ")", ")", ";", "}", "else", "{", "$", "form", "->", "setAllowedTickets", "(", "$", "this", "->", "registration", "->", "Event", "(", ")", "->", "getAvailableTickets", "(", ")", ")", ";", "}", "if", "(", "!", "$", "formHasData", ")", "{", "// load any default data", "$", "form", "->", "loadDataFrom", "(", "$", "attendee", ")", ";", "// automatically populate from previous attendee", "$", "this", "->", "populatePreviousData", "(", "$", "form", ")", ";", "}", "$", "this", "->", "extend", "(", "\"onAdd\"", ",", "$", "form", ",", "$", "this", "->", "registration", ")", ";", "return", "array", "(", "'Title'", "=>", "$", "ticket", "?", "$", "ticket", "->", "Title", ":", "null", ",", "'Form'", "=>", "$", "form", ")", ";", "}" ]
Add action renders the add attendee form. @param HTTPRequest $request @return array
[ "Add", "action", "renders", "the", "add", "attendee", "form", "." ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/controllers/EventAttendeeController.php#L28-L68
662
registripe/registripe-core
code/controllers/EventAttendeeController.php
EventAttendeeController.populatePreviousData
protected function populatePreviousData(Form $form) { $prepops = EventAttendee::config()->prepopulated_fields; if (!$prepops) { return; } $latestattendee = $this->registration->Attendees() ->sort("LastEdited", "DESC")->first(); if($latestattendee){ $form->loadDataFrom($latestattendee, Form::MERGE_DEFAULT, $prepops); } }
php
protected function populatePreviousData(Form $form) { $prepops = EventAttendee::config()->prepopulated_fields; if (!$prepops) { return; } $latestattendee = $this->registration->Attendees() ->sort("LastEdited", "DESC")->first(); if($latestattendee){ $form->loadDataFrom($latestattendee, Form::MERGE_DEFAULT, $prepops); } }
[ "protected", "function", "populatePreviousData", "(", "Form", "$", "form", ")", "{", "$", "prepops", "=", "EventAttendee", "::", "config", "(", ")", "->", "prepopulated_fields", ";", "if", "(", "!", "$", "prepops", ")", "{", "return", ";", "}", "$", "latestattendee", "=", "$", "this", "->", "registration", "->", "Attendees", "(", ")", "->", "sort", "(", "\"LastEdited\"", ",", "\"DESC\"", ")", "->", "first", "(", ")", ";", "if", "(", "$", "latestattendee", ")", "{", "$", "form", "->", "loadDataFrom", "(", "$", "latestattendee", ",", "Form", "::", "MERGE_DEFAULT", ",", "$", "prepops", ")", ";", "}", "}" ]
poplate given form with specfific data from last attednee
[ "poplate", "given", "form", "with", "specfific", "data", "from", "last", "attednee" ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/controllers/EventAttendeeController.php#L71-L81
663
registripe/registripe-core
code/controllers/EventAttendeeController.php
EventAttendeeController.edit
public function edit($request) { //get attendee from registration $attendee = $this->registration->Attendees() ->byID($request->param('ID')); if(!$attendee) { return $this->httpError(404, "Attendee not found"); } $form = $this->AttendeeForm(); //add tickets dropdown, if there is no selected ticket $ticket = $attendee->Ticket(); if(!$ticket->exists()){ $form->setAllowedTickets( $this->registration->Event()->getAvailableTickets() ); } if (!$form->hasSessionData()) { $form->loadDataFrom($attendee); } //add tickets dropdown, if there is no selected ticket $form->getValidator()->addRequiredField("ID"); $this->extend("onEdit", $form, $attendee, $this->registration); return array( 'Title' => $attendee->Ticket()->Title, 'Form' => $form ); }
php
public function edit($request) { //get attendee from registration $attendee = $this->registration->Attendees() ->byID($request->param('ID')); if(!$attendee) { return $this->httpError(404, "Attendee not found"); } $form = $this->AttendeeForm(); //add tickets dropdown, if there is no selected ticket $ticket = $attendee->Ticket(); if(!$ticket->exists()){ $form->setAllowedTickets( $this->registration->Event()->getAvailableTickets() ); } if (!$form->hasSessionData()) { $form->loadDataFrom($attendee); } //add tickets dropdown, if there is no selected ticket $form->getValidator()->addRequiredField("ID"); $this->extend("onEdit", $form, $attendee, $this->registration); return array( 'Title' => $attendee->Ticket()->Title, 'Form' => $form ); }
[ "public", "function", "edit", "(", "$", "request", ")", "{", "//get attendee from registration", "$", "attendee", "=", "$", "this", "->", "registration", "->", "Attendees", "(", ")", "->", "byID", "(", "$", "request", "->", "param", "(", "'ID'", ")", ")", ";", "if", "(", "!", "$", "attendee", ")", "{", "return", "$", "this", "->", "httpError", "(", "404", ",", "\"Attendee not found\"", ")", ";", "}", "$", "form", "=", "$", "this", "->", "AttendeeForm", "(", ")", ";", "//add tickets dropdown, if there is no selected ticket", "$", "ticket", "=", "$", "attendee", "->", "Ticket", "(", ")", ";", "if", "(", "!", "$", "ticket", "->", "exists", "(", ")", ")", "{", "$", "form", "->", "setAllowedTickets", "(", "$", "this", "->", "registration", "->", "Event", "(", ")", "->", "getAvailableTickets", "(", ")", ")", ";", "}", "if", "(", "!", "$", "form", "->", "hasSessionData", "(", ")", ")", "{", "$", "form", "->", "loadDataFrom", "(", "$", "attendee", ")", ";", "}", "//add tickets dropdown, if there is no selected ticket", "$", "form", "->", "getValidator", "(", ")", "->", "addRequiredField", "(", "\"ID\"", ")", ";", "$", "this", "->", "extend", "(", "\"onEdit\"", ",", "$", "form", ",", "$", "attendee", ",", "$", "this", "->", "registration", ")", ";", "return", "array", "(", "'Title'", "=>", "$", "attendee", "->", "Ticket", "(", ")", "->", "Title", ",", "'Form'", "=>", "$", "form", ")", ";", "}" ]
Edit action renders the attendee form, populated with existing details. @param HTTPRequest $request @return array
[ "Edit", "action", "renders", "the", "attendee", "form", "populated", "with", "existing", "details", "." ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/controllers/EventAttendeeController.php#L88-L113
664
registripe/registripe-core
code/controllers/EventAttendeeController.php
EventAttendeeController.save
public function save($data, $form) { //look for attendee id in form field or request params $attendeeid = $form->Fields()->fieldByName("ID")->dataValue(); //look for existing attendee $attendee = $this->registration->Attendees() ->byID((int)$attendeeid); //prevent changes to the type of ticket if($attendee && $attendee->TicketID && $attendee->TicketID != $data['TicketID']){ $form->sessionMessage('You cannot change the ticket', 'bad'); return $this->redirectBack(); } //create new attendee if(!$attendee){ $attendee = $this->createAttendee(); } //save ticket selection $form->saveInto($attendee); $attendee->write(); $this->registration->calculateTotal(); $this->registration->write(); $this->extend("onSave", $attendee, $this->registration); return $this->redirect($this->NextURL); }
php
public function save($data, $form) { //look for attendee id in form field or request params $attendeeid = $form->Fields()->fieldByName("ID")->dataValue(); //look for existing attendee $attendee = $this->registration->Attendees() ->byID((int)$attendeeid); //prevent changes to the type of ticket if($attendee && $attendee->TicketID && $attendee->TicketID != $data['TicketID']){ $form->sessionMessage('You cannot change the ticket', 'bad'); return $this->redirectBack(); } //create new attendee if(!$attendee){ $attendee = $this->createAttendee(); } //save ticket selection $form->saveInto($attendee); $attendee->write(); $this->registration->calculateTotal(); $this->registration->write(); $this->extend("onSave", $attendee, $this->registration); return $this->redirect($this->NextURL); }
[ "public", "function", "save", "(", "$", "data", ",", "$", "form", ")", "{", "//look for attendee id in form field or request params", "$", "attendeeid", "=", "$", "form", "->", "Fields", "(", ")", "->", "fieldByName", "(", "\"ID\"", ")", "->", "dataValue", "(", ")", ";", "//look for existing attendee", "$", "attendee", "=", "$", "this", "->", "registration", "->", "Attendees", "(", ")", "->", "byID", "(", "(", "int", ")", "$", "attendeeid", ")", ";", "//prevent changes to the type of ticket", "if", "(", "$", "attendee", "&&", "$", "attendee", "->", "TicketID", "&&", "$", "attendee", "->", "TicketID", "!=", "$", "data", "[", "'TicketID'", "]", ")", "{", "$", "form", "->", "sessionMessage", "(", "'You cannot change the ticket'", ",", "'bad'", ")", ";", "return", "$", "this", "->", "redirectBack", "(", ")", ";", "}", "//create new attendee", "if", "(", "!", "$", "attendee", ")", "{", "$", "attendee", "=", "$", "this", "->", "createAttendee", "(", ")", ";", "}", "//save ticket selection", "$", "form", "->", "saveInto", "(", "$", "attendee", ")", ";", "$", "attendee", "->", "write", "(", ")", ";", "$", "this", "->", "registration", "->", "calculateTotal", "(", ")", ";", "$", "this", "->", "registration", "->", "write", "(", ")", ";", "$", "this", "->", "extend", "(", "\"onSave\"", ",", "$", "attendee", ",", "$", "this", "->", "registration", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "NextURL", ")", ";", "}" ]
Save new and edited attendees @param array $data @param Form $form @return HTTPResponse
[ "Save", "new", "and", "edited", "attendees" ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/controllers/EventAttendeeController.php#L134-L159
665
registripe/registripe-core
code/controllers/EventAttendeeController.php
EventAttendeeController.createAttendee
protected function createAttendee() { $attendee = EventAttendee::create(); $attendee->RegistrationID = $this->registration->ID; return $attendee; }
php
protected function createAttendee() { $attendee = EventAttendee::create(); $attendee->RegistrationID = $this->registration->ID; return $attendee; }
[ "protected", "function", "createAttendee", "(", ")", "{", "$", "attendee", "=", "EventAttendee", "::", "create", "(", ")", ";", "$", "attendee", "->", "RegistrationID", "=", "$", "this", "->", "registration", "->", "ID", ";", "return", "$", "attendee", ";", "}" ]
Helper for creating new attendee on registration.
[ "Helper", "for", "creating", "new", "attendee", "on", "registration", "." ]
e52b3340aef323067ebfa9bd5fa07cb81bb63db9
https://github.com/registripe/registripe-core/blob/e52b3340aef323067ebfa9bd5fa07cb81bb63db9/code/controllers/EventAttendeeController.php#L187-L191
666
diatem-net/jin-image
src/Image/ImagickGd.php
ImagickGd.convertGDRessourceToImagick
public static function convertGDRessourceToImagick($imgRessource, $png = false) { ob_start(); if ($png) { imagepng($imgRessource, null, 0); } else { imagejpeg($imgRessource, null, 100); } $blob = ob_get_clean(); $image = new \Imagick(); $image->readImageBlob($blob); return $image; }
php
public static function convertGDRessourceToImagick($imgRessource, $png = false) { ob_start(); if ($png) { imagepng($imgRessource, null, 0); } else { imagejpeg($imgRessource, null, 100); } $blob = ob_get_clean(); $image = new \Imagick(); $image->readImageBlob($blob); return $image; }
[ "public", "static", "function", "convertGDRessourceToImagick", "(", "$", "imgRessource", ",", "$", "png", "=", "false", ")", "{", "ob_start", "(", ")", ";", "if", "(", "$", "png", ")", "{", "imagepng", "(", "$", "imgRessource", ",", "null", ",", "0", ")", ";", "}", "else", "{", "imagejpeg", "(", "$", "imgRessource", ",", "null", ",", "100", ")", ";", "}", "$", "blob", "=", "ob_get_clean", "(", ")", ";", "$", "image", "=", "new", "\\", "Imagick", "(", ")", ";", "$", "image", "->", "readImageBlob", "(", "$", "blob", ")", ";", "return", "$", "image", ";", "}" ]
Convertit une ressource image GD en objet Imagick @param resource $imgRessource Ressource image GD @param boolean $png PNG (true) ou JPEG (false) @return \Imagick
[ "Convertit", "une", "ressource", "image", "GD", "en", "objet", "Imagick" ]
b630c00d8172c051fcb9df36417bd12962bb21e8
https://github.com/diatem-net/jin-image/blob/b630c00d8172c051fcb9df36417bd12962bb21e8/src/Image/ImagickGd.php#L23-L37
667
diatem-net/jin-image
src/Image/ImagickGd.php
ImagickGd.convertImagickToGDRessource
public static function convertImagickToGDRessource(\Imagick $imagick, $png = false) { $imagick->setImageFormat('png'); $data = $imagick->getimageblob(); $im = imagecreatefromstring($data); if ($png) { imagealphablending($im, true); // setting alpha blending on imagesavealpha($im, true); } return $im; }
php
public static function convertImagickToGDRessource(\Imagick $imagick, $png = false) { $imagick->setImageFormat('png'); $data = $imagick->getimageblob(); $im = imagecreatefromstring($data); if ($png) { imagealphablending($im, true); // setting alpha blending on imagesavealpha($im, true); } return $im; }
[ "public", "static", "function", "convertImagickToGDRessource", "(", "\\", "Imagick", "$", "imagick", ",", "$", "png", "=", "false", ")", "{", "$", "imagick", "->", "setImageFormat", "(", "'png'", ")", ";", "$", "data", "=", "$", "imagick", "->", "getimageblob", "(", ")", ";", "$", "im", "=", "imagecreatefromstring", "(", "$", "data", ")", ";", "if", "(", "$", "png", ")", "{", "imagealphablending", "(", "$", "im", ",", "true", ")", ";", "// setting alpha blending on\r", "imagesavealpha", "(", "$", "im", ",", "true", ")", ";", "}", "return", "$", "im", ";", "}" ]
Convertir un objet Imagick en ressource image GD @param \Imagick $imagick Objet Imagick @return resource
[ "Convertir", "un", "objet", "Imagick", "en", "ressource", "image", "GD" ]
b630c00d8172c051fcb9df36417bd12962bb21e8
https://github.com/diatem-net/jin-image/blob/b630c00d8172c051fcb9df36417bd12962bb21e8/src/Image/ImagickGd.php#L45-L57
668
agalbourdin/agl-core
src/Observer/Observer.php
Observer.setEvents
public static function setEvents($pEvents = NULL) { if ($pEvents === NULL) { $pEvents = Agl::app()->getConfig('main/events'); } if (is_array($pEvents)) { self::$_events = $pEvents; } else { self::$_events = array(); } return self::$_events; }
php
public static function setEvents($pEvents = NULL) { if ($pEvents === NULL) { $pEvents = Agl::app()->getConfig('main/events'); } if (is_array($pEvents)) { self::$_events = $pEvents; } else { self::$_events = array(); } return self::$_events; }
[ "public", "static", "function", "setEvents", "(", "$", "pEvents", "=", "NULL", ")", "{", "if", "(", "$", "pEvents", "===", "NULL", ")", "{", "$", "pEvents", "=", "Agl", "::", "app", "(", ")", "->", "getConfig", "(", "'main/events'", ")", ";", "}", "if", "(", "is_array", "(", "$", "pEvents", ")", ")", "{", "self", "::", "$", "_events", "=", "$", "pEvents", ";", "}", "else", "{", "self", "::", "$", "_events", "=", "array", "(", ")", ";", "}", "return", "self", "::", "$", "_events", ";", "}" ]
Register events. Get events from the configuration by default. @param $pEvents null|array @return array
[ "Register", "events", ".", "Get", "events", "from", "the", "configuration", "by", "default", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Observer/Observer.php#L45-L58
669
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php
ElementtypeService.findElementtypeByUniqueId
public function findElementtypeByUniqueId($uniqueId) { foreach ($this->elementtypeManager->findAll() as $elementtype) { if ($elementtype->getUniqueId() === $uniqueId) { return $elementtype; } } return null; }
php
public function findElementtypeByUniqueId($uniqueId) { foreach ($this->elementtypeManager->findAll() as $elementtype) { if ($elementtype->getUniqueId() === $uniqueId) { return $elementtype; } } return null; }
[ "public", "function", "findElementtypeByUniqueId", "(", "$", "uniqueId", ")", "{", "foreach", "(", "$", "this", "->", "elementtypeManager", "->", "findAll", "(", ")", "as", "$", "elementtype", ")", "{", "if", "(", "$", "elementtype", "->", "getUniqueId", "(", ")", "===", "$", "uniqueId", ")", "{", "return", "$", "elementtype", ";", "}", "}", "return", "null", ";", "}" ]
Find element type by unique id. @param string $uniqueId @return Elementtype|null
[ "Find", "element", "type", "by", "unique", "id", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php#L78-L87
670
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php
ElementtypeService.findElementtypeByType
public function findElementtypeByType($type) { $elementtypes = []; foreach ($this->elementtypeManager->findAll() as $elementtype) { if ($elementtype->getType() === $type) { $elementtypes[] = $elementtype; } } return $elementtypes; }
php
public function findElementtypeByType($type) { $elementtypes = []; foreach ($this->elementtypeManager->findAll() as $elementtype) { if ($elementtype->getType() === $type) { $elementtypes[] = $elementtype; } } return $elementtypes; }
[ "public", "function", "findElementtypeByType", "(", "$", "type", ")", "{", "$", "elementtypes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "elementtypeManager", "->", "findAll", "(", ")", "as", "$", "elementtype", ")", "{", "if", "(", "$", "elementtype", "->", "getType", "(", ")", "===", "$", "type", ")", "{", "$", "elementtypes", "[", "]", "=", "$", "elementtype", ";", "}", "}", "return", "$", "elementtypes", ";", "}" ]
Find element type by type. @param string $type @return Elementtype[]
[ "Find", "element", "type", "by", "type", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php#L96-L106
671
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php
ElementtypeService.createElementtype
public function createElementtype( $type, $uniqueId, $name, $icon, ElementtypeStructure $elementtypeStructure = null, array $mappings = null, $user, $flush = true) { if (!$icon) { $icons = [ Elementtype::TYPE_FULL => 'artikel_list.gif', Elementtype::TYPE_STRUCTURE => 'nav_haupt.gif', Elementtype::TYPE_LAYOUTAREA => '_fallback.gif', Elementtype::TYPE_LAYOUTCONTAINER => '_fallback.gif', Elementtype::TYPE_PART => 'teaser_hellblau_list.gif', Elementtype::TYPE_REFERENCE => '_fallback.gif', ]; $icon = $icons[$type]; } $elementtype = new Elementtype(); $elementtype ->setUniqueId($uniqueId) ->setType($type) ->setTitle('de', $name) ->setTitle('en', $name) ->setIcon($icon) ->setRevision(1) ->setStructure($elementtypeStructure) ->setMappings($mappings) ->setCreateUser($user) ->setCreatedAt(new \DateTime()) ->setModifyUser($elementtype->getCreateUser()) ->setModifiedAt($elementtype->getCreatedAt()); $this->elementtypeManager->updateElementtype($elementtype); return $elementtype; }
php
public function createElementtype( $type, $uniqueId, $name, $icon, ElementtypeStructure $elementtypeStructure = null, array $mappings = null, $user, $flush = true) { if (!$icon) { $icons = [ Elementtype::TYPE_FULL => 'artikel_list.gif', Elementtype::TYPE_STRUCTURE => 'nav_haupt.gif', Elementtype::TYPE_LAYOUTAREA => '_fallback.gif', Elementtype::TYPE_LAYOUTCONTAINER => '_fallback.gif', Elementtype::TYPE_PART => 'teaser_hellblau_list.gif', Elementtype::TYPE_REFERENCE => '_fallback.gif', ]; $icon = $icons[$type]; } $elementtype = new Elementtype(); $elementtype ->setUniqueId($uniqueId) ->setType($type) ->setTitle('de', $name) ->setTitle('en', $name) ->setIcon($icon) ->setRevision(1) ->setStructure($elementtypeStructure) ->setMappings($mappings) ->setCreateUser($user) ->setCreatedAt(new \DateTime()) ->setModifyUser($elementtype->getCreateUser()) ->setModifiedAt($elementtype->getCreatedAt()); $this->elementtypeManager->updateElementtype($elementtype); return $elementtype; }
[ "public", "function", "createElementtype", "(", "$", "type", ",", "$", "uniqueId", ",", "$", "name", ",", "$", "icon", ",", "ElementtypeStructure", "$", "elementtypeStructure", "=", "null", ",", "array", "$", "mappings", "=", "null", ",", "$", "user", ",", "$", "flush", "=", "true", ")", "{", "if", "(", "!", "$", "icon", ")", "{", "$", "icons", "=", "[", "Elementtype", "::", "TYPE_FULL", "=>", "'artikel_list.gif'", ",", "Elementtype", "::", "TYPE_STRUCTURE", "=>", "'nav_haupt.gif'", ",", "Elementtype", "::", "TYPE_LAYOUTAREA", "=>", "'_fallback.gif'", ",", "Elementtype", "::", "TYPE_LAYOUTCONTAINER", "=>", "'_fallback.gif'", ",", "Elementtype", "::", "TYPE_PART", "=>", "'teaser_hellblau_list.gif'", ",", "Elementtype", "::", "TYPE_REFERENCE", "=>", "'_fallback.gif'", ",", "]", ";", "$", "icon", "=", "$", "icons", "[", "$", "type", "]", ";", "}", "$", "elementtype", "=", "new", "Elementtype", "(", ")", ";", "$", "elementtype", "->", "setUniqueId", "(", "$", "uniqueId", ")", "->", "setType", "(", "$", "type", ")", "->", "setTitle", "(", "'de'", ",", "$", "name", ")", "->", "setTitle", "(", "'en'", ",", "$", "name", ")", "->", "setIcon", "(", "$", "icon", ")", "->", "setRevision", "(", "1", ")", "->", "setStructure", "(", "$", "elementtypeStructure", ")", "->", "setMappings", "(", "$", "mappings", ")", "->", "setCreateUser", "(", "$", "user", ")", "->", "setCreatedAt", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "setModifyUser", "(", "$", "elementtype", "->", "getCreateUser", "(", ")", ")", "->", "setModifiedAt", "(", "$", "elementtype", "->", "getCreatedAt", "(", ")", ")", ";", "$", "this", "->", "elementtypeManager", "->", "updateElementtype", "(", "$", "elementtype", ")", ";", "return", "$", "elementtype", ";", "}" ]
Create a new empty Element Type. @param string $type @param string $uniqueId @param string $name @param string $icon @param ElementtypeStructure $elementtypeStructure @param array $mappings @param string $user @param bool $flush @return Elementtype
[ "Create", "a", "new", "empty", "Element", "Type", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php#L169-L210
672
phlexible/phlexible
src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php
ElementtypeService.duplicateElementtype
public function duplicateElementtype(Elementtype $sourceElementtype, $user) { $elementtype = clone $sourceElementtype; $uniqId = uniqid(); foreach ($elementtype->getTitles() as $language => $title) { $elementtype->setTitle($language, $title.' - copy - '.$uniqId); } $elementtypeStructure = new ElementtypeStructure(); $elementtype ->setId(null) ->setUniqueId($elementtype->getUniqueId().'-'.$uniqId) ->setRevision(1) ->setStructure($elementtypeStructure) ->setCreatedAt(new \DateTime()) ->setCreateUser($user); $rii = new \RecursiveIteratorIterator($sourceElementtype->getStructure(), \RecursiveIteratorIterator::SELF_FIRST); $dsIdMap = []; foreach ($rii as $sourceNode) { /* @var $sourceNode ElementtypeStructureNode */ if ($sourceNode->isReferenced()) { continue; } $node = clone $sourceNode; $dsIdMap[$sourceNode->getDsId()] = $dsId = UuidUtil::generate(); $parentDsId = null; if (!$sourceNode->isRoot()) { $parentDsId = $dsIdMap[$sourceNode->getParentNode()->getDsId()]; } $node ->setDsId($dsId) ->setParentDsId($parentDsId); $elementtypeStructure->addNode($node); } $mappings = $elementtype->getMappings(); foreach ($mappings as $mappingIndex => $mapping) { foreach ($mapping['fields'] as $mappingFieldIndex => $mapingField) { if (isset($dsIdMap[$mapingField['dsId']])) { $mappings[$mappingIndex]['fields'][$mappingFieldIndex]['dsId'] = $dsIdMap[$mapingField['dsId']]; } } } $elementtype->setMappings($mappings); $this->elementtypeManager->updateElementtype($elementtype); return $elementtype; }
php
public function duplicateElementtype(Elementtype $sourceElementtype, $user) { $elementtype = clone $sourceElementtype; $uniqId = uniqid(); foreach ($elementtype->getTitles() as $language => $title) { $elementtype->setTitle($language, $title.' - copy - '.$uniqId); } $elementtypeStructure = new ElementtypeStructure(); $elementtype ->setId(null) ->setUniqueId($elementtype->getUniqueId().'-'.$uniqId) ->setRevision(1) ->setStructure($elementtypeStructure) ->setCreatedAt(new \DateTime()) ->setCreateUser($user); $rii = new \RecursiveIteratorIterator($sourceElementtype->getStructure(), \RecursiveIteratorIterator::SELF_FIRST); $dsIdMap = []; foreach ($rii as $sourceNode) { /* @var $sourceNode ElementtypeStructureNode */ if ($sourceNode->isReferenced()) { continue; } $node = clone $sourceNode; $dsIdMap[$sourceNode->getDsId()] = $dsId = UuidUtil::generate(); $parentDsId = null; if (!$sourceNode->isRoot()) { $parentDsId = $dsIdMap[$sourceNode->getParentNode()->getDsId()]; } $node ->setDsId($dsId) ->setParentDsId($parentDsId); $elementtypeStructure->addNode($node); } $mappings = $elementtype->getMappings(); foreach ($mappings as $mappingIndex => $mapping) { foreach ($mapping['fields'] as $mappingFieldIndex => $mapingField) { if (isset($dsIdMap[$mapingField['dsId']])) { $mappings[$mappingIndex]['fields'][$mappingFieldIndex]['dsId'] = $dsIdMap[$mapingField['dsId']]; } } } $elementtype->setMappings($mappings); $this->elementtypeManager->updateElementtype($elementtype); return $elementtype; }
[ "public", "function", "duplicateElementtype", "(", "Elementtype", "$", "sourceElementtype", ",", "$", "user", ")", "{", "$", "elementtype", "=", "clone", "$", "sourceElementtype", ";", "$", "uniqId", "=", "uniqid", "(", ")", ";", "foreach", "(", "$", "elementtype", "->", "getTitles", "(", ")", "as", "$", "language", "=>", "$", "title", ")", "{", "$", "elementtype", "->", "setTitle", "(", "$", "language", ",", "$", "title", ".", "' - copy - '", ".", "$", "uniqId", ")", ";", "}", "$", "elementtypeStructure", "=", "new", "ElementtypeStructure", "(", ")", ";", "$", "elementtype", "->", "setId", "(", "null", ")", "->", "setUniqueId", "(", "$", "elementtype", "->", "getUniqueId", "(", ")", ".", "'-'", ".", "$", "uniqId", ")", "->", "setRevision", "(", "1", ")", "->", "setStructure", "(", "$", "elementtypeStructure", ")", "->", "setCreatedAt", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "setCreateUser", "(", "$", "user", ")", ";", "$", "rii", "=", "new", "\\", "RecursiveIteratorIterator", "(", "$", "sourceElementtype", "->", "getStructure", "(", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", ";", "$", "dsIdMap", "=", "[", "]", ";", "foreach", "(", "$", "rii", "as", "$", "sourceNode", ")", "{", "/* @var $sourceNode ElementtypeStructureNode */", "if", "(", "$", "sourceNode", "->", "isReferenced", "(", ")", ")", "{", "continue", ";", "}", "$", "node", "=", "clone", "$", "sourceNode", ";", "$", "dsIdMap", "[", "$", "sourceNode", "->", "getDsId", "(", ")", "]", "=", "$", "dsId", "=", "UuidUtil", "::", "generate", "(", ")", ";", "$", "parentDsId", "=", "null", ";", "if", "(", "!", "$", "sourceNode", "->", "isRoot", "(", ")", ")", "{", "$", "parentDsId", "=", "$", "dsIdMap", "[", "$", "sourceNode", "->", "getParentNode", "(", ")", "->", "getDsId", "(", ")", "]", ";", "}", "$", "node", "->", "setDsId", "(", "$", "dsId", ")", "->", "setParentDsId", "(", "$", "parentDsId", ")", ";", "$", "elementtypeStructure", "->", "addNode", "(", "$", "node", ")", ";", "}", "$", "mappings", "=", "$", "elementtype", "->", "getMappings", "(", ")", ";", "foreach", "(", "$", "mappings", "as", "$", "mappingIndex", "=>", "$", "mapping", ")", "{", "foreach", "(", "$", "mapping", "[", "'fields'", "]", "as", "$", "mappingFieldIndex", "=>", "$", "mapingField", ")", "{", "if", "(", "isset", "(", "$", "dsIdMap", "[", "$", "mapingField", "[", "'dsId'", "]", "]", ")", ")", "{", "$", "mappings", "[", "$", "mappingIndex", "]", "[", "'fields'", "]", "[", "$", "mappingFieldIndex", "]", "[", "'dsId'", "]", "=", "$", "dsIdMap", "[", "$", "mapingField", "[", "'dsId'", "]", "]", ";", "}", "}", "}", "$", "elementtype", "->", "setMappings", "(", "$", "mappings", ")", ";", "$", "this", "->", "elementtypeManager", "->", "updateElementtype", "(", "$", "elementtype", ")", ";", "return", "$", "elementtype", ";", "}" ]
Duplicate an elementtype. @param Elementtype $sourceElementtype @param string $user @return Elementtype
[ "Duplicate", "an", "elementtype", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/ElementtypeService.php#L247-L304
673
jannisfink/config
src/value/ValueParser.php
ValueParser.parseIntelligent
public function parseIntelligent($value) { $functions = [ "parseNumeric", "parseBoolean", "parseString" ]; foreach ($functions as $function) { try { return call_user_func([$this, $function], $value); } catch (ParseException $e) { // empty on purpose } } $exportValue = var_export($value, true); throw new ParseException("'$exportValue' could not be parsed by any parser"); }
php
public function parseIntelligent($value) { $functions = [ "parseNumeric", "parseBoolean", "parseString" ]; foreach ($functions as $function) { try { return call_user_func([$this, $function], $value); } catch (ParseException $e) { // empty on purpose } } $exportValue = var_export($value, true); throw new ParseException("'$exportValue' could not be parsed by any parser"); }
[ "public", "function", "parseIntelligent", "(", "$", "value", ")", "{", "$", "functions", "=", "[", "\"parseNumeric\"", ",", "\"parseBoolean\"", ",", "\"parseString\"", "]", ";", "foreach", "(", "$", "functions", "as", "$", "function", ")", "{", "try", "{", "return", "call_user_func", "(", "[", "$", "this", ",", "$", "function", "]", ",", "$", "value", ")", ";", "}", "catch", "(", "ParseException", "$", "e", ")", "{", "// empty on purpose", "}", "}", "$", "exportValue", "=", "var_export", "(", "$", "value", ",", "true", ")", ";", "throw", "new", "ParseException", "(", "\"'$exportValue' could not be parsed by any parser\"", ")", ";", "}" ]
Gets a raw value land tries to parse it in several ways. When it found a function that can parse the given value, it will return immediately instead of trying to parse it with one of the possible functions left. @param $value mixed the raw value @return mixed the parsed value @throws ParseException if the given value can not be parsed by any pasing function of this class
[ "Gets", "a", "raw", "value", "land", "tries", "to", "parse", "it", "in", "several", "ways", ".", "When", "it", "found", "a", "function", "that", "can", "parse", "the", "given", "value", "it", "will", "return", "immediately", "instead", "of", "trying", "to", "parse", "it", "with", "one", "of", "the", "possible", "functions", "left", "." ]
54dc18c6125c971c46ded9f9484f6802112aab44
https://github.com/jannisfink/config/blob/54dc18c6125c971c46ded9f9484f6802112aab44/src/value/ValueParser.php#L32-L49
674
jannisfink/config
src/value/ValueParser.php
ValueParser.parseNumeric
public function parseNumeric($value) { if (is_numeric($value)) { return $value + 0; } $exportValue = var_export($value, true); throw new ParseException("'$exportValue' could not be parsed as a number"); }
php
public function parseNumeric($value) { if (is_numeric($value)) { return $value + 0; } $exportValue = var_export($value, true); throw new ParseException("'$exportValue' could not be parsed as a number"); }
[ "public", "function", "parseNumeric", "(", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "$", "value", "+", "0", ";", "}", "$", "exportValue", "=", "var_export", "(", "$", "value", ",", "true", ")", ";", "throw", "new", "ParseException", "(", "\"'$exportValue' could not be parsed as a number\"", ")", ";", "}" ]
Make this numeric element a number of the correct type. See @link http://php.net/manual/de/function.is-numeric.php#107326 @param mixed $value the value @return int|float the parsed value @throws ParseException if the element is not numeric
[ "Make", "this", "numeric", "element", "a", "number", "of", "the", "correct", "type", "." ]
54dc18c6125c971c46ded9f9484f6802112aab44
https://github.com/jannisfink/config/blob/54dc18c6125c971c46ded9f9484f6802112aab44/src/value/ValueParser.php#L61-L68
675
jannisfink/config
src/value/ValueParser.php
ValueParser.parseString
public function parseString($value) { if (is_string($value)) { return $value; } $exportValue = var_export($value, true); throw new ParseException("'$exportValue' can not be parsed as a string"); }
php
public function parseString($value) { if (is_string($value)) { return $value; } $exportValue = var_export($value, true); throw new ParseException("'$exportValue' can not be parsed as a string"); }
[ "public", "function", "parseString", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "$", "exportValue", "=", "var_export", "(", "$", "value", ",", "true", ")", ";", "throw", "new", "ParseException", "(", "\"'$exportValue' can not be parsed as a string\"", ")", ";", "}" ]
Tests, if the given value is of type string @param mixed $value the value @return string the value as string @throws ParseException
[ "Tests", "if", "the", "given", "value", "is", "of", "type", "string" ]
54dc18c6125c971c46ded9f9484f6802112aab44
https://github.com/jannisfink/config/blob/54dc18c6125c971c46ded9f9484f6802112aab44/src/value/ValueParser.php#L109-L116
676
gliverphp/database
src/MySQL/MySQLResponseObject.php
MySQLResponseObject.getResultObject
public function getResultObject(array $result_array) { $result_object = array(); //loop through, converting to objects foreach($result_array as $key => $value) { //cast to object and return $result_object[] = (object)$value; } return (object)$result_object; }
php
public function getResultObject(array $result_array) { $result_object = array(); //loop through, converting to objects foreach($result_array as $key => $value) { //cast to object and return $result_object[] = (object)$value; } return (object)$result_object; }
[ "public", "function", "getResultObject", "(", "array", "$", "result_array", ")", "{", "$", "result_object", "=", "array", "(", ")", ";", "//loop through, converting to objects", "foreach", "(", "$", "result_array", "as", "$", "key", "=>", "$", "value", ")", "{", "//cast to object and return", "$", "result_object", "[", "]", "=", "(", "object", ")", "$", "value", ";", "}", "return", "(", "object", ")", "$", "result_object", ";", "}" ]
This method sets the resultset in object format @param array $result_array The resultset in array format @return \Object $this object instance
[ "This", "method", "sets", "the", "resultset", "in", "object", "format" ]
b998bd3d24cb2f269b9bd54438c7df8751377ba9
https://github.com/gliverphp/database/blob/b998bd3d24cb2f269b9bd54438c7df8751377ba9/src/MySQL/MySQLResponseObject.php#L332-L345
677
duellsy/pockpack
src/Duellsy/Pockpack/PockpackBase.php
PockpackBase.getClient
public function getClient() { if ( $this->client ) { return $this->client; } $this->client = new Client(self::BASE_URL); return $this->client; }
php
public function getClient() { if ( $this->client ) { return $this->client; } $this->client = new Client(self::BASE_URL); return $this->client; }
[ "public", "function", "getClient", "(", ")", "{", "if", "(", "$", "this", "->", "client", ")", "{", "return", "$", "this", "->", "client", ";", "}", "$", "this", "->", "client", "=", "new", "Client", "(", "self", "::", "BASE_URL", ")", ";", "return", "$", "this", "->", "client", ";", "}" ]
Get the client used to query Pocket. @return Client HTTP Client used to communicate with Pocket
[ "Get", "the", "client", "used", "to", "query", "Pocket", "." ]
b38b9942631ae786c6ed953da65f666ea9305f3c
https://github.com/duellsy/pockpack/blob/b38b9942631ae786c6ed953da65f666ea9305f3c/src/Duellsy/Pockpack/PockpackBase.php#L37-L46
678
kreta-plugins/VCS
src/Kreta/Component/VCS/Repository/IssueRepository.php
IssueRepository.findRelatedIssuesByRepository
public function findRelatedIssuesByRepository(RepositoryInterface $repository, $shortName, $numericId) { $repositoryIds = []; foreach ($repository->getProjects() as $project) { $repositoryIds[] = $project->getId(); } $queryBuilder = $this->repository->createQueryBuilder('i') ->leftJoin('i.project', 'p'); $this->addCriteria($queryBuilder, [ 'in' => ['i.project' => $repositoryIds], 'p.shortName' => $shortName, 'i.numericId' => $numericId, ] ); return $queryBuilder->getQuery()->getResult(); }
php
public function findRelatedIssuesByRepository(RepositoryInterface $repository, $shortName, $numericId) { $repositoryIds = []; foreach ($repository->getProjects() as $project) { $repositoryIds[] = $project->getId(); } $queryBuilder = $this->repository->createQueryBuilder('i') ->leftJoin('i.project', 'p'); $this->addCriteria($queryBuilder, [ 'in' => ['i.project' => $repositoryIds], 'p.shortName' => $shortName, 'i.numericId' => $numericId, ] ); return $queryBuilder->getQuery()->getResult(); }
[ "public", "function", "findRelatedIssuesByRepository", "(", "RepositoryInterface", "$", "repository", ",", "$", "shortName", ",", "$", "numericId", ")", "{", "$", "repositoryIds", "=", "[", "]", ";", "foreach", "(", "$", "repository", "->", "getProjects", "(", ")", "as", "$", "project", ")", "{", "$", "repositoryIds", "[", "]", "=", "$", "project", "->", "getId", "(", ")", ";", "}", "$", "queryBuilder", "=", "$", "this", "->", "repository", "->", "createQueryBuilder", "(", "'i'", ")", "->", "leftJoin", "(", "'i.project'", ",", "'p'", ")", ";", "$", "this", "->", "addCriteria", "(", "$", "queryBuilder", ",", "[", "'in'", "=>", "[", "'i.project'", "=>", "$", "repositoryIds", "]", ",", "'p.shortName'", "=>", "$", "shortName", ",", "'i.numericId'", "=>", "$", "numericId", ",", "]", ")", ";", "return", "$", "queryBuilder", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Finds related issues of repository, short name and numeric id given. @param \Kreta\Component\VCS\Model\Interfaces\RepositoryInterface $repository The repository @param string $shortName The short name @param string $numericId The numeric id @return \Kreta\Component\Issue\Model\Interfaces\IssueInterface[]
[ "Finds", "related", "issues", "of", "repository", "short", "name", "and", "numeric", "id", "given", "." ]
0b6daae2b8044d9250adc8009d03a6745370cd2e
https://github.com/kreta-plugins/VCS/blob/0b6daae2b8044d9250adc8009d03a6745370cd2e/src/Kreta/Component/VCS/Repository/IssueRepository.php#L72-L88
679
budkit/budkit-framework
src/Budkit/Debug/Log.php
Log.tick
public function tick($class, array $params = array(), $usernameid = NULL, $decrement = false) { if (empty($class)): return false; //We need to know the class to tick endif; $handler = new File(); $file = date("Y-m-d") . ".log"; $folder = PATH_LOGS . DS . $class . DS; if (!$handler->isFile($folder . $file)) { //if its not a folder if (!$handler->create($folder . $file, "a+")) { throw new Exception("Could not create the log file {$file}"); return false; } } unset($params["file"]); $tick = array_merge(array("time" => time(), "inc" => (!$decrement) ? "+1" : "-1"), $params); $line = json_encode($tick); if (!$handler->write($folder . $file, PHP_EOL . $line, "a+")) { throw new Exception("Could not write out to the stats file {$file}"); return false; } return true; }
php
public function tick($class, array $params = array(), $usernameid = NULL, $decrement = false) { if (empty($class)): return false; //We need to know the class to tick endif; $handler = new File(); $file = date("Y-m-d") . ".log"; $folder = PATH_LOGS . DS . $class . DS; if (!$handler->isFile($folder . $file)) { //if its not a folder if (!$handler->create($folder . $file, "a+")) { throw new Exception("Could not create the log file {$file}"); return false; } } unset($params["file"]); $tick = array_merge(array("time" => time(), "inc" => (!$decrement) ? "+1" : "-1"), $params); $line = json_encode($tick); if (!$handler->write($folder . $file, PHP_EOL . $line, "a+")) { throw new Exception("Could not write out to the stats file {$file}"); return false; } return true; }
[ "public", "function", "tick", "(", "$", "class", ",", "array", "$", "params", "=", "array", "(", ")", ",", "$", "usernameid", "=", "NULL", ",", "$", "decrement", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "class", ")", ")", ":", "return", "false", ";", "//We need to know the class to tick", "endif", ";", "$", "handler", "=", "new", "File", "(", ")", ";", "$", "file", "=", "date", "(", "\"Y-m-d\"", ")", ".", "\".log\"", ";", "$", "folder", "=", "PATH_LOGS", ".", "DS", ".", "$", "class", ".", "DS", ";", "if", "(", "!", "$", "handler", "->", "isFile", "(", "$", "folder", ".", "$", "file", ")", ")", "{", "//if its not a folder", "if", "(", "!", "$", "handler", "->", "create", "(", "$", "folder", ".", "$", "file", ",", "\"a+\"", ")", ")", "{", "throw", "new", "Exception", "(", "\"Could not create the log file {$file}\"", ")", ";", "return", "false", ";", "}", "}", "unset", "(", "$", "params", "[", "\"file\"", "]", ")", ";", "$", "tick", "=", "array_merge", "(", "array", "(", "\"time\"", "=>", "time", "(", ")", ",", "\"inc\"", "=>", "(", "!", "$", "decrement", ")", "?", "\"+1\"", ":", "\"-1\"", ")", ",", "$", "params", ")", ";", "$", "line", "=", "json_encode", "(", "$", "tick", ")", ";", "if", "(", "!", "$", "handler", "->", "write", "(", "$", "folder", ".", "$", "file", ",", "PHP_EOL", ".", "$", "line", ",", "\"a+\"", ")", ")", "{", "throw", "new", "Exception", "(", "\"Could not write out to the stats file {$file}\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Ticks a user performed action @param $class @param array $params @param null $usernameid @param bool|false $decrement @return bool @throws Exception
[ "Ticks", "a", "user", "performed", "action" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Debug/Log.php#L129-L158
680
infinity-se/infinity-base
src/InfinityBase/Service/AbstractService.php
AbstractService.identity
protected function identity() { // Get authentication service if (null === $this->identity) { $authenticationService = $this->getServiceLocator() ->get('Zend\Authentication\AuthenticationService'); if (!$authenticationService->hasIdentity()) { throw new \Exception('No identity loaded'); } $this->identity = $authenticationService->getIdentity(); } return $this->identity; }
php
protected function identity() { // Get authentication service if (null === $this->identity) { $authenticationService = $this->getServiceLocator() ->get('Zend\Authentication\AuthenticationService'); if (!$authenticationService->hasIdentity()) { throw new \Exception('No identity loaded'); } $this->identity = $authenticationService->getIdentity(); } return $this->identity; }
[ "protected", "function", "identity", "(", ")", "{", "// Get authentication service", "if", "(", "null", "===", "$", "this", "->", "identity", ")", "{", "$", "authenticationService", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'Zend\\Authentication\\AuthenticationService'", ")", ";", "if", "(", "!", "$", "authenticationService", "->", "hasIdentity", "(", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'No identity loaded'", ")", ";", "}", "$", "this", "->", "identity", "=", "$", "authenticationService", "->", "getIdentity", "(", ")", ";", "}", "return", "$", "this", "->", "identity", ";", "}" ]
Get the current identity @return User
[ "Get", "the", "current", "identity" ]
4f869ae4b549e779560a83528d2ed2664f6deb5b
https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/Service/AbstractService.php#L33-L46
681
infinity-se/infinity-base
src/InfinityBase/Service/AbstractService.php
AbstractService.save
protected function save($successMessage, $failureMessage) { try { $this->getEntityManager()->flush(); $this->addMessage($successMessage, FlashMessenger::NAMESPACE_SUCCESS); return true; } catch (\Exception $e) { $this->addMessage($failureMessage, FlashMessenger::NAMESPACE_ERROR); // Check exception type if ($e instanceof \Doctrine\DBAL\DBALException) { $previous = $e->getPrevious(); if ($previous instanceof \Doctrine\DBAL\Driver\Mysqli\MysqliException) { // Check exception type switch ($previous->getCode()) { case 1062: $this->addMessage( 'You are using details that already exist.', 'error' ); return false; } } } /** * TO BE REMOVED -- BELOW */ throw new \Exception('You are seeing this because this error needs to be properly handled.', 0, $e); /** * TO BE REMOVED -- ABOVE */ return false; } }
php
protected function save($successMessage, $failureMessage) { try { $this->getEntityManager()->flush(); $this->addMessage($successMessage, FlashMessenger::NAMESPACE_SUCCESS); return true; } catch (\Exception $e) { $this->addMessage($failureMessage, FlashMessenger::NAMESPACE_ERROR); // Check exception type if ($e instanceof \Doctrine\DBAL\DBALException) { $previous = $e->getPrevious(); if ($previous instanceof \Doctrine\DBAL\Driver\Mysqli\MysqliException) { // Check exception type switch ($previous->getCode()) { case 1062: $this->addMessage( 'You are using details that already exist.', 'error' ); return false; } } } /** * TO BE REMOVED -- BELOW */ throw new \Exception('You are seeing this because this error needs to be properly handled.', 0, $e); /** * TO BE REMOVED -- ABOVE */ return false; } }
[ "protected", "function", "save", "(", "$", "successMessage", ",", "$", "failureMessage", ")", "{", "try", "{", "$", "this", "->", "getEntityManager", "(", ")", "->", "flush", "(", ")", ";", "$", "this", "->", "addMessage", "(", "$", "successMessage", ",", "FlashMessenger", "::", "NAMESPACE_SUCCESS", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "addMessage", "(", "$", "failureMessage", ",", "FlashMessenger", "::", "NAMESPACE_ERROR", ")", ";", "// Check exception type", "if", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "DBAL", "\\", "DBALException", ")", "{", "$", "previous", "=", "$", "e", "->", "getPrevious", "(", ")", ";", "if", "(", "$", "previous", "instanceof", "\\", "Doctrine", "\\", "DBAL", "\\", "Driver", "\\", "Mysqli", "\\", "MysqliException", ")", "{", "// Check exception type", "switch", "(", "$", "previous", "->", "getCode", "(", ")", ")", "{", "case", "1062", ":", "$", "this", "->", "addMessage", "(", "'You are using details that already exist.'", ",", "'error'", ")", ";", "return", "false", ";", "}", "}", "}", "/**\n * TO BE REMOVED -- BELOW\n */", "throw", "new", "\\", "Exception", "(", "'You are seeing this because this error needs to be properly handled.'", ",", "0", ",", "$", "e", ")", ";", "/**\n * TO BE REMOVED -- ABOVE\n */", "return", "false", ";", "}", "}" ]
Flush the entityManager and handle errors @return boolean
[ "Flush", "the", "entityManager", "and", "handle", "errors" ]
4f869ae4b549e779560a83528d2ed2664f6deb5b
https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/Service/AbstractService.php#L53-L87
682
flowcode/AmulenClassificationBundle
src/Flowcode/ClassificationBundle/Controller/CollectionController.php
CollectionController.createAction
public function createAction(Request $request) { $entity = new Collection(); $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('admin_collection_show', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $entity = new Collection(); $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('admin_collection_show', array('id' => $entity->getId()))); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "entity", "=", "new", "Collection", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_collection_show'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new Collection entity. @Route("/", name="admin_collection_create") @Method("POST") @Template("FlowcodeClassificationBundle:Collection:new.html.twig")
[ "Creates", "a", "new", "Collection", "entity", "." ]
e280537c47f85e7da614ccd00a6993ff9ed86e18
https://github.com/flowcode/AmulenClassificationBundle/blob/e280537c47f85e7da614ccd00a6993ff9ed86e18/src/Flowcode/ClassificationBundle/Controller/CollectionController.php#L45-L63
683
flowcode/AmulenClassificationBundle
src/Flowcode/ClassificationBundle/Controller/CollectionController.php
CollectionController.createCreateForm
private function createCreateForm(Collection $entity) { $form = $this->createForm($this->get('amulen.classification.form.collection'), $entity, array( 'action' => $this->generateUrl('admin_collection_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(Collection $entity) { $form = $this->createForm($this->get('amulen.classification.form.collection'), $entity, array( 'action' => $this->generateUrl('admin_collection_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "Collection", "$", "entity", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "$", "this", "->", "get", "(", "'amulen.classification.form.collection'", ")", ",", "$", "entity", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_collection_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a Collection entity. @param Collection $entity The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "Collection", "entity", "." ]
e280537c47f85e7da614ccd00a6993ff9ed86e18
https://github.com/flowcode/AmulenClassificationBundle/blob/e280537c47f85e7da614ccd00a6993ff9ed86e18/src/Flowcode/ClassificationBundle/Controller/CollectionController.php#L72-L82
684
flowcode/AmulenClassificationBundle
src/Flowcode/ClassificationBundle/Controller/CollectionController.php
CollectionController.newAction
public function newAction() { $entity = new Collection(); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function newAction() { $entity = new Collection(); $form = $this->createCreateForm($entity); return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "newAction", "(", ")", "{", "$", "entity", "=", "new", "Collection", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Displays a form to create a new Collection entity. @Route("/new", name="admin_collection_new") @Method("GET") @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "Collection", "entity", "." ]
e280537c47f85e7da614ccd00a6993ff9ed86e18
https://github.com/flowcode/AmulenClassificationBundle/blob/e280537c47f85e7da614ccd00a6993ff9ed86e18/src/Flowcode/ClassificationBundle/Controller/CollectionController.php#L91-L100
685
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/HandlerExecutionChain.php
HandlerExecutionChain.addInterceptors
public function addInterceptors(array $interceptors) { foreach ($interceptors as $interceptor) { if ($interceptor instanceof HandlerInterceptor) { array_push($this->interceptors, $interceptor); } } }
php
public function addInterceptors(array $interceptors) { foreach ($interceptors as $interceptor) { if ($interceptor instanceof HandlerInterceptor) { array_push($this->interceptors, $interceptor); } } }
[ "public", "function", "addInterceptors", "(", "array", "$", "interceptors", ")", "{", "foreach", "(", "$", "interceptors", "as", "$", "interceptor", ")", "{", "if", "(", "$", "interceptor", "instanceof", "HandlerInterceptor", ")", "{", "array_push", "(", "$", "this", "->", "interceptors", ",", "$", "interceptor", ")", ";", "}", "}", "}" ]
Add a list of HandlerInterceptor instances to the end of this chain @param array $interceptors The interceptors to add @return void
[ "Add", "a", "list", "of", "HandlerInterceptor", "instances", "to", "the", "end", "of", "this", "chain" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/HandlerExecutionChain.php#L107-L114
686
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/HandlerExecutionChain.php
HandlerExecutionChain.applyPreHandle
public function applyPreHandle(ServletRequestInterface $request, ServletResponseInterface $response) { $interceptors = $this->getInterceptors(); if (!empty($interceptors)) { for ($i = 0; $i < count($interceptors); $i++) { $interceptor = $interceptors[$i]; if (!$interceptor->preHandle($request, $response, $this->handler)) { $this->triggerAfterCompletion($request, $response, null); return false; } $this->interceptorIndex = $i; } } return true; }
php
public function applyPreHandle(ServletRequestInterface $request, ServletResponseInterface $response) { $interceptors = $this->getInterceptors(); if (!empty($interceptors)) { for ($i = 0; $i < count($interceptors); $i++) { $interceptor = $interceptors[$i]; if (!$interceptor->preHandle($request, $response, $this->handler)) { $this->triggerAfterCompletion($request, $response, null); return false; } $this->interceptorIndex = $i; } } return true; }
[ "public", "function", "applyPreHandle", "(", "ServletRequestInterface", "$", "request", ",", "ServletResponseInterface", "$", "response", ")", "{", "$", "interceptors", "=", "$", "this", "->", "getInterceptors", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "interceptors", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "interceptors", ")", ";", "$", "i", "++", ")", "{", "$", "interceptor", "=", "$", "interceptors", "[", "$", "i", "]", ";", "if", "(", "!", "$", "interceptor", "->", "preHandle", "(", "$", "request", ",", "$", "response", ",", "$", "this", "->", "handler", ")", ")", "{", "$", "this", "->", "triggerAfterCompletion", "(", "$", "request", ",", "$", "response", ",", "null", ")", ";", "return", "false", ";", "}", "$", "this", "->", "interceptorIndex", "=", "$", "i", ";", "}", "}", "return", "true", ";", "}" ]
Apply preHandle methods of registered interceptors @param ServletRequestInterface $request The current request @param ServletResponseInterface $response The current response @return boolean
[ "Apply", "preHandle", "methods", "of", "registered", "interceptors" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/HandlerExecutionChain.php#L122-L136
687
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/HandlerExecutionChain.php
HandlerExecutionChain.applyPostHandle
public function applyPostHandle(ServletRequestInterface $request, ServletResponseInterface $response, ModelAndView $model) { $interceptors = $this->getInterceptors(); if (!empty($interceptors)) { for ($i = $this->interceptorIndex; $i >= 0; $i--) { $interceptor = $interceptors[$i]; $interceptor->postHandle($request, $response, $this->handler, $model); } } }
php
public function applyPostHandle(ServletRequestInterface $request, ServletResponseInterface $response, ModelAndView $model) { $interceptors = $this->getInterceptors(); if (!empty($interceptors)) { for ($i = $this->interceptorIndex; $i >= 0; $i--) { $interceptor = $interceptors[$i]; $interceptor->postHandle($request, $response, $this->handler, $model); } } }
[ "public", "function", "applyPostHandle", "(", "ServletRequestInterface", "$", "request", ",", "ServletResponseInterface", "$", "response", ",", "ModelAndView", "$", "model", ")", "{", "$", "interceptors", "=", "$", "this", "->", "getInterceptors", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "interceptors", ")", ")", "{", "for", "(", "$", "i", "=", "$", "this", "->", "interceptorIndex", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "interceptor", "=", "$", "interceptors", "[", "$", "i", "]", ";", "$", "interceptor", "->", "postHandle", "(", "$", "request", ",", "$", "response", ",", "$", "this", "->", "handler", ",", "$", "model", ")", ";", "}", "}", "}" ]
Applies postHandle methods of registered interceptors @param ServletRequestInterface $request The current request @param ServletResponseInterface $response The current response @param ModelAndView $model The current model @return void
[ "Applies", "postHandle", "methods", "of", "registered", "interceptors" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/HandlerExecutionChain.php#L145-L154
688
Ocelot-Framework/ocelot-mvc
src/Web/Servlet/HandlerExecutionChain.php
HandlerExecutionChain.triggerAfterCompletion
public function triggerAfterCompletion(ServletRequestInterface $request, ServletResponseInterface $response, \Exception $ex) { $interceptors = $this->getInterceptors(); if (!empty($interceptors)) { for ($i = $this->interceptorIndex; $i >= 0; $i--) { $interceptor = $interceptors[$i]; try { $interceptor->afterCompletion($request, $response, $this->handler); } catch (\Exception $exc) { // TODO: Add logging } } } }
php
public function triggerAfterCompletion(ServletRequestInterface $request, ServletResponseInterface $response, \Exception $ex) { $interceptors = $this->getInterceptors(); if (!empty($interceptors)) { for ($i = $this->interceptorIndex; $i >= 0; $i--) { $interceptor = $interceptors[$i]; try { $interceptor->afterCompletion($request, $response, $this->handler); } catch (\Exception $exc) { // TODO: Add logging } } } }
[ "public", "function", "triggerAfterCompletion", "(", "ServletRequestInterface", "$", "request", ",", "ServletResponseInterface", "$", "response", ",", "\\", "Exception", "$", "ex", ")", "{", "$", "interceptors", "=", "$", "this", "->", "getInterceptors", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "interceptors", ")", ")", "{", "for", "(", "$", "i", "=", "$", "this", "->", "interceptorIndex", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "interceptor", "=", "$", "interceptors", "[", "$", "i", "]", ";", "try", "{", "$", "interceptor", "->", "afterCompletion", "(", "$", "request", ",", "$", "response", ",", "$", "this", "->", "handler", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exc", ")", "{", "// TODO: Add logging", "}", "}", "}", "}" ]
Applies afterCompletion methods of registered interceptors @param ServletRequestInterface $request The current request @param ServletResponseInterface $response The current response @param \Exception $ex Any thrown exception during dispatch process @return void
[ "Applies", "afterCompletion", "methods", "of", "registered", "interceptors" ]
42a08208c6cebb87b363a0479331bafb7ec257c6
https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/HandlerExecutionChain.php#L163-L176
689
vitodtagliente/pure-orm
ConnectionSettings.php
ConnectionSettings.getConnectionString
public function getConnectionString(){ $connection_string = array(); $type = $this->getType(); array_push($connection_string, $type); if($type == self::SQLite){ $filename = 'db.sqlite'; if(isset($this->properties['filename'])) $filename = $this->properties['filename']; array_push($connection_string, ":$filename"); } else { array_push($connection_string, ':host='); array_push($connection_string, (isset($this->properties['host']))? $this->properties['host']:'localhost' ); array_push($connection_string, ';dbname='); array_push($connection_string, (isset($this->properties['name']))? $this->properties['name']:null ); } array_push($connection_string, ';charset='); array_push($connection_string, $this->getCharset()); return implode($connection_string); }
php
public function getConnectionString(){ $connection_string = array(); $type = $this->getType(); array_push($connection_string, $type); if($type == self::SQLite){ $filename = 'db.sqlite'; if(isset($this->properties['filename'])) $filename = $this->properties['filename']; array_push($connection_string, ":$filename"); } else { array_push($connection_string, ':host='); array_push($connection_string, (isset($this->properties['host']))? $this->properties['host']:'localhost' ); array_push($connection_string, ';dbname='); array_push($connection_string, (isset($this->properties['name']))? $this->properties['name']:null ); } array_push($connection_string, ';charset='); array_push($connection_string, $this->getCharset()); return implode($connection_string); }
[ "public", "function", "getConnectionString", "(", ")", "{", "$", "connection_string", "=", "array", "(", ")", ";", "$", "type", "=", "$", "this", "->", "getType", "(", ")", ";", "array_push", "(", "$", "connection_string", ",", "$", "type", ")", ";", "if", "(", "$", "type", "==", "self", "::", "SQLite", ")", "{", "$", "filename", "=", "'db.sqlite'", ";", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "'filename'", "]", ")", ")", "$", "filename", "=", "$", "this", "->", "properties", "[", "'filename'", "]", ";", "array_push", "(", "$", "connection_string", ",", "\":$filename\"", ")", ";", "}", "else", "{", "array_push", "(", "$", "connection_string", ",", "':host='", ")", ";", "array_push", "(", "$", "connection_string", ",", "(", "isset", "(", "$", "this", "->", "properties", "[", "'host'", "]", ")", ")", "?", "$", "this", "->", "properties", "[", "'host'", "]", ":", "'localhost'", ")", ";", "array_push", "(", "$", "connection_string", ",", "';dbname='", ")", ";", "array_push", "(", "$", "connection_string", ",", "(", "isset", "(", "$", "this", "->", "properties", "[", "'name'", "]", ")", ")", "?", "$", "this", "->", "properties", "[", "'name'", "]", ":", "null", ")", ";", "}", "array_push", "(", "$", "connection_string", ",", "';charset='", ")", ";", "array_push", "(", "$", "connection_string", ",", "$", "this", "->", "getCharset", "(", ")", ")", ";", "return", "implode", "(", "$", "connection_string", ")", ";", "}" ]
ritorna la stringa di connessione per interfaccia pdo
[ "ritorna", "la", "stringa", "di", "connessione", "per", "interfaccia", "pdo" ]
04d80106430f45f82f922cc9da25de3d278dbb94
https://github.com/vitodtagliente/pure-orm/blob/04d80106430f45f82f922cc9da25de3d278dbb94/ConnectionSettings.php#L56-L84
690
AlcyZ/Alcys-ORM
src/Core/Db/Facade/InsertFacade.php
InsertFacade.execute
public function execute() { $query = $this->factory->builder($this->insert)->process(); $result = $this->pdo->query($query); if(!$result) { throw new \Exception('An error is while the insertion occurred! (query: "' . $query . '")'); } return $this->pdo->lastInsertId(); }
php
public function execute() { $query = $this->factory->builder($this->insert)->process(); $result = $this->pdo->query($query); if(!$result) { throw new \Exception('An error is while the insertion occurred! (query: "' . $query . '")'); } return $this->pdo->lastInsertId(); }
[ "public", "function", "execute", "(", ")", "{", "$", "query", "=", "$", "this", "->", "factory", "->", "builder", "(", "$", "this", "->", "insert", ")", "->", "process", "(", ")", ";", "$", "result", "=", "$", "this", "->", "pdo", "->", "query", "(", "$", "query", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "\\", "Exception", "(", "'An error is while the insertion occurred! (query: \"'", ".", "$", "query", ".", "'\")'", ")", ";", "}", "return", "$", "this", "->", "pdo", "->", "lastInsertId", "(", ")", ";", "}" ]
Execute the query and insert the expected entries in the database. @throws \Exception When an error is occurred while the insertion.
[ "Execute", "the", "query", "and", "insert", "the", "expected", "entries", "in", "the", "database", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/InsertFacade.php#L78-L88
691
AlcyZ/Alcys-ORM
src/Core/Db/Facade/InsertFacade.php
InsertFacade.columns
public function columns(array $columns) { $columnsArray = array(); foreach($columns as $column) { $columnsArray[] = $this->factory->references('Column', $column); } $this->insert->columns($columnsArray); return $this; }
php
public function columns(array $columns) { $columnsArray = array(); foreach($columns as $column) { $columnsArray[] = $this->factory->references('Column', $column); } $this->insert->columns($columnsArray); return $this; }
[ "public", "function", "columns", "(", "array", "$", "columns", ")", "{", "$", "columnsArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "columnsArray", "[", "]", "=", "$", "this", "->", "factory", "->", "references", "(", "'Column'", ",", "$", "column", ")", ";", "}", "$", "this", "->", "insert", "->", "columns", "(", "$", "columnsArray", ")", ";", "return", "$", "this", ";", "}" ]
Set columns to the query in which should insert new entries. Afterwards, the value method should call to set the values. @param array $columns An usual array with the column names as values. @return $this The same instance to concatenate methods.
[ "Set", "columns", "to", "the", "query", "in", "which", "should", "insert", "new", "entries", ".", "Afterwards", "the", "value", "method", "should", "call", "to", "set", "the", "values", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/InsertFacade.php#L99-L109
692
AlcyZ/Alcys-ORM
src/Core/Db/Facade/InsertFacade.php
InsertFacade.values
public function values(array $values) { $valuesArray = array(); foreach($values as $value) { $valuesArray[] = $this->factory->references('Value', $value); } $this->insert->values($valuesArray); return $this; }
php
public function values(array $values) { $valuesArray = array(); foreach($values as $value) { $valuesArray[] = $this->factory->references('Value', $value); } $this->insert->values($valuesArray); return $this; }
[ "public", "function", "values", "(", "array", "$", "values", ")", "{", "$", "valuesArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "valuesArray", "[", "]", "=", "$", "this", "->", "factory", "->", "references", "(", "'Value'", ",", "$", "value", ")", ";", "}", "$", "this", "->", "insert", "->", "values", "(", "$", "valuesArray", ")", ";", "return", "$", "this", ";", "}" ]
Set values to the query. The method can execute multiple times. The passed array require the same amount of elements, otherwise an exception will thrown. @param array $values An usual array with the values that should insert. @return $this The same instance to concatenate methods.
[ "Set", "values", "to", "the", "query", ".", "The", "method", "can", "execute", "multiple", "times", ".", "The", "passed", "array", "require", "the", "same", "amount", "of", "elements", "otherwise", "an", "exception", "will", "thrown", "." ]
dd30946ad35ab06cba2167cf6dfa02b733614720
https://github.com/AlcyZ/Alcys-ORM/blob/dd30946ad35ab06cba2167cf6dfa02b733614720/src/Core/Db/Facade/InsertFacade.php#L121-L131
693
vincenttouzet/AdminConfigurationBundle
Controller/ConfigurationController.php
ConfigurationController.renderTemplate
protected function renderTemplate(ConfigGroup $group = null) { $adminPool = $this->container->get('sonata.admin.pool'); return $this->render( 'VinceTAdminConfigurationBundle:Configuration:index.html.twig', array( 'configuration_menu' => $this->createMenu(), 'group' => $group, 'form' => $this->createConfigGroupForm($group)->createView(), 'admin_section' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configsection'), 'admin_group' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configgroup'), 'admin_value' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configvalue'), 'admin_type' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configtype'), ) ); }
php
protected function renderTemplate(ConfigGroup $group = null) { $adminPool = $this->container->get('sonata.admin.pool'); return $this->render( 'VinceTAdminConfigurationBundle:Configuration:index.html.twig', array( 'configuration_menu' => $this->createMenu(), 'group' => $group, 'form' => $this->createConfigGroupForm($group)->createView(), 'admin_section' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configsection'), 'admin_group' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configgroup'), 'admin_value' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configvalue'), 'admin_type' => $adminPool->getAdminByAdminCode('admin.configuration.admin.configtype'), ) ); }
[ "protected", "function", "renderTemplate", "(", "ConfigGroup", "$", "group", "=", "null", ")", "{", "$", "adminPool", "=", "$", "this", "->", "container", "->", "get", "(", "'sonata.admin.pool'", ")", ";", "return", "$", "this", "->", "render", "(", "'VinceTAdminConfigurationBundle:Configuration:index.html.twig'", ",", "array", "(", "'configuration_menu'", "=>", "$", "this", "->", "createMenu", "(", ")", ",", "'group'", "=>", "$", "group", ",", "'form'", "=>", "$", "this", "->", "createConfigGroupForm", "(", "$", "group", ")", "->", "createView", "(", ")", ",", "'admin_section'", "=>", "$", "adminPool", "->", "getAdminByAdminCode", "(", "'admin.configuration.admin.configsection'", ")", ",", "'admin_group'", "=>", "$", "adminPool", "->", "getAdminByAdminCode", "(", "'admin.configuration.admin.configgroup'", ")", ",", "'admin_value'", "=>", "$", "adminPool", "->", "getAdminByAdminCode", "(", "'admin.configuration.admin.configvalue'", ")", ",", "'admin_type'", "=>", "$", "adminPool", "->", "getAdminByAdminCode", "(", "'admin.configuration.admin.configtype'", ")", ",", ")", ")", ";", "}" ]
Render the main template @param ConfigGroup $group [description] @return [type]
[ "Render", "the", "main", "template" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Controller/ConfigurationController.php#L107-L123
694
vincenttouzet/AdminConfigurationBundle
Controller/ConfigurationController.php
ConfigurationController.createConfigGroupForm
protected function createConfigGroupForm(ConfigGroup $group = null) { $formBuilder = $this->createFormBuilder(); if ($group) { $values = $this->container->get('admin.configuration.configvalue_manager')->getRepository()->findByConfigGroupId($group->getId()); foreach ($values as $configValue) { $sub = $this->container->get('form.factory')->createNamedBuilder( str_replace(':', '___', $configValue->getPath()), 'admin_configuration_configvalue_'.$configValue->getConfigType()->getFormType(), $configValue ); $formBuilder->add($sub); } } return $formBuilder->getForm(); }
php
protected function createConfigGroupForm(ConfigGroup $group = null) { $formBuilder = $this->createFormBuilder(); if ($group) { $values = $this->container->get('admin.configuration.configvalue_manager')->getRepository()->findByConfigGroupId($group->getId()); foreach ($values as $configValue) { $sub = $this->container->get('form.factory')->createNamedBuilder( str_replace(':', '___', $configValue->getPath()), 'admin_configuration_configvalue_'.$configValue->getConfigType()->getFormType(), $configValue ); $formBuilder->add($sub); } } return $formBuilder->getForm(); }
[ "protected", "function", "createConfigGroupForm", "(", "ConfigGroup", "$", "group", "=", "null", ")", "{", "$", "formBuilder", "=", "$", "this", "->", "createFormBuilder", "(", ")", ";", "if", "(", "$", "group", ")", "{", "$", "values", "=", "$", "this", "->", "container", "->", "get", "(", "'admin.configuration.configvalue_manager'", ")", "->", "getRepository", "(", ")", "->", "findByConfigGroupId", "(", "$", "group", "->", "getId", "(", ")", ")", ";", "foreach", "(", "$", "values", "as", "$", "configValue", ")", "{", "$", "sub", "=", "$", "this", "->", "container", "->", "get", "(", "'form.factory'", ")", "->", "createNamedBuilder", "(", "str_replace", "(", "':'", ",", "'___'", ",", "$", "configValue", "->", "getPath", "(", ")", ")", ",", "'admin_configuration_configvalue_'", ".", "$", "configValue", "->", "getConfigType", "(", ")", "->", "getFormType", "(", ")", ",", "$", "configValue", ")", ";", "$", "formBuilder", "->", "add", "(", "$", "sub", ")", ";", "}", "}", "return", "$", "formBuilder", "->", "getForm", "(", ")", ";", "}" ]
Create the form for all values in group @param ConfigGroup $group [description] @return [type]
[ "Create", "the", "form", "for", "all", "values", "in", "group" ]
8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb
https://github.com/vincenttouzet/AdminConfigurationBundle/blob/8e7edd0810d88aa1d1be4bd303bcc14cbfd0caeb/Controller/ConfigurationController.php#L132-L148
695
interactivesolutions/honeycomb-acl
src/app/console/commands/HCPermissions.php
HCPermissions.generateRolesAndPermissions
private function generateRolesAndPermissions() { if( empty($this->aclData) ) { $this->error('empty roles and permissions in "generateRolesAndPermissions" method'); return; } foreach ( $this->aclData as $acl ) { $this->createPermissions($acl['acl']); $this->createRoles($acl['acl']); } $this->createRolesPermissions($this->aclData); }
php
private function generateRolesAndPermissions() { if( empty($this->aclData) ) { $this->error('empty roles and permissions in "generateRolesAndPermissions" method'); return; } foreach ( $this->aclData as $acl ) { $this->createPermissions($acl['acl']); $this->createRoles($acl['acl']); } $this->createRolesPermissions($this->aclData); }
[ "private", "function", "generateRolesAndPermissions", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "aclData", ")", ")", "{", "$", "this", "->", "error", "(", "'empty roles and permissions in \"generateRolesAndPermissions\" method'", ")", ";", "return", ";", "}", "foreach", "(", "$", "this", "->", "aclData", "as", "$", "acl", ")", "{", "$", "this", "->", "createPermissions", "(", "$", "acl", "[", "'acl'", "]", ")", ";", "$", "this", "->", "createRoles", "(", "$", "acl", "[", "'acl'", "]", ")", ";", "}", "$", "this", "->", "createRolesPermissions", "(", "$", "this", "->", "aclData", ")", ";", "}" ]
Create roles, permissions and roles_permissions
[ "Create", "roles", "permissions", "and", "roles_permissions" ]
6c73d7d1c5d17ef730593e03386236a746bab12c
https://github.com/interactivesolutions/honeycomb-acl/blob/6c73d7d1c5d17ef730593e03386236a746bab12c/src/app/console/commands/HCPermissions.php#L94-L108
696
interactivesolutions/honeycomb-acl
src/app/console/commands/HCPermissions.php
HCPermissions.createRolesPermissions
private function createRolesPermissions(array $aclData) { $allRolesActions = $this->extractAllActions($aclData); $uncheckedActionsOutput = []; foreach ( $this->rolesList as $roleRecord ) { // load current role permissions $roleRecord->load('permissions'); // get current role permissions $currentRolePermissions = $roleRecord->permissions->pluck('action')->toArray(); // if role already has permissions if( count($currentRolePermissions) ) { // unchecked actions $uncheckedActions = array_diff($allRolesActions[$roleRecord->slug], $currentRolePermissions); if( ! empty($uncheckedActions) ) { $uncheckedActionsOutput[] = [$roleRecord->name, implode("\n", $uncheckedActions)]; } continue; } // if role doesn't have any permissions than create it // get all permissions $permissions = Permissions::whereIn('action', $allRolesActions[$roleRecord->slug])->get(); // sync permissions $roleRecord->permissions()->sync($permissions->pluck('id')); } // if role has unchecked actions than show which actions is unchecked if( $uncheckedActionsOutput ) { $this->table(['Role', 'Unchecked actions'], $uncheckedActionsOutput); } }
php
private function createRolesPermissions(array $aclData) { $allRolesActions = $this->extractAllActions($aclData); $uncheckedActionsOutput = []; foreach ( $this->rolesList as $roleRecord ) { // load current role permissions $roleRecord->load('permissions'); // get current role permissions $currentRolePermissions = $roleRecord->permissions->pluck('action')->toArray(); // if role already has permissions if( count($currentRolePermissions) ) { // unchecked actions $uncheckedActions = array_diff($allRolesActions[$roleRecord->slug], $currentRolePermissions); if( ! empty($uncheckedActions) ) { $uncheckedActionsOutput[] = [$roleRecord->name, implode("\n", $uncheckedActions)]; } continue; } // if role doesn't have any permissions than create it // get all permissions $permissions = Permissions::whereIn('action', $allRolesActions[$roleRecord->slug])->get(); // sync permissions $roleRecord->permissions()->sync($permissions->pluck('id')); } // if role has unchecked actions than show which actions is unchecked if( $uncheckedActionsOutput ) { $this->table(['Role', 'Unchecked actions'], $uncheckedActionsOutput); } }
[ "private", "function", "createRolesPermissions", "(", "array", "$", "aclData", ")", "{", "$", "allRolesActions", "=", "$", "this", "->", "extractAllActions", "(", "$", "aclData", ")", ";", "$", "uncheckedActionsOutput", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "rolesList", "as", "$", "roleRecord", ")", "{", "// load current role permissions", "$", "roleRecord", "->", "load", "(", "'permissions'", ")", ";", "// get current role permissions", "$", "currentRolePermissions", "=", "$", "roleRecord", "->", "permissions", "->", "pluck", "(", "'action'", ")", "->", "toArray", "(", ")", ";", "// if role already has permissions", "if", "(", "count", "(", "$", "currentRolePermissions", ")", ")", "{", "// unchecked actions", "$", "uncheckedActions", "=", "array_diff", "(", "$", "allRolesActions", "[", "$", "roleRecord", "->", "slug", "]", ",", "$", "currentRolePermissions", ")", ";", "if", "(", "!", "empty", "(", "$", "uncheckedActions", ")", ")", "{", "$", "uncheckedActionsOutput", "[", "]", "=", "[", "$", "roleRecord", "->", "name", ",", "implode", "(", "\"\\n\"", ",", "$", "uncheckedActions", ")", "]", ";", "}", "continue", ";", "}", "// if role doesn't have any permissions than create it", "// get all permissions", "$", "permissions", "=", "Permissions", "::", "whereIn", "(", "'action'", ",", "$", "allRolesActions", "[", "$", "roleRecord", "->", "slug", "]", ")", "->", "get", "(", ")", ";", "// sync permissions", "$", "roleRecord", "->", "permissions", "(", ")", "->", "sync", "(", "$", "permissions", "->", "pluck", "(", "'id'", ")", ")", ";", "}", "// if role has unchecked actions than show which actions is unchecked", "if", "(", "$", "uncheckedActionsOutput", ")", "{", "$", "this", "->", "table", "(", "[", "'Role'", ",", "'Unchecked actions'", "]", ",", "$", "uncheckedActionsOutput", ")", ";", "}", "}" ]
Creating roles permissions @param $aclData @internal param $acl
[ "Creating", "roles", "permissions" ]
6c73d7d1c5d17ef730593e03386236a746bab12c
https://github.com/interactivesolutions/honeycomb-acl/blob/6c73d7d1c5d17ef730593e03386236a746bab12c/src/app/console/commands/HCPermissions.php#L177-L216
697
squire-assistant/dependency-injection
ContainerBuilder.php
ContainerBuilder.addResource
public function addResource(ResourceInterface $resource) { if (!$this->trackResources) { return $this; } $this->resources[] = $resource; return $this; }
php
public function addResource(ResourceInterface $resource) { if (!$this->trackResources) { return $this; } $this->resources[] = $resource; return $this; }
[ "public", "function", "addResource", "(", "ResourceInterface", "$", "resource", ")", "{", "if", "(", "!", "$", "this", "->", "trackResources", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "resources", "[", "]", "=", "$", "resource", ";", "return", "$", "this", ";", "}" ]
Adds a resource for this configuration. @param ResourceInterface $resource A resource instance @return $this
[ "Adds", "a", "resource", "for", "this", "configuration", "." ]
c61d77bf8814369344fd71b015d7238322126041
https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/ContainerBuilder.php#L211-L220
698
squire-assistant/dependency-injection
ContainerBuilder.php
ContainerBuilder.addClassResource
public function addClassResource(\ReflectionClass $class) { if (!$this->trackResources) { return $this; } do { if (is_file($class->getFileName())) { $this->addResource(new FileResource($class->getFileName())); } } while ($class = $class->getParentClass()); return $this; }
php
public function addClassResource(\ReflectionClass $class) { if (!$this->trackResources) { return $this; } do { if (is_file($class->getFileName())) { $this->addResource(new FileResource($class->getFileName())); } } while ($class = $class->getParentClass()); return $this; }
[ "public", "function", "addClassResource", "(", "\\", "ReflectionClass", "$", "class", ")", "{", "if", "(", "!", "$", "this", "->", "trackResources", ")", "{", "return", "$", "this", ";", "}", "do", "{", "if", "(", "is_file", "(", "$", "class", "->", "getFileName", "(", ")", ")", ")", "{", "$", "this", "->", "addResource", "(", "new", "FileResource", "(", "$", "class", "->", "getFileName", "(", ")", ")", ")", ";", "}", "}", "while", "(", "$", "class", "=", "$", "class", "->", "getParentClass", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Adds the given class hierarchy as resources. @param \ReflectionClass $class @return $this
[ "Adds", "the", "given", "class", "hierarchy", "as", "resources", "." ]
c61d77bf8814369344fd71b015d7238322126041
https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/ContainerBuilder.php#L263-L276
699
squire-assistant/dependency-injection
ContainerBuilder.php
ContainerBuilder.resolveServices
public function resolveServices($value) { if (is_array($value)) { foreach ($value as $k => $v) { $value[$k] = $this->resolveServices($v); } } elseif ($value instanceof Reference) { $value = $this->get((string) $value, $value->getInvalidBehavior()); } elseif ($value instanceof Definition) { $value = $this->createService($value, null); } elseif ($value instanceof Expression) { $value = $this->getExpressionLanguage()->evaluate($value, array('container' => $this)); } return $value; }
php
public function resolveServices($value) { if (is_array($value)) { foreach ($value as $k => $v) { $value[$k] = $this->resolveServices($v); } } elseif ($value instanceof Reference) { $value = $this->get((string) $value, $value->getInvalidBehavior()); } elseif ($value instanceof Definition) { $value = $this->createService($value, null); } elseif ($value instanceof Expression) { $value = $this->getExpressionLanguage()->evaluate($value, array('container' => $this)); } return $value; }
[ "public", "function", "resolveServices", "(", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "value", "[", "$", "k", "]", "=", "$", "this", "->", "resolveServices", "(", "$", "v", ")", ";", "}", "}", "elseif", "(", "$", "value", "instanceof", "Reference", ")", "{", "$", "value", "=", "$", "this", "->", "get", "(", "(", "string", ")", "$", "value", ",", "$", "value", "->", "getInvalidBehavior", "(", ")", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "Definition", ")", "{", "$", "value", "=", "$", "this", "->", "createService", "(", "$", "value", ",", "null", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "Expression", ")", "{", "$", "value", "=", "$", "this", "->", "getExpressionLanguage", "(", ")", "->", "evaluate", "(", "$", "value", ",", "array", "(", "'container'", "=>", "$", "this", ")", ")", ";", "}", "return", "$", "value", ";", "}" ]
Replaces service references by the real service instance and evaluates expressions. @param mixed $value A value @return mixed The same value with all service references replaced by the real service instances and all expressions evaluated
[ "Replaces", "service", "references", "by", "the", "real", "service", "instance", "and", "evaluates", "expressions", "." ]
c61d77bf8814369344fd71b015d7238322126041
https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/ContainerBuilder.php#L942-L957