id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
232,000
digiaonline/paytrail-php
src/Http/Client.php
Client.processPayment
public function processPayment(Payment $payment) { $response = $this->postRequest('/api-payment/create', $payment->toJson()); if ( ! in_array('application/json', $response->getHeader('Content-Type'))) { throw new PaymentFailed('Server returned a non-JSON result.'); } $body = json_decode((string)$response->getBody()); if ($response->getStatusCode() !== 201) { throw new PaymentFailed( sprintf('Paytrail request failed: %s (%d)', $body->errorMessage, $body->errorCode) ); } $result = new Result; $result->configure( array( 'orderNumber' => $body->orderNumber, 'token' => $body->token, 'url' => $body->url, ) ); return $result; }
php
public function processPayment(Payment $payment) { $response = $this->postRequest('/api-payment/create', $payment->toJson()); if ( ! in_array('application/json', $response->getHeader('Content-Type'))) { throw new PaymentFailed('Server returned a non-JSON result.'); } $body = json_decode((string)$response->getBody()); if ($response->getStatusCode() !== 201) { throw new PaymentFailed( sprintf('Paytrail request failed: %s (%d)', $body->errorMessage, $body->errorCode) ); } $result = new Result; $result->configure( array( 'orderNumber' => $body->orderNumber, 'token' => $body->token, 'url' => $body->url, ) ); return $result; }
[ "public", "function", "processPayment", "(", "Payment", "$", "payment", ")", "{", "$", "response", "=", "$", "this", "->", "postRequest", "(", "'/api-payment/create'", ",", "$", "payment", "->", "toJson", "(", ")", ")", ";", "if", "(", "!", "in_array", "(", "'application/json'", ",", "$", "response", "->", "getHeader", "(", "'Content-Type'", ")", ")", ")", "{", "throw", "new", "PaymentFailed", "(", "'Server returned a non-JSON result.'", ")", ";", "}", "$", "body", "=", "json_decode", "(", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ")", ";", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!==", "201", ")", "{", "throw", "new", "PaymentFailed", "(", "sprintf", "(", "'Paytrail request failed: %s (%d)'", ",", "$", "body", "->", "errorMessage", ",", "$", "body", "->", "errorCode", ")", ")", ";", "}", "$", "result", "=", "new", "Result", ";", "$", "result", "->", "configure", "(", "array", "(", "'orderNumber'", "=>", "$", "body", "->", "orderNumber", ",", "'token'", "=>", "$", "body", "->", "token", ",", "'url'", "=>", "$", "body", "->", "url", ",", ")", ")", ";", "return", "$", "result", ";", "}" ]
Processes the payment. @param Payment $payment The payment object. @return \Paytrail\Http\Result @throws \Paytrail\Exception\PaymentFailed
[ "Processes", "the", "payment", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L135-L161
232,001
digiaonline/paytrail-php
src/Http/Client.php
Client.validateChecksum
public function validateChecksum($checksum, $orderNumber, $timestamp, $paid = null, $method = null) { return $checksum === $this->calculateChecksum($orderNumber, $timestamp, $paid, $method); }
php
public function validateChecksum($checksum, $orderNumber, $timestamp, $paid = null, $method = null) { return $checksum === $this->calculateChecksum($orderNumber, $timestamp, $paid, $method); }
[ "public", "function", "validateChecksum", "(", "$", "checksum", ",", "$", "orderNumber", ",", "$", "timestamp", ",", "$", "paid", "=", "null", ",", "$", "method", "=", "null", ")", "{", "return", "$", "checksum", "===", "$", "this", "->", "calculateChecksum", "(", "$", "orderNumber", ",", "$", "timestamp", ",", "$", "paid", ",", "$", "method", ")", ";", "}" ]
Validates the given checksum against the order. @param string $checksum Checksum to validate. @param string $orderNumber The order number. @param int $timestamp The timestamp of the order. @param string|null $paid Payment paid. @param int|null $method The method. @return bool
[ "Validates", "the", "given", "checksum", "against", "the", "order", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L174-L177
232,002
digiaonline/paytrail-php
src/Http/Client.php
Client.calculateChecksum
protected function calculateChecksum($orderNumber, $timestamp, $paid = null, $method = null) { $data = array($orderNumber, $timestamp); if ($paid !== null) { $data[] = $paid; } if ($method !== null) { $data[] = $method; } $data[] = $this->_apiSecret; return strtoupper(md5(implode('|', $data))); }
php
protected function calculateChecksum($orderNumber, $timestamp, $paid = null, $method = null) { $data = array($orderNumber, $timestamp); if ($paid !== null) { $data[] = $paid; } if ($method !== null) { $data[] = $method; } $data[] = $this->_apiSecret; return strtoupper(md5(implode('|', $data))); }
[ "protected", "function", "calculateChecksum", "(", "$", "orderNumber", ",", "$", "timestamp", ",", "$", "paid", "=", "null", ",", "$", "method", "=", "null", ")", "{", "$", "data", "=", "array", "(", "$", "orderNumber", ",", "$", "timestamp", ")", ";", "if", "(", "$", "paid", "!==", "null", ")", "{", "$", "data", "[", "]", "=", "$", "paid", ";", "}", "if", "(", "$", "method", "!==", "null", ")", "{", "$", "data", "[", "]", "=", "$", "method", ";", "}", "$", "data", "[", "]", "=", "$", "this", "->", "_apiSecret", ";", "return", "strtoupper", "(", "md5", "(", "implode", "(", "'|'", ",", "$", "data", ")", ")", ")", ";", "}" ]
Calculates the checksum. @param string $orderNumber The order number. @param int $timestamp The timestamp of the order. @param string|null $paid Payment paid. @param int|null $method The method. @return string
[ "Calculates", "the", "checksum", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L189-L201
232,003
digiaonline/paytrail-php
src/Http/Client.php
Client.postRequest
protected function postRequest($uri, $body = null, $options = array()) { if ($this->testMode) { $options['debug'] = true; } $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Verkkomaksut-Api-Version' => $this->apiVersion, ); $options = array_merge( array( 'auth' => array($this->_apiKey, $this->_apiSecret), 'timeout' => 30, 'connect_timeout' => 10, ), $options ); $request = new Request('POST', $uri, $headers, $body); return $this->_client->send($request, $options); }
php
protected function postRequest($uri, $body = null, $options = array()) { if ($this->testMode) { $options['debug'] = true; } $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Verkkomaksut-Api-Version' => $this->apiVersion, ); $options = array_merge( array( 'auth' => array($this->_apiKey, $this->_apiSecret), 'timeout' => 30, 'connect_timeout' => 10, ), $options ); $request = new Request('POST', $uri, $headers, $body); return $this->_client->send($request, $options); }
[ "protected", "function", "postRequest", "(", "$", "uri", ",", "$", "body", "=", "null", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "testMode", ")", "{", "$", "options", "[", "'debug'", "]", "=", "true", ";", "}", "$", "headers", "=", "array", "(", "'Content-Type'", "=>", "'application/json'", ",", "'Accept'", "=>", "'application/json'", ",", "'X-Verkkomaksut-Api-Version'", "=>", "$", "this", "->", "apiVersion", ",", ")", ";", "$", "options", "=", "array_merge", "(", "array", "(", "'auth'", "=>", "array", "(", "$", "this", "->", "_apiKey", ",", "$", "this", "->", "_apiSecret", ")", ",", "'timeout'", "=>", "30", ",", "'connect_timeout'", "=>", "10", ",", ")", ",", "$", "options", ")", ";", "$", "request", "=", "new", "Request", "(", "'POST'", ",", "$", "uri", ",", "$", "headers", ",", "$", "body", ")", ";", "return", "$", "this", "->", "_client", "->", "send", "(", "$", "request", ",", "$", "options", ")", ";", "}" ]
Runs a POST request. @param string $uri The URI to post to. @param string|null $body The body to post. @param array $options The options. @return \Psr\Http\Message\ResponseInterface
[ "Runs", "a", "POST", "request", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L212-L236
232,004
digiaonline/paytrail-php
src/Http/Client.php
Client.setApiVersion
public function setApiVersion($apiVersion) { if ( ! in_array($apiVersion, self::$supportedApiVersions)) { throw new ApiVersionNotSupported(sprintf('API version %d is not supported.', $apiVersion)); } $this->apiVersion = $apiVersion; }
php
public function setApiVersion($apiVersion) { if ( ! in_array($apiVersion, self::$supportedApiVersions)) { throw new ApiVersionNotSupported(sprintf('API version %d is not supported.', $apiVersion)); } $this->apiVersion = $apiVersion; }
[ "public", "function", "setApiVersion", "(", "$", "apiVersion", ")", "{", "if", "(", "!", "in_array", "(", "$", "apiVersion", ",", "self", "::", "$", "supportedApiVersions", ")", ")", "{", "throw", "new", "ApiVersionNotSupported", "(", "sprintf", "(", "'API version %d is not supported.'", ",", "$", "apiVersion", ")", ")", ";", "}", "$", "this", "->", "apiVersion", "=", "$", "apiVersion", ";", "}" ]
Set the Paytrail API version. @param int $apiVersion The API version. @throws \Paytrail\Exception\ApiVersionNotSupported
[ "Set", "the", "Paytrail", "API", "version", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L275-L281
232,005
digiaonline/paytrail-php
src/Http/Client.php
Client.getLogoUrl
public function getLogoUrl() { $params = [ 'id' => $this->_apiKey, 'type' => $this->logoType, 'cols' => (int)$this->logoCols, 'text' => (int)$this->logoText, 'auth' => $this->calculateLogoAuth(), ]; return self::LOGO_BASE_URL . '?' . http_build_query($params); }
php
public function getLogoUrl() { $params = [ 'id' => $this->_apiKey, 'type' => $this->logoType, 'cols' => (int)$this->logoCols, 'text' => (int)$this->logoText, 'auth' => $this->calculateLogoAuth(), ]; return self::LOGO_BASE_URL . '?' . http_build_query($params); }
[ "public", "function", "getLogoUrl", "(", ")", "{", "$", "params", "=", "[", "'id'", "=>", "$", "this", "->", "_apiKey", ",", "'type'", "=>", "$", "this", "->", "logoType", ",", "'cols'", "=>", "(", "int", ")", "$", "this", "->", "logoCols", ",", "'text'", "=>", "(", "int", ")", "$", "this", "->", "logoText", ",", "'auth'", "=>", "$", "this", "->", "calculateLogoAuth", "(", ")", ",", "]", ";", "return", "self", "::", "LOGO_BASE_URL", ".", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "}" ]
Get the URL to the dynamic Paytrail logo. @return string
[ "Get", "the", "URL", "to", "the", "dynamic", "Paytrail", "logo", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L288-L299
232,006
praxisnetau/silverware
src/Extensions/Forms/AlertMessageExtension.php
AlertMessageExtension.getAlertMessageType
public function getAlertMessageType() { // Obtain Base Alert Class: $classes = $this->styles('alert'); // Determine Message Type: switch ($this->owner->MessageType) { case ValidationResult::TYPE_GOOD: $classes[] = $this->style('alert.success'); break; case ValidationResult::TYPE_INFO: $classes[] = $this->style('alert.info'); break; case ValidationResult::TYPE_ERROR: $classes[] = $this->style('alert.danger'); break; default: $classes[] = $this->style('alert.warning'); } // Answer Classes: return ViewTools::singleton()->array2att($classes); }
php
public function getAlertMessageType() { // Obtain Base Alert Class: $classes = $this->styles('alert'); // Determine Message Type: switch ($this->owner->MessageType) { case ValidationResult::TYPE_GOOD: $classes[] = $this->style('alert.success'); break; case ValidationResult::TYPE_INFO: $classes[] = $this->style('alert.info'); break; case ValidationResult::TYPE_ERROR: $classes[] = $this->style('alert.danger'); break; default: $classes[] = $this->style('alert.warning'); } // Answer Classes: return ViewTools::singleton()->array2att($classes); }
[ "public", "function", "getAlertMessageType", "(", ")", "{", "// Obtain Base Alert Class:", "$", "classes", "=", "$", "this", "->", "styles", "(", "'alert'", ")", ";", "// Determine Message Type:", "switch", "(", "$", "this", "->", "owner", "->", "MessageType", ")", "{", "case", "ValidationResult", "::", "TYPE_GOOD", ":", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "'alert.success'", ")", ";", "break", ";", "case", "ValidationResult", "::", "TYPE_INFO", ":", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "'alert.info'", ")", ";", "break", ";", "case", "ValidationResult", "::", "TYPE_ERROR", ":", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "'alert.danger'", ")", ";", "break", ";", "default", ":", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "'alert.warning'", ")", ";", "}", "// Answer Classes:", "return", "ViewTools", "::", "singleton", "(", ")", "->", "array2att", "(", "$", "classes", ")", ";", "}" ]
Answers a string of alert classes for the message type of the extended object. @return string
[ "Answers", "a", "string", "of", "alert", "classes", "for", "the", "message", "type", "of", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Forms/AlertMessageExtension.php#L43-L68
232,007
praxisnetau/silverware
src/Model/PageType.php
PageType.getPageName
public function getPageName() { if ($this->PageClass && class_exists($this->PageClass)) { return Injector::inst()->get($this->PageClass)->i18n_singular_name(); } }
php
public function getPageName() { if ($this->PageClass && class_exists($this->PageClass)) { return Injector::inst()->get($this->PageClass)->i18n_singular_name(); } }
[ "public", "function", "getPageName", "(", ")", "{", "if", "(", "$", "this", "->", "PageClass", "&&", "class_exists", "(", "$", "this", "->", "PageClass", ")", ")", "{", "return", "Injector", "::", "inst", "(", ")", "->", "get", "(", "$", "this", "->", "PageClass", ")", "->", "i18n_singular_name", "(", ")", ";", "}", "}" ]
Answers the singular name of the associated page class. @return string
[ "Answers", "the", "singular", "name", "of", "the", "associated", "page", "class", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/PageType.php#L290-L295
232,008
praxisnetau/silverware
src/Model/PageType.php
PageType.getColumnOptions
public function getColumnOptions() { // Create Options Array: $options = []; // Merge Template Columns: if ($template = $this->getPageTemplate()) { foreach ($template->getAllComponentsByClass(Column::class) as $column) { $options[$column->ID] = $this->getColumnLabel($column, $template); } } // Merge Layout Columns: if ($layout = $this->getPageLayout()) { foreach ($layout->getAllComponentsByClass(Column::class) as $column) { $options[$column->ID] = $this->getColumnLabel($column, $layout); } } // Answer Options Array: return $options; }
php
public function getColumnOptions() { // Create Options Array: $options = []; // Merge Template Columns: if ($template = $this->getPageTemplate()) { foreach ($template->getAllComponentsByClass(Column::class) as $column) { $options[$column->ID] = $this->getColumnLabel($column, $template); } } // Merge Layout Columns: if ($layout = $this->getPageLayout()) { foreach ($layout->getAllComponentsByClass(Column::class) as $column) { $options[$column->ID] = $this->getColumnLabel($column, $layout); } } // Answer Options Array: return $options; }
[ "public", "function", "getColumnOptions", "(", ")", "{", "// Create Options Array:", "$", "options", "=", "[", "]", ";", "// Merge Template Columns:", "if", "(", "$", "template", "=", "$", "this", "->", "getPageTemplate", "(", ")", ")", "{", "foreach", "(", "$", "template", "->", "getAllComponentsByClass", "(", "Column", "::", "class", ")", "as", "$", "column", ")", "{", "$", "options", "[", "$", "column", "->", "ID", "]", "=", "$", "this", "->", "getColumnLabel", "(", "$", "column", ",", "$", "template", ")", ";", "}", "}", "// Merge Layout Columns:", "if", "(", "$", "layout", "=", "$", "this", "->", "getPageLayout", "(", ")", ")", "{", "foreach", "(", "$", "layout", "->", "getAllComponentsByClass", "(", "Column", "::", "class", ")", "as", "$", "column", ")", "{", "$", "options", "[", "$", "column", "->", "ID", "]", "=", "$", "this", "->", "getColumnLabel", "(", "$", "column", ",", "$", "layout", ")", ";", "}", "}", "// Answer Options Array:", "return", "$", "options", ";", "}" ]
Answers an array of options for the column field in child column span records. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "column", "field", "in", "child", "column", "span", "records", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/PageType.php#L352-L381
232,009
praxisnetau/silverware
src/Model/PageType.php
PageType.getColumnLabel
public function getColumnLabel(Column $column, SectionHolder $holder, $depth = 3) { $label = sprintf('%s > %s', $holder->i18n_singular_name(), $column->NestedTitle($depth, ' > ') ); if ($column->isSidebar()) { $label .= sprintf( ' (%s)', _t(__CLASS__ . '.SIDEBAR', 'Sidebar') ); } return $label; }
php
public function getColumnLabel(Column $column, SectionHolder $holder, $depth = 3) { $label = sprintf('%s > %s', $holder->i18n_singular_name(), $column->NestedTitle($depth, ' > ') ); if ($column->isSidebar()) { $label .= sprintf( ' (%s)', _t(__CLASS__ . '.SIDEBAR', 'Sidebar') ); } return $label; }
[ "public", "function", "getColumnLabel", "(", "Column", "$", "column", ",", "SectionHolder", "$", "holder", ",", "$", "depth", "=", "3", ")", "{", "$", "label", "=", "sprintf", "(", "'%s > %s'", ",", "$", "holder", "->", "i18n_singular_name", "(", ")", ",", "$", "column", "->", "NestedTitle", "(", "$", "depth", ",", "' > '", ")", ")", ";", "if", "(", "$", "column", "->", "isSidebar", "(", ")", ")", "{", "$", "label", ".=", "sprintf", "(", "' (%s)'", ",", "_t", "(", "__CLASS__", ".", "'.SIDEBAR'", ",", "'Sidebar'", ")", ")", ";", "}", "return", "$", "label", ";", "}" ]
Answers a label for a column field option. @param Column $column @param SectionHolder $holder @param integer $depth @return string
[ "Answers", "a", "label", "for", "a", "column", "field", "option", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/PageType.php#L392-L407
232,010
praxisnetau/silverware
src/Model/PageType.php
PageType.getPageClassOptions
public function getPageClassOptions() { $options = []; foreach (ClassInfo::subclassesFor(Page::class) as $class) { $type = self::findByClass($class); if (!$type || $type->ID == $this->ID) { $options[$class] = Injector::inst()->get($class)->i18n_singular_name(); } } asort($options); return $options; }
php
public function getPageClassOptions() { $options = []; foreach (ClassInfo::subclassesFor(Page::class) as $class) { $type = self::findByClass($class); if (!$type || $type->ID == $this->ID) { $options[$class] = Injector::inst()->get($class)->i18n_singular_name(); } } asort($options); return $options; }
[ "public", "function", "getPageClassOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "ClassInfo", "::", "subclassesFor", "(", "Page", "::", "class", ")", "as", "$", "class", ")", "{", "$", "type", "=", "self", "::", "findByClass", "(", "$", "class", ")", ";", "if", "(", "!", "$", "type", "||", "$", "type", "->", "ID", "==", "$", "this", "->", "ID", ")", "{", "$", "options", "[", "$", "class", "]", "=", "Injector", "::", "inst", "(", ")", "->", "get", "(", "$", "class", ")", "->", "i18n_singular_name", "(", ")", ";", "}", "}", "asort", "(", "$", "options", ")", ";", "return", "$", "options", ";", "}" ]
Answers a sorted array of available page classes mapped to their singular name. @return array
[ "Answers", "a", "sorted", "array", "of", "available", "page", "classes", "mapped", "to", "their", "singular", "name", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/PageType.php#L414-L431
232,011
praxisnetau/silverware
src/Extensions/Style/AlignmentStyle.php
AlignmentStyle.updateContentClassNames
public function updateContentClassNames(&$classes) { if (!$this->apply()) { return; } foreach ($this->getTextAlignmentClassNames() as $class) { $classes[] = $class; } foreach ($this->getImageAlignmentClassNames() as $class) { $classes[] = $class; } }
php
public function updateContentClassNames(&$classes) { if (!$this->apply()) { return; } foreach ($this->getTextAlignmentClassNames() as $class) { $classes[] = $class; } foreach ($this->getImageAlignmentClassNames() as $class) { $classes[] = $class; } }
[ "public", "function", "updateContentClassNames", "(", "&", "$", "classes", ")", "{", "if", "(", "!", "$", "this", "->", "apply", "(", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "getTextAlignmentClassNames", "(", ")", "as", "$", "class", ")", "{", "$", "classes", "[", "]", "=", "$", "class", ";", "}", "foreach", "(", "$", "this", "->", "getImageAlignmentClassNames", "(", ")", "as", "$", "class", ")", "{", "$", "classes", "[", "]", "=", "$", "class", ";", "}", "}" ]
Updates the content class names of the extended object. @param array $classes Array of class names from the extended object. @return void
[ "Updates", "the", "content", "class", "names", "of", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/AlignmentStyle.php#L132-L145
232,012
praxisnetau/silverware
src/Extensions/Style/AlignmentStyle.php
AlignmentStyle.getTextAlignmentClassNames
public function getTextAlignmentClassNames() { $classes = []; $alignment = $this->owner->dbObject('TextAlignment'); foreach ($alignment->getViewports() as $viewport) { $classes[] = $this->getTextAlignmentClass($viewport, $alignment->getField($viewport)); } return $classes; }
php
public function getTextAlignmentClassNames() { $classes = []; $alignment = $this->owner->dbObject('TextAlignment'); foreach ($alignment->getViewports() as $viewport) { $classes[] = $this->getTextAlignmentClass($viewport, $alignment->getField($viewport)); } return $classes; }
[ "public", "function", "getTextAlignmentClassNames", "(", ")", "{", "$", "classes", "=", "[", "]", ";", "$", "alignment", "=", "$", "this", "->", "owner", "->", "dbObject", "(", "'TextAlignment'", ")", ";", "foreach", "(", "$", "alignment", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "getTextAlignmentClass", "(", "$", "viewport", ",", "$", "alignment", "->", "getField", "(", "$", "viewport", ")", ")", ";", "}", "return", "$", "classes", ";", "}" ]
Answers an array of classes for text alignment. @return array
[ "Answers", "an", "array", "of", "classes", "for", "text", "alignment", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/AlignmentStyle.php#L152-L163
232,013
praxisnetau/silverware
src/Extensions/Style/AlignmentStyle.php
AlignmentStyle.getImageAlignmentClassNames
public function getImageAlignmentClassNames() { $classes = []; $alignment = $this->owner->dbObject('ImageAlignment'); foreach ($alignment->getViewports() as $viewport) { $classes[] = $this->getImageAlignmentClass($viewport, $alignment->getField($viewport)); } return $classes; }
php
public function getImageAlignmentClassNames() { $classes = []; $alignment = $this->owner->dbObject('ImageAlignment'); foreach ($alignment->getViewports() as $viewport) { $classes[] = $this->getImageAlignmentClass($viewport, $alignment->getField($viewport)); } return $classes; }
[ "public", "function", "getImageAlignmentClassNames", "(", ")", "{", "$", "classes", "=", "[", "]", ";", "$", "alignment", "=", "$", "this", "->", "owner", "->", "dbObject", "(", "'ImageAlignment'", ")", ";", "foreach", "(", "$", "alignment", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "getImageAlignmentClass", "(", "$", "viewport", ",", "$", "alignment", "->", "getField", "(", "$", "viewport", ")", ")", ";", "}", "return", "$", "classes", ";", "}" ]
Answers an array of classes for image alignment. @return array
[ "Answers", "an", "array", "of", "classes", "for", "image", "alignment", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/AlignmentStyle.php#L170-L181
232,014
praxisnetau/silverware
src/Extensions/Style/AlignmentStyle.php
AlignmentStyle.getTextAlignmentOptions
public function getTextAlignmentOptions() { return [ self::ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'), self::ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ALIGN_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right'), self::ALIGN_JUSTIFY => _t(__CLASS__ . '.JUSTIFY', 'Justify') ]; }
php
public function getTextAlignmentOptions() { return [ self::ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'), self::ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ALIGN_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right'), self::ALIGN_JUSTIFY => _t(__CLASS__ . '.JUSTIFY', 'Justify') ]; }
[ "public", "function", "getTextAlignmentOptions", "(", ")", "{", "return", "[", "self", "::", "ALIGN_LEFT", "=>", "_t", "(", "__CLASS__", ".", "'.LEFT'", ",", "'Left'", ")", ",", "self", "::", "ALIGN_CENTER", "=>", "_t", "(", "__CLASS__", ".", "'.CENTER'", ",", "'Center'", ")", ",", "self", "::", "ALIGN_RIGHT", "=>", "_t", "(", "__CLASS__", ".", "'.RIGHT'", ",", "'Right'", ")", ",", "self", "::", "ALIGN_JUSTIFY", "=>", "_t", "(", "__CLASS__", ".", "'.JUSTIFY'", ",", "'Justify'", ")", "]", ";", "}" ]
Answers an array of options for text alignment fields. @return array
[ "Answers", "an", "array", "of", "options", "for", "text", "alignment", "fields", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/AlignmentStyle.php#L188-L196
232,015
praxisnetau/silverware
src/Extensions/Style/AlignmentStyle.php
AlignmentStyle.getImageAlignmentOptions
public function getImageAlignmentOptions() { return [ self::ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'), self::ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ALIGN_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right') ]; }
php
public function getImageAlignmentOptions() { return [ self::ALIGN_LEFT => _t(__CLASS__ . '.LEFT', 'Left'), self::ALIGN_CENTER => _t(__CLASS__ . '.CENTER', 'Center'), self::ALIGN_RIGHT => _t(__CLASS__ . '.RIGHT', 'Right') ]; }
[ "public", "function", "getImageAlignmentOptions", "(", ")", "{", "return", "[", "self", "::", "ALIGN_LEFT", "=>", "_t", "(", "__CLASS__", ".", "'.LEFT'", ",", "'Left'", ")", ",", "self", "::", "ALIGN_CENTER", "=>", "_t", "(", "__CLASS__", ".", "'.CENTER'", ",", "'Center'", ")", ",", "self", "::", "ALIGN_RIGHT", "=>", "_t", "(", "__CLASS__", ".", "'.RIGHT'", ",", "'Right'", ")", "]", ";", "}" ]
Answers an array of options for image alignment fields. @return array
[ "Answers", "an", "array", "of", "options", "for", "image", "alignment", "fields", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/AlignmentStyle.php#L203-L210
232,016
praxisnetau/silverware
src/ORM/FieldType/DBViewports.php
DBViewports.allEqualTo
public function allEqualTo($value) { foreach ($this->getViewports() as $viewport) { if ($this->getField($viewport) != $value) { return false; } } return true; }
php
public function allEqualTo($value) { foreach ($this->getViewports() as $viewport) { if ($this->getField($viewport) != $value) { return false; } } return true; }
[ "public", "function", "allEqualTo", "(", "$", "value", ")", "{", "foreach", "(", "$", "this", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "if", "(", "$", "this", "->", "getField", "(", "$", "viewport", ")", "!=", "$", "value", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Answers true if every viewport field is equal to the given value. @param mixed $value Value to test. @return boolean
[ "Answers", "true", "if", "every", "viewport", "field", "is", "equal", "to", "the", "given", "value", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/ORM/FieldType/DBViewports.php#L89-L100
232,017
praxisnetau/silverware
src/ORM/FieldType/DBViewports.php
DBViewports.getViewportOptions
public function getViewportOptions() { $options = []; foreach ($this->getViewports() as $viewport) { $options[strtolower($viewport)] = $this->getViewportLabel($viewport); } return $options; }
php
public function getViewportOptions() { $options = []; foreach ($this->getViewports() as $viewport) { $options[strtolower($viewport)] = $this->getViewportLabel($viewport); } return $options; }
[ "public", "function", "getViewportOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "options", "[", "strtolower", "(", "$", "viewport", ")", "]", "=", "$", "this", "->", "getViewportLabel", "(", "$", "viewport", ")", ";", "}", "return", "$", "options", ";", "}" ]
Answers an array of viewport options for a form field. @return array
[ "Answers", "an", "array", "of", "viewport", "options", "for", "a", "form", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/ORM/FieldType/DBViewports.php#L152-L161
232,018
Sibilino/yii2-dygraphswidget
widget/DygraphsWidget.php
DygraphsWidget.getGraphScript
protected function getGraphScript() { $id = $this->htmlOptions['id']; $options = Json::encode($this->options); $data = $this->processDates(); return " var $this->jsVarName = new Dygraph( document.getElementById('$id'), $data, $options ); "; }
php
protected function getGraphScript() { $id = $this->htmlOptions['id']; $options = Json::encode($this->options); $data = $this->processDates(); return " var $this->jsVarName = new Dygraph( document.getElementById('$id'), $data, $options ); "; }
[ "protected", "function", "getGraphScript", "(", ")", "{", "$", "id", "=", "$", "this", "->", "htmlOptions", "[", "'id'", "]", ";", "$", "options", "=", "Json", "::", "encode", "(", "$", "this", "->", "options", ")", ";", "$", "data", "=", "$", "this", "->", "processDates", "(", ")", ";", "return", "\"\n var $this->jsVarName = new Dygraph(\n document.getElementById('$id'),\n $data,\n $options\n );\n \"", ";", "}" ]
Generates the JavaScript code that will initialize the Dygraphs object. @return string @since 1.0.0
[ "Generates", "the", "JavaScript", "code", "that", "will", "initialize", "the", "Dygraphs", "object", "." ]
f6d1da43c377eecf573b897751caf15444a248a8
https://github.com/Sibilino/yii2-dygraphswidget/blob/f6d1da43c377eecf573b897751caf15444a248a8/widget/DygraphsWidget.php#L153-L164
232,019
Sibilino/yii2-dygraphswidget
widget/DygraphsWidget.php
DygraphsWidget.processDates
protected function processDates() { if (is_array($this->data)) { foreach ($this->data as &$row) { if ($row[0] instanceof \DateTimeInterface) $row[0] = new JsExpression("new Date(".($row[0]->getTimestamp()*1000).")"); elseif ($this->xIsDate) $row[0] = new JsExpression("new Date('$row[0]')"); } return Json::encode($this->data, JSON_NUMERIC_CHECK); } return Json::encode($this->data); }
php
protected function processDates() { if (is_array($this->data)) { foreach ($this->data as &$row) { if ($row[0] instanceof \DateTimeInterface) $row[0] = new JsExpression("new Date(".($row[0]->getTimestamp()*1000).")"); elseif ($this->xIsDate) $row[0] = new JsExpression("new Date('$row[0]')"); } return Json::encode($this->data, JSON_NUMERIC_CHECK); } return Json::encode($this->data); }
[ "protected", "function", "processDates", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "data", ")", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "&", "$", "row", ")", "{", "if", "(", "$", "row", "[", "0", "]", "instanceof", "\\", "DateTimeInterface", ")", "$", "row", "[", "0", "]", "=", "new", "JsExpression", "(", "\"new Date(\"", ".", "(", "$", "row", "[", "0", "]", "->", "getTimestamp", "(", ")", "*", "1000", ")", ".", "\")\"", ")", ";", "elseif", "(", "$", "this", "->", "xIsDate", ")", "$", "row", "[", "0", "]", "=", "new", "JsExpression", "(", "\"new Date('$row[0]')\"", ")", ";", "}", "return", "Json", "::", "encode", "(", "$", "this", "->", "data", ",", "JSON_NUMERIC_CHECK", ")", ";", "}", "return", "Json", "::", "encode", "(", "$", "this", "->", "data", ")", ";", "}" ]
Encodes the current data into the proper JS variable. @return Ambigous <string, mixed>
[ "Encodes", "the", "current", "data", "into", "the", "proper", "JS", "variable", "." ]
f6d1da43c377eecf573b897751caf15444a248a8
https://github.com/Sibilino/yii2-dygraphswidget/blob/f6d1da43c377eecf573b897751caf15444a248a8/widget/DygraphsWidget.php#L195-L206
232,020
i-am-tom/schemer
src/Validator.php
Validator.allow
public static function allow(array $whitelist) : Validator\Any { return self::any()->should( function ($value) use ($whitelist) : bool { foreach ($whitelist as $candidate) { if ($candidate === $value) { return true; } } return false; }, 'not in the whitelist' ); }
php
public static function allow(array $whitelist) : Validator\Any { return self::any()->should( function ($value) use ($whitelist) : bool { foreach ($whitelist as $candidate) { if ($candidate === $value) { return true; } } return false; }, 'not in the whitelist' ); }
[ "public", "static", "function", "allow", "(", "array", "$", "whitelist", ")", ":", "Validator", "\\", "Any", "{", "return", "self", "::", "any", "(", ")", "->", "should", "(", "function", "(", "$", "value", ")", "use", "(", "$", "whitelist", ")", ":", "bool", "{", "foreach", "(", "$", "whitelist", "as", "$", "candidate", ")", "{", "if", "(", "$", "candidate", "===", "$", "value", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", ",", "'not in the whitelist'", ")", ";", "}" ]
The value must be on a given whitelist. @param array $whitelist The allowed values. @return Schemer\Validator\Any
[ "The", "value", "must", "be", "on", "a", "given", "whitelist", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator.php#L26-L40
232,021
i-am-tom/schemer
src/Validator.php
Validator.instanceOf
public static function instanceOf(string $comparison) : Validator\Any { return self::any() ->must('is_object', 'not an object') ->must( function ($value) use ($comparison) : bool { return $value instanceof $comparison; }, "not an instance of $comparison" ); }
php
public static function instanceOf(string $comparison) : Validator\Any { return self::any() ->must('is_object', 'not an object') ->must( function ($value) use ($comparison) : bool { return $value instanceof $comparison; }, "not an instance of $comparison" ); }
[ "public", "static", "function", "instanceOf", "(", "string", "$", "comparison", ")", ":", "Validator", "\\", "Any", "{", "return", "self", "::", "any", "(", ")", "->", "must", "(", "'is_object'", ",", "'not an object'", ")", "->", "must", "(", "function", "(", "$", "value", ")", "use", "(", "$", "comparison", ")", ":", "bool", "{", "return", "$", "value", "instanceof", "$", "comparison", ";", "}", ",", "\"not an instance of $comparison\"", ")", ";", "}" ]
The value must be an instance of the given class. @param string $comparison @return Schemer\Validator\Any
[ "The", "value", "must", "be", "an", "instance", "of", "the", "given", "class", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator.php#L77-L87
232,022
i-am-tom/schemer
src/Validator.php
Validator.oneOf
public static function oneOf(array $validators) : Validator\Any { return self::any()->should( function ($value) use ($validators) : bool { foreach ($validators as $validator) { if (!$validator->validate($value)->isError()) { return true; } } return false; }, 'matches none of the options' ); }
php
public static function oneOf(array $validators) : Validator\Any { return self::any()->should( function ($value) use ($validators) : bool { foreach ($validators as $validator) { if (!$validator->validate($value)->isError()) { return true; } } return false; }, 'matches none of the options' ); }
[ "public", "static", "function", "oneOf", "(", "array", "$", "validators", ")", ":", "Validator", "\\", "Any", "{", "return", "self", "::", "any", "(", ")", "->", "should", "(", "function", "(", "$", "value", ")", "use", "(", "$", "validators", ")", ":", "bool", "{", "foreach", "(", "$", "validators", "as", "$", "validator", ")", "{", "if", "(", "!", "$", "validator", "->", "validate", "(", "$", "value", ")", "->", "isError", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", ",", "'matches none of the options'", ")", ";", "}" ]
The value must match one of a given set of validators. @param array $validators The possible validators to use. @return Schemer\Validator\Any
[ "The", "value", "must", "match", "one", "of", "a", "given", "set", "of", "validators", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator.php#L103-L117
232,023
i-am-tom/schemer
src/Validator.php
Validator.reject
public static function reject(array $blacklist) : Validator\Any { return self::any()->should( function ($value) use ($blacklist) : bool { foreach ($blacklist as $candidate) { if ($candidate === $value) { return false; } } return true; }, 'in the blacklist' ); }
php
public static function reject(array $blacklist) : Validator\Any { return self::any()->should( function ($value) use ($blacklist) : bool { foreach ($blacklist as $candidate) { if ($candidate === $value) { return false; } } return true; }, 'in the blacklist' ); }
[ "public", "static", "function", "reject", "(", "array", "$", "blacklist", ")", ":", "Validator", "\\", "Any", "{", "return", "self", "::", "any", "(", ")", "->", "should", "(", "function", "(", "$", "value", ")", "use", "(", "$", "blacklist", ")", ":", "bool", "{", "foreach", "(", "$", "blacklist", "as", "$", "candidate", ")", "{", "if", "(", "$", "candidate", "===", "$", "value", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", ",", "'in the blacklist'", ")", ";", "}" ]
The value must not be on a given blacklist. @param array $blacklist The forbidden values. @return Schemer\Validator\Any
[ "The", "value", "must", "not", "be", "on", "a", "given", "blacklist", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator.php#L133-L147
232,024
kuzzleio/sdk-php
src/Security/Profile.php
Profile.setPolicies
public function setPolicies(array $policies) { $this->policies = []; foreach ($policies as $policy) { $this->policies[] = $this->policyFactory($policy); } return $this; }
php
public function setPolicies(array $policies) { $this->policies = []; foreach ($policies as $policy) { $this->policies[] = $this->policyFactory($policy); } return $this; }
[ "public", "function", "setPolicies", "(", "array", "$", "policies", ")", "{", "$", "this", "->", "policies", "=", "[", "]", ";", "foreach", "(", "$", "policies", "as", "$", "policy", ")", "{", "$", "this", "->", "policies", "[", "]", "=", "$", "this", "->", "policyFactory", "(", "$", "policy", ")", ";", "}", "return", "$", "this", ";", "}" ]
Replaces the roles associated to the profile. @param array[]|Role[] $policies List of policies descriptions or Kuzzle\Security\Role instances corresponding to the new associated roles @return Profile
[ "Replaces", "the", "roles", "associated", "to", "the", "profile", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Profile.php#L69-L78
232,025
suncat2000/AdminPageBoardBundle
Routing/RouteConfig.php
RouteConfig.getPageName
public function getPageName($routeName) { if (isset($this->routePageMap[$routeName])) { return $this->routePageMap[$routeName]; } throw new NotFoundRouteNameException(sprintf('Not found route with name \'%s\'', $routeName)); }
php
public function getPageName($routeName) { if (isset($this->routePageMap[$routeName])) { return $this->routePageMap[$routeName]; } throw new NotFoundRouteNameException(sprintf('Not found route with name \'%s\'', $routeName)); }
[ "public", "function", "getPageName", "(", "$", "routeName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "routePageMap", "[", "$", "routeName", "]", ")", ")", "{", "return", "$", "this", "->", "routePageMap", "[", "$", "routeName", "]", ";", "}", "throw", "new", "NotFoundRouteNameException", "(", "sprintf", "(", "'Not found route with name \\'%s\\''", ",", "$", "routeName", ")", ")", ";", "}" ]
Get page board name by route name @param $routeName @return null|string
[ "Get", "page", "board", "name", "by", "route", "name" ]
fc1bce24f7edaead6057d05910dc133259049557
https://github.com/suncat2000/AdminPageBoardBundle/blob/fc1bce24f7edaead6057d05910dc133259049557/Routing/RouteConfig.php#L54-L61
232,026
praxisnetau/silverware
src/Extensions/Admin/CropPriorityFileFormExtension.php
CropPriorityFileFormExtension.updateFormFields
public function updateFormFields(FieldList $fields, Controller $controller, $name, $context) { // Check Record Type: if ($context['Record'] instanceof Image) { // Update Field Objects: $fields->insertAfter( 'ParentID', DropdownField::create( 'CropPriority', _t(__CLASS__ . '.CROPPRIORITY', 'Crop priority'), $this->getCropPriorityOptions() ) ); } }
php
public function updateFormFields(FieldList $fields, Controller $controller, $name, $context) { // Check Record Type: if ($context['Record'] instanceof Image) { // Update Field Objects: $fields->insertAfter( 'ParentID', DropdownField::create( 'CropPriority', _t(__CLASS__ . '.CROPPRIORITY', 'Crop priority'), $this->getCropPriorityOptions() ) ); } }
[ "public", "function", "updateFormFields", "(", "FieldList", "$", "fields", ",", "Controller", "$", "controller", ",", "$", "name", ",", "$", "context", ")", "{", "// Check Record Type:", "if", "(", "$", "context", "[", "'Record'", "]", "instanceof", "Image", ")", "{", "// Update Field Objects:", "$", "fields", "->", "insertAfter", "(", "'ParentID'", ",", "DropdownField", "::", "create", "(", "'CropPriority'", ",", "_t", "(", "__CLASS__", ".", "'.CROPPRIORITY'", ",", "'Crop priority'", ")", ",", "$", "this", "->", "getCropPriorityOptions", "(", ")", ")", ")", ";", "}", "}" ]
Updates the form fields of the extended object. @param FieldList $fields @param Controller $controller @param string $name @param array $context @return void
[ "Updates", "the", "form", "fields", "of", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Admin/CropPriorityFileFormExtension.php#L47-L65
232,027
praxisnetau/silverware
src/Extensions/Admin/CropPriorityFileFormExtension.php
CropPriorityFileFormExtension.getCropPriorityOptions
public function getCropPriorityOptions() { return [ 'center' => _t(__CLASS__ . '.CENTER', 'Center'), 'top' => _t(__CLASS__ . '.TOP', 'Top'), 'left' => _t(__CLASS__ . '.LEFT', 'Left'), 'right' => _t(__CLASS__ . '.RIGHT', 'Right'), 'bottom' => _t(__CLASS__ . '.BOTTOM', 'Bottom') ]; }
php
public function getCropPriorityOptions() { return [ 'center' => _t(__CLASS__ . '.CENTER', 'Center'), 'top' => _t(__CLASS__ . '.TOP', 'Top'), 'left' => _t(__CLASS__ . '.LEFT', 'Left'), 'right' => _t(__CLASS__ . '.RIGHT', 'Right'), 'bottom' => _t(__CLASS__ . '.BOTTOM', 'Bottom') ]; }
[ "public", "function", "getCropPriorityOptions", "(", ")", "{", "return", "[", "'center'", "=>", "_t", "(", "__CLASS__", ".", "'.CENTER'", ",", "'Center'", ")", ",", "'top'", "=>", "_t", "(", "__CLASS__", ".", "'.TOP'", ",", "'Top'", ")", ",", "'left'", "=>", "_t", "(", "__CLASS__", ".", "'.LEFT'", ",", "'Left'", ")", ",", "'right'", "=>", "_t", "(", "__CLASS__", ".", "'.RIGHT'", ",", "'Right'", ")", ",", "'bottom'", "=>", "_t", "(", "__CLASS__", ".", "'.BOTTOM'", ",", "'Bottom'", ")", "]", ";", "}" ]
Answers an array of options for the crop priority field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "crop", "priority", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Admin/CropPriorityFileFormExtension.php#L72-L81
232,028
wallstreetio/ontraport
src/Fluent.php
Fluent.get
public function get($attribute = null, $default = null) { if (is_null($attribute)) { return $this->attributes; } if (array_key_exists($attribute, $this->attributes)) { return $this->attributes[$attribute]; } return $default; }
php
public function get($attribute = null, $default = null) { if (is_null($attribute)) { return $this->attributes; } if (array_key_exists($attribute, $this->attributes)) { return $this->attributes[$attribute]; } return $default; }
[ "public", "function", "get", "(", "$", "attribute", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "attribute", ")", ")", "{", "return", "$", "this", "->", "attributes", ";", "}", "if", "(", "array_key_exists", "(", "$", "attribute", ",", "$", "this", "->", "attributes", ")", ")", "{", "return", "$", "this", "->", "attributes", "[", "$", "attribute", "]", ";", "}", "return", "$", "default", ";", "}" ]
Returns an attribute of the resource. @param mixed $attribute @param mixed $default @return mixed
[ "Returns", "an", "attribute", "of", "the", "resource", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Fluent.php#L75-L86
232,029
terra-ops/terra-cli
src/terra/Factory.php
Factory.createTerra
private function createTerra() { $terra = new Terra(); // Get config from env variables or files. if ($config_env = getenv('TERRA')) { $config_env = Yaml::parse($config_env); $config = new Config($config_env); } else { $fs = new Filesystem(); $user_config = array(); $user_config_file = getenv('HOME').'/.terra/terra'; if ($fs->exists($user_config_file)) { $user_config = Yaml::parse($user_config_file); } $project_config = array(); $process = new Process('git rev-parse --show-toplevel'); $process->run(); if ($process->isSuccessful()) { $project_config_file = trim($process->getOutput()).'/terra.yml'; if ($fs->exists($project_config_file)) { $project_config = Yaml::parse($project_config_file); } } $config = new Config($user_config, $project_config); } $terra->setConfig($config); return $terra; }
php
private function createTerra() { $terra = new Terra(); // Get config from env variables or files. if ($config_env = getenv('TERRA')) { $config_env = Yaml::parse($config_env); $config = new Config($config_env); } else { $fs = new Filesystem(); $user_config = array(); $user_config_file = getenv('HOME').'/.terra/terra'; if ($fs->exists($user_config_file)) { $user_config = Yaml::parse($user_config_file); } $project_config = array(); $process = new Process('git rev-parse --show-toplevel'); $process->run(); if ($process->isSuccessful()) { $project_config_file = trim($process->getOutput()).'/terra.yml'; if ($fs->exists($project_config_file)) { $project_config = Yaml::parse($project_config_file); } } $config = new Config($user_config, $project_config); } $terra->setConfig($config); return $terra; }
[ "private", "function", "createTerra", "(", ")", "{", "$", "terra", "=", "new", "Terra", "(", ")", ";", "// Get config from env variables or files.", "if", "(", "$", "config_env", "=", "getenv", "(", "'TERRA'", ")", ")", "{", "$", "config_env", "=", "Yaml", "::", "parse", "(", "$", "config_env", ")", ";", "$", "config", "=", "new", "Config", "(", "$", "config_env", ")", ";", "}", "else", "{", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "$", "user_config", "=", "array", "(", ")", ";", "$", "user_config_file", "=", "getenv", "(", "'HOME'", ")", ".", "'/.terra/terra'", ";", "if", "(", "$", "fs", "->", "exists", "(", "$", "user_config_file", ")", ")", "{", "$", "user_config", "=", "Yaml", "::", "parse", "(", "$", "user_config_file", ")", ";", "}", "$", "project_config", "=", "array", "(", ")", ";", "$", "process", "=", "new", "Process", "(", "'git rev-parse --show-toplevel'", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "$", "project_config_file", "=", "trim", "(", "$", "process", "->", "getOutput", "(", ")", ")", ".", "'/terra.yml'", ";", "if", "(", "$", "fs", "->", "exists", "(", "$", "project_config_file", ")", ")", "{", "$", "project_config", "=", "Yaml", "::", "parse", "(", "$", "project_config_file", ")", ";", "}", "}", "$", "config", "=", "new", "Config", "(", "$", "user_config", ",", "$", "project_config", ")", ";", "}", "$", "terra", "->", "setConfig", "(", "$", "config", ")", ";", "return", "$", "terra", ";", "}" ]
Creates a Terra instance. @return Terra A configured Flo instance.
[ "Creates", "a", "Terra", "instance", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Factory.php#L20-L51
232,030
malios/php-to-ascii-table
src/Builder.php
Builder.addRow
public function addRow($rowArrayOrObject) { if (is_array($rowArrayOrObject)) { $rowArray = $rowArrayOrObject; } else if ($rowArrayOrObject instanceof \JsonSerializable) { $rowArray = $rowArrayOrObject->jsonSerialize(); } else { throw new BuilderException(sprintf( 'Row must be either an array or JsonSerializable, %s given instead', gettype($rowArrayOrObject) )); } $row = new Row(); foreach ($rowArray as $columnName => $value) { $cell = new Cell($columnName, $value); $row->addCell($cell); } $this->table->addRow($row); }
php
public function addRow($rowArrayOrObject) { if (is_array($rowArrayOrObject)) { $rowArray = $rowArrayOrObject; } else if ($rowArrayOrObject instanceof \JsonSerializable) { $rowArray = $rowArrayOrObject->jsonSerialize(); } else { throw new BuilderException(sprintf( 'Row must be either an array or JsonSerializable, %s given instead', gettype($rowArrayOrObject) )); } $row = new Row(); foreach ($rowArray as $columnName => $value) { $cell = new Cell($columnName, $value); $row->addCell($cell); } $this->table->addRow($row); }
[ "public", "function", "addRow", "(", "$", "rowArrayOrObject", ")", "{", "if", "(", "is_array", "(", "$", "rowArrayOrObject", ")", ")", "{", "$", "rowArray", "=", "$", "rowArrayOrObject", ";", "}", "else", "if", "(", "$", "rowArrayOrObject", "instanceof", "\\", "JsonSerializable", ")", "{", "$", "rowArray", "=", "$", "rowArrayOrObject", "->", "jsonSerialize", "(", ")", ";", "}", "else", "{", "throw", "new", "BuilderException", "(", "sprintf", "(", "'Row must be either an array or JsonSerializable, %s given instead'", ",", "gettype", "(", "$", "rowArrayOrObject", ")", ")", ")", ";", "}", "$", "row", "=", "new", "Row", "(", ")", ";", "foreach", "(", "$", "rowArray", "as", "$", "columnName", "=>", "$", "value", ")", "{", "$", "cell", "=", "new", "Cell", "(", "$", "columnName", ",", "$", "value", ")", ";", "$", "row", "->", "addCell", "(", "$", "cell", ")", ";", "}", "$", "this", "->", "table", "->", "addRow", "(", "$", "row", ")", ";", "}" ]
Add single row. The value passed should be either an array or an JsonSerializable object @param array|\JsonSerializable $rowArrayOrObject @throws BuilderException
[ "Add", "single", "row", ".", "The", "value", "passed", "should", "be", "either", "an", "array", "or", "an", "JsonSerializable", "object" ]
cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65
https://github.com/malios/php-to-ascii-table/blob/cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65/src/Builder.php#L57-L77
232,031
malios/php-to-ascii-table
src/Builder.php
Builder.renderTable
public function renderTable() : string { if ($this->table->isEmpty()) throw new BuilderException('Cannot render empty table'); $visibleColumns = $this->table->getVisibleColumns(); // border for header and footer $borderParts = array_map(function ($columnName) { $width = $this->table->getColumnWidth($columnName); return str_repeat(self::CHAR_LINE_SEPARATOR, ($width + 2)); }, $visibleColumns->toArray()); $border = self::CHAR_CORNER_SEPARATOR . join(self::CHAR_CORNER_SEPARATOR, $borderParts) . self::CHAR_CORNER_SEPARATOR; $headerCells = array_map(function ($columnName) { return new Cell($columnName, $columnName); }, $visibleColumns->toArray()); $headerRow = new Row(); $headerRow->addCells(...$headerCells); $header = $this->renderRow($headerRow, $visibleColumns); $body = ''; $rows = $this->table->getRows(); $visibleColumns = $this->table->getVisibleColumns(); foreach ($rows as $row) { $currentLine = $this->renderRow($row, $visibleColumns); $body .= $currentLine . PHP_EOL; } $tableAsString = $border . PHP_EOL . $header . PHP_EOL . $border . PHP_EOL . $body . $border; return $tableAsString; }
php
public function renderTable() : string { if ($this->table->isEmpty()) throw new BuilderException('Cannot render empty table'); $visibleColumns = $this->table->getVisibleColumns(); // border for header and footer $borderParts = array_map(function ($columnName) { $width = $this->table->getColumnWidth($columnName); return str_repeat(self::CHAR_LINE_SEPARATOR, ($width + 2)); }, $visibleColumns->toArray()); $border = self::CHAR_CORNER_SEPARATOR . join(self::CHAR_CORNER_SEPARATOR, $borderParts) . self::CHAR_CORNER_SEPARATOR; $headerCells = array_map(function ($columnName) { return new Cell($columnName, $columnName); }, $visibleColumns->toArray()); $headerRow = new Row(); $headerRow->addCells(...$headerCells); $header = $this->renderRow($headerRow, $visibleColumns); $body = ''; $rows = $this->table->getRows(); $visibleColumns = $this->table->getVisibleColumns(); foreach ($rows as $row) { $currentLine = $this->renderRow($row, $visibleColumns); $body .= $currentLine . PHP_EOL; } $tableAsString = $border . PHP_EOL . $header . PHP_EOL . $border . PHP_EOL . $body . $border; return $tableAsString; }
[ "public", "function", "renderTable", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "table", "->", "isEmpty", "(", ")", ")", "throw", "new", "BuilderException", "(", "'Cannot render empty table'", ")", ";", "$", "visibleColumns", "=", "$", "this", "->", "table", "->", "getVisibleColumns", "(", ")", ";", "// border for header and footer", "$", "borderParts", "=", "array_map", "(", "function", "(", "$", "columnName", ")", "{", "$", "width", "=", "$", "this", "->", "table", "->", "getColumnWidth", "(", "$", "columnName", ")", ";", "return", "str_repeat", "(", "self", "::", "CHAR_LINE_SEPARATOR", ",", "(", "$", "width", "+", "2", ")", ")", ";", "}", ",", "$", "visibleColumns", "->", "toArray", "(", ")", ")", ";", "$", "border", "=", "self", "::", "CHAR_CORNER_SEPARATOR", ".", "join", "(", "self", "::", "CHAR_CORNER_SEPARATOR", ",", "$", "borderParts", ")", ".", "self", "::", "CHAR_CORNER_SEPARATOR", ";", "$", "headerCells", "=", "array_map", "(", "function", "(", "$", "columnName", ")", "{", "return", "new", "Cell", "(", "$", "columnName", ",", "$", "columnName", ")", ";", "}", ",", "$", "visibleColumns", "->", "toArray", "(", ")", ")", ";", "$", "headerRow", "=", "new", "Row", "(", ")", ";", "$", "headerRow", "->", "addCells", "(", "...", "$", "headerCells", ")", ";", "$", "header", "=", "$", "this", "->", "renderRow", "(", "$", "headerRow", ",", "$", "visibleColumns", ")", ";", "$", "body", "=", "''", ";", "$", "rows", "=", "$", "this", "->", "table", "->", "getRows", "(", ")", ";", "$", "visibleColumns", "=", "$", "this", "->", "table", "->", "getVisibleColumns", "(", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "currentLine", "=", "$", "this", "->", "renderRow", "(", "$", "row", ",", "$", "visibleColumns", ")", ";", "$", "body", ".=", "$", "currentLine", ".", "PHP_EOL", ";", "}", "$", "tableAsString", "=", "$", "border", ".", "PHP_EOL", ".", "$", "header", ".", "PHP_EOL", ".", "$", "border", ".", "PHP_EOL", ".", "$", "body", ".", "$", "border", ";", "return", "$", "tableAsString", ";", "}" ]
Render table and return result string @return string @throws BuilderException
[ "Render", "table", "and", "return", "result", "string" ]
cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65
https://github.com/malios/php-to-ascii-table/blob/cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65/src/Builder.php#L110-L144
232,032
malios/php-to-ascii-table
src/Builder.php
Builder.renderRow
private function renderRow(RowInterface $row, Collection $columnNames) { $line = self::CHAR_CELL_SEPARATOR; // render cells of the row foreach ($columnNames as $columnName) { $colWidth = $this->table->getColumnWidth($columnName); if ($row->hasCell($columnName)) { $cell = $row->getCell($columnName); $currentCell = $this->renderCell($cell, $colWidth); } else { $currentCell = $this->renderCell(new Cell($columnName, ''), $colWidth); } $line .= $currentCell . self::CHAR_CELL_SEPARATOR; } return $line; }
php
private function renderRow(RowInterface $row, Collection $columnNames) { $line = self::CHAR_CELL_SEPARATOR; // render cells of the row foreach ($columnNames as $columnName) { $colWidth = $this->table->getColumnWidth($columnName); if ($row->hasCell($columnName)) { $cell = $row->getCell($columnName); $currentCell = $this->renderCell($cell, $colWidth); } else { $currentCell = $this->renderCell(new Cell($columnName, ''), $colWidth); } $line .= $currentCell . self::CHAR_CELL_SEPARATOR; } return $line; }
[ "private", "function", "renderRow", "(", "RowInterface", "$", "row", ",", "Collection", "$", "columnNames", ")", "{", "$", "line", "=", "self", "::", "CHAR_CELL_SEPARATOR", ";", "// render cells of the row", "foreach", "(", "$", "columnNames", "as", "$", "columnName", ")", "{", "$", "colWidth", "=", "$", "this", "->", "table", "->", "getColumnWidth", "(", "$", "columnName", ")", ";", "if", "(", "$", "row", "->", "hasCell", "(", "$", "columnName", ")", ")", "{", "$", "cell", "=", "$", "row", "->", "getCell", "(", "$", "columnName", ")", ";", "$", "currentCell", "=", "$", "this", "->", "renderCell", "(", "$", "cell", ",", "$", "colWidth", ")", ";", "}", "else", "{", "$", "currentCell", "=", "$", "this", "->", "renderCell", "(", "new", "Cell", "(", "$", "columnName", ",", "''", ")", ",", "$", "colWidth", ")", ";", "}", "$", "line", ".=", "$", "currentCell", ".", "self", "::", "CHAR_CELL_SEPARATOR", ";", "}", "return", "$", "line", ";", "}" ]
Render single row and return string @param RowInterface $row @param Collection $columnNames @return string
[ "Render", "single", "row", "and", "return", "string" ]
cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65
https://github.com/malios/php-to-ascii-table/blob/cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65/src/Builder.php#L153-L171
232,033
malios/php-to-ascii-table
src/Builder.php
Builder.renderCell
private function renderCell(CellInterface $cell, int $colWidth) : string { $content = self::CHAR_CELL_PADDING . $cell->getValue() . str_repeat(self::CHAR_CELL_PADDING, ($colWidth - $cell->getWidth() + 1)); return $content; }
php
private function renderCell(CellInterface $cell, int $colWidth) : string { $content = self::CHAR_CELL_PADDING . $cell->getValue() . str_repeat(self::CHAR_CELL_PADDING, ($colWidth - $cell->getWidth() + 1)); return $content; }
[ "private", "function", "renderCell", "(", "CellInterface", "$", "cell", ",", "int", "$", "colWidth", ")", ":", "string", "{", "$", "content", "=", "self", "::", "CHAR_CELL_PADDING", ".", "$", "cell", "->", "getValue", "(", ")", ".", "str_repeat", "(", "self", "::", "CHAR_CELL_PADDING", ",", "(", "$", "colWidth", "-", "$", "cell", "->", "getWidth", "(", ")", "+", "1", ")", ")", ";", "return", "$", "content", ";", "}" ]
Render cell content with left and right padding depending on the column width @param CellInterface $cell @param int $colWidth @return string
[ "Render", "cell", "content", "with", "left", "and", "right", "padding", "depending", "on", "the", "column", "width" ]
cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65
https://github.com/malios/php-to-ascii-table/blob/cdabb1c694dffd2dbc3944fcaa62f4a1bb2f5e65/src/Builder.php#L180-L186
232,034
uniqby/yii2-phone-formatter
i18n/Formatter.php
Formatter.asPhoneE164
public static function asPhoneE164($phone, $defaultRegionAlpha2) { $phoneUtil = PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneUtil->parseAndKeepRawInput($phone, $defaultRegionAlpha2); return $phoneUtil->format($phoneNumber, PhoneNumberFormat::E164); } catch (NumberParseException $e) { return $phone; } }
php
public static function asPhoneE164($phone, $defaultRegionAlpha2) { $phoneUtil = PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneUtil->parseAndKeepRawInput($phone, $defaultRegionAlpha2); return $phoneUtil->format($phoneNumber, PhoneNumberFormat::E164); } catch (NumberParseException $e) { return $phone; } }
[ "public", "static", "function", "asPhoneE164", "(", "$", "phone", ",", "$", "defaultRegionAlpha2", ")", "{", "$", "phoneUtil", "=", "PhoneNumberUtil", "::", "getInstance", "(", ")", ";", "try", "{", "$", "phoneNumber", "=", "$", "phoneUtil", "->", "parseAndKeepRawInput", "(", "$", "phone", ",", "$", "defaultRegionAlpha2", ")", ";", "return", "$", "phoneUtil", "->", "format", "(", "$", "phoneNumber", ",", "PhoneNumberFormat", "::", "E164", ")", ";", "}", "catch", "(", "NumberParseException", "$", "e", ")", "{", "return", "$", "phone", ";", "}", "}" ]
Converts phone to E164 format @param string $phone @param $defaultRegionAlpha2 @return String
[ "Converts", "phone", "to", "E164", "format" ]
c374df3923015dcb8ab9f21ca153db076943adec
https://github.com/uniqby/yii2-phone-formatter/blob/c374df3923015dcb8ab9f21ca153db076943adec/i18n/Formatter.php#L27-L37
232,035
uniqby/yii2-phone-formatter
i18n/Formatter.php
Formatter.asPhoneInt
public static function asPhoneInt($phone, $defaultRegionAlpha2) { $phoneUtil = PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneUtil->parseAndKeepRawInput($phone, $defaultRegionAlpha2); return $phoneUtil->format($phoneNumber, PhoneNumberFormat::INTERNATIONAL); } catch (NumberParseException $e) { return $phone; } }
php
public static function asPhoneInt($phone, $defaultRegionAlpha2) { $phoneUtil = PhoneNumberUtil::getInstance(); try { $phoneNumber = $phoneUtil->parseAndKeepRawInput($phone, $defaultRegionAlpha2); return $phoneUtil->format($phoneNumber, PhoneNumberFormat::INTERNATIONAL); } catch (NumberParseException $e) { return $phone; } }
[ "public", "static", "function", "asPhoneInt", "(", "$", "phone", ",", "$", "defaultRegionAlpha2", ")", "{", "$", "phoneUtil", "=", "PhoneNumberUtil", "::", "getInstance", "(", ")", ";", "try", "{", "$", "phoneNumber", "=", "$", "phoneUtil", "->", "parseAndKeepRawInput", "(", "$", "phone", ",", "$", "defaultRegionAlpha2", ")", ";", "return", "$", "phoneUtil", "->", "format", "(", "$", "phoneNumber", ",", "PhoneNumberFormat", "::", "INTERNATIONAL", ")", ";", "}", "catch", "(", "NumberParseException", "$", "e", ")", "{", "return", "$", "phone", ";", "}", "}" ]
Converts phone number to international format @param string $phone @param $defaultRegionAlpha2 @return String
[ "Converts", "phone", "number", "to", "international", "format" ]
c374df3923015dcb8ab9f21ca153db076943adec
https://github.com/uniqby/yii2-phone-formatter/blob/c374df3923015dcb8ab9f21ca153db076943adec/i18n/Formatter.php#L46-L56
232,036
praxisnetau/silverware
src/Crumbs/Breadcrumb.php
Breadcrumb.setItem
public function setItem($link, $title) { $this->setLink($link); $this->setTitle($title); return $this; }
php
public function setItem($link, $title) { $this->setLink($link); $this->setTitle($title); return $this; }
[ "public", "function", "setItem", "(", "$", "link", ",", "$", "title", ")", "{", "$", "this", "->", "setLink", "(", "$", "link", ")", ";", "$", "this", "->", "setTitle", "(", "$", "title", ")", ";", "return", "$", "this", ";", "}" ]
Defines the link and title of the receiver. @param string $link @param string $title @return $this
[ "Defines", "the", "link", "and", "title", "of", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Crumbs/Breadcrumb.php#L102-L108
232,037
praxisnetau/silverware
src/Components/DeveloperComponent.php
DeveloperComponent.getDeveloperLink
public function getDeveloperLink() { if ($this->DeveloperURL) { return $this->dbObject('DeveloperURL')->URL(); } if ($this->DeveloperPageID) { return $this->DeveloperPage()->Link(); } }
php
public function getDeveloperLink() { if ($this->DeveloperURL) { return $this->dbObject('DeveloperURL')->URL(); } if ($this->DeveloperPageID) { return $this->DeveloperPage()->Link(); } }
[ "public", "function", "getDeveloperLink", "(", ")", "{", "if", "(", "$", "this", "->", "DeveloperURL", ")", "{", "return", "$", "this", "->", "dbObject", "(", "'DeveloperURL'", ")", "->", "URL", "(", ")", ";", "}", "if", "(", "$", "this", "->", "DeveloperPageID", ")", "{", "return", "$", "this", "->", "DeveloperPage", "(", ")", "->", "Link", "(", ")", ";", "}", "}" ]
Answers the link to the developer page. @return string
[ "Answers", "the", "link", "to", "the", "developer", "page", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/DeveloperComponent.php#L317-L326
232,038
praxisnetau/silverware
src/Components/DeveloperComponent.php
DeveloperComponent.getDeveloperNameLink
public function getDeveloperNameLink() { if ($this->hasDeveloperLink() && !$this->LinkDisabled) { $target = $this->OpenLinkInNewTab ? ' target="_blank"' : ''; return sprintf( '<a href="%s" rel="nofollow"%s>%s</a>', $this->DeveloperLink, $target, $this->DeveloperName ); } return $this->DeveloperName; }
php
public function getDeveloperNameLink() { if ($this->hasDeveloperLink() && !$this->LinkDisabled) { $target = $this->OpenLinkInNewTab ? ' target="_blank"' : ''; return sprintf( '<a href="%s" rel="nofollow"%s>%s</a>', $this->DeveloperLink, $target, $this->DeveloperName ); } return $this->DeveloperName; }
[ "public", "function", "getDeveloperNameLink", "(", ")", "{", "if", "(", "$", "this", "->", "hasDeveloperLink", "(", ")", "&&", "!", "$", "this", "->", "LinkDisabled", ")", "{", "$", "target", "=", "$", "this", "->", "OpenLinkInNewTab", "?", "' target=\"_blank\"'", ":", "''", ";", "return", "sprintf", "(", "'<a href=\"%s\" rel=\"nofollow\"%s>%s</a>'", ",", "$", "this", "->", "DeveloperLink", ",", "$", "target", ",", "$", "this", "->", "DeveloperName", ")", ";", "}", "return", "$", "this", "->", "DeveloperName", ";", "}" ]
Answers the developer name link for the template. @return string
[ "Answers", "the", "developer", "name", "link", "for", "the", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/DeveloperComponent.php#L343-L359
232,039
praxisnetau/silverware
src/Extensions/ConfigExtension.php
ConfigExtension.getAllBodyAttributes
public function getAllBodyAttributes() { $attributes = ['class' => $this->getCurrentPageAncestry()]; foreach ($this->owner->getExtensionInstances() as $class => $extension) { if ($extension instanceof ConfigExtension) { $attributes = array_merge($attributes, $extension->getBodyAttributes()); } } $this->owner->extend('updateBodyAttributes', $attributes); return $attributes; }
php
public function getAllBodyAttributes() { $attributes = ['class' => $this->getCurrentPageAncestry()]; foreach ($this->owner->getExtensionInstances() as $class => $extension) { if ($extension instanceof ConfigExtension) { $attributes = array_merge($attributes, $extension->getBodyAttributes()); } } $this->owner->extend('updateBodyAttributes', $attributes); return $attributes; }
[ "public", "function", "getAllBodyAttributes", "(", ")", "{", "$", "attributes", "=", "[", "'class'", "=>", "$", "this", "->", "getCurrentPageAncestry", "(", ")", "]", ";", "foreach", "(", "$", "this", "->", "owner", "->", "getExtensionInstances", "(", ")", "as", "$", "class", "=>", "$", "extension", ")", "{", "if", "(", "$", "extension", "instanceof", "ConfigExtension", ")", "{", "$", "attributes", "=", "array_merge", "(", "$", "attributes", ",", "$", "extension", "->", "getBodyAttributes", "(", ")", ")", ";", "}", "}", "$", "this", "->", "owner", "->", "extend", "(", "'updateBodyAttributes'", ",", "$", "attributes", ")", ";", "return", "$", "attributes", ";", "}" ]
Answers all body attributes from config extension subclasses as an array. @return array
[ "Answers", "all", "body", "attributes", "from", "config", "extension", "subclasses", "as", "an", "array", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ConfigExtension.php#L91-L106
232,040
praxisnetau/silverware
src/Extensions/ConfigExtension.php
ConfigExtension.getAssetFolder
protected function getAssetFolder() { $folders = $this->owner->config()->asset_folders; if (is_array($folders) && isset($folders[static::class])) { return $folders[static::class]; } }
php
protected function getAssetFolder() { $folders = $this->owner->config()->asset_folders; if (is_array($folders) && isset($folders[static::class])) { return $folders[static::class]; } }
[ "protected", "function", "getAssetFolder", "(", ")", "{", "$", "folders", "=", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "asset_folders", ";", "if", "(", "is_array", "(", "$", "folders", ")", "&&", "isset", "(", "$", "folders", "[", "static", "::", "class", "]", ")", ")", "{", "return", "$", "folders", "[", "static", "::", "class", "]", ";", "}", "}" ]
Answers the asset folder used by the receiver. @return string
[ "Answers", "the", "asset", "folder", "used", "by", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ConfigExtension.php#L133-L140
232,041
navarr/MinecraftProfile
src/Profile.php
Profile.fromUsername
public static function fromUsername($username, ApiClient $apiClient = null) { if (is_null($apiClient)) { $apiClient = static::createApiClient(); } $apiResult = $apiClient->uuidApi($username); $json = $apiResult; if (isset($json->error)) { throw new \RuntimeException('Mojang Error: '.$json->errorMessage); } if (empty($json) || !isset($json[0]->id)) { throw new \RuntimeException('Invalid Username ('.$username.')'); } static::rateLimitBust(); return static::fromUuid($json[0]->id); }
php
public static function fromUsername($username, ApiClient $apiClient = null) { if (is_null($apiClient)) { $apiClient = static::createApiClient(); } $apiResult = $apiClient->uuidApi($username); $json = $apiResult; if (isset($json->error)) { throw new \RuntimeException('Mojang Error: '.$json->errorMessage); } if (empty($json) || !isset($json[0]->id)) { throw new \RuntimeException('Invalid Username ('.$username.')'); } static::rateLimitBust(); return static::fromUuid($json[0]->id); }
[ "public", "static", "function", "fromUsername", "(", "$", "username", ",", "ApiClient", "$", "apiClient", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "apiClient", ")", ")", "{", "$", "apiClient", "=", "static", "::", "createApiClient", "(", ")", ";", "}", "$", "apiResult", "=", "$", "apiClient", "->", "uuidApi", "(", "$", "username", ")", ";", "$", "json", "=", "$", "apiResult", ";", "if", "(", "isset", "(", "$", "json", "->", "error", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Mojang Error: '", ".", "$", "json", "->", "errorMessage", ")", ";", "}", "if", "(", "empty", "(", "$", "json", ")", "||", "!", "isset", "(", "$", "json", "[", "0", "]", "->", "id", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Invalid Username ('", ".", "$", "username", ".", "')'", ")", ";", "}", "static", "::", "rateLimitBust", "(", ")", ";", "return", "static", "::", "fromUuid", "(", "$", "json", "[", "0", "]", "->", "id", ")", ";", "}" ]
For gods' sakes, use a UUID. @param string $username @param Profile\ApiClient $apiClient @deprecated As Mojang commonly returns a 429 in response @throws \RuntimeException @return Profile
[ "For", "gods", "sakes", "use", "a", "UUID", "." ]
af3c855e992a1bdb16cacd858ce8adbf849efc50
https://github.com/navarr/MinecraftProfile/blob/af3c855e992a1bdb16cacd858ce8adbf849efc50/src/Profile.php#L84-L104
232,042
zephia/olx
src/Entity/Ad.php
Ad.getPriceCurrency
public function getPriceCurrency() { if (empty($this->price_currency)) { throw new LogicException( sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'price_currency') ); } return $this->price_currency; }
php
public function getPriceCurrency() { if (empty($this->price_currency)) { throw new LogicException( sprintf(self::ERROR_MISSING_ATTRIBUTE_FORMAT, 'price_currency') ); } return $this->price_currency; }
[ "public", "function", "getPriceCurrency", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "price_currency", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "self", "::", "ERROR_MISSING_ATTRIBUTE_FORMAT", ",", "'price_currency'", ")", ")", ";", "}", "return", "$", "this", "->", "price_currency", ";", "}" ]
Get Price Currency @return int
[ "Get", "Price", "Currency" ]
dae5477a3d74ca6d9b82f5436b07ad85e1ceeb5b
https://github.com/zephia/olx/blob/dae5477a3d74ca6d9b82f5436b07ad85e1ceeb5b/src/Entity/Ad.php#L282-L290
232,043
praxisnetau/silverware
src/Components/FeatureComponent.php
FeatureComponent.getHeadingText
public function getHeadingText() { if ($this->Heading) { return $this->Heading; } if ($this->hasLinkPage()) { return $this->LinkPage()->MetaTitle; } }
php
public function getHeadingText() { if ($this->Heading) { return $this->Heading; } if ($this->hasLinkPage()) { return $this->LinkPage()->MetaTitle; } }
[ "public", "function", "getHeadingText", "(", ")", "{", "if", "(", "$", "this", "->", "Heading", ")", "{", "return", "$", "this", "->", "Heading", ";", "}", "if", "(", "$", "this", "->", "hasLinkPage", "(", ")", ")", "{", "return", "$", "this", "->", "LinkPage", "(", ")", "->", "MetaTitle", ";", "}", "}" ]
Answers the heading text for the receiver. @return string
[ "Answers", "the", "heading", "text", "for", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/FeatureComponent.php#L546-L555
232,044
praxisnetau/silverware
src/Components/FeatureComponent.php
FeatureComponent.getSummaryText
public function getSummaryText() { if ($this->Summary) { return $this->dbObject('Summary'); } if ($this->hasLinkPage()) { return $this->LinkPage()->MetaSummary; } }
php
public function getSummaryText() { if ($this->Summary) { return $this->dbObject('Summary'); } if ($this->hasLinkPage()) { return $this->LinkPage()->MetaSummary; } }
[ "public", "function", "getSummaryText", "(", ")", "{", "if", "(", "$", "this", "->", "Summary", ")", "{", "return", "$", "this", "->", "dbObject", "(", "'Summary'", ")", ";", "}", "if", "(", "$", "this", "->", "hasLinkPage", "(", ")", ")", "{", "return", "$", "this", "->", "LinkPage", "(", ")", "->", "MetaSummary", ";", "}", "}" ]
Answers the summary text either from the receiver or the featured page. @return DBHTMLText|string
[ "Answers", "the", "summary", "text", "either", "from", "the", "receiver", "or", "the", "featured", "page", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/FeatureComponent.php#L696-L705
232,045
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.getRequiredFiles
public function getRequiredFiles($config) { $files = []; foreach ($config as $key => $name) { if (is_numeric($key) && is_string($name)) { $files[] = $name; } elseif (is_numeric($key) && is_array($name)) { foreach ($name as $module => $file) { $files[] = sprintf('%s: %s', $module, $file); } } elseif (!is_numeric($key) && is_array($name)) { foreach ($name as $file) { $files[] = sprintf('%s: %s', $key, $file); } } } return $files; }
php
public function getRequiredFiles($config) { $files = []; foreach ($config as $key => $name) { if (is_numeric($key) && is_string($name)) { $files[] = $name; } elseif (is_numeric($key) && is_array($name)) { foreach ($name as $module => $file) { $files[] = sprintf('%s: %s', $module, $file); } } elseif (!is_numeric($key) && is_array($name)) { foreach ($name as $file) { $files[] = sprintf('%s: %s', $key, $file); } } } return $files; }
[ "public", "function", "getRequiredFiles", "(", "$", "config", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "name", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", "&&", "is_string", "(", "$", "name", ")", ")", "{", "$", "files", "[", "]", "=", "$", "name", ";", "}", "elseif", "(", "is_numeric", "(", "$", "key", ")", "&&", "is_array", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "name", "as", "$", "module", "=>", "$", "file", ")", "{", "$", "files", "[", "]", "=", "sprintf", "(", "'%s: %s'", ",", "$", "module", ",", "$", "file", ")", ";", "}", "}", "elseif", "(", "!", "is_numeric", "(", "$", "key", ")", "&&", "is_array", "(", "$", "name", ")", ")", "{", "foreach", "(", "$", "name", "as", "$", "file", ")", "{", "$", "files", "[", "]", "=", "sprintf", "(", "'%s: %s'", ",", "$", "key", ",", "$", "file", ")", ";", "}", "}", "}", "return", "$", "files", ";", "}" ]
Answers an array of files required by given configuration array. @param array $config @return array
[ "Answers", "an", "array", "of", "files", "required", "by", "given", "configuration", "array", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L138-L165
232,046
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.getRequiredJSFiles
public function getRequiredJSFiles() { $files = []; foreach (ClassInfo::subclassesFor(ContentController::class) as $controller) { if ($required_js = Injector::inst()->get($controller)->getRequiredJS()) { foreach ($required_js as $file) { $file = ModuleResourceLoader::singleton()->resolvePath($file); if (!isset($files[$file])) { $files[$file] = file_get_contents(Director::getAbsFile($file)); } } } } return $files; }
php
public function getRequiredJSFiles() { $files = []; foreach (ClassInfo::subclassesFor(ContentController::class) as $controller) { if ($required_js = Injector::inst()->get($controller)->getRequiredJS()) { foreach ($required_js as $file) { $file = ModuleResourceLoader::singleton()->resolvePath($file); if (!isset($files[$file])) { $files[$file] = file_get_contents(Director::getAbsFile($file)); } } } } return $files; }
[ "public", "function", "getRequiredJSFiles", "(", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "ClassInfo", "::", "subclassesFor", "(", "ContentController", "::", "class", ")", "as", "$", "controller", ")", "{", "if", "(", "$", "required_js", "=", "Injector", "::", "inst", "(", ")", "->", "get", "(", "$", "controller", ")", "->", "getRequiredJS", "(", ")", ")", "{", "foreach", "(", "$", "required_js", "as", "$", "file", ")", "{", "$", "file", "=", "ModuleResourceLoader", "::", "singleton", "(", ")", "->", "resolvePath", "(", "$", "file", ")", ";", "if", "(", "!", "isset", "(", "$", "files", "[", "$", "file", "]", ")", ")", "{", "$", "files", "[", "$", "file", "]", "=", "file_get_contents", "(", "Director", "::", "getAbsFile", "(", "$", "file", ")", ")", ";", "}", "}", "}", "}", "return", "$", "files", ";", "}" ]
Answers an array of all JavaScript files required by the content controllers of the app. @return array
[ "Answers", "an", "array", "of", "all", "JavaScript", "files", "required", "by", "the", "content", "controllers", "of", "the", "app", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L182-L205
232,047
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.getRequiredCSSFiles
public function getRequiredCSSFiles() { $files = []; foreach (ClassInfo::subclassesFor(ContentController::class) as $controller) { if ($required_css = Injector::inst()->get($controller)->getRequiredCSS()) { foreach ($required_css as $file) { $file = ModuleResourceLoader::singleton()->resolvePath($file); if (!isset($files[$file])) { $files[$file] = file_get_contents(Director::getAbsFile($file)); } } } } return $files; }
php
public function getRequiredCSSFiles() { $files = []; foreach (ClassInfo::subclassesFor(ContentController::class) as $controller) { if ($required_css = Injector::inst()->get($controller)->getRequiredCSS()) { foreach ($required_css as $file) { $file = ModuleResourceLoader::singleton()->resolvePath($file); if (!isset($files[$file])) { $files[$file] = file_get_contents(Director::getAbsFile($file)); } } } } return $files; }
[ "public", "function", "getRequiredCSSFiles", "(", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "ClassInfo", "::", "subclassesFor", "(", "ContentController", "::", "class", ")", "as", "$", "controller", ")", "{", "if", "(", "$", "required_css", "=", "Injector", "::", "inst", "(", ")", "->", "get", "(", "$", "controller", ")", "->", "getRequiredCSS", "(", ")", ")", "{", "foreach", "(", "$", "required_css", "as", "$", "file", ")", "{", "$", "file", "=", "ModuleResourceLoader", "::", "singleton", "(", ")", "->", "resolvePath", "(", "$", "file", ")", ";", "if", "(", "!", "isset", "(", "$", "files", "[", "$", "file", "]", ")", ")", "{", "$", "files", "[", "$", "file", "]", "=", "file_get_contents", "(", "Director", "::", "getAbsFile", "(", "$", "file", ")", ")", ";", "}", "}", "}", "}", "return", "$", "files", ";", "}" ]
Answers an array of all CSS files required by the content controllers of the app. @return array
[ "Answers", "an", "array", "of", "all", "CSS", "files", "required", "by", "the", "content", "controllers", "of", "the", "app", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L222-L245
232,048
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.getCustomCSSAsString
public function getCustomCSSAsString() { // Create CSS Array: $css = []; // Merge Custom CSS from Page Controller: if ($this->owner instanceof PageController) { $css = array_merge($css, $this->owner->getCustomCSS()); } // Create CSS String: $css = implode("\n", $css); // Remove Empty Lines: $css = ViewTools::singleton()->removeEmptyLines($css); // Trim CSS String: $css = trim($css); // Minify CSS String: if (!Director::isDev()) { $css = ViewTools::singleton()->minifyCSS($css); } // Answer CSS String: return $css; }
php
public function getCustomCSSAsString() { // Create CSS Array: $css = []; // Merge Custom CSS from Page Controller: if ($this->owner instanceof PageController) { $css = array_merge($css, $this->owner->getCustomCSS()); } // Create CSS String: $css = implode("\n", $css); // Remove Empty Lines: $css = ViewTools::singleton()->removeEmptyLines($css); // Trim CSS String: $css = trim($css); // Minify CSS String: if (!Director::isDev()) { $css = ViewTools::singleton()->minifyCSS($css); } // Answer CSS String: return $css; }
[ "public", "function", "getCustomCSSAsString", "(", ")", "{", "// Create CSS Array:", "$", "css", "=", "[", "]", ";", "// Merge Custom CSS from Page Controller:", "if", "(", "$", "this", "->", "owner", "instanceof", "PageController", ")", "{", "$", "css", "=", "array_merge", "(", "$", "css", ",", "$", "this", "->", "owner", "->", "getCustomCSS", "(", ")", ")", ";", "}", "// Create CSS String:", "$", "css", "=", "implode", "(", "\"\\n\"", ",", "$", "css", ")", ";", "// Remove Empty Lines:", "$", "css", "=", "ViewTools", "::", "singleton", "(", ")", "->", "removeEmptyLines", "(", "$", "css", ")", ";", "// Trim CSS String:", "$", "css", "=", "trim", "(", "$", "css", ")", ";", "// Minify CSS String:", "if", "(", "!", "Director", "::", "isDev", "(", ")", ")", "{", "$", "css", "=", "ViewTools", "::", "singleton", "(", ")", "->", "minifyCSS", "(", "$", "css", ")", ";", "}", "// Answer CSS String:", "return", "$", "css", ";", "}" ]
Answers the custom CSS required for the template as a string. @return string
[ "Answers", "the", "custom", "CSS", "required", "for", "the", "template", "as", "a", "string", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L252-L285
232,049
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.isDevServerActive
public function isDevServerActive() { // Using Development Environment? if (!Director::isDev()) { return false; } // Already Checked Server? if ($this->devServerTested) { return $this->devServerActive; } // Test Server Connection: return $this->testDevServer(); }
php
public function isDevServerActive() { // Using Development Environment? if (!Director::isDev()) { return false; } // Already Checked Server? if ($this->devServerTested) { return $this->devServerActive; } // Test Server Connection: return $this->testDevServer(); }
[ "public", "function", "isDevServerActive", "(", ")", "{", "// Using Development Environment?", "if", "(", "!", "Director", "::", "isDev", "(", ")", ")", "{", "return", "false", ";", "}", "// Already Checked Server?", "if", "(", "$", "this", "->", "devServerTested", ")", "{", "return", "$", "this", "->", "devServerActive", ";", "}", "// Test Server Connection:", "return", "$", "this", "->", "testDevServer", "(", ")", ";", "}" ]
Answers true if a webpack development server is currently being used. @return boolean
[ "Answers", "true", "if", "a", "webpack", "development", "server", "is", "currently", "being", "used", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L292-L309
232,050
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.getDevServerURL
public function getDevServerURL($path = null) { // Using Development Environment? if (!Director::isDev()) { return; } // Obtain Development Server Config: if ($config = $this->getDevServerConfig()) { if (isset($config['host']) && isset($config['port'])) { // Auto Host Mode: if ($config['host'] === 'auto') { $config['host'] = Director::host(); } // Define Protocol: $protocol = function ($config) { if (isset($config['https']) && $config['https'] !== 'auto') { return sprintf('%s:', $config['https'] ? 'https' : 'http'); } }; // Answer URL String: return sprintf( '%s//%s:%d/%s', $protocol($config), $config['host'], $config['port'], $path ); } } }
php
public function getDevServerURL($path = null) { // Using Development Environment? if (!Director::isDev()) { return; } // Obtain Development Server Config: if ($config = $this->getDevServerConfig()) { if (isset($config['host']) && isset($config['port'])) { // Auto Host Mode: if ($config['host'] === 'auto') { $config['host'] = Director::host(); } // Define Protocol: $protocol = function ($config) { if (isset($config['https']) && $config['https'] !== 'auto') { return sprintf('%s:', $config['https'] ? 'https' : 'http'); } }; // Answer URL String: return sprintf( '%s//%s:%d/%s', $protocol($config), $config['host'], $config['port'], $path ); } } }
[ "public", "function", "getDevServerURL", "(", "$", "path", "=", "null", ")", "{", "// Using Development Environment?", "if", "(", "!", "Director", "::", "isDev", "(", ")", ")", "{", "return", ";", "}", "// Obtain Development Server Config:", "if", "(", "$", "config", "=", "$", "this", "->", "getDevServerConfig", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'host'", "]", ")", "&&", "isset", "(", "$", "config", "[", "'port'", "]", ")", ")", "{", "// Auto Host Mode:", "if", "(", "$", "config", "[", "'host'", "]", "===", "'auto'", ")", "{", "$", "config", "[", "'host'", "]", "=", "Director", "::", "host", "(", ")", ";", "}", "// Define Protocol:", "$", "protocol", "=", "function", "(", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'https'", "]", ")", "&&", "$", "config", "[", "'https'", "]", "!==", "'auto'", ")", "{", "return", "sprintf", "(", "'%s:'", ",", "$", "config", "[", "'https'", "]", "?", "'https'", ":", "'http'", ")", ";", "}", "}", ";", "// Answer URL String:", "return", "sprintf", "(", "'%s//%s:%d/%s'", ",", "$", "protocol", "(", "$", "config", ")", ",", "$", "config", "[", "'host'", "]", ",", "$", "config", "[", "'port'", "]", ",", "$", "path", ")", ";", "}", "}", "}" ]
Answers the URL for the webpack development server. @param string $path Path to append to the URL. @return string
[ "Answers", "the", "URL", "for", "the", "webpack", "development", "server", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L318-L359
232,051
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.initRequirements
protected function initRequirements() { // Themed JavaScript Enabled? if ($this->owner->config()->load_themed_js) { // Load Themed JavaScript: foreach ($this->owner->config()->required_themed_js as $name) { $this->loadThemedJS($name); } } // Themed CSS Enabled? if ($this->owner->config()->load_themed_css || $this->isDevServerFallback()) { // Load Themed CSS: foreach ($this->owner->config()->required_themed_css as $name) { $this->loadThemedCSS($name); } } // Regular JavaScript Enabled? if ($this->owner->config()->load_js) { // Load Regular JavaScript: foreach ($this->owner->getRequiredJS() as $name) { $this->loadJS($name); } } // Regular CSS Enabled? if ($this->owner->config()->load_css) { // Load Regular CSS: foreach ($this->owner->getRequiredCSS() as $name) { $this->loadCSS($name); } } // Load Page Controller Requirements: if ($this->owner instanceof PageController) { // Custom CSS Enabled? if ($this->owner->config()->load_custom_css) { // Load Custom CSS: if ($css = $this->getCustomCSSAsString()) { $this->loadCustomCSS($css); } } } // Combine Files (dev only): $this->combineFiles(); }
php
protected function initRequirements() { // Themed JavaScript Enabled? if ($this->owner->config()->load_themed_js) { // Load Themed JavaScript: foreach ($this->owner->config()->required_themed_js as $name) { $this->loadThemedJS($name); } } // Themed CSS Enabled? if ($this->owner->config()->load_themed_css || $this->isDevServerFallback()) { // Load Themed CSS: foreach ($this->owner->config()->required_themed_css as $name) { $this->loadThemedCSS($name); } } // Regular JavaScript Enabled? if ($this->owner->config()->load_js) { // Load Regular JavaScript: foreach ($this->owner->getRequiredJS() as $name) { $this->loadJS($name); } } // Regular CSS Enabled? if ($this->owner->config()->load_css) { // Load Regular CSS: foreach ($this->owner->getRequiredCSS() as $name) { $this->loadCSS($name); } } // Load Page Controller Requirements: if ($this->owner instanceof PageController) { // Custom CSS Enabled? if ($this->owner->config()->load_custom_css) { // Load Custom CSS: if ($css = $this->getCustomCSSAsString()) { $this->loadCustomCSS($css); } } } // Combine Files (dev only): $this->combineFiles(); }
[ "protected", "function", "initRequirements", "(", ")", "{", "// Themed JavaScript Enabled?", "if", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "load_themed_js", ")", "{", "// Load Themed JavaScript:", "foreach", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "required_themed_js", "as", "$", "name", ")", "{", "$", "this", "->", "loadThemedJS", "(", "$", "name", ")", ";", "}", "}", "// Themed CSS Enabled?", "if", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "load_themed_css", "||", "$", "this", "->", "isDevServerFallback", "(", ")", ")", "{", "// Load Themed CSS:", "foreach", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "required_themed_css", "as", "$", "name", ")", "{", "$", "this", "->", "loadThemedCSS", "(", "$", "name", ")", ";", "}", "}", "// Regular JavaScript Enabled?", "if", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "load_js", ")", "{", "// Load Regular JavaScript:", "foreach", "(", "$", "this", "->", "owner", "->", "getRequiredJS", "(", ")", "as", "$", "name", ")", "{", "$", "this", "->", "loadJS", "(", "$", "name", ")", ";", "}", "}", "// Regular CSS Enabled?", "if", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "load_css", ")", "{", "// Load Regular CSS:", "foreach", "(", "$", "this", "->", "owner", "->", "getRequiredCSS", "(", ")", "as", "$", "name", ")", "{", "$", "this", "->", "loadCSS", "(", "$", "name", ")", ";", "}", "}", "// Load Page Controller Requirements:", "if", "(", "$", "this", "->", "owner", "instanceof", "PageController", ")", "{", "// Custom CSS Enabled?", "if", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "load_custom_css", ")", "{", "// Load Custom CSS:", "if", "(", "$", "css", "=", "$", "this", "->", "getCustomCSSAsString", "(", ")", ")", "{", "$", "this", "->", "loadCustomCSS", "(", "$", "css", ")", ";", "}", "}", "}", "// Combine Files (dev only):", "$", "this", "->", "combineFiles", "(", ")", ";", "}" ]
Initialises the requirements for the extended controller. @return void
[ "Initialises", "the", "requirements", "for", "the", "extended", "controller", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L386-L457
232,052
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.loadThemedJS
protected function loadThemedJS($name) { if ($this->isDevServerActive()) { Requirements::javascript($this->getDevServerURL($this->ext($name, 'js'))); } else { Requirements::themedJavascript($name); } }
php
protected function loadThemedJS($name) { if ($this->isDevServerActive()) { Requirements::javascript($this->getDevServerURL($this->ext($name, 'js'))); } else { Requirements::themedJavascript($name); } }
[ "protected", "function", "loadThemedJS", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "isDevServerActive", "(", ")", ")", "{", "Requirements", "::", "javascript", "(", "$", "this", "->", "getDevServerURL", "(", "$", "this", "->", "ext", "(", "$", "name", ",", "'js'", ")", ")", ")", ";", "}", "else", "{", "Requirements", "::", "themedJavascript", "(", "$", "name", ")", ";", "}", "}" ]
Loads the themed JavaScript with the given name. @param string $name Name of themed JavaScript file. @return void
[ "Loads", "the", "themed", "JavaScript", "with", "the", "given", "name", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L567-L574
232,053
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.loadThemedCSS
protected function loadThemedCSS($name) { if ($this->isDevServerActive()) { Requirements::css($this->getDevServerURL($this->ext($name, 'css'))); } else { Requirements::themedCSS($name); } }
php
protected function loadThemedCSS($name) { if ($this->isDevServerActive()) { Requirements::css($this->getDevServerURL($this->ext($name, 'css'))); } else { Requirements::themedCSS($name); } }
[ "protected", "function", "loadThemedCSS", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "isDevServerActive", "(", ")", ")", "{", "Requirements", "::", "css", "(", "$", "this", "->", "getDevServerURL", "(", "$", "this", "->", "ext", "(", "$", "name", ",", "'css'", ")", ")", ")", ";", "}", "else", "{", "Requirements", "::", "themedCSS", "(", "$", "name", ")", ";", "}", "}" ]
Loads the themed CSS with the given name. @param string $name Name of themed CSS file. @return void
[ "Loads", "the", "themed", "CSS", "with", "the", "given", "name", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L583-L590
232,054
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.combineFiles
protected function combineFiles() { if (Director::isDev() && $this->owner->config()->combine_files) { // Obtain Tools: $tools = ViewTools::singleton(); // Combine Files: $tools->combineFiles($this->owner->config()->combined_js, $this->owner->getRequiredJSFiles()); $tools->combineFiles($this->owner->config()->combined_css, $this->owner->getRequiredCSSFiles()); } }
php
protected function combineFiles() { if (Director::isDev() && $this->owner->config()->combine_files) { // Obtain Tools: $tools = ViewTools::singleton(); // Combine Files: $tools->combineFiles($this->owner->config()->combined_js, $this->owner->getRequiredJSFiles()); $tools->combineFiles($this->owner->config()->combined_css, $this->owner->getRequiredCSSFiles()); } }
[ "protected", "function", "combineFiles", "(", ")", "{", "if", "(", "Director", "::", "isDev", "(", ")", "&&", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "combine_files", ")", "{", "// Obtain Tools:", "$", "tools", "=", "ViewTools", "::", "singleton", "(", ")", ";", "// Combine Files:", "$", "tools", "->", "combineFiles", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "combined_js", ",", "$", "this", "->", "owner", "->", "getRequiredJSFiles", "(", ")", ")", ";", "$", "tools", "->", "combineFiles", "(", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "combined_css", ",", "$", "this", "->", "owner", "->", "getRequiredCSSFiles", "(", ")", ")", ";", "}", "}" ]
Combines required files together for bundling with the theme. @return void
[ "Combines", "required", "files", "together", "for", "bundling", "with", "the", "theme", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L597-L611
232,055
praxisnetau/silverware
src/Extensions/ControllerExtension.php
ControllerExtension.ext
protected function ext($name, $ext) { // Obtain Info: $info = pathinfo($name); // Check Extension: if (!isset($info['extension']) || $info['extension'] !== $ext) { $name = sprintf('%s.%s', $name, $ext); } // Answer Name: return $name; }
php
protected function ext($name, $ext) { // Obtain Info: $info = pathinfo($name); // Check Extension: if (!isset($info['extension']) || $info['extension'] !== $ext) { $name = sprintf('%s.%s', $name, $ext); } // Answer Name: return $name; }
[ "protected", "function", "ext", "(", "$", "name", ",", "$", "ext", ")", "{", "// Obtain Info:", "$", "info", "=", "pathinfo", "(", "$", "name", ")", ";", "// Check Extension:", "if", "(", "!", "isset", "(", "$", "info", "[", "'extension'", "]", ")", "||", "$", "info", "[", "'extension'", "]", "!==", "$", "ext", ")", "{", "$", "name", "=", "sprintf", "(", "'%s.%s'", ",", "$", "name", ",", "$", "ext", ")", ";", "}", "// Answer Name:", "return", "$", "name", ";", "}" ]
Applies the given extension to the given file name if it is not already present. @param string $name Filename to process. @param string $ext Required file extension. @return string
[ "Applies", "the", "given", "extension", "to", "the", "given", "file", "name", "if", "it", "is", "not", "already", "present", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/ControllerExtension.php#L621-L636
232,056
praxisnetau/silverware
src/Forms/Validators/MediaURLValidator.php
MediaURLValidator.php
public function php($data) { // Obtain Result (from parent): $valid = parent::php($data); // Obtain URL Field: if ($field = $this->form->Fields()->dataFieldByName($this->urlField)) { // Detect Value: if (!$field->Value()) { return $valid; } // Attempt Adapter Creation: try { $adapter = Embed::create($field->Value()); $valid = true; } catch (EmbedException $e) { $this->validationError($this->urlField, $e->getMessage(), ValidationResult::TYPE_ERROR); $valid = false; } } else { // Cannot Find URL Field: throw new ValidationException( sprintf( _t(__CLASS__ . '.CANNOTFINDURLFIELD', 'Cannot find a field to validate with name "%s"'), $this->urlField ) ); } // Answer Result: return $valid; }
php
public function php($data) { // Obtain Result (from parent): $valid = parent::php($data); // Obtain URL Field: if ($field = $this->form->Fields()->dataFieldByName($this->urlField)) { // Detect Value: if (!$field->Value()) { return $valid; } // Attempt Adapter Creation: try { $adapter = Embed::create($field->Value()); $valid = true; } catch (EmbedException $e) { $this->validationError($this->urlField, $e->getMessage(), ValidationResult::TYPE_ERROR); $valid = false; } } else { // Cannot Find URL Field: throw new ValidationException( sprintf( _t(__CLASS__ . '.CANNOTFINDURLFIELD', 'Cannot find a field to validate with name "%s"'), $this->urlField ) ); } // Answer Result: return $valid; }
[ "public", "function", "php", "(", "$", "data", ")", "{", "// Obtain Result (from parent):", "$", "valid", "=", "parent", "::", "php", "(", "$", "data", ")", ";", "// Obtain URL Field:", "if", "(", "$", "field", "=", "$", "this", "->", "form", "->", "Fields", "(", ")", "->", "dataFieldByName", "(", "$", "this", "->", "urlField", ")", ")", "{", "// Detect Value:", "if", "(", "!", "$", "field", "->", "Value", "(", ")", ")", "{", "return", "$", "valid", ";", "}", "// Attempt Adapter Creation:", "try", "{", "$", "adapter", "=", "Embed", "::", "create", "(", "$", "field", "->", "Value", "(", ")", ")", ";", "$", "valid", "=", "true", ";", "}", "catch", "(", "EmbedException", "$", "e", ")", "{", "$", "this", "->", "validationError", "(", "$", "this", "->", "urlField", ",", "$", "e", "->", "getMessage", "(", ")", ",", "ValidationResult", "::", "TYPE_ERROR", ")", ";", "$", "valid", "=", "false", ";", "}", "}", "else", "{", "// Cannot Find URL Field:", "throw", "new", "ValidationException", "(", "sprintf", "(", "_t", "(", "__CLASS__", ".", "'.CANNOTFINDURLFIELD'", ",", "'Cannot find a field to validate with name \"%s\"'", ")", ",", "$", "this", "->", "urlField", ")", ")", ";", "}", "// Answer Result:", "return", "$", "valid", ";", "}" ]
Validates the given array of form data and answers the result. @param array $data @throws ValidationException @return boolean
[ "Validates", "the", "given", "array", "of", "form", "data", "and", "answers", "the", "result", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/Validators/MediaURLValidator.php#L77-L125
232,057
shopwareLabs/plugin-info
src/Backend/Zip.php
Zip.getChildrenValues
private function getChildrenValues(\DOMNode $node, $name) { $children = array(); foreach ($node->childNodes as $child) { if ($child instanceof \DOMElement && $child->localName === $name) { $children[] = $child->nodeValue; } } return $children; }
php
private function getChildrenValues(\DOMNode $node, $name) { $children = array(); foreach ($node->childNodes as $child) { if ($child instanceof \DOMElement && $child->localName === $name) { $children[] = $child->nodeValue; } } return $children; }
[ "private", "function", "getChildrenValues", "(", "\\", "DOMNode", "$", "node", ",", "$", "name", ")", "{", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "child", ")", "{", "if", "(", "$", "child", "instanceof", "\\", "DOMElement", "&&", "$", "child", "->", "localName", "===", "$", "name", ")", "{", "$", "children", "[", "]", "=", "$", "child", "->", "nodeValue", ";", "}", "}", "return", "$", "children", ";", "}" ]
Get child element values by name. @param \DOMNode $node @param mixed $name @return \DOMElement[]
[ "Get", "child", "element", "values", "by", "name", "." ]
2d553fdd463ed95fd58aba7adba78a35442a302f
https://github.com/shopwareLabs/plugin-info/blob/2d553fdd463ed95fd58aba7adba78a35442a302f/src/Backend/Zip.php#L208-L218
232,058
php-fp/php-fp-either
src/Constructor/Right.php
Right.ap
public function ap(Either $that) : Either { return $this->chain( function ($f) use ($that) { return $that->map($f); } ); }
php
public function ap(Either $that) : Either { return $this->chain( function ($f) use ($that) { return $that->map($f); } ); }
[ "public", "function", "ap", "(", "Either", "$", "that", ")", ":", "Either", "{", "return", "$", "this", "->", "chain", "(", "function", "(", "$", "f", ")", "use", "(", "$", "that", ")", "{", "return", "$", "that", "->", "map", "(", "$", "f", ")", ";", "}", ")", ";", "}" ]
Apply a wrapped paramater to this wrapped function. @param Either $that The parameter to apply. @return Either The wrapped result.
[ "Apply", "a", "wrapped", "paramater", "to", "this", "wrapped", "function", "." ]
48c81c055cf08fbdb8c9de41a678fbb83a3d9c72
https://github.com/php-fp/php-fp-either/blob/48c81c055cf08fbdb8c9de41a678fbb83a3d9c72/src/Constructor/Right.php#L17-L25
232,059
praxisnetau/silverware
src/Grid/Frameworks/Bootstrap/Column.php
Column.getSpanClassNames
public function getSpanClassNames(DBViewports $span = null) { $classes = []; if (!$span) { $span = $this->owner->getSpanViewports(); } if ($span->allEqualTo('auto')) { // Add Span Prefix Only: $classes[] = $this->spanPrefix; } elseif ($span->allEmpty()) { // Add Column Span Defaults: foreach ($this->columnSpanDefaults as $viewport => $value) { $classes[] = $this->getSpanClass($viewport, $value); } } else { // Add Column Span Field Values: foreach ($span->getViewports() as $viewport) { $classes[] = $this->getSpanClass($viewport, $span->getField($viewport)); } } return $classes; }
php
public function getSpanClassNames(DBViewports $span = null) { $classes = []; if (!$span) { $span = $this->owner->getSpanViewports(); } if ($span->allEqualTo('auto')) { // Add Span Prefix Only: $classes[] = $this->spanPrefix; } elseif ($span->allEmpty()) { // Add Column Span Defaults: foreach ($this->columnSpanDefaults as $viewport => $value) { $classes[] = $this->getSpanClass($viewport, $value); } } else { // Add Column Span Field Values: foreach ($span->getViewports() as $viewport) { $classes[] = $this->getSpanClass($viewport, $span->getField($viewport)); } } return $classes; }
[ "public", "function", "getSpanClassNames", "(", "DBViewports", "$", "span", "=", "null", ")", "{", "$", "classes", "=", "[", "]", ";", "if", "(", "!", "$", "span", ")", "{", "$", "span", "=", "$", "this", "->", "owner", "->", "getSpanViewports", "(", ")", ";", "}", "if", "(", "$", "span", "->", "allEqualTo", "(", "'auto'", ")", ")", "{", "// Add Span Prefix Only:", "$", "classes", "[", "]", "=", "$", "this", "->", "spanPrefix", ";", "}", "elseif", "(", "$", "span", "->", "allEmpty", "(", ")", ")", "{", "// Add Column Span Defaults:", "foreach", "(", "$", "this", "->", "columnSpanDefaults", "as", "$", "viewport", "=>", "$", "value", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "getSpanClass", "(", "$", "viewport", ",", "$", "value", ")", ";", "}", "}", "else", "{", "// Add Column Span Field Values:", "foreach", "(", "$", "span", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "getSpanClass", "(", "$", "viewport", ",", "$", "span", "->", "getField", "(", "$", "viewport", ")", ")", ";", "}", "}", "return", "$", "classes", ";", "}" ]
Answers the span class names for the extended object. @param DBViewports $span Optional viewports field to use instead of extended object field. @return array
[ "Answers", "the", "span", "class", "names", "for", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Frameworks/Bootstrap/Column.php#L103-L136
232,060
praxisnetau/silverware
src/Grid/Frameworks/Bootstrap/Column.php
Column.getOffsetClassNames
public function getOffsetClassNames(DBViewports $offset = null) { $classes = []; if (!$offset) { $offset = $this->owner->getOffsetViewports(); } foreach ($offset->getViewports() as $viewport) { $classes[] = $this->getOffsetClass($viewport, $offset->getField($viewport)); } return $classes; }
php
public function getOffsetClassNames(DBViewports $offset = null) { $classes = []; if (!$offset) { $offset = $this->owner->getOffsetViewports(); } foreach ($offset->getViewports() as $viewport) { $classes[] = $this->getOffsetClass($viewport, $offset->getField($viewport)); } return $classes; }
[ "public", "function", "getOffsetClassNames", "(", "DBViewports", "$", "offset", "=", "null", ")", "{", "$", "classes", "=", "[", "]", ";", "if", "(", "!", "$", "offset", ")", "{", "$", "offset", "=", "$", "this", "->", "owner", "->", "getOffsetViewports", "(", ")", ";", "}", "foreach", "(", "$", "offset", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "getOffsetClass", "(", "$", "viewport", ",", "$", "offset", "->", "getField", "(", "$", "viewport", ")", ")", ";", "}", "return", "$", "classes", ";", "}" ]
Answers the offset class names for the extended object. @param DBViewports $offset Optional viewports field to use instead of extended object field. @return array
[ "Answers", "the", "offset", "class", "names", "for", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Frameworks/Bootstrap/Column.php#L145-L158
232,061
praxisnetau/silverware
src/Grid/Frameworks/Bootstrap/Column.php
Column.getSpanClass
protected function getSpanClass($viewport, $value) { if ($value) { $class = [$this->spanPrefix]; $class[] = $this->grid()->getStyle('viewport', $viewport); if ($value != 'fill') { $class[] = $value; } return implode('-', array_filter($class)); } }
php
protected function getSpanClass($viewport, $value) { if ($value) { $class = [$this->spanPrefix]; $class[] = $this->grid()->getStyle('viewport', $viewport); if ($value != 'fill') { $class[] = $value; } return implode('-', array_filter($class)); } }
[ "protected", "function", "getSpanClass", "(", "$", "viewport", ",", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "class", "=", "[", "$", "this", "->", "spanPrefix", "]", ";", "$", "class", "[", "]", "=", "$", "this", "->", "grid", "(", ")", "->", "getStyle", "(", "'viewport'", ",", "$", "viewport", ")", ";", "if", "(", "$", "value", "!=", "'fill'", ")", "{", "$", "class", "[", "]", "=", "$", "value", ";", "}", "return", "implode", "(", "'-'", ",", "array_filter", "(", "$", "class", ")", ")", ";", "}", "}" ]
Answers the span class for the given viewport and value. @param string $viewport @param string $value @return string
[ "Answers", "the", "span", "class", "for", "the", "given", "viewport", "and", "value", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Frameworks/Bootstrap/Column.php#L192-L207
232,062
praxisnetau/silverware
src/Grid/Frameworks/Bootstrap/Column.php
Column.getOffsetClass
protected function getOffsetClass($viewport, $value) { if ($value) { $class = [$this->offsetPrefix]; $class[] = $this->grid()->getStyle('viewport', $viewport); if ($value == 'reset') { $class[] = 0; } else { $class[] = $value; } return implode('-', array_filter($class)); } }
php
protected function getOffsetClass($viewport, $value) { if ($value) { $class = [$this->offsetPrefix]; $class[] = $this->grid()->getStyle('viewport', $viewport); if ($value == 'reset') { $class[] = 0; } else { $class[] = $value; } return implode('-', array_filter($class)); } }
[ "protected", "function", "getOffsetClass", "(", "$", "viewport", ",", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "class", "=", "[", "$", "this", "->", "offsetPrefix", "]", ";", "$", "class", "[", "]", "=", "$", "this", "->", "grid", "(", ")", "->", "getStyle", "(", "'viewport'", ",", "$", "viewport", ")", ";", "if", "(", "$", "value", "==", "'reset'", ")", "{", "$", "class", "[", "]", "=", "0", ";", "}", "else", "{", "$", "class", "[", "]", "=", "$", "value", ";", "}", "return", "implode", "(", "'-'", ",", "array_filter", "(", "$", "class", ")", ")", ";", "}", "}" ]
Answers the offset class for the specified viewport and value. @param string $viewport @param string $value @return string
[ "Answers", "the", "offset", "class", "for", "the", "specified", "viewport", "and", "value", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Grid/Frameworks/Bootstrap/Column.php#L217-L234
232,063
praxisnetau/silverware
src/Extensions/Admin/LeftAndMainExtension.php
LeftAndMainExtension.initSiteTreeIcons
protected function initSiteTreeIcons() { foreach (ClassInfo::subclassesFor(SiteTree::class) as $class) { $icon = Config::inst()->get($class, 'icon'); $path = ModuleResourceLoader::singleton()->resolvePath($icon); if ($path !== $icon) { $path = preg_replace('#^vendor/#i', 'resources/', $path); Config::modify()->set($class, 'icon', $path); } } }
php
protected function initSiteTreeIcons() { foreach (ClassInfo::subclassesFor(SiteTree::class) as $class) { $icon = Config::inst()->get($class, 'icon'); $path = ModuleResourceLoader::singleton()->resolvePath($icon); if ($path !== $icon) { $path = preg_replace('#^vendor/#i', 'resources/', $path); Config::modify()->set($class, 'icon', $path); } } }
[ "protected", "function", "initSiteTreeIcons", "(", ")", "{", "foreach", "(", "ClassInfo", "::", "subclassesFor", "(", "SiteTree", "::", "class", ")", "as", "$", "class", ")", "{", "$", "icon", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "$", "class", ",", "'icon'", ")", ";", "$", "path", "=", "ModuleResourceLoader", "::", "singleton", "(", ")", "->", "resolvePath", "(", "$", "icon", ")", ";", "if", "(", "$", "path", "!==", "$", "icon", ")", "{", "$", "path", "=", "preg_replace", "(", "'#^vendor/#i'", ",", "'resources/'", ",", "$", "path", ")", ";", "Config", "::", "modify", "(", ")", "->", "set", "(", "$", "class", ",", "'icon'", ",", "$", "path", ")", ";", "}", "}", "}" ]
Processes the icon configuration for all site tree classes and resolves resources. @return void
[ "Processes", "the", "icon", "configuration", "for", "all", "site", "tree", "classes", "and", "resolves", "resources", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Admin/LeftAndMainExtension.php#L66-L83
232,064
praxisnetau/silverware
src/Extensions/Admin/LeftAndMainExtension.php
LeftAndMainExtension.initThemedEditorCSS
protected function initThemedEditorCSS() { // Initialise: $paths = []; // Iterate Themed Editor CSS Files: foreach ($this->getThemedEditorCSS() as $name) { if ($path = ThemeResourceLoader::inst()->findThemedCSS($name, SSViewer::get_themes())) { $paths[] = $path; } } // Merge Themed Editor CSS Paths into HTML Editor Config: TinyMCEConfig::config()->merge('editor_css', $paths); }
php
protected function initThemedEditorCSS() { // Initialise: $paths = []; // Iterate Themed Editor CSS Files: foreach ($this->getThemedEditorCSS() as $name) { if ($path = ThemeResourceLoader::inst()->findThemedCSS($name, SSViewer::get_themes())) { $paths[] = $path; } } // Merge Themed Editor CSS Paths into HTML Editor Config: TinyMCEConfig::config()->merge('editor_css', $paths); }
[ "protected", "function", "initThemedEditorCSS", "(", ")", "{", "// Initialise:", "$", "paths", "=", "[", "]", ";", "// Iterate Themed Editor CSS Files:", "foreach", "(", "$", "this", "->", "getThemedEditorCSS", "(", ")", "as", "$", "name", ")", "{", "if", "(", "$", "path", "=", "ThemeResourceLoader", "::", "inst", "(", ")", "->", "findThemedCSS", "(", "$", "name", ",", "SSViewer", "::", "get_themes", "(", ")", ")", ")", "{", "$", "paths", "[", "]", "=", "$", "path", ";", "}", "}", "// Merge Themed Editor CSS Paths into HTML Editor Config:", "TinyMCEConfig", "::", "config", "(", ")", "->", "merge", "(", "'editor_css'", ",", "$", "paths", ")", ";", "}" ]
Merges configured editor CSS from the theme into HTML editor config. @return void
[ "Merges", "configured", "editor", "CSS", "from", "the", "theme", "into", "HTML", "editor", "config", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Admin/LeftAndMainExtension.php#L90-L109
232,065
praxisnetau/silverware
src/Tags/Tag.php
Tag.forSource
public static function forSource(TagSource $source, SS_List $items = null) { // Create Data List: $tags = DataList::create(static::class); // Filter Tagged Items: if ($items instanceof DataList) { if (!$items->exists()) { return ArrayList::create(); } if ($belongs = Config::inst()->get(static::class, 'belongs_many_many')) { // Filter Tags Associated with Items: if ($component = array_search($items->dataClass(), $belongs)) { $tags = $tags->filter(sprintf('%s.ID', $component), $items->column('ID')); } } } // Convert List to Array: $tags = $tags->toArray(); // Associate Tags with Source: foreach ($tags as $tag) { $tag->setSource($source); } // Answer Array List: return ArrayList::create($tags); }
php
public static function forSource(TagSource $source, SS_List $items = null) { // Create Data List: $tags = DataList::create(static::class); // Filter Tagged Items: if ($items instanceof DataList) { if (!$items->exists()) { return ArrayList::create(); } if ($belongs = Config::inst()->get(static::class, 'belongs_many_many')) { // Filter Tags Associated with Items: if ($component = array_search($items->dataClass(), $belongs)) { $tags = $tags->filter(sprintf('%s.ID', $component), $items->column('ID')); } } } // Convert List to Array: $tags = $tags->toArray(); // Associate Tags with Source: foreach ($tags as $tag) { $tag->setSource($source); } // Answer Array List: return ArrayList::create($tags); }
[ "public", "static", "function", "forSource", "(", "TagSource", "$", "source", ",", "SS_List", "$", "items", "=", "null", ")", "{", "// Create Data List:", "$", "tags", "=", "DataList", "::", "create", "(", "static", "::", "class", ")", ";", "// Filter Tagged Items:", "if", "(", "$", "items", "instanceof", "DataList", ")", "{", "if", "(", "!", "$", "items", "->", "exists", "(", ")", ")", "{", "return", "ArrayList", "::", "create", "(", ")", ";", "}", "if", "(", "$", "belongs", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "static", "::", "class", ",", "'belongs_many_many'", ")", ")", "{", "// Filter Tags Associated with Items:", "if", "(", "$", "component", "=", "array_search", "(", "$", "items", "->", "dataClass", "(", ")", ",", "$", "belongs", ")", ")", "{", "$", "tags", "=", "$", "tags", "->", "filter", "(", "sprintf", "(", "'%s.ID'", ",", "$", "component", ")", ",", "$", "items", "->", "column", "(", "'ID'", ")", ")", ";", "}", "}", "}", "// Convert List to Array:", "$", "tags", "=", "$", "tags", "->", "toArray", "(", ")", ";", "// Associate Tags with Source:", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "tag", "->", "setSource", "(", "$", "source", ")", ";", "}", "// Answer Array List:", "return", "ArrayList", "::", "create", "(", "$", "tags", ")", ";", "}" ]
Answers a list of tags for the given tag source and optional list of tagged items. @param TagSource $source The tag source object. @param SS_List $items Optional list of tagged items for filtering tags. @return ArrayList
[ "Answers", "a", "list", "of", "tags", "for", "the", "given", "tag", "source", "and", "optional", "list", "of", "tagged", "items", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tags/Tag.php#L132-L171
232,066
praxisnetau/silverware
src/Tags/Tag.php
Tag.getTagged
public function getTagged() { foreach ($this->manyMany() as $name => $class) { if (self::getSchema()->manyManyComponent(static::class, $name)['parentClass'] === static::class) { return $this->getManyManyComponents($name); } } }
php
public function getTagged() { foreach ($this->manyMany() as $name => $class) { if (self::getSchema()->manyManyComponent(static::class, $name)['parentClass'] === static::class) { return $this->getManyManyComponents($name); } } }
[ "public", "function", "getTagged", "(", ")", "{", "foreach", "(", "$", "this", "->", "manyMany", "(", ")", "as", "$", "name", "=>", "$", "class", ")", "{", "if", "(", "self", "::", "getSchema", "(", ")", "->", "manyManyComponent", "(", "static", "::", "class", ",", "$", "name", ")", "[", "'parentClass'", "]", "===", "static", "::", "class", ")", "{", "return", "$", "this", "->", "getManyManyComponents", "(", "$", "name", ")", ";", "}", "}", "}" ]
Answers a list of the records tagged by the receiver. @return ManyManyList
[ "Answers", "a", "list", "of", "the", "records", "tagged", "by", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tags/Tag.php#L268-L277
232,067
praxisnetau/silverware
src/Tags/Tag.php
Tag.getDefaultSource
public function getDefaultSource() { if (($name = $this->config()->default_source) && $source = Controller::curr()->{$name}) { return $source; } }
php
public function getDefaultSource() { if (($name = $this->config()->default_source) && $source = Controller::curr()->{$name}) { return $source; } }
[ "public", "function", "getDefaultSource", "(", ")", "{", "if", "(", "(", "$", "name", "=", "$", "this", "->", "config", "(", ")", "->", "default_source", ")", "&&", "$", "source", "=", "Controller", "::", "curr", "(", ")", "->", "{", "$", "name", "}", ")", "{", "return", "$", "source", ";", "}", "}" ]
Answers the default source object for the tag. @return SiteTree
[ "Answers", "the", "default", "source", "object", "for", "the", "tag", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tags/Tag.php#L298-L303
232,068
praxisnetau/silverware
src/Tags/Tag.php
Tag.getLink
public function getLink() { if ($source = $this->getSource()) { return $source->Link($this->TagAction); } if ($source = $this->getDefaultSource()) { return $source->Link($this->TagAction); } return $this->TagAction; }
php
public function getLink() { if ($source = $this->getSource()) { return $source->Link($this->TagAction); } if ($source = $this->getDefaultSource()) { return $source->Link($this->TagAction); } return $this->TagAction; }
[ "public", "function", "getLink", "(", ")", "{", "if", "(", "$", "source", "=", "$", "this", "->", "getSource", "(", ")", ")", "{", "return", "$", "source", "->", "Link", "(", "$", "this", "->", "TagAction", ")", ";", "}", "if", "(", "$", "source", "=", "$", "this", "->", "getDefaultSource", "(", ")", ")", "{", "return", "$", "source", "->", "Link", "(", "$", "this", "->", "TagAction", ")", ";", "}", "return", "$", "this", "->", "TagAction", ";", "}" ]
Answers the link for the tag. @return string
[ "Answers", "the", "link", "for", "the", "tag", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tags/Tag.php#L310-L321
232,069
kuzzleio/sdk-php
src/MemoryStorage.php
MemoryStorage.mapGeoRadiusResults
private function mapGeoRadiusResults($results) { $ret = []; // Simple array of point names (no options provided) if (!is_array($results[0])) { foreach ($results as $point) { array_push($ret, ['name' => $point]); } return $ret; } foreach ($results as $point) { // The point id is always the first item $p = ['name' => $point[0]]; $pointLength = count($point); for ($i = 1; $i < $pointLength; $i++) { // withcoord results are stored in an array... if (is_array($point[$i])) { $p['coordinates'] = []; foreach ($point[$i] as $coord) { array_push($p['coordinates'], floatval($coord)); } } else { // ... while withdist ones are not $p['distance'] = floatval($point[$i]); } } array_push($ret, $p); } return $ret; }
php
private function mapGeoRadiusResults($results) { $ret = []; // Simple array of point names (no options provided) if (!is_array($results[0])) { foreach ($results as $point) { array_push($ret, ['name' => $point]); } return $ret; } foreach ($results as $point) { // The point id is always the first item $p = ['name' => $point[0]]; $pointLength = count($point); for ($i = 1; $i < $pointLength; $i++) { // withcoord results are stored in an array... if (is_array($point[$i])) { $p['coordinates'] = []; foreach ($point[$i] as $coord) { array_push($p['coordinates'], floatval($coord)); } } else { // ... while withdist ones are not $p['distance'] = floatval($point[$i]); } } array_push($ret, $p); } return $ret; }
[ "private", "function", "mapGeoRadiusResults", "(", "$", "results", ")", "{", "$", "ret", "=", "[", "]", ";", "// Simple array of point names (no options provided)", "if", "(", "!", "is_array", "(", "$", "results", "[", "0", "]", ")", ")", "{", "foreach", "(", "$", "results", "as", "$", "point", ")", "{", "array_push", "(", "$", "ret", ",", "[", "'name'", "=>", "$", "point", "]", ")", ";", "}", "return", "$", "ret", ";", "}", "foreach", "(", "$", "results", "as", "$", "point", ")", "{", "// The point id is always the first item", "$", "p", "=", "[", "'name'", "=>", "$", "point", "[", "0", "]", "]", ";", "$", "pointLength", "=", "count", "(", "$", "point", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "pointLength", ";", "$", "i", "++", ")", "{", "// withcoord results are stored in an array...", "if", "(", "is_array", "(", "$", "point", "[", "$", "i", "]", ")", ")", "{", "$", "p", "[", "'coordinates'", "]", "=", "[", "]", ";", "foreach", "(", "$", "point", "[", "$", "i", "]", "as", "$", "coord", ")", "{", "array_push", "(", "$", "p", "[", "'coordinates'", "]", ",", "floatval", "(", "$", "coord", ")", ")", ";", "}", "}", "else", "{", "// ... while withdist ones are not", "$", "p", "[", "'distance'", "]", "=", "floatval", "(", "$", "point", "[", "$", "i", "]", ")", ";", "}", "}", "array_push", "(", "$", "ret", ",", "$", "p", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Maps georadius results to the format specified in the SDK documentation, preventing different formats depending on the passed options Results can be either an array of point names, or an array of arrays, each one of them containing the point name, and additional informations depending on the passed options (coordinates, distances) @param results @return array
[ "Maps", "georadius", "results", "to", "the", "format", "specified", "in", "the", "SDK", "documentation", "preventing", "different", "formats", "depending", "on", "the", "passed", "options" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/MemoryStorage.php#L503-L539
232,070
kuzzleio/sdk-php
src/MemoryStorage.php
MemoryStorage.mapArrayStringToArrayInt
private function mapArrayStringToArrayInt($results) { $ret = []; foreach ($results as $value) { array_push($ret, intval($value)); } return $ret; }
php
private function mapArrayStringToArrayInt($results) { $ret = []; foreach ($results as $value) { array_push($ret, intval($value)); } return $ret; }
[ "private", "function", "mapArrayStringToArrayInt", "(", "$", "results", ")", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "results", "as", "$", "value", ")", "{", "array_push", "(", "$", "ret", ",", "intval", "(", "$", "value", ")", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Map an array of strings to an array of integers @param results @return array
[ "Map", "an", "array", "of", "strings", "to", "an", "array", "of", "integers" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/MemoryStorage.php#L559-L568
232,071
shopwareLabs/plugin-info
src/PluginInfo.php
PluginInfo.get
public function get($plugin) { $pluginJson = $this->backend->getPluginInfo($plugin); $this->validate($pluginJson); $pluginStruct = $this->hydrator->get($pluginJson); return new InfoDecorator($pluginStruct); }
php
public function get($plugin) { $pluginJson = $this->backend->getPluginInfo($plugin); $this->validate($pluginJson); $pluginStruct = $this->hydrator->get($pluginJson); return new InfoDecorator($pluginStruct); }
[ "public", "function", "get", "(", "$", "plugin", ")", "{", "$", "pluginJson", "=", "$", "this", "->", "backend", "->", "getPluginInfo", "(", "$", "plugin", ")", ";", "$", "this", "->", "validate", "(", "$", "pluginJson", ")", ";", "$", "pluginStruct", "=", "$", "this", "->", "hydrator", "->", "get", "(", "$", "pluginJson", ")", ";", "return", "new", "InfoDecorator", "(", "$", "pluginStruct", ")", ";", "}" ]
Depending on the backend, plugin could be a directory or zip @param string $plugin @return InfoDecorator
[ "Depending", "on", "the", "backend", "plugin", "could", "be", "a", "directory", "or", "zip" ]
2d553fdd463ed95fd58aba7adba78a35442a302f
https://github.com/shopwareLabs/plugin-info/blob/2d553fdd463ed95fd58aba7adba78a35442a302f/src/PluginInfo.php#L43-L52
232,072
shopwareLabs/plugin-info
src/PluginInfo.php
PluginInfo.validate
private function validate($json) { $retriever = new JsonSchema\Uri\UriRetriever(); // Detect phar archives - they don't need the file:// prefix $prefix = strpos(__DIR__, 'phar://') === 0 ? '' : 'file://'; $schema = $retriever->retrieve( $prefix . __DIR__ . '/../res/plugin-info-schema.json' ); $validator = new JsonSchema\Validator(); $validator->check(json_decode(json_encode($json)), $schema); if (!$validator->isValid()) { $errors = array_map(function($error) { return $error['property'] . ': ' . $error['message']; }, $validator->getErrors()); throw new ValidatorException("Json not valid: " . implode(', ', $errors)); } }
php
private function validate($json) { $retriever = new JsonSchema\Uri\UriRetriever(); // Detect phar archives - they don't need the file:// prefix $prefix = strpos(__DIR__, 'phar://') === 0 ? '' : 'file://'; $schema = $retriever->retrieve( $prefix . __DIR__ . '/../res/plugin-info-schema.json' ); $validator = new JsonSchema\Validator(); $validator->check(json_decode(json_encode($json)), $schema); if (!$validator->isValid()) { $errors = array_map(function($error) { return $error['property'] . ': ' . $error['message']; }, $validator->getErrors()); throw new ValidatorException("Json not valid: " . implode(', ', $errors)); } }
[ "private", "function", "validate", "(", "$", "json", ")", "{", "$", "retriever", "=", "new", "JsonSchema", "\\", "Uri", "\\", "UriRetriever", "(", ")", ";", "// Detect phar archives - they don't need the file:// prefix", "$", "prefix", "=", "strpos", "(", "__DIR__", ",", "'phar://'", ")", "===", "0", "?", "''", ":", "'file://'", ";", "$", "schema", "=", "$", "retriever", "->", "retrieve", "(", "$", "prefix", ".", "__DIR__", ".", "'/../res/plugin-info-schema.json'", ")", ";", "$", "validator", "=", "new", "JsonSchema", "\\", "Validator", "(", ")", ";", "$", "validator", "->", "check", "(", "json_decode", "(", "json_encode", "(", "$", "json", ")", ")", ",", "$", "schema", ")", ";", "if", "(", "!", "$", "validator", "->", "isValid", "(", ")", ")", "{", "$", "errors", "=", "array_map", "(", "function", "(", "$", "error", ")", "{", "return", "$", "error", "[", "'property'", "]", ".", "': '", ".", "$", "error", "[", "'message'", "]", ";", "}", ",", "$", "validator", "->", "getErrors", "(", ")", ")", ";", "throw", "new", "ValidatorException", "(", "\"Json not valid: \"", ".", "implode", "(", "', '", ",", "$", "errors", ")", ")", ";", "}", "}" ]
validate a given plugin object against the defined json format @param $json @throws Exceptions\ValidatorException
[ "validate", "a", "given", "plugin", "object", "against", "the", "defined", "json", "format" ]
2d553fdd463ed95fd58aba7adba78a35442a302f
https://github.com/shopwareLabs/plugin-info/blob/2d553fdd463ed95fd58aba7adba78a35442a302f/src/PluginInfo.php#L60-L81
232,073
i-am-tom/schemer
src/Validator/Text.php
Text.email
public function email() : Text { return $this->pipe( self::predicate( function (string $value) : bool { return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; }, 'not an email' ) ); }
php
public function email() : Text { return $this->pipe( self::predicate( function (string $value) : bool { return filter_var($value, FILTER_VALIDATE_EMAIL) !== false; }, 'not an email' ) ); }
[ "public", "function", "email", "(", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "string", "$", "value", ")", ":", "bool", "{", "return", "filter_var", "(", "$", "value", ",", "FILTER_VALIDATE_EMAIL", ")", "!==", "false", ";", "}", ",", "'not an email'", ")", ")", ";", "}" ]
This string must be an email. @return Schemer\Validator\Text
[ "This", "string", "must", "be", "an", "email", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Text.php#L45-L55
232,074
i-am-tom/schemer
src/Validator/Text.php
Text.max
public function max(int $length) : Text { return $this->pipe( self::predicate( function (string $value) use ($length) : bool { return strlen($value) <= $length; }, 'more than ' . self::characterf($length) ) ); }
php
public function max(int $length) : Text { return $this->pipe( self::predicate( function (string $value) use ($length) : bool { return strlen($value) <= $length; }, 'more than ' . self::characterf($length) ) ); }
[ "public", "function", "max", "(", "int", "$", "length", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "string", "$", "value", ")", "use", "(", "$", "length", ")", ":", "bool", "{", "return", "strlen", "(", "$", "value", ")", "<=", "$", "length", ";", "}", ",", "'more than '", ".", "self", "::", "characterf", "(", "$", "length", ")", ")", ")", ";", "}" ]
This string must have at most a given number of characters. @param int $length The maximum string length. @return Schemer\Validator\Text
[ "This", "string", "must", "have", "at", "most", "a", "given", "number", "of", "characters", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Text.php#L88-L98
232,075
i-am-tom/schemer
src/Validator/Text.php
Text.regex
public function regex(string $regex) : Text { return $this->pipe( self::predicate( function ($value) use ($regex) { return preg_match($regex, $value) === 1; }, "does not match $regex" ) ); }
php
public function regex(string $regex) : Text { return $this->pipe( self::predicate( function ($value) use ($regex) { return preg_match($regex, $value) === 1; }, "does not match $regex" ) ); }
[ "public", "function", "regex", "(", "string", "$", "regex", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "$", "value", ")", "use", "(", "$", "regex", ")", "{", "return", "preg_match", "(", "$", "regex", ",", "$", "value", ")", "===", "1", ";", "}", ",", "\"does not match $regex\"", ")", ")", ";", "}" ]
This string must match a given regular expression. @param string $regex The regular expression to match. @return Schemer\Validator\Text
[ "This", "string", "must", "match", "a", "given", "regular", "expression", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Text.php#L122-L132
232,076
kuzzleio/sdk-php
src/CollectionMapping.php
CollectionMapping.apply
public function apply(array $options = []) { $data = [ 'body' => [ 'properties' => $this->mapping ] ]; $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('collection', 'updateMapping'), $this->collection->getKuzzle()->addHeaders($data, $this->headers), $options ); return $this->refresh($options); }
php
public function apply(array $options = []) { $data = [ 'body' => [ 'properties' => $this->mapping ] ]; $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('collection', 'updateMapping'), $this->collection->getKuzzle()->addHeaders($data, $this->headers), $options ); return $this->refresh($options); }
[ "public", "function", "apply", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'body'", "=>", "[", "'properties'", "=>", "$", "this", "->", "mapping", "]", "]", ";", "$", "this", "->", "collection", "->", "getKuzzle", "(", ")", "->", "query", "(", "$", "this", "->", "collection", "->", "buildQueryArgs", "(", "'collection'", ",", "'updateMapping'", ")", ",", "$", "this", "->", "collection", "->", "getKuzzle", "(", ")", "->", "addHeaders", "(", "$", "data", ",", "$", "this", "->", "headers", ")", ",", "$", "options", ")", ";", "return", "$", "this", "->", "refresh", "(", "$", "options", ")", ";", "}" ]
Applies the new mapping to the data collection. @param array $options Optional parameters @return CollectionMapping
[ "Applies", "the", "new", "mapping", "to", "the", "data", "collection", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/CollectionMapping.php#L48-L63
232,077
kuzzleio/sdk-php
src/CollectionMapping.php
CollectionMapping.refresh
public function refresh(array $options = []) { $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('collection', 'getMapping'), $this->collection->getKuzzle()->addHeaders([], $this->headers), $options ); if (array_key_exists($this->collection->getIndexName(), $response['result'])) { $indexMappings = $response['result'][$this->collection->getIndexName()]['mappings']; if (array_key_exists($this->collection->getCollectionName(), $indexMappings)) { $this->mapping = $indexMappings[$this->collection->getCollectionName()]['properties']; } else { throw new ErrorException('No mapping found for collection ' . $this->collection->getCollectionName()); } } else { throw new ErrorException('No mapping found for index ' . $this->collection->getIndexName()); } return $this; }
php
public function refresh(array $options = []) { $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('collection', 'getMapping'), $this->collection->getKuzzle()->addHeaders([], $this->headers), $options ); if (array_key_exists($this->collection->getIndexName(), $response['result'])) { $indexMappings = $response['result'][$this->collection->getIndexName()]['mappings']; if (array_key_exists($this->collection->getCollectionName(), $indexMappings)) { $this->mapping = $indexMappings[$this->collection->getCollectionName()]['properties']; } else { throw new ErrorException('No mapping found for collection ' . $this->collection->getCollectionName()); } } else { throw new ErrorException('No mapping found for index ' . $this->collection->getIndexName()); } return $this; }
[ "public", "function", "refresh", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "collection", "->", "getKuzzle", "(", ")", "->", "query", "(", "$", "this", "->", "collection", "->", "buildQueryArgs", "(", "'collection'", ",", "'getMapping'", ")", ",", "$", "this", "->", "collection", "->", "getKuzzle", "(", ")", "->", "addHeaders", "(", "[", "]", ",", "$", "this", "->", "headers", ")", ",", "$", "options", ")", ";", "if", "(", "array_key_exists", "(", "$", "this", "->", "collection", "->", "getIndexName", "(", ")", ",", "$", "response", "[", "'result'", "]", ")", ")", "{", "$", "indexMappings", "=", "$", "response", "[", "'result'", "]", "[", "$", "this", "->", "collection", "->", "getIndexName", "(", ")", "]", "[", "'mappings'", "]", ";", "if", "(", "array_key_exists", "(", "$", "this", "->", "collection", "->", "getCollectionName", "(", ")", ",", "$", "indexMappings", ")", ")", "{", "$", "this", "->", "mapping", "=", "$", "indexMappings", "[", "$", "this", "->", "collection", "->", "getCollectionName", "(", ")", "]", "[", "'properties'", "]", ";", "}", "else", "{", "throw", "new", "ErrorException", "(", "'No mapping found for collection '", ".", "$", "this", "->", "collection", "->", "getCollectionName", "(", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "ErrorException", "(", "'No mapping found for index '", ".", "$", "this", "->", "collection", "->", "getIndexName", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Instantiates a new CollectionMapping object with an up-to-date content. @param array $options Optional parameters @return CollectionMapping @throws ErrorException
[ "Instantiates", "a", "new", "CollectionMapping", "object", "with", "an", "up", "-", "to", "-", "date", "content", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/CollectionMapping.php#L73-L94
232,078
i-am-tom/schemer
src/Validator/Real.php
Real.exactly
public function exactly(float $check, string $error = 'not exactly %d') : Real { return $this->pipe( self::predicate( function (float $value) use ($check) : bool { return $value === $check; }, sprintf($error, $check) ) ); }
php
public function exactly(float $check, string $error = 'not exactly %d') : Real { return $this->pipe( self::predicate( function (float $value) use ($check) : bool { return $value === $check; }, sprintf($error, $check) ) ); }
[ "public", "function", "exactly", "(", "float", "$", "check", ",", "string", "$", "error", "=", "'not exactly %d'", ")", ":", "Real", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "float", "$", "value", ")", "use", "(", "$", "check", ")", ":", "bool", "{", "return", "$", "value", "===", "$", "check", ";", "}", ",", "sprintf", "(", "$", "error", ",", "$", "check", ")", ")", ")", ";", "}" ]
The number must be exactly a given value. @param float check @param string $error @return Schemer\Validator\Real
[ "The", "number", "must", "be", "exactly", "a", "given", "value", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Real.php#L28-L38
232,079
i-am-tom/schemer
src/Validator/Real.php
Real.max
public function max(float $max, string $error = 'not at most %d') : Real { return $this->pipe( self::predicate( function (float $value) use ($max) : bool { return $value <= $max; }, sprintf($error, $max) ) ); }
php
public function max(float $max, string $error = 'not at most %d') : Real { return $this->pipe( self::predicate( function (float $value) use ($max) : bool { return $value <= $max; }, sprintf($error, $max) ) ); }
[ "public", "function", "max", "(", "float", "$", "max", ",", "string", "$", "error", "=", "'not at most %d'", ")", ":", "Real", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "float", "$", "value", ")", "use", "(", "$", "max", ")", ":", "bool", "{", "return", "$", "value", "<=", "$", "max", ";", "}", ",", "sprintf", "(", "$", "error", ",", "$", "max", ")", ")", ")", ";", "}" ]
The number must be at most a given value. @param float $max @param string $error @return Schemer\Validator\Real
[ "The", "number", "must", "be", "at", "most", "a", "given", "value", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Real.php#L46-L56
232,080
i-am-tom/schemer
src/Validator/Real.php
Real.min
public function min(float $min, string $error = 'not at least %d') : Real { return $this->pipe( self::predicate( function (float $value) use ($min) : bool { return $value >= $min; }, sprintf($error, $min) ) ); }
php
public function min(float $min, string $error = 'not at least %d') : Real { return $this->pipe( self::predicate( function (float $value) use ($min) : bool { return $value >= $min; }, sprintf($error, $min) ) ); }
[ "public", "function", "min", "(", "float", "$", "min", ",", "string", "$", "error", "=", "'not at least %d'", ")", ":", "Real", "{", "return", "$", "this", "->", "pipe", "(", "self", "::", "predicate", "(", "function", "(", "float", "$", "value", ")", "use", "(", "$", "min", ")", ":", "bool", "{", "return", "$", "value", ">=", "$", "min", ";", "}", ",", "sprintf", "(", "$", "error", ",", "$", "min", ")", ")", ")", ";", "}" ]
The number must be at least a given value. @param float $min @param string $error @return Schemer\Validator\Real
[ "The", "number", "must", "be", "at", "least", "a", "given", "value", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Validator/Real.php#L64-L74
232,081
mthenw/nosqlite.php
src/NoSQLite/Store.php
Store.getAll
public function getAll() { if (!$this->isDataLoadedFromDb) { $stmt = $this->db->prepare('SELECT * FROM ' . $this->name); $stmt->execute(); while ($row = $stmt->fetch(\PDO::FETCH_NUM, \PDO::FETCH_ORI_NEXT)) { $this->data[$row[0]] = $row[1]; } } return $this->data; }
php
public function getAll() { if (!$this->isDataLoadedFromDb) { $stmt = $this->db->prepare('SELECT * FROM ' . $this->name); $stmt->execute(); while ($row = $stmt->fetch(\PDO::FETCH_NUM, \PDO::FETCH_ORI_NEXT)) { $this->data[$row[0]] = $row[1]; } } return $this->data; }
[ "public", "function", "getAll", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isDataLoadedFromDb", ")", "{", "$", "stmt", "=", "$", "this", "->", "db", "->", "prepare", "(", "'SELECT * FROM '", ".", "$", "this", "->", "name", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "while", "(", "$", "row", "=", "$", "stmt", "->", "fetch", "(", "\\", "PDO", "::", "FETCH_NUM", ",", "\\", "PDO", "::", "FETCH_ORI_NEXT", ")", ")", "{", "$", "this", "->", "data", "[", "$", "row", "[", "0", "]", "]", "=", "$", "row", "[", "1", "]", ";", "}", "}", "return", "$", "this", "->", "data", ";", "}" ]
Get all values as array with key => value structure @return array
[ "Get", "all", "values", "as", "array", "with", "key", "=", ">", "value", "structure" ]
c05dde438831c100e888301259974fb47ad26c4a
https://github.com/mthenw/nosqlite.php/blob/c05dde438831c100e888301259974fb47ad26c4a/src/NoSQLite/Store.php#L100-L112
232,082
mthenw/nosqlite.php
src/NoSQLite/Store.php
Store.deleteAll
public function deleteAll() { $stmt = $this->db->prepare('DELETE FROM ' . $this->name); $stmt->execute(); $this->data = array(); }
php
public function deleteAll() { $stmt = $this->db->prepare('DELETE FROM ' . $this->name); $stmt->execute(); $this->data = array(); }
[ "public", "function", "deleteAll", "(", ")", "{", "$", "stmt", "=", "$", "this", "->", "db", "->", "prepare", "(", "'DELETE FROM '", ".", "$", "this", "->", "name", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "$", "this", "->", "data", "=", "array", "(", ")", ";", "}" ]
Delete all values from store @return null
[ "Delete", "all", "values", "from", "store" ]
c05dde438831c100e888301259974fb47ad26c4a
https://github.com/mthenw/nosqlite.php/blob/c05dde438831c100e888301259974fb47ad26c4a/src/NoSQLite/Store.php#L163-L168
232,083
mthenw/nosqlite.php
src/NoSQLite/Store.php
Store.createTable
private function createTable() { $stmt = 'CREATE TABLE IF NOT EXISTS "' . $this->name; $stmt.= '" ("' . $this->keyColumnName . '" TEXT PRIMARY KEY, "'; $stmt.= $this->valueColumnName . '" TEXT);'; $this->db->exec($stmt); }
php
private function createTable() { $stmt = 'CREATE TABLE IF NOT EXISTS "' . $this->name; $stmt.= '" ("' . $this->keyColumnName . '" TEXT PRIMARY KEY, "'; $stmt.= $this->valueColumnName . '" TEXT);'; $this->db->exec($stmt); }
[ "private", "function", "createTable", "(", ")", "{", "$", "stmt", "=", "'CREATE TABLE IF NOT EXISTS \"'", ".", "$", "this", "->", "name", ";", "$", "stmt", ".=", "'\" (\"'", ".", "$", "this", "->", "keyColumnName", ".", "'\" TEXT PRIMARY KEY, \"'", ";", "$", "stmt", ".=", "$", "this", "->", "valueColumnName", ".", "'\" TEXT);'", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "stmt", ")", ";", "}" ]
Create storage table in database if not exists @return null
[ "Create", "storage", "table", "in", "database", "if", "not", "exists" ]
c05dde438831c100e888301259974fb47ad26c4a
https://github.com/mthenw/nosqlite.php/blob/c05dde438831c100e888301259974fb47ad26c4a/src/NoSQLite/Store.php#L226-L232
232,084
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.addListener
public function addListener($event, $listener) { if (!is_callable($listener)) { throw new InvalidArgumentException('Unable to add a listener on event "' . $event . '": given listener is not callable'); } if (!array_key_exists($event, $this->listeners)) { $this->listeners[$event] = []; } $this->listeners[$event][spl_object_hash($listener)] = $listener; return $this; }
php
public function addListener($event, $listener) { if (!is_callable($listener)) { throw new InvalidArgumentException('Unable to add a listener on event "' . $event . '": given listener is not callable'); } if (!array_key_exists($event, $this->listeners)) { $this->listeners[$event] = []; } $this->listeners[$event][spl_object_hash($listener)] = $listener; return $this; }
[ "public", "function", "addListener", "(", "$", "event", ",", "$", "listener", ")", "{", "if", "(", "!", "is_callable", "(", "$", "listener", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unable to add a listener on event \"'", ".", "$", "event", ".", "'\": given listener is not callable'", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "event", ",", "$", "this", "->", "listeners", ")", ")", "{", "$", "this", "->", "listeners", "[", "$", "event", "]", "=", "[", "]", ";", "}", "$", "this", "->", "listeners", "[", "$", "event", "]", "[", "spl_object_hash", "(", "$", "listener", ")", "]", "=", "$", "listener", ";", "return", "$", "this", ";", "}" ]
Adds a listener to a Kuzzle global event. When an event is fired, listeners are called in the order of their insertion. @param string $event One of the event described in the Event Handling section of the kuzzle documentation @param callable $listener The function to call each time one of the registered event is fired @return Kuzzle @throws InvalidArgumentException
[ "Adds", "a", "listener", "to", "a", "Kuzzle", "global", "event", ".", "When", "an", "event", "is", "fired", "listeners", "are", "called", "in", "the", "order", "of", "their", "insertion", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L134-L147
232,085
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.emitEvent
public function emitEvent($event) { if (array_key_exists($event, $this->listeners)) { $arg_list = func_get_args(); array_shift($arg_list); foreach ($this->listeners[$event] as $callback) { call_user_func_array($callback, $arg_list); } } return $this; }
php
public function emitEvent($event) { if (array_key_exists($event, $this->listeners)) { $arg_list = func_get_args(); array_shift($arg_list); foreach ($this->listeners[$event] as $callback) { call_user_func_array($callback, $arg_list); } } return $this; }
[ "public", "function", "emitEvent", "(", "$", "event", ")", "{", "if", "(", "array_key_exists", "(", "$", "event", ",", "$", "this", "->", "listeners", ")", ")", "{", "$", "arg_list", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "arg_list", ")", ";", "foreach", "(", "$", "this", "->", "listeners", "[", "$", "event", "]", "as", "$", "callback", ")", "{", "call_user_func_array", "(", "$", "callback", ",", "$", "arg_list", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Emit an event to all registered listeners @param string $event One of the event described in the Event Handling section of the kuzzle documentation @return Kuzzle
[ "Emit", "an", "event", "to", "all", "registered", "listeners" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L156-L167
232,086
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.checkToken
public function checkToken($token, array $options = []) { $response = $this->query( $this->buildQueryArgs('auth', 'checkToken'), [ 'body' => ['token' => $token] ], $options ); return $response['result']; }
php
public function checkToken($token, array $options = []) { $response = $this->query( $this->buildQueryArgs('auth', 'checkToken'), [ 'body' => ['token' => $token] ], $options ); return $response['result']; }
[ "public", "function", "checkToken", "(", "$", "token", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'auth'", ",", "'checkToken'", ")", ",", "[", "'body'", "=>", "[", "'token'", "=>", "$", "token", "]", "]", ",", "$", "options", ")", ";", "return", "$", "response", "[", "'result'", "]", ";", "}" ]
Checks the validity of a JSON Web Token. @param string $token The token to check @param array $options Optional parameters @return array with a valid boolean property. If the token is valid, a expiresAt property is set with the expiration timestamp. If not, a state property is set explaining why the token is invalid.
[ "Checks", "the", "validity", "of", "a", "JSON", "Web", "Token", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L178-L189
232,087
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.collection
public function collection($collection, $index = '') { if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to create a new data collection object: no index specified'); } $index = $this->defaultIndex; } if (!array_key_exists($index, $this->collections)) { $this->collections[$index] = []; } if (!array_key_exists($collection, $this->collections[$index])) { $this->collections[$index][$collection] = new Collection($this, $collection, $index); } return $this->collections[$index][$collection]; }
php
public function collection($collection, $index = '') { if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to create a new data collection object: no index specified'); } $index = $this->defaultIndex; } if (!array_key_exists($index, $this->collections)) { $this->collections[$index] = []; } if (!array_key_exists($collection, $this->collections[$index])) { $this->collections[$index][$collection] = new Collection($this, $collection, $index); } return $this->collections[$index][$collection]; }
[ "public", "function", "collection", "(", "$", "collection", ",", "$", "index", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "index", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "defaultIndex", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unable to create a new data collection object: no index specified'", ")", ";", "}", "$", "index", "=", "$", "this", "->", "defaultIndex", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "collections", ")", ")", "{", "$", "this", "->", "collections", "[", "$", "index", "]", "=", "[", "]", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "collection", ",", "$", "this", "->", "collections", "[", "$", "index", "]", ")", ")", "{", "$", "this", "->", "collections", "[", "$", "index", "]", "[", "$", "collection", "]", "=", "new", "Collection", "(", "$", "this", ",", "$", "collection", ",", "$", "index", ")", ";", "}", "return", "$", "this", "->", "collections", "[", "$", "index", "]", "[", "$", "collection", "]", ";", "}" ]
Instantiates a new KuzzleDataCollection object. @param string $collection The name of the data collection you want to manipulate @param string $index The name of the index containing the data collection @return Collection @throws InvalidArgumentException
[ "Instantiates", "a", "new", "KuzzleDataCollection", "object", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L224-L243
232,088
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.listCollections
public function listCollections($index = '', array $options = []) { $collectionType = 'all'; if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to list collections: no index specified'); } $index = $this->defaultIndex; } if (array_key_exists('type', $options)) { $collectionType = $options['type']; } $options['httpParams'] = [ ':type' => $collectionType ]; $query = [ 'body' => [ 'type' => $collectionType ] ]; $response = $this->query($this->buildQueryArgs('collection', 'list', $index), $query, $options); return $response['result']['collections']; }
php
public function listCollections($index = '', array $options = []) { $collectionType = 'all'; if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to list collections: no index specified'); } $index = $this->defaultIndex; } if (array_key_exists('type', $options)) { $collectionType = $options['type']; } $options['httpParams'] = [ ':type' => $collectionType ]; $query = [ 'body' => [ 'type' => $collectionType ] ]; $response = $this->query($this->buildQueryArgs('collection', 'list', $index), $query, $options); return $response['result']['collections']; }
[ "public", "function", "listCollections", "(", "$", "index", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "collectionType", "=", "'all'", ";", "if", "(", "empty", "(", "$", "index", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "defaultIndex", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unable to list collections: no index specified'", ")", ";", "}", "$", "index", "=", "$", "this", "->", "defaultIndex", ";", "}", "if", "(", "array_key_exists", "(", "'type'", ",", "$", "options", ")", ")", "{", "$", "collectionType", "=", "$", "options", "[", "'type'", "]", ";", "}", "$", "options", "[", "'httpParams'", "]", "=", "[", "':type'", "=>", "$", "collectionType", "]", ";", "$", "query", "=", "[", "'body'", "=>", "[", "'type'", "=>", "$", "collectionType", "]", "]", ";", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'collection'", ",", "'list'", ",", "$", "index", ")", ",", "$", "query", ",", "$", "options", ")", ";", "return", "$", "response", "[", "'result'", "]", "[", "'collections'", "]", ";", "}" ]
Retrieves the list of known data collections contained in a specified index. @param string $index Index containing the collections to be listed @param array $options Optional parameters @return array containing the list of stored and/or realtime collections on the provided index @throws InvalidArgumentException
[ "Retrieves", "the", "list", "of", "known", "data", "collections", "contained", "in", "a", "specified", "index", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L371-L400
232,089
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.login
public function login($strategy, array $credentials = [], $expiresIn = '', array $options = []) { $body = $credentials; if (empty($strategy)) { throw new InvalidArgumentException('Unable to login: no strategy specified'); } if (!array_key_exists('httpParams', $options)) { $options['httpParams'] = []; } if (!array_key_exists(':strategy', $options['httpParams'])) { $options['httpParams'][':strategy'] = $strategy; } if (!empty($expiresIn)) { $options['query_parameters']['expiresIn'] = $expiresIn; } $response = $this->query( $this->buildQueryArgs('auth', 'login'), [ 'body' => $body ], $options ); if ($response['result']['jwt']) { $this->jwtToken = $response['result']['jwt']; } return $response['result']; }
php
public function login($strategy, array $credentials = [], $expiresIn = '', array $options = []) { $body = $credentials; if (empty($strategy)) { throw new InvalidArgumentException('Unable to login: no strategy specified'); } if (!array_key_exists('httpParams', $options)) { $options['httpParams'] = []; } if (!array_key_exists(':strategy', $options['httpParams'])) { $options['httpParams'][':strategy'] = $strategy; } if (!empty($expiresIn)) { $options['query_parameters']['expiresIn'] = $expiresIn; } $response = $this->query( $this->buildQueryArgs('auth', 'login'), [ 'body' => $body ], $options ); if ($response['result']['jwt']) { $this->jwtToken = $response['result']['jwt']; } return $response['result']; }
[ "public", "function", "login", "(", "$", "strategy", ",", "array", "$", "credentials", "=", "[", "]", ",", "$", "expiresIn", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "body", "=", "$", "credentials", ";", "if", "(", "empty", "(", "$", "strategy", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unable to login: no strategy specified'", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'httpParams'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'httpParams'", "]", "=", "[", "]", ";", "}", "if", "(", "!", "array_key_exists", "(", "':strategy'", ",", "$", "options", "[", "'httpParams'", "]", ")", ")", "{", "$", "options", "[", "'httpParams'", "]", "[", "':strategy'", "]", "=", "$", "strategy", ";", "}", "if", "(", "!", "empty", "(", "$", "expiresIn", ")", ")", "{", "$", "options", "[", "'query_parameters'", "]", "[", "'expiresIn'", "]", "=", "$", "expiresIn", ";", "}", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'auth'", ",", "'login'", ")", ",", "[", "'body'", "=>", "$", "body", "]", ",", "$", "options", ")", ";", "if", "(", "$", "response", "[", "'result'", "]", "[", "'jwt'", "]", ")", "{", "$", "this", "->", "jwtToken", "=", "$", "response", "[", "'result'", "]", "[", "'jwt'", "]", ";", "}", "return", "$", "response", "[", "'result'", "]", ";", "}" ]
Log a user according to a strategy and credentials @param string $strategy Authentication strategy (local, facebook, github, …) @param array $credentials Optional login credentials, depending on the strategy @param string $expiresIn Login expiration time @param array $options Optional options @return array
[ "Log", "a", "user", "according", "to", "a", "strategy", "and", "credentials" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L428-L461
232,090
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.now
public function now(array $options = []) { $response = $this->query( $this->buildQueryArgs('server', 'now'), [], $options ); return new DateTime('@' . round($response['result']['now'] / 1000)); }
php
public function now(array $options = []) { $response = $this->query( $this->buildQueryArgs('server', 'now'), [], $options ); return new DateTime('@' . round($response['result']['now'] / 1000)); }
[ "public", "function", "now", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'server'", ",", "'now'", ")", ",", "[", "]", ",", "$", "options", ")", ";", "return", "new", "DateTime", "(", "'@'", ".", "round", "(", "$", "response", "[", "'result'", "]", "[", "'now'", "]", "/", "1000", ")", ")", ";", "}" ]
Retrieves the current Kuzzle time. @param array $options Optional parameters @return DateTime
[ "Retrieves", "the", "current", "Kuzzle", "time", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L503-L512
232,091
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.setAutoRefresh
public function setAutoRefresh($index = '', $autoRefresh = false, array $options = []) { if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to set auto refresh on index: no index specified'); } $index = $this->defaultIndex; } $response = $this->query( $this->buildQueryArgs('index', 'setAutoRefresh', $index), [ 'body' => [ 'autoRefresh' => $autoRefresh ] ], $options ); return $response['result']; }
php
public function setAutoRefresh($index = '', $autoRefresh = false, array $options = []) { if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to set auto refresh on index: no index specified'); } $index = $this->defaultIndex; } $response = $this->query( $this->buildQueryArgs('index', 'setAutoRefresh', $index), [ 'body' => [ 'autoRefresh' => $autoRefresh ] ], $options ); return $response['result']; }
[ "public", "function", "setAutoRefresh", "(", "$", "index", "=", "''", ",", "$", "autoRefresh", "=", "false", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "index", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "defaultIndex", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unable to set auto refresh on index: no index specified'", ")", ";", "}", "$", "index", "=", "$", "this", "->", "defaultIndex", ";", "}", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'index'", ",", "'setAutoRefresh'", ",", "$", "index", ")", ",", "[", "'body'", "=>", "[", "'autoRefresh'", "=>", "$", "autoRefresh", "]", "]", ",", "$", "options", ")", ";", "return", "$", "response", "[", "'result'", "]", ";", "}" ]
The autoRefresh flag, when set to true, will make Kuzzle perform a refresh request immediately after each write request, forcing the documents to be immediately visible to search @param string $index Optional The index to set the autoRefresh for. If not set, defaults to Kuzzle->defaultIndex @param bool $autoRefresh The value to set for the autoRefresh setting. @param array $options Optional parameters @return boolean
[ "The", "autoRefresh", "flag", "when", "set", "to", "true", "will", "make", "Kuzzle", "perform", "a", "refresh", "request", "immediately", "after", "each", "write", "request", "forcing", "the", "documents", "to", "be", "immediately", "visible", "to", "search" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L701-L722
232,092
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.getAutoRefresh
public function getAutoRefresh($index = '', array $options = []) { if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to set auto refresh on index: no index specified'); } $index = $this->defaultIndex; } $response = $this->query( $this->buildQueryArgs('index', 'getAutoRefresh', $index), [], $options ); return $response['result']; }
php
public function getAutoRefresh($index = '', array $options = []) { if (empty($index)) { if (empty($this->defaultIndex)) { throw new InvalidArgumentException('Unable to set auto refresh on index: no index specified'); } $index = $this->defaultIndex; } $response = $this->query( $this->buildQueryArgs('index', 'getAutoRefresh', $index), [], $options ); return $response['result']; }
[ "public", "function", "getAutoRefresh", "(", "$", "index", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "index", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "defaultIndex", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Unable to set auto refresh on index: no index specified'", ")", ";", "}", "$", "index", "=", "$", "this", "->", "defaultIndex", ";", "}", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'index'", ",", "'getAutoRefresh'", ",", "$", "index", ")", ",", "[", "]", ",", "$", "options", ")", ";", "return", "$", "response", "[", "'result'", "]", ";", "}" ]
Returns de current autoRefresh status for the given index @param string $index Optional TThe index to get the status from. Defaults to Kuzzle->defaultIndex @param array $options Optional parameters @return boolean
[ "Returns", "de", "current", "autoRefresh", "status", "for", "the", "given", "index" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L731-L748
232,093
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.updateSelf
public function updateSelf(array $content, array $options = []) { $response = $this->query( $this->buildQueryArgs('auth', 'updateSelf'), [ 'body' => $content ], $options ); return $response['result']; }
php
public function updateSelf(array $content, array $options = []) { $response = $this->query( $this->buildQueryArgs('auth', 'updateSelf'), [ 'body' => $content ], $options ); return $response['result']; }
[ "public", "function", "updateSelf", "(", "array", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'auth'", ",", "'updateSelf'", ")", ",", "[", "'body'", "=>", "$", "content", "]", ",", "$", "options", ")", ";", "return", "$", "response", "[", "'result'", "]", ";", "}" ]
Performs a partial update on the current user. @param array $content a plain javascript object representing the user's modification @param array $options (optional) arguments @return array
[ "Performs", "a", "partial", "update", "on", "the", "current", "user", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L770-L781
232,094
kuzzleio/sdk-php
src/Kuzzle.php
Kuzzle.whoAmI
public function whoAmI(array $options = []) { $response = $this->query( $this->buildQueryArgs('auth', 'getCurrentUser'), [], $options ); return new User($this->security(), $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function whoAmI(array $options = []) { $response = $this->query( $this->buildQueryArgs('auth', 'getCurrentUser'), [], $options ); return new User($this->security(), $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "whoAmI", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "query", "(", "$", "this", "->", "buildQueryArgs", "(", "'auth'", ",", "'getCurrentUser'", ")", ",", "[", "]", ",", "$", "options", ")", ";", "return", "new", "User", "(", "$", "this", "->", "security", "(", ")", ",", "$", "response", "[", "'result'", "]", "[", "'_id'", "]", ",", "$", "response", "[", "'result'", "]", "[", "'_source'", "]", ",", "$", "response", "[", "'result'", "]", "[", "'_meta'", "]", ")", ";", "}" ]
Retrieves current user object. @param array $options (optional) arguments @return User
[ "Retrieves", "current", "user", "object", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Kuzzle.php#L848-L857
232,095
suncat2000/AdminPageBoardBundle
Manager/PageBoardManager.php
PageBoardManager.getPageBlocksByRouteName
public function getPageBlocksByRouteName($routeName) { $pageName = $this->routeConfig->getPageName($routeName); if (!isset($this->pageBlocks[$pageName])) { throw new \Exception( sprintf( 'Not found blocs for page with name \'%s\' and route name \'%s\'', $pageName, $routeName ) ); } return $this->pageBlocks[$pageName]; }
php
public function getPageBlocksByRouteName($routeName) { $pageName = $this->routeConfig->getPageName($routeName); if (!isset($this->pageBlocks[$pageName])) { throw new \Exception( sprintf( 'Not found blocs for page with name \'%s\' and route name \'%s\'', $pageName, $routeName ) ); } return $this->pageBlocks[$pageName]; }
[ "public", "function", "getPageBlocksByRouteName", "(", "$", "routeName", ")", "{", "$", "pageName", "=", "$", "this", "->", "routeConfig", "->", "getPageName", "(", "$", "routeName", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pageBlocks", "[", "$", "pageName", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Not found blocs for page with name \\'%s\\' and route name \\'%s\\''", ",", "$", "pageName", ",", "$", "routeName", ")", ")", ";", "}", "return", "$", "this", "->", "pageBlocks", "[", "$", "pageName", "]", ";", "}" ]
Get page-board blocks by route name @param $routeName @throws \Exception @throws \Suncat\AdminPageBoardBundle\Routing\Exception\NotFoundRouteNameException
[ "Get", "page", "-", "board", "blocks", "by", "route", "name" ]
fc1bce24f7edaead6057d05910dc133259049557
https://github.com/suncat2000/AdminPageBoardBundle/blob/fc1bce24f7edaead6057d05910dc133259049557/Manager/PageBoardManager.php#L49-L64
232,096
suncat2000/AdminPageBoardBundle
Manager/PageBoardManager.php
PageBoardManager.getPageBlocksByRequest
public function getPageBlocksByRequest(Request $request) { $routeName = $request->get('_route'); $pageName = $this->routeConfig->getPageName($routeName); if (!isset($this->pageBlocks[$pageName])) { throw new \Exception( sprintf( 'Not found blocs for page with name \'%s\' and route name \'%s\'', $pageName, $routeName ) ); } $blocks = $this->pageBlocks[$pageName]; // add route_params to blocks foreach ($blocks as $index => $block) { $blocks[$index]['settings']['route_params'] = $request->get('_route_params'); } return $blocks; }
php
public function getPageBlocksByRequest(Request $request) { $routeName = $request->get('_route'); $pageName = $this->routeConfig->getPageName($routeName); if (!isset($this->pageBlocks[$pageName])) { throw new \Exception( sprintf( 'Not found blocs for page with name \'%s\' and route name \'%s\'', $pageName, $routeName ) ); } $blocks = $this->pageBlocks[$pageName]; // add route_params to blocks foreach ($blocks as $index => $block) { $blocks[$index]['settings']['route_params'] = $request->get('_route_params'); } return $blocks; }
[ "public", "function", "getPageBlocksByRequest", "(", "Request", "$", "request", ")", "{", "$", "routeName", "=", "$", "request", "->", "get", "(", "'_route'", ")", ";", "$", "pageName", "=", "$", "this", "->", "routeConfig", "->", "getPageName", "(", "$", "routeName", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pageBlocks", "[", "$", "pageName", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Not found blocs for page with name \\'%s\\' and route name \\'%s\\''", ",", "$", "pageName", ",", "$", "routeName", ")", ")", ";", "}", "$", "blocks", "=", "$", "this", "->", "pageBlocks", "[", "$", "pageName", "]", ";", "// add route_params to blocks", "foreach", "(", "$", "blocks", "as", "$", "index", "=>", "$", "block", ")", "{", "$", "blocks", "[", "$", "index", "]", "[", "'settings'", "]", "[", "'route_params'", "]", "=", "$", "request", "->", "get", "(", "'_route_params'", ")", ";", "}", "return", "$", "blocks", ";", "}" ]
Get page-board blocks by Request @param Request $request @return mixed @throws \Exception @throws \Suncat\AdminPageBoardBundle\Routing\Exception\NotFoundRouteNameException
[ "Get", "page", "-", "board", "blocks", "by", "Request" ]
fc1bce24f7edaead6057d05910dc133259049557
https://github.com/suncat2000/AdminPageBoardBundle/blob/fc1bce24f7edaead6057d05910dc133259049557/Manager/PageBoardManager.php#L74-L96
232,097
praxisnetau/silverware
src/Extensions/Control/BreadcrumbsExtension.php
BreadcrumbsExtension.getBreadcrumbsTemplate
public function getBreadcrumbsTemplate() { if ($template = $this->owner->config()->breadcrumbs_template) { return $template; } return $this->owner->config()->default_breadcrumbs_template; }
php
public function getBreadcrumbsTemplate() { if ($template = $this->owner->config()->breadcrumbs_template) { return $template; } return $this->owner->config()->default_breadcrumbs_template; }
[ "public", "function", "getBreadcrumbsTemplate", "(", ")", "{", "if", "(", "$", "template", "=", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "breadcrumbs_template", ")", "{", "return", "$", "template", ";", "}", "return", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "default_breadcrumbs_template", ";", "}" ]
Answers the name of the template to use for rendering breadcrumbs. @return string
[ "Answers", "the", "name", "of", "the", "template", "to", "use", "for", "rendering", "breadcrumbs", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Control/BreadcrumbsExtension.php#L75-L82
232,098
praxisnetau/silverware
src/Extensions/Control/BreadcrumbsExtension.php
BreadcrumbsExtension.getBreadcrumbItems
public function getBreadcrumbItems($maxDepth = 20, $stopAtPageType = false, $showHidden = false) { // Obtain Model Breadcrumb Items: $items = $this->owner->data()->getBreadcrumbItems($maxDepth, $stopAtPageType, $showHidden); // Obtain Extra Breadcrumb Items: $extra = $this->owner->getExtraBreadcrumbItems(); // Check Breadcrumb Item Instances: $extra->each(function ($item) { if (!($item instanceof SiteTree) && !($item instanceof Crumbable)) { throw new Exception( sprintf( 'Item of class "%s" is not a SiteTree object or an implementor of Crumbable', get_class($item) ) ); } }); // Merge Extra Breadcrumb Items: $items->merge($extra); // Answer Breadcrumb Items: return $items; }
php
public function getBreadcrumbItems($maxDepth = 20, $stopAtPageType = false, $showHidden = false) { // Obtain Model Breadcrumb Items: $items = $this->owner->data()->getBreadcrumbItems($maxDepth, $stopAtPageType, $showHidden); // Obtain Extra Breadcrumb Items: $extra = $this->owner->getExtraBreadcrumbItems(); // Check Breadcrumb Item Instances: $extra->each(function ($item) { if (!($item instanceof SiteTree) && !($item instanceof Crumbable)) { throw new Exception( sprintf( 'Item of class "%s" is not a SiteTree object or an implementor of Crumbable', get_class($item) ) ); } }); // Merge Extra Breadcrumb Items: $items->merge($extra); // Answer Breadcrumb Items: return $items; }
[ "public", "function", "getBreadcrumbItems", "(", "$", "maxDepth", "=", "20", ",", "$", "stopAtPageType", "=", "false", ",", "$", "showHidden", "=", "false", ")", "{", "// Obtain Model Breadcrumb Items:", "$", "items", "=", "$", "this", "->", "owner", "->", "data", "(", ")", "->", "getBreadcrumbItems", "(", "$", "maxDepth", ",", "$", "stopAtPageType", ",", "$", "showHidden", ")", ";", "// Obtain Extra Breadcrumb Items:", "$", "extra", "=", "$", "this", "->", "owner", "->", "getExtraBreadcrumbItems", "(", ")", ";", "// Check Breadcrumb Item Instances:", "$", "extra", "->", "each", "(", "function", "(", "$", "item", ")", "{", "if", "(", "!", "(", "$", "item", "instanceof", "SiteTree", ")", "&&", "!", "(", "$", "item", "instanceof", "Crumbable", ")", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Item of class \"%s\" is not a SiteTree object or an implementor of Crumbable'", ",", "get_class", "(", "$", "item", ")", ")", ")", ";", "}", "}", ")", ";", "// Merge Extra Breadcrumb Items:", "$", "items", "->", "merge", "(", "$", "extra", ")", ";", "// Answer Breadcrumb Items:", "return", "$", "items", ";", "}" ]
Answers a list of breadcrumbs for the current page. @param integer $maxDepth @param boolean|string $stopAtPageType @param boolean $showHidden @throws Exception @return ArrayList
[ "Answers", "a", "list", "of", "breadcrumbs", "for", "the", "current", "page", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Control/BreadcrumbsExtension.php#L95-L129
232,099
praxisnetau/silverware
src/Extensions/Forms/StatusMessageExtension.php
StatusMessageExtension.addStatusMessage
public function addStatusMessage($textOrArray, $type = 'warning', $icon = 'warning', $insertBefore = 'Root') { if (!is_null($textOrArray)) { // Obtain Arguments: if (is_array($textOrArray)) { $text = isset($textOrArray['text']) ? $textOrArray['text'] : null; $type = isset($textOrArray['type']) ? $textOrArray['type'] : null; $icon = isset($textOrArray['icon']) ? $textOrArray['icon'] : null; } else { $text = $textOrArray; } // Add Literal Field: $this->owner->insertBefore( $insertBefore, LiteralField::create( 'StatusMessageLiteral', sprintf( '<p class="message status %s"><i class="fa fa-fw fa-%s"></i> %s</p>', $type, $icon, $text ) ) ); } }
php
public function addStatusMessage($textOrArray, $type = 'warning', $icon = 'warning', $insertBefore = 'Root') { if (!is_null($textOrArray)) { // Obtain Arguments: if (is_array($textOrArray)) { $text = isset($textOrArray['text']) ? $textOrArray['text'] : null; $type = isset($textOrArray['type']) ? $textOrArray['type'] : null; $icon = isset($textOrArray['icon']) ? $textOrArray['icon'] : null; } else { $text = $textOrArray; } // Add Literal Field: $this->owner->insertBefore( $insertBefore, LiteralField::create( 'StatusMessageLiteral', sprintf( '<p class="message status %s"><i class="fa fa-fw fa-%s"></i> %s</p>', $type, $icon, $text ) ) ); } }
[ "public", "function", "addStatusMessage", "(", "$", "textOrArray", ",", "$", "type", "=", "'warning'", ",", "$", "icon", "=", "'warning'", ",", "$", "insertBefore", "=", "'Root'", ")", "{", "if", "(", "!", "is_null", "(", "$", "textOrArray", ")", ")", "{", "// Obtain Arguments:", "if", "(", "is_array", "(", "$", "textOrArray", ")", ")", "{", "$", "text", "=", "isset", "(", "$", "textOrArray", "[", "'text'", "]", ")", "?", "$", "textOrArray", "[", "'text'", "]", ":", "null", ";", "$", "type", "=", "isset", "(", "$", "textOrArray", "[", "'type'", "]", ")", "?", "$", "textOrArray", "[", "'type'", "]", ":", "null", ";", "$", "icon", "=", "isset", "(", "$", "textOrArray", "[", "'icon'", "]", ")", "?", "$", "textOrArray", "[", "'icon'", "]", ":", "null", ";", "}", "else", "{", "$", "text", "=", "$", "textOrArray", ";", "}", "// Add Literal Field:", "$", "this", "->", "owner", "->", "insertBefore", "(", "$", "insertBefore", ",", "LiteralField", "::", "create", "(", "'StatusMessageLiteral'", ",", "sprintf", "(", "'<p class=\"message status %s\"><i class=\"fa fa-fw fa-%s\"></i> %s</p>'", ",", "$", "type", ",", "$", "icon", ",", "$", "text", ")", ")", ")", ";", "}", "}" ]
Adds a status message as a literal field to the extended object. @param string|array $textOrArray @param string $type @param string $icon @param string $insertBefore @return void
[ "Adds", "a", "status", "message", "as", "a", "literal", "field", "to", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Forms/StatusMessageExtension.php#L44-L74