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
partition
stringclasses
1 value
vinicius73/SeoTools
src/Vinicius73/SEO/Generators/OpenGraphGenerator.php
OpenGraphGenerator.generate
public function generate() { $html = array(); foreach ($this->properties as $property => $value): if (is_array($value)): foreach ($value as $_value) { $html[] = strtr( static::OPENGRAPH_TAG, array( '[property]' => static::OPENGRAPH_PREFIX . $property, '[value]' => $_value ) ); } else: $html[] = strtr( static::OPENGRAPH_TAG, array( '[property]' => static::OPENGRAPH_PREFIX . $property, '[value]' => $value ) ); endif; endforeach; return implode(PHP_EOL, $html); }
php
public function generate() { $html = array(); foreach ($this->properties as $property => $value): if (is_array($value)): foreach ($value as $_value) { $html[] = strtr( static::OPENGRAPH_TAG, array( '[property]' => static::OPENGRAPH_PREFIX . $property, '[value]' => $_value ) ); } else: $html[] = strtr( static::OPENGRAPH_TAG, array( '[property]' => static::OPENGRAPH_PREFIX . $property, '[value]' => $value ) ); endif; endforeach; return implode(PHP_EOL, $html); }
[ "public", "function", "generate", "(", ")", "{", "$", "html", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "properties", "as", "$", "property", "=>", "$", "value", ")", ":", "if", "(", "is_array", "(", "$", "value", ")", ")", "...
Render the open graph tags. @return string
[ "Render", "the", "open", "graph", "tags", "." ]
5d2543482921713e0676c310ff8b23b2989443a1
https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/OpenGraphGenerator.php#L43-L70
train
vinicius73/SeoTools
src/Vinicius73/SEO/Generators/OpenGraphGenerator.php
OpenGraphGenerator.fromRaw
public function fromRaw($properties) { $this->validateProperties($properties); foreach ($properties as $property => $value) { $this->properties[$property] = $value; } }
php
public function fromRaw($properties) { $this->validateProperties($properties); foreach ($properties as $property => $value) { $this->properties[$property] = $value; } }
[ "public", "function", "fromRaw", "(", "$", "properties", ")", "{", "$", "this", "->", "validateProperties", "(", "$", "properties", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "this", "->", "pr...
Set the open graph properties from a raw array. @param array $properties
[ "Set", "the", "open", "graph", "properties", "from", "a", "raw", "array", "." ]
5d2543482921713e0676c310ff8b23b2989443a1
https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/OpenGraphGenerator.php#L77-L84
train
vinicius73/SeoTools
src/Vinicius73/SEO/Generators/OpenGraphGenerator.php
OpenGraphGenerator.fromObject
public function fromObject(OpenGraphAware $object) { $properties = $object->getOpenGraphData(); $this->validateProperties($properties); foreach ($properties as $property => $value) { $this->properties[$property] = $value; } }
php
public function fromObject(OpenGraphAware $object) { $properties = $object->getOpenGraphData(); $this->validateProperties($properties); foreach ($properties as $property => $value) { $this->properties[$property] = $value; } }
[ "public", "function", "fromObject", "(", "OpenGraphAware", "$", "object", ")", "{", "$", "properties", "=", "$", "object", "->", "getOpenGraphData", "(", ")", ";", "$", "this", "->", "validateProperties", "(", "$", "properties", ")", ";", "foreach", "(", "...
Use the open graph data of a open graph aware object. @param OpenGraphAware $object
[ "Use", "the", "open", "graph", "data", "of", "a", "open", "graph", "aware", "object", "." ]
5d2543482921713e0676c310ff8b23b2989443a1
https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/OpenGraphGenerator.php#L91-L100
train
vinicius73/SeoTools
src/Vinicius73/SEO/Generators/OpenGraphGenerator.php
OpenGraphGenerator.validateProperties
protected function validateProperties($properties) { foreach ($this->required as $required) { if (!array_key_exists($required, $properties)) { throw new \InvalidArgumentException("Required open graph property [$required] is not present."); } } }
php
protected function validateProperties($properties) { foreach ($this->required as $required) { if (!array_key_exists($required, $properties)) { throw new \InvalidArgumentException("Required open graph property [$required] is not present."); } } }
[ "protected", "function", "validateProperties", "(", "$", "properties", ")", "{", "foreach", "(", "$", "this", "->", "required", "as", "$", "required", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "required", ",", "$", "properties", ")", ")", "...
Validate to make sure the properties contain all required ones. @param array $properties
[ "Validate", "to", "make", "sure", "the", "properties", "contain", "all", "required", "ones", "." ]
5d2543482921713e0676c310ff8b23b2989443a1
https://github.com/vinicius73/SeoTools/blob/5d2543482921713e0676c310ff8b23b2989443a1/src/Vinicius73/SEO/Generators/OpenGraphGenerator.php#L117-L124
train
webeweb/jquery-datatables-bundle
Twig/Extension/DataTablesTwigExtension.php
DataTablesTwigExtension.jQueryDataTablesStandaloneFunction
public function jQueryDataTablesStandaloneFunction(array $args = []) { return $this->jQueryDataTablesStandalone(ArrayHelper::get($args, "selector", ".table"), ArrayHelper::get($args, "language"), ArrayHelper::get($args, "options", [])); }
php
public function jQueryDataTablesStandaloneFunction(array $args = []) { return $this->jQueryDataTablesStandalone(ArrayHelper::get($args, "selector", ".table"), ArrayHelper::get($args, "language"), ArrayHelper::get($args, "options", [])); }
[ "public", "function", "jQueryDataTablesStandaloneFunction", "(", "array", "$", "args", "=", "[", "]", ")", "{", "return", "$", "this", "->", "jQueryDataTablesStandalone", "(", "ArrayHelper", "::", "get", "(", "$", "args", ",", "\"selector\"", ",", "\".table\"", ...
Displays a jQuery DataTables "Standalone". @param array $args The arguments. @return string Returns the jQuery DataTables "Standalone". @throws FileNotFoundException Throws a file not found exception if the language file does not exist.
[ "Displays", "a", "jQuery", "DataTables", "Standalone", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Twig/Extension/DataTablesTwigExtension.php#L98-L100
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.execute
public function execute() { $ch = \curl_init(); $this->setAuth($ch); try { switch (strtoupper($this->method)) { case 'GET': $this->executeGet($ch); break; case 'POST': $this->executePost($ch); break; case 'PUT': $this->executePut($ch); break; case 'PATCH': $this->executePatch($ch); break; case 'DELETE': $this->executeDelete($ch); break; // This custom case is used to execute a Multipart PUT request case 'PUT_MP': $this->method = 'PUT'; $this->executePutMultipart($ch); break; case 'POST_MP': $this->method = 'POST'; $this->executePostMultipart($ch); break; default: throw new \InvalidArgumentException('Current method (' . $this->method . ') is an invalid REST method.'); } } catch (\InvalidArgumentException $e) { \curl_close($ch); throw $e; } catch (\Exception $e) { \curl_close($ch); throw $e; } }
php
public function execute() { $ch = \curl_init(); $this->setAuth($ch); try { switch (strtoupper($this->method)) { case 'GET': $this->executeGet($ch); break; case 'POST': $this->executePost($ch); break; case 'PUT': $this->executePut($ch); break; case 'PATCH': $this->executePatch($ch); break; case 'DELETE': $this->executeDelete($ch); break; // This custom case is used to execute a Multipart PUT request case 'PUT_MP': $this->method = 'PUT'; $this->executePutMultipart($ch); break; case 'POST_MP': $this->method = 'POST'; $this->executePostMultipart($ch); break; default: throw new \InvalidArgumentException('Current method (' . $this->method . ') is an invalid REST method.'); } } catch (\InvalidArgumentException $e) { \curl_close($ch); throw $e; } catch (\Exception $e) { \curl_close($ch); throw $e; } }
[ "public", "function", "execute", "(", ")", "{", "$", "ch", "=", "\\", "curl_init", "(", ")", ";", "$", "this", "->", "setAuth", "(", "$", "ch", ")", ";", "try", "{", "switch", "(", "strtoupper", "(", "$", "this", "->", "method", ")", ")", "{", ...
Execute curl request for each type of HTTP Request @throws \InvalidArgumentException
[ "Execute", "curl", "request", "for", "each", "type", "of", "HTTP", "Request" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L168-L208
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.buildPostBody
public function buildPostBody($data = null) { $reqBody = ($data !== null) ? $data : $this->request_body; $this->request_body = (string) $reqBody; }
php
public function buildPostBody($data = null) { $reqBody = ($data !== null) ? $data : $this->request_body; $this->request_body = (string) $reqBody; }
[ "public", "function", "buildPostBody", "(", "$", "data", "=", "null", ")", "{", "$", "reqBody", "=", "(", "$", "data", "!==", "null", ")", "?", "$", "data", ":", "$", "this", "->", "request_body", ";", "$", "this", "->", "request_body", "=", "(", "...
Build RAW post body @param string $data
[ "Build", "RAW", "post", "body" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L215-L220
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.executePutMultipart
protected function executePutMultipart($ch) { $xml = $this->request_body; $uri_string = $this->file_to_upload[0]; $file_name = $this->file_to_upload[1]; $post = array( 'ResourceDescriptor' => $xml, $uri_string => '@' . $file_name . ';filename=' . basename($file_name) ); \curl_setopt($ch, CURLOPT_TIMEOUT, 10); \curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); \curl_setopt($ch, CURLOPT_POSTFIELDS, $post); \curl_setopt($ch, CURLOPT_URL, $this->url); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $this->response_body = \curl_exec($ch); $this->response_info = \curl_getinfo($ch); \curl_close($ch); }
php
protected function executePutMultipart($ch) { $xml = $this->request_body; $uri_string = $this->file_to_upload[0]; $file_name = $this->file_to_upload[1]; $post = array( 'ResourceDescriptor' => $xml, $uri_string => '@' . $file_name . ';filename=' . basename($file_name) ); \curl_setopt($ch, CURLOPT_TIMEOUT, 10); \curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); \curl_setopt($ch, CURLOPT_POSTFIELDS, $post); \curl_setopt($ch, CURLOPT_URL, $this->url); \curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $this->response_body = \curl_exec($ch); $this->response_info = \curl_getinfo($ch); \curl_close($ch); }
[ "protected", "function", "executePutMultipart", "(", "$", "ch", ")", "{", "$", "xml", "=", "$", "this", "->", "request_body", ";", "$", "uri_string", "=", "$", "this", "->", "file_to_upload", "[", "0", "]", ";", "$", "file_name", "=", "$", "this", "->"...
Runs PUT multi-part request @param \CURL $ch
[ "Runs", "PUT", "multi", "-", "part", "request" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L254-L275
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.doExecute
protected function doExecute(&$curlHandle) { $this->setCurlOpts($curlHandle); $response = \curl_exec($curlHandle); $header_size = \curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE); $this->response_body = substr($response, $header_size); $this->response_headers = []; $lines = explode("\r\n", substr($response, 0, $header_size)); foreach ($lines as $i => $line) { if ($i === 0) { $this->response_headers['http_code'] = $line; $piece = explode(" ", $line); if (count($piece) > 1) { $this->response_headers['protocol'] = $piece[0]; $this->response_headers['status_code'] = $piece[1]; array_splice($piece, 0, 2); //Remove protocol and code $this->response_headers['reason_phrase'] = implode(" ", $piece); } } else { $piece = explode(': ', $line, 2); if (count($piece) == 2) { list ($key, $value) = $piece; if (trim($key) !== "") { $this->response_headers[$key] = trim($value); } } } } $this->response_info = \curl_getinfo($curlHandle); \curl_close($curlHandle); }
php
protected function doExecute(&$curlHandle) { $this->setCurlOpts($curlHandle); $response = \curl_exec($curlHandle); $header_size = \curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE); $this->response_body = substr($response, $header_size); $this->response_headers = []; $lines = explode("\r\n", substr($response, 0, $header_size)); foreach ($lines as $i => $line) { if ($i === 0) { $this->response_headers['http_code'] = $line; $piece = explode(" ", $line); if (count($piece) > 1) { $this->response_headers['protocol'] = $piece[0]; $this->response_headers['status_code'] = $piece[1]; array_splice($piece, 0, 2); //Remove protocol and code $this->response_headers['reason_phrase'] = implode(" ", $piece); } } else { $piece = explode(': ', $line, 2); if (count($piece) == 2) { list ($key, $value) = $piece; if (trim($key) !== "") { $this->response_headers[$key] = trim($value); } } } } $this->response_info = \curl_getinfo($curlHandle); \curl_close($curlHandle); }
[ "protected", "function", "doExecute", "(", "&", "$", "curlHandle", ")", "{", "$", "this", "->", "setCurlOpts", "(", "$", "curlHandle", ")", ";", "$", "response", "=", "\\", "curl_exec", "(", "$", "curlHandle", ")", ";", "$", "header_size", "=", "\\", "...
Perform Curl REquest @param object $curlHandle
[ "Perform", "Curl", "REquest" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L356-L391
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.setCurlOpts
protected function setCurlOpts(&$curlHandle) { \curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10); \curl_setopt($curlHandle, CURLOPT_URL, $this->url); \curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); \curl_setopt($curlHandle, CURLOPT_VERBOSE, false); \curl_setopt($curlHandle, CURLOPT_HEADER, true); \curl_setopt($curlHandle, CURLOPT_COOKIEFILE, '/dev/null'); \curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $this->getDefaultHeader()); }
php
protected function setCurlOpts(&$curlHandle) { \curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10); \curl_setopt($curlHandle, CURLOPT_URL, $this->url); \curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); \curl_setopt($curlHandle, CURLOPT_VERBOSE, false); \curl_setopt($curlHandle, CURLOPT_HEADER, true); \curl_setopt($curlHandle, CURLOPT_COOKIEFILE, '/dev/null'); \curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $this->getDefaultHeader()); }
[ "protected", "function", "setCurlOpts", "(", "&", "$", "curlHandle", ")", "{", "\\", "curl_setopt", "(", "$", "curlHandle", ",", "CURLOPT_TIMEOUT", ",", "10", ")", ";", "\\", "curl_setopt", "(", "$", "curlHandle", ",", "CURLOPT_URL", ",", "$", "this", "->"...
Set Curl Default Options @param object $curlHandle
[ "Set", "Curl", "Default", "Options" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L398-L406
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.setAuth
protected function setAuth(&$curlHandle) { if ($this->username !== null && $this->password !== null) { \curl_setopt($curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); \curl_setopt($curlHandle, CURLOPT_USERPWD, base64_encode($this->username . ':' . $this->password)); // \curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // \curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); } }
php
protected function setAuth(&$curlHandle) { if ($this->username !== null && $this->password !== null) { \curl_setopt($curlHandle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); \curl_setopt($curlHandle, CURLOPT_USERPWD, base64_encode($this->username . ':' . $this->password)); // \curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // \curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); } }
[ "protected", "function", "setAuth", "(", "&", "$", "curlHandle", ")", "{", "if", "(", "$", "this", "->", "username", "!==", "null", "&&", "$", "this", "->", "password", "!==", "null", ")", "{", "\\", "curl_setopt", "(", "$", "curlHandle", ",", "CURLOPT...
Set Basic Authentication Headers to Curl Options @param object $curlHandle
[ "Set", "Basic", "Authentication", "Headers", "to", "Curl", "Options" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L436-L443
train
VM9/orion-explorer-php-frame-work
src/Orion/Utils/HttpRequest.php
HttpRequest.getResponseHeader
public function getResponseHeader($key = null) { if (null != $key) { if (array_key_exists($key, $this->response_headers)) { return $this->response_headers[$key]; } } else { return $this->response_headers; } }
php
public function getResponseHeader($key = null) { if (null != $key) { if (array_key_exists($key, $this->response_headers)) { return $this->response_headers[$key]; } } else { return $this->response_headers; } }
[ "public", "function", "getResponseHeader", "(", "$", "key", "=", "null", ")", "{", "if", "(", "null", "!=", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "response_headers", ")", ")", "{", "return", "$"...
Get Response Header @return type
[ "Get", "Response", "Header" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Utils/HttpRequest.php#L540-L548
train
Distilleries/Expendable
src/Distilleries/Expendable/Scopes/Translatable.php
Translatable.bootTranslatable
public static function bootTranslatable() { static::addGlobalScope(new TranslatableScope); try { $observer = app(TranslatableObserverContract::class); static::observe($observer); } catch (\Exception $exception) {} }
php
public static function bootTranslatable() { static::addGlobalScope(new TranslatableScope); try { $observer = app(TranslatableObserverContract::class); static::observe($observer); } catch (\Exception $exception) {} }
[ "public", "static", "function", "bootTranslatable", "(", ")", "{", "static", "::", "addGlobalScope", "(", "new", "TranslatableScope", ")", ";", "try", "{", "$", "observer", "=", "app", "(", "TranslatableObserverContract", "::", "class", ")", ";", "static", "::...
Boot the soft deleting trait for a model. @return void
[ "Boot", "the", "soft", "deleting", "trait", "for", "a", "model", "." ]
badfdabb7fc78447906fc9856bd313f2f1dbae8d
https://github.com/Distilleries/Expendable/blob/badfdabb7fc78447906fc9856bd313f2f1dbae8d/src/Distilleries/Expendable/Scopes/Translatable.php#L15-L22
train
webeweb/jquery-datatables-bundle
Normalizer/DataTablesNormalizer.php
DataTablesNormalizer.normalizeColumn
public static function normalizeColumn(DataTablesColumnInterface $column) { $output = []; ArrayHelper::set($output, "cellType", $column->getCellType(), [null]); ArrayHelper::set($output, "classname", $column->getClassname(), [null]); ArrayHelper::set($output, "contentPadding", $column->getContentPadding(), [null]); ArrayHelper::set($output, "data", $column->getData(), [null]); ArrayHelper::set($output, "defaultContent", $column->getDefaultContent(), [null]); ArrayHelper::set($output, "name", $column->getName(), [null]); ArrayHelper::set($output, "orderable", $column->getOrderable(), [null, true]); ArrayHelper::set($output, "orderData", $column->getOrderData(), [null]); ArrayHelper::set($output, "orderDataType", $column->getOrderDataType(), [null]); ArrayHelper::set($output, "orderSequence", $column->getOrderSequence(), [null]); ArrayHelper::set($output, "searchable", $column->getSearchable(), [null, true]); ArrayHelper::set($output, "type", $column->getType(), [null]); ArrayHelper::set($output, "visible", $column->getVisible(), [null, true]); ArrayHelper::set($output, "width", $column->getWidth(), [null]); return $output; }
php
public static function normalizeColumn(DataTablesColumnInterface $column) { $output = []; ArrayHelper::set($output, "cellType", $column->getCellType(), [null]); ArrayHelper::set($output, "classname", $column->getClassname(), [null]); ArrayHelper::set($output, "contentPadding", $column->getContentPadding(), [null]); ArrayHelper::set($output, "data", $column->getData(), [null]); ArrayHelper::set($output, "defaultContent", $column->getDefaultContent(), [null]); ArrayHelper::set($output, "name", $column->getName(), [null]); ArrayHelper::set($output, "orderable", $column->getOrderable(), [null, true]); ArrayHelper::set($output, "orderData", $column->getOrderData(), [null]); ArrayHelper::set($output, "orderDataType", $column->getOrderDataType(), [null]); ArrayHelper::set($output, "orderSequence", $column->getOrderSequence(), [null]); ArrayHelper::set($output, "searchable", $column->getSearchable(), [null, true]); ArrayHelper::set($output, "type", $column->getType(), [null]); ArrayHelper::set($output, "visible", $column->getVisible(), [null, true]); ArrayHelper::set($output, "width", $column->getWidth(), [null]); return $output; }
[ "public", "static", "function", "normalizeColumn", "(", "DataTablesColumnInterface", "$", "column", ")", "{", "$", "output", "=", "[", "]", ";", "ArrayHelper", "::", "set", "(", "$", "output", ",", "\"cellType\"", ",", "$", "column", "->", "getCellType", "("...
Normalize a column. @param DataTablesColumnInterface $column The column. @return array Returns teh normalized column.
[ "Normalize", "a", "column", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Normalizer/DataTablesNormalizer.php#L32-L52
train
webeweb/jquery-datatables-bundle
Normalizer/DataTablesNormalizer.php
DataTablesNormalizer.normalizeResponse
public static function normalizeResponse(DataTablesResponseInterface $response) { $output = []; $output["data"] = $response->getData(); $output["draw"] = $response->getDraw(); $output["recordsFiltered"] = $response->getRecordsFiltered(); $output["recordsTotal"] = $response->getRecordsTotal(); return $output; }
php
public static function normalizeResponse(DataTablesResponseInterface $response) { $output = []; $output["data"] = $response->getData(); $output["draw"] = $response->getDraw(); $output["recordsFiltered"] = $response->getRecordsFiltered(); $output["recordsTotal"] = $response->getRecordsTotal(); return $output; }
[ "public", "static", "function", "normalizeResponse", "(", "DataTablesResponseInterface", "$", "response", ")", "{", "$", "output", "=", "[", "]", ";", "$", "output", "[", "\"data\"", "]", "=", "$", "response", "->", "getData", "(", ")", ";", "$", "output",...
Normalize a response. @param DataTablesResponseInterface $response The response. @return array Returns the normalized response.
[ "Normalize", "a", "response", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Normalizer/DataTablesNormalizer.php#L60-L70
train
Krinkle/intuition
language/mw-classes/Language.php
Language.isValidCode
public static function isValidCode( $code ) { return strcspn( $code, ":/\\\000" ) === strlen( $code ) && !preg_match( Title::getTitleInvalidRegex(), $code ); }
php
public static function isValidCode( $code ) { return strcspn( $code, ":/\\\000" ) === strlen( $code ) && !preg_match( Title::getTitleInvalidRegex(), $code ); }
[ "public", "static", "function", "isValidCode", "(", "$", "code", ")", "{", "return", "strcspn", "(", "$", "code", ",", "\":/\\\\\\000\"", ")", "===", "strlen", "(", "$", "code", ")", "&&", "!", "preg_match", "(", "Title", "::", "getTitleInvalidRegex", "(",...
Returns true if a language code string is of a valid form, whether or not it exists. This includes codes which are used solely for customisation via the MediaWiki namespace. @param $code string @return bool
[ "Returns", "true", "if", "a", "language", "code", "string", "is", "of", "a", "valid", "form", "whether", "or", "not", "it", "exists", ".", "This", "includes", "codes", "which", "are", "used", "solely", "for", "customisation", "via", "the", "MediaWiki", "na...
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L130-L134
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getLocalisationCache
public static function getLocalisationCache() { if ( is_null( self::$dataCache ) ) { global $wgLocalisationCacheConf; $class = $wgLocalisationCacheConf['class']; self::$dataCache = new $class( $wgLocalisationCacheConf ); } return self::$dataCache; }
php
public static function getLocalisationCache() { if ( is_null( self::$dataCache ) ) { global $wgLocalisationCacheConf; $class = $wgLocalisationCacheConf['class']; self::$dataCache = new $class( $wgLocalisationCacheConf ); } return self::$dataCache; }
[ "public", "static", "function", "getLocalisationCache", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "dataCache", ")", ")", "{", "global", "$", "wgLocalisationCacheConf", ";", "$", "class", "=", "$", "wgLocalisationCacheConf", "[", "'class'", ...
Get the LocalisationCache instance @return LocalisationCache
[ "Get", "the", "LocalisationCache", "instance" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L153-L160
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getGenderNsText
function getGenderNsText( $index, $gender ) { $ns = self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' ); return isset( $ns[$index][$gender] ) ? $ns[$index][$gender] : $this->getNsText( $index ); }
php
function getGenderNsText( $index, $gender ) { $ns = self::$dataCache->getItem( $this->mCode, 'namespaceGenderAliases' ); return isset( $ns[$index][$gender] ) ? $ns[$index][$gender] : $this->getNsText( $index ); }
[ "function", "getGenderNsText", "(", "$", "index", ",", "$", "gender", ")", "{", "$", "ns", "=", "self", "::", "$", "dataCache", "->", "getItem", "(", "$", "this", "->", "mCode", ",", "'namespaceGenderAliases'", ")", ";", "return", "isset", "(", "$", "n...
Returns gender-dependent namespace alias if available. @param $index Int: namespace index @param $gender String: gender key (male, female... ) @return String @since 1.18
[ "Returns", "gender", "-", "dependent", "namespace", "alias", "if", "available", "." ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L292-L295
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getLocalNsIndex
function getLocalNsIndex( $text ) { $lctext = $this->lc( $text ); $ids = $this->getNamespaceIds(); return isset( $ids[$lctext] ) ? $ids[$lctext] : false; }
php
function getLocalNsIndex( $text ) { $lctext = $this->lc( $text ); $ids = $this->getNamespaceIds(); return isset( $ids[$lctext] ) ? $ids[$lctext] : false; }
[ "function", "getLocalNsIndex", "(", "$", "text", ")", "{", "$", "lctext", "=", "$", "this", "->", "lc", "(", "$", "text", ")", ";", "$", "ids", "=", "$", "this", "->", "getNamespaceIds", "(", ")", ";", "return", "isset", "(", "$", "ids", "[", "$"...
Get a namespace key by value, case insensitive. Only matches namespace names for the current language, not the canonical ones defined in Namespace.php. @param $text String @return mixed An integer if $text is a valid value otherwise false
[ "Get", "a", "namespace", "key", "by", "value", "case", "insensitive", ".", "Only", "matches", "namespace", "names", "for", "the", "current", "language", "not", "the", "canonical", "ones", "defined", "in", "Namespace", ".", "php", "." ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L316-L320
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getNsIndex
function getNsIndex( $text ) { $lctext = $this->lc( $text ); if ( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) { return $ns; } $ids = $this->getNamespaceIds(); return isset( $ids[$lctext] ) ? $ids[$lctext] : false; }
php
function getNsIndex( $text ) { $lctext = $this->lc( $text ); if ( ( $ns = MWNamespace::getCanonicalIndex( $lctext ) ) !== null ) { return $ns; } $ids = $this->getNamespaceIds(); return isset( $ids[$lctext] ) ? $ids[$lctext] : false; }
[ "function", "getNsIndex", "(", "$", "text", ")", "{", "$", "lctext", "=", "$", "this", "->", "lc", "(", "$", "text", ")", ";", "if", "(", "(", "$", "ns", "=", "MWNamespace", "::", "getCanonicalIndex", "(", "$", "lctext", ")", ")", "!==", "null", ...
Get a namespace key by value, case insensitive. Canonical namespace names override custom ones defined for the current language. @param $text String @return mixed An integer if $text is a valid value otherwise false
[ "Get", "a", "namespace", "key", "by", "value", "case", "insensitive", ".", "Canonical", "namespace", "names", "override", "custom", "ones", "defined", "for", "the", "current", "language", "." ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L386-L393
train
Krinkle/intuition
language/mw-classes/Language.php
Language.hebrewYearStart
private static function hebrewYearStart( $year ) { $a = intval( ( 12 * ( $year - 1 ) + 17 ) % 19 ); $b = intval( ( $year - 1 ) % 4 ); $m = 32.044093161144 + 1.5542417966212 * $a + $b / 4.0 - 0.0031777940220923 * ( $year - 1 ); if ( $m < 0 ) { $m--; } $Mar = intval( $m ); if ( $m < 0 ) { $m++; } $m -= $Mar; $c = intval( ( $Mar + 3 * ( $year - 1 ) + 5 * $b + 5 ) % 7 ); if ( $c == 0 && $a > 11 && $m >= 0.89772376543210 ) { $Mar++; } elseif ( $c == 1 && $a > 6 && $m >= 0.63287037037037 ) { $Mar += 2; } elseif ( $c == 2 || $c == 4 || $c == 6 ) { $Mar++; } $Mar += intval( ( $year - 3761 ) / 100 ) - intval( ( $year - 3761 ) / 400 ) - 24; return $Mar; }
php
private static function hebrewYearStart( $year ) { $a = intval( ( 12 * ( $year - 1 ) + 17 ) % 19 ); $b = intval( ( $year - 1 ) % 4 ); $m = 32.044093161144 + 1.5542417966212 * $a + $b / 4.0 - 0.0031777940220923 * ( $year - 1 ); if ( $m < 0 ) { $m--; } $Mar = intval( $m ); if ( $m < 0 ) { $m++; } $m -= $Mar; $c = intval( ( $Mar + 3 * ( $year - 1 ) + 5 * $b + 5 ) % 7 ); if ( $c == 0 && $a > 11 && $m >= 0.89772376543210 ) { $Mar++; } elseif ( $c == 1 && $a > 6 && $m >= 0.63287037037037 ) { $Mar += 2; } elseif ( $c == 2 || $c == 4 || $c == 6 ) { $Mar++; } $Mar += intval( ( $year - 3761 ) / 100 ) - intval( ( $year - 3761 ) / 400 ) - 24; return $Mar; }
[ "private", "static", "function", "hebrewYearStart", "(", "$", "year", ")", "{", "$", "a", "=", "intval", "(", "(", "12", "*", "(", "$", "year", "-", "1", ")", "+", "17", ")", "%", "19", ")", ";", "$", "b", "=", "intval", "(", "(", "$", "year"...
This calculates the Hebrew year start, as days since 1 September. Based on Carl Friedrich Gauss algorithm for finding Easter date. Used for Hebrew date. @param $year int @return string
[ "This", "calculates", "the", "Hebrew", "year", "start", "as", "days", "since", "1", "September", ".", "Based", "on", "Carl", "Friedrich", "Gauss", "algorithm", "for", "finding", "Easter", "date", ".", "Used", "for", "Hebrew", "date", "." ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L1310-L1334
train
Krinkle/intuition
language/mw-classes/Language.php
Language.romanNumeral
static function romanNumeral( $num ) { static $table = array( array( '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ), array( '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ), array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ), array( '', 'M', 'MM', 'MMM' ) ); $num = intval( $num ); if ( $num > 3000 || $num <= 0 ) { return $num; } $s = ''; for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) { if ( $num >= $pow10 ) { $s .= $table[$i][floor( $num / $pow10 )]; } $num = $num % $pow10; } return $s; }
php
static function romanNumeral( $num ) { static $table = array( array( '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X' ), array( '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', 'C' ), array( '', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', 'M' ), array( '', 'M', 'MM', 'MMM' ) ); $num = intval( $num ); if ( $num > 3000 || $num <= 0 ) { return $num; } $s = ''; for ( $pow10 = 1000, $i = 3; $i >= 0; $pow10 /= 10, $i-- ) { if ( $num >= $pow10 ) { $s .= $table[$i][floor( $num / $pow10 )]; } $num = $num % $pow10; } return $s; }
[ "static", "function", "romanNumeral", "(", "$", "num", ")", "{", "static", "$", "table", "=", "array", "(", "array", "(", "''", ",", "'I'", ",", "'II'", ",", "'III'", ",", "'IV'", ",", "'V'", ",", "'VI'", ",", "'VII'", ",", "'VIII'", ",", "'IX'", ...
Roman number formatting up to 3000 @param $num int @return string
[ "Roman", "number", "formatting", "up", "to", "3000" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L1427-L1448
train
Krinkle/intuition
language/mw-classes/Language.php
Language.uc
function uc( $str, $first = false ) { if ( function_exists( 'mb_strtoupper' ) ) { if ( $first ) { if ( $this->isMultibyte( $str ) ) { return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 ); } else { return ucfirst( $str ); } } else { return $this->isMultibyte( $str ) ? mb_strtoupper( $str ) : strtoupper( $str ); } } else { if ( $this->isMultibyte( $str ) ) { $x = $first ? '^' : ''; return preg_replace_callback( "/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/", array( $this, 'ucCallback' ), $str ); } else { return $first ? ucfirst( $str ) : strtoupper( $str ); } } }
php
function uc( $str, $first = false ) { if ( function_exists( 'mb_strtoupper' ) ) { if ( $first ) { if ( $this->isMultibyte( $str ) ) { return mb_strtoupper( mb_substr( $str, 0, 1 ) ) . mb_substr( $str, 1 ); } else { return ucfirst( $str ); } } else { return $this->isMultibyte( $str ) ? mb_strtoupper( $str ) : strtoupper( $str ); } } else { if ( $this->isMultibyte( $str ) ) { $x = $first ? '^' : ''; return preg_replace_callback( "/$x([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/", array( $this, 'ucCallback' ), $str ); } else { return $first ? ucfirst( $str ) : strtoupper( $str ); } } }
[ "function", "uc", "(", "$", "str", ",", "$", "first", "=", "false", ")", "{", "if", "(", "function_exists", "(", "'mb_strtoupper'", ")", ")", "{", "if", "(", "$", "first", ")", "{", "if", "(", "$", "this", "->", "isMultibyte", "(", "$", "str", ")...
Convert a string to uppercase @param $str string @param $first bool @return string
[ "Convert", "a", "string", "to", "uppercase" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L1748-L1771
train
Krinkle/intuition
language/mw-classes/Language.php
Language.ucwordbreaks
function ucwordbreaks( $str ) { if ( $this->isMultibyte( $str ) ) { $str = $this->lc( $str ); // since \b doesn't work for UTF-8, we explicitely define word break chars $breaks = "[ \-\(\)\}\{\.,\?!]"; // find first letter after word break $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$breaks([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/"; if ( function_exists( 'mb_strtoupper' ) ) { return preg_replace_callback( $replaceRegexp, array( $this, 'ucwordbreaksCallbackMB' ), $str ); } else { return preg_replace_callback( $replaceRegexp, array( $this, 'ucwordsCallbackWiki' ), $str ); } } else { return preg_replace_callback( '/\b([\w\x80-\xff]+)\b/', array( $this, 'ucwordbreaksCallbackAscii' ), $str ); } }
php
function ucwordbreaks( $str ) { if ( $this->isMultibyte( $str ) ) { $str = $this->lc( $str ); // since \b doesn't work for UTF-8, we explicitely define word break chars $breaks = "[ \-\(\)\}\{\.,\?!]"; // find first letter after word break $replaceRegexp = "/^([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)|$breaks([a-z]|[\\xc0-\\xff][\\x80-\\xbf]*)/"; if ( function_exists( 'mb_strtoupper' ) ) { return preg_replace_callback( $replaceRegexp, array( $this, 'ucwordbreaksCallbackMB' ), $str ); } else { return preg_replace_callback( $replaceRegexp, array( $this, 'ucwordsCallbackWiki' ), $str ); } } else { return preg_replace_callback( '/\b([\w\x80-\xff]+)\b/', array( $this, 'ucwordbreaksCallbackAscii' ), $str ); } }
[ "function", "ucwordbreaks", "(", "$", "str", ")", "{", "if", "(", "$", "this", "->", "isMultibyte", "(", "$", "str", ")", ")", "{", "$", "str", "=", "$", "this", "->", "lc", "(", "$", "str", ")", ";", "// since \\b doesn't work for UTF-8, we explicitely ...
capitalize words at word breaks @param $str string @return mixed
[ "capitalize", "words", "at", "word", "breaks" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L1865-L1895
train
Krinkle/intuition
language/mw-classes/Language.php
Language.firstChar
function firstChar( $s ) { $matches = array(); preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/', $s, $matches ); if ( isset( $matches[1] ) ) { if ( strlen( $matches[1] ) != 3 ) { return $matches[1]; } // Break down Hangul syllables to grab the first jamo $code = utf8ToCodepoint( $matches[1] ); if ( $code < 0xac00 || 0xd7a4 <= $code ) { return $matches[1]; } elseif ( $code < 0xb098 ) { return "\xe3\x84\xb1"; } elseif ( $code < 0xb2e4 ) { return "\xe3\x84\xb4"; } elseif ( $code < 0xb77c ) { return "\xe3\x84\xb7"; } elseif ( $code < 0xb9c8 ) { return "\xe3\x84\xb9"; } elseif ( $code < 0xbc14 ) { return "\xe3\x85\x81"; } elseif ( $code < 0xc0ac ) { return "\xe3\x85\x82"; } elseif ( $code < 0xc544 ) { return "\xe3\x85\x85"; } elseif ( $code < 0xc790 ) { return "\xe3\x85\x87"; } elseif ( $code < 0xcc28 ) { return "\xe3\x85\x88"; } elseif ( $code < 0xce74 ) { return "\xe3\x85\x8a"; } elseif ( $code < 0xd0c0 ) { return "\xe3\x85\x8b"; } elseif ( $code < 0xd30c ) { return "\xe3\x85\x8c"; } elseif ( $code < 0xd558 ) { return "\xe3\x85\x8d"; } else { return "\xe3\x85\x8e"; } } else { return ''; } }
php
function firstChar( $s ) { $matches = array(); preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})/', $s, $matches ); if ( isset( $matches[1] ) ) { if ( strlen( $matches[1] ) != 3 ) { return $matches[1]; } // Break down Hangul syllables to grab the first jamo $code = utf8ToCodepoint( $matches[1] ); if ( $code < 0xac00 || 0xd7a4 <= $code ) { return $matches[1]; } elseif ( $code < 0xb098 ) { return "\xe3\x84\xb1"; } elseif ( $code < 0xb2e4 ) { return "\xe3\x84\xb4"; } elseif ( $code < 0xb77c ) { return "\xe3\x84\xb7"; } elseif ( $code < 0xb9c8 ) { return "\xe3\x84\xb9"; } elseif ( $code < 0xbc14 ) { return "\xe3\x85\x81"; } elseif ( $code < 0xc0ac ) { return "\xe3\x85\x82"; } elseif ( $code < 0xc544 ) { return "\xe3\x85\x85"; } elseif ( $code < 0xc790 ) { return "\xe3\x85\x87"; } elseif ( $code < 0xcc28 ) { return "\xe3\x85\x88"; } elseif ( $code < 0xce74 ) { return "\xe3\x85\x8a"; } elseif ( $code < 0xd0c0 ) { return "\xe3\x85\x8b"; } elseif ( $code < 0xd30c ) { return "\xe3\x85\x8c"; } elseif ( $code < 0xd558 ) { return "\xe3\x85\x8d"; } else { return "\xe3\x85\x8e"; } } else { return ''; } }
[ "function", "firstChar", "(", "$", "s", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "preg_match", "(", "'/^([\\x00-\\x7f]|[\\xc0-\\xdf][\\x80-\\xbf]|'", ".", "'[\\xe0-\\xef][\\x80-\\xbf]{2}|[\\xf0-\\xf7][\\x80-\\xbf]{3})/'", ",", "$", "s", ",", "$", "matche...
Get the first character of a string. @param $s string @return string
[ "Get", "the", "first", "character", "of", "a", "string", "." ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L2009-L2059
train
Krinkle/intuition
language/mw-classes/Language.php
Language.normalize
function normalize( $s ) { global $wgAllUnicodeFixes; $s = UtfNormal::cleanUp( $s ); if ( $wgAllUnicodeFixes ) { $s = $this->transformUsingPairFile( 'normalize-ar.ser', $s ); $s = $this->transformUsingPairFile( 'normalize-ml.ser', $s ); } return $s; }
php
function normalize( $s ) { global $wgAllUnicodeFixes; $s = UtfNormal::cleanUp( $s ); if ( $wgAllUnicodeFixes ) { $s = $this->transformUsingPairFile( 'normalize-ar.ser', $s ); $s = $this->transformUsingPairFile( 'normalize-ml.ser', $s ); } return $s; }
[ "function", "normalize", "(", "$", "s", ")", "{", "global", "$", "wgAllUnicodeFixes", ";", "$", "s", "=", "UtfNormal", "::", "cleanUp", "(", "$", "s", ")", ";", "if", "(", "$", "wgAllUnicodeFixes", ")", "{", "$", "s", "=", "$", "this", "->", "trans...
Convert a UTF-8 string to normal form C. In Malayalam and Arabic, this also cleans up certain backwards-compatible sequences, converting them to the modern Unicode equivalent. This is language-specific for performance reasons only. @param $s string @return string
[ "Convert", "a", "UTF", "-", "8", "string", "to", "normal", "form", "C", ".", "In", "Malayalam", "and", "Arabic", "this", "also", "cleans", "up", "certain", "backwards", "-", "compatible", "sequences", "converting", "them", "to", "the", "modern", "Unicode", ...
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L2114-L2123
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getMagic
function getMagic( $mw ) { $this->doMagicHook(); if ( isset( $this->mMagicExtensions[$mw->mId] ) ) { $rawEntry = $this->mMagicExtensions[$mw->mId]; } else { $magicWords = $this->getMagicWords(); if ( isset( $magicWords[$mw->mId] ) ) { $rawEntry = $magicWords[$mw->mId]; } else { $rawEntry = false; } } if ( !is_array( $rawEntry ) ) { error_log( "\"$rawEntry\" is not a valid magic word for \"$mw->mId\"" ); } else { $mw->mCaseSensitive = $rawEntry[0]; $mw->mSynonyms = array_slice( $rawEntry, 1 ); } }
php
function getMagic( $mw ) { $this->doMagicHook(); if ( isset( $this->mMagicExtensions[$mw->mId] ) ) { $rawEntry = $this->mMagicExtensions[$mw->mId]; } else { $magicWords = $this->getMagicWords(); if ( isset( $magicWords[$mw->mId] ) ) { $rawEntry = $magicWords[$mw->mId]; } else { $rawEntry = false; } } if ( !is_array( $rawEntry ) ) { error_log( "\"$rawEntry\" is not a valid magic word for \"$mw->mId\"" ); } else { $mw->mCaseSensitive = $rawEntry[0]; $mw->mSynonyms = array_slice( $rawEntry, 1 ); } }
[ "function", "getMagic", "(", "$", "mw", ")", "{", "$", "this", "->", "doMagicHook", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "mMagicExtensions", "[", "$", "mw", "->", "mId", "]", ")", ")", "{", "$", "rawEntry", "=", "$", "this",...
Fill a MagicWord object with data from here @param $mw
[ "Fill", "a", "MagicWord", "object", "with", "data", "from", "here" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L2246-L2266
train
Krinkle/intuition
language/mw-classes/Language.php
Language.addMagicWordsByLang
function addMagicWordsByLang( $newWords ) { $code = $this->getCode(); $fallbackChain = array(); while ( $code && !in_array( $code, $fallbackChain ) ) { $fallbackChain[] = $code; $code = self::getFallbackFor( $code ); } if ( !in_array( 'en', $fallbackChain ) ) { $fallbackChain[] = 'en'; } $fallbackChain = array_reverse( $fallbackChain ); foreach ( $fallbackChain as $code ) { if ( isset( $newWords[$code] ) ) { $this->mMagicExtensions = $newWords[$code] + $this->mMagicExtensions; } } }
php
function addMagicWordsByLang( $newWords ) { $code = $this->getCode(); $fallbackChain = array(); while ( $code && !in_array( $code, $fallbackChain ) ) { $fallbackChain[] = $code; $code = self::getFallbackFor( $code ); } if ( !in_array( 'en', $fallbackChain ) ) { $fallbackChain[] = 'en'; } $fallbackChain = array_reverse( $fallbackChain ); foreach ( $fallbackChain as $code ) { if ( isset( $newWords[$code] ) ) { $this->mMagicExtensions = $newWords[$code] + $this->mMagicExtensions; } } }
[ "function", "addMagicWordsByLang", "(", "$", "newWords", ")", "{", "$", "code", "=", "$", "this", "->", "getCode", "(", ")", ";", "$", "fallbackChain", "=", "array", "(", ")", ";", "while", "(", "$", "code", "&&", "!", "in_array", "(", "$", "code", ...
Add magic words to the extension array @param $newWords array
[ "Add", "magic", "words", "to", "the", "extension", "array" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L2273-L2289
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getSpecialPageAliases
function getSpecialPageAliases() { // Cache aliases because it may be slow to load them if ( is_null( $this->mExtendedSpecialPageAliases ) ) { // Initialise array $this->mExtendedSpecialPageAliases = self::$dataCache->getItem( $this->mCode, 'specialPageAliases' ); wfRunHooks( 'LanguageGetSpecialPageAliases', array( &$this->mExtendedSpecialPageAliases, $this->getCode() ) ); } return $this->mExtendedSpecialPageAliases; }
php
function getSpecialPageAliases() { // Cache aliases because it may be slow to load them if ( is_null( $this->mExtendedSpecialPageAliases ) ) { // Initialise array $this->mExtendedSpecialPageAliases = self::$dataCache->getItem( $this->mCode, 'specialPageAliases' ); wfRunHooks( 'LanguageGetSpecialPageAliases', array( &$this->mExtendedSpecialPageAliases, $this->getCode() ) ); } return $this->mExtendedSpecialPageAliases; }
[ "function", "getSpecialPageAliases", "(", ")", "{", "// Cache aliases because it may be slow to load them", "if", "(", "is_null", "(", "$", "this", "->", "mExtendedSpecialPageAliases", ")", ")", "{", "// Initialise array", "$", "this", "->", "mExtendedSpecialPageAliases", ...
Get special page names, as an associative array case folded alias => real name
[ "Get", "special", "page", "names", "as", "an", "associative", "array", "case", "folded", "alias", "=", ">", "real", "name" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L2295-L2306
train
Krinkle/intuition
language/mw-classes/Language.php
Language.preConvertPlural
protected function preConvertPlural( /* Array */ $forms, $count ) { while ( count( $forms ) < $count ) { $forms[] = $forms[count( $forms ) - 1]; } return $forms; }
php
protected function preConvertPlural( /* Array */ $forms, $count ) { while ( count( $forms ) < $count ) { $forms[] = $forms[count( $forms ) - 1]; } return $forms; }
[ "protected", "function", "preConvertPlural", "(", "/* Array */", "$", "forms", ",", "$", "count", ")", "{", "while", "(", "count", "(", "$", "forms", ")", "<", "$", "count", ")", "{", "$", "forms", "[", "]", "=", "$", "forms", "[", "count", "(", "$...
Checks that convertPlural was given an array and pads it to requested amount of forms by copying the last one. @param $count Integer: How many forms should there be at least @param $forms Array of forms given to convertPlural @return array Padded array of forms or an exception if not an array
[ "Checks", "that", "convertPlural", "was", "given", "an", "array", "and", "pads", "it", "to", "requested", "amount", "of", "forms", "by", "copying", "the", "last", "one", "." ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L2818-L2823
train
Krinkle/intuition
language/mw-classes/Language.php
Language.getFileName
static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) { // Protect against path traversal if ( !Language::isValidCode( $code ) || strcspn( $code, ":/\\\000" ) !== strlen( $code ) ) { throw new MWException( "Invalid language code \"$code\"" ); } return $prefix . str_replace( '-', '_', ucfirst( $code ) ) . $suffix; }
php
static function getFileName( $prefix = 'Language', $code, $suffix = '.php' ) { // Protect against path traversal if ( !Language::isValidCode( $code ) || strcspn( $code, ":/\\\000" ) !== strlen( $code ) ) { throw new MWException( "Invalid language code \"$code\"" ); } return $prefix . str_replace( '-', '_', ucfirst( $code ) ) . $suffix; }
[ "static", "function", "getFileName", "(", "$", "prefix", "=", "'Language'", ",", "$", "code", ",", "$", "suffix", "=", "'.php'", ")", "{", "// Protect against path traversal", "if", "(", "!", "Language", "::", "isValidCode", "(", "$", "code", ")", "||", "s...
Get the name of a file for a certain language code @param $prefix string Prepend this to the filename @param $code string Language code @param $suffix string Append this to the filename @return string $prefix . $mangledCode . $suffix
[ "Get", "the", "name", "of", "a", "file", "for", "a", "certain", "language", "code" ]
36f48ffe925905ae5d60c7f04d76077e150d3a2c
https://github.com/Krinkle/intuition/blob/36f48ffe925905ae5d60c7f04d76077e150d3a2c/language/mw-classes/Language.php#L3081-L3090
train
gfazioli/Laravel-Morris-PHP
src/Morris/MorrisBase.php
MorrisBase.toArray
public function toArray() { $return = []; foreach ( $this as $property => $value ) { if ( '__' == substr( $property, 0, 2 ) || '' === $value || is_null( $value ) || ( is_array( $value ) && empty( $value ) ) ) { continue; } if ( in_array( $property, $this->functions ) && substr( $value, 0, 8 ) == 'function' ) { $value = "%{$property}%"; } $return[ $property ] = $value; } return $return; }
php
public function toArray() { $return = []; foreach ( $this as $property => $value ) { if ( '__' == substr( $property, 0, 2 ) || '' === $value || is_null( $value ) || ( is_array( $value ) && empty( $value ) ) ) { continue; } if ( in_array( $property, $this->functions ) && substr( $value, 0, 8 ) == 'function' ) { $value = "%{$property}%"; } $return[ $property ] = $value; } return $return; }
[ "public", "function", "toArray", "(", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "'__'", "==", "substr", "(", "$", "property", ",", "0", ",", "2", ")...
Return the array of this object @brief Array @return array
[ "Return", "the", "array", "of", "this", "object" ]
af981f80ebe93ed40178ccb9101c097a6ca54e1c
https://github.com/gfazioli/Laravel-Morris-PHP/blob/af981f80ebe93ed40178ccb9101c097a6ca54e1c/src/Morris/MorrisBase.php#L85-L101
train
gfazioli/Laravel-Morris-PHP
src/Morris/MorrisBase.php
MorrisBase.toJSON
public function toJSON() { $json = json_encode( $this->toArray() ); return str_replace( [ '"%hoverCallback%"', '"%formatter%"', '"%dateFormat%"', ], [ $this->hoverCallback, $this->formatter, $this->dateFormat, ], $json ); }
php
public function toJSON() { $json = json_encode( $this->toArray() ); return str_replace( [ '"%hoverCallback%"', '"%formatter%"', '"%dateFormat%"', ], [ $this->hoverCallback, $this->formatter, $this->dateFormat, ], $json ); }
[ "public", "function", "toJSON", "(", ")", "{", "$", "json", "=", "json_encode", "(", "$", "this", "->", "toArray", "(", ")", ")", ";", "return", "str_replace", "(", "[", "'\"%hoverCallback%\"'", ",", "'\"%formatter%\"'", ",", "'\"%dateFormat%\"'", ",", "]", ...
Return the jSON encode of this chart @brief JSON @return string
[ "Return", "the", "jSON", "encode", "of", "this", "chart" ]
af981f80ebe93ed40178ccb9101c097a6ca54e1c
https://github.com/gfazioli/Laravel-Morris-PHP/blob/af981f80ebe93ed40178ccb9101c097a6ca54e1c/src/Morris/MorrisBase.php#L110-L127
train
gfazioli/Laravel-Morris-PHP
src/Morris/MorrisBase.php
MorrisBase.toJavascript
public function toJavascript() { ob_start(); ?> <script type="text/javascript"> jQuery( function( $ ) { "use strict"; Morris.<?php echo $this->__chart_type ?>( <?php echo $this->toJSON() ?> ); } ); </script> <?php $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
php
public function toJavascript() { ob_start(); ?> <script type="text/javascript"> jQuery( function( $ ) { "use strict"; Morris.<?php echo $this->__chart_type ?>( <?php echo $this->toJSON() ?> ); } ); </script> <?php $buffer = ob_get_contents(); ob_end_clean(); return $buffer; }
[ "public", "function", "toJavascript", "(", ")", "{", "ob_start", "(", ")", ";", "?>\n <script type=\"text/javascript\">\n jQuery( function( $ )\n {\n \"use strict\";\n\n Morris.<?php", "echo", "$", "this", "->", "__chart_type", "?>(\n <?php", "ec...
Return the HTML markup for Javascript code @brief Brief @return string
[ "Return", "the", "HTML", "markup", "for", "Javascript", "code" ]
af981f80ebe93ed40178ccb9101c097a6ca54e1c
https://github.com/gfazioli/Laravel-Morris-PHP/blob/af981f80ebe93ed40178ccb9101c097a6ca54e1c/src/Morris/MorrisBase.php#L135-L154
train
oliverklee/ext-oelib
Classes/MapperRegistry.php
Tx_Oelib_MapperRegistry.getByClassName
private function getByClassName($className) { if ($className === '') { throw new \InvalidArgumentException('$className must not be empty.', 1331488868); } $unifiedClassName = self::unifyClassName($className); if (!isset($this->mappers[$unifiedClassName])) { if (!class_exists($className, true)) { throw new \InvalidArgumentException( 'No mapper class "' . $className . '" could be found.' ); } /** @var \Tx_Oelib_DataMapper $mapper */ $mapper = GeneralUtility::makeInstance($unifiedClassName); $this->mappers[$unifiedClassName] = $mapper; } else { /** @var \Tx_Oelib_DataMapper $mapper */ $mapper = $this->mappers[$unifiedClassName]; } if ($this->testingMode) { $mapper->setTestingFramework($this->testingFramework); } if ($this->denyDatabaseAccess) { $mapper->disableDatabaseAccess(); } return $mapper; }
php
private function getByClassName($className) { if ($className === '') { throw new \InvalidArgumentException('$className must not be empty.', 1331488868); } $unifiedClassName = self::unifyClassName($className); if (!isset($this->mappers[$unifiedClassName])) { if (!class_exists($className, true)) { throw new \InvalidArgumentException( 'No mapper class "' . $className . '" could be found.' ); } /** @var \Tx_Oelib_DataMapper $mapper */ $mapper = GeneralUtility::makeInstance($unifiedClassName); $this->mappers[$unifiedClassName] = $mapper; } else { /** @var \Tx_Oelib_DataMapper $mapper */ $mapper = $this->mappers[$unifiedClassName]; } if ($this->testingMode) { $mapper->setTestingFramework($this->testingFramework); } if ($this->denyDatabaseAccess) { $mapper->disableDatabaseAccess(); } return $mapper; }
[ "private", "function", "getByClassName", "(", "$", "className", ")", "{", "if", "(", "$", "className", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$className must not be empty.'", ",", "1331488868", ")", ";", "}", "$", "unif...
Retrieves a dataMapper by class name. @param string $className the name of an existing mapper class, must not be empty @return \Tx_Oelib_DataMapper the requested mapper instance @throws \InvalidArgumentException
[ "Retrieves", "a", "dataMapper", "by", "class", "name", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/MapperRegistry.php#L96-L126
train
webeweb/jquery-datatables-bundle
Provider/AbstractDataTablesProvider.php
AbstractDataTablesProvider.renderButtons
protected function renderButtons($entity, $editRoute, $deleteRoute = null, $enableDelete = true) { // Initialize the titles. $titles = []; $titles[] = $this->getTranslator()->trans("label.edit", [], "CoreBundle"); $titles[] = $this->getTranslator()->trans("label.delete", [], "CoreBundle"); // Initialize the actions. $actions = []; $actions[] = $this->getButtonTwigExtension()->bootstrapButtonDefaultFunction(["icon" => "pencil", "title" => $titles[0], "size" => "xs"]); $actions[] = $this->getButtonTwigExtension()->bootstrapButtonDangerFunction(["icon" => "trash", "title" => $titles[1], "size" => "xs"]); // Initialize the routes. $routes = []; $routes[] = $this->getRouter()->generate($editRoute, ["id" => $entity->getId()]); $routes[] = $this->getRouter()->generate("jquery_datatables_delete", ["name" => $this->getName(), "id" => $entity->getId()]); // Check the delete route and use it if provided. if (null !== $deleteRoute) { $routes[1] = $this->getRouter()->generate($deleteRoute, ["id" => $entity->getId()]); } // Initialize the links. $links = []; $links[] = $this->getButtonTwigExtension()->bootstrapButtonLinkFilter($actions[0], $routes[0]); if (true === $enableDelete) { $links[] = $this->getButtonTwigExtension()->bootstrapButtonLinkFilter($actions[1], $routes[1]); } return implode(" ", $links); }
php
protected function renderButtons($entity, $editRoute, $deleteRoute = null, $enableDelete = true) { // Initialize the titles. $titles = []; $titles[] = $this->getTranslator()->trans("label.edit", [], "CoreBundle"); $titles[] = $this->getTranslator()->trans("label.delete", [], "CoreBundle"); // Initialize the actions. $actions = []; $actions[] = $this->getButtonTwigExtension()->bootstrapButtonDefaultFunction(["icon" => "pencil", "title" => $titles[0], "size" => "xs"]); $actions[] = $this->getButtonTwigExtension()->bootstrapButtonDangerFunction(["icon" => "trash", "title" => $titles[1], "size" => "xs"]); // Initialize the routes. $routes = []; $routes[] = $this->getRouter()->generate($editRoute, ["id" => $entity->getId()]); $routes[] = $this->getRouter()->generate("jquery_datatables_delete", ["name" => $this->getName(), "id" => $entity->getId()]); // Check the delete route and use it if provided. if (null !== $deleteRoute) { $routes[1] = $this->getRouter()->generate($deleteRoute, ["id" => $entity->getId()]); } // Initialize the links. $links = []; $links[] = $this->getButtonTwigExtension()->bootstrapButtonLinkFilter($actions[0], $routes[0]); if (true === $enableDelete) { $links[] = $this->getButtonTwigExtension()->bootstrapButtonLinkFilter($actions[1], $routes[1]); } return implode(" ", $links); }
[ "protected", "function", "renderButtons", "(", "$", "entity", ",", "$", "editRoute", ",", "$", "deleteRoute", "=", "null", ",", "$", "enableDelete", "=", "true", ")", "{", "// Initialize the titles.", "$", "titles", "=", "[", "]", ";", "$", "titles", "[", ...
Render the DataTables buttons. @param mixed $entity The entity. @param string $editRoute The edit route. @param string $deleteRoute The delete route. @param bool $enableDelete Enable delete ? @return string Returns the DataTables buttons.
[ "Render", "the", "DataTables", "buttons", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Provider/AbstractDataTablesProvider.php#L79-L109
train
webeweb/jquery-datatables-bundle
Provider/AbstractDataTablesProvider.php
AbstractDataTablesProvider.renderFloat
protected function renderFloat($number, $decimals = 2, $decPoint = ".", $thousandsSep = ",") { if (null === $number) { return ""; } return number_format($number, $decimals, $decPoint, $thousandsSep); }
php
protected function renderFloat($number, $decimals = 2, $decPoint = ".", $thousandsSep = ",") { if (null === $number) { return ""; } return number_format($number, $decimals, $decPoint, $thousandsSep); }
[ "protected", "function", "renderFloat", "(", "$", "number", ",", "$", "decimals", "=", "2", ",", "$", "decPoint", "=", "\".\"", ",", "$", "thousandsSep", "=", "\",\"", ")", "{", "if", "(", "null", "===", "$", "number", ")", "{", "return", "\"\"", ";"...
Render a float. @param float $number The number. @param int $decimals The decimals. @param string $decPoint The decimal point. @param string $thousandsSep The thousands separator. @return string Returns the rendered number.
[ "Render", "a", "float", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Provider/AbstractDataTablesProvider.php#L142-L147
train
webeweb/jquery-datatables-bundle
Provider/AbstractDataTablesProvider.php
AbstractDataTablesProvider.wrapContent
protected function wrapContent($prefix, $content, $suffix) { $output = []; if (null !== $prefix) { $output[] = $prefix; } $output[] = $content; if (null !== $suffix) { $output[] = $suffix; } return implode("", $output); }
php
protected function wrapContent($prefix, $content, $suffix) { $output = []; if (null !== $prefix) { $output[] = $prefix; } $output[] = $content; if (null !== $suffix) { $output[] = $suffix; } return implode("", $output); }
[ "protected", "function", "wrapContent", "(", "$", "prefix", ",", "$", "content", ",", "$", "suffix", ")", "{", "$", "output", "=", "[", "]", ";", "if", "(", "null", "!==", "$", "prefix", ")", "{", "$", "output", "[", "]", "=", "$", "prefix", ";",...
Wrap a content. @param string|null $prefix The prefix @param string $content The content. @param string|null $suffix The suffix. @return string Returns the wrapped content.
[ "Wrap", "a", "content", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Provider/AbstractDataTablesProvider.php#L157-L170
train
oliverklee/ext-oelib
Classes/Session.php
Tx_Oelib_Session.getInstance
public static function getInstance($type) { self::checkType($type); if (!isset(self::$instances[$type])) { self::$instances[$type] = new \Tx_Oelib_Session($type); } return self::$instances[$type]; }
php
public static function getInstance($type) { self::checkType($type); if (!isset(self::$instances[$type])) { self::$instances[$type] = new \Tx_Oelib_Session($type); } return self::$instances[$type]; }
[ "public", "static", "function", "getInstance", "(", "$", "type", ")", "{", "self", "::", "checkType", "(", "$", "type", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "type", "]", ")", ")", "{", "self", "::", "$...
Returns an instance of this class. @param int $type the type of the session to use; either TYPE_USER (persistent) or TYPE_TEMPORARY (only for the lifetime of the session cookie) @return \Tx_Oelib_Session the current Singleton instance for the given type
[ "Returns", "an", "instance", "of", "this", "class", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Session.php#L73-L82
train
oliverklee/ext-oelib
Classes/Session.php
Tx_Oelib_Session.setInstance
public static function setInstance($type, \Tx_Oelib_Session $instance) { self::checkType($type); self::$instances[$type] = $instance; }
php
public static function setInstance($type, \Tx_Oelib_Session $instance) { self::checkType($type); self::$instances[$type] = $instance; }
[ "public", "static", "function", "setInstance", "(", "$", "type", ",", "\\", "Tx_Oelib_Session", "$", "instance", ")", "{", "self", "::", "checkType", "(", "$", "type", ")", ";", "self", "::", "$", "instances", "[", "$", "type", "]", "=", "$", "instance...
Sets the instance for the given type. @param int $type the type to set, must be either TYPE_USER or TYPE_TEMPORARY @param \Tx_Oelib_Session $instance the instance to set @return void
[ "Sets", "the", "instance", "for", "the", "given", "type", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/Session.php#L92-L97
train
girosolution/girocheckout_sdk
src/girocheckout-sdk/api/paydirekt/GiroCheckout_SDK_PaydirektTransaction.php
GiroCheckout_SDK_PaydirektTransaction.validateParams
public function validateParams( $p_aParams, &$p_strError ) { if( isset($p_aParams['shoppingCartType']) ) { $strShoppingCartType = trim($p_aParams['shoppingCartType']); } if (empty($strShoppingCartType)) { $strShoppingCartType = "MIXED"; // Default value } if( isset($p_aParams['shippingAddresseFirstName']) ) { $strFirstName = trim( $p_aParams['shippingAddresseFirstName'] ); } else { $strFirstName = ""; } if( isset($p_aParams['shippingAddresseLastName']) ) { $strLastName = trim( $p_aParams['shippingAddresseLastName'] ); } else { $strLastName = ""; } if( isset($p_aParams['shippingEmail']) ) { $strEmail = trim( $p_aParams['shippingEmail'] ); } else { $strEmail = ""; } if( isset($p_aParams['shippingZipCode']) ) { $strZipCode = trim($p_aParams['shippingZipCode']); } else { $strZipCode = ""; } if( isset($p_aParams['shippingCity']) ) { $strCity = trim( $p_aParams['shippingCity'] ); } else { $strCity = ""; } if( isset($p_aParams['shippingCountry']) ) { $strCountry = trim( $p_aParams['shippingCountry'] ); } else { $strCountry = ""; } // Validate shopping cart type if ( !in_array($strShoppingCartType, array( 'PHYSICAL', 'DIGITAL', 'MIXED', 'ANONYMOUS_DONATION', 'AUTHORITIES_PAYMENT', ))) { $p_strError = "Shopping cart type"; return FALSE; } // Validate other address fields depending on shoppingCartType // First and last name are mandatory for mixed, physical and digital shopping carts if( in_array( $strShoppingCartType, array('MIXED', 'PHYSICAL', 'DIGITAL') ) ) { if (empty($strFirstName)) { $p_strError = "First Name"; return FALSE; } if (empty($strLastName)) { $p_strError = "Last Name"; return FALSE; } } if( $strShoppingCartType == 'DIGITAL' ) { if( empty($strEmail) ) { $p_strError = "Shipping Email"; return FALSE; } } elseif( in_array( $strShoppingCartType, array('MIXED', 'PHYSICAL') ) ) { if( empty($strZipCode) ) { $p_strError = "Shipping Address Zip code"; return FALSE; } if( empty($strCity) ) { $p_strError = "Shipping Address City"; return FALSE; } if( empty($strCountry) ) { $p_strError = "Shipping Address Country"; return FALSE; } } return TRUE; }
php
public function validateParams( $p_aParams, &$p_strError ) { if( isset($p_aParams['shoppingCartType']) ) { $strShoppingCartType = trim($p_aParams['shoppingCartType']); } if (empty($strShoppingCartType)) { $strShoppingCartType = "MIXED"; // Default value } if( isset($p_aParams['shippingAddresseFirstName']) ) { $strFirstName = trim( $p_aParams['shippingAddresseFirstName'] ); } else { $strFirstName = ""; } if( isset($p_aParams['shippingAddresseLastName']) ) { $strLastName = trim( $p_aParams['shippingAddresseLastName'] ); } else { $strLastName = ""; } if( isset($p_aParams['shippingEmail']) ) { $strEmail = trim( $p_aParams['shippingEmail'] ); } else { $strEmail = ""; } if( isset($p_aParams['shippingZipCode']) ) { $strZipCode = trim($p_aParams['shippingZipCode']); } else { $strZipCode = ""; } if( isset($p_aParams['shippingCity']) ) { $strCity = trim( $p_aParams['shippingCity'] ); } else { $strCity = ""; } if( isset($p_aParams['shippingCountry']) ) { $strCountry = trim( $p_aParams['shippingCountry'] ); } else { $strCountry = ""; } // Validate shopping cart type if ( !in_array($strShoppingCartType, array( 'PHYSICAL', 'DIGITAL', 'MIXED', 'ANONYMOUS_DONATION', 'AUTHORITIES_PAYMENT', ))) { $p_strError = "Shopping cart type"; return FALSE; } // Validate other address fields depending on shoppingCartType // First and last name are mandatory for mixed, physical and digital shopping carts if( in_array( $strShoppingCartType, array('MIXED', 'PHYSICAL', 'DIGITAL') ) ) { if (empty($strFirstName)) { $p_strError = "First Name"; return FALSE; } if (empty($strLastName)) { $p_strError = "Last Name"; return FALSE; } } if( $strShoppingCartType == 'DIGITAL' ) { if( empty($strEmail) ) { $p_strError = "Shipping Email"; return FALSE; } } elseif( in_array( $strShoppingCartType, array('MIXED', 'PHYSICAL') ) ) { if( empty($strZipCode) ) { $p_strError = "Shipping Address Zip code"; return FALSE; } if( empty($strCity) ) { $p_strError = "Shipping Address City"; return FALSE; } if( empty($strCountry) ) { $p_strError = "Shipping Address Country"; return FALSE; } } return TRUE; }
[ "public", "function", "validateParams", "(", "$", "p_aParams", ",", "&", "$", "p_strError", ")", "{", "if", "(", "isset", "(", "$", "p_aParams", "[", "'shoppingCartType'", "]", ")", ")", "{", "$", "strShoppingCartType", "=", "trim", "(", "$", "p_aParams", ...
Do some special validations for this payment method. Used only in a few, simply returns true for most. @param $p_aParams Array of parameters from shop @param $p_strError string [OUT] Field name in case of error @return bool TRUE if ok, FALSE if validation error.
[ "Do", "some", "special", "validations", "for", "this", "payment", "method", ".", "Used", "only", "in", "a", "few", "simply", "returns", "true", "for", "most", "." ]
4360f8894452a9c8f41b07f021746105e27a8575
https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/api/paydirekt/GiroCheckout_SDK_PaydirektTransaction.php#L115-L208
train
rdohms/DMS
src/DMS/Filter/Mapping/Loader/AnnotationLoader.php
AnnotationLoader.loadClassMetadata
public function loadClassMetadata(Mapping\ClassMetadataInterface $metadata) { $reflClass = $metadata->getReflectionClass(); //Iterate over properties to get annotations foreach($reflClass->getProperties() as $property) { $this->readProperty($property, $metadata); } }
php
public function loadClassMetadata(Mapping\ClassMetadataInterface $metadata) { $reflClass = $metadata->getReflectionClass(); //Iterate over properties to get annotations foreach($reflClass->getProperties() as $property) { $this->readProperty($property, $metadata); } }
[ "public", "function", "loadClassMetadata", "(", "Mapping", "\\", "ClassMetadataInterface", "$", "metadata", ")", "{", "$", "reflClass", "=", "$", "metadata", "->", "getReflectionClass", "(", ")", ";", "//Iterate over properties to get annotations", "foreach", "(", "$"...
Loads annotations data present in the class, using a Doctrine annotation reader @param ClassMetadata $metadata
[ "Loads", "annotations", "data", "present", "in", "the", "class", "using", "a", "Doctrine", "annotation", "reader" ]
3fab902ac2db2a31876101280cdfe7611146a243
https://github.com/rdohms/DMS/blob/3fab902ac2db2a31876101280cdfe7611146a243/src/DMS/Filter/Mapping/Loader/AnnotationLoader.php#L44-L56
train
silverstripe/silverstripe-sitewidecontent-report
src/Model/SitewideContentTaxonomy.php
SitewideContentTaxonomy.updateColumns
public function updateColumns($itemType, &$columns) { if ($itemType !== 'Pages') { return; } // Check if pages has the tags field if (!self::enabled()) { return; } // Set column $field = Config::inst()->get(__CLASS__, 'tag_field'); $columns['Terms'] = [ 'printonly' => true, // Hide on page report 'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Tags', 'Tags'), 'datasource' => function ($record) use ($field) { $tags = $record->$field()->column('Name'); return implode(', ', $tags); }, ]; }
php
public function updateColumns($itemType, &$columns) { if ($itemType !== 'Pages') { return; } // Check if pages has the tags field if (!self::enabled()) { return; } // Set column $field = Config::inst()->get(__CLASS__, 'tag_field'); $columns['Terms'] = [ 'printonly' => true, // Hide on page report 'title' => _t('SilverStripe\\SiteWideContentReport\\SitewideContentReport.Tags', 'Tags'), 'datasource' => function ($record) use ($field) { $tags = $record->$field()->column('Name'); return implode(', ', $tags); }, ]; }
[ "public", "function", "updateColumns", "(", "$", "itemType", ",", "&", "$", "columns", ")", "{", "if", "(", "$", "itemType", "!==", "'Pages'", ")", "{", "return", ";", "}", "// Check if pages has the tags field", "if", "(", "!", "self", "::", "enabled", "(...
Update columns to include taxonomy details. @param string $itemType (i.e 'Pages' or 'Files') @param array $columns Columns
[ "Update", "columns", "to", "include", "taxonomy", "details", "." ]
8375b4d789d25db3e1f718d48d042d145c083f60
https://github.com/silverstripe/silverstripe-sitewidecontent-report/blob/8375b4d789d25db3e1f718d48d042d145c083f60/src/Model/SitewideContentTaxonomy.php#L34-L56
train
silverstripe/silverstripe-sitewidecontent-report
src/Model/SitewideContentTaxonomy.php
SitewideContentTaxonomy.enabled
public static function enabled() { if (!class_exists(TaxonomyTerm::class)) { return false; } // Check if pages has the tags field $field = Config::inst()->get(__CLASS__, 'tag_field'); return singleton('Page')->hasMethod($field); }
php
public static function enabled() { if (!class_exists(TaxonomyTerm::class)) { return false; } // Check if pages has the tags field $field = Config::inst()->get(__CLASS__, 'tag_field'); return singleton('Page')->hasMethod($field); }
[ "public", "static", "function", "enabled", "(", ")", "{", "if", "(", "!", "class_exists", "(", "TaxonomyTerm", "::", "class", ")", ")", "{", "return", "false", ";", "}", "// Check if pages has the tags field", "$", "field", "=", "Config", "::", "inst", "(", ...
Check if this field is enabled. @return bool
[ "Check", "if", "this", "field", "is", "enabled", "." ]
8375b4d789d25db3e1f718d48d042d145c083f60
https://github.com/silverstripe/silverstripe-sitewidecontent-report/blob/8375b4d789d25db3e1f718d48d042d145c083f60/src/Model/SitewideContentTaxonomy.php#L63-L73
train
VM9/orion-explorer-php-frame-work
src/Orion/Context/SubscriptionFactory.php
SubscriptionFactory.addEntitySubject
public function addEntitySubject($id, $type = null, $idKey = "id", $typeKey = "type") { if(!isset($this->_subscription->subject)){ $this->_subscription->subject = (object) [ "entities" => [], "condition" => (object)["attrs" => []] ]; } $entity = (object) []; $entity->$idKey = $id; if (null != $type) { $entity->$typeKey = (string)$type; } $this->_subscription->subject->entities[] = $entity; return $this; }
php
public function addEntitySubject($id, $type = null, $idKey = "id", $typeKey = "type") { if(!isset($this->_subscription->subject)){ $this->_subscription->subject = (object) [ "entities" => [], "condition" => (object)["attrs" => []] ]; } $entity = (object) []; $entity->$idKey = $id; if (null != $type) { $entity->$typeKey = (string)$type; } $this->_subscription->subject->entities[] = $entity; return $this; }
[ "public", "function", "addEntitySubject", "(", "$", "id", ",", "$", "type", "=", "null", ",", "$", "idKey", "=", "\"id\"", ",", "$", "typeKey", "=", "\"type\"", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_subscription", "->", "subjec...
Add a Entity to subject.entities @param string $id @param string $type @param string $idKey "id"(default) or "idPattern" @param string $typeKey "type"(default) or "typePattern" @return \Orion\Context\Subscription
[ "Add", "a", "Entity", "to", "subject", ".", "entities" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Context/SubscriptionFactory.php#L86-L104
train
VM9/orion-explorer-php-frame-work
src/Orion/Context/SubscriptionFactory.php
SubscriptionFactory.addAttrCondition
public function addAttrCondition($attr) { if(!isset($this->_subscription->subject)){ $this->_subscription->subject = (object) []; } if(!isset($this->_subscription->subject->condition)){ $this->_subscription->subject->condition = (object) []; } if (!isset($this->_subscription->subject->condition->attrs)) { $this->_subscription->subject->condition->attrs = []; } array_push($this->_subscription->subject->condition->attrs, $attr); return $this; }
php
public function addAttrCondition($attr) { if(!isset($this->_subscription->subject)){ $this->_subscription->subject = (object) []; } if(!isset($this->_subscription->subject->condition)){ $this->_subscription->subject->condition = (object) []; } if (!isset($this->_subscription->subject->condition->attrs)) { $this->_subscription->subject->condition->attrs = []; } array_push($this->_subscription->subject->condition->attrs, $attr); return $this; }
[ "public", "function", "addAttrCondition", "(", "$", "attr", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_subscription", "->", "subject", ")", ")", "{", "$", "this", "->", "_subscription", "->", "subject", "=", "(", "object", ")", "[", ...
Add a Attr to subject.condition.attr "The conditions element defines the "trigger" for the subscription. The attrs field contains a list of attribute names. These names define the "triggering attributes", i.e. attributes that upon creation/change due to entity creation or update trigger the notification." "The rule is that if at least one of the attributes in the conditions.attrs list changes (e.g. some kind of "OR" condition), then a notification is sent. " "You can leave conditions.attrs empty to make a notification trigger on any entity attribute change (regardless of the name of the attribute)." "You can include filtering expressions in conditions. For example, to get notified not only if pressure changes, but if it changes within the range 700-800. This is an advanced topic, see the "Subscriptions" section in the NGSIv2 specification. [http://telefonicaid.github.io/fiware-orion/api/v2/stable/]" @param string $id @param string $type @return \Orion\Context\Subscription
[ "Add", "a", "Attr", "to", "subject", ".", "condition", ".", "attr" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Context/SubscriptionFactory.php#L131-L145
train
VM9/orion-explorer-php-frame-work
src/Orion/Context/SubscriptionFactory.php
SubscriptionFactory.addExpressionCondition
public function addExpressionCondition($expression) { if(!isset($this->_subscription->subject)){ $this->_subscription->subject = (object) []; } if(!isset($this->_subscription->subject->condition)){ $this->_subscription->subject->condition = (object) []; } $this->_subscription->subject->condition->expression = $expression; return $this; }
php
public function addExpressionCondition($expression) { if(!isset($this->_subscription->subject)){ $this->_subscription->subject = (object) []; } if(!isset($this->_subscription->subject->condition)){ $this->_subscription->subject->condition = (object) []; } $this->_subscription->subject->condition->expression = $expression; return $this; }
[ "public", "function", "addExpressionCondition", "(", "$", "expression", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_subscription", "->", "subject", ")", ")", "{", "$", "this", "->", "_subscription", "->", "subject", "=", "(", "object", "...
Add expression condition " an expression composed of `q`,`georel`,`geometry` and `coords` http://telefonicaid.github.io/fiware-orion/api/v2/stable/ @param string $expression @return \Orion\Context\Subscription
[ "Add", "expression", "condition", "an", "expression", "composed", "of", "q", "georel", "geometry", "and", "coords" ]
f16005de36ec4b86e44eb47a4aa04e37fe5deca6
https://github.com/VM9/orion-explorer-php-frame-work/blob/f16005de36ec4b86e44eb47a4aa04e37fe5deca6/src/Orion/Context/SubscriptionFactory.php#L155-L167
train
yriveiro/php-backoff
src/Backoff.php
Backoff.setOptions
public function setOptions(array $options) : BackoffInterface { $this->options = array_merge($this->options, $options); return $this; }
php
public function setOptions(array $options) : BackoffInterface { $this->options = array_merge($this->options, $options); return $this; }
[ "public", "function", "setOptions", "(", "array", "$", "options", ")", ":", "BackoffInterface", "{", "$", "this", "->", "options", "=", "array_merge", "(", "$", "this", "->", "options", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Allows overwrite default option values. @param array $options Configuration options. @return BackoffInterface
[ "Allows", "overwrite", "default", "option", "values", "." ]
421f95268e3bede9066fb07095e7836132d5c8ea
https://github.com/yriveiro/php-backoff/blob/421f95268e3bede9066fb07095e7836132d5c8ea/src/Backoff.php#L53-L58
train
yriveiro/php-backoff
src/Backoff.php
Backoff.exponential
public function exponential(int $attempt) : float { if (!is_int($attempt)) { throw new InvalidArgumentException('Attempt must be an integer'); } if ($attempt < 1) { throw new InvalidArgumentException('Attempt must be >= 1'); } if ($this->maxAttempsExceeded($attempt)) { throw new BackoffException( sprintf( "The number of max attempts (%s) was exceeded", $this->options['maxAttempts'] ) ); } $wait = (1 << ($attempt - 1)) * 1000; return ($this->options['cap'] < $wait) ? $this->options['cap'] : $wait; }
php
public function exponential(int $attempt) : float { if (!is_int($attempt)) { throw new InvalidArgumentException('Attempt must be an integer'); } if ($attempt < 1) { throw new InvalidArgumentException('Attempt must be >= 1'); } if ($this->maxAttempsExceeded($attempt)) { throw new BackoffException( sprintf( "The number of max attempts (%s) was exceeded", $this->options['maxAttempts'] ) ); } $wait = (1 << ($attempt - 1)) * 1000; return ($this->options['cap'] < $wait) ? $this->options['cap'] : $wait; }
[ "public", "function", "exponential", "(", "int", "$", "attempt", ")", ":", "float", "{", "if", "(", "!", "is_int", "(", "$", "attempt", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Attempt must be an integer'", ")", ";", "}", "if", "("...
Exponential backoff algorithm. c = attempt E(c) = (2**c - 1) @param int $attempt Attempt number. @return float Time to sleep in microseconds before a new retry. The value is in microseconds to use with usleep, sleep function only works with seconds @throws \InvalidArgumentException.
[ "Exponential", "backoff", "algorithm", "." ]
421f95268e3bede9066fb07095e7836132d5c8ea
https://github.com/yriveiro/php-backoff/blob/421f95268e3bede9066fb07095e7836132d5c8ea/src/Backoff.php#L75-L97
train
yriveiro/php-backoff
src/Backoff.php
Backoff.equalJitter
public function equalJitter(int $attempt) : int { $half = ($this->exponential($attempt) / 2); return (int) floor($half + $this->random(0.0, $half)); }
php
public function equalJitter(int $attempt) : int { $half = ($this->exponential($attempt) / 2); return (int) floor($half + $this->random(0.0, $half)); }
[ "public", "function", "equalJitter", "(", "int", "$", "attempt", ")", ":", "int", "{", "$", "half", "=", "(", "$", "this", "->", "exponential", "(", "$", "attempt", ")", "/", "2", ")", ";", "return", "(", "int", ")", "floor", "(", "$", "half", "+...
This method adds a half jitter value to exponential backoff value. @param int $attempt Attempt number. @return int
[ "This", "method", "adds", "a", "half", "jitter", "value", "to", "exponential", "backoff", "value", "." ]
421f95268e3bede9066fb07095e7836132d5c8ea
https://github.com/yriveiro/php-backoff/blob/421f95268e3bede9066fb07095e7836132d5c8ea/src/Backoff.php#L106-L111
train
yriveiro/php-backoff
src/Backoff.php
Backoff.fullJitter
public function fullJitter(int $attempt) : int { return (int) floor($this->random(0.0, $this->exponential($attempt) / 2)); }
php
public function fullJitter(int $attempt) : int { return (int) floor($this->random(0.0, $this->exponential($attempt) / 2)); }
[ "public", "function", "fullJitter", "(", "int", "$", "attempt", ")", ":", "int", "{", "return", "(", "int", ")", "floor", "(", "$", "this", "->", "random", "(", "0.0", ",", "$", "this", "->", "exponential", "(", "$", "attempt", ")", "/", "2", ")", ...
This method adds a jitter value to exponential backoff value. @param int $attempt Attempt number. @return int
[ "This", "method", "adds", "a", "jitter", "value", "to", "exponential", "backoff", "value", "." ]
421f95268e3bede9066fb07095e7836132d5c8ea
https://github.com/yriveiro/php-backoff/blob/421f95268e3bede9066fb07095e7836132d5c8ea/src/Backoff.php#L120-L123
train
yriveiro/php-backoff
src/Backoff.php
Backoff.random
protected function random(float $min, float $max) : float { return ($min + lcg_value() * (abs($max - $min))); }
php
protected function random(float $min, float $max) : float { return ($min + lcg_value() * (abs($max - $min))); }
[ "protected", "function", "random", "(", "float", "$", "min", ",", "float", "$", "max", ")", ":", "float", "{", "return", "(", "$", "min", "+", "lcg_value", "(", ")", "*", "(", "abs", "(", "$", "max", "-", "$", "min", ")", ")", ")", ";", "}" ]
Generates a random number between min and max. @param float $min @param float $max @return float
[ "Generates", "a", "random", "number", "between", "min", "and", "max", "." ]
421f95268e3bede9066fb07095e7836132d5c8ea
https://github.com/yriveiro/php-backoff/blob/421f95268e3bede9066fb07095e7836132d5c8ea/src/Backoff.php#L133-L136
train
rotassator/omnipay-payway-restapi
src/Message/AbstractRequest.php
AbstractRequest.getRequestHeaders
public function getRequestHeaders() { // common headers $headers = array( 'Accept' => 'application/json', ); // set content type if ($this->getHttpMethod() !== 'GET') { $headers['Content-Type'] = 'application/x-www-form-urlencoded'; } // prevent duplicate POSTs if ($this->getHttpMethod() === 'POST') { $headers['Idempotency-Key'] = $this->getIdempotencyKey(); } return $headers; }
php
public function getRequestHeaders() { // common headers $headers = array( 'Accept' => 'application/json', ); // set content type if ($this->getHttpMethod() !== 'GET') { $headers['Content-Type'] = 'application/x-www-form-urlencoded'; } // prevent duplicate POSTs if ($this->getHttpMethod() === 'POST') { $headers['Idempotency-Key'] = $this->getIdempotencyKey(); } return $headers; }
[ "public", "function", "getRequestHeaders", "(", ")", "{", "// common headers", "$", "headers", "=", "array", "(", "'Accept'", "=>", "'application/json'", ",", ")", ";", "// set content type", "if", "(", "$", "this", "->", "getHttpMethod", "(", ")", "!==", "'GE...
Get request headers @return array Request headers
[ "Get", "request", "headers" ]
4241c1fd0d52a663839d5b65858d6ddf2af2670f
https://github.com/rotassator/omnipay-payway-restapi/blob/4241c1fd0d52a663839d5b65858d6ddf2af2670f/src/Message/AbstractRequest.php#L428-L446
train
rotassator/omnipay-payway-restapi
src/Message/AbstractRequest.php
AbstractRequest.sendData
public function sendData($data) { // enforce TLS >= v1.2 (https://www.payway.com.au/rest-docs/index.html#basics) $config = $this->httpClient->getConfig(); $curlOptions = $config->get('curl.options'); $curlOptions[CURLOPT_SSLVERSION] = 6; $config->set('curl.options', $curlOptions); $this->httpClient->setConfig($config); // don't throw exceptions for 4xx errors $this->httpClient->getEventDispatcher()->addListener( 'request.error', function ($event) { if ($event['response']->isClientError()) { $event->stopPropagation(); } } ); if ($this->getSSLCertificatePath()) { $this->httpClient->setSslVerification($this->getSSLCertificatePath()); } $request = $this->httpClient->createRequest( $this->getHttpMethod(), $this->getEndpoint(), $this->getRequestHeaders(), $data ); // get the appropriate API key $apikey = ($this->getUseSecretKey()) ? $this->getApiKeySecret() : $this->getApiKeyPublic(); $request->setHeader('Authorization', 'Basic ' . base64_encode($apikey . ':')); // send the request $response = $request->send(); $this->response = new Response($this, $response->json()); // save additional info $this->response->setHttpResponseCode($response->getStatusCode()); $this->response->setTransactionType($this->getTransactionType()); return $this->response; }
php
public function sendData($data) { // enforce TLS >= v1.2 (https://www.payway.com.au/rest-docs/index.html#basics) $config = $this->httpClient->getConfig(); $curlOptions = $config->get('curl.options'); $curlOptions[CURLOPT_SSLVERSION] = 6; $config->set('curl.options', $curlOptions); $this->httpClient->setConfig($config); // don't throw exceptions for 4xx errors $this->httpClient->getEventDispatcher()->addListener( 'request.error', function ($event) { if ($event['response']->isClientError()) { $event->stopPropagation(); } } ); if ($this->getSSLCertificatePath()) { $this->httpClient->setSslVerification($this->getSSLCertificatePath()); } $request = $this->httpClient->createRequest( $this->getHttpMethod(), $this->getEndpoint(), $this->getRequestHeaders(), $data ); // get the appropriate API key $apikey = ($this->getUseSecretKey()) ? $this->getApiKeySecret() : $this->getApiKeyPublic(); $request->setHeader('Authorization', 'Basic ' . base64_encode($apikey . ':')); // send the request $response = $request->send(); $this->response = new Response($this, $response->json()); // save additional info $this->response->setHttpResponseCode($response->getStatusCode()); $this->response->setTransactionType($this->getTransactionType()); return $this->response; }
[ "public", "function", "sendData", "(", "$", "data", ")", "{", "// enforce TLS >= v1.2 (https://www.payway.com.au/rest-docs/index.html#basics)", "$", "config", "=", "$", "this", "->", "httpClient", "->", "getConfig", "(", ")", ";", "$", "curlOptions", "=", "$", "conf...
Send data request @param [type] $data [description] @return [type] [description]
[ "Send", "data", "request" ]
4241c1fd0d52a663839d5b65858d6ddf2af2670f
https://github.com/rotassator/omnipay-payway-restapi/blob/4241c1fd0d52a663839d5b65858d6ddf2af2670f/src/Message/AbstractRequest.php#L453-L497
train
rotassator/omnipay-payway-restapi
src/Message/AbstractRequest.php
AbstractRequest.addToData
public function addToData(array $data = array(), array $parms = array()) { foreach ($parms as $parm) { $getter = 'get' . ucfirst($parm); if (method_exists($this, $getter) && $this->$getter()) { $data[$parm] = $this->$getter(); } } return $data; }
php
public function addToData(array $data = array(), array $parms = array()) { foreach ($parms as $parm) { $getter = 'get' . ucfirst($parm); if (method_exists($this, $getter) && $this->$getter()) { $data[$parm] = $this->$getter(); } } return $data; }
[ "public", "function", "addToData", "(", "array", "$", "data", "=", "array", "(", ")", ",", "array", "$", "parms", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "parms", "as", "$", "parm", ")", "{", "$", "getter", "=", "'get'", ".", "ucfi...
Add multiple parameters to data @param array $data Data array @param array $parms Parameters to add to data
[ "Add", "multiple", "parameters", "to", "data" ]
4241c1fd0d52a663839d5b65858d6ddf2af2670f
https://github.com/rotassator/omnipay-payway-restapi/blob/4241c1fd0d52a663839d5b65858d6ddf2af2670f/src/Message/AbstractRequest.php#L504-L514
train
oliverklee/ext-oelib
Classes/ConfigurationRegistry.php
Tx_Oelib_ConfigurationRegistry.getByNamespace
private function getByNamespace($namespace) { $this->checkForNonEmptyNamespace($namespace); if (!isset($this->configurations[$namespace])) { $this->configurations[$namespace] = $this->retrieveConfigurationFromTypoScriptSetup($namespace); } return $this->configurations[$namespace]; }
php
private function getByNamespace($namespace) { $this->checkForNonEmptyNamespace($namespace); if (!isset($this->configurations[$namespace])) { $this->configurations[$namespace] = $this->retrieveConfigurationFromTypoScriptSetup($namespace); } return $this->configurations[$namespace]; }
[ "private", "function", "getByNamespace", "(", "$", "namespace", ")", "{", "$", "this", "->", "checkForNonEmptyNamespace", "(", "$", "namespace", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "configurations", "[", "$", "namespace", "]", ")", ...
Retrieves a Configuration by namespace. @param string $namespace the name of a configuration namespace, e.g., "plugin.tx_oelib", must not be empty @return \Tx_Oelib_Configuration the configuration for the given namespace
[ "Retrieves", "a", "Configuration", "by", "namespace", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/ConfigurationRegistry.php#L98-L108
train
oliverklee/ext-oelib
Classes/ConfigurationRegistry.php
Tx_Oelib_ConfigurationRegistry.set
public function set($namespace, \Tx_Oelib_Configuration $configuration) { $this->checkForNonEmptyNamespace($namespace); if (isset($this->configurations[$namespace])) { $this->dropConfiguration($namespace); } $this->configurations[$namespace] = $configuration; }
php
public function set($namespace, \Tx_Oelib_Configuration $configuration) { $this->checkForNonEmptyNamespace($namespace); if (isset($this->configurations[$namespace])) { $this->dropConfiguration($namespace); } $this->configurations[$namespace] = $configuration; }
[ "public", "function", "set", "(", "$", "namespace", ",", "\\", "Tx_Oelib_Configuration", "$", "configuration", ")", "{", "$", "this", "->", "checkForNonEmptyNamespace", "(", "$", "namespace", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "configurati...
Sets a configuration for a certain namespace. @param string $namespace the namespace of the configuration to set, must not be empty @param \Tx_Oelib_Configuration $configuration the configuration to set @return void
[ "Sets", "a", "configuration", "for", "a", "certain", "namespace", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/ConfigurationRegistry.php#L120-L129
train
oliverklee/ext-oelib
Classes/ConfigurationRegistry.php
Tx_Oelib_ConfigurationRegistry.retrieveConfigurationFromTypoScriptSetup
private function retrieveConfigurationFromTypoScriptSetup($namespace) { $data = $this->getCompleteTypoScriptSetup(); $namespaceParts = explode('.', $namespace); foreach ($namespaceParts as $namespacePart) { if (!array_key_exists($namespacePart . '.', $data)) { $data = []; break; } $data = $data[$namespacePart . '.']; } /** @var \Tx_Oelib_Configuration $configuration */ $configuration = GeneralUtility::makeInstance(\Tx_Oelib_Configuration::class); $configuration->setData($data); return $configuration; }
php
private function retrieveConfigurationFromTypoScriptSetup($namespace) { $data = $this->getCompleteTypoScriptSetup(); $namespaceParts = explode('.', $namespace); foreach ($namespaceParts as $namespacePart) { if (!array_key_exists($namespacePart . '.', $data)) { $data = []; break; } $data = $data[$namespacePart . '.']; } /** @var \Tx_Oelib_Configuration $configuration */ $configuration = GeneralUtility::makeInstance(\Tx_Oelib_Configuration::class); $configuration->setData($data); return $configuration; }
[ "private", "function", "retrieveConfigurationFromTypoScriptSetup", "(", "$", "namespace", ")", "{", "$", "data", "=", "$", "this", "->", "getCompleteTypoScriptSetup", "(", ")", ";", "$", "namespaceParts", "=", "explode", "(", "'.'", ",", "$", "namespace", ")", ...
Retrieves the configuration from TS Setup of the current page for a given namespace. @param string $namespace the namespace of the configuration to retrieve, must not be empty @return \Tx_Oelib_Configuration the TypoScript configuration for that namespace, might be empty
[ "Retrieves", "the", "configuration", "from", "TS", "Setup", "of", "the", "current", "page", "for", "a", "given", "namespace", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/ConfigurationRegistry.php#L157-L175
train
oliverklee/ext-oelib
Classes/ConfigurationRegistry.php
Tx_Oelib_ConfigurationRegistry.getCompleteTypoScriptSetup
private function getCompleteTypoScriptSetup() { $pageUid = \Tx_Oelib_PageFinder::getInstance()->getPageUid(); if ($pageUid === 0) { return []; } if ($this->existsFrontEnd()) { return $this->getFrontEndController()->tmpl->setup; } /** @var TemplateService $template */ $template = GeneralUtility::makeInstance(TemplateService::class); $template->tt_track = 0; $template->init(); /** @var PageRepository $page */ $page = GeneralUtility::makeInstance(PageRepository::class); $rootline = $page->getRootLine($pageUid); $template->runThroughTemplates($rootline, 0); $template->generateConfig(); return $template->setup; }
php
private function getCompleteTypoScriptSetup() { $pageUid = \Tx_Oelib_PageFinder::getInstance()->getPageUid(); if ($pageUid === 0) { return []; } if ($this->existsFrontEnd()) { return $this->getFrontEndController()->tmpl->setup; } /** @var TemplateService $template */ $template = GeneralUtility::makeInstance(TemplateService::class); $template->tt_track = 0; $template->init(); /** @var PageRepository $page */ $page = GeneralUtility::makeInstance(PageRepository::class); $rootline = $page->getRootLine($pageUid); $template->runThroughTemplates($rootline, 0); $template->generateConfig(); return $template->setup; }
[ "private", "function", "getCompleteTypoScriptSetup", "(", ")", "{", "$", "pageUid", "=", "\\", "Tx_Oelib_PageFinder", "::", "getInstance", "(", ")", "->", "getPageUid", "(", ")", ";", "if", "(", "$", "pageUid", "===", "0", ")", "{", "return", "[", "]", "...
Retrieves the complete TypoScript setup for the current page as a nested array. @return array the TypoScriptSetup for the current page, will be empty if no page is selected or if the TS setup of the page is empty
[ "Retrieves", "the", "complete", "TypoScript", "setup", "for", "the", "current", "page", "as", "a", "nested", "array", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/ConfigurationRegistry.php#L184-L207
train
oliverklee/ext-oelib
Classes/ConfigurationRegistry.php
Tx_Oelib_ConfigurationRegistry.existsFrontEnd
private function existsFrontEnd() { $frontEndController = $this->getFrontEndController(); return ($frontEndController !== null) && is_object($frontEndController->tmpl) && $frontEndController->tmpl->loaded; }
php
private function existsFrontEnd() { $frontEndController = $this->getFrontEndController(); return ($frontEndController !== null) && is_object($frontEndController->tmpl) && $frontEndController->tmpl->loaded; }
[ "private", "function", "existsFrontEnd", "(", ")", "{", "$", "frontEndController", "=", "$", "this", "->", "getFrontEndController", "(", ")", ";", "return", "(", "$", "frontEndController", "!==", "null", ")", "&&", "is_object", "(", "$", "frontEndController", ...
Checks whether there is an initialized front end with a loaded TS template. Note: This function can return TRUE even in the BE if there is a front end. @return bool TRUE if there is an initialized front end, FALSE otherwise
[ "Checks", "whether", "there", "is", "an", "initialized", "front", "end", "with", "a", "loaded", "TS", "template", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/ConfigurationRegistry.php#L218-L223
train
wp-jungle/baobab
src/Baobab/Configuration/Initializer/ThemeSettings.php
ThemeSettings.restrictAdminBarVisibility
public function restrictAdminBarVisibility() { // Don't go further if not logged in or within admin panel if (is_admin() || !is_user_logged_in()) { return; } $data = $this->getData(); // Don't go further if no setting if ( !isset($data['admin_bar']) || empty($data['admin_bar'])) { return; } $access = $data['admin_bar']; // Is current user's role within our access roles? $user = wp_get_current_user(); $role = $user->roles; $role = (count($role) > 0) ? $role[0] : ''; $isUserIncluded = in_array($role, $access['roles']); // Hide admin bar if required if (($access['mode'] == 'show' && !$isUserIncluded) || ($access['mode'] == 'hide' && $isUserIncluded) ) { show_admin_bar(false); } }
php
public function restrictAdminBarVisibility() { // Don't go further if not logged in or within admin panel if (is_admin() || !is_user_logged_in()) { return; } $data = $this->getData(); // Don't go further if no setting if ( !isset($data['admin_bar']) || empty($data['admin_bar'])) { return; } $access = $data['admin_bar']; // Is current user's role within our access roles? $user = wp_get_current_user(); $role = $user->roles; $role = (count($role) > 0) ? $role[0] : ''; $isUserIncluded = in_array($role, $access['roles']); // Hide admin bar if required if (($access['mode'] == 'show' && !$isUserIncluded) || ($access['mode'] == 'hide' && $isUserIncluded) ) { show_admin_bar(false); } }
[ "public", "function", "restrictAdminBarVisibility", "(", ")", "{", "// Don't go further if not logged in or within admin panel", "if", "(", "is_admin", "(", ")", "||", "!", "is_user_logged_in", "(", ")", ")", "{", "return", ";", "}", "$", "data", "=", "$", "this",...
Restrict visiblity of the admin bar
[ "Restrict", "visiblity", "of", "the", "admin", "bar" ]
ed2a9f2bbc3d194aa4df454b50aec43796fc68da
https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/ThemeSettings.php#L60-L91
train
wp-jungle/baobab
src/Baobab/Configuration/Initializer/ThemeSettings.php
ThemeSettings.restrictAdminPanelAccess
private function restrictAdminPanelAccess() { // Don't restrict anything when doing AJAX or CLI stuff if ((defined('DOING_AJAX') && DOING_AJAX) || (defined('WP_CLI') && WP_CLI) || !is_user_logged_in()) { return; } $data = $this->getData(); // Don't go further if no setting if ( !isset($data['admin_access']) || empty($data['admin_access']) || !is_admin()) { return; } $access = $data['admin_access']; // Is current user's role within our access roles? $user = wp_get_current_user(); $role = $user->roles; $role = (count($role) > 0) ? $role[0] : ''; $isUserIncluded = in_array($role, $access['roles']); // Redirect to website home if required if (($access['mode'] == 'allow' && !$isUserIncluded) || ($access['mode'] == 'forbid' && $isUserIncluded) ) { wp_redirect(home_url()); exit; } }
php
private function restrictAdminPanelAccess() { // Don't restrict anything when doing AJAX or CLI stuff if ((defined('DOING_AJAX') && DOING_AJAX) || (defined('WP_CLI') && WP_CLI) || !is_user_logged_in()) { return; } $data = $this->getData(); // Don't go further if no setting if ( !isset($data['admin_access']) || empty($data['admin_access']) || !is_admin()) { return; } $access = $data['admin_access']; // Is current user's role within our access roles? $user = wp_get_current_user(); $role = $user->roles; $role = (count($role) > 0) ? $role[0] : ''; $isUserIncluded = in_array($role, $access['roles']); // Redirect to website home if required if (($access['mode'] == 'allow' && !$isUserIncluded) || ($access['mode'] == 'forbid' && $isUserIncluded) ) { wp_redirect(home_url()); exit; } }
[ "private", "function", "restrictAdminPanelAccess", "(", ")", "{", "// Don't restrict anything when doing AJAX or CLI stuff", "if", "(", "(", "defined", "(", "'DOING_AJAX'", ")", "&&", "DOING_AJAX", ")", "||", "(", "defined", "(", "'WP_CLI'", ")", "&&", "WP_CLI", ")"...
Restrict access to the wp-admin.
[ "Restrict", "access", "to", "the", "wp", "-", "admin", "." ]
ed2a9f2bbc3d194aa4df454b50aec43796fc68da
https://github.com/wp-jungle/baobab/blob/ed2a9f2bbc3d194aa4df454b50aec43796fc68da/src/Baobab/Configuration/Initializer/ThemeSettings.php#L96-L128
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.parseCssShorthandValue
private function parseCssShorthandValue($value) { $values = preg_split('/\\s+/', $value); $css = []; $css['top'] = $values[0]; $css['right'] = (count($values) > 1) ? $values[1] : $css['top']; $css['bottom'] = (count($values) > 2) ? $values[2] : $css['top']; $css['left'] = (count($values) > 3) ? $values[3] : $css['right']; return $css; }
php
private function parseCssShorthandValue($value) { $values = preg_split('/\\s+/', $value); $css = []; $css['top'] = $values[0]; $css['right'] = (count($values) > 1) ? $values[1] : $css['top']; $css['bottom'] = (count($values) > 2) ? $values[2] : $css['top']; $css['left'] = (count($values) > 3) ? $values[3] : $css['right']; return $css; }
[ "private", "function", "parseCssShorthandValue", "(", "$", "value", ")", "{", "$", "values", "=", "preg_split", "(", "'/\\\\s+/'", ",", "$", "value", ")", ";", "$", "css", "=", "[", "]", ";", "$", "css", "[", "'top'", "]", "=", "$", "values", "[", ...
Parses a shorthand CSS value and splits it into individual values @param string $value a string of CSS value with 1, 2, 3 or 4 sizes For example: padding: 0 auto; '0 auto' is split into top: 0, left: auto, bottom: 0, right: auto. @return string[] an array of values for top, right, bottom and left (using these as associative array keys)
[ "Parses", "a", "shorthand", "CSS", "value", "and", "splits", "it", "into", "individual", "values" ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L627-L638
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.clearAllCaches
private function clearAllCaches() { $this->clearCache(self::CACHE_KEY_CSS); $this->clearCache(self::CACHE_KEY_SELECTOR); $this->clearCache(self::CACHE_KEY_XPATH); $this->clearCache(self::CACHE_KEY_CSS_DECLARATIONS_BLOCK); $this->clearCache(self::CACHE_KEY_COMBINED_STYLES); }
php
private function clearAllCaches() { $this->clearCache(self::CACHE_KEY_CSS); $this->clearCache(self::CACHE_KEY_SELECTOR); $this->clearCache(self::CACHE_KEY_XPATH); $this->clearCache(self::CACHE_KEY_CSS_DECLARATIONS_BLOCK); $this->clearCache(self::CACHE_KEY_COMBINED_STYLES); }
[ "private", "function", "clearAllCaches", "(", ")", "{", "$", "this", "->", "clearCache", "(", "self", "::", "CACHE_KEY_CSS", ")", ";", "$", "this", "->", "clearCache", "(", "self", "::", "CACHE_KEY_SELECTOR", ")", ";", "$", "this", "->", "clearCache", "(",...
Clears all caches. @return void
[ "Clears", "all", "caches", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L744-L751
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.clearCache
private function clearCache($key) { $allowedCacheKeys = [ self::CACHE_KEY_CSS, self::CACHE_KEY_SELECTOR, self::CACHE_KEY_XPATH, self::CACHE_KEY_CSS_DECLARATIONS_BLOCK, self::CACHE_KEY_COMBINED_STYLES, ]; if (!in_array($key, $allowedCacheKeys, true)) { throw new \InvalidArgumentException('Invalid cache key: ' . $key, 1391822035); } $this->caches[$key] = []; }
php
private function clearCache($key) { $allowedCacheKeys = [ self::CACHE_KEY_CSS, self::CACHE_KEY_SELECTOR, self::CACHE_KEY_XPATH, self::CACHE_KEY_CSS_DECLARATIONS_BLOCK, self::CACHE_KEY_COMBINED_STYLES, ]; if (!in_array($key, $allowedCacheKeys, true)) { throw new \InvalidArgumentException('Invalid cache key: ' . $key, 1391822035); } $this->caches[$key] = []; }
[ "private", "function", "clearCache", "(", "$", "key", ")", "{", "$", "allowedCacheKeys", "=", "[", "self", "::", "CACHE_KEY_CSS", ",", "self", "::", "CACHE_KEY_SELECTOR", ",", "self", "::", "CACHE_KEY_XPATH", ",", "self", "::", "CACHE_KEY_CSS_DECLARATIONS_BLOCK", ...
Clears a single cache by key. @param int $key the cache key, must be CACHE_KEY_CSS, CACHE_KEY_SELECTOR, CACHE_KEY_XPATH or CACHE_KEY_CSS_DECLARATION_BLOCK @return void @throws \InvalidArgumentException
[ "Clears", "a", "single", "cache", "by", "key", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L763-L777
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.normalizeStyleAttributes
private function normalizeStyleAttributes(\DOMElement $node) { $normalizedOriginalStyle = preg_replace_callback( '/[A-z\\-]+(?=\\:)/S', function (array $m) { return strtolower($m[0]); }, $node->getAttribute('style') ); // in order to not overwrite existing style attributes in the HTML, we // have to save the original HTML styles $nodePath = $node->getNodePath(); if (!isset($this->styleAttributesForNodes[$nodePath])) { $this->styleAttributesForNodes[$nodePath] = $this->parseCssDeclarationsBlock($normalizedOriginalStyle); $this->visitedNodes[$nodePath] = $node; } $node->setAttribute('style', $normalizedOriginalStyle); }
php
private function normalizeStyleAttributes(\DOMElement $node) { $normalizedOriginalStyle = preg_replace_callback( '/[A-z\\-]+(?=\\:)/S', function (array $m) { return strtolower($m[0]); }, $node->getAttribute('style') ); // in order to not overwrite existing style attributes in the HTML, we // have to save the original HTML styles $nodePath = $node->getNodePath(); if (!isset($this->styleAttributesForNodes[$nodePath])) { $this->styleAttributesForNodes[$nodePath] = $this->parseCssDeclarationsBlock($normalizedOriginalStyle); $this->visitedNodes[$nodePath] = $node; } $node->setAttribute('style', $normalizedOriginalStyle); }
[ "private", "function", "normalizeStyleAttributes", "(", "\\", "DOMElement", "$", "node", ")", "{", "$", "normalizedOriginalStyle", "=", "preg_replace_callback", "(", "'/[A-z\\\\-]+(?=\\\\:)/S'", ",", "function", "(", "array", "$", "m", ")", "{", "return", "strtolowe...
Normalizes the value of the "style" attribute and saves it. @param \DOMElement $node @return void
[ "Normalizes", "the", "value", "of", "the", "style", "attribute", "and", "saves", "it", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L938-L957
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.getBodyElement
private function getBodyElement(\DOMDocument $document) { $bodyElement = $document->getElementsByTagName('body')->item(0); if ($bodyElement === null) { throw new \BadMethodCallException( 'getBodyElement method may only be called after ensureExistenceOfBodyElement has been called.', 1508173775427 ); } return $bodyElement; }
php
private function getBodyElement(\DOMDocument $document) { $bodyElement = $document->getElementsByTagName('body')->item(0); if ($bodyElement === null) { throw new \BadMethodCallException( 'getBodyElement method may only be called after ensureExistenceOfBodyElement has been called.', 1508173775427 ); } return $bodyElement; }
[ "private", "function", "getBodyElement", "(", "\\", "DOMDocument", "$", "document", ")", "{", "$", "bodyElement", "=", "$", "document", "->", "getElementsByTagName", "(", "'body'", ")", "->", "item", "(", "0", ")", ";", "if", "(", "$", "bodyElement", "==="...
Returns the BODY element. This method assumes that there always is a BODY element. @param \DOMDocument $document @return \DOMElement @throws \BadMethodCallException
[ "Returns", "the", "BODY", "element", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L1201-L1212
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.createRawXmlDocument
private function createRawXmlDocument() { $xmlDocument = new \DOMDocument; $xmlDocument->encoding = 'UTF-8'; $xmlDocument->strictErrorChecking = false; $xmlDocument->formatOutput = true; $libXmlState = libxml_use_internal_errors(true); $xmlDocument->loadHTML($this->getUnifiedHtml()); libxml_clear_errors(); libxml_use_internal_errors($libXmlState); $xmlDocument->normalizeDocument(); return $xmlDocument; }
php
private function createRawXmlDocument() { $xmlDocument = new \DOMDocument; $xmlDocument->encoding = 'UTF-8'; $xmlDocument->strictErrorChecking = false; $xmlDocument->formatOutput = true; $libXmlState = libxml_use_internal_errors(true); $xmlDocument->loadHTML($this->getUnifiedHtml()); libxml_clear_errors(); libxml_use_internal_errors($libXmlState); $xmlDocument->normalizeDocument(); return $xmlDocument; }
[ "private", "function", "createRawXmlDocument", "(", ")", "{", "$", "xmlDocument", "=", "new", "\\", "DOMDocument", ";", "$", "xmlDocument", "->", "encoding", "=", "'UTF-8'", ";", "$", "xmlDocument", "->", "strictErrorChecking", "=", "false", ";", "$", "xmlDocu...
Creates a DOMDocument instance with the current HTML. @return \DOMDocument
[ "Creates", "a", "DOMDocument", "instance", "with", "the", "current", "HTML", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L1269-L1282
train
oliverklee/ext-oelib
Resources/Private/Php/Emogrifier/Emogrifier.php
Emogrifier.getUnifiedHtml
private function getUnifiedHtml() { $htmlWithoutUnprocessableTags = $this->removeUnprocessableTags($this->html); $htmlWithDocumentType = $this->ensureDocumentType($htmlWithoutUnprocessableTags); return $this->addContentTypeMetaTag($htmlWithDocumentType); }
php
private function getUnifiedHtml() { $htmlWithoutUnprocessableTags = $this->removeUnprocessableTags($this->html); $htmlWithDocumentType = $this->ensureDocumentType($htmlWithoutUnprocessableTags); return $this->addContentTypeMetaTag($htmlWithDocumentType); }
[ "private", "function", "getUnifiedHtml", "(", ")", "{", "$", "htmlWithoutUnprocessableTags", "=", "$", "this", "->", "removeUnprocessableTags", "(", "$", "this", "->", "html", ")", ";", "$", "htmlWithDocumentType", "=", "$", "this", "->", "ensureDocumentType", "...
Returns the HTML with the unprocessable HTML tags removed and with added document type and Content-Type meta tag if needed. @return string the unified HTML @throws \BadMethodCallException
[ "Returns", "the", "HTML", "with", "the", "unprocessable", "HTML", "tags", "removed", "and", "with", "added", "document", "type", "and", "Content", "-", "Type", "meta", "tag", "if", "needed", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Resources/Private/Php/Emogrifier/Emogrifier.php#L1292-L1298
train
Distilleries/Expendable
src/Distilleries/Expendable/Models/StatusTrait.php
StatusTrait.onlyOffline
public static function onlyOffline() { $instance = new static; $column = $instance->getQualifiedStatusColumn(); return $instance->withoutGlobalScope(StatusScope::class)->where($column, false); }
php
public static function onlyOffline() { $instance = new static; $column = $instance->getQualifiedStatusColumn(); return $instance->withoutGlobalScope(StatusScope::class)->where($column, false); }
[ "public", "static", "function", "onlyOffline", "(", ")", "{", "$", "instance", "=", "new", "static", ";", "$", "column", "=", "$", "instance", "->", "getQualifiedStatusColumn", "(", ")", ";", "return", "$", "instance", "->", "withoutGlobalScope", "(", "Statu...
Get a new query builder that only includes offline items. @return \Illuminate\Database\Eloquent\Builder|static
[ "Get", "a", "new", "query", "builder", "that", "only", "includes", "offline", "items", "." ]
badfdabb7fc78447906fc9856bd313f2f1dbae8d
https://github.com/Distilleries/Expendable/blob/badfdabb7fc78447906fc9856bd313f2f1dbae8d/src/Distilleries/Expendable/Models/StatusTrait.php#L24-L32
train
ArgentCrusade/selectel-cloud-storage
src/Collections/Collection.php
Collection.current
public function current() { $currentKey = $this->keys[$this->position]; return isset($this->items[$currentKey]) ? $this->items[$currentKey] : null; }
php
public function current() { $currentKey = $this->keys[$this->position]; return isset($this->items[$currentKey]) ? $this->items[$currentKey] : null; }
[ "public", "function", "current", "(", ")", "{", "$", "currentKey", "=", "$", "this", "->", "keys", "[", "$", "this", "->", "position", "]", ";", "return", "isset", "(", "$", "this", "->", "items", "[", "$", "currentKey", "]", ")", "?", "$", "this",...
Current iterator item. @return mixed|null
[ "Current", "iterator", "item", "." ]
f085af14b496463dc30d4804eac8c5f574d121a4
https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Collections/Collection.php#L145-L150
train
ArgentCrusade/selectel-cloud-storage
src/Collections/Collection.php
Collection.valid
public function valid() { if (!isset($this->keys[$this->position])) { return false; } $currentKey = $this->keys[$this->position]; return isset($this->items[$currentKey]); }
php
public function valid() { if (!isset($this->keys[$this->position])) { return false; } $currentKey = $this->keys[$this->position]; return isset($this->items[$currentKey]); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "keys", "[", "$", "this", "->", "position", "]", ")", ")", "{", "return", "false", ";", "}", "$", "currentKey", "=", "$", "this", "->", "keys", "[", ...
Determines if there is some value at current iterator position. @return bool
[ "Determines", "if", "there", "is", "some", "value", "at", "current", "iterator", "position", "." ]
f085af14b496463dc30d4804eac8c5f574d121a4
https://github.com/ArgentCrusade/selectel-cloud-storage/blob/f085af14b496463dc30d4804eac8c5f574d121a4/src/Collections/Collection.php#L175-L184
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.getModel
public function getModel(array $data) { if (!isset($data['uid'])) { throw new \InvalidArgumentException('$data must contain an element "uid".', 1331319491); } $model = $this->find($data['uid']); if ($model->isGhost()) { $this->fillModel($model, $data); } return $model; }
php
public function getModel(array $data) { if (!isset($data['uid'])) { throw new \InvalidArgumentException('$data must contain an element "uid".', 1331319491); } $model = $this->find($data['uid']); if ($model->isGhost()) { $this->fillModel($model, $data); } return $model; }
[ "public", "function", "getModel", "(", "array", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'uid'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$data must contain an element \"uid\".'", ",", "13313...
Returns a model for the provided array. If the UID provided with the array is already mapped, this yet existing model will be returned irrespective of the other provided data, otherwise the model will be loaded with the provided data. @param array $data data for the model to return, must at least contain an element with the key "uid" @return \Tx_Oelib_Model model for the provided UID, filled with the data provided in case it did not have any data in memory before
[ "Returns", "a", "model", "for", "the", "provided", "array", ".", "If", "the", "UID", "provided", "with", "the", "array", "is", "already", "mapped", "this", "yet", "existing", "model", "will", "be", "returned", "irrespective", "of", "the", "other", "provided"...
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L160-L173
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.getListOfModels
public function getListOfModels(array $dataOfModels) { $list = new \Tx_Oelib_List(); foreach ($dataOfModels as $modelRecord) { $list->add($this->getModel($modelRecord)); } return $list; }
php
public function getListOfModels(array $dataOfModels) { $list = new \Tx_Oelib_List(); foreach ($dataOfModels as $modelRecord) { $list->add($this->getModel($modelRecord)); } return $list; }
[ "public", "function", "getListOfModels", "(", "array", "$", "dataOfModels", ")", "{", "$", "list", "=", "new", "\\", "Tx_Oelib_List", "(", ")", ";", "foreach", "(", "$", "dataOfModels", "as", "$", "modelRecord", ")", "{", "$", "list", "->", "add", "(", ...
Returns a list of models for the provided two-dimensional array with model data. @param array[] $dataOfModels two-dimensional array, each inner array must at least contain the element "uid", may be empty @return \Tx_Oelib_List<\Tx_Oelib_Model> Models with the UIDs provided. The models will be filled with the data provided in case they did not have any data before, otherwise the already loaded data will be used. If $dataOfModels was empty, an empty list will be returned. @see getModel()
[ "Returns", "a", "list", "of", "models", "for", "the", "provided", "two", "-", "dimensional", "array", "with", "model", "data", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L191-L200
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.existsModel
public function existsModel($uid, $allowHidden = false) { $model = $this->find($uid); if ($model->isGhost()) { $this->load($model); } return $model->isLoaded() && (!$model->isHidden() || $allowHidden); }
php
public function existsModel($uid, $allowHidden = false) { $model = $this->find($uid); if ($model->isGhost()) { $this->load($model); } return $model->isLoaded() && (!$model->isHidden() || $allowHidden); }
[ "public", "function", "existsModel", "(", "$", "uid", ",", "$", "allowHidden", "=", "false", ")", "{", "$", "model", "=", "$", "this", "->", "find", "(", "$", "uid", ")", ";", "if", "(", "$", "model", "->", "isGhost", "(", ")", ")", "{", "$", "...
Checks whether a model with a certain UID actually exists in the database and could be loaded. @param int $uid the UID of the record to retrieve, must be > 0 @param bool $allowHidden whether hidden records should be allowed to be retrieved @return bool TRUE if a model with the UID $uid exists in the database, FALSE otherwise
[ "Checks", "whether", "a", "model", "with", "a", "certain", "UID", "actually", "exists", "in", "the", "database", "and", "could", "be", "loaded", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L237-L246
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.createRelations
protected function createRelations(array &$data, \Tx_Oelib_Model $model) { foreach (array_keys($this->relations) as $key) { if ($this->isOneToManyRelationConfigured($key)) { $this->createOneToManyRelation($data, $key, $model); } elseif ($this->isManyToOneRelationConfigured($key)) { $this->createManyToOneRelation($data, $key); } else { if ($this->isManyToManyRelationConfigured($key)) { $this->createMToNRelation($data, $key, $model); } else { $this->createCommaSeparatedRelation($data, $key, $model); } } } }
php
protected function createRelations(array &$data, \Tx_Oelib_Model $model) { foreach (array_keys($this->relations) as $key) { if ($this->isOneToManyRelationConfigured($key)) { $this->createOneToManyRelation($data, $key, $model); } elseif ($this->isManyToOneRelationConfigured($key)) { $this->createManyToOneRelation($data, $key); } else { if ($this->isManyToManyRelationConfigured($key)) { $this->createMToNRelation($data, $key, $model); } else { $this->createCommaSeparatedRelation($data, $key, $model); } } } }
[ "protected", "function", "createRelations", "(", "array", "&", "$", "data", ",", "\\", "Tx_Oelib_Model", "$", "model", ")", "{", "foreach", "(", "array_keys", "(", "$", "this", "->", "relations", ")", "as", "$", "key", ")", "{", "if", "(", "$", "this",...
Processes a model's data and creates any relations that are hidden within it using foreign key mapping. @param array &$data the model data to process, might be modified @param \Tx_Oelib_Model $model the model to create the relations for @return void
[ "Processes", "a", "model", "s", "data", "and", "creates", "any", "relations", "that", "are", "hidden", "within", "it", "using", "foreign", "key", "mapping", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L380-L395
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.getRelationConfigurationFromTca
private function getRelationConfigurationFromTca($key) { $tca = \Tx_Oelib_Db::getTcaForTable($this->getTableName()); if (!isset($tca['columns'][$key])) { throw new \BadMethodCallException( 'In the table ' . $this->getTableName() . ', the column ' . $key . ' does not have a TCA entry.', 1331319627 ); } return $tca['columns'][$key]['config']; }
php
private function getRelationConfigurationFromTca($key) { $tca = \Tx_Oelib_Db::getTcaForTable($this->getTableName()); if (!isset($tca['columns'][$key])) { throw new \BadMethodCallException( 'In the table ' . $this->getTableName() . ', the column ' . $key . ' does not have a TCA entry.', 1331319627 ); } return $tca['columns'][$key]['config']; }
[ "private", "function", "getRelationConfigurationFromTca", "(", "$", "key", ")", "{", "$", "tca", "=", "\\", "Tx_Oelib_Db", "::", "getTcaForTable", "(", "$", "this", "->", "getTableName", "(", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "tca", "[", ...
Retrieves the configuration of a relation from the TCA. @param string $key the key of the relation to retrieve, must not be empty @return array configuration for that relation, will not be empty if the TCA is valid @throws \BadMethodCallException
[ "Retrieves", "the", "configuration", "of", "a", "relation", "from", "the", "TCA", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L407-L419
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.getNewGhost
public function getNewGhost() { $model = $this->createGhost($this->map->getNewUid()); $this->registerModelAsMemoryOnlyDummy($model); return $model; }
php
public function getNewGhost() { $model = $this->createGhost($this->map->getNewUid()); $this->registerModelAsMemoryOnlyDummy($model); return $model; }
[ "public", "function", "getNewGhost", "(", ")", "{", "$", "model", "=", "$", "this", "->", "createGhost", "(", "$", "this", "->", "map", "->", "getNewUid", "(", ")", ")", ";", "$", "this", "->", "registerModelAsMemoryOnlyDummy", "(", "$", "model", ")", ...
Creates a new registered ghost with a UID that has not been used in this data mapper yet. Important: As this ghost's UID has nothing to do with the real UIDs in the database, this ghost must not be loaded or saved. @return \Tx_Oelib_Model a new ghost
[ "Creates", "a", "new", "registered", "ghost", "with", "a", "UID", "that", "has", "not", "been", "used", "in", "this", "data", "mapper", "yet", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L717-L723
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.save
public function save(\Tx_Oelib_Model $model) { if ($this->isModelAMemoryOnlyDummy($model)) { throw new \InvalidArgumentException( 'This model is a memory-only dummy that must not be saved.', 1331319682 ); } if (!$this->hasDatabaseAccess() || !$model->isDirty() || !$model->isLoaded() || $model->isReadOnly() ) { return; } $data = $this->getPreparedModelData($model); $this->cacheModelByKeys($model, $data); if ($model->hasUid()) { \Tx_Oelib_Db::update($this->getTableName(), 'uid = ' . $model->getUid(), $data); $this->deleteManyToManyRelationIntermediateRecords($model); } else { $this->prepareDataForNewRecord($data); $model->setUid(\Tx_Oelib_Db::insert($this->getTableName(), $data)); $this->map->add($model); } if ($model->isDeleted()) { $model->markAsDead(); } else { $model->markAsClean(); // We save the 1:n relations after marking this model as clean // in order to avoid infinite loops when the foreign model tries // to save this parent. $this->saveOneToManyRelationRecords($model); $this->createManyToManyRelationIntermediateRecords($model); } }
php
public function save(\Tx_Oelib_Model $model) { if ($this->isModelAMemoryOnlyDummy($model)) { throw new \InvalidArgumentException( 'This model is a memory-only dummy that must not be saved.', 1331319682 ); } if (!$this->hasDatabaseAccess() || !$model->isDirty() || !$model->isLoaded() || $model->isReadOnly() ) { return; } $data = $this->getPreparedModelData($model); $this->cacheModelByKeys($model, $data); if ($model->hasUid()) { \Tx_Oelib_Db::update($this->getTableName(), 'uid = ' . $model->getUid(), $data); $this->deleteManyToManyRelationIntermediateRecords($model); } else { $this->prepareDataForNewRecord($data); $model->setUid(\Tx_Oelib_Db::insert($this->getTableName(), $data)); $this->map->add($model); } if ($model->isDeleted()) { $model->markAsDead(); } else { $model->markAsClean(); // We save the 1:n relations after marking this model as clean // in order to avoid infinite loops when the foreign model tries // to save this parent. $this->saveOneToManyRelationRecords($model); $this->createManyToManyRelationIntermediateRecords($model); } }
[ "public", "function", "save", "(", "\\", "Tx_Oelib_Model", "$", "model", ")", "{", "if", "(", "$", "this", "->", "isModelAMemoryOnlyDummy", "(", "$", "model", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'This model is a memory-only dum...
Writes a model to the database. Does nothing if database access is denied, if the model is clean, if the model has status dead, virgin or ghost, if the model is read-only or if there is no data to set. @param \Tx_Oelib_Model $model the model to write to the database @return void
[ "Writes", "a", "model", "to", "the", "database", ".", "Does", "nothing", "if", "database", "access", "is", "denied", "if", "the", "model", "is", "clean", "if", "the", "model", "has", "status", "dead", "virgin", "or", "ghost", "if", "the", "model", "is", ...
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L792-L831
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.getPreparedModelData
private function getPreparedModelData(\Tx_Oelib_Model $model) { if (!$model->hasUid()) { $model->setCreationDate(); } $model->setTimestamp(); $data = $model->getData(); foreach ($this->relations as $key => $relation) { if ($this->isOneToManyRelationConfigured($key)) { $functionName = 'count'; } elseif ($this->isManyToOneRelationConfigured($key)) { $functionName = 'getUid'; if ($data[$key] instanceof \Tx_Oelib_Model) { $this->saveManyToOneRelatedModels( $data[$key], \Tx_Oelib_MapperRegistry::get($relation) ); } } else { if ($this->isManyToManyRelationConfigured($key)) { $functionName = 'count'; } else { $functionName = 'getUids'; } if ($data[$key] instanceof \Tx_Oelib_List) { $this->saveManyToManyAndCommaSeparatedRelatedModels( $data[$key], \Tx_Oelib_MapperRegistry::get($relation) ); } } $data[$key] = (isset($data[$key]) && is_object($data[$key])) ? $data[$key]->$functionName() : 0; } return $data; }
php
private function getPreparedModelData(\Tx_Oelib_Model $model) { if (!$model->hasUid()) { $model->setCreationDate(); } $model->setTimestamp(); $data = $model->getData(); foreach ($this->relations as $key => $relation) { if ($this->isOneToManyRelationConfigured($key)) { $functionName = 'count'; } elseif ($this->isManyToOneRelationConfigured($key)) { $functionName = 'getUid'; if ($data[$key] instanceof \Tx_Oelib_Model) { $this->saveManyToOneRelatedModels( $data[$key], \Tx_Oelib_MapperRegistry::get($relation) ); } } else { if ($this->isManyToManyRelationConfigured($key)) { $functionName = 'count'; } else { $functionName = 'getUids'; } if ($data[$key] instanceof \Tx_Oelib_List) { $this->saveManyToManyAndCommaSeparatedRelatedModels( $data[$key], \Tx_Oelib_MapperRegistry::get($relation) ); } } $data[$key] = (isset($data[$key]) && is_object($data[$key])) ? $data[$key]->$functionName() : 0; } return $data; }
[ "private", "function", "getPreparedModelData", "(", "\\", "Tx_Oelib_Model", "$", "model", ")", "{", "if", "(", "!", "$", "model", "->", "hasUid", "(", ")", ")", "{", "$", "model", "->", "setCreationDate", "(", ")", ";", "}", "$", "model", "->", "setTim...
Prepares the model's data for the database. Changes the relations into a database-applicable format. Sets the timestamp and sets the "crdate" for new models. @param \Tx_Oelib_Model $model the model to write to the database @return array the model's data prepared for the database, will not be empty
[ "Prepares", "the", "model", "s", "data", "for", "the", "database", ".", "Changes", "the", "relations", "into", "a", "database", "-", "applicable", "format", ".", "Sets", "the", "timestamp", "and", "sets", "the", "crdate", "for", "new", "models", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L842-L883
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.prepareDataForNewRecord
protected function prepareDataForNewRecord(array &$data) { if ($this->testingFramework === null) { return; } $tableName = $this->getTableName(); $this->testingFramework->markTableAsDirty($tableName); $data[$this->testingFramework->getDummyColumnName($tableName)] = 1; }
php
protected function prepareDataForNewRecord(array &$data) { if ($this->testingFramework === null) { return; } $tableName = $this->getTableName(); $this->testingFramework->markTableAsDirty($tableName); $data[$this->testingFramework->getDummyColumnName($tableName)] = 1; }
[ "protected", "function", "prepareDataForNewRecord", "(", "array", "&", "$", "data", ")", "{", "if", "(", "$", "this", "->", "testingFramework", "===", "null", ")", "{", "return", ";", "}", "$", "tableName", "=", "$", "this", "->", "getTableName", "(", ")...
Prepares the data for models that get newly inserted into the DB. @param array $data the data of the record, will be modified @return void
[ "Prepares", "the", "data", "for", "models", "that", "get", "newly", "inserted", "into", "the", "DB", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L892-L901
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.deleteOneToManyRelations
private function deleteOneToManyRelations(\Tx_Oelib_Model $model) { $data = $model->getData(); foreach ($this->relations as $key => $mapperName) { if ($this->isOneToManyRelationConfigured($key)) { $relatedModels = $data[$key]; if (!is_object($relatedModels)) { continue; } $mapper = \Tx_Oelib_MapperRegistry::get($mapperName); /** @var \Tx_Oelib_Model $relatedModel */ foreach ($relatedModels as $relatedModel) { $mapper->delete($relatedModel); } } } }
php
private function deleteOneToManyRelations(\Tx_Oelib_Model $model) { $data = $model->getData(); foreach ($this->relations as $key => $mapperName) { if ($this->isOneToManyRelationConfigured($key)) { $relatedModels = $data[$key]; if (!is_object($relatedModels)) { continue; } $mapper = \Tx_Oelib_MapperRegistry::get($mapperName); /** @var \Tx_Oelib_Model $relatedModel */ foreach ($relatedModels as $relatedModel) { $mapper->delete($relatedModel); } } } }
[ "private", "function", "deleteOneToManyRelations", "(", "\\", "Tx_Oelib_Model", "$", "model", ")", "{", "$", "data", "=", "$", "model", "->", "getData", "(", ")", ";", "foreach", "(", "$", "this", "->", "relations", "as", "$", "key", "=>", "$", "mapperNa...
Deletes all one-to-many related models of this model. @param \Tx_Oelib_Model $model the model for which to delete the related models @return void
[ "Deletes", "all", "one", "-", "to", "-", "many", "related", "models", "of", "this", "model", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1153-L1171
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.getUniversalWhereClause
protected function getUniversalWhereClause($allowHiddenRecords = false) { $tableName = $this->getTableName(); if ($this->testingFramework !== null) { $dummyColumnName = $this->testingFramework->getDummyColumnName($tableName); $leftPart = \Tx_Oelib_Db::tableHasColumn($this->getTableName(), $dummyColumnName) ? $dummyColumnName . ' = 1' : '1 = 1'; } else { $leftPart = '1 = 1'; } return $leftPart . \Tx_Oelib_Db::enableFields($tableName, ($allowHiddenRecords ? 1 : -1)); }
php
protected function getUniversalWhereClause($allowHiddenRecords = false) { $tableName = $this->getTableName(); if ($this->testingFramework !== null) { $dummyColumnName = $this->testingFramework->getDummyColumnName($tableName); $leftPart = \Tx_Oelib_Db::tableHasColumn($this->getTableName(), $dummyColumnName) ? $dummyColumnName . ' = 1' : '1 = 1'; } else { $leftPart = '1 = 1'; } return $leftPart . \Tx_Oelib_Db::enableFields($tableName, ($allowHiddenRecords ? 1 : -1)); }
[ "protected", "function", "getUniversalWhereClause", "(", "$", "allowHiddenRecords", "=", "false", ")", "{", "$", "tableName", "=", "$", "this", "->", "getTableName", "(", ")", ";", "if", "(", "$", "this", "->", "testingFramework", "!==", "null", ")", "{", ...
Returns the WHERE clause that selects all visible records from the DB. @param bool $allowHiddenRecords whether hidden records should be found @return string the WHERE clause that selects all visible records in the, DB, will not be empty
[ "Returns", "the", "WHERE", "clause", "that", "selects", "all", "visible", "records", "from", "the", "DB", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1198-L1209
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.registerModelAsMemoryOnlyDummy
private function registerModelAsMemoryOnlyDummy(\Tx_Oelib_Model $model) { if (!$model->hasUid()) { return; } $this->uidsOfMemoryOnlyDummyModels[$model->getUid()] = true; }
php
private function registerModelAsMemoryOnlyDummy(\Tx_Oelib_Model $model) { if (!$model->hasUid()) { return; } $this->uidsOfMemoryOnlyDummyModels[$model->getUid()] = true; }
[ "private", "function", "registerModelAsMemoryOnlyDummy", "(", "\\", "Tx_Oelib_Model", "$", "model", ")", "{", "if", "(", "!", "$", "model", "->", "hasUid", "(", ")", ")", "{", "return", ";", "}", "$", "this", "->", "uidsOfMemoryOnlyDummyModels", "[", "$", ...
Registers a model as a memory-only dummy that must not be saved. @param \Tx_Oelib_Model $model the model to register @return void
[ "Registers", "a", "model", "as", "a", "memory", "-", "only", "dummy", "that", "must", "not", "be", "saved", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1218-L1225
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.findByWhereClause
protected function findByWhereClause($whereClause = '', $sorting = '', $limit = '') { $orderBy = ''; $tca = \Tx_Oelib_Db::getTcaForTable($this->getTableName()); if ($sorting !== '') { $orderBy = $sorting; } elseif (isset($tca['ctrl']['default_sortby'])) { $matches = []; if (preg_match( '/^ORDER BY (.+)$/', $tca['ctrl']['default_sortby'], $matches )) { $orderBy = $matches[1]; } } $completeWhereClause = ($whereClause === '') ? '' : $whereClause . ' AND '; $rows = \Tx_Oelib_Db::selectMultiple( '*', $this->getTableName(), $completeWhereClause . $this->getUniversalWhereClause(), '', $orderBy, $limit ); return $this->getListOfModels($rows); }
php
protected function findByWhereClause($whereClause = '', $sorting = '', $limit = '') { $orderBy = ''; $tca = \Tx_Oelib_Db::getTcaForTable($this->getTableName()); if ($sorting !== '') { $orderBy = $sorting; } elseif (isset($tca['ctrl']['default_sortby'])) { $matches = []; if (preg_match( '/^ORDER BY (.+)$/', $tca['ctrl']['default_sortby'], $matches )) { $orderBy = $matches[1]; } } $completeWhereClause = ($whereClause === '') ? '' : $whereClause . ' AND '; $rows = \Tx_Oelib_Db::selectMultiple( '*', $this->getTableName(), $completeWhereClause . $this->getUniversalWhereClause(), '', $orderBy, $limit ); return $this->getListOfModels($rows); }
[ "protected", "function", "findByWhereClause", "(", "$", "whereClause", "=", "''", ",", "$", "sorting", "=", "''", ",", "$", "limit", "=", "''", ")", "{", "$", "orderBy", "=", "''", ";", "$", "tca", "=", "\\", "Tx_Oelib_Db", "::", "getTcaForTable", "(",...
Retrieves all non-deleted, non-hidden models from the DB which match the given where clause. @param string $whereClause WHERE clause for the record to retrieve must be quoted and SQL safe, may be empty @param string $sorting the sorting for the found records, must be a valid DB field optionally followed by "ASC" or "DESC", may be empty @param string $limit the LIMIT value ([begin,]max), may be empty @return \Tx_Oelib_List<\Tx_Oelib_Model> all models found in DB for the given where clause, will be an empty list if no models were found
[ "Retrieves", "all", "non", "-", "deleted", "non", "-", "hidden", "models", "from", "the", "DB", "which", "match", "the", "given", "where", "clause", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1258-L1290
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.findByPageUid
public function findByPageUid($pageUids, $sorting = '', $limit = '') { if (($pageUids === '') || ($pageUids === '0') || ($pageUids === 0)) { return $this->findByWhereClause('', $sorting, $limit); } return $this->findByWhereClause($this->getTableName() . '.pid IN (' . $pageUids . ')', $sorting, $limit); }
php
public function findByPageUid($pageUids, $sorting = '', $limit = '') { if (($pageUids === '') || ($pageUids === '0') || ($pageUids === 0)) { return $this->findByWhereClause('', $sorting, $limit); } return $this->findByWhereClause($this->getTableName() . '.pid IN (' . $pageUids . ')', $sorting, $limit); }
[ "public", "function", "findByPageUid", "(", "$", "pageUids", ",", "$", "sorting", "=", "''", ",", "$", "limit", "=", "''", ")", "{", "if", "(", "(", "$", "pageUids", "===", "''", ")", "||", "(", "$", "pageUids", "===", "'0'", ")", "||", "(", "$",...
Finds all records which are located on the given pages. @param string $pageUids comma-separated UIDs of the pages on which the records should be found, may be empty @param string $sorting the sorting for the found records, must be a valid DB field optionally followed by "ASC" or "DESC", may be empty @param string $limit the LIMIT value ([begin,]max), may be empty @return \Tx_Oelib_List<\Tx_Oelib_Model> all records with the matching page UIDs, will be empty if no records have been found
[ "Finds", "all", "records", "which", "are", "located", "on", "the", "given", "pages", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1306-L1313
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.findOneByKeyFromCache
protected function findOneByKeyFromCache($key, $value) { if ($key === '') { throw new \InvalidArgumentException('$key must not be empty.', 1416847364); } if (!isset($this->cacheByKey[$key])) { throw new \InvalidArgumentException('"' . $key . '" is not a valid key for this mapper.', 1331319882); } if ($value === '') { throw new \InvalidArgumentException('$value must not be empty.', 1331319892); } if (!isset($this->cacheByKey[$key][$value])) { throw new \Tx_Oelib_Exception_NotFound(); } return $this->cacheByKey[$key][$value]; }
php
protected function findOneByKeyFromCache($key, $value) { if ($key === '') { throw new \InvalidArgumentException('$key must not be empty.', 1416847364); } if (!isset($this->cacheByKey[$key])) { throw new \InvalidArgumentException('"' . $key . '" is not a valid key for this mapper.', 1331319882); } if ($value === '') { throw new \InvalidArgumentException('$value must not be empty.', 1331319892); } if (!isset($this->cacheByKey[$key][$value])) { throw new \Tx_Oelib_Exception_NotFound(); } return $this->cacheByKey[$key][$value]; }
[ "protected", "function", "findOneByKeyFromCache", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "key", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$key must not be empty.'", ",", "1416847364", ")", ";", "}"...
Looks up a model in the cache by key. When this function reports "no match", the model could still exist in the database, though. @param string $key an existing key, must not be empty @param string $value the value for the key of the model to find, must not be empty @throws \InvalidArgumentException @throws \Tx_Oelib_Exception_NotFound if there is no match in the cache yet @return \Tx_Oelib_Model the cached model
[ "Looks", "up", "a", "model", "in", "the", "cache", "by", "key", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1330-L1347
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.findOneByCompoundKeyFromCache
public function findOneByCompoundKeyFromCache($value) { if ($value === '') { throw new \InvalidArgumentException('$value must not be empty.', 1331319992); } if (!isset($this->cacheByCompoundKey[$value])) { throw new \Tx_Oelib_Exception_NotFound(); } return $this->cacheByCompoundKey[$value]; }
php
public function findOneByCompoundKeyFromCache($value) { if ($value === '') { throw new \InvalidArgumentException('$value must not be empty.', 1331319992); } if (!isset($this->cacheByCompoundKey[$value])) { throw new \Tx_Oelib_Exception_NotFound(); } return $this->cacheByCompoundKey[$value]; }
[ "public", "function", "findOneByCompoundKeyFromCache", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$value must not be empty.'", ",", "1331319992", ")", ";", "}", "if", "(...
Looks up a model in the compound cache. When this function reports "no match", the model could still exist in the database, though. @param string $value the value for the compound key of the model to find, must not be empty @throws \InvalidArgumentException @throws \Tx_Oelib_Exception_NotFound if there is no match in the cache yet @return \Tx_Oelib_Model the cached model
[ "Looks", "up", "a", "model", "in", "the", "compound", "cache", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1363-L1374
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.cacheModelByCompoundKey
protected function cacheModelByCompoundKey(\Tx_Oelib_Model $model, array $data) { if (empty($this->compoundKeyParts)) { throw new \BadMethodCallException( 'The compound key parts are not defined.', 1363806895 ); } $values = []; foreach ($this->compoundKeyParts as $key) { if (isset($data[$key])) { $values[] = $data[$key]; } } if (count($this->compoundKeyParts) === count($values)) { $value = implode('.', $values); if ($value !== '') { $this->cacheByCompoundKey[$value] = $model; } } }
php
protected function cacheModelByCompoundKey(\Tx_Oelib_Model $model, array $data) { if (empty($this->compoundKeyParts)) { throw new \BadMethodCallException( 'The compound key parts are not defined.', 1363806895 ); } $values = []; foreach ($this->compoundKeyParts as $key) { if (isset($data[$key])) { $values[] = $data[$key]; } } if (count($this->compoundKeyParts) === count($values)) { $value = implode('.', $values); if ($value !== '') { $this->cacheByCompoundKey[$value] = $model; } } }
[ "protected", "function", "cacheModelByCompoundKey", "(", "\\", "Tx_Oelib_Model", "$", "model", ",", "array", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "compoundKeyParts", ")", ")", "{", "throw", "new", "\\", "BadMethodCallException", ...
Automatically caches a model by an additional compound key. It is cached only if all parts of the compound key have values. This method works automatically; it is not necessary to overwrite it. @param \Tx_Oelib_Model $model the model to cache @param string[] $data the data of the model as it is in the DB, may be empty @throws \BadMethodCallException @return void
[ "Automatically", "caches", "a", "model", "by", "an", "additional", "compound", "key", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1433-L1453
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.findOneByKey
public function findOneByKey($key, $value) { try { $model = $this->findOneByKeyFromCache($key, $value); } catch (\Tx_Oelib_Exception_NotFound $exception) { $model = $this->findSingleByWhereClause([$key => $value]); } return $model; }
php
public function findOneByKey($key, $value) { try { $model = $this->findOneByKeyFromCache($key, $value); } catch (\Tx_Oelib_Exception_NotFound $exception) { $model = $this->findSingleByWhereClause([$key => $value]); } return $model; }
[ "public", "function", "findOneByKey", "(", "$", "key", ",", "$", "value", ")", "{", "try", "{", "$", "model", "=", "$", "this", "->", "findOneByKeyFromCache", "(", "$", "key", ",", "$", "value", ")", ";", "}", "catch", "(", "\\", "Tx_Oelib_Exception_No...
Looks up a model by key. This function will first check the cache-by-key and, if there is no match, will try to find the model in the database. @throws \Tx_Oelib_Exception_NotFound if there is no match (neither in the cache nor in the database) @param string $key an existing key, must not be empty @param string $value the value for the key of the model to find, must not be empty @return \Tx_Oelib_Model the cached model
[ "Looks", "up", "a", "model", "by", "key", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1470-L1479
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.findOneByCompoundKey
public function findOneByCompoundKey(array $compoundKeyValues) { if (empty($compoundKeyValues)) { throw new \InvalidArgumentException( get_class($this) . '::compoundKeyValues must not be empty.', 1354976660 ); } try { $model = $this->findOneByCompoundKeyFromCache($this->extractCompoundKeyValues($compoundKeyValues)); } catch (\Tx_Oelib_Exception_NotFound $exception) { $model = $this->findSingleByWhereClause($compoundKeyValues); } return $model; }
php
public function findOneByCompoundKey(array $compoundKeyValues) { if (empty($compoundKeyValues)) { throw new \InvalidArgumentException( get_class($this) . '::compoundKeyValues must not be empty.', 1354976660 ); } try { $model = $this->findOneByCompoundKeyFromCache($this->extractCompoundKeyValues($compoundKeyValues)); } catch (\Tx_Oelib_Exception_NotFound $exception) { $model = $this->findSingleByWhereClause($compoundKeyValues); } return $model; }
[ "public", "function", "findOneByCompoundKey", "(", "array", "$", "compoundKeyValues", ")", "{", "if", "(", "empty", "(", "$", "compoundKeyValues", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "get_class", "(", "$", "this", ")", ".", ...
Looks up a model by a compound key. This function will first check the cache-by-key and, if there is no match, will try to find the model in the database. @param string[] $compoundKeyValues existing key value pairs, must not be empty The array must have all the keys that are set in the additionalCompoundKey array. The array values contain the model data with which to look up. @throws \InvalidArgumentException if parameter array $keyValue is empty @throws \Tx_Oelib_Exception_NotFound if there is no match (neither in the cache nor in the database) @return \Tx_Oelib_Model the cached model
[ "Looks", "up", "a", "model", "by", "a", "compound", "key", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1497-L1513
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.extractCompoundKeyValues
protected function extractCompoundKeyValues(array $compoundKeyValues) { $values = []; foreach ($this->compoundKeyParts as $key) { if (!isset($compoundKeyValues[$key])) { throw new \InvalidArgumentException( get_class($this) . '::keyValue does not contain all compound keys.', 1354976661 ); } $values[] = $compoundKeyValues[$key]; } return implode('.', $values); }
php
protected function extractCompoundKeyValues(array $compoundKeyValues) { $values = []; foreach ($this->compoundKeyParts as $key) { if (!isset($compoundKeyValues[$key])) { throw new \InvalidArgumentException( get_class($this) . '::keyValue does not contain all compound keys.', 1354976661 ); } $values[] = $compoundKeyValues[$key]; } return implode('.', $values); }
[ "protected", "function", "extractCompoundKeyValues", "(", "array", "$", "compoundKeyValues", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "compoundKeyParts", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$"...
Extracting the key value from model data. @param string[] $compoundKeyValues existing key value pairs, must not be empty The array must have all the keys that are set in the additionalCompoundKey array. The array values contain the model data with which to look up. @throws \InvalidArgumentException @return string Contains the values for the compound key parts concatenated with a dot.
[ "Extracting", "the", "key", "value", "from", "model", "data", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1527-L1541
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.countByWhereClause
public function countByWhereClause($whereClause = '') { $completeWhereClause = ($whereClause === '') ? '' : $whereClause . ' AND '; return \Tx_Oelib_Db::count($this->getTableName(), $completeWhereClause . $this->getUniversalWhereClause()); }
php
public function countByWhereClause($whereClause = '') { $completeWhereClause = ($whereClause === '') ? '' : $whereClause . ' AND '; return \Tx_Oelib_Db::count($this->getTableName(), $completeWhereClause . $this->getUniversalWhereClause()); }
[ "public", "function", "countByWhereClause", "(", "$", "whereClause", "=", "''", ")", "{", "$", "completeWhereClause", "=", "(", "$", "whereClause", "===", "''", ")", "?", "''", ":", "$", "whereClause", ".", "' AND '", ";", "return", "\\", "Tx_Oelib_Db", ":...
Returns the number of records matching the given WHERE clause. @param string $whereClause WHERE clause for the number of records to retrieve, must be quoted and SQL safe, may be empty @return int the number of records matching the given WHERE clause
[ "Returns", "the", "number", "of", "records", "matching", "the", "given", "WHERE", "clause", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1591-L1598
train
oliverklee/ext-oelib
Classes/DataMapper.php
Tx_Oelib_DataMapper.countByPageUid
public function countByPageUid($pageUids) { if (($pageUids === '') || ($pageUids === '0')) { return $this->countByWhereClause(''); } return $this->countByWhereClause($this->getTableName() . '.pid IN (' . $pageUids . ')'); }
php
public function countByPageUid($pageUids) { if (($pageUids === '') || ($pageUids === '0')) { return $this->countByWhereClause(''); } return $this->countByWhereClause($this->getTableName() . '.pid IN (' . $pageUids . ')'); }
[ "public", "function", "countByPageUid", "(", "$", "pageUids", ")", "{", "if", "(", "(", "$", "pageUids", "===", "''", ")", "||", "(", "$", "pageUids", "===", "'0'", ")", ")", "{", "return", "$", "this", "->", "countByWhereClause", "(", "''", ")", ";"...
Returns the number of records located on the given pages. @param string $pageUids comma-separated UIDs of the pages on which the records should be found, may be empty @return int the number of records located on the given pages
[ "Returns", "the", "number", "of", "records", "located", "on", "the", "given", "pages", "." ]
f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1
https://github.com/oliverklee/ext-oelib/blob/f2f353fdb8b5eb58b805f3c3170a82e9ed9066e1/Classes/DataMapper.php#L1609-L1616
train
girosolution/girocheckout_sdk
src/girocheckout-sdk/GiroCheckout_SDK_Tools.php
GiroCheckout_SDK_Tools.getCreditCardLogoName
public static function getCreditCardLogoName($visa_msc = false, $amex = false, $jcb = false) { if( $visa_msc == false && $amex == false && $jcb == false ) { return null; } $logoName = ''; if( $visa_msc ) { $logoName .= 'visa_msc_'; } if( $amex ) { $logoName .= 'amex_'; } if( $jcb ) { $logoName .= 'jcb_'; } $logoName .= '40px.png'; return $logoName; }
php
public static function getCreditCardLogoName($visa_msc = false, $amex = false, $jcb = false) { if( $visa_msc == false && $amex == false && $jcb == false ) { return null; } $logoName = ''; if( $visa_msc ) { $logoName .= 'visa_msc_'; } if( $amex ) { $logoName .= 'amex_'; } if( $jcb ) { $logoName .= 'jcb_'; } $logoName .= '40px.png'; return $logoName; }
[ "public", "static", "function", "getCreditCardLogoName", "(", "$", "visa_msc", "=", "false", ",", "$", "amex", "=", "false", ",", "$", "jcb", "=", "false", ")", "{", "if", "(", "$", "visa_msc", "==", "false", "&&", "$", "amex", "==", "false", "&&", "...
returns logname by given credit card types and size @param bool $visa_msc @param bool $amex @param bool $jcb @param bool $diners @param integer $size @param string $layout @return string
[ "returns", "logname", "by", "given", "credit", "card", "types", "and", "size" ]
4360f8894452a9c8f41b07f021746105e27a8575
https://github.com/girosolution/girocheckout_sdk/blob/4360f8894452a9c8f41b07f021746105e27a8575/src/girocheckout-sdk/GiroCheckout_SDK_Tools.php#L27-L48
train
webeweb/jquery-datatables-bundle
Helper/DataTablesRepositoryHelper.php
DataTablesRepositoryHelper.appendOrder
public static function appendOrder(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) { foreach ($dtWrapper->getRequest()->getOrder() as $dtOrder) { $dtColumn = array_values($dtWrapper->getColumns())[$dtOrder->getColumn()]; if (false === $dtColumn->getOrderable()) { continue; } $queryBuilder->addOrderBy($dtColumn->getMapping()->getAlias(), $dtOrder->getDir()); } }
php
public static function appendOrder(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) { foreach ($dtWrapper->getRequest()->getOrder() as $dtOrder) { $dtColumn = array_values($dtWrapper->getColumns())[$dtOrder->getColumn()]; if (false === $dtColumn->getOrderable()) { continue; } $queryBuilder->addOrderBy($dtColumn->getMapping()->getAlias(), $dtOrder->getDir()); } }
[ "public", "static", "function", "appendOrder", "(", "QueryBuilder", "$", "queryBuilder", ",", "DataTablesWrapperInterface", "$", "dtWrapper", ")", "{", "foreach", "(", "$", "dtWrapper", "->", "getRequest", "(", ")", "->", "getOrder", "(", ")", "as", "$", "dtOr...
Append an ORDER clause. @param QueryBuilder $queryBuilder The query builder. @param DataTablesWrapperInterface $dtWrapper The wrapper. @return void
[ "Append", "an", "ORDER", "clause", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Helper/DataTablesRepositoryHelper.php#L32-L43
train
webeweb/jquery-datatables-bundle
Helper/DataTablesRepositoryHelper.php
DataTablesRepositoryHelper.appendWhere
public static function appendWhere(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) { $operator = static::determineOperator($dtWrapper); if (null === $operator) { return; } $wheres = []; $params = []; $values = []; foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) { if (true === $dtColumn->getSearchable() && ("OR" === $operator || "" !== $dtColumn->getSearch()->getValue())) { $wheres[] = DataTablesMappingHelper::getWhere($dtColumn->getMapping()); $params[] = DataTablesMappingHelper::getParam($dtColumn->getMapping()); $values[] = "%" . ("AND" === $operator ? $dtColumn->getSearch()->getValue() : $dtWrapper->getRequest()->getSearch()->getValue()) . "%"; } } $queryBuilder->andWhere("(" . implode(" " . $operator . " ", $wheres) . ")"); for ($i = count($params) - 1; 0 <= $i; --$i) { $queryBuilder->setParameter($params[$i], $values[$i]); } }
php
public static function appendWhere(QueryBuilder $queryBuilder, DataTablesWrapperInterface $dtWrapper) { $operator = static::determineOperator($dtWrapper); if (null === $operator) { return; } $wheres = []; $params = []; $values = []; foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) { if (true === $dtColumn->getSearchable() && ("OR" === $operator || "" !== $dtColumn->getSearch()->getValue())) { $wheres[] = DataTablesMappingHelper::getWhere($dtColumn->getMapping()); $params[] = DataTablesMappingHelper::getParam($dtColumn->getMapping()); $values[] = "%" . ("AND" === $operator ? $dtColumn->getSearch()->getValue() : $dtWrapper->getRequest()->getSearch()->getValue()) . "%"; } } $queryBuilder->andWhere("(" . implode(" " . $operator . " ", $wheres) . ")"); for ($i = count($params) - 1; 0 <= $i; --$i) { $queryBuilder->setParameter($params[$i], $values[$i]); } }
[ "public", "static", "function", "appendWhere", "(", "QueryBuilder", "$", "queryBuilder", ",", "DataTablesWrapperInterface", "$", "dtWrapper", ")", "{", "$", "operator", "=", "static", "::", "determineOperator", "(", "$", "dtWrapper", ")", ";", "if", "(", "null",...
Append a WHERE clause. @param QueryBuilder $queryBuilder The query builder. @param DataTablesWrapperInterface $dtWrapper The wrapper. @return void
[ "Append", "a", "WHERE", "clause", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Helper/DataTablesRepositoryHelper.php#L52-L77
train
webeweb/jquery-datatables-bundle
Helper/DataTablesRepositoryHelper.php
DataTablesRepositoryHelper.determineOperator
public static function determineOperator(DataTablesWrapperInterface $dtWrapper) { foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) { if (false === $dtColumn->getSearchable()) { continue; } if ("" !== $dtColumn->getSearch()->getValue()) { return "AND"; } } // Check if the wrapper defines a search. if ("" !== $dtWrapper->getRequest()->getSearch()->getValue()) { return "OR"; } return null; }
php
public static function determineOperator(DataTablesWrapperInterface $dtWrapper) { foreach ($dtWrapper->getRequest()->getColumns() as $dtColumn) { if (false === $dtColumn->getSearchable()) { continue; } if ("" !== $dtColumn->getSearch()->getValue()) { return "AND"; } } // Check if the wrapper defines a search. if ("" !== $dtWrapper->getRequest()->getSearch()->getValue()) { return "OR"; } return null; }
[ "public", "static", "function", "determineOperator", "(", "DataTablesWrapperInterface", "$", "dtWrapper", ")", "{", "foreach", "(", "$", "dtWrapper", "->", "getRequest", "(", ")", "->", "getColumns", "(", ")", "as", "$", "dtColumn", ")", "{", "if", "(", "fal...
Determines an operator. @param DataTablesWrapperInterface $dtWrapper The wrapper. @return string Returns the operator.
[ "Determines", "an", "operator", "." ]
b53df9585a523fa1617128e6b467a5e574262a94
https://github.com/webeweb/jquery-datatables-bundle/blob/b53df9585a523fa1617128e6b467a5e574262a94/Helper/DataTablesRepositoryHelper.php#L85-L102
train
jaxon-php/jaxon-dialogs
src/Libraries/Library.php
Library.init
final public function init($sName, $xDialog) { // Set the library name $this->sName = $sName; // Set the dialog $this->xDialog = $xDialog; // Set the Response instance $this->setResponse($xDialog->response()); // Set the default URI. $this->sUri = $this->xDialog->getOption('dialogs.lib.uri', $this->sUri); // Set the library URI. $this->sUri = rtrim($this->getOption('uri', $this->sUri), '/'); // Set the subdir $this->sSubDir = trim($this->getOption('subdir', $this->sSubDir), '/'); // Set the version number $this->sVersion = trim($this->getOption('version', $this->sVersion), '/'); }
php
final public function init($sName, $xDialog) { // Set the library name $this->sName = $sName; // Set the dialog $this->xDialog = $xDialog; // Set the Response instance $this->setResponse($xDialog->response()); // Set the default URI. $this->sUri = $this->xDialog->getOption('dialogs.lib.uri', $this->sUri); // Set the library URI. $this->sUri = rtrim($this->getOption('uri', $this->sUri), '/'); // Set the subdir $this->sSubDir = trim($this->getOption('subdir', $this->sSubDir), '/'); // Set the version number $this->sVersion = trim($this->getOption('version', $this->sVersion), '/'); }
[ "final", "public", "function", "init", "(", "$", "sName", ",", "$", "xDialog", ")", "{", "// Set the library name", "$", "this", "->", "sName", "=", "$", "sName", ";", "// Set the dialog", "$", "this", "->", "xDialog", "=", "$", "xDialog", ";", "// Set the...
Initialize the library class instance @param string $sName The plugin name @param Jaxon\Dialogs\Dialog $xDialog The Dialog plugin instance @return void
[ "Initialize", "the", "library", "class", "instance" ]
830c5bff764e1a9aafb0c2d6a8aeb7be4c2b06d7
https://github.com/jaxon-php/jaxon-dialogs/blob/830c5bff764e1a9aafb0c2d6a8aeb7be4c2b06d7/src/Libraries/Library.php#L116-L132
train
jaxon-php/jaxon-dialogs
src/Libraries/Library.php
Library.hasOption
final public function hasOption($sName) { $sName = 'dialogs.' . $this->getName() . '.' . $sName; return $this->xDialog->hasOption($sName); }
php
final public function hasOption($sName) { $sName = 'dialogs.' . $this->getName() . '.' . $sName; return $this->xDialog->hasOption($sName); }
[ "final", "public", "function", "hasOption", "(", "$", "sName", ")", "{", "$", "sName", "=", "'dialogs.'", ".", "$", "this", "->", "getName", "(", ")", ".", "'.'", ".", "$", "sName", ";", "return", "$", "this", "->", "xDialog", "->", "hasOption", "(",...
Check the presence of a config option @param string $sName The option name @return bool True if the option exists, and false if not
[ "Check", "the", "presence", "of", "a", "config", "option" ]
830c5bff764e1a9aafb0c2d6a8aeb7be4c2b06d7
https://github.com/jaxon-php/jaxon-dialogs/blob/830c5bff764e1a9aafb0c2d6a8aeb7be4c2b06d7/src/Libraries/Library.php#L155-L159
train