id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
18,600
bosha/PTel
src/PTel.php
PTel.getMetaData
public function getMetaData($param) { if (!$this->_sock) { throw new SocketClientException("Connection gone!"); } $info = stream_get_meta_data($this->_sock); return $info[$param]; }
php
public function getMetaData($param) { if (!$this->_sock) { throw new SocketClientException("Connection gone!"); } $info = stream_get_meta_data($this->_sock); return $info[$param]; }
[ "public", "function", "getMetaData", "(", "$", "param", ")", "{", "if", "(", "!", "$", "this", "->", "_sock", ")", "{", "throw", "new", "SocketClientException", "(", "\"Connection gone!\"", ")", ";", "}", "$", "info", "=", "stream_get_meta_data", "(", "$", "this", "->", "_sock", ")", ";", "return", "$", "info", "[", "$", "param", "]", ";", "}" ]
Return stream meta data parameter @param $param string Parameter name @throws SocketClientException On socket communication error @return mixed Value of parameter
[ "Return", "stream", "meta", "data", "parameter" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L374-L378
18,601
bosha/PTel
src/PTel.php
PTel._negotiateDo
private function _negotiateDo($cmd) { switch ($cmd) { case TEL_TTYPE: // Send terminal type $term = (binary) $this->terminal_type; return $this->send(TEL_IAC.TEL_SUB.TEL_TTYPE.TEL_BIN.$term. TEL_IAC.TEL_SUBEND,false); case TEL_XDISPLOC: // Send display location $hostname = (binary) php_uname('n').':0.0'; return $this->send(TEL_IAC.TEL_SUB.TEL_XDISPLOC.TEL_BIN.$hostname. TEL_IAC.TEL_SUBEND, false); case TEL_NEWENV: // Send new environment name $env = (binary) 'DISPLAY ' . php_uname('n'). ':0.0'; return $this->send(TEL_IAC.TEL_SUB.TEL_NEWENV.TEL_BIN.$env. TEL_IAC.TEL_SUBEND, false); case TEL_TSPEED: // Send terminal speed $tspeed = (binary) $this->terminal_speed_in . ','. $this->terminal_speed_out; return $this->send(TEL_IAC.TEL_SUB.TEL_TSPEED.TEL_BIN.$tspeed. TEL_IAC.TEL_SUBEND, false); case TEL_NAWS: // Negotiate about window size $null = chr(0); $height = chr($this->window_size_height); $width = chr($this->window_size_width); return $this->send(TEL_IAC.TEL_SUB.TEL_NAWS.$null.$width.$null.$height. TEL_IAC.TEL_SUBEND, false); case TEL_GA: break; case TEL_ECHO: // This is workaround for some strange thing return $this->send(TEL_IAC.TEL_WONT.TEL_ECHO, false); default: // In case we didn't implement - tell that we will don't // use this option return $this->send(TEL_IAC.TEL_DONT.$cmd, false); } }
php
private function _negotiateDo($cmd) { switch ($cmd) { case TEL_TTYPE: // Send terminal type $term = (binary) $this->terminal_type; return $this->send(TEL_IAC.TEL_SUB.TEL_TTYPE.TEL_BIN.$term. TEL_IAC.TEL_SUBEND,false); case TEL_XDISPLOC: // Send display location $hostname = (binary) php_uname('n').':0.0'; return $this->send(TEL_IAC.TEL_SUB.TEL_XDISPLOC.TEL_BIN.$hostname. TEL_IAC.TEL_SUBEND, false); case TEL_NEWENV: // Send new environment name $env = (binary) 'DISPLAY ' . php_uname('n'). ':0.0'; return $this->send(TEL_IAC.TEL_SUB.TEL_NEWENV.TEL_BIN.$env. TEL_IAC.TEL_SUBEND, false); case TEL_TSPEED: // Send terminal speed $tspeed = (binary) $this->terminal_speed_in . ','. $this->terminal_speed_out; return $this->send(TEL_IAC.TEL_SUB.TEL_TSPEED.TEL_BIN.$tspeed. TEL_IAC.TEL_SUBEND, false); case TEL_NAWS: // Negotiate about window size $null = chr(0); $height = chr($this->window_size_height); $width = chr($this->window_size_width); return $this->send(TEL_IAC.TEL_SUB.TEL_NAWS.$null.$width.$null.$height. TEL_IAC.TEL_SUBEND, false); case TEL_GA: break; case TEL_ECHO: // This is workaround for some strange thing return $this->send(TEL_IAC.TEL_WONT.TEL_ECHO, false); default: // In case we didn't implement - tell that we will don't // use this option return $this->send(TEL_IAC.TEL_DONT.$cmd, false); } }
[ "private", "function", "_negotiateDo", "(", "$", "cmd", ")", "{", "switch", "(", "$", "cmd", ")", "{", "case", "TEL_TTYPE", ":", "// Send terminal type", "$", "term", "=", "(", "binary", ")", "$", "this", "->", "terminal_type", ";", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_SUB", ".", "TEL_TTYPE", ".", "TEL_BIN", ".", "$", "term", ".", "TEL_IAC", ".", "TEL_SUBEND", ",", "false", ")", ";", "case", "TEL_XDISPLOC", ":", "// Send display location", "$", "hostname", "=", "(", "binary", ")", "php_uname", "(", "'n'", ")", ".", "':0.0'", ";", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_SUB", ".", "TEL_XDISPLOC", ".", "TEL_BIN", ".", "$", "hostname", ".", "TEL_IAC", ".", "TEL_SUBEND", ",", "false", ")", ";", "case", "TEL_NEWENV", ":", "// Send new environment name", "$", "env", "=", "(", "binary", ")", "'DISPLAY '", ".", "php_uname", "(", "'n'", ")", ".", "':0.0'", ";", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_SUB", ".", "TEL_NEWENV", ".", "TEL_BIN", ".", "$", "env", ".", "TEL_IAC", ".", "TEL_SUBEND", ",", "false", ")", ";", "case", "TEL_TSPEED", ":", "// Send terminal speed", "$", "tspeed", "=", "(", "binary", ")", "$", "this", "->", "terminal_speed_in", ".", "','", ".", "$", "this", "->", "terminal_speed_out", ";", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_SUB", ".", "TEL_TSPEED", ".", "TEL_BIN", ".", "$", "tspeed", ".", "TEL_IAC", ".", "TEL_SUBEND", ",", "false", ")", ";", "case", "TEL_NAWS", ":", "// Negotiate about window size", "$", "null", "=", "chr", "(", "0", ")", ";", "$", "height", "=", "chr", "(", "$", "this", "->", "window_size_height", ")", ";", "$", "width", "=", "chr", "(", "$", "this", "->", "window_size_width", ")", ";", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_SUB", ".", "TEL_NAWS", ".", "$", "null", ".", "$", "width", ".", "$", "null", ".", "$", "height", ".", "TEL_IAC", ".", "TEL_SUBEND", ",", "false", ")", ";", "case", "TEL_GA", ":", "break", ";", "case", "TEL_ECHO", ":", "// This is workaround for some strange thing", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_WONT", ".", "TEL_ECHO", ",", "false", ")", ";", "default", ":", "// In case we didn't implement - tell that we will don't", "// use this option", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_DONT", ".", "$", "cmd", ",", "false", ")", ";", "}", "}" ]
Telnet DO negotiaion @param char $cmd Binary representation of command char @throws SocketClientException On socket communication error @return int Bytes written
[ "Telnet", "DO", "negotiaion" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L422-L454
18,602
bosha/PTel
src/PTel.php
PTel._negotiateWill
private function _negotiateWill($cmd) { switch ($cmd) { case TEL_GA: break; case TEL_ECHO: break; default: return $this->send(TEL_IAC.TEL_WONT.$cmd, false); } }
php
private function _negotiateWill($cmd) { switch ($cmd) { case TEL_GA: break; case TEL_ECHO: break; default: return $this->send(TEL_IAC.TEL_WONT.$cmd, false); } }
[ "private", "function", "_negotiateWill", "(", "$", "cmd", ")", "{", "switch", "(", "$", "cmd", ")", "{", "case", "TEL_GA", ":", "break", ";", "case", "TEL_ECHO", ":", "break", ";", "default", ":", "return", "$", "this", "->", "send", "(", "TEL_IAC", ".", "TEL_WONT", ".", "$", "cmd", ",", "false", ")", ";", "}", "}" ]
Telnet WILL negotiaion @param char $cmd Binary representation of command char @throws SocketClientException On socket communication error @return int Bytes written
[ "Telnet", "WILL", "negotiaion" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L464-L473
18,603
bosha/PTel
src/PTel.php
PTel.waitReply
public function waitReply($timeout = 10) { $timestart = time(); while (true) { $char = $this->recvChr(); $timerun = time() - $timestart; if ($timerun >= $timeout) { return false; } if(!empty($char)) { return true; } } return false; }
php
public function waitReply($timeout = 10) { $timestart = time(); while (true) { $char = $this->recvChr(); $timerun = time() - $timestart; if ($timerun >= $timeout) { return false; } if(!empty($char)) { return true; } } return false; }
[ "public", "function", "waitReply", "(", "$", "timeout", "=", "10", ")", "{", "$", "timestart", "=", "time", "(", ")", ";", "while", "(", "true", ")", "{", "$", "char", "=", "$", "this", "->", "recvChr", "(", ")", ";", "$", "timerun", "=", "time", "(", ")", "-", "$", "timestart", ";", "if", "(", "$", "timerun", ">=", "$", "timeout", ")", "{", "return", "false", ";", "}", "if", "(", "!", "empty", "(", "$", "char", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Wait for reply from socket @param int $timeout Max timeout to wait reply @throws SocketClientException On socket communication error @return bool True if found reply, false if timeout reached
[ "Wait", "for", "reply", "from", "socket" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L483-L496
18,604
bosha/PTel
src/PTel.php
PTel.waitFor
public function waitFor($str, $maxtimeout = 10) { $timestart = time(); $buff = ''; while (true) { $buff .= $this->recvChr(); $timerun = time() - $timestart; if (preg_match("/$str/", $buff, $matches)) { return true; } if ($timerun >= $maxtimeout) { throw new TelnetException("Could not find occurance [ $str ] within timeout"); } } return false; }
php
public function waitFor($str, $maxtimeout = 10) { $timestart = time(); $buff = ''; while (true) { $buff .= $this->recvChr(); $timerun = time() - $timestart; if (preg_match("/$str/", $buff, $matches)) { return true; } if ($timerun >= $maxtimeout) { throw new TelnetException("Could not find occurance [ $str ] within timeout"); } } return false; }
[ "public", "function", "waitFor", "(", "$", "str", ",", "$", "maxtimeout", "=", "10", ")", "{", "$", "timestart", "=", "time", "(", ")", ";", "$", "buff", "=", "''", ";", "while", "(", "true", ")", "{", "$", "buff", ".=", "$", "this", "->", "recvChr", "(", ")", ";", "$", "timerun", "=", "time", "(", ")", "-", "$", "timestart", ";", "if", "(", "preg_match", "(", "\"/$str/\"", ",", "$", "buff", ",", "$", "matches", ")", ")", "{", "return", "true", ";", "}", "if", "(", "$", "timerun", ">=", "$", "maxtimeout", ")", "{", "throw", "new", "TelnetException", "(", "\"Could not find occurance [ $str ] within timeout\"", ")", ";", "}", "}", "return", "false", ";", "}" ]
Wait for specified message from socket till timeout @param string $str String to wait @param int $maxtimeout Maximum timeout to wait @throws SocketClientException On socket communication error @throws TelnetException If maxtimeout reached @return bool True if found
[ "Wait", "for", "specified", "message", "from", "socket", "till", "timeout" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L508-L524
18,605
bosha/PTel
src/PTel.php
PTel.getOutputOf
public function getOutputOf($cmd, $newline = true, $maxtimeout = 10) { $return = array(); $this->recvAll(); $this->send($cmd, $newline); $timestart = time(); while (true) { $buff = $this->recvLine(); $timerun = time() - $timestart; if (strpos($buff, $this->prompt) !== false) { break; } if (preg_match("/$this->page_delimiter/i", $buff)) { $this->send(" ", false); $timestart = time(); continue; } if ($timerun >= $maxtimeout) { throw new TelnetException("Timeout reached while waiting to execute command: [ $cmd ]"); } $return[] = $buff; } $newret = array_slice($return, 1, -1); $newret = implode("\r", $newret); return $newret; }
php
public function getOutputOf($cmd, $newline = true, $maxtimeout = 10) { $return = array(); $this->recvAll(); $this->send($cmd, $newline); $timestart = time(); while (true) { $buff = $this->recvLine(); $timerun = time() - $timestart; if (strpos($buff, $this->prompt) !== false) { break; } if (preg_match("/$this->page_delimiter/i", $buff)) { $this->send(" ", false); $timestart = time(); continue; } if ($timerun >= $maxtimeout) { throw new TelnetException("Timeout reached while waiting to execute command: [ $cmd ]"); } $return[] = $buff; } $newret = array_slice($return, 1, -1); $newret = implode("\r", $newret); return $newret; }
[ "public", "function", "getOutputOf", "(", "$", "cmd", ",", "$", "newline", "=", "true", ",", "$", "maxtimeout", "=", "10", ")", "{", "$", "return", "=", "array", "(", ")", ";", "$", "this", "->", "recvAll", "(", ")", ";", "$", "this", "->", "send", "(", "$", "cmd", ",", "$", "newline", ")", ";", "$", "timestart", "=", "time", "(", ")", ";", "while", "(", "true", ")", "{", "$", "buff", "=", "$", "this", "->", "recvLine", "(", ")", ";", "$", "timerun", "=", "time", "(", ")", "-", "$", "timestart", ";", "if", "(", "strpos", "(", "$", "buff", ",", "$", "this", "->", "prompt", ")", "!==", "false", ")", "{", "break", ";", "}", "if", "(", "preg_match", "(", "\"/$this->page_delimiter/i\"", ",", "$", "buff", ")", ")", "{", "$", "this", "->", "send", "(", "\" \"", ",", "false", ")", ";", "$", "timestart", "=", "time", "(", ")", ";", "continue", ";", "}", "if", "(", "$", "timerun", ">=", "$", "maxtimeout", ")", "{", "throw", "new", "TelnetException", "(", "\"Timeout reached while waiting to execute command: [ $cmd ]\"", ")", ";", "}", "$", "return", "[", "]", "=", "$", "buff", ";", "}", "$", "newret", "=", "array_slice", "(", "$", "return", ",", "1", ",", "-", "1", ")", ";", "$", "newret", "=", "implode", "(", "\"\\r\"", ",", "$", "newret", ")", ";", "return", "$", "newret", ";", "}" ]
Get only output of running command @param string $cmd Command to execute @param bool $newline Add new line character, or not @param int $maxtimeout Maximum timeout to wait command execution @throws SocketClientException On socket communication error @throws TelnetException If maximum timeout reached @return string Result of command
[ "Get", "only", "output", "of", "running", "command" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L538-L565
18,606
bosha/PTel
src/PTel.php
PTel.setTermSpeed
public function setTermSpeed($in, $out) { $this->terminal_speed_in = $in; $this->terminal_speed_out = $out; return $this; }
php
public function setTermSpeed($in, $out) { $this->terminal_speed_in = $in; $this->terminal_speed_out = $out; return $this; }
[ "public", "function", "setTermSpeed", "(", "$", "in", ",", "$", "out", ")", "{", "$", "this", "->", "terminal_speed_in", "=", "$", "in", ";", "$", "this", "->", "terminal_speed_out", "=", "$", "out", ";", "return", "$", "this", ";", "}" ]
Setting terminal speed @param string $in String with inbound terminal speed @param string $out String with outbound terminal speed @return $this Instance of current class
[ "Setting", "terminal", "speed" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L587-L592
18,607
bosha/PTel
src/PTel.php
PTel.setWindowSize
public function setWindowSize($height, $width) { if (!is_int($height) || !is_int($width)) { throw new TelnetException("Wrong windows height or width used. Should valid integer."); } if ($height < 1 || $width < 1 || $height === 255 || $width === 255) { throw new TelnetException("Window size can't be negative or 255"); } $this->winsize_height = $height; $this->winsize_widht = $width; return $this; }
php
public function setWindowSize($height, $width) { if (!is_int($height) || !is_int($width)) { throw new TelnetException("Wrong windows height or width used. Should valid integer."); } if ($height < 1 || $width < 1 || $height === 255 || $width === 255) { throw new TelnetException("Window size can't be negative or 255"); } $this->winsize_height = $height; $this->winsize_widht = $width; return $this; }
[ "public", "function", "setWindowSize", "(", "$", "height", ",", "$", "width", ")", "{", "if", "(", "!", "is_int", "(", "$", "height", ")", "||", "!", "is_int", "(", "$", "width", ")", ")", "{", "throw", "new", "TelnetException", "(", "\"Wrong windows height or width used. Should valid integer.\"", ")", ";", "}", "if", "(", "$", "height", "<", "1", "||", "$", "width", "<", "1", "||", "$", "height", "===", "255", "||", "$", "width", "===", "255", ")", "{", "throw", "new", "TelnetException", "(", "\"Window size can't be negative or 255\"", ")", ";", "}", "$", "this", "->", "winsize_height", "=", "$", "height", ";", "$", "this", "->", "winsize_widht", "=", "$", "width", ";", "return", "$", "this", ";", "}" ]
Window size used while negotiating @param int $height Window height @param int $width Window width @throws TelnetException On wrong parameter specified @throws SocketClientException On socket communication error @return $this Instance of current class
[ "Window", "size", "used", "while", "negotiating" ]
049d72f8faaf6c2548353e715e06ad1f28c756b5
https://github.com/bosha/PTel/blob/049d72f8faaf6c2548353e715e06ad1f28c756b5/src/PTel.php#L605-L618
18,608
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setLiveInfoPosition
public function setLiveInfoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->liveInfoProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setLiveInfoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->liveInfoProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setLiveInfoPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "liveInfoProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the live info position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "live", "info", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L124-L128
18,609
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setSpectatorInfoPosition
public function setSpectatorInfoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->spectatorInfoProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setSpectatorInfoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->spectatorInfoProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setSpectatorInfoPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "spectatorInfoProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the spectator info position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "spectator", "info", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L174-L178
18,610
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setCheckpointListPosition
public function setCheckpointListPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->checkpointListProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setCheckpointListPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->checkpointListProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setCheckpointListPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "checkpointListProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the checkpoint list position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "checkpoint", "list", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L248-L252
18,611
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setRoundScoresPosition
public function setRoundScoresPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->roundScoresProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setRoundScoresPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->roundScoresProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setRoundScoresPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "roundScoresProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the round scores position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "round", "scores", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L298-L302
18,612
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setChronoPosition
public function setChronoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->chronoProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setChronoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->chronoProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setChronoPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "chronoProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the chrono position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "chrono", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L348-L352
18,613
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setSpeedAndDistancePosition
public function setSpeedAndDistancePosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->speedAndDistanceProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setSpeedAndDistancePosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->speedAndDistanceProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setSpeedAndDistancePosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "speedAndDistanceProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the speed and distance position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "speed", "and", "distance", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L398-L402
18,614
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setPersonalBestAndRankPosition
public function setPersonalBestAndRankPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->personalBestAndRankProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setPersonalBestAndRankPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->personalBestAndRankProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setPersonalBestAndRankPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "personalBestAndRankProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the personal best and rank position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "personal", "best", "and", "rank", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L448-L452
18,615
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setPositionPosition
public function setPositionPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->positionProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setPositionPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->positionProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setPositionPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "positionProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the position position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "position", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L498-L502
18,616
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setCheckpointTimePosition
public function setCheckpointTimePosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->checkpointTimeProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setCheckpointTimePosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->checkpointTimeProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setCheckpointTimePosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "checkpointTimeProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the checkpoint time position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "checkpoint", "time", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L548-L552
18,617
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setWarmUpPosition
public function setWarmUpPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->warmUpProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setWarmUpPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->warmUpProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setWarmUpPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "warmUpProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the warm-up position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "warm", "-", "up", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L598-L602
18,618
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setMultiLapInfoPosition
public function setMultiLapInfoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->multiLapInfoProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setMultiLapInfoPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->multiLapInfoProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setMultiLapInfoPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "multiLapInfoProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the multi-lap info position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "multi", "-", "lap", "info", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L648-L652
18,619
steeffeen/FancyManiaLinks
FML/XmlRpc/TMUIProperties.php
TMUIProperties.setCheckpointRankingPosition
public function setCheckpointRankingPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->checkpointRankingProperties, $positionX, $positionY, $positionZ); return $this; }
php
public function setCheckpointRankingPosition($positionX, $positionY, $positionZ = null) { $this->setPositionProperty($this->checkpointRankingProperties, $positionX, $positionY, $positionZ); return $this; }
[ "public", "function", "setCheckpointRankingPosition", "(", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", "=", "null", ")", "{", "$", "this", "->", "setPositionProperty", "(", "$", "this", "->", "checkpointRankingProperties", ",", "$", "positionX", ",", "$", "positionY", ",", "$", "positionZ", ")", ";", "return", "$", "this", ";", "}" ]
Set the checkpoint ranking position @api @param float $positionX X position @param float $positionY Y position @param float $positionZ (optional) Z position (Z-index) @return static
[ "Set", "the", "checkpoint", "ranking", "position" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/XmlRpc/TMUIProperties.php#L698-L702
18,620
scrutinizer-ci/rabbitmq
src/Scrutinizer/RabbitMQ/Rpc/RpcClient.php
RpcClient.invoke
public function invoke($queueName, $payload, $resultType, $timeout = 10) { $rs = $this->invokeAll(array(array($queueName, $payload, $resultType)), $timeout); if ($rs[0] instanceof RpcError) { throw new RpcErrorException($rs[0]); } return $rs[0]; }
php
public function invoke($queueName, $payload, $resultType, $timeout = 10) { $rs = $this->invokeAll(array(array($queueName, $payload, $resultType)), $timeout); if ($rs[0] instanceof RpcError) { throw new RpcErrorException($rs[0]); } return $rs[0]; }
[ "public", "function", "invoke", "(", "$", "queueName", ",", "$", "payload", ",", "$", "resultType", ",", "$", "timeout", "=", "10", ")", "{", "$", "rs", "=", "$", "this", "->", "invokeAll", "(", "array", "(", "array", "(", "$", "queueName", ",", "$", "payload", ",", "$", "resultType", ")", ")", ",", "$", "timeout", ")", ";", "if", "(", "$", "rs", "[", "0", "]", "instanceof", "RpcError", ")", "{", "throw", "new", "RpcErrorException", "(", "$", "rs", "[", "0", "]", ")", ";", "}", "return", "$", "rs", "[", "0", "]", ";", "}" ]
Invokes a single remote command and returns the result of the invocation. The remote command is invoked synchronously. @param $queueName @param $payload @param $resultType @throws RpcErrorException when a remote error occurs @return mixed
[ "Invokes", "a", "single", "remote", "command", "and", "returns", "the", "result", "of", "the", "invocation", "." ]
5603f7901de2ad352086287f8d2c65bbae5170d5
https://github.com/scrutinizer-ci/rabbitmq/blob/5603f7901de2ad352086287f8d2c65bbae5170d5/src/Scrutinizer/RabbitMQ/Rpc/RpcClient.php#L93-L101
18,621
webforge-labs/psc-cms
lib/Psc/Code/Generate/GProperty.php
GProperty.reflectorFactory
public static function reflectorFactory(Reflector $reflector) { $args = func_get_args(); $g = new static($args[1]); $g->elevate($args[0]); return $g; }
php
public static function reflectorFactory(Reflector $reflector) { $args = func_get_args(); $g = new static($args[1]); $g->elevate($args[0]); return $g; }
[ "public", "static", "function", "reflectorFactory", "(", "Reflector", "$", "reflector", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "g", "=", "new", "static", "(", "$", "args", "[", "1", "]", ")", ";", "$", "g", "->", "elevate", "(", "$", "args", "[", "0", "]", ")", ";", "return", "$", "g", ";", "}" ]
Erstellt ein neues GProperty der zweite Parameter ist wichtig @param Reflector $reflector @param GClass $gClass
[ "Erstellt", "ein", "neues", "GProperty" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/GProperty.php#L126-L131
18,622
askupasoftware/amarkal
Form/Updater.php
Updater.reset
public function reset( array $names = array() ) { if( array() == $names ) { // Unset new instance to force reset $this->new_instance = array(); return $this->update(); } else { foreach( $this->components as $c ) { if( in_array($c->get_name(), $names) ) { $this->new_instance[$c->get_name()] = $c->get_default_value(); } } return $this->update(); } }
php
public function reset( array $names = array() ) { if( array() == $names ) { // Unset new instance to force reset $this->new_instance = array(); return $this->update(); } else { foreach( $this->components as $c ) { if( in_array($c->get_name(), $names) ) { $this->new_instance[$c->get_name()] = $c->get_default_value(); } } return $this->update(); } }
[ "public", "function", "reset", "(", "array", "$", "names", "=", "array", "(", ")", ")", "{", "if", "(", "array", "(", ")", "==", "$", "names", ")", "{", "// Unset new instance to force reset", "$", "this", "->", "new_instance", "=", "array", "(", ")", ";", "return", "$", "this", "->", "update", "(", ")", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "components", "as", "$", "c", ")", "{", "if", "(", "in_array", "(", "$", "c", "->", "get_name", "(", ")", ",", "$", "names", ")", ")", "{", "$", "this", "->", "new_instance", "[", "$", "c", "->", "get_name", "(", ")", "]", "=", "$", "c", "->", "get_default_value", "(", ")", ";", "}", "}", "return", "$", "this", "->", "update", "(", ")", ";", "}", "}" ]
Reset all fields to their default values. @param array $names List of component names to be set to their defaults. If no names are specified, all components will be reset @return array The updated values array.
[ "Reset", "all", "fields", "to", "their", "default", "values", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Form/Updater.php#L97-L116
18,623
askupasoftware/amarkal
Form/Updater.php
Updater.update_components
private function update_components( $components ) { foreach ( $components as $component ) { // Update each component in the composite collection if ( $component instanceof UI\Components\Composite ) { $this->update_components( $component->components ); } // Update individual fields, as well as the composite parent field. if ( $component instanceof UI\ValueComponentInterface ) { $this->update_component( $component ); } } }
php
private function update_components( $components ) { foreach ( $components as $component ) { // Update each component in the composite collection if ( $component instanceof UI\Components\Composite ) { $this->update_components( $component->components ); } // Update individual fields, as well as the composite parent field. if ( $component instanceof UI\ValueComponentInterface ) { $this->update_component( $component ); } } }
[ "private", "function", "update_components", "(", "$", "components", ")", "{", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "// Update each component in the composite collection", "if", "(", "$", "component", "instanceof", "UI", "\\", "Components", "\\", "Composite", ")", "{", "$", "this", "->", "update_components", "(", "$", "component", "->", "components", ")", ";", "}", "// Update individual fields, as well as the composite parent field.", "if", "(", "$", "component", "instanceof", "UI", "\\", "ValueComponentInterface", ")", "{", "$", "this", "->", "update_component", "(", "$", "component", ")", ";", "}", "}", "}" ]
Update the given list of components. Recursively calls itself fpr composite components. @param UI\AbstractComponent $components
[ "Update", "the", "given", "list", "of", "components", ".", "Recursively", "calls", "itself", "fpr", "composite", "components", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Form/Updater.php#L124-L140
18,624
askupasoftware/amarkal
Form/Updater.php
Updater.update_value
private function update_value( $component, $value ) { $component->set_value( $value ); $this->final_instance[$component->get_name()] = $value; }
php
private function update_value( $component, $value ) { $component->set_value( $value ); $this->final_instance[$component->get_name()] = $value; }
[ "private", "function", "update_value", "(", "$", "component", ",", "$", "value", ")", "{", "$", "component", "->", "set_value", "(", "$", "value", ")", ";", "$", "this", "->", "final_instance", "[", "$", "component", "->", "get_name", "(", ")", "]", "=", "$", "value", ";", "}" ]
Update the component's value and the final instance with the given value. @param UI\AbstractComponent $component @param string $value
[ "Update", "the", "component", "s", "value", "and", "the", "final", "instance", "with", "the", "given", "value", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Form/Updater.php#L200-L204
18,625
askupasoftware/amarkal
Form/Updater.php
Updater.update_filterable
private function update_filterable( UI\FilterableComponentInterface $component ) { $this->update_value( $component, $component->apply_filter( $this->new_instance[$component->get_name()] ) ); }
php
private function update_filterable( UI\FilterableComponentInterface $component ) { $this->update_value( $component, $component->apply_filter( $this->new_instance[$component->get_name()] ) ); }
[ "private", "function", "update_filterable", "(", "UI", "\\", "FilterableComponentInterface", "$", "component", ")", "{", "$", "this", "->", "update_value", "(", "$", "component", ",", "$", "component", "->", "apply_filter", "(", "$", "this", "->", "new_instance", "[", "$", "component", "->", "get_name", "(", ")", "]", ")", ")", ";", "}" ]
Filter the component's value using its filter function. @param UI\FilterableComponentInterface $component
[ "Filter", "the", "component", "s", "value", "using", "its", "filter", "function", "." ]
fe8283e2d6847ef697abec832da7ee741a85058c
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Form/Updater.php#L224-L230
18,626
forxer/tao
src/Tao/Support/StopWords.php
StopWords.get
public function get($locale = 'en') { if (isset($this->stopwords[$locale])) { return $this->stopwords[$locale]; } $this->stopwords[$locale] = []; $filename = $this->path . '/' . $locale . '.php'; if (file_exists($filename)) { $this->stopwords[$locale] = require $filename; } return $this->stopwords[$locale]; }
php
public function get($locale = 'en') { if (isset($this->stopwords[$locale])) { return $this->stopwords[$locale]; } $this->stopwords[$locale] = []; $filename = $this->path . '/' . $locale . '.php'; if (file_exists($filename)) { $this->stopwords[$locale] = require $filename; } return $this->stopwords[$locale]; }
[ "public", "function", "get", "(", "$", "locale", "=", "'en'", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "stopwords", "[", "$", "locale", "]", ")", ")", "{", "return", "$", "this", "->", "stopwords", "[", "$", "locale", "]", ";", "}", "$", "this", "->", "stopwords", "[", "$", "locale", "]", "=", "[", "]", ";", "$", "filename", "=", "$", "this", "->", "path", ".", "'/'", ".", "$", "locale", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "this", "->", "stopwords", "[", "$", "locale", "]", "=", "require", "$", "filename", ";", "}", "return", "$", "this", "->", "stopwords", "[", "$", "locale", "]", ";", "}" ]
Return stop word list for given locale. @param string $locale @return array
[ "Return", "stop", "word", "list", "for", "given", "locale", "." ]
b5e9109c244a29a72403ae6a58633ab96a67c660
https://github.com/forxer/tao/blob/b5e9109c244a29a72403ae6a58633ab96a67c660/src/Tao/Support/StopWords.php#L25-L40
18,627
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseRolePeer.php
BaseRolePeer.doInsert
public static function doInsert($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(RolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity } else { $criteria = $values->buildCriteria(); // build Criteria from Role object } if ($criteria->containsKey(RolePeer::ID) && $criteria->keyContainsValue(RolePeer::ID) ) { throw new PropelException('Cannot insert a value for auto-increment primary key ('.RolePeer::ID.')'); } // Set the correct dbName $criteria->setDbName(RolePeer::DATABASE_NAME); try { // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) $con->beginTransaction(); $pk = BasePeer::doInsert($criteria, $con); $con->commit(); } catch (Exception $e) { $con->rollBack(); throw $e; } return $pk; }
php
public static function doInsert($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(RolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity } else { $criteria = $values->buildCriteria(); // build Criteria from Role object } if ($criteria->containsKey(RolePeer::ID) && $criteria->keyContainsValue(RolePeer::ID) ) { throw new PropelException('Cannot insert a value for auto-increment primary key ('.RolePeer::ID.')'); } // Set the correct dbName $criteria->setDbName(RolePeer::DATABASE_NAME); try { // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) $con->beginTransaction(); $pk = BasePeer::doInsert($criteria, $con); $con->commit(); } catch (Exception $e) { $con->rollBack(); throw $e; } return $pk; }
[ "public", "static", "function", "doInsert", "(", "$", "values", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "RolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "values", ";", "// rename for clarity", "}", "else", "{", "$", "criteria", "=", "$", "values", "->", "buildCriteria", "(", ")", ";", "// build Criteria from Role object", "}", "if", "(", "$", "criteria", "->", "containsKey", "(", "RolePeer", "::", "ID", ")", "&&", "$", "criteria", "->", "keyContainsValue", "(", "RolePeer", "::", "ID", ")", ")", "{", "throw", "new", "PropelException", "(", "'Cannot insert a value for auto-increment primary key ('", ".", "RolePeer", "::", "ID", ".", "')'", ")", ";", "}", "// Set the correct dbName", "$", "criteria", "->", "setDbName", "(", "RolePeer", "::", "DATABASE_NAME", ")", ";", "try", "{", "// use transaction because $criteria could contain info", "// for more than one table (I guess, conceivably)", "$", "con", "->", "beginTransaction", "(", ")", ";", "$", "pk", "=", "BasePeer", "::", "doInsert", "(", "$", "criteria", ",", "$", "con", ")", ";", "$", "con", "->", "commit", "(", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "con", "->", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "pk", ";", "}" ]
Performs an INSERT on the database, given a Role or Criteria object. @param mixed $values Criteria or Role object containing data that is used to create the INSERT statement. @param PropelPDO $con the PropelPDO connection to use @return mixed The new primary key. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "INSERT", "on", "the", "database", "given", "a", "Role", "or", "Criteria", "object", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseRolePeer.php#L516-L548
18,628
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Consoles/ModelDetail.php
ModelDetail.showDetail
protected function showDetail(Model $model) { $name = $this->manager->getClassName($model); $this->title("Summary of Model {$name} :"); $summary = $this->manager->getModelSummary($name); $rows = []; foreach ($summary as $key => $value) { if (is_bool($value)) { $value = $value ? 'yes' : 'no'; } $valueText = $this->paintString($value, 'brown'); $rows[] = [$key, $valueText]; } $this->table(['Key', 'Value'], $rows); $this->showDatabaseFields($model); $this->showRelatoins($model); $this->showModifier($model); }
php
protected function showDetail(Model $model) { $name = $this->manager->getClassName($model); $this->title("Summary of Model {$name} :"); $summary = $this->manager->getModelSummary($name); $rows = []; foreach ($summary as $key => $value) { if (is_bool($value)) { $value = $value ? 'yes' : 'no'; } $valueText = $this->paintString($value, 'brown'); $rows[] = [$key, $valueText]; } $this->table(['Key', 'Value'], $rows); $this->showDatabaseFields($model); $this->showRelatoins($model); $this->showModifier($model); }
[ "protected", "function", "showDetail", "(", "Model", "$", "model", ")", "{", "$", "name", "=", "$", "this", "->", "manager", "->", "getClassName", "(", "$", "model", ")", ";", "$", "this", "->", "title", "(", "\"Summary of Model {$name} :\"", ")", ";", "$", "summary", "=", "$", "this", "->", "manager", "->", "getModelSummary", "(", "$", "name", ")", ";", "$", "rows", "=", "[", "]", ";", "foreach", "(", "$", "summary", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "value", "?", "'yes'", ":", "'no'", ";", "}", "$", "valueText", "=", "$", "this", "->", "paintString", "(", "$", "value", ",", "'brown'", ")", ";", "$", "rows", "[", "]", "=", "[", "$", "key", ",", "$", "valueText", "]", ";", "}", "$", "this", "->", "table", "(", "[", "'Key'", ",", "'Value'", "]", ",", "$", "rows", ")", ";", "$", "this", "->", "showDatabaseFields", "(", "$", "model", ")", ";", "$", "this", "->", "showRelatoins", "(", "$", "model", ")", ";", "$", "this", "->", "showModifier", "(", "$", "model", ")", ";", "}" ]
show detail of model @param Model $model @return void
[ "show", "detail", "of", "model" ]
4288426517f53d05177b8729c4ba94c5beca9a98
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Consoles/ModelDetail.php#L77-L101
18,629
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Consoles/ModelDetail.php
ModelDetail.showDatabaseFields
protected function showDatabaseFields(Model $model) { $this->title("Table {$model->getTable()} :"); if ( ! $this->db->isConnected()) { $this->warn("Not Connected to databse, please check your connection config\r"); } else { $fields = $this->db->getFields($model->getTable()); $headers = ['name', 'type', 'null', 'length', 'unsigned', 'autoincrement', 'primary_key', 'foreign_key']; $this->table($headers, $fields->toArray()); } }
php
protected function showDatabaseFields(Model $model) { $this->title("Table {$model->getTable()} :"); if ( ! $this->db->isConnected()) { $this->warn("Not Connected to databse, please check your connection config\r"); } else { $fields = $this->db->getFields($model->getTable()); $headers = ['name', 'type', 'null', 'length', 'unsigned', 'autoincrement', 'primary_key', 'foreign_key']; $this->table($headers, $fields->toArray()); } }
[ "protected", "function", "showDatabaseFields", "(", "Model", "$", "model", ")", "{", "$", "this", "->", "title", "(", "\"Table {$model->getTable()} :\"", ")", ";", "if", "(", "!", "$", "this", "->", "db", "->", "isConnected", "(", ")", ")", "{", "$", "this", "->", "warn", "(", "\"Not Connected to databse, please check your connection config\\r\"", ")", ";", "}", "else", "{", "$", "fields", "=", "$", "this", "->", "db", "->", "getFields", "(", "$", "model", "->", "getTable", "(", ")", ")", ";", "$", "headers", "=", "[", "'name'", ",", "'type'", ",", "'null'", ",", "'length'", ",", "'unsigned'", ",", "'autoincrement'", ",", "'primary_key'", ",", "'foreign_key'", "]", ";", "$", "this", "->", "table", "(", "$", "headers", ",", "$", "fields", "->", "toArray", "(", ")", ")", ";", "}", "}" ]
show database fileds @param Model $model @return void
[ "show", "database", "fileds" ]
4288426517f53d05177b8729c4ba94c5beca9a98
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Consoles/ModelDetail.php#L109-L121
18,630
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Consoles/ModelDetail.php
ModelDetail.showRelatoins
protected function showRelatoins(Model $model) { $name = $this->manager->getClassName($model); $this->title("Relations of Model {$name}: "); $relations = $this->manager->getRelations($model); $tbody = []; foreach ($relations as $relation) { $relationName = $this->manager->getClassName($relation); $related = $relation->getRelated() ?:null; $tbody[] = [ $this->paintString($relationName, 'brown'), $related ? $this->manager->getClassName($related) : '', ]; } $this->table(['relation', 'model'], $tbody); }
php
protected function showRelatoins(Model $model) { $name = $this->manager->getClassName($model); $this->title("Relations of Model {$name}: "); $relations = $this->manager->getRelations($model); $tbody = []; foreach ($relations as $relation) { $relationName = $this->manager->getClassName($relation); $related = $relation->getRelated() ?:null; $tbody[] = [ $this->paintString($relationName, 'brown'), $related ? $this->manager->getClassName($related) : '', ]; } $this->table(['relation', 'model'], $tbody); }
[ "protected", "function", "showRelatoins", "(", "Model", "$", "model", ")", "{", "$", "name", "=", "$", "this", "->", "manager", "->", "getClassName", "(", "$", "model", ")", ";", "$", "this", "->", "title", "(", "\"Relations of Model {$name}: \"", ")", ";", "$", "relations", "=", "$", "this", "->", "manager", "->", "getRelations", "(", "$", "model", ")", ";", "$", "tbody", "=", "[", "]", ";", "foreach", "(", "$", "relations", "as", "$", "relation", ")", "{", "$", "relationName", "=", "$", "this", "->", "manager", "->", "getClassName", "(", "$", "relation", ")", ";", "$", "related", "=", "$", "relation", "->", "getRelated", "(", ")", "?", ":", "null", ";", "$", "tbody", "[", "]", "=", "[", "$", "this", "->", "paintString", "(", "$", "relationName", ",", "'brown'", ")", ",", "$", "related", "?", "$", "this", "->", "manager", "->", "getClassName", "(", "$", "related", ")", ":", "''", ",", "]", ";", "}", "$", "this", "->", "table", "(", "[", "'relation'", ",", "'model'", "]", ",", "$", "tbody", ")", ";", "}" ]
show relations of model @param Model $model @return void
[ "show", "relations", "of", "model" ]
4288426517f53d05177b8729c4ba94c5beca9a98
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Consoles/ModelDetail.php#L129-L149
18,631
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Consoles/ModelDetail.php
ModelDetail.showModifier
protected function showModifier(Model $model) { $name = $this->manager->getClassName($model); $this->title("Modifier of Model {$name}: "); $modifiers = [ 'mutators' => $this->manager->getMutators($model), 'accessors' => $this->manager->getAccessors($model), 'scopes' => $this->manager->getScopes($model), ]; $rows = []; foreach (max($modifiers) as $modifier) { foreach (['mutator', 'accessor', 'scope'] as $type) { $$type = ''; $types = &$modifiers[Str::plural($type)]; if ($types->count() > 0) { $$type = $this->paintString($types->first()->getName(), 'brown'); unset($types[0]); } } $rows[] = [$mutator, $accessor, $scope]; } $headers = ['mutator', 'accessor', 'scope']; $this->table($headers, $rows); }
php
protected function showModifier(Model $model) { $name = $this->manager->getClassName($model); $this->title("Modifier of Model {$name}: "); $modifiers = [ 'mutators' => $this->manager->getMutators($model), 'accessors' => $this->manager->getAccessors($model), 'scopes' => $this->manager->getScopes($model), ]; $rows = []; foreach (max($modifiers) as $modifier) { foreach (['mutator', 'accessor', 'scope'] as $type) { $$type = ''; $types = &$modifiers[Str::plural($type)]; if ($types->count() > 0) { $$type = $this->paintString($types->first()->getName(), 'brown'); unset($types[0]); } } $rows[] = [$mutator, $accessor, $scope]; } $headers = ['mutator', 'accessor', 'scope']; $this->table($headers, $rows); }
[ "protected", "function", "showModifier", "(", "Model", "$", "model", ")", "{", "$", "name", "=", "$", "this", "->", "manager", "->", "getClassName", "(", "$", "model", ")", ";", "$", "this", "->", "title", "(", "\"Modifier of Model {$name}: \"", ")", ";", "$", "modifiers", "=", "[", "'mutators'", "=>", "$", "this", "->", "manager", "->", "getMutators", "(", "$", "model", ")", ",", "'accessors'", "=>", "$", "this", "->", "manager", "->", "getAccessors", "(", "$", "model", ")", ",", "'scopes'", "=>", "$", "this", "->", "manager", "->", "getScopes", "(", "$", "model", ")", ",", "]", ";", "$", "rows", "=", "[", "]", ";", "foreach", "(", "max", "(", "$", "modifiers", ")", "as", "$", "modifier", ")", "{", "foreach", "(", "[", "'mutator'", ",", "'accessor'", ",", "'scope'", "]", "as", "$", "type", ")", "{", "$", "$", "type", "=", "''", ";", "$", "types", "=", "&", "$", "modifiers", "[", "Str", "::", "plural", "(", "$", "type", ")", "]", ";", "if", "(", "$", "types", "->", "count", "(", ")", ">", "0", ")", "{", "$", "$", "type", "=", "$", "this", "->", "paintString", "(", "$", "types", "->", "first", "(", ")", "->", "getName", "(", ")", ",", "'brown'", ")", ";", "unset", "(", "$", "types", "[", "0", "]", ")", ";", "}", "}", "$", "rows", "[", "]", "=", "[", "$", "mutator", ",", "$", "accessor", ",", "$", "scope", "]", ";", "}", "$", "headers", "=", "[", "'mutator'", ",", "'accessor'", ",", "'scope'", "]", ";", "$", "this", "->", "table", "(", "$", "headers", ",", "$", "rows", ")", ";", "}" ]
show model modifier @param Model $model @return void
[ "show", "model", "modifier" ]
4288426517f53d05177b8729c4ba94c5beca9a98
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Consoles/ModelDetail.php#L157-L189
18,632
nicklaw5/larapi
src/Larapi.php
Larapi.badRequest
public function badRequest($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_BAD_REQUEST, $headers); }
php
public function badRequest($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_BAD_REQUEST, $headers); }
[ "public", "function", "badRequest", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_BAD_REQUEST", ",", "$", "headers", ")", ";", "}" ]
Returns 400 Bad Request Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "400", "Bad", "Request", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L110-L113
18,633
nicklaw5/larapi
src/Larapi.php
Larapi.unauthorized
public function unauthorized($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_UNAUTHORIZED, $headers); }
php
public function unauthorized($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_UNAUTHORIZED, $headers); }
[ "public", "function", "unauthorized", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_UNAUTHORIZED", ",", "$", "headers", ")", ";", "}" ]
Returns 401 Unauthorized Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "401", "Unauthorized", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L123-L126
18,634
nicklaw5/larapi
src/Larapi.php
Larapi.forbidden
public function forbidden($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_FORBIDDEN, $headers); }
php
public function forbidden($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_FORBIDDEN, $headers); }
[ "public", "function", "forbidden", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_FORBIDDEN", ",", "$", "headers", ")", ";", "}" ]
Returns 403 Forbidden Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "403", "Forbidden", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L136-L139
18,635
nicklaw5/larapi
src/Larapi.php
Larapi.notFound
public function notFound($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_NOT_FOUND, $headers); }
php
public function notFound($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_NOT_FOUND, $headers); }
[ "public", "function", "notFound", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_NOT_FOUND", ",", "$", "headers", ")", ";", "}" ]
Returns 404 Not Found HTTP Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "404", "Not", "Found", "HTTP", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L149-L152
18,636
nicklaw5/larapi
src/Larapi.php
Larapi.methodNotAllowed
public function methodNotAllowed($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_METHOD_NOT_ALLOWED, $headers); }
php
public function methodNotAllowed($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_METHOD_NOT_ALLOWED, $headers); }
[ "public", "function", "methodNotAllowed", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_METHOD_NOT_ALLOWED", ",", "$", "headers", ")", ";", "}" ]
Returns 405 Method Not Allowed Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "405", "Method", "Not", "Allowed", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L162-L165
18,637
nicklaw5/larapi
src/Larapi.php
Larapi.conflict
public function conflict($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_CONFLICT, $headers); }
php
public function conflict($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_CONFLICT, $headers); }
[ "public", "function", "conflict", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_CONFLICT", ",", "$", "headers", ")", ";", "}" ]
Returns 409 Conflict Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "409", "Conflict", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L175-L178
18,638
nicklaw5/larapi
src/Larapi.php
Larapi.unprocessableEntity
public function unprocessableEntity($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_UNPROCESSABLE_ENTITY, $headers); }
php
public function unprocessableEntity($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_UNPROCESSABLE_ENTITY, $headers); }
[ "public", "function", "unprocessableEntity", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_UNPROCESSABLE_ENTITY", ",", "$", "headers", ")", ";", "}" ]
Returns 422 Unprocessable Entity @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "422", "Unprocessable", "Entity" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L188-L191
18,639
nicklaw5/larapi
src/Larapi.php
Larapi.internalError
public function internalError($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_INTERNAL_SERVER_ERROR, $headers); }
php
public function internalError($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_INTERNAL_SERVER_ERROR, $headers); }
[ "public", "function", "internalError", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_INTERNAL_SERVER_ERROR", ",", "$", "headers", ")", ";", "}" ]
Returns 500 Internal Server HTTP Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "500", "Internal", "Server", "HTTP", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L201-L204
18,640
nicklaw5/larapi
src/Larapi.php
Larapi.notImplemented
public function notImplemented($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_NOT_IMPLEMENTED, $headers); }
php
public function notImplemented($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_NOT_IMPLEMENTED, $headers); }
[ "public", "function", "notImplemented", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_NOT_IMPLEMENTED", ",", "$", "headers", ")", ";", "}" ]
Returns 501 Not Implemented HTTP Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "501", "Not", "Implemented", "HTTP", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L214-L217
18,641
nicklaw5/larapi
src/Larapi.php
Larapi.notAvailable
public function notAvailable($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_SERVICE_UNAVAILABLE, $headers); }
php
public function notAvailable($msg = '', $errorCode = null, $headers = []) { return $this->getErrorResponse($msg, $errorCode, self::HTTP_SERVICE_UNAVAILABLE, $headers); }
[ "public", "function", "notAvailable", "(", "$", "msg", "=", "''", ",", "$", "errorCode", "=", "null", ",", "$", "headers", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getErrorResponse", "(", "$", "msg", ",", "$", "errorCode", ",", "self", "::", "HTTP_SERVICE_UNAVAILABLE", ",", "$", "headers", ")", ";", "}" ]
Returns 503 Not Available HTTP Response @param string $msg @param int $errorCode @param array $headers @return json
[ "Returns", "503", "Not", "Available", "HTTP", "Response" ]
fb3493118bb9c6ce01567230c09e8402ac148d0e
https://github.com/nicklaw5/larapi/blob/fb3493118bb9c6ce01567230c09e8402ac148d0e/src/Larapi.php#L227-L230
18,642
fyuze/framework
src/Fyuze/Kernel/Services/Debug.php
Debug.bootstrap
public function bootstrap() { $this->registry->make('toolbar') ->addCollector(new Response($this->registry->make('response')), true); }
php
public function bootstrap() { $this->registry->make('toolbar') ->addCollector(new Response($this->registry->make('response')), true); }
[ "public", "function", "bootstrap", "(", ")", "{", "$", "this", "->", "registry", "->", "make", "(", "'toolbar'", ")", "->", "addCollector", "(", "new", "Response", "(", "$", "this", "->", "registry", "->", "make", "(", "'response'", ")", ")", ",", "true", ")", ";", "}" ]
Once the has started
[ "Once", "the", "has", "started" ]
89b3984f7225e24bfcdafb090ee197275b3222c9
https://github.com/fyuze/framework/blob/89b3984f7225e24bfcdafb090ee197275b3222c9/src/Fyuze/Kernel/Services/Debug.php#L16-L20
18,643
titon/db
src/Titon/Db/Repository.php
Repository.addBehavior
public function addBehavior(Behavior $behavior) { $behavior->setRepository($this); $this->_behaviors[$behavior->getAlias()] = $behavior; $this->attachObject($behavior->getAlias(), $behavior); if ($behavior instanceof Listener) { $this->on('db', $behavior); } return $this; }
php
public function addBehavior(Behavior $behavior) { $behavior->setRepository($this); $this->_behaviors[$behavior->getAlias()] = $behavior; $this->attachObject($behavior->getAlias(), $behavior); if ($behavior instanceof Listener) { $this->on('db', $behavior); } return $this; }
[ "public", "function", "addBehavior", "(", "Behavior", "$", "behavior", ")", "{", "$", "behavior", "->", "setRepository", "(", "$", "this", ")", ";", "$", "this", "->", "_behaviors", "[", "$", "behavior", "->", "getAlias", "(", ")", "]", "=", "$", "behavior", ";", "$", "this", "->", "attachObject", "(", "$", "behavior", "->", "getAlias", "(", ")", ",", "$", "behavior", ")", ";", "if", "(", "$", "behavior", "instanceof", "Listener", ")", "{", "$", "this", "->", "on", "(", "'db'", ",", "$", "behavior", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a behavior. @param \Titon\Db\Behavior $behavior @return $this
[ "Add", "a", "behavior", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L142-L154
18,644
titon/db
src/Titon/Db/Repository.php
Repository.aggregate
public function aggregate(Query $query, $function, $field) { $query->fields( Query::func(strtoupper($function), [$field => Func::FIELD])->asAlias('aggregate') ); $results = $this->getDriver() ->setContext('read') ->executeQuery($query) ->find(); if (isset($results[0])) { return (int) $results[0]['aggregate']; } return 0; }
php
public function aggregate(Query $query, $function, $field) { $query->fields( Query::func(strtoupper($function), [$field => Func::FIELD])->asAlias('aggregate') ); $results = $this->getDriver() ->setContext('read') ->executeQuery($query) ->find(); if (isset($results[0])) { return (int) $results[0]['aggregate']; } return 0; }
[ "public", "function", "aggregate", "(", "Query", "$", "query", ",", "$", "function", ",", "$", "field", ")", "{", "$", "query", "->", "fields", "(", "Query", "::", "func", "(", "strtoupper", "(", "$", "function", ")", ",", "[", "$", "field", "=>", "Func", "::", "FIELD", "]", ")", "->", "asAlias", "(", "'aggregate'", ")", ")", ";", "$", "results", "=", "$", "this", "->", "getDriver", "(", ")", "->", "setContext", "(", "'read'", ")", "->", "executeQuery", "(", "$", "query", ")", "->", "find", "(", ")", ";", "if", "(", "isset", "(", "$", "results", "[", "0", "]", ")", ")", "{", "return", "(", "int", ")", "$", "results", "[", "0", "]", "[", "'aggregate'", "]", ";", "}", "return", "0", ";", "}" ]
Perform an aggregation on the database and return the calculated value. The currently supported aggregates are `avg`, `count`, `min`, `max`, and `sum`. @param \Titon\Db\Query $query @param string $function @param string $field @return int
[ "Perform", "an", "aggregation", "on", "the", "database", "and", "return", "the", "calculated", "value", ".", "The", "currently", "supported", "aggregates", "are", "avg", "count", "min", "max", "and", "sum", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L178-L193
18,645
titon/db
src/Titon/Db/Repository.php
Repository.castResults
public function castResults(Event $event, array &$results, $finder) { $columns = $this->getSchema()->getColumns(); $driver = $this->getDriver(); $entityClass = $this->getEntity(); foreach ($results as $i => $result) { foreach ($result as $field => $value) { if (isset($columns[$field])) { $result[$field] = $driver->getType($columns[$field]['type'])->from($value); } if (!is_array($value)) { continue; } $result[$field] = new Entity($value); } $results[$i] = new $entityClass($result); } }
php
public function castResults(Event $event, array &$results, $finder) { $columns = $this->getSchema()->getColumns(); $driver = $this->getDriver(); $entityClass = $this->getEntity(); foreach ($results as $i => $result) { foreach ($result as $field => $value) { if (isset($columns[$field])) { $result[$field] = $driver->getType($columns[$field]['type'])->from($value); } if (!is_array($value)) { continue; } $result[$field] = new Entity($value); } $results[$i] = new $entityClass($result); } }
[ "public", "function", "castResults", "(", "Event", "$", "event", ",", "array", "&", "$", "results", ",", "$", "finder", ")", "{", "$", "columns", "=", "$", "this", "->", "getSchema", "(", ")", "->", "getColumns", "(", ")", ";", "$", "driver", "=", "$", "this", "->", "getDriver", "(", ")", ";", "$", "entityClass", "=", "$", "this", "->", "getEntity", "(", ")", ";", "foreach", "(", "$", "results", "as", "$", "i", "=>", "$", "result", ")", "{", "foreach", "(", "$", "result", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "columns", "[", "$", "field", "]", ")", ")", "{", "$", "result", "[", "$", "field", "]", "=", "$", "driver", "->", "getType", "(", "$", "columns", "[", "$", "field", "]", "[", "'type'", "]", ")", "->", "from", "(", "$", "value", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "continue", ";", "}", "$", "result", "[", "$", "field", "]", "=", "new", "Entity", "(", "$", "value", ")", ";", "}", "$", "results", "[", "$", "i", "]", "=", "new", "$", "entityClass", "(", "$", "result", ")", ";", "}", "}" ]
Type cast the results and wrap each result in an entity after a find operation. @param \Titon\Event\Event $event @param array $results @param string $finder
[ "Type", "cast", "the", "results", "and", "wrap", "each", "result", "in", "an", "entity", "after", "a", "find", "operation", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L202-L222
18,646
titon/db
src/Titon/Db/Repository.php
Repository.create
public function create($data, array $options = []) { return $this->query(Query::INSERT)->save($data, $options); }
php
public function create($data, array $options = []) { return $this->query(Query::INSERT)->save($data, $options); }
[ "public", "function", "create", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "query", "(", "Query", "::", "INSERT", ")", "->", "save", "(", "$", "data", ",", "$", "options", ")", ";", "}" ]
Insert data into the database as a new record. If any related data exists, insert new records after joining them to the original record. Validate schema data and related data structure before inserting. @param array|\Titon\Type\Contract\Arrayable $data @param array $options @return int The record ID on success, 0 on failure
[ "Insert", "data", "into", "the", "database", "as", "a", "new", "record", ".", "If", "any", "related", "data", "exists", "insert", "new", "records", "after", "joining", "them", "to", "the", "original", "record", ".", "Validate", "schema", "data", "and", "related", "data", "structure", "before", "inserting", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L233-L235
18,647
titon/db
src/Titon/Db/Repository.php
Repository.createMany
public function createMany(array $data, $allowPk = false, array $options = []) { $pk = $this->getPrimaryKey(); $columns = $this->getSchema()->getColumns(); $records = []; $defaults = []; if ($columns) { foreach ($columns as $key => $column) { $defaults[$key] = array_key_exists('default', $column) ? $column['default'] : ''; } unset($defaults[$pk]); } foreach ($data as $record) { // Convert from an entity if ($record instanceof Arrayable) { $record = $record->toArray(); } // Merge in defaults $record = Hash::merge($defaults, $record); // Remove primary key if (!$allowPk) { unset($record[$pk]); } // Filter out invalid columns if ($columns) { $record = array_intersect_key($record, $columns); } $records[] = $record; } return $this->query(Query::MULTI_INSERT)->save($records, $options); }
php
public function createMany(array $data, $allowPk = false, array $options = []) { $pk = $this->getPrimaryKey(); $columns = $this->getSchema()->getColumns(); $records = []; $defaults = []; if ($columns) { foreach ($columns as $key => $column) { $defaults[$key] = array_key_exists('default', $column) ? $column['default'] : ''; } unset($defaults[$pk]); } foreach ($data as $record) { // Convert from an entity if ($record instanceof Arrayable) { $record = $record->toArray(); } // Merge in defaults $record = Hash::merge($defaults, $record); // Remove primary key if (!$allowPk) { unset($record[$pk]); } // Filter out invalid columns if ($columns) { $record = array_intersect_key($record, $columns); } $records[] = $record; } return $this->query(Query::MULTI_INSERT)->save($records, $options); }
[ "public", "function", "createMany", "(", "array", "$", "data", ",", "$", "allowPk", "=", "false", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "pk", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "$", "columns", "=", "$", "this", "->", "getSchema", "(", ")", "->", "getColumns", "(", ")", ";", "$", "records", "=", "[", "]", ";", "$", "defaults", "=", "[", "]", ";", "if", "(", "$", "columns", ")", "{", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", "column", ")", "{", "$", "defaults", "[", "$", "key", "]", "=", "array_key_exists", "(", "'default'", ",", "$", "column", ")", "?", "$", "column", "[", "'default'", "]", ":", "''", ";", "}", "unset", "(", "$", "defaults", "[", "$", "pk", "]", ")", ";", "}", "foreach", "(", "$", "data", "as", "$", "record", ")", "{", "// Convert from an entity", "if", "(", "$", "record", "instanceof", "Arrayable", ")", "{", "$", "record", "=", "$", "record", "->", "toArray", "(", ")", ";", "}", "// Merge in defaults", "$", "record", "=", "Hash", "::", "merge", "(", "$", "defaults", ",", "$", "record", ")", ";", "// Remove primary key", "if", "(", "!", "$", "allowPk", ")", "{", "unset", "(", "$", "record", "[", "$", "pk", "]", ")", ";", "}", "// Filter out invalid columns", "if", "(", "$", "columns", ")", "{", "$", "record", "=", "array_intersect_key", "(", "$", "record", ",", "$", "columns", ")", ";", "}", "$", "records", "[", "]", "=", "$", "record", ";", "}", "return", "$", "this", "->", "query", "(", "Query", "::", "MULTI_INSERT", ")", "->", "save", "(", "$", "records", ",", "$", "options", ")", ";", "}" ]
Insert multiple records into the database using a single query. Missing fields will be added with an empty value or the schema default value. Does not support callbacks or transactions. @uses Titon\Utility\Hash @param array $data Multi-dimensional array of records @param bool $allowPk If true will allow primary key fields, else will remove them @param array $options @return int The count of records inserted
[ "Insert", "multiple", "records", "into", "the", "database", "using", "a", "single", "query", ".", "Missing", "fields", "will", "be", "added", "with", "an", "empty", "value", "or", "the", "schema", "default", "value", ".", "Does", "not", "support", "callbacks", "or", "transactions", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L249-L287
18,648
titon/db
src/Titon/Db/Repository.php
Repository.createTable
public function createTable(array $options = [], array $attributes = []) { $schema = $this->getSchema(); $schema->addOptions($options); // Create the table $status = (bool) $this->query(Query::CREATE_TABLE) ->attribute($attributes) ->schema($schema) ->save(); // Create the indexes if ($status) { foreach ($schema->getIndexes() as $index => $columns) { $this->query(Query::CREATE_INDEX) ->from($schema->getTable(), $index) ->save($columns); } } return $status; }
php
public function createTable(array $options = [], array $attributes = []) { $schema = $this->getSchema(); $schema->addOptions($options); // Create the table $status = (bool) $this->query(Query::CREATE_TABLE) ->attribute($attributes) ->schema($schema) ->save(); // Create the indexes if ($status) { foreach ($schema->getIndexes() as $index => $columns) { $this->query(Query::CREATE_INDEX) ->from($schema->getTable(), $index) ->save($columns); } } return $status; }
[ "public", "function", "createTable", "(", "array", "$", "options", "=", "[", "]", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "schema", "=", "$", "this", "->", "getSchema", "(", ")", ";", "$", "schema", "->", "addOptions", "(", "$", "options", ")", ";", "// Create the table", "$", "status", "=", "(", "bool", ")", "$", "this", "->", "query", "(", "Query", "::", "CREATE_TABLE", ")", "->", "attribute", "(", "$", "attributes", ")", "->", "schema", "(", "$", "schema", ")", "->", "save", "(", ")", ";", "// Create the indexes", "if", "(", "$", "status", ")", "{", "foreach", "(", "$", "schema", "->", "getIndexes", "(", ")", "as", "$", "index", "=>", "$", "columns", ")", "{", "$", "this", "->", "query", "(", "Query", "::", "CREATE_INDEX", ")", "->", "from", "(", "$", "schema", "->", "getTable", "(", ")", ",", "$", "index", ")", "->", "save", "(", "$", "columns", ")", ";", "}", "}", "return", "$", "status", ";", "}" ]
Create a database table and indexes based off the tables schema. The schema must be an array of column data. @param array $options @param array $attributes @return bool
[ "Create", "a", "database", "table", "and", "indexes", "based", "off", "the", "tables", "schema", ".", "The", "schema", "must", "be", "an", "array", "of", "column", "data", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L297-L317
18,649
titon/db
src/Titon/Db/Repository.php
Repository.delete
public function delete($id, array $options = []) { return $this->query(Query::DELETE) ->where($this->getPrimaryKey(), $id) ->save([], $options); }
php
public function delete($id, array $options = []) { return $this->query(Query::DELETE) ->where($this->getPrimaryKey(), $id) ->save([], $options); }
[ "public", "function", "delete", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "query", "(", "Query", "::", "DELETE", ")", "->", "where", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ",", "$", "id", ")", "->", "save", "(", "[", "]", ",", "$", "options", ")", ";", "}" ]
Delete a record by ID. @param int|int[] $id @param array $options @return int The count of records deleted
[ "Delete", "a", "record", "by", "ID", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L353-L357
18,650
titon/db
src/Titon/Db/Repository.php
Repository.deleteMany
public function deleteMany(Closure $conditions, array $options = []) { $query = $this->query(Query::DELETE)->bindCallback($conditions); // Validate that this won't delete all records $where = $query->getWhere()->getParams(); if (empty($where)) { throw new InvalidQueryException('No where clause detected, will not delete all records'); } return $query->save([], $options); }
php
public function deleteMany(Closure $conditions, array $options = []) { $query = $this->query(Query::DELETE)->bindCallback($conditions); // Validate that this won't delete all records $where = $query->getWhere()->getParams(); if (empty($where)) { throw new InvalidQueryException('No where clause detected, will not delete all records'); } return $query->save([], $options); }
[ "public", "function", "deleteMany", "(", "Closure", "$", "conditions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "query", "=", "$", "this", "->", "query", "(", "Query", "::", "DELETE", ")", "->", "bindCallback", "(", "$", "conditions", ")", ";", "// Validate that this won't delete all records", "$", "where", "=", "$", "query", "->", "getWhere", "(", ")", "->", "getParams", "(", ")", ";", "if", "(", "empty", "(", "$", "where", ")", ")", "{", "throw", "new", "InvalidQueryException", "(", "'No where clause detected, will not delete all records'", ")", ";", "}", "return", "$", "query", "->", "save", "(", "[", "]", ",", "$", "options", ")", ";", "}" ]
Delete multiple records with conditions. @param \Closure $conditions @param array $options @return int The count of records deleted @throws \Titon\Db\Exception\InvalidQueryException
[ "Delete", "multiple", "records", "with", "conditions", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L367-L378
18,651
titon/db
src/Titon/Db/Repository.php
Repository.exists
public function exists($id) { return (bool) $this->select()->where($this->getPrimaryKey(), $id)->count(); }
php
public function exists($id) { return (bool) $this->select()->where($this->getPrimaryKey(), $id)->count(); }
[ "public", "function", "exists", "(", "$", "id", ")", "{", "return", "(", "bool", ")", "$", "this", "->", "select", "(", ")", "->", "where", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ",", "$", "id", ")", "->", "count", "(", ")", ";", "}" ]
Check if a record with an ID exists. @param int $id @return bool
[ "Check", "if", "a", "record", "with", "an", "ID", "exists", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L395-L397
18,652
titon/db
src/Titon/Db/Repository.php
Repository.filterData
public function filterData(Event $event, Query $query, $id, array &$data) { if ($columns = $this->getSchema()->getColumns()) { $data = array_intersect_key($data, $columns); } return true; }
php
public function filterData(Event $event, Query $query, $id, array &$data) { if ($columns = $this->getSchema()->getColumns()) { $data = array_intersect_key($data, $columns); } return true; }
[ "public", "function", "filterData", "(", "Event", "$", "event", ",", "Query", "$", "query", ",", "$", "id", ",", "array", "&", "$", "data", ")", "{", "if", "(", "$", "columns", "=", "$", "this", "->", "getSchema", "(", ")", "->", "getColumns", "(", ")", ")", "{", "$", "data", "=", "array_intersect_key", "(", "$", "data", ",", "$", "columns", ")", ";", "}", "return", "true", ";", "}" ]
Filter out invalid columns before a save operation. @param \Titon\Event\Event $event @param \Titon\Db\Query $query @param int|int[] $id @param array $data @return bool
[ "Filter", "out", "invalid", "columns", "before", "a", "save", "operation", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L408-L414
18,653
titon/db
src/Titon/Db/Repository.php
Repository.find
public function find(Query $query, $type, array $options = []) { $options = $options + [ 'before' => true, 'after' => true, 'collection' => $this->getConfig('collection') ]; $finder = $this->getFinder($type); $state = null; if ($options['before']) { $event = $this->emit('db.preFind', [$query, $type]); $state = $event->getState(); if (!$state) { return $finder->noResults($options); } } // Use the event response as the results if (is_array($state)) { $results = $state; // Query the driver for results } else { $finder->before($query, $options); // Update the connection context $results = $this->getDriver() ->setContext('read') ->executeQuery($query) ->find(); } if (!$results) { return $finder->noResults($options); } if ($options['after']) { $this->emit('db.postFind', [&$results, $type]); } return $finder->after($results, $options); }
php
public function find(Query $query, $type, array $options = []) { $options = $options + [ 'before' => true, 'after' => true, 'collection' => $this->getConfig('collection') ]; $finder = $this->getFinder($type); $state = null; if ($options['before']) { $event = $this->emit('db.preFind', [$query, $type]); $state = $event->getState(); if (!$state) { return $finder->noResults($options); } } // Use the event response as the results if (is_array($state)) { $results = $state; // Query the driver for results } else { $finder->before($query, $options); // Update the connection context $results = $this->getDriver() ->setContext('read') ->executeQuery($query) ->find(); } if (!$results) { return $finder->noResults($options); } if ($options['after']) { $this->emit('db.postFind', [&$results, $type]); } return $finder->after($results, $options); }
[ "public", "function", "find", "(", "Query", "$", "query", ",", "$", "type", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "options", "+", "[", "'before'", "=>", "true", ",", "'after'", "=>", "true", ",", "'collection'", "=>", "$", "this", "->", "getConfig", "(", "'collection'", ")", "]", ";", "$", "finder", "=", "$", "this", "->", "getFinder", "(", "$", "type", ")", ";", "$", "state", "=", "null", ";", "if", "(", "$", "options", "[", "'before'", "]", ")", "{", "$", "event", "=", "$", "this", "->", "emit", "(", "'db.preFind'", ",", "[", "$", "query", ",", "$", "type", "]", ")", ";", "$", "state", "=", "$", "event", "->", "getState", "(", ")", ";", "if", "(", "!", "$", "state", ")", "{", "return", "$", "finder", "->", "noResults", "(", "$", "options", ")", ";", "}", "}", "// Use the event response as the results", "if", "(", "is_array", "(", "$", "state", ")", ")", "{", "$", "results", "=", "$", "state", ";", "// Query the driver for results", "}", "else", "{", "$", "finder", "->", "before", "(", "$", "query", ",", "$", "options", ")", ";", "// Update the connection context", "$", "results", "=", "$", "this", "->", "getDriver", "(", ")", "->", "setContext", "(", "'read'", ")", "->", "executeQuery", "(", "$", "query", ")", "->", "find", "(", ")", ";", "}", "if", "(", "!", "$", "results", ")", "{", "return", "$", "finder", "->", "noResults", "(", "$", "options", ")", ";", "}", "if", "(", "$", "options", "[", "'after'", "]", ")", "{", "$", "this", "->", "emit", "(", "'db.postFind'", ",", "[", "&", "$", "results", ",", "$", "type", "]", ")", ";", "}", "return", "$", "finder", "->", "after", "(", "$", "results", ",", "$", "options", ")", ";", "}" ]
All-in-one method for fetching results from a query. Depending on the type of finder, the returned results will differ. Before a fetch is executed, a `preFind` event will be triggered. If this event returns a falsey value, the find will exit and return a `noResults` value based on the current finder. If this event returns an array of data, the find will exit and return the array as the results instead of querying the driver. Before executing against the driver, the finders `before` method will be called allowing the current query to be modified. The driver connection context will also be set to `read`. If no results are returned from the driver, the finders `noResults` method will be called. After a fetch is executed (or a `preFind` event returns data), a `postFind` event will be triggered. This event allows the results to be modified via references. Finally, before the results are returned, wrap each row in an entity object and pass it through the finders `after` method. @param \Titon\Db\Query $query @param string $type @param mixed $options { @type bool $before Will trigger before callbacks @type bool $after Will trigger after callbacks } @return array|\Titon\Db\Entity|\Titon\Db\EntityCollection
[ "All", "-", "in", "-", "one", "method", "for", "fetching", "results", "from", "a", "query", ".", "Depending", "on", "the", "type", "of", "finder", "the", "returned", "results", "will", "differ", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L447-L490
18,654
titon/db
src/Titon/Db/Repository.php
Repository.findID
public function findID(Query $query) { $pk = $this->getPrimaryKey(); // Gather ID from where clause foreach ($query->getWhere()->getParams() as $param) { if ($param instanceof Expr && $param->getField() === $pk && in_array($param->getOperator(), ['=', 'in'])) { return $param->getValue(); } } // Query for the ID then $select = clone $query; $results = array_values($select->setType(Query::SELECT)->fields($pk)->lists($pk, $pk, [ 'before' => false, 'after' => false ])); if (count($results) > 1) { return $results; } else if (count($results) === 1) { return $results[0]; } return null; }
php
public function findID(Query $query) { $pk = $this->getPrimaryKey(); // Gather ID from where clause foreach ($query->getWhere()->getParams() as $param) { if ($param instanceof Expr && $param->getField() === $pk && in_array($param->getOperator(), ['=', 'in'])) { return $param->getValue(); } } // Query for the ID then $select = clone $query; $results = array_values($select->setType(Query::SELECT)->fields($pk)->lists($pk, $pk, [ 'before' => false, 'after' => false ])); if (count($results) > 1) { return $results; } else if (count($results) === 1) { return $results[0]; } return null; }
[ "public", "function", "findID", "(", "Query", "$", "query", ")", "{", "$", "pk", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "// Gather ID from where clause", "foreach", "(", "$", "query", "->", "getWhere", "(", ")", "->", "getParams", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "param", "instanceof", "Expr", "&&", "$", "param", "->", "getField", "(", ")", "===", "$", "pk", "&&", "in_array", "(", "$", "param", "->", "getOperator", "(", ")", ",", "[", "'='", ",", "'in'", "]", ")", ")", "{", "return", "$", "param", "->", "getValue", "(", ")", ";", "}", "}", "// Query for the ID then", "$", "select", "=", "clone", "$", "query", ";", "$", "results", "=", "array_values", "(", "$", "select", "->", "setType", "(", "Query", "::", "SELECT", ")", "->", "fields", "(", "$", "pk", ")", "->", "lists", "(", "$", "pk", ",", "$", "pk", ",", "[", "'before'", "=>", "false", ",", "'after'", "=>", "false", "]", ")", ")", ";", "if", "(", "count", "(", "$", "results", ")", ">", "1", ")", "{", "return", "$", "results", ";", "}", "else", "if", "(", "count", "(", "$", "results", ")", "===", "1", ")", "{", "return", "$", "results", "[", "0", "]", ";", "}", "return", "null", ";", "}" ]
Find the a primary key value within a query. Begin by looping through the where clause and match any value that equates to the PK field. If none can be found, do a select query for a list of IDs. @param \Titon\Db\Query $query @return int|int[]
[ "Find", "the", "a", "primary", "key", "value", "within", "a", "query", ".", "Begin", "by", "looping", "through", "the", "where", "clause", "and", "match", "any", "value", "that", "equates", "to", "the", "PK", "field", ".", "If", "none", "can", "be", "found", "do", "a", "select", "query", "for", "a", "list", "of", "IDs", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L499-L524
18,655
titon/db
src/Titon/Db/Repository.php
Repository.getBehavior
public function getBehavior($alias) { if ($this->hasBehavior($alias)) { return $this->_behaviors[$alias]; } throw new MissingBehaviorException(sprintf('Behavior %s does not exist', $alias)); }
php
public function getBehavior($alias) { if ($this->hasBehavior($alias)) { return $this->_behaviors[$alias]; } throw new MissingBehaviorException(sprintf('Behavior %s does not exist', $alias)); }
[ "public", "function", "getBehavior", "(", "$", "alias", ")", "{", "if", "(", "$", "this", "->", "hasBehavior", "(", "$", "alias", ")", ")", "{", "return", "$", "this", "->", "_behaviors", "[", "$", "alias", "]", ";", "}", "throw", "new", "MissingBehaviorException", "(", "sprintf", "(", "'Behavior %s does not exist'", ",", "$", "alias", ")", ")", ";", "}" ]
Return a behavior by alias. @param string $alias @return \Titon\Db\Behavior @throws \Titon\Db\Exception\MissingBehaviorException
[ "Return", "a", "behavior", "by", "alias", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L542-L548
18,656
titon/db
src/Titon/Db/Repository.php
Repository.getDisplayField
public function getDisplayField() { return $this->cache(__METHOD__, function() { $fields = $this->getConfig('displayField'); $schema = $this->getSchema(); foreach ((array) $fields as $field) { if ($schema->hasColumn($field)) { return $field; } } return $this->getPrimaryKey(); }); }
php
public function getDisplayField() { return $this->cache(__METHOD__, function() { $fields = $this->getConfig('displayField'); $schema = $this->getSchema(); foreach ((array) $fields as $field) { if ($schema->hasColumn($field)) { return $field; } } return $this->getPrimaryKey(); }); }
[ "public", "function", "getDisplayField", "(", ")", "{", "return", "$", "this", "->", "cache", "(", "__METHOD__", ",", "function", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "getConfig", "(", "'displayField'", ")", ";", "$", "schema", "=", "$", "this", "->", "getSchema", "(", ")", ";", "foreach", "(", "(", "array", ")", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "$", "schema", "->", "hasColumn", "(", "$", "field", ")", ")", "{", "return", "$", "field", ";", "}", "}", "return", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "}", ")", ";", "}" ]
Return the field used as the display field. @return string
[ "Return", "the", "field", "used", "as", "the", "display", "field", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L587-L600
18,657
titon/db
src/Titon/Db/Repository.php
Repository.getDriver
public function getDriver() { if ($this->_driver) { return $this->_driver; } return $this->_driver = $this->getDatabase()->getDriver($this->getConnectionKey()); }
php
public function getDriver() { if ($this->_driver) { return $this->_driver; } return $this->_driver = $this->getDatabase()->getDriver($this->getConnectionKey()); }
[ "public", "function", "getDriver", "(", ")", "{", "if", "(", "$", "this", "->", "_driver", ")", "{", "return", "$", "this", "->", "_driver", ";", "}", "return", "$", "this", "->", "_driver", "=", "$", "this", "->", "getDatabase", "(", ")", "->", "getDriver", "(", "$", "this", "->", "getConnectionKey", "(", ")", ")", ";", "}" ]
Return the driver defined by key. @uses Titon\Common\Registry @return \Titon\Db\Driver
[ "Return", "the", "driver", "defined", "by", "key", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L609-L615
18,658
titon/db
src/Titon/Db/Repository.php
Repository.getFinder
public function getFinder($key) { if (isset($this->_finders[$key])) { return $this->_finders[$key]; } throw new MissingFinderException(sprintf('Finder %s does not exist', $key)); }
php
public function getFinder($key) { if (isset($this->_finders[$key])) { return $this->_finders[$key]; } throw new MissingFinderException(sprintf('Finder %s does not exist', $key)); }
[ "public", "function", "getFinder", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_finders", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_finders", "[", "$", "key", "]", ";", "}", "throw", "new", "MissingFinderException", "(", "sprintf", "(", "'Finder %s does not exist'", ",", "$", "key", ")", ")", ";", "}" ]
Return a finder by name. @param string $key @return \Titon\Db\Finder @throws \Titon\Db\Exception\MissingFinderException
[ "Return", "a", "finder", "by", "name", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L633-L639
18,659
titon/db
src/Titon/Db/Repository.php
Repository.getPrimaryKey
public function getPrimaryKey() { return $this->cache(__METHOD__, function() { $pk = $this->getConfig('primaryKey'); $schema = $this->getSchema(); if ($schema->hasColumn($pk)) { return $pk; } if ($pk = $schema->getPrimaryKey()) { return $pk['columns'][0]; } return 'id'; }); }
php
public function getPrimaryKey() { return $this->cache(__METHOD__, function() { $pk = $this->getConfig('primaryKey'); $schema = $this->getSchema(); if ($schema->hasColumn($pk)) { return $pk; } if ($pk = $schema->getPrimaryKey()) { return $pk['columns'][0]; } return 'id'; }); }
[ "public", "function", "getPrimaryKey", "(", ")", "{", "return", "$", "this", "->", "cache", "(", "__METHOD__", ",", "function", "(", ")", "{", "$", "pk", "=", "$", "this", "->", "getConfig", "(", "'primaryKey'", ")", ";", "$", "schema", "=", "$", "this", "->", "getSchema", "(", ")", ";", "if", "(", "$", "schema", "->", "hasColumn", "(", "$", "pk", ")", ")", "{", "return", "$", "pk", ";", "}", "if", "(", "$", "pk", "=", "$", "schema", "->", "getPrimaryKey", "(", ")", ")", "{", "return", "$", "pk", "[", "'columns'", "]", "[", "0", "]", ";", "}", "return", "'id'", ";", "}", ")", ";", "}" ]
Return the field used as the primary, usually the ID. @return string
[ "Return", "the", "field", "used", "as", "the", "primary", "usually", "the", "ID", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L655-L670
18,660
titon/db
src/Titon/Db/Repository.php
Repository.getSchema
public function getSchema() { if ($this->_schema instanceof Schema) { return $this->_schema; // Manually defined columns // Allows for full schema and key/index support } else if ($this->_schema && is_array($this->_schema)) { $columns = $this->_schema; // Inspect database for columns // This approach should only be used for validating columns and types } else { $columns = $this->getDriver()->describeTable($this->getTable()); } $this->setSchema(new Schema($this->getTable(), $columns)); return $this->_schema; }
php
public function getSchema() { if ($this->_schema instanceof Schema) { return $this->_schema; // Manually defined columns // Allows for full schema and key/index support } else if ($this->_schema && is_array($this->_schema)) { $columns = $this->_schema; // Inspect database for columns // This approach should only be used for validating columns and types } else { $columns = $this->getDriver()->describeTable($this->getTable()); } $this->setSchema(new Schema($this->getTable(), $columns)); return $this->_schema; }
[ "public", "function", "getSchema", "(", ")", "{", "if", "(", "$", "this", "->", "_schema", "instanceof", "Schema", ")", "{", "return", "$", "this", "->", "_schema", ";", "// Manually defined columns", "// Allows for full schema and key/index support", "}", "else", "if", "(", "$", "this", "->", "_schema", "&&", "is_array", "(", "$", "this", "->", "_schema", ")", ")", "{", "$", "columns", "=", "$", "this", "->", "_schema", ";", "// Inspect database for columns", "// This approach should only be used for validating columns and types", "}", "else", "{", "$", "columns", "=", "$", "this", "->", "getDriver", "(", ")", "->", "describeTable", "(", "$", "this", "->", "getTable", "(", ")", ")", ";", "}", "$", "this", "->", "setSchema", "(", "new", "Schema", "(", "$", "this", "->", "getTable", "(", ")", ",", "$", "columns", ")", ")", ";", "return", "$", "this", "->", "_schema", ";", "}" ]
Return a schema object that represents the database table. @return \Titon\Db\Driver\Schema
[ "Return", "a", "schema", "object", "that", "represents", "the", "database", "table", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L677-L695
18,661
titon/db
src/Titon/Db/Repository.php
Repository.query
public function query($type) { $query = $this->getDriver()->newQuery($type); $query->setRepository($this); $query->from($this->getTable(), $this->getAlias()); return $query; }
php
public function query($type) { $query = $this->getDriver()->newQuery($type); $query->setRepository($this); $query->from($this->getTable(), $this->getAlias()); return $query; }
[ "public", "function", "query", "(", "$", "type", ")", "{", "$", "query", "=", "$", "this", "->", "getDriver", "(", ")", "->", "newQuery", "(", "$", "type", ")", ";", "$", "query", "->", "setRepository", "(", "$", "this", ")", ";", "$", "query", "->", "from", "(", "$", "this", "->", "getTable", "(", ")", ",", "$", "this", "->", "getAlias", "(", ")", ")", ";", "return", "$", "query", ";", "}" ]
Instantiate a new query builder. @param string $type @return \Titon\Db\Query
[ "Instantiate", "a", "new", "query", "builder", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L786-L792
18,662
titon/db
src/Titon/Db/Repository.php
Repository.read
public function read($id, array $options = [], Closure $callback = null) { return $this->select() ->where($this->getPrimaryKey(), $id) ->bindCallback($callback) ->first($options); }
php
public function read($id, array $options = [], Closure $callback = null) { return $this->select() ->where($this->getPrimaryKey(), $id) ->bindCallback($callback) ->first($options); }
[ "public", "function", "read", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ",", "Closure", "$", "callback", "=", "null", ")", "{", "return", "$", "this", "->", "select", "(", ")", "->", "where", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ",", "$", "id", ")", "->", "bindCallback", "(", "$", "callback", ")", "->", "first", "(", "$", "options", ")", ";", "}" ]
Fetch a single record by ID. @param int $id @param array $options @param \Closure $callback @return \Titon\Db\Entity|array
[ "Fetch", "a", "single", "record", "by", "ID", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L802-L807
18,663
titon/db
src/Titon/Db/Repository.php
Repository.save
public function save(Query $query, array $options = []) { $type = $query->getType(); if ($type === Query::DELETE) { return $this->_processDelete($query, $options); } else if ($type === Query::INSERT) { return $this->_processCreate($query, $options); } else if ($type === Query::UPDATE) { return $this->_processUpdate($query, $options); } // No processing or events, just execute it directly return $this->getDriver()->executeQuery($query)->save(); }
php
public function save(Query $query, array $options = []) { $type = $query->getType(); if ($type === Query::DELETE) { return $this->_processDelete($query, $options); } else if ($type === Query::INSERT) { return $this->_processCreate($query, $options); } else if ($type === Query::UPDATE) { return $this->_processUpdate($query, $options); } // No processing or events, just execute it directly return $this->getDriver()->executeQuery($query)->save(); }
[ "public", "function", "save", "(", "Query", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "type", "=", "$", "query", "->", "getType", "(", ")", ";", "if", "(", "$", "type", "===", "Query", "::", "DELETE", ")", "{", "return", "$", "this", "->", "_processDelete", "(", "$", "query", ",", "$", "options", ")", ";", "}", "else", "if", "(", "$", "type", "===", "Query", "::", "INSERT", ")", "{", "return", "$", "this", "->", "_processCreate", "(", "$", "query", ",", "$", "options", ")", ";", "}", "else", "if", "(", "$", "type", "===", "Query", "::", "UPDATE", ")", "{", "return", "$", "this", "->", "_processUpdate", "(", "$", "query", ",", "$", "options", ")", ";", "}", "// No processing or events, just execute it directly", "return", "$", "this", "->", "getDriver", "(", ")", "->", "executeQuery", "(", "$", "query", ")", "->", "save", "(", ")", ";", "}" ]
Return a count of how many rows were affected by the query. @param \Titon\Db\Query $query @param array $options @return int
[ "Return", "a", "count", "of", "how", "many", "rows", "were", "affected", "by", "the", "query", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L826-L841
18,664
titon/db
src/Titon/Db/Repository.php
Repository.update
public function update($id, $data, array $options = []) { return $this->query(Query::UPDATE) ->where($this->getPrimaryKey(), $id) ->save($data, $options); }
php
public function update($id, $data, array $options = []) { return $this->query(Query::UPDATE) ->where($this->getPrimaryKey(), $id) ->save($data, $options); }
[ "public", "function", "update", "(", "$", "id", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "query", "(", "Query", "::", "UPDATE", ")", "->", "where", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ",", "$", "id", ")", "->", "save", "(", "$", "data", ",", "$", "options", ")", ";", "}" ]
Update a database record based on ID. @param int $id @param array|\Titon\Type\Contract\Arrayable $data @param array $options @return int The count of records updated
[ "Update", "a", "database", "record", "based", "on", "ID", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L893-L897
18,665
titon/db
src/Titon/Db/Repository.php
Repository.updateMany
public function updateMany($data, Closure $conditions, array $options = []) { return $this->query(Query::UPDATE) ->bindCallback($conditions) ->save($data, $options); }
php
public function updateMany($data, Closure $conditions, array $options = []) { return $this->query(Query::UPDATE) ->bindCallback($conditions) ->save($data, $options); }
[ "public", "function", "updateMany", "(", "$", "data", ",", "Closure", "$", "conditions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "query", "(", "Query", "::", "UPDATE", ")", "->", "bindCallback", "(", "$", "conditions", ")", "->", "save", "(", "$", "data", ",", "$", "options", ")", ";", "}" ]
Update multiple records with conditions. @param array|\Titon\Type\Contract\Arrayable $data @param \Closure $conditions @param array $options @return int The count of records updated @throws \Titon\Db\Exception\InvalidQueryException
[ "Update", "multiple", "records", "with", "conditions", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L908-L912
18,666
titon/db
src/Titon/Db/Repository.php
Repository.upsert
public function upsert($data, $id = null, array $options = []) { $pk = $this->getPrimaryKey(); $update = false; // Check for an ID in the data if (!$id && isset($data[$pk])) { $id = $data[$pk]; } unset($data[$pk]); // Check for record existence if ($id) { $update = $this->exists($id); } // Either update if ($update) { if ($this->update($id, $data, $options) === false) { return 0; } // Or insert } else { $id = $this->create($data, $options); } return $id; }
php
public function upsert($data, $id = null, array $options = []) { $pk = $this->getPrimaryKey(); $update = false; // Check for an ID in the data if (!$id && isset($data[$pk])) { $id = $data[$pk]; } unset($data[$pk]); // Check for record existence if ($id) { $update = $this->exists($id); } // Either update if ($update) { if ($this->update($id, $data, $options) === false) { return 0; } // Or insert } else { $id = $this->create($data, $options); } return $id; }
[ "public", "function", "upsert", "(", "$", "data", ",", "$", "id", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "pk", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "$", "update", "=", "false", ";", "// Check for an ID in the data", "if", "(", "!", "$", "id", "&&", "isset", "(", "$", "data", "[", "$", "pk", "]", ")", ")", "{", "$", "id", "=", "$", "data", "[", "$", "pk", "]", ";", "}", "unset", "(", "$", "data", "[", "$", "pk", "]", ")", ";", "// Check for record existence", "if", "(", "$", "id", ")", "{", "$", "update", "=", "$", "this", "->", "exists", "(", "$", "id", ")", ";", "}", "// Either update", "if", "(", "$", "update", ")", "{", "if", "(", "$", "this", "->", "update", "(", "$", "id", ",", "$", "data", ",", "$", "options", ")", "===", "false", ")", "{", "return", "0", ";", "}", "// Or insert", "}", "else", "{", "$", "id", "=", "$", "this", "->", "create", "(", "$", "data", ",", "$", "options", ")", ";", "}", "return", "$", "id", ";", "}" ]
Either update or insert a record by checking for ID and record existence. @param array|\Titon\Type\Contract\Arrayable $data @param int $id @param array $options @return int The record ID on success, 0 on failure
[ "Either", "update", "or", "insert", "a", "record", "by", "checking", "for", "ID", "and", "record", "existence", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L922-L950
18,667
titon/db
src/Titon/Db/Repository.php
Repository._processCreate
protected function _processCreate(Query $query, array $options = []) { $data = $query->getData(); $options = $options + [ 'before' => true, 'after' => true ]; if ($options['before']) { foreach (['db.preSave', 'db.preCreate'] as $event) { $event = $this->emit($event, [$query, null, &$data]); if (!$event->getState()) { return 0; } } } // Reset the modified data $query->data($data); // Update the connection context $driver = $this->getDriver(); $driver->setContext('write'); // Execute the query $count = $driver->executeQuery($query)->save(); // Exit early if save failed if ($count === false) { return 0; } $id = $driver->getLastInsertID($this); if ($options['after']) { $this->emit('db.postSave db.postCreate', [$id, $count]); } return $this->id = $id; }
php
protected function _processCreate(Query $query, array $options = []) { $data = $query->getData(); $options = $options + [ 'before' => true, 'after' => true ]; if ($options['before']) { foreach (['db.preSave', 'db.preCreate'] as $event) { $event = $this->emit($event, [$query, null, &$data]); if (!$event->getState()) { return 0; } } } // Reset the modified data $query->data($data); // Update the connection context $driver = $this->getDriver(); $driver->setContext('write'); // Execute the query $count = $driver->executeQuery($query)->save(); // Exit early if save failed if ($count === false) { return 0; } $id = $driver->getLastInsertID($this); if ($options['after']) { $this->emit('db.postSave db.postCreate', [$id, $count]); } return $this->id = $id; }
[ "protected", "function", "_processCreate", "(", "Query", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "$", "query", "->", "getData", "(", ")", ";", "$", "options", "=", "$", "options", "+", "[", "'before'", "=>", "true", ",", "'after'", "=>", "true", "]", ";", "if", "(", "$", "options", "[", "'before'", "]", ")", "{", "foreach", "(", "[", "'db.preSave'", ",", "'db.preCreate'", "]", "as", "$", "event", ")", "{", "$", "event", "=", "$", "this", "->", "emit", "(", "$", "event", ",", "[", "$", "query", ",", "null", ",", "&", "$", "data", "]", ")", ";", "if", "(", "!", "$", "event", "->", "getState", "(", ")", ")", "{", "return", "0", ";", "}", "}", "}", "// Reset the modified data", "$", "query", "->", "data", "(", "$", "data", ")", ";", "// Update the connection context", "$", "driver", "=", "$", "this", "->", "getDriver", "(", ")", ";", "$", "driver", "->", "setContext", "(", "'write'", ")", ";", "// Execute the query", "$", "count", "=", "$", "driver", "->", "executeQuery", "(", "$", "query", ")", "->", "save", "(", ")", ";", "// Exit early if save failed", "if", "(", "$", "count", "===", "false", ")", "{", "return", "0", ";", "}", "$", "id", "=", "$", "driver", "->", "getLastInsertID", "(", "$", "this", ")", ";", "if", "(", "$", "options", "[", "'after'", "]", ")", "{", "$", "this", "->", "emit", "(", "'db.postSave db.postCreate'", ",", "[", "$", "id", ",", "$", "count", "]", ")", ";", "}", "return", "$", "this", "->", "id", "=", "$", "id", ";", "}" ]
Primary method that handles the processing of insert queries. Before a save is executed, a `preSave` and `preCreate` event will be triggered. This event allows data to be modified before saving via references. If this event returns a falsey value, the save will exit early and return a 0. This allows behaviors and events to cease save operations. Before the driver is queried, the connection context will be set to `write`. After the query has executed, and no rows have been affected, the method will exit early with a 0 response. Otherwise, a `postSave` and `postCreate` event will be triggered. @param \Titon\Db\Query $query @param mixed $options { @type bool $before Will trigger before callbacks @type bool $after Will trigger after callbacks } @return int - The ID of the record if successful - 0 if save operation failed
[ "Primary", "method", "that", "handles", "the", "processing", "of", "insert", "queries", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L974-L1013
18,668
titon/db
src/Titon/Db/Repository.php
Repository._processDelete
protected function _processDelete(Query $query, array $options = []) { $options = $options + [ 'before' => true, 'after' => true ]; // Fetch ID $this->id = $id = $this->findID($query); if ($options['before']) { $event = $this->emit('db.preDelete', [$query, $id]); $state = $event->getState(); if (!$state) { return 0; } else if (is_numeric($state)) { return (int) $state; } } // Update the connection context and execute the query $count = $this->getDriver() ->setContext('delete') ->executeQuery($query) ->save(); // Only trigger callback if something was deleted if ($count && $options['after']) { $this->emit('db.postDelete', [$id, $count]); } return (int) $count; }
php
protected function _processDelete(Query $query, array $options = []) { $options = $options + [ 'before' => true, 'after' => true ]; // Fetch ID $this->id = $id = $this->findID($query); if ($options['before']) { $event = $this->emit('db.preDelete', [$query, $id]); $state = $event->getState(); if (!$state) { return 0; } else if (is_numeric($state)) { return (int) $state; } } // Update the connection context and execute the query $count = $this->getDriver() ->setContext('delete') ->executeQuery($query) ->save(); // Only trigger callback if something was deleted if ($count && $options['after']) { $this->emit('db.postDelete', [$id, $count]); } return (int) $count; }
[ "protected", "function", "_processDelete", "(", "Query", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "options", "+", "[", "'before'", "=>", "true", ",", "'after'", "=>", "true", "]", ";", "// Fetch ID", "$", "this", "->", "id", "=", "$", "id", "=", "$", "this", "->", "findID", "(", "$", "query", ")", ";", "if", "(", "$", "options", "[", "'before'", "]", ")", "{", "$", "event", "=", "$", "this", "->", "emit", "(", "'db.preDelete'", ",", "[", "$", "query", ",", "$", "id", "]", ")", ";", "$", "state", "=", "$", "event", "->", "getState", "(", ")", ";", "if", "(", "!", "$", "state", ")", "{", "return", "0", ";", "}", "else", "if", "(", "is_numeric", "(", "$", "state", ")", ")", "{", "return", "(", "int", ")", "$", "state", ";", "}", "}", "// Update the connection context and execute the query", "$", "count", "=", "$", "this", "->", "getDriver", "(", ")", "->", "setContext", "(", "'delete'", ")", "->", "executeQuery", "(", "$", "query", ")", "->", "save", "(", ")", ";", "// Only trigger callback if something was deleted", "if", "(", "$", "count", "&&", "$", "options", "[", "'after'", "]", ")", "{", "$", "this", "->", "emit", "(", "'db.postDelete'", ",", "[", "$", "id", ",", "$", "count", "]", ")", ";", "}", "return", "(", "int", ")", "$", "count", ";", "}" ]
Primary method that handles the processing of delete queries. Before a delete is executed, a `preDelete` event will be triggered. If a falsey value is returned, exit early with a 0. If a numeric value is returned, exit early and return the number, which acts as a virtual affected row count (permitting behaviors to short circuit the process). Before the driver is queried, the connection context will be set to `delete`. After a delete has executed successfully, a `postDelete` event will be triggered. @param \Titon\Db\Query $query @param mixed $options { @type bool $before Will trigger before callbacks @type bool $after Will trigger after callbacks } @return int The count of records deleted
[ "Primary", "method", "that", "handles", "the", "processing", "of", "delete", "queries", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L1034-L1066
18,669
titon/db
src/Titon/Db/Repository.php
Repository._processUpdate
protected function _processUpdate(Query $query, array $options = []) { $data = $query->getData(); $options = $options + [ 'before' => true, 'after' => true ]; // Fetch ID $this->id = $id = $this->findID($query); if ($options['before']) { foreach (['db.preSave', 'db.preUpdate'] as $event) { $event = $this->emit($event, [$query, $id, &$data]); if (!$event->getState()) { return 0; } } } // Reset the modified data $query->data($data); // Update the connection context and execute the query $count = $this->getDriver() ->setContext('write') ->executeQuery($query) ->save(); // Exit early if save failed if ($count === false) { return false; } if ($options['after']) { $this->emit('db.postSave db.postUpdate', [$id, $count]); } return $count; }
php
protected function _processUpdate(Query $query, array $options = []) { $data = $query->getData(); $options = $options + [ 'before' => true, 'after' => true ]; // Fetch ID $this->id = $id = $this->findID($query); if ($options['before']) { foreach (['db.preSave', 'db.preUpdate'] as $event) { $event = $this->emit($event, [$query, $id, &$data]); if (!$event->getState()) { return 0; } } } // Reset the modified data $query->data($data); // Update the connection context and execute the query $count = $this->getDriver() ->setContext('write') ->executeQuery($query) ->save(); // Exit early if save failed if ($count === false) { return false; } if ($options['after']) { $this->emit('db.postSave db.postUpdate', [$id, $count]); } return $count; }
[ "protected", "function", "_processUpdate", "(", "Query", "$", "query", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "$", "query", "->", "getData", "(", ")", ";", "$", "options", "=", "$", "options", "+", "[", "'before'", "=>", "true", ",", "'after'", "=>", "true", "]", ";", "// Fetch ID", "$", "this", "->", "id", "=", "$", "id", "=", "$", "this", "->", "findID", "(", "$", "query", ")", ";", "if", "(", "$", "options", "[", "'before'", "]", ")", "{", "foreach", "(", "[", "'db.preSave'", ",", "'db.preUpdate'", "]", "as", "$", "event", ")", "{", "$", "event", "=", "$", "this", "->", "emit", "(", "$", "event", ",", "[", "$", "query", ",", "$", "id", ",", "&", "$", "data", "]", ")", ";", "if", "(", "!", "$", "event", "->", "getState", "(", ")", ")", "{", "return", "0", ";", "}", "}", "}", "// Reset the modified data", "$", "query", "->", "data", "(", "$", "data", ")", ";", "// Update the connection context and execute the query", "$", "count", "=", "$", "this", "->", "getDriver", "(", ")", "->", "setContext", "(", "'write'", ")", "->", "executeQuery", "(", "$", "query", ")", "->", "save", "(", ")", ";", "// Exit early if save failed", "if", "(", "$", "count", "===", "false", ")", "{", "return", "false", ";", "}", "if", "(", "$", "options", "[", "'after'", "]", ")", "{", "$", "this", "->", "emit", "(", "'db.postSave db.postUpdate'", ",", "[", "$", "id", ",", "$", "count", "]", ")", ";", "}", "return", "$", "count", ";", "}" ]
Primary method that handles the processing of update queries. Before a save is executed, a `preSave` and `preUpdate` event will be triggered. This event allows data to be modified before saving via references. If this event returns a falsey value, the save will exit early and return a 0. This allows behaviors and events to cease save operations. Before the driver is queried, the connection context will be set to `write`. After the query has executed, and no rows have been affected, the method will exit early with a 0 response. Otherwise, a `postSave` and `postUpdate` event will be triggered. @param \Titon\Db\Query $query @param mixed $options { @type bool $before Will trigger before callbacks @type bool $after Will trigger after callbacks } @return int - The count of records updated - 0 if save operation failed
[ "Primary", "method", "that", "handles", "the", "processing", "of", "update", "queries", "." ]
fbc5159d1ce9d2139759c9367565986981485604
https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Repository.php#L1090-L1129
18,670
arsengoian/viper-framework
src/Viper/Daemon/DaemonHistorian.php
DaemonHistorian.clearLog
function clearLog() : void { @unlink($this -> errLogger -> getFile()); @unlink($this -> logger -> getFile()); @unlink($this -> errLogger -> getFile().'.shell'); @unlink($this -> logger -> getFile().'.shell'); }
php
function clearLog() : void { @unlink($this -> errLogger -> getFile()); @unlink($this -> logger -> getFile()); @unlink($this -> errLogger -> getFile().'.shell'); @unlink($this -> logger -> getFile().'.shell'); }
[ "function", "clearLog", "(", ")", ":", "void", "{", "@", "unlink", "(", "$", "this", "->", "errLogger", "->", "getFile", "(", ")", ")", ";", "@", "unlink", "(", "$", "this", "->", "logger", "->", "getFile", "(", ")", ")", ";", "@", "unlink", "(", "$", "this", "->", "errLogger", "->", "getFile", "(", ")", ".", "'.shell'", ")", ";", "@", "unlink", "(", "$", "this", "->", "logger", "->", "getFile", "(", ")", ".", "'.shell'", ")", ";", "}" ]
Cleans daemon log
[ "Cleans", "daemon", "log" ]
22796c5cc219cae3ca0b4af370a347ba2acab0f2
https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/DaemonHistorian.php#L75-L81
18,671
aedart/laravel-helpers
src/Traits/View/BladeTrait.php
BladeTrait.getDefaultBlade
public function getDefaultBlade(): ?BladeCompiler { // The blade compiler is usually only available, once // Laravel's view service provider has been initialised. // Thus, before just returning the Blade Facade's root // instance, we must make sure that the view facade // actually returns something $view = View::getFacadeRoot(); if (isset($view)) { return Blade::getFacadeRoot(); } return $view; }
php
public function getDefaultBlade(): ?BladeCompiler { // The blade compiler is usually only available, once // Laravel's view service provider has been initialised. // Thus, before just returning the Blade Facade's root // instance, we must make sure that the view facade // actually returns something $view = View::getFacadeRoot(); if (isset($view)) { return Blade::getFacadeRoot(); } return $view; }
[ "public", "function", "getDefaultBlade", "(", ")", ":", "?", "BladeCompiler", "{", "// The blade compiler is usually only available, once", "// Laravel's view service provider has been initialised.", "// Thus, before just returning the Blade Facade's root", "// instance, we must make sure that the view facade", "// actually returns something", "$", "view", "=", "View", "::", "getFacadeRoot", "(", ")", ";", "if", "(", "isset", "(", "$", "view", ")", ")", "{", "return", "Blade", "::", "getFacadeRoot", "(", ")", ";", "}", "return", "$", "view", ";", "}" ]
Get a default blade value, if any is available @return BladeCompiler|null A default blade value or Null if no default value is available
[ "Get", "a", "default", "blade", "value", "if", "any", "is", "available" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/View/BladeTrait.php#L77-L89
18,672
ClanCats/Core
src/classes/CCStorage.php
CCStorage.add
public static function add( $key, $path, $url = null ) { static::$paths[$key] = $path; if ( !is_null( $url ) ) { static::$urls[$key] = $url; } }
php
public static function add( $key, $path, $url = null ) { static::$paths[$key] = $path; if ( !is_null( $url ) ) { static::$urls[$key] = $url; } }
[ "public", "static", "function", "add", "(", "$", "key", ",", "$", "path", ",", "$", "url", "=", "null", ")", "{", "static", "::", "$", "paths", "[", "$", "key", "]", "=", "$", "path", ";", "if", "(", "!", "is_null", "(", "$", "url", ")", ")", "{", "static", "::", "$", "urls", "[", "$", "key", "]", "=", "$", "url", ";", "}", "}" ]
Adds a new storage directory @param string $key @param string $path @param string $url @return void
[ "Adds", "a", "new", "storage", "directory" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStorage.php#L75-L83
18,673
ClanCats/Core
src/classes/CCStorage.php
CCStorage.file
public static function file( $file ) { $params = array_merge( static::$params, array( 'time' => time(), 'fingerprint' => \CCSession::fingerprint(), 'random' => CCStr::random(), )); foreach( $params as $param => $value ) { $file = str_replace( ':'.$param, $value, $file ); } return $file; }
php
public static function file( $file ) { $params = array_merge( static::$params, array( 'time' => time(), 'fingerprint' => \CCSession::fingerprint(), 'random' => CCStr::random(), )); foreach( $params as $param => $value ) { $file = str_replace( ':'.$param, $value, $file ); } return $file; }
[ "public", "static", "function", "file", "(", "$", "file", ")", "{", "$", "params", "=", "array_merge", "(", "static", "::", "$", "params", ",", "array", "(", "'time'", "=>", "time", "(", ")", ",", "'fingerprint'", "=>", "\\", "CCSession", "::", "fingerprint", "(", ")", ",", "'random'", "=>", "CCStr", "::", "random", "(", ")", ",", ")", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", "=>", "$", "value", ")", "{", "$", "file", "=", "str_replace", "(", "':'", ".", "$", "param", ",", "$", "value", ",", "$", "file", ")", ";", "}", "return", "$", "file", ";", "}" ]
Prepares a file with the parameters @param string $file @return $file
[ "Prepares", "a", "file", "with", "the", "parameters" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStorage.php#L91-L105
18,674
ClanCats/Core
src/classes/CCStorage.php
CCStorage.url
public static function url( $file = null, $key = null ) { // get the storage key if ( is_null( $key ) ) { $key = static::$default; } // check if path exists if ( !isset( static::$urls[$key] ) ) { throw new CCException( 'CCStorage - use of undefined public url '.$key.'.' ); } return CCUrl::to( static::$urls[$key].$file ); }
php
public static function url( $file = null, $key = null ) { // get the storage key if ( is_null( $key ) ) { $key = static::$default; } // check if path exists if ( !isset( static::$urls[$key] ) ) { throw new CCException( 'CCStorage - use of undefined public url '.$key.'.' ); } return CCUrl::to( static::$urls[$key].$file ); }
[ "public", "static", "function", "url", "(", "$", "file", "=", "null", ",", "$", "key", "=", "null", ")", "{", "// get the storage key", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "$", "key", "=", "static", "::", "$", "default", ";", "}", "// check if path exists", "if", "(", "!", "isset", "(", "static", "::", "$", "urls", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "CCException", "(", "'CCStorage - use of undefined public url '", ".", "$", "key", ".", "'.'", ")", ";", "}", "return", "CCUrl", "::", "to", "(", "static", "::", "$", "urls", "[", "$", "key", "]", ".", "$", "file", ")", ";", "}" ]
Get the public url to a file if available @param string $file @param string $key @return string
[ "Get", "the", "public", "url", "to", "a", "file", "if", "available" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStorage.php#L143-L158
18,675
ClanCats/Core
src/classes/CCStorage.php
CCStorage.write
public static function write( $file, $content, $key = null ) { return CCFile::write( static::path( $file, $key ), $content ); }
php
public static function write( $file, $content, $key = null ) { return CCFile::write( static::path( $file, $key ), $content ); }
[ "public", "static", "function", "write", "(", "$", "file", ",", "$", "content", ",", "$", "key", "=", "null", ")", "{", "return", "CCFile", "::", "write", "(", "static", "::", "path", "(", "$", "file", ",", "$", "key", ")", ",", "$", "content", ")", ";", "}" ]
Write a file to the storage @param string $file @param string $key @return string
[ "Write", "a", "file", "to", "the", "storage" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStorage.php#L167-L170
18,676
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.setComment
public function setComment($newComment = NULL) { if ($this->isFinalized) { return FALSE; } $this->zipComment = $newComment; return TRUE; }
php
public function setComment($newComment = NULL) { if ($this->isFinalized) { return FALSE; } $this->zipComment = $newComment; return TRUE; }
[ "public", "function", "setComment", "(", "$", "newComment", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "isFinalized", ")", "{", "return", "FALSE", ";", "}", "$", "this", "->", "zipComment", "=", "$", "newComment", ";", "return", "TRUE", ";", "}" ]
Set Zip archive comment. @param string $newComment New comment. NULL to clear. @return bool $success
[ "Set", "Zip", "archive", "comment", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L139-L146
18,677
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.addDirectory
public function addDirectory($directoryPath, $timestamp = 0, $fileComment = NULL, $extFileAttr = self::EXT_FILE_ATTR_DIR) { if ($this->isFinalized) { return FALSE; } $directoryPath = str_replace("\\", "/", $directoryPath); $directoryPath = rtrim($directoryPath, "/"); if (strlen($directoryPath) > 0) { $this->buildZipEntry($directoryPath.'/', $fileComment, "\x00\x00", "\x00\x00", $timestamp, "\x00\x00\x00\x00", 0, 0, $extFileAttr); return TRUE; } return FALSE; }
php
public function addDirectory($directoryPath, $timestamp = 0, $fileComment = NULL, $extFileAttr = self::EXT_FILE_ATTR_DIR) { if ($this->isFinalized) { return FALSE; } $directoryPath = str_replace("\\", "/", $directoryPath); $directoryPath = rtrim($directoryPath, "/"); if (strlen($directoryPath) > 0) { $this->buildZipEntry($directoryPath.'/', $fileComment, "\x00\x00", "\x00\x00", $timestamp, "\x00\x00\x00\x00", 0, 0, $extFileAttr); return TRUE; } return FALSE; }
[ "public", "function", "addDirectory", "(", "$", "directoryPath", ",", "$", "timestamp", "=", "0", ",", "$", "fileComment", "=", "NULL", ",", "$", "extFileAttr", "=", "self", "::", "EXT_FILE_ATTR_DIR", ")", "{", "if", "(", "$", "this", "->", "isFinalized", ")", "{", "return", "FALSE", ";", "}", "$", "directoryPath", "=", "str_replace", "(", "\"\\\\\"", ",", "\"/\"", ",", "$", "directoryPath", ")", ";", "$", "directoryPath", "=", "rtrim", "(", "$", "directoryPath", ",", "\"/\"", ")", ";", "if", "(", "strlen", "(", "$", "directoryPath", ")", ">", "0", ")", "{", "$", "this", "->", "buildZipEntry", "(", "$", "directoryPath", ".", "'/'", ",", "$", "fileComment", ",", "\"\\x00\\x00\"", ",", "\"\\x00\\x00\"", ",", "$", "timestamp", ",", "\"\\x00\\x00\\x00\\x00\"", ",", "0", ",", "0", ",", "$", "extFileAttr", ")", ";", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Add an empty directory entry to the zip archive. Basically this is only used if an empty directory is added. @param string $directoryPath Directory Path and name to be added to the archive. @param int $timestamp (Optional) Timestamp for the added directory, if omitted or set to 0, the current time will be used. @param string $fileComment (Optional) Comment to be added to the archive for this directory. To use fileComment, timestamp must be given. @param int $extFileAttr (Optional) The external file reference, use generateExtAttr to generate this. @return bool $success
[ "Add", "an", "empty", "directory", "entry", "to", "the", "zip", "archive", ".", "Basically", "this", "is", "only", "used", "if", "an", "empty", "directory", "is", "added", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L188-L200
18,678
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.addStreamData
public function addStreamData($data) { if ($this->isFinalized || strlen($this->streamFilePath) == 0) { return FALSE; } $length = fwrite($this->streamData, $data, strlen($data)); if ($length != strlen($data)) { throw new Exception("File IO: Error writing; Length mismatch: Expected " . strlen($data) . " bytes, wrote " . ($length === FALSE ? "NONE!" : $length)); } $this->streamFileLength += $length; return $length; }
php
public function addStreamData($data) { if ($this->isFinalized || strlen($this->streamFilePath) == 0) { return FALSE; } $length = fwrite($this->streamData, $data, strlen($data)); if ($length != strlen($data)) { throw new Exception("File IO: Error writing; Length mismatch: Expected " . strlen($data) . " bytes, wrote " . ($length === FALSE ? "NONE!" : $length)); } $this->streamFileLength += $length; return $length; }
[ "public", "function", "addStreamData", "(", "$", "data", ")", "{", "if", "(", "$", "this", "->", "isFinalized", "||", "strlen", "(", "$", "this", "->", "streamFilePath", ")", "==", "0", ")", "{", "return", "FALSE", ";", "}", "$", "length", "=", "fwrite", "(", "$", "this", "->", "streamData", ",", "$", "data", ",", "strlen", "(", "$", "data", ")", ")", ";", "if", "(", "$", "length", "!=", "strlen", "(", "$", "data", ")", ")", "{", "throw", "new", "Exception", "(", "\"File IO: Error writing; Length mismatch: Expected \"", ".", "strlen", "(", "$", "data", ")", ".", "\" bytes, wrote \"", ".", "(", "$", "length", "===", "FALSE", "?", "\"NONE!\"", ":", "$", "length", ")", ")", ";", "}", "$", "this", "->", "streamFileLength", "+=", "$", "length", ";", "return", "$", "length", ";", "}" ]
Add data to the open stream. @param string $data @throws Exception Throws an exception in case of errors @return mixed length in bytes added or FALSE if the archive is finalized or there are no open stream.
[ "Add", "data", "to", "the", "open", "stream", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L389-L401
18,679
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.closeStream
public function closeStream() { if ($this->isFinalized || strlen($this->streamFilePath) == 0) { return FALSE; } fflush($this->streamData); fclose($this->streamData); $this->processFile($this->streamFile, $this->streamFilePath, $this->streamTimestamp, $this->streamFileComment, $this->streamExtFileAttr); $this->streamData = null; $this->streamFilePath = null; $this->streamTimestamp = null; $this->streamFileComment = null; $this->streamFileLength = 0; $this->streamExtFileAttr = null; // Windows is a little slow at times, so a millisecond later, we can unlink this. unlink($this->streamFile); $this->streamFile = null; return TRUE; }
php
public function closeStream() { if ($this->isFinalized || strlen($this->streamFilePath) == 0) { return FALSE; } fflush($this->streamData); fclose($this->streamData); $this->processFile($this->streamFile, $this->streamFilePath, $this->streamTimestamp, $this->streamFileComment, $this->streamExtFileAttr); $this->streamData = null; $this->streamFilePath = null; $this->streamTimestamp = null; $this->streamFileComment = null; $this->streamFileLength = 0; $this->streamExtFileAttr = null; // Windows is a little slow at times, so a millisecond later, we can unlink this. unlink($this->streamFile); $this->streamFile = null; return TRUE; }
[ "public", "function", "closeStream", "(", ")", "{", "if", "(", "$", "this", "->", "isFinalized", "||", "strlen", "(", "$", "this", "->", "streamFilePath", ")", "==", "0", ")", "{", "return", "FALSE", ";", "}", "fflush", "(", "$", "this", "->", "streamData", ")", ";", "fclose", "(", "$", "this", "->", "streamData", ")", ";", "$", "this", "->", "processFile", "(", "$", "this", "->", "streamFile", ",", "$", "this", "->", "streamFilePath", ",", "$", "this", "->", "streamTimestamp", ",", "$", "this", "->", "streamFileComment", ",", "$", "this", "->", "streamExtFileAttr", ")", ";", "$", "this", "->", "streamData", "=", "null", ";", "$", "this", "->", "streamFilePath", "=", "null", ";", "$", "this", "->", "streamTimestamp", "=", "null", ";", "$", "this", "->", "streamFileComment", "=", "null", ";", "$", "this", "->", "streamFileLength", "=", "0", ";", "$", "this", "->", "streamExtFileAttr", "=", "null", ";", "// Windows is a little slow at times, so a millisecond later, we can unlink this.", "unlink", "(", "$", "this", "->", "streamFile", ")", ";", "$", "this", "->", "streamFile", "=", "null", ";", "return", "TRUE", ";", "}" ]
Close the current stream. @return bool $success
[ "Close", "the", "current", "stream", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L408-L431
18,680
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.finalize
public function finalize() { if (!$this->isFinalized) { if (strlen($this->streamFilePath) > 0) { $this->closeStream(); } $cd = implode("", $this->cdRec); $cdRecSize = pack("v", sizeof($this->cdRec)); $cdRec = $cd . self::ZIP_END_OF_CENTRAL_DIRECTORY . $cdRecSize . $cdRecSize . pack("VV", strlen($cd), $this->offset); if (!empty($this->zipComment)) { $cdRec .= pack("v", strlen($this->zipComment)) . $this->zipComment; } else { $cdRec .= "\x00\x00"; } $this->zipwrite($cdRec); $this->isFinalized = TRUE; $this->cdRec = NULL; return TRUE; } return FALSE; }
php
public function finalize() { if (!$this->isFinalized) { if (strlen($this->streamFilePath) > 0) { $this->closeStream(); } $cd = implode("", $this->cdRec); $cdRecSize = pack("v", sizeof($this->cdRec)); $cdRec = $cd . self::ZIP_END_OF_CENTRAL_DIRECTORY . $cdRecSize . $cdRecSize . pack("VV", strlen($cd), $this->offset); if (!empty($this->zipComment)) { $cdRec .= pack("v", strlen($this->zipComment)) . $this->zipComment; } else { $cdRec .= "\x00\x00"; } $this->zipwrite($cdRec); $this->isFinalized = TRUE; $this->cdRec = NULL; return TRUE; } return FALSE; }
[ "public", "function", "finalize", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isFinalized", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "streamFilePath", ")", ">", "0", ")", "{", "$", "this", "->", "closeStream", "(", ")", ";", "}", "$", "cd", "=", "implode", "(", "\"\"", ",", "$", "this", "->", "cdRec", ")", ";", "$", "cdRecSize", "=", "pack", "(", "\"v\"", ",", "sizeof", "(", "$", "this", "->", "cdRec", ")", ")", ";", "$", "cdRec", "=", "$", "cd", ".", "self", "::", "ZIP_END_OF_CENTRAL_DIRECTORY", ".", "$", "cdRecSize", ".", "$", "cdRecSize", ".", "pack", "(", "\"VV\"", ",", "strlen", "(", "$", "cd", ")", ",", "$", "this", "->", "offset", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "zipComment", ")", ")", "{", "$", "cdRec", ".=", "pack", "(", "\"v\"", ",", "strlen", "(", "$", "this", "->", "zipComment", ")", ")", ".", "$", "this", "->", "zipComment", ";", "}", "else", "{", "$", "cdRec", ".=", "\"\\x00\\x00\"", ";", "}", "$", "this", "->", "zipwrite", "(", "$", "cdRec", ")", ";", "$", "this", "->", "isFinalized", "=", "TRUE", ";", "$", "this", "->", "cdRec", "=", "NULL", ";", "return", "TRUE", ";", "}", "return", "FALSE", ";", "}" ]
Close the archive. A closed archive can no longer have new files added to it. @return bool $success
[ "Close", "the", "archive", ".", "A", "closed", "archive", "can", "no", "longer", "have", "new", "files", "added", "to", "it", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L488-L513
18,681
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.getZipFile
public function getZipFile() { if (!$this->isFinalized) { $this->finalize(); } $this->zipflush(); rewind($this->zipFile); return $this->zipFile; }
php
public function getZipFile() { if (!$this->isFinalized) { $this->finalize(); } $this->zipflush(); rewind($this->zipFile); return $this->zipFile; }
[ "public", "function", "getZipFile", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isFinalized", ")", "{", "$", "this", "->", "finalize", "(", ")", ";", "}", "$", "this", "->", "zipflush", "(", ")", ";", "rewind", "(", "$", "this", "->", "zipFile", ")", ";", "return", "$", "this", "->", "zipFile", ";", "}" ]
Get the handle ressource for the archive zip file. If the zip haven't been finalized yet, this will cause it to become finalized @return zip file handle
[ "Get", "the", "handle", "ressource", "for", "the", "archive", "zip", "file", ".", "If", "the", "zip", "haven", "t", "been", "finalized", "yet", "this", "will", "cause", "it", "to", "become", "finalized" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L521-L531
18,682
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.getZipData
public function getZipData() { if (!$this->isFinalized) { $this->finalize(); } if (!is_resource($this->zipFile)) { return $this->zipData; } else { rewind($this->zipFile); $filestat = fstat($this->zipFile); return fread($this->zipFile, $filestat['size']); } }
php
public function getZipData() { if (!$this->isFinalized) { $this->finalize(); } if (!is_resource($this->zipFile)) { return $this->zipData; } else { rewind($this->zipFile); $filestat = fstat($this->zipFile); return fread($this->zipFile, $filestat['size']); } }
[ "public", "function", "getZipData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isFinalized", ")", "{", "$", "this", "->", "finalize", "(", ")", ";", "}", "if", "(", "!", "is_resource", "(", "$", "this", "->", "zipFile", ")", ")", "{", "return", "$", "this", "->", "zipData", ";", "}", "else", "{", "rewind", "(", "$", "this", "->", "zipFile", ")", ";", "$", "filestat", "=", "fstat", "(", "$", "this", "->", "zipFile", ")", ";", "return", "fread", "(", "$", "this", "->", "zipFile", ",", "$", "filestat", "[", "'size'", "]", ")", ";", "}", "}" ]
Get the zip file contents If the zip haven't been finalized yet, this will cause it to become finalized @return zip data
[ "Get", "the", "zip", "file", "contents", "If", "the", "zip", "haven", "t", "been", "finalized", "yet", "this", "will", "cause", "it", "to", "become", "finalized" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L539-L550
18,683
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.getArchiveSize
public function getArchiveSize() { if (!is_resource($this->zipFile)) { return strlen($this->zipData); } $filestat = fstat($this->zipFile); return $filestat['size']; }
php
public function getArchiveSize() { if (!is_resource($this->zipFile)) { return strlen($this->zipData); } $filestat = fstat($this->zipFile); return $filestat['size']; }
[ "public", "function", "getArchiveSize", "(", ")", "{", "if", "(", "!", "is_resource", "(", "$", "this", "->", "zipFile", ")", ")", "{", "return", "strlen", "(", "$", "this", "->", "zipData", ")", ";", "}", "$", "filestat", "=", "fstat", "(", "$", "this", "->", "zipFile", ")", ";", "return", "$", "filestat", "[", "'size'", "]", ";", "}" ]
Return the current size of the archive @return $size Size of the archive
[ "Return", "the", "current", "size", "of", "the", "archive" ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L613-L620
18,684
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.getDosTime
private function getDosTime($timestamp = 0) { $timestamp = (int)$timestamp; $oldTZ = @date_default_timezone_get(); date_default_timezone_set('UTC'); $date = ($timestamp == 0 ? getdate() : getdate($timestamp)); date_default_timezone_set($oldTZ); if ($date["year"] >= 1980) { return pack("V", (($date["mday"] + ($date["mon"] << 5) + (($date["year"]-1980) << 9)) << 16) | (($date["seconds"] >> 1) + ($date["minutes"] << 5) + ($date["hours"] << 11))); } return "\x00\x00\x00\x00"; }
php
private function getDosTime($timestamp = 0) { $timestamp = (int)$timestamp; $oldTZ = @date_default_timezone_get(); date_default_timezone_set('UTC'); $date = ($timestamp == 0 ? getdate() : getdate($timestamp)); date_default_timezone_set($oldTZ); if ($date["year"] >= 1980) { return pack("V", (($date["mday"] + ($date["mon"] << 5) + (($date["year"]-1980) << 9)) << 16) | (($date["seconds"] >> 1) + ($date["minutes"] << 5) + ($date["hours"] << 11))); } return "\x00\x00\x00\x00"; }
[ "private", "function", "getDosTime", "(", "$", "timestamp", "=", "0", ")", "{", "$", "timestamp", "=", "(", "int", ")", "$", "timestamp", ";", "$", "oldTZ", "=", "@", "date_default_timezone_get", "(", ")", ";", "date_default_timezone_set", "(", "'UTC'", ")", ";", "$", "date", "=", "(", "$", "timestamp", "==", "0", "?", "getdate", "(", ")", ":", "getdate", "(", "$", "timestamp", ")", ")", ";", "date_default_timezone_set", "(", "$", "oldTZ", ")", ";", "if", "(", "$", "date", "[", "\"year\"", "]", ">=", "1980", ")", "{", "return", "pack", "(", "\"V\"", ",", "(", "(", "$", "date", "[", "\"mday\"", "]", "+", "(", "$", "date", "[", "\"mon\"", "]", "<<", "5", ")", "+", "(", "(", "$", "date", "[", "\"year\"", "]", "-", "1980", ")", "<<", "9", ")", ")", "<<", "16", ")", "|", "(", "(", "$", "date", "[", "\"seconds\"", "]", ">>", "1", ")", "+", "(", "$", "date", "[", "\"minutes\"", "]", "<<", "5", ")", "+", "(", "$", "date", "[", "\"hours\"", "]", "<<", "11", ")", ")", ")", ";", "}", "return", "\"\\x00\\x00\\x00\\x00\"", ";", "}" ]
Calculate the 2 byte dostime used in the zip entries. @param int $timestamp @return 2-byte encoded DOS Date
[ "Calculate", "the", "2", "byte", "dostime", "used", "in", "the", "zip", "entries", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L628-L639
18,685
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.generateExtAttr
public static function generateExtAttr($owner = 07, $group = 05, $other = 05, $isFile = true) { $fp = $isFile ? self::S_IFREG : self::S_IFDIR; $fp |= (($owner & 07) << 6) | (($group & 07) << 3) | ($other & 07); return ($fp << 16) | ($isFile ? self::S_DOS_A : self::S_DOS_D); }
php
public static function generateExtAttr($owner = 07, $group = 05, $other = 05, $isFile = true) { $fp = $isFile ? self::S_IFREG : self::S_IFDIR; $fp |= (($owner & 07) << 6) | (($group & 07) << 3) | ($other & 07); return ($fp << 16) | ($isFile ? self::S_DOS_A : self::S_DOS_D); }
[ "public", "static", "function", "generateExtAttr", "(", "$", "owner", "=", "07", ",", "$", "group", "=", "05", ",", "$", "other", "=", "05", ",", "$", "isFile", "=", "true", ")", "{", "$", "fp", "=", "$", "isFile", "?", "self", "::", "S_IFREG", ":", "self", "::", "S_IFDIR", ";", "$", "fp", "|=", "(", "(", "$", "owner", "&", "07", ")", "<<", "6", ")", "|", "(", "(", "$", "group", "&", "07", ")", "<<", "3", ")", "|", "(", "$", "other", "&", "07", ")", ";", "return", "(", "$", "fp", "<<", "16", ")", "|", "(", "$", "isFile", "?", "self", "::", "S_DOS_A", ":", "self", "::", "S_DOS_D", ")", ";", "}" ]
Create the file permissions for a file or directory, for use in the extFileAttr parameters. @param int $owner Unix permisions for owner (octal from 00 to 07) @param int $group Unix permisions for group (octal from 00 to 07) @param int $other Unix permisions for others (octal from 00 to 07) @param bool $isFile @return EXTRERNAL_REF field.
[ "Create", "the", "file", "permissions", "for", "a", "file", "or", "directory", "for", "use", "in", "the", "extFileAttr", "parameters", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L828-L833
18,686
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.getFileExtAttr
public static function getFileExtAttr($filename) { if (file_exists($filename)) { $fp = fileperms($filename) << 16; return $fp | (is_dir($filename) ? self::S_DOS_D : self::S_DOS_A); } return FALSE; }
php
public static function getFileExtAttr($filename) { if (file_exists($filename)) { $fp = fileperms($filename) << 16; return $fp | (is_dir($filename) ? self::S_DOS_D : self::S_DOS_A); } return FALSE; }
[ "public", "static", "function", "getFileExtAttr", "(", "$", "filename", ")", "{", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "fp", "=", "fileperms", "(", "$", "filename", ")", "<<", "16", ";", "return", "$", "fp", "|", "(", "is_dir", "(", "$", "filename", ")", "?", "self", "::", "S_DOS_D", ":", "self", "::", "S_DOS_A", ")", ";", "}", "return", "FALSE", ";", "}" ]
Get the file permissions for a file or directory, for use in the extFileAttr parameters. @param string $filename @return external ref field, or FALSE if the file is not found.
[ "Get", "the", "file", "permissions", "for", "a", "file", "or", "directory", "for", "use", "in", "the", "extFileAttr", "parameters", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L841-L847
18,687
slashworks/control-bundle
src/Slashworks/AppBundle/Resources/private/api/zip.lib.php
Zip.getTemporaryFile
private static function getTemporaryFile() { if(is_callable(self::$temp)) { $temporaryFile = @call_user_func(self::$temp); if(is_string($temporaryFile) && strlen($temporaryFile) && is_writable($temporaryFile)) { return $temporaryFile; } } $temporaryDirectory = (is_string(self::$temp) && strlen(self::$temp)) ? self::$temp : sys_get_temp_dir(); return tempnam($temporaryDirectory, 'Zip'); }
php
private static function getTemporaryFile() { if(is_callable(self::$temp)) { $temporaryFile = @call_user_func(self::$temp); if(is_string($temporaryFile) && strlen($temporaryFile) && is_writable($temporaryFile)) { return $temporaryFile; } } $temporaryDirectory = (is_string(self::$temp) && strlen(self::$temp)) ? self::$temp : sys_get_temp_dir(); return tempnam($temporaryDirectory, 'Zip'); }
[ "private", "static", "function", "getTemporaryFile", "(", ")", "{", "if", "(", "is_callable", "(", "self", "::", "$", "temp", ")", ")", "{", "$", "temporaryFile", "=", "@", "call_user_func", "(", "self", "::", "$", "temp", ")", ";", "if", "(", "is_string", "(", "$", "temporaryFile", ")", "&&", "strlen", "(", "$", "temporaryFile", ")", "&&", "is_writable", "(", "$", "temporaryFile", ")", ")", "{", "return", "$", "temporaryFile", ";", "}", "}", "$", "temporaryDirectory", "=", "(", "is_string", "(", "self", "::", "$", "temp", ")", "&&", "strlen", "(", "self", "::", "$", "temp", ")", ")", "?", "self", "::", "$", "temp", ":", "sys_get_temp_dir", "(", ")", ";", "return", "tempnam", "(", "$", "temporaryDirectory", ",", "'Zip'", ")", ";", "}" ]
Returns the path to a temporary file. @return string
[ "Returns", "the", "path", "to", "a", "temporary", "file", "." ]
2ba86d96f1f41f9424e2229c4e2b13017e973f89
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Resources/private/api/zip.lib.php#L852-L861
18,688
webforge-labs/psc-cms
lib/Psc/Form/Validator.php
Validator.validate
public function validate($field, $data = NULL, $flags = 0x000000) { $key = $this->getKey($field); if (isset($this->dataProvider)) { $data = $this->dataProvider->getValidatorData($field); } if ($this->hasField($field)) { try { foreach ($this->rules[$key] as $rule) { $data = $rule->validate($data); // wenn wir hier data zurückgeben, können wir die rules chainen } } catch (EmptyDataException $e) { if (($flags & self::OPTIONAL) == self::OPTIONAL || $this->isOptional($field)) { return $e->getDefaultValue(); } else { if ($e->getMessage() == NULL) { $e->setMessage(sprintf($this->standardEmptyMessage,$this->getKey($field))); } throw $this->convertToValidatorException($e, $field, $data); } } catch (\Exception $e) { throw $this->convertToValidatorException($e, $field, $data); } } else { throw new \Psc\Exception('Feld: '.Code::varInfo($field).' ist dem Validator nicht bekannt.'); } return $data; }
php
public function validate($field, $data = NULL, $flags = 0x000000) { $key = $this->getKey($field); if (isset($this->dataProvider)) { $data = $this->dataProvider->getValidatorData($field); } if ($this->hasField($field)) { try { foreach ($this->rules[$key] as $rule) { $data = $rule->validate($data); // wenn wir hier data zurückgeben, können wir die rules chainen } } catch (EmptyDataException $e) { if (($flags & self::OPTIONAL) == self::OPTIONAL || $this->isOptional($field)) { return $e->getDefaultValue(); } else { if ($e->getMessage() == NULL) { $e->setMessage(sprintf($this->standardEmptyMessage,$this->getKey($field))); } throw $this->convertToValidatorException($e, $field, $data); } } catch (\Exception $e) { throw $this->convertToValidatorException($e, $field, $data); } } else { throw new \Psc\Exception('Feld: '.Code::varInfo($field).' ist dem Validator nicht bekannt.'); } return $data; }
[ "public", "function", "validate", "(", "$", "field", ",", "$", "data", "=", "NULL", ",", "$", "flags", "=", "0x000000", ")", "{", "$", "key", "=", "$", "this", "->", "getKey", "(", "$", "field", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "dataProvider", ")", ")", "{", "$", "data", "=", "$", "this", "->", "dataProvider", "->", "getValidatorData", "(", "$", "field", ")", ";", "}", "if", "(", "$", "this", "->", "hasField", "(", "$", "field", ")", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "rules", "[", "$", "key", "]", "as", "$", "rule", ")", "{", "$", "data", "=", "$", "rule", "->", "validate", "(", "$", "data", ")", ";", "// wenn wir hier data zurückgeben, können wir die rules chainen", "}", "}", "catch", "(", "EmptyDataException", "$", "e", ")", "{", "if", "(", "(", "$", "flags", "&", "self", "::", "OPTIONAL", ")", "==", "self", "::", "OPTIONAL", "||", "$", "this", "->", "isOptional", "(", "$", "field", ")", ")", "{", "return", "$", "e", "->", "getDefaultValue", "(", ")", ";", "}", "else", "{", "if", "(", "$", "e", "->", "getMessage", "(", ")", "==", "NULL", ")", "{", "$", "e", "->", "setMessage", "(", "sprintf", "(", "$", "this", "->", "standardEmptyMessage", ",", "$", "this", "->", "getKey", "(", "$", "field", ")", ")", ")", ";", "}", "throw", "$", "this", "->", "convertToValidatorException", "(", "$", "e", ",", "$", "field", ",", "$", "data", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "$", "this", "->", "convertToValidatorException", "(", "$", "e", ",", "$", "field", ",", "$", "data", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "Psc", "\\", "Exception", "(", "'Feld: '", ".", "Code", "::", "varInfo", "(", "$", "field", ")", ".", "' ist dem Validator nicht bekannt.'", ")", ";", "}", "return", "$", "data", ";", "}" ]
Validiert die Daten zu einem Feld gibt die Daten zurück! Wenn das Feld nicht validiert werden, wird eine Exception geworfen! @throws ValidatorException wenn die Daten nicht zum Feld passen ist $flags OPTIONAL gesetzt und wird die Rule eine EmptyDataException werfen, wird der DefaultWert (normal: NULL) der Exception zurückgegeben wenn $this->dataProvider gesetzt ist, wird IMMER $this->dataProvider->getValidatorData() benutzt und nicht der $data Parameter
[ "Validiert", "die", "Daten", "zu", "einem", "Feld" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Form/Validator.php#L53-L89
18,689
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setLightAmbientColor
public function setLightAmbientColor($red, $green, $blue) { $this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setLightAmbientColor($red, $green, $blue) { $this->lightAmbientColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setLightAmbientColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "lightAmbientColor", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the ambient color in which elements reflect the light @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "ambient", "color", "in", "which", "elements", "reflect", "the", "light" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L117-L121
18,690
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setCloudsMinimumColor
public function setCloudsMinimumColor($red, $green, $blue) { $this->cloudsMinimumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setCloudsMinimumColor($red, $green, $blue) { $this->cloudsMinimumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setCloudsMinimumColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "cloudsMinimumColor", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the minimum value for the background color range @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "minimum", "value", "for", "the", "background", "color", "range" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L143-L147
18,691
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setCloudsMaximumColor
public function setCloudsMaximumColor($red, $green, $blue) { $this->cloudsMaximumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setCloudsMaximumColor($red, $green, $blue) { $this->cloudsMaximumColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setCloudsMaximumColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "cloudsMaximumColor", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the maximum value for the background color range @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "maximum", "value", "for", "the", "background", "color", "range" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L169-L173
18,692
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setLight0Color
public function setLight0Color($red, $green, $blue) { $this->light0Color = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setLight0Color($red, $green, $blue) { $this->light0Color = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setLight0Color", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "light0Color", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the RGB color of light source 0 @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "RGB", "color", "of", "light", "source", "0" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L195-L199
18,693
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setLightBallColor
public function setLightBallColor($red, $green, $blue) { $this->lightBallColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setLightBallColor($red, $green, $blue) { $this->lightBallColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setLightBallColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "lightBallColor", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the light ball color @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "light", "ball", "color" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L293-L297
18,694
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setFogColor
public function setFogColor($red, $green, $blue) { $this->fogColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setFogColor($red, $green, $blue) { $this->fogColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setFogColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "fogColor", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the fog color @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "fog", "color" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L367-L371
18,695
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.setSelfIlluminationColor
public function setSelfIlluminationColor($red, $green, $blue) { $this->selfIlluminationColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
php
public function setSelfIlluminationColor($red, $green, $blue) { $this->selfIlluminationColor = floatval($red) . ' ' . floatval($green) . ' ' . floatval($blue); return $this; }
[ "public", "function", "setSelfIlluminationColor", "(", "$", "red", ",", "$", "green", ",", "$", "blue", ")", "{", "$", "this", "->", "selfIlluminationColor", "=", "floatval", "(", "$", "red", ")", ".", "' '", ".", "floatval", "(", "$", "green", ")", ".", "' '", ".", "floatval", "(", "$", "blue", ")", ";", "return", "$", "this", ";", "}" ]
Set the self illumination color @api @param float $red Red color value @param float $green Green color value @param float $blue Blue color value @return static
[ "Set", "the", "self", "illumination", "color" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L393-L397
18,696
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.addSkyGradient
public function addSkyGradient($x, $color) { $skyGradientKey = new SkyGradientKey($x, $color); return $this->addSkyGradientKey($skyGradientKey); }
php
public function addSkyGradient($x, $color) { $skyGradientKey = new SkyGradientKey($x, $color); return $this->addSkyGradientKey($skyGradientKey); }
[ "public", "function", "addSkyGradient", "(", "$", "x", ",", "$", "color", ")", "{", "$", "skyGradientKey", "=", "new", "SkyGradientKey", "(", "$", "x", ",", "$", "color", ")", ";", "return", "$", "this", "->", "addSkyGradientKey", "(", "$", "skyGradientKey", ")", ";", "}" ]
Add a sky gradient @api @param float $x X value @param string $color Color value @return static
[ "Add", "a", "sky", "gradient" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L455-L459
18,697
steeffeen/FancyManiaLinks
FML/Stylesheet/Mood.php
Mood.render
public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("mood"); if ($this->lightAmbientColor) { $domElement->setAttribute("LAmbient_LinearRgb", $this->lightAmbientColor); } if ($this->cloudsMinimumColor) { $domElement->setAttribute("CloudsRgbMinLinear", $this->cloudsMinimumColor); } if ($this->cloudsMaximumColor) { $domElement->setAttribute("CloudsRgbMaxLinear", $this->cloudsMaximumColor); } if ($this->light0Color) { $domElement->setAttribute("LDir0_LinearRgb", $this->light0Color); } if ($this->light0Intensity != 1.) { $domElement->setAttribute("LDir0_Intens", $this->light0Intensity); } if ($this->light0PhiAngle) { $domElement->setAttribute("LDir0_DirPhi", $this->light0PhiAngle); } if ($this->light0ThetaAngle) { $domElement->setAttribute("LDir0_DirTheta", $this->light0ThetaAngle); } if ($this->lightBallColor) { $domElement->setAttribute("LBall_LinearRgb", $this->lightBallColor); } if ($this->lightBallIntensity != 1.) { $domElement->setAttribute("LBall_Intens", $this->lightBallIntensity); } if ($this->lightBallRadius) { $domElement->setAttribute("LBall_Radius", $this->lightBallRadius); } if ($this->fogColor) { $domElement->setAttribute("FogColorSrgb", $this->fogColor); } if ($this->selfIlluminationColor) { $domElement->setAttribute("SelfIllumColor", $this->selfIlluminationColor); } if ($this->skyGradientScale != 1.) { $domElement->setAttribute("SkyGradientV_Scale", $this->skyGradientScale); } if ($this->skyGradientKeys) { $skyGradientElement = $domDocument->createElement("skygradient"); $domElement->appendChild($skyGradientElement); foreach ($this->skyGradientKeys as $skyGradientKey) { $skyGradientKeyElement = $skyGradientKey->render($domDocument); $skyGradientElement->appendChild($skyGradientKeyElement); } } return $domElement; }
php
public function render(\DOMDocument $domDocument) { $domElement = $domDocument->createElement("mood"); if ($this->lightAmbientColor) { $domElement->setAttribute("LAmbient_LinearRgb", $this->lightAmbientColor); } if ($this->cloudsMinimumColor) { $domElement->setAttribute("CloudsRgbMinLinear", $this->cloudsMinimumColor); } if ($this->cloudsMaximumColor) { $domElement->setAttribute("CloudsRgbMaxLinear", $this->cloudsMaximumColor); } if ($this->light0Color) { $domElement->setAttribute("LDir0_LinearRgb", $this->light0Color); } if ($this->light0Intensity != 1.) { $domElement->setAttribute("LDir0_Intens", $this->light0Intensity); } if ($this->light0PhiAngle) { $domElement->setAttribute("LDir0_DirPhi", $this->light0PhiAngle); } if ($this->light0ThetaAngle) { $domElement->setAttribute("LDir0_DirTheta", $this->light0ThetaAngle); } if ($this->lightBallColor) { $domElement->setAttribute("LBall_LinearRgb", $this->lightBallColor); } if ($this->lightBallIntensity != 1.) { $domElement->setAttribute("LBall_Intens", $this->lightBallIntensity); } if ($this->lightBallRadius) { $domElement->setAttribute("LBall_Radius", $this->lightBallRadius); } if ($this->fogColor) { $domElement->setAttribute("FogColorSrgb", $this->fogColor); } if ($this->selfIlluminationColor) { $domElement->setAttribute("SelfIllumColor", $this->selfIlluminationColor); } if ($this->skyGradientScale != 1.) { $domElement->setAttribute("SkyGradientV_Scale", $this->skyGradientScale); } if ($this->skyGradientKeys) { $skyGradientElement = $domDocument->createElement("skygradient"); $domElement->appendChild($skyGradientElement); foreach ($this->skyGradientKeys as $skyGradientKey) { $skyGradientKeyElement = $skyGradientKey->render($domDocument); $skyGradientElement->appendChild($skyGradientKeyElement); } } return $domElement; }
[ "public", "function", "render", "(", "\\", "DOMDocument", "$", "domDocument", ")", "{", "$", "domElement", "=", "$", "domDocument", "->", "createElement", "(", "\"mood\"", ")", ";", "if", "(", "$", "this", "->", "lightAmbientColor", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LAmbient_LinearRgb\"", ",", "$", "this", "->", "lightAmbientColor", ")", ";", "}", "if", "(", "$", "this", "->", "cloudsMinimumColor", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"CloudsRgbMinLinear\"", ",", "$", "this", "->", "cloudsMinimumColor", ")", ";", "}", "if", "(", "$", "this", "->", "cloudsMaximumColor", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"CloudsRgbMaxLinear\"", ",", "$", "this", "->", "cloudsMaximumColor", ")", ";", "}", "if", "(", "$", "this", "->", "light0Color", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LDir0_LinearRgb\"", ",", "$", "this", "->", "light0Color", ")", ";", "}", "if", "(", "$", "this", "->", "light0Intensity", "!=", "1.", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LDir0_Intens\"", ",", "$", "this", "->", "light0Intensity", ")", ";", "}", "if", "(", "$", "this", "->", "light0PhiAngle", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LDir0_DirPhi\"", ",", "$", "this", "->", "light0PhiAngle", ")", ";", "}", "if", "(", "$", "this", "->", "light0ThetaAngle", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LDir0_DirTheta\"", ",", "$", "this", "->", "light0ThetaAngle", ")", ";", "}", "if", "(", "$", "this", "->", "lightBallColor", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LBall_LinearRgb\"", ",", "$", "this", "->", "lightBallColor", ")", ";", "}", "if", "(", "$", "this", "->", "lightBallIntensity", "!=", "1.", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LBall_Intens\"", ",", "$", "this", "->", "lightBallIntensity", ")", ";", "}", "if", "(", "$", "this", "->", "lightBallRadius", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"LBall_Radius\"", ",", "$", "this", "->", "lightBallRadius", ")", ";", "}", "if", "(", "$", "this", "->", "fogColor", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"FogColorSrgb\"", ",", "$", "this", "->", "fogColor", ")", ";", "}", "if", "(", "$", "this", "->", "selfIlluminationColor", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"SelfIllumColor\"", ",", "$", "this", "->", "selfIlluminationColor", ")", ";", "}", "if", "(", "$", "this", "->", "skyGradientScale", "!=", "1.", ")", "{", "$", "domElement", "->", "setAttribute", "(", "\"SkyGradientV_Scale\"", ",", "$", "this", "->", "skyGradientScale", ")", ";", "}", "if", "(", "$", "this", "->", "skyGradientKeys", ")", "{", "$", "skyGradientElement", "=", "$", "domDocument", "->", "createElement", "(", "\"skygradient\"", ")", ";", "$", "domElement", "->", "appendChild", "(", "$", "skyGradientElement", ")", ";", "foreach", "(", "$", "this", "->", "skyGradientKeys", "as", "$", "skyGradientKey", ")", "{", "$", "skyGradientKeyElement", "=", "$", "skyGradientKey", "->", "render", "(", "$", "domDocument", ")", ";", "$", "skyGradientElement", "->", "appendChild", "(", "$", "skyGradientKeyElement", ")", ";", "}", "}", "return", "$", "domElement", ";", "}" ]
Render the Mood @param \DOMDocument $domDocument DOMDocument for which the Mood should be rendered @return \DOMElement
[ "Render", "the", "Mood" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Stylesheet/Mood.php#L479-L530
18,698
left-right/center
src/controllers/RowController.php
RowController.store
public function store($table) { $table = config('center.tables.' . $table); # Security if (!isset($table->name)) { return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.table_does_not_exist')); } $inserts = self::processColumnsInput($table); /*validate $v = Validator::make(Request::all(), [ 'email' => 'required|unique:users|max:255', ]); if ($v->fails()) { return redirect()->back()->withInput()->withErrors($v->errors()); }*/ //if users table, sent invitation if ($table->name == config('center.db.users')) { $password = Str::random(12); $inserts['password'] = Hash::make($password); $email = $inserts['email']; $link = action('\LeftRight\Center\Controllers\TableController@index'); Mail::send('center::emails.welcome', ['email'=>$email, 'password'=>$password, 'link'=>$link], function($message) use ($email) { $message->to($email)->subject(trans('center::site.welcome_email_subject')); }); } //run insert try { $row_id = DB::table($table->name)->insertGetId($inserts); } catch (Exception $e) { return redirect()->back()->withInput()->with('error', $e->getMessage()); } //handle any checkboxes, had to wait for row_id self::processRelationsInput($table, $row_id); //clean up any abandoned files FileController::cleanup(); //return to last line in stack or object index return redirect(Trail::last(action('\LeftRight\Center\Controllers\RowController@index', $table->name))); }
php
public function store($table) { $table = config('center.tables.' . $table); # Security if (!isset($table->name)) { return redirect()->action('\LeftRight\Center\Controllers\TableController@index')->with('error', trans('center::site.table_does_not_exist')); } $inserts = self::processColumnsInput($table); /*validate $v = Validator::make(Request::all(), [ 'email' => 'required|unique:users|max:255', ]); if ($v->fails()) { return redirect()->back()->withInput()->withErrors($v->errors()); }*/ //if users table, sent invitation if ($table->name == config('center.db.users')) { $password = Str::random(12); $inserts['password'] = Hash::make($password); $email = $inserts['email']; $link = action('\LeftRight\Center\Controllers\TableController@index'); Mail::send('center::emails.welcome', ['email'=>$email, 'password'=>$password, 'link'=>$link], function($message) use ($email) { $message->to($email)->subject(trans('center::site.welcome_email_subject')); }); } //run insert try { $row_id = DB::table($table->name)->insertGetId($inserts); } catch (Exception $e) { return redirect()->back()->withInput()->with('error', $e->getMessage()); } //handle any checkboxes, had to wait for row_id self::processRelationsInput($table, $row_id); //clean up any abandoned files FileController::cleanup(); //return to last line in stack or object index return redirect(Trail::last(action('\LeftRight\Center\Controllers\RowController@index', $table->name))); }
[ "public", "function", "store", "(", "$", "table", ")", "{", "$", "table", "=", "config", "(", "'center.tables.'", ".", "$", "table", ")", ";", "# Security", "if", "(", "!", "isset", "(", "$", "table", "->", "name", ")", ")", "{", "return", "redirect", "(", ")", "->", "action", "(", "'\\LeftRight\\Center\\Controllers\\TableController@index'", ")", "->", "with", "(", "'error'", ",", "trans", "(", "'center::site.table_does_not_exist'", ")", ")", ";", "}", "$", "inserts", "=", "self", "::", "processColumnsInput", "(", "$", "table", ")", ";", "/*validate\n\t\t$v = Validator::make(Request::all(), [\n\t\t 'email' => 'required|unique:users|max:255',\n\t\t]);\n\t\t\n\t\tif ($v->fails()) {\n\t\t return redirect()->back()->withInput()->withErrors($v->errors());\n\t\t}*/", "//if users table, sent invitation", "if", "(", "$", "table", "->", "name", "==", "config", "(", "'center.db.users'", ")", ")", "{", "$", "password", "=", "Str", "::", "random", "(", "12", ")", ";", "$", "inserts", "[", "'password'", "]", "=", "Hash", "::", "make", "(", "$", "password", ")", ";", "$", "email", "=", "$", "inserts", "[", "'email'", "]", ";", "$", "link", "=", "action", "(", "'\\LeftRight\\Center\\Controllers\\TableController@index'", ")", ";", "Mail", "::", "send", "(", "'center::emails.welcome'", ",", "[", "'email'", "=>", "$", "email", ",", "'password'", "=>", "$", "password", ",", "'link'", "=>", "$", "link", "]", ",", "function", "(", "$", "message", ")", "use", "(", "$", "email", ")", "{", "$", "message", "->", "to", "(", "$", "email", ")", "->", "subject", "(", "trans", "(", "'center::site.welcome_email_subject'", ")", ")", ";", "}", ")", ";", "}", "//run insert", "try", "{", "$", "row_id", "=", "DB", "::", "table", "(", "$", "table", "->", "name", ")", "->", "insertGetId", "(", "$", "inserts", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "redirect", "(", ")", "->", "back", "(", ")", "->", "withInput", "(", ")", "->", "with", "(", "'error'", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "//handle any checkboxes, had to wait for row_id", "self", "::", "processRelationsInput", "(", "$", "table", ",", "$", "row_id", ")", ";", "//clean up any abandoned files", "FileController", "::", "cleanup", "(", ")", ";", "//return to last line in stack or object index", "return", "redirect", "(", "Trail", "::", "last", "(", "action", "(", "'\\LeftRight\\Center\\Controllers\\RowController@index'", ",", "$", "table", "->", "name", ")", ")", ")", ";", "}" ]
save a new object instance to the database
[ "save", "a", "new", "object", "instance", "to", "the", "database" ]
47c225538475ca3e87fa49f31a323b6e6bd4eff2
https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/controllers/RowController.php#L268-L313
18,699
left-right/center
src/controllers/RowController.php
RowController.listColumn
public static function listColumn($table) { if (is_string($table)) $table = config('center.tables.' . $table); $fields = !empty($table->list) ? $table->list : array_keys((array) $table->fields); foreach ($fields as $field) { if ($table->fields->{$field}->type == 'string') return $field; } }
php
public static function listColumn($table) { if (is_string($table)) $table = config('center.tables.' . $table); $fields = !empty($table->list) ? $table->list : array_keys((array) $table->fields); foreach ($fields as $field) { if ($table->fields->{$field}->type == 'string') return $field; } }
[ "public", "static", "function", "listColumn", "(", "$", "table", ")", "{", "if", "(", "is_string", "(", "$", "table", ")", ")", "$", "table", "=", "config", "(", "'center.tables.'", ".", "$", "table", ")", ";", "$", "fields", "=", "!", "empty", "(", "$", "table", "->", "list", ")", "?", "$", "table", "->", "list", ":", "array_keys", "(", "(", "array", ")", "$", "table", "->", "fields", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "if", "(", "$", "table", "->", "fields", "->", "{", "$", "field", "}", "->", "type", "==", "'string'", ")", "return", "$", "field", ";", "}", "}" ]
get the first text field column name
[ "get", "the", "first", "text", "field", "column", "name" ]
47c225538475ca3e87fa49f31a323b6e6bd4eff2
https://github.com/left-right/center/blob/47c225538475ca3e87fa49f31a323b6e6bd4eff2/src/controllers/RowController.php#L705-L711