repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
xicrow/php-debug
src/Debugger.php
Debugger.getDebugInformation
public static function getDebugInformation($data, array $options = []) { // Merge options with default options $options = array_merge([ 'depth' => 25, 'indent' => 0, ], $options); // Get data type $dataType = gettype($data); // Set name of method to get debug information for data $methodName = 'getDebugInformation' . ucfirst(strtolower($dataType)); // Get result from debug information method $result = 'No method found supporting data type: ' . $dataType; if (method_exists('\Xicrow\PhpDebug\Debugger', $methodName)) { $result = (string)self::$methodName($data, [ 'depth' => ($options['depth'] - 1), 'indent' => ($options['indent'] + 1), ]); } // Format the result if (php_sapi_name() != 'cli' && !empty(self::$style['debug_' . strtolower($dataType) . '_format'])) { $result = sprintf(self::$style['debug_' . strtolower($dataType) . '_format'], $result); } // Return result return $result; }
php
public static function getDebugInformation($data, array $options = []) { // Merge options with default options $options = array_merge([ 'depth' => 25, 'indent' => 0, ], $options); // Get data type $dataType = gettype($data); // Set name of method to get debug information for data $methodName = 'getDebugInformation' . ucfirst(strtolower($dataType)); // Get result from debug information method $result = 'No method found supporting data type: ' . $dataType; if (method_exists('\Xicrow\PhpDebug\Debugger', $methodName)) { $result = (string)self::$methodName($data, [ 'depth' => ($options['depth'] - 1), 'indent' => ($options['indent'] + 1), ]); } // Format the result if (php_sapi_name() != 'cli' && !empty(self::$style['debug_' . strtolower($dataType) . '_format'])) { $result = sprintf(self::$style['debug_' . strtolower($dataType) . '_format'], $result); } // Return result return $result; }
[ "public", "static", "function", "getDebugInformation", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Merge options with default options", "$", "options", "=", "array_merge", "(", "[", "'depth'", "=>", "25", ",", "'indent'", "=>", "0", ",", "]", ",", "$", "options", ")", ";", "// Get data type", "$", "dataType", "=", "gettype", "(", "$", "data", ")", ";", "// Set name of method to get debug information for data", "$", "methodName", "=", "'getDebugInformation'", ".", "ucfirst", "(", "strtolower", "(", "$", "dataType", ")", ")", ";", "// Get result from debug information method", "$", "result", "=", "'No method found supporting data type: '", ".", "$", "dataType", ";", "if", "(", "method_exists", "(", "'\\Xicrow\\PhpDebug\\Debugger'", ",", "$", "methodName", ")", ")", "{", "$", "result", "=", "(", "string", ")", "self", "::", "$", "methodName", "(", "$", "data", ",", "[", "'depth'", "=>", "(", "$", "options", "[", "'depth'", "]", "-", "1", ")", ",", "'indent'", "=>", "(", "$", "options", "[", "'indent'", "]", "+", "1", ")", ",", "]", ")", ";", "}", "// Format the result", "if", "(", "php_sapi_name", "(", ")", "!=", "'cli'", "&&", "!", "empty", "(", "self", "::", "$", "style", "[", "'debug_'", ".", "strtolower", "(", "$", "dataType", ")", ".", "'_format'", "]", ")", ")", "{", "$", "result", "=", "sprintf", "(", "self", "::", "$", "style", "[", "'debug_'", ".", "strtolower", "(", "$", "dataType", ")", ".", "'_format'", "]", ",", "$", "result", ")", ";", "}", "// Return result", "return", "$", "result", ";", "}" ]
@param mixed $data @return string
[ "@param", "mixed", "$data" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L304-L334
xicrow/php-debug
src/Debugger.php
Debugger.getDebugInformationArray
private static function getDebugInformationArray($data, array $options = []) { $options = array_merge([ 'depth' => 25, 'indent' => 0, ], $options); $debugInfo = "["; $break = $end = null; if (!empty($data)) { $break = "\n" . str_repeat("\t", $options['indent']); $end = "\n" . str_repeat("\t", $options['indent'] - 1); } $datas = []; if ($options['depth'] >= 0) { foreach ($data as $key => $val) { // Sniff for globals as !== explodes in < 5.4 if ($key === 'GLOBALS' && is_array($val) && isset($val['GLOBALS'])) { $val = '[recursion]'; } elseif ($val !== $data) { $val = static::getDebugInformation($val, $options); } $datas[] = $break . static::getDebugInformation($key) . ' => ' . $val; } } else { $datas[] = $break . '[maximum depth reached]'; } return $debugInfo . implode(',', $datas) . $end . ']'; }
php
private static function getDebugInformationArray($data, array $options = []) { $options = array_merge([ 'depth' => 25, 'indent' => 0, ], $options); $debugInfo = "["; $break = $end = null; if (!empty($data)) { $break = "\n" . str_repeat("\t", $options['indent']); $end = "\n" . str_repeat("\t", $options['indent'] - 1); } $datas = []; if ($options['depth'] >= 0) { foreach ($data as $key => $val) { // Sniff for globals as !== explodes in < 5.4 if ($key === 'GLOBALS' && is_array($val) && isset($val['GLOBALS'])) { $val = '[recursion]'; } elseif ($val !== $data) { $val = static::getDebugInformation($val, $options); } $datas[] = $break . static::getDebugInformation($key) . ' => ' . $val; } } else { $datas[] = $break . '[maximum depth reached]'; } return $debugInfo . implode(',', $datas) . $end . ']'; }
[ "private", "static", "function", "getDebugInformationArray", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'depth'", "=>", "25", ",", "'indent'", "=>", "0", ",", "]", ",", "$", "options", ")", ";", "$", "debugInfo", "=", "\"[\"", ";", "$", "break", "=", "$", "end", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "data", ")", ")", "{", "$", "break", "=", "\"\\n\"", ".", "str_repeat", "(", "\"\\t\"", ",", "$", "options", "[", "'indent'", "]", ")", ";", "$", "end", "=", "\"\\n\"", ".", "str_repeat", "(", "\"\\t\"", ",", "$", "options", "[", "'indent'", "]", "-", "1", ")", ";", "}", "$", "datas", "=", "[", "]", ";", "if", "(", "$", "options", "[", "'depth'", "]", ">=", "0", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "val", ")", "{", "// Sniff for globals as !== explodes in < 5.4", "if", "(", "$", "key", "===", "'GLOBALS'", "&&", "is_array", "(", "$", "val", ")", "&&", "isset", "(", "$", "val", "[", "'GLOBALS'", "]", ")", ")", "{", "$", "val", "=", "'[recursion]'", ";", "}", "elseif", "(", "$", "val", "!==", "$", "data", ")", "{", "$", "val", "=", "static", "::", "getDebugInformation", "(", "$", "val", ",", "$", "options", ")", ";", "}", "$", "datas", "[", "]", "=", "$", "break", ".", "static", "::", "getDebugInformation", "(", "$", "key", ")", ".", "' => '", ".", "$", "val", ";", "}", "}", "else", "{", "$", "datas", "[", "]", "=", "$", "break", ".", "'[maximum depth reached]'", ";", "}", "return", "$", "debugInfo", ".", "implode", "(", "','", ",", "$", "datas", ")", ".", "$", "end", ".", "']'", ";", "}" ]
@param array $data @return string
[ "@param", "array", "$data" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L387-L418
xicrow/php-debug
src/Debugger.php
Debugger.getDebugInformationObject
private static function getDebugInformationObject($data, array $options = []) { $options = array_merge([ 'depth' => 25, 'indent' => 0, ], $options); $debugInfo = ''; $debugInfo .= 'object(' . get_class($data) . ') {'; $break = "\n" . str_repeat("\t", $options['indent']); $end = "\n" . str_repeat("\t", $options['indent'] - 1); if ($options['depth'] > 0 && method_exists($data, '__debugInfo')) { try { $debugArray = static::getDebugInformationArray($data->__debugInfo(), array_merge($options, [ 'depth' => ($options['depth'] - 1), ])); $debugInfo .= substr($debugArray, 1, -1); return $debugInfo . $end . '}'; } catch (\Exception $e) { $message = $e->getMessage(); return $debugInfo . "\n(unable to export object: $message)\n }"; } } if ($options['depth'] > 0) { $props = []; $objectVars = get_object_vars($data); foreach ($objectVars as $key => $value) { $value = static::getDebugInformation($value, array_merge($options, [ 'depth' => ($options['depth'] - 1), ])); $props[] = "$key => " . $value; } $ref = new \ReflectionObject($data); $filters = [ \ReflectionProperty::IS_PROTECTED => 'protected', \ReflectionProperty::IS_PRIVATE => 'private', ]; foreach ($filters as $filter => $visibility) { $reflectionProperties = $ref->getProperties($filter); foreach ($reflectionProperties as $reflectionProperty) { $reflectionProperty->setAccessible(true); $property = $reflectionProperty->getValue($data); $value = static::getDebugInformation($property, array_merge($options, [ 'depth' => ($options['depth'] - 1), ])); $key = $reflectionProperty->name; $props[] = sprintf('[%s] %s => %s', $visibility, $key, $value); } } $debugInfo .= $break . implode($break, $props) . $end; } $debugInfo .= '}'; return $debugInfo; }
php
private static function getDebugInformationObject($data, array $options = []) { $options = array_merge([ 'depth' => 25, 'indent' => 0, ], $options); $debugInfo = ''; $debugInfo .= 'object(' . get_class($data) . ') {'; $break = "\n" . str_repeat("\t", $options['indent']); $end = "\n" . str_repeat("\t", $options['indent'] - 1); if ($options['depth'] > 0 && method_exists($data, '__debugInfo')) { try { $debugArray = static::getDebugInformationArray($data->__debugInfo(), array_merge($options, [ 'depth' => ($options['depth'] - 1), ])); $debugInfo .= substr($debugArray, 1, -1); return $debugInfo . $end . '}'; } catch (\Exception $e) { $message = $e->getMessage(); return $debugInfo . "\n(unable to export object: $message)\n }"; } } if ($options['depth'] > 0) { $props = []; $objectVars = get_object_vars($data); foreach ($objectVars as $key => $value) { $value = static::getDebugInformation($value, array_merge($options, [ 'depth' => ($options['depth'] - 1), ])); $props[] = "$key => " . $value; } $ref = new \ReflectionObject($data); $filters = [ \ReflectionProperty::IS_PROTECTED => 'protected', \ReflectionProperty::IS_PRIVATE => 'private', ]; foreach ($filters as $filter => $visibility) { $reflectionProperties = $ref->getProperties($filter); foreach ($reflectionProperties as $reflectionProperty) { $reflectionProperty->setAccessible(true); $property = $reflectionProperty->getValue($data); $value = static::getDebugInformation($property, array_merge($options, [ 'depth' => ($options['depth'] - 1), ])); $key = $reflectionProperty->name; $props[] = sprintf('[%s] %s => %s', $visibility, $key, $value); } } $debugInfo .= $break . implode($break, $props) . $end; } $debugInfo .= '}'; return $debugInfo; }
[ "private", "static", "function", "getDebugInformationObject", "(", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'depth'", "=>", "25", ",", "'indent'", "=>", "0", ",", "]", ",", "$", "options", ")", ";", "$", "debugInfo", "=", "''", ";", "$", "debugInfo", ".=", "'object('", ".", "get_class", "(", "$", "data", ")", ".", "') {'", ";", "$", "break", "=", "\"\\n\"", ".", "str_repeat", "(", "\"\\t\"", ",", "$", "options", "[", "'indent'", "]", ")", ";", "$", "end", "=", "\"\\n\"", ".", "str_repeat", "(", "\"\\t\"", ",", "$", "options", "[", "'indent'", "]", "-", "1", ")", ";", "if", "(", "$", "options", "[", "'depth'", "]", ">", "0", "&&", "method_exists", "(", "$", "data", ",", "'__debugInfo'", ")", ")", "{", "try", "{", "$", "debugArray", "=", "static", "::", "getDebugInformationArray", "(", "$", "data", "->", "__debugInfo", "(", ")", ",", "array_merge", "(", "$", "options", ",", "[", "'depth'", "=>", "(", "$", "options", "[", "'depth'", "]", "-", "1", ")", ",", "]", ")", ")", ";", "$", "debugInfo", ".=", "substr", "(", "$", "debugArray", ",", "1", ",", "-", "1", ")", ";", "return", "$", "debugInfo", ".", "$", "end", ".", "'}'", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "return", "$", "debugInfo", ".", "\"\\n(unable to export object: $message)\\n }\"", ";", "}", "}", "if", "(", "$", "options", "[", "'depth'", "]", ">", "0", ")", "{", "$", "props", "=", "[", "]", ";", "$", "objectVars", "=", "get_object_vars", "(", "$", "data", ")", ";", "foreach", "(", "$", "objectVars", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "value", "=", "static", "::", "getDebugInformation", "(", "$", "value", ",", "array_merge", "(", "$", "options", ",", "[", "'depth'", "=>", "(", "$", "options", "[", "'depth'", "]", "-", "1", ")", ",", "]", ")", ")", ";", "$", "props", "[", "]", "=", "\"$key => \"", ".", "$", "value", ";", "}", "$", "ref", "=", "new", "\\", "ReflectionObject", "(", "$", "data", ")", ";", "$", "filters", "=", "[", "\\", "ReflectionProperty", "::", "IS_PROTECTED", "=>", "'protected'", ",", "\\", "ReflectionProperty", "::", "IS_PRIVATE", "=>", "'private'", ",", "]", ";", "foreach", "(", "$", "filters", "as", "$", "filter", "=>", "$", "visibility", ")", "{", "$", "reflectionProperties", "=", "$", "ref", "->", "getProperties", "(", "$", "filter", ")", ";", "foreach", "(", "$", "reflectionProperties", "as", "$", "reflectionProperty", ")", "{", "$", "reflectionProperty", "->", "setAccessible", "(", "true", ")", ";", "$", "property", "=", "$", "reflectionProperty", "->", "getValue", "(", "$", "data", ")", ";", "$", "value", "=", "static", "::", "getDebugInformation", "(", "$", "property", ",", "array_merge", "(", "$", "options", ",", "[", "'depth'", "=>", "(", "$", "options", "[", "'depth'", "]", "-", "1", ")", ",", "]", ")", ")", ";", "$", "key", "=", "$", "reflectionProperty", "->", "name", ";", "$", "props", "[", "]", "=", "sprintf", "(", "'[%s] %s => %s'", ",", "$", "visibility", ",", "$", "key", ",", "$", "value", ")", ";", "}", "}", "$", "debugInfo", ".=", "$", "break", ".", "implode", "(", "$", "break", ",", "$", "props", ")", ".", "$", "end", ";", "}", "$", "debugInfo", ".=", "'}'", ";", "return", "$", "debugInfo", ";", "}" ]
@param object $data @return string
[ "@param", "object", "$data" ]
train
https://github.com/xicrow/php-debug/blob/b027be3249c0ce1a2a8d8ef50a05cd5805eaf45a/src/Debugger.php#L425-L487
webforge-labs/psc-cms
lib/Psc/Mail/Helper.php
Helper.recipient
public static function recipient($recipient) { if (is_string($recipient)) return $recipient; if (is_array($recipient)) return $recipient; // @TODO checks? throw new Exception('Unbekannter Parameter: '.Code::varInfo($recipient)); }
php
public static function recipient($recipient) { if (is_string($recipient)) return $recipient; if (is_array($recipient)) return $recipient; // @TODO checks? throw new Exception('Unbekannter Parameter: '.Code::varInfo($recipient)); }
[ "public", "static", "function", "recipient", "(", "$", "recipient", ")", "{", "if", "(", "is_string", "(", "$", "recipient", ")", ")", "return", "$", "recipient", ";", "if", "(", "is_array", "(", "$", "recipient", ")", ")", "return", "$", "recipient", ";", "// @TODO checks?", "throw", "new", "Exception", "(", "'Unbekannter Parameter: '", ".", "Code", "::", "varInfo", "(", "$", "recipient", ")", ")", ";", "}" ]
$message->setTo(self::recipient('[email protected]')); @return korrektes Format für Message::set(From|To|Bcc|Cc)
[ "$message", "-", ">", "setTo", "(", "self", "::", "recipient", "(", "p", ".", "scheit@ps", "-", "webforge", ".", "com", "))", ";" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Mail/Helper.php#L69-L74
webforge-labs/psc-cms
lib/Psc/Mail/Helper.php
Helper.from
public static function from($sender = NULL) { if (!isset($sender) && ($sender = Config::get('mail.from')) == NULL) { $sender = 'www@'.PSC::getEnvironment()->getHostName(); } return self::recipient($sender); }
php
public static function from($sender = NULL) { if (!isset($sender) && ($sender = Config::get('mail.from')) == NULL) { $sender = 'www@'.PSC::getEnvironment()->getHostName(); } return self::recipient($sender); }
[ "public", "static", "function", "from", "(", "$", "sender", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "sender", ")", "&&", "(", "$", "sender", "=", "Config", "::", "get", "(", "'mail.from'", ")", ")", "==", "NULL", ")", "{", "$", "sender", "=", "'www@'", ".", "PSC", "::", "getEnvironment", "(", ")", "->", "getHostName", "(", ")", ";", "}", "return", "self", "::", "recipient", "(", "$", "sender", ")", ";", "}" ]
Erstellt "from" für eine Message Der $sender hat ein Default von Config[mail.from] wenn das nicht gestzt ist, wird www@host genommen
[ "Erstellt", "from", "für", "eine", "Message" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Mail/Helper.php#L82-L87
webforge-labs/psc-cms
lib/Psc/Mail/Helper.php
Helper.send
public static function send(Swift_Message $message, Swift_SmtpTransport $transport = NULL, Swift_Mailer $mailer = NULL) { if (!isset($transport) && !isset($mailer)) { if (Config::req('mail.smtp.user') != NULL) { $transport = Swift_SmtpTransport::newInstance('smtprelaypool.ispgateway.de',465, 'ssl') ->setUsername(Config::req('mail.smtp.user')) ->setPassword(Config::req('mail.smtp.password')); } else { $transport = Swift_Mailtransport::newInstance(); // lokaler mailer } } if (!isset($mailer)) { $mailer = \Swift_Mailer::newInstance($transport); } return $mailer->send($message); }
php
public static function send(Swift_Message $message, Swift_SmtpTransport $transport = NULL, Swift_Mailer $mailer = NULL) { if (!isset($transport) && !isset($mailer)) { if (Config::req('mail.smtp.user') != NULL) { $transport = Swift_SmtpTransport::newInstance('smtprelaypool.ispgateway.de',465, 'ssl') ->setUsername(Config::req('mail.smtp.user')) ->setPassword(Config::req('mail.smtp.password')); } else { $transport = Swift_Mailtransport::newInstance(); // lokaler mailer } } if (!isset($mailer)) { $mailer = \Swift_Mailer::newInstance($transport); } return $mailer->send($message); }
[ "public", "static", "function", "send", "(", "Swift_Message", "$", "message", ",", "Swift_SmtpTransport", "$", "transport", "=", "NULL", ",", "Swift_Mailer", "$", "mailer", "=", "NULL", ")", "{", "if", "(", "!", "isset", "(", "$", "transport", ")", "&&", "!", "isset", "(", "$", "mailer", ")", ")", "{", "if", "(", "Config", "::", "req", "(", "'mail.smtp.user'", ")", "!=", "NULL", ")", "{", "$", "transport", "=", "Swift_SmtpTransport", "::", "newInstance", "(", "'smtprelaypool.ispgateway.de'", ",", "465", ",", "'ssl'", ")", "->", "setUsername", "(", "Config", "::", "req", "(", "'mail.smtp.user'", ")", ")", "->", "setPassword", "(", "Config", "::", "req", "(", "'mail.smtp.password'", ")", ")", ";", "}", "else", "{", "$", "transport", "=", "Swift_Mailtransport", "::", "newInstance", "(", ")", ";", "// lokaler mailer", "}", "}", "if", "(", "!", "isset", "(", "$", "mailer", ")", ")", "{", "$", "mailer", "=", "\\", "Swift_Mailer", "::", "newInstance", "(", "$", "transport", ")", ";", "}", "return", "$", "mailer", "->", "send", "(", "$", "message", ")", ";", "}" ]
Sendet die Message Wird Transport und Mailer nicht angegeben, werden diese erstellt Ist ein Mailer angegeben wird transport nicht erstellt (wird ignoriert) wenn ein SMTP Zugang mit Config[mail.smtp.user] und Config[mail.smtp.password] gesetzt wurde, wird dieser als Transport genutzt ansonsten der lokale Mailer @return die Ausgabe von mailer->send() (int $sent)
[ "Sendet", "die", "Message" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Mail/Helper.php#L99-L116
webforge-labs/psc-cms
lib/Psc/System/System.php
System.which
public static function which($command, $flags = 0x000000) { $win = ($flags ^ self::FORCE_UNIX) && PSC::getEnvironment()->getOS() == Environment::WINDOWS; $locate = function ($cmd) use ($flags, $win) { $location = exec($cmd); if (mb_strlen($script = trim($location)) > 0) { if ($win && ($flags ^ \Psc\System\System::DONTQUOTE) && mb_strpos($script,' ')) return '"'.$script.'"'; else return $script; } throw new \Psc\System\Exception('CMD did not return'); }; if ($win) { foreach (Array( 'for %i in ('.$command.'.bat) do @echo. %~$PATH:i', 'for %i in ('.$command.'.exe) do @echo. %~$PATH:i' ) as $cmd) { try { return $locate($cmd); } catch (\Psc\System\Exception $e) { } } } else { /* UNIX */ $cmd = 'which '.$command; try { return $locate($cmd); } catch (\Psc\System\Exception $e) { } } //failure if ($flags & self::REQUIRED) { throw new Exception('Es konnte kein Pfad für Befehl: "'.$command.'" gefunden werden'); } else { return $command; } }
php
public static function which($command, $flags = 0x000000) { $win = ($flags ^ self::FORCE_UNIX) && PSC::getEnvironment()->getOS() == Environment::WINDOWS; $locate = function ($cmd) use ($flags, $win) { $location = exec($cmd); if (mb_strlen($script = trim($location)) > 0) { if ($win && ($flags ^ \Psc\System\System::DONTQUOTE) && mb_strpos($script,' ')) return '"'.$script.'"'; else return $script; } throw new \Psc\System\Exception('CMD did not return'); }; if ($win) { foreach (Array( 'for %i in ('.$command.'.bat) do @echo. %~$PATH:i', 'for %i in ('.$command.'.exe) do @echo. %~$PATH:i' ) as $cmd) { try { return $locate($cmd); } catch (\Psc\System\Exception $e) { } } } else { /* UNIX */ $cmd = 'which '.$command; try { return $locate($cmd); } catch (\Psc\System\Exception $e) { } } //failure if ($flags & self::REQUIRED) { throw new Exception('Es konnte kein Pfad für Befehl: "'.$command.'" gefunden werden'); } else { return $command; } }
[ "public", "static", "function", "which", "(", "$", "command", ",", "$", "flags", "=", "0x000000", ")", "{", "$", "win", "=", "(", "$", "flags", "^", "self", "::", "FORCE_UNIX", ")", "&&", "PSC", "::", "getEnvironment", "(", ")", "->", "getOS", "(", ")", "==", "Environment", "::", "WINDOWS", ";", "$", "locate", "=", "function", "(", "$", "cmd", ")", "use", "(", "$", "flags", ",", "$", "win", ")", "{", "$", "location", "=", "exec", "(", "$", "cmd", ")", ";", "if", "(", "mb_strlen", "(", "$", "script", "=", "trim", "(", "$", "location", ")", ")", ">", "0", ")", "{", "if", "(", "$", "win", "&&", "(", "$", "flags", "^", "\\", "Psc", "\\", "System", "\\", "System", "::", "DONTQUOTE", ")", "&&", "mb_strpos", "(", "$", "script", ",", "' '", ")", ")", "return", "'\"'", ".", "$", "script", ".", "'\"'", ";", "else", "return", "$", "script", ";", "}", "throw", "new", "\\", "Psc", "\\", "System", "\\", "Exception", "(", "'CMD did not return'", ")", ";", "}", ";", "if", "(", "$", "win", ")", "{", "foreach", "(", "Array", "(", "'for %i in ('", ".", "$", "command", ".", "'.bat) do @echo. %~$PATH:i'", ",", "'for %i in ('", ".", "$", "command", ".", "'.exe) do @echo. %~$PATH:i'", ")", "as", "$", "cmd", ")", "{", "try", "{", "return", "$", "locate", "(", "$", "cmd", ")", ";", "}", "catch", "(", "\\", "Psc", "\\", "System", "\\", "Exception", "$", "e", ")", "{", "}", "}", "}", "else", "{", "/* UNIX */", "$", "cmd", "=", "'which '", ".", "$", "command", ";", "try", "{", "return", "$", "locate", "(", "$", "cmd", ")", ";", "}", "catch", "(", "\\", "Psc", "\\", "System", "\\", "Exception", "$", "e", ")", "{", "}", "}", "//failure", "if", "(", "$", "flags", "&", "self", "::", "REQUIRED", ")", "{", "throw", "new", "Exception", "(", "'Es konnte kein Pfad für Befehl: \"'.", "$", "c", "ommand.", "'", "\" gefunden werden')", ";", "", "}", "else", "{", "return", "$", "command", ";", "}", "}" ]
Gibt den Ort kompletten Pfad zur ausführbaren Datei zurück Wird der Befehl nicht gefunden wird NULL zurückgegeben, ist das flag REQUIRED gesetzt, wird eine exception stattdessen geschmissen
[ "Gibt", "den", "Ort", "kompletten", "Pfad", "zur", "ausführbaren", "Datei", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/System.php#L26-L72
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.NotFound
public static function NotFound($body = NULL, \Exception $previous = NULL) { return self::code(404, $body, $previous); }
php
public static function NotFound($body = NULL, \Exception $previous = NULL) { return self::code(404, $body, $previous); }
[ "public", "static", "function", "NotFound", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "404", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
NotFound (404) The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is commonly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
[ "NotFound", "(", "404", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L40-L42
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.Unauthorized
public static function Unauthorized($body = NULL, \Exception $previous = NULL) { return self::code(401, $body, $previous); }
php
public static function Unauthorized($body = NULL, \Exception $previous = NULL) { return self::code(401, $body, $previous); }
[ "public", "static", "function", "Unauthorized", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "401", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
Unauthorized (401) The request requires user authentication. If the request already included Authorization credentials, then the 401 response indicates that authorization has been refused for those credentials.
[ "Unauthorized", "(", "401", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L50-L52
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.BadRequest
public static function BadRequest($body = NULL, \Exception $previous = NULL, Array $headers = array()) { return self::code(400, $body, $previous, $headers); }
php
public static function BadRequest($body = NULL, \Exception $previous = NULL, Array $headers = array()) { return self::code(400, $body, $previous, $headers); }
[ "public", "static", "function", "BadRequest", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ",", "Array", "$", "headers", "=", "array", "(", ")", ")", "{", "return", "self", "::", "code", "(", "400", ",", "$", "body", ",", "$", "previous", ",", "$", "headers", ")", ";", "}" ]
BadRequest (400) The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications. => used in Validation
[ "BadRequest", "(", "400", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L60-L62
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.Forbidden
public static function Forbidden($body = NULL, \Exception $previous = NULL) { return self::code(403, $body, $previous); }
php
public static function Forbidden($body = NULL, \Exception $previous = NULL) { return self::code(403, $body, $previous); }
[ "public", "static", "function", "Forbidden", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "403", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
Forbidden (403) The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.
[ "Forbidden", "(", "403", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L69-L71
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.MethodNotAllowed
public static function MethodNotAllowed($body = NULL, \Exception $previous = NULL) { return self::code(405, $body, $previous); }
php
public static function MethodNotAllowed($body = NULL, \Exception $previous = NULL) { return self::code(405, $body, $previous); }
[ "public", "static", "function", "MethodNotAllowed", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "405", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
MethodNotAllowed (405) The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
[ "MethodNotAllowed", "(", "405", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L78-L80
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.NotAcceptable
public static function NotAcceptable($body = NULL, \Exception $previous = NULL) { return self::code(406, $body, $previous); }
php
public static function NotAcceptable($body = NULL, \Exception $previous = NULL) { return self::code(406, $body, $previous); }
[ "public", "static", "function", "NotAcceptable", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "406", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
Not Acceptable (406) The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.
[ "Not", "Acceptable", "(", "406", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L87-L89
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.Conflict
public static function Conflict($body = NULL, \Exception $previous = NULL) { return self::code(409, $body, $previous); }
php
public static function Conflict($body = NULL, \Exception $previous = NULL) { return self::code(409, $body, $previous); }
[ "public", "static", "function", "Conflict", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "409", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
Conflict (409) The request could not be completed due to a conflict with the current state of the resource. This code is only allowed in situations where it is expected that the user might be able to resolve the conflict and resubmit the request. The response body SHOULD include enough information for the user to recognize the source of the conflict. Ideally, the response entity would include enough information for the user or user agent to fix the problem; however, that might not be possible and is not required. Conflicts are most likely to occur in response to a PUT request. For example, if versioning were being used and the entity being PUT included changes to a resource which conflict with those made by an earlier (third-party) request, the server might use the 409 response to indicate that it can't complete the request. In this case, the response entity would likely contain a list of the differences between the two versions in a format defined by the response Content-Type.
[ "Conflict", "(", "409", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L98-L100
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.UnsupportedMediaType
public static function UnsupportedMediaType($body = NULL, \Exception $previous = NULL) { return self::code(415, $body, $previous); }
php
public static function UnsupportedMediaType($body = NULL, \Exception $previous = NULL) { return self::code(415, $body, $previous); }
[ "public", "static", "function", "UnsupportedMediaType", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "415", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
Unsupported Media Type (415) The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
[ "Unsupported", "Media", "Type", "(", "415", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L107-L109
webforge-labs/psc-cms
lib/Psc/Net/HTTP/HTTPException.php
HTTPException.ServiceUnavaible
public static function ServiceUnavaible($body = NULL, \Exception $previous = NULL) { return self::code(503, $body, $previous); }
php
public static function ServiceUnavaible($body = NULL, \Exception $previous = NULL) { return self::code(503, $body, $previous); }
[ "public", "static", "function", "ServiceUnavaible", "(", "$", "body", "=", "NULL", ",", "\\", "Exception", "$", "previous", "=", "NULL", ")", "{", "return", "self", "::", "code", "(", "503", ",", "$", "body", ",", "$", "previous", ")", ";", "}" ]
Service Unavailable (503) The server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay. If known, the length of the delay MAY be indicated in a Retry-After header. If no Retry-After is given, the client SHOULD handle the response as it would for a 500 response. Note: The existence of the 503 status code does not imply that a server must use it when becoming overloaded. Some servers may wish to simply refuse the connection.
[ "Service", "Unavailable", "(", "503", ")" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/HTTP/HTTPException.php#L118-L120
parsnick/steak
src/Boot/RegisterBladeExtensions.php
RegisterBladeExtensions.boot
public function boot(Container $app) { $app->afterResolving(function (BladeCompiler $compiler, $app) { $this->allowHighlightTag($compiler); }); }
php
public function boot(Container $app) { $app->afterResolving(function (BladeCompiler $compiler, $app) { $this->allowHighlightTag($compiler); }); }
[ "public", "function", "boot", "(", "Container", "$", "app", ")", "{", "$", "app", "->", "afterResolving", "(", "function", "(", "BladeCompiler", "$", "compiler", ",", "$", "app", ")", "{", "$", "this", "->", "allowHighlightTag", "(", "$", "compiler", ")", ";", "}", ")", ";", "}" ]
Set up required container bindings. @param Container $app
[ "Set", "up", "required", "container", "bindings", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Boot/RegisterBladeExtensions.php#L15-L22
parsnick/steak
src/Boot/RegisterBladeExtensions.php
RegisterBladeExtensions.allowHighlightTag
protected function allowHighlightTag(BladeCompiler $compiler) { $compiler->directive('highlight', function ($expression) { if (is_null($expression)) { $expression = "('php')"; } return "<?php \$__env->startSection{$expression}; ?>"; }); $compiler->directive('endhighlight', function () { return <<<'HTML' <?php $last = $__env->stopSection(); echo '<pre><code class="language-', $last, '">', trim($__env->yieldContent($last)), '</code></pre>'; ?> HTML; }); }
php
protected function allowHighlightTag(BladeCompiler $compiler) { $compiler->directive('highlight', function ($expression) { if (is_null($expression)) { $expression = "('php')"; } return "<?php \$__env->startSection{$expression}; ?>"; }); $compiler->directive('endhighlight', function () { return <<<'HTML' <?php $last = $__env->stopSection(); echo '<pre><code class="language-', $last, '">', trim($__env->yieldContent($last)), '</code></pre>'; ?> HTML; }); }
[ "protected", "function", "allowHighlightTag", "(", "BladeCompiler", "$", "compiler", ")", "{", "$", "compiler", "->", "directive", "(", "'highlight'", ",", "function", "(", "$", "expression", ")", "{", "if", "(", "is_null", "(", "$", "expression", ")", ")", "{", "$", "expression", "=", "\"('php')\"", ";", "}", "return", "\"<?php \\$__env->startSection{$expression}; ?>\"", ";", "}", ")", ";", "$", "compiler", "->", "directive", "(", "'endhighlight'", ",", "function", "(", ")", "{", "return", " <<<'HTML'\n<?php $last = $__env->stopSection(); echo '<pre><code class=\"language-', $last, '\">', trim($__env->yieldContent($last)), '</code></pre>'; ?>\nHTML", ";", "}", ")", ";", "}" ]
Add basic syntax highlighting. This just adds markup that is picked up by a javascript highlighting library. @param BladeCompiler $compiler
[ "Add", "basic", "syntax", "highlighting", "." ]
train
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Boot/RegisterBladeExtensions.php#L31-L45
meccado/acl-admin-control-panel
src/Models/Admin/Role.php
Role.can
public function can($permission) { if (is_array($permission)) { return (!! (count($permission) == count(array_intersect($this->permissions()->pluck('name')->toarray(), $permission)))); } else { return in_array($permission, $this->permissions()->pluck('name')->toarray()); } }
php
public function can($permission) { if (is_array($permission)) { return (!! (count($permission) == count(array_intersect($this->permissions()->pluck('name')->toarray(), $permission)))); } else { return in_array($permission, $this->permissions()->pluck('name')->toarray()); } }
[ "public", "function", "can", "(", "$", "permission", ")", "{", "if", "(", "is_array", "(", "$", "permission", ")", ")", "{", "return", "(", "!", "!", "(", "count", "(", "$", "permission", ")", "==", "count", "(", "array_intersect", "(", "$", "this", "->", "permissions", "(", ")", "->", "pluck", "(", "'name'", ")", "->", "toarray", "(", ")", ",", "$", "permission", ")", ")", ")", ")", ";", "}", "else", "{", "return", "in_array", "(", "$", "permission", ",", "$", "this", "->", "permissions", "(", ")", "->", "pluck", "(", "'name'", ")", "->", "toarray", "(", ")", ")", ";", "}", "}" ]
Checks if the role has the given permission. @param string $permission @return bool
[ "Checks", "if", "the", "role", "has", "the", "given", "permission", "." ]
train
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Models/Admin/Role.php#L65-L72
yuncms/framework
src/behaviors/IpBehavior.php
IpBehavior.getValue
protected function getValue($event) { if ($this->value === null && Yii::$app instanceof Application) { $ip = Yii::$app->request->userIP; if ($ip === null) { return $this->getDefaultValue($event); } return $ip; } return parent::getValue($event); }
php
protected function getValue($event) { if ($this->value === null && Yii::$app instanceof Application) { $ip = Yii::$app->request->userIP; if ($ip === null) { return $this->getDefaultValue($event); } return $ip; } return parent::getValue($event); }
[ "protected", "function", "getValue", "(", "$", "event", ")", "{", "if", "(", "$", "this", "->", "value", "===", "null", "&&", "Yii", "::", "$", "app", "instanceof", "Application", ")", "{", "$", "ip", "=", "Yii", "::", "$", "app", "->", "request", "->", "userIP", ";", "if", "(", "$", "ip", "===", "null", ")", "{", "return", "$", "this", "->", "getDefaultValue", "(", "$", "event", ")", ";", "}", "return", "$", "ip", ";", "}", "return", "parent", "::", "getValue", "(", "$", "event", ")", ";", "}" ]
{@inheritdoc} In case, when the [[value]] property is `null`, the value of [[defaultValue]] will be used as the value.
[ "{", "@inheritdoc", "}" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/behaviors/IpBehavior.php#L66-L76
phpmob/changmin
src/PhpMob/CoreBundle/Validator/ReservedWordValidator.php
ReservedWordValidator.validate
public function validate($value, Constraint $constraint) { if (empty(trim($value))) { return; } if (in_array(mb_strtolower(trim($value)), $this->reservedWords)) { $this->context->addViolation($constraint->message, [ '%value%' => $value, ]); } }
php
public function validate($value, Constraint $constraint) { if (empty(trim($value))) { return; } if (in_array(mb_strtolower(trim($value)), $this->reservedWords)) { $this->context->addViolation($constraint->message, [ '%value%' => $value, ]); } }
[ "public", "function", "validate", "(", "$", "value", ",", "Constraint", "$", "constraint", ")", "{", "if", "(", "empty", "(", "trim", "(", "$", "value", ")", ")", ")", "{", "return", ";", "}", "if", "(", "in_array", "(", "mb_strtolower", "(", "trim", "(", "$", "value", ")", ")", ",", "$", "this", "->", "reservedWords", ")", ")", "{", "$", "this", "->", "context", "->", "addViolation", "(", "$", "constraint", "->", "message", ",", "[", "'%value%'", "=>", "$", "value", ",", "]", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/Validator/ReservedWordValidator.php#L39-L50
webforge-labs/psc-cms
lib/Psc/CMS/Item/MetaAdapter.php
MetaAdapter.getAdapter
protected function getAdapter($context) { return $this->context === $context || $context === NULL ? $this : new static($this->entityMeta, $context); }
php
protected function getAdapter($context) { return $this->context === $context || $context === NULL ? $this : new static($this->entityMeta, $context); }
[ "protected", "function", "getAdapter", "(", "$", "context", ")", "{", "return", "$", "this", "->", "context", "===", "$", "context", "||", "$", "context", "===", "NULL", "?", "$", "this", ":", "new", "static", "(", "$", "this", "->", "entityMeta", ",", "$", "context", ")", ";", "}" ]
Erstellt einen neuen MetaAdapter im richtigen Context @return MetaAdapter mit dem angegebenen Context
[ "Erstellt", "einen", "neuen", "MetaAdapter", "im", "richtigen", "Context" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/MetaAdapter.php#L106-L108
webforge-labs/psc-cms
lib/Psc/CMS/Item/MetaAdapter.php
MetaAdapter.getTabRequestMeta
public function getTabRequestMeta() { if ($this->context === 'new') { return $this->entityMeta->getNewFormRequestMeta(); } elseif ($this->context === 'grid') { return $this->entityMeta->getGridRequestMeta(); } elseif ($this->context === self::CONTEXT_SEARCHPANEL) { return $this->entityMeta->getSearchPanelRequestMeta(); } elseif ($this->context === self::CONTEXT_DEFAULT || $this->context === self::CONTEXT_ASSOC_LIST) { return $this->entityMeta->getDefaultRequestMeta(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt",$this->context)); } }
php
public function getTabRequestMeta() { if ($this->context === 'new') { return $this->entityMeta->getNewFormRequestMeta(); } elseif ($this->context === 'grid') { return $this->entityMeta->getGridRequestMeta(); } elseif ($this->context === self::CONTEXT_SEARCHPANEL) { return $this->entityMeta->getSearchPanelRequestMeta(); } elseif ($this->context === self::CONTEXT_DEFAULT || $this->context === self::CONTEXT_ASSOC_LIST) { return $this->entityMeta->getDefaultRequestMeta(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt",$this->context)); } }
[ "public", "function", "getTabRequestMeta", "(", ")", "{", "if", "(", "$", "this", "->", "context", "===", "'new'", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getNewFormRequestMeta", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "'grid'", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getGridRequestMeta", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "self", "::", "CONTEXT_SEARCHPANEL", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getSearchPanelRequestMeta", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "self", "::", "CONTEXT_DEFAULT", "||", "$", "this", "->", "context", "===", "self", "::", "CONTEXT_ASSOC_LIST", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getDefaultRequestMeta", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Context '%s' ist unbekannt\"", ",", "$", "this", "->", "context", ")", ")", ";", "}", "}" ]
gibt die aktuelle RequestMeta für den Context zurück im Context New ist dies z.b. die newFormRequestMeta aus dem EntityMeta @return Psc\CMS\RequestMeta
[ "gibt", "die", "aktuelle", "RequestMeta", "für", "den", "Context", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/MetaAdapter.php#L134-L146
webforge-labs/psc-cms
lib/Psc/CMS/Item/MetaAdapter.php
MetaAdapter.getTabLabel
public function getTabLabel() { if ($this->context === 'new') { return $this->entityMeta->getNewLabel(); } elseif ($this->context === 'grid') { return $this->entityMeta->getGridLabel(); } elseif ($this->context === self::CONTEXT_SEARCHPANEL) { return $this->entityMeta->getSearchLabel(); } elseif ($this->context === self::CONTEXT_DEFAULT) { return $this->entityMeta->getLabel(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt",$this->context)); } }
php
public function getTabLabel() { if ($this->context === 'new') { return $this->entityMeta->getNewLabel(); } elseif ($this->context === 'grid') { return $this->entityMeta->getGridLabel(); } elseif ($this->context === self::CONTEXT_SEARCHPANEL) { return $this->entityMeta->getSearchLabel(); } elseif ($this->context === self::CONTEXT_DEFAULT) { return $this->entityMeta->getLabel(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt",$this->context)); } }
[ "public", "function", "getTabLabel", "(", ")", "{", "if", "(", "$", "this", "->", "context", "===", "'new'", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getNewLabel", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "'grid'", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getGridLabel", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "self", "::", "CONTEXT_SEARCHPANEL", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getSearchLabel", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "self", "::", "CONTEXT_DEFAULT", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getLabel", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Context '%s' ist unbekannt\"", ",", "$", "this", "->", "context", ")", ")", ";", "}", "}" ]
Das Label für den Tab selbst
[ "Das", "Label", "für", "den", "Tab", "selbst" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/MetaAdapter.php#L151-L163
webforge-labs/psc-cms
lib/Psc/CMS/Item/MetaAdapter.php
MetaAdapter.getButtonLabel
public function getButtonLabel() { if (isset($this->buttonLabel)) { return $this->buttonLabel; } elseif ($this->context === 'new') { return $this->entityMeta->getNewLabel(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt für getButtonLabel",$this->context)); } }
php
public function getButtonLabel() { if (isset($this->buttonLabel)) { return $this->buttonLabel; } elseif ($this->context === 'new') { return $this->entityMeta->getNewLabel(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt für getButtonLabel",$this->context)); } }
[ "public", "function", "getButtonLabel", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "buttonLabel", ")", ")", "{", "return", "$", "this", "->", "buttonLabel", ";", "}", "elseif", "(", "$", "this", "->", "context", "===", "'new'", ")", "{", "return", "$", "this", "->", "entityMeta", "->", "getNewLabel", "(", ")", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"Context '%s' ist unbekannt für getButtonLabel\",", "$", "t", "his-", ">c", "ontext)", ")", ";", "", "}", "}" ]
Gibt das Label für den normalo Button zurück
[ "Gibt", "das", "Label", "für", "den", "normalo", "Button", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/MetaAdapter.php#L175-L183
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaFlash.php
ManiaFlash.getHashtagMessages
public function getHashtagMessages($name, $offset = 0, $length = 10) { if(!$name) { throw new Exception('Please specify a tag name'); } return $this->execute('GET', '/maniaflash/hashtags/%s/messages/?offset=%d&length=%d', array($name, $offset, $length)); }
php
public function getHashtagMessages($name, $offset = 0, $length = 10) { if(!$name) { throw new Exception('Please specify a tag name'); } return $this->execute('GET', '/maniaflash/hashtags/%s/messages/?offset=%d&length=%d', array($name, $offset, $length)); }
[ "public", "function", "getHashtagMessages", "(", "$", "name", ",", "$", "offset", "=", "0", ",", "$", "length", "=", "10", ")", "{", "if", "(", "!", "$", "name", ")", "{", "throw", "new", "Exception", "(", "'Please specify a tag name'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'GET'", ",", "'/maniaflash/hashtags/%s/messages/?offset=%d&length=%d'", ",", "array", "(", "$", "name", ",", "$", "offset", ",", "$", "length", ")", ")", ";", "}" ]
Return latest messages of an hashtag @param string $id @return Object[] - id - author - dateCreated - message - longMessage - mediaURL @throws Exception
[ "Return", "latest", "messages", "of", "an", "hashtag" ]
train
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaFlash.php#L47-L54
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaFlash.php
ManiaFlash.getMessages
public function getMessages($id, $offset = 0, $length = 10) { if(!$id) { throw new Exception('Invalid id'); } return $this->execute('GET', '/maniaflash/channels/%s/messages/?offset=%d&length=%d', array($id, $offset, $length)); }
php
public function getMessages($id, $offset = 0, $length = 10) { if(!$id) { throw new Exception('Invalid id'); } return $this->execute('GET', '/maniaflash/channels/%s/messages/?offset=%d&length=%d', array($id, $offset, $length)); }
[ "public", "function", "getMessages", "(", "$", "id", ",", "$", "offset", "=", "0", ",", "$", "length", "=", "10", ")", "{", "if", "(", "!", "$", "id", ")", "{", "throw", "new", "Exception", "(", "'Invalid id'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'GET'", ",", "'/maniaflash/channels/%s/messages/?offset=%d&length=%d'", ",", "array", "(", "$", "id", ",", "$", "offset", ",", "$", "length", ")", ")", ";", "}" ]
Return latest messages of a channel @param string $id @return Object[] - id - author - dateCreated - message - longMessage - mediaURL @throws Exception
[ "Return", "latest", "messages", "of", "a", "channel" ]
train
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaFlash.php#L68-L75
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaFlash.php
ManiaFlash.postMessage
public function postMessage($channelId, $message, $longMessage = null, $mediaURL = null) { return $this->execute('POST', '/maniaflash/channels/%s/', array( $channelId, array( 'message' => $message, 'longMessage' => $longMessage, 'mediaURL' => $mediaURL))); }
php
public function postMessage($channelId, $message, $longMessage = null, $mediaURL = null) { return $this->execute('POST', '/maniaflash/channels/%s/', array( $channelId, array( 'message' => $message, 'longMessage' => $longMessage, 'mediaURL' => $mediaURL))); }
[ "public", "function", "postMessage", "(", "$", "channelId", ",", "$", "message", ",", "$", "longMessage", "=", "null", ",", "$", "mediaURL", "=", "null", ")", "{", "return", "$", "this", "->", "execute", "(", "'POST'", ",", "'/maniaflash/channels/%s/'", ",", "array", "(", "$", "channelId", ",", "array", "(", "'message'", "=>", "$", "message", ",", "'longMessage'", "=>", "$", "longMessage", ",", "'mediaURL'", "=>", "$", "mediaURL", ")", ")", ")", ";", "}" ]
Publish a message on a maniaflash channel @param string $channelId @param string $message @param string $longMessage @param string $mediaUrl @return type
[ "Publish", "a", "message", "on", "a", "maniaflash", "channel" ]
train
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaFlash.php#L85-L93
Craftsware/scissor
src/Module/View.php
View.data
private function data($view) { $data['var'] = $this->module->get('var'); if(isset($view['with']) ) { foreach((array) $view['with'] as $name => $value) { $data['var'][$name] = $value; } } $data['file'] = $this->getPath($view, $this->module->get('module')); return $data; }
php
private function data($view) { $data['var'] = $this->module->get('var'); if(isset($view['with']) ) { foreach((array) $view['with'] as $name => $value) { $data['var'][$name] = $value; } } $data['file'] = $this->getPath($view, $this->module->get('module')); return $data; }
[ "private", "function", "data", "(", "$", "view", ")", "{", "$", "data", "[", "'var'", "]", "=", "$", "this", "->", "module", "->", "get", "(", "'var'", ")", ";", "if", "(", "isset", "(", "$", "view", "[", "'with'", "]", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "view", "[", "'with'", "]", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "data", "[", "'var'", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "$", "data", "[", "'file'", "]", "=", "$", "this", "->", "getPath", "(", "$", "view", ",", "$", "this", "->", "module", "->", "get", "(", "'module'", ")", ")", ";", "return", "$", "data", ";", "}" ]
Prepare the data path for the requested view @param array $view @param array $data
[ "Prepare", "the", "data", "path", "for", "the", "requested", "view" ]
train
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Module/View.php#L137-L154
Craftsware/scissor
src/Module/View.php
View.load
private function load($view) { $data = $this->data($view); if(file_exists($data['file'])) { extract($data['var']); require $data['file']; } }
php
private function load($view) { $data = $this->data($view); if(file_exists($data['file'])) { extract($data['var']); require $data['file']; } }
[ "private", "function", "load", "(", "$", "view", ")", "{", "$", "data", "=", "$", "this", "->", "data", "(", "$", "view", ")", ";", "if", "(", "file_exists", "(", "$", "data", "[", "'file'", "]", ")", ")", "{", "extract", "(", "$", "data", "[", "'var'", "]", ")", ";", "require", "$", "data", "[", "'file'", "]", ";", "}", "}" ]
View the file to the controller @param array $view
[ "View", "the", "file", "to", "the", "controller" ]
train
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Module/View.php#L164-L174
Craftsware/scissor
src/Module/View.php
View.getPath
private function getPath($view, $module) { if(isset($module)) { if(isset($view['from'])) { return realpath(dirname($module['path']) . '/' . $view['from'] . '/Views/' . $view['name'] . '.php'); } else { return realpath($module['path'] . '/Views/' . $view['name'] . '.php'); } } }
php
private function getPath($view, $module) { if(isset($module)) { if(isset($view['from'])) { return realpath(dirname($module['path']) . '/' . $view['from'] . '/Views/' . $view['name'] . '.php'); } else { return realpath($module['path'] . '/Views/' . $view['name'] . '.php'); } } }
[ "private", "function", "getPath", "(", "$", "view", ",", "$", "module", ")", "{", "if", "(", "isset", "(", "$", "module", ")", ")", "{", "if", "(", "isset", "(", "$", "view", "[", "'from'", "]", ")", ")", "{", "return", "realpath", "(", "dirname", "(", "$", "module", "[", "'path'", "]", ")", ".", "'/'", ".", "$", "view", "[", "'from'", "]", ".", "'/Views/'", ".", "$", "view", "[", "'name'", "]", ".", "'.php'", ")", ";", "}", "else", "{", "return", "realpath", "(", "$", "module", "[", "'path'", "]", ".", "'/Views/'", ".", "$", "view", "[", "'name'", "]", ".", "'.php'", ")", ";", "}", "}", "}" ]
Get file path for the requested view name @param array $view @param array $mod @return string
[ "Get", "file", "path", "for", "the", "requested", "view", "name" ]
train
https://github.com/Craftsware/scissor/blob/644e4a8ea9859fc30fee36705e54784acd8d43e2/src/Module/View.php#L195-L209
VincentChalnot/SidusEAVFilterBundle
Filter/Type/AdvancedTextFilterType.php
AdvancedTextFilterType.applyAttributeQueryBuilder
protected function applyAttributeQueryBuilder( AttributeQueryBuilderInterface $attributeQb, $data ): AttributeQueryBuilderInterface { $input = $data['input']; switch ($data['option']) { case 'exact': return $attributeQb->equals($input); case 'like_': return $attributeQb->like(trim($input, '%').'%'); case '_like': return $attributeQb->like('%'.trim($input, '%')); case '_like_': return $attributeQb->like('%'.trim($input, '%').'%'); case 'notlike_': return $attributeQb->notLike(trim($input, '%').'%'); case '_notlike': return $attributeQb->notLike('%'.trim($input, '%')); case '_notlike_': return $attributeQb->notLike('%'.trim($input, '%').'%'); case 'empty': return $attributeQb->equals(''); case 'notempty': return $attributeQb->notEquals(''); case 'null': return $attributeQb->isNull(); case 'notnull': return $attributeQb->isNotNull(); } throw new \UnexpectedValueException("Unknown option '{$data['option']}'"); }
php
protected function applyAttributeQueryBuilder( AttributeQueryBuilderInterface $attributeQb, $data ): AttributeQueryBuilderInterface { $input = $data['input']; switch ($data['option']) { case 'exact': return $attributeQb->equals($input); case 'like_': return $attributeQb->like(trim($input, '%').'%'); case '_like': return $attributeQb->like('%'.trim($input, '%')); case '_like_': return $attributeQb->like('%'.trim($input, '%').'%'); case 'notlike_': return $attributeQb->notLike(trim($input, '%').'%'); case '_notlike': return $attributeQb->notLike('%'.trim($input, '%')); case '_notlike_': return $attributeQb->notLike('%'.trim($input, '%').'%'); case 'empty': return $attributeQb->equals(''); case 'notempty': return $attributeQb->notEquals(''); case 'null': return $attributeQb->isNull(); case 'notnull': return $attributeQb->isNotNull(); } throw new \UnexpectedValueException("Unknown option '{$data['option']}'"); }
[ "protected", "function", "applyAttributeQueryBuilder", "(", "AttributeQueryBuilderInterface", "$", "attributeQb", ",", "$", "data", ")", ":", "AttributeQueryBuilderInterface", "{", "$", "input", "=", "$", "data", "[", "'input'", "]", ";", "switch", "(", "$", "data", "[", "'option'", "]", ")", "{", "case", "'exact'", ":", "return", "$", "attributeQb", "->", "equals", "(", "$", "input", ")", ";", "case", "'like_'", ":", "return", "$", "attributeQb", "->", "like", "(", "trim", "(", "$", "input", ",", "'%'", ")", ".", "'%'", ")", ";", "case", "'_like'", ":", "return", "$", "attributeQb", "->", "like", "(", "'%'", ".", "trim", "(", "$", "input", ",", "'%'", ")", ")", ";", "case", "'_like_'", ":", "return", "$", "attributeQb", "->", "like", "(", "'%'", ".", "trim", "(", "$", "input", ",", "'%'", ")", ".", "'%'", ")", ";", "case", "'notlike_'", ":", "return", "$", "attributeQb", "->", "notLike", "(", "trim", "(", "$", "input", ",", "'%'", ")", ".", "'%'", ")", ";", "case", "'_notlike'", ":", "return", "$", "attributeQb", "->", "notLike", "(", "'%'", ".", "trim", "(", "$", "input", ",", "'%'", ")", ")", ";", "case", "'_notlike_'", ":", "return", "$", "attributeQb", "->", "notLike", "(", "'%'", ".", "trim", "(", "$", "input", ",", "'%'", ")", ".", "'%'", ")", ";", "case", "'empty'", ":", "return", "$", "attributeQb", "->", "equals", "(", "''", ")", ";", "case", "'notempty'", ":", "return", "$", "attributeQb", "->", "notEquals", "(", "''", ")", ";", "case", "'null'", ":", "return", "$", "attributeQb", "->", "isNull", "(", ")", ";", "case", "'notnull'", ":", "return", "$", "attributeQb", "->", "isNotNull", "(", ")", ";", "}", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Unknown option '{$data['option']}'\"", ")", ";", "}" ]
@param AttributeQueryBuilderInterface $attributeQb @param mixed $data @return AttributeQueryBuilderInterface
[ "@param", "AttributeQueryBuilderInterface", "$attributeQb", "@param", "mixed", "$data" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/AdvancedTextFilterType.php#L20-L50
redaigbaria/oauth2
examples/relational/Storage/SessionStorage.php
SessionStorage.getByAccessToken
public function getByAccessToken(AccessTokenEntity $accessToken) { $result = Capsule::table('oauth_sessions') ->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri']) ->join('oauth_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id') ->where('oauth_access_tokens.access_token', $accessToken->getId()) ->get(); if (count($result) === 1) { $session = new SessionEntity($this->server); $session->setId($result[0]['id']); $session->setOwner($result[0]['owner_type'], $result[0]['owner_id']); return $session; } return; }
php
public function getByAccessToken(AccessTokenEntity $accessToken) { $result = Capsule::table('oauth_sessions') ->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri']) ->join('oauth_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id') ->where('oauth_access_tokens.access_token', $accessToken->getId()) ->get(); if (count($result) === 1) { $session = new SessionEntity($this->server); $session->setId($result[0]['id']); $session->setOwner($result[0]['owner_type'], $result[0]['owner_id']); return $session; } return; }
[ "public", "function", "getByAccessToken", "(", "AccessTokenEntity", "$", "accessToken", ")", "{", "$", "result", "=", "Capsule", "::", "table", "(", "'oauth_sessions'", ")", "->", "select", "(", "[", "'oauth_sessions.id'", ",", "'oauth_sessions.owner_type'", ",", "'oauth_sessions.owner_id'", ",", "'oauth_sessions.client_id'", ",", "'oauth_sessions.client_redirect_uri'", "]", ")", "->", "join", "(", "'oauth_access_tokens'", ",", "'oauth_access_tokens.session_id'", ",", "'='", ",", "'oauth_sessions.id'", ")", "->", "where", "(", "'oauth_access_tokens.access_token'", ",", "$", "accessToken", "->", "getId", "(", ")", ")", "->", "get", "(", ")", ";", "if", "(", "count", "(", "$", "result", ")", "===", "1", ")", "{", "$", "session", "=", "new", "SessionEntity", "(", "$", "this", "->", "server", ")", ";", "$", "session", "->", "setId", "(", "$", "result", "[", "0", "]", "[", "'id'", "]", ")", ";", "$", "session", "->", "setOwner", "(", "$", "result", "[", "0", "]", "[", "'owner_type'", "]", ",", "$", "result", "[", "0", "]", "[", "'owner_id'", "]", ")", ";", "return", "$", "session", ";", "}", "return", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/SessionStorage.php#L18-L35
redaigbaria/oauth2
examples/relational/Storage/SessionStorage.php
SessionStorage.getByAuthCode
public function getByAuthCode(AuthCodeEntity $authCode) { $result = Capsule::table('oauth_sessions') ->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri']) ->join('oauth_auth_codes', 'oauth_auth_codes.session_id', '=', 'oauth_sessions.id') ->where('oauth_auth_codes.auth_code', $authCode->getId()) ->get(); if (count($result) === 1) { $session = new SessionEntity($this->server); $session->setId($result[0]['id']); $session->setOwner($result[0]['owner_type'], $result[0]['owner_id']); return $session; } return; }
php
public function getByAuthCode(AuthCodeEntity $authCode) { $result = Capsule::table('oauth_sessions') ->select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri']) ->join('oauth_auth_codes', 'oauth_auth_codes.session_id', '=', 'oauth_sessions.id') ->where('oauth_auth_codes.auth_code', $authCode->getId()) ->get(); if (count($result) === 1) { $session = new SessionEntity($this->server); $session->setId($result[0]['id']); $session->setOwner($result[0]['owner_type'], $result[0]['owner_id']); return $session; } return; }
[ "public", "function", "getByAuthCode", "(", "AuthCodeEntity", "$", "authCode", ")", "{", "$", "result", "=", "Capsule", "::", "table", "(", "'oauth_sessions'", ")", "->", "select", "(", "[", "'oauth_sessions.id'", ",", "'oauth_sessions.owner_type'", ",", "'oauth_sessions.owner_id'", ",", "'oauth_sessions.client_id'", ",", "'oauth_sessions.client_redirect_uri'", "]", ")", "->", "join", "(", "'oauth_auth_codes'", ",", "'oauth_auth_codes.session_id'", ",", "'='", ",", "'oauth_sessions.id'", ")", "->", "where", "(", "'oauth_auth_codes.auth_code'", ",", "$", "authCode", "->", "getId", "(", ")", ")", "->", "get", "(", ")", ";", "if", "(", "count", "(", "$", "result", ")", "===", "1", ")", "{", "$", "session", "=", "new", "SessionEntity", "(", "$", "this", "->", "server", ")", ";", "$", "session", "->", "setId", "(", "$", "result", "[", "0", "]", "[", "'id'", "]", ")", ";", "$", "session", "->", "setOwner", "(", "$", "result", "[", "0", "]", "[", "'owner_type'", "]", ",", "$", "result", "[", "0", "]", "[", "'owner_id'", "]", ")", ";", "return", "$", "session", ";", "}", "return", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/SessionStorage.php#L40-L57
redaigbaria/oauth2
examples/relational/Storage/SessionStorage.php
SessionStorage.getScopes
public function getScopes(SessionEntity $session) { $result = Capsule::table('oauth_sessions') ->select('oauth_scopes.*') ->join('oauth_session_scopes', 'oauth_sessions.id', '=', 'oauth_session_scopes.session_id') ->join('oauth_scopes', 'oauth_scopes.id', '=', 'oauth_session_scopes.scope') ->where('oauth_sessions.id', $session->getId()) ->get(); $scopes = []; foreach ($result as $scope) { $scopes[] = (new ScopeEntity($this->server))->hydrate([ 'id' => $scope['id'], 'description' => $scope['description'], ]); } return $scopes; }
php
public function getScopes(SessionEntity $session) { $result = Capsule::table('oauth_sessions') ->select('oauth_scopes.*') ->join('oauth_session_scopes', 'oauth_sessions.id', '=', 'oauth_session_scopes.session_id') ->join('oauth_scopes', 'oauth_scopes.id', '=', 'oauth_session_scopes.scope') ->where('oauth_sessions.id', $session->getId()) ->get(); $scopes = []; foreach ($result as $scope) { $scopes[] = (new ScopeEntity($this->server))->hydrate([ 'id' => $scope['id'], 'description' => $scope['description'], ]); } return $scopes; }
[ "public", "function", "getScopes", "(", "SessionEntity", "$", "session", ")", "{", "$", "result", "=", "Capsule", "::", "table", "(", "'oauth_sessions'", ")", "->", "select", "(", "'oauth_scopes.*'", ")", "->", "join", "(", "'oauth_session_scopes'", ",", "'oauth_sessions.id'", ",", "'='", ",", "'oauth_session_scopes.session_id'", ")", "->", "join", "(", "'oauth_scopes'", ",", "'oauth_scopes.id'", ",", "'='", ",", "'oauth_session_scopes.scope'", ")", "->", "where", "(", "'oauth_sessions.id'", ",", "$", "session", "->", "getId", "(", ")", ")", "->", "get", "(", ")", ";", "$", "scopes", "=", "[", "]", ";", "foreach", "(", "$", "result", "as", "$", "scope", ")", "{", "$", "scopes", "[", "]", "=", "(", "new", "ScopeEntity", "(", "$", "this", "->", "server", ")", ")", "->", "hydrate", "(", "[", "'id'", "=>", "$", "scope", "[", "'id'", "]", ",", "'description'", "=>", "$", "scope", "[", "'description'", "]", ",", "]", ")", ";", "}", "return", "$", "scopes", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/SessionStorage.php#L62-L81
redaigbaria/oauth2
examples/relational/Storage/SessionStorage.php
SessionStorage.create
public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null) { $id = Capsule::table('oauth_sessions') ->insertGetId([ 'owner_type' => $ownerType, 'owner_id' => $ownerId, 'client_id' => $clientId, ]); return $id; }
php
public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null) { $id = Capsule::table('oauth_sessions') ->insertGetId([ 'owner_type' => $ownerType, 'owner_id' => $ownerId, 'client_id' => $clientId, ]); return $id; }
[ "public", "function", "create", "(", "$", "ownerType", ",", "$", "ownerId", ",", "$", "clientId", ",", "$", "clientRedirectUri", "=", "null", ")", "{", "$", "id", "=", "Capsule", "::", "table", "(", "'oauth_sessions'", ")", "->", "insertGetId", "(", "[", "'owner_type'", "=>", "$", "ownerType", ",", "'owner_id'", "=>", "$", "ownerId", ",", "'client_id'", "=>", "$", "clientId", ",", "]", ")", ";", "return", "$", "id", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/SessionStorage.php#L86-L96
redaigbaria/oauth2
examples/relational/Storage/SessionStorage.php
SessionStorage.associateScope
public function associateScope(SessionEntity $session, ScopeEntity $scope) { Capsule::table('oauth_session_scopes') ->insert([ 'session_id' => $session->getId(), 'scope' => $scope->getId(), ]); }
php
public function associateScope(SessionEntity $session, ScopeEntity $scope) { Capsule::table('oauth_session_scopes') ->insert([ 'session_id' => $session->getId(), 'scope' => $scope->getId(), ]); }
[ "public", "function", "associateScope", "(", "SessionEntity", "$", "session", ",", "ScopeEntity", "$", "scope", ")", "{", "Capsule", "::", "table", "(", "'oauth_session_scopes'", ")", "->", "insert", "(", "[", "'session_id'", "=>", "$", "session", "->", "getId", "(", ")", ",", "'scope'", "=>", "$", "scope", "->", "getId", "(", ")", ",", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/examples/relational/Storage/SessionStorage.php#L101-L108
ClanCats/Core
src/classes/CCController.php
CCController.create
public static function create( $path ) { $class = static::find( $path ); // if class already loaded if ( !class_exists( $class, false ) ) { // register the controller with the autoloader \CCFinder::bind( $class, CCPath::get( $path, CCDIR_CONTROLLER, 'Controller'.EXT ) ); } // create new controller instance and assign the name $controller = new $class; $controller->name = $path; return $controller; }
php
public static function create( $path ) { $class = static::find( $path ); // if class already loaded if ( !class_exists( $class, false ) ) { // register the controller with the autoloader \CCFinder::bind( $class, CCPath::get( $path, CCDIR_CONTROLLER, 'Controller'.EXT ) ); } // create new controller instance and assign the name $controller = new $class; $controller->name = $path; return $controller; }
[ "public", "static", "function", "create", "(", "$", "path", ")", "{", "$", "class", "=", "static", "::", "find", "(", "$", "path", ")", ";", "// if class already loaded", "if", "(", "!", "class_exists", "(", "$", "class", ",", "false", ")", ")", "{", "// register the controller with the autoloader", "\\", "CCFinder", "::", "bind", "(", "$", "class", ",", "CCPath", "::", "get", "(", "$", "path", ",", "CCDIR_CONTROLLER", ",", "'Controller'", ".", "EXT", ")", ")", ";", "}", "// create new controller instance and assign the name", "$", "controller", "=", "new", "$", "class", ";", "$", "controller", "->", "name", "=", "$", "path", ";", "return", "$", "controller", ";", "}" ]
CCController factory @param string $path @return CCController
[ "CCController", "factory" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCController.php#L41-L57
ClanCats/Core
src/classes/CCController.php
CCController.has_action
public static function has_action( $path, $action = null ) { $path = CCStr::cut( $path, '@' ); $path = CCStr::cut( $path, '?' ); // fix closure given if ( !is_string( $path ) ) { return false; } // get controllers default action if ( is_null( $action ) ) { $action = static::$_default_action; } // try to load the controller if ( !$controller = static::create( $path ) ) { return false; } return method_exists( $controller, static::$_action_prefix.$action ); }
php
public static function has_action( $path, $action = null ) { $path = CCStr::cut( $path, '@' ); $path = CCStr::cut( $path, '?' ); // fix closure given if ( !is_string( $path ) ) { return false; } // get controllers default action if ( is_null( $action ) ) { $action = static::$_default_action; } // try to load the controller if ( !$controller = static::create( $path ) ) { return false; } return method_exists( $controller, static::$_action_prefix.$action ); }
[ "public", "static", "function", "has_action", "(", "$", "path", ",", "$", "action", "=", "null", ")", "{", "$", "path", "=", "CCStr", "::", "cut", "(", "$", "path", ",", "'@'", ")", ";", "$", "path", "=", "CCStr", "::", "cut", "(", "$", "path", ",", "'?'", ")", ";", "// fix closure given", "if", "(", "!", "is_string", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "// get controllers default action", "if", "(", "is_null", "(", "$", "action", ")", ")", "{", "$", "action", "=", "static", "::", "$", "_default_action", ";", "}", "// try to load the controller", "if", "(", "!", "$", "controller", "=", "static", "::", "create", "(", "$", "path", ")", ")", "{", "return", "false", ";", "}", "return", "method_exists", "(", "$", "controller", ",", "static", "::", "$", "_action_prefix", ".", "$", "action", ")", ";", "}" ]
check if a controller implements an action @param string $path @param string $action @return bool
[ "check", "if", "a", "controller", "implements", "an", "action" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCController.php#L84-L108
ClanCats/Core
src/classes/CCController.php
CCController.set_language_alias
protected function set_language_alias( $action ) { // create langugage aliases $name = explode( '::', $this->name ); if ( isset( $name[1] ) ) { $prefix = $name[0].'::'; $name = $name[1]; } else { $prefix = ''; $name = $name[0]; } if ( empty( $action ) ) { $action = static::$_default_action; } CCLang::alias( ':controller', $prefix.'controller/'.strtolower( $name ) ); CCLang::alias( ':action', $prefix.'controller/'.strtolower( $name.'.'.$action ) ); }
php
protected function set_language_alias( $action ) { // create langugage aliases $name = explode( '::', $this->name ); if ( isset( $name[1] ) ) { $prefix = $name[0].'::'; $name = $name[1]; } else { $prefix = ''; $name = $name[0]; } if ( empty( $action ) ) { $action = static::$_default_action; } CCLang::alias( ':controller', $prefix.'controller/'.strtolower( $name ) ); CCLang::alias( ':action', $prefix.'controller/'.strtolower( $name.'.'.$action ) ); }
[ "protected", "function", "set_language_alias", "(", "$", "action", ")", "{", "// create langugage aliases", "$", "name", "=", "explode", "(", "'::'", ",", "$", "this", "->", "name", ")", ";", "if", "(", "isset", "(", "$", "name", "[", "1", "]", ")", ")", "{", "$", "prefix", "=", "$", "name", "[", "0", "]", ".", "'::'", ";", "$", "name", "=", "$", "name", "[", "1", "]", ";", "}", "else", "{", "$", "prefix", "=", "''", ";", "$", "name", "=", "$", "name", "[", "0", "]", ";", "}", "if", "(", "empty", "(", "$", "action", ")", ")", "{", "$", "action", "=", "static", "::", "$", "_default_action", ";", "}", "CCLang", "::", "alias", "(", "':controller'", ",", "$", "prefix", ".", "'controller/'", ".", "strtolower", "(", "$", "name", ")", ")", ";", "CCLang", "::", "alias", "(", "':action'", ",", "$", "prefix", ".", "'controller/'", ".", "strtolower", "(", "$", "name", ".", "'.'", ".", "$", "action", ")", ")", ";", "}" ]
Creates the language prefixes wich allows us to use the short :action and :controller translations @param string $action @return void
[ "Creates", "the", "language", "prefixes", "wich", "allows", "us", "to", "use", "the", "short", ":", "action", "and", ":", "controller", "translations" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCController.php#L158-L181
ClanCats/Core
src/classes/CCController.php
CCController.execute
public function execute( $action = null, $params = array() ) { $this->set_language_alias( $action ); // reset the response $this->response = null; $this->output = null; // fix notice $return = null; if ( is_null( $action ) ) { $action = static::$_default_action; } // capture all output made in the controller ob_start(); // run wake event if ( method_exists( $this, 'wake' ) ) { $return = call_user_func_array( array( $this, 'wake' ), $params ); } // do we already have an resposne from the wake event? if ( !$return instanceof CCResponse ) { // check if we got a custom action handler if ( !is_null( static::$_action_handler ) ) { $return = call_user_func( array( $this, static::$_action_handler ), $action, $params ); } // normal action else { // check if the action exists if ( method_exists( $this, static::$_action_prefix.$action ) ) { $return = call_user_func_array( array( $this, static::$_action_prefix.$action ), $params ); } else { $return = CCResponse::error( 404 ); } } } // get the output $this->output = ob_get_clean(); // do we got a response now? if ( $return instanceof CCResponse ) { $this->response = $return; } // or a string elseif ( !empty( $return ) && is_string( $return ) ) { $this->response = $this->_respond( $return ); } // do we got a valid response if not use controller output if ( !$this->response instanceof CCResponse ) { $this->response = $this->_respond( $this->output ); } // run sleep event if ( method_exists( $this, 'sleep' ) ) { call_user_func_array( array( $this, 'sleep' ), $params ); } // return thaaaaat return $this->response; }
php
public function execute( $action = null, $params = array() ) { $this->set_language_alias( $action ); // reset the response $this->response = null; $this->output = null; // fix notice $return = null; if ( is_null( $action ) ) { $action = static::$_default_action; } // capture all output made in the controller ob_start(); // run wake event if ( method_exists( $this, 'wake' ) ) { $return = call_user_func_array( array( $this, 'wake' ), $params ); } // do we already have an resposne from the wake event? if ( !$return instanceof CCResponse ) { // check if we got a custom action handler if ( !is_null( static::$_action_handler ) ) { $return = call_user_func( array( $this, static::$_action_handler ), $action, $params ); } // normal action else { // check if the action exists if ( method_exists( $this, static::$_action_prefix.$action ) ) { $return = call_user_func_array( array( $this, static::$_action_prefix.$action ), $params ); } else { $return = CCResponse::error( 404 ); } } } // get the output $this->output = ob_get_clean(); // do we got a response now? if ( $return instanceof CCResponse ) { $this->response = $return; } // or a string elseif ( !empty( $return ) && is_string( $return ) ) { $this->response = $this->_respond( $return ); } // do we got a valid response if not use controller output if ( !$this->response instanceof CCResponse ) { $this->response = $this->_respond( $this->output ); } // run sleep event if ( method_exists( $this, 'sleep' ) ) { call_user_func_array( array( $this, 'sleep' ), $params ); } // return thaaaaat return $this->response; }
[ "public", "function", "execute", "(", "$", "action", "=", "null", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "this", "->", "set_language_alias", "(", "$", "action", ")", ";", "// reset the response", "$", "this", "->", "response", "=", "null", ";", "$", "this", "->", "output", "=", "null", ";", "// fix notice", "$", "return", "=", "null", ";", "if", "(", "is_null", "(", "$", "action", ")", ")", "{", "$", "action", "=", "static", "::", "$", "_default_action", ";", "}", "// capture all output made in the controller", "ob_start", "(", ")", ";", "// run wake event", "if", "(", "method_exists", "(", "$", "this", ",", "'wake'", ")", ")", "{", "$", "return", "=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "'wake'", ")", ",", "$", "params", ")", ";", "}", "// do we already have an resposne from the wake event?", "if", "(", "!", "$", "return", "instanceof", "CCResponse", ")", "{", "// check if we got a custom action handler", "if", "(", "!", "is_null", "(", "static", "::", "$", "_action_handler", ")", ")", "{", "$", "return", "=", "call_user_func", "(", "array", "(", "$", "this", ",", "static", "::", "$", "_action_handler", ")", ",", "$", "action", ",", "$", "params", ")", ";", "}", "// normal action", "else", "{", "// check if the action exists", "if", "(", "method_exists", "(", "$", "this", ",", "static", "::", "$", "_action_prefix", ".", "$", "action", ")", ")", "{", "$", "return", "=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "static", "::", "$", "_action_prefix", ".", "$", "action", ")", ",", "$", "params", ")", ";", "}", "else", "{", "$", "return", "=", "CCResponse", "::", "error", "(", "404", ")", ";", "}", "}", "}", "// get the output", "$", "this", "->", "output", "=", "ob_get_clean", "(", ")", ";", "// do we got a response now?", "if", "(", "$", "return", "instanceof", "CCResponse", ")", "{", "$", "this", "->", "response", "=", "$", "return", ";", "}", "// or a string", "elseif", "(", "!", "empty", "(", "$", "return", ")", "&&", "is_string", "(", "$", "return", ")", ")", "{", "$", "this", "->", "response", "=", "$", "this", "->", "_respond", "(", "$", "return", ")", ";", "}", "// do we got a valid response if not use controller output\t\t", "if", "(", "!", "$", "this", "->", "response", "instanceof", "CCResponse", ")", "{", "$", "this", "->", "response", "=", "$", "this", "->", "_respond", "(", "$", "this", "->", "output", ")", ";", "}", "// run sleep event", "if", "(", "method_exists", "(", "$", "this", ",", "'sleep'", ")", ")", "{", "call_user_func_array", "(", "array", "(", "$", "this", ",", "'sleep'", ")", ",", "$", "params", ")", ";", "}", "// return thaaaaat", "return", "$", "this", "->", "response", ";", "}" ]
controller execution @param string $action @param array $params @return CCResponse
[ "controller", "execution" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCController.php#L190-L266
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.checkContainerForWrite
public function checkContainerForWrite($container) { $container = static::addContainerToName($container, ''); if (!is_dir($container)) { if (!mkdir($container, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } }
php
public function checkContainerForWrite($container) { $container = static::addContainerToName($container, ''); if (!is_dir($container)) { if (!mkdir($container, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } }
[ "public", "function", "checkContainerForWrite", "(", "$", "container", ")", "{", "$", "container", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "''", ")", ";", "if", "(", "!", "is_dir", "(", "$", "container", ")", ")", "{", "if", "(", "!", "mkdir", "(", "$", "container", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to create container.'", ")", ";", "}", "}", "}" ]
Creates the container for this file management if it does not already exist @param string $container @throws \Exception
[ "Creates", "the", "container", "for", "this", "file", "management", "if", "it", "does", "not", "already", "exist" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L44-L52
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.listContainers
public function listContainers($include_properties = false) { $out = []; $root = FileUtilities::fixFolderPath(static::asFullPath('', false)); $files = array_diff(scandir($root), ['.', '..', '.private']); foreach ($files as $file) { $dir = $root . $file; // get file meta if (is_dir($dir) || is_file($dir)) { $result = ['name' => $file, 'path' => $file]; if ($include_properties) { $temp = stat($dir); $result['last_modified'] = gmdate(static::TIMESTAMP_FORMAT, array_get($temp, 'mtime', 0)); } $out[] = $result; } } return $out; }
php
public function listContainers($include_properties = false) { $out = []; $root = FileUtilities::fixFolderPath(static::asFullPath('', false)); $files = array_diff(scandir($root), ['.', '..', '.private']); foreach ($files as $file) { $dir = $root . $file; // get file meta if (is_dir($dir) || is_file($dir)) { $result = ['name' => $file, 'path' => $file]; if ($include_properties) { $temp = stat($dir); $result['last_modified'] = gmdate(static::TIMESTAMP_FORMAT, array_get($temp, 'mtime', 0)); } $out[] = $result; } } return $out; }
[ "public", "function", "listContainers", "(", "$", "include_properties", "=", "false", ")", "{", "$", "out", "=", "[", "]", ";", "$", "root", "=", "FileUtilities", "::", "fixFolderPath", "(", "static", "::", "asFullPath", "(", "''", ",", "false", ")", ")", ";", "$", "files", "=", "array_diff", "(", "scandir", "(", "$", "root", ")", ",", "[", "'.'", ",", "'..'", ",", "'.private'", "]", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "dir", "=", "$", "root", ".", "$", "file", ";", "// get file meta", "if", "(", "is_dir", "(", "$", "dir", ")", "||", "is_file", "(", "$", "dir", ")", ")", "{", "$", "result", "=", "[", "'name'", "=>", "$", "file", ",", "'path'", "=>", "$", "file", "]", ";", "if", "(", "$", "include_properties", ")", "{", "$", "temp", "=", "stat", "(", "$", "dir", ")", ";", "$", "result", "[", "'last_modified'", "]", "=", "gmdate", "(", "static", "::", "TIMESTAMP_FORMAT", ",", "array_get", "(", "$", "temp", ",", "'mtime'", ",", "0", ")", ")", ";", "}", "$", "out", "[", "]", "=", "$", "result", ";", "}", "}", "return", "$", "out", ";", "}" ]
List all containers, just names if noted @param bool $include_properties If true, additional properties are retrieved @throws \Exception @return array
[ "List", "all", "containers", "just", "names", "if", "noted" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L62-L82
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.createContainer
public function createContainer($properties = [], $check_exist = false) { $container = array_get($properties, 'name', array_get($properties, 'path')); if (empty($container)) { throw new BadRequestException('No name found for container in create request.'); } // does this folder already exist? if ($this->folderExists($container, '')) { if ($check_exist) { throw new BadRequestException("Container '$container' already exists."); } } else { // create the container $dir = static::addContainerToName($container, ''); if (!mkdir($dir, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } return ['name' => $container, 'path' => $container]; // $properties = (empty($properties)) ? '' : json_encode($properties); // $result = file_put_contents($key, $properties); // if (false === $result) { // throw new InternalServerErrorException('Failed to create container properties.'); // } }
php
public function createContainer($properties = [], $check_exist = false) { $container = array_get($properties, 'name', array_get($properties, 'path')); if (empty($container)) { throw new BadRequestException('No name found for container in create request.'); } // does this folder already exist? if ($this->folderExists($container, '')) { if ($check_exist) { throw new BadRequestException("Container '$container' already exists."); } } else { // create the container $dir = static::addContainerToName($container, ''); if (!mkdir($dir, 0777, true)) { throw new InternalServerErrorException('Failed to create container.'); } } return ['name' => $container, 'path' => $container]; // $properties = (empty($properties)) ? '' : json_encode($properties); // $result = file_put_contents($key, $properties); // if (false === $result) { // throw new InternalServerErrorException('Failed to create container properties.'); // } }
[ "public", "function", "createContainer", "(", "$", "properties", "=", "[", "]", ",", "$", "check_exist", "=", "false", ")", "{", "$", "container", "=", "array_get", "(", "$", "properties", ",", "'name'", ",", "array_get", "(", "$", "properties", ",", "'path'", ")", ")", ";", "if", "(", "empty", "(", "$", "container", ")", ")", "{", "throw", "new", "BadRequestException", "(", "'No name found for container in create request.'", ")", ";", "}", "// does this folder already exist?", "if", "(", "$", "this", "->", "folderExists", "(", "$", "container", ",", "''", ")", ")", "{", "if", "(", "$", "check_exist", ")", "{", "throw", "new", "BadRequestException", "(", "\"Container '$container' already exists.\"", ")", ";", "}", "}", "else", "{", "// create the container", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "''", ")", ";", "if", "(", "!", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to create container.'", ")", ";", "}", "}", "return", "[", "'name'", "=>", "$", "container", ",", "'path'", "=>", "$", "container", "]", ";", "// $properties = (empty($properties)) ? '' : json_encode($properties);", "// $result = file_put_contents($key, $properties);", "// if (false === $result) {", "// throw new InternalServerErrorException('Failed to create container properties.');", "// }", "}" ]
Create a container using properties, where at least name is required @param array $properties @param bool $check_exist If true, throws error if the container already exists @throws \Exception @throws BadRequestException @return array
[ "Create", "a", "container", "using", "properties", "where", "at", "least", "name", "is", "required" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L135-L162
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.createContainers
public function createContainers($containers = [], $check_exist = false) { if (empty($containers)) { return []; } $out = []; foreach ($containers as $key => $folder) { try { // path is full path, name is relative to root, take either $out[$key] = $this->createContainer($folder, $check_exist); } catch (\Exception $ex) { // error whole batch here? $out[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()]; } } return $out; }
php
public function createContainers($containers = [], $check_exist = false) { if (empty($containers)) { return []; } $out = []; foreach ($containers as $key => $folder) { try { // path is full path, name is relative to root, take either $out[$key] = $this->createContainer($folder, $check_exist); } catch (\Exception $ex) { // error whole batch here? $out[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()]; } } return $out; }
[ "public", "function", "createContainers", "(", "$", "containers", "=", "[", "]", ",", "$", "check_exist", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "containers", ")", ")", "{", "return", "[", "]", ";", "}", "$", "out", "=", "[", "]", ";", "foreach", "(", "$", "containers", "as", "$", "key", "=>", "$", "folder", ")", "{", "try", "{", "// path is full path, name is relative to root, take either", "$", "out", "[", "$", "key", "]", "=", "$", "this", "->", "createContainer", "(", "$", "folder", ",", "$", "check_exist", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "// error whole batch here?", "$", "out", "[", "$", "key", "]", "[", "'error'", "]", "=", "[", "'message'", "=>", "$", "ex", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "ex", "->", "getCode", "(", ")", "]", ";", "}", "}", "return", "$", "out", ";", "}" ]
Create multiple containers using array of properties, where at least name is required @param array $containers @param bool $check_exist If true, throws error if the container already exists @return array
[ "Create", "multiple", "containers", "using", "array", "of", "properties", "where", "at", "least", "name", "is", "required" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L172-L190
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.deleteContainer
public function deleteContainer($container, $force = false) { $dir = static::addContainerToName($container, ''); if (!rmdir($dir)) { throw new InternalServerErrorException('Failed to delete container.'); } }
php
public function deleteContainer($container, $force = false) { $dir = static::addContainerToName($container, ''); if (!rmdir($dir)) { throw new InternalServerErrorException('Failed to delete container.'); } }
[ "public", "function", "deleteContainer", "(", "$", "container", ",", "$", "force", "=", "false", ")", "{", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "''", ")", ";", "if", "(", "!", "rmdir", "(", "$", "dir", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to delete container.'", ")", ";", "}", "}" ]
Delete a container and all of its content @param string $container @param bool $force Force a delete if it is not empty @throws \Exception @return void
[ "Delete", "a", "container", "and", "all", "of", "its", "content" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L215-L221
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.folderExists
public function folderExists($container, $path) { $path = FileUtilities::fixFolderPath($path); $dir = static::addContainerToName($container, $path); return is_dir($dir); }
php
public function folderExists($container, $path) { $path = FileUtilities::fixFolderPath($path); $dir = static::addContainerToName($container, $path); return is_dir($dir); }
[ "public", "function", "folderExists", "(", "$", "container", ",", "$", "path", ")", "{", "$", "path", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "path", ")", ";", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "return", "is_dir", "(", "$", "dir", ")", ";", "}" ]
@param $container @param $path @return bool
[ "@param", "$container", "@param", "$path" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L264-L270
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.getFolder
public function getFolder($container, $path, $include_files = true, $include_folders = true, $full_tree = false) { $path = FileUtilities::fixFolderPath($path); $delimiter = ($full_tree) ? '' : DIRECTORY_SEPARATOR; $resources = []; $dirPath = FileUtilities::fixFolderPath(static::asFullPath('')); if (is_dir($dirPath)) { $localizer = $path; $results = static::listTree($dirPath, $path, $delimiter); foreach ($results as $data) { $fullPathName = $data['path']; $data['name'] = rtrim(substr($fullPathName, strlen($localizer)), '/'); if ('/' == substr($fullPathName, -1, 1)) { // folders if ($include_folders) { $data['type'] = 'folder'; $resources[] = $data; } } else { // files if ($include_files) { $data['type'] = 'file'; $resources[] = $data; } } } } else { if (!empty($path)) { throw new NotFoundException("Folder '$path' does not exist in storage."); } // container root doesn't really exist until first write creates it } return $resources; }
php
public function getFolder($container, $path, $include_files = true, $include_folders = true, $full_tree = false) { $path = FileUtilities::fixFolderPath($path); $delimiter = ($full_tree) ? '' : DIRECTORY_SEPARATOR; $resources = []; $dirPath = FileUtilities::fixFolderPath(static::asFullPath('')); if (is_dir($dirPath)) { $localizer = $path; $results = static::listTree($dirPath, $path, $delimiter); foreach ($results as $data) { $fullPathName = $data['path']; $data['name'] = rtrim(substr($fullPathName, strlen($localizer)), '/'); if ('/' == substr($fullPathName, -1, 1)) { // folders if ($include_folders) { $data['type'] = 'folder'; $resources[] = $data; } } else { // files if ($include_files) { $data['type'] = 'file'; $resources[] = $data; } } } } else { if (!empty($path)) { throw new NotFoundException("Folder '$path' does not exist in storage."); } // container root doesn't really exist until first write creates it } return $resources; }
[ "public", "function", "getFolder", "(", "$", "container", ",", "$", "path", ",", "$", "include_files", "=", "true", ",", "$", "include_folders", "=", "true", ",", "$", "full_tree", "=", "false", ")", "{", "$", "path", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "path", ")", ";", "$", "delimiter", "=", "(", "$", "full_tree", ")", "?", "''", ":", "DIRECTORY_SEPARATOR", ";", "$", "resources", "=", "[", "]", ";", "$", "dirPath", "=", "FileUtilities", "::", "fixFolderPath", "(", "static", "::", "asFullPath", "(", "''", ")", ")", ";", "if", "(", "is_dir", "(", "$", "dirPath", ")", ")", "{", "$", "localizer", "=", "$", "path", ";", "$", "results", "=", "static", "::", "listTree", "(", "$", "dirPath", ",", "$", "path", ",", "$", "delimiter", ")", ";", "foreach", "(", "$", "results", "as", "$", "data", ")", "{", "$", "fullPathName", "=", "$", "data", "[", "'path'", "]", ";", "$", "data", "[", "'name'", "]", "=", "rtrim", "(", "substr", "(", "$", "fullPathName", ",", "strlen", "(", "$", "localizer", ")", ")", ",", "'/'", ")", ";", "if", "(", "'/'", "==", "substr", "(", "$", "fullPathName", ",", "-", "1", ",", "1", ")", ")", "{", "// folders", "if", "(", "$", "include_folders", ")", "{", "$", "data", "[", "'type'", "]", "=", "'folder'", ";", "$", "resources", "[", "]", "=", "$", "data", ";", "}", "}", "else", "{", "// files", "if", "(", "$", "include_files", ")", "{", "$", "data", "[", "'type'", "]", "=", "'file'", ";", "$", "resources", "[", "]", "=", "$", "data", ";", "}", "}", "}", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "path", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$path' does not exist in storage.\"", ")", ";", "}", "// container root doesn't really exist until first write creates it", "}", "return", "$", "resources", ";", "}" ]
@param string $container @param string $path @param bool $include_files @param bool $include_folders @param bool $full_tree @throws NotFoundException @return array
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "bool", "$include_files", "@param", "bool", "$include_folders", "@param", "bool", "$full_tree" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L282-L316
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.getFolderProperties
public function getFolderProperties($container, $path) { $path = FileUtilities::fixFolderPath($path); $out = ['name' => basename($path), 'path' => $path]; $dirPath = static::addContainerToName($container, $path); $temp = stat($dirPath); $out['last_modified'] = gmdate(static::TIMESTAMP_FORMAT, array_get($temp, 'mtime', 0)); return $out; }
php
public function getFolderProperties($container, $path) { $path = FileUtilities::fixFolderPath($path); $out = ['name' => basename($path), 'path' => $path]; $dirPath = static::addContainerToName($container, $path); $temp = stat($dirPath); $out['last_modified'] = gmdate(static::TIMESTAMP_FORMAT, array_get($temp, 'mtime', 0)); return $out; }
[ "public", "function", "getFolderProperties", "(", "$", "container", ",", "$", "path", ")", "{", "$", "path", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "path", ")", ";", "$", "out", "=", "[", "'name'", "=>", "basename", "(", "$", "path", ")", ",", "'path'", "=>", "$", "path", "]", ";", "$", "dirPath", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "$", "temp", "=", "stat", "(", "$", "dirPath", ")", ";", "$", "out", "[", "'last_modified'", "]", "=", "gmdate", "(", "static", "::", "TIMESTAMP_FORMAT", ",", "array_get", "(", "$", "temp", ",", "'mtime'", ",", "0", ")", ")", ";", "return", "$", "out", ";", "}" ]
@param string $container @param string $path @throws NotFoundException @return array
[ "@param", "string", "$container", "@param", "string", "$path" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L325-L334
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.createFolder
public function createFolder($container, $path, $is_public = true, $properties = [], $check_exist = true) { if (empty($path)) { throw new BadRequestException("Invalid empty path."); } $path = FileUtilities::fixFolderPath($path); // does this folder already exist? if ($this->folderExists($container, $path)) { if ($check_exist) { throw new BadRequestException("Folder '$path' already exists."); } return; } // create the folder $this->checkContainerForWrite($container); // need to be able to write to storage $dir = static::addContainerToName($container, $path); if (false === @mkdir($dir, 0777, true)) { \Log::error('Unable to create directory: ' . $dir); throw new InternalServerErrorException('Failed to create folder: ' . $path); } // $properties = (empty($properties)) ? '' : json_encode($properties); // $result = file_put_contents($key, $properties); // if (false === $result) { // throw new InternalServerErrorException('Failed to create folder properties.'); // } }
php
public function createFolder($container, $path, $is_public = true, $properties = [], $check_exist = true) { if (empty($path)) { throw new BadRequestException("Invalid empty path."); } $path = FileUtilities::fixFolderPath($path); // does this folder already exist? if ($this->folderExists($container, $path)) { if ($check_exist) { throw new BadRequestException("Folder '$path' already exists."); } return; } // create the folder $this->checkContainerForWrite($container); // need to be able to write to storage $dir = static::addContainerToName($container, $path); if (false === @mkdir($dir, 0777, true)) { \Log::error('Unable to create directory: ' . $dir); throw new InternalServerErrorException('Failed to create folder: ' . $path); } // $properties = (empty($properties)) ? '' : json_encode($properties); // $result = file_put_contents($key, $properties); // if (false === $result) { // throw new InternalServerErrorException('Failed to create folder properties.'); // } }
[ "public", "function", "createFolder", "(", "$", "container", ",", "$", "path", ",", "$", "is_public", "=", "true", ",", "$", "properties", "=", "[", "]", ",", "$", "check_exist", "=", "true", ")", "{", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "throw", "new", "BadRequestException", "(", "\"Invalid empty path.\"", ")", ";", "}", "$", "path", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "path", ")", ";", "// does this folder already exist?", "if", "(", "$", "this", "->", "folderExists", "(", "$", "container", ",", "$", "path", ")", ")", "{", "if", "(", "$", "check_exist", ")", "{", "throw", "new", "BadRequestException", "(", "\"Folder '$path' already exists.\"", ")", ";", "}", "return", ";", "}", "// create the folder", "$", "this", "->", "checkContainerForWrite", "(", "$", "container", ")", ";", "// need to be able to write to storage", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "if", "(", "false", "===", "@", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ")", "{", "\\", "Log", "::", "error", "(", "'Unable to create directory: '", ".", "$", "dir", ")", ";", "throw", "new", "InternalServerErrorException", "(", "'Failed to create folder: '", ".", "$", "path", ")", ";", "}", "// $properties = (empty($properties)) ? '' : json_encode($properties);", "// $result = file_put_contents($key, $properties);", "// if (false === $result) {", "// throw new InternalServerErrorException('Failed to create folder properties.');", "// }", "}" ]
@param string $container @param string $path @param bool $is_public @param array $properties @param bool $check_exist @throws \Exception @throws NotFoundException @throws BadRequestException @return void
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "bool", "$is_public", "@param", "array", "$properties", "@param", "bool", "$check_exist" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L348-L377
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.copyFolder
public function copyFolder($container, $dest_path, $src_container, $src_path, $check_exist = false) { // does this file already exist? if (!$this->folderExists($src_container, $src_path)) { throw new NotFoundException("Folder '$src_path' does not exist."); } if ($this->folderExists($container, $dest_path)) { if (($check_exist)) { throw new BadRequestException("Folder '$dest_path' already exists."); } } // does this file's parent folder exist? $parent = FileUtilities::getParentFolder($dest_path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the folder $this->checkContainerForWrite($container); // need to be able to write to storage FileUtilities::copyTree( static::addContainerToName($src_container, $src_path), static::addContainerToName($container, $dest_path) ); }
php
public function copyFolder($container, $dest_path, $src_container, $src_path, $check_exist = false) { // does this file already exist? if (!$this->folderExists($src_container, $src_path)) { throw new NotFoundException("Folder '$src_path' does not exist."); } if ($this->folderExists($container, $dest_path)) { if (($check_exist)) { throw new BadRequestException("Folder '$dest_path' already exists."); } } // does this file's parent folder exist? $parent = FileUtilities::getParentFolder($dest_path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the folder $this->checkContainerForWrite($container); // need to be able to write to storage FileUtilities::copyTree( static::addContainerToName($src_container, $src_path), static::addContainerToName($container, $dest_path) ); }
[ "public", "function", "copyFolder", "(", "$", "container", ",", "$", "dest_path", ",", "$", "src_container", ",", "$", "src_path", ",", "$", "check_exist", "=", "false", ")", "{", "// does this file already exist?", "if", "(", "!", "$", "this", "->", "folderExists", "(", "$", "src_container", ",", "$", "src_path", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$src_path' does not exist.\"", ")", ";", "}", "if", "(", "$", "this", "->", "folderExists", "(", "$", "container", ",", "$", "dest_path", ")", ")", "{", "if", "(", "(", "$", "check_exist", ")", ")", "{", "throw", "new", "BadRequestException", "(", "\"Folder '$dest_path' already exists.\"", ")", ";", "}", "}", "// does this file's parent folder exist?", "$", "parent", "=", "FileUtilities", "::", "getParentFolder", "(", "$", "dest_path", ")", ";", "if", "(", "!", "empty", "(", "$", "parent", ")", "&&", "(", "!", "$", "this", "->", "folderExists", "(", "$", "container", ",", "$", "parent", ")", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$parent' does not exist.\"", ")", ";", "}", "// create the folder", "$", "this", "->", "checkContainerForWrite", "(", "$", "container", ")", ";", "// need to be able to write to storage", "FileUtilities", "::", "copyTree", "(", "static", "::", "addContainerToName", "(", "$", "src_container", ",", "$", "src_path", ")", ",", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "dest_path", ")", ")", ";", "}" ]
@param string $container @param string $dest_path @param $src_container @param string $src_path @param bool $check_exist @throws NotFoundException @throws BadRequestException @return void
[ "@param", "string", "$container", "@param", "string", "$dest_path", "@param", "$src_container", "@param", "string", "$src_path", "@param", "bool", "$check_exist" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L390-L412
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.deleteFolder
public function deleteFolder($container, $path, $force = false, $content_only = false) { $dir = static::addContainerToName($container, $path); FileUtilities::deleteTree($dir, $force, !$content_only); }
php
public function deleteFolder($container, $path, $force = false, $content_only = false) { $dir = static::addContainerToName($container, $path); FileUtilities::deleteTree($dir, $force, !$content_only); }
[ "public", "function", "deleteFolder", "(", "$", "container", ",", "$", "path", ",", "$", "force", "=", "false", ",", "$", "content_only", "=", "false", ")", "{", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "FileUtilities", "::", "deleteTree", "(", "$", "dir", ",", "$", "force", ",", "!", "$", "content_only", ")", ";", "}" ]
@param string $container @param string $path @param bool $force @param bool $content_only @throws \Exception
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "bool", "$force", "@param", "bool", "$content_only" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L435-L439
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.getFileContent
public function getFileContent($container, $path, $local_file = '', $content_as_base = true) { $file = static::addContainerToName($container, $path); if (!is_file($file)) { throw new NotFoundException("File '$path' does not exist in storage."); } $data = file_get_contents($file); if (false === $data) { throw new InternalServerErrorException('Failed to retrieve file content.'); } if (!empty($local_file)) { // write to local or temp file $result = file_put_contents($local_file, $data); if (false === $result) { throw new InternalServerErrorException('Failed to put file content as local file.'); } return ''; } else { // get content as raw or encoded as base64 for transport if ($content_as_base) { $data = base64_encode($data); } return $data; } }
php
public function getFileContent($container, $path, $local_file = '', $content_as_base = true) { $file = static::addContainerToName($container, $path); if (!is_file($file)) { throw new NotFoundException("File '$path' does not exist in storage."); } $data = file_get_contents($file); if (false === $data) { throw new InternalServerErrorException('Failed to retrieve file content.'); } if (!empty($local_file)) { // write to local or temp file $result = file_put_contents($local_file, $data); if (false === $result) { throw new InternalServerErrorException('Failed to put file content as local file.'); } return ''; } else { // get content as raw or encoded as base64 for transport if ($content_as_base) { $data = base64_encode($data); } return $data; } }
[ "public", "function", "getFileContent", "(", "$", "container", ",", "$", "path", ",", "$", "local_file", "=", "''", ",", "$", "content_as_base", "=", "true", ")", "{", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"File '$path' does not exist in storage.\"", ")", ";", "}", "$", "data", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "false", "===", "$", "data", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to retrieve file content.'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "local_file", ")", ")", "{", "// write to local or temp file", "$", "result", "=", "file_put_contents", "(", "$", "local_file", ",", "$", "data", ")", ";", "if", "(", "false", "===", "$", "result", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to put file content as local file.'", ")", ";", "}", "return", "''", ";", "}", "else", "{", "// get content as raw or encoded as base64 for transport", "if", "(", "$", "content_as_base", ")", "{", "$", "data", "=", "base64_encode", "(", "$", "data", ")", ";", "}", "return", "$", "data", ";", "}", "}" ]
@param string $container @param string $path @param string $local_file @param bool $content_as_base @throws \Exception @throws NotFoundException @return string
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "string", "$local_file", "@param", "bool", "$content_as_base" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L501-L527
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.getFileProperties
public function getFileProperties($container, $path, $include_content = false, $content_as_base = true) { if (!$this->fileExists($container, $path)) { throw new NotFoundException("File '$path' does not exist in storage."); } $file = static::addContainerToName($container, $path); $shortName = FileUtilities::getNameFromPath($path); $ext = FileUtilities::getFileExtension($file); $temp = stat($file); $data = [ 'path' => $path, 'name' => $shortName, 'content_type' => FileUtilities::determineContentType($ext, '', $file), 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($temp, 'mtime', 0)), 'content_length' => array_get($temp, 'size', 0) ]; if ($include_content) { $contents = file_get_contents($file); if (false === $contents) { throw new InternalServerErrorException('Failed to retrieve file properties.'); } if ($content_as_base) { $contents = base64_encode($contents); } $data['content'] = $contents; } return $data; }
php
public function getFileProperties($container, $path, $include_content = false, $content_as_base = true) { if (!$this->fileExists($container, $path)) { throw new NotFoundException("File '$path' does not exist in storage."); } $file = static::addContainerToName($container, $path); $shortName = FileUtilities::getNameFromPath($path); $ext = FileUtilities::getFileExtension($file); $temp = stat($file); $data = [ 'path' => $path, 'name' => $shortName, 'content_type' => FileUtilities::determineContentType($ext, '', $file), 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($temp, 'mtime', 0)), 'content_length' => array_get($temp, 'size', 0) ]; if ($include_content) { $contents = file_get_contents($file); if (false === $contents) { throw new InternalServerErrorException('Failed to retrieve file properties.'); } if ($content_as_base) { $contents = base64_encode($contents); } $data['content'] = $contents; } return $data; }
[ "public", "function", "getFileProperties", "(", "$", "container", ",", "$", "path", ",", "$", "include_content", "=", "false", ",", "$", "content_as_base", "=", "true", ")", "{", "if", "(", "!", "$", "this", "->", "fileExists", "(", "$", "container", ",", "$", "path", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"File '$path' does not exist in storage.\"", ")", ";", "}", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "$", "shortName", "=", "FileUtilities", "::", "getNameFromPath", "(", "$", "path", ")", ";", "$", "ext", "=", "FileUtilities", "::", "getFileExtension", "(", "$", "file", ")", ";", "$", "temp", "=", "stat", "(", "$", "file", ")", ";", "$", "data", "=", "[", "'path'", "=>", "$", "path", ",", "'name'", "=>", "$", "shortName", ",", "'content_type'", "=>", "FileUtilities", "::", "determineContentType", "(", "$", "ext", ",", "''", ",", "$", "file", ")", ",", "'last_modified'", "=>", "gmdate", "(", "'D, d M Y H:i:s \\G\\M\\T'", ",", "array_get", "(", "$", "temp", ",", "'mtime'", ",", "0", ")", ")", ",", "'content_length'", "=>", "array_get", "(", "$", "temp", ",", "'size'", ",", "0", ")", "]", ";", "if", "(", "$", "include_content", ")", "{", "$", "contents", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "false", "===", "$", "contents", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to retrieve file properties.'", ")", ";", "}", "if", "(", "$", "content_as_base", ")", "{", "$", "contents", "=", "base64_encode", "(", "$", "contents", ")", ";", "}", "$", "data", "[", "'content'", "]", "=", "$", "contents", ";", "}", "return", "$", "data", ";", "}" ]
@param string $container @param string $path @param bool $include_content @param bool $content_as_base @throws NotFoundException @throws \Exception @return array
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "bool", "$include_content", "@param", "bool", "$content_as_base" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L539-L567
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.streamFile
public function streamFile($container, $path, $download = false) { $file = static::addContainerToName($container, $path); if (!is_file($file)) { throw new NotFoundException("The specified file '" . $path . "' was not found in storage."); } $chunk = \Config::get('df.file_chunk_size'); FileUtilities::sendFile($file, $download, $chunk); }
php
public function streamFile($container, $path, $download = false) { $file = static::addContainerToName($container, $path); if (!is_file($file)) { throw new NotFoundException("The specified file '" . $path . "' was not found in storage."); } $chunk = \Config::get('df.file_chunk_size'); FileUtilities::sendFile($file, $download, $chunk); }
[ "public", "function", "streamFile", "(", "$", "container", ",", "$", "path", ",", "$", "download", "=", "false", ")", "{", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"The specified file '\"", ".", "$", "path", ".", "\"' was not found in storage.\"", ")", ";", "}", "$", "chunk", "=", "\\", "Config", "::", "get", "(", "'df.file_chunk_size'", ")", ";", "FileUtilities", "::", "sendFile", "(", "$", "file", ",", "$", "download", ",", "$", "chunk", ")", ";", "}" ]
@param string $container @param string $path @param bool $download @throws \DreamFactory\Core\Exceptions\NotFoundException
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "bool", "$download" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L576-L585
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.writeFile
public function writeFile($container, $path, $content, $content_is_base = false, $check_exist = false) { // does this file already exist? if ($this->fileExists($container, $path)) { if (($check_exist)) { throw new InternalServerErrorException("File '$path' already exists."); } } // does this folder's parent exist? $parent = FileUtilities::getParentFolder($path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the file $this->checkContainerForWrite($container); // need to be able to write to storage if ($content_is_base) { $content = base64_decode($content); } $file = static::addContainerToName($container, $path); $result = file_put_contents($file, $content); if (false === $result) { throw new InternalServerErrorException('Failed to create file.'); } }
php
public function writeFile($container, $path, $content, $content_is_base = false, $check_exist = false) { // does this file already exist? if ($this->fileExists($container, $path)) { if (($check_exist)) { throw new InternalServerErrorException("File '$path' already exists."); } } // does this folder's parent exist? $parent = FileUtilities::getParentFolder($path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the file $this->checkContainerForWrite($container); // need to be able to write to storage if ($content_is_base) { $content = base64_decode($content); } $file = static::addContainerToName($container, $path); $result = file_put_contents($file, $content); if (false === $result) { throw new InternalServerErrorException('Failed to create file.'); } }
[ "public", "function", "writeFile", "(", "$", "container", ",", "$", "path", ",", "$", "content", ",", "$", "content_is_base", "=", "false", ",", "$", "check_exist", "=", "false", ")", "{", "// does this file already exist?", "if", "(", "$", "this", "->", "fileExists", "(", "$", "container", ",", "$", "path", ")", ")", "{", "if", "(", "(", "$", "check_exist", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "\"File '$path' already exists.\"", ")", ";", "}", "}", "// does this folder's parent exist?", "$", "parent", "=", "FileUtilities", "::", "getParentFolder", "(", "$", "path", ")", ";", "if", "(", "!", "empty", "(", "$", "parent", ")", "&&", "(", "!", "$", "this", "->", "folderExists", "(", "$", "container", ",", "$", "parent", ")", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$parent' does not exist.\"", ")", ";", "}", "// create the file", "$", "this", "->", "checkContainerForWrite", "(", "$", "container", ")", ";", "// need to be able to write to storage", "if", "(", "$", "content_is_base", ")", "{", "$", "content", "=", "base64_decode", "(", "$", "content", ")", ";", "}", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "$", "result", "=", "file_put_contents", "(", "$", "file", ",", "$", "content", ")", ";", "if", "(", "false", "===", "$", "result", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to create file.'", ")", ";", "}", "}" ]
@param string $container @param string $path @param string $content @param boolean $content_is_base @param bool $check_exist @throws NotFoundException @throws \Exception @return void
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "string", "$content", "@param", "boolean", "$content_is_base", "@param", "bool", "$check_exist" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L611-L635
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.moveFile
public function moveFile($container, $path, $local_path, $check_exist = true) { // does local file exist? if (!file_exists($local_path)) { throw new NotFoundException("File '$local_path' does not exist."); } // does this file already exist? if ($this->fileExists($container, $path)) { if (($check_exist)) { throw new BadRequestException("File '$path' already exists."); } } // does this file's parent folder exist? $parent = FileUtilities::getParentFolder($path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the file $this->checkContainerForWrite($container); // need to be able to write to storage $file = static::addContainerToName($container, $path); if (!rename($local_path, $file)) { throw new InternalServerErrorException("Failed to move file '$path'"); } }
php
public function moveFile($container, $path, $local_path, $check_exist = true) { // does local file exist? if (!file_exists($local_path)) { throw new NotFoundException("File '$local_path' does not exist."); } // does this file already exist? if ($this->fileExists($container, $path)) { if (($check_exist)) { throw new BadRequestException("File '$path' already exists."); } } // does this file's parent folder exist? $parent = FileUtilities::getParentFolder($path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the file $this->checkContainerForWrite($container); // need to be able to write to storage $file = static::addContainerToName($container, $path); if (!rename($local_path, $file)) { throw new InternalServerErrorException("Failed to move file '$path'"); } }
[ "public", "function", "moveFile", "(", "$", "container", ",", "$", "path", ",", "$", "local_path", ",", "$", "check_exist", "=", "true", ")", "{", "// does local file exist?", "if", "(", "!", "file_exists", "(", "$", "local_path", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"File '$local_path' does not exist.\"", ")", ";", "}", "// does this file already exist?", "if", "(", "$", "this", "->", "fileExists", "(", "$", "container", ",", "$", "path", ")", ")", "{", "if", "(", "(", "$", "check_exist", ")", ")", "{", "throw", "new", "BadRequestException", "(", "\"File '$path' already exists.\"", ")", ";", "}", "}", "// does this file's parent folder exist?", "$", "parent", "=", "FileUtilities", "::", "getParentFolder", "(", "$", "path", ")", ";", "if", "(", "!", "empty", "(", "$", "parent", ")", "&&", "(", "!", "$", "this", "->", "folderExists", "(", "$", "container", ",", "$", "parent", ")", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$parent' does not exist.\"", ")", ";", "}", "// create the file", "$", "this", "->", "checkContainerForWrite", "(", "$", "container", ")", ";", "// need to be able to write to storage", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "if", "(", "!", "rename", "(", "$", "local_path", ",", "$", "file", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "\"Failed to move file '$path'\"", ")", ";", "}", "}" ]
@param string $container @param string $path @param string $local_path @param bool $check_exist @throws \Exception @throws NotFoundException @throws BadRequestException @return void
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "string", "$local_path", "@param", "bool", "$check_exist" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L648-L672
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.copyFile
public function copyFile($container, $dest_path, $src_container, $src_path, $check_exist = false) { // does this file already exist? if (!$this->fileExists($src_container, $src_path)) { throw new NotFoundException("File '$src_path' does not exist."); } if ($this->fileExists($container, $dest_path)) { if (($check_exist)) { throw new BadRequestException("File '$dest_path' already exists."); } } // does this file's parent folder exist? $parent = FileUtilities::getParentFolder($dest_path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the file $this->checkContainerForWrite($container); // need to be able to write to storage $file = static::addContainerToName($src_container, $dest_path); $srcFile = static::addContainerToName($container, $src_path); $result = copy($srcFile, $file); if (!$result) { throw new InternalServerErrorException('Failed to copy file.'); } }
php
public function copyFile($container, $dest_path, $src_container, $src_path, $check_exist = false) { // does this file already exist? if (!$this->fileExists($src_container, $src_path)) { throw new NotFoundException("File '$src_path' does not exist."); } if ($this->fileExists($container, $dest_path)) { if (($check_exist)) { throw new BadRequestException("File '$dest_path' already exists."); } } // does this file's parent folder exist? $parent = FileUtilities::getParentFolder($dest_path); if (!empty($parent) && (!$this->folderExists($container, $parent))) { throw new NotFoundException("Folder '$parent' does not exist."); } // create the file $this->checkContainerForWrite($container); // need to be able to write to storage $file = static::addContainerToName($src_container, $dest_path); $srcFile = static::addContainerToName($container, $src_path); $result = copy($srcFile, $file); if (!$result) { throw new InternalServerErrorException('Failed to copy file.'); } }
[ "public", "function", "copyFile", "(", "$", "container", ",", "$", "dest_path", ",", "$", "src_container", ",", "$", "src_path", ",", "$", "check_exist", "=", "false", ")", "{", "// does this file already exist?", "if", "(", "!", "$", "this", "->", "fileExists", "(", "$", "src_container", ",", "$", "src_path", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"File '$src_path' does not exist.\"", ")", ";", "}", "if", "(", "$", "this", "->", "fileExists", "(", "$", "container", ",", "$", "dest_path", ")", ")", "{", "if", "(", "(", "$", "check_exist", ")", ")", "{", "throw", "new", "BadRequestException", "(", "\"File '$dest_path' already exists.\"", ")", ";", "}", "}", "// does this file's parent folder exist?", "$", "parent", "=", "FileUtilities", "::", "getParentFolder", "(", "$", "dest_path", ")", ";", "if", "(", "!", "empty", "(", "$", "parent", ")", "&&", "(", "!", "$", "this", "->", "folderExists", "(", "$", "container", ",", "$", "parent", ")", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$parent' does not exist.\"", ")", ";", "}", "// create the file", "$", "this", "->", "checkContainerForWrite", "(", "$", "container", ")", ";", "// need to be able to write to storage", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "src_container", ",", "$", "dest_path", ")", ";", "$", "srcFile", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "src_path", ")", ";", "$", "result", "=", "copy", "(", "$", "srcFile", ",", "$", "file", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to copy file.'", ")", ";", "}", "}" ]
@param string $container @param string $dest_path @param string $src_container @param string $src_path @param bool $check_exist @throws \Exception @throws NotFoundException @throws BadRequestException @return void
[ "@param", "string", "$container", "@param", "string", "$dest_path", "@param", "string", "$src_container", "@param", "string", "$src_path", "@param", "bool", "$check_exist" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L686-L711
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.deleteFile
public function deleteFile($container, $path, $noCheck = false) { $file = static::addContainerToName($container, $path); if (!$noCheck && !is_file($file)) { throw new NotFoundException("File '$file' was not found."); } if (!unlink($file)) { throw new InternalServerErrorException('Failed to delete file.'); } }
php
public function deleteFile($container, $path, $noCheck = false) { $file = static::addContainerToName($container, $path); if (!$noCheck && !is_file($file)) { throw new NotFoundException("File '$file' was not found."); } if (!unlink($file)) { throw new InternalServerErrorException('Failed to delete file.'); } }
[ "public", "function", "deleteFile", "(", "$", "container", ",", "$", "path", ",", "$", "noCheck", "=", "false", ")", "{", "$", "file", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "if", "(", "!", "$", "noCheck", "&&", "!", "is_file", "(", "$", "file", ")", ")", "{", "throw", "new", "NotFoundException", "(", "\"File '$file' was not found.\"", ")", ";", "}", "if", "(", "!", "unlink", "(", "$", "file", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to delete file.'", ")", ";", "}", "}" ]
@param string $container @param string $path @param bool $noCheck @throws \Exception @throws BadRequestException @return void
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "bool", "$noCheck" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L722-L731
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.deleteFiles
public function deleteFiles($container, $files, $root = '') { $root = FileUtilities::fixFolderPath($root); foreach ($files as $key => $fileInfo) { try { // path is full path, name is relative to root, take either $path = array_get($fileInfo, 'path'); if (!empty($path)) { $file = static::asFullPath($path, true); if (!is_file($file)) { throw new BadRequestException("'$path' is not a valid file."); } if (!unlink($file)) { throw new InternalServerErrorException("Failed to delete file '$path'."); } } else { $name = array_get($fileInfo, 'name'); if (!empty($name)) { $path = $root . $name; $this->deleteFile($container, $path); } else { throw new BadRequestException('No path or name found for file in delete request.'); } } } catch (\Exception $ex) { // error whole batch here? $files[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()]; } } return $files; }
php
public function deleteFiles($container, $files, $root = '') { $root = FileUtilities::fixFolderPath($root); foreach ($files as $key => $fileInfo) { try { // path is full path, name is relative to root, take either $path = array_get($fileInfo, 'path'); if (!empty($path)) { $file = static::asFullPath($path, true); if (!is_file($file)) { throw new BadRequestException("'$path' is not a valid file."); } if (!unlink($file)) { throw new InternalServerErrorException("Failed to delete file '$path'."); } } else { $name = array_get($fileInfo, 'name'); if (!empty($name)) { $path = $root . $name; $this->deleteFile($container, $path); } else { throw new BadRequestException('No path or name found for file in delete request.'); } } } catch (\Exception $ex) { // error whole batch here? $files[$key]['error'] = ['message' => $ex->getMessage(), 'code' => $ex->getCode()]; } } return $files; }
[ "public", "function", "deleteFiles", "(", "$", "container", ",", "$", "files", ",", "$", "root", "=", "''", ")", "{", "$", "root", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "root", ")", ";", "foreach", "(", "$", "files", "as", "$", "key", "=>", "$", "fileInfo", ")", "{", "try", "{", "// path is full path, name is relative to root, take either", "$", "path", "=", "array_get", "(", "$", "fileInfo", ",", "'path'", ")", ";", "if", "(", "!", "empty", "(", "$", "path", ")", ")", "{", "$", "file", "=", "static", "::", "asFullPath", "(", "$", "path", ",", "true", ")", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "{", "throw", "new", "BadRequestException", "(", "\"'$path' is not a valid file.\"", ")", ";", "}", "if", "(", "!", "unlink", "(", "$", "file", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "\"Failed to delete file '$path'.\"", ")", ";", "}", "}", "else", "{", "$", "name", "=", "array_get", "(", "$", "fileInfo", ",", "'name'", ")", ";", "if", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "$", "path", "=", "$", "root", ".", "$", "name", ";", "$", "this", "->", "deleteFile", "(", "$", "container", ",", "$", "path", ")", ";", "}", "else", "{", "throw", "new", "BadRequestException", "(", "'No path or name found for file in delete request.'", ")", ";", "}", "}", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "// error whole batch here?", "$", "files", "[", "$", "key", "]", "[", "'error'", "]", "=", "[", "'message'", "=>", "$", "ex", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "ex", "->", "getCode", "(", ")", "]", ";", "}", "}", "return", "$", "files", ";", "}" ]
@param string $container @param array $files @param string $root @throws BadRequestException @return array
[ "@param", "string", "$container", "@param", "array", "$files", "@param", "string", "$root" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L741-L772
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.extractZipFile
public function extractZipFile($container, $path, $zip, $clean = false, $drop_path = '') { if ($clean) { try { // clear out anything in this directory $dir = static::addContainerToName($container, $path); FileUtilities::deleteTree($dir, true, false); } catch (\Exception $ex) { throw new InternalServerErrorException("Could not clean out existing directory $path.\n{$ex->getMessage()}"); } } for ($i = 0; $i < $zip->numFiles; $i++) { $name = $zip->getNameIndex($i); if (empty($name)) { continue; } if (!empty($drop_path)) { $name = str_ireplace($drop_path, '', $name); } $fullPathName = $path . $name; if ('/' === substr($fullPathName, -1)) { $this->createFolder($container, $fullPathName, true, [], false); } else { $parent = FileUtilities::getParentFolder($fullPathName); if (!empty($parent)) { $this->createFolder($container, $parent, true, [], false); } $content = $zip->getFromIndex($i); $this->writeFile($container, $fullPathName, $content); } } return [ 'name' => rtrim($path, DIRECTORY_SEPARATOR), 'path' => $path, 'type' => 'file' ]; }
php
public function extractZipFile($container, $path, $zip, $clean = false, $drop_path = '') { if ($clean) { try { // clear out anything in this directory $dir = static::addContainerToName($container, $path); FileUtilities::deleteTree($dir, true, false); } catch (\Exception $ex) { throw new InternalServerErrorException("Could not clean out existing directory $path.\n{$ex->getMessage()}"); } } for ($i = 0; $i < $zip->numFiles; $i++) { $name = $zip->getNameIndex($i); if (empty($name)) { continue; } if (!empty($drop_path)) { $name = str_ireplace($drop_path, '', $name); } $fullPathName = $path . $name; if ('/' === substr($fullPathName, -1)) { $this->createFolder($container, $fullPathName, true, [], false); } else { $parent = FileUtilities::getParentFolder($fullPathName); if (!empty($parent)) { $this->createFolder($container, $parent, true, [], false); } $content = $zip->getFromIndex($i); $this->writeFile($container, $fullPathName, $content); } } return [ 'name' => rtrim($path, DIRECTORY_SEPARATOR), 'path' => $path, 'type' => 'file' ]; }
[ "public", "function", "extractZipFile", "(", "$", "container", ",", "$", "path", ",", "$", "zip", ",", "$", "clean", "=", "false", ",", "$", "drop_path", "=", "''", ")", "{", "if", "(", "$", "clean", ")", "{", "try", "{", "// clear out anything in this directory", "$", "dir", "=", "static", "::", "addContainerToName", "(", "$", "container", ",", "$", "path", ")", ";", "FileUtilities", "::", "deleteTree", "(", "$", "dir", ",", "true", ",", "false", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "throw", "new", "InternalServerErrorException", "(", "\"Could not clean out existing directory $path.\\n{$ex->getMessage()}\"", ")", ";", "}", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "zip", "->", "numFiles", ";", "$", "i", "++", ")", "{", "$", "name", "=", "$", "zip", "->", "getNameIndex", "(", "$", "i", ")", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "empty", "(", "$", "drop_path", ")", ")", "{", "$", "name", "=", "str_ireplace", "(", "$", "drop_path", ",", "''", ",", "$", "name", ")", ";", "}", "$", "fullPathName", "=", "$", "path", ".", "$", "name", ";", "if", "(", "'/'", "===", "substr", "(", "$", "fullPathName", ",", "-", "1", ")", ")", "{", "$", "this", "->", "createFolder", "(", "$", "container", ",", "$", "fullPathName", ",", "true", ",", "[", "]", ",", "false", ")", ";", "}", "else", "{", "$", "parent", "=", "FileUtilities", "::", "getParentFolder", "(", "$", "fullPathName", ")", ";", "if", "(", "!", "empty", "(", "$", "parent", ")", ")", "{", "$", "this", "->", "createFolder", "(", "$", "container", ",", "$", "parent", ",", "true", ",", "[", "]", ",", "false", ")", ";", "}", "$", "content", "=", "$", "zip", "->", "getFromIndex", "(", "$", "i", ")", ";", "$", "this", "->", "writeFile", "(", "$", "container", ",", "$", "fullPathName", ",", "$", "content", ")", ";", "}", "}", "return", "[", "'name'", "=>", "rtrim", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ",", "'path'", "=>", "$", "path", ",", "'type'", "=>", "'file'", "]", ";", "}" ]
@param string $container @param string $path @param \ZipArchive $zip @param bool $clean @param string $drop_path @throws \Exception @return array
[ "@param", "string", "$container", "@param", "string", "$path", "@param", "\\", "ZipArchive", "$zip", "@param", "bool", "$clean", "@param", "string", "$drop_path" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L825-L862
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.asFullPath
private static function asFullPath($name, $includesFiles = false) { $appendage = ($name ? '/' . ltrim($name, '/') : null); return static::$root . $appendage; //return Platform::getStoragePath( $name, true, $includesFiles ); }
php
private static function asFullPath($name, $includesFiles = false) { $appendage = ($name ? '/' . ltrim($name, '/') : null); return static::$root . $appendage; //return Platform::getStoragePath( $name, true, $includesFiles ); }
[ "private", "static", "function", "asFullPath", "(", "$", "name", ",", "$", "includesFiles", "=", "false", ")", "{", "$", "appendage", "=", "(", "$", "name", "?", "'/'", ".", "ltrim", "(", "$", "name", ",", "'/'", ")", ":", "null", ")", ";", "return", "static", "::", "$", "root", ".", "$", "appendage", ";", "//return Platform::getStoragePath( $name, true, $includesFiles );", "}" ]
@param $name @param bool $includesFiles @return string
[ "@param", "$name", "@param", "bool", "$includesFiles" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L870-L876
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.addContainerToName
private static function addContainerToName($container, $name) { if (!empty($container)) { $container = FileUtilities::fixFolderPath($container); } return static::asFullPath($container . $name, true); }
php
private static function addContainerToName($container, $name) { if (!empty($container)) { $container = FileUtilities::fixFolderPath($container); } return static::asFullPath($container . $name, true); }
[ "private", "static", "function", "addContainerToName", "(", "$", "container", ",", "$", "name", ")", "{", "if", "(", "!", "empty", "(", "$", "container", ")", ")", "{", "$", "container", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "container", ")", ";", "}", "return", "static", "::", "asFullPath", "(", "$", "container", ".", "$", "name", ",", "true", ")", ";", "}" ]
@param $container @param $name @return string
[ "@param", "$container", "@param", "$name" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L895-L902
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.removeContainerFromName
private static function removeContainerFromName($container, $name) { $name = static::asLocalPath($name); if (empty($container)) { return $name; } $container = FileUtilities::fixFolderPath($container); return substr($name, strlen($container) + 1); }
php
private static function removeContainerFromName($container, $name) { $name = static::asLocalPath($name); if (empty($container)) { return $name; } $container = FileUtilities::fixFolderPath($container); return substr($name, strlen($container) + 1); }
[ "private", "static", "function", "removeContainerFromName", "(", "$", "container", ",", "$", "name", ")", "{", "$", "name", "=", "static", "::", "asLocalPath", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "container", ")", ")", "{", "return", "$", "name", ";", "}", "$", "container", "=", "FileUtilities", "::", "fixFolderPath", "(", "$", "container", ")", ";", "return", "substr", "(", "$", "name", ",", "strlen", "(", "$", "container", ")", "+", "1", ")", ";", "}" ]
@param $container @param $name @return string
[ "@param", "$container", "@param", "$name" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L910-L920
dreamfactorysoftware/df-file
src/Components/LocalFileSystem.php
LocalFileSystem.listTree
public static function listTree($root, $prefix = '', $delimiter = '') { $dir = $root . ((!empty($prefix)) ? $prefix : ''); $out = []; if (is_dir($dir)) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $key = $dir . $file; $local = ((!empty($prefix)) ? $prefix : '') . $file; // get file meta if (is_dir($key)) { $stat = stat($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local) . '/', 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)) ]; if (empty($delimiter)) { $out = array_merge($out, static::listTree($root, $local . DIRECTORY_SEPARATOR)); } } elseif (is_file($key)) { $stat = stat($key); $ext = FileUtilities::getFileExtension($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local), 'content_type' => FileUtilities::determineContentType($ext, '', $key), 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)), 'content_length' => array_get($stat, 'size', 0) ]; } else { error_log($key); } } } else { throw new NotFoundException("Folder '$prefix' does not exist in storage."); } return $out; }
php
public static function listTree($root, $prefix = '', $delimiter = '') { $dir = $root . ((!empty($prefix)) ? $prefix : ''); $out = []; if (is_dir($dir)) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $key = $dir . $file; $local = ((!empty($prefix)) ? $prefix : '') . $file; // get file meta if (is_dir($key)) { $stat = stat($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local) . '/', 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)) ]; if (empty($delimiter)) { $out = array_merge($out, static::listTree($root, $local . DIRECTORY_SEPARATOR)); } } elseif (is_file($key)) { $stat = stat($key); $ext = FileUtilities::getFileExtension($key); $out[] = [ 'path' => str_replace(DIRECTORY_SEPARATOR, '/', $local), 'content_type' => FileUtilities::determineContentType($ext, '', $key), 'last_modified' => gmdate('D, d M Y H:i:s \G\M\T', array_get($stat, 'mtime', 0)), 'content_length' => array_get($stat, 'size', 0) ]; } else { error_log($key); } } } else { throw new NotFoundException("Folder '$prefix' does not exist in storage."); } return $out; }
[ "public", "static", "function", "listTree", "(", "$", "root", ",", "$", "prefix", "=", "''", ",", "$", "delimiter", "=", "''", ")", "{", "$", "dir", "=", "$", "root", ".", "(", "(", "!", "empty", "(", "$", "prefix", ")", ")", "?", "$", "prefix", ":", "''", ")", ";", "$", "out", "=", "[", "]", ";", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "files", "=", "array_diff", "(", "scandir", "(", "$", "dir", ")", ",", "[", "'.'", ",", "'..'", "]", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "key", "=", "$", "dir", ".", "$", "file", ";", "$", "local", "=", "(", "(", "!", "empty", "(", "$", "prefix", ")", ")", "?", "$", "prefix", ":", "''", ")", ".", "$", "file", ";", "// get file meta", "if", "(", "is_dir", "(", "$", "key", ")", ")", "{", "$", "stat", "=", "stat", "(", "$", "key", ")", ";", "$", "out", "[", "]", "=", "[", "'path'", "=>", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "local", ")", ".", "'/'", ",", "'last_modified'", "=>", "gmdate", "(", "'D, d M Y H:i:s \\G\\M\\T'", ",", "array_get", "(", "$", "stat", ",", "'mtime'", ",", "0", ")", ")", "]", ";", "if", "(", "empty", "(", "$", "delimiter", ")", ")", "{", "$", "out", "=", "array_merge", "(", "$", "out", ",", "static", "::", "listTree", "(", "$", "root", ",", "$", "local", ".", "DIRECTORY_SEPARATOR", ")", ")", ";", "}", "}", "elseif", "(", "is_file", "(", "$", "key", ")", ")", "{", "$", "stat", "=", "stat", "(", "$", "key", ")", ";", "$", "ext", "=", "FileUtilities", "::", "getFileExtension", "(", "$", "key", ")", ";", "$", "out", "[", "]", "=", "[", "'path'", "=>", "str_replace", "(", "DIRECTORY_SEPARATOR", ",", "'/'", ",", "$", "local", ")", ",", "'content_type'", "=>", "FileUtilities", "::", "determineContentType", "(", "$", "ext", ",", "''", ",", "$", "key", ")", ",", "'last_modified'", "=>", "gmdate", "(", "'D, d M Y H:i:s \\G\\M\\T'", ",", "array_get", "(", "$", "stat", ",", "'mtime'", ",", "0", ")", ")", ",", "'content_length'", "=>", "array_get", "(", "$", "stat", ",", "'size'", ",", "0", ")", "]", ";", "}", "else", "{", "error_log", "(", "$", "key", ")", ";", "}", "}", "}", "else", "{", "throw", "new", "NotFoundException", "(", "\"Folder '$prefix' does not exist in storage.\"", ")", ";", "}", "return", "$", "out", ";", "}" ]
List folders and files @param string $root root path name @param string $prefix Optional. search only for folders and files by specified prefix. @param string $delimiter Optional. Delimiter, i.e. '/', for specifying folder hierarchy @return array @throws \Exception
[ "List", "folders", "and", "files" ]
train
https://github.com/dreamfactorysoftware/df-file/blob/e78aaec3e1d6585b5e7fe9b7646af4b1180ecd66/src/Components/LocalFileSystem.php#L932-L969
voda/php-translator
Antee/i18n/TranslateMacros.php
TranslateMacros.install
public static function install(Compiler $parser) { $me = new static($parser); $callback = array($me, 'macroGettext'); $me->addMacro('_', $callback); $me->addMacro('_n', $callback); $me->addMacro('_p', $callback); $me->addMacro('_np', $callback); }
php
public static function install(Compiler $parser) { $me = new static($parser); $callback = array($me, 'macroGettext'); $me->addMacro('_', $callback); $me->addMacro('_n', $callback); $me->addMacro('_p', $callback); $me->addMacro('_np', $callback); }
[ "public", "static", "function", "install", "(", "Compiler", "$", "parser", ")", "{", "$", "me", "=", "new", "static", "(", "$", "parser", ")", ";", "$", "callback", "=", "array", "(", "$", "me", ",", "'macroGettext'", ")", ";", "$", "me", "->", "addMacro", "(", "'_'", ",", "$", "callback", ")", ";", "$", "me", "->", "addMacro", "(", "'_n'", ",", "$", "callback", ")", ";", "$", "me", "->", "addMacro", "(", "'_p'", ",", "$", "callback", ")", ";", "$", "me", "->", "addMacro", "(", "'_np'", ",", "$", "callback", ")", ";", "}" ]
Add gettext macros @param Template @param ITranslator
[ "Add", "gettext", "macros" ]
train
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/TranslateMacros.php#L65-L72
voda/php-translator
Antee/i18n/TranslateMacros.php
TranslateMacros.registerHelpers
public static function registerHelpers(Template $template, ITranslator $translator) { $template->registerHelper('gettext', array($translator, 'gettext')); $template->registerHelper('ngettext', array($translator, 'ngettext')); $template->registerHelper('pgettext', array($translator, 'pgettext')); $template->registerHelper('npgettext', array($translator, 'npgettext')); }
php
public static function registerHelpers(Template $template, ITranslator $translator) { $template->registerHelper('gettext', array($translator, 'gettext')); $template->registerHelper('ngettext', array($translator, 'ngettext')); $template->registerHelper('pgettext', array($translator, 'pgettext')); $template->registerHelper('npgettext', array($translator, 'npgettext')); }
[ "public", "static", "function", "registerHelpers", "(", "Template", "$", "template", ",", "ITranslator", "$", "translator", ")", "{", "$", "template", "->", "registerHelper", "(", "'gettext'", ",", "array", "(", "$", "translator", ",", "'gettext'", ")", ")", ";", "$", "template", "->", "registerHelper", "(", "'ngettext'", ",", "array", "(", "$", "translator", ",", "'ngettext'", ")", ")", ";", "$", "template", "->", "registerHelper", "(", "'pgettext'", ",", "array", "(", "$", "translator", ",", "'pgettext'", ")", ")", ";", "$", "template", "->", "registerHelper", "(", "'npgettext'", ",", "array", "(", "$", "translator", ",", "'npgettext'", ")", ")", ";", "}" ]
Add gettext helpers to template. @param Template @param ITranslator
[ "Add", "gettext", "helpers", "to", "template", "." ]
train
https://github.com/voda/php-translator/blob/b1890ce89f7185b8958e6cf89cf2ad231d5e5f58/Antee/i18n/TranslateMacros.php#L80-L85
inpsyde/inpsyde-filter
src/WordPress/Absint.php
Absint.filter
public function filter( $value ) { if ( ! is_scalar( $value ) || empty( $value ) ) { do_action( 'inpsyde.filter.error', 'The given value is not scalar or empty.', [ 'method' => __METHOD__, 'value' => $value ] ); return $value; } return absint( $value ); }
php
public function filter( $value ) { if ( ! is_scalar( $value ) || empty( $value ) ) { do_action( 'inpsyde.filter.error', 'The given value is not scalar or empty.', [ 'method' => __METHOD__, 'value' => $value ] ); return $value; } return absint( $value ); }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "if", "(", "!", "is_scalar", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "do_action", "(", "'inpsyde.filter.error'", ",", "'The given value is not scalar or empty.'", ",", "[", "'method'", "=>", "__METHOD__", ",", "'value'", "=>", "$", "value", "]", ")", ";", "return", "$", "value", ";", "}", "return", "absint", "(", "$", "value", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/WordPress/Absint.php#L17-L26
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.getFieldNames
public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) { if (!array_key_exists($type, UserRolePeer::$fieldNames)) { throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); } return UserRolePeer::$fieldNames[$type]; }
php
public static function getFieldNames($type = BasePeer::TYPE_PHPNAME) { if (!array_key_exists($type, UserRolePeer::$fieldNames)) { throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.'); } return UserRolePeer::$fieldNames[$type]; }
[ "public", "static", "function", "getFieldNames", "(", "$", "type", "=", "BasePeer", "::", "TYPE_PHPNAME", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "UserRolePeer", "::", "$", "fieldNames", ")", ")", "{", "throw", "new", "PropelException", "(", "'Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. '", ".", "$", "type", ".", "' was given.'", ")", ";", "}", "return", "UserRolePeer", "::", "$", "fieldNames", "[", "$", "type", "]", ";", "}" ]
Returns an array of field names. @param string $type The type of fieldnames to return: One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM @return array A list of field names @throws PropelException - if the type is not valid.
[ "Returns", "an", "array", "of", "field", "names", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L120-L127
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.addSelectColumns
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(UserRolePeer::USER_ID); $criteria->addSelectColumn(UserRolePeer::ROLE_ID); } else { $criteria->addSelectColumn($alias . '.user_id'); $criteria->addSelectColumn($alias . '.role_id'); } }
php
public static function addSelectColumns(Criteria $criteria, $alias = null) { if (null === $alias) { $criteria->addSelectColumn(UserRolePeer::USER_ID); $criteria->addSelectColumn(UserRolePeer::ROLE_ID); } else { $criteria->addSelectColumn($alias . '.user_id'); $criteria->addSelectColumn($alias . '.role_id'); } }
[ "public", "static", "function", "addSelectColumns", "(", "Criteria", "$", "criteria", ",", "$", "alias", "=", "null", ")", "{", "if", "(", "null", "===", "$", "alias", ")", "{", "$", "criteria", "->", "addSelectColumn", "(", "UserRolePeer", "::", "USER_ID", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "UserRolePeer", "::", "ROLE_ID", ")", ";", "}", "else", "{", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.user_id'", ")", ";", "$", "criteria", "->", "addSelectColumn", "(", "$", "alias", ".", "'.role_id'", ")", ";", "}", "}" ]
Add all the columns needed to create a new object. Note: any columns that were marked with lazyLoad="true" in the XML schema will not be added to the select list and only loaded on demand. @param Criteria $criteria object containing the columns to add. @param string $alias optional table alias @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Add", "all", "the", "columns", "needed", "to", "create", "a", "new", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L158-L167
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.removeInstanceFromPool
public static function removeInstanceFromPool($value) { if (Propel::isInstancePoolingEnabled() && $value !== null) { if (is_object($value) && $value instanceof UserRole) { $key = serialize(array((string) $value->getUserId(), (string) $value->getRoleId())); } elseif (is_array($value) && count($value) === 2) { // assume we've been passed a primary key $key = serialize(array((string) $value[0], (string) $value[1])); } else { $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or UserRole object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); throw $e; } unset(UserRolePeer::$instances[$key]); } }
php
public static function removeInstanceFromPool($value) { if (Propel::isInstancePoolingEnabled() && $value !== null) { if (is_object($value) && $value instanceof UserRole) { $key = serialize(array((string) $value->getUserId(), (string) $value->getRoleId())); } elseif (is_array($value) && count($value) === 2) { // assume we've been passed a primary key $key = serialize(array((string) $value[0], (string) $value[1])); } else { $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or UserRole object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true))); throw $e; } unset(UserRolePeer::$instances[$key]); } }
[ "public", "static", "function", "removeInstanceFromPool", "(", "$", "value", ")", "{", "if", "(", "Propel", "::", "isInstancePoolingEnabled", "(", ")", "&&", "$", "value", "!==", "null", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", "&&", "$", "value", "instanceof", "UserRole", ")", "{", "$", "key", "=", "serialize", "(", "array", "(", "(", "string", ")", "$", "value", "->", "getUserId", "(", ")", ",", "(", "string", ")", "$", "value", "->", "getRoleId", "(", ")", ")", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", "&&", "count", "(", "$", "value", ")", "===", "2", ")", "{", "// assume we've been passed a primary key", "$", "key", "=", "serialize", "(", "array", "(", "(", "string", ")", "$", "value", "[", "0", "]", ",", "(", "string", ")", "$", "value", "[", "1", "]", ")", ")", ";", "}", "else", "{", "$", "e", "=", "new", "PropelException", "(", "\"Invalid value passed to removeInstanceFromPool(). Expected primary key or UserRole object; got \"", ".", "(", "is_object", "(", "$", "value", ")", "?", "get_class", "(", "$", "value", ")", ".", "' object.'", ":", "var_export", "(", "$", "value", ",", "true", ")", ")", ")", ";", "throw", "$", "e", ";", "}", "unset", "(", "UserRolePeer", "::", "$", "instances", "[", "$", "key", "]", ")", ";", "}", "}" ]
Removes an object from the instance pool. Propel keeps cached copies of objects in an instance pool when they are retrieved from the database. In some cases -- especially when you override doDelete methods in your stub classes -- you may need to explicitly remove objects from the cache in order to prevent returning objects that no longer exist. @param mixed $value A UserRole object or a primary key value. @return void @throws PropelException - if the value is invalid.
[ "Removes", "an", "object", "from", "the", "instance", "pool", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L311-L326
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.getInstanceFromPool
public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(UserRolePeer::$instances[$key])) { return UserRolePeer::$instances[$key]; } } return null; // just to be explicit }
php
public static function getInstanceFromPool($key) { if (Propel::isInstancePoolingEnabled()) { if (isset(UserRolePeer::$instances[$key])) { return UserRolePeer::$instances[$key]; } } return null; // just to be explicit }
[ "public", "static", "function", "getInstanceFromPool", "(", "$", "key", ")", "{", "if", "(", "Propel", "::", "isInstancePoolingEnabled", "(", ")", ")", "{", "if", "(", "isset", "(", "UserRolePeer", "::", "$", "instances", "[", "$", "key", "]", ")", ")", "{", "return", "UserRolePeer", "::", "$", "instances", "[", "$", "key", "]", ";", "}", "}", "return", "null", ";", "// just to be explicit", "}" ]
Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. For tables with a single-column primary key, that simple pkey value will be returned. For tables with a multi-column primary key, a serialize()d version of the primary key will be returned. @param string $key The key (@see getPrimaryKeyHash()) for this instance. @return UserRole Found object or null if 1) no instance exists for specified key or 2) instance pooling has been disabled. @see getPrimaryKeyHash()
[ "Retrieves", "a", "string", "version", "of", "the", "primary", "key", "from", "the", "DB", "resultset", "row", "that", "can", "be", "used", "to", "uniquely", "identify", "a", "row", "in", "this", "table", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L338-L347
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.getPrimaryKeyHashFromRow
public static function getPrimaryKeyHashFromRow($row, $startcol = 0) { // If the PK cannot be derived from the row, return null. if ($row[$startcol] === null && $row[$startcol + 1] === null) { return null; } return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); }
php
public static function getPrimaryKeyHashFromRow($row, $startcol = 0) { // If the PK cannot be derived from the row, return null. if ($row[$startcol] === null && $row[$startcol + 1] === null) { return null; } return serialize(array((string) $row[$startcol], (string) $row[$startcol + 1])); }
[ "public", "static", "function", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "$", "startcol", "=", "0", ")", "{", "// If the PK cannot be derived from the row, return null.", "if", "(", "$", "row", "[", "$", "startcol", "]", "===", "null", "&&", "$", "row", "[", "$", "startcol", "+", "1", "]", "===", "null", ")", "{", "return", "null", ";", "}", "return", "serialize", "(", "array", "(", "(", "string", ")", "$", "row", "[", "$", "startcol", "]", ",", "(", "string", ")", "$", "row", "[", "$", "startcol", "+", "1", "]", ")", ")", ";", "}" ]
Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. For tables with a single-column primary key, that simple pkey value will be returned. For tables with a multi-column primary key, a serialize()d version of the primary key will be returned. @param array $row PropelPDO resultset row. @param int $startcol The 0-based offset for reading from the resultset row. @return string A string version of PK or null if the components of primary key in result array are all null.
[ "Retrieves", "a", "string", "version", "of", "the", "primary", "key", "from", "the", "DB", "resultset", "row", "that", "can", "be", "used", "to", "uniquely", "identify", "a", "row", "in", "this", "table", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L382-L390
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.doSelectJoinAll
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(UserRolePeer::DATABASE_NAME); } UserRolePeer::addSelectColumns($criteria); $startcol2 = UserRolePeer::NUM_HYDRATE_COLUMNS; UserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS; RolePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RolePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(UserRolePeer::USER_ID, UserPeer::ID, $join_behavior); $criteria->addJoin(UserRolePeer::ROLE_ID, RolePeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UserRolePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UserRolePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = UserRolePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); UserRolePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined User rows $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = UserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = UserPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); UserPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (UserRole) to the collection in $obj2 (User) $obj2->addUserRole($obj1); } // if joined row not null // Add objects for joined Role rows $key3 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RolePeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RolePeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RolePeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (UserRole) to the collection in $obj3 (Role) $obj3->addUserRole($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
php
public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(UserRolePeer::DATABASE_NAME); } UserRolePeer::addSelectColumns($criteria); $startcol2 = UserRolePeer::NUM_HYDRATE_COLUMNS; UserPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + UserPeer::NUM_HYDRATE_COLUMNS; RolePeer::addSelectColumns($criteria); $startcol4 = $startcol3 + RolePeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(UserRolePeer::USER_ID, UserPeer::ID, $join_behavior); $criteria->addJoin(UserRolePeer::ROLE_ID, RolePeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = UserRolePeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = UserRolePeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = UserRolePeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); UserRolePeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined User rows $key2 = UserPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = UserPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = UserPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); UserPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (UserRole) to the collection in $obj2 (User) $obj2->addUserRole($obj1); } // if joined row not null // Add objects for joined Role rows $key3 = RolePeer::getPrimaryKeyHashFromRow($row, $startcol3); if ($key3 !== null) { $obj3 = RolePeer::getInstanceFromPool($key3); if (!$obj3) { $cls = RolePeer::getOMClass(); $obj3 = new $cls(); $obj3->hydrate($row, $startcol3); RolePeer::addInstanceToPool($obj3, $key3); } // if obj3 loaded // Add the $obj1 (UserRole) to the collection in $obj3 (Role) $obj3->addUserRole($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
[ "public", "static", "function", "doSelectJoinAll", "(", "Criteria", "$", "criteria", ",", "$", "con", "=", "null", ",", "$", "join_behavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "criteria", "=", "clone", "$", "criteria", ";", "// Set the correct dbName if it has not been overridden", "if", "(", "$", "criteria", "->", "getDbName", "(", ")", "==", "Propel", "::", "getDefaultDB", "(", ")", ")", "{", "$", "criteria", "->", "setDbName", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "}", "UserRolePeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "$", "startcol2", "=", "UserRolePeer", "::", "NUM_HYDRATE_COLUMNS", ";", "UserPeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "$", "startcol3", "=", "$", "startcol2", "+", "UserPeer", "::", "NUM_HYDRATE_COLUMNS", ";", "RolePeer", "::", "addSelectColumns", "(", "$", "criteria", ")", ";", "$", "startcol4", "=", "$", "startcol3", "+", "RolePeer", "::", "NUM_HYDRATE_COLUMNS", ";", "$", "criteria", "->", "addJoin", "(", "UserRolePeer", "::", "USER_ID", ",", "UserPeer", "::", "ID", ",", "$", "join_behavior", ")", ";", "$", "criteria", "->", "addJoin", "(", "UserRolePeer", "::", "ROLE_ID", ",", "RolePeer", "::", "ID", ",", "$", "join_behavior", ")", ";", "$", "stmt", "=", "BasePeer", "::", "doSelect", "(", "$", "criteria", ",", "$", "con", ")", ";", "$", "results", "=", "array", "(", ")", ";", "while", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "PDO", "::", "FETCH_NUM", ")", ")", "{", "$", "key1", "=", "UserRolePeer", "::", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "0", ")", ";", "if", "(", "null", "!==", "(", "$", "obj1", "=", "UserRolePeer", "::", "getInstanceFromPool", "(", "$", "key1", ")", ")", ")", "{", "// We no longer rehydrate the object, since this can cause data loss.", "// See http://www.propelorm.org/ticket/509", "// $obj1->hydrate($row, 0, true); // rehydrate", "}", "else", "{", "$", "cls", "=", "UserRolePeer", "::", "getOMClass", "(", ")", ";", "$", "obj1", "=", "new", "$", "cls", "(", ")", ";", "$", "obj1", "->", "hydrate", "(", "$", "row", ")", ";", "UserRolePeer", "::", "addInstanceToPool", "(", "$", "obj1", ",", "$", "key1", ")", ";", "}", "// if obj1 already loaded", "// Add objects for joined User rows", "$", "key2", "=", "UserPeer", "::", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "$", "startcol2", ")", ";", "if", "(", "$", "key2", "!==", "null", ")", "{", "$", "obj2", "=", "UserPeer", "::", "getInstanceFromPool", "(", "$", "key2", ")", ";", "if", "(", "!", "$", "obj2", ")", "{", "$", "cls", "=", "UserPeer", "::", "getOMClass", "(", ")", ";", "$", "obj2", "=", "new", "$", "cls", "(", ")", ";", "$", "obj2", "->", "hydrate", "(", "$", "row", ",", "$", "startcol2", ")", ";", "UserPeer", "::", "addInstanceToPool", "(", "$", "obj2", ",", "$", "key2", ")", ";", "}", "// if obj2 loaded", "// Add the $obj1 (UserRole) to the collection in $obj2 (User)", "$", "obj2", "->", "addUserRole", "(", "$", "obj1", ")", ";", "}", "// if joined row not null", "// Add objects for joined Role rows", "$", "key3", "=", "RolePeer", "::", "getPrimaryKeyHashFromRow", "(", "$", "row", ",", "$", "startcol3", ")", ";", "if", "(", "$", "key3", "!==", "null", ")", "{", "$", "obj3", "=", "RolePeer", "::", "getInstanceFromPool", "(", "$", "key3", ")", ";", "if", "(", "!", "$", "obj3", ")", "{", "$", "cls", "=", "RolePeer", "::", "getOMClass", "(", ")", ";", "$", "obj3", "=", "new", "$", "cls", "(", ")", ";", "$", "obj3", "->", "hydrate", "(", "$", "row", ",", "$", "startcol3", ")", ";", "RolePeer", "::", "addInstanceToPool", "(", "$", "obj3", ",", "$", "key3", ")", ";", "}", "// if obj3 loaded", "// Add the $obj1 (UserRole) to the collection in $obj3 (Role)", "$", "obj3", "->", "addUserRole", "(", "$", "obj1", ")", ";", "}", "// if joined row not null", "$", "results", "[", "]", "=", "$", "obj1", ";", "}", "$", "stmt", "->", "closeCursor", "(", ")", ";", "return", "$", "results", ";", "}" ]
Selects a collection of UserRole objects pre-filled with all related objects. @param Criteria $criteria @param PropelPDO $con @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN @return array Array of UserRole objects. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Selects", "a", "collection", "of", "UserRole", "objects", "pre", "-", "filled", "with", "all", "related", "objects", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L765-L845
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.buildTableMap
public static function buildTableMap() { $dbMap = Propel::getDatabaseMap(BaseUserRolePeer::DATABASE_NAME); if (!$dbMap->hasTable(BaseUserRolePeer::TABLE_NAME)) { $dbMap->addTableObject(new \Slashworks\BackendBundle\Model\map\UserRoleTableMap()); } }
php
public static function buildTableMap() { $dbMap = Propel::getDatabaseMap(BaseUserRolePeer::DATABASE_NAME); if (!$dbMap->hasTable(BaseUserRolePeer::TABLE_NAME)) { $dbMap->addTableObject(new \Slashworks\BackendBundle\Model\map\UserRoleTableMap()); } }
[ "public", "static", "function", "buildTableMap", "(", ")", "{", "$", "dbMap", "=", "Propel", "::", "getDatabaseMap", "(", "BaseUserRolePeer", "::", "DATABASE_NAME", ")", ";", "if", "(", "!", "$", "dbMap", "->", "hasTable", "(", "BaseUserRolePeer", "::", "TABLE_NAME", ")", ")", "{", "$", "dbMap", "->", "addTableObject", "(", "new", "\\", "Slashworks", "\\", "BackendBundle", "\\", "Model", "\\", "map", "\\", "UserRoleTableMap", "(", ")", ")", ";", "}", "}" ]
Add a TableMap instance to the database for this peer class.
[ "Add", "a", "TableMap", "instance", "to", "the", "database", "for", "this", "peer", "class", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1112-L1118
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.doInsert
public static function doInsert($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity } else { $criteria = $values->buildCriteria(); // build Criteria from UserRole object } // Set the correct dbName $criteria->setDbName(UserRolePeer::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(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity } else { $criteria = $values->buildCriteria(); // build Criteria from UserRole object } // Set the correct dbName $criteria->setDbName(UserRolePeer::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", "(", "UserRolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "values", ";", "// rename for clarity", "}", "else", "{", "$", "criteria", "=", "$", "values", "->", "buildCriteria", "(", ")", ";", "// build Criteria from UserRole object", "}", "// Set the correct dbName", "$", "criteria", "->", "setDbName", "(", "UserRolePeer", "::", "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 UserRole or Criteria object. @param mixed $values Criteria or UserRole 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", "UserRole", "or", "Criteria", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1140-L1168
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.doUpdate
public static function doUpdate($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $selectCriteria = new Criteria(UserRolePeer::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity $comparison = $criteria->getComparison(UserRolePeer::USER_ID); $value = $criteria->remove(UserRolePeer::USER_ID); if ($value) { $selectCriteria->add(UserRolePeer::USER_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } $comparison = $criteria->getComparison(UserRolePeer::ROLE_ID); $value = $criteria->remove(UserRolePeer::ROLE_ID); if ($value) { $selectCriteria->add(UserRolePeer::ROLE_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } } else { // $values is UserRole object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(UserRolePeer::DATABASE_NAME); return BasePeer::doUpdate($selectCriteria, $criteria, $con); }
php
public static function doUpdate($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $selectCriteria = new Criteria(UserRolePeer::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = clone $values; // rename for clarity $comparison = $criteria->getComparison(UserRolePeer::USER_ID); $value = $criteria->remove(UserRolePeer::USER_ID); if ($value) { $selectCriteria->add(UserRolePeer::USER_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } $comparison = $criteria->getComparison(UserRolePeer::ROLE_ID); $value = $criteria->remove(UserRolePeer::ROLE_ID); if ($value) { $selectCriteria->add(UserRolePeer::ROLE_ID, $value, $comparison); } else { $selectCriteria->setPrimaryTableName(UserRolePeer::TABLE_NAME); } } else { // $values is UserRole object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(UserRolePeer::DATABASE_NAME); return BasePeer::doUpdate($selectCriteria, $criteria, $con); }
[ "public", "static", "function", "doUpdate", "(", "$", "values", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserRolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "$", "selectCriteria", "=", "new", "Criteria", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "$", "criteria", "=", "clone", "$", "values", ";", "// rename for clarity", "$", "comparison", "=", "$", "criteria", "->", "getComparison", "(", "UserRolePeer", "::", "USER_ID", ")", ";", "$", "value", "=", "$", "criteria", "->", "remove", "(", "UserRolePeer", "::", "USER_ID", ")", ";", "if", "(", "$", "value", ")", "{", "$", "selectCriteria", "->", "add", "(", "UserRolePeer", "::", "USER_ID", ",", "$", "value", ",", "$", "comparison", ")", ";", "}", "else", "{", "$", "selectCriteria", "->", "setPrimaryTableName", "(", "UserRolePeer", "::", "TABLE_NAME", ")", ";", "}", "$", "comparison", "=", "$", "criteria", "->", "getComparison", "(", "UserRolePeer", "::", "ROLE_ID", ")", ";", "$", "value", "=", "$", "criteria", "->", "remove", "(", "UserRolePeer", "::", "ROLE_ID", ")", ";", "if", "(", "$", "value", ")", "{", "$", "selectCriteria", "->", "add", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "value", ",", "$", "comparison", ")", ";", "}", "else", "{", "$", "selectCriteria", "->", "setPrimaryTableName", "(", "UserRolePeer", "::", "TABLE_NAME", ")", ";", "}", "}", "else", "{", "// $values is UserRole object", "$", "criteria", "=", "$", "values", "->", "buildCriteria", "(", ")", ";", "// gets full criteria", "$", "selectCriteria", "=", "$", "values", "->", "buildPkeyCriteria", "(", ")", ";", "// gets criteria w/ primary key(s)", "}", "// set the correct dbName", "$", "criteria", "->", "setDbName", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "return", "BasePeer", "::", "doUpdate", "(", "$", "selectCriteria", ",", "$", "criteria", ",", "$", "con", ")", ";", "}" ]
Performs an UPDATE on the database, given a UserRole or Criteria object. @param mixed $values Criteria or UserRole object containing data that is used to create the UPDATE statement. @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions). @return int The number of affected rows (if supported by underlying database driver). @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "an", "UPDATE", "on", "the", "database", "given", "a", "UserRole", "or", "Criteria", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1179-L1215
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.doDelete
public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // invalidate the cache for all objects of this type, since we have no // way of knowing (without running a query) what objects should be invalidated // from the cache based on this Criteria. UserRolePeer::clearInstancePool(); // rename for clarity $criteria = clone $values; } elseif ($values instanceof UserRole) { // it's a model object // invalidate the cache for this single object UserRolePeer::removeInstanceFromPool($values); // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(UserRolePeer::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(UserRolePeer::USER_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(UserRolePeer::ROLE_ID, $value[1])); $criteria->addOr($criterion); // we can invalidate the cache for this single PK UserRolePeer::removeInstanceFromPool($value); } } // Set the correct dbName $criteria->setDbName(UserRolePeer::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += BasePeer::doDelete($criteria, $con); UserRolePeer::clearRelatedInstancePool(); $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
php
public static function doDelete($values, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } if ($values instanceof Criteria) { // invalidate the cache for all objects of this type, since we have no // way of knowing (without running a query) what objects should be invalidated // from the cache based on this Criteria. UserRolePeer::clearInstancePool(); // rename for clarity $criteria = clone $values; } elseif ($values instanceof UserRole) { // it's a model object // invalidate the cache for this single object UserRolePeer::removeInstanceFromPool($values); // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(UserRolePeer::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(UserRolePeer::USER_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(UserRolePeer::ROLE_ID, $value[1])); $criteria->addOr($criterion); // we can invalidate the cache for this single PK UserRolePeer::removeInstanceFromPool($value); } } // Set the correct dbName $criteria->setDbName(UserRolePeer::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->beginTransaction(); $affectedRows += BasePeer::doDelete($criteria, $con); UserRolePeer::clearRelatedInstancePool(); $con->commit(); return $affectedRows; } catch (Exception $e) { $con->rollBack(); throw $e; } }
[ "public", "static", "function", "doDelete", "(", "$", "values", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserRolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_WRITE", ")", ";", "}", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "// invalidate the cache for all objects of this type, since we have no", "// way of knowing (without running a query) what objects should be invalidated", "// from the cache based on this Criteria.", "UserRolePeer", "::", "clearInstancePool", "(", ")", ";", "// rename for clarity", "$", "criteria", "=", "clone", "$", "values", ";", "}", "elseif", "(", "$", "values", "instanceof", "UserRole", ")", "{", "// it's a model object", "// invalidate the cache for this single object", "UserRolePeer", "::", "removeInstanceFromPool", "(", "$", "values", ")", ";", "// create criteria based on pk values", "$", "criteria", "=", "$", "values", "->", "buildPkeyCriteria", "(", ")", ";", "}", "else", "{", "// it's a primary key, or an array of pks", "$", "criteria", "=", "new", "Criteria", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "// primary key is composite; we therefore, expect", "// the primary key passed to be an array of pkey values", "if", "(", "count", "(", "$", "values", ")", "==", "count", "(", "$", "values", ",", "COUNT_RECURSIVE", ")", ")", "{", "// array is not multi-dimensional", "$", "values", "=", "array", "(", "$", "values", ")", ";", "}", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "criterion", "=", "$", "criteria", "->", "getNewCriterion", "(", "UserRolePeer", "::", "USER_ID", ",", "$", "value", "[", "0", "]", ")", ";", "$", "criterion", "->", "addAnd", "(", "$", "criteria", "->", "getNewCriterion", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "value", "[", "1", "]", ")", ")", ";", "$", "criteria", "->", "addOr", "(", "$", "criterion", ")", ";", "// we can invalidate the cache for this single PK", "UserRolePeer", "::", "removeInstanceFromPool", "(", "$", "value", ")", ";", "}", "}", "// Set the correct dbName", "$", "criteria", "->", "setDbName", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "$", "affectedRows", "=", "0", ";", "// initialize var to track total num of affected rows", "try", "{", "// use transaction because $criteria could contain info", "// for more than one table or we could emulating ON DELETE CASCADE, etc.", "$", "con", "->", "beginTransaction", "(", ")", ";", "$", "affectedRows", "+=", "BasePeer", "::", "doDelete", "(", "$", "criteria", ",", "$", "con", ")", ";", "UserRolePeer", "::", "clearRelatedInstancePool", "(", ")", ";", "$", "con", "->", "commit", "(", ")", ";", "return", "$", "affectedRows", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "con", "->", "rollBack", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Performs a DELETE on the database, given a UserRole or Criteria object OR a primary key value. @param mixed $values Criteria or UserRole object or primary key or array of primary keys which is used to create the DELETE statement @param PropelPDO $con the connection to use @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows if supported by native driver or if emulated using Propel. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "a", "DELETE", "on", "the", "database", "given", "a", "UserRole", "or", "Criteria", "object", "OR", "a", "primary", "key", "value", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1260-L1314
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php
BaseUserRolePeer.retrieveByPK
public static function retrieveByPK($user_id, $role_id, PropelPDO $con = null) { $_instancePoolKey = serialize(array((string) $user_id, (string) $role_id)); if (null !== ($obj = UserRolePeer::getInstanceFromPool($_instancePoolKey))) { return $obj; } if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(UserRolePeer::DATABASE_NAME); $criteria->add(UserRolePeer::USER_ID, $user_id); $criteria->add(UserRolePeer::ROLE_ID, $role_id); $v = UserRolePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
php
public static function retrieveByPK($user_id, $role_id, PropelPDO $con = null) { $_instancePoolKey = serialize(array((string) $user_id, (string) $role_id)); if (null !== ($obj = UserRolePeer::getInstanceFromPool($_instancePoolKey))) { return $obj; } if ($con === null) { $con = Propel::getConnection(UserRolePeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(UserRolePeer::DATABASE_NAME); $criteria->add(UserRolePeer::USER_ID, $user_id); $criteria->add(UserRolePeer::ROLE_ID, $role_id); $v = UserRolePeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
[ "public", "static", "function", "retrieveByPK", "(", "$", "user_id", ",", "$", "role_id", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "_instancePoolKey", "=", "serialize", "(", "array", "(", "(", "string", ")", "$", "user_id", ",", "(", "string", ")", "$", "role_id", ")", ")", ";", "if", "(", "null", "!==", "(", "$", "obj", "=", "UserRolePeer", "::", "getInstanceFromPool", "(", "$", "_instancePoolKey", ")", ")", ")", "{", "return", "$", "obj", ";", "}", "if", "(", "$", "con", "===", "null", ")", "{", "$", "con", "=", "Propel", "::", "getConnection", "(", "UserRolePeer", "::", "DATABASE_NAME", ",", "Propel", "::", "CONNECTION_READ", ")", ";", "}", "$", "criteria", "=", "new", "Criteria", "(", "UserRolePeer", "::", "DATABASE_NAME", ")", ";", "$", "criteria", "->", "add", "(", "UserRolePeer", "::", "USER_ID", ",", "$", "user_id", ")", ";", "$", "criteria", "->", "add", "(", "UserRolePeer", "::", "ROLE_ID", ",", "$", "role_id", ")", ";", "$", "v", "=", "UserRolePeer", "::", "doSelect", "(", "$", "criteria", ",", "$", "con", ")", ";", "return", "!", "empty", "(", "$", "v", ")", "?", "$", "v", "[", "0", "]", ":", "null", ";", "}" ]
Retrieve object using using composite pkey values. @param int $user_id @param int $role_id @param PropelPDO $con @return UserRole
[ "Retrieve", "object", "using", "using", "composite", "pkey", "values", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUserRolePeer.php#L1360-L1375
xinix-technology/norm
src/Norm/Type/NormArray.php
NormArray.offsetSet
public function offsetSet($key, $value) { if (! is_int($key)) { $this->attributes[] = $value; } else { $this->attributes[$key] = $value; } }
php
public function offsetSet($key, $value) { if (! is_int($key)) { $this->attributes[] = $value; } else { $this->attributes[$key] = $value; } }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_int", "(", "$", "key", ")", ")", "{", "$", "this", "->", "attributes", "[", "]", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Type/NormArray.php#L44-L51
xinix-technology/norm
src/Norm/Connection/SQLServerConnection.php
SqlServerConnection.persist
public function persist($collection, array $document) { if ($collection instanceof Collection) { $collectionName = $collection->getName(); } else { $collectionName = $collection; $collection = static::factory($collection); } $this->ddl($collection); $marshalledDocument = $this->marshall($document); if (isset($document['$id'])) { $marshalledDocument['$id'] = $document['$id']; $sql = $this->dialect->grammarUpdate($collectionName, $marshalledDocument); $marshalledDocument['id'] = $marshalledDocument['$id']; unset($marshalledDocument['$id']); $this->execute($sql, $marshalledDocument); } else { $sql = $this->dialect->grammarInsert($collectionName, $marshalledDocument); $id = null; $succeed = $this->execute($sql, $marshalledDocument); if ($succeed) { $lastInsertId = mssql_fetch_array($succeed); $id = $lastInsertId[0]; } else { throw new Exception('[Norm/PDOConnection] Insert error.'); } if (!is_null($id)) { $marshalledDocument['id'] = $id; } } return $this->unmarshall($marshalledDocument); }
php
public function persist($collection, array $document) { if ($collection instanceof Collection) { $collectionName = $collection->getName(); } else { $collectionName = $collection; $collection = static::factory($collection); } $this->ddl($collection); $marshalledDocument = $this->marshall($document); if (isset($document['$id'])) { $marshalledDocument['$id'] = $document['$id']; $sql = $this->dialect->grammarUpdate($collectionName, $marshalledDocument); $marshalledDocument['id'] = $marshalledDocument['$id']; unset($marshalledDocument['$id']); $this->execute($sql, $marshalledDocument); } else { $sql = $this->dialect->grammarInsert($collectionName, $marshalledDocument); $id = null; $succeed = $this->execute($sql, $marshalledDocument); if ($succeed) { $lastInsertId = mssql_fetch_array($succeed); $id = $lastInsertId[0]; } else { throw new Exception('[Norm/PDOConnection] Insert error.'); } if (!is_null($id)) { $marshalledDocument['id'] = $id; } } return $this->unmarshall($marshalledDocument); }
[ "public", "function", "persist", "(", "$", "collection", ",", "array", "$", "document", ")", "{", "if", "(", "$", "collection", "instanceof", "Collection", ")", "{", "$", "collectionName", "=", "$", "collection", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "collectionName", "=", "$", "collection", ";", "$", "collection", "=", "static", "::", "factory", "(", "$", "collection", ")", ";", "}", "$", "this", "->", "ddl", "(", "$", "collection", ")", ";", "$", "marshalledDocument", "=", "$", "this", "->", "marshall", "(", "$", "document", ")", ";", "if", "(", "isset", "(", "$", "document", "[", "'$id'", "]", ")", ")", "{", "$", "marshalledDocument", "[", "'$id'", "]", "=", "$", "document", "[", "'$id'", "]", ";", "$", "sql", "=", "$", "this", "->", "dialect", "->", "grammarUpdate", "(", "$", "collectionName", ",", "$", "marshalledDocument", ")", ";", "$", "marshalledDocument", "[", "'id'", "]", "=", "$", "marshalledDocument", "[", "'$id'", "]", ";", "unset", "(", "$", "marshalledDocument", "[", "'$id'", "]", ")", ";", "$", "this", "->", "execute", "(", "$", "sql", ",", "$", "marshalledDocument", ")", ";", "}", "else", "{", "$", "sql", "=", "$", "this", "->", "dialect", "->", "grammarInsert", "(", "$", "collectionName", ",", "$", "marshalledDocument", ")", ";", "$", "id", "=", "null", ";", "$", "succeed", "=", "$", "this", "->", "execute", "(", "$", "sql", ",", "$", "marshalledDocument", ")", ";", "if", "(", "$", "succeed", ")", "{", "$", "lastInsertId", "=", "mssql_fetch_array", "(", "$", "succeed", ")", ";", "$", "id", "=", "$", "lastInsertId", "[", "0", "]", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'[Norm/PDOConnection] Insert error.'", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "id", ")", ")", "{", "$", "marshalledDocument", "[", "'id'", "]", "=", "$", "id", ";", "}", "}", "return", "$", "this", "->", "unmarshall", "(", "$", "marshalledDocument", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/SQLServerConnection.php#L62-L108
xinix-technology/norm
src/Norm/Connection/SQLServerConnection.php
SqlServerConnection.query
public function query($collection, array $criteria = null) { $collection = $this->factory($collection); return new SQLServerCursor($collection, $criteria); }
php
public function query($collection, array $criteria = null) { $collection = $this->factory($collection); return new SQLServerCursor($collection, $criteria); }
[ "public", "function", "query", "(", "$", "collection", ",", "array", "$", "criteria", "=", "null", ")", "{", "$", "collection", "=", "$", "this", "->", "factory", "(", "$", "collection", ")", ";", "return", "new", "SQLServerCursor", "(", "$", "collection", ",", "$", "criteria", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/SQLServerConnection.php#L113-L118
xinix-technology/norm
src/Norm/Connection/SQLServerConnection.php
SqlServerConnection.ddl
public function ddl(Collection $collection) { if (!empty($this->options['autoddl'])) { $sql = $this->dialect->grammarDDL($collection, $this->options['autoddl']); $this->execute($sql); } }
php
public function ddl(Collection $collection) { if (!empty($this->options['autoddl'])) { $sql = $this->dialect->grammarDDL($collection, $this->options['autoddl']); $this->execute($sql); } }
[ "public", "function", "ddl", "(", "Collection", "$", "collection", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'autoddl'", "]", ")", ")", "{", "$", "sql", "=", "$", "this", "->", "dialect", "->", "grammarDDL", "(", "$", "collection", ",", "$", "this", "->", "options", "[", "'autoddl'", "]", ")", ";", "$", "this", "->", "execute", "(", "$", "sql", ")", ";", "}", "}" ]
DDL runner for collection @param \Norm\Collection $collection @return void
[ "DDL", "runner", "for", "collection" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/SQLServerConnection.php#L181-L188
xinix-technology/norm
src/Norm/Connection/SQLServerConnection.php
SqlServerConnection.execute
protected function execute($sql, array $data = array()) { try{ foreach ($data as $key => $value) { $sql = str_replace(":".$key, "'".$value."'", $sql); } $execute = mssql_query($sql,$this->raw); }catch(\Exception $e){ return null; } return $execute; }
php
protected function execute($sql, array $data = array()) { try{ foreach ($data as $key => $value) { $sql = str_replace(":".$key, "'".$value."'", $sql); } $execute = mssql_query($sql,$this->raw); }catch(\Exception $e){ return null; } return $execute; }
[ "protected", "function", "execute", "(", "$", "sql", ",", "array", "$", "data", "=", "array", "(", ")", ")", "{", "try", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "sql", "=", "str_replace", "(", "\":\"", ".", "$", "key", ",", "\"'\"", ".", "$", "value", ".", "\"'\"", ",", "$", "sql", ")", ";", "}", "$", "execute", "=", "mssql_query", "(", "$", "sql", ",", "$", "this", "->", "raw", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "null", ";", "}", "return", "$", "execute", ";", "}" ]
Execute an sql @param string $sql @param array $data @return bool
[ "Execute", "an", "sql" ]
train
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Connection/SQLServerConnection.php#L198-L213
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.write
public function write($path, $contents, Config $config) { // 1. Save to temporary local file -- it will be destroyed automatically $tempfile = tmpfile(); fwrite($tempfile, $contents); // 2. Use Cloudinary to send $uploaded_metadata = $this->writeStream($path, $tempfile, $config); return $uploaded_metadata; }
php
public function write($path, $contents, Config $config) { // 1. Save to temporary local file -- it will be destroyed automatically $tempfile = tmpfile(); fwrite($tempfile, $contents); // 2. Use Cloudinary to send $uploaded_metadata = $this->writeStream($path, $tempfile, $config); return $uploaded_metadata; }
[ "public", "function", "write", "(", "$", "path", ",", "$", "contents", ",", "Config", "$", "config", ")", "{", "// 1. Save to temporary local file -- it will be destroyed automatically", "$", "tempfile", "=", "tmpfile", "(", ")", ";", "fwrite", "(", "$", "tempfile", ",", "$", "contents", ")", ";", "// 2. Use Cloudinary to send", "$", "uploaded_metadata", "=", "$", "this", "->", "writeStream", "(", "$", "path", ",", "$", "tempfile", ",", "$", "config", ")", ";", "return", "$", "uploaded_metadata", ";", "}" ]
Write a new file. Create temporary stream with content. Pass to writeStream. @param string $path @param string $contents @param Config $config Config object @return array|false false on failure file meta data on success
[ "Write", "a", "new", "file", ".", "Create", "temporary", "stream", "with", "content", ".", "Pass", "to", "writeStream", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L51-L62
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.rename
public function rename($path, $newpath) { $pathinfo = pathinfo($path); if ($pathinfo['dirname'] != '.') { $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename']; } else { $path_remote = $pathinfo['filename']; } $newpathinfo = pathinfo($newpath); if ($newpathinfo['dirname'] != '.') { $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename']; } else { $newpath_remote = $newpathinfo['filename']; } $result = Uploader::rename($path_remote, $newpath_remote); return $result['public_id'] == $newpathinfo['filename']; }
php
public function rename($path, $newpath) { $pathinfo = pathinfo($path); if ($pathinfo['dirname'] != '.') { $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename']; } else { $path_remote = $pathinfo['filename']; } $newpathinfo = pathinfo($newpath); if ($newpathinfo['dirname'] != '.') { $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename']; } else { $newpath_remote = $newpathinfo['filename']; } $result = Uploader::rename($path_remote, $newpath_remote); return $result['public_id'] == $newpathinfo['filename']; }
[ "public", "function", "rename", "(", "$", "path", ",", "$", "newpath", ")", "{", "$", "pathinfo", "=", "pathinfo", "(", "$", "path", ")", ";", "if", "(", "$", "pathinfo", "[", "'dirname'", "]", "!=", "'.'", ")", "{", "$", "path_remote", "=", "$", "pathinfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "pathinfo", "[", "'filename'", "]", ";", "}", "else", "{", "$", "path_remote", "=", "$", "pathinfo", "[", "'filename'", "]", ";", "}", "$", "newpathinfo", "=", "pathinfo", "(", "$", "newpath", ")", ";", "if", "(", "$", "newpathinfo", "[", "'dirname'", "]", "!=", "'.'", ")", "{", "$", "newpath_remote", "=", "$", "newpathinfo", "[", "'dirname'", "]", ".", "'/'", ".", "$", "newpathinfo", "[", "'filename'", "]", ";", "}", "else", "{", "$", "newpath_remote", "=", "$", "newpathinfo", "[", "'filename'", "]", ";", "}", "$", "result", "=", "Uploader", "::", "rename", "(", "$", "path_remote", ",", "$", "newpath_remote", ")", ";", "return", "$", "result", "[", "'public_id'", "]", "==", "$", "newpathinfo", "[", "'filename'", "]", ";", "}" ]
Rename a file. Paths without extensions. @param string $path @param string $newpath @return bool
[ "Rename", "a", "file", ".", "Paths", "without", "extensions", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L120-L139
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.copy
public function copy($path, $newpath) { $url = cloudinary_url_internal($path); $result = Uploader::upload($url, ['public_id' => $newpath]); return is_array($result) ? $result['public_id'] == $newpath : false; }
php
public function copy($path, $newpath) { $url = cloudinary_url_internal($path); $result = Uploader::upload($url, ['public_id' => $newpath]); return is_array($result) ? $result['public_id'] == $newpath : false; }
[ "public", "function", "copy", "(", "$", "path", ",", "$", "newpath", ")", "{", "$", "url", "=", "cloudinary_url_internal", "(", "$", "path", ")", ";", "$", "result", "=", "Uploader", "::", "upload", "(", "$", "url", ",", "[", "'public_id'", "=>", "$", "newpath", "]", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "$", "result", "[", "'public_id'", "]", "==", "$", "newpath", ":", "false", ";", "}" ]
Copy a file. Copy content from existing url. @param string $path @param string $newpath @return bool
[ "Copy", "a", "file", ".", "Copy", "content", "from", "existing", "url", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L150-L156
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.delete
public function delete($path) { $result = Uploader::destroy($path, ['invalidate' => true]); return is_array($result) ? $result['result'] == 'ok' : false; }
php
public function delete($path) { $result = Uploader::destroy($path, ['invalidate' => true]); return is_array($result) ? $result['result'] == 'ok' : false; }
[ "public", "function", "delete", "(", "$", "path", ")", "{", "$", "result", "=", "Uploader", "::", "destroy", "(", "$", "path", ",", "[", "'invalidate'", "=>", "true", "]", ")", ";", "return", "is_array", "(", "$", "result", ")", "?", "$", "result", "[", "'result'", "]", "==", "'ok'", ":", "false", ";", "}" ]
Delete a file. @param string $path @return bool
[ "Delete", "a", "file", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L165-L170
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.has
public function has($path) { try { $this->api->resource($path); } catch (Exception $e) { return false; } return true; }
php
public function has($path) { try { $this->api->resource($path); } catch (Exception $e) { return false; } return true; }
[ "public", "function", "has", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "api", "->", "resource", "(", "$", "path", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check whether a file exists. Using url to check response headers. Maybe I should use api resource? substr(get_headers(cloudinary_url_internal($path))[0], -6 ) == '200 OK'; need to test that for spead @param string $path @return array|bool|null
[ "Check", "whether", "a", "file", "exists", ".", "Using", "url", "to", "check", "response", "headers", ".", "Maybe", "I", "should", "use", "api", "resource?" ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L215-L224
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.readStream
public function readStream($path) { try { $stream = fopen(cloudinary_url($path), 'r'); } catch (Exception $e) { return false; } return compact('stream', 'path'); }
php
public function readStream($path) { try { $stream = fopen(cloudinary_url($path), 'r'); } catch (Exception $e) { return false; } return compact('stream', 'path'); }
[ "public", "function", "readStream", "(", "$", "path", ")", "{", "try", "{", "$", "stream", "=", "fopen", "(", "cloudinary_url", "(", "$", "path", ")", ",", "'r'", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "compact", "(", "'stream'", ",", "'path'", ")", ";", "}" ]
Read a file as a stream. @param string $path @return array|false
[ "Read", "a", "file", "as", "a", "stream", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L247-L256
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.listContents
public function listContents($directory = '', $recursive = false) { // get resources array $resources = ((array) $this->api->resources([ 'type' => 'upload', 'prefix' => $directory ])['resources']); // parse resourses foreach ($resources as $i => $resource) { $resources[$i] = $this->prepareResourceMetadata($resource); } return $resources; }
php
public function listContents($directory = '', $recursive = false) { // get resources array $resources = ((array) $this->api->resources([ 'type' => 'upload', 'prefix' => $directory ])['resources']); // parse resourses foreach ($resources as $i => $resource) { $resources[$i] = $this->prepareResourceMetadata($resource); } return $resources; }
[ "public", "function", "listContents", "(", "$", "directory", "=", "''", ",", "$", "recursive", "=", "false", ")", "{", "// get resources array", "$", "resources", "=", "(", "(", "array", ")", "$", "this", "->", "api", "->", "resources", "(", "[", "'type'", "=>", "'upload'", ",", "'prefix'", "=>", "$", "directory", "]", ")", "[", "'resources'", "]", ")", ";", "// parse resourses", "foreach", "(", "$", "resources", "as", "$", "i", "=>", "$", "resource", ")", "{", "$", "resources", "[", "$", "i", "]", "=", "$", "this", "->", "prepareResourceMetadata", "(", "$", "resource", ")", ";", "}", "return", "$", "resources", ";", "}" ]
List contents of a directory. @param string $directory @param bool $recursive @return array
[ "List", "contents", "of", "a", "directory", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L266-L280
t3chnik/flysystem-cloudinary-adapter
src/CloudinaryAdapter.php
CloudinaryAdapter.prepareResourceMetadata
protected function prepareResourceMetadata($resource) { $resource['type'] = 'file'; $resource['path'] = $resource['public_id']; $resource = array_merge($resource, $this->prepareSize($resource)); $resource = array_merge($resource, $this->prepareTimestamp($resource)); $resource = array_merge($resource, $this->prepareMimetype($resource)); return $resource; }
php
protected function prepareResourceMetadata($resource) { $resource['type'] = 'file'; $resource['path'] = $resource['public_id']; $resource = array_merge($resource, $this->prepareSize($resource)); $resource = array_merge($resource, $this->prepareTimestamp($resource)); $resource = array_merge($resource, $this->prepareMimetype($resource)); return $resource; }
[ "protected", "function", "prepareResourceMetadata", "(", "$", "resource", ")", "{", "$", "resource", "[", "'type'", "]", "=", "'file'", ";", "$", "resource", "[", "'path'", "]", "=", "$", "resource", "[", "'public_id'", "]", ";", "$", "resource", "=", "array_merge", "(", "$", "resource", ",", "$", "this", "->", "prepareSize", "(", "$", "resource", ")", ")", ";", "$", "resource", "=", "array_merge", "(", "$", "resource", ",", "$", "this", "->", "prepareTimestamp", "(", "$", "resource", ")", ")", ";", "$", "resource", "=", "array_merge", "(", "$", "resource", ",", "$", "this", "->", "prepareMimetype", "(", "$", "resource", ")", ")", ";", "return", "$", "resource", ";", "}" ]
Prepare apropriate metadata for resource metadata given from cloudinary. @param array $resource @return array
[ "Prepare", "apropriate", "metadata", "for", "resource", "metadata", "given", "from", "cloudinary", "." ]
train
https://github.com/t3chnik/flysystem-cloudinary-adapter/blob/154109bfb2f43e681528f2d537afd5e078ede4c7/src/CloudinaryAdapter.php#L348-L357
2amigos/yiifoundation
widgets/Section.php
Section.init
public function init() { $this->assets = array( 'js' => YII_DEBUG ? 'foundation/foundation.section.js' : 'foundation.min.js' ); Html::addCssClass($this->htmlOptions, Enum::SECTION_CONTAINER); Html::addCssClass($this->htmlOptions, $this->style); ArrayHelper::addValue('data-section', $this->style, $this->htmlOptions); $this->registerClientScript(); parent::init(); }
php
public function init() { $this->assets = array( 'js' => YII_DEBUG ? 'foundation/foundation.section.js' : 'foundation.min.js' ); Html::addCssClass($this->htmlOptions, Enum::SECTION_CONTAINER); Html::addCssClass($this->htmlOptions, $this->style); ArrayHelper::addValue('data-section', $this->style, $this->htmlOptions); $this->registerClientScript(); parent::init(); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "assets", "=", "array", "(", "'js'", "=>", "YII_DEBUG", "?", "'foundation/foundation.section.js'", ":", "'foundation.min.js'", ")", ";", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "Enum", "::", "SECTION_CONTAINER", ")", ";", "Html", "::", "addCssClass", "(", "$", "this", "->", "htmlOptions", ",", "$", "this", "->", "style", ")", ";", "ArrayHelper", "::", "addValue", "(", "'data-section'", ",", "$", "this", "->", "style", ",", "$", "this", "->", "htmlOptions", ")", ";", "$", "this", "->", "registerClientScript", "(", ")", ";", "parent", "::", "init", "(", ")", ";", "}" ]
Initilizes the widget
[ "Initilizes", "the", "widget" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Section.php#L76-L87
2amigos/yiifoundation
widgets/Section.php
Section.renderSection
public function renderSection() { $sections = array(); foreach ($this->items as $item) { $sections[] = $this->renderItem($item); } return \CHtml::tag('div', $this->htmlOptions, implode("\n", $sections)); }
php
public function renderSection() { $sections = array(); foreach ($this->items as $item) { $sections[] = $this->renderItem($item); } return \CHtml::tag('div', $this->htmlOptions, implode("\n", $sections)); }
[ "public", "function", "renderSection", "(", ")", "{", "$", "sections", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "sections", "[", "]", "=", "$", "this", "->", "renderItem", "(", "$", "item", ")", ";", "}", "return", "\\", "CHtml", "::", "tag", "(", "'div'", ",", "$", "this", "->", "htmlOptions", ",", "implode", "(", "\"\\n\"", ",", "$", "sections", ")", ")", ";", "}" ]
Renders the section @return string the rendering result
[ "Renders", "the", "section" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Section.php#L101-L108
2amigos/yiifoundation
widgets/Section.php
Section.renderItem
public function renderItem($item) { $sectionItem = array(); $sectionItem[] = \CHtml::tag( 'p', array('class' => 'title', 'data-section-title' => 'data-section-title'), \CHtml::link(ArrayHelper::getValue($item, 'label', 'Section Title'), '#') ); $options = ArrayHelper::getValue($item, 'options', array()); Html::addCssClass($options, 'content'); ArrayHelper::addValue('data-section-content', 'data-section-content', $options); $sectionOptions = array(); if (ArrayHelper::getValue($item, 'active')) { ArrayHelper::addValue('class', 'active', $sectionOptions); } $sectionItem[] = \CHtml::tag('div', $options, ArrayHelper::getValue($item, 'content', 'Section Content')); return \CHtml::tag('section', $sectionOptions, implode("\n", $sectionItem)); }
php
public function renderItem($item) { $sectionItem = array(); $sectionItem[] = \CHtml::tag( 'p', array('class' => 'title', 'data-section-title' => 'data-section-title'), \CHtml::link(ArrayHelper::getValue($item, 'label', 'Section Title'), '#') ); $options = ArrayHelper::getValue($item, 'options', array()); Html::addCssClass($options, 'content'); ArrayHelper::addValue('data-section-content', 'data-section-content', $options); $sectionOptions = array(); if (ArrayHelper::getValue($item, 'active')) { ArrayHelper::addValue('class', 'active', $sectionOptions); } $sectionItem[] = \CHtml::tag('div', $options, ArrayHelper::getValue($item, 'content', 'Section Content')); return \CHtml::tag('section', $sectionOptions, implode("\n", $sectionItem)); }
[ "public", "function", "renderItem", "(", "$", "item", ")", "{", "$", "sectionItem", "=", "array", "(", ")", ";", "$", "sectionItem", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'p'", ",", "array", "(", "'class'", "=>", "'title'", ",", "'data-section-title'", "=>", "'data-section-title'", ")", ",", "\\", "CHtml", "::", "link", "(", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'label'", ",", "'Section Title'", ")", ",", "'#'", ")", ")", ";", "$", "options", "=", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'options'", ",", "array", "(", ")", ")", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "'content'", ")", ";", "ArrayHelper", "::", "addValue", "(", "'data-section-content'", ",", "'data-section-content'", ",", "$", "options", ")", ";", "$", "sectionOptions", "=", "array", "(", ")", ";", "if", "(", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'active'", ")", ")", "{", "ArrayHelper", "::", "addValue", "(", "'class'", ",", "'active'", ",", "$", "sectionOptions", ")", ";", "}", "$", "sectionItem", "[", "]", "=", "\\", "CHtml", "::", "tag", "(", "'div'", ",", "$", "options", ",", "ArrayHelper", "::", "getValue", "(", "$", "item", ",", "'content'", ",", "'Section Content'", ")", ")", ";", "return", "\\", "CHtml", "::", "tag", "(", "'section'", ",", "$", "sectionOptions", ",", "implode", "(", "\"\\n\"", ",", "$", "sectionItem", ")", ")", ";", "}" ]
Renders a section item @param array $item the section item @return string the section result
[ "Renders", "a", "section", "item" ]
train
https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/widgets/Section.php#L115-L132
mattsparks/the-stringler
src/Manipulator.php
Manipulator.camelToSnake
public function camelToSnake() : Manipulator { $modifiedString = ''; foreach (str_split($this->string, 1) as $character) { $modifiedString .= ctype_upper($character) ? '_' . $character : $character; } return new static(mb_strtolower($modifiedString)); }
php
public function camelToSnake() : Manipulator { $modifiedString = ''; foreach (str_split($this->string, 1) as $character) { $modifiedString .= ctype_upper($character) ? '_' . $character : $character; } return new static(mb_strtolower($modifiedString)); }
[ "public", "function", "camelToSnake", "(", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "this", "->", "string", ",", "1", ")", "as", "$", "character", ")", "{", "$", "modifiedString", ".=", "ctype_upper", "(", "$", "character", ")", "?", "'_'", ".", "$", "character", ":", "$", "character", ";", "}", "return", "new", "static", "(", "mb_strtolower", "(", "$", "modifiedString", ")", ")", ";", "}" ]
Convert a camel-case string to snake-case. @return object|Manipulator
[ "Convert", "a", "camel", "-", "case", "string", "to", "snake", "-", "case", "." ]
train
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L49-L58
mattsparks/the-stringler
src/Manipulator.php
Manipulator.eachCharacter
public function eachCharacter(\Closure $closure) : Manipulator { $modifiedString = ''; foreach (str_split($this->string) as $character) { $modifiedString .= $closure($character); } return new static($modifiedString); }
php
public function eachCharacter(\Closure $closure) : Manipulator { $modifiedString = ''; foreach (str_split($this->string) as $character) { $modifiedString .= $closure($character); } return new static($modifiedString); }
[ "public", "function", "eachCharacter", "(", "\\", "Closure", "$", "closure", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "str_split", "(", "$", "this", "->", "string", ")", "as", "$", "character", ")", "{", "$", "modifiedString", ".=", "$", "closure", "(", "$", "character", ")", ";", "}", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Perform an action on each character in the string. @param $closure @return object|Manipulator
[ "Perform", "an", "action", "on", "each", "character", "in", "the", "string", "." ]
train
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L106-L115
mattsparks/the-stringler
src/Manipulator.php
Manipulator.eachWord
public function eachWord(\Closure $closure, bool $preserveSpaces = false) : Manipulator { $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= $closure($word); $modifiedString .= $preserveSpaces ? ' ' : ''; } return new static(trim($modifiedString)); }
php
public function eachWord(\Closure $closure, bool $preserveSpaces = false) : Manipulator { $modifiedString = ''; foreach (explode(' ', $this->string) as $word) { $modifiedString .= $closure($word); $modifiedString .= $preserveSpaces ? ' ' : ''; } return new static(trim($modifiedString)); }
[ "public", "function", "eachWord", "(", "\\", "Closure", "$", "closure", ",", "bool", "$", "preserveSpaces", "=", "false", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "''", ";", "foreach", "(", "explode", "(", "' '", ",", "$", "this", "->", "string", ")", "as", "$", "word", ")", "{", "$", "modifiedString", ".=", "$", "closure", "(", "$", "word", ")", ";", "$", "modifiedString", ".=", "$", "preserveSpaces", "?", "' '", ":", "''", ";", "}", "return", "new", "static", "(", "trim", "(", "$", "modifiedString", ")", ")", ";", "}" ]
Perform an action on each word in the string. @param $closure @param bool $preserveSpaces @return object|Manipulator
[ "Perform", "an", "action", "on", "each", "word", "in", "the", "string", "." ]
train
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L124-L134
mattsparks/the-stringler
src/Manipulator.php
Manipulator.getPossessive
public function getPossessive() : Manipulator { $modifiedString = $this->trimEnd(); if (mb_substr($modifiedString, -1) === 's') { $modifiedString .= '\''; } else { $modifiedString .= '\'s'; } return new static($modifiedString); }
php
public function getPossessive() : Manipulator { $modifiedString = $this->trimEnd(); if (mb_substr($modifiedString, -1) === 's') { $modifiedString .= '\''; } else { $modifiedString .= '\'s'; } return new static($modifiedString); }
[ "public", "function", "getPossessive", "(", ")", ":", "Manipulator", "{", "$", "modifiedString", "=", "$", "this", "->", "trimEnd", "(", ")", ";", "if", "(", "mb_substr", "(", "$", "modifiedString", ",", "-", "1", ")", "===", "'s'", ")", "{", "$", "modifiedString", ".=", "'\\''", ";", "}", "else", "{", "$", "modifiedString", ".=", "'\\'s'", ";", "}", "return", "new", "static", "(", "$", "modifiedString", ")", ";", "}" ]
Get Possessive Version of String @return object|Manipulator
[ "Get", "Possessive", "Version", "of", "String" ]
train
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L141-L152
mattsparks/the-stringler
src/Manipulator.php
Manipulator.htmlEntitiesDecode
public function htmlEntitiesDecode($flags = ENT_HTML5, string $encoding = 'UTF-8') : Manipulator { return new static(html_entity_decode($this->string, $flags, $encoding)); }
php
public function htmlEntitiesDecode($flags = ENT_HTML5, string $encoding = 'UTF-8') : Manipulator { return new static(html_entity_decode($this->string, $flags, $encoding)); }
[ "public", "function", "htmlEntitiesDecode", "(", "$", "flags", "=", "ENT_HTML5", ",", "string", "$", "encoding", "=", "'UTF-8'", ")", ":", "Manipulator", "{", "return", "new", "static", "(", "html_entity_decode", "(", "$", "this", "->", "string", ",", "$", "flags", ",", "$", "encoding", ")", ")", ";", "}" ]
Decode HTML Entities @param constant $flags @param string $encoding @return object|Manipulator
[ "Decode", "HTML", "Entities" ]
train
https://github.com/mattsparks/the-stringler/blob/bc11319ae4330b8ee1ed7333934ff180423b5218/src/Manipulator.php#L161-L164