id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
2,200
bfansports/CloudProcessingEngine-SDK
src/SA/CpeSdk/CpeActivity.php
CpeActivity.activityHeartbeat
public function activityHeartbeat($data = null) { $context = [ 'taskToken' => $this->token ]; try { $this->cpeLogger->logOut("INFO", basename(__FILE__), "\033[1mSending heartbeat to Sfn ...\033[0m", $this->logKey); $this->cpeSfnHandler->sfn->sendTaskHeartbeat($context); // Notify the client if any if ($this->client) $this->client->onHeartbeat($this->token, $data); } catch (\Exception $e) { $this->cpeLogger->logOut("ERROR", basename(__FILE__), "Unable to send 'Task Heartbeat' to Sfn! " . $e->getMessage(), $this->logKey); // Notify the client if any if ($this->client) $this->client->onException($context, $e); return false; } return true; }
php
public function activityHeartbeat($data = null) { $context = [ 'taskToken' => $this->token ]; try { $this->cpeLogger->logOut("INFO", basename(__FILE__), "\033[1mSending heartbeat to Sfn ...\033[0m", $this->logKey); $this->cpeSfnHandler->sfn->sendTaskHeartbeat($context); // Notify the client if any if ($this->client) $this->client->onHeartbeat($this->token, $data); } catch (\Exception $e) { $this->cpeLogger->logOut("ERROR", basename(__FILE__), "Unable to send 'Task Heartbeat' to Sfn! " . $e->getMessage(), $this->logKey); // Notify the client if any if ($this->client) $this->client->onException($context, $e); return false; } return true; }
[ "public", "function", "activityHeartbeat", "(", "$", "data", "=", "null", ")", "{", "$", "context", "=", "[", "'taskToken'", "=>", "$", "this", "->", "token", "]", ";", "try", "{", "$", "this", "->", "cpeLogger", "->", "logOut", "(", "\"INFO\"", ",", "basename", "(", "__FILE__", ")", ",", "\"\\033[1mSending heartbeat to Sfn ...\\033[0m\"", ",", "$", "this", "->", "logKey", ")", ";", "$", "this", "->", "cpeSfnHandler", "->", "sfn", "->", "sendTaskHeartbeat", "(", "$", "context", ")", ";", "// Notify the client if any", "if", "(", "$", "this", "->", "client", ")", "$", "this", "->", "client", "->", "onHeartbeat", "(", "$", "this", "->", "token", ",", "$", "data", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "cpeLogger", "->", "logOut", "(", "\"ERROR\"", ",", "basename", "(", "__FILE__", ")", ",", "\"Unable to send 'Task Heartbeat' to Sfn! \"", ".", "$", "e", "->", "getMessage", "(", ")", ",", "$", "this", "->", "logKey", ")", ";", "// Notify the client if any", "if", "(", "$", "this", "->", "client", ")", "$", "this", "->", "client", "->", "onException", "(", "$", "context", ",", "$", "e", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Send heartbeat to Sfn to keep the task alive. Call this from your activity logic. If return false then the heartbeat was not sent Try again or throw an exception to mark the Activity as failed
[ "Send", "heartbeat", "to", "Sfn", "to", "keep", "the", "task", "alive", ".", "Call", "this", "from", "your", "activity", "logic", ".", "If", "return", "false", "then", "the", "heartbeat", "was", "not", "sent", "Try", "again", "or", "throw", "an", "exception", "to", "mark", "the", "Activity", "as", "failed" ]
8714d088a16c6dd4735df68e17256cc41bba2cfb
https://github.com/bfansports/CloudProcessingEngine-SDK/blob/8714d088a16c6dd4735df68e17256cc41bba2cfb/src/SA/CpeSdk/CpeActivity.php#L263-L293
2,201
hametuha/hametwoo
src/Hametuha/HametWoo/Utility/Tools.php
Tools.has_shipping
public function has_shipping( $order ) { $virtual = true; foreach ( $this->get_all_products_in( $order ) as $product ) { /* @var \WC_Product $product */ if ( ! $product->is_virtual() ) { $virtual = false; break; } } return ! $virtual; }
php
public function has_shipping( $order ) { $virtual = true; foreach ( $this->get_all_products_in( $order ) as $product ) { /* @var \WC_Product $product */ if ( ! $product->is_virtual() ) { $virtual = false; break; } } return ! $virtual; }
[ "public", "function", "has_shipping", "(", "$", "order", ")", "{", "$", "virtual", "=", "true", ";", "foreach", "(", "$", "this", "->", "get_all_products_in", "(", "$", "order", ")", "as", "$", "product", ")", "{", "/* @var \\WC_Product $product */", "if", "(", "!", "$", "product", "->", "is_virtual", "(", ")", ")", "{", "$", "virtual", "=", "false", ";", "break", ";", "}", "}", "return", "!", "$", "virtual", ";", "}" ]
Detect if order has shipping product @param int|\WC_Order|\stdClass $order Order object. @since 0.8.3 @return bool
[ "Detect", "if", "order", "has", "shipping", "product" ]
bcd5948ea53d6ca2181873a9f9d0d221c346592e
https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo/Utility/Tools.php#L56-L66
2,202
hametuha/hametwoo
src/Hametuha/HametWoo/Utility/Tools.php
Tools.get_all_products_in
public function get_all_products_in( $order ) { $order = wc_get_order( $order ); if ( ! $order ) { return []; } $products = []; foreach ( $order->get_items() as $item ) { $products[] = $order->get_product_from_item( $item ); } return $products; }
php
public function get_all_products_in( $order ) { $order = wc_get_order( $order ); if ( ! $order ) { return []; } $products = []; foreach ( $order->get_items() as $item ) { $products[] = $order->get_product_from_item( $item ); } return $products; }
[ "public", "function", "get_all_products_in", "(", "$", "order", ")", "{", "$", "order", "=", "wc_get_order", "(", "$", "order", ")", ";", "if", "(", "!", "$", "order", ")", "{", "return", "[", "]", ";", "}", "$", "products", "=", "[", "]", ";", "foreach", "(", "$", "order", "->", "get_items", "(", ")", "as", "$", "item", ")", "{", "$", "products", "[", "]", "=", "$", "order", "->", "get_product_from_item", "(", "$", "item", ")", ";", "}", "return", "$", "products", ";", "}" ]
Get all product in order @param int|\WC_Order|\stdClass $order Order object. @since 0.8.3 @return array
[ "Get", "all", "product", "in", "order" ]
bcd5948ea53d6ca2181873a9f9d0d221c346592e
https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo/Utility/Tools.php#L76-L86
2,203
hametuha/hametwoo
src/Hametuha/HametWoo/Utility/Tools.php
Tools.card_icons
public function card_icons() { $icons = []; $base_url = WC()->plugin_url() . '/assets/images/icons/credit-cards/'; $base_dir = WC()->plugin_path() . '/assets/images/icons/credit-cards/'; if ( is_dir( $base_dir ) ) { foreach ( scandir( $base_dir ) as $icon ) { if ( preg_match( '#(.*)\.svg$#', $icon, $matches ) ) { $icons[ $matches[1] ] = $base_url . $icon; } } } return $icons; }
php
public function card_icons() { $icons = []; $base_url = WC()->plugin_url() . '/assets/images/icons/credit-cards/'; $base_dir = WC()->plugin_path() . '/assets/images/icons/credit-cards/'; if ( is_dir( $base_dir ) ) { foreach ( scandir( $base_dir ) as $icon ) { if ( preg_match( '#(.*)\.svg$#', $icon, $matches ) ) { $icons[ $matches[1] ] = $base_url . $icon; } } } return $icons; }
[ "public", "function", "card_icons", "(", ")", "{", "$", "icons", "=", "[", "]", ";", "$", "base_url", "=", "WC", "(", ")", "->", "plugin_url", "(", ")", ".", "'/assets/images/icons/credit-cards/'", ";", "$", "base_dir", "=", "WC", "(", ")", "->", "plugin_path", "(", ")", ".", "'/assets/images/icons/credit-cards/'", ";", "if", "(", "is_dir", "(", "$", "base_dir", ")", ")", "{", "foreach", "(", "scandir", "(", "$", "base_dir", ")", "as", "$", "icon", ")", "{", "if", "(", "preg_match", "(", "'#(.*)\\.svg$#'", ",", "$", "icon", ",", "$", "matches", ")", ")", "{", "$", "icons", "[", "$", "matches", "[", "1", "]", "]", "=", "$", "base_url", ".", "$", "icon", ";", "}", "}", "}", "return", "$", "icons", ";", "}" ]
Get card icon URL. @return array
[ "Get", "card", "icon", "URL", "." ]
bcd5948ea53d6ca2181873a9f9d0d221c346592e
https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo/Utility/Tools.php#L105-L117
2,204
hametuha/hametwoo
src/Hametuha/HametWoo/Utility/Tools.php
Tools.card_css
public function card_css( $selector = '.wc-credit-card-form-card-number' ) { $css = <<<CSS {$selector}{ background-repeat: no-repeat; background-position: right .6180469716em center; background-size: 31px 20px; } CSS; foreach ( $this->card_icons() as $icon => $url ) { $css .= <<<CSS {$selector}.{$icon} { background-image: url("{$url}"); } CSS; } return sprintf( '<style type="text/css">%s</style>', $css ); }
php
public function card_css( $selector = '.wc-credit-card-form-card-number' ) { $css = <<<CSS {$selector}{ background-repeat: no-repeat; background-position: right .6180469716em center; background-size: 31px 20px; } CSS; foreach ( $this->card_icons() as $icon => $url ) { $css .= <<<CSS {$selector}.{$icon} { background-image: url("{$url}"); } CSS; } return sprintf( '<style type="text/css">%s</style>', $css ); }
[ "public", "function", "card_css", "(", "$", "selector", "=", "'.wc-credit-card-form-card-number'", ")", "{", "$", "css", "=", " <<<CSS\n{$selector}{\n background-repeat: no-repeat;\n background-position: right .6180469716em center;\n background-size: 31px 20px;\n}\nCSS", ";", "foreach", "(", "$", "this", "->", "card_icons", "(", ")", "as", "$", "icon", "=>", "$", "url", ")", "{", "$", "css", ".=", " <<<CSS\n\n{$selector}.{$icon} {\n\tbackground-image: url(\"{$url}\");\n}\nCSS", ";", "}", "return", "sprintf", "(", "'<style type=\"text/css\">%s</style>'", ",", "$", "css", ")", ";", "}" ]
Get style sheet for card input. @param string $selector CSS selector name. Default '.wc-credit-card-form-card-number'. @return string
[ "Get", "style", "sheet", "for", "card", "input", "." ]
bcd5948ea53d6ca2181873a9f9d0d221c346592e
https://github.com/hametuha/hametwoo/blob/bcd5948ea53d6ca2181873a9f9d0d221c346592e/src/Hametuha/HametWoo/Utility/Tools.php#L126-L144
2,205
koinephp/View
lib/Koine/View/Renderer.php
Renderer.getFilePath
public function getFilePath($filename) { if (!strpos($filename, '.')) { $filename .= ".phtml"; } foreach ($this->config->getPaths() as $path) { $file = "$path/$filename"; if (file_exists($file)) { return $file; } } throw new FileNotFoundException( 'File \'' . $filename . '\' was not found.' ); }
php
public function getFilePath($filename) { if (!strpos($filename, '.')) { $filename .= ".phtml"; } foreach ($this->config->getPaths() as $path) { $file = "$path/$filename"; if (file_exists($file)) { return $file; } } throw new FileNotFoundException( 'File \'' . $filename . '\' was not found.' ); }
[ "public", "function", "getFilePath", "(", "$", "filename", ")", "{", "if", "(", "!", "strpos", "(", "$", "filename", ",", "'.'", ")", ")", "{", "$", "filename", ".=", "\".phtml\"", ";", "}", "foreach", "(", "$", "this", "->", "config", "->", "getPaths", "(", ")", "as", "$", "path", ")", "{", "$", "file", "=", "\"$path/$filename\"", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "return", "$", "file", ";", "}", "}", "throw", "new", "FileNotFoundException", "(", "'File \\''", ".", "$", "filename", ".", "'\\' was not found.'", ")", ";", "}" ]
Returns the path for the given filename. @throws FileNotFoundException when file does not exist in the view paths @return string
[ "Returns", "the", "path", "for", "the", "given", "filename", "." ]
9fec0dd4de6d91e2cab12915e7e238ffe318ae94
https://github.com/koinephp/View/blob/9fec0dd4de6d91e2cab12915e7e238ffe318ae94/lib/Koine/View/Renderer.php#L106-L123
2,206
koinephp/View
lib/Koine/View/Renderer.php
Renderer.setData
public function setData(array $data) { foreach ($this->getData()->toArray() as $key => $value) { $this->getData()->offsetUnset($key); } $this->addData($data); return $this; }
php
public function setData(array $data) { foreach ($this->getData()->toArray() as $key => $value) { $this->getData()->offsetUnset($key); } $this->addData($data); return $this; }
[ "public", "function", "setData", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "this", "->", "getData", "(", ")", "->", "toArray", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "getData", "(", ")", "->", "offsetUnset", "(", "$", "key", ")", ";", "}", "$", "this", "->", "addData", "(", "$", "data", ")", ";", "return", "$", "this", ";", "}" ]
Sets the renderer data @param array $data @return self
[ "Sets", "the", "renderer", "data" ]
9fec0dd4de6d91e2cab12915e7e238ffe318ae94
https://github.com/koinephp/View/blob/9fec0dd4de6d91e2cab12915e7e238ffe318ae94/lib/Koine/View/Renderer.php#L155-L164
2,207
Puzzlout/FrameworkMvcLegacy
src/UC/LeftMenu.php
LeftMenu.Build
public function Build() { $left_menu_output = "<ul class=\"content_left nav-sidebar\">"; $main_menus = $this->_LoadXml(); $left_menu_output .= $this->ProcessMainMenus($main_menus); $left_menu_output .= "</ul>"; return $left_menu_output; }
php
public function Build() { $left_menu_output = "<ul class=\"content_left nav-sidebar\">"; $main_menus = $this->_LoadXml(); $left_menu_output .= $this->ProcessMainMenus($main_menus); $left_menu_output .= "</ul>"; return $left_menu_output; }
[ "public", "function", "Build", "(", ")", "{", "$", "left_menu_output", "=", "\"<ul class=\\\"content_left nav-sidebar\\\">\"", ";", "$", "main_menus", "=", "$", "this", "->", "_LoadXml", "(", ")", ";", "$", "left_menu_output", ".=", "$", "this", "->", "ProcessMainMenus", "(", "$", "main_menus", ")", ";", "$", "left_menu_output", ".=", "\"</ul>\"", ";", "return", "$", "left_menu_output", ";", "}" ]
Returns a string representing the left menu @return type string
[ "Returns", "a", "string", "representing", "the", "left", "menu" ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/UC/LeftMenu.php#L48-L54
2,208
Puzzlout/FrameworkMvcLegacy
src/UC/LeftMenu.php
LeftMenu._LoadXml
private function _LoadXml() { $xml = new \DOMDocument; $filename = "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . $this->app->name() . '/Config/menus.xml'; if (file_exists($filename)) { $xml->load($filename); } else { throw new \Exception("In " . __CLASS__ . "->" . __METHOD__); } return $xml->getElementsByTagName("main_menu"); }
php
private function _LoadXml() { $xml = new \DOMDocument; $filename = "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName . $this->app->name() . '/Config/menus.xml'; if (file_exists($filename)) { $xml->load($filename); } else { throw new \Exception("In " . __CLASS__ . "->" . __METHOD__); } return $xml->getElementsByTagName("main_menu"); }
[ "private", "function", "_LoadXml", "(", ")", "{", "$", "xml", "=", "new", "\\", "DOMDocument", ";", "$", "filename", "=", "\"APP_ROOT_DIR\"", ".", "\\", "Puzzlout", "\\", "Framework", "\\", "Enums", "\\", "ApplicationFolderName", "::", "AppsFolderName", ".", "$", "this", "->", "app", "->", "name", "(", ")", ".", "'/Config/menus.xml'", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "xml", "->", "load", "(", "$", "filename", ")", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "\"In \"", ".", "__CLASS__", ".", "\"->\"", ".", "__METHOD__", ")", ";", "}", "return", "$", "xml", "->", "getElementsByTagName", "(", "\"main_menu\"", ")", ";", "}" ]
Load the left menu from xml and returns the data to process The list of DOMElementNode is the list of main menus to display @return type DOMELementNodeList @throws Exception when file is not found
[ "Load", "the", "left", "menu", "from", "xml", "and", "returns", "the", "data", "to", "process", "The", "list", "of", "DOMElementNode", "is", "the", "list", "of", "main", "menus", "to", "display" ]
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/UC/LeftMenu.php#L63-L72
2,209
lasallecrm/lasallecrm-l5-lasallecrmapi-pkg
src/Repositories/PeopleRepository.php
PeopleRepository.isFirstnameSurname
public function isFirstnameSurname($firstName, $surname) { $result = $this->model ->where('first_name', $firstName) ->where('surname', $surname) ->first() ; if ($result) { return $result->id; } return false; }
php
public function isFirstnameSurname($firstName, $surname) { $result = $this->model ->where('first_name', $firstName) ->where('surname', $surname) ->first() ; if ($result) { return $result->id; } return false; }
[ "public", "function", "isFirstnameSurname", "(", "$", "firstName", ",", "$", "surname", ")", "{", "$", "result", "=", "$", "this", "->", "model", "->", "where", "(", "'first_name'", ",", "$", "firstName", ")", "->", "where", "(", "'surname'", ",", "$", "surname", ")", "->", "first", "(", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "result", "->", "id", ";", "}", "return", "false", ";", "}" ]
Does a record exist with the given "first_name" and "surname"? @param string $firstName The first name. @param string $surname The surname. @return mixed
[ "Does", "a", "record", "exist", "with", "the", "given", "first_name", "and", "surname", "?" ]
6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb
https://github.com/lasallecrm/lasallecrm-l5-lasallecrmapi-pkg/blob/6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb/src/Repositories/PeopleRepository.php#L71-L83
2,210
lasallecrm/lasallecrm-l5-lasallecrmapi-pkg
src/Repositories/PeopleRepository.php
PeopleRepository.createNewRecord
public function createNewRecord($data) { $people = new $this->model; $people['user_id'] = $data['user_id']; $people['title'] = $data['title']; $people['salutation'] = $data['salutation']; $people['first_name'] = $data['first_name']; $people['middle_name'] = $data['middle_name']; $people['surname'] = $data['surname']; $people['position'] = $data['position']; $people['description'] = $data['description']; $people['comments'] = $data['comments']; $people['birthday'] = $data['birthday']; $people['anniversary'] = $data['anniversary']; $people['created_at'] = $data['created_at']; $people['created_by'] = $data['created_by']; $people['updated_at'] = $data['updated_at']; $people['updated_by'] = $data['updated_by']; $people['profile'] = $data['profile']; $people['featured_image'] = $data['featured_image']; if ($people->save()) { // Return the new ID return $people->id; } return false; }
php
public function createNewRecord($data) { $people = new $this->model; $people['user_id'] = $data['user_id']; $people['title'] = $data['title']; $people['salutation'] = $data['salutation']; $people['first_name'] = $data['first_name']; $people['middle_name'] = $data['middle_name']; $people['surname'] = $data['surname']; $people['position'] = $data['position']; $people['description'] = $data['description']; $people['comments'] = $data['comments']; $people['birthday'] = $data['birthday']; $people['anniversary'] = $data['anniversary']; $people['created_at'] = $data['created_at']; $people['created_by'] = $data['created_by']; $people['updated_at'] = $data['updated_at']; $people['updated_by'] = $data['updated_by']; $people['profile'] = $data['profile']; $people['featured_image'] = $data['featured_image']; if ($people->save()) { // Return the new ID return $people->id; } return false; }
[ "public", "function", "createNewRecord", "(", "$", "data", ")", "{", "$", "people", "=", "new", "$", "this", "->", "model", ";", "$", "people", "[", "'user_id'", "]", "=", "$", "data", "[", "'user_id'", "]", ";", "$", "people", "[", "'title'", "]", "=", "$", "data", "[", "'title'", "]", ";", "$", "people", "[", "'salutation'", "]", "=", "$", "data", "[", "'salutation'", "]", ";", "$", "people", "[", "'first_name'", "]", "=", "$", "data", "[", "'first_name'", "]", ";", "$", "people", "[", "'middle_name'", "]", "=", "$", "data", "[", "'middle_name'", "]", ";", "$", "people", "[", "'surname'", "]", "=", "$", "data", "[", "'surname'", "]", ";", "$", "people", "[", "'position'", "]", "=", "$", "data", "[", "'position'", "]", ";", "$", "people", "[", "'description'", "]", "=", "$", "data", "[", "'description'", "]", ";", "$", "people", "[", "'comments'", "]", "=", "$", "data", "[", "'comments'", "]", ";", "$", "people", "[", "'birthday'", "]", "=", "$", "data", "[", "'birthday'", "]", ";", "$", "people", "[", "'anniversary'", "]", "=", "$", "data", "[", "'anniversary'", "]", ";", "$", "people", "[", "'created_at'", "]", "=", "$", "data", "[", "'created_at'", "]", ";", "$", "people", "[", "'created_by'", "]", "=", "$", "data", "[", "'created_by'", "]", ";", "$", "people", "[", "'updated_at'", "]", "=", "$", "data", "[", "'updated_at'", "]", ";", "$", "people", "[", "'updated_by'", "]", "=", "$", "data", "[", "'updated_by'", "]", ";", "$", "people", "[", "'profile'", "]", "=", "$", "data", "[", "'profile'", "]", ";", "$", "people", "[", "'featured_image'", "]", "=", "$", "data", "[", "'featured_image'", "]", ";", "if", "(", "$", "people", "->", "save", "(", ")", ")", "{", "// Return the new ID", "return", "$", "people", "->", "id", ";", "}", "return", "false", ";", "}" ]
INSERT INTO 'peoples' @param array $data The data to be saved, which is already validated, washed, & prepped. @return mixed The new list_email.id when save is successful, false when save fails
[ "INSERT", "INTO", "peoples" ]
6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb
https://github.com/lasallecrm/lasallecrm-l5-lasallecrmapi-pkg/blob/6ef0eb3a9158fd2bc31b0aa570d94eddb96e10cb/src/Repositories/PeopleRepository.php#L91-L122
2,211
Talesoft/tale-loader
Loader/PsrLoader.php
PsrLoader.loadClass
public function loadClass($className) { foreach ($this->definitions as $def) { $nameSpace = $def->getNameSpace(); $path = $def->getPath(); $name = $className; if ($nameSpace) { $ns = rtrim($nameSpace, '\\').'\\'; $nameLen = strlen($className); $nsLen = strlen($ns); if ($nameLen < $nsLen || substr($className, 0, $nsLen) !== $ns) return false; $name = substr($name, $nsLen); } $ds = DIRECTORY_SEPARATOR; $path = $path ? $path.$ds : ''; $path .= str_replace(['_', '\\'], $ds, $name).'.php'; if (($path = stream_resolve_include_path($path)) !== false) include $path; if (class_exists($className, false)) return true; } return false; }
php
public function loadClass($className) { foreach ($this->definitions as $def) { $nameSpace = $def->getNameSpace(); $path = $def->getPath(); $name = $className; if ($nameSpace) { $ns = rtrim($nameSpace, '\\').'\\'; $nameLen = strlen($className); $nsLen = strlen($ns); if ($nameLen < $nsLen || substr($className, 0, $nsLen) !== $ns) return false; $name = substr($name, $nsLen); } $ds = DIRECTORY_SEPARATOR; $path = $path ? $path.$ds : ''; $path .= str_replace(['_', '\\'], $ds, $name).'.php'; if (($path = stream_resolve_include_path($path)) !== false) include $path; if (class_exists($className, false)) return true; } return false; }
[ "public", "function", "loadClass", "(", "$", "className", ")", "{", "foreach", "(", "$", "this", "->", "definitions", "as", "$", "def", ")", "{", "$", "nameSpace", "=", "$", "def", "->", "getNameSpace", "(", ")", ";", "$", "path", "=", "$", "def", "->", "getPath", "(", ")", ";", "$", "name", "=", "$", "className", ";", "if", "(", "$", "nameSpace", ")", "{", "$", "ns", "=", "rtrim", "(", "$", "nameSpace", ",", "'\\\\'", ")", ".", "'\\\\'", ";", "$", "nameLen", "=", "strlen", "(", "$", "className", ")", ";", "$", "nsLen", "=", "strlen", "(", "$", "ns", ")", ";", "if", "(", "$", "nameLen", "<", "$", "nsLen", "||", "substr", "(", "$", "className", ",", "0", ",", "$", "nsLen", ")", "!==", "$", "ns", ")", "return", "false", ";", "$", "name", "=", "substr", "(", "$", "name", ",", "$", "nsLen", ")", ";", "}", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "path", "=", "$", "path", "?", "$", "path", ".", "$", "ds", ":", "''", ";", "$", "path", ".=", "str_replace", "(", "[", "'_'", ",", "'\\\\'", "]", ",", "$", "ds", ",", "$", "name", ")", ".", "'.php'", ";", "if", "(", "(", "$", "path", "=", "stream_resolve_include_path", "(", "$", "path", ")", ")", "!==", "false", ")", "include", "$", "path", ";", "if", "(", "class_exists", "(", "$", "className", ",", "false", ")", ")", "return", "true", ";", "}", "return", "false", ";", "}" ]
Loads a class based on its class name. If it's not found, it's simply ignored in order to let another loader try to load it If it's the only loader, an error will be thrown after a failed loading There's no loader recursion, the final check uses the second parameter of class_exists() to not trigger another autoloader inside this one @param string $className The FQCN of the class to load @return bool Has the class been loaded or not
[ "Loads", "a", "class", "based", "on", "its", "class", "name", "." ]
c818ee7861537706b02acda787e6c2fe4ead174f
https://github.com/Talesoft/tale-loader/blob/c818ee7861537706b02acda787e6c2fe4ead174f/Loader/PsrLoader.php#L113-L146
2,212
sgtlambda/jvwp
src/TemplateUtils.php
TemplateUtils.findTemplate
public static function findTemplate (\Twig_Loader_Filesystem $filesystem, $name) { $name = self::normalizeName($name); self::validateName($name); list($namespace, $shortname) = self::parseName($name); $paths = $filesystem->getPaths($namespace); if (empty($paths)) { throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); } foreach ($paths as $path) { if (is_file($path . '/' . $shortname)) { if (false !== $realpath = realpath($path . '/' . $shortname)) { return $realpath; } return $path . '/' . $shortname; } } throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $paths))); }
php
public static function findTemplate (\Twig_Loader_Filesystem $filesystem, $name) { $name = self::normalizeName($name); self::validateName($name); list($namespace, $shortname) = self::parseName($name); $paths = $filesystem->getPaths($namespace); if (empty($paths)) { throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); } foreach ($paths as $path) { if (is_file($path . '/' . $shortname)) { if (false !== $realpath = realpath($path . '/' . $shortname)) { return $realpath; } return $path . '/' . $shortname; } } throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $paths))); }
[ "public", "static", "function", "findTemplate", "(", "\\", "Twig_Loader_Filesystem", "$", "filesystem", ",", "$", "name", ")", "{", "$", "name", "=", "self", "::", "normalizeName", "(", "$", "name", ")", ";", "self", "::", "validateName", "(", "$", "name", ")", ";", "list", "(", "$", "namespace", ",", "$", "shortname", ")", "=", "self", "::", "parseName", "(", "$", "name", ")", ";", "$", "paths", "=", "$", "filesystem", "->", "getPaths", "(", "$", "namespace", ")", ";", "if", "(", "empty", "(", "$", "paths", ")", ")", "{", "throw", "new", "Twig_Error_Loader", "(", "sprintf", "(", "'There are no registered paths for namespace \"%s\".'", ",", "$", "namespace", ")", ")", ";", "}", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "is_file", "(", "$", "path", ".", "'/'", ".", "$", "shortname", ")", ")", "{", "if", "(", "false", "!==", "$", "realpath", "=", "realpath", "(", "$", "path", ".", "'/'", ".", "$", "shortname", ")", ")", "{", "return", "$", "realpath", ";", "}", "return", "$", "path", ".", "'/'", ".", "$", "shortname", ";", "}", "}", "throw", "new", "Twig_Error_Loader", "(", "sprintf", "(", "'Unable to find template \"%s\" (looked into: %s).'", ",", "$", "name", ",", "implode", "(", "', '", ",", "$", "paths", ")", ")", ")", ";", "}" ]
Determine the path of a template based on its name @param \Twig_Loader_Filesystem $filesystem @param string $name @return string @throws Twig_Error_Loader
[ "Determine", "the", "path", "of", "a", "template", "based", "on", "its", "name" ]
85dba59281216ccb9cff580d26063d304350bbe0
https://github.com/sgtlambda/jvwp/blob/85dba59281216ccb9cff580d26063d304350bbe0/src/TemplateUtils.php#L63-L81
2,213
BlackBoxRepo/PandoContentBundle
Factory/AssetFactory.php
AssetFactory.create
public function create(\SplFileInfo $file) { $extension = $file->getExtension(); switch ($extension) { case 'css': return new StylesheetDocument(); case 'js': return new JavascriptDocument(); default: if (strstr($this->getMimeType($file), 'image')) { return new ImageDocument(); } return new FileDocument(); } }
php
public function create(\SplFileInfo $file) { $extension = $file->getExtension(); switch ($extension) { case 'css': return new StylesheetDocument(); case 'js': return new JavascriptDocument(); default: if (strstr($this->getMimeType($file), 'image')) { return new ImageDocument(); } return new FileDocument(); } }
[ "public", "function", "create", "(", "\\", "SplFileInfo", "$", "file", ")", "{", "$", "extension", "=", "$", "file", "->", "getExtension", "(", ")", ";", "switch", "(", "$", "extension", ")", "{", "case", "'css'", ":", "return", "new", "StylesheetDocument", "(", ")", ";", "case", "'js'", ":", "return", "new", "JavascriptDocument", "(", ")", ";", "default", ":", "if", "(", "strstr", "(", "$", "this", "->", "getMimeType", "(", "$", "file", ")", ",", "'image'", ")", ")", "{", "return", "new", "ImageDocument", "(", ")", ";", "}", "return", "new", "FileDocument", "(", ")", ";", "}", "}" ]
Returns a new instance of the Document that matches the type of the file passed in @param \SplFileInfo $file @return FileInterface
[ "Returns", "a", "new", "instance", "of", "the", "Document", "that", "matches", "the", "type", "of", "the", "file", "passed", "in" ]
fa54d0c7542c1d359a5dbb4f32dab3e195e41007
https://github.com/BlackBoxRepo/PandoContentBundle/blob/fa54d0c7542c1d359a5dbb4f32dab3e195e41007/Factory/AssetFactory.php#L18-L33
2,214
BlackBoxRepo/PandoContentBundle
Factory/AssetFactory.php
AssetFactory.getMimeType
public function getMimeType(\SplFileInfo $file) { $fileInfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($fileInfo, $file->getPathname()); finfo_close($fileInfo); return $mimeType; }
php
public function getMimeType(\SplFileInfo $file) { $fileInfo = finfo_open(FILEINFO_MIME_TYPE); $mimeType = finfo_file($fileInfo, $file->getPathname()); finfo_close($fileInfo); return $mimeType; }
[ "public", "function", "getMimeType", "(", "\\", "SplFileInfo", "$", "file", ")", "{", "$", "fileInfo", "=", "finfo_open", "(", "FILEINFO_MIME_TYPE", ")", ";", "$", "mimeType", "=", "finfo_file", "(", "$", "fileInfo", ",", "$", "file", "->", "getPathname", "(", ")", ")", ";", "finfo_close", "(", "$", "fileInfo", ")", ";", "return", "$", "mimeType", ";", "}" ]
Returns the mime-type of the given file @param \SplFileInfo $file @return string
[ "Returns", "the", "mime", "-", "type", "of", "the", "given", "file" ]
fa54d0c7542c1d359a5dbb4f32dab3e195e41007
https://github.com/BlackBoxRepo/PandoContentBundle/blob/fa54d0c7542c1d359a5dbb4f32dab3e195e41007/Factory/AssetFactory.php#L41-L48
2,215
esperecyan/webidl
src/TypeHinter.php
TypeHinter.to
public static function to($type, $value, $argNum = 0, $pseudoTypes = []) { try { return lib\Type::to($type, $value, $pseudoTypes); } catch (\LogicException $exception) { $callerInfomation = self::getCallerInfomation(); $errorMessage = $callerInfomation['function'] === '__set' ? sprintf( 'Value set to %s is not of the expected type', $callerInfomation['class'] . '::' . $callerInfomation['args'][0] ) : sprintf( 'Argument %d passed to %s is not of the expected type', $argNum + 1, $callerInfomation['class'] . '::' . $callerInfomation['function'] . '()' ); if ($exception instanceof \DomainException) { throw new \DomainException($errorMessage, 0, $exception); } elseif ($exception instanceof \InvalidArgumentException) { throw new \InvalidArgumentException($errorMessage, 0, $exception); } else { throw $exception; } } }
php
public static function to($type, $value, $argNum = 0, $pseudoTypes = []) { try { return lib\Type::to($type, $value, $pseudoTypes); } catch (\LogicException $exception) { $callerInfomation = self::getCallerInfomation(); $errorMessage = $callerInfomation['function'] === '__set' ? sprintf( 'Value set to %s is not of the expected type', $callerInfomation['class'] . '::' . $callerInfomation['args'][0] ) : sprintf( 'Argument %d passed to %s is not of the expected type', $argNum + 1, $callerInfomation['class'] . '::' . $callerInfomation['function'] . '()' ); if ($exception instanceof \DomainException) { throw new \DomainException($errorMessage, 0, $exception); } elseif ($exception instanceof \InvalidArgumentException) { throw new \InvalidArgumentException($errorMessage, 0, $exception); } else { throw $exception; } } }
[ "public", "static", "function", "to", "(", "$", "type", ",", "$", "value", ",", "$", "argNum", "=", "0", ",", "$", "pseudoTypes", "=", "[", "]", ")", "{", "try", "{", "return", "lib", "\\", "Type", "::", "to", "(", "$", "type", ",", "$", "value", ",", "$", "pseudoTypes", ")", ";", "}", "catch", "(", "\\", "LogicException", "$", "exception", ")", "{", "$", "callerInfomation", "=", "self", "::", "getCallerInfomation", "(", ")", ";", "$", "errorMessage", "=", "$", "callerInfomation", "[", "'function'", "]", "===", "'__set'", "?", "sprintf", "(", "'Value set to %s is not of the expected type'", ",", "$", "callerInfomation", "[", "'class'", "]", ".", "'::'", ".", "$", "callerInfomation", "[", "'args'", "]", "[", "0", "]", ")", ":", "sprintf", "(", "'Argument %d passed to %s is not of the expected type'", ",", "$", "argNum", "+", "1", ",", "$", "callerInfomation", "[", "'class'", "]", ".", "'::'", ".", "$", "callerInfomation", "[", "'function'", "]", ".", "'()'", ")", ";", "if", "(", "$", "exception", "instanceof", "\\", "DomainException", ")", "{", "throw", "new", "\\", "DomainException", "(", "$", "errorMessage", ",", "0", ",", "$", "exception", ")", ";", "}", "elseif", "(", "$", "exception", "instanceof", "\\", "InvalidArgumentException", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "errorMessage", ",", "0", ",", "$", "exception", ")", ";", "}", "else", "{", "throw", "$", "exception", ";", "}", "}", "}" ]
Converts a given value in accordance with a given IDL type. @link https://github.com/esperecyan/webidl/blob/master/README.md#esperecyanwebidltypehintertotype-value-argnum-pseudotypes webidl/README.md at master · esperecyan/webidl @param string $type The IDL type. @param mixed $value The value being converted. @param int $argNum The argument offset that received the value being converted. Arguments are counted starting from zero. If the caller method is __set(), this argument are ignored. @param (string|string[]|array)[] The associative array with the identifiers of callback interface types, enumeration types, callback function types or dictionary types (the strings passed in $type) as key. For the corresponding values, see the link. @throws \InvalidArgumentException If $value is not castable. The exception includes a message with method name etc. @throws \DomainException If $value is not castable. The exception includes a message with method name etc. @return mixed
[ "Converts", "a", "given", "value", "in", "accordance", "with", "a", "given", "IDL", "type", "." ]
1448c290d8d16c3ccda09a1977fdf03159c2d1c8
https://github.com/esperecyan/webidl/blob/1448c290d8d16c3ccda09a1977fdf03159c2d1c8/src/TypeHinter.php#L24-L48
2,216
neat-php/http
classes/Request.php
Request.requestLine
public function requestLine() { $uri = $this->url->path(); if ($this->url->query()) { $uri .= '?' . $this->url->query(); } return sprintf('%s %s HTTP/%s', $this->method, $uri, $this->version); }
php
public function requestLine() { $uri = $this->url->path(); if ($this->url->query()) { $uri .= '?' . $this->url->query(); } return sprintf('%s %s HTTP/%s', $this->method, $uri, $this->version); }
[ "public", "function", "requestLine", "(", ")", "{", "$", "uri", "=", "$", "this", "->", "url", "->", "path", "(", ")", ";", "if", "(", "$", "this", "->", "url", "->", "query", "(", ")", ")", "{", "$", "uri", ".=", "'?'", ".", "$", "this", "->", "url", "->", "query", "(", ")", ";", "}", "return", "sprintf", "(", "'%s %s HTTP/%s'", ",", "$", "this", "->", "method", ",", "$", "uri", ",", "$", "this", "->", "version", ")", ";", "}" ]
Get request line @return string
[ "Get", "request", "line" ]
5d4781a8481c1f708fd642292e44244435a8369c
https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Request.php#L69-L77
2,217
varunsridharan/wp-transient-api
src/Transient_API.php
Transient_WP_Api.key
public function key( $key = '', $is_option = false ) { return $this->get_key( $this->validate_length( $key ), $is_option ); }
php
public function key( $key = '', $is_option = false ) { return $this->get_key( $this->validate_length( $key ), $is_option ); }
[ "public", "function", "key", "(", "$", "key", "=", "''", ",", "$", "is_option", "=", "false", ")", "{", "return", "$", "this", "->", "get_key", "(", "$", "this", "->", "validate_length", "(", "$", "key", ")", ",", "$", "is_option", ")", ";", "}" ]
Returns a Unique Key. @param string $key @param bool $is_option @return mixed
[ "Returns", "a", "Unique", "Key", "." ]
5564a928d3de87601ac86f7a882dd7f47d62181b
https://github.com/varunsridharan/wp-transient-api/blob/5564a928d3de87601ac86f7a882dd7f47d62181b/src/Transient_API.php#L110-L112
2,218
varunsridharan/wp-transient-api
src/Transient_API.php
Transient_WP_Api.get_key
public function get_key( $key = '', $is_option = false ) { if ( true === $is_option ) { return $this->option_prefix . $key . $this->option_surfix; } return $this->transient_prefix . $key . $this->transient_surfix; }
php
public function get_key( $key = '', $is_option = false ) { if ( true === $is_option ) { return $this->option_prefix . $key . $this->option_surfix; } return $this->transient_prefix . $key . $this->transient_surfix; }
[ "public", "function", "get_key", "(", "$", "key", "=", "''", ",", "$", "is_option", "=", "false", ")", "{", "if", "(", "true", "===", "$", "is_option", ")", "{", "return", "$", "this", "->", "option_prefix", ".", "$", "key", ".", "$", "this", "->", "option_surfix", ";", "}", "return", "$", "this", "->", "transient_prefix", ".", "$", "key", ".", "$", "this", "->", "transient_surfix", ";", "}" ]
Returns Key Based on Requirement. @param string $key @param bool $is_option @return string
[ "Returns", "Key", "Based", "on", "Requirement", "." ]
5564a928d3de87601ac86f7a882dd7f47d62181b
https://github.com/varunsridharan/wp-transient-api/blob/5564a928d3de87601ac86f7a882dd7f47d62181b/src/Transient_API.php#L122-L128
2,219
varunsridharan/wp-transient-api
src/Transient_API.php
Transient_WP_Api.validate_length
protected function validate_length( $key = '' ) { if ( $this->check_length( $key ) === false ) { return $this->validate_length( md5( $key ) ); } return $key; }
php
protected function validate_length( $key = '' ) { if ( $this->check_length( $key ) === false ) { return $this->validate_length( md5( $key ) ); } return $key; }
[ "protected", "function", "validate_length", "(", "$", "key", "=", "''", ")", "{", "if", "(", "$", "this", "->", "check_length", "(", "$", "key", ")", "===", "false", ")", "{", "return", "$", "this", "->", "validate_length", "(", "md5", "(", "$", "key", ")", ")", ";", "}", "return", "$", "key", ";", "}" ]
Validates Key Length if key lenght exceeds it will md5 or returns the orginal key @uses \md5() @uses \VS_Transient_WP_Api::check_length() @param string $key @return string
[ "Validates", "Key", "Length", "if", "key", "lenght", "exceeds", "it", "will", "md5", "or", "returns", "the", "orginal", "key" ]
5564a928d3de87601ac86f7a882dd7f47d62181b
https://github.com/varunsridharan/wp-transient-api/blob/5564a928d3de87601ac86f7a882dd7f47d62181b/src/Transient_API.php#L140-L145
2,220
varunsridharan/wp-transient-api
src/Transient_API.php
Transient_WP_Api.validate_version
protected function validate_version( $value, $type = '' ) { if ( false === $value || empty( $value ) || is_null( $value ) ) { return false; } if ( 'option' === $type ) { return version_compare( $this->option_version, $value, '=' ); } return version_compare( $this->transient_version, $value, '=' ); }
php
protected function validate_version( $value, $type = '' ) { if ( false === $value || empty( $value ) || is_null( $value ) ) { return false; } if ( 'option' === $type ) { return version_compare( $this->option_version, $value, '=' ); } return version_compare( $this->transient_version, $value, '=' ); }
[ "protected", "function", "validate_version", "(", "$", "value", ",", "$", "type", "=", "''", ")", "{", "if", "(", "false", "===", "$", "value", "||", "empty", "(", "$", "value", ")", "||", "is_null", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "'option'", "===", "$", "type", ")", "{", "return", "version_compare", "(", "$", "this", "->", "option_version", ",", "$", "value", ",", "'='", ")", ";", "}", "return", "version_compare", "(", "$", "this", "->", "transient_version", ",", "$", "value", ",", "'='", ")", ";", "}" ]
Validates If Saved Version is same as in the class version. @param $value @param string $type @uses \VS_Transient_WP_Api::$option_version @uses \VS_Transient_WP_Api::$transient_version @return bool|mixed
[ "Validates", "If", "Saved", "Version", "is", "same", "as", "in", "the", "class", "version", "." ]
5564a928d3de87601ac86f7a882dd7f47d62181b
https://github.com/varunsridharan/wp-transient-api/blob/5564a928d3de87601ac86f7a882dd7f47d62181b/src/Transient_API.php#L287-L297
2,221
varunsridharan/wp-transient-api
src/Transient_API.php
Transient_Api.delete_version_issue
protected function delete_version_issue( $key, $type = '' ) { if ( true === $this->option_auto_delete && 'option' === $type ) { $this->delete_option( $key ); } if ( true === $this->transient_auto_delete ) { return $this->delete_transient( $key ); } return false; }
php
protected function delete_version_issue( $key, $type = '' ) { if ( true === $this->option_auto_delete && 'option' === $type ) { $this->delete_option( $key ); } if ( true === $this->transient_auto_delete ) { return $this->delete_transient( $key ); } return false; }
[ "protected", "function", "delete_version_issue", "(", "$", "key", ",", "$", "type", "=", "''", ")", "{", "if", "(", "true", "===", "$", "this", "->", "option_auto_delete", "&&", "'option'", "===", "$", "type", ")", "{", "$", "this", "->", "delete_option", "(", "$", "key", ")", ";", "}", "if", "(", "true", "===", "$", "this", "->", "transient_auto_delete", ")", "{", "return", "$", "this", "->", "delete_transient", "(", "$", "key", ")", ";", "}", "return", "false", ";", "}" ]
Deletes if cache has any issues. @param $key @param string $type @return mixed
[ "Deletes", "if", "cache", "has", "any", "issues", "." ]
5564a928d3de87601ac86f7a882dd7f47d62181b
https://github.com/varunsridharan/wp-transient-api/blob/5564a928d3de87601ac86f7a882dd7f47d62181b/src/Transient_API.php#L501-L510
2,222
SergioMadness/framework
framework/components/datamapper/abstraction/Model.php
Model.getAttribute
public function getAttribute($name) { $result = null; if ($this->attributeExists($name)) { $result = $this->attributes[$name]; } return $result; }
php
public function getAttribute($name) { $result = null; if ($this->attributeExists($name)) { $result = $this->attributes[$name]; } return $result; }
[ "public", "function", "getAttribute", "(", "$", "name", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "this", "->", "attributeExists", "(", "$", "name", ")", ")", "{", "$", "result", "=", "$", "this", "->", "attributes", "[", "$", "name", "]", ";", "}", "return", "$", "result", ";", "}" ]
Get attribute by name @param string $name @return string
[ "Get", "attribute", "by", "name" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/datamapper/abstraction/Model.php#L92-L101
2,223
SergioMadness/framework
framework/components/datamapper/abstraction/Model.php
Model.getDirtyAttribute
public function getDirtyAttribute($name) { $result = null; if ($this->dirtyAttributeExists($name)) { $result = $this->dirtyAttributes[$name]; } return $result; }
php
public function getDirtyAttribute($name) { $result = null; if ($this->dirtyAttributeExists($name)) { $result = $this->dirtyAttributes[$name]; } return $result; }
[ "public", "function", "getDirtyAttribute", "(", "$", "name", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "this", "->", "dirtyAttributeExists", "(", "$", "name", ")", ")", "{", "$", "result", "=", "$", "this", "->", "dirtyAttributes", "[", "$", "name", "]", ";", "}", "return", "$", "result", ";", "}" ]
Get dirty attribute @param string $name @return mixed
[ "Get", "dirty", "attribute" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/datamapper/abstraction/Model.php#L122-L131
2,224
SergioMadness/framework
framework/components/datamapper/abstraction/Model.php
Model.propertyExists
public function propertyExists($name) { $properties = $this->getProperties(); return empty($properties) || in_array($name, $properties); }
php
public function propertyExists($name) { $properties = $this->getProperties(); return empty($properties) || in_array($name, $properties); }
[ "public", "function", "propertyExists", "(", "$", "name", ")", "{", "$", "properties", "=", "$", "this", "->", "getProperties", "(", ")", ";", "return", "empty", "(", "$", "properties", ")", "||", "in_array", "(", "$", "name", ",", "$", "properties", ")", ";", "}" ]
Check property exists @param string $name @return bool
[ "Check", "property", "exists" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/components/datamapper/abstraction/Model.php#L183-L187
2,225
tourze/model
src/Exception/ValidationException.php
ValidationException.merge
public function merge(ValidationException $object, $hasMany = false) { $alias = $object->alias(); // We will need this when generating errors $this->_objects[ $alias ]['_hasMany'] = (false !== $hasMany); if (true === $hasMany) { // This is most likely a hasMany relationship $this->_objects[ $alias ][] = $object->objects(); } elseif ($hasMany) { // This is most likely a hasMany relationship $this->_objects[ $alias ][ $hasMany ] = $object->objects(); } else { $this->_objects[ $alias ] = $object->objects(); } return $this; }
php
public function merge(ValidationException $object, $hasMany = false) { $alias = $object->alias(); // We will need this when generating errors $this->_objects[ $alias ]['_hasMany'] = (false !== $hasMany); if (true === $hasMany) { // This is most likely a hasMany relationship $this->_objects[ $alias ][] = $object->objects(); } elseif ($hasMany) { // This is most likely a hasMany relationship $this->_objects[ $alias ][ $hasMany ] = $object->objects(); } else { $this->_objects[ $alias ] = $object->objects(); } return $this; }
[ "public", "function", "merge", "(", "ValidationException", "$", "object", ",", "$", "hasMany", "=", "false", ")", "{", "$", "alias", "=", "$", "object", "->", "alias", "(", ")", ";", "// We will need this when generating errors", "$", "this", "->", "_objects", "[", "$", "alias", "]", "[", "'_hasMany'", "]", "=", "(", "false", "!==", "$", "hasMany", ")", ";", "if", "(", "true", "===", "$", "hasMany", ")", "{", "// This is most likely a hasMany relationship", "$", "this", "->", "_objects", "[", "$", "alias", "]", "[", "]", "=", "$", "object", "->", "objects", "(", ")", ";", "}", "elseif", "(", "$", "hasMany", ")", "{", "// This is most likely a hasMany relationship", "$", "this", "->", "_objects", "[", "$", "alias", "]", "[", "$", "hasMany", "]", "=", "$", "object", "->", "objects", "(", ")", ";", "}", "else", "{", "$", "this", "->", "_objects", "[", "$", "alias", "]", "=", "$", "object", "->", "objects", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Merges an ValidationException object into the current exception Useful when you want to combine errors into one array @param ValidationException $object The exception to merge @param mixed $hasMany The array key to use if this exception can be merged multiple times @return ValidationException
[ "Merges", "an", "ValidationException", "object", "into", "the", "current", "exception", "Useful", "when", "you", "want", "to", "combine", "errors", "into", "one", "array" ]
1fd8fb141f47f320f3f20b369d127b0b89f82986
https://github.com/tourze/model/blob/1fd8fb141f47f320f3f20b369d127b0b89f82986/src/Exception/ValidationException.php#L101-L124
2,226
tourze/model
src/Exception/ValidationException.php
ValidationException.generateErrors
protected function generateErrors($alias, array $array, $directory, $translate) { $errors = []; foreach ($array as $key => $object) { if (is_array($object)) { $errors[ $key ] = ($key === '_external') // Search for errors in $alias/_external.php ? $this->generateErrors($alias . '/' . $key, $object, $directory, $translate) // Regular models get their own file not nested within $alias : $this->generateErrors($key, $object, $directory, $translate); } elseif ($object instanceof Validation) { if (null === $directory) { // Return the raw errors $file = null; } else { $file = trim($directory . '/' . $alias, '/'); } $errors += $object->errors($file, $translate); } } return $errors; }
php
protected function generateErrors($alias, array $array, $directory, $translate) { $errors = []; foreach ($array as $key => $object) { if (is_array($object)) { $errors[ $key ] = ($key === '_external') // Search for errors in $alias/_external.php ? $this->generateErrors($alias . '/' . $key, $object, $directory, $translate) // Regular models get their own file not nested within $alias : $this->generateErrors($key, $object, $directory, $translate); } elseif ($object instanceof Validation) { if (null === $directory) { // Return the raw errors $file = null; } else { $file = trim($directory . '/' . $alias, '/'); } $errors += $object->errors($file, $translate); } } return $errors; }
[ "protected", "function", "generateErrors", "(", "$", "alias", ",", "array", "$", "array", ",", "$", "directory", ",", "$", "translate", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "object", ")", "{", "if", "(", "is_array", "(", "$", "object", ")", ")", "{", "$", "errors", "[", "$", "key", "]", "=", "(", "$", "key", "===", "'_external'", ")", "// Search for errors in $alias/_external.php", "?", "$", "this", "->", "generateErrors", "(", "$", "alias", ".", "'/'", ".", "$", "key", ",", "$", "object", ",", "$", "directory", ",", "$", "translate", ")", "// Regular models get their own file not nested within $alias", ":", "$", "this", "->", "generateErrors", "(", "$", "key", ",", "$", "object", ",", "$", "directory", ",", "$", "translate", ")", ";", "}", "elseif", "(", "$", "object", "instanceof", "Validation", ")", "{", "if", "(", "null", "===", "$", "directory", ")", "{", "// Return the raw errors", "$", "file", "=", "null", ";", "}", "else", "{", "$", "file", "=", "trim", "(", "$", "directory", ".", "'/'", ".", "$", "alias", ",", "'/'", ")", ";", "}", "$", "errors", "+=", "$", "object", "->", "errors", "(", "$", "file", ",", "$", "translate", ")", ";", "}", "}", "return", "$", "errors", ";", "}" ]
Recursive method to fetch all the errors in this exception @param string $alias Alias to use for messages file @param array $array Array of Validation objects to get errors from @param string $directory Directory to load error messages from @param mixed $translate Translate the message @return array
[ "Recursive", "method", "to", "fetch", "all", "the", "errors", "in", "this", "exception" ]
1fd8fb141f47f320f3f20b369d127b0b89f82986
https://github.com/tourze/model/blob/1fd8fb141f47f320f3f20b369d127b0b89f82986/src/Exception/ValidationException.php#L150-L181
2,227
mrgrain/autobahn-cli
src/Utils/Dotenv.php
Dotenv.set
public function set($variable, $value = '', $export = false) { $line = $this->composeLine($variable, $value, $export); $number = $this->has($variable) ? $this->line_numbers[$variable] : null; $this->writeLine($line, $number); $this->load(); return $line; }
php
public function set($variable, $value = '', $export = false) { $line = $this->composeLine($variable, $value, $export); $number = $this->has($variable) ? $this->line_numbers[$variable] : null; $this->writeLine($line, $number); $this->load(); return $line; }
[ "public", "function", "set", "(", "$", "variable", ",", "$", "value", "=", "''", ",", "$", "export", "=", "false", ")", "{", "$", "line", "=", "$", "this", "->", "composeLine", "(", "$", "variable", ",", "$", "value", ",", "$", "export", ")", ";", "$", "number", "=", "$", "this", "->", "has", "(", "$", "variable", ")", "?", "$", "this", "->", "line_numbers", "[", "$", "variable", "]", ":", "null", ";", "$", "this", "->", "writeLine", "(", "$", "line", ",", "$", "number", ")", ";", "$", "this", "->", "load", "(", ")", ";", "return", "$", "line", ";", "}" ]
Set an environment variable to a value. @param string $variable @param mixed $value @param bool $export @return string|void
[ "Set", "an", "environment", "variable", "to", "a", "value", "." ]
e7973abd72c2f9c52f810bc1fc0d90a022a347e1
https://github.com/mrgrain/autobahn-cli/blob/e7973abd72c2f9c52f810bc1fc0d90a022a347e1/src/Utils/Dotenv.php#L95-L103
2,228
mrgrain/autobahn-cli
src/Utils/Dotenv.php
Dotenv.writeLine
protected function writeLine($line, $number = null) { $this->ensureFileIsWritable(); // Append if (is_null($number)) { return file_put_contents($this->filePath, $line . PHP_EOL, FILE_APPEND); } // Replace $lines = $this->readLinesFromFile($this->filePath); $lines[$number] = $line; return file_put_contents($this->filePath, implode(PHP_EOL, $lines)); }
php
protected function writeLine($line, $number = null) { $this->ensureFileIsWritable(); // Append if (is_null($number)) { return file_put_contents($this->filePath, $line . PHP_EOL, FILE_APPEND); } // Replace $lines = $this->readLinesFromFile($this->filePath); $lines[$number] = $line; return file_put_contents($this->filePath, implode(PHP_EOL, $lines)); }
[ "protected", "function", "writeLine", "(", "$", "line", ",", "$", "number", "=", "null", ")", "{", "$", "this", "->", "ensureFileIsWritable", "(", ")", ";", "// Append", "if", "(", "is_null", "(", "$", "number", ")", ")", "{", "return", "file_put_contents", "(", "$", "this", "->", "filePath", ",", "$", "line", ".", "PHP_EOL", ",", "FILE_APPEND", ")", ";", "}", "// Replace", "$", "lines", "=", "$", "this", "->", "readLinesFromFile", "(", "$", "this", "->", "filePath", ")", ";", "$", "lines", "[", "$", "number", "]", "=", "$", "line", ";", "return", "file_put_contents", "(", "$", "this", "->", "filePath", ",", "implode", "(", "PHP_EOL", ",", "$", "lines", ")", ")", ";", "}" ]
Write a line to the dotenv file. @param string $line The line to write @param integer|null $number Write to a specific location @return mixed
[ "Write", "a", "line", "to", "the", "dotenv", "file", "." ]
e7973abd72c2f9c52f810bc1fc0d90a022a347e1
https://github.com/mrgrain/autobahn-cli/blob/e7973abd72c2f9c52f810bc1fc0d90a022a347e1/src/Utils/Dotenv.php#L111-L124
2,229
mrgrain/autobahn-cli
src/Utils/Dotenv.php
Dotenv.ensureFileIsWritable
protected function ensureFileIsWritable() { if ((!is_writable($this->filePath) || !is_file($this->filePath)) && (!is_dir(dirname($this->filePath)) || !is_writable(dirname($this->filePath))) ) { throw new InvalidPathException(sprintf('Unable to write the environment file at %s.', $this->filePath)); } }
php
protected function ensureFileIsWritable() { if ((!is_writable($this->filePath) || !is_file($this->filePath)) && (!is_dir(dirname($this->filePath)) || !is_writable(dirname($this->filePath))) ) { throw new InvalidPathException(sprintf('Unable to write the environment file at %s.', $this->filePath)); } }
[ "protected", "function", "ensureFileIsWritable", "(", ")", "{", "if", "(", "(", "!", "is_writable", "(", "$", "this", "->", "filePath", ")", "||", "!", "is_file", "(", "$", "this", "->", "filePath", ")", ")", "&&", "(", "!", "is_dir", "(", "dirname", "(", "$", "this", "->", "filePath", ")", ")", "||", "!", "is_writable", "(", "dirname", "(", "$", "this", "->", "filePath", ")", ")", ")", ")", "{", "throw", "new", "InvalidPathException", "(", "sprintf", "(", "'Unable to write the environment file at %s.'", ",", "$", "this", "->", "filePath", ")", ")", ";", "}", "}" ]
Ensures the given filePath is writable. @throws \Dotenv\Exception\InvalidPathException @return void
[ "Ensures", "the", "given", "filePath", "is", "writable", "." ]
e7973abd72c2f9c52f810bc1fc0d90a022a347e1
https://github.com/mrgrain/autobahn-cli/blob/e7973abd72c2f9c52f810bc1fc0d90a022a347e1/src/Utils/Dotenv.php#L133-L140
2,230
mrgrain/autobahn-cli
src/Utils/Dotenv.php
Dotenv.composeLine
protected function composeLine($name, $value, $export = false) { return sprintf('%s%s="%s"', ($export ? 'export ' : ''), $name, addcslashes($value, '"\\')); }
php
protected function composeLine($name, $value, $export = false) { return sprintf('%s%s="%s"', ($export ? 'export ' : ''), $name, addcslashes($value, '"\\')); }
[ "protected", "function", "composeLine", "(", "$", "name", ",", "$", "value", ",", "$", "export", "=", "false", ")", "{", "return", "sprintf", "(", "'%s%s=\"%s\"'", ",", "(", "$", "export", "?", "'export '", ":", "''", ")", ",", "$", "name", ",", "addcslashes", "(", "$", "value", ",", "'\"\\\\'", ")", ")", ";", "}" ]
Compose the dotenv line from given input @param $name @param $value @param bool $export @return string
[ "Compose", "the", "dotenv", "line", "from", "given", "input" ]
e7973abd72c2f9c52f810bc1fc0d90a022a347e1
https://github.com/mrgrain/autobahn-cli/blob/e7973abd72c2f9c52f810bc1fc0d90a022a347e1/src/Utils/Dotenv.php#L182-L185
2,231
bishopb/vanilla
library/core/class.regarding.php
Gdn_Regarding.Comment
public function Comment($CommentID, $Verify = TRUE, $AutoParent = TRUE) { $Regarding = $this->Regarding('Comment', $CommentID, $Verify); if ($Verify && $AutoParent) $Regarding->AutoParent('discussion'); return $Regarding; }
php
public function Comment($CommentID, $Verify = TRUE, $AutoParent = TRUE) { $Regarding = $this->Regarding('Comment', $CommentID, $Verify); if ($Verify && $AutoParent) $Regarding->AutoParent('discussion'); return $Regarding; }
[ "public", "function", "Comment", "(", "$", "CommentID", ",", "$", "Verify", "=", "TRUE", ",", "$", "AutoParent", "=", "TRUE", ")", "{", "$", "Regarding", "=", "$", "this", "->", "Regarding", "(", "'Comment'", ",", "$", "CommentID", ",", "$", "Verify", ")", ";", "if", "(", "$", "Verify", "&&", "$", "AutoParent", ")", "$", "Regarding", "->", "AutoParent", "(", "'discussion'", ")", ";", "return", "$", "Regarding", ";", "}" ]
Start a RegardingEntity for a comment Able to autoparent to its discussion owner if verfied. @param $CommentID int ID of the comment @param $Verify optional boolean whether or not to verify this. default true. @param $AutoParent optional boolean whether or not to try to autoparent. default true. @return Gdn_RegardingEntity
[ "Start", "a", "RegardingEntity", "for", "a", "comment" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.regarding.php#L33-L37
2,232
bishopb/vanilla
library/core/class.regarding.php
Gdn_Regarding.Message
public function Message($MessageID, $Verify = TRUE, $AutoParent = TRUE) { $Regarding = $this->Regarding('ConversationMessage', $MessageID, $Verify); if ($Verify && $AutoParent) $Regarding->AutoParent('conversation'); return $Regarding; }
php
public function Message($MessageID, $Verify = TRUE, $AutoParent = TRUE) { $Regarding = $this->Regarding('ConversationMessage', $MessageID, $Verify); if ($Verify && $AutoParent) $Regarding->AutoParent('conversation'); return $Regarding; }
[ "public", "function", "Message", "(", "$", "MessageID", ",", "$", "Verify", "=", "TRUE", ",", "$", "AutoParent", "=", "TRUE", ")", "{", "$", "Regarding", "=", "$", "this", "->", "Regarding", "(", "'ConversationMessage'", ",", "$", "MessageID", ",", "$", "Verify", ")", ";", "if", "(", "$", "Verify", "&&", "$", "AutoParent", ")", "$", "Regarding", "->", "AutoParent", "(", "'conversation'", ")", ";", "return", "$", "Regarding", ";", "}" ]
Start a RegardingEntity for a conversation message Able to autoparent to its conversation owner if verfied. @param $MessageID int ID of the conversation message @param $Verify optional boolean whether or not to verify this. default true. @param $AutoParent optional boolean whether or not to try to autoparent. default true. @return Gdn_RegardingEntity
[ "Start", "a", "RegardingEntity", "for", "a", "conversation", "message" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.regarding.php#L60-L64
2,233
bishopb/vanilla
library/core/class.regarding.php
Gdn_Regarding.That
public function That() { $Args = func_get_args(); $ThingType = array_shift($Args); return call_user_func_array(array($this, $ThingType), $Args); }
php
public function That() { $Args = func_get_args(); $ThingType = array_shift($Args); return call_user_func_array(array($this, $ThingType), $Args); }
[ "public", "function", "That", "(", ")", "{", "$", "Args", "=", "func_get_args", "(", ")", ";", "$", "ThingType", "=", "array_shift", "(", "$", "Args", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "ThingType", ")", ",", "$", "Args", ")", ";", "}" ]
Transparent forwarder to built-in starter methods
[ "Transparent", "forwarder", "to", "built", "-", "in", "starter", "methods" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.regarding.php#L107-L112
2,234
samsonos/cms_input_material
src/FieldMaterialTable.php
FieldMaterialTable.queryHandler
public function queryHandler() { /** @var array $materialIds Array of identifiers of suitable materials */ $materialIds = array(); // Fill our recently declared array $matIdQuery = dbQuery(NavigationMaterial::class); if (!empty($this->nav)) { $childStructures = array($this->nav->id); $stepChildren = array($this->nav->id); while ( dbQuery('structure_relation') ->cond('parent_id', $stepChildren) ->fields('child_id', $stepChildren) ) { $childStructures = array_merge($childStructures, $stepChildren); } $matIdQuery->cond('StructureID', $childStructures); } $matIdQuery->cond('Active', 1)->fields('MaterialID', $materialIds); // Add this identifiers as query condition if they exist empty($materialIds) ? $this->query->id(0) : $this->query->id($materialIds); }
php
public function queryHandler() { /** @var array $materialIds Array of identifiers of suitable materials */ $materialIds = array(); // Fill our recently declared array $matIdQuery = dbQuery(NavigationMaterial::class); if (!empty($this->nav)) { $childStructures = array($this->nav->id); $stepChildren = array($this->nav->id); while ( dbQuery('structure_relation') ->cond('parent_id', $stepChildren) ->fields('child_id', $stepChildren) ) { $childStructures = array_merge($childStructures, $stepChildren); } $matIdQuery->cond('StructureID', $childStructures); } $matIdQuery->cond('Active', 1)->fields('MaterialID', $materialIds); // Add this identifiers as query condition if they exist empty($materialIds) ? $this->query->id(0) : $this->query->id($materialIds); }
[ "public", "function", "queryHandler", "(", ")", "{", "/** @var array $materialIds Array of identifiers of suitable materials */", "$", "materialIds", "=", "array", "(", ")", ";", "// Fill our recently declared array", "$", "matIdQuery", "=", "dbQuery", "(", "NavigationMaterial", "::", "class", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "nav", ")", ")", "{", "$", "childStructures", "=", "array", "(", "$", "this", "->", "nav", "->", "id", ")", ";", "$", "stepChildren", "=", "array", "(", "$", "this", "->", "nav", "->", "id", ")", ";", "while", "(", "dbQuery", "(", "'structure_relation'", ")", "->", "cond", "(", "'parent_id'", ",", "$", "stepChildren", ")", "->", "fields", "(", "'child_id'", ",", "$", "stepChildren", ")", ")", "{", "$", "childStructures", "=", "array_merge", "(", "$", "childStructures", ",", "$", "stepChildren", ")", ";", "}", "$", "matIdQuery", "->", "cond", "(", "'StructureID'", ",", "$", "childStructures", ")", ";", "}", "$", "matIdQuery", "->", "cond", "(", "'Active'", ",", "1", ")", "->", "fields", "(", "'MaterialID'", ",", "$", "materialIds", ")", ";", "// Add this identifiers as query condition if they exist", "empty", "(", "$", "materialIds", ")", "?", "$", "this", "->", "query", "->", "id", "(", "0", ")", ":", "$", "this", "->", "query", "->", "id", "(", "$", "materialIds", ")", ";", "}" ]
Function to add query conditions @return void
[ "Function", "to", "add", "query", "conditions" ]
a6355a902a9b12441ee88a7dab4a877f5d329f58
https://github.com/samsonos/cms_input_material/blob/a6355a902a9b12441ee88a7dab4a877f5d329f58/src/FieldMaterialTable.php#L64-L90
2,235
samsonos/cms_input_material
src/FieldMaterialTable.php
FieldMaterialTable.setPagerPrefix
public function setPagerPrefix() { // Generate pager url prefix return 'samsoncms_input_material_application/table/' . (isset($this->nav) ? $this->nav->id : '0') . '/' . (isset($this->search{0}) ? $this->search : '0') . '/'; }
php
public function setPagerPrefix() { // Generate pager url prefix return 'samsoncms_input_material_application/table/' . (isset($this->nav) ? $this->nav->id : '0') . '/' . (isset($this->search{0}) ? $this->search : '0') . '/'; }
[ "public", "function", "setPagerPrefix", "(", ")", "{", "// Generate pager url prefix", "return", "'samsoncms_input_material_application/table/'", ".", "(", "isset", "(", "$", "this", "->", "nav", ")", "?", "$", "this", "->", "nav", "->", "id", ":", "'0'", ")", ".", "'/'", ".", "(", "isset", "(", "$", "this", "->", "search", "{", "0", "}", ")", "?", "$", "this", "->", "search", ":", "'0'", ")", ".", "'/'", ";", "}" ]
Function to form pager prefix @return string Pager prefix
[ "Function", "to", "form", "pager", "prefix" ]
a6355a902a9b12441ee88a7dab4a877f5d329f58
https://github.com/samsonos/cms_input_material/blob/a6355a902a9b12441ee88a7dab4a877f5d329f58/src/FieldMaterialTable.php#L96-L101
2,236
samsonos/cms_input_material
src/FieldMaterialTable.php
FieldMaterialTable.row
public function row(&$material, \samson\pager\Pager & $pager = null, $module = null) { // Set table row view context m()->view($this->row_tmpl); // // If there is Navigation for material pass them // if (isset($material->onetomany['_structure'])) { // foreach ($material->onetomany['_structure'] as $structure) { // m()->set('structure', $structure); // break; // } // } // Render row template return m() ->set($material, 'material') ->set('pager', $this->pager) ->set('structureId', isset($this->nav) ? $this->nav->id : '0') ->output(); }
php
public function row(&$material, \samson\pager\Pager & $pager = null, $module = null) { // Set table row view context m()->view($this->row_tmpl); // // If there is Navigation for material pass them // if (isset($material->onetomany['_structure'])) { // foreach ($material->onetomany['_structure'] as $structure) { // m()->set('structure', $structure); // break; // } // } // Render row template return m() ->set($material, 'material') ->set('pager', $this->pager) ->set('structureId', isset($this->nav) ? $this->nav->id : '0') ->output(); }
[ "public", "function", "row", "(", "&", "$", "material", ",", "\\", "samson", "\\", "pager", "\\", "Pager", "&", "$", "pager", "=", "null", ",", "$", "module", "=", "null", ")", "{", "// Set table row view context", "m", "(", ")", "->", "view", "(", "$", "this", "->", "row_tmpl", ")", ";", "// // If there is Navigation for material pass them", "// if (isset($material->onetomany['_structure'])) {", "// foreach ($material->onetomany['_structure'] as $structure) {", "// m()->set('structure', $structure);", "// break;", "// }", "// }", "// Render row template", "return", "m", "(", ")", "->", "set", "(", "$", "material", ",", "'material'", ")", "->", "set", "(", "'pager'", ",", "$", "this", "->", "pager", ")", "->", "set", "(", "'structureId'", ",", "isset", "(", "$", "this", "->", "nav", ")", "?", "$", "this", "->", "nav", "->", "id", ":", "'0'", ")", "->", "output", "(", ")", ";", "}" ]
Function to render rows of the table @param \samson\activerecord\material $material Material object to fill row info @return string Rendered row
[ "Function", "to", "render", "rows", "of", "the", "table" ]
a6355a902a9b12441ee88a7dab4a877f5d329f58
https://github.com/samsonos/cms_input_material/blob/a6355a902a9b12441ee88a7dab4a877f5d329f58/src/FieldMaterialTable.php#L108-L127
2,237
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.initialize
protected function initialize() { $this->log('initialisatie', LOG_DEBUG); // in case of multiple remote hosts use the first $remote_host = is_array($this->remote_host) ? $this->remote_host[0] : $this->remote_host; $this->timestamp = time(); $this->remote_target_dir = strtr($this->remote_dir_format, array('%project_name%' => $this->project_name, '%timestamp%' => date($this->remote_dir_timestamp_format, $this->timestamp))); if ($timestamps = $this->findPastDeploymentTimestamps($remote_host, $this->remote_dir)) { list($this->previous_timestamp, $this->last_timestamp) = $timestamps; } if ($this->previous_timestamp) { $this->previous_remote_target_dir = strtr($this->remote_dir_format, array('%project_name%' => $this->project_name, '%timestamp%' => date($this->remote_dir_timestamp_format, $this->previous_timestamp))); } if ($this->last_timestamp) { $this->last_remote_target_dir = strtr($this->remote_dir_format, array('%project_name%' => $this->project_name, '%timestamp%' => date($this->remote_dir_timestamp_format, $this->last_timestamp))); } }
php
protected function initialize() { $this->log('initialisatie', LOG_DEBUG); // in case of multiple remote hosts use the first $remote_host = is_array($this->remote_host) ? $this->remote_host[0] : $this->remote_host; $this->timestamp = time(); $this->remote_target_dir = strtr($this->remote_dir_format, array('%project_name%' => $this->project_name, '%timestamp%' => date($this->remote_dir_timestamp_format, $this->timestamp))); if ($timestamps = $this->findPastDeploymentTimestamps($remote_host, $this->remote_dir)) { list($this->previous_timestamp, $this->last_timestamp) = $timestamps; } if ($this->previous_timestamp) { $this->previous_remote_target_dir = strtr($this->remote_dir_format, array('%project_name%' => $this->project_name, '%timestamp%' => date($this->remote_dir_timestamp_format, $this->previous_timestamp))); } if ($this->last_timestamp) { $this->last_remote_target_dir = strtr($this->remote_dir_format, array('%project_name%' => $this->project_name, '%timestamp%' => date($this->remote_dir_timestamp_format, $this->last_timestamp))); } }
[ "protected", "function", "initialize", "(", ")", "{", "$", "this", "->", "log", "(", "'initialisatie'", ",", "LOG_DEBUG", ")", ";", "// in case of multiple remote hosts use the first", "$", "remote_host", "=", "is_array", "(", "$", "this", "->", "remote_host", ")", "?", "$", "this", "->", "remote_host", "[", "0", "]", ":", "$", "this", "->", "remote_host", ";", "$", "this", "->", "timestamp", "=", "time", "(", ")", ";", "$", "this", "->", "remote_target_dir", "=", "strtr", "(", "$", "this", "->", "remote_dir_format", ",", "array", "(", "'%project_name%'", "=>", "$", "this", "->", "project_name", ",", "'%timestamp%'", "=>", "date", "(", "$", "this", "->", "remote_dir_timestamp_format", ",", "$", "this", "->", "timestamp", ")", ")", ")", ";", "if", "(", "$", "timestamps", "=", "$", "this", "->", "findPastDeploymentTimestamps", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ")", ")", "{", "list", "(", "$", "this", "->", "previous_timestamp", ",", "$", "this", "->", "last_timestamp", ")", "=", "$", "timestamps", ";", "}", "if", "(", "$", "this", "->", "previous_timestamp", ")", "{", "$", "this", "->", "previous_remote_target_dir", "=", "strtr", "(", "$", "this", "->", "remote_dir_format", ",", "array", "(", "'%project_name%'", "=>", "$", "this", "->", "project_name", ",", "'%timestamp%'", "=>", "date", "(", "$", "this", "->", "remote_dir_timestamp_format", ",", "$", "this", "->", "previous_timestamp", ")", ")", ")", ";", "}", "if", "(", "$", "this", "->", "last_timestamp", ")", "{", "$", "this", "->", "last_remote_target_dir", "=", "strtr", "(", "$", "this", "->", "remote_dir_format", ",", "array", "(", "'%project_name%'", "=>", "$", "this", "->", "project_name", ",", "'%timestamp%'", "=>", "date", "(", "$", "this", "->", "remote_dir_timestamp_format", ",", "$", "this", "->", "last_timestamp", ")", ")", ")", ";", "}", "}" ]
Determines the timestamp of the new deployment and those of the latest two
[ "Determines", "the", "timestamp", "of", "the", "new", "deployment", "and", "those", "of", "the", "latest", "two" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L272-L295
2,238
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.check
protected function check($action) { $this->log('check', LOG_DEBUG); if (is_array($this->remote_host)) { foreach ($this->remote_host as $key => $remote_host) { if ($key == 0) continue; $this->prepareRemoteDirectory($remote_host, $this->remote_dir); } } if ($action == 'update') $this->checkFiles(is_array($this->remote_host) ? $this->remote_host[0] : $this->remote_host, $this->remote_dir, $this->last_remote_target_dir); if ($action == 'update') { if (is_array($this->remote_host)) { foreach ($this->remote_host as $remote_host) { if ($files = $this->listFilesToRename($remote_host, $this->remote_dir)) { $this->log("Target-specific file renames on $remote_host:"); foreach ($files as $filepath => $newpath) $this->log(" $newpath => $filepath"); } } } else { if ($files = $this->listFilesToRename($this->remote_host, $this->remote_dir)) { $this->log('Target-specific file renames:'); foreach ($files as $filepath => $newpath) $this->log(" $newpath => $filepath"); } } } // als alles goed is gegaan kan er doorgegaan worden met de deployment if ($action == 'update') return static::inputPrompt('Proceed with deployment? (yes/no): ', 'no') == 'yes'; elseif ($action == 'rollback') return static::inputPrompt('Proceed with rollback? (yes/no): ', 'no') == 'yes'; return false; }
php
protected function check($action) { $this->log('check', LOG_DEBUG); if (is_array($this->remote_host)) { foreach ($this->remote_host as $key => $remote_host) { if ($key == 0) continue; $this->prepareRemoteDirectory($remote_host, $this->remote_dir); } } if ($action == 'update') $this->checkFiles(is_array($this->remote_host) ? $this->remote_host[0] : $this->remote_host, $this->remote_dir, $this->last_remote_target_dir); if ($action == 'update') { if (is_array($this->remote_host)) { foreach ($this->remote_host as $remote_host) { if ($files = $this->listFilesToRename($remote_host, $this->remote_dir)) { $this->log("Target-specific file renames on $remote_host:"); foreach ($files as $filepath => $newpath) $this->log(" $newpath => $filepath"); } } } else { if ($files = $this->listFilesToRename($this->remote_host, $this->remote_dir)) { $this->log('Target-specific file renames:'); foreach ($files as $filepath => $newpath) $this->log(" $newpath => $filepath"); } } } // als alles goed is gegaan kan er doorgegaan worden met de deployment if ($action == 'update') return static::inputPrompt('Proceed with deployment? (yes/no): ', 'no') == 'yes'; elseif ($action == 'rollback') return static::inputPrompt('Proceed with rollback? (yes/no): ', 'no') == 'yes'; return false; }
[ "protected", "function", "check", "(", "$", "action", ")", "{", "$", "this", "->", "log", "(", "'check'", ",", "LOG_DEBUG", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "remote_host", ")", ")", "{", "foreach", "(", "$", "this", "->", "remote_host", "as", "$", "key", "=>", "$", "remote_host", ")", "{", "if", "(", "$", "key", "==", "0", ")", "continue", ";", "$", "this", "->", "prepareRemoteDirectory", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ")", ";", "}", "}", "if", "(", "$", "action", "==", "'update'", ")", "$", "this", "->", "checkFiles", "(", "is_array", "(", "$", "this", "->", "remote_host", ")", "?", "$", "this", "->", "remote_host", "[", "0", "]", ":", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "last_remote_target_dir", ")", ";", "if", "(", "$", "action", "==", "'update'", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "remote_host", ")", ")", "{", "foreach", "(", "$", "this", "->", "remote_host", "as", "$", "remote_host", ")", "{", "if", "(", "$", "files", "=", "$", "this", "->", "listFilesToRename", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ")", ")", "{", "$", "this", "->", "log", "(", "\"Target-specific file renames on $remote_host:\"", ")", ";", "foreach", "(", "$", "files", "as", "$", "filepath", "=>", "$", "newpath", ")", "$", "this", "->", "log", "(", "\" $newpath => $filepath\"", ")", ";", "}", "}", "}", "else", "{", "if", "(", "$", "files", "=", "$", "this", "->", "listFilesToRename", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ")", ")", "{", "$", "this", "->", "log", "(", "'Target-specific file renames:'", ")", ";", "foreach", "(", "$", "files", "as", "$", "filepath", "=>", "$", "newpath", ")", "$", "this", "->", "log", "(", "\" $newpath => $filepath\"", ")", ";", "}", "}", "}", "// als alles goed is gegaan kan er doorgegaan worden met de deployment", "if", "(", "$", "action", "==", "'update'", ")", "return", "static", "::", "inputPrompt", "(", "'Proceed with deployment? (yes/no): '", ",", "'no'", ")", "==", "'yes'", ";", "elseif", "(", "$", "action", "==", "'rollback'", ")", "return", "static", "::", "inputPrompt", "(", "'Proceed with rollback? (yes/no): '", ",", "'no'", ")", "==", "'yes'", ";", "return", "false", ";", "}" ]
Run a dry-run to the remote server to show the changes to be made @param string $action update or rollback @throws DeployException @return bool if the user wants to proceed with the deployment
[ "Run", "a", "dry", "-", "run", "to", "the", "remote", "server", "to", "show", "the", "changes", "to", "be", "made" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L304-L355
2,239
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.rollback
public function rollback() { $this->log('rollback', LOG_DEBUG); if (!$this->previous_remote_target_dir) { $this->log('Rollback impossible, no previous deployment found !'); return; } if (!$this->check('rollback')) return; if (is_array($this->remote_host)) { // eerst op alle hosts de symlink terugdraaien foreach ($this->remote_host as $remote_host) { $this->preRollback($remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->changeSymlink($remote_host, $this->remote_dir, $this->previous_remote_target_dir); } $this->postDeactivation($this->remote_host[0], $this->remote_dir, $this->previous_remote_target_dir); // de caches resetten foreach ($this->remote_host as $remote_host) { $this->clearRemoteCaches($remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->postRollback($remote_host, $this->remote_dir, $this->previous_remote_target_dir); } // als laatste de nieuwe directory terugdraaien foreach ($this->remote_host as $remote_host) { $this->rollbackFiles($remote_host, $this->remote_dir, $this->last_remote_target_dir); } } else { $this->preRollback($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->changeSymlink($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->postDeactivation($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->clearRemoteCaches($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->postRollback($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->rollbackFiles($this->remote_host, $this->remote_dir, $this->last_remote_target_dir); } }
php
public function rollback() { $this->log('rollback', LOG_DEBUG); if (!$this->previous_remote_target_dir) { $this->log('Rollback impossible, no previous deployment found !'); return; } if (!$this->check('rollback')) return; if (is_array($this->remote_host)) { // eerst op alle hosts de symlink terugdraaien foreach ($this->remote_host as $remote_host) { $this->preRollback($remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->changeSymlink($remote_host, $this->remote_dir, $this->previous_remote_target_dir); } $this->postDeactivation($this->remote_host[0], $this->remote_dir, $this->previous_remote_target_dir); // de caches resetten foreach ($this->remote_host as $remote_host) { $this->clearRemoteCaches($remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->postRollback($remote_host, $this->remote_dir, $this->previous_remote_target_dir); } // als laatste de nieuwe directory terugdraaien foreach ($this->remote_host as $remote_host) { $this->rollbackFiles($remote_host, $this->remote_dir, $this->last_remote_target_dir); } } else { $this->preRollback($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->changeSymlink($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->postDeactivation($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->clearRemoteCaches($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->postRollback($this->remote_host, $this->remote_dir, $this->previous_remote_target_dir); $this->rollbackFiles($this->remote_host, $this->remote_dir, $this->last_remote_target_dir); } }
[ "public", "function", "rollback", "(", ")", "{", "$", "this", "->", "log", "(", "'rollback'", ",", "LOG_DEBUG", ")", ";", "if", "(", "!", "$", "this", "->", "previous_remote_target_dir", ")", "{", "$", "this", "->", "log", "(", "'Rollback impossible, no previous deployment found !'", ")", ";", "return", ";", "}", "if", "(", "!", "$", "this", "->", "check", "(", "'rollback'", ")", ")", "return", ";", "if", "(", "is_array", "(", "$", "this", "->", "remote_host", ")", ")", "{", "// eerst op alle hosts de symlink terugdraaien", "foreach", "(", "$", "this", "->", "remote_host", "as", "$", "remote_host", ")", "{", "$", "this", "->", "preRollback", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "changeSymlink", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "}", "$", "this", "->", "postDeactivation", "(", "$", "this", "->", "remote_host", "[", "0", "]", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "// de caches resetten", "foreach", "(", "$", "this", "->", "remote_host", "as", "$", "remote_host", ")", "{", "$", "this", "->", "clearRemoteCaches", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "postRollback", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "}", "// als laatste de nieuwe directory terugdraaien", "foreach", "(", "$", "this", "->", "remote_host", "as", "$", "remote_host", ")", "{", "$", "this", "->", "rollbackFiles", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "last_remote_target_dir", ")", ";", "}", "}", "else", "{", "$", "this", "->", "preRollback", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "changeSymlink", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "postDeactivation", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "clearRemoteCaches", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "postRollback", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "previous_remote_target_dir", ")", ";", "$", "this", "->", "rollbackFiles", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ",", "$", "this", "->", "last_remote_target_dir", ")", ";", "}", "}" ]
Draait de laatste deployment terug
[ "Draait", "de", "laatste", "deployment", "terug" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L406-L454
2,240
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.cleanup
public function cleanup() { $this->log('cleanup', LOG_DEBUG); $past_deployments = array(); if (is_array($this->remote_host)) { foreach ($this->remote_host as $remote_host) { if ($past_dirs = $this->collectPastDeployments($remote_host, $this->remote_dir)) { $past_deployments[] = array( 'remote_host' => $remote_host, 'remote_dir' => $this->remote_dir, 'dirs' => $past_dirs ); } } } else { if ($past_dirs = $this->collectPastDeployments($this->remote_host, $this->remote_dir)) { $past_deployments[] = array( 'remote_host' => $this->remote_host, 'remote_dir' => $this->remote_dir, 'dirs' => $past_dirs ); } } if (!empty($past_deployments)) { if (static::inputPrompt('Delete old directories? (yes/no): ', 'no') == 'yes') $this->deletePastDeployments($past_deployments); } else { $this->log('No cleanup needed'); } }
php
public function cleanup() { $this->log('cleanup', LOG_DEBUG); $past_deployments = array(); if (is_array($this->remote_host)) { foreach ($this->remote_host as $remote_host) { if ($past_dirs = $this->collectPastDeployments($remote_host, $this->remote_dir)) { $past_deployments[] = array( 'remote_host' => $remote_host, 'remote_dir' => $this->remote_dir, 'dirs' => $past_dirs ); } } } else { if ($past_dirs = $this->collectPastDeployments($this->remote_host, $this->remote_dir)) { $past_deployments[] = array( 'remote_host' => $this->remote_host, 'remote_dir' => $this->remote_dir, 'dirs' => $past_dirs ); } } if (!empty($past_deployments)) { if (static::inputPrompt('Delete old directories? (yes/no): ', 'no') == 'yes') $this->deletePastDeployments($past_deployments); } else { $this->log('No cleanup needed'); } }
[ "public", "function", "cleanup", "(", ")", "{", "$", "this", "->", "log", "(", "'cleanup'", ",", "LOG_DEBUG", ")", ";", "$", "past_deployments", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "remote_host", ")", ")", "{", "foreach", "(", "$", "this", "->", "remote_host", "as", "$", "remote_host", ")", "{", "if", "(", "$", "past_dirs", "=", "$", "this", "->", "collectPastDeployments", "(", "$", "remote_host", ",", "$", "this", "->", "remote_dir", ")", ")", "{", "$", "past_deployments", "[", "]", "=", "array", "(", "'remote_host'", "=>", "$", "remote_host", ",", "'remote_dir'", "=>", "$", "this", "->", "remote_dir", ",", "'dirs'", "=>", "$", "past_dirs", ")", ";", "}", "}", "}", "else", "{", "if", "(", "$", "past_dirs", "=", "$", "this", "->", "collectPastDeployments", "(", "$", "this", "->", "remote_host", ",", "$", "this", "->", "remote_dir", ")", ")", "{", "$", "past_deployments", "[", "]", "=", "array", "(", "'remote_host'", "=>", "$", "this", "->", "remote_host", ",", "'remote_dir'", "=>", "$", "this", "->", "remote_dir", ",", "'dirs'", "=>", "$", "past_dirs", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "past_deployments", ")", ")", "{", "if", "(", "static", "::", "inputPrompt", "(", "'Delete old directories? (yes/no): '", ",", "'no'", ")", "==", "'yes'", ")", "$", "this", "->", "deletePastDeployments", "(", "$", "past_deployments", ")", ";", "}", "else", "{", "$", "this", "->", "log", "(", "'No cleanup needed'", ")", ";", "}", "}" ]
Deletes obsolete deployment directories
[ "Deletes", "obsolete", "deployment", "directories" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L459-L498
2,241
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.updateFiles
protected function updateFiles($remote_host, $remote_dir, $target_dir) { $this->log('updateFiles', LOG_DEBUG); $this->rsyncExec($this->rsync_path .' --rsh="ssh -p '. $this->remote_port .'" -azcO --force --delete --progress '. $this->prepareExcludes() .' '. $this->prepareLinkDest($remote_dir) .' ./ '. $this->remote_user .'@'. $remote_host .':'. $remote_dir .'/'. $target_dir); $this->fixDatadirSymlinks($remote_host, $remote_dir, $target_dir); $this->renameTargetFiles($remote_host, $remote_dir); }
php
protected function updateFiles($remote_host, $remote_dir, $target_dir) { $this->log('updateFiles', LOG_DEBUG); $this->rsyncExec($this->rsync_path .' --rsh="ssh -p '. $this->remote_port .'" -azcO --force --delete --progress '. $this->prepareExcludes() .' '. $this->prepareLinkDest($remote_dir) .' ./ '. $this->remote_user .'@'. $remote_host .':'. $remote_dir .'/'. $target_dir); $this->fixDatadirSymlinks($remote_host, $remote_dir, $target_dir); $this->renameTargetFiles($remote_host, $remote_dir); }
[ "protected", "function", "updateFiles", "(", "$", "remote_host", ",", "$", "remote_dir", ",", "$", "target_dir", ")", "{", "$", "this", "->", "log", "(", "'updateFiles'", ",", "LOG_DEBUG", ")", ";", "$", "this", "->", "rsyncExec", "(", "$", "this", "->", "rsync_path", ".", "' --rsh=\"ssh -p '", ".", "$", "this", "->", "remote_port", ".", "'\" -azcO --force --delete --progress '", ".", "$", "this", "->", "prepareExcludes", "(", ")", ".", "' '", ".", "$", "this", "->", "prepareLinkDest", "(", "$", "remote_dir", ")", ".", "' ./ '", ".", "$", "this", "->", "remote_user", ".", "'@'", ".", "$", "remote_host", ".", "':'", ".", "$", "remote_dir", ".", "'/'", ".", "$", "target_dir", ")", ";", "$", "this", "->", "fixDatadirSymlinks", "(", "$", "remote_host", ",", "$", "remote_dir", ",", "$", "target_dir", ")", ";", "$", "this", "->", "renameTargetFiles", "(", "$", "remote_host", ",", "$", "remote_dir", ")", ";", "}" ]
Uploads files to the new directory on the remote server @param string $remote_host @param string $remote_dir @param string $target_dir
[ "Uploads", "files", "to", "the", "new", "directory", "on", "the", "remote", "server" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L536-L545
2,242
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.fixDatadirSymlinks
protected function fixDatadirSymlinks($remote_host, $remote_dir, $target_dir) { $this->log('fixDatadirSymlinks', LOG_DEBUG); if (empty($this->data_dirs)) return; $this->log('Creating data dir symlinks:', LOG_DEBUG); $cmd = "cd $remote_dir/{$target_dir}; php {$this->datadir_patcher} --datadir-prefix={$this->data_dir_prefix} --previous-dir={$this->last_remote_target_dir} ". implode(' ', $this->data_dirs); $output = array(); $return = null; $this->sshExec($remote_host, $cmd, $output, $return); $this->log($output); }
php
protected function fixDatadirSymlinks($remote_host, $remote_dir, $target_dir) { $this->log('fixDatadirSymlinks', LOG_DEBUG); if (empty($this->data_dirs)) return; $this->log('Creating data dir symlinks:', LOG_DEBUG); $cmd = "cd $remote_dir/{$target_dir}; php {$this->datadir_patcher} --datadir-prefix={$this->data_dir_prefix} --previous-dir={$this->last_remote_target_dir} ". implode(' ', $this->data_dirs); $output = array(); $return = null; $this->sshExec($remote_host, $cmd, $output, $return); $this->log($output); }
[ "protected", "function", "fixDatadirSymlinks", "(", "$", "remote_host", ",", "$", "remote_dir", ",", "$", "target_dir", ")", "{", "$", "this", "->", "log", "(", "'fixDatadirSymlinks'", ",", "LOG_DEBUG", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "data_dirs", ")", ")", "return", ";", "$", "this", "->", "log", "(", "'Creating data dir symlinks:'", ",", "LOG_DEBUG", ")", ";", "$", "cmd", "=", "\"cd $remote_dir/{$target_dir}; php {$this->datadir_patcher} --datadir-prefix={$this->data_dir_prefix} --previous-dir={$this->last_remote_target_dir} \"", ".", "implode", "(", "' '", ",", "$", "this", "->", "data_dirs", ")", ";", "$", "output", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "$", "cmd", ",", "$", "output", ",", "$", "return", ")", ";", "$", "this", "->", "log", "(", "$", "output", ")", ";", "}" ]
Executes the datadir patcher to create symlinks to the data dirs. @param string $remote_host @param string $remote_dir @param string $target_dir
[ "Executes", "the", "datadir", "patcher", "to", "create", "symlinks", "to", "the", "data", "dirs", "." ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L554-L570
2,243
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.restartGearmanWorkers
protected function restartGearmanWorkers($remote_host, $remote_dir, $target_dir) { $this->log("restartGearmanWorkers($remote_host, $remote_dir, $target_dir)", LOG_DEBUG); if (!isset($this->gearman['workers']) || empty($this->gearman['workers'])) return; $cmd = "cd $remote_dir/{$target_dir}; "; foreach ($this->gearman['servers'] as $server) { foreach ($this->gearman['workers'] as $worker) { $worker = sprintf($worker, $this->target); $cmd .= "php {$this->gearman_restarter} --ip={$server['ip']} --port={$server['port']} --function=$worker; "; } } $output = array(); $return = null; $this->sshExec($remote_host, $cmd, $output, $return); }
php
protected function restartGearmanWorkers($remote_host, $remote_dir, $target_dir) { $this->log("restartGearmanWorkers($remote_host, $remote_dir, $target_dir)", LOG_DEBUG); if (!isset($this->gearman['workers']) || empty($this->gearman['workers'])) return; $cmd = "cd $remote_dir/{$target_dir}; "; foreach ($this->gearman['servers'] as $server) { foreach ($this->gearman['workers'] as $worker) { $worker = sprintf($worker, $this->target); $cmd .= "php {$this->gearman_restarter} --ip={$server['ip']} --port={$server['port']} --function=$worker; "; } } $output = array(); $return = null; $this->sshExec($remote_host, $cmd, $output, $return); }
[ "protected", "function", "restartGearmanWorkers", "(", "$", "remote_host", ",", "$", "remote_dir", ",", "$", "target_dir", ")", "{", "$", "this", "->", "log", "(", "\"restartGearmanWorkers($remote_host, $remote_dir, $target_dir)\"", ",", "LOG_DEBUG", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "gearman", "[", "'workers'", "]", ")", "||", "empty", "(", "$", "this", "->", "gearman", "[", "'workers'", "]", ")", ")", "return", ";", "$", "cmd", "=", "\"cd $remote_dir/{$target_dir}; \"", ";", "foreach", "(", "$", "this", "->", "gearman", "[", "'servers'", "]", "as", "$", "server", ")", "{", "foreach", "(", "$", "this", "->", "gearman", "[", "'workers'", "]", "as", "$", "worker", ")", "{", "$", "worker", "=", "sprintf", "(", "$", "worker", ",", "$", "this", "->", "target", ")", ";", "$", "cmd", ".=", "\"php {$this->gearman_restarter} --ip={$server['ip']} --port={$server['port']} --function=$worker; \"", ";", "}", "}", "$", "output", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "$", "cmd", ",", "$", "output", ",", "$", "return", ")", ";", "}" ]
Gearman workers herstarten @param string $remote_host @param string $remote_dir @param string $target_dir
[ "Gearman", "workers", "herstarten" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L579-L600
2,244
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.rollbackFiles
protected function rollbackFiles($remote_host, $remote_dir, $target_dir) { $this->log('rollbackFiles', LOG_DEBUG); $output = array(); $return = null; $this->sshExec($remote_host, 'cd '. $remote_dir .'; rm -rf '. $target_dir, $output, $return); }
php
protected function rollbackFiles($remote_host, $remote_dir, $target_dir) { $this->log('rollbackFiles', LOG_DEBUG); $output = array(); $return = null; $this->sshExec($remote_host, 'cd '. $remote_dir .'; rm -rf '. $target_dir, $output, $return); }
[ "protected", "function", "rollbackFiles", "(", "$", "remote_host", ",", "$", "remote_dir", ",", "$", "target_dir", ")", "{", "$", "this", "->", "log", "(", "'rollbackFiles'", ",", "LOG_DEBUG", ")", ";", "$", "output", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "'cd '", ".", "$", "remote_dir", ".", "'; rm -rf '", ".", "$", "target_dir", ",", "$", "output", ",", "$", "return", ")", ";", "}" ]
Verwijdert de laatst geuploadde directory @param string $remote_host @param string $remote_dir @param string $target_dir
[ "Verwijdert", "de", "laatst", "geuploadde", "directory" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L609-L616
2,245
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.listFilesToRename
protected function listFilesToRename($remote_host, $remote_dir) { if (!isset($this->files_to_rename["$remote_host-$remote_dir"])) { $target_files_to_move = array(); // doelspecifieke files hernoemen if (!empty($this->target_specific_files)) { foreach ($this->target_specific_files as $filepath) { $ext = pathinfo($filepath, PATHINFO_EXTENSION); if (isset($target_files_to_move[$filepath])) { $target_filepath = str_replace(".$ext", ".{$this->target}.$ext", $target_files_to_move[$filepath]); } else { $target_filepath = str_replace(".$ext", ".{$this->target}.$ext", $filepath); } $target_files_to_move[$filepath] = $target_filepath; } } // controleren of alle files bestaan if (!empty($target_files_to_move)) { foreach ($target_files_to_move as $current_filepath) { if (!file_exists($current_filepath)) { throw new DeployException("$current_filepath does not exist"); } } } $this->files_to_rename["$remote_host-$remote_dir"] = $target_files_to_move; } return $this->files_to_rename["$remote_host-$remote_dir"]; }
php
protected function listFilesToRename($remote_host, $remote_dir) { if (!isset($this->files_to_rename["$remote_host-$remote_dir"])) { $target_files_to_move = array(); // doelspecifieke files hernoemen if (!empty($this->target_specific_files)) { foreach ($this->target_specific_files as $filepath) { $ext = pathinfo($filepath, PATHINFO_EXTENSION); if (isset($target_files_to_move[$filepath])) { $target_filepath = str_replace(".$ext", ".{$this->target}.$ext", $target_files_to_move[$filepath]); } else { $target_filepath = str_replace(".$ext", ".{$this->target}.$ext", $filepath); } $target_files_to_move[$filepath] = $target_filepath; } } // controleren of alle files bestaan if (!empty($target_files_to_move)) { foreach ($target_files_to_move as $current_filepath) { if (!file_exists($current_filepath)) { throw new DeployException("$current_filepath does not exist"); } } } $this->files_to_rename["$remote_host-$remote_dir"] = $target_files_to_move; } return $this->files_to_rename["$remote_host-$remote_dir"]; }
[ "protected", "function", "listFilesToRename", "(", "$", "remote_host", ",", "$", "remote_dir", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "files_to_rename", "[", "\"$remote_host-$remote_dir\"", "]", ")", ")", "{", "$", "target_files_to_move", "=", "array", "(", ")", ";", "// doelspecifieke files hernoemen", "if", "(", "!", "empty", "(", "$", "this", "->", "target_specific_files", ")", ")", "{", "foreach", "(", "$", "this", "->", "target_specific_files", "as", "$", "filepath", ")", "{", "$", "ext", "=", "pathinfo", "(", "$", "filepath", ",", "PATHINFO_EXTENSION", ")", ";", "if", "(", "isset", "(", "$", "target_files_to_move", "[", "$", "filepath", "]", ")", ")", "{", "$", "target_filepath", "=", "str_replace", "(", "\".$ext\"", ",", "\".{$this->target}.$ext\"", ",", "$", "target_files_to_move", "[", "$", "filepath", "]", ")", ";", "}", "else", "{", "$", "target_filepath", "=", "str_replace", "(", "\".$ext\"", ",", "\".{$this->target}.$ext\"", ",", "$", "filepath", ")", ";", "}", "$", "target_files_to_move", "[", "$", "filepath", "]", "=", "$", "target_filepath", ";", "}", "}", "// controleren of alle files bestaan", "if", "(", "!", "empty", "(", "$", "target_files_to_move", ")", ")", "{", "foreach", "(", "$", "target_files_to_move", "as", "$", "current_filepath", ")", "{", "if", "(", "!", "file_exists", "(", "$", "current_filepath", ")", ")", "{", "throw", "new", "DeployException", "(", "\"$current_filepath does not exist\"", ")", ";", "}", "}", "}", "$", "this", "->", "files_to_rename", "[", "\"$remote_host-$remote_dir\"", "]", "=", "$", "target_files_to_move", ";", "}", "return", "$", "this", "->", "files_to_rename", "[", "\"$remote_host-$remote_dir\"", "]", ";", "}" ]
Maakt een lijst van de files die specifiek zijn voor een clusterrol of doel en op de doelserver hernoemd moeten worden @param string $remote_host @param string $remote_dir @throws DeployException @return array
[ "Maakt", "een", "lijst", "van", "de", "files", "die", "specifiek", "zijn", "voor", "een", "clusterrol", "of", "doel", "en", "op", "de", "doelserver", "hernoemd", "moeten", "worden" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L662-L704
2,246
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.prepareExcludes
protected function prepareExcludes() { $this->log('prepareExcludes', LOG_DEBUG); chdir($this->basedir); $exclude_param = ''; if (count($this->rsync_excludes) > 0) { foreach ($this->rsync_excludes as $exclude) { if (!file_exists($exclude)) { throw new DeployException('Rsync exclude file not found: '. $exclude); } $exclude_param .= '--exclude-from='. escapeshellarg($exclude) .' '; } } if (!empty($this->data_dirs)) { foreach ($this->data_dirs as $data_dir) { $exclude_param .= '--exclude '. escapeshellarg("/$data_dir") .' '; } } return $exclude_param; }
php
protected function prepareExcludes() { $this->log('prepareExcludes', LOG_DEBUG); chdir($this->basedir); $exclude_param = ''; if (count($this->rsync_excludes) > 0) { foreach ($this->rsync_excludes as $exclude) { if (!file_exists($exclude)) { throw new DeployException('Rsync exclude file not found: '. $exclude); } $exclude_param .= '--exclude-from='. escapeshellarg($exclude) .' '; } } if (!empty($this->data_dirs)) { foreach ($this->data_dirs as $data_dir) { $exclude_param .= '--exclude '. escapeshellarg("/$data_dir") .' '; } } return $exclude_param; }
[ "protected", "function", "prepareExcludes", "(", ")", "{", "$", "this", "->", "log", "(", "'prepareExcludes'", ",", "LOG_DEBUG", ")", ";", "chdir", "(", "$", "this", "->", "basedir", ")", ";", "$", "exclude_param", "=", "''", ";", "if", "(", "count", "(", "$", "this", "->", "rsync_excludes", ")", ">", "0", ")", "{", "foreach", "(", "$", "this", "->", "rsync_excludes", "as", "$", "exclude", ")", "{", "if", "(", "!", "file_exists", "(", "$", "exclude", ")", ")", "{", "throw", "new", "DeployException", "(", "'Rsync exclude file not found: '", ".", "$", "exclude", ")", ";", "}", "$", "exclude_param", ".=", "'--exclude-from='", ".", "escapeshellarg", "(", "$", "exclude", ")", ".", "' '", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "data_dirs", ")", ")", "{", "foreach", "(", "$", "this", "->", "data_dirs", "as", "$", "data_dir", ")", "{", "$", "exclude_param", ".=", "'--exclude '", ".", "escapeshellarg", "(", "\"/$data_dir\"", ")", ".", "' '", ";", "}", "}", "return", "$", "exclude_param", ";", "}" ]
Zet het array van rsync excludes om in een lijst rsync parameters @throws DeployException @return string
[ "Zet", "het", "array", "van", "rsync", "excludes", "om", "in", "een", "lijst", "rsync", "parameters" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L743-L773
2,247
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.prepareRemoteDirectory
protected function prepareRemoteDirectory($remote_host, $remote_dir) { $this->log('Initialize remote directory: '. $remote_host .':'. $remote_dir, LOG_INFO, true); $output = array(); $return = null; $this->sshExec($remote_host, "mkdir -p $remote_dir", $output, $return, '', '', LOG_DEBUG); if (empty($this->data_dirs)) return; $data_dirs = count($this->data_dirs) > 1 ? '{'. implode(',', $this->data_dirs) .'}' : implode(',', $this->data_dirs); $cmd = "mkdir -v -m 0775 -p $remote_dir/{$this->data_dir_prefix}/$data_dirs"; $output = array(); $return = null; $this->sshExec($remote_host, $cmd, $output, $return, '', '', LOG_DEBUG); }
php
protected function prepareRemoteDirectory($remote_host, $remote_dir) { $this->log('Initialize remote directory: '. $remote_host .':'. $remote_dir, LOG_INFO, true); $output = array(); $return = null; $this->sshExec($remote_host, "mkdir -p $remote_dir", $output, $return, '', '', LOG_DEBUG); if (empty($this->data_dirs)) return; $data_dirs = count($this->data_dirs) > 1 ? '{'. implode(',', $this->data_dirs) .'}' : implode(',', $this->data_dirs); $cmd = "mkdir -v -m 0775 -p $remote_dir/{$this->data_dir_prefix}/$data_dirs"; $output = array(); $return = null; $this->sshExec($remote_host, $cmd, $output, $return, '', '', LOG_DEBUG); }
[ "protected", "function", "prepareRemoteDirectory", "(", "$", "remote_host", ",", "$", "remote_dir", ")", "{", "$", "this", "->", "log", "(", "'Initialize remote directory: '", ".", "$", "remote_host", ".", "':'", ".", "$", "remote_dir", ",", "LOG_INFO", ",", "true", ")", ";", "$", "output", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "\"mkdir -p $remote_dir\"", ",", "$", "output", ",", "$", "return", ",", "''", ",", "''", ",", "LOG_DEBUG", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "data_dirs", ")", ")", "return", ";", "$", "data_dirs", "=", "count", "(", "$", "this", "->", "data_dirs", ")", ">", "1", "?", "'{'", ".", "implode", "(", "','", ",", "$", "this", "->", "data_dirs", ")", ".", "'}'", ":", "implode", "(", "','", ",", "$", "this", "->", "data_dirs", ")", ";", "$", "cmd", "=", "\"mkdir -v -m 0775 -p $remote_dir/{$this->data_dir_prefix}/$data_dirs\"", ";", "$", "output", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "$", "cmd", ",", "$", "output", ",", "$", "return", ",", "''", ",", "''", ",", "LOG_DEBUG", ")", ";", "}" ]
Initializes the remote project and data directories. @param string $remote_host @param string $remote_dir
[ "Initializes", "the", "remote", "project", "and", "data", "directories", "." ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L804-L822
2,248
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.findPastDeploymentTimestamps
protected function findPastDeploymentTimestamps($remote_host, $remote_dir) { $this->log('findPastDeploymentTimestamps', LOG_DEBUG); $this->prepareRemoteDirectory($remote_host, $remote_dir); if ($remote_dir === null) $remote_dir = $this->remote_dir; $dirs = array(); $return = null; $this->sshExec($remote_host, "ls -1 $remote_dir", $dirs, $return, '', '', LOG_DEBUG); if ($return !== 0) throw new DeployException('ssh initialize failed'); if (!count($dirs)) return null; $past_deployments = array(); $deployment_timestamps = array(); foreach ($dirs as $dirname) { if ( preg_match('/'. preg_quote($this->project_name) .'_\d{4}-\d{2}-\d{2}_\d{6}/', $dirname) && ($time = strtotime(str_replace(array($this->project_name .'_', '_'), array('', ' '), $dirname))) ) { $past_deployments[] = $dirname; $deployment_timestamps[] = $time; } } $count = count($deployment_timestamps); if ($count == 0) return null; $this->log('Past deployments:', LOG_INFO, true); $this->log($past_deployments, LOG_INFO, true); sort($deployment_timestamps); if ($count >= 2) return array_slice($deployment_timestamps, -2); return array(null, array_pop($deployment_timestamps)); }
php
protected function findPastDeploymentTimestamps($remote_host, $remote_dir) { $this->log('findPastDeploymentTimestamps', LOG_DEBUG); $this->prepareRemoteDirectory($remote_host, $remote_dir); if ($remote_dir === null) $remote_dir = $this->remote_dir; $dirs = array(); $return = null; $this->sshExec($remote_host, "ls -1 $remote_dir", $dirs, $return, '', '', LOG_DEBUG); if ($return !== 0) throw new DeployException('ssh initialize failed'); if (!count($dirs)) return null; $past_deployments = array(); $deployment_timestamps = array(); foreach ($dirs as $dirname) { if ( preg_match('/'. preg_quote($this->project_name) .'_\d{4}-\d{2}-\d{2}_\d{6}/', $dirname) && ($time = strtotime(str_replace(array($this->project_name .'_', '_'), array('', ' '), $dirname))) ) { $past_deployments[] = $dirname; $deployment_timestamps[] = $time; } } $count = count($deployment_timestamps); if ($count == 0) return null; $this->log('Past deployments:', LOG_INFO, true); $this->log($past_deployments, LOG_INFO, true); sort($deployment_timestamps); if ($count >= 2) return array_slice($deployment_timestamps, -2); return array(null, array_pop($deployment_timestamps)); }
[ "protected", "function", "findPastDeploymentTimestamps", "(", "$", "remote_host", ",", "$", "remote_dir", ")", "{", "$", "this", "->", "log", "(", "'findPastDeploymentTimestamps'", ",", "LOG_DEBUG", ")", ";", "$", "this", "->", "prepareRemoteDirectory", "(", "$", "remote_host", ",", "$", "remote_dir", ")", ";", "if", "(", "$", "remote_dir", "===", "null", ")", "$", "remote_dir", "=", "$", "this", "->", "remote_dir", ";", "$", "dirs", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "\"ls -1 $remote_dir\"", ",", "$", "dirs", ",", "$", "return", ",", "''", ",", "''", ",", "LOG_DEBUG", ")", ";", "if", "(", "$", "return", "!==", "0", ")", "throw", "new", "DeployException", "(", "'ssh initialize failed'", ")", ";", "if", "(", "!", "count", "(", "$", "dirs", ")", ")", "return", "null", ";", "$", "past_deployments", "=", "array", "(", ")", ";", "$", "deployment_timestamps", "=", "array", "(", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dirname", ")", "{", "if", "(", "preg_match", "(", "'/'", ".", "preg_quote", "(", "$", "this", "->", "project_name", ")", ".", "'_\\d{4}-\\d{2}-\\d{2}_\\d{6}/'", ",", "$", "dirname", ")", "&&", "(", "$", "time", "=", "strtotime", "(", "str_replace", "(", "array", "(", "$", "this", "->", "project_name", ".", "'_'", ",", "'_'", ")", ",", "array", "(", "''", ",", "' '", ")", ",", "$", "dirname", ")", ")", ")", ")", "{", "$", "past_deployments", "[", "]", "=", "$", "dirname", ";", "$", "deployment_timestamps", "[", "]", "=", "$", "time", ";", "}", "}", "$", "count", "=", "count", "(", "$", "deployment_timestamps", ")", ";", "if", "(", "$", "count", "==", "0", ")", "return", "null", ";", "$", "this", "->", "log", "(", "'Past deployments:'", ",", "LOG_INFO", ",", "true", ")", ";", "$", "this", "->", "log", "(", "$", "past_deployments", ",", "LOG_INFO", ",", "true", ")", ";", "sort", "(", "$", "deployment_timestamps", ")", ";", "if", "(", "$", "count", ">=", "2", ")", "return", "array_slice", "(", "$", "deployment_timestamps", ",", "-", "2", ")", ";", "return", "array", "(", "null", ",", "array_pop", "(", "$", "deployment_timestamps", ")", ")", ";", "}" ]
Returns the timestamps of the second latest and latest deployments @param string $remote_host @param string $remote_dir @throws DeployException @return array [previous_timestamp, last_timestamp]
[ "Returns", "the", "timestamps", "of", "the", "second", "latest", "and", "latest", "deployments" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L832-L880
2,249
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.collectPastDeployments
protected function collectPastDeployments($remote_host, $remote_dir) { $this->log('collectPastDeployments', LOG_DEBUG); $dirs = array(); $return = null; $this->sshExec($remote_host, "ls -1 $remote_dir", $dirs, $return); if ($return !== 0) { throw new DeployException('ssh initialize failed'); } if (!count($dirs)) return null; $deployment_dirs = array(); foreach ($dirs as $dirname) { if (preg_match('/'. preg_quote($this->project_name) .'_\d{4}-\d{2}-\d{2}_\d{6}/', $dirname)) { $deployment_dirs[] = $dirname; } } // the two latest deployments always stay if (count($deployment_dirs) <= 2) return null; $dirs_to_delete = array(); sort($deployment_dirs); $deployment_dirs = array_slice($deployment_dirs, 0, -2); foreach ($deployment_dirs as $key => $dirname) { $time = strtotime(str_replace(array($this->project_name .'_', '_'), array('', ' '), $dirname)); // deployments older than a month can go if ($time < strtotime('-1 month')) { $this->log("$dirname is older than a month"); $dirs_to_delete[] = $dirname; } // of deployments older than a week only the last one of the day stays elseif ($time < strtotime('-1 week')) { if (isset($deployment_dirs[$key+1])) { $time_next = strtotime(str_replace(array($this->project_name .'_', '_'), array('', ' '), $deployment_dirs[$key+1])); // if the next deployment was on the same day this one can go if (date('j', $time_next) == date('j', $time)) { $this->log("$dirname was replaced the same day"); $dirs_to_delete[] = $dirname; } else { $this->log("$dirname stays"); } } } else { $this->log("$dirname stays"); } } return $dirs_to_delete; }
php
protected function collectPastDeployments($remote_host, $remote_dir) { $this->log('collectPastDeployments', LOG_DEBUG); $dirs = array(); $return = null; $this->sshExec($remote_host, "ls -1 $remote_dir", $dirs, $return); if ($return !== 0) { throw new DeployException('ssh initialize failed'); } if (!count($dirs)) return null; $deployment_dirs = array(); foreach ($dirs as $dirname) { if (preg_match('/'. preg_quote($this->project_name) .'_\d{4}-\d{2}-\d{2}_\d{6}/', $dirname)) { $deployment_dirs[] = $dirname; } } // the two latest deployments always stay if (count($deployment_dirs) <= 2) return null; $dirs_to_delete = array(); sort($deployment_dirs); $deployment_dirs = array_slice($deployment_dirs, 0, -2); foreach ($deployment_dirs as $key => $dirname) { $time = strtotime(str_replace(array($this->project_name .'_', '_'), array('', ' '), $dirname)); // deployments older than a month can go if ($time < strtotime('-1 month')) { $this->log("$dirname is older than a month"); $dirs_to_delete[] = $dirname; } // of deployments older than a week only the last one of the day stays elseif ($time < strtotime('-1 week')) { if (isset($deployment_dirs[$key+1])) { $time_next = strtotime(str_replace(array($this->project_name .'_', '_'), array('', ' '), $deployment_dirs[$key+1])); // if the next deployment was on the same day this one can go if (date('j', $time_next) == date('j', $time)) { $this->log("$dirname was replaced the same day"); $dirs_to_delete[] = $dirname; } else { $this->log("$dirname stays"); } } } else { $this->log("$dirname stays"); } } return $dirs_to_delete; }
[ "protected", "function", "collectPastDeployments", "(", "$", "remote_host", ",", "$", "remote_dir", ")", "{", "$", "this", "->", "log", "(", "'collectPastDeployments'", ",", "LOG_DEBUG", ")", ";", "$", "dirs", "=", "array", "(", ")", ";", "$", "return", "=", "null", ";", "$", "this", "->", "sshExec", "(", "$", "remote_host", ",", "\"ls -1 $remote_dir\"", ",", "$", "dirs", ",", "$", "return", ")", ";", "if", "(", "$", "return", "!==", "0", ")", "{", "throw", "new", "DeployException", "(", "'ssh initialize failed'", ")", ";", "}", "if", "(", "!", "count", "(", "$", "dirs", ")", ")", "return", "null", ";", "$", "deployment_dirs", "=", "array", "(", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dirname", ")", "{", "if", "(", "preg_match", "(", "'/'", ".", "preg_quote", "(", "$", "this", "->", "project_name", ")", ".", "'_\\d{4}-\\d{2}-\\d{2}_\\d{6}/'", ",", "$", "dirname", ")", ")", "{", "$", "deployment_dirs", "[", "]", "=", "$", "dirname", ";", "}", "}", "// the two latest deployments always stay", "if", "(", "count", "(", "$", "deployment_dirs", ")", "<=", "2", ")", "return", "null", ";", "$", "dirs_to_delete", "=", "array", "(", ")", ";", "sort", "(", "$", "deployment_dirs", ")", ";", "$", "deployment_dirs", "=", "array_slice", "(", "$", "deployment_dirs", ",", "0", ",", "-", "2", ")", ";", "foreach", "(", "$", "deployment_dirs", "as", "$", "key", "=>", "$", "dirname", ")", "{", "$", "time", "=", "strtotime", "(", "str_replace", "(", "array", "(", "$", "this", "->", "project_name", ".", "'_'", ",", "'_'", ")", ",", "array", "(", "''", ",", "' '", ")", ",", "$", "dirname", ")", ")", ";", "// deployments older than a month can go", "if", "(", "$", "time", "<", "strtotime", "(", "'-1 month'", ")", ")", "{", "$", "this", "->", "log", "(", "\"$dirname is older than a month\"", ")", ";", "$", "dirs_to_delete", "[", "]", "=", "$", "dirname", ";", "}", "// of deployments older than a week only the last one of the day stays", "elseif", "(", "$", "time", "<", "strtotime", "(", "'-1 week'", ")", ")", "{", "if", "(", "isset", "(", "$", "deployment_dirs", "[", "$", "key", "+", "1", "]", ")", ")", "{", "$", "time_next", "=", "strtotime", "(", "str_replace", "(", "array", "(", "$", "this", "->", "project_name", ".", "'_'", ",", "'_'", ")", ",", "array", "(", "''", ",", "' '", ")", ",", "$", "deployment_dirs", "[", "$", "key", "+", "1", "]", ")", ")", ";", "// if the next deployment was on the same day this one can go", "if", "(", "date", "(", "'j'", ",", "$", "time_next", ")", "==", "date", "(", "'j'", ",", "$", "time", ")", ")", "{", "$", "this", "->", "log", "(", "\"$dirname was replaced the same day\"", ")", ";", "$", "dirs_to_delete", "[", "]", "=", "$", "dirname", ";", "}", "else", "{", "$", "this", "->", "log", "(", "\"$dirname stays\"", ")", ";", "}", "}", "}", "else", "{", "$", "this", "->", "log", "(", "\"$dirname stays\"", ")", ";", "}", "}", "return", "$", "dirs_to_delete", ";", "}" ]
Returns all obsolete deployments that can be deleted. @param string $remote_host @param string $remote_dir @throws DeployException @return array
[ "Returns", "all", "obsolete", "deployments", "that", "can", "be", "deleted", "." ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L890-L962
2,250
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.deletePastDeployments
protected function deletePastDeployments($past_deployments) { foreach ($past_deployments as $past_deployment) { $this->rollbackFiles($past_deployment['remote_host'], $past_deployment['remote_dir'], implode(' ', $past_deployment['dirs'])); } }
php
protected function deletePastDeployments($past_deployments) { foreach ($past_deployments as $past_deployment) { $this->rollbackFiles($past_deployment['remote_host'], $past_deployment['remote_dir'], implode(' ', $past_deployment['dirs'])); } }
[ "protected", "function", "deletePastDeployments", "(", "$", "past_deployments", ")", "{", "foreach", "(", "$", "past_deployments", "as", "$", "past_deployment", ")", "{", "$", "this", "->", "rollbackFiles", "(", "$", "past_deployment", "[", "'remote_host'", "]", ",", "$", "past_deployment", "[", "'remote_dir'", "]", ",", "implode", "(", "' '", ",", "$", "past_deployment", "[", "'dirs'", "]", ")", ")", ";", "}", "}" ]
Deletes obsolete deployments as collected by collectPastDeployments @param array $past_deployments
[ "Deletes", "obsolete", "deployments", "as", "collected", "by", "collectPastDeployments" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L969-L975
2,251
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.sshExec
protected function sshExec($remote_host, $command, &$output, &$return, $hide_pattern = '', $hide_replacement = '', $ouput_loglevel = LOG_INFO) { $cmd = $this->ssh_path .' -p '. $this->remote_port .' '. $this->remote_user .'@'. $remote_host .' "'. str_replace('"', '\"', $command) .'"'; if ($hide_pattern != '') { $show_cmd = preg_replace($hide_pattern, $hide_replacement, $cmd); } else { $show_cmd = $cmd; } $this->log('sshExec: '. $show_cmd, $ouput_loglevel); exec($cmd, $output, $return); }
php
protected function sshExec($remote_host, $command, &$output, &$return, $hide_pattern = '', $hide_replacement = '', $ouput_loglevel = LOG_INFO) { $cmd = $this->ssh_path .' -p '. $this->remote_port .' '. $this->remote_user .'@'. $remote_host .' "'. str_replace('"', '\"', $command) .'"'; if ($hide_pattern != '') { $show_cmd = preg_replace($hide_pattern, $hide_replacement, $cmd); } else { $show_cmd = $cmd; } $this->log('sshExec: '. $show_cmd, $ouput_loglevel); exec($cmd, $output, $return); }
[ "protected", "function", "sshExec", "(", "$", "remote_host", ",", "$", "command", ",", "&", "$", "output", ",", "&", "$", "return", ",", "$", "hide_pattern", "=", "''", ",", "$", "hide_replacement", "=", "''", ",", "$", "ouput_loglevel", "=", "LOG_INFO", ")", "{", "$", "cmd", "=", "$", "this", "->", "ssh_path", ".", "' -p '", ".", "$", "this", "->", "remote_port", ".", "' '", ".", "$", "this", "->", "remote_user", ".", "'@'", ".", "$", "remote_host", ".", "' \"'", ".", "str_replace", "(", "'\"'", ",", "'\\\"'", ",", "$", "command", ")", ".", "'\"'", ";", "if", "(", "$", "hide_pattern", "!=", "''", ")", "{", "$", "show_cmd", "=", "preg_replace", "(", "$", "hide_pattern", ",", "$", "hide_replacement", ",", "$", "cmd", ")", ";", "}", "else", "{", "$", "show_cmd", "=", "$", "cmd", ";", "}", "$", "this", "->", "log", "(", "'sshExec: '", ".", "$", "show_cmd", ",", "$", "ouput_loglevel", ")", ";", "exec", "(", "$", "cmd", ",", "$", "output", ",", "$", "return", ")", ";", "}" ]
Wrapper for SSH command's @param string $remote_host @param string $command @param array $output @param int $return @param string $hide_pattern Regexp to clean up output (eg. passwords) @param string $hide_replacement @param int $ouput_loglevel
[ "Wrapper", "for", "SSH", "command", "s" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L988-L1001
2,252
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.rsyncExec
protected function rsyncExec($command, $error_msg = 'Rsync has failed') { $this->log('execRSync: '. $command, LOG_DEBUG); chdir($this->basedir); passthru($command, $return); $this->log(''); if ($return !== 0) { throw new DeployException($error_msg); } }
php
protected function rsyncExec($command, $error_msg = 'Rsync has failed') { $this->log('execRSync: '. $command, LOG_DEBUG); chdir($this->basedir); passthru($command, $return); $this->log(''); if ($return !== 0) { throw new DeployException($error_msg); } }
[ "protected", "function", "rsyncExec", "(", "$", "command", ",", "$", "error_msg", "=", "'Rsync has failed'", ")", "{", "$", "this", "->", "log", "(", "'execRSync: '", ".", "$", "command", ",", "LOG_DEBUG", ")", ";", "chdir", "(", "$", "this", "->", "basedir", ")", ";", "passthru", "(", "$", "command", ",", "$", "return", ")", ";", "$", "this", "->", "log", "(", "''", ")", ";", "if", "(", "$", "return", "!==", "0", ")", "{", "throw", "new", "DeployException", "(", "$", "error_msg", ")", ";", "}", "}" ]
Wrapper for rsync command's @param string $command @param string $error_msg @throws DeployException
[ "Wrapper", "for", "rsync", "command", "s" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L1010-L1023
2,253
bugbyte/deployer
lib/base/BaseDeploy.class.php
BaseDeploy.inputPrompt
static protected function inputPrompt($message, $default = '', $isPassword = false) { fwrite(STDOUT, $message); if (!$isPassword) { $input = trim(fgets(STDIN)); } else { $input = self::getPassword(false); echo PHP_EOL; } if ($input == '') $input = $default; return $input; }
php
static protected function inputPrompt($message, $default = '', $isPassword = false) { fwrite(STDOUT, $message); if (!$isPassword) { $input = trim(fgets(STDIN)); } else { $input = self::getPassword(false); echo PHP_EOL; } if ($input == '') $input = $default; return $input; }
[ "static", "protected", "function", "inputPrompt", "(", "$", "message", ",", "$", "default", "=", "''", ",", "$", "isPassword", "=", "false", ")", "{", "fwrite", "(", "STDOUT", ",", "$", "message", ")", ";", "if", "(", "!", "$", "isPassword", ")", "{", "$", "input", "=", "trim", "(", "fgets", "(", "STDIN", ")", ")", ";", "}", "else", "{", "$", "input", "=", "self", "::", "getPassword", "(", "false", ")", ";", "echo", "PHP_EOL", ";", "}", "if", "(", "$", "input", "==", "''", ")", "$", "input", "=", "$", "default", ";", "return", "$", "input", ";", "}" ]
Asks the user for input @param string $message @param string $default @param boolean $isPassword @return string
[ "Asks", "the", "user", "for", "input" ]
501f78900fdbb6b2ed89090645559a98a986a307
https://github.com/bugbyte/deployer/blob/501f78900fdbb6b2ed89090645559a98a986a307/lib/base/BaseDeploy.class.php#L1033-L1051
2,254
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapFormHelper.php
BootstrapFormHelper.create
public function create($model = null, $options = []) { $defaults = [ 'inputDefaults' => [ 'div' => [ 'class' => 'form-group', ], 'label' => [ 'class' => 'control-label', ], 'class' => 'form-control', 'error' => [ 'attributes' => [ 'wrap' => 'p', 'class' => 'text-danger', ], ], ], 'class' => null, 'role' => 'form', ]; $options = Hash::merge($defaults, $options); return parent::create($model, $options); }
php
public function create($model = null, $options = []) { $defaults = [ 'inputDefaults' => [ 'div' => [ 'class' => 'form-group', ], 'label' => [ 'class' => 'control-label', ], 'class' => 'form-control', 'error' => [ 'attributes' => [ 'wrap' => 'p', 'class' => 'text-danger', ], ], ], 'class' => null, 'role' => 'form', ]; $options = Hash::merge($defaults, $options); return parent::create($model, $options); }
[ "public", "function", "create", "(", "$", "model", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'inputDefaults'", "=>", "[", "'div'", "=>", "[", "'class'", "=>", "'form-group'", ",", "]", ",", "'label'", "=>", "[", "'class'", "=>", "'control-label'", ",", "]", ",", "'class'", "=>", "'form-control'", ",", "'error'", "=>", "[", "'attributes'", "=>", "[", "'wrap'", "=>", "'p'", ",", "'class'", "=>", "'text-danger'", ",", "]", ",", "]", ",", "]", ",", "'class'", "=>", "null", ",", "'role'", "=>", "'form'", ",", "]", ";", "$", "options", "=", "Hash", "::", "merge", "(", "$", "defaults", ",", "$", "options", ")", ";", "return", "parent", "::", "create", "(", "$", "model", ",", "$", "options", ")", ";", "}" ]
Starts a new form with input defaults. @param string $model @param array $options @return string
[ "Starts", "a", "new", "form", "with", "input", "defaults", "." ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapFormHelper.php#L51-L76
2,255
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapFormHelper.php
BootstrapFormHelper.btnReset
public function btnReset($title = '', $options = []) { $title = empty($title) ? __('Reset') : $title; $options = array_merge([ 'class' => 'btn btn-success', 'type' => 'reset', ], $options); return parent::button($title, $options); }
php
public function btnReset($title = '', $options = []) { $title = empty($title) ? __('Reset') : $title; $options = array_merge([ 'class' => 'btn btn-success', 'type' => 'reset', ], $options); return parent::button($title, $options); }
[ "public", "function", "btnReset", "(", "$", "title", "=", "''", ",", "$", "options", "=", "[", "]", ")", "{", "$", "title", "=", "empty", "(", "$", "title", ")", "?", "__", "(", "'Reset'", ")", ":", "$", "title", ";", "$", "options", "=", "array_merge", "(", "[", "'class'", "=>", "'btn btn-success'", ",", "'type'", "=>", "'reset'", ",", "]", ",", "$", "options", ")", ";", "return", "parent", "::", "button", "(", "$", "title", ",", "$", "options", ")", ";", "}" ]
Creates a reset button for a form @param string $title @param array $options @return string
[ "Creates", "a", "reset", "button", "for", "a", "form" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapFormHelper.php#L214-L222
2,256
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapFormHelper.php
BootstrapFormHelper.btnSubmit
public function btnSubmit($title = '', $options = []) { $title = empty($title) ? __('Submit') : $title; $options = array_merge([ 'class' => 'btn btn-success', 'type' => 'submit', ], $options); return parent::button($title, $options); }
php
public function btnSubmit($title = '', $options = []) { $title = empty($title) ? __('Submit') : $title; $options = array_merge([ 'class' => 'btn btn-success', 'type' => 'submit', ], $options); return parent::button($title, $options); }
[ "public", "function", "btnSubmit", "(", "$", "title", "=", "''", ",", "$", "options", "=", "[", "]", ")", "{", "$", "title", "=", "empty", "(", "$", "title", ")", "?", "__", "(", "'Submit'", ")", ":", "$", "title", ";", "$", "options", "=", "array_merge", "(", "[", "'class'", "=>", "'btn btn-success'", ",", "'type'", "=>", "'submit'", ",", "]", ",", "$", "options", ")", ";", "return", "parent", "::", "button", "(", "$", "title", ",", "$", "options", ")", ";", "}" ]
Creates a submit button for a form @param string $title @param array $options @return string
[ "Creates", "a", "submit", "button", "for", "a", "form" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapFormHelper.php#L231-L239
2,257
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapFormHelper.php
BootstrapFormHelper.btnCancel
public function btnCancel($title = '', $options = []) { $title = empty($title) ? __('Cancel') : $title; $options = array_merge([ 'class' => 'btn btn-danger', 'type' => 'reset', 'data-dismiss' => 'modal', ], $options); return parent::button($title, $options); }
php
public function btnCancel($title = '', $options = []) { $title = empty($title) ? __('Cancel') : $title; $options = array_merge([ 'class' => 'btn btn-danger', 'type' => 'reset', 'data-dismiss' => 'modal', ], $options); return parent::button($title, $options); }
[ "public", "function", "btnCancel", "(", "$", "title", "=", "''", ",", "$", "options", "=", "[", "]", ")", "{", "$", "title", "=", "empty", "(", "$", "title", ")", "?", "__", "(", "'Cancel'", ")", ":", "$", "title", ";", "$", "options", "=", "array_merge", "(", "[", "'class'", "=>", "'btn btn-danger'", ",", "'type'", "=>", "'reset'", ",", "'data-dismiss'", "=>", "'modal'", ",", "]", ",", "$", "options", ")", ";", "return", "parent", "::", "button", "(", "$", "title", ",", "$", "options", ")", ";", "}" ]
Creates a cancel button. Used to dismiss modals @param string $title @param array $options @return string
[ "Creates", "a", "cancel", "button", ".", "Used", "to", "dismiss", "modals" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapFormHelper.php#L248-L257
2,258
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapFormHelper.php
BootstrapFormHelper.end
public function end($options = null, $secureAttributes = []) { if (!empty($options)) { if (!is_array($options)) { $options = ['label' => $options]; } $defaults = [ 'class' => 'btn btn-success', ]; $options = array_merge($defaults, $options); } return parent::end($options, $secureAttributes); }
php
public function end($options = null, $secureAttributes = []) { if (!empty($options)) { if (!is_array($options)) { $options = ['label' => $options]; } $defaults = [ 'class' => 'btn btn-success', ]; $options = array_merge($defaults, $options); } return parent::end($options, $secureAttributes); }
[ "public", "function", "end", "(", "$", "options", "=", "null", ",", "$", "secureAttributes", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", ")", "{", "$", "options", "=", "[", "'label'", "=>", "$", "options", "]", ";", "}", "$", "defaults", "=", "[", "'class'", "=>", "'btn btn-success'", ",", "]", ";", "$", "options", "=", "array_merge", "(", "$", "defaults", ",", "$", "options", ")", ";", "}", "return", "parent", "::", "end", "(", "$", "options", ",", "$", "secureAttributes", ")", ";", "}" ]
Add divs and classes necessary for bootstrap to end form. @param array $options @param array $secureAttributes @return string
[ "Add", "divs", "and", "classes", "necessary", "for", "bootstrap", "to", "end", "form", "." ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapFormHelper.php#L266-L278
2,259
salernolabs/collapser
src/Javascript.php
Javascript.handleCharacter47
protected function handleCharacter47() { if ($this->inQuotes || $this->inSingleQuotes || $this->inCondition) return true; return parent::handleCharacter47(); }
php
protected function handleCharacter47() { if ($this->inQuotes || $this->inSingleQuotes || $this->inCondition) return true; return parent::handleCharacter47(); }
[ "protected", "function", "handleCharacter47", "(", ")", "{", "if", "(", "$", "this", "->", "inQuotes", "||", "$", "this", "->", "inSingleQuotes", "||", "$", "this", "->", "inCondition", ")", "return", "true", ";", "return", "parent", "::", "handleCharacter47", "(", ")", ";", "}" ]
Handle javascript matches @see \Chorizo\Utilities\Collapser\Media::handleCharacter47()
[ "Handle", "javascript", "matches" ]
fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c
https://github.com/salernolabs/collapser/blob/fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c/src/Javascript.php#L79-L84
2,260
salernolabs/collapser
src/Javascript.php
Javascript.handleCharacter32
protected function handleCharacter32() { $this->lastSpace = $this->currentIndex; if (!empty($this->keywordHashMap[$this->buildingWord])) { return true; } if ((chr($this->nextCharacter) . $this->input[$this->currentIndex + 2]) == 'in') { return true; } if ($this->inCondition) { return true; } if ($this->inQuotes) { return true; } if ($this->inSingleQuotes) { return true; } return false; }
php
protected function handleCharacter32() { $this->lastSpace = $this->currentIndex; if (!empty($this->keywordHashMap[$this->buildingWord])) { return true; } if ((chr($this->nextCharacter) . $this->input[$this->currentIndex + 2]) == 'in') { return true; } if ($this->inCondition) { return true; } if ($this->inQuotes) { return true; } if ($this->inSingleQuotes) { return true; } return false; }
[ "protected", "function", "handleCharacter32", "(", ")", "{", "$", "this", "->", "lastSpace", "=", "$", "this", "->", "currentIndex", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "keywordHashMap", "[", "$", "this", "->", "buildingWord", "]", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "chr", "(", "$", "this", "->", "nextCharacter", ")", ".", "$", "this", "->", "input", "[", "$", "this", "->", "currentIndex", "+", "2", "]", ")", "==", "'in'", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "inCondition", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "inQuotes", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "inSingleQuotes", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Handle un-quoted spaces @return boolean
[ "Handle", "un", "-", "quoted", "spaces" ]
fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c
https://github.com/salernolabs/collapser/blob/fbf1ced832bafb4ffba7dd30b2d48e52e64a4e7c/src/Javascript.php#L91-L117
2,261
pdenis/SnideTravinizerBundle
Loader/ScrutinizerLoader.php
ScrutinizerLoader.load
public function load(Repo $repo) { $scrutinizerRepo = $this->client->fetchRepository(new Repository($repo->getSlug(), $repo->getType())); if ($scrutinizerRepo) { // Inject scrutinizer data into repository $repo->setMetrics($scrutinizerRepo->getMetrics()); $repo->setPdependMetrics($scrutinizerRepo->getPdependMetrics()); } return $repo; }
php
public function load(Repo $repo) { $scrutinizerRepo = $this->client->fetchRepository(new Repository($repo->getSlug(), $repo->getType())); if ($scrutinizerRepo) { // Inject scrutinizer data into repository $repo->setMetrics($scrutinizerRepo->getMetrics()); $repo->setPdependMetrics($scrutinizerRepo->getPdependMetrics()); } return $repo; }
[ "public", "function", "load", "(", "Repo", "$", "repo", ")", "{", "$", "scrutinizerRepo", "=", "$", "this", "->", "client", "->", "fetchRepository", "(", "new", "Repository", "(", "$", "repo", "->", "getSlug", "(", ")", ",", "$", "repo", "->", "getType", "(", ")", ")", ")", ";", "if", "(", "$", "scrutinizerRepo", ")", "{", "// Inject scrutinizer data into repository", "$", "repo", "->", "setMetrics", "(", "$", "scrutinizerRepo", "->", "getMetrics", "(", ")", ")", ";", "$", "repo", "->", "setPdependMetrics", "(", "$", "scrutinizerRepo", "->", "getPdependMetrics", "(", ")", ")", ";", "}", "return", "$", "repo", ";", "}" ]
Load scruinitzer infos for repository @param Repo $repo @return Repo
[ "Load", "scruinitzer", "infos", "for", "repository" ]
53a6fd647280d81a496018d379e4b5c446f81729
https://github.com/pdenis/SnideTravinizerBundle/blob/53a6fd647280d81a496018d379e4b5c446f81729/Loader/ScrutinizerLoader.php#L47-L58
2,262
trivialsense/php-framework-common
src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php
TranslatableRepository.getResult
public function getResult(QueryBuilder $qb, $locale = null, $hydrationMode = AbstractQuery::HYDRATE_OBJECT) { return $this->getTranslatedQuery($qb, $locale)->getResult($hydrationMode); }
php
public function getResult(QueryBuilder $qb, $locale = null, $hydrationMode = AbstractQuery::HYDRATE_OBJECT) { return $this->getTranslatedQuery($qb, $locale)->getResult($hydrationMode); }
[ "public", "function", "getResult", "(", "QueryBuilder", "$", "qb", ",", "$", "locale", "=", "null", ",", "$", "hydrationMode", "=", "AbstractQuery", "::", "HYDRATE_OBJECT", ")", "{", "return", "$", "this", "->", "getTranslatedQuery", "(", "$", "qb", ",", "$", "locale", ")", "->", "getResult", "(", "$", "hydrationMode", ")", ";", "}" ]
Returns translated results for given locale @param QueryBuilder $qb A Doctrine query builder instance @param string $locale A locale name @param string $hydrationMode A Doctrine results hydration mode @return QueryBuilder
[ "Returns", "translated", "results", "for", "given", "locale" ]
3cb769c62df7badaeae557306c8f738252adaa28
https://github.com/trivialsense/php-framework-common/blob/3cb769c62df7badaeae557306c8f738252adaa28/src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php#L128-L131
2,263
trivialsense/php-framework-common
src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php
TranslatableRepository.getArrayResult
public function getArrayResult(QueryBuilder $qb, $locale = null) { return $this->getTranslatedQuery($qb, $locale)->getArrayResult(); }
php
public function getArrayResult(QueryBuilder $qb, $locale = null) { return $this->getTranslatedQuery($qb, $locale)->getArrayResult(); }
[ "public", "function", "getArrayResult", "(", "QueryBuilder", "$", "qb", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "this", "->", "getTranslatedQuery", "(", "$", "qb", ",", "$", "locale", ")", "->", "getArrayResult", "(", ")", ";", "}" ]
Returns translated array results for given locale @param QueryBuilder $qb A Doctrine query builder instance @param string $locale A locale name @return QueryBuilder
[ "Returns", "translated", "array", "results", "for", "given", "locale" ]
3cb769c62df7badaeae557306c8f738252adaa28
https://github.com/trivialsense/php-framework-common/blob/3cb769c62df7badaeae557306c8f738252adaa28/src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php#L141-L144
2,264
trivialsense/php-framework-common
src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php
TranslatableRepository.getSingleResult
public function getSingleResult(QueryBuilder $qb, $locale = null, $hydrationMode = null) { return $this->getTranslatedQuery($qb, $locale)->getSingleResult($hydrationMode); }
php
public function getSingleResult(QueryBuilder $qb, $locale = null, $hydrationMode = null) { return $this->getTranslatedQuery($qb, $locale)->getSingleResult($hydrationMode); }
[ "public", "function", "getSingleResult", "(", "QueryBuilder", "$", "qb", ",", "$", "locale", "=", "null", ",", "$", "hydrationMode", "=", "null", ")", "{", "return", "$", "this", "->", "getTranslatedQuery", "(", "$", "qb", ",", "$", "locale", ")", "->", "getSingleResult", "(", "$", "hydrationMode", ")", ";", "}" ]
Returns translated single result for given locale @param QueryBuilder $qb A Doctrine query builder instance @param string $locale A locale name @param string $hydrationMode A Doctrine results hydration mode @return QueryBuilder
[ "Returns", "translated", "single", "result", "for", "given", "locale" ]
3cb769c62df7badaeae557306c8f738252adaa28
https://github.com/trivialsense/php-framework-common/blob/3cb769c62df7badaeae557306c8f738252adaa28/src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php#L155-L158
2,265
trivialsense/php-framework-common
src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php
TranslatableRepository.getScalarResult
public function getScalarResult(QueryBuilder $qb, $locale = null) { return $this->getTranslatedQuery($qb, $locale)->getScalarResult(); }
php
public function getScalarResult(QueryBuilder $qb, $locale = null) { return $this->getTranslatedQuery($qb, $locale)->getScalarResult(); }
[ "public", "function", "getScalarResult", "(", "QueryBuilder", "$", "qb", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "this", "->", "getTranslatedQuery", "(", "$", "qb", ",", "$", "locale", ")", "->", "getScalarResult", "(", ")", ";", "}" ]
Returns translated scalar result for given locale @param QueryBuilder $qb A Doctrine query builder instance @param string $locale A locale name @return QueryBuilder
[ "Returns", "translated", "scalar", "result", "for", "given", "locale" ]
3cb769c62df7badaeae557306c8f738252adaa28
https://github.com/trivialsense/php-framework-common/blob/3cb769c62df7badaeae557306c8f738252adaa28/src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php#L168-L171
2,266
trivialsense/php-framework-common
src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php
TranslatableRepository.getSingleScalarResult
public function getSingleScalarResult(QueryBuilder $qb, $locale = null) { return $this->getTranslatedQuery($qb, $locale)->getSingleScalarResult(); }
php
public function getSingleScalarResult(QueryBuilder $qb, $locale = null) { return $this->getTranslatedQuery($qb, $locale)->getSingleScalarResult(); }
[ "public", "function", "getSingleScalarResult", "(", "QueryBuilder", "$", "qb", ",", "$", "locale", "=", "null", ")", "{", "return", "$", "this", "->", "getTranslatedQuery", "(", "$", "qb", ",", "$", "locale", ")", "->", "getSingleScalarResult", "(", ")", ";", "}" ]
Returns translated single scalar result for given locale @param QueryBuilder $qb A Doctrine query builder instance @param string $locale A locale name @return QueryBuilder
[ "Returns", "translated", "single", "scalar", "result", "for", "given", "locale" ]
3cb769c62df7badaeae557306c8f738252adaa28
https://github.com/trivialsense/php-framework-common/blob/3cb769c62df7badaeae557306c8f738252adaa28/src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php#L181-L184
2,267
trivialsense/php-framework-common
src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php
TranslatableRepository.getTranslatedQuery
protected function getTranslatedQuery(QueryBuilder $qb, $locale = null) { $query = $this->setTranslationHints($qb->getQuery(), $locale); return $query; }
php
protected function getTranslatedQuery(QueryBuilder $qb, $locale = null) { $query = $this->setTranslationHints($qb->getQuery(), $locale); return $query; }
[ "protected", "function", "getTranslatedQuery", "(", "QueryBuilder", "$", "qb", ",", "$", "locale", "=", "null", ")", "{", "$", "query", "=", "$", "this", "->", "setTranslationHints", "(", "$", "qb", "->", "getQuery", "(", ")", ",", "$", "locale", ")", ";", "return", "$", "query", ";", "}" ]
Returns translated Doctrine query instance @param QueryBuilder $qb A Doctrine query builder instance @param string $locale A locale name @return Query
[ "Returns", "translated", "Doctrine", "query", "instance" ]
3cb769c62df7badaeae557306c8f738252adaa28
https://github.com/trivialsense/php-framework-common/blob/3cb769c62df7badaeae557306c8f738252adaa28/src/TrivialSense/FrameworkCommon/Repository/TranslatableRepository.php#L194-L199
2,268
aedart/util
src/Traits/populate/PopulateHelperTrait.php
PopulateHelperTrait.assertPopulateData
public function assertPopulateData(array $data, array $required) : void { // Check if the provided data has less entries, than the // required if (count($data) < count($required)) { throw new Exception(sprintf('Cannot populate %s, incorrect amount of properties given', get_class($this))); } // Check that all of the required are present foreach ($required as $requiredKey) { if( ! isset($data[$requiredKey])){ throw new Exception(sprintf('Cannot populate %s, missing %s', get_class($this), $requiredKey)); } } }
php
public function assertPopulateData(array $data, array $required) : void { // Check if the provided data has less entries, than the // required if (count($data) < count($required)) { throw new Exception(sprintf('Cannot populate %s, incorrect amount of properties given', get_class($this))); } // Check that all of the required are present foreach ($required as $requiredKey) { if( ! isset($data[$requiredKey])){ throw new Exception(sprintf('Cannot populate %s, missing %s', get_class($this), $requiredKey)); } } }
[ "public", "function", "assertPopulateData", "(", "array", "$", "data", ",", "array", "$", "required", ")", ":", "void", "{", "// Check if the provided data has less entries, than the", "// required", "if", "(", "count", "(", "$", "data", ")", "<", "count", "(", "$", "required", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Cannot populate %s, incorrect amount of properties given'", ",", "get_class", "(", "$", "this", ")", ")", ")", ";", "}", "// Check that all of the required are present", "foreach", "(", "$", "required", "as", "$", "requiredKey", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "requiredKey", "]", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Cannot populate %s, missing %s'", ",", "get_class", "(", "$", "this", ")", ",", "$", "requiredKey", ")", ")", ";", "}", "}", "}" ]
Assert that the given data array contains all of the required keys @param array $data List of key => value pairs, which should contains all of the required... @param array $required List of keys that must be present in the data-list @throws Exception If there are too few properties provided or if the required properties are not present in the given data array
[ "Assert", "that", "the", "given", "data", "array", "contains", "all", "of", "the", "required", "keys" ]
6282d19cea2d2f7922298523cdd55fd978929988
https://github.com/aedart/util/blob/6282d19cea2d2f7922298523cdd55fd978929988/src/Traits/populate/PopulateHelperTrait.php#L27-L41
2,269
parfumix/laravel-translator
src/DriverAssets/Database/LanguageRepository.php
LanguageRepository.getLocaleById
public function getLocaleById($id) { $locale = $this->source ->where('id', $id) ->first(); return isset($locale->id) ? $locale->locale : null; }
php
public function getLocaleById($id) { $locale = $this->source ->where('id', $id) ->first(); return isset($locale->id) ? $locale->locale : null; }
[ "public", "function", "getLocaleById", "(", "$", "id", ")", "{", "$", "locale", "=", "$", "this", "->", "source", "->", "where", "(", "'id'", ",", "$", "id", ")", "->", "first", "(", ")", ";", "return", "isset", "(", "$", "locale", "->", "id", ")", "?", "$", "locale", "->", "locale", ":", "null", ";", "}" ]
Get locale by id . @param $id @return null
[ "Get", "locale", "by", "id", "." ]
b85f17cbfebd4f35d1bfb817fbf13bff2c3f487e
https://github.com/parfumix/laravel-translator/blob/b85f17cbfebd4f35d1bfb817fbf13bff2c3f487e/src/DriverAssets/Database/LanguageRepository.php#L36-L42
2,270
dmeikle/pesedget
src/Gossamer/Pesedget/Database/DatasourceFactory.php
DatasourceFactory.buildDatasourceInstance
private function buildDatasourceInstance($sourceName, Logger $logger) { $parser = new YAMLParser($logger); $ymlFilePath = __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'credentials.yml'; $parser->setFilePath($ymlFilePath); $dsConfig = $parser->loadConfig(); $sourceName = trim($sourceName, "<br>"); $datasourceClass = $dsConfig['database'][$sourceName]['class']; $datasource = new $datasourceClass($dsConfig['database'][$sourceName]['credentials']); $datasource->setLogger($logger); unset($parser); return $datasource; }
php
private function buildDatasourceInstance($sourceName, Logger $logger) { $parser = new YAMLParser($logger); $ymlFilePath = __SITE_PATH . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'credentials.yml'; $parser->setFilePath($ymlFilePath); $dsConfig = $parser->loadConfig(); $sourceName = trim($sourceName, "<br>"); $datasourceClass = $dsConfig['database'][$sourceName]['class']; $datasource = new $datasourceClass($dsConfig['database'][$sourceName]['credentials']); $datasource->setLogger($logger); unset($parser); return $datasource; }
[ "private", "function", "buildDatasourceInstance", "(", "$", "sourceName", ",", "Logger", "$", "logger", ")", "{", "$", "parser", "=", "new", "YAMLParser", "(", "$", "logger", ")", ";", "$", "ymlFilePath", "=", "__SITE_PATH", ".", "DIRECTORY_SEPARATOR", ".", "'app'", ".", "DIRECTORY_SEPARATOR", ".", "'config'", ".", "DIRECTORY_SEPARATOR", ".", "'credentials.yml'", ";", "$", "parser", "->", "setFilePath", "(", "$", "ymlFilePath", ")", ";", "$", "dsConfig", "=", "$", "parser", "->", "loadConfig", "(", ")", ";", "$", "sourceName", "=", "trim", "(", "$", "sourceName", ",", "\"<br>\"", ")", ";", "$", "datasourceClass", "=", "$", "dsConfig", "[", "'database'", "]", "[", "$", "sourceName", "]", "[", "'class'", "]", ";", "$", "datasource", "=", "new", "$", "datasourceClass", "(", "$", "dsConfig", "[", "'database'", "]", "[", "$", "sourceName", "]", "[", "'credentials'", "]", ")", ";", "$", "datasource", "->", "setLogger", "(", "$", "logger", ")", ";", "unset", "(", "$", "parser", ")", ";", "return", "$", "datasource", ";", "}" ]
creates a datasource based on the credentials.yml configuration @param type $sourceName @param Logger $logger @return \core\datasources\datasourceClass
[ "creates", "a", "datasource", "based", "on", "the", "credentials", ".", "yml", "configuration" ]
bcfca25569d1f47c073f08906a710ed895f77b4d
https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Database/DatasourceFactory.php#L73-L88
2,271
silktide/reposition-sql
src/Normaliser/SqlNormaliser.php
SqlNormaliser.denormalise
public function denormalise(array $data, array $options = []) { if (empty($data)) { return $data; } if (!isset($options["entityClass"])) { throw new NormalisationException("Cannot denormalise data without knowing the main entity class"); } if (!isset($options["metadataProvider"])) { throw new NormalisationException("Cannot denormalise data without a metadata provider"); } /** @var EntityMetadataProviderInterface $metadataProvider */ $this->metadataProvider = $options["metadataProvider"]; $metadata = $this->metadataProvider->getEntityMetadata($options["entityClass"]); // split fields based on prefix $prefixedFields = []; foreach ($data[0] as $field => $value) { $fieldParts = explode("__", $field); // if this field has no prefix, set it to an empty string if (count($fieldParts) == 1) { array_unshift($fieldParts, ""); } // add the field to the prefix's array $prefix = $fieldParts[0]; if (empty($prefixedFields[$prefix])) { $prefixedFields[$prefix] = []; } $prefixedFields[$prefix][$fieldParts[1]] = $field; } // handle case where only 1 prefix is present if (count($prefixedFields) == 1) { $fields = array_pop($prefixedFields); $primaryKey = $metadata->getPrimaryKey(); if (isset($fields[$primaryKey])) { $this->primaryKeyFields = [$fields[$primaryKey] => true]; } return $this->denormaliseData($data, $fields); } // complex result set if (!isset($options["entityMap"])) { throw new NormalisationException("Cannot denormalise data without an entity map"); } $entityMap = $options["entityMap"]; $collection = $metadata->getCollection(); if (empty($prefixedFields[$collection])) { throw new NormalisationException("The collection '$collection' was not found in the fields array for this record set: '" . implode("', '", array_keys($prefixedFields)) . "'"); } // reset primary key fields $this->primaryKeyFields = []; $this->treedEntities = []; $this->childRowAliases = []; $this->createFieldTree($prefixedFields, $entityMap, $collection, $options["entityClass"]); reset($data); $result = $this->denormaliseData($data, $prefixedFields[$collection], $collection); return $result; }
php
public function denormalise(array $data, array $options = []) { if (empty($data)) { return $data; } if (!isset($options["entityClass"])) { throw new NormalisationException("Cannot denormalise data without knowing the main entity class"); } if (!isset($options["metadataProvider"])) { throw new NormalisationException("Cannot denormalise data without a metadata provider"); } /** @var EntityMetadataProviderInterface $metadataProvider */ $this->metadataProvider = $options["metadataProvider"]; $metadata = $this->metadataProvider->getEntityMetadata($options["entityClass"]); // split fields based on prefix $prefixedFields = []; foreach ($data[0] as $field => $value) { $fieldParts = explode("__", $field); // if this field has no prefix, set it to an empty string if (count($fieldParts) == 1) { array_unshift($fieldParts, ""); } // add the field to the prefix's array $prefix = $fieldParts[0]; if (empty($prefixedFields[$prefix])) { $prefixedFields[$prefix] = []; } $prefixedFields[$prefix][$fieldParts[1]] = $field; } // handle case where only 1 prefix is present if (count($prefixedFields) == 1) { $fields = array_pop($prefixedFields); $primaryKey = $metadata->getPrimaryKey(); if (isset($fields[$primaryKey])) { $this->primaryKeyFields = [$fields[$primaryKey] => true]; } return $this->denormaliseData($data, $fields); } // complex result set if (!isset($options["entityMap"])) { throw new NormalisationException("Cannot denormalise data without an entity map"); } $entityMap = $options["entityMap"]; $collection = $metadata->getCollection(); if (empty($prefixedFields[$collection])) { throw new NormalisationException("The collection '$collection' was not found in the fields array for this record set: '" . implode("', '", array_keys($prefixedFields)) . "'"); } // reset primary key fields $this->primaryKeyFields = []; $this->treedEntities = []; $this->childRowAliases = []; $this->createFieldTree($prefixedFields, $entityMap, $collection, $options["entityClass"]); reset($data); $result = $this->denormaliseData($data, $prefixedFields[$collection], $collection); return $result; }
[ "public", "function", "denormalise", "(", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "data", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "\"entityClass\"", "]", ")", ")", "{", "throw", "new", "NormalisationException", "(", "\"Cannot denormalise data without knowing the main entity class\"", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "\"metadataProvider\"", "]", ")", ")", "{", "throw", "new", "NormalisationException", "(", "\"Cannot denormalise data without a metadata provider\"", ")", ";", "}", "/** @var EntityMetadataProviderInterface $metadataProvider */", "$", "this", "->", "metadataProvider", "=", "$", "options", "[", "\"metadataProvider\"", "]", ";", "$", "metadata", "=", "$", "this", "->", "metadataProvider", "->", "getEntityMetadata", "(", "$", "options", "[", "\"entityClass\"", "]", ")", ";", "// split fields based on prefix", "$", "prefixedFields", "=", "[", "]", ";", "foreach", "(", "$", "data", "[", "0", "]", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "fieldParts", "=", "explode", "(", "\"__\"", ",", "$", "field", ")", ";", "// if this field has no prefix, set it to an empty string", "if", "(", "count", "(", "$", "fieldParts", ")", "==", "1", ")", "{", "array_unshift", "(", "$", "fieldParts", ",", "\"\"", ")", ";", "}", "// add the field to the prefix's array", "$", "prefix", "=", "$", "fieldParts", "[", "0", "]", ";", "if", "(", "empty", "(", "$", "prefixedFields", "[", "$", "prefix", "]", ")", ")", "{", "$", "prefixedFields", "[", "$", "prefix", "]", "=", "[", "]", ";", "}", "$", "prefixedFields", "[", "$", "prefix", "]", "[", "$", "fieldParts", "[", "1", "]", "]", "=", "$", "field", ";", "}", "// handle case where only 1 prefix is present", "if", "(", "count", "(", "$", "prefixedFields", ")", "==", "1", ")", "{", "$", "fields", "=", "array_pop", "(", "$", "prefixedFields", ")", ";", "$", "primaryKey", "=", "$", "metadata", "->", "getPrimaryKey", "(", ")", ";", "if", "(", "isset", "(", "$", "fields", "[", "$", "primaryKey", "]", ")", ")", "{", "$", "this", "->", "primaryKeyFields", "=", "[", "$", "fields", "[", "$", "primaryKey", "]", "=>", "true", "]", ";", "}", "return", "$", "this", "->", "denormaliseData", "(", "$", "data", ",", "$", "fields", ")", ";", "}", "// complex result set", "if", "(", "!", "isset", "(", "$", "options", "[", "\"entityMap\"", "]", ")", ")", "{", "throw", "new", "NormalisationException", "(", "\"Cannot denormalise data without an entity map\"", ")", ";", "}", "$", "entityMap", "=", "$", "options", "[", "\"entityMap\"", "]", ";", "$", "collection", "=", "$", "metadata", "->", "getCollection", "(", ")", ";", "if", "(", "empty", "(", "$", "prefixedFields", "[", "$", "collection", "]", ")", ")", "{", "throw", "new", "NormalisationException", "(", "\"The collection '$collection' was not found in the fields array for this record set: '\"", ".", "implode", "(", "\"', '\"", ",", "array_keys", "(", "$", "prefixedFields", ")", ")", ".", "\"'\"", ")", ";", "}", "// reset primary key fields", "$", "this", "->", "primaryKeyFields", "=", "[", "]", ";", "$", "this", "->", "treedEntities", "=", "[", "]", ";", "$", "this", "->", "childRowAliases", "=", "[", "]", ";", "$", "this", "->", "createFieldTree", "(", "$", "prefixedFields", ",", "$", "entityMap", ",", "$", "collection", ",", "$", "options", "[", "\"entityClass\"", "]", ")", ";", "reset", "(", "$", "data", ")", ";", "$", "result", "=", "$", "this", "->", "denormaliseData", "(", "$", "data", ",", "$", "prefixedFields", "[", "$", "collection", "]", ",", "$", "collection", ")", ";", "return", "$", "result", ";", "}" ]
format DB data into standard format @param array $data @param array $options @throws NormalisationException @return array
[ "format", "DB", "data", "into", "standard", "format" ]
7790da95810576f84f0896fb046c8fba296576b5
https://github.com/silktide/reposition-sql/blob/7790da95810576f84f0896fb046c8fba296576b5/src/Normaliser/SqlNormaliser.php#L55-L122
2,272
spiderling-php/phpunit-matches-selector
src/Converter.php
Converter.describeDOMElement
public static function describeDOMElement($other) { if ($other instanceof DOMElement) { $tag = $other->tagName; $id = $other->getAttribute("id"); $id = $id ? '#'.$id : null; $classes = Converter::parseClasses($other->getAttribute("class")); $classes = $classes ? '.'.join('.', $classes) : null; return $tag.$id.$classes; } else { return '[unknown]'; } }
php
public static function describeDOMElement($other) { if ($other instanceof DOMElement) { $tag = $other->tagName; $id = $other->getAttribute("id"); $id = $id ? '#'.$id : null; $classes = Converter::parseClasses($other->getAttribute("class")); $classes = $classes ? '.'.join('.', $classes) : null; return $tag.$id.$classes; } else { return '[unknown]'; } }
[ "public", "static", "function", "describeDOMElement", "(", "$", "other", ")", "{", "if", "(", "$", "other", "instanceof", "DOMElement", ")", "{", "$", "tag", "=", "$", "other", "->", "tagName", ";", "$", "id", "=", "$", "other", "->", "getAttribute", "(", "\"id\"", ")", ";", "$", "id", "=", "$", "id", "?", "'#'", ".", "$", "id", ":", "null", ";", "$", "classes", "=", "Converter", "::", "parseClasses", "(", "$", "other", "->", "getAttribute", "(", "\"class\"", ")", ")", ";", "$", "classes", "=", "$", "classes", "?", "'.'", ".", "join", "(", "'.'", ",", "$", "classes", ")", ":", "null", ";", "return", "$", "tag", ".", "$", "id", ".", "$", "classes", ";", "}", "else", "{", "return", "'[unknown]'", ";", "}", "}" ]
Convert a dom element to a textual representation. Shows tag name, id and classes @param mixed $other @return string
[ "Convert", "a", "dom", "element", "to", "a", "textual", "representation", ".", "Shows", "tag", "name", "id", "and", "classes" ]
4f8cd3ecd05b27dd232677d72d6e8aaddfa85531
https://github.com/spiderling-php/phpunit-matches-selector/blob/4f8cd3ecd05b27dd232677d72d6e8aaddfa85531/src/Converter.php#L36-L51
2,273
SocietyCMS/Modules
Http/Controllers/backend/ModulesController.php
ModulesController.index
public function index() { $coreModules = $this->moduleManager->getCoreModules(); $thirdPartyModules = $this->moduleManager->getThirdPartyModules(); return view('modules::backend.modules.index', compact('coreModules', 'thirdPartyModules')); }
php
public function index() { $coreModules = $this->moduleManager->getCoreModules(); $thirdPartyModules = $this->moduleManager->getThirdPartyModules(); return view('modules::backend.modules.index', compact('coreModules', 'thirdPartyModules')); }
[ "public", "function", "index", "(", ")", "{", "$", "coreModules", "=", "$", "this", "->", "moduleManager", "->", "getCoreModules", "(", ")", ";", "$", "thirdPartyModules", "=", "$", "this", "->", "moduleManager", "->", "getThirdPartyModules", "(", ")", ";", "return", "view", "(", "'modules::backend.modules.index'", ",", "compact", "(", "'coreModules'", ",", "'thirdPartyModules'", ")", ")", ";", "}" ]
Display a list of all modules. @return View
[ "Display", "a", "list", "of", "all", "modules", "." ]
bfb8d29fa47bd61787d16dbb1d14e144eb902ec1
https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Http/Controllers/backend/ModulesController.php#L34-L40
2,274
SocietyCMS/Modules
Http/Controllers/backend/ModulesController.php
ModulesController.show
public function show(Module $module) { $module = $this->moduleManager->get($module); $changelog = $this->moduleManager->changelogFor($module); return view('modules::backend.modules.show', compact('module', 'changelog')); }
php
public function show(Module $module) { $module = $this->moduleManager->get($module); $changelog = $this->moduleManager->changelogFor($module); return view('modules::backend.modules.show', compact('module', 'changelog')); }
[ "public", "function", "show", "(", "Module", "$", "module", ")", "{", "$", "module", "=", "$", "this", "->", "moduleManager", "->", "get", "(", "$", "module", ")", ";", "$", "changelog", "=", "$", "this", "->", "moduleManager", "->", "changelogFor", "(", "$", "module", ")", ";", "return", "view", "(", "'modules::backend.modules.show'", ",", "compact", "(", "'module'", ",", "'changelog'", ")", ")", ";", "}" ]
Display module info. @param Module $module @return View
[ "Display", "module", "info", "." ]
bfb8d29fa47bd61787d16dbb1d14e144eb902ec1
https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Http/Controllers/backend/ModulesController.php#L49-L55
2,275
SocietyCMS/Modules
Http/Controllers/backend/ModulesController.php
ModulesController.disable
public function disable(Module $module) { if ($this->moduleManager->isCoreModule($module)) { return redirect()->route('backend::modules.modules.show', [$module->getLowerName()]) ->with('error', trans('workshop::modules.module cannot be disabled')); } $module->disable(); }
php
public function disable(Module $module) { if ($this->moduleManager->isCoreModule($module)) { return redirect()->route('backend::modules.modules.show', [$module->getLowerName()]) ->with('error', trans('workshop::modules.module cannot be disabled')); } $module->disable(); }
[ "public", "function", "disable", "(", "Module", "$", "module", ")", "{", "if", "(", "$", "this", "->", "moduleManager", "->", "isCoreModule", "(", "$", "module", ")", ")", "{", "return", "redirect", "(", ")", "->", "route", "(", "'backend::modules.modules.show'", ",", "[", "$", "module", "->", "getLowerName", "(", ")", "]", ")", "->", "with", "(", "'error'", ",", "trans", "(", "'workshop::modules.module cannot be disabled'", ")", ")", ";", "}", "$", "module", "->", "disable", "(", ")", ";", "}" ]
Disable the given module. @param Module $module @return mixed
[ "Disable", "the", "given", "module", "." ]
bfb8d29fa47bd61787d16dbb1d14e144eb902ec1
https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Http/Controllers/backend/ModulesController.php#L64-L72
2,276
indigophp-archive/codeception-fuel-module
fuel/fuel/core/classes/module.php
Module.exists
public static function exists($module) { if (array_key_exists($module, static::$modules)) { return static::$modules[$module]; } else { $paths = \Config::get('module_paths', array()); foreach ($paths as $path) { if (is_dir($path.$module)) { return $path.$module.DS; } } } return false; }
php
public static function exists($module) { if (array_key_exists($module, static::$modules)) { return static::$modules[$module]; } else { $paths = \Config::get('module_paths', array()); foreach ($paths as $path) { if (is_dir($path.$module)) { return $path.$module.DS; } } } return false; }
[ "public", "static", "function", "exists", "(", "$", "module", ")", "{", "if", "(", "array_key_exists", "(", "$", "module", ",", "static", "::", "$", "modules", ")", ")", "{", "return", "static", "::", "$", "modules", "[", "$", "module", "]", ";", "}", "else", "{", "$", "paths", "=", "\\", "Config", "::", "get", "(", "'module_paths'", ",", "array", "(", ")", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "is_dir", "(", "$", "path", ".", "$", "module", ")", ")", "{", "return", "$", "path", ".", "$", "module", ".", "DS", ";", "}", "}", "}", "return", "false", ";", "}" ]
Checks if the given module exists. @param string $module The module name @return bool|string Path to the module found, or false if not found
[ "Checks", "if", "the", "given", "module", "exists", "." ]
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/module.php#L141-L161
2,277
tmquang6805/phalex
library/Phalex/Config/Cache/FileTrait.php
FileTrait.getConfig
public function getConfig($file = null) { $file = !empty($file) ? $file : $this->fileCache; if (file_exists($file)) { if (!is_readable($file)) { throw new Exception\RuntimeException(sprintf('"%s" cannot read', $file)); } return require $file; } return false; }
php
public function getConfig($file = null) { $file = !empty($file) ? $file : $this->fileCache; if (file_exists($file)) { if (!is_readable($file)) { throw new Exception\RuntimeException(sprintf('"%s" cannot read', $file)); } return require $file; } return false; }
[ "public", "function", "getConfig", "(", "$", "file", "=", "null", ")", "{", "$", "file", "=", "!", "empty", "(", "$", "file", ")", "?", "$", "file", ":", "$", "this", "->", "fileCache", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "if", "(", "!", "is_readable", "(", "$", "file", ")", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'\"%s\" cannot read'", ",", "$", "file", ")", ")", ";", "}", "return", "require", "$", "file", ";", "}", "return", "false", ";", "}" ]
Get config from file cache @param string $file @return array|false Return array config when file existed and readable, otherwise return false @throws Exception\RuntimeException
[ "Get", "config", "from", "file", "cache" ]
6452b4e695b456838d9d553d96f2b114e1c110b4
https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Config/Cache/FileTrait.php#L36-L46
2,278
tmquang6805/phalex
library/Phalex/Config/Cache/FileTrait.php
FileTrait.setConfig
public function setConfig(array $config, $file = null) { $file = !empty($file) ? $file : $this->fileCache; if (file_exists($file)) { unlink($file); } (new PhpArray()) ->setUseBracketArraySyntax(true) ->toFile($file, $config); }
php
public function setConfig(array $config, $file = null) { $file = !empty($file) ? $file : $this->fileCache; if (file_exists($file)) { unlink($file); } (new PhpArray()) ->setUseBracketArraySyntax(true) ->toFile($file, $config); }
[ "public", "function", "setConfig", "(", "array", "$", "config", ",", "$", "file", "=", "null", ")", "{", "$", "file", "=", "!", "empty", "(", "$", "file", ")", "?", "$", "file", ":", "$", "this", "->", "fileCache", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "unlink", "(", "$", "file", ")", ";", "}", "(", "new", "PhpArray", "(", ")", ")", "->", "setUseBracketArraySyntax", "(", "true", ")", "->", "toFile", "(", "$", "file", ",", "$", "config", ")", ";", "}" ]
Set config to file @param array $config @param string $file
[ "Set", "config", "to", "file" ]
6452b4e695b456838d9d553d96f2b114e1c110b4
https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Config/Cache/FileTrait.php#L53-L62
2,279
tjbp/php-countries
src/Iso3166.php
Iso3166.get
public static function get($code) { try { return static::getByAlpha2($code); } catch (OutOfBoundsException $e) { try { return static::getByAlpha3($code); } catch (OutOfBoundsException $e) { try { return static::getByNumeric3($code); } catch (OutOfBoundsException $e) { throw new OutOfBoundsException("The code \"{$code}\" is not listed in ISO 4217"); } } } }
php
public static function get($code) { try { return static::getByAlpha2($code); } catch (OutOfBoundsException $e) { try { return static::getByAlpha3($code); } catch (OutOfBoundsException $e) { try { return static::getByNumeric3($code); } catch (OutOfBoundsException $e) { throw new OutOfBoundsException("The code \"{$code}\" is not listed in ISO 4217"); } } } }
[ "public", "static", "function", "get", "(", "$", "code", ")", "{", "try", "{", "return", "static", "::", "getByAlpha2", "(", "$", "code", ")", ";", "}", "catch", "(", "OutOfBoundsException", "$", "e", ")", "{", "try", "{", "return", "static", "::", "getByAlpha3", "(", "$", "code", ")", ";", "}", "catch", "(", "OutOfBoundsException", "$", "e", ")", "{", "try", "{", "return", "static", "::", "getByNumeric3", "(", "$", "code", ")", ";", "}", "catch", "(", "OutOfBoundsException", "$", "e", ")", "{", "throw", "new", "OutOfBoundsException", "(", "\"The code \\\"{$code}\\\" is not listed in ISO 4217\"", ")", ";", "}", "}", "}", "}" ]
Try all methods for a result. @param mixed $code @return array
[ "Try", "all", "methods", "for", "a", "result", "." ]
d865db456020dd9662b1b2edaa3665bc80a042dc
https://github.com/tjbp/php-countries/blob/d865db456020dd9662b1b2edaa3665bc80a042dc/src/Iso3166.php#L68-L83
2,280
tjbp/php-countries
src/Iso3166.php
Iso3166.getByAlpha2
public static function getByAlpha2($alpha2) { $alpha2 = strtoupper($alpha2); if (!isset(static::$countries[$alpha2])) { throw new OutOfBoundsException("The 2 character alpha code \"$alpha2\" is not listed in ISO 3166"); } return new Country(static::$countries[$alpha2]); }
php
public static function getByAlpha2($alpha2) { $alpha2 = strtoupper($alpha2); if (!isset(static::$countries[$alpha2])) { throw new OutOfBoundsException("The 2 character alpha code \"$alpha2\" is not listed in ISO 3166"); } return new Country(static::$countries[$alpha2]); }
[ "public", "static", "function", "getByAlpha2", "(", "$", "alpha2", ")", "{", "$", "alpha2", "=", "strtoupper", "(", "$", "alpha2", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "countries", "[", "$", "alpha2", "]", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "\"The 2 character alpha code \\\"$alpha2\\\" is not listed in ISO 3166\"", ")", ";", "}", "return", "new", "Country", "(", "static", "::", "$", "countries", "[", "$", "alpha2", "]", ")", ";", "}" ]
Find and return country by its alphabetic two-character identifier. @param string $alpha2 @return array
[ "Find", "and", "return", "country", "by", "its", "alphabetic", "two", "-", "character", "identifier", "." ]
d865db456020dd9662b1b2edaa3665bc80a042dc
https://github.com/tjbp/php-countries/blob/d865db456020dd9662b1b2edaa3665bc80a042dc/src/Iso3166.php#L91-L100
2,281
tjbp/php-countries
src/Iso3166.php
Iso3166.getByAlpha3
public static function getByAlpha3($alpha3) { $alpha3 = strtoupper($alpha3); if (!isset(static::$alpha3Index[$alpha3])) { throw new OutOfBoundsException("The 3 character alpha code \"$alpha3\" is not listed in ISO 3166"); } return new Country(static::$countries[static::$alpha3Index[$alpha3]]); }
php
public static function getByAlpha3($alpha3) { $alpha3 = strtoupper($alpha3); if (!isset(static::$alpha3Index[$alpha3])) { throw new OutOfBoundsException("The 3 character alpha code \"$alpha3\" is not listed in ISO 3166"); } return new Country(static::$countries[static::$alpha3Index[$alpha3]]); }
[ "public", "static", "function", "getByAlpha3", "(", "$", "alpha3", ")", "{", "$", "alpha3", "=", "strtoupper", "(", "$", "alpha3", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "alpha3Index", "[", "$", "alpha3", "]", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "\"The 3 character alpha code \\\"$alpha3\\\" is not listed in ISO 3166\"", ")", ";", "}", "return", "new", "Country", "(", "static", "::", "$", "countries", "[", "static", "::", "$", "alpha3Index", "[", "$", "alpha3", "]", "]", ")", ";", "}" ]
Find and return country by its alphabetic three-character identifier. @param string $alpha3 @return array
[ "Find", "and", "return", "country", "by", "its", "alphabetic", "three", "-", "character", "identifier", "." ]
d865db456020dd9662b1b2edaa3665bc80a042dc
https://github.com/tjbp/php-countries/blob/d865db456020dd9662b1b2edaa3665bc80a042dc/src/Iso3166.php#L108-L117
2,282
tjbp/php-countries
src/Iso3166.php
Iso3166.getByNumeric3
public static function getByNumeric3($numeric3) { $numeric3 = strtoupper($numeric3); if (!isset(static::$numeric3Index[$numeric3])) { throw new OutOfBoundsException("The 3 character numeric code \"$numeric3\" is not listed in ISO 3166"); } return new Country(static::$countries[static::$numeric3Index[$numeric3]]); }
php
public static function getByNumeric3($numeric3) { $numeric3 = strtoupper($numeric3); if (!isset(static::$numeric3Index[$numeric3])) { throw new OutOfBoundsException("The 3 character numeric code \"$numeric3\" is not listed in ISO 3166"); } return new Country(static::$countries[static::$numeric3Index[$numeric3]]); }
[ "public", "static", "function", "getByNumeric3", "(", "$", "numeric3", ")", "{", "$", "numeric3", "=", "strtoupper", "(", "$", "numeric3", ")", ";", "if", "(", "!", "isset", "(", "static", "::", "$", "numeric3Index", "[", "$", "numeric3", "]", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "\"The 3 character numeric code \\\"$numeric3\\\" is not listed in ISO 3166\"", ")", ";", "}", "return", "new", "Country", "(", "static", "::", "$", "countries", "[", "static", "::", "$", "numeric3Index", "[", "$", "numeric3", "]", "]", ")", ";", "}" ]
Find and return country by its numeric three-character identifier. @param string $numeric3 @return array
[ "Find", "and", "return", "country", "by", "its", "numeric", "three", "-", "character", "identifier", "." ]
d865db456020dd9662b1b2edaa3665bc80a042dc
https://github.com/tjbp/php-countries/blob/d865db456020dd9662b1b2edaa3665bc80a042dc/src/Iso3166.php#L125-L134
2,283
tjbp/php-countries
src/Iso3166.php
Iso3166.all
public static function all() { $countries = array_values(static::$countries); array_walk($countries, function (&$value) { $value = new Country($value); }); return $countries; }
php
public static function all() { $countries = array_values(static::$countries); array_walk($countries, function (&$value) { $value = new Country($value); }); return $countries; }
[ "public", "static", "function", "all", "(", ")", "{", "$", "countries", "=", "array_values", "(", "static", "::", "$", "countries", ")", ";", "array_walk", "(", "$", "countries", ",", "function", "(", "&", "$", "value", ")", "{", "$", "value", "=", "new", "Country", "(", "$", "value", ")", ";", "}", ")", ";", "return", "$", "countries", ";", "}" ]
Return all countries as a numerically-keyed array. @return array
[ "Return", "all", "countries", "as", "a", "numerically", "-", "keyed", "array", "." ]
d865db456020dd9662b1b2edaa3665bc80a042dc
https://github.com/tjbp/php-countries/blob/d865db456020dd9662b1b2edaa3665bc80a042dc/src/Iso3166.php#L141-L150
2,284
crazedsanity/dbsession
src/dbsession/DBSession.class.php
DBSession.sessdb_table_exists
public function sessdb_table_exists() { try { $this->db->run_query("SELECT * FROM ". self::tableName . " ORDER BY ". self::tablePKey ." LIMIT 1"); $exists = true; } catch(exception $e) { $this->exception_handler(__METHOD__ .": exception while trying to detect table::: ". $e->getMessage()); $exists = false; } return($exists); }
php
public function sessdb_table_exists() { try { $this->db->run_query("SELECT * FROM ". self::tableName . " ORDER BY ". self::tablePKey ." LIMIT 1"); $exists = true; } catch(exception $e) { $this->exception_handler(__METHOD__ .": exception while trying to detect table::: ". $e->getMessage()); $exists = false; } return($exists); }
[ "public", "function", "sessdb_table_exists", "(", ")", "{", "try", "{", "$", "this", "->", "db", "->", "run_query", "(", "\"SELECT * FROM \"", ".", "self", "::", "tableName", ".", "\" ORDER BY \"", ".", "self", "::", "tablePKey", ".", "\" LIMIT 1\"", ")", ";", "$", "exists", "=", "true", ";", "}", "catch", "(", "exception", "$", "e", ")", "{", "$", "this", "->", "exception_handler", "(", "__METHOD__", ".", "\": exception while trying to detect table::: \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "$", "exists", "=", "false", ";", "}", "return", "(", "$", "exists", ")", ";", "}" ]
Determines if the appropriate table exists in the database.
[ "Determines", "if", "the", "appropriate", "table", "exists", "in", "the", "database", "." ]
94d4c383821b78fb1dcd9d41400f1a73faa3c50d
https://github.com/crazedsanity/dbsession/blob/94d4c383821b78fb1dcd9d41400f1a73faa3c50d/src/dbsession/DBSession.class.php#L154-L166
2,285
crazedsanity/dbsession
src/dbsession/DBSession.class.php
DBSession.sessdb_read
public function sessdb_read($sid) { $retval = ''; try { $sql = "SELECT * FROM ". self::tableName ." WHERE session_id=:sid"; $numRows = $this->db->run_query($sql, array('sid'=>$sid)); if($numRows == 1) { $data = $this->db->get_single_record(); $retval = $data['session_data']; } } catch(exception $e) { //no throwing exceptions... $this->exception_handler(__METHOD__ .": failed to read::: ". $e->getMessage()); } return($retval); }
php
public function sessdb_read($sid) { $retval = ''; try { $sql = "SELECT * FROM ". self::tableName ." WHERE session_id=:sid"; $numRows = $this->db->run_query($sql, array('sid'=>$sid)); if($numRows == 1) { $data = $this->db->get_single_record(); $retval = $data['session_data']; } } catch(exception $e) { //no throwing exceptions... $this->exception_handler(__METHOD__ .": failed to read::: ". $e->getMessage()); } return($retval); }
[ "public", "function", "sessdb_read", "(", "$", "sid", ")", "{", "$", "retval", "=", "''", ";", "try", "{", "$", "sql", "=", "\"SELECT * FROM \"", ".", "self", "::", "tableName", ".", "\" WHERE session_id=:sid\"", ";", "$", "numRows", "=", "$", "this", "->", "db", "->", "run_query", "(", "$", "sql", ",", "array", "(", "'sid'", "=>", "$", "sid", ")", ")", ";", "if", "(", "$", "numRows", "==", "1", ")", "{", "$", "data", "=", "$", "this", "->", "db", "->", "get_single_record", "(", ")", ";", "$", "retval", "=", "$", "data", "[", "'session_data'", "]", ";", "}", "}", "catch", "(", "exception", "$", "e", ")", "{", "//no throwing exceptions...", "$", "this", "->", "exception_handler", "(", "__METHOD__", ".", "\": failed to read::: \"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "return", "(", "$", "retval", ")", ";", "}" ]
Read information about the session. If there is no data, it MUST return an empty string instead of NULL.
[ "Read", "information", "about", "the", "session", ".", "If", "there", "is", "no", "data", "it", "MUST", "return", "an", "empty", "string", "instead", "of", "NULL", "." ]
94d4c383821b78fb1dcd9d41400f1a73faa3c50d
https://github.com/crazedsanity/dbsession/blob/94d4c383821b78fb1dcd9d41400f1a73faa3c50d/src/dbsession/DBSession.class.php#L220-L237
2,286
faithmade/churchthemes
churchthemes.php
ChurchThemes_Framework.set_plugin_data
public function set_plugin_data() { // Load plugin.php if get_plugins() not available if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } // Get path to plugin's directory $plugin_dir = plugin_basename( dirname( __FILE__ ) ); // Get plugin data $plugin_data = current( get_plugins( '/' . $plugin_dir ) ); // Set plugin data $this->plugin_data = apply_filters( 'ctc_plugin_data', $plugin_data ); }
php
public function set_plugin_data() { // Load plugin.php if get_plugins() not available if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } // Get path to plugin's directory $plugin_dir = plugin_basename( dirname( __FILE__ ) ); // Get plugin data $plugin_data = current( get_plugins( '/' . $plugin_dir ) ); // Set plugin data $this->plugin_data = apply_filters( 'ctc_plugin_data', $plugin_data ); }
[ "public", "function", "set_plugin_data", "(", ")", "{", "// Load plugin.php if get_plugins() not available\r", "if", "(", "!", "function_exists", "(", "'get_plugins'", ")", ")", "{", "require_once", "ABSPATH", ".", "'wp-admin/includes/plugin.php'", ";", "}", "// Get path to plugin's directory\r", "$", "plugin_dir", "=", "plugin_basename", "(", "dirname", "(", "__FILE__", ")", ")", ";", "// Get plugin data\r", "$", "plugin_data", "=", "current", "(", "get_plugins", "(", "'/'", ".", "$", "plugin_dir", ")", ")", ";", "// Set plugin data\r", "$", "this", "->", "plugin_data", "=", "apply_filters", "(", "'ctc_plugin_data'", ",", "$", "plugin_data", ")", ";", "}" ]
Set plugin data This data is used by constants. @since 0.9 @access public
[ "Set", "plugin", "data" ]
b121e840edaec8fdb3189fc9324cc88d7a0db81c
https://github.com/faithmade/churchthemes/blob/b121e840edaec8fdb3189fc9324cc88d7a0db81c/churchthemes.php#L87-L103
2,287
faithmade/churchthemes
churchthemes.php
ChurchThemes_Framework.load_textdomain
public function load_textdomain() { // Textdomain $domain = 'churchthemes-framework'; // WordPress core locale filter $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); // WordPress 3.6 and earlier don't auto-load from wp-content/languages, so check and load manually // http://core.trac.wordpress.org/changeset/22346 $external_mofile = WP_LANG_DIR . '/plugins/'. $domain . '-' . $locale . '.mo'; if ( get_bloginfo( 'version' ) <= 3.6 && file_exists( $external_mofile ) ) { // external translation exists load_textdomain( $domain, $external_mofile ); } // Load normally // Either using WordPress 3.7+ or older version with external translation else { $languages_dir = CTC_DIR . '/' . trailingslashit( CTC_LANG_DIR ); // ensure trailing slash load_plugin_textdomain( $domain, false, $languages_dir ); } }
php
public function load_textdomain() { // Textdomain $domain = 'churchthemes-framework'; // WordPress core locale filter $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); // WordPress 3.6 and earlier don't auto-load from wp-content/languages, so check and load manually // http://core.trac.wordpress.org/changeset/22346 $external_mofile = WP_LANG_DIR . '/plugins/'. $domain . '-' . $locale . '.mo'; if ( get_bloginfo( 'version' ) <= 3.6 && file_exists( $external_mofile ) ) { // external translation exists load_textdomain( $domain, $external_mofile ); } // Load normally // Either using WordPress 3.7+ or older version with external translation else { $languages_dir = CTC_DIR . '/' . trailingslashit( CTC_LANG_DIR ); // ensure trailing slash load_plugin_textdomain( $domain, false, $languages_dir ); } }
[ "public", "function", "load_textdomain", "(", ")", "{", "// Textdomain\r", "$", "domain", "=", "'churchthemes-framework'", ";", "// WordPress core locale filter\r", "$", "locale", "=", "apply_filters", "(", "'plugin_locale'", ",", "get_locale", "(", ")", ",", "$", "domain", ")", ";", "// WordPress 3.6 and earlier don't auto-load from wp-content/languages, so check and load manually\r", "// http://core.trac.wordpress.org/changeset/22346\r", "$", "external_mofile", "=", "WP_LANG_DIR", ".", "'/plugins/'", ".", "$", "domain", ".", "'-'", ".", "$", "locale", ".", "'.mo'", ";", "if", "(", "get_bloginfo", "(", "'version'", ")", "<=", "3.6", "&&", "file_exists", "(", "$", "external_mofile", ")", ")", "{", "// external translation exists\r", "load_textdomain", "(", "$", "domain", ",", "$", "external_mofile", ")", ";", "}", "// Load normally\r", "// Either using WordPress 3.7+ or older version with external translation\r", "else", "{", "$", "languages_dir", "=", "CTC_DIR", ".", "'/'", ".", "trailingslashit", "(", "CTC_LANG_DIR", ")", ";", "// ensure trailing slash\r", "load_plugin_textdomain", "(", "$", "domain", ",", "false", ",", "$", "languages_dir", ")", ";", "}", "}" ]
Load language file This will load the MO file for the current locale. The translation file must be named churchthemes-framework-$locale.mo. First it will check to see if the MO file exists in wp-content/languages/plugins. If not, then the 'languages' direcory inside the plugin will be used. It is ideal to keep translation files outside of the plugin to avoid loss during updates. @since 0.9 @access public
[ "Load", "language", "file" ]
b121e840edaec8fdb3189fc9324cc88d7a0db81c
https://github.com/faithmade/churchthemes/blob/b121e840edaec8fdb3189fc9324cc88d7a0db81c/churchthemes.php#L154-L176
2,288
pokap/pool-dbm
src/Pok/PoolDBM/Console/Command/GenerateMultiModelCommand.php
GenerateMultiModelCommand.buildParameters
protected function buildParameters($className) { /** @var \Pok\PoolDBM\Mapping\ClassMetadata $metadata */ $metadata = $this->getModelManager()->getClassMetadata($className); $managers = array(); foreach ($metadata->getFieldMappings() as $model) { $managers[$model->getManagerName()] = array( 'namespace' => '\\' . $model->getName(), 'methods' => array() ); $fields = $model->getFields(); if ($metadata->getManagerIdentifier() === $model->getManagerName()) { $fields[] = $metadata->getFieldIdentifier(); } $pattern = self::patternDeclared($fields); $refl = new \ReflectionClass($model->getName()); foreach ($refl->getMethods() as $method) { if (!$method->isPublic() || $method->isStatic() || $method->isConstructor() || $method->isDestructor() || $method->isAbstract()) { continue; } preg_match($pattern, $method->getName(), $matches); if (empty($matches)) { continue; } $arg = array( 'comment' => $method->getDocComment(), 'name' => $method->getName(), 'type' => in_array($matches[1], array('get','is','has','all','check')) ? 'getter' : 'setter', 'arguments' => Reflector::parameters($method->getParameters()), 'parameters' => $method->getParameters() ); $managers[$model->getManagerName()]['methods'][] = $arg; } } $associations = new Bag(); foreach ($metadata->getAssociationDefinitions() as $definition) { if ($definition->isMany()) { $associations->many[$definition->getField()] = array( 'fields' => $definition->getReferences(), 'className' => $definition->getTargetMultiModel() ); } else { $associations->one[$definition->getField()] = array( 'className' => $definition->getTargetMultiModel() ); } } $occ = strrpos($metadata->getName(), '\\'); return array( 'model_namespace' => substr($metadata->getName(), 0, $occ), 'model_name' => substr($metadata->getName(), $occ + 1), 'managers' => $managers, 'associations' => $associations ); }
php
protected function buildParameters($className) { /** @var \Pok\PoolDBM\Mapping\ClassMetadata $metadata */ $metadata = $this->getModelManager()->getClassMetadata($className); $managers = array(); foreach ($metadata->getFieldMappings() as $model) { $managers[$model->getManagerName()] = array( 'namespace' => '\\' . $model->getName(), 'methods' => array() ); $fields = $model->getFields(); if ($metadata->getManagerIdentifier() === $model->getManagerName()) { $fields[] = $metadata->getFieldIdentifier(); } $pattern = self::patternDeclared($fields); $refl = new \ReflectionClass($model->getName()); foreach ($refl->getMethods() as $method) { if (!$method->isPublic() || $method->isStatic() || $method->isConstructor() || $method->isDestructor() || $method->isAbstract()) { continue; } preg_match($pattern, $method->getName(), $matches); if (empty($matches)) { continue; } $arg = array( 'comment' => $method->getDocComment(), 'name' => $method->getName(), 'type' => in_array($matches[1], array('get','is','has','all','check')) ? 'getter' : 'setter', 'arguments' => Reflector::parameters($method->getParameters()), 'parameters' => $method->getParameters() ); $managers[$model->getManagerName()]['methods'][] = $arg; } } $associations = new Bag(); foreach ($metadata->getAssociationDefinitions() as $definition) { if ($definition->isMany()) { $associations->many[$definition->getField()] = array( 'fields' => $definition->getReferences(), 'className' => $definition->getTargetMultiModel() ); } else { $associations->one[$definition->getField()] = array( 'className' => $definition->getTargetMultiModel() ); } } $occ = strrpos($metadata->getName(), '\\'); return array( 'model_namespace' => substr($metadata->getName(), 0, $occ), 'model_name' => substr($metadata->getName(), $occ + 1), 'managers' => $managers, 'associations' => $associations ); }
[ "protected", "function", "buildParameters", "(", "$", "className", ")", "{", "/** @var \\Pok\\PoolDBM\\Mapping\\ClassMetadata $metadata */", "$", "metadata", "=", "$", "this", "->", "getModelManager", "(", ")", "->", "getClassMetadata", "(", "$", "className", ")", ";", "$", "managers", "=", "array", "(", ")", ";", "foreach", "(", "$", "metadata", "->", "getFieldMappings", "(", ")", "as", "$", "model", ")", "{", "$", "managers", "[", "$", "model", "->", "getManagerName", "(", ")", "]", "=", "array", "(", "'namespace'", "=>", "'\\\\'", ".", "$", "model", "->", "getName", "(", ")", ",", "'methods'", "=>", "array", "(", ")", ")", ";", "$", "fields", "=", "$", "model", "->", "getFields", "(", ")", ";", "if", "(", "$", "metadata", "->", "getManagerIdentifier", "(", ")", "===", "$", "model", "->", "getManagerName", "(", ")", ")", "{", "$", "fields", "[", "]", "=", "$", "metadata", "->", "getFieldIdentifier", "(", ")", ";", "}", "$", "pattern", "=", "self", "::", "patternDeclared", "(", "$", "fields", ")", ";", "$", "refl", "=", "new", "\\", "ReflectionClass", "(", "$", "model", "->", "getName", "(", ")", ")", ";", "foreach", "(", "$", "refl", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "!", "$", "method", "->", "isPublic", "(", ")", "||", "$", "method", "->", "isStatic", "(", ")", "||", "$", "method", "->", "isConstructor", "(", ")", "||", "$", "method", "->", "isDestructor", "(", ")", "||", "$", "method", "->", "isAbstract", "(", ")", ")", "{", "continue", ";", "}", "preg_match", "(", "$", "pattern", ",", "$", "method", "->", "getName", "(", ")", ",", "$", "matches", ")", ";", "if", "(", "empty", "(", "$", "matches", ")", ")", "{", "continue", ";", "}", "$", "arg", "=", "array", "(", "'comment'", "=>", "$", "method", "->", "getDocComment", "(", ")", ",", "'name'", "=>", "$", "method", "->", "getName", "(", ")", ",", "'type'", "=>", "in_array", "(", "$", "matches", "[", "1", "]", ",", "array", "(", "'get'", ",", "'is'", ",", "'has'", ",", "'all'", ",", "'check'", ")", ")", "?", "'getter'", ":", "'setter'", ",", "'arguments'", "=>", "Reflector", "::", "parameters", "(", "$", "method", "->", "getParameters", "(", ")", ")", ",", "'parameters'", "=>", "$", "method", "->", "getParameters", "(", ")", ")", ";", "$", "managers", "[", "$", "model", "->", "getManagerName", "(", ")", "]", "[", "'methods'", "]", "[", "]", "=", "$", "arg", ";", "}", "}", "$", "associations", "=", "new", "Bag", "(", ")", ";", "foreach", "(", "$", "metadata", "->", "getAssociationDefinitions", "(", ")", "as", "$", "definition", ")", "{", "if", "(", "$", "definition", "->", "isMany", "(", ")", ")", "{", "$", "associations", "->", "many", "[", "$", "definition", "->", "getField", "(", ")", "]", "=", "array", "(", "'fields'", "=>", "$", "definition", "->", "getReferences", "(", ")", ",", "'className'", "=>", "$", "definition", "->", "getTargetMultiModel", "(", ")", ")", ";", "}", "else", "{", "$", "associations", "->", "one", "[", "$", "definition", "->", "getField", "(", ")", "]", "=", "array", "(", "'className'", "=>", "$", "definition", "->", "getTargetMultiModel", "(", ")", ")", ";", "}", "}", "$", "occ", "=", "strrpos", "(", "$", "metadata", "->", "getName", "(", ")", ",", "'\\\\'", ")", ";", "return", "array", "(", "'model_namespace'", "=>", "substr", "(", "$", "metadata", "->", "getName", "(", ")", ",", "0", ",", "$", "occ", ")", ",", "'model_name'", "=>", "substr", "(", "$", "metadata", "->", "getName", "(", ")", ",", "$", "occ", "+", "1", ")", ",", "'managers'", "=>", "$", "managers", ",", "'associations'", "=>", "$", "associations", ")", ";", "}" ]
Build parameters with data recovered by the driver. @param string $className @return array
[ "Build", "parameters", "with", "data", "recovered", "by", "the", "driver", "." ]
cce32d7cb5f13f42c358c8140b2f97ddf1d9435a
https://github.com/pokap/pool-dbm/blob/cce32d7cb5f13f42c358c8140b2f97ddf1d9435a/src/Pok/PoolDBM/Console/Command/GenerateMultiModelCommand.php#L91-L156
2,289
osflab/view
Helper/Bootstrap/Addon/Status.php
Status.status
public function status($status) { if (!$this->statusIsNullable || $status !== null) { Checkers::checkStatus($status, null); } $this->status = $status; return $this; }
php
public function status($status) { if (!$this->statusIsNullable || $status !== null) { Checkers::checkStatus($status, null); } $this->status = $status; return $this; }
[ "public", "function", "status", "(", "$", "status", ")", "{", "if", "(", "!", "$", "this", "->", "statusIsNullable", "||", "$", "status", "!==", "null", ")", "{", "Checkers", "::", "checkStatus", "(", "$", "status", ",", "null", ")", ";", "}", "$", "this", "->", "status", "=", "$", "status", ";", "return", "$", "this", ";", "}" ]
Valid bootstrap status @param string $status @return $this
[ "Valid", "bootstrap", "status" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Addon/Status.php#L35-L42
2,290
academic/VipaImportBundle
Importer/PKP/SectionImporter.php
SectionImporter.importJournalSections
public function importJournalSections($oldJournalId, $newJournalId) { $this->consoleOutput->writeln("Importing journal's sections..."); $sectionsSql = "SELECT * FROM sections WHERE journal_id = :id"; $sectionsStatement = $this->dbalConnection->prepare($sectionsSql); $sectionsStatement->bindValue('id', $oldJournalId); $sectionsStatement->execute(); $sections = $sectionsStatement->fetchAll(); try { $this->em->beginTransaction(); $createdSections = array(); $createdSectionIds = array(); $persistCounter = 0; foreach ($sections as $section) { $createdSection = $this->importSection($section['section_id'], $newJournalId); $createdSections[$section['section_id']] = $createdSection; $persistCounter++; if ($persistCounter % 10 == 0 || $persistCounter == count($sections)) { $this->consoleOutput->writeln("Writing sections...", true); $this->em->flush(); $this->em->commit(); $this->em->clear(); $this->em->beginTransaction(); /** @var Section $entity */ foreach ($createdSections as $oldSectionId => $entity) { $createdSectionIds[$oldSectionId] = $entity->getId(); $map = new ImportMap($oldSectionId, $entity->getId(), Section::class); $this->em->persist($map); } $this->em->flush(); $createdSections = []; } } $this->em->commit(); } catch (Exception $exception) { $this->em->rollback(); throw $exception; } return $createdSectionIds; }
php
public function importJournalSections($oldJournalId, $newJournalId) { $this->consoleOutput->writeln("Importing journal's sections..."); $sectionsSql = "SELECT * FROM sections WHERE journal_id = :id"; $sectionsStatement = $this->dbalConnection->prepare($sectionsSql); $sectionsStatement->bindValue('id', $oldJournalId); $sectionsStatement->execute(); $sections = $sectionsStatement->fetchAll(); try { $this->em->beginTransaction(); $createdSections = array(); $createdSectionIds = array(); $persistCounter = 0; foreach ($sections as $section) { $createdSection = $this->importSection($section['section_id'], $newJournalId); $createdSections[$section['section_id']] = $createdSection; $persistCounter++; if ($persistCounter % 10 == 0 || $persistCounter == count($sections)) { $this->consoleOutput->writeln("Writing sections...", true); $this->em->flush(); $this->em->commit(); $this->em->clear(); $this->em->beginTransaction(); /** @var Section $entity */ foreach ($createdSections as $oldSectionId => $entity) { $createdSectionIds[$oldSectionId] = $entity->getId(); $map = new ImportMap($oldSectionId, $entity->getId(), Section::class); $this->em->persist($map); } $this->em->flush(); $createdSections = []; } } $this->em->commit(); } catch (Exception $exception) { $this->em->rollback(); throw $exception; } return $createdSectionIds; }
[ "public", "function", "importJournalSections", "(", "$", "oldJournalId", ",", "$", "newJournalId", ")", "{", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Importing journal's sections...\"", ")", ";", "$", "sectionsSql", "=", "\"SELECT * FROM sections WHERE journal_id = :id\"", ";", "$", "sectionsStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "sectionsSql", ")", ";", "$", "sectionsStatement", "->", "bindValue", "(", "'id'", ",", "$", "oldJournalId", ")", ";", "$", "sectionsStatement", "->", "execute", "(", ")", ";", "$", "sections", "=", "$", "sectionsStatement", "->", "fetchAll", "(", ")", ";", "try", "{", "$", "this", "->", "em", "->", "beginTransaction", "(", ")", ";", "$", "createdSections", "=", "array", "(", ")", ";", "$", "createdSectionIds", "=", "array", "(", ")", ";", "$", "persistCounter", "=", "0", ";", "foreach", "(", "$", "sections", "as", "$", "section", ")", "{", "$", "createdSection", "=", "$", "this", "->", "importSection", "(", "$", "section", "[", "'section_id'", "]", ",", "$", "newJournalId", ")", ";", "$", "createdSections", "[", "$", "section", "[", "'section_id'", "]", "]", "=", "$", "createdSection", ";", "$", "persistCounter", "++", ";", "if", "(", "$", "persistCounter", "%", "10", "==", "0", "||", "$", "persistCounter", "==", "count", "(", "$", "sections", ")", ")", "{", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Writing sections...\"", ",", "true", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "em", "->", "commit", "(", ")", ";", "$", "this", "->", "em", "->", "clear", "(", ")", ";", "$", "this", "->", "em", "->", "beginTransaction", "(", ")", ";", "/** @var Section $entity */", "foreach", "(", "$", "createdSections", "as", "$", "oldSectionId", "=>", "$", "entity", ")", "{", "$", "createdSectionIds", "[", "$", "oldSectionId", "]", "=", "$", "entity", "->", "getId", "(", ")", ";", "$", "map", "=", "new", "ImportMap", "(", "$", "oldSectionId", ",", "$", "entity", "->", "getId", "(", ")", ",", "Section", "::", "class", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "map", ")", ";", "}", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "$", "createdSections", "=", "[", "]", ";", "}", "}", "$", "this", "->", "em", "->", "commit", "(", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "em", "->", "rollback", "(", ")", ";", "throw", "$", "exception", ";", "}", "return", "$", "createdSectionIds", ";", "}" ]
Imports sections of the given journal. @param int $oldJournalId Section's old Journal ID @param int $newJournalId Section's new Journal ID @return array An array whose keys are old IDs and values are new IDs @throws Exception @throws \Doctrine\DBAL\DBALException
[ "Imports", "sections", "of", "the", "given", "journal", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/SectionImporter.php#L26-L73
2,291
academic/VipaImportBundle
Importer/PKP/SectionImporter.php
SectionImporter.importSection
public function importSection($id, $newJournalId) { /** @var Journal $journal */ $journal = $this->em->getReference('VipaJournalBundle:Journal', $newJournalId); $this->consoleOutput->writeln("Reading section #" . $id . "... ", true); $sectionSql = "SELECT * FROM sections WHERE section_id = :id LIMIT 1"; $sectionStatement = $this->dbalConnection->prepare($sectionSql); $sectionStatement->bindValue('id', $id); $sectionStatement->execute(); $settingsSql = "SELECT locale, setting_name, setting_value FROM section_settings WHERE section_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql); $settingsStatement->bindValue('id', $id); $settingsStatement->execute(); $pkpSection = $sectionStatement->fetch(); $pkpSettings = $settingsStatement->fetchAll(); foreach ($pkpSettings as $setting) { $locale = !empty($setting['locale']) ? $setting['locale'] : 'en_US'; $name = $setting['setting_name']; $value = $setting['setting_value']; $this->settings[$locale][$name] = $value; } $section = new Section(); $section->setJournal($journal); $section->setAllowIndex(!empty($pkpSection['meta_indexed']) ? $pkpSection['meta_indexed'] : 0); $section->setHideTitle(!empty($pkpSection['hide_title']) ? $pkpSection['hide_title'] : 0); $section->setSectionOrder(!empty($pkpSection['seq']) ? intval($pkpSection['seq']) : 0); foreach ($this->settings as $fieldLocale => $fields) { $section->setCurrentLocale(mb_substr($fieldLocale, 0, 2, 'UTF-8')); $section->setTitle(!empty($fields['title']) ? $fields['title']: '-'); } $this->consoleOutput->writeln("Writing section #" . $id . "... ", true); $this->em->persist($section); return $section; }
php
public function importSection($id, $newJournalId) { /** @var Journal $journal */ $journal = $this->em->getReference('VipaJournalBundle:Journal', $newJournalId); $this->consoleOutput->writeln("Reading section #" . $id . "... ", true); $sectionSql = "SELECT * FROM sections WHERE section_id = :id LIMIT 1"; $sectionStatement = $this->dbalConnection->prepare($sectionSql); $sectionStatement->bindValue('id', $id); $sectionStatement->execute(); $settingsSql = "SELECT locale, setting_name, setting_value FROM section_settings WHERE section_id = :id"; $settingsStatement = $this->dbalConnection->prepare($settingsSql); $settingsStatement->bindValue('id', $id); $settingsStatement->execute(); $pkpSection = $sectionStatement->fetch(); $pkpSettings = $settingsStatement->fetchAll(); foreach ($pkpSettings as $setting) { $locale = !empty($setting['locale']) ? $setting['locale'] : 'en_US'; $name = $setting['setting_name']; $value = $setting['setting_value']; $this->settings[$locale][$name] = $value; } $section = new Section(); $section->setJournal($journal); $section->setAllowIndex(!empty($pkpSection['meta_indexed']) ? $pkpSection['meta_indexed'] : 0); $section->setHideTitle(!empty($pkpSection['hide_title']) ? $pkpSection['hide_title'] : 0); $section->setSectionOrder(!empty($pkpSection['seq']) ? intval($pkpSection['seq']) : 0); foreach ($this->settings as $fieldLocale => $fields) { $section->setCurrentLocale(mb_substr($fieldLocale, 0, 2, 'UTF-8')); $section->setTitle(!empty($fields['title']) ? $fields['title']: '-'); } $this->consoleOutput->writeln("Writing section #" . $id . "... ", true); $this->em->persist($section); return $section; }
[ "public", "function", "importSection", "(", "$", "id", ",", "$", "newJournalId", ")", "{", "/** @var Journal $journal */", "$", "journal", "=", "$", "this", "->", "em", "->", "getReference", "(", "'VipaJournalBundle:Journal'", ",", "$", "newJournalId", ")", ";", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Reading section #\"", ".", "$", "id", ".", "\"... \"", ",", "true", ")", ";", "$", "sectionSql", "=", "\"SELECT * FROM sections WHERE section_id = :id LIMIT 1\"", ";", "$", "sectionStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "sectionSql", ")", ";", "$", "sectionStatement", "->", "bindValue", "(", "'id'", ",", "$", "id", ")", ";", "$", "sectionStatement", "->", "execute", "(", ")", ";", "$", "settingsSql", "=", "\"SELECT locale, setting_name, setting_value FROM section_settings WHERE section_id = :id\"", ";", "$", "settingsStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "settingsSql", ")", ";", "$", "settingsStatement", "->", "bindValue", "(", "'id'", ",", "$", "id", ")", ";", "$", "settingsStatement", "->", "execute", "(", ")", ";", "$", "pkpSection", "=", "$", "sectionStatement", "->", "fetch", "(", ")", ";", "$", "pkpSettings", "=", "$", "settingsStatement", "->", "fetchAll", "(", ")", ";", "foreach", "(", "$", "pkpSettings", "as", "$", "setting", ")", "{", "$", "locale", "=", "!", "empty", "(", "$", "setting", "[", "'locale'", "]", ")", "?", "$", "setting", "[", "'locale'", "]", ":", "'en_US'", ";", "$", "name", "=", "$", "setting", "[", "'setting_name'", "]", ";", "$", "value", "=", "$", "setting", "[", "'setting_value'", "]", ";", "$", "this", "->", "settings", "[", "$", "locale", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "$", "section", "=", "new", "Section", "(", ")", ";", "$", "section", "->", "setJournal", "(", "$", "journal", ")", ";", "$", "section", "->", "setAllowIndex", "(", "!", "empty", "(", "$", "pkpSection", "[", "'meta_indexed'", "]", ")", "?", "$", "pkpSection", "[", "'meta_indexed'", "]", ":", "0", ")", ";", "$", "section", "->", "setHideTitle", "(", "!", "empty", "(", "$", "pkpSection", "[", "'hide_title'", "]", ")", "?", "$", "pkpSection", "[", "'hide_title'", "]", ":", "0", ")", ";", "$", "section", "->", "setSectionOrder", "(", "!", "empty", "(", "$", "pkpSection", "[", "'seq'", "]", ")", "?", "intval", "(", "$", "pkpSection", "[", "'seq'", "]", ")", ":", "0", ")", ";", "foreach", "(", "$", "this", "->", "settings", "as", "$", "fieldLocale", "=>", "$", "fields", ")", "{", "$", "section", "->", "setCurrentLocale", "(", "mb_substr", "(", "$", "fieldLocale", ",", "0", ",", "2", ",", "'UTF-8'", ")", ")", ";", "$", "section", "->", "setTitle", "(", "!", "empty", "(", "$", "fields", "[", "'title'", "]", ")", "?", "$", "fields", "[", "'title'", "]", ":", "'-'", ")", ";", "}", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Writing section #\"", ".", "$", "id", ".", "\"... \"", ",", "true", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "section", ")", ";", "return", "$", "section", ";", "}" ]
Imports the given section @param int $id Section's ID @param int $newJournalId Section's Journal ID @return Section
[ "Imports", "the", "given", "section" ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/SectionImporter.php#L81-L123
2,292
phossa2/libs
src/Phossa2/Logger/Entry/LogEntryPrototypeTrait.php
LogEntryPrototypeTrait.newLogEntry
protected function newLogEntry( /*# string */ $channel, /*# string */ $level, /*# string */ $message, array $context = [] )/*# : EventInterface */ { if (is_null($this->entry_proto)) { return new LogEntry($channel, $level, $message, $context); } else { $entry = clone $this->entry_proto; return $entry ->setChannel($channel) ->setLevel($level) ->setMessage($message) ->setContext($context) ->setTimestamp(); } }
php
protected function newLogEntry( /*# string */ $channel, /*# string */ $level, /*# string */ $message, array $context = [] )/*# : EventInterface */ { if (is_null($this->entry_proto)) { return new LogEntry($channel, $level, $message, $context); } else { $entry = clone $this->entry_proto; return $entry ->setChannel($channel) ->setLevel($level) ->setMessage($message) ->setContext($context) ->setTimestamp(); } }
[ "protected", "function", "newLogEntry", "(", "/*# string */", "$", "channel", ",", "/*# string */", "$", "level", ",", "/*# string */", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "/*# : EventInterface */", "{", "if", "(", "is_null", "(", "$", "this", "->", "entry_proto", ")", ")", "{", "return", "new", "LogEntry", "(", "$", "channel", ",", "$", "level", ",", "$", "message", ",", "$", "context", ")", ";", "}", "else", "{", "$", "entry", "=", "clone", "$", "this", "->", "entry_proto", ";", "return", "$", "entry", "->", "setChannel", "(", "$", "channel", ")", "->", "setLevel", "(", "$", "level", ")", "->", "setMessage", "(", "$", "message", ")", "->", "setContext", "(", "$", "context", ")", "->", "setTimestamp", "(", ")", ";", "}", "}" ]
Create a log entry @param string $channel @param string $level @param string $message $param array $context @return LogEntryInterface @access protected
[ "Create", "a", "log", "entry" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Entry/LogEntryPrototypeTrait.php#L55-L72
2,293
artscorestudio/website-bundle
Repository/ConfigRepository.php
ConfigRepository.getDefaultConfiguration
public function getDefaultConfiguration() { $query = $this->createQueryBuilder('c'); $query->where('c.isDefault=:isDefault') ->orderBy('c.updatedAt', 'DESC') ->setMaxResults(1) ->setParameter(':isDefault', true); return $query->getQuery()->getResult(); }
php
public function getDefaultConfiguration() { $query = $this->createQueryBuilder('c'); $query->where('c.isDefault=:isDefault') ->orderBy('c.updatedAt', 'DESC') ->setMaxResults(1) ->setParameter(':isDefault', true); return $query->getQuery()->getResult(); }
[ "public", "function", "getDefaultConfiguration", "(", ")", "{", "$", "query", "=", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", ";", "$", "query", "->", "where", "(", "'c.isDefault=:isDefault'", ")", "->", "orderBy", "(", "'c.updatedAt'", ",", "'DESC'", ")", "->", "setMaxResults", "(", "1", ")", "->", "setParameter", "(", "':isDefault'", ",", "true", ")", ";", "return", "$", "query", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
Get Default Configuration
[ "Get", "Default", "Configuration" ]
016d62d7558cd8c2fe821ae2645735149c5e6ee5
https://github.com/artscorestudio/website-bundle/blob/016d62d7558cd8c2fe821ae2645735149c5e6ee5/Repository/ConfigRepository.php#L26-L35
2,294
gluephp/glue-whoops
src/ProductionHandler.php
ProductionHandler.getFrameArgsOutput
private function getFrameArgsOutput(Frame $frame, $line) { if ($this->addTraceFunctionArgsToOutput() === false || $this->addTraceFunctionArgsToOutput() < $line) { return ''; } // Dump the arguments: ob_start(); var_dump($frame->getArgs()); if (ob_get_length() > $this->getTraceFunctionArgsOutputLimit()) { // The argument var_dump is to big. // Discarded to limit memory usage. ob_clean(); return sprintf( "\n%sArguments dump length greater than %d Bytes. Discarded.", self::VAR_DUMP_PREFIX, $this->getTraceFunctionArgsOutputLimit() ); } return sprintf("\n%s", preg_replace('/^/m', self::VAR_DUMP_PREFIX, ob_get_clean()) ); }
php
private function getFrameArgsOutput(Frame $frame, $line) { if ($this->addTraceFunctionArgsToOutput() === false || $this->addTraceFunctionArgsToOutput() < $line) { return ''; } // Dump the arguments: ob_start(); var_dump($frame->getArgs()); if (ob_get_length() > $this->getTraceFunctionArgsOutputLimit()) { // The argument var_dump is to big. // Discarded to limit memory usage. ob_clean(); return sprintf( "\n%sArguments dump length greater than %d Bytes. Discarded.", self::VAR_DUMP_PREFIX, $this->getTraceFunctionArgsOutputLimit() ); } return sprintf("\n%s", preg_replace('/^/m', self::VAR_DUMP_PREFIX, ob_get_clean()) ); }
[ "private", "function", "getFrameArgsOutput", "(", "Frame", "$", "frame", ",", "$", "line", ")", "{", "if", "(", "$", "this", "->", "addTraceFunctionArgsToOutput", "(", ")", "===", "false", "||", "$", "this", "->", "addTraceFunctionArgsToOutput", "(", ")", "<", "$", "line", ")", "{", "return", "''", ";", "}", "// Dump the arguments:", "ob_start", "(", ")", ";", "var_dump", "(", "$", "frame", "->", "getArgs", "(", ")", ")", ";", "if", "(", "ob_get_length", "(", ")", ">", "$", "this", "->", "getTraceFunctionArgsOutputLimit", "(", ")", ")", "{", "// The argument var_dump is to big.", "// Discarded to limit memory usage.", "ob_clean", "(", ")", ";", "return", "sprintf", "(", "\"\\n%sArguments dump length greater than %d Bytes. Discarded.\"", ",", "self", "::", "VAR_DUMP_PREFIX", ",", "$", "this", "->", "getTraceFunctionArgsOutputLimit", "(", ")", ")", ";", "}", "return", "sprintf", "(", "\"\\n%s\"", ",", "preg_replace", "(", "'/^/m'", ",", "self", "::", "VAR_DUMP_PREFIX", ",", "ob_get_clean", "(", ")", ")", ")", ";", "}" ]
Get the frame args var_dump. @param \Whoops\Exception\Frame $frame [description] @param integer $line [description] @return string
[ "Get", "the", "frame", "args", "var_dump", "." ]
4530599508be5ff4823595c8190cbaae027876aa
https://github.com/gluephp/glue-whoops/blob/4530599508be5ff4823595c8190cbaae027876aa/src/ProductionHandler.php#L175-L199
2,295
CampaignChain/channel-linkedin
REST/LinkedInClient.php
LinkedInClient.getConnectionByToken
public function getConnectionByToken(Token $token) { $application = $this->oauthApp ->getApplication(self::RESOURCE_OWNER); $connection = $this->connect($application->getKey(), $application->getSecret(), $token->getAccessToken(), $token->getTokenSecret()); return new LinkedInClientService($connection); }
php
public function getConnectionByToken(Token $token) { $application = $this->oauthApp ->getApplication(self::RESOURCE_OWNER); $connection = $this->connect($application->getKey(), $application->getSecret(), $token->getAccessToken(), $token->getTokenSecret()); return new LinkedInClientService($connection); }
[ "public", "function", "getConnectionByToken", "(", "Token", "$", "token", ")", "{", "$", "application", "=", "$", "this", "->", "oauthApp", "->", "getApplication", "(", "self", "::", "RESOURCE_OWNER", ")", ";", "$", "connection", "=", "$", "this", "->", "connect", "(", "$", "application", "->", "getKey", "(", ")", ",", "$", "application", "->", "getSecret", "(", ")", ",", "$", "token", "->", "getAccessToken", "(", ")", ",", "$", "token", "->", "getTokenSecret", "(", ")", ")", ";", "return", "new", "LinkedInClientService", "(", "$", "connection", ")", ";", "}" ]
Return a connection based on the suplied Token @param Token $token @return LinkedInClientService
[ "Return", "a", "connection", "based", "on", "the", "suplied", "Token" ]
f3a52c78e719ab888f237dd8b99ab429350f3113
https://github.com/CampaignChain/channel-linkedin/blob/f3a52c78e719ab888f237dd8b99ab429350f3113/REST/LinkedInClient.php#L78-L86
2,296
coolms/common
src/Form/Element/DateTimeTrait.php
DateTimeTrait.normalizeDateTime
protected function normalizeDateTime($value) { try { if (is_int($value)) { //timestamp $value = new DateTime("@$value"); } elseif (!$value instanceof DateTime) { $value = new DateTime($value); } } catch (\Exception $e) { throw new InvalidArgumentException('Invalid date string provided', $e->getCode(), $e); } return $value; }
php
protected function normalizeDateTime($value) { try { if (is_int($value)) { //timestamp $value = new DateTime("@$value"); } elseif (!$value instanceof DateTime) { $value = new DateTime($value); } } catch (\Exception $e) { throw new InvalidArgumentException('Invalid date string provided', $e->getCode(), $e); } return $value; }
[ "protected", "function", "normalizeDateTime", "(", "$", "value", ")", "{", "try", "{", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "//timestamp", "$", "value", "=", "new", "DateTime", "(", "\"@$value\"", ")", ";", "}", "elseif", "(", "!", "$", "value", "instanceof", "DateTime", ")", "{", "$", "value", "=", "new", "DateTime", "(", "$", "value", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid date string provided'", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "return", "$", "value", ";", "}" ]
Normalize the provided value to a DateTime object @param string|int|DateTime $value @throws InvalidArgumentException @return DateTime
[ "Normalize", "the", "provided", "value", "to", "a", "DateTime", "object" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/Element/DateTimeTrait.php#L46-L60
2,297
dankempster/axstrad-common
src/Exception/InvalidArgumentException.php
InvalidArgumentException.create
public static function create( $expected, $actual, $paramNo = null, $code = null, $previous = null ) { $msgMsk = 'Expected %1$s. Got %2$s'; if ($paramNo !== null) { $msgMsk = 'Param #%3$s '.lcfirst($msgMsk); } if ($code !== null) { $msgMsk = '[%4$s] '.$msgMsk; } $class = get_called_class(); return new $class( sprintf( $msgMsk, $expected, Debug::summarise($actual), $paramNo, $code ), is_int($code) ? $code : null, $previous ); }
php
public static function create( $expected, $actual, $paramNo = null, $code = null, $previous = null ) { $msgMsk = 'Expected %1$s. Got %2$s'; if ($paramNo !== null) { $msgMsk = 'Param #%3$s '.lcfirst($msgMsk); } if ($code !== null) { $msgMsk = '[%4$s] '.$msgMsk; } $class = get_called_class(); return new $class( sprintf( $msgMsk, $expected, Debug::summarise($actual), $paramNo, $code ), is_int($code) ? $code : null, $previous ); }
[ "public", "static", "function", "create", "(", "$", "expected", ",", "$", "actual", ",", "$", "paramNo", "=", "null", ",", "$", "code", "=", "null", ",", "$", "previous", "=", "null", ")", "{", "$", "msgMsk", "=", "'Expected %1$s. Got %2$s'", ";", "if", "(", "$", "paramNo", "!==", "null", ")", "{", "$", "msgMsk", "=", "'Param #%3$s '", ".", "lcfirst", "(", "$", "msgMsk", ")", ";", "}", "if", "(", "$", "code", "!==", "null", ")", "{", "$", "msgMsk", "=", "'[%4$s] '", ".", "$", "msgMsk", ";", "}", "$", "class", "=", "get_called_class", "(", ")", ";", "return", "new", "$", "class", "(", "sprintf", "(", "$", "msgMsk", ",", "$", "expected", ",", "Debug", "::", "summarise", "(", "$", "actual", ")", ",", "$", "paramNo", ",", "$", "code", ")", ",", "is_int", "(", "$", "code", ")", "?", "$", "code", ":", "null", ",", "$", "previous", ")", ";", "}" ]
Invalid Argument exception factory @param string $expected @param mixed $actual @param null|integer $paramNo @param null|integer $code @param null|\Exception $previous @return InvalidArgumentException A new instance of self
[ "Invalid", "Argument", "exception", "factory" ]
900ae03199aa027750d9fa8375d376e3754a5abd
https://github.com/dankempster/axstrad-common/blob/900ae03199aa027750d9fa8375d376e3754a5abd/src/Exception/InvalidArgumentException.php#L39-L68
2,298
znframework/package-security
CrossSiteRequestForgery.php
CrossSiteRequestForgery.token
public static function token(String $uri = NULL, String $type = 'post') { Security::CSRFToken($uri, $type); }
php
public static function token(String $uri = NULL, String $type = 'post') { Security::CSRFToken($uri, $type); }
[ "public", "static", "function", "token", "(", "String", "$", "uri", "=", "NULL", ",", "String", "$", "type", "=", "'post'", ")", "{", "Security", "::", "CSRFToken", "(", "$", "uri", ",", "$", "type", ")", ";", "}" ]
Cross Site Request Forgery @param string $uri = NULL @param string $type = 'post' @return void
[ "Cross", "Site", "Request", "Forgery" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/CrossSiteRequestForgery.php#L24-L27
2,299
erdemkeren/jet-sms-php
src/Http/Clients/JetSmsXmlClient.php
JetSmsXmlClient.performCurlSession
private function performCurlSession($payload) { $perCurlConnection = curl_init(); curl_setopt($perCurlConnection, CURLOPT_URL, $this->url); curl_setopt($perCurlConnection, CURLOPT_RETURNTRANSFER, 1); curl_setopt($perCurlConnection, CURLOPT_TIMEOUT, 10); curl_setopt($perCurlConnection, CURLOPT_POSTFIELDS, $payload); $result = curl_exec($perCurlConnection); return $result; }
php
private function performCurlSession($payload) { $perCurlConnection = curl_init(); curl_setopt($perCurlConnection, CURLOPT_URL, $this->url); curl_setopt($perCurlConnection, CURLOPT_RETURNTRANSFER, 1); curl_setopt($perCurlConnection, CURLOPT_TIMEOUT, 10); curl_setopt($perCurlConnection, CURLOPT_POSTFIELDS, $payload); $result = curl_exec($perCurlConnection); return $result; }
[ "private", "function", "performCurlSession", "(", "$", "payload", ")", "{", "$", "perCurlConnection", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "perCurlConnection", ",", "CURLOPT_URL", ",", "$", "this", "->", "url", ")", ";", "curl_setopt", "(", "$", "perCurlConnection", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "perCurlConnection", ",", "CURLOPT_TIMEOUT", ",", "10", ")", ";", "curl_setopt", "(", "$", "perCurlConnection", ",", "CURLOPT_POSTFIELDS", ",", "$", "payload", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "perCurlConnection", ")", ";", "return", "$", "result", ";", "}" ]
Perform the curl session. @param string $payload @return string
[ "Perform", "the", "curl", "session", "." ]
5b103a980bd2a8dce003964a17e2568736dfcf4e
https://github.com/erdemkeren/jet-sms-php/blob/5b103a980bd2a8dce003964a17e2568736dfcf4e/src/Http/Clients/JetSmsXmlClient.php#L149-L160