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
atelierspierrot/library
src/Library/Session/FlashSession.php
FlashSession.allFlashes
public function allFlashes() { if ( ! $this->isOpened()) { $this->start(); } if (!empty($this->old_flashes)) { $_oldf = $this->old_flashes; $this->old_flashes = array(); return $_oldf; } return null; }
php
public function allFlashes() { if ( ! $this->isOpened()) { $this->start(); } if (!empty($this->old_flashes)) { $_oldf = $this->old_flashes; $this->old_flashes = array(); return $_oldf; } return null; }
[ "public", "function", "allFlashes", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "start", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "old_flashes", ")", ")", "{",...
Get current session flash parameters stack @return array
[ "Get", "current", "session", "flash", "parameters", "stack" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L151-L162
train
atelierspierrot/library
src/Library/Session/FlashSession.php
FlashSession.clearFlashes
public function clearFlashes() { if ( ! $this->isOpened()) { $this->start(); } $this->flashes = array(); $this->old_flashes = array(); return $this; }
php
public function clearFlashes() { if ( ! $this->isOpened()) { $this->start(); } $this->flashes = array(); $this->old_flashes = array(); return $this; }
[ "public", "function", "clearFlashes", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isOpened", "(", ")", ")", "{", "$", "this", "->", "start", "(", ")", ";", "}", "$", "this", "->", "flashes", "=", "array", "(", ")", ";", "$", "this", "->"...
Delete current session flash parameters @return self
[ "Delete", "current", "session", "flash", "parameters" ]
a2988a11370d13c7e0dc47f9d2d81c664c30b8dd
https://github.com/atelierspierrot/library/blob/a2988a11370d13c7e0dc47f9d2d81c664c30b8dd/src/Library/Session/FlashSession.php#L169-L177
train
SymBB/symbb
src/Symbb/Core/SystemBundle/Api/StatisticApi.php
StatisticApi.addVisitor
public function addVisitor(UserInterface $user, Request $request) { $days = 30; $ip = $request->getClientIp(); $data = $this->getVisitors(); $date = new \DateTime(); $currTimestamp = $date->getTimestamp(); // entries should be only hourly $date->setTime($date->format('H'), 0, 0); $todayTimestamp = $date->getTimestamp(); if (!isset($data[$todayTimestamp])) { $data[$todayTimestamp] = array(); } $type = $user->getSymbbType(); $currVisitor = array( 'id' => $user->getId(), 'type' => $type, 'ip' => $ip, 'lastVisiting' => $currTimestamp ); $overwriteKey = null; // remove entries who are to old $maxOldDate = new \DateTime(); $maxOldDate->setTime(0, 0, 0); $maxOldDate->modify('-' . $days . 'days'); foreach ($data as $timestamp => $tmp) { if (!is_numeric($timestamp) || $timestamp < $maxOldDate->getTimestamp()) { unset($data[$timestamp]); } } foreach ($data[$todayTimestamp] as $key => $visitor) { if ( // case 1: guest -> check ip ( $currVisitor['type'] == 'guest' && $visitor['type'] == $currVisitor['type'] && $visitor['ip'] == $currVisitor['ip'] ) || // case 2: user -> check id ( can login with different ips ) ( $currVisitor['type'] == 'user' && $visitor['type'] == $currVisitor['type'] && $visitor['id'] == $currVisitor['id'] ) ) { $overwriteKey = $key; break; } } // if we have found the same visitor in the data // then we will overwrite it // if not we will add the vistor if ($overwriteKey !== null) { $data[$todayTimestamp][$overwriteKey] = $currVisitor; } else { $data[$todayTimestamp][] = $currVisitor; } // sort ksort($data, SORT_NUMERIC); // reverse so that the newest are the first $data = array_reverse($data, true); $this->memcache->set(self::MEMCACHE_VISITOR_KEY, $data, (86400 * $days)); // 30 days valid }
php
public function addVisitor(UserInterface $user, Request $request) { $days = 30; $ip = $request->getClientIp(); $data = $this->getVisitors(); $date = new \DateTime(); $currTimestamp = $date->getTimestamp(); // entries should be only hourly $date->setTime($date->format('H'), 0, 0); $todayTimestamp = $date->getTimestamp(); if (!isset($data[$todayTimestamp])) { $data[$todayTimestamp] = array(); } $type = $user->getSymbbType(); $currVisitor = array( 'id' => $user->getId(), 'type' => $type, 'ip' => $ip, 'lastVisiting' => $currTimestamp ); $overwriteKey = null; // remove entries who are to old $maxOldDate = new \DateTime(); $maxOldDate->setTime(0, 0, 0); $maxOldDate->modify('-' . $days . 'days'); foreach ($data as $timestamp => $tmp) { if (!is_numeric($timestamp) || $timestamp < $maxOldDate->getTimestamp()) { unset($data[$timestamp]); } } foreach ($data[$todayTimestamp] as $key => $visitor) { if ( // case 1: guest -> check ip ( $currVisitor['type'] == 'guest' && $visitor['type'] == $currVisitor['type'] && $visitor['ip'] == $currVisitor['ip'] ) || // case 2: user -> check id ( can login with different ips ) ( $currVisitor['type'] == 'user' && $visitor['type'] == $currVisitor['type'] && $visitor['id'] == $currVisitor['id'] ) ) { $overwriteKey = $key; break; } } // if we have found the same visitor in the data // then we will overwrite it // if not we will add the vistor if ($overwriteKey !== null) { $data[$todayTimestamp][$overwriteKey] = $currVisitor; } else { $data[$todayTimestamp][] = $currVisitor; } // sort ksort($data, SORT_NUMERIC); // reverse so that the newest are the first $data = array_reverse($data, true); $this->memcache->set(self::MEMCACHE_VISITOR_KEY, $data, (86400 * $days)); // 30 days valid }
[ "public", "function", "addVisitor", "(", "UserInterface", "$", "user", ",", "Request", "$", "request", ")", "{", "$", "days", "=", "30", ";", "$", "ip", "=", "$", "request", "->", "getClientIp", "(", ")", ";", "$", "data", "=", "$", "this", "->", "...
this method will add a visitor to the statistic currently its only a memcache storage because this information is not important if someone will track his visitors fully he should use a analytics tool @param UserInterface $user @param Request $request
[ "this", "method", "will", "add", "a", "visitor", "to", "the", "statistic", "currently", "its", "only", "a", "memcache", "storage", "because", "this", "information", "is", "not", "important", "if", "someone", "will", "track", "his", "visitors", "fully", "he", ...
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/SystemBundle/Api/StatisticApi.php#L79-L152
train
nubs/sensible
src/Strategy/CommandLocatorStrategy.php
CommandLocatorStrategy.get
public function get() { foreach ($this->_commands as $command) { $location = $this->_commandLocator->locate(basename($command)); if ($location !== null) { return $location; } } return null; }
php
public function get() { foreach ($this->_commands as $command) { $location = $this->_commandLocator->locate(basename($command)); if ($location !== null) { return $location; } } return null; }
[ "public", "function", "get", "(", ")", "{", "foreach", "(", "$", "this", "->", "_commands", "as", "$", "command", ")", "{", "$", "location", "=", "$", "this", "->", "_commandLocator", "->", "locate", "(", "basename", "(", "$", "command", ")", ")", ";...
Returns the path to the first command found in the list. @return string|null The located command, or null if none could be found.
[ "Returns", "the", "path", "to", "the", "first", "command", "found", "in", "the", "list", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Strategy/CommandLocatorStrategy.php#L34-L44
train
dejan7/HTTPQuest
src/Decoders/FormDataDecoder.php
FormDataDecoder.readUntil
protected function readUntil($search) { while (($position = strpos($this->buffer, $search)) === false) { if (feof($this->fp)) { fclose($this->fp); throw new DecodeException( "Invalid multipart data encountered; " . "end of content was reached before expected" ); } $this->buffer .= fread($this->fp, $this->bytesPerRead); } return $position; }
php
protected function readUntil($search) { while (($position = strpos($this->buffer, $search)) === false) { if (feof($this->fp)) { fclose($this->fp); throw new DecodeException( "Invalid multipart data encountered; " . "end of content was reached before expected" ); } $this->buffer .= fread($this->fp, $this->bytesPerRead); } return $position; }
[ "protected", "function", "readUntil", "(", "$", "search", ")", "{", "while", "(", "(", "$", "position", "=", "strpos", "(", "$", "this", "->", "buffer", ",", "$", "search", ")", ")", "===", "false", ")", "{", "if", "(", "feof", "(", "$", "this", ...
Read the input stream into the buffer until a string is encountered @param string $search The string to read until @return int The position of the string in the buffer @throws DecodeException
[ "Read", "the", "input", "stream", "into", "the", "buffer", "until", "a", "string", "is", "encountered" ]
c0e1e2b08db6da2917020090aad767fe31552be3
https://github.com/dejan7/HTTPQuest/blob/c0e1e2b08db6da2917020090aad767fe31552be3/src/Decoders/FormDataDecoder.php#L246-L259
train
dejan7/HTTPQuest
src/Decoders/FormDataDecoder.php
FormDataDecoder.addValue
protected function addValue(&$fieldsArray, $name, $value) { $arrayCheck = substr($name, -2); if ($arrayCheck == '[]') { $nameSubstr = substr($name, 0, -2); if (!isset($fieldsArray[$nameSubstr])) $fieldsArray[$nameSubstr] = []; $fieldsArray[$nameSubstr][] = $value; } else { $fieldsArray[$name] = $value; } }
php
protected function addValue(&$fieldsArray, $name, $value) { $arrayCheck = substr($name, -2); if ($arrayCheck == '[]') { $nameSubstr = substr($name, 0, -2); if (!isset($fieldsArray[$nameSubstr])) $fieldsArray[$nameSubstr] = []; $fieldsArray[$nameSubstr][] = $value; } else { $fieldsArray[$name] = $value; } }
[ "protected", "function", "addValue", "(", "&", "$", "fieldsArray", ",", "$", "name", ",", "$", "value", ")", "{", "$", "arrayCheck", "=", "substr", "(", "$", "name", ",", "-", "2", ")", ";", "if", "(", "$", "arrayCheck", "==", "'[]'", ")", "{", "...
Inserts the value into the passed array. Used to parse input array from HTTP request body, if needed @param array $fieldsArray @param string $name name of the field @param string $value value of the field
[ "Inserts", "the", "value", "into", "the", "passed", "array", ".", "Used", "to", "parse", "input", "array", "from", "HTTP", "request", "body", "if", "needed" ]
c0e1e2b08db6da2917020090aad767fe31552be3
https://github.com/dejan7/HTTPQuest/blob/c0e1e2b08db6da2917020090aad767fe31552be3/src/Decoders/FormDataDecoder.php#L288-L301
train
logikostech/common
src/UserOptionTrait.php
UserOptionTrait.getUserOption
public function getUserOption($option, $defaultValue=null) { return isset($this->_options[$option]) ? $this->_options[$option] : $defaultValue; }
php
public function getUserOption($option, $defaultValue=null) { return isset($this->_options[$option]) ? $this->_options[$option] : $defaultValue; }
[ "public", "function", "getUserOption", "(", "$", "option", ",", "$", "defaultValue", "=", "null", ")", "{", "return", "isset", "(", "$", "this", "->", "_options", "[", "$", "option", "]", ")", "?", "$", "this", "->", "_options", "[", "$", "option", "...
Returns the value of an option if present @param string option @param mixed defaultValue @return mixed
[ "Returns", "the", "value", "of", "an", "option", "if", "present" ]
3329e934e28702b95a9a232f196d87c92e1a9401
https://github.com/logikostech/common/blob/3329e934e28702b95a9a232f196d87c92e1a9401/src/UserOptionTrait.php#L46-L50
train
logikostech/common
src/UserOptionTrait.php
UserOptionTrait._setDefaultUserOptions
protected function _setDefaultUserOptions(array $options) { foreach ($options as $option=>$value) { if (!$this->getUserOption($option)) $this->setUserOption($option,$value); } return $this; }
php
protected function _setDefaultUserOptions(array $options) { foreach ($options as $option=>$value) { if (!$this->getUserOption($option)) $this->setUserOption($option,$value); } return $this; }
[ "protected", "function", "_setDefaultUserOptions", "(", "array", "$", "options", ")", "{", "foreach", "(", "$", "options", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "getUserOption", "(", "$", "option", ")", "...
Used to set defaults, will not overwrite existing values @param array $options
[ "Used", "to", "set", "defaults", "will", "not", "overwrite", "existing", "values" ]
3329e934e28702b95a9a232f196d87c92e1a9401
https://github.com/logikostech/common/blob/3329e934e28702b95a9a232f196d87c92e1a9401/src/UserOptionTrait.php#L85-L91
train
fintech-fab/money-transfer-emulator-sdk
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
Gateway.city
public function city() { $requestParams = $this->initRequestParams('city'); $this->request('city', $requestParams); return empty($this->error); }
php
public function city() { $requestParams = $this->initRequestParams('city'); $this->request('city', $requestParams); return empty($this->error); }
[ "public", "function", "city", "(", ")", "{", "$", "requestParams", "=", "$", "this", "->", "initRequestParams", "(", "'city'", ")", ";", "$", "this", "->", "request", "(", "'city'", ",", "$", "requestParams", ")", ";", "return", "empty", "(", "$", "thi...
Get City list from gateway @return boolean
[ "Get", "City", "list", "from", "gateway" ]
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L79-L85
train
fintech-fab/money-transfer-emulator-sdk
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
Gateway.fee
public function fee($cityId, $orderAmount) { $params = compact('cityId', 'orderAmount'); $requestParams = $this->initRequestParams('fee', $params); $this->request('fee', $requestParams); return empty($this->error); }
php
public function fee($cityId, $orderAmount) { $params = compact('cityId', 'orderAmount'); $requestParams = $this->initRequestParams('fee', $params); $this->request('fee', $requestParams); return empty($this->error); }
[ "public", "function", "fee", "(", "$", "cityId", ",", "$", "orderAmount", ")", "{", "$", "params", "=", "compact", "(", "'cityId'", ",", "'orderAmount'", ")", ";", "$", "requestParams", "=", "$", "this", "->", "initRequestParams", "(", "'fee'", ",", "$",...
Get fee result by city and amount @param integer $cityId @param float $orderAmount @return boolean
[ "Get", "fee", "result", "by", "city", "and", "amount" ]
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L119-L126
train
fintech-fab/money-transfer-emulator-sdk
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
Gateway.getFeeValue
public function getFeeValue($cityId, $orderAmount) { $result = $this->fee($cityId, $orderAmount); if (!$result) { dd($this->getResultRaw()); return null; } return $this->getResultFeeValue(); }
php
public function getFeeValue($cityId, $orderAmount) { $result = $this->fee($cityId, $orderAmount); if (!$result) { dd($this->getResultRaw()); return null; } return $this->getResultFeeValue(); }
[ "public", "function", "getFeeValue", "(", "$", "cityId", ",", "$", "orderAmount", ")", "{", "$", "result", "=", "$", "this", "->", "fee", "(", "$", "cityId", ",", "$", "orderAmount", ")", ";", "if", "(", "!", "$", "result", ")", "{", "dd", "(", "...
Get fee value by city and amount @param integer $cityId @param float $orderAmount @return boolean
[ "Get", "fee", "value", "by", "city", "and", "amount" ]
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L136-L148
train
fintech-fab/money-transfer-emulator-sdk
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
Gateway.status
public function status($orderCode, $toNumber) { $params = compact('orderCode', 'toNumber'); $requestParams = $this->initRequestParams('status', $params); $this->request('status', $requestParams); return empty($this->error); }
php
public function status($orderCode, $toNumber) { $params = compact('orderCode', 'toNumber'); $requestParams = $this->initRequestParams('status', $params); $this->request('status', $requestParams); return empty($this->error); }
[ "public", "function", "status", "(", "$", "orderCode", ",", "$", "toNumber", ")", "{", "$", "params", "=", "compact", "(", "'orderCode'", ",", "'toNumber'", ")", ";", "$", "requestParams", "=", "$", "this", "->", "initRequestParams", "(", "'status'", ",", ...
Get payment status @param string $orderCode @param string $toNumber @return boolean
[ "Get", "payment", "status" ]
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L195-L202
train
fintech-fab/money-transfer-emulator-sdk
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
Gateway.request
private function request($type, $requestParams) { $this->cleanup(); $curl = new Curl(); $curl->setCheckCertificates($this->configParams['strongSSL']); $curl->post($this->configParams['gatewayUrl'], array( 'type' => $type, 'input' => $requestParams, )); $this->parseErrors($curl); if (!$this->error || $this->error['type'] == self::C_ERROR_PROCESSING) { $this->response = json_decode($curl->result); } }
php
private function request($type, $requestParams) { $this->cleanup(); $curl = new Curl(); $curl->setCheckCertificates($this->configParams['strongSSL']); $curl->post($this->configParams['gatewayUrl'], array( 'type' => $type, 'input' => $requestParams, )); $this->parseErrors($curl); if (!$this->error || $this->error['type'] == self::C_ERROR_PROCESSING) { $this->response = json_decode($curl->result); } }
[ "private", "function", "request", "(", "$", "type", ",", "$", "requestParams", ")", "{", "$", "this", "->", "cleanup", "(", ")", ";", "$", "curl", "=", "new", "Curl", "(", ")", ";", "$", "curl", "->", "setCheckCertificates", "(", "$", "this", "->", ...
Executing http request @param string $type @param array $requestParams
[ "Executing", "http", "request" ]
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L464-L481
train
fintech-fab/money-transfer-emulator-sdk
src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php
Gateway.parseErrors
private function parseErrors(Curl $curl) { $this->rawResponse = $curl->result; if ($curl->error) { $this->error = array( 'type' => self::C_ERROR_HTTP, 'message' => 'Curl error: ' . $curl->error, ); return; } if ($curl->code != '200') { $this->error = array( 'type' => self::C_ERROR_HTTP, 'message' => 'Response code: ' . $curl->code, ); return; } if (empty($curl->result)) { $this->error = array( 'type' => self::C_ERROR_GATEWAY, 'message' => 'Empty Response', ); return; } $response = @json_decode($curl->result); if (!$response || empty($response->type)) { $this->error = array( 'type' => self::C_ERROR_GATEWAY, 'message' => 'Response is not json or Unrecognized response format', ); return; } if ($response->type == 'error') { $this->error = array( 'type' => self::C_ERROR_PROCESSING, 'message' => $response->message, ); return; } }
php
private function parseErrors(Curl $curl) { $this->rawResponse = $curl->result; if ($curl->error) { $this->error = array( 'type' => self::C_ERROR_HTTP, 'message' => 'Curl error: ' . $curl->error, ); return; } if ($curl->code != '200') { $this->error = array( 'type' => self::C_ERROR_HTTP, 'message' => 'Response code: ' . $curl->code, ); return; } if (empty($curl->result)) { $this->error = array( 'type' => self::C_ERROR_GATEWAY, 'message' => 'Empty Response', ); return; } $response = @json_decode($curl->result); if (!$response || empty($response->type)) { $this->error = array( 'type' => self::C_ERROR_GATEWAY, 'message' => 'Response is not json or Unrecognized response format', ); return; } if ($response->type == 'error') { $this->error = array( 'type' => self::C_ERROR_PROCESSING, 'message' => $response->message, ); return; } }
[ "private", "function", "parseErrors", "(", "Curl", "$", "curl", ")", "{", "$", "this", "->", "rawResponse", "=", "$", "curl", "->", "result", ";", "if", "(", "$", "curl", "->", "error", ")", "{", "$", "this", "->", "error", "=", "array", "(", "'typ...
Parse error type @param Curl $curl
[ "Parse", "error", "type" ]
5aa881e80bbf78c0cd667a7769d1eb0f8c19b827
https://github.com/fintech-fab/money-transfer-emulator-sdk/blob/5aa881e80bbf78c0cd667a7769d1eb0f8c19b827/src/FintechFab/MoneyTransferEmulatorSdk/Gateway.php#L488-L539
train
kernel-php/xml2object
Xml2Object.php
Xml2Object.simpleArrayToObject
public static function simpleArrayToObject($array, $object = null) { foreach ($array as $key => $value) { $object->$key = $value; } return $object; }
php
public static function simpleArrayToObject($array, $object = null) { foreach ($array as $key => $value) { $object->$key = $value; } return $object; }
[ "public", "static", "function", "simpleArrayToObject", "(", "$", "array", ",", "$", "object", "=", "null", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "object", "->", "$", "key", "=", "$", "value", "...
utilisation simple array with numeric keys to object
[ "utilisation", "simple", "array", "with", "numeric", "keys", "to", "object" ]
12275be3e4d8ed2df5b43aecfabbf6c8fc5809fd
https://github.com/kernel-php/xml2object/blob/12275be3e4d8ed2df5b43aecfabbf6c8fc5809fd/Xml2Object.php#L56-L61
train
AthensFramework/Core
src/writer/HTMLWriter.php
HTMLWriter.visitForm
public function visitForm(FormInterface $form) { $template = "form/{$form->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $form->getId(), "classes" => $form->getClasses(), "data" => $form->getData(), "method" => $form->getMethod(), "target" => $form->getTarget(), "writables" => $form->getWritableBearer()->getWritables(), "actions" => $form->getActions(), "errors" => $form->getErrors(), ] ); }
php
public function visitForm(FormInterface $form) { $template = "form/{$form->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $form->getId(), "classes" => $form->getClasses(), "data" => $form->getData(), "method" => $form->getMethod(), "target" => $form->getTarget(), "writables" => $form->getWritableBearer()->getWritables(), "actions" => $form->getActions(), "errors" => $form->getErrors(), ] ); }
[ "public", "function", "visitForm", "(", "FormInterface", "$", "form", ")", "{", "$", "template", "=", "\"form/{$form->getType()}.twig\"", ";", "return", "$", "this", "->", "loadTemplate", "(", "$", "template", ")", "->", "render", "(", "[", "\"id\"", "=>", "...
Render FormInterface into html. This method is generally called via double-dispatch, as provided by Visitor\VisitableTrait. @param FormInterface $form @return string
[ "Render", "FormInterface", "into", "html", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/HTMLWriter.php#L264-L282
train
AthensFramework/Core
src/writer/HTMLWriter.php
HTMLWriter.visitFormAction
public function visitFormAction(FormActionInterface $formAction) { $template = "form-action/{$formAction->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "label" => $formAction->getLabel(), "target" => $formAction->getTarget(), "classes" => $formAction->getClasses(), "data" => $formAction->getData(), ] ); }
php
public function visitFormAction(FormActionInterface $formAction) { $template = "form-action/{$formAction->getType()}.twig"; return $this ->loadTemplate($template) ->render( [ "label" => $formAction->getLabel(), "target" => $formAction->getTarget(), "classes" => $formAction->getClasses(), "data" => $formAction->getData(), ] ); }
[ "public", "function", "visitFormAction", "(", "FormActionInterface", "$", "formAction", ")", "{", "$", "template", "=", "\"form-action/{$formAction->getType()}.twig\"", ";", "return", "$", "this", "->", "loadTemplate", "(", "$", "template", ")", "->", "render", "(",...
Render FormActionInterface into html. This method is generally called via double-dispatch, as provided by Visitor\VisitableTrait. @param FormActionInterface $formAction @return string
[ "Render", "FormActionInterface", "into", "html", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/HTMLWriter.php#L292-L306
train
AthensFramework/Core
src/writer/HTMLWriter.php
HTMLWriter.visitFilter
public function visitFilter(FilterInterface $filter) { if ($filter instanceof DummyFilter) { $type = 'dummy'; } elseif ($filter instanceof SelectFilter) { $type = 'select'; } elseif ($filter instanceof SearchFilter) { $type = 'search'; } elseif ($filter instanceof SortFilter) { $type = 'sort'; } elseif ($filter instanceof PaginationFilter) { $type = "{$filter->getType()}-pagination"; } elseif (method_exists($filter, 'getType') === true) { $type = $filter->getType(); } else { $type = 'dummy'; } $template = "filter/$type.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $filter->getId(), "options" => $filter->getOptions(), ] ); }
php
public function visitFilter(FilterInterface $filter) { if ($filter instanceof DummyFilter) { $type = 'dummy'; } elseif ($filter instanceof SelectFilter) { $type = 'select'; } elseif ($filter instanceof SearchFilter) { $type = 'search'; } elseif ($filter instanceof SortFilter) { $type = 'sort'; } elseif ($filter instanceof PaginationFilter) { $type = "{$filter->getType()}-pagination"; } elseif (method_exists($filter, 'getType') === true) { $type = $filter->getType(); } else { $type = 'dummy'; } $template = "filter/$type.twig"; return $this ->loadTemplate($template) ->render( [ "id" => $filter->getId(), "options" => $filter->getOptions(), ] ); }
[ "public", "function", "visitFilter", "(", "FilterInterface", "$", "filter", ")", "{", "if", "(", "$", "filter", "instanceof", "DummyFilter", ")", "{", "$", "type", "=", "'dummy'", ";", "}", "elseif", "(", "$", "filter", "instanceof", "SelectFilter", ")", "...
Helper method to render a FilterInterface to html. @param FilterInterface $filter @return array
[ "Helper", "method", "to", "render", "a", "FilterInterface", "to", "html", "." ]
6237b914b9f6aef6b2fcac23094b657a86185340
https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/writer/HTMLWriter.php#L314-L341
train
joegreen88/zf1-component-http
src/Zend/Http/UserAgent/AbstractDevice.php
Zend_Http_UserAgent_AbstractDevice._restoreFromArray
protected function _restoreFromArray(array $spec) { foreach ($spec as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } }
php
protected function _restoreFromArray(array $spec) { foreach ($spec as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } }
[ "protected", "function", "_restoreFromArray", "(", "array", "$", "spec", ")", "{", "foreach", "(", "$", "spec", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "key", ")", ")", "{", "$", "th...
Restore object state from array @param array $spec @return void
[ "Restore", "object", "state", "from", "array" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent/AbstractDevice.php#L156-L163
train
joegreen88/zf1-component-http
src/Zend/Http/UserAgent/AbstractDevice.php
Zend_Http_UserAgent_AbstractDevice.setGroup
public function setGroup($group, $feature) { if (!isset($this->_aGroup[$group])) { $this->_aGroup[$group] = array(); } if (!in_array($feature, $this->_aGroup[$group])) { $this->_aGroup[$group][] = $feature; } return $this; }
php
public function setGroup($group, $feature) { if (!isset($this->_aGroup[$group])) { $this->_aGroup[$group] = array(); } if (!in_array($feature, $this->_aGroup[$group])) { $this->_aGroup[$group][] = $feature; } return $this; }
[ "public", "function", "setGroup", "(", "$", "group", ",", "$", "feature", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_aGroup", "[", "$", "group", "]", ")", ")", "{", "$", "this", "->", "_aGroup", "[", "$", "group", "]", "=", "a...
Affects a feature to a group @param string $group Group name @param string $feature Feature name @return Zend_Http_UserAgent_AbstractDevice
[ "Affects", "a", "feature", "to", "a", "group" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent/AbstractDevice.php#L236-L245
train
joegreen88/zf1-component-http
src/Zend/Http/UserAgent/AbstractDevice.php
Zend_Http_UserAgent_AbstractDevice._matchAgentAgainstSignatures
protected static function _matchAgentAgainstSignatures($userAgent, $signatures) { $userAgent = strtolower($userAgent); foreach ($signatures as $signature) { if (!empty($signature)) { if (strpos($userAgent, $signature) !== false) { // Browser signature was found in user agent string return true; } } } return false; }
php
protected static function _matchAgentAgainstSignatures($userAgent, $signatures) { $userAgent = strtolower($userAgent); foreach ($signatures as $signature) { if (!empty($signature)) { if (strpos($userAgent, $signature) !== false) { // Browser signature was found in user agent string return true; } } } return false; }
[ "protected", "static", "function", "_matchAgentAgainstSignatures", "(", "$", "userAgent", ",", "$", "signatures", ")", "{", "$", "userAgent", "=", "strtolower", "(", "$", "userAgent", ")", ";", "foreach", "(", "$", "signatures", "as", "$", "signature", ")", ...
Match a user agent string against a list of signatures @param string $userAgent @param array $signatures @return bool
[ "Match", "a", "user", "agent", "string", "against", "a", "list", "of", "signatures" ]
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/UserAgent/AbstractDevice.php#L980-L992
train
ehough/chaingang
src/main/php/ehough/chaingang/impl/StandardContext.php
ehough_chaingang_impl_StandardContext.get
public final function get($key) { if (isset($this->_map[$key])) { return $this->_map[$key]; } return null; }
php
public final function get($key) { if (isset($this->_map[$key])) { return $this->_map[$key]; } return null; }
[ "public", "final", "function", "get", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_map", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "_map", "[", "$", "key", "]", ";", "}", "return", "null", "...
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases. @param string $key Key whose associated value is to be returned. @return mixed The value to which this map maps the specified key, or null if the map contains no mapping for this key.
[ "Returns", "the", "value", "to", "which", "this", "map", "maps", "the", "specified", "key", "." ]
823f7f54333df89c480ddf8d14ac0f2c6bb75868
https://github.com/ehough/chaingang/blob/823f7f54333df89c480ddf8d14ac0f2c6bb75868/src/main/php/ehough/chaingang/impl/StandardContext.php#L87-L95
train
ehough/chaingang
src/main/php/ehough/chaingang/impl/StandardContext.php
ehough_chaingang_impl_StandardContext.putAll
public final function putAll(array $values) { if (! is_array($values)) { return; } foreach ($values as $key => $value) { $this->put($key, $value); } }
php
public final function putAll(array $values) { if (! is_array($values)) { return; } foreach ($values as $key => $value) { $this->put($key, $value); } }
[ "public", "final", "function", "putAll", "(", "array", "$", "values", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$",...
Copies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. @param array $values Mappings to be stored in this map. @return void
[ "Copies", "all", "of", "the", "mappings", "from", "the", "specified", "map", "to", "this", "map", "." ]
823f7f54333df89c480ddf8d14ac0f2c6bb75868
https://github.com/ehough/chaingang/blob/823f7f54333df89c480ddf8d14ac0f2c6bb75868/src/main/php/ehough/chaingang/impl/StandardContext.php#L140-L151
train
ehough/chaingang
src/main/php/ehough/chaingang/impl/StandardContext.php
ehough_chaingang_impl_StandardContext.remove
public final function remove($key) { $previous = $this->get($key); if (isset($this->_map[$key])) { unset($this->_map[$key]); } return $previous; }
php
public final function remove($key) { $previous = $this->get($key); if (isset($this->_map[$key])) { unset($this->_map[$key]); } return $previous; }
[ "public", "final", "function", "remove", "(", "$", "key", ")", "{", "$", "previous", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_map", "[", "$", "key", "]", ")", ")", "{", "unset", "...
Removes the mapping for this key from this map if it is present. @param string $key Key whose mapping is to be removed from the map. @return mixed Previous value associated with specified key, or null if there was no mapping for key.
[ "Removes", "the", "mapping", "for", "this", "key", "from", "this", "map", "if", "it", "is", "present", "." ]
823f7f54333df89c480ddf8d14ac0f2c6bb75868
https://github.com/ehough/chaingang/blob/823f7f54333df89c480ddf8d14ac0f2c6bb75868/src/main/php/ehough/chaingang/impl/StandardContext.php#L160-L170
train
phellow/intl
src/ArrayTranslator.php
ArrayTranslator.initLocale
protected function initLocale($locale) { $file = $this->localeDir . '/' . $locale . '.php'; if (file_exists($file)) { $data = include $file; if (!is_array($data)) { $data = []; } } else { $data = []; } if (!isset($data['pluralForm']) || !is_callable($data['pluralForm'])) { $data['pluralForm'] = null; } if (!isset($data['texts'])) { $data['texts'] = []; } $this->data[$locale] = $data; }
php
protected function initLocale($locale) { $file = $this->localeDir . '/' . $locale . '.php'; if (file_exists($file)) { $data = include $file; if (!is_array($data)) { $data = []; } } else { $data = []; } if (!isset($data['pluralForm']) || !is_callable($data['pluralForm'])) { $data['pluralForm'] = null; } if (!isset($data['texts'])) { $data['texts'] = []; } $this->data[$locale] = $data; }
[ "protected", "function", "initLocale", "(", "$", "locale", ")", "{", "$", "file", "=", "$", "this", "->", "localeDir", ".", "'/'", ".", "$", "locale", ".", "'.php'", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "data", "=", ...
Set translations and plural form for the given locale. @param string $locale
[ "Set", "translations", "and", "plural", "form", "for", "the", "given", "locale", "." ]
7817f57242a6084ce68ddfb3055191c955ec14f1
https://github.com/phellow/intl/blob/7817f57242a6084ce68ddfb3055191c955ec14f1/src/ArrayTranslator.php#L66-L87
train
phellow/intl
src/ArrayTranslator.php
ArrayTranslator.getPluralIndex
protected function getPluralIndex(callable $pluralForm, $number) { $nplurals = 0; $plural = 0; call_user_func_array($pluralForm, [&$nplurals, &$plural, $number]); if (is_bool($plural)) { $plural = $plural ? 1 : 0; } if ($plural < 0) { $plural = 0; } if ($plural > $nplurals - 1) { $plural = $nplurals - 1; } return $plural; }
php
protected function getPluralIndex(callable $pluralForm, $number) { $nplurals = 0; $plural = 0; call_user_func_array($pluralForm, [&$nplurals, &$plural, $number]); if (is_bool($plural)) { $plural = $plural ? 1 : 0; } if ($plural < 0) { $plural = 0; } if ($plural > $nplurals - 1) { $plural = $nplurals - 1; } return $plural; }
[ "protected", "function", "getPluralIndex", "(", "callable", "$", "pluralForm", ",", "$", "number", ")", "{", "$", "nplurals", "=", "0", ";", "$", "plural", "=", "0", ";", "call_user_func_array", "(", "$", "pluralForm", ",", "[", "&", "$", "nplurals", ","...
Get plural form index for the given number. @param callable $pluralForm @param int $number @return int
[ "Get", "plural", "form", "index", "for", "the", "given", "number", "." ]
7817f57242a6084ce68ddfb3055191c955ec14f1
https://github.com/phellow/intl/blob/7817f57242a6084ce68ddfb3055191c955ec14f1/src/ArrayTranslator.php#L147-L167
train
ForceLabsDev/framework
src/Psr/ClassLoader.php
ClassLoader.addNamespace
public function addNamespace($prefix, $baseDir) { $prefix = trim($prefix, '\\').'\\'; $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; if (!isset($this->namespaceMap[$prefix])) { $this->namespaceMap[$prefix] = []; } array_push($this->namespaceMap[$prefix], str_replace('$path', $this->basePath, $baseDir)); }
php
public function addNamespace($prefix, $baseDir) { $prefix = trim($prefix, '\\').'\\'; $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR; if (!isset($this->namespaceMap[$prefix])) { $this->namespaceMap[$prefix] = []; } array_push($this->namespaceMap[$prefix], str_replace('$path', $this->basePath, $baseDir)); }
[ "public", "function", "addNamespace", "(", "$", "prefix", ",", "$", "baseDir", ")", "{", "$", "prefix", "=", "trim", "(", "$", "prefix", ",", "'\\\\'", ")", ".", "'\\\\'", ";", "$", "baseDir", "=", "rtrim", "(", "$", "baseDir", ",", "DIRECTORY_SEPARATO...
Registers a PSR-4 namespace. @param string $prefix @param string $baseDir
[ "Registers", "a", "PSR", "-", "4", "namespace", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Psr/ClassLoader.php#L31-L39
train
ForceLabsDev/framework
src/Psr/ClassLoader.php
ClassLoader.register
public function register() { spl_autoload_register(function ($class) { $prefix = $class; while (false !== $pos = strrpos($prefix, '\\')) { $prefix = substr($class, 0, $pos + 1); $relativeClass = substr($class, $pos + 1); $paths = $this->getPaths($prefix); if ($paths !== null) { foreach ($paths as $baseDir) { $file = $baseDir.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass).'.php'; if (file_exists($file)) { require $file; return true; } } } $prefix = rtrim($prefix, '\\'); } return false; }); }
php
public function register() { spl_autoload_register(function ($class) { $prefix = $class; while (false !== $pos = strrpos($prefix, '\\')) { $prefix = substr($class, 0, $pos + 1); $relativeClass = substr($class, $pos + 1); $paths = $this->getPaths($prefix); if ($paths !== null) { foreach ($paths as $baseDir) { $file = $baseDir.str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass).'.php'; if (file_exists($file)) { require $file; return true; } } } $prefix = rtrim($prefix, '\\'); } return false; }); }
[ "public", "function", "register", "(", ")", "{", "spl_autoload_register", "(", "function", "(", "$", "class", ")", "{", "$", "prefix", "=", "$", "class", ";", "while", "(", "false", "!==", "$", "pos", "=", "strrpos", "(", "$", "prefix", ",", "'\\\\'", ...
Registers the autoloading via SPL.
[ "Registers", "the", "autoloading", "via", "SPL", "." ]
e2288582432857771e85c9859acd6d32e5f2f9b7
https://github.com/ForceLabsDev/framework/blob/e2288582432857771e85c9859acd6d32e5f2f9b7/src/Psr/ClassLoader.php#L61-L84
train
phPoirot/View
src/ViewModelTemplate.php
ViewModelTemplate.setRenderer
function setRenderer($renderer) { if (!$renderer instanceof iViewRenderer && !is_callable($renderer)) throw new \InvalidArgumentException(sprintf( 'Renderer must extend of (iViewRenderer) or callable. given: (%s)' , \Poirot\Std\flatten($renderer) )); $this->renderer = $renderer; return $this; }
php
function setRenderer($renderer) { if (!$renderer instanceof iViewRenderer && !is_callable($renderer)) throw new \InvalidArgumentException(sprintf( 'Renderer must extend of (iViewRenderer) or callable. given: (%s)' , \Poirot\Std\flatten($renderer) )); $this->renderer = $renderer; return $this; }
[ "function", "setRenderer", "(", "$", "renderer", ")", "{", "if", "(", "!", "$", "renderer", "instanceof", "iViewRenderer", "&&", "!", "is_callable", "(", "$", "renderer", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Rend...
Set Iso Renderer Closure Renderer: - function(string $templatePathName, array $viewVars) @param iViewRenderer|\Closure|callable $renderer @return $this
[ "Set", "Iso", "Renderer" ]
37434b14ebc11e86651f356233a55ef36cac1cc0
https://github.com/phPoirot/View/blob/37434b14ebc11e86651f356233a55ef36cac1cc0/src/ViewModelTemplate.php#L118-L128
train
phPoirot/View
src/ViewModelTemplate.php
ViewModelTemplate.setResolverOptions
protected function setResolverOptions($options) { $resolver = $this->resolver(); $resolver->with($resolver::parseWith($options)); }
php
protected function setResolverOptions($options) { $resolver = $this->resolver(); $resolver->with($resolver::parseWith($options)); }
[ "protected", "function", "setResolverOptions", "(", "$", "options", ")", "{", "$", "resolver", "=", "$", "this", "->", "resolver", "(", ")", ";", "$", "resolver", "->", "with", "(", "$", "resolver", "::", "parseWith", "(", "$", "options", ")", ")", ";"...
Proxy Helper Options For Resolver @param $options
[ "Proxy", "Helper", "Options", "For", "Resolver" ]
37434b14ebc11e86651f356233a55ef36cac1cc0
https://github.com/phPoirot/View/blob/37434b14ebc11e86651f356233a55ef36cac1cc0/src/ViewModelTemplate.php#L160-L164
train
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/chartObject.class.php
chartObject.getMaxValue
public function getMaxValue() { $retour = 0; foreach($this->listeValues as $indice => $value) { if(is_array($value)) { for($i=0 ; $i<count($value) ; $i++) { if($value[$i]>$retour) $retour = $value[$i]; } } else { if($value>$retour) $retour = $value; } } return $retour; }
php
public function getMaxValue() { $retour = 0; foreach($this->listeValues as $indice => $value) { if(is_array($value)) { for($i=0 ; $i<count($value) ; $i++) { if($value[$i]>$retour) $retour = $value[$i]; } } else { if($value>$retour) $retour = $value; } } return $retour; }
[ "public", "function", "getMaxValue", "(", ")", "{", "$", "retour", "=", "0", ";", "foreach", "(", "$", "this", "->", "listeValues", "as", "$", "indice", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "for", ...
renvoi la valeur maximal parmis la liste de valeur
[ "renvoi", "la", "valeur", "maximal", "parmis", "la", "liste", "de", "valeur" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/chartObject.class.php#L180-L201
train
michaelcullum/voting-lib
src/STV/Election.php
Election.getStateCandidates
public function getStateCandidates(int $state): array { $candidates = []; foreach ($this->candidates as $candidateId => $candidate) { if ($candidate->getState() == $state) { $candidates[$candidateId] = $candidate; } } return $candidates; }
php
public function getStateCandidates(int $state): array { $candidates = []; foreach ($this->candidates as $candidateId => $candidate) { if ($candidate->getState() == $state) { $candidates[$candidateId] = $candidate; } } return $candidates; }
[ "public", "function", "getStateCandidates", "(", "int", "$", "state", ")", ":", "array", "{", "$", "candidates", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "candidates", "as", "$", "candidateId", "=>", "$", "candidate", ")", "{", "if", "(",...
Get all candidates of a specific state. @param int $state A candidate state (See Candidate constants) @return \Michaelc\Voting\STV\Candidate[]
[ "Get", "all", "candidates", "of", "a", "specific", "state", "." ]
83f0543493448021386e3a3b8c95d3268f1ee212
https://github.com/michaelcullum/voting-lib/blob/83f0543493448021386e3a3b8c95d3268f1ee212/src/STV/Election.php#L122-L133
train
michaelcullum/voting-lib
src/STV/Election.php
Election.getCandidateIds
public function getCandidateIds(): array { $candidateIds = []; foreach ($this->candidates as $candidate) { $candidateIds[] = $candidate->getId(); } return $candidateIds; }
php
public function getCandidateIds(): array { $candidateIds = []; foreach ($this->candidates as $candidate) { $candidateIds[] = $candidate->getId(); } return $candidateIds; }
[ "public", "function", "getCandidateIds", "(", ")", ":", "array", "{", "$", "candidateIds", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "candidates", "as", "$", "candidate", ")", "{", "$", "candidateIds", "[", "]", "=", "$", "candidate", "->"...
Get an array of candidate ids. @return int[]
[ "Get", "an", "array", "of", "candidate", "ids", "." ]
83f0543493448021386e3a3b8c95d3268f1ee212
https://github.com/michaelcullum/voting-lib/blob/83f0543493448021386e3a3b8c95d3268f1ee212/src/STV/Election.php#L150-L159
train
michaelcullum/voting-lib
src/STV/Election.php
Election.getCandidatesStatus
public function getCandidatesStatus(): array { $candidates = []; foreach ($this->getElectedCandidates() as $candidate) { $candidates['elected'][] = $candidate->getId(); } foreach ($this->getActiveCandidates() as $candidate) { $candidates['active'][] = [$candidate->getId(), $candidate->getVotes()]; } foreach ($this->getDefeatedCandidates() as $candidate) { $candidates['defeated'][] = $candidate->getId(); } return $candidates; }
php
public function getCandidatesStatus(): array { $candidates = []; foreach ($this->getElectedCandidates() as $candidate) { $candidates['elected'][] = $candidate->getId(); } foreach ($this->getActiveCandidates() as $candidate) { $candidates['active'][] = [$candidate->getId(), $candidate->getVotes()]; } foreach ($this->getDefeatedCandidates() as $candidate) { $candidates['defeated'][] = $candidate->getId(); } return $candidates; }
[ "public", "function", "getCandidatesStatus", "(", ")", ":", "array", "{", "$", "candidates", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getElectedCandidates", "(", ")", "as", "$", "candidate", ")", "{", "$", "candidates", "[", "'elected'", "...
Get status of all candidates. @return array
[ "Get", "status", "of", "all", "candidates", "." ]
83f0543493448021386e3a3b8c95d3268f1ee212
https://github.com/michaelcullum/voting-lib/blob/83f0543493448021386e3a3b8c95d3268f1ee212/src/STV/Election.php#L206-L223
train
NamelessCoder/gizzle-git-plugins
src/GizzlePlugins/PullPlugin.php
PullPlugin.process
public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(); $branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch()); $url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl()); $git = $this->resolveGitCommand(); $command = array( 'cd', escapeshellarg($directory), '&&', $git, self::COMMAND, escapeshellarg($url), escapeshellarg($branch) ); if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REBASE, FALSE)) { $command[] = self::COMMAND_REBASE; } $output = $this->executeGitCommand($command); $payload->getResponse()->addOutputFromPlugin($this, $output); }
php
public function process(Payload $payload) { $directory = $this->getDirectorySettingOrFail(); $branch = $this->getSettingValue(self::OPTION_BRANCH, $payload->getRepository()->getMasterBranch()); $url = $this->getSettingValue(self::OPTION_REPOSITORY, $payload->getRepository()->getUrl()); $git = $this->resolveGitCommand(); $command = array( 'cd', escapeshellarg($directory), '&&', $git, self::COMMAND, escapeshellarg($url), escapeshellarg($branch) ); if (TRUE === (boolean) $this->getSettingValue(self::OPTION_REBASE, FALSE)) { $command[] = self::COMMAND_REBASE; } $output = $this->executeGitCommand($command); $payload->getResponse()->addOutputFromPlugin($this, $output); }
[ "public", "function", "process", "(", "Payload", "$", "payload", ")", "{", "$", "directory", "=", "$", "this", "->", "getDirectorySettingOrFail", "(", ")", ";", "$", "branch", "=", "$", "this", "->", "getSettingValue", "(", "self", "::", "OPTION_BRANCH", "...
Perform whichever task the Plugin should perform based on the payload's data. @param Payload $payload @return void
[ "Perform", "whichever", "task", "the", "Plugin", "should", "perform", "based", "on", "the", "payload", "s", "data", "." ]
7c476db81b58bed7dc769866491b2adb6ddb19bb
https://github.com/NamelessCoder/gizzle-git-plugins/blob/7c476db81b58bed7dc769866491b2adb6ddb19bb/src/GizzlePlugins/PullPlugin.php#L33-L47
train
ItinerisLtd/preflight-command
src/CheckerCollection.php
CheckerCollection.set
public function set(CheckerInterface $checker): self { $this->checkers[$checker->getId()] = $checker; return $this; }
php
public function set(CheckerInterface $checker): self { $this->checkers[$checker->getId()] = $checker; return $this; }
[ "public", "function", "set", "(", "CheckerInterface", "$", "checker", ")", ":", "self", "{", "$", "this", "->", "checkers", "[", "$", "checker", "->", "getId", "(", ")", "]", "=", "$", "checker", ";", "return", "$", "this", ";", "}" ]
Add or replace a checker instance to the collection at given id. @param CheckerInterface $checker The checker instance. @return CheckerCollection
[ "Add", "or", "replace", "a", "checker", "instance", "to", "the", "collection", "at", "given", "id", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CheckerCollection.php#L22-L27
train
tomvlk/sweet-orm
src/SweetORM/Structure/ValidationManager.php
ValidationManager.validator
public static function validator (EntityStructure $entityStructure, $data) { switch (gettype($data)) { case 'array': return new ArrayValidator($entityStructure, $data); default: return false; } }
php
public static function validator (EntityStructure $entityStructure, $data) { switch (gettype($data)) { case 'array': return new ArrayValidator($entityStructure, $data); default: return false; } }
[ "public", "static", "function", "validator", "(", "EntityStructure", "$", "entityStructure", ",", "$", "data", ")", "{", "switch", "(", "gettype", "(", "$", "data", ")", ")", "{", "case", "'array'", ":", "return", "new", "ArrayValidator", "(", "$", "entity...
Get validator matching for the given data type. @param EntityStructure $entityStructure @param mixed $data @return Validator|false @codeCoverageIgnore ignore due to the coverage issue in switches.
[ "Get", "validator", "matching", "for", "the", "given", "data", "type", "." ]
bca014a9f83be34c87b14d6c8a36156e24577374
https://github.com/tomvlk/sweet-orm/blob/bca014a9f83be34c87b14d6c8a36156e24577374/src/SweetORM/Structure/ValidationManager.php#L30-L38
train
ptorn/bth-anax-user
src/User/UserController.php
UserController.init
public function init() { $this->userService = $this->di->get("userService"); $this->session = $this->di->get("session"); $this->response = $this->di->get("response"); $this->view = $this->di->get("view"); $this->pageRender = $this->di->get("pageRender"); }
php
public function init() { $this->userService = $this->di->get("userService"); $this->session = $this->di->get("session"); $this->response = $this->di->get("response"); $this->view = $this->di->get("view"); $this->pageRender = $this->di->get("pageRender"); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "userService", "=", "$", "this", "->", "di", "->", "get", "(", "\"userService\"", ")", ";", "$", "this", "->", "session", "=", "$", "this", "->", "di", "->", "get", "(", "\"session\"", ...
Initiate the controller. @return void
[ "Initiate", "the", "controller", "." ]
223e569cbebfd3f9302bdef648b13b73cb3f1d19
https://github.com/ptorn/bth-anax-user/blob/223e569cbebfd3f9302bdef648b13b73cb3f1d19/src/User/UserController.php#L31-L38
train
ptorn/bth-anax-user
src/User/UserController.php
UserController.getPostLogin
public function getPostLogin() { if ($this->userService->checkLoggedin()) { $this->response->redirect(""); } $title = "Administration - Login"; $form = new UserLoginForm($this->di); $form->check(); $data = [ "form" => $form->getHTML(), ]; $this->view->add("user/login", $data); $this->pageRender->renderPage(["title" => $title]); }
php
public function getPostLogin() { if ($this->userService->checkLoggedin()) { $this->response->redirect(""); } $title = "Administration - Login"; $form = new UserLoginForm($this->di); $form->check(); $data = [ "form" => $form->getHTML(), ]; $this->view->add("user/login", $data); $this->pageRender->renderPage(["title" => $title]); }
[ "public", "function", "getPostLogin", "(", ")", "{", "if", "(", "$", "this", "->", "userService", "->", "checkLoggedin", "(", ")", ")", "{", "$", "this", "->", "response", "->", "redirect", "(", "\"\"", ")", ";", "}", "$", "title", "=", "\"Administrati...
Login-page @throws Exception @return void
[ "Login", "-", "page" ]
223e569cbebfd3f9302bdef648b13b73cb3f1d19
https://github.com/ptorn/bth-anax-user/blob/223e569cbebfd3f9302bdef648b13b73cb3f1d19/src/User/UserController.php#L49-L67
train
afonzeca/arun-core
src/ArunCore/Core/Helpers/Sanitizer.php
Sanitizer.stripBadChars
public function stripBadChars(string $parameter, array $optionalChars = []): string { return str_replace(self::badChars . $optionalChars, "", $parameter); }
php
public function stripBadChars(string $parameter, array $optionalChars = []): string { return str_replace(self::badChars . $optionalChars, "", $parameter); }
[ "public", "function", "stripBadChars", "(", "string", "$", "parameter", ",", "array", "$", "optionalChars", "=", "[", "]", ")", ":", "string", "{", "return", "str_replace", "(", "self", "::", "badChars", ".", "$", "optionalChars", ",", "\"\"", ",", "$", ...
Strip unauthorized chars from string @param string $parameter [] @param array $optionalChars @return string
[ "Strip", "unauthorized", "chars", "from", "string" ]
7a8af37e326187ff9ed7e2ff7bde6a489a9803a2
https://github.com/afonzeca/arun-core/blob/7a8af37e326187ff9ed7e2ff7bde6a489a9803a2/src/ArunCore/Core/Helpers/Sanitizer.php#L62-L65
train
calgamo/config
src/ConfigReader.php
ConfigReader.readFromArray
public function readFromArray(array $data) : array { foreach($data as $key => $value) { if (is_string($value)){ $value = $this->macro_processor->process($value); $data[$key] = $value; } else if(is_array($value)){ $data[$key] = $this->readFromArray($value); } } return $data; }
php
public function readFromArray(array $data) : array { foreach($data as $key => $value) { if (is_string($value)){ $value = $this->macro_processor->process($value); $data[$key] = $value; } else if(is_array($value)){ $data[$key] = $this->readFromArray($value); } } return $data; }
[ "public", "function", "readFromArray", "(", "array", "$", "data", ")", ":", "array", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$...
Read from array @param array $data @return array
[ "Read", "from", "array" ]
315c87f0ab1283a805a24db3a6220eda281d49e8
https://github.com/calgamo/config/blob/315c87f0ab1283a805a24db3a6220eda281d49e8/src/ConfigReader.php#L58-L71
train
loopsframework/base
src/Loops/Object.php
Object.offsetGet
public function offsetGet($offset) { if($this->ResolveTraitOffsetExists($offset)) { return $this->ResolveTraitOffsetGet($offset); } if($this->AccessTraitOffsetExists($offset)) { return $this->AccessTraitOffsetGet($offset); } //return service if one exists with the requested name if($this->getLoops()->hasService($offset)) { return $this->getLoops()->getService($offset); } user_error("Undefined index: $offset", E_USER_NOTICE); }
php
public function offsetGet($offset) { if($this->ResolveTraitOffsetExists($offset)) { return $this->ResolveTraitOffsetGet($offset); } if($this->AccessTraitOffsetExists($offset)) { return $this->AccessTraitOffsetGet($offset); } //return service if one exists with the requested name if($this->getLoops()->hasService($offset)) { return $this->getLoops()->getService($offset); } user_error("Undefined index: $offset", E_USER_NOTICE); }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "if", "(", "$", "this", "->", "ResolveTraitOffsetExists", "(", "$", "offset", ")", ")", "{", "return", "$", "this", "->", "ResolveTraitOffsetGet", "(", "$", "offset", ")", ";", "}", "if", ...
Gets a value either via the ResolveTrait, AccessTrait or the loops getService functionality Values are checked in that order. If no value existed, a notice will be generated. @param string $key The name of the service @return mixed The requested service or NULL if not available
[ "Gets", "a", "value", "either", "via", "the", "ResolveTrait", "AccessTrait", "or", "the", "loops", "getService", "functionality" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/Object.php#L91-L106
train
GrupaZero/core
src/Gzero/Core/Services/RoutesService.php
RoutesService.add
public function add(...$parameters) { if (count($parameters) === 1) { $this->routes['regular'][] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['regular'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]; } else { throw new \InvalidArgumentException; } }
php
public function add(...$parameters) { if (count($parameters) === 1) { $this->routes['regular'][] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['regular'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]; } else { throw new \InvalidArgumentException; } }
[ "public", "function", "add", "(", "...", "$", "parameters", ")", "{", "if", "(", "count", "(", "$", "parameters", ")", "===", "1", ")", "{", "$", "this", "->", "routes", "[", "'regular'", "]", "[", "]", "=", "[", "'closure'", "=>", "$", "parameters...
Add non multilingual route @param array ...$parameters closure or group options plus closure @throws \InvalidArgumentException @return void
[ "Add", "non", "multilingual", "route" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L23-L32
train
GrupaZero/core
src/Gzero/Core/Services/RoutesService.php
RoutesService.addMultiLanguage
public function addMultiLanguage(...$parameters) { if (count($parameters) === 1) { $this->routes['ml'][] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['ml'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]; } else { throw new \InvalidArgumentException; } }
php
public function addMultiLanguage(...$parameters) { if (count($parameters) === 1) { $this->routes['ml'][] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['ml'][] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]; } else { throw new \InvalidArgumentException; } }
[ "public", "function", "addMultiLanguage", "(", "...", "$", "parameters", ")", "{", "if", "(", "count", "(", "$", "parameters", ")", "===", "1", ")", "{", "$", "this", "->", "routes", "[", "'ml'", "]", "[", "]", "=", "[", "'closure'", "=>", "$", "pa...
Add multilingual route @param array ...$parameters closure or group options plus closure @throws \InvalidArgumentException @return void
[ "Add", "multilingual", "route" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L43-L52
train
GrupaZero/core
src/Gzero/Core/Services/RoutesService.php
RoutesService.setCatchAll
public function setCatchAll(...$parameters) { if (count($parameters) === 1) { $this->routes['catchAll'] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['catchAll'] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]; } else { throw new \InvalidArgumentException; } }
php
public function setCatchAll(...$parameters) { if (count($parameters) === 1) { $this->routes['catchAll'] = ['closure' => $parameters[0], 'groupArgs' => []]; } elseif (count($parameters) === 2) { $this->routes['catchAll'] = ['closure' => $parameters[1], 'groupArgs' => $parameters[0]]; } else { throw new \InvalidArgumentException; } }
[ "public", "function", "setCatchAll", "(", "...", "$", "parameters", ")", "{", "if", "(", "count", "(", "$", "parameters", ")", "===", "1", ")", "{", "$", "this", "->", "routes", "[", "'catchAll'", "]", "=", "[", "'closure'", "=>", "$", "parameters", ...
Add catch all route @param array ...$parameters closure or group options plus closure @throws \InvalidArgumentException @return void
[ "Add", "catch", "all", "route" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L63-L72
train
GrupaZero/core
src/Gzero/Core/Services/RoutesService.php
RoutesService.registerAll
public function registerAll() { /** @var LanguageService $service */ $service = resolve(LanguageService::class); $languages = $service->getAllEnabled(); foreach ($this->routes['ml'] as $value) { foreach ($languages as $language) { $prefix = null; if (!$language->is_default) { $prefix = $language->code; } Route::group( array_merge(['prefix' => $prefix], $value['groupArgs']), function ($router) use ($value, $language) { $value['closure']($router, $language->code); } ); } } foreach ($this->routes['regular'] as $value) { Route::group( $value['groupArgs'], function ($router) use ($value) { $value['closure']($router); } ); } if (!empty($this->routes['catchAll'])) { Route::group( $this->routes['catchAll']['groupArgs'], function ($router) { $this->routes['catchAll']['closure']($router); } ); } $router = resolve('router'); $router->getRoutes()->refreshActionLookups(); $router->getRoutes()->refreshNameLookups(); }
php
public function registerAll() { /** @var LanguageService $service */ $service = resolve(LanguageService::class); $languages = $service->getAllEnabled(); foreach ($this->routes['ml'] as $value) { foreach ($languages as $language) { $prefix = null; if (!$language->is_default) { $prefix = $language->code; } Route::group( array_merge(['prefix' => $prefix], $value['groupArgs']), function ($router) use ($value, $language) { $value['closure']($router, $language->code); } ); } } foreach ($this->routes['regular'] as $value) { Route::group( $value['groupArgs'], function ($router) use ($value) { $value['closure']($router); } ); } if (!empty($this->routes['catchAll'])) { Route::group( $this->routes['catchAll']['groupArgs'], function ($router) { $this->routes['catchAll']['closure']($router); } ); } $router = resolve('router'); $router->getRoutes()->refreshActionLookups(); $router->getRoutes()->refreshNameLookups(); }
[ "public", "function", "registerAll", "(", ")", "{", "/** @var LanguageService $service */", "$", "service", "=", "resolve", "(", "LanguageService", "::", "class", ")", ";", "$", "languages", "=", "$", "service", "->", "getAllEnabled", "(", ")", ";", "foreach", ...
It registers all routes @return void
[ "It", "registers", "all", "routes" ]
093e515234fa0385b259ba4d8bc7832174a44eab
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Services/RoutesService.php#L79-L118
train
WellCommerce/DataGrid
Column/ColumnCollection.php
ColumnCollection.get
public function get($identifier) : ColumnInterface { if (false === $this->has($identifier)) { throw new ColumnNotFoundException($identifier); } return $this->items[$identifier]; }
php
public function get($identifier) : ColumnInterface { if (false === $this->has($identifier)) { throw new ColumnNotFoundException($identifier); } return $this->items[$identifier]; }
[ "public", "function", "get", "(", "$", "identifier", ")", ":", "ColumnInterface", "{", "if", "(", "false", "===", "$", "this", "->", "has", "(", "$", "identifier", ")", ")", "{", "throw", "new", "ColumnNotFoundException", "(", "$", "identifier", ")", ";"...
Returns column by its identifier @param string $identifier Column identifier @return ColumnInterface
[ "Returns", "column", "by", "its", "identifier" ]
5ce3cd47c7902aaeb07c343a76574399286f56ff
https://github.com/WellCommerce/DataGrid/blob/5ce3cd47c7902aaeb07c343a76574399286f56ff/Column/ColumnCollection.php#L42-L49
train
flextype-components/debug
Debug.php
Debug.elapsedTime
public static function elapsedTime(string $point_name) : string { if (isset(Debug::$time[$point_name])) return sprintf("%01.4f", microtime(true) - Debug::$time[$point_name]); }
php
public static function elapsedTime(string $point_name) : string { if (isset(Debug::$time[$point_name])) return sprintf("%01.4f", microtime(true) - Debug::$time[$point_name]); }
[ "public", "static", "function", "elapsedTime", "(", "string", "$", "point_name", ")", ":", "string", "{", "if", "(", "isset", "(", "Debug", "::", "$", "time", "[", "$", "point_name", "]", ")", ")", "return", "sprintf", "(", "\"%01.4f\"", ",", "microtime"...
Get elapsed time for current point echo Debug::elapsedTime('point_name'); @param string $point_name Point name @return string
[ "Get", "elapsed", "time", "for", "current", "point" ]
af8a12f0cecf713ea8394694c75b5be065a35ffe
https://github.com/flextype-components/debug/blob/af8a12f0cecf713ea8394694c75b5be065a35ffe/Debug.php#L51-L54
train
flextype-components/debug
Debug.php
Debug.memoryUsage
public static function memoryUsage(string $point_name) : string { if (isset(Debug::$memory[$point_name])) { $unit = array('B', 'KB', 'MB', 'GB', 'TiB', 'PiB'); $size = memory_get_usage() - Debug::$memory[$point_name]; $memory_usage = @round($size/pow(1024, ($i=floor(log($size, 1024)))), 2).' '.$unit[($i < 0 ? 0 : $i)]; return $memory_usage; } }
php
public static function memoryUsage(string $point_name) : string { if (isset(Debug::$memory[$point_name])) { $unit = array('B', 'KB', 'MB', 'GB', 'TiB', 'PiB'); $size = memory_get_usage() - Debug::$memory[$point_name]; $memory_usage = @round($size/pow(1024, ($i=floor(log($size, 1024)))), 2).' '.$unit[($i < 0 ? 0 : $i)]; return $memory_usage; } }
[ "public", "static", "function", "memoryUsage", "(", "string", "$", "point_name", ")", ":", "string", "{", "if", "(", "isset", "(", "Debug", "::", "$", "memory", "[", "$", "point_name", "]", ")", ")", "{", "$", "unit", "=", "array", "(", "'B'", ",", ...
Get memory usage for current point echo Debug::memoryUsage('point_name'); @param string $point_name Point name @return string
[ "Get", "memory", "usage", "for", "current", "point" ]
af8a12f0cecf713ea8394694c75b5be065a35ffe
https://github.com/flextype-components/debug/blob/af8a12f0cecf713ea8394694c75b5be065a35ffe/Debug.php#L76-L84
train
clusterpoint/php-client-api
request.class.php
CPS_Request.setShape
public function setShape($value, $replace = true) { $name = 'shapes'; if (!(is_array($value) || is_string($value))) { throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } if ($replace) { $this->_setRawParam($name, $value); } else { $exParam = $this->_getRawParam($name); if (!is_array($exParam)) { $exParam = array($exParam); } if (is_array($value)) { foreach($value as $val){ $exParam[] = $val; } } else if (is_string($value)) { $exParam[] = $value; } $this->_setRawParam($name, $exParam); } }
php
public function setShape($value, $replace = true) { $name = 'shapes'; if (!(is_array($value) || is_string($value))) { throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } if ($replace) { $this->_setRawParam($name, $value); } else { $exParam = $this->_getRawParam($name); if (!is_array($exParam)) { $exParam = array($exParam); } if (is_array($value)) { foreach($value as $val){ $exParam[] = $val; } } else if (is_string($value)) { $exParam[] = $value; } $this->_setRawParam($name, $exParam); } }
[ "public", "function", "setShape", "(", "$", "value", ",", "$", "replace", "=", "true", ")", "{", "$", "name", "=", "'shapes'", ";", "if", "(", "!", "(", "is_array", "(", "$", "value", ")", "||", "is_string", "(", "$", "value", ")", ")", ")", "{",...
Sets shape definition for geospatial search @param String|array $value A single shape definition as string or array of string that define multiple shapes @param bool $replace Should previous set values be replaced
[ "Sets", "shape", "definition", "for", "geospatial", "search" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L267-L289
train
clusterpoint/php-client-api
request.class.php
CPS_Request.setParam
public function setParam($name, $value) { if (in_array($name, $this->_textParamNames)) { $this->_setTextParam($name, $value); } else if (in_array($name, $this->_rawParamNames)) { $this->_setRawParam($name, $value); } else { throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } }
php
public function setParam($name, $value) { if (in_array($name, $this->_textParamNames)) { $this->_setTextParam($name, $value); } else if (in_array($name, $this->_rawParamNames)) { $this->_setRawParam($name, $value); } else { throw new CPS_Exception(array(array('long_message' => 'Invalid request parameter', 'code' => ERROR_CODE_INVALID_PARAMETER, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } }
[ "public", "function", "setParam", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "in_array", "(", "$", "name", ",", "$", "this", "->", "_textParamNames", ")", ")", "{", "$", "this", "->", "_setTextParam", "(", "$", "name", ",", "$", "val...
sets a request parameter @param string $name name of the parameter @param mixed $value value to set. Could be a single string or an array of strings
[ "sets", "a", "request", "parameter" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L296-L304
train
clusterpoint/php-client-api
request.class.php
CPS_Request._setTextParam
private function _setTextParam(&$name, &$value) { if (!is_array($value)) $value = array($value); $this->_textParams[$name] = $value; }
php
private function _setTextParam(&$name, &$value) { if (!is_array($value)) $value = array($value); $this->_textParams[$name] = $value; }
[ "private", "function", "_setTextParam", "(", "&", "$", "name", ",", "&", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "$", "value", "=", "array", "(", "$", "value", ")", ";", "$", "this", "->", "_textParams", "...
sets a text-only request parameter @param string &$name name of the parameter @param mixed &$value value to set. Could be a single string or an array of strings
[ "sets", "a", "text", "-", "only", "request", "parameter" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L386-L390
train
clusterpoint/php-client-api
request.class.php
CPS_Request._setRawParam
private function _setRawParam(&$name, &$value) { if (!is_array($value)) $value = array($value); $this->_rawParams[$name] = $value; }
php
private function _setRawParam(&$name, &$value) { if (!is_array($value)) $value = array($value); $this->_rawParams[$name] = $value; }
[ "private", "function", "_setRawParam", "(", "&", "$", "name", ",", "&", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "$", "value", "=", "array", "(", "$", "value", ")", ";", "$", "this", "->", "_rawParams", "["...
sets a raw request parameter @param string &$name name of the parameter @param mixed &$value value to set. Could be a single string or an array of strings
[ "sets", "a", "raw", "request", "parameter" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L396-L400
train
clusterpoint/php-client-api
request.class.php
CPS_Request._setDocId
private static function _setDocId(&$subdoc, &$parentNode, $id, &$docIdXpath, $curLevel = 0) { if ($parentNode->nodeName == $docIdXpath[$curLevel]) { if ($curLevel == count($docIdXpath) - 1) { // remove all sub-nodes $curChild = $parentNode->firstChild; while ($curChild) { $nextChild = $curChild->nextSibling; $parentNode->removeChild($curChild); $curChild = $nextChild; } // set the ID if (!CPS_Request::isValidUTF8((string) $id)) throw new CPS_Exception(array(array('long_message' => 'Invalid UTF-8 encoding in document ID', 'code' => ERROR_CODE_INVALID_UTF8, 'level' => 'ERROR', 'source' => 'CPS_API'))); $textNode = $subdoc->createTextNode($id); $parentNode->appendChild($textNode); } else { // traverse children $found = false; $curChild = $parentNode->firstChild; while ($curChild) { if ($curChild->nodeName == $docIdXpath[$curLevel + 1]) { CPS_Request::_setDocId($subdoc, $curChild, $id, $docIdXpath, $curLevel + 1); $found = true; break; } $curChild = $curChild->nextSibling; } if (!$found) { $newNode = $subdoc->createElement($docIdXpath[$curLevel + 1]); $parentNode->appendChild($newNode); CPS_Request::_setDocId($subdoc, $newNode, $id, $docIdXpath, $curLevel + 1); } } } else { throw new CPS_Exception(array(array('long_message' => 'Document root xpath not matching document ID xpath', 'code' => ERROR_CODE_INVALID_XPATHS, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } }
php
private static function _setDocId(&$subdoc, &$parentNode, $id, &$docIdXpath, $curLevel = 0) { if ($parentNode->nodeName == $docIdXpath[$curLevel]) { if ($curLevel == count($docIdXpath) - 1) { // remove all sub-nodes $curChild = $parentNode->firstChild; while ($curChild) { $nextChild = $curChild->nextSibling; $parentNode->removeChild($curChild); $curChild = $nextChild; } // set the ID if (!CPS_Request::isValidUTF8((string) $id)) throw new CPS_Exception(array(array('long_message' => 'Invalid UTF-8 encoding in document ID', 'code' => ERROR_CODE_INVALID_UTF8, 'level' => 'ERROR', 'source' => 'CPS_API'))); $textNode = $subdoc->createTextNode($id); $parentNode->appendChild($textNode); } else { // traverse children $found = false; $curChild = $parentNode->firstChild; while ($curChild) { if ($curChild->nodeName == $docIdXpath[$curLevel + 1]) { CPS_Request::_setDocId($subdoc, $curChild, $id, $docIdXpath, $curLevel + 1); $found = true; break; } $curChild = $curChild->nextSibling; } if (!$found) { $newNode = $subdoc->createElement($docIdXpath[$curLevel + 1]); $parentNode->appendChild($newNode); CPS_Request::_setDocId($subdoc, $newNode, $id, $docIdXpath, $curLevel + 1); } } } else { throw new CPS_Exception(array(array('long_message' => 'Document root xpath not matching document ID xpath', 'code' => ERROR_CODE_INVALID_XPATHS, 'level' => 'REJECTED', 'source' => 'CPS_API'))); } }
[ "private", "static", "function", "_setDocId", "(", "&", "$", "subdoc", ",", "&", "$", "parentNode", ",", "$", "id", ",", "&", "$", "docIdXpath", ",", "$", "curLevel", "=", "0", ")", "{", "if", "(", "$", "parentNode", "->", "nodeName", "==", "$", "d...
sets the docid inside the document @param DOMDocument &$subdoc document where the id should be loaded into
[ "sets", "the", "docid", "inside", "the", "document" ]
44c98a727271c91bb9b9a70975ec4f69d99e64e7
https://github.com/clusterpoint/php-client-api/blob/44c98a727271c91bb9b9a70975ec4f69d99e64e7/request.class.php#L467-L503
train
priskz/paylorm
src/Priskz/Paylorm/Data/MySQL/Eloquent/CrudMemcachedRepository.php
CrudMemcachedRepository.delete
public function delete($object) { $deleted = $object->delete(); if( ! $deleted) { return new Payload($object, 'not_deleted'); } // Remove the deleted model from cache. Cache::tags($this->model->getTable())->flush($updated->getKey()); return new Payload(null, 'deleted'); }
php
public function delete($object) { $deleted = $object->delete(); if( ! $deleted) { return new Payload($object, 'not_deleted'); } // Remove the deleted model from cache. Cache::tags($this->model->getTable())->flush($updated->getKey()); return new Payload(null, 'deleted'); }
[ "public", "function", "delete", "(", "$", "object", ")", "{", "$", "deleted", "=", "$", "object", "->", "delete", "(", ")", ";", "if", "(", "!", "$", "deleted", ")", "{", "return", "new", "Payload", "(", "$", "object", ",", "'not_deleted'", ")", ";...
Delete the given Model @param $object @return Payload
[ "Delete", "the", "given", "Model" ]
ae59eb4d9382f0c6fd361cca8ae465a0da88bc93
https://github.com/priskz/paylorm/blob/ae59eb4d9382f0c6fd361cca8ae465a0da88bc93/src/Priskz/Paylorm/Data/MySQL/Eloquent/CrudMemcachedRepository.php#L75-L88
train
synapsestudios/synapse-base
src/Synapse/Install/GenerateInstallCommand.php
GenerateInstallCommand.execute
public function execute(InputInterface $input, OutputInterface $output) { $outputPath = DATADIR; $output->write(['', ' Generating install files...', ''], true); $this->dumpStructure($outputPath); $output->writeln(' Exported DB structure'); $this->dumpData($outputPath); $output->write([' Exported DB data', ''], true); }
php
public function execute(InputInterface $input, OutputInterface $output) { $outputPath = DATADIR; $output->write(['', ' Generating install files...', ''], true); $this->dumpStructure($outputPath); $output->writeln(' Exported DB structure'); $this->dumpData($outputPath); $output->write([' Exported DB data', ''], true); }
[ "public", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "outputPath", "=", "DATADIR", ";", "$", "output", "->", "write", "(", "[", "''", ",", "' Generating install files...'", ",", "''", "]...
Execute this console command, in order to generate install files @param InputInterface $input Command line input interface @param OutputInterface $output Command line output interface
[ "Execute", "this", "console", "command", "in", "order", "to", "generate", "install", "files" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L92-L103
train
synapsestudios/synapse-base
src/Synapse/Install/GenerateInstallCommand.php
GenerateInstallCommand.getDumpStructureCommand
public function getDumpStructureCommand($database, $username, $password, $outputPath) { return sprintf( 'mysqldump %s -u %s -p%s --no-data | sed "s/AUTO_INCREMENT=[0-9]*//" > %s', escapeshellarg($database), escapeshellarg($username), escapeshellarg($password), escapeshellarg($outputPath) ); }
php
public function getDumpStructureCommand($database, $username, $password, $outputPath) { return sprintf( 'mysqldump %s -u %s -p%s --no-data | sed "s/AUTO_INCREMENT=[0-9]*//" > %s', escapeshellarg($database), escapeshellarg($username), escapeshellarg($password), escapeshellarg($outputPath) ); }
[ "public", "function", "getDumpStructureCommand", "(", "$", "database", ",", "$", "username", ",", "$", "password", ",", "$", "outputPath", ")", "{", "return", "sprintf", "(", "'mysqldump %s -u %s -p%s --no-data | sed \"s/AUTO_INCREMENT=[0-9]*//\" > %s'", ",", "escapeshell...
Return the mysqldump command for structure only @param string $database the database name @param string $username the database username @param string $password the database password @param string $outputPath the resultant file location @return string the command to run
[ "Return", "the", "mysqldump", "command", "for", "structure", "only" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L114-L123
train
synapsestudios/synapse-base
src/Synapse/Install/GenerateInstallCommand.php
GenerateInstallCommand.getDumpDataCommand
public function getDumpDataCommand($database, $username, $password, $outputPath, $tables = array()) { $tables = array_map('escapeshellarg', $tables); $command = sprintf( 'mysqldump %s %s -u %s -p%s --no-create-info > %s', escapeshellarg($database), implode(' ', $tables), escapeshellarg($username), escapeshellarg($password), escapeshellarg($outputPath) ); return $command; }
php
public function getDumpDataCommand($database, $username, $password, $outputPath, $tables = array()) { $tables = array_map('escapeshellarg', $tables); $command = sprintf( 'mysqldump %s %s -u %s -p%s --no-create-info > %s', escapeshellarg($database), implode(' ', $tables), escapeshellarg($username), escapeshellarg($password), escapeshellarg($outputPath) ); return $command; }
[ "public", "function", "getDumpDataCommand", "(", "$", "database", ",", "$", "username", ",", "$", "password", ",", "$", "outputPath", ",", "$", "tables", "=", "array", "(", ")", ")", "{", "$", "tables", "=", "array_map", "(", "'escapeshellarg'", ",", "$"...
Return the mysqldump command for data only @param string $database the database name @param string $username the database username @param string $password the database password @param string $outputPath the resultant file location @param array $tables the tables to include (optional) @return string the command to run
[ "Return", "the", "mysqldump", "command", "for", "data", "only" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L135-L149
train
synapsestudios/synapse-base
src/Synapse/Install/GenerateInstallCommand.php
GenerateInstallCommand.dumpStructure
protected function dumpStructure($outputPath) { return shell_exec($this->getDumpStructureCommand( $this->dbConfig['database'], $this->dbConfig['username'], $this->dbConfig['password'], $outputPath.'/'.self::STRUCTURE_FILE )); }
php
protected function dumpStructure($outputPath) { return shell_exec($this->getDumpStructureCommand( $this->dbConfig['database'], $this->dbConfig['username'], $this->dbConfig['password'], $outputPath.'/'.self::STRUCTURE_FILE )); }
[ "protected", "function", "dumpStructure", "(", "$", "outputPath", ")", "{", "return", "shell_exec", "(", "$", "this", "->", "getDumpStructureCommand", "(", "$", "this", "->", "dbConfig", "[", "'database'", "]", ",", "$", "this", "->", "dbConfig", "[", "'user...
Export database structure to dbStructure install file @param string $outputPath Path where file should be exported
[ "Export", "database", "structure", "to", "dbStructure", "install", "file" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L156-L164
train
synapsestudios/synapse-base
src/Synapse/Install/GenerateInstallCommand.php
GenerateInstallCommand.dumpData
protected function dumpData($outputPath) { $tables = Arr::get($this->installConfig, 'dataTables', []); /** * Do not attempt to create an empty data install file if no tables are to be exported. * Otherwise all tables will be exported. */ if (! count($tables)) { return; } $command = sprintf( 'mysqldump %s %s -u %s -p%s --no-create-info > %s', escapeshellarg($this->dbConfig['database']), implode(' ', $tables), escapeshellarg($this->dbConfig['username']), escapeshellarg($this->dbConfig['password']), escapeshellarg($outputPath.'/'.self::DATA_FILE) ); return shell_exec($command); }
php
protected function dumpData($outputPath) { $tables = Arr::get($this->installConfig, 'dataTables', []); /** * Do not attempt to create an empty data install file if no tables are to be exported. * Otherwise all tables will be exported. */ if (! count($tables)) { return; } $command = sprintf( 'mysqldump %s %s -u %s -p%s --no-create-info > %s', escapeshellarg($this->dbConfig['database']), implode(' ', $tables), escapeshellarg($this->dbConfig['username']), escapeshellarg($this->dbConfig['password']), escapeshellarg($outputPath.'/'.self::DATA_FILE) ); return shell_exec($command); }
[ "protected", "function", "dumpData", "(", "$", "outputPath", ")", "{", "$", "tables", "=", "Arr", "::", "get", "(", "$", "this", "->", "installConfig", ",", "'dataTables'", ",", "[", "]", ")", ";", "/**\n * Do not attempt to create an empty data install f...
Export database data to dbData install file @param string $outputPath Path where file should be exported
[ "Export", "database", "data", "to", "dbData", "install", "file" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Install/GenerateInstallCommand.php#L171-L193
train
getconnect/connect-php
src/APIClient.php
APIClient.pushEvent
public function pushEvent($collectionName, $event) { $url = self::BASE_API_URL . $collectionName; $result = Request::post($url) ->sendsAndExpectsType(Mime::JSON) ->addHeaders([ 'X-Project-Id' => $this->projectId, 'X-Api-Key' => $this->apiKey ]) ->body(json_encode($event)) ->send(); return $this->buildResponse($event, $result); }
php
public function pushEvent($collectionName, $event) { $url = self::BASE_API_URL . $collectionName; $result = Request::post($url) ->sendsAndExpectsType(Mime::JSON) ->addHeaders([ 'X-Project-Id' => $this->projectId, 'X-Api-Key' => $this->apiKey ]) ->body(json_encode($event)) ->send(); return $this->buildResponse($event, $result); }
[ "public", "function", "pushEvent", "(", "$", "collectionName", ",", "$", "event", ")", "{", "$", "url", "=", "self", "::", "BASE_API_URL", ".", "$", "collectionName", ";", "$", "result", "=", "Request", "::", "post", "(", "$", "url", ")", "->", "sendsA...
Push an event to the Connect API. @param string $collectionName The name of the collection to push to @param array $event The event details @return Response
[ "Push", "an", "event", "to", "the", "Connect", "API", "." ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/APIClient.php#L44-L55
train
getconnect/connect-php
src/APIClient.php
APIClient.buildResponse
private function buildResponse($event, $response) { $success = !$response->hasErrors(); $duplicate = ($response->code == 409); $statusCode = $response->code; $errorMessage = null; if ($response->code == 401) { $errorMessage = 'Unauthorised. Please check your Project Id and API Key'; } if ($response->body != null && $response->body->errorMessage != null) { $errorMessage = $response->body->errorMessage; } return new Response($success, $duplicate, $statusCode, $errorMessage, $event); }
php
private function buildResponse($event, $response) { $success = !$response->hasErrors(); $duplicate = ($response->code == 409); $statusCode = $response->code; $errorMessage = null; if ($response->code == 401) { $errorMessage = 'Unauthorised. Please check your Project Id and API Key'; } if ($response->body != null && $response->body->errorMessage != null) { $errorMessage = $response->body->errorMessage; } return new Response($success, $duplicate, $statusCode, $errorMessage, $event); }
[ "private", "function", "buildResponse", "(", "$", "event", ",", "$", "response", ")", "{", "$", "success", "=", "!", "$", "response", "->", "hasErrors", "(", ")", ";", "$", "duplicate", "=", "(", "$", "response", "->", "code", "==", "409", ")", ";", ...
Build a single response to return to the user @param array $event the event that the response is related to @param \Httpful\Response $response The response from the API @return Response
[ "Build", "a", "single", "response", "to", "return", "to", "the", "user" ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/APIClient.php#L81-L93
train
getconnect/connect-php
src/APIClient.php
APIClient.buildBatchResponse
private function buildBatchResponse($batch, $response) { $result = []; $responseBody = json_decode($response->raw_body, true); foreach ($batch as $collection => $events) { $eventResults = []; $eventResponses = $responseBody[$collection]; foreach($events as $index => $event) { $eventResponse = $eventResponses[$index]; $eventResult = new Response($eventResponse['success'], $eventResponse['duplicate'], null, $eventResponse['message'], $event); array_push($eventResults, $eventResult); } $result[$collection] = $eventResults; } $statusCode = $response->code; $errorMessage = $response->body->errorMessage; return new ResponseBatch($statusCode, $errorMessage, $result); }
php
private function buildBatchResponse($batch, $response) { $result = []; $responseBody = json_decode($response->raw_body, true); foreach ($batch as $collection => $events) { $eventResults = []; $eventResponses = $responseBody[$collection]; foreach($events as $index => $event) { $eventResponse = $eventResponses[$index]; $eventResult = new Response($eventResponse['success'], $eventResponse['duplicate'], null, $eventResponse['message'], $event); array_push($eventResults, $eventResult); } $result[$collection] = $eventResults; } $statusCode = $response->code; $errorMessage = $response->body->errorMessage; return new ResponseBatch($statusCode, $errorMessage, $result); }
[ "private", "function", "buildBatchResponse", "(", "$", "batch", ",", "$", "response", ")", "{", "$", "result", "=", "[", "]", ";", "$", "responseBody", "=", "json_decode", "(", "$", "response", "->", "raw_body", ",", "true", ")", ";", "foreach", "(", "...
Build a batch of responses to return to the user @param array $batch the batch that the response is related to @param \Httpful\Response $response The response from the API @return Response
[ "Build", "a", "batch", "of", "responses", "to", "return", "to", "the", "user" ]
cbce3daae58eca16450df811ac6f1280fc1ef6b1
https://github.com/getconnect/connect-php/blob/cbce3daae58eca16450df811ac6f1280fc1ef6b1/src/APIClient.php#L101-L119
train
yoanm/php-jsonrpc-http-server-swagger-doc-sdk
features/bootstrap/DocNormalizerContext.php
DocNormalizerContext.thenPathNamedShouldHaveTheFollowingResponse
public function thenPathNamedShouldHaveTheFollowingResponse($httpMethod, $pathName, PyStringNode $data) { $this->thenIShouldHaveAPathNamed($httpMethod, $pathName); $operation = $this->extractPath($httpMethod, $pathName); $operationResponseSchemaList = $operation['responses']['200']['schema']['allOf']; $decodedExpected = $this->jsonDecode($data->getRaw()); Assert::assertContains($decodedExpected, $operationResponseSchemaList); }
php
public function thenPathNamedShouldHaveTheFollowingResponse($httpMethod, $pathName, PyStringNode $data) { $this->thenIShouldHaveAPathNamed($httpMethod, $pathName); $operation = $this->extractPath($httpMethod, $pathName); $operationResponseSchemaList = $operation['responses']['200']['schema']['allOf']; $decodedExpected = $this->jsonDecode($data->getRaw()); Assert::assertContains($decodedExpected, $operationResponseSchemaList); }
[ "public", "function", "thenPathNamedShouldHaveTheFollowingResponse", "(", "$", "httpMethod", ",", "$", "pathName", ",", "PyStringNode", "$", "data", ")", "{", "$", "this", "->", "thenIShouldHaveAPathNamed", "(", "$", "httpMethod", ",", "$", "pathName", ")", ";", ...
Error and response result are stored under the same key @Then :httpMethod path named :pathName should have the following response: @Then :httpMethod path named :pathName should have the following error:
[ "Error", "and", "response", "result", "are", "stored", "under", "the", "same", "key" ]
058a23941d25719a3f21deb5e4a17153ff7f32e8
https://github.com/yoanm/php-jsonrpc-http-server-swagger-doc-sdk/blob/058a23941d25719a3f21deb5e4a17153ff7f32e8/features/bootstrap/DocNormalizerContext.php#L428-L437
train
tomphp/TjoAnnotationRouter
src/TjoAnnotationRouter/Config/Merger.php
Merger.merge
public function merge(array $newConfig, array &$config) { foreach ($newConfig as $routeName => $routeInfo) { if (!isset($config[$routeName])) { $config[$routeName] = $this->newRoute($routeName, $routeInfo); } if (isset($routeInfo['child_routes'])) { if (!isset($config[$routeName]['child_routes'])) { $config[$routeName]['child_routes'] = array(); } $this->merge($routeInfo['child_routes'], $config[$routeName]['child_routes']); } } }
php
public function merge(array $newConfig, array &$config) { foreach ($newConfig as $routeName => $routeInfo) { if (!isset($config[$routeName])) { $config[$routeName] = $this->newRoute($routeName, $routeInfo); } if (isset($routeInfo['child_routes'])) { if (!isset($config[$routeName]['child_routes'])) { $config[$routeName]['child_routes'] = array(); } $this->merge($routeInfo['child_routes'], $config[$routeName]['child_routes']); } } }
[ "public", "function", "merge", "(", "array", "$", "newConfig", ",", "array", "&", "$", "config", ")", "{", "foreach", "(", "$", "newConfig", "as", "$", "routeName", "=>", "$", "routeInfo", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", ...
Recursively update the route stack. @todo Convert recursion to iteration @param array $newConfig @param array $config @return RouteInterface
[ "Recursively", "update", "the", "route", "stack", "." ]
ee323691e948d82449287eae5c1ecce80cc90971
https://github.com/tomphp/TjoAnnotationRouter/blob/ee323691e948d82449287eae5c1ecce80cc90971/src/TjoAnnotationRouter/Config/Merger.php#L50-L65
train
SocietyCMS/Setting
Support/Settings.php
Settings.get
public function get($name, $default = null) { if (! str_contains($name, '::')) { throw new InvalidArgumentException("Setting key must be in the format '[module]::[setting]', '$name' given."); } $defaultFromConfig = $this->getDefaultFromConfigFor($name); if ($this->setting->has($name)) { return $this->setting->get($name); } return is_null($default) ? $defaultFromConfig : $default; }
php
public function get($name, $default = null) { if (! str_contains($name, '::')) { throw new InvalidArgumentException("Setting key must be in the format '[module]::[setting]', '$name' given."); } $defaultFromConfig = $this->getDefaultFromConfigFor($name); if ($this->setting->has($name)) { return $this->setting->get($name); } return is_null($default) ? $defaultFromConfig : $default; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "str_contains", "(", "$", "name", ",", "'::'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Setting key must be in the format '[m...
Getting the setting. @param string $name @param string $locale @param string $default @return mixed
[ "Getting", "the", "setting", "." ]
a2726098cd596d2979750cd47d6fcec61c77e391
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L49-L62
train
SocietyCMS/Setting
Support/Settings.php
Settings.setFromRequest
public function setFromRequest($settings) { $this->removeTokenKey($settings); foreach ($settings as $settingName => $settingValues) { $this->set($settingName, $settingValues); } }
php
public function setFromRequest($settings) { $this->removeTokenKey($settings); foreach ($settings as $settingName => $settingValues) { $this->set($settingName, $settingValues); } }
[ "public", "function", "setFromRequest", "(", "$", "settings", ")", "{", "$", "this", "->", "removeTokenKey", "(", "$", "settings", ")", ";", "foreach", "(", "$", "settings", "as", "$", "settingName", "=>", "$", "settingValues", ")", "{", "$", "this", "->...
Set multiple given configuration values from a request. @param mixed $settings @return void
[ "Set", "multiple", "given", "configuration", "values", "from", "a", "request", "." ]
a2726098cd596d2979750cd47d6fcec61c77e391
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L89-L96
train
SocietyCMS/Setting
Support/Settings.php
Settings.moduleConfig
public function moduleConfig($modules) { if (is_string($modules)) { $config = config('society.'.strtolower($modules).'.settings'); return $config; } $config = []; foreach ($modules as $module) { if ($moduleSettings = config('society.'.strtolower($module->getName()).'.settings')) { $config[$module->getName()] = $moduleSettings; } } return $config; }
php
public function moduleConfig($modules) { if (is_string($modules)) { $config = config('society.'.strtolower($modules).'.settings'); return $config; } $config = []; foreach ($modules as $module) { if ($moduleSettings = config('society.'.strtolower($module->getName()).'.settings')) { $config[$module->getName()] = $moduleSettings; } } return $config; }
[ "public", "function", "moduleConfig", "(", "$", "modules", ")", "{", "if", "(", "is_string", "(", "$", "modules", ")", ")", "{", "$", "config", "=", "config", "(", "'society.'", ".", "strtolower", "(", "$", "modules", ")", ".", "'.settings'", ")", ";",...
Return all modules that have settings with its settings. @param array|string $modules @return array
[ "Return", "all", "modules", "that", "have", "settings", "with", "its", "settings", "." ]
a2726098cd596d2979750cd47d6fcec61c77e391
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L106-L122
train
SocietyCMS/Setting
Support/Settings.php
Settings.getConfigFor
private function getConfigFor($name) { list($module, $settingName) = explode('::', $name); $result = []; foreach (config("society.$module.settings") as $sub) { $result = array_merge($result, $sub); } return Arr::get($result, "$settingName"); }
php
private function getConfigFor($name) { list($module, $settingName) = explode('::', $name); $result = []; foreach (config("society.$module.settings") as $sub) { $result = array_merge($result, $sub); } return Arr::get($result, "$settingName"); }
[ "private", "function", "getConfigFor", "(", "$", "name", ")", "{", "list", "(", "$", "module", ",", "$", "settingName", ")", "=", "explode", "(", "'::'", ",", "$", "name", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "config", "(", ...
Get the settings configuration file. @param $name @return mixed
[ "Get", "the", "settings", "configuration", "file", "." ]
a2726098cd596d2979750cd47d6fcec61c77e391
https://github.com/SocietyCMS/Setting/blob/a2726098cd596d2979750cd47d6fcec61c77e391/Support/Settings.php#L154-L164
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.find
public function find($class, DataRequest $dataRequest) { try { $dataRequest->setSelectedFields(array('*')); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $class, 'a'); $accessEntities = $queryBuilder->getQuery()->getResult(); if ($accessEntities == null) { return array(); } foreach ($accessEntities as $accessEntity) { $this->loadPermissions($accessEntity); } return $accessEntities; } catch (\Exception $e) { throw new Exception('Cannot load the access entities for the given data request from the database.', 0, $e); } }
php
public function find($class, DataRequest $dataRequest) { try { $dataRequest->setSelectedFields(array('*')); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $class, 'a'); $accessEntities = $queryBuilder->getQuery()->getResult(); if ($accessEntities == null) { return array(); } foreach ($accessEntities as $accessEntity) { $this->loadPermissions($accessEntity); } return $accessEntities; } catch (\Exception $e) { throw new Exception('Cannot load the access entities for the given data request from the database.', 0, $e); } }
[ "public", "function", "find", "(", "$", "class", ",", "DataRequest", "$", "dataRequest", ")", "{", "try", "{", "$", "dataRequest", "->", "setSelectedFields", "(", "array", "(", "'*'", ")", ")", ";", "$", "queryBuilder", "=", "$", "this", "->", "entityMan...
Returns an array with all found access entities for the given DataRequest object. @param string $class @param \Zepi\Core\Utils\DataRequest $dataRequest @return array @throws \Zepi\Core\AccessControl\Exception Cannot load the access entities for the given data request.
[ "Returns", "an", "array", "with", "all", "found", "access", "entities", "for", "the", "given", "DataRequest", "object", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L101-L122
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.count
public function count($class, DataRequest $dataRequest) { try { $request = clone $dataRequest; $request->setPage(0); $request->setNumberOfEntries(0); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityManager->buildDataRequestQuery($request, $queryBuilder, $class, 'a'); // Count $queryBuilder->select($queryBuilder->expr()->count('a.id')); $data = $queryBuilder->getQuery(); if ($data === false) { return 0; } return $data->getSingleScalarResult(); } catch (\Exception $e) { throw new Exception('Cannot count the access entities for the given data request.', 0, $e); } }
php
public function count($class, DataRequest $dataRequest) { try { $request = clone $dataRequest; $request->setPage(0); $request->setNumberOfEntries(0); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityManager->buildDataRequestQuery($request, $queryBuilder, $class, 'a'); // Count $queryBuilder->select($queryBuilder->expr()->count('a.id')); $data = $queryBuilder->getQuery(); if ($data === false) { return 0; } return $data->getSingleScalarResult(); } catch (\Exception $e) { throw new Exception('Cannot count the access entities for the given data request.', 0, $e); } }
[ "public", "function", "count", "(", "$", "class", ",", "DataRequest", "$", "dataRequest", ")", "{", "try", "{", "$", "request", "=", "clone", "$", "dataRequest", ";", "$", "request", "->", "setPage", "(", "0", ")", ";", "$", "request", "->", "setNumber...
Returns the number of all found access entities for the given DataRequest object. @param string $class @param \Zepi\Core\Utils\DataRequest $dataRequest @return integer @throws \Zepi\Core\AccessControl\Exception Cannot count the access entities for the given data request.
[ "Returns", "the", "number", "of", "all", "found", "access", "entities", "for", "the", "given", "DataRequest", "object", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L134-L157
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.has
public function has($class, $entityId) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'id' => $entityId, )); if ($data !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is an access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e); } }
php
public function has($class, $entityId) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'id' => $entityId, )); if ($data !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is an access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e); } }
[ "public", "function", "has", "(", "$", "class", ",", "$", "entityId", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "data", "=", "$", "em", "->", "getRepository", "(", ...
Returns true if the given entity id exists @param string $class @param integer $entityId @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot check if there is an access entitiy for the given class "{class}" and id "{entityId}".
[ "Returns", "true", "if", "the", "given", "entity", "id", "exists" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L168-L184
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.get
public function get($class, $entityId) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'id' => $entityId, )); if ($accessEntity !== null) { $this->loadPermissions($accessEntity); return $accessEntity; } return false; } catch (\Exception $e) { throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e); } }
php
public function get($class, $entityId) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'id' => $entityId, )); if ($accessEntity !== null) { $this->loadPermissions($accessEntity); return $accessEntity; } return false; } catch (\Exception $e) { throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and id "' . $entityId . '".', 0, $e); } }
[ "public", "function", "get", "(", "$", "class", ",", "$", "entityId", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "accessEntity", "=", "$", "em", "->", "getRepository", ...
Returns the entity for the given id. Returns false if there is no entity for the given id. @param string $class @param integer $entityId @return false|mixed @throws \Zepi\Core\AccessControl\Exception Cannot load the access entitiy for the given class "{class}" and id "{entityId}".
[ "Returns", "the", "entity", "for", "the", "given", "id", ".", "Returns", "false", "if", "there", "is", "no", "entity", "for", "the", "given", "id", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L196-L214
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.hasAccessEntityForUuid
public function hasAccessEntityForUuid($class, $uuid) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'uuid' => $uuid, )); if ($data !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is an access entitiy for the given uuid "' . $uuid . '".', 0, $e); } }
php
public function hasAccessEntityForUuid($class, $uuid) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'uuid' => $uuid, )); if ($data !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is an access entitiy for the given uuid "' . $uuid . '".', 0, $e); } }
[ "public", "function", "hasAccessEntityForUuid", "(", "$", "class", ",", "$", "uuid", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "data", "=", "$", "em", "->", "getReposit...
Returns true if there is a access entity for the given uuid @access public @param string $class @param string $uuid @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot check if there is an access entitiy for the given uuid "{uuid}".
[ "Returns", "true", "if", "there", "is", "a", "access", "entity", "for", "the", "given", "uuid" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L226-L242
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.hasAccessEntityForName
public function hasAccessEntityForName($class, $name) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'name' => $name, )); if ($data !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is an access entitiy for the given type "' . $class . '" and name "' . $name . '".', 0, $e); } }
php
public function hasAccessEntityForName($class, $name) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($class)->findOneBy(array( 'name' => $name, )); if ($data !== null) { return true; } return false; } catch (\Exception $e) { throw new Exception('Cannot check if there is an access entitiy for the given type "' . $class . '" and name "' . $name . '".', 0, $e); } }
[ "public", "function", "hasAccessEntityForName", "(", "$", "class", ",", "$", "name", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "data", "=", "$", "em", "->", "getReposit...
Returns true if there is a access entity for the given type and name @access public @param string $class @param string $name @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot check if there is an access entitiy for the given type "{type}" and name "{name}".
[ "Returns", "true", "if", "there", "is", "a", "access", "entity", "for", "the", "given", "type", "and", "name" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L254-L270
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.getAccessEntityForUuid
public function getAccessEntityForUuid($class, $uuid) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'uuid' => $uuid, )); if ($accessEntity !== null) { $this->loadPermissions($accessEntity); return $accessEntity; } return false; } catch (\Exception $e) { throw new Exception('Cannot load the access entitiy from the database for the given uuid "' . $uuid . '".', 0, $e); } }
php
public function getAccessEntityForUuid($class, $uuid) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'uuid' => $uuid, )); if ($accessEntity !== null) { $this->loadPermissions($accessEntity); return $accessEntity; } return false; } catch (\Exception $e) { throw new Exception('Cannot load the access entitiy from the database for the given uuid "' . $uuid . '".', 0, $e); } }
[ "public", "function", "getAccessEntityForUuid", "(", "$", "class", ",", "$", "uuid", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "accessEntity", "=", "$", "em", "->", "ge...
Returns the access entity object for the given uuid @access public @param string $class @param string $uuid @return false|\Zepi\Core\AccessControl\Entity\AccessEntity @throws \Zepi\Core\AccessControl\Exception Cannot load the access entitiy from the database for the given uuid "{uuid}".
[ "Returns", "the", "access", "entity", "object", "for", "the", "given", "uuid" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L282-L300
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.getAccessEntityForName
public function getAccessEntityForName($class, $name) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'name' => $name, )); if ($accessEntity !== null) { $this->loadPermissions($accessEntity); return $accessEntity; } return false; } catch (\Exception $e) { throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and name "' . $name . '".', 0, $e); } }
php
public function getAccessEntityForName($class, $name) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($class)->findOneBy(array( 'name' => $name, )); if ($accessEntity !== null) { $this->loadPermissions($accessEntity); return $accessEntity; } return false; } catch (\Exception $e) { throw new Exception('Cannot load the access entitiy for the given class "' . $class . '" and name "' . $name . '".', 0, $e); } }
[ "public", "function", "getAccessEntityForName", "(", "$", "class", ",", "$", "name", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "accessEntity", "=", "$", "em", "->", "ge...
Returns the access entity object for the given type and name @access public @param string $class @param string $name @return false|\Zepi\Core\AccessControl\Entity\AccessEntity @throws \Zepi\Core\AccessControl\Exception Cannot load access entitiy from the database for the given class "{class}" and name "{name}".
[ "Returns", "the", "access", "entity", "object", "for", "the", "given", "type", "and", "name" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L312-L330
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.addAccessEntity
public function addAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->persist($accessEntity); $em->flush(); return $accessEntity->getUuid(); } catch (\Exception $e) { throw new Exception('Cannot add the new access entitiy "' . $accessEntity->getName() . '".', 0, $e); } }
php
public function addAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->persist($accessEntity); $em->flush(); return $accessEntity->getUuid(); } catch (\Exception $e) { throw new Exception('Cannot add the new access entitiy "' . $accessEntity->getName() . '".', 0, $e); } }
[ "public", "function", "addAccessEntity", "(", "AccessEntity", "$", "accessEntity", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "accessEntity"...
Adds an access entity. Returns the uuid of the access entity or false, if the access entity can not inserted. @access public @param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity @return string|false @throws \Zepi\Core\AccessControl\Exception Cannot add the new access entity "{name}".
[ "Adds", "an", "access", "entity", ".", "Returns", "the", "uuid", "of", "the", "access", "entity", "or", "false", "if", "the", "access", "entity", "can", "not", "inserted", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L342-L353
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.updateAccessEntity
public function updateAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->flush(); return true; } catch (\Exception $e) { throw new Exception('Cannot update the access entitiy "' . $accessEntity->getUuid() . '".', 0, $e); } }
php
public function updateAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->flush(); return true; } catch (\Exception $e) { throw new Exception('Cannot update the access entitiy "' . $accessEntity->getUuid() . '".', 0, $e); } }
[ "public", "function", "updateAccessEntity", "(", "AccessEntity", "$", "accessEntity", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "retur...
Updates the access entity. Returns true if everything worked as excepted or false if the update didn't worked. @access public @param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity @return boolean @throws \Zepi\Core\AccessControl\Exception Cannot update the access entity "{name}".
[ "Updates", "the", "access", "entity", ".", "Returns", "true", "if", "everything", "worked", "as", "excepted", "or", "false", "if", "the", "update", "didn", "t", "worked", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L365-L375
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.deleteAccessEntity
public function deleteAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->remove($accessEntity); $em->flush(); return true; } catch (\Exception $e) { throw new Exception('Cannot delete the access entitiy "' . $uuid . '".', 0, $e); } }
php
public function deleteAccessEntity(AccessEntity $accessEntity) { try { $em = $this->entityManager->getDoctrineEntityManager(); $em->remove($accessEntity); $em->flush(); return true; } catch (\Exception $e) { throw new Exception('Cannot delete the access entitiy "' . $uuid . '".', 0, $e); } }
[ "public", "function", "deleteAccessEntity", "(", "AccessEntity", "$", "accessEntity", ")", "{", "try", "{", "$", "em", "=", "$", "this", "->", "entityManager", "->", "getDoctrineEntityManager", "(", ")", ";", "$", "em", "->", "remove", "(", "$", "accessEntit...
Deletes the given access entity in the database. @access public @param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity @return boolean
[ "Deletes", "the", "given", "access", "entity", "in", "the", "database", "." ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L384-L395
train
zepi/turbo-base
Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php
AccessEntitiesDataSourceDoctrine.loadPermissions
protected function loadPermissions(AccessEntity $accessEntity) { $permissions = $this->permissionsDataSource->getPermissionsForUuid($accessEntity->getUuid()); if ($permissions === false) { return; } $accessEntity->setPermissions($permissions); }
php
protected function loadPermissions(AccessEntity $accessEntity) { $permissions = $this->permissionsDataSource->getPermissionsForUuid($accessEntity->getUuid()); if ($permissions === false) { return; } $accessEntity->setPermissions($permissions); }
[ "protected", "function", "loadPermissions", "(", "AccessEntity", "$", "accessEntity", ")", "{", "$", "permissions", "=", "$", "this", "->", "permissionsDataSource", "->", "getPermissionsForUuid", "(", "$", "accessEntity", "->", "getUuid", "(", ")", ")", ";", "if...
Loads the permissions for the given access entity object @param \Zepi\Core\AccessControl\Entity\AccessEntity $accessEntity
[ "Loads", "the", "permissions", "for", "the", "given", "access", "entity", "object" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/AccessEntitiesDataSourceDoctrine.php#L402-L411
train
strident/Container
src/LockBox.php
LockBox.set
public function set($name, $value) { if (isset($this->locked[$name])) { throw new LockedItemException($name); } $this->items[$name] = $value; }
php
public function set($name, $value) { if (isset($this->locked[$name])) { throw new LockedItemException($name); } $this->items[$name] = $value; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "locked", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "LockedItemException", "(", "$", "name", ")", ";", "}", "$", ...
Sets a item by name. @param string $name @param mixed $value @return LockBox
[ "Sets", "a", "item", "by", "name", "." ]
88fc1cded20d2baf69ea94f950c1e89cdb62262b
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L53-L60
train
strident/Container
src/LockBox.php
LockBox.get
public function get($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } return $this->items[$name]; }
php
public function get($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } return $this->items[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "ItemNotFoundException", "(", "$", "name", ")", ";", "}", "return", "$", "this", "->", "items", "[...
Returns a item by name. @param string $name @return mixed
[ "Returns", "a", "item", "by", "name", "." ]
88fc1cded20d2baf69ea94f950c1e89cdb62262b
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L69-L76
train
strident/Container
src/LockBox.php
LockBox.lock
public function lock($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } $this->locked[$name] = true; return $this; }
php
public function lock($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } $this->locked[$name] = true; return $this; }
[ "public", "function", "lock", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "ItemNotFoundException", "(", "$", "name", ")", ";", "}", "$", "this", "->", "locked", "[", "$", ...
Locks an item. @param string $name @return LockBox
[ "Locks", "an", "item", "." ]
88fc1cded20d2baf69ea94f950c1e89cdb62262b
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L111-L120
train
strident/Container
src/LockBox.php
LockBox.unlock
public function unlock($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } unset($this->locked[$name]); return $this; }
php
public function unlock($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } unset($this->locked[$name]); return $this; }
[ "public", "function", "unlock", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "ItemNotFoundException", "(", "$", "name", ")", ";", "}", "unset", "(", "$", "this", "->", "loc...
Unlocks an item. @param string $name @return LockBox
[ "Unlocks", "an", "item", "." ]
88fc1cded20d2baf69ea94f950c1e89cdb62262b
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L129-L138
train
strident/Container
src/LockBox.php
LockBox.isLocked
public function isLocked($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } return isset($this->locked[$name]); }
php
public function isLocked($name) { if (!$this->has($name)) { throw new ItemNotFoundException($name); } return isset($this->locked[$name]); }
[ "public", "function", "isLocked", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "ItemNotFoundException", "(", "$", "name", ")", ";", "}", "return", "isset", "(", "$", "this", ...
Returns true if the item is locked. @param string $name @return boolean
[ "Returns", "true", "if", "the", "item", "is", "locked", "." ]
88fc1cded20d2baf69ea94f950c1e89cdb62262b
https://github.com/strident/Container/blob/88fc1cded20d2baf69ea94f950c1e89cdb62262b/src/LockBox.php#L147-L154
train
xiewulong/yii2-xui
Tinymce.php
Tinymce.init
public function init(){ parent::init(); $id = $this->getRandomId(); $view = $this->getView(); TinymceAsset::register($view); TinymceLanguageAsset::register($view); $view->registerJs("tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_formats',autosave_ask_before_unload:false,preview_styles:false,toolbar:'$this->toolbar'});"); }
php
public function init(){ parent::init(); $id = $this->getRandomId(); $view = $this->getView(); TinymceAsset::register($view); TinymceLanguageAsset::register($view); $view->registerJs("tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_formats',autosave_ask_before_unload:false,preview_styles:false,toolbar:'$this->toolbar'});"); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "id", "=", "$", "this", "->", "getRandomId", "(", ")", ";", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "TinymceAsset", "::", "register", ...
newdocument strikethrough cut copy paste blockquote removeformat subscript superscript
[ "newdocument", "strikethrough", "cut", "copy", "paste", "blockquote", "removeformat", "subscript", "superscript" ]
ec64752d88eddc0cdb8bcb26c4616473a3a18235
https://github.com/xiewulong/yii2-xui/blob/ec64752d88eddc0cdb8bcb26c4616473a3a18235/Tinymce.php#L40-L48
train
wasabi-cms/core
src/Controller/LanguagesController.php
LanguagesController.sort
public function sort() { if (!$this->request->is('ajax') || !$this->request->is('post')) { throw new MethodNotAllowedException(); } if (empty($this->request->data)) { throw new BadRequestException(); } // save the new language positions $languages = $this->Languages->patchEntities( $this->Languages->find('allFrontendBackend'), $this->request->data ); /** @var Connection $connection */ $connection = $this->Languages->connection(); $connection->begin(); foreach ($languages as $language) { if (!$this->Languages->save($language)) { $connection->rollback(); break; } } if ($connection->inTransaction()) { $connection->commit(); $status = 'success'; $flashMessage = __d('wasabi_core', 'The language position has been updated.'); } else { $status = 'error'; $flashMessage = $this->dbErrorMessage; } // create the json response $frontendLanguages = $this->Languages ->filterFrontend(new Collection($languages)) ->sortBy('position', SORT_ASC, SORT_NUMERIC) ->toList(); $backendLanguages = $this->Languages ->filterBackend(new Collection($languages)) ->sortBy('position', SORT_ASC, SORT_NUMERIC) ->toList(); $this->set(compact('status', 'flashMessage', 'frontendLanguages', 'backendLanguages')); $this->set('_serialize', ['status', 'flashMessage', 'frontendLanguages', 'backendLanguages']); $this->RequestHandler->renderAs($this, 'json'); }
php
public function sort() { if (!$this->request->is('ajax') || !$this->request->is('post')) { throw new MethodNotAllowedException(); } if (empty($this->request->data)) { throw new BadRequestException(); } // save the new language positions $languages = $this->Languages->patchEntities( $this->Languages->find('allFrontendBackend'), $this->request->data ); /** @var Connection $connection */ $connection = $this->Languages->connection(); $connection->begin(); foreach ($languages as $language) { if (!$this->Languages->save($language)) { $connection->rollback(); break; } } if ($connection->inTransaction()) { $connection->commit(); $status = 'success'; $flashMessage = __d('wasabi_core', 'The language position has been updated.'); } else { $status = 'error'; $flashMessage = $this->dbErrorMessage; } // create the json response $frontendLanguages = $this->Languages ->filterFrontend(new Collection($languages)) ->sortBy('position', SORT_ASC, SORT_NUMERIC) ->toList(); $backendLanguages = $this->Languages ->filterBackend(new Collection($languages)) ->sortBy('position', SORT_ASC, SORT_NUMERIC) ->toList(); $this->set(compact('status', 'flashMessage', 'frontendLanguages', 'backendLanguages')); $this->set('_serialize', ['status', 'flashMessage', 'frontendLanguages', 'backendLanguages']); $this->RequestHandler->renderAs($this, 'json'); }
[ "public", "function", "sort", "(", ")", "{", "if", "(", "!", "$", "this", "->", "request", "->", "is", "(", "'ajax'", ")", "||", "!", "$", "this", "->", "request", "->", "is", "(", "'post'", ")", ")", "{", "throw", "new", "MethodNotAllowedException",...
Sort action AJAX POST Save the order of languages. @return void
[ "Sort", "action", "AJAX", "POST" ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/LanguagesController.php#L143-L189
train
wasabi-cms/core
src/Controller/LanguagesController.php
LanguagesController.change
public function change($id = null) { if ($id === null || !$this->Languages->exists(['id' => $id])) { $this->Flash->error($this->invalidRequestMessage); $this->redirect($this->referer()); return; } $this->request->session()->write('contentLanguageId', (int)$id); $this->redirect($this->referer()); }
php
public function change($id = null) { if ($id === null || !$this->Languages->exists(['id' => $id])) { $this->Flash->error($this->invalidRequestMessage); $this->redirect($this->referer()); return; } $this->request->session()->write('contentLanguageId', (int)$id); $this->redirect($this->referer()); }
[ "public", "function", "change", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", "===", "null", "||", "!", "$", "this", "->", "Languages", "->", "exists", "(", "[", "'id'", "=>", "$", "id", "]", ")", ")", "{", "$", "this", "->", "...
Change action GET Change the content language to $id and update the session. @param string $id The language id. @return void
[ "Change", "action", "GET" ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Controller/LanguagesController.php#L200-L209
train
unclecheese/silverstripe-reflection-templates
code/SiteTreeReflectionTemplate.php
SiteTreeReflectionTemplate.getTemplateAccessors
public function getTemplateAccessors() { if($this->templateAccessors) return $this->templateAccessors; $vars = parent::getTemplateAccessors(); $cc = new ReflectionClass('ContentController'); $site_tree = new ReflectionClass('SiteTree'); $hierarchy = new ReflectionClass('Hierarchy'); $methods = array_merge( $site_tree->getMethods(), $cc->getMethods(), $hierarchy->getMethods(), array_keys(singleton('SiteTree')->has_many()), array_keys(singleton('SiteTree')->many_many()), array_keys(singleton('SiteTree')->db()), array_keys(DataObject::config()->fixed_fields) ); foreach($methods as $m) { $name = is_object($m) ? $m->getName() : $m; // We only care about methods that follow the UpperCamelCase convention. if(preg_match("/[A-Z]/",$name[0])) { $vars[] = $name; } } // Just a random exception case $vars[] = "Form"; return $this->templateAccessors = $vars; }
php
public function getTemplateAccessors() { if($this->templateAccessors) return $this->templateAccessors; $vars = parent::getTemplateAccessors(); $cc = new ReflectionClass('ContentController'); $site_tree = new ReflectionClass('SiteTree'); $hierarchy = new ReflectionClass('Hierarchy'); $methods = array_merge( $site_tree->getMethods(), $cc->getMethods(), $hierarchy->getMethods(), array_keys(singleton('SiteTree')->has_many()), array_keys(singleton('SiteTree')->many_many()), array_keys(singleton('SiteTree')->db()), array_keys(DataObject::config()->fixed_fields) ); foreach($methods as $m) { $name = is_object($m) ? $m->getName() : $m; // We only care about methods that follow the UpperCamelCase convention. if(preg_match("/[A-Z]/",$name[0])) { $vars[] = $name; } } // Just a random exception case $vars[] = "Form"; return $this->templateAccessors = $vars; }
[ "public", "function", "getTemplateAccessors", "(", ")", "{", "if", "(", "$", "this", "->", "templateAccessors", ")", "return", "$", "this", "->", "templateAccessors", ";", "$", "vars", "=", "parent", "::", "getTemplateAccessors", "(", ")", ";", "$", "cc", ...
Gets all the core template accessors available to SiteTree templates and caches the result @return array
[ "Gets", "all", "the", "core", "template", "accessors", "available", "to", "SiteTree", "templates", "and", "caches", "the", "result" ]
7ae6fc333246afd1099bf91f281211ec8d8232d2
https://github.com/unclecheese/silverstripe-reflection-templates/blob/7ae6fc333246afd1099bf91f281211ec8d8232d2/code/SiteTreeReflectionTemplate.php#L18-L49
train
twanhaverkamp/core-bundle
Twig/AbstractExtension.php
AbstractExtension.generateUrl
final protected function generateUrl(string $name, array $params = []) : string { return $this->urlGenerator ->generate($name, $params); }
php
final protected function generateUrl(string $name, array $params = []) : string { return $this->urlGenerator ->generate($name, $params); }
[ "final", "protected", "function", "generateUrl", "(", "string", "$", "name", ",", "array", "$", "params", "=", "[", "]", ")", ":", "string", "{", "return", "$", "this", "->", "urlGenerator", "->", "generate", "(", "$", "name", ",", "$", "params", ")", ...
Generate a URL by the given name and params @param string $name @param array $params @return string
[ "Generate", "a", "URL", "by", "the", "given", "name", "and", "params" ]
04ccf69c159566a850ed9d048d09accd12e68e26
https://github.com/twanhaverkamp/core-bundle/blob/04ccf69c159566a850ed9d048d09accd12e68e26/Twig/AbstractExtension.php#L51-L55
train
OWeb/OWeb-Framework
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
Node_Container.replace_child
public function replace_child(Node $what, $with) { $replace_key = array_search($what, $this->children); if($replace_key === false) return false; if(is_array($with)) foreach($with as $child) $child->set_parent($this); array_splice($this->children, $replace_key, 1, $with); return true; }
php
public function replace_child(Node $what, $with) { $replace_key = array_search($what, $this->children); if($replace_key === false) return false; if(is_array($with)) foreach($with as $child) $child->set_parent($this); array_splice($this->children, $replace_key, 1, $with); return true; }
[ "public", "function", "replace_child", "(", "Node", "$", "what", ",", "$", "with", ")", "{", "$", "replace_key", "=", "array_search", "(", "$", "what", ",", "$", "this", "->", "children", ")", ";", "if", "(", "$", "replace_key", "===", "false", ")", ...
Replaces a child node @param Node $what @param mixed $with Node or an array of Node @return bool
[ "Replaces", "a", "child", "node" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L32-L46
train
OWeb/OWeb-Framework
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
Node_Container.remove_child
public function remove_child(Node $child) { $key = array_search($what, $this->children); if($key === false) return false; $this->children[$key]->set_parent(); unset($this->children[$key]); return true; }
php
public function remove_child(Node $child) { $key = array_search($what, $this->children); if($key === false) return false; $this->children[$key]->set_parent(); unset($this->children[$key]); return true; }
[ "public", "function", "remove_child", "(", "Node", "$", "child", ")", "{", "$", "key", "=", "array_search", "(", "$", "what", ",", "$", "this", "->", "children", ")", ";", "if", "(", "$", "key", "===", "false", ")", "return", "false", ";", "$", "th...
Removes a child fromthe node @param Node $child @return bool
[ "Removes", "a", "child", "fromthe", "node" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L53-L63
train
OWeb/OWeb-Framework
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
Node_Container.last_tag_node
public function last_tag_node() { $children_len = count($this->children); for($i=$children_len-1; $i >= 0; $i--) if($this->children[$i] instanceof Node_Container_Tag) return $this->children[$i]; return null; }
php
public function last_tag_node() { $children_len = count($this->children); for($i=$children_len-1; $i >= 0; $i--) if($this->children[$i] instanceof Node_Container_Tag) return $this->children[$i]; return null; }
[ "public", "function", "last_tag_node", "(", ")", "{", "$", "children_len", "=", "count", "(", "$", "this", "->", "children", ")", ";", "for", "(", "$", "i", "=", "$", "children_len", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", ...
Gets the last child of type Node_Container_Tag. @return Node_Container_Tag
[ "Gets", "the", "last", "child", "of", "type", "Node_Container_Tag", "." ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L78-L87
train
OWeb/OWeb-Framework
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
Node_Container.get_html
public function get_html($nl2br=true, $htmlEntities = true) { $html = ''; foreach($this->children as $child) $html .= $child->get_html($nl2br, $htmlEntities); if($this instanceof Node_Container_Document) return $html; $bbcode = $this->root()->get_bbcode($this->tag); if(is_callable($bbcode->handler()) && ($func = $bbcode->handler()) !== false) return $func($html, $this->attribs, $this); //return call_user_func($bbcode->handler(), $html, $this->attribs, $this); return str_replace('%content%', $html, $bbcode->handler()); }
php
public function get_html($nl2br=true, $htmlEntities = true) { $html = ''; foreach($this->children as $child) $html .= $child->get_html($nl2br, $htmlEntities); if($this instanceof Node_Container_Document) return $html; $bbcode = $this->root()->get_bbcode($this->tag); if(is_callable($bbcode->handler()) && ($func = $bbcode->handler()) !== false) return $func($html, $this->attribs, $this); //return call_user_func($bbcode->handler(), $html, $this->attribs, $this); return str_replace('%content%', $html, $bbcode->handler()); }
[ "public", "function", "get_html", "(", "$", "nl2br", "=", "true", ",", "$", "htmlEntities", "=", "true", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "$", "html", ".=", "$", "child",...
Gets a HTML representation of this node @return string
[ "Gets", "a", "HTML", "representation", "of", "this", "node" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L93-L110
train
OWeb/OWeb-Framework
OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php
Node_Container.get_text
public function get_text() { $text = ''; foreach($this->children as $child) $text .= $child->get_text(); return $text; }
php
public function get_text() { $text = ''; foreach($this->children as $child) $text .= $child->get_text(); return $text; }
[ "public", "function", "get_text", "(", ")", "{", "$", "text", "=", "''", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "$", "text", ".=", "$", "child", "->", "get_text", "(", ")", ";", "return", "$", "text", ";", "}...
Gets the raw text content of this node and it's children. The returned text is UNSAFE and should not be used without filtering! @return string
[ "Gets", "the", "raw", "text", "content", "of", "this", "node", "and", "it", "s", "children", "." ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/SBBCodeParser/classes/Node/Container.php#L120-L128
train
wisquimas/valleysofsorcery
admin/mf_custom_fields.php
mf_custom_fields.edit_field
function edit_field() { global $mf_domain; //check param custom_field_id $data = $this->fields_form(); $field = $this->get_custom_field($_GET['custom_field_id']); //check if exist field if(!$field){ $this->mf_flash('error'); }else{ $no_set = array('options','active','display_order'); foreach($field as $k => $v){ if( !in_array($k,$no_set) ){ $data['core'][$k]['value'] = $v; } } $data['option'] = unserialize($field['options'] ); } $this->form_custom_field($data); ?> <?php }
php
function edit_field() { global $mf_domain; //check param custom_field_id $data = $this->fields_form(); $field = $this->get_custom_field($_GET['custom_field_id']); //check if exist field if(!$field){ $this->mf_flash('error'); }else{ $no_set = array('options','active','display_order'); foreach($field as $k => $v){ if( !in_array($k,$no_set) ){ $data['core'][$k]['value'] = $v; } } $data['option'] = unserialize($field['options'] ); } $this->form_custom_field($data); ?> <?php }
[ "function", "edit_field", "(", ")", "{", "global", "$", "mf_domain", ";", "//check param custom_field_id", "$", "data", "=", "$", "this", "->", "fields_form", "(", ")", ";", "$", "field", "=", "$", "this", "->", "get_custom_field", "(", "$", "_GET", "[", ...
Page for edit a custom field
[ "Page", "for", "edit", "a", "custom", "field" ]
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L242-L264
train
wisquimas/valleysofsorcery
admin/mf_custom_fields.php
mf_custom_fields.get_custom_fields_name
function get_custom_fields_name () { $path = MF_PATH.'/field_types/*'; $folders = glob($path,GLOB_ONLYDIR); $fields = array(); foreach($folders as $folder) { $name = preg_match('/\/([\w\_]+)\_field$/i',$folder,$name_match); $fields[$name_match[1]] = preg_replace('/_/',' ',$name_match[1]); } return $fields; }
php
function get_custom_fields_name () { $path = MF_PATH.'/field_types/*'; $folders = glob($path,GLOB_ONLYDIR); $fields = array(); foreach($folders as $folder) { $name = preg_match('/\/([\w\_]+)\_field$/i',$folder,$name_match); $fields[$name_match[1]] = preg_replace('/_/',' ',$name_match[1]); } return $fields; }
[ "function", "get_custom_fields_name", "(", ")", "{", "$", "path", "=", "MF_PATH", ".", "'/field_types/*'", ";", "$", "folders", "=", "glob", "(", "$", "path", ",", "GLOB_ONLYDIR", ")", ";", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$...
Get the list of custom fields @return array
[ "Get", "the", "list", "of", "custom", "fields" ]
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L321-L333
train
wisquimas/valleysofsorcery
admin/mf_custom_fields.php
mf_custom_fields.save_order_field
public static function save_order_field( $group_id, $order ) { global $wpdb; if( !is_numeric($group_id) ) { return false; } foreach( $order as $key => $value ) { $update = $wpdb->update( MF_TABLE_CUSTOM_FIELDS, array( 'display_order' => $key ), array( 'custom_group_id' => $group_id, 'id' => $value ), array( '%d' ), array( '%d', '%d' ) ); if( $update === false ) { return $update; } } return true; }
php
public static function save_order_field( $group_id, $order ) { global $wpdb; if( !is_numeric($group_id) ) { return false; } foreach( $order as $key => $value ) { $update = $wpdb->update( MF_TABLE_CUSTOM_FIELDS, array( 'display_order' => $key ), array( 'custom_group_id' => $group_id, 'id' => $value ), array( '%d' ), array( '%d', '%d' ) ); if( $update === false ) { return $update; } } return true; }
[ "public", "static", "function", "save_order_field", "(", "$", "group_id", ",", "$", "order", ")", "{", "global", "$", "wpdb", ";", "if", "(", "!", "is_numeric", "(", "$", "group_id", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "o...
Save the order of the custom fields
[ "Save", "the", "order", "of", "the", "custom", "fields" ]
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L564-L585
train
wisquimas/valleysofsorcery
admin/mf_custom_fields.php
mf_custom_fields.has_fields
public static function has_fields($post_type_name) { global $wpdb; $sql = $wpdb->prepare("SELECT COUNT(1) FROM ".MF_TABLE_CUSTOM_FIELDS. " WHERE post_type = %s",$post_type_name); return $wpdb->get_var( $sql ) > 0; }
php
public static function has_fields($post_type_name) { global $wpdb; $sql = $wpdb->prepare("SELECT COUNT(1) FROM ".MF_TABLE_CUSTOM_FIELDS. " WHERE post_type = %s",$post_type_name); return $wpdb->get_var( $sql ) > 0; }
[ "public", "static", "function", "has_fields", "(", "$", "post_type_name", ")", "{", "global", "$", "wpdb", ";", "$", "sql", "=", "$", "wpdb", "->", "prepare", "(", "\"SELECT COUNT(1) FROM \"", ".", "MF_TABLE_CUSTOM_FIELDS", ".", "\" WHERE post_type = %s\"", ",", ...
Return True if the post type has at least one custom field return @bool
[ "Return", "True", "if", "the", "post", "type", "has", "at", "least", "one", "custom", "field" ]
78a8d8f1d1102c5043e2cf7c98762e63464d2d7a
https://github.com/wisquimas/valleysofsorcery/blob/78a8d8f1d1102c5043e2cf7c98762e63464d2d7a/admin/mf_custom_fields.php#L592-L598
train