id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
229,700
|
chadicus/marvel-api-client
|
src/Client.php
|
Client.send
|
final private function send(string $resource, int $id = null, array $query = [])
{
$query['apikey'] = $this->publicApiKey;
$query['ts'] = time();
$query['hash'] = md5("{$query['ts']}{$this->privateApiKey}{$this->publicApiKey}");
$cacheKey = urlencode($resource) . ($id !== null ? "/{$id}" : '') . '?' . http_build_query($query);
$url = self::BASE_URL . $cacheKey;
$response = $this->cache->get($cacheKey);
if ($response === null) {
$response = $this->guzzleClient->request('GET', $url, self::$guzzleRequestOptions);
}
if ($response->getStatusCode() !== 200) {
return null;
}
$this->cache->set($cacheKey, $response, self::MAX_TTL);
return DataWrapper::fromJson((string)$response->getBody());
}
|
php
|
final private function send(string $resource, int $id = null, array $query = [])
{
$query['apikey'] = $this->publicApiKey;
$query['ts'] = time();
$query['hash'] = md5("{$query['ts']}{$this->privateApiKey}{$this->publicApiKey}");
$cacheKey = urlencode($resource) . ($id !== null ? "/{$id}" : '') . '?' . http_build_query($query);
$url = self::BASE_URL . $cacheKey;
$response = $this->cache->get($cacheKey);
if ($response === null) {
$response = $this->guzzleClient->request('GET', $url, self::$guzzleRequestOptions);
}
if ($response->getStatusCode() !== 200) {
return null;
}
$this->cache->set($cacheKey, $response, self::MAX_TTL);
return DataWrapper::fromJson((string)$response->getBody());
}
|
[
"final",
"private",
"function",
"send",
"(",
"string",
"$",
"resource",
",",
"int",
"$",
"id",
"=",
"null",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"[",
"'apikey'",
"]",
"=",
"$",
"this",
"->",
"publicApiKey",
";",
"$",
"query",
"[",
"'ts'",
"]",
"=",
"time",
"(",
")",
";",
"$",
"query",
"[",
"'hash'",
"]",
"=",
"md5",
"(",
"\"{$query['ts']}{$this->privateApiKey}{$this->publicApiKey}\"",
")",
";",
"$",
"cacheKey",
"=",
"urlencode",
"(",
"$",
"resource",
")",
".",
"(",
"$",
"id",
"!==",
"null",
"?",
"\"/{$id}\"",
":",
"''",
")",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"query",
")",
";",
"$",
"url",
"=",
"self",
"::",
"BASE_URL",
".",
"$",
"cacheKey",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(",
"$",
"response",
"===",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"guzzleClient",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
",",
"self",
"::",
"$",
"guzzleRequestOptions",
")",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"$",
"cacheKey",
",",
"$",
"response",
",",
"self",
"::",
"MAX_TTL",
")",
";",
"return",
"DataWrapper",
"::",
"fromJson",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"}"
] |
Send the given API URL request.
@param string $resource The API resource to search for.
@param integer $id The id of a specific API resource.
@param array $query Array of search criteria to use in request.
@return null|DataWrapperInterface
|
[
"Send",
"the",
"given",
"API",
"URL",
"request",
"."
] |
a27729f070c0a3f14b2d2df3a3961590e2d59cb2
|
https://github.com/chadicus/marvel-api-client/blob/a27729f070c0a3f14b2d2df3a3961590e2d59cb2/src/Client.php#L125-L145
|
229,701
|
epochblue/darksky-php
|
src/DarkSky.php
|
DarkSky.getForecast
|
public function getForecast($lat, $long)
{
$endpoint = sprintf('/forecast/%s/%s,%s', $this->apiKey, $lat, $long);
return $this->makeAPIRequest($endpoint);
}
|
php
|
public function getForecast($lat, $long)
{
$endpoint = sprintf('/forecast/%s/%s,%s', $this->apiKey, $lat, $long);
return $this->makeAPIRequest($endpoint);
}
|
[
"public",
"function",
"getForecast",
"(",
"$",
"lat",
",",
"$",
"long",
")",
"{",
"$",
"endpoint",
"=",
"sprintf",
"(",
"'/forecast/%s/%s,%s'",
",",
"$",
"this",
"->",
"apiKey",
",",
"$",
"lat",
",",
"$",
"long",
")",
";",
"return",
"$",
"this",
"->",
"makeAPIRequest",
"(",
"$",
"endpoint",
")",
";",
"}"
] |
Retrieves the forecast for the given latitude and longitude.
@param $lat float The latitude
@param $long float The longitude
@return array The decoded JSON response from the API call
|
[
"Retrieves",
"the",
"forecast",
"for",
"the",
"given",
"latitude",
"and",
"longitude",
"."
] |
ac3f8af7c2036d6313a4512d11ebb57a6dfd521b
|
https://github.com/epochblue/darksky-php/blob/ac3f8af7c2036d6313a4512d11ebb57a6dfd521b/src/DarkSky.php#L46-L50
|
229,702
|
epochblue/darksky-php
|
src/DarkSky.php
|
DarkSky.getPrecipitation
|
public function getPrecipitation()
{
$now = time();
$params = array();
foreach(func_get_args() as $arg) {
$lat = $arg['lat'];
$long = $arg['long'];
$time = (isset($arg['time'])) ? $arg['time'] : $now;
$dt = new \DateTime();
$dt->setTimestamp($time);
// The DarkSky API requires the time be between -8hrs and +1hrs from now
$min = new \DateTime("-8 hours");
$max = new \DateTime("+1 hours");
if ($dt < $min || $dt > $max) {
throw new \InvalidArgumentException('Time value must greater than -8hrs and less the +1hr from now.');
}
// The DarkSky API expects this timestamp to be in GMT.
$dt->setTimezone(new DateTimeZone('GMT'));
$params[] = implode(',', array($lat, $long, $dt->getTimestamp()));
}
$endpoint = sprintf('/precipitation/%s/%s', $this->apiKey, implode(';', $params));
return $this->makeAPIRequest($endpoint);
}
|
php
|
public function getPrecipitation()
{
$now = time();
$params = array();
foreach(func_get_args() as $arg) {
$lat = $arg['lat'];
$long = $arg['long'];
$time = (isset($arg['time'])) ? $arg['time'] : $now;
$dt = new \DateTime();
$dt->setTimestamp($time);
// The DarkSky API requires the time be between -8hrs and +1hrs from now
$min = new \DateTime("-8 hours");
$max = new \DateTime("+1 hours");
if ($dt < $min || $dt > $max) {
throw new \InvalidArgumentException('Time value must greater than -8hrs and less the +1hr from now.');
}
// The DarkSky API expects this timestamp to be in GMT.
$dt->setTimezone(new DateTimeZone('GMT'));
$params[] = implode(',', array($lat, $long, $dt->getTimestamp()));
}
$endpoint = sprintf('/precipitation/%s/%s', $this->apiKey, implode(';', $params));
return $this->makeAPIRequest($endpoint);
}
|
[
"public",
"function",
"getPrecipitation",
"(",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"func_get_args",
"(",
")",
"as",
"$",
"arg",
")",
"{",
"$",
"lat",
"=",
"$",
"arg",
"[",
"'lat'",
"]",
";",
"$",
"long",
"=",
"$",
"arg",
"[",
"'long'",
"]",
";",
"$",
"time",
"=",
"(",
"isset",
"(",
"$",
"arg",
"[",
"'time'",
"]",
")",
")",
"?",
"$",
"arg",
"[",
"'time'",
"]",
":",
"$",
"now",
";",
"$",
"dt",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"dt",
"->",
"setTimestamp",
"(",
"$",
"time",
")",
";",
"// The DarkSky API requires the time be between -8hrs and +1hrs from now",
"$",
"min",
"=",
"new",
"\\",
"DateTime",
"(",
"\"-8 hours\"",
")",
";",
"$",
"max",
"=",
"new",
"\\",
"DateTime",
"(",
"\"+1 hours\"",
")",
";",
"if",
"(",
"$",
"dt",
"<",
"$",
"min",
"||",
"$",
"dt",
">",
"$",
"max",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Time value must greater than -8hrs and less the +1hr from now.'",
")",
";",
"}",
"// The DarkSky API expects this timestamp to be in GMT.",
"$",
"dt",
"->",
"setTimezone",
"(",
"new",
"DateTimeZone",
"(",
"'GMT'",
")",
")",
";",
"$",
"params",
"[",
"]",
"=",
"implode",
"(",
"','",
",",
"array",
"(",
"$",
"lat",
",",
"$",
"long",
",",
"$",
"dt",
"->",
"getTimestamp",
"(",
")",
")",
")",
";",
"}",
"$",
"endpoint",
"=",
"sprintf",
"(",
"'/precipitation/%s/%s'",
",",
"$",
"this",
"->",
"apiKey",
",",
"implode",
"(",
"';'",
",",
"$",
"params",
")",
")",
";",
"return",
"$",
"this",
"->",
"makeAPIRequest",
"(",
"$",
"endpoint",
")",
";",
"}"
] |
Returns forecasts for a collection of arbitrary points.
NOTE:
This method takes an arbitrary number of parameters, but each
parameter must be an associative array with 2 required keys
and 1 optional key.
Each parameter should follow this format:
array(
'lat' => 37.126617, // float, latitude, required
'long' => -87.842756, // float, longitude, required
'time' => 1350531963 // integer, unix timestamp, optional
)
If the 'time' key isn't included, the current time will be used. The given
timestamp will be automatically converted to GMT time, so do not pre-convert
this value.
@param array Associative array of lat/long/[time] to pull information from.
@return array The decoded JSON response from the API call
@throws \InvalidArgumentException If a given time is outside the -8hrs to +1hr range
|
[
"Returns",
"forecasts",
"for",
"a",
"collection",
"of",
"arbitrary",
"points",
"."
] |
ac3f8af7c2036d6313a4512d11ebb57a6dfd521b
|
https://github.com/epochblue/darksky-php/blob/ac3f8af7c2036d6313a4512d11ebb57a6dfd521b/src/DarkSky.php#L92-L120
|
229,703
|
softark/creole
|
block/CodeTrait.php
|
CodeTrait.consumeCode
|
protected function consumeCode($lines, $current)
{
// consume until }}}
$content = [];
for ($i = $current + 1, $count = count($lines); $i < $count; $i++) {
$line = rtrim($lines[$i]);
if (strcmp($line, '}}}') !== 0) {
$content[] = $line;
} else {
break;
}
}
$block = [
'code',
'content' => implode("\n", $content),
];
return [$block, $i];
}
|
php
|
protected function consumeCode($lines, $current)
{
// consume until }}}
$content = [];
for ($i = $current + 1, $count = count($lines); $i < $count; $i++) {
$line = rtrim($lines[$i]);
if (strcmp($line, '}}}') !== 0) {
$content[] = $line;
} else {
break;
}
}
$block = [
'code',
'content' => implode("\n", $content),
];
return [$block, $i];
}
|
[
"protected",
"function",
"consumeCode",
"(",
"$",
"lines",
",",
"$",
"current",
")",
"{",
"// consume until }}}",
"$",
"content",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"current",
"+",
"1",
",",
"$",
"count",
"=",
"count",
"(",
"$",
"lines",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"line",
"=",
"rtrim",
"(",
"$",
"lines",
"[",
"$",
"i",
"]",
")",
";",
"if",
"(",
"strcmp",
"(",
"$",
"line",
",",
"'}}}'",
")",
"!==",
"0",
")",
"{",
"$",
"content",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"$",
"block",
"=",
"[",
"'code'",
",",
"'content'",
"=>",
"implode",
"(",
"\"\\n\"",
",",
"$",
"content",
")",
",",
"]",
";",
"return",
"[",
"$",
"block",
",",
"$",
"i",
"]",
";",
"}"
] |
Consume lines for a code block
|
[
"Consume",
"lines",
"for",
"a",
"code",
"block"
] |
f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b
|
https://github.com/softark/creole/blob/f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b/block/CodeTrait.php#L26-L43
|
229,704
|
milesj/utility
|
Controller/Component/AutoLoginComponent.php
|
AutoLoginComponent.initialize
|
public function initialize(Controller $controller) {
$autoLogin = (array) Configure::read('AutoLogin');
// Is debug enabled?
$this->_debug = (!empty($autoLogin['ips']) && in_array(env('REMOTE_ADDR'), (array) $autoLogin['ips']));
}
|
php
|
public function initialize(Controller $controller) {
$autoLogin = (array) Configure::read('AutoLogin');
// Is debug enabled?
$this->_debug = (!empty($autoLogin['ips']) && in_array(env('REMOTE_ADDR'), (array) $autoLogin['ips']));
}
|
[
"public",
"function",
"initialize",
"(",
"Controller",
"$",
"controller",
")",
"{",
"$",
"autoLogin",
"=",
"(",
"array",
")",
"Configure",
"::",
"read",
"(",
"'AutoLogin'",
")",
";",
"// Is debug enabled?",
"$",
"this",
"->",
"_debug",
"=",
"(",
"!",
"empty",
"(",
"$",
"autoLogin",
"[",
"'ips'",
"]",
")",
"&&",
"in_array",
"(",
"env",
"(",
"'REMOTE_ADDR'",
")",
",",
"(",
"array",
")",
"$",
"autoLogin",
"[",
"'ips'",
"]",
")",
")",
";",
"}"
] |
Initialize settings and debug.
@param Controller $controller
|
[
"Initialize",
"settings",
"and",
"debug",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AutoLoginComponent.php#L125-L130
|
229,705
|
milesj/utility
|
Controller/Component/AutoLoginComponent.php
|
AutoLoginComponent.login
|
public function login($data) {
$username = $data[$this->username];
$password = $data[$this->password];
$autoLogin = isset($data['auto_login']) ? $data['auto_login'] : !$this->requirePrompt;
if ($username && $password && $autoLogin) {
$this->write($username, $password);
} else if (!$autoLogin) {
$this->delete();
}
}
|
php
|
public function login($data) {
$username = $data[$this->username];
$password = $data[$this->password];
$autoLogin = isset($data['auto_login']) ? $data['auto_login'] : !$this->requirePrompt;
if ($username && $password && $autoLogin) {
$this->write($username, $password);
} else if (!$autoLogin) {
$this->delete();
}
}
|
[
"public",
"function",
"login",
"(",
"$",
"data",
")",
"{",
"$",
"username",
"=",
"$",
"data",
"[",
"$",
"this",
"->",
"username",
"]",
";",
"$",
"password",
"=",
"$",
"data",
"[",
"$",
"this",
"->",
"password",
"]",
";",
"$",
"autoLogin",
"=",
"isset",
"(",
"$",
"data",
"[",
"'auto_login'",
"]",
")",
"?",
"$",
"data",
"[",
"'auto_login'",
"]",
":",
"!",
"$",
"this",
"->",
"requirePrompt",
";",
"if",
"(",
"$",
"username",
"&&",
"$",
"password",
"&&",
"$",
"autoLogin",
")",
"{",
"$",
"this",
"->",
"write",
"(",
"$",
"username",
",",
"$",
"password",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"autoLogin",
")",
"{",
"$",
"this",
"->",
"delete",
"(",
")",
";",
"}",
"}"
] |
Login the user by storing their information in a cookie.
@param array $data
|
[
"Login",
"the",
"user",
"by",
"storing",
"their",
"information",
"in",
"a",
"cookie",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AutoLoginComponent.php#L243-L254
|
229,706
|
milesj/utility
|
Controller/Component/AutoLoginComponent.php
|
AutoLoginComponent.logout
|
public function logout() {
$this->debug('logout', $this->Cookie, $this->Auth->user());
$this->delete();
}
|
php
|
public function logout() {
$this->debug('logout', $this->Cookie, $this->Auth->user());
$this->delete();
}
|
[
"public",
"function",
"logout",
"(",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'logout'",
",",
"$",
"this",
"->",
"Cookie",
",",
"$",
"this",
"->",
"Auth",
"->",
"user",
"(",
")",
")",
";",
"$",
"this",
"->",
"delete",
"(",
")",
";",
"}"
] |
Logout the user by deleting the cookie.
|
[
"Logout",
"the",
"user",
"by",
"deleting",
"the",
"cookie",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AutoLoginComponent.php#L259-L262
|
229,707
|
milesj/utility
|
Controller/Component/AutoLoginComponent.php
|
AutoLoginComponent.write
|
public function write($username, $password) {
$time = time();
$cookie = array();
$cookie['username'] = base64_encode($username);
$cookie['password'] = base64_encode($password);
$cookie['hash'] = $this->Auth->password($username . $time);
$cookie['time'] = $time;
if (env('REMOTE_ADDR') === '127.0.0.1' || env('HTTP_HOST') === 'localhost') {
$this->Cookie->domain = $this->cookieLocalDomain;
}
$this->Cookie->write($this->cookieName, $cookie, true, $this->expires);
$this->debug('cookieSet', $cookie, $this->Auth->user());
}
|
php
|
public function write($username, $password) {
$time = time();
$cookie = array();
$cookie['username'] = base64_encode($username);
$cookie['password'] = base64_encode($password);
$cookie['hash'] = $this->Auth->password($username . $time);
$cookie['time'] = $time;
if (env('REMOTE_ADDR') === '127.0.0.1' || env('HTTP_HOST') === 'localhost') {
$this->Cookie->domain = $this->cookieLocalDomain;
}
$this->Cookie->write($this->cookieName, $cookie, true, $this->expires);
$this->debug('cookieSet', $cookie, $this->Auth->user());
}
|
[
"public",
"function",
"write",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"cookie",
"=",
"array",
"(",
")",
";",
"$",
"cookie",
"[",
"'username'",
"]",
"=",
"base64_encode",
"(",
"$",
"username",
")",
";",
"$",
"cookie",
"[",
"'password'",
"]",
"=",
"base64_encode",
"(",
"$",
"password",
")",
";",
"$",
"cookie",
"[",
"'hash'",
"]",
"=",
"$",
"this",
"->",
"Auth",
"->",
"password",
"(",
"$",
"username",
".",
"$",
"time",
")",
";",
"$",
"cookie",
"[",
"'time'",
"]",
"=",
"$",
"time",
";",
"if",
"(",
"env",
"(",
"'REMOTE_ADDR'",
")",
"===",
"'127.0.0.1'",
"||",
"env",
"(",
"'HTTP_HOST'",
")",
"===",
"'localhost'",
")",
"{",
"$",
"this",
"->",
"Cookie",
"->",
"domain",
"=",
"$",
"this",
"->",
"cookieLocalDomain",
";",
"}",
"$",
"this",
"->",
"Cookie",
"->",
"write",
"(",
"$",
"this",
"->",
"cookieName",
",",
"$",
"cookie",
",",
"true",
",",
"$",
"this",
"->",
"expires",
")",
";",
"$",
"this",
"->",
"debug",
"(",
"'cookieSet'",
",",
"$",
"cookie",
",",
"$",
"this",
"->",
"Auth",
"->",
"user",
"(",
")",
")",
";",
"}"
] |
Remember the user information.
@param string $username
@param string $password
|
[
"Remember",
"the",
"user",
"information",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AutoLoginComponent.php#L293-L308
|
229,708
|
milesj/utility
|
Controller/Component/AutoLoginComponent.php
|
AutoLoginComponent.debug
|
public function debug($key, $cookie = array(), $user = array()) {
$scopes = array(
'login' => 'Login Successful',
'loginFail' => 'Login Failure',
'loginCallback' => 'Login Callback',
'logout' => 'Logout',
'logoutCallback' => 'Logout Callback',
'cookieSet' => 'Cookie Set',
'cookieFail' => 'Cookie Mismatch',
'hashFail' => 'Hash Mismatch',
'custom' => 'Custom Callback'
);
if ($this->_debug && isset($scopes[$key])) {
$debug = (array) Configure::read('AutoLogin');
$content = "";
if ($cookie || $user) {
if ($cookie) {
$content .= "Cookie information: \n\n" . print_r($cookie, true) . "\n\n\n";
}
if ($user) {
$content .= "User information: \n\n" . print_r($user, true);
}
} else {
$content = 'No debug information.';
}
if (empty($debug['scope']) || in_array($key, (array) $debug['scope'])) {
if (!empty($debug['email'])) {
mail($debug['email'], '[AutoLogin] ' . $scopes[$key], $content, 'From: ' . $debug['email']);
} else {
$this->log($scopes[$key] . ': ' . $content, LOG_DEBUG);
}
}
}
}
|
php
|
public function debug($key, $cookie = array(), $user = array()) {
$scopes = array(
'login' => 'Login Successful',
'loginFail' => 'Login Failure',
'loginCallback' => 'Login Callback',
'logout' => 'Logout',
'logoutCallback' => 'Logout Callback',
'cookieSet' => 'Cookie Set',
'cookieFail' => 'Cookie Mismatch',
'hashFail' => 'Hash Mismatch',
'custom' => 'Custom Callback'
);
if ($this->_debug && isset($scopes[$key])) {
$debug = (array) Configure::read('AutoLogin');
$content = "";
if ($cookie || $user) {
if ($cookie) {
$content .= "Cookie information: \n\n" . print_r($cookie, true) . "\n\n\n";
}
if ($user) {
$content .= "User information: \n\n" . print_r($user, true);
}
} else {
$content = 'No debug information.';
}
if (empty($debug['scope']) || in_array($key, (array) $debug['scope'])) {
if (!empty($debug['email'])) {
mail($debug['email'], '[AutoLogin] ' . $scopes[$key], $content, 'From: ' . $debug['email']);
} else {
$this->log($scopes[$key] . ': ' . $content, LOG_DEBUG);
}
}
}
}
|
[
"public",
"function",
"debug",
"(",
"$",
"key",
",",
"$",
"cookie",
"=",
"array",
"(",
")",
",",
"$",
"user",
"=",
"array",
"(",
")",
")",
"{",
"$",
"scopes",
"=",
"array",
"(",
"'login'",
"=>",
"'Login Successful'",
",",
"'loginFail'",
"=>",
"'Login Failure'",
",",
"'loginCallback'",
"=>",
"'Login Callback'",
",",
"'logout'",
"=>",
"'Logout'",
",",
"'logoutCallback'",
"=>",
"'Logout Callback'",
",",
"'cookieSet'",
"=>",
"'Cookie Set'",
",",
"'cookieFail'",
"=>",
"'Cookie Mismatch'",
",",
"'hashFail'",
"=>",
"'Hash Mismatch'",
",",
"'custom'",
"=>",
"'Custom Callback'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_debug",
"&&",
"isset",
"(",
"$",
"scopes",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"debug",
"=",
"(",
"array",
")",
"Configure",
"::",
"read",
"(",
"'AutoLogin'",
")",
";",
"$",
"content",
"=",
"\"\"",
";",
"if",
"(",
"$",
"cookie",
"||",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"cookie",
")",
"{",
"$",
"content",
".=",
"\"Cookie information: \\n\\n\"",
".",
"print_r",
"(",
"$",
"cookie",
",",
"true",
")",
".",
"\"\\n\\n\\n\"",
";",
"}",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"content",
".=",
"\"User information: \\n\\n\"",
".",
"print_r",
"(",
"$",
"user",
",",
"true",
")",
";",
"}",
"}",
"else",
"{",
"$",
"content",
"=",
"'No debug information.'",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"debug",
"[",
"'scope'",
"]",
")",
"||",
"in_array",
"(",
"$",
"key",
",",
"(",
"array",
")",
"$",
"debug",
"[",
"'scope'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"debug",
"[",
"'email'",
"]",
")",
")",
"{",
"mail",
"(",
"$",
"debug",
"[",
"'email'",
"]",
",",
"'[AutoLogin] '",
".",
"$",
"scopes",
"[",
"$",
"key",
"]",
",",
"$",
"content",
",",
"'From: '",
".",
"$",
"debug",
"[",
"'email'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"scopes",
"[",
"$",
"key",
"]",
".",
"': '",
".",
"$",
"content",
",",
"LOG_DEBUG",
")",
";",
"}",
"}",
"}",
"}"
] |
Debug the current auth and cookies.
@param string $key
@param array $cookie
@param array $user
|
[
"Debug",
"the",
"current",
"auth",
"and",
"cookies",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AutoLoginComponent.php#L324-L361
|
229,709
|
fecshop/yii2-fec
|
lib/PHPExcel/PHPExcel/Writer/HTML.php
|
PHPExcel_Writer_HTML._writeImageInCell
|
private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) {
// Construct HTML
$html = '';
// Write images
foreach ($pSheet->getDrawingCollection() as $drawing) {
if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
if ($drawing->getCoordinates() == $coordinates) {
$filename = $drawing->getPath();
// Strip off eventual '.'
if (substr($filename, 0, 1) == '.') {
$filename = substr($filename, 1);
}
// Prepend images root
$filename = $this->getImagesRoot() . $filename;
// Strip off eventual '.'
if (substr($filename, 0, 1) == '.' && substr($filename, 0, 2) != './') {
$filename = substr($filename, 1);
}
// Convert UTF8 data to PCDATA
$filename = htmlspecialchars($filename);
$html .= PHP_EOL;
if ((!$this->_embedImages) || ($this->_isPdf)) {
$imageData = $filename;
} else {
$imageDetails = getimagesize($filename);
if ($fp = fopen($filename,"rb", 0)) {
$picture = fread($fp,filesize($filename));
fclose($fp);
// base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics
$base64 = chunk_split(base64_encode($picture));
$imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64;
} else {
$imageData = $filename;
}
}
$html .= '<div style="position: relative;">';
$html .= '<img style="position: absolute; z-index: 1; left: ' .
$drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' .
$drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' .
$imageData . '" border="0" />';
$html .= '</div>';
}
}
}
// Return
return $html;
}
|
php
|
private function _writeImageInCell(PHPExcel_Worksheet $pSheet, $coordinates) {
// Construct HTML
$html = '';
// Write images
foreach ($pSheet->getDrawingCollection() as $drawing) {
if ($drawing instanceof PHPExcel_Worksheet_Drawing) {
if ($drawing->getCoordinates() == $coordinates) {
$filename = $drawing->getPath();
// Strip off eventual '.'
if (substr($filename, 0, 1) == '.') {
$filename = substr($filename, 1);
}
// Prepend images root
$filename = $this->getImagesRoot() . $filename;
// Strip off eventual '.'
if (substr($filename, 0, 1) == '.' && substr($filename, 0, 2) != './') {
$filename = substr($filename, 1);
}
// Convert UTF8 data to PCDATA
$filename = htmlspecialchars($filename);
$html .= PHP_EOL;
if ((!$this->_embedImages) || ($this->_isPdf)) {
$imageData = $filename;
} else {
$imageDetails = getimagesize($filename);
if ($fp = fopen($filename,"rb", 0)) {
$picture = fread($fp,filesize($filename));
fclose($fp);
// base64 encode the binary data, then break it
// into chunks according to RFC 2045 semantics
$base64 = chunk_split(base64_encode($picture));
$imageData = 'data:'.$imageDetails['mime'].';base64,' . $base64;
} else {
$imageData = $filename;
}
}
$html .= '<div style="position: relative;">';
$html .= '<img style="position: absolute; z-index: 1; left: ' .
$drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' .
$drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' .
$imageData . '" border="0" />';
$html .= '</div>';
}
}
}
// Return
return $html;
}
|
[
"private",
"function",
"_writeImageInCell",
"(",
"PHPExcel_Worksheet",
"$",
"pSheet",
",",
"$",
"coordinates",
")",
"{",
"// Construct HTML",
"$",
"html",
"=",
"''",
";",
"// Write images",
"foreach",
"(",
"$",
"pSheet",
"->",
"getDrawingCollection",
"(",
")",
"as",
"$",
"drawing",
")",
"{",
"if",
"(",
"$",
"drawing",
"instanceof",
"PHPExcel_Worksheet_Drawing",
")",
"{",
"if",
"(",
"$",
"drawing",
"->",
"getCoordinates",
"(",
")",
"==",
"$",
"coordinates",
")",
"{",
"$",
"filename",
"=",
"$",
"drawing",
"->",
"getPath",
"(",
")",
";",
"// Strip off eventual '.'",
"if",
"(",
"substr",
"(",
"$",
"filename",
",",
"0",
",",
"1",
")",
"==",
"'.'",
")",
"{",
"$",
"filename",
"=",
"substr",
"(",
"$",
"filename",
",",
"1",
")",
";",
"}",
"// Prepend images root",
"$",
"filename",
"=",
"$",
"this",
"->",
"getImagesRoot",
"(",
")",
".",
"$",
"filename",
";",
"// Strip off eventual '.'",
"if",
"(",
"substr",
"(",
"$",
"filename",
",",
"0",
",",
"1",
")",
"==",
"'.'",
"&&",
"substr",
"(",
"$",
"filename",
",",
"0",
",",
"2",
")",
"!=",
"'./'",
")",
"{",
"$",
"filename",
"=",
"substr",
"(",
"$",
"filename",
",",
"1",
")",
";",
"}",
"// Convert UTF8 data to PCDATA",
"$",
"filename",
"=",
"htmlspecialchars",
"(",
"$",
"filename",
")",
";",
"$",
"html",
".=",
"PHP_EOL",
";",
"if",
"(",
"(",
"!",
"$",
"this",
"->",
"_embedImages",
")",
"||",
"(",
"$",
"this",
"->",
"_isPdf",
")",
")",
"{",
"$",
"imageData",
"=",
"$",
"filename",
";",
"}",
"else",
"{",
"$",
"imageDetails",
"=",
"getimagesize",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"filename",
",",
"\"rb\"",
",",
"0",
")",
")",
"{",
"$",
"picture",
"=",
"fread",
"(",
"$",
"fp",
",",
"filesize",
"(",
"$",
"filename",
")",
")",
";",
"fclose",
"(",
"$",
"fp",
")",
";",
"// base64 encode the binary data, then break it",
"// into chunks according to RFC 2045 semantics",
"$",
"base64",
"=",
"chunk_split",
"(",
"base64_encode",
"(",
"$",
"picture",
")",
")",
";",
"$",
"imageData",
"=",
"'data:'",
".",
"$",
"imageDetails",
"[",
"'mime'",
"]",
".",
"';base64,'",
".",
"$",
"base64",
";",
"}",
"else",
"{",
"$",
"imageData",
"=",
"$",
"filename",
";",
"}",
"}",
"$",
"html",
".=",
"'<div style=\"position: relative;\">'",
";",
"$",
"html",
".=",
"'<img style=\"position: absolute; z-index: 1; left: '",
".",
"$",
"drawing",
"->",
"getOffsetX",
"(",
")",
".",
"'px; top: '",
".",
"$",
"drawing",
"->",
"getOffsetY",
"(",
")",
".",
"'px; width: '",
".",
"$",
"drawing",
"->",
"getWidth",
"(",
")",
".",
"'px; height: '",
".",
"$",
"drawing",
"->",
"getHeight",
"(",
")",
".",
"'px;\" src=\"'",
".",
"$",
"imageData",
".",
"'\" border=\"0\" />'",
";",
"$",
"html",
".=",
"'</div>'",
";",
"}",
"}",
"}",
"// Return",
"return",
"$",
"html",
";",
"}"
] |
Generate image tag in cell
@param PHPExcel_Worksheet $pSheet PHPExcel_Worksheet
@param string $coordinates Cell coordinates
@return string
@throws PHPExcel_Writer_Exception
|
[
"Generate",
"image",
"tag",
"in",
"cell"
] |
fda0e381f931bc503e493bec90185162109018e6
|
https://github.com/fecshop/yii2-fec/blob/fda0e381f931bc503e493bec90185162109018e6/lib/PHPExcel/PHPExcel/Writer/HTML.php#L567-L622
|
229,710
|
fuelphp/common
|
src/Pagination.php
|
Pagination.set
|
public function set($var, $value = null)
{
if ( ! is_array($var))
{
$var = array ($var => $value);
}
foreach ($var as $key => $value)
{
$value = $this->validateConfig($key, $value);
if (isset($this->config[$key]))
{
// preserve the type
if (is_bool($this->config[$key]))
{
$this->config[$key] = (bool) $value;
}
elseif (is_string($this->config[$key]))
{
$this->config[$key] = (string) $value;
}
else
{
$this->config[$key] = (int) $value;
}
}
}
}
|
php
|
public function set($var, $value = null)
{
if ( ! is_array($var))
{
$var = array ($var => $value);
}
foreach ($var as $key => $value)
{
$value = $this->validateConfig($key, $value);
if (isset($this->config[$key]))
{
// preserve the type
if (is_bool($this->config[$key]))
{
$this->config[$key] = (bool) $value;
}
elseif (is_string($this->config[$key]))
{
$this->config[$key] = (string) $value;
}
else
{
$this->config[$key] = (int) $value;
}
}
}
}
|
[
"public",
"function",
"set",
"(",
"$",
"var",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"var",
")",
")",
"{",
"$",
"var",
"=",
"array",
"(",
"$",
"var",
"=>",
"$",
"value",
")",
";",
"}",
"foreach",
"(",
"$",
"var",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"validateConfig",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"// preserve the type",
"if",
"(",
"is_bool",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"key",
"]",
"=",
"(",
"int",
")",
"$",
"value",
";",
"}",
"}",
"}",
"}"
] |
Setter for configuration items
|
[
"Setter",
"for",
"configuration",
"items"
] |
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
|
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Pagination.php#L106-L134
|
229,711
|
fuelphp/common
|
src/Pagination.php
|
Pagination.render
|
public function render()
{
// make sure we have a correct url
$this->paginationUrl();
// and a current page number
$this->calculateNumbers();
$urls = array();
// generate the URL's for the pagination block
if ($this->config['totalPages'] > 1)
{
// calculate start- and end page numbers
$start = $this->config['current'] - floor($this->config['numberOfLinks'] * $this->config['linkOffset']);
$end = $this->config['current'] + floor($this->config['numberOfLinks'] * ( 1 - $this->config['linkOffset']));
// adjust for the first few pages
if ($start < 1)
{
$end -= $start - 1;
$start = 1;
}
// make sure we don't overshoot the current page due to rounding issues
if ($end < $this->config['current'])
{
$start++;
$end++;
}
// make sure we don't overshoot the total
if ($end > $this->config['totalPages'])
{
$start = max(1, $start - $end + $this->config['totalPages']);
$end = $this->config['totalPages'];
}
// now generate the URL's for the pagination block
for($i = $start; $i <= $end; $i++)
{
$urls[$i] = $this->generateUrl($i);
}
}
// send the generated url's to the view
$this->view->set('urls', $urls);
// store the current and total pages
$this->view->set('active', $this->config['current']);
$this->view->set('total', $this->config['totalPages']);
// do we need to add a first link?
if ($this->config['showFirst'])
{
$this->view->set('first', $this->generateUrl(1));
}
if (isset($start) and $start > 1)
{
$this->view->set('previous', $this->generateUrl($start-1));
}
if (isset($end) and $end !== $this->config['totalPages'])
{
$this->view->set('next', $this->generateUrl($end+1));
}
// do we need to add a last link?
if ($this->config['showLast'])
{
$this->view->set('last', $this->generateUrl($this->config['totalPages']));
}
$this->view->set('align', $this->config['align']);
// return the view
return $this->view;
}
|
php
|
public function render()
{
// make sure we have a correct url
$this->paginationUrl();
// and a current page number
$this->calculateNumbers();
$urls = array();
// generate the URL's for the pagination block
if ($this->config['totalPages'] > 1)
{
// calculate start- and end page numbers
$start = $this->config['current'] - floor($this->config['numberOfLinks'] * $this->config['linkOffset']);
$end = $this->config['current'] + floor($this->config['numberOfLinks'] * ( 1 - $this->config['linkOffset']));
// adjust for the first few pages
if ($start < 1)
{
$end -= $start - 1;
$start = 1;
}
// make sure we don't overshoot the current page due to rounding issues
if ($end < $this->config['current'])
{
$start++;
$end++;
}
// make sure we don't overshoot the total
if ($end > $this->config['totalPages'])
{
$start = max(1, $start - $end + $this->config['totalPages']);
$end = $this->config['totalPages'];
}
// now generate the URL's for the pagination block
for($i = $start; $i <= $end; $i++)
{
$urls[$i] = $this->generateUrl($i);
}
}
// send the generated url's to the view
$this->view->set('urls', $urls);
// store the current and total pages
$this->view->set('active', $this->config['current']);
$this->view->set('total', $this->config['totalPages']);
// do we need to add a first link?
if ($this->config['showFirst'])
{
$this->view->set('first', $this->generateUrl(1));
}
if (isset($start) and $start > 1)
{
$this->view->set('previous', $this->generateUrl($start-1));
}
if (isset($end) and $end !== $this->config['totalPages'])
{
$this->view->set('next', $this->generateUrl($end+1));
}
// do we need to add a last link?
if ($this->config['showLast'])
{
$this->view->set('last', $this->generateUrl($this->config['totalPages']));
}
$this->view->set('align', $this->config['align']);
// return the view
return $this->view;
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"// make sure we have a correct url",
"$",
"this",
"->",
"paginationUrl",
"(",
")",
";",
"// and a current page number",
"$",
"this",
"->",
"calculateNumbers",
"(",
")",
";",
"$",
"urls",
"=",
"array",
"(",
")",
";",
"// generate the URL's for the pagination block",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
">",
"1",
")",
"{",
"// calculate start- and end page numbers",
"$",
"start",
"=",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
"-",
"floor",
"(",
"$",
"this",
"->",
"config",
"[",
"'numberOfLinks'",
"]",
"*",
"$",
"this",
"->",
"config",
"[",
"'linkOffset'",
"]",
")",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
"+",
"floor",
"(",
"$",
"this",
"->",
"config",
"[",
"'numberOfLinks'",
"]",
"*",
"(",
"1",
"-",
"$",
"this",
"->",
"config",
"[",
"'linkOffset'",
"]",
")",
")",
";",
"// adjust for the first few pages",
"if",
"(",
"$",
"start",
"<",
"1",
")",
"{",
"$",
"end",
"-=",
"$",
"start",
"-",
"1",
";",
"$",
"start",
"=",
"1",
";",
"}",
"// make sure we don't overshoot the current page due to rounding issues",
"if",
"(",
"$",
"end",
"<",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
")",
"{",
"$",
"start",
"++",
";",
"$",
"end",
"++",
";",
"}",
"// make sure we don't overshoot the total",
"if",
"(",
"$",
"end",
">",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
")",
"{",
"$",
"start",
"=",
"max",
"(",
"1",
",",
"$",
"start",
"-",
"$",
"end",
"+",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
")",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
";",
"}",
"// now generate the URL's for the pagination block",
"for",
"(",
"$",
"i",
"=",
"$",
"start",
";",
"$",
"i",
"<=",
"$",
"end",
";",
"$",
"i",
"++",
")",
"{",
"$",
"urls",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"i",
")",
";",
"}",
"}",
"// send the generated url's to the view",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'urls'",
",",
"$",
"urls",
")",
";",
"// store the current and total pages",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'active'",
",",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
")",
";",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'total'",
",",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
")",
";",
"// do we need to add a first link?",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'showFirst'",
"]",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'first'",
",",
"$",
"this",
"->",
"generateUrl",
"(",
"1",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"start",
")",
"and",
"$",
"start",
">",
"1",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'previous'",
",",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"start",
"-",
"1",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"end",
")",
"and",
"$",
"end",
"!==",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'next'",
",",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"end",
"+",
"1",
")",
")",
";",
"}",
"// do we need to add a last link?",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'showLast'",
"]",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'last'",
",",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"view",
"->",
"set",
"(",
"'align'",
",",
"$",
"this",
"->",
"config",
"[",
"'align'",
"]",
")",
";",
"// return the view",
"return",
"$",
"this",
"->",
"view",
";",
"}"
] |
Render the pagination view, and return the view
@return View the configured view object
|
[
"Render",
"the",
"pagination",
"view",
"and",
"return",
"the",
"view"
] |
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
|
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Pagination.php#L151-L229
|
229,712
|
fuelphp/common
|
src/Pagination.php
|
Pagination.paginationUrl
|
protected function paginationUrl()
{
// if we have one, don't bother
if ( ! empty($this->paginationUrl))
{
return;
}
// do we have any GET variables?
$get = $this->input->getQuery();
// do we need to set one
if ( ! empty($this->config['getVariable']))
{
// don't use curly braces here, http_build_query will encode them
$get[$this->config['getVariable']] = '___PAGE___';
}
// do we need to create a segment?
if ( ! empty($this->config['uriSegment']))
{
$segments = explode('/', trim($this->input->getPathInfo(),'/'));
$segments[$this->config['uriSegment']] = '{page}';
// construct the Uri
$this->paginationUrl = '/'.implode('/', $segments);
}
else
{
// start with the current Uri
$this->paginationUrl = $this->input->getPathInfo();
}
// attach the extension if needed
$this->paginationUrl .= $this->input->getExtension();
// any get variables?
if ( ! empty($get))
{
$this->paginationUrl .= '?'.str_replace('___PAGE___', '{page}', http_build_query($get->getContents()));
}
}
|
php
|
protected function paginationUrl()
{
// if we have one, don't bother
if ( ! empty($this->paginationUrl))
{
return;
}
// do we have any GET variables?
$get = $this->input->getQuery();
// do we need to set one
if ( ! empty($this->config['getVariable']))
{
// don't use curly braces here, http_build_query will encode them
$get[$this->config['getVariable']] = '___PAGE___';
}
// do we need to create a segment?
if ( ! empty($this->config['uriSegment']))
{
$segments = explode('/', trim($this->input->getPathInfo(),'/'));
$segments[$this->config['uriSegment']] = '{page}';
// construct the Uri
$this->paginationUrl = '/'.implode('/', $segments);
}
else
{
// start with the current Uri
$this->paginationUrl = $this->input->getPathInfo();
}
// attach the extension if needed
$this->paginationUrl .= $this->input->getExtension();
// any get variables?
if ( ! empty($get))
{
$this->paginationUrl .= '?'.str_replace('___PAGE___', '{page}', http_build_query($get->getContents()));
}
}
|
[
"protected",
"function",
"paginationUrl",
"(",
")",
"{",
"// if we have one, don't bother",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"paginationUrl",
")",
")",
"{",
"return",
";",
"}",
"// do we have any GET variables?",
"$",
"get",
"=",
"$",
"this",
"->",
"input",
"->",
"getQuery",
"(",
")",
";",
"// do we need to set one",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'getVariable'",
"]",
")",
")",
"{",
"// don't use curly braces here, http_build_query will encode them",
"$",
"get",
"[",
"$",
"this",
"->",
"config",
"[",
"'getVariable'",
"]",
"]",
"=",
"'___PAGE___'",
";",
"}",
"// do we need to create a segment?",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
")",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"this",
"->",
"input",
"->",
"getPathInfo",
"(",
")",
",",
"'/'",
")",
")",
";",
"$",
"segments",
"[",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
"]",
"=",
"'{page}'",
";",
"// construct the Uri",
"$",
"this",
"->",
"paginationUrl",
"=",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"$",
"segments",
")",
";",
"}",
"else",
"{",
"// start with the current Uri",
"$",
"this",
"->",
"paginationUrl",
"=",
"$",
"this",
"->",
"input",
"->",
"getPathInfo",
"(",
")",
";",
"}",
"// attach the extension if needed",
"$",
"this",
"->",
"paginationUrl",
".=",
"$",
"this",
"->",
"input",
"->",
"getExtension",
"(",
")",
";",
"// any get variables?",
"if",
"(",
"!",
"empty",
"(",
"$",
"get",
")",
")",
"{",
"$",
"this",
"->",
"paginationUrl",
".=",
"'?'",
".",
"str_replace",
"(",
"'___PAGE___'",
",",
"'{page}'",
",",
"http_build_query",
"(",
"$",
"get",
"->",
"getContents",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Construct the pagination Url from the current Url and the configuration set
|
[
"Construct",
"the",
"pagination",
"Url",
"from",
"the",
"current",
"Url",
"and",
"the",
"configuration",
"set"
] |
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
|
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Pagination.php#L246-L287
|
229,713
|
fuelphp/common
|
src/Pagination.php
|
Pagination.calculateNumbers
|
protected function calculateNumbers()
{
// do we need to fetch or calculate the current page number?
if (empty($this->config['current']))
{
// do we have a segment number?
if ( ! empty($this->config['uriSegment']))
{
$segments = explode('/', trim($this->input->getPathInfo(),'/'));
if (isset($segments[$this->config['uriSegment']]) and is_numeric($segments[$this->config['uriSegment']]))
{
$this->config['current'] = $segments[$this->config['uriSegment']];
}
}
// do we have a getVariable set?
if ( ! empty($this->config['getVariable']) and $get = $this->input->getQuery())
{
if (isset($get[$this->config['getVariable']]) and is_numeric($get[$this->config['getVariable']]))
{
$this->config['current'] = $get[$this->config['uriSegment']];
}
}
// if none could be determine, try to calculate it
if (empty($this->config['current']) and $this->config['offset'] and $this->config['limit'])
{
$this->config['current'] = (int) ($this->config['offset'] / $this->config['limit']) + 1;
}
// if all else fails, default to one
if (empty($this->config['current']))
{
$this->config['current'] = 1;
}
}
// do we need to calculate the total number of pages
if (empty($this->config['totalPages']) and ! empty($this->config['totalItems']) and ! empty($this->config['limit']))
{
$this->config['totalPages'] = (int) ($this->config['totalItems'] / $this->config['limit']) + 1;
}
}
|
php
|
protected function calculateNumbers()
{
// do we need to fetch or calculate the current page number?
if (empty($this->config['current']))
{
// do we have a segment number?
if ( ! empty($this->config['uriSegment']))
{
$segments = explode('/', trim($this->input->getPathInfo(),'/'));
if (isset($segments[$this->config['uriSegment']]) and is_numeric($segments[$this->config['uriSegment']]))
{
$this->config['current'] = $segments[$this->config['uriSegment']];
}
}
// do we have a getVariable set?
if ( ! empty($this->config['getVariable']) and $get = $this->input->getQuery())
{
if (isset($get[$this->config['getVariable']]) and is_numeric($get[$this->config['getVariable']]))
{
$this->config['current'] = $get[$this->config['uriSegment']];
}
}
// if none could be determine, try to calculate it
if (empty($this->config['current']) and $this->config['offset'] and $this->config['limit'])
{
$this->config['current'] = (int) ($this->config['offset'] / $this->config['limit']) + 1;
}
// if all else fails, default to one
if (empty($this->config['current']))
{
$this->config['current'] = 1;
}
}
// do we need to calculate the total number of pages
if (empty($this->config['totalPages']) and ! empty($this->config['totalItems']) and ! empty($this->config['limit']))
{
$this->config['totalPages'] = (int) ($this->config['totalItems'] / $this->config['limit']) + 1;
}
}
|
[
"protected",
"function",
"calculateNumbers",
"(",
")",
"{",
"// do we need to fetch or calculate the current page number?",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
")",
")",
"{",
"// do we have a segment number?",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
")",
")",
"{",
"$",
"segments",
"=",
"explode",
"(",
"'/'",
",",
"trim",
"(",
"$",
"this",
"->",
"input",
"->",
"getPathInfo",
"(",
")",
",",
"'/'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"segments",
"[",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
"]",
")",
"and",
"is_numeric",
"(",
"$",
"segments",
"[",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
"=",
"$",
"segments",
"[",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
"]",
";",
"}",
"}",
"// do we have a getVariable set?",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'getVariable'",
"]",
")",
"and",
"$",
"get",
"=",
"$",
"this",
"->",
"input",
"->",
"getQuery",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"get",
"[",
"$",
"this",
"->",
"config",
"[",
"'getVariable'",
"]",
"]",
")",
"and",
"is_numeric",
"(",
"$",
"get",
"[",
"$",
"this",
"->",
"config",
"[",
"'getVariable'",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
"=",
"$",
"get",
"[",
"$",
"this",
"->",
"config",
"[",
"'uriSegment'",
"]",
"]",
";",
"}",
"}",
"// if none could be determine, try to calculate it",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
")",
"and",
"$",
"this",
"->",
"config",
"[",
"'offset'",
"]",
"and",
"$",
"this",
"->",
"config",
"[",
"'limit'",
"]",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
"=",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"config",
"[",
"'offset'",
"]",
"/",
"$",
"this",
"->",
"config",
"[",
"'limit'",
"]",
")",
"+",
"1",
";",
"}",
"// if all else fails, default to one",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'current'",
"]",
"=",
"1",
";",
"}",
"}",
"// do we need to calculate the total number of pages",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
")",
"and",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'totalItems'",
"]",
")",
"and",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'limit'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'totalPages'",
"]",
"=",
"(",
"int",
")",
"(",
"$",
"this",
"->",
"config",
"[",
"'totalItems'",
"]",
"/",
"$",
"this",
"->",
"config",
"[",
"'limit'",
"]",
")",
"+",
"1",
";",
"}",
"}"
] |
If no current page number is given, calculate it
|
[
"If",
"no",
"current",
"page",
"number",
"is",
"given",
"calculate",
"it"
] |
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
|
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Pagination.php#L292-L334
|
229,714
|
netgen/NetgenOpenGraphBundle
|
bundle/DependencyInjection/Compiler/MetaTagHandlersCompilerPass.php
|
MetaTagHandlersCompilerPass.process
|
public function process(ContainerBuilder $container)
{
$metaTagHandlers = $container->findTaggedServiceIds('netgen_open_graph.meta_tag_handler');
if (!empty($metaTagHandlers) && $container->hasDefinition('netgen_open_graph.handler_registry')) {
$handlerRegistry = $container->getDefinition('netgen_open_graph.handler_registry');
foreach ($metaTagHandlers as $serviceId => $metaTagHandler) {
if (!isset($metaTagHandler[0]['alias'])) {
throw new LogicException(
'netgen_open_graph.meta_tag_handler service tag needs an "alias" attribute to identify the handler. None given.'
);
}
$handlerRegistry->addMethodCall(
'addHandler',
array(
$metaTagHandler[0]['alias'],
new Reference($serviceId),
)
);
}
}
}
|
php
|
public function process(ContainerBuilder $container)
{
$metaTagHandlers = $container->findTaggedServiceIds('netgen_open_graph.meta_tag_handler');
if (!empty($metaTagHandlers) && $container->hasDefinition('netgen_open_graph.handler_registry')) {
$handlerRegistry = $container->getDefinition('netgen_open_graph.handler_registry');
foreach ($metaTagHandlers as $serviceId => $metaTagHandler) {
if (!isset($metaTagHandler[0]['alias'])) {
throw new LogicException(
'netgen_open_graph.meta_tag_handler service tag needs an "alias" attribute to identify the handler. None given.'
);
}
$handlerRegistry->addMethodCall(
'addHandler',
array(
$metaTagHandler[0]['alias'],
new Reference($serviceId),
)
);
}
}
}
|
[
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"metaTagHandlers",
"=",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'netgen_open_graph.meta_tag_handler'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"metaTagHandlers",
")",
"&&",
"$",
"container",
"->",
"hasDefinition",
"(",
"'netgen_open_graph.handler_registry'",
")",
")",
"{",
"$",
"handlerRegistry",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'netgen_open_graph.handler_registry'",
")",
";",
"foreach",
"(",
"$",
"metaTagHandlers",
"as",
"$",
"serviceId",
"=>",
"$",
"metaTagHandler",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"metaTagHandler",
"[",
"0",
"]",
"[",
"'alias'",
"]",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'netgen_open_graph.meta_tag_handler service tag needs an \"alias\" attribute to identify the handler. None given.'",
")",
";",
"}",
"$",
"handlerRegistry",
"->",
"addMethodCall",
"(",
"'addHandler'",
",",
"array",
"(",
"$",
"metaTagHandler",
"[",
"0",
"]",
"[",
"'alias'",
"]",
",",
"new",
"Reference",
"(",
"$",
"serviceId",
")",
",",
")",
")",
";",
"}",
"}",
"}"
] |
Adds all registered meta tag handlers to the registry.
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container
|
[
"Adds",
"all",
"registered",
"meta",
"tag",
"handlers",
"to",
"the",
"registry",
"."
] |
fcaad267742492cfa4049adbf075343c262c4767
|
https://github.com/netgen/NetgenOpenGraphBundle/blob/fcaad267742492cfa4049adbf075343c262c4767/bundle/DependencyInjection/Compiler/MetaTagHandlersCompilerPass.php#L17-L37
|
229,715
|
fuelphp/common
|
src/Cookie.php
|
Cookie.send
|
public function send()
{
$result = true;
if ($this->isNew)
{
// make this cookie as used
$this->isNew = false;
// set the cookie
$result = $this->wrapper->setcookie($this->name, $this->value, $this->config['expiration'], $this->config['path'], $this->config['domain'], $this->config['secure'], $this->config['http_only']);
// mark the cookie as sent
if ($result)
{
$this->isSent = true;
}
}
elseif ($this->isDeleted)
{
// delete the cookie by nullifying and expiring it
$result = $this->wrapper->setcookie($this->name, null, -86400, $this->config['path'], $this->config['domain'], $this->config['secure'], $this->config['http_only']);
// mark the cookie as sent
if ($result)
{
$this->isSent = true;
}
}
return $result;
}
|
php
|
public function send()
{
$result = true;
if ($this->isNew)
{
// make this cookie as used
$this->isNew = false;
// set the cookie
$result = $this->wrapper->setcookie($this->name, $this->value, $this->config['expiration'], $this->config['path'], $this->config['domain'], $this->config['secure'], $this->config['http_only']);
// mark the cookie as sent
if ($result)
{
$this->isSent = true;
}
}
elseif ($this->isDeleted)
{
// delete the cookie by nullifying and expiring it
$result = $this->wrapper->setcookie($this->name, null, -86400, $this->config['path'], $this->config['domain'], $this->config['secure'], $this->config['http_only']);
// mark the cookie as sent
if ($result)
{
$this->isSent = true;
}
}
return $result;
}
|
[
"public",
"function",
"send",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"isNew",
")",
"{",
"// make this cookie as used",
"$",
"this",
"->",
"isNew",
"=",
"false",
";",
"// set the cookie",
"$",
"result",
"=",
"$",
"this",
"->",
"wrapper",
"->",
"setcookie",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"value",
",",
"$",
"this",
"->",
"config",
"[",
"'expiration'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'path'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'domain'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'secure'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'http_only'",
"]",
")",
";",
"// mark the cookie as sent",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"isSent",
"=",
"true",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isDeleted",
")",
"{",
"// delete the cookie by nullifying and expiring it",
"$",
"result",
"=",
"$",
"this",
"->",
"wrapper",
"->",
"setcookie",
"(",
"$",
"this",
"->",
"name",
",",
"null",
",",
"-",
"86400",
",",
"$",
"this",
"->",
"config",
"[",
"'path'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'domain'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'secure'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'http_only'",
"]",
")",
";",
"// mark the cookie as sent",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"isSent",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Send this cookie to the client
@return bool
@since 2.0.0
|
[
"Send",
"this",
"cookie",
"to",
"the",
"client"
] |
ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40
|
https://github.com/fuelphp/common/blob/ddb6b9ced050f1ae7b22326d9c8c32b0dabdbf40/src/Cookie.php#L184-L215
|
229,716
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.beforeSave
|
public function beforeSave(Model $model, $options = array()) {
$model->data = $this->convert($model, $model->data, self::TO);
return true;
}
|
php
|
public function beforeSave(Model $model, $options = array()) {
$model->data = $this->convert($model, $model->data, self::TO);
return true;
}
|
[
"public",
"function",
"beforeSave",
"(",
"Model",
"$",
"model",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"model",
"->",
"data",
"=",
"$",
"this",
"->",
"convert",
"(",
"$",
"model",
",",
"$",
"model",
"->",
"data",
",",
"self",
"::",
"TO",
")",
";",
"return",
"true",
";",
"}"
] |
Run the converter before an insert or update query.
@param Model $model
@param array $options
@return bool|mixed
|
[
"Run",
"the",
"converter",
"before",
"an",
"insert",
"or",
"update",
"query",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L100-L104
|
229,717
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.afterFind
|
public function afterFind(Model $model, $results, $primary = true) {
if ($results) {
foreach ($results as $index => $result) {
$results[$index] = $this->convert($model, $result, self::FROM);
}
}
return $results;
}
|
php
|
public function afterFind(Model $model, $results, $primary = true) {
if ($results) {
foreach ($results as $index => $result) {
$results[$index] = $this->convert($model, $result, self::FROM);
}
}
return $results;
}
|
[
"public",
"function",
"afterFind",
"(",
"Model",
"$",
"model",
",",
"$",
"results",
",",
"$",
"primary",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"results",
")",
"{",
"foreach",
"(",
"$",
"results",
"as",
"$",
"index",
"=>",
"$",
"result",
")",
"{",
"$",
"results",
"[",
"$",
"index",
"]",
"=",
"$",
"this",
"->",
"convert",
"(",
"$",
"model",
",",
"$",
"result",
",",
"self",
"::",
"FROM",
")",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] |
Run the converter after a find query.
@param Model $model
@param mixed $results
@param bool $primary
@return array|mixed
|
[
"Run",
"the",
"converter",
"after",
"a",
"find",
"query",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L114-L122
|
229,718
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.convert
|
public function convert(Model $model, $data, $mode) {
if (empty($data[$model->alias])) {
return $data;
}
foreach ($data[$model->alias] as $key => $value) {
if (isset($this->settings[$model->alias][$key])) {
$converter = $this->settings[$model->alias][$key];
if (method_exists($model, $converter['engine'])) {
$function = array($model, $converter['engine']);
} else if (method_exists($this, $converter['engine'])) {
$function = array($this, $converter['engine']);
}
if (isset($function)) {
if (is_array($value) && $converter['flatten']) {
$value = (string) $value;
}
$data[$model->alias][$key] = call_user_func_array($function, array($value, $converter, $mode));
}
}
}
return $data;
}
|
php
|
public function convert(Model $model, $data, $mode) {
if (empty($data[$model->alias])) {
return $data;
}
foreach ($data[$model->alias] as $key => $value) {
if (isset($this->settings[$model->alias][$key])) {
$converter = $this->settings[$model->alias][$key];
if (method_exists($model, $converter['engine'])) {
$function = array($model, $converter['engine']);
} else if (method_exists($this, $converter['engine'])) {
$function = array($this, $converter['engine']);
}
if (isset($function)) {
if (is_array($value) && $converter['flatten']) {
$value = (string) $value;
}
$data[$model->alias][$key] = call_user_func_array($function, array($value, $converter, $mode));
}
}
}
return $data;
}
|
[
"public",
"function",
"convert",
"(",
"Model",
"$",
"model",
",",
"$",
"data",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"$",
"model",
"->",
"alias",
"]",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"foreach",
"(",
"$",
"data",
"[",
"$",
"model",
"->",
"alias",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"settings",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"converter",
"=",
"$",
"this",
"->",
"settings",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"$",
"key",
"]",
";",
"if",
"(",
"method_exists",
"(",
"$",
"model",
",",
"$",
"converter",
"[",
"'engine'",
"]",
")",
")",
"{",
"$",
"function",
"=",
"array",
"(",
"$",
"model",
",",
"$",
"converter",
"[",
"'engine'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"converter",
"[",
"'engine'",
"]",
")",
")",
"{",
"$",
"function",
"=",
"array",
"(",
"$",
"this",
",",
"$",
"converter",
"[",
"'engine'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"function",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"$",
"converter",
"[",
"'flatten'",
"]",
")",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"$",
"data",
"[",
"$",
"model",
"->",
"alias",
"]",
"[",
"$",
"key",
"]",
"=",
"call_user_func_array",
"(",
"$",
"function",
",",
"array",
"(",
"$",
"value",
",",
"$",
"converter",
",",
"$",
"mode",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Loop through the data and run the correct converter engine on the associated field.
@param Model $model
@param array $data
@param int $mode
@return mixed
|
[
"Loop",
"through",
"the",
"data",
"and",
"run",
"the",
"correct",
"converter",
"engine",
"on",
"the",
"associated",
"field",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L132-L158
|
229,719
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.serialize
|
public function serialize($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return serialize($value);
}
if ($mode === self::FROM && $options['decode']) {
return @unserialize($value);
}
return $value;
}
|
php
|
public function serialize($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return serialize($value);
}
if ($mode === self::FROM && $options['decode']) {
return @unserialize($value);
}
return $value;
}
|
[
"public",
"function",
"serialize",
"(",
"$",
"value",
",",
"array",
"$",
"options",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"TO",
"&&",
"$",
"options",
"[",
"'encode'",
"]",
")",
"{",
"return",
"serialize",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"FROM",
"&&",
"$",
"options",
"[",
"'decode'",
"]",
")",
"{",
"return",
"@",
"unserialize",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Convert between serialized and unserialized arrays.
@param string $value
@param array $options
@param int $mode
@return string
|
[
"Convert",
"between",
"serialized",
"and",
"unserialized",
"arrays",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L168-L178
|
229,720
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.json
|
public function json($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return json_encode($value);
}
if ($mode === self::FROM && $options['decode']) {
return json_decode($value, !$options['object']);
}
return $value;
}
|
php
|
public function json($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return json_encode($value);
}
if ($mode === self::FROM && $options['decode']) {
return json_decode($value, !$options['object']);
}
return $value;
}
|
[
"public",
"function",
"json",
"(",
"$",
"value",
",",
"array",
"$",
"options",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"TO",
"&&",
"$",
"options",
"[",
"'encode'",
"]",
")",
"{",
"return",
"json_encode",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"FROM",
"&&",
"$",
"options",
"[",
"'decode'",
"]",
")",
"{",
"return",
"json_decode",
"(",
"$",
"value",
",",
"!",
"$",
"options",
"[",
"'object'",
"]",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Convert between JSON and array types.
@param string $value
@param array $options
@param int $mode
@return string
|
[
"Convert",
"between",
"JSON",
"and",
"array",
"types",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L188-L198
|
229,721
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.html
|
public function html($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return htmlentities($value, $options['flags'], $options['encoding']);
}
if ($mode === self::FROM && $options['decode']) {
return html_entity_decode($value, $options['flags'], $options['encoding']);
}
return $value;
}
|
php
|
public function html($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return htmlentities($value, $options['flags'], $options['encoding']);
}
if ($mode === self::FROM && $options['decode']) {
return html_entity_decode($value, $options['flags'], $options['encoding']);
}
return $value;
}
|
[
"public",
"function",
"html",
"(",
"$",
"value",
",",
"array",
"$",
"options",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"TO",
"&&",
"$",
"options",
"[",
"'encode'",
"]",
")",
"{",
"return",
"htmlentities",
"(",
"$",
"value",
",",
"$",
"options",
"[",
"'flags'",
"]",
",",
"$",
"options",
"[",
"'encoding'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"FROM",
"&&",
"$",
"options",
"[",
"'decode'",
"]",
")",
"{",
"return",
"html_entity_decode",
"(",
"$",
"value",
",",
"$",
"options",
"[",
"'flags'",
"]",
",",
"$",
"options",
"[",
"'encoding'",
"]",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Convert between HTML entities and raw value.
@param string $value
@param array $options
@param int $mode
@return string
|
[
"Convert",
"between",
"HTML",
"entities",
"and",
"raw",
"value",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L208-L218
|
229,722
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.base64
|
public function base64($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return base64_encode($value);
}
if ($mode === self::FROM && $options['decode']) {
return base64_decode($value);
}
return $value;
}
|
php
|
public function base64($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return base64_encode($value);
}
if ($mode === self::FROM && $options['decode']) {
return base64_decode($value);
}
return $value;
}
|
[
"public",
"function",
"base64",
"(",
"$",
"value",
",",
"array",
"$",
"options",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"TO",
"&&",
"$",
"options",
"[",
"'encode'",
"]",
")",
"{",
"return",
"base64_encode",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"FROM",
"&&",
"$",
"options",
"[",
"'decode'",
"]",
")",
"{",
"return",
"base64_decode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Convert between base64 encoding and raw value.
@param string $value
@param array $options
@param int $mode
@return string
|
[
"Convert",
"between",
"base64",
"encoding",
"and",
"raw",
"value",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L228-L238
|
229,723
|
milesj/utility
|
Model/Behavior/ConvertableBehavior.php
|
ConvertableBehavior.utf8
|
public function utf8($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return utf8_encode($value);
}
if ($mode === self::FROM && $options['decode']) {
return utf8_decode($value);
}
return $value;
}
|
php
|
public function utf8($value, array $options, $mode) {
if ($mode === self::TO && $options['encode']) {
return utf8_encode($value);
}
if ($mode === self::FROM && $options['decode']) {
return utf8_decode($value);
}
return $value;
}
|
[
"public",
"function",
"utf8",
"(",
"$",
"value",
",",
"array",
"$",
"options",
",",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"TO",
"&&",
"$",
"options",
"[",
"'encode'",
"]",
")",
"{",
"return",
"utf8_encode",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"mode",
"===",
"self",
"::",
"FROM",
"&&",
"$",
"options",
"[",
"'decode'",
"]",
")",
"{",
"return",
"utf8_decode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Convert between UTF-8 encoded and non-encoded strings.
@param string $value
@param array $options
@param int $mode
@return string
|
[
"Convert",
"between",
"UTF",
"-",
"8",
"encoded",
"and",
"non",
"-",
"encoded",
"strings",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Model/Behavior/ConvertableBehavior.php#L288-L298
|
229,724
|
chadicus/marvel-api-client
|
src/Cache/ArrayCache.php
|
ArrayCache.getExpiration
|
private function getExpiration($ttl) : int
{
if ($ttl === null) {
return PHP_INT_MAX;
}
if (is_int($ttl)) {
return time() + $ttl;
}
return (new DateTime())->add($ttl)->getTimestamp();
}
|
php
|
private function getExpiration($ttl) : int
{
if ($ttl === null) {
return PHP_INT_MAX;
}
if (is_int($ttl)) {
return time() + $ttl;
}
return (new DateTime())->add($ttl)->getTimestamp();
}
|
[
"private",
"function",
"getExpiration",
"(",
"$",
"ttl",
")",
":",
"int",
"{",
"if",
"(",
"$",
"ttl",
"===",
"null",
")",
"{",
"return",
"PHP_INT_MAX",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"ttl",
")",
")",
"{",
"return",
"time",
"(",
")",
"+",
"$",
"ttl",
";",
"}",
"return",
"(",
"new",
"DateTime",
"(",
")",
")",
"->",
"add",
"(",
"$",
"ttl",
")",
"->",
"getTimestamp",
"(",
")",
";",
"}"
] |
Converts the given time to live value to a DataTime instance;
@param mixed $ttl The time-to-live value to validate.
@return integer
|
[
"Converts",
"the",
"given",
"time",
"to",
"live",
"value",
"to",
"a",
"DataTime",
"instance",
";"
] |
a27729f070c0a3f14b2d2df3a3961590e2d59cb2
|
https://github.com/chadicus/marvel-api-client/blob/a27729f070c0a3f14b2d2df3a3961590e2d59cb2/src/Cache/ArrayCache.php#L187-L198
|
229,725
|
softark/creole
|
block/RawHtmlTrait.php
|
RawHtmlTrait.renderRawHtml
|
protected function renderRawHtml($block)
{
$output = $block['content'];
if (is_callable($this->rawHtmlFilter, true)) {
$output = call_user_func($this->rawHtmlFilter, $output);
}
return $output . "\n";
}
|
php
|
protected function renderRawHtml($block)
{
$output = $block['content'];
if (is_callable($this->rawHtmlFilter, true)) {
$output = call_user_func($this->rawHtmlFilter, $output);
}
return $output . "\n";
}
|
[
"protected",
"function",
"renderRawHtml",
"(",
"$",
"block",
")",
"{",
"$",
"output",
"=",
"$",
"block",
"[",
"'content'",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"rawHtmlFilter",
",",
"true",
")",
")",
"{",
"$",
"output",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"rawHtmlFilter",
",",
"$",
"output",
")",
";",
"}",
"return",
"$",
"output",
".",
"\"\\n\"",
";",
"}"
] |
Renders a raw html block
|
[
"Renders",
"a",
"raw",
"html",
"block"
] |
f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b
|
https://github.com/softark/creole/blob/f56f267e46fa45df1fab01f5d9f1c2bfb0394a9b/block/RawHtmlTrait.php#L60-L67
|
229,726
|
gridonic/hapi
|
src/Harvest/Model/Timer.php
|
Timer.parseXml
|
public function parseXml($node)
{
foreach ($node->childNodes as $item) {
switch ($item->nodeName) {
case "day_entry":
$this->_dayEntry = new DayEntry();
$this->_dayEntry->parseXml( $node );
break;
case "hours_for_previously_running_timer":
$this->_hoursForPrevious = $item->nodeValue;
break;
default:
break;
}
}
}
|
php
|
public function parseXml($node)
{
foreach ($node->childNodes as $item) {
switch ($item->nodeName) {
case "day_entry":
$this->_dayEntry = new DayEntry();
$this->_dayEntry->parseXml( $node );
break;
case "hours_for_previously_running_timer":
$this->_hoursForPrevious = $item->nodeValue;
break;
default:
break;
}
}
}
|
[
"public",
"function",
"parseXml",
"(",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"item",
")",
"{",
"switch",
"(",
"$",
"item",
"->",
"nodeName",
")",
"{",
"case",
"\"day_entry\"",
":",
"$",
"this",
"->",
"_dayEntry",
"=",
"new",
"DayEntry",
"(",
")",
";",
"$",
"this",
"->",
"_dayEntry",
"->",
"parseXml",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"\"hours_for_previously_running_timer\"",
":",
"$",
"this",
"->",
"_hoursForPrevious",
"=",
"$",
"item",
"->",
"nodeValue",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"}",
"}"
] |
parse XML represenation into a Harvest Timer object
@param \DOMNode $node xml node to parse
@return void
|
[
"parse",
"XML",
"represenation",
"into",
"a",
"Harvest",
"Timer",
"object"
] |
018c05b548428aa3e8d1040e0e2b1ec75b85adfe
|
https://github.com/gridonic/hapi/blob/018c05b548428aa3e8d1040e0e2b1ec75b85adfe/src/Harvest/Model/Timer.php#L86-L101
|
229,727
|
milesj/utility
|
Lib/CakeEngine.php
|
CakeEngine.render
|
public function render(array $tag, $content) {
$setup = $this->getFilter()->getTag($tag['tag']);
$vars = $tag['attributes'];
$vars['filter'] = $this->getFilter();
$vars['content'] = $content;
$this->_view->set($vars);
// Try outside of the plugin first in-case they use their own templates
try {
$response = $this->_view->render($setup['template']);
// Else fallback to the plugin templates
} catch (Exception $e) {
$this->_view->plugin = 'Utility';
$response = $this->_view->render($setup['template']);
}
$this->_view->hasRendered = false;
$this->_view->plugin = null;
return $response;
}
|
php
|
public function render(array $tag, $content) {
$setup = $this->getFilter()->getTag($tag['tag']);
$vars = $tag['attributes'];
$vars['filter'] = $this->getFilter();
$vars['content'] = $content;
$this->_view->set($vars);
// Try outside of the plugin first in-case they use their own templates
try {
$response = $this->_view->render($setup['template']);
// Else fallback to the plugin templates
} catch (Exception $e) {
$this->_view->plugin = 'Utility';
$response = $this->_view->render($setup['template']);
}
$this->_view->hasRendered = false;
$this->_view->plugin = null;
return $response;
}
|
[
"public",
"function",
"render",
"(",
"array",
"$",
"tag",
",",
"$",
"content",
")",
"{",
"$",
"setup",
"=",
"$",
"this",
"->",
"getFilter",
"(",
")",
"->",
"getTag",
"(",
"$",
"tag",
"[",
"'tag'",
"]",
")",
";",
"$",
"vars",
"=",
"$",
"tag",
"[",
"'attributes'",
"]",
";",
"$",
"vars",
"[",
"'filter'",
"]",
"=",
"$",
"this",
"->",
"getFilter",
"(",
")",
";",
"$",
"vars",
"[",
"'content'",
"]",
"=",
"$",
"content",
";",
"$",
"this",
"->",
"_view",
"->",
"set",
"(",
"$",
"vars",
")",
";",
"// Try outside of the plugin first in-case they use their own templates",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_view",
"->",
"render",
"(",
"$",
"setup",
"[",
"'template'",
"]",
")",
";",
"// Else fallback to the plugin templates",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"_view",
"->",
"plugin",
"=",
"'Utility'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"_view",
"->",
"render",
"(",
"$",
"setup",
"[",
"'template'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"_view",
"->",
"hasRendered",
"=",
"false",
";",
"$",
"this",
"->",
"_view",
"->",
"plugin",
"=",
"null",
";",
"return",
"$",
"response",
";",
"}"
] |
Renders the tag by using Cake views.
@param array $tag
@param string $content
@return string
@throws \Exception
|
[
"Renders",
"the",
"tag",
"by",
"using",
"Cake",
"views",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Lib/CakeEngine.php#L48-L72
|
229,728
|
milesj/utility
|
Controller/Component/AjaxHandlerComponent.php
|
AjaxHandlerComponent.initialize
|
public function initialize(Controller $controller) {
if ($controller->request->is('ajax')) {
Configure::write('debug', 0);
// Must disable security component for AJAX
if (isset($controller->Security)) {
$controller->Security->validatePost = false;
$controller->Security->csrfCheck = false;
}
// If not from this domain, destroy
if (!$this->allowRemote && (strpos(env('HTTP_REFERER'), trim(env('HTTP_HOST'), '/')) === false)) {
if (isset($controller->Security)) {
$controller->Security->blackHole($controller, 'Invalid referrer detected for this request.');
} else {
$controller->redirect(null, 403, true);
}
}
}
$this->controller = $controller;
}
|
php
|
public function initialize(Controller $controller) {
if ($controller->request->is('ajax')) {
Configure::write('debug', 0);
// Must disable security component for AJAX
if (isset($controller->Security)) {
$controller->Security->validatePost = false;
$controller->Security->csrfCheck = false;
}
// If not from this domain, destroy
if (!$this->allowRemote && (strpos(env('HTTP_REFERER'), trim(env('HTTP_HOST'), '/')) === false)) {
if (isset($controller->Security)) {
$controller->Security->blackHole($controller, 'Invalid referrer detected for this request.');
} else {
$controller->redirect(null, 403, true);
}
}
}
$this->controller = $controller;
}
|
[
"public",
"function",
"initialize",
"(",
"Controller",
"$",
"controller",
")",
"{",
"if",
"(",
"$",
"controller",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
")",
"{",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"// Must disable security component for AJAX",
"if",
"(",
"isset",
"(",
"$",
"controller",
"->",
"Security",
")",
")",
"{",
"$",
"controller",
"->",
"Security",
"->",
"validatePost",
"=",
"false",
";",
"$",
"controller",
"->",
"Security",
"->",
"csrfCheck",
"=",
"false",
";",
"}",
"// If not from this domain, destroy",
"if",
"(",
"!",
"$",
"this",
"->",
"allowRemote",
"&&",
"(",
"strpos",
"(",
"env",
"(",
"'HTTP_REFERER'",
")",
",",
"trim",
"(",
"env",
"(",
"'HTTP_HOST'",
")",
",",
"'/'",
")",
")",
"===",
"false",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"controller",
"->",
"Security",
")",
")",
"{",
"$",
"controller",
"->",
"Security",
"->",
"blackHole",
"(",
"$",
"controller",
",",
"'Invalid referrer detected for this request.'",
")",
";",
"}",
"else",
"{",
"$",
"controller",
"->",
"redirect",
"(",
"null",
",",
"403",
",",
"true",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"controller",
"=",
"$",
"controller",
";",
"}"
] |
Load the Controller object.
@param Controller $controller
|
[
"Load",
"the",
"Controller",
"object",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AjaxHandlerComponent.php#L71-L92
|
229,729
|
milesj/utility
|
Controller/Component/AjaxHandlerComponent.php
|
AjaxHandlerComponent.startup
|
public function startup(Controller $controller) {
$handled = ($this->_handled === array('*') || in_array($controller->action, $this->_handled));
if ($handled && !$controller->request->is('ajax')) {
if (isset($controller->Security)) {
$controller->Security->blackHole($controller, 'You are not authorized to process this request.');
} else {
$controller->redirect(null, 401, true);
}
}
$this->controller = $controller;
}
|
php
|
public function startup(Controller $controller) {
$handled = ($this->_handled === array('*') || in_array($controller->action, $this->_handled));
if ($handled && !$controller->request->is('ajax')) {
if (isset($controller->Security)) {
$controller->Security->blackHole($controller, 'You are not authorized to process this request.');
} else {
$controller->redirect(null, 401, true);
}
}
$this->controller = $controller;
}
|
[
"public",
"function",
"startup",
"(",
"Controller",
"$",
"controller",
")",
"{",
"$",
"handled",
"=",
"(",
"$",
"this",
"->",
"_handled",
"===",
"array",
"(",
"'*'",
")",
"||",
"in_array",
"(",
"$",
"controller",
"->",
"action",
",",
"$",
"this",
"->",
"_handled",
")",
")",
";",
"if",
"(",
"$",
"handled",
"&&",
"!",
"$",
"controller",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"controller",
"->",
"Security",
")",
")",
"{",
"$",
"controller",
"->",
"Security",
"->",
"blackHole",
"(",
"$",
"controller",
",",
"'You are not authorized to process this request.'",
")",
";",
"}",
"else",
"{",
"$",
"controller",
"->",
"redirect",
"(",
"null",
",",
"401",
",",
"true",
")",
";",
"}",
"}",
"$",
"this",
"->",
"controller",
"=",
"$",
"controller",
";",
"}"
] |
Determine if the action is an AJAX action and handle it.
@param Controller $controller
|
[
"Determine",
"if",
"the",
"action",
"is",
"an",
"AJAX",
"action",
"and",
"handle",
"it",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AjaxHandlerComponent.php#L99-L111
|
229,730
|
milesj/utility
|
Controller/Component/AjaxHandlerComponent.php
|
AjaxHandlerComponent.handle
|
public function handle() {
$actions = func_get_args();
if ($actions === array('*') || empty($actions)) {
$this->_handled = array('*');
} else {
$this->_handled = array_unique(array_intersect($actions, get_class_methods($this->controller)));
}
}
|
php
|
public function handle() {
$actions = func_get_args();
if ($actions === array('*') || empty($actions)) {
$this->_handled = array('*');
} else {
$this->_handled = array_unique(array_intersect($actions, get_class_methods($this->controller)));
}
}
|
[
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"actions",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"$",
"actions",
"===",
"array",
"(",
"'*'",
")",
"||",
"empty",
"(",
"$",
"actions",
")",
")",
"{",
"$",
"this",
"->",
"_handled",
"=",
"array",
"(",
"'*'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_handled",
"=",
"array_unique",
"(",
"array_intersect",
"(",
"$",
"actions",
",",
"get_class_methods",
"(",
"$",
"this",
"->",
"controller",
")",
")",
")",
";",
"}",
"}"
] |
A list of actions that are handled as an AJAX call.
|
[
"A",
"list",
"of",
"actions",
"that",
"are",
"handled",
"as",
"an",
"AJAX",
"call",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AjaxHandlerComponent.php#L116-L124
|
229,731
|
milesj/utility
|
Controller/Component/AjaxHandlerComponent.php
|
AjaxHandlerComponent.respond
|
public function respond($type = 'json', array $response = array()) {
if ($response) {
$response = $response + array(
'success' => false,
'data' => '',
'code' => null
);
$this->response($response['success'], $response['data'], $response['code']);
}
if ($type === 'html') {
$this->RequestHandler->renderAs($this->controller, 'ajax');
} else {
$this->RequestHandler->respondAs($type);
$this->controller->autoLayout = false;
$this->controller->autoRender = false;
echo $this->_format($type);
}
}
|
php
|
public function respond($type = 'json', array $response = array()) {
if ($response) {
$response = $response + array(
'success' => false,
'data' => '',
'code' => null
);
$this->response($response['success'], $response['data'], $response['code']);
}
if ($type === 'html') {
$this->RequestHandler->renderAs($this->controller, 'ajax');
} else {
$this->RequestHandler->respondAs($type);
$this->controller->autoLayout = false;
$this->controller->autoRender = false;
echo $this->_format($type);
}
}
|
[
"public",
"function",
"respond",
"(",
"$",
"type",
"=",
"'json'",
",",
"array",
"$",
"response",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"$",
"response",
"+",
"array",
"(",
"'success'",
"=>",
"false",
",",
"'data'",
"=>",
"''",
",",
"'code'",
"=>",
"null",
")",
";",
"$",
"this",
"->",
"response",
"(",
"$",
"response",
"[",
"'success'",
"]",
",",
"$",
"response",
"[",
"'data'",
"]",
",",
"$",
"response",
"[",
"'code'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"type",
"===",
"'html'",
")",
"{",
"$",
"this",
"->",
"RequestHandler",
"->",
"renderAs",
"(",
"$",
"this",
"->",
"controller",
",",
"'ajax'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"RequestHandler",
"->",
"respondAs",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"controller",
"->",
"autoLayout",
"=",
"false",
";",
"$",
"this",
"->",
"controller",
"->",
"autoRender",
"=",
"false",
";",
"echo",
"$",
"this",
"->",
"_format",
"(",
"$",
"type",
")",
";",
"}",
"}"
] |
Respond the AJAX call with the gathered data.
@param string $type
@param array $response
|
[
"Respond",
"the",
"AJAX",
"call",
"with",
"the",
"gathered",
"data",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AjaxHandlerComponent.php#L132-L153
|
229,732
|
milesj/utility
|
Controller/Component/AjaxHandlerComponent.php
|
AjaxHandlerComponent.response
|
public function response($success, $data = '', $code = null) {
$this->_success = (bool) $success;
$this->_data = $data;
$this->_code = $code;
}
|
php
|
public function response($success, $data = '', $code = null) {
$this->_success = (bool) $success;
$this->_data = $data;
$this->_code = $code;
}
|
[
"public",
"function",
"response",
"(",
"$",
"success",
",",
"$",
"data",
"=",
"''",
",",
"$",
"code",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_success",
"=",
"(",
"bool",
")",
"$",
"success",
";",
"$",
"this",
"->",
"_data",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"_code",
"=",
"$",
"code",
";",
"}"
] |
Handle the response as a success or failure alongside a message or error.
@param bool $success
@param mixed $data
@param mixed $code
|
[
"Handle",
"the",
"response",
"as",
"a",
"success",
"or",
"failure",
"alongside",
"a",
"message",
"or",
"error",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AjaxHandlerComponent.php#L162-L166
|
229,733
|
milesj/utility
|
Controller/Component/AjaxHandlerComponent.php
|
AjaxHandlerComponent._format
|
protected function _format($type) {
$response = array(
'success' => $this->_success,
'data' => $this->_data
);
if ($this->_code) {
$response['code'] = $this->_code;
}
switch (strtolower($type)) {
case 'json':
$format = TypeConverter::toJson($response);
break;
case 'xml':
$format = TypeConverter::toXml($response);
break;
case 'html';
case 'text':
default:
$format = (string) $this->_data;
break;
}
return $format;
}
|
php
|
protected function _format($type) {
$response = array(
'success' => $this->_success,
'data' => $this->_data
);
if ($this->_code) {
$response['code'] = $this->_code;
}
switch (strtolower($type)) {
case 'json':
$format = TypeConverter::toJson($response);
break;
case 'xml':
$format = TypeConverter::toXml($response);
break;
case 'html';
case 'text':
default:
$format = (string) $this->_data;
break;
}
return $format;
}
|
[
"protected",
"function",
"_format",
"(",
"$",
"type",
")",
"{",
"$",
"response",
"=",
"array",
"(",
"'success'",
"=>",
"$",
"this",
"->",
"_success",
",",
"'data'",
"=>",
"$",
"this",
"->",
"_data",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_code",
")",
"{",
"$",
"response",
"[",
"'code'",
"]",
"=",
"$",
"this",
"->",
"_code",
";",
"}",
"switch",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
"{",
"case",
"'json'",
":",
"$",
"format",
"=",
"TypeConverter",
"::",
"toJson",
"(",
"$",
"response",
")",
";",
"break",
";",
"case",
"'xml'",
":",
"$",
"format",
"=",
"TypeConverter",
"::",
"toXml",
"(",
"$",
"response",
")",
";",
"break",
";",
"case",
"'html'",
";",
"case",
"'text'",
":",
"default",
":",
"$",
"format",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"_data",
";",
"break",
";",
"}",
"return",
"$",
"format",
";",
"}"
] |
Format the response into the right content type.
@param string $type
@return string
|
[
"Format",
"the",
"response",
"into",
"the",
"right",
"content",
"type",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/Component/AjaxHandlerComponent.php#L174-L199
|
229,734
|
netgen/NetgenOpenGraphBundle
|
bundle/Handler/Registry.php
|
Registry.addHandler
|
public function addHandler($identifier, HandlerInterface $metaTagHandler)
{
if (!isset($this->metaTagHandlers[$identifier])) {
$this->metaTagHandlers[$identifier] = $metaTagHandler;
}
}
|
php
|
public function addHandler($identifier, HandlerInterface $metaTagHandler)
{
if (!isset($this->metaTagHandlers[$identifier])) {
$this->metaTagHandlers[$identifier] = $metaTagHandler;
}
}
|
[
"public",
"function",
"addHandler",
"(",
"$",
"identifier",
",",
"HandlerInterface",
"$",
"metaTagHandler",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"metaTagHandlers",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"$",
"this",
"->",
"metaTagHandlers",
"[",
"$",
"identifier",
"]",
"=",
"$",
"metaTagHandler",
";",
"}",
"}"
] |
Adds a handler to the registry.
@param string $identifier
@param \Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface $metaTagHandler
|
[
"Adds",
"a",
"handler",
"to",
"the",
"registry",
"."
] |
fcaad267742492cfa4049adbf075343c262c4767
|
https://github.com/netgen/NetgenOpenGraphBundle/blob/fcaad267742492cfa4049adbf075343c262c4767/bundle/Handler/Registry.php#L20-L25
|
229,735
|
netgen/NetgenOpenGraphBundle
|
bundle/Handler/Registry.php
|
Registry.getHandler
|
public function getHandler($identifier)
{
if (isset($this->metaTagHandlers[$identifier])) {
return $this->metaTagHandlers[$identifier];
}
throw new HandlerNotFoundException($identifier);
}
|
php
|
public function getHandler($identifier)
{
if (isset($this->metaTagHandlers[$identifier])) {
return $this->metaTagHandlers[$identifier];
}
throw new HandlerNotFoundException($identifier);
}
|
[
"public",
"function",
"getHandler",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metaTagHandlers",
"[",
"$",
"identifier",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"metaTagHandlers",
"[",
"$",
"identifier",
"]",
";",
"}",
"throw",
"new",
"HandlerNotFoundException",
"(",
"$",
"identifier",
")",
";",
"}"
] |
Returns handler by its identifier.
@param string $identifier
@throws \Netgen\Bundle\OpenGraphBundle\Exception\HandlerNotFoundException If the handler is not found
@return \Netgen\Bundle\OpenGraphBundle\Handler\HandlerInterface
|
[
"Returns",
"handler",
"by",
"its",
"identifier",
"."
] |
fcaad267742492cfa4049adbf075343c262c4767
|
https://github.com/netgen/NetgenOpenGraphBundle/blob/fcaad267742492cfa4049adbf075343c262c4767/bundle/Handler/Registry.php#L36-L43
|
229,736
|
fecshop/yii2-fec
|
lib/PHPExcel/PHPExcel/Writer/Excel2007/RelsVBA.php
|
PHPExcel_Writer_Excel2007_RelsVBA.writeVBARelationships
|
public function writeVBARelationships(PHPExcel $pPHPExcel = null){
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0','UTF-8','yes');
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', 'rId1');
$objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
$objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
$objWriter->endElement();//Relationship
$objWriter->endElement();//Relationships
// Return
return $objWriter->getData();
}
|
php
|
public function writeVBARelationships(PHPExcel $pPHPExcel = null){
// Create XML writer
$objWriter = null;
if ($this->getParentWriter()->getUseDiskCaching()) {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_DISK, $this->getParentWriter()->getDiskCachingDirectory());
} else {
$objWriter = new PHPExcel_Shared_XMLWriter(PHPExcel_Shared_XMLWriter::STORAGE_MEMORY);
}
// XML header
$objWriter->startDocument('1.0','UTF-8','yes');
// Relationships
$objWriter->startElement('Relationships');
$objWriter->writeAttribute('xmlns', 'http://schemas.openxmlformats.org/package/2006/relationships');
$objWriter->startElement('Relationship');
$objWriter->writeAttribute('Id', 'rId1');
$objWriter->writeAttribute('Type', 'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature');
$objWriter->writeAttribute('Target', 'vbaProjectSignature.bin');
$objWriter->endElement();//Relationship
$objWriter->endElement();//Relationships
// Return
return $objWriter->getData();
}
|
[
"public",
"function",
"writeVBARelationships",
"(",
"PHPExcel",
"$",
"pPHPExcel",
"=",
"null",
")",
"{",
"// Create XML writer",
"$",
"objWriter",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"getParentWriter",
"(",
")",
"->",
"getUseDiskCaching",
"(",
")",
")",
"{",
"$",
"objWriter",
"=",
"new",
"PHPExcel_Shared_XMLWriter",
"(",
"PHPExcel_Shared_XMLWriter",
"::",
"STORAGE_DISK",
",",
"$",
"this",
"->",
"getParentWriter",
"(",
")",
"->",
"getDiskCachingDirectory",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"objWriter",
"=",
"new",
"PHPExcel_Shared_XMLWriter",
"(",
"PHPExcel_Shared_XMLWriter",
"::",
"STORAGE_MEMORY",
")",
";",
"}",
"// XML header",
"$",
"objWriter",
"->",
"startDocument",
"(",
"'1.0'",
",",
"'UTF-8'",
",",
"'yes'",
")",
";",
"// Relationships",
"$",
"objWriter",
"->",
"startElement",
"(",
"'Relationships'",
")",
";",
"$",
"objWriter",
"->",
"writeAttribute",
"(",
"'xmlns'",
",",
"'http://schemas.openxmlformats.org/package/2006/relationships'",
")",
";",
"$",
"objWriter",
"->",
"startElement",
"(",
"'Relationship'",
")",
";",
"$",
"objWriter",
"->",
"writeAttribute",
"(",
"'Id'",
",",
"'rId1'",
")",
";",
"$",
"objWriter",
"->",
"writeAttribute",
"(",
"'Type'",
",",
"'http://schemas.microsoft.com/office/2006/relationships/vbaProjectSignature'",
")",
";",
"$",
"objWriter",
"->",
"writeAttribute",
"(",
"'Target'",
",",
"'vbaProjectSignature.bin'",
")",
";",
"$",
"objWriter",
"->",
"endElement",
"(",
")",
";",
"//Relationship",
"$",
"objWriter",
"->",
"endElement",
"(",
")",
";",
"//Relationships",
"// Return",
"return",
"$",
"objWriter",
"->",
"getData",
"(",
")",
";",
"}"
] |
Write relationships for a signed VBA Project
@param PHPExcel $pPHPExcel
@return string XML Output
@throws PHPExcel_Writer_Exception
|
[
"Write",
"relationships",
"for",
"a",
"signed",
"VBA",
"Project"
] |
fda0e381f931bc503e493bec90185162109018e6
|
https://github.com/fecshop/yii2-fec/blob/fda0e381f931bc503e493bec90185162109018e6/lib/PHPExcel/PHPExcel/Writer/Excel2007/RelsVBA.php#L45-L70
|
229,737
|
milesj/utility
|
Controller/SitemapController.php
|
SitemapController.index
|
public function index() {
$controllers = App::objects('Controller');
$sitemap = array();
// Fetch sitemap data
foreach ($controllers as $controller) {
App::uses($controller, 'Controller');
// Don't load AppController's, SitemapController or Controller's who can't be found
if (strpos($controller, 'AppController') !== false || $controller === 'SitemapController' || !App::load($controller)) {
continue;
}
$instance = new $controller($this->request, $this->response);
$instance->constructClasses();
if (method_exists($instance, '_generateSitemap')) {
if ($data = $instance->_generateSitemap()) {
$sitemap = array_merge($sitemap, $data);
}
}
}
// Cleanup sitemap
if ($sitemap) {
foreach ($sitemap as &$item) {
if (is_array($item['loc'])) {
if (!isset($item['loc']['plugin'])) {
$item['loc']['plugin'] = false;
}
$item['loc'] = h(Router::url($item['loc'], true));
}
if (array_key_exists('lastmod', $item)) {
if (!$item['lastmod']) {
unset($item['lastmod']);
} else {
$item['lastmod'] = CakeTime::format(DateTime::W3C, $item['lastmod']);
}
}
}
}
// Disable direct linking
if (empty($this->request->params['ext'])) {
throw new NotFoundException();
}
// Render view and don't use specific view engines
$this->RequestHandler->respondAs($this->request->params['ext']);
$this->set('sitemap', $sitemap);
}
|
php
|
public function index() {
$controllers = App::objects('Controller');
$sitemap = array();
// Fetch sitemap data
foreach ($controllers as $controller) {
App::uses($controller, 'Controller');
// Don't load AppController's, SitemapController or Controller's who can't be found
if (strpos($controller, 'AppController') !== false || $controller === 'SitemapController' || !App::load($controller)) {
continue;
}
$instance = new $controller($this->request, $this->response);
$instance->constructClasses();
if (method_exists($instance, '_generateSitemap')) {
if ($data = $instance->_generateSitemap()) {
$sitemap = array_merge($sitemap, $data);
}
}
}
// Cleanup sitemap
if ($sitemap) {
foreach ($sitemap as &$item) {
if (is_array($item['loc'])) {
if (!isset($item['loc']['plugin'])) {
$item['loc']['plugin'] = false;
}
$item['loc'] = h(Router::url($item['loc'], true));
}
if (array_key_exists('lastmod', $item)) {
if (!$item['lastmod']) {
unset($item['lastmod']);
} else {
$item['lastmod'] = CakeTime::format(DateTime::W3C, $item['lastmod']);
}
}
}
}
// Disable direct linking
if (empty($this->request->params['ext'])) {
throw new NotFoundException();
}
// Render view and don't use specific view engines
$this->RequestHandler->respondAs($this->request->params['ext']);
$this->set('sitemap', $sitemap);
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"controllers",
"=",
"App",
"::",
"objects",
"(",
"'Controller'",
")",
";",
"$",
"sitemap",
"=",
"array",
"(",
")",
";",
"// Fetch sitemap data\r",
"foreach",
"(",
"$",
"controllers",
"as",
"$",
"controller",
")",
"{",
"App",
"::",
"uses",
"(",
"$",
"controller",
",",
"'Controller'",
")",
";",
"// Don't load AppController's, SitemapController or Controller's who can't be found\r",
"if",
"(",
"strpos",
"(",
"$",
"controller",
",",
"'AppController'",
")",
"!==",
"false",
"||",
"$",
"controller",
"===",
"'SitemapController'",
"||",
"!",
"App",
"::",
"load",
"(",
"$",
"controller",
")",
")",
"{",
"continue",
";",
"}",
"$",
"instance",
"=",
"new",
"$",
"controller",
"(",
"$",
"this",
"->",
"request",
",",
"$",
"this",
"->",
"response",
")",
";",
"$",
"instance",
"->",
"constructClasses",
"(",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"instance",
",",
"'_generateSitemap'",
")",
")",
"{",
"if",
"(",
"$",
"data",
"=",
"$",
"instance",
"->",
"_generateSitemap",
"(",
")",
")",
"{",
"$",
"sitemap",
"=",
"array_merge",
"(",
"$",
"sitemap",
",",
"$",
"data",
")",
";",
"}",
"}",
"}",
"// Cleanup sitemap\r",
"if",
"(",
"$",
"sitemap",
")",
"{",
"foreach",
"(",
"$",
"sitemap",
"as",
"&",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
"[",
"'loc'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"item",
"[",
"'loc'",
"]",
"[",
"'plugin'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'loc'",
"]",
"[",
"'plugin'",
"]",
"=",
"false",
";",
"}",
"$",
"item",
"[",
"'loc'",
"]",
"=",
"h",
"(",
"Router",
"::",
"url",
"(",
"$",
"item",
"[",
"'loc'",
"]",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'lastmod'",
",",
"$",
"item",
")",
")",
"{",
"if",
"(",
"!",
"$",
"item",
"[",
"'lastmod'",
"]",
")",
"{",
"unset",
"(",
"$",
"item",
"[",
"'lastmod'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"item",
"[",
"'lastmod'",
"]",
"=",
"CakeTime",
"::",
"format",
"(",
"DateTime",
"::",
"W3C",
",",
"$",
"item",
"[",
"'lastmod'",
"]",
")",
";",
"}",
"}",
"}",
"}",
"// Disable direct linking\r",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"request",
"->",
"params",
"[",
"'ext'",
"]",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
")",
";",
"}",
"// Render view and don't use specific view engines\r",
"$",
"this",
"->",
"RequestHandler",
"->",
"respondAs",
"(",
"$",
"this",
"->",
"request",
"->",
"params",
"[",
"'ext'",
"]",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'sitemap'",
",",
"$",
"sitemap",
")",
";",
"}"
] |
Loop through active controllers and generate sitemap data.
|
[
"Loop",
"through",
"active",
"controllers",
"and",
"generate",
"sitemap",
"data",
"."
] |
146318ff0a882917defab7f4918b0d198eb5a3c0
|
https://github.com/milesj/utility/blob/146318ff0a882917defab7f4918b0d198eb5a3c0/Controller/SitemapController.php#L26-L79
|
229,738
|
Webiny/Framework
|
src/Webiny/Component/EventManager/EventProcessor.php
|
EventProcessor.process
|
public function process($eventListeners, Event $event, $resultType = null, $limit = null)
{
$eventListeners = $this->orderByPriority($eventListeners);
$results = [];
/* @var $eventListener EventListener */
foreach ($eventListeners as $eventListener) {
$handler = $eventListener->getHandler();
if ($this->isNull($handler)) {
continue;
}
$method = $eventListener->getMethod();
if ($this->isCallable($handler)) {
/** @var $handler \Closure */
$result = $handler($event);
} else {
$result = call_user_func_array([
$handler,
$method
], [$event]);
}
if ($this->isNull($resultType) || (!$this->isNull($resultType) && $this->isInstanceOf($result, $resultType))) {
$results[] = $result;
if ($limit === 1 && count($results) === 1) {
return $results[0];
}
if (count($results) === $limit) {
return $results;
}
}
if ($event->isPropagationStopped()) {
break;
}
}
return $results;
}
|
php
|
public function process($eventListeners, Event $event, $resultType = null, $limit = null)
{
$eventListeners = $this->orderByPriority($eventListeners);
$results = [];
/* @var $eventListener EventListener */
foreach ($eventListeners as $eventListener) {
$handler = $eventListener->getHandler();
if ($this->isNull($handler)) {
continue;
}
$method = $eventListener->getMethod();
if ($this->isCallable($handler)) {
/** @var $handler \Closure */
$result = $handler($event);
} else {
$result = call_user_func_array([
$handler,
$method
], [$event]);
}
if ($this->isNull($resultType) || (!$this->isNull($resultType) && $this->isInstanceOf($result, $resultType))) {
$results[] = $result;
if ($limit === 1 && count($results) === 1) {
return $results[0];
}
if (count($results) === $limit) {
return $results;
}
}
if ($event->isPropagationStopped()) {
break;
}
}
return $results;
}
|
[
"public",
"function",
"process",
"(",
"$",
"eventListeners",
",",
"Event",
"$",
"event",
",",
"$",
"resultType",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"eventListeners",
"=",
"$",
"this",
"->",
"orderByPriority",
"(",
"$",
"eventListeners",
")",
";",
"$",
"results",
"=",
"[",
"]",
";",
"/* @var $eventListener EventListener */",
"foreach",
"(",
"$",
"eventListeners",
"as",
"$",
"eventListener",
")",
"{",
"$",
"handler",
"=",
"$",
"eventListener",
"->",
"getHandler",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isNull",
"(",
"$",
"handler",
")",
")",
"{",
"continue",
";",
"}",
"$",
"method",
"=",
"$",
"eventListener",
"->",
"getMethod",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isCallable",
"(",
"$",
"handler",
")",
")",
"{",
"/** @var $handler \\Closure */",
"$",
"result",
"=",
"$",
"handler",
"(",
"$",
"event",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"call_user_func_array",
"(",
"[",
"$",
"handler",
",",
"$",
"method",
"]",
",",
"[",
"$",
"event",
"]",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isNull",
"(",
"$",
"resultType",
")",
"||",
"(",
"!",
"$",
"this",
"->",
"isNull",
"(",
"$",
"resultType",
")",
"&&",
"$",
"this",
"->",
"isInstanceOf",
"(",
"$",
"result",
",",
"$",
"resultType",
")",
")",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"result",
";",
"if",
"(",
"$",
"limit",
"===",
"1",
"&&",
"count",
"(",
"$",
"results",
")",
"===",
"1",
")",
"{",
"return",
"$",
"results",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"results",
")",
"===",
"$",
"limit",
")",
"{",
"return",
"$",
"results",
";",
"}",
"}",
"if",
"(",
"$",
"event",
"->",
"isPropagationStopped",
"(",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] |
Process given event
@param array|ArrayObject $eventListeners EventListeners that are subscribed to this event
@param Event $event Event data object
@param null|string $resultType Type of event result to enforce (can be any class or interface name)
@param null|int $limit Number of results to return
@return array
|
[
"Process",
"given",
"event"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/EventManager/EventProcessor.php#L32-L77
|
229,739
|
deanblackborough/zf3-view-helpers
|
src/Bootstrap4Helper.php
|
Bootstrap4Helper.assignBgStyle
|
protected function assignBgStyle(string $color)
{
if (in_array($color, $this->supported_bg_styles) === true) {
$this->bg_color = $color;
}
}
|
php
|
protected function assignBgStyle(string $color)
{
if (in_array($color, $this->supported_bg_styles) === true) {
$this->bg_color = $color;
}
}
|
[
"protected",
"function",
"assignBgStyle",
"(",
"string",
"$",
"color",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"color",
",",
"$",
"this",
"->",
"supported_bg_styles",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"bg_color",
"=",
"$",
"color",
";",
"}",
"}"
] |
Validate and assign the background colour, needs to be one of the following, primary, secondary, success,
danger, warning, info, light, dark or white, if an incorrect style is passed in we don't apply the class.
@param string $color
|
[
"Validate",
"and",
"assign",
"the",
"background",
"colour",
"needs",
"to",
"be",
"one",
"of",
"the",
"following",
"primary",
"secondary",
"success",
"danger",
"warning",
"info",
"light",
"dark",
"or",
"white",
"if",
"an",
"incorrect",
"style",
"is",
"passed",
"in",
"we",
"don",
"t",
"apply",
"the",
"class",
"."
] |
db8bea4ca62709b2ac8c732aedbb2a5235223f23
|
https://github.com/deanblackborough/zf3-view-helpers/blob/db8bea4ca62709b2ac8c732aedbb2a5235223f23/src/Bootstrap4Helper.php#L75-L80
|
229,740
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/View.php
|
View.getScriptsHtml
|
public function getScriptsHtml()
{
$scripts = '';
if (!isset($this->scripts)) {
return $scripts;
}
foreach ($this->scripts as $s) {
$scripts .= '<script type="' . $s['type'] . '" src="' . $s['path'] . '"></script>' . "\n";
}
return $scripts;
}
|
php
|
public function getScriptsHtml()
{
$scripts = '';
if (!isset($this->scripts)) {
return $scripts;
}
foreach ($this->scripts as $s) {
$scripts .= '<script type="' . $s['type'] . '" src="' . $s['path'] . '"></script>' . "\n";
}
return $scripts;
}
|
[
"public",
"function",
"getScriptsHtml",
"(",
")",
"{",
"$",
"scripts",
"=",
"''",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"scripts",
")",
")",
"{",
"return",
"$",
"scripts",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"scripts",
"as",
"$",
"s",
")",
"{",
"$",
"scripts",
".=",
"'<script type=\"'",
".",
"$",
"s",
"[",
"'type'",
"]",
".",
"'\" src=\"'",
".",
"$",
"s",
"[",
"'path'",
"]",
".",
"'\"></script>'",
".",
"\"\\n\"",
";",
"}",
"return",
"$",
"scripts",
";",
"}"
] |
Get the script list as html tags.
@return string
|
[
"Get",
"the",
"script",
"list",
"as",
"html",
"tags",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/View.php#L183-L195
|
229,741
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/View.php
|
View.getStyleSheetsHtml
|
public function getStyleSheetsHtml()
{
$styleSheets = '';
if (!isset($this->styles)) {
return $styleSheets;
}
foreach ($this->styles as $s) {
$styleSheets .= '<link rel="stylesheet" type="text/css" href="' . $s . '"/>' . "\n";
}
return $styleSheets;
}
|
php
|
public function getStyleSheetsHtml()
{
$styleSheets = '';
if (!isset($this->styles)) {
return $styleSheets;
}
foreach ($this->styles as $s) {
$styleSheets .= '<link rel="stylesheet" type="text/css" href="' . $s . '"/>' . "\n";
}
return $styleSheets;
}
|
[
"public",
"function",
"getStyleSheetsHtml",
"(",
")",
"{",
"$",
"styleSheets",
"=",
"''",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"styles",
")",
")",
"{",
"return",
"$",
"styleSheets",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"styles",
"as",
"$",
"s",
")",
"{",
"$",
"styleSheets",
".=",
"'<link rel=\"stylesheet\" type=\"text/css\" href=\"'",
".",
"$",
"s",
".",
"'\"/>'",
".",
"\"\\n\"",
";",
"}",
"return",
"$",
"styleSheets",
";",
"}"
] |
Get the stylesheet list as html tags.
@return string
|
[
"Get",
"the",
"stylesheet",
"list",
"as",
"html",
"tags",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/View.php#L212-L224
|
229,742
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/View.php
|
View.getMetaHtml
|
public function getMetaHtml()
{
$meta = '';
if (empty($this->meta)) {
return $meta;
}
foreach ($this->meta as $name => $content) {
$meta .= '<meta name="' . $name . '" content="' . $content . '"/>' . "\n";
}
return $meta;
}
|
php
|
public function getMetaHtml()
{
$meta = '';
if (empty($this->meta)) {
return $meta;
}
foreach ($this->meta as $name => $content) {
$meta .= '<meta name="' . $name . '" content="' . $content . '"/>' . "\n";
}
return $meta;
}
|
[
"public",
"function",
"getMetaHtml",
"(",
")",
"{",
"$",
"meta",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"meta",
")",
")",
"{",
"return",
"$",
"meta",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"meta",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"{",
"$",
"meta",
".=",
"'<meta name=\"'",
".",
"$",
"name",
".",
"'\" content=\"'",
".",
"$",
"content",
".",
"'\"/>'",
".",
"\"\\n\"",
";",
"}",
"return",
"$",
"meta",
";",
"}"
] |
Get the meta list as html tags.
@return string
|
[
"Get",
"the",
"meta",
"list",
"as",
"html",
"tags",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/View.php#L241-L253
|
229,743
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/View.php
|
View.assign
|
public function assign(array $data, $root = 'Ctrl')
{
foreach ($data as $k => $d) {
if ($root != '') {
if (!isset($this->viewData[$root])) {
$this->viewData[$root] = [];
}
$this->viewData[$root][$k] = $d;
} else {
$this->viewData[$k] = $d;
}
}
}
|
php
|
public function assign(array $data, $root = 'Ctrl')
{
foreach ($data as $k => $d) {
if ($root != '') {
if (!isset($this->viewData[$root])) {
$this->viewData[$root] = [];
}
$this->viewData[$root][$k] = $d;
} else {
$this->viewData[$k] = $d;
}
}
}
|
[
"public",
"function",
"assign",
"(",
"array",
"$",
"data",
",",
"$",
"root",
"=",
"'Ctrl'",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"d",
")",
"{",
"if",
"(",
"$",
"root",
"!=",
"''",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"viewData",
"[",
"$",
"root",
"]",
")",
")",
"{",
"$",
"this",
"->",
"viewData",
"[",
"$",
"root",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"viewData",
"[",
"$",
"root",
"]",
"[",
"$",
"k",
"]",
"=",
"$",
"d",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"viewData",
"[",
"$",
"k",
"]",
"=",
"$",
"d",
";",
"}",
"}",
"}"
] |
Assign variables to the view.
@param array $data List of variables that should be assigned.
@param string $root Variable root. Default root is Ctrl.
|
[
"Assign",
"variables",
"to",
"the",
"view",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/View.php#L281-L294
|
229,744
|
Webiny/Framework
|
src/Webiny/Component/Bootstrap/ApplicationClasses/View.php
|
View.getAssignedData
|
public function getAssignedData()
{
// append the internal data to the view
$this->viewData['View'] = [
'Title' => $this->getTitle(),
'TitleHtml' => $this->getTitleHtml(),
'Scripts' => $this->getScripts(),
'ScriptsHtml' => $this->getScriptsHtml(),
'StyleSheets' => $this->getStyleSheets(),
'StyleSheetsHtml' => $this->getStyleSheetsHtml(),
'Meta' => $this->getMeta(),
'MetaHtml' => $this->getMetaHtml()
];
return $this->viewData;
}
|
php
|
public function getAssignedData()
{
// append the internal data to the view
$this->viewData['View'] = [
'Title' => $this->getTitle(),
'TitleHtml' => $this->getTitleHtml(),
'Scripts' => $this->getScripts(),
'ScriptsHtml' => $this->getScriptsHtml(),
'StyleSheets' => $this->getStyleSheets(),
'StyleSheetsHtml' => $this->getStyleSheetsHtml(),
'Meta' => $this->getMeta(),
'MetaHtml' => $this->getMetaHtml()
];
return $this->viewData;
}
|
[
"public",
"function",
"getAssignedData",
"(",
")",
"{",
"// append the internal data to the view",
"$",
"this",
"->",
"viewData",
"[",
"'View'",
"]",
"=",
"[",
"'Title'",
"=>",
"$",
"this",
"->",
"getTitle",
"(",
")",
",",
"'TitleHtml'",
"=>",
"$",
"this",
"->",
"getTitleHtml",
"(",
")",
",",
"'Scripts'",
"=>",
"$",
"this",
"->",
"getScripts",
"(",
")",
",",
"'ScriptsHtml'",
"=>",
"$",
"this",
"->",
"getScriptsHtml",
"(",
")",
",",
"'StyleSheets'",
"=>",
"$",
"this",
"->",
"getStyleSheets",
"(",
")",
",",
"'StyleSheetsHtml'",
"=>",
"$",
"this",
"->",
"getStyleSheetsHtml",
"(",
")",
",",
"'Meta'",
"=>",
"$",
"this",
"->",
"getMeta",
"(",
")",
",",
"'MetaHtml'",
"=>",
"$",
"this",
"->",
"getMetaHtml",
"(",
")",
"]",
";",
"return",
"$",
"this",
"->",
"viewData",
";",
"}"
] |
Get a list of assigned view data.
@return array
|
[
"Get",
"a",
"list",
"of",
"assigned",
"view",
"data",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Bootstrap/ApplicationClasses/View.php#L301-L316
|
229,745
|
addiks/phpsql
|
src/Addiks/PHPSQL/PDO/Statement.php
|
Statement.bindValue
|
public function bindValue($param, $value, $type = null)
{
if (is_numeric($param)) {
$param--;
}
switch($type){
case \PDO::PARAM_BOOL:
case \PDO::PARAM_INPUT_OUTPUT:
case \PDO::PARAM_INT:
case \PDO::PARAM_LOB:
case \PDO::PARAM_NULL:
case \PDO::PARAM_STMT:
case \PDO::PARAM_STR:
$this->boundValues[] = [(string)$value, $param, $type];
break;
default:
throw new Exception("Invalid data-type '{$type}'! Must be one of \PDO::PARAM_* constants.");
}
}
|
php
|
public function bindValue($param, $value, $type = null)
{
if (is_numeric($param)) {
$param--;
}
switch($type){
case \PDO::PARAM_BOOL:
case \PDO::PARAM_INPUT_OUTPUT:
case \PDO::PARAM_INT:
case \PDO::PARAM_LOB:
case \PDO::PARAM_NULL:
case \PDO::PARAM_STMT:
case \PDO::PARAM_STR:
$this->boundValues[] = [(string)$value, $param, $type];
break;
default:
throw new Exception("Invalid data-type '{$type}'! Must be one of \PDO::PARAM_* constants.");
}
}
|
[
"public",
"function",
"bindValue",
"(",
"$",
"param",
",",
"$",
"value",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"param",
")",
")",
"{",
"$",
"param",
"--",
";",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"\\",
"PDO",
"::",
"PARAM_BOOL",
":",
"case",
"\\",
"PDO",
"::",
"PARAM_INPUT_OUTPUT",
":",
"case",
"\\",
"PDO",
"::",
"PARAM_INT",
":",
"case",
"\\",
"PDO",
"::",
"PARAM_LOB",
":",
"case",
"\\",
"PDO",
"::",
"PARAM_NULL",
":",
"case",
"\\",
"PDO",
"::",
"PARAM_STMT",
":",
"case",
"\\",
"PDO",
"::",
"PARAM_STR",
":",
"$",
"this",
"->",
"boundValues",
"[",
"]",
"=",
"[",
"(",
"string",
")",
"$",
"value",
",",
"$",
"param",
",",
"$",
"type",
"]",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"\"Invalid data-type '{$type}'! Must be one of \\PDO::PARAM_* constants.\"",
")",
";",
"}",
"}"
] |
Binds a value to a corresponding named or question mark
placeholder in the SQL statement that was use to prepare the statement.
@param mixed $param Parameter identifier. For a prepared statement using named placeholders,
this will be a parameter name of the form :name. For a prepared statement
using question mark placeholders, this will be the 1-indexed position of the parameter
@param mixed $value The value to bind to the parameter.
@param integer $type Explicit data type for the parameter using the Core::PARAM_* constants.
@return boolean Returns TRUE on success or FALSE on failure.
|
[
"Binds",
"a",
"value",
"to",
"a",
"corresponding",
"named",
"or",
"question",
"mark",
"placeholder",
"in",
"the",
"SQL",
"statement",
"that",
"was",
"use",
"to",
"prepare",
"the",
"statement",
"."
] |
28dae64ffc2123f39f801a50ab53bfe29890cbd9
|
https://github.com/addiks/phpsql/blob/28dae64ffc2123f39f801a50ab53bfe29890cbd9/src/Addiks/PHPSQL/PDO/Statement.php#L159-L181
|
229,746
|
addiks/phpsql
|
src/Addiks/PHPSQL/PDO/Statement.php
|
Statement.setAttribute
|
public function setAttribute($attribute, $value)
{
switch($attribute){
case Core::ATTR_AUTO_ACCESSOR_OVERRIDE:
case Core::ATTR_AUTO_FREE_QUERY_OBJECTS:
case Core::ATTR_AUTOCOMMIT:
case Core::ATTR_AUTOLOAD_TABLE_CLASSES:
case Core::ATTR_CACHE:
case Core::ATTR_CACHE_LIFESPAN:
case Core::ATTR_CASCADE_SAVES:
case Core::ATTR_CASE:
case Core::ATTR_CLIENT_VERSION:
case Core::ATTR_CMPNAME_FORMAT:
case Core::ATTR_COLL_KEY:
case Core::ATTR_COLL_LIMIT:
case Core::ATTR_COLLECTION_CLASS:
case Core::ATTR_CONNECTION_STATUS:
case Core::ATTR_CREATE_TABLES:
case Core::ATTR_CURSOR:
case Core::ATTR_CURSOR_NAME:
case Core::ATTR_DBNAME_FORMAT:
case Core::ATTR_DECIMAL_PLACES:
case Core::ATTR_DEF_TABLESPACE:
case Core::ATTR_DEF_TEXT_LENGTH:
case Core::ATTR_DEF_VARCHAR_LENGTH:
case Core::ATTR_DEFAULT_COLUMN_OPTIONS:
case Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS:
case Core::ATTR_DEFAULT_PARAM_NAMESPACE:
case Core::ATTR_DEFAULT_SEQUENCE:
case Core::ATTR_DEFAULT_TABLE_CHARSET:
case Core::ATTR_DEFAULT_TABLE_COLLATE:
case Core::ATTR_DEFAULT_TABLE_TYPE:
case Core::ATTR_DRIVER_NAME:
case Core::ATTR_EMULATE_DATABASE:
case Core::ATTR_ERRMODE:
case Core::ATTR_EXPORT:
case Core::ATTR_FETCH_CATALOG_NAMES:
case Core::ATTR_FETCH_TABLE_NAMES:
case Core::ATTR_FETCHMODE:
case Core::ATTR_FIELD_CASE:
case Core::ATTR_FKNAME_FORMAT:
case Core::ATTR_HYDRATE_OVERWRITE:
case Core::ATTR_IDXNAME_FORMAT:
case Core::ATTR_LISTENER:
case Core::ATTR_LOAD_REFERENCES:
case Core::ATTR_MAX_COLUMN_LEN:
case Core::ATTR_MAX_IDENTIFIER_LENGTH:
case Core::ATTR_MODEL_CLASS_PREFIX:
case Core::ATTR_MODEL_LOADING:
case Core::ATTR_NAME_PREFIX:
case Core::ATTR_ORACLE_NULLS:
case Core::ATTR_PERSISTENT:
case Core::ATTR_PORTABILITY:
case Core::ATTR_PREFETCH:
case Core::ATTR_QUERY_CACHE:
case Core::ATTR_QUERY_CACHE_LIFESPAN:
case Core::ATTR_QUERY_CLASS:
case Core::ATTR_QUERY_LIMIT:
case Core::ATTR_QUOTE_IDENTIFIER:
case Core::ATTR_RECORD_LISTENER:
case Core::ATTR_RECURSIVE_MERGE_FIXTURES:
case Core::ATTR_RESULT_CACHE:
case Core::ATTR_RESULT_CACHE_LIFESPAN:
case Core::ATTR_SEQCOL_NAME:
case Core::ATTR_SEQNAME_FORMAT:
case Core::ATTR_SERVER_INFO:
case Core::ATTR_SERVER_VERSION:
case Core::ATTR_STATEMENT_CLASS:
case Core::ATTR_STRINGIFY_FETCHES:
case Core::ATTR_TABLE_CLASS:
case Core::ATTR_TABLE_CLASS_FORMAT:
case Core::ATTR_TBLCLASS_FORMAT:
case Core::ATTR_TBLNAME_FORMAT:
case Core::ATTR_THROW_EXCEPTIONS:
case Core::ATTR_TIMEOUT:
case Core::ATTR_USE_DQL_CALLBACKS:
case Core::ATTR_USE_NATIVE_ENUM:
case Core::ATTR_USE_NATIVE_SET:
case Core::ATTR_VALIDATE:
$this->attributes[$attribute] = $value;
break;
default:
throw new Exception("Invalid attribute '{$attribute}'! Must be one of Core::ATTR_* constants.");
}
}
|
php
|
public function setAttribute($attribute, $value)
{
switch($attribute){
case Core::ATTR_AUTO_ACCESSOR_OVERRIDE:
case Core::ATTR_AUTO_FREE_QUERY_OBJECTS:
case Core::ATTR_AUTOCOMMIT:
case Core::ATTR_AUTOLOAD_TABLE_CLASSES:
case Core::ATTR_CACHE:
case Core::ATTR_CACHE_LIFESPAN:
case Core::ATTR_CASCADE_SAVES:
case Core::ATTR_CASE:
case Core::ATTR_CLIENT_VERSION:
case Core::ATTR_CMPNAME_FORMAT:
case Core::ATTR_COLL_KEY:
case Core::ATTR_COLL_LIMIT:
case Core::ATTR_COLLECTION_CLASS:
case Core::ATTR_CONNECTION_STATUS:
case Core::ATTR_CREATE_TABLES:
case Core::ATTR_CURSOR:
case Core::ATTR_CURSOR_NAME:
case Core::ATTR_DBNAME_FORMAT:
case Core::ATTR_DECIMAL_PLACES:
case Core::ATTR_DEF_TABLESPACE:
case Core::ATTR_DEF_TEXT_LENGTH:
case Core::ATTR_DEF_VARCHAR_LENGTH:
case Core::ATTR_DEFAULT_COLUMN_OPTIONS:
case Core::ATTR_DEFAULT_IDENTIFIER_OPTIONS:
case Core::ATTR_DEFAULT_PARAM_NAMESPACE:
case Core::ATTR_DEFAULT_SEQUENCE:
case Core::ATTR_DEFAULT_TABLE_CHARSET:
case Core::ATTR_DEFAULT_TABLE_COLLATE:
case Core::ATTR_DEFAULT_TABLE_TYPE:
case Core::ATTR_DRIVER_NAME:
case Core::ATTR_EMULATE_DATABASE:
case Core::ATTR_ERRMODE:
case Core::ATTR_EXPORT:
case Core::ATTR_FETCH_CATALOG_NAMES:
case Core::ATTR_FETCH_TABLE_NAMES:
case Core::ATTR_FETCHMODE:
case Core::ATTR_FIELD_CASE:
case Core::ATTR_FKNAME_FORMAT:
case Core::ATTR_HYDRATE_OVERWRITE:
case Core::ATTR_IDXNAME_FORMAT:
case Core::ATTR_LISTENER:
case Core::ATTR_LOAD_REFERENCES:
case Core::ATTR_MAX_COLUMN_LEN:
case Core::ATTR_MAX_IDENTIFIER_LENGTH:
case Core::ATTR_MODEL_CLASS_PREFIX:
case Core::ATTR_MODEL_LOADING:
case Core::ATTR_NAME_PREFIX:
case Core::ATTR_ORACLE_NULLS:
case Core::ATTR_PERSISTENT:
case Core::ATTR_PORTABILITY:
case Core::ATTR_PREFETCH:
case Core::ATTR_QUERY_CACHE:
case Core::ATTR_QUERY_CACHE_LIFESPAN:
case Core::ATTR_QUERY_CLASS:
case Core::ATTR_QUERY_LIMIT:
case Core::ATTR_QUOTE_IDENTIFIER:
case Core::ATTR_RECORD_LISTENER:
case Core::ATTR_RECURSIVE_MERGE_FIXTURES:
case Core::ATTR_RESULT_CACHE:
case Core::ATTR_RESULT_CACHE_LIFESPAN:
case Core::ATTR_SEQCOL_NAME:
case Core::ATTR_SEQNAME_FORMAT:
case Core::ATTR_SERVER_INFO:
case Core::ATTR_SERVER_VERSION:
case Core::ATTR_STATEMENT_CLASS:
case Core::ATTR_STRINGIFY_FETCHES:
case Core::ATTR_TABLE_CLASS:
case Core::ATTR_TABLE_CLASS_FORMAT:
case Core::ATTR_TBLCLASS_FORMAT:
case Core::ATTR_TBLNAME_FORMAT:
case Core::ATTR_THROW_EXCEPTIONS:
case Core::ATTR_TIMEOUT:
case Core::ATTR_USE_DQL_CALLBACKS:
case Core::ATTR_USE_NATIVE_ENUM:
case Core::ATTR_USE_NATIVE_SET:
case Core::ATTR_VALIDATE:
$this->attributes[$attribute] = $value;
break;
default:
throw new Exception("Invalid attribute '{$attribute}'! Must be one of Core::ATTR_* constants.");
}
}
|
[
"public",
"function",
"setAttribute",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"attribute",
")",
"{",
"case",
"Core",
"::",
"ATTR_AUTO_ACCESSOR_OVERRIDE",
":",
"case",
"Core",
"::",
"ATTR_AUTO_FREE_QUERY_OBJECTS",
":",
"case",
"Core",
"::",
"ATTR_AUTOCOMMIT",
":",
"case",
"Core",
"::",
"ATTR_AUTOLOAD_TABLE_CLASSES",
":",
"case",
"Core",
"::",
"ATTR_CACHE",
":",
"case",
"Core",
"::",
"ATTR_CACHE_LIFESPAN",
":",
"case",
"Core",
"::",
"ATTR_CASCADE_SAVES",
":",
"case",
"Core",
"::",
"ATTR_CASE",
":",
"case",
"Core",
"::",
"ATTR_CLIENT_VERSION",
":",
"case",
"Core",
"::",
"ATTR_CMPNAME_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_COLL_KEY",
":",
"case",
"Core",
"::",
"ATTR_COLL_LIMIT",
":",
"case",
"Core",
"::",
"ATTR_COLLECTION_CLASS",
":",
"case",
"Core",
"::",
"ATTR_CONNECTION_STATUS",
":",
"case",
"Core",
"::",
"ATTR_CREATE_TABLES",
":",
"case",
"Core",
"::",
"ATTR_CURSOR",
":",
"case",
"Core",
"::",
"ATTR_CURSOR_NAME",
":",
"case",
"Core",
"::",
"ATTR_DBNAME_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_DECIMAL_PLACES",
":",
"case",
"Core",
"::",
"ATTR_DEF_TABLESPACE",
":",
"case",
"Core",
"::",
"ATTR_DEF_TEXT_LENGTH",
":",
"case",
"Core",
"::",
"ATTR_DEF_VARCHAR_LENGTH",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_COLUMN_OPTIONS",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_IDENTIFIER_OPTIONS",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_PARAM_NAMESPACE",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_SEQUENCE",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_TABLE_CHARSET",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_TABLE_COLLATE",
":",
"case",
"Core",
"::",
"ATTR_DEFAULT_TABLE_TYPE",
":",
"case",
"Core",
"::",
"ATTR_DRIVER_NAME",
":",
"case",
"Core",
"::",
"ATTR_EMULATE_DATABASE",
":",
"case",
"Core",
"::",
"ATTR_ERRMODE",
":",
"case",
"Core",
"::",
"ATTR_EXPORT",
":",
"case",
"Core",
"::",
"ATTR_FETCH_CATALOG_NAMES",
":",
"case",
"Core",
"::",
"ATTR_FETCH_TABLE_NAMES",
":",
"case",
"Core",
"::",
"ATTR_FETCHMODE",
":",
"case",
"Core",
"::",
"ATTR_FIELD_CASE",
":",
"case",
"Core",
"::",
"ATTR_FKNAME_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_HYDRATE_OVERWRITE",
":",
"case",
"Core",
"::",
"ATTR_IDXNAME_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_LISTENER",
":",
"case",
"Core",
"::",
"ATTR_LOAD_REFERENCES",
":",
"case",
"Core",
"::",
"ATTR_MAX_COLUMN_LEN",
":",
"case",
"Core",
"::",
"ATTR_MAX_IDENTIFIER_LENGTH",
":",
"case",
"Core",
"::",
"ATTR_MODEL_CLASS_PREFIX",
":",
"case",
"Core",
"::",
"ATTR_MODEL_LOADING",
":",
"case",
"Core",
"::",
"ATTR_NAME_PREFIX",
":",
"case",
"Core",
"::",
"ATTR_ORACLE_NULLS",
":",
"case",
"Core",
"::",
"ATTR_PERSISTENT",
":",
"case",
"Core",
"::",
"ATTR_PORTABILITY",
":",
"case",
"Core",
"::",
"ATTR_PREFETCH",
":",
"case",
"Core",
"::",
"ATTR_QUERY_CACHE",
":",
"case",
"Core",
"::",
"ATTR_QUERY_CACHE_LIFESPAN",
":",
"case",
"Core",
"::",
"ATTR_QUERY_CLASS",
":",
"case",
"Core",
"::",
"ATTR_QUERY_LIMIT",
":",
"case",
"Core",
"::",
"ATTR_QUOTE_IDENTIFIER",
":",
"case",
"Core",
"::",
"ATTR_RECORD_LISTENER",
":",
"case",
"Core",
"::",
"ATTR_RECURSIVE_MERGE_FIXTURES",
":",
"case",
"Core",
"::",
"ATTR_RESULT_CACHE",
":",
"case",
"Core",
"::",
"ATTR_RESULT_CACHE_LIFESPAN",
":",
"case",
"Core",
"::",
"ATTR_SEQCOL_NAME",
":",
"case",
"Core",
"::",
"ATTR_SEQNAME_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_SERVER_INFO",
":",
"case",
"Core",
"::",
"ATTR_SERVER_VERSION",
":",
"case",
"Core",
"::",
"ATTR_STATEMENT_CLASS",
":",
"case",
"Core",
"::",
"ATTR_STRINGIFY_FETCHES",
":",
"case",
"Core",
"::",
"ATTR_TABLE_CLASS",
":",
"case",
"Core",
"::",
"ATTR_TABLE_CLASS_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_TBLCLASS_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_TBLNAME_FORMAT",
":",
"case",
"Core",
"::",
"ATTR_THROW_EXCEPTIONS",
":",
"case",
"Core",
"::",
"ATTR_TIMEOUT",
":",
"case",
"Core",
"::",
"ATTR_USE_DQL_CALLBACKS",
":",
"case",
"Core",
"::",
"ATTR_USE_NATIVE_ENUM",
":",
"case",
"Core",
"::",
"ATTR_USE_NATIVE_SET",
":",
"case",
"Core",
"::",
"ATTR_VALIDATE",
":",
"$",
"this",
"->",
"attributes",
"[",
"$",
"attribute",
"]",
"=",
"$",
"value",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"\"Invalid attribute '{$attribute}'! Must be one of Core::ATTR_* constants.\"",
")",
";",
"}",
"}"
] |
Set a statement attribute
@param integer $attribute
@param mixed $value the value of given attribute
@return boolean Returns TRUE on success or FALSE on failure.
|
[
"Set",
"a",
"statement",
"attribute"
] |
28dae64ffc2123f39f801a50ab53bfe29890cbd9
|
https://github.com/addiks/phpsql/blob/28dae64ffc2123f39f801a50ab53bfe29890cbd9/src/Addiks/PHPSQL/PDO/Statement.php#L601-L687
|
229,747
|
Webiny/Framework
|
src/Webiny/Component/Config/Drivers/YamlDriver.php
|
YamlDriver.setIndent
|
public function setIndent($indent)
{
if (!$this->isNumber($indent)) {
throw new ConfigException(ConfigException::MSG_INVALID_ARG, [
'$indent',
'integer'
]
);
}
$this->indent = $indent;
return $this;
}
|
php
|
public function setIndent($indent)
{
if (!$this->isNumber($indent)) {
throw new ConfigException(ConfigException::MSG_INVALID_ARG, [
'$indent',
'integer'
]
);
}
$this->indent = $indent;
return $this;
}
|
[
"public",
"function",
"setIndent",
"(",
"$",
"indent",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isNumber",
"(",
"$",
"indent",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"ConfigException",
"::",
"MSG_INVALID_ARG",
",",
"[",
"'$indent'",
",",
"'integer'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"indent",
"=",
"$",
"indent",
";",
"return",
"$",
"this",
";",
"}"
] |
Set Yaml indent
@param int $indent
@throws ConfigException
@return $this
|
[
"Set",
"Yaml",
"indent"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Config/Drivers/YamlDriver.php#L41-L53
|
229,748
|
Webiny/Framework
|
src/Webiny/Component/Config/Drivers/IniDriver.php
|
IniDriver.parseIniString
|
private function parseIniString($data)
{
$config = $this->arr();
$data = parse_ini_string($data, true);
foreach ($data as $section => $value) {
$config = $config->mergeRecursive($this->processValue($section, $value));
}
return $config;
}
|
php
|
private function parseIniString($data)
{
$config = $this->arr();
$data = parse_ini_string($data, true);
foreach ($data as $section => $value) {
$config = $config->mergeRecursive($this->processValue($section, $value));
}
return $config;
}
|
[
"private",
"function",
"parseIniString",
"(",
"$",
"data",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"arr",
"(",
")",
";",
"$",
"data",
"=",
"parse_ini_string",
"(",
"$",
"data",
",",
"true",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"section",
"=>",
"$",
"value",
")",
"{",
"$",
"config",
"=",
"$",
"config",
"->",
"mergeRecursive",
"(",
"$",
"this",
"->",
"processValue",
"(",
"$",
"section",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Parse INI string and return config array
@param array $data
@return array
|
[
"Parse",
"INI",
"string",
"and",
"return",
"config",
"array"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Config/Drivers/IniDriver.php#L85-L94
|
229,749
|
Webiny/Framework
|
src/Webiny/Component/Config/Drivers/IniDriver.php
|
IniDriver.processValue
|
private function processValue($section, $value, $config = [])
{
// Need to catch Exception in case INI string is not properly formed
try {
// Make sure $config is an ArrayObject
$config = $this->arr($config);
} catch (StdObjectException $e) {
$config = $this->arr();
}
// Create StringObject and trim invalid characters
$section = $this->str($section);
$this->validateSection($section);
// Handle nested sections, ex: parent.child.property
if ($section->contains($this->delimiter)) {
/**
* Explode section and only take 2 elements
* First element will be the new array key, and second will be passed for recursive processing
* Ex: parent.child.property will be split into 'parent' and 'child.property'
*/
$sections = $section->explode($this->delimiter, 2)->removeFirst($section);
$localConfig = $config->key($section, [], true);
$config->key($section, $this->processValue($sections->last()->val(), $value, $localConfig));
} else {
// If value is an array, we need to process it's keys
if ($this->isArray($value)) {
foreach ($value as $k => $v) {
$localConfig = $config->key($section, [], true);
$config->key($section, $this->processValue($k, $v, $localConfig));
}
} else {
$config->key($section, $value);
}
}
return $config->val();
}
|
php
|
private function processValue($section, $value, $config = [])
{
// Need to catch Exception in case INI string is not properly formed
try {
// Make sure $config is an ArrayObject
$config = $this->arr($config);
} catch (StdObjectException $e) {
$config = $this->arr();
}
// Create StringObject and trim invalid characters
$section = $this->str($section);
$this->validateSection($section);
// Handle nested sections, ex: parent.child.property
if ($section->contains($this->delimiter)) {
/**
* Explode section and only take 2 elements
* First element will be the new array key, and second will be passed for recursive processing
* Ex: parent.child.property will be split into 'parent' and 'child.property'
*/
$sections = $section->explode($this->delimiter, 2)->removeFirst($section);
$localConfig = $config->key($section, [], true);
$config->key($section, $this->processValue($sections->last()->val(), $value, $localConfig));
} else {
// If value is an array, we need to process it's keys
if ($this->isArray($value)) {
foreach ($value as $k => $v) {
$localConfig = $config->key($section, [], true);
$config->key($section, $this->processValue($k, $v, $localConfig));
}
} else {
$config->key($section, $value);
}
}
return $config->val();
}
|
[
"private",
"function",
"processValue",
"(",
"$",
"section",
",",
"$",
"value",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"// Need to catch Exception in case INI string is not properly formed",
"try",
"{",
"// Make sure $config is an ArrayObject",
"$",
"config",
"=",
"$",
"this",
"->",
"arr",
"(",
"$",
"config",
")",
";",
"}",
"catch",
"(",
"StdObjectException",
"$",
"e",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"arr",
"(",
")",
";",
"}",
"// Create StringObject and trim invalid characters",
"$",
"section",
"=",
"$",
"this",
"->",
"str",
"(",
"$",
"section",
")",
";",
"$",
"this",
"->",
"validateSection",
"(",
"$",
"section",
")",
";",
"// Handle nested sections, ex: parent.child.property",
"if",
"(",
"$",
"section",
"->",
"contains",
"(",
"$",
"this",
"->",
"delimiter",
")",
")",
"{",
"/**\n * Explode section and only take 2 elements\n * First element will be the new array key, and second will be passed for recursive processing\n * Ex: parent.child.property will be split into 'parent' and 'child.property'\n */",
"$",
"sections",
"=",
"$",
"section",
"->",
"explode",
"(",
"$",
"this",
"->",
"delimiter",
",",
"2",
")",
"->",
"removeFirst",
"(",
"$",
"section",
")",
";",
"$",
"localConfig",
"=",
"$",
"config",
"->",
"key",
"(",
"$",
"section",
",",
"[",
"]",
",",
"true",
")",
";",
"$",
"config",
"->",
"key",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"processValue",
"(",
"$",
"sections",
"->",
"last",
"(",
")",
"->",
"val",
"(",
")",
",",
"$",
"value",
",",
"$",
"localConfig",
")",
")",
";",
"}",
"else",
"{",
"// If value is an array, we need to process it's keys",
"if",
"(",
"$",
"this",
"->",
"isArray",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"localConfig",
"=",
"$",
"config",
"->",
"key",
"(",
"$",
"section",
",",
"[",
"]",
",",
"true",
")",
";",
"$",
"config",
"->",
"key",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"processValue",
"(",
"$",
"k",
",",
"$",
"v",
",",
"$",
"localConfig",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"config",
"->",
"key",
"(",
"$",
"section",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"config",
"->",
"val",
"(",
")",
";",
"}"
] |
Process given section and it's value
Config array is empty by default, but it's a nested recursive call, it will be populated with data from previous calls
@param string $section
@param string|array $value
@param array $config
@return array
|
[
"Process",
"given",
"section",
"and",
"it",
"s",
"value",
"Config",
"array",
"is",
"empty",
"by",
"default",
"but",
"it",
"s",
"a",
"nested",
"recursive",
"call",
"it",
"will",
"be",
"populated",
"with",
"data",
"from",
"previous",
"calls"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Config/Drivers/IniDriver.php#L106-L143
|
229,750
|
milesj/admin
|
Controller/AdminController.php
|
AdminController.index
|
public function index() {
$plugins = Admin::getModels();
$counts = array();
// Gather record counts
foreach ($plugins as $plugin) {
foreach ($plugin['models'] as $model) {
if ($model['installed']) {
$object = Admin::introspectModel($model['class']);
if ($object->hasMethod('getCount')) {
$count = $object->getCount();
} else {
$count = $object->find('count', array(
'cache' => array($model['class'], 'count'),
'cacheExpires' => '+24 hours'
));
}
$counts[$model['class']] = $count;
}
}
}
$this->set('plugins', $plugins);
$this->set('counts', $counts);
}
|
php
|
public function index() {
$plugins = Admin::getModels();
$counts = array();
// Gather record counts
foreach ($plugins as $plugin) {
foreach ($plugin['models'] as $model) {
if ($model['installed']) {
$object = Admin::introspectModel($model['class']);
if ($object->hasMethod('getCount')) {
$count = $object->getCount();
} else {
$count = $object->find('count', array(
'cache' => array($model['class'], 'count'),
'cacheExpires' => '+24 hours'
));
}
$counts[$model['class']] = $count;
}
}
}
$this->set('plugins', $plugins);
$this->set('counts', $counts);
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"plugins",
"=",
"Admin",
"::",
"getModels",
"(",
")",
";",
"$",
"counts",
"=",
"array",
"(",
")",
";",
"// Gather record counts",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"foreach",
"(",
"$",
"plugin",
"[",
"'models'",
"]",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"[",
"'installed'",
"]",
")",
"{",
"$",
"object",
"=",
"Admin",
"::",
"introspectModel",
"(",
"$",
"model",
"[",
"'class'",
"]",
")",
";",
"if",
"(",
"$",
"object",
"->",
"hasMethod",
"(",
"'getCount'",
")",
")",
"{",
"$",
"count",
"=",
"$",
"object",
"->",
"getCount",
"(",
")",
";",
"}",
"else",
"{",
"$",
"count",
"=",
"$",
"object",
"->",
"find",
"(",
"'count'",
",",
"array",
"(",
"'cache'",
"=>",
"array",
"(",
"$",
"model",
"[",
"'class'",
"]",
",",
"'count'",
")",
",",
"'cacheExpires'",
"=>",
"'+24 hours'",
")",
")",
";",
"}",
"$",
"counts",
"[",
"$",
"model",
"[",
"'class'",
"]",
"]",
"=",
"$",
"count",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"set",
"(",
"'plugins'",
",",
"$",
"plugins",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'counts'",
",",
"$",
"counts",
")",
";",
"}"
] |
List out all models and plugins.
|
[
"List",
"out",
"all",
"models",
"and",
"plugins",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/AdminController.php#L13-L39
|
229,751
|
milesj/admin
|
Controller/AdminController.php
|
AdminController.config
|
public function config() {
$config = Configure::read();
unset($config['debug']);
ksort($config);
$this->set('configuration', $config);
}
|
php
|
public function config() {
$config = Configure::read();
unset($config['debug']);
ksort($config);
$this->set('configuration', $config);
}
|
[
"public",
"function",
"config",
"(",
")",
"{",
"$",
"config",
"=",
"Configure",
"::",
"read",
"(",
")",
";",
"unset",
"(",
"$",
"config",
"[",
"'debug'",
"]",
")",
";",
"ksort",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'configuration'",
",",
"$",
"config",
")",
";",
"}"
] |
Display all configuration grouped by system.
|
[
"Display",
"all",
"configuration",
"grouped",
"by",
"system",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/AdminController.php#L51-L57
|
229,752
|
milesj/admin
|
Controller/AdminController.php
|
AdminController.cache
|
public function cache() {
$config = array();
foreach (Cache::configured() as $key) {
$temp = Cache::config($key);
$config[$key] = $temp['settings'];
}
ksort($config);
$this->set('configuration', $config);
}
|
php
|
public function cache() {
$config = array();
foreach (Cache::configured() as $key) {
$temp = Cache::config($key);
$config[$key] = $temp['settings'];
}
ksort($config);
$this->set('configuration', $config);
}
|
[
"public",
"function",
"cache",
"(",
")",
"{",
"$",
"config",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"Cache",
"::",
"configured",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"temp",
"=",
"Cache",
"::",
"config",
"(",
"$",
"key",
")",
";",
"$",
"config",
"[",
"$",
"key",
"]",
"=",
"$",
"temp",
"[",
"'settings'",
"]",
";",
"}",
"ksort",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"set",
"(",
"'configuration'",
",",
"$",
"config",
")",
";",
"}"
] |
Display all cache configurations.
|
[
"Display",
"all",
"cache",
"configurations",
"."
] |
e5e93823d1eb4415f05a3191f653eb50c296d2c6
|
https://github.com/milesj/admin/blob/e5e93823d1eb4415f05a3191f653eb50c296d2c6/Controller/AdminController.php#L62-L73
|
229,753
|
Webiny/Framework
|
src/Webiny/Component/Http/Response/CacheControl.php
|
CacheControl.setAsDontCache
|
public function setAsDontCache()
{
$this->cacheControl->key('Expires', -1);
$this->cacheControl->key('Pragma', 'no-cache');
$this->cacheControl->key('Cache-Control', 'no-cache, must-revalidate');
return $this;
}
|
php
|
public function setAsDontCache()
{
$this->cacheControl->key('Expires', -1);
$this->cacheControl->key('Pragma', 'no-cache');
$this->cacheControl->key('Cache-Control', 'no-cache, must-revalidate');
return $this;
}
|
[
"public",
"function",
"setAsDontCache",
"(",
")",
"{",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"'Expires'",
",",
"-",
"1",
")",
";",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"'Pragma'",
",",
"'no-cache'",
")",
";",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"'Cache-Control'",
",",
"'no-cache, must-revalidate'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Populates the current cache control headers with options so the content is not cached by the browser.
These headers are returned with each response by default.
@return $this
|
[
"Populates",
"the",
"current",
"cache",
"control",
"headers",
"with",
"options",
"so",
"the",
"content",
"is",
"not",
"cached",
"by",
"the",
"browser",
".",
"These",
"headers",
"are",
"returned",
"with",
"each",
"response",
"by",
"default",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Response/CacheControl.php#L56-L63
|
229,754
|
Webiny/Framework
|
src/Webiny/Component/Http/Response/CacheControl.php
|
CacheControl.setAsCache
|
public function setAsCache(DateTimeObject $expirationDate)
{
$expirationDateFormatted = date('D, d M Y H:i:s', $expirationDate->getTimestamp());
$this->cacheControl->key('Expires', $expirationDateFormatted . ' GMT');
$maxAge = $expirationDate->getTimestamp() - time();
$this->cacheControl->key('Cache-Control', 'private, max-age=' . $maxAge);
$this->cacheControl->key('Last-Modified', date('D, d M Y H:i:s') . ' GMT');
return $this;
}
|
php
|
public function setAsCache(DateTimeObject $expirationDate)
{
$expirationDateFormatted = date('D, d M Y H:i:s', $expirationDate->getTimestamp());
$this->cacheControl->key('Expires', $expirationDateFormatted . ' GMT');
$maxAge = $expirationDate->getTimestamp() - time();
$this->cacheControl->key('Cache-Control', 'private, max-age=' . $maxAge);
$this->cacheControl->key('Last-Modified', date('D, d M Y H:i:s') . ' GMT');
return $this;
}
|
[
"public",
"function",
"setAsCache",
"(",
"DateTimeObject",
"$",
"expirationDate",
")",
"{",
"$",
"expirationDateFormatted",
"=",
"date",
"(",
"'D, d M Y H:i:s'",
",",
"$",
"expirationDate",
"->",
"getTimestamp",
"(",
")",
")",
";",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"'Expires'",
",",
"$",
"expirationDateFormatted",
".",
"' GMT'",
")",
";",
"$",
"maxAge",
"=",
"$",
"expirationDate",
"->",
"getTimestamp",
"(",
")",
"-",
"time",
"(",
")",
";",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"'Cache-Control'",
",",
"'private, max-age='",
".",
"$",
"maxAge",
")",
";",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"'Last-Modified'",
",",
"date",
"(",
"'D, d M Y H:i:s'",
")",
".",
"' GMT'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Populates the cache control headers with options so that the browser caches the content.
@param DateTimeObject $expirationDate Defines the date when the cache should expire.
@return $this
|
[
"Populates",
"the",
"cache",
"control",
"headers",
"with",
"options",
"so",
"that",
"the",
"browser",
"caches",
"the",
"content",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Response/CacheControl.php#L72-L83
|
229,755
|
Webiny/Framework
|
src/Webiny/Component/Http/Response/CacheControl.php
|
CacheControl.setCacheControl
|
public function setCacheControl(array $cacheControl)
{
//validate headers
foreach ($cacheControl as $k => $v) {
if (!$this->validateCacheControlHeader($k)) {
throw new ResponseException('Invalid cache control header "' . $v . '".');
}
}
$this->cacheControl = $this->arr($cacheControl);
return $this;
}
|
php
|
public function setCacheControl(array $cacheControl)
{
//validate headers
foreach ($cacheControl as $k => $v) {
if (!$this->validateCacheControlHeader($k)) {
throw new ResponseException('Invalid cache control header "' . $v . '".');
}
}
$this->cacheControl = $this->arr($cacheControl);
return $this;
}
|
[
"public",
"function",
"setCacheControl",
"(",
"array",
"$",
"cacheControl",
")",
"{",
"//validate headers",
"foreach",
"(",
"$",
"cacheControl",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateCacheControlHeader",
"(",
"$",
"k",
")",
")",
"{",
"throw",
"new",
"ResponseException",
"(",
"'Invalid cache control header \"'",
".",
"$",
"v",
".",
"'\".'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"cacheControl",
"=",
"$",
"this",
"->",
"arr",
"(",
"$",
"cacheControl",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Overwrites the current cache control headers.
@param array $cacheControl Array containing new cache control headers.
@throws ResponseException
@return $this
|
[
"Overwrites",
"the",
"current",
"cache",
"control",
"headers",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Response/CacheControl.php#L103-L115
|
229,756
|
Webiny/Framework
|
src/Webiny/Component/Http/Response/CacheControl.php
|
CacheControl.setCacheControlEntry
|
public function setCacheControlEntry($key, $value)
{
if (!$this->validateCacheControlHeader($key)) {
throw new ResponseException('Invalid cache control header "' . $key . '".');
}
$this->cacheControl->key($key, $value);
return $this;
}
|
php
|
public function setCacheControlEntry($key, $value)
{
if (!$this->validateCacheControlHeader($key)) {
throw new ResponseException('Invalid cache control header "' . $key . '".');
}
$this->cacheControl->key($key, $value);
return $this;
}
|
[
"public",
"function",
"setCacheControlEntry",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateCacheControlHeader",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"ResponseException",
"(",
"'Invalid cache control header \"'",
".",
"$",
"key",
".",
"'\".'",
")",
";",
"}",
"$",
"this",
"->",
"cacheControl",
"->",
"key",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets or adds an entry to cache control headers.
@param string $key Cache control header name.
@param string $value Cache control header value.
@throws ResponseException
@return $this
|
[
"Sets",
"or",
"adds",
"an",
"entry",
"to",
"cache",
"control",
"headers",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Http/Response/CacheControl.php#L126-L135
|
229,757
|
ZenMagick/ZenCart
|
includes/classes/order_total.php
|
order_total.collect_posts
|
function collect_posts() {
if (MODULE_ORDER_TOTAL_INSTALLED) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ( $GLOBALS[$class]->credit_class ) {
$post_var = 'c' . $GLOBALS[$class]->code;
if ($_POST[$post_var]) $_SESSION[$post_var] = $_POST[$post_var];
$GLOBALS[$class]->collect_posts();
}
}
}
}
|
php
|
function collect_posts() {
if (MODULE_ORDER_TOTAL_INSTALLED) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ( $GLOBALS[$class]->credit_class ) {
$post_var = 'c' . $GLOBALS[$class]->code;
if ($_POST[$post_var]) $_SESSION[$post_var] = $_POST[$post_var];
$GLOBALS[$class]->collect_posts();
}
}
}
}
|
[
"function",
"collect_posts",
"(",
")",
"{",
"if",
"(",
"MODULE_ORDER_TOTAL_INSTALLED",
")",
"{",
"reset",
"(",
"$",
"this",
"->",
"modules",
")",
";",
"while",
"(",
"list",
"(",
",",
"$",
"value",
")",
"=",
"each",
"(",
"$",
"this",
"->",
"modules",
")",
")",
"{",
"$",
"class",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"strrpos",
"(",
"$",
"value",
",",
"'.'",
")",
")",
";",
"if",
"(",
"$",
"GLOBALS",
"[",
"$",
"class",
"]",
"->",
"credit_class",
")",
"{",
"$",
"post_var",
"=",
"'c'",
".",
"$",
"GLOBALS",
"[",
"$",
"class",
"]",
"->",
"code",
";",
"if",
"(",
"$",
"_POST",
"[",
"$",
"post_var",
"]",
")",
"$",
"_SESSION",
"[",
"$",
"post_var",
"]",
"=",
"$",
"_POST",
"[",
"$",
"post_var",
"]",
";",
"$",
"GLOBALS",
"[",
"$",
"class",
"]",
"->",
"collect_posts",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
with an error
|
[
"with",
"an",
"error"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/classes/order_total.php#L155-L167
|
229,758
|
themsaid/katana-core
|
src/MarkdownFileBuilder.php
|
MarkdownFileBuilder.render
|
public function render()
{
$viewContent = $this->buildBladeViewContent();
if ($this->isExpired()) {
$this->filesystem->put($this->cached, $this->bladeCompiler->compileString($viewContent));
}
$data = $this->getViewData();
return $this->engine->get($this->cached, $data);
}
|
php
|
public function render()
{
$viewContent = $this->buildBladeViewContent();
if ($this->isExpired()) {
$this->filesystem->put($this->cached, $this->bladeCompiler->compileString($viewContent));
}
$data = $this->getViewData();
return $this->engine->get($this->cached, $data);
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"viewContent",
"=",
"$",
"this",
"->",
"buildBladeViewContent",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isExpired",
"(",
")",
")",
"{",
"$",
"this",
"->",
"filesystem",
"->",
"put",
"(",
"$",
"this",
"->",
"cached",
",",
"$",
"this",
"->",
"bladeCompiler",
"->",
"compileString",
"(",
"$",
"viewContent",
")",
")",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"getViewData",
"(",
")",
";",
"return",
"$",
"this",
"->",
"engine",
"->",
"get",
"(",
"$",
"this",
"->",
"cached",
",",
"$",
"data",
")",
";",
"}"
] |
Get the evaluated contents of the file.
|
[
"Get",
"the",
"evaluated",
"contents",
"of",
"the",
"file",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/MarkdownFileBuilder.php#L83-L94
|
229,759
|
themsaid/katana-core
|
src/MarkdownFileBuilder.php
|
MarkdownFileBuilder.buildBladeViewContent
|
protected function buildBladeViewContent()
{
$sections = '';
foreach ($this->fileYAML as $name => $value) {
$sections .= "@section('$name', '".addslashes($value)."')\n\r";
}
return
"@extends('{$this->fileYAML['view::extends']}')
$sections
@section('{$this->fileYAML['view::yields']}')
{$this->fileContent}
@stop";
}
|
php
|
protected function buildBladeViewContent()
{
$sections = '';
foreach ($this->fileYAML as $name => $value) {
$sections .= "@section('$name', '".addslashes($value)."')\n\r";
}
return
"@extends('{$this->fileYAML['view::extends']}')
$sections
@section('{$this->fileYAML['view::yields']}')
{$this->fileContent}
@stop";
}
|
[
"protected",
"function",
"buildBladeViewContent",
"(",
")",
"{",
"$",
"sections",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"fileYAML",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"sections",
".=",
"\"@section('$name', '\"",
".",
"addslashes",
"(",
"$",
"value",
")",
".",
"\"')\\n\\r\"",
";",
"}",
"return",
"\"@extends('{$this->fileYAML['view::extends']}')\n $sections\n @section('{$this->fileYAML['view::yields']}')\n {$this->fileContent}\n @stop\"",
";",
"}"
] |
Build the content of the imaginary blade view.
@return string
|
[
"Build",
"the",
"content",
"of",
"the",
"imaginary",
"blade",
"view",
"."
] |
897c1adb6863d5145f1f104cbc8c9200cd98c3fb
|
https://github.com/themsaid/katana-core/blob/897c1adb6863d5145f1f104cbc8c9200cd98c3fb/src/MarkdownFileBuilder.php#L101-L115
|
229,760
|
Webiny/Framework
|
src/Webiny/Component/Security/Token/Token.php
|
Token.setRememberMe
|
public function setRememberMe($rememberMe)
{
$this->rememberMe = $rememberMe;
$this->storage->setTokenRememberMe($rememberMe);
return $this;
}
|
php
|
public function setRememberMe($rememberMe)
{
$this->rememberMe = $rememberMe;
$this->storage->setTokenRememberMe($rememberMe);
return $this;
}
|
[
"public",
"function",
"setRememberMe",
"(",
"$",
"rememberMe",
")",
"{",
"$",
"this",
"->",
"rememberMe",
"=",
"$",
"rememberMe",
";",
"$",
"this",
"->",
"storage",
"->",
"setTokenRememberMe",
"(",
"$",
"rememberMe",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Should token be remembered or not
@param bool $rememberMe
@return $this
|
[
"Should",
"token",
"be",
"remembered",
"or",
"not"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Security/Token/Token.php#L107-L113
|
229,761
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.getObject
|
public function getObject($bucket, $key, array $params = [])
{
$params['Bucket'] = $bucket;
$params['Key'] = $key;
return $this->instance->getObject($params);
}
|
php
|
public function getObject($bucket, $key, array $params = [])
{
$params['Bucket'] = $bucket;
$params['Key'] = $key;
return $this->instance->getObject($params);
}
|
[
"public",
"function",
"getObject",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'Bucket'",
"]",
"=",
"$",
"bucket",
";",
"$",
"params",
"[",
"'Key'",
"]",
"=",
"$",
"key",
";",
"return",
"$",
"this",
"->",
"instance",
"->",
"getObject",
"(",
"$",
"params",
")",
";",
"}"
] |
Get object identified by bucket and key
@param string $bucket
@param string $key
@param array $params
@return mixed
|
[
"Get",
"object",
"identified",
"by",
"bucket",
"and",
"key"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L62-L68
|
229,762
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.deleteMatchingObjects
|
public function deleteMatchingObjects($bucket, $prefix = '', $regex = '', array $options = [])
{
return $this->instance->deleteMatchingObjects($bucket, $prefix, $regex, $options);
}
|
php
|
public function deleteMatchingObjects($bucket, $prefix = '', $regex = '', array $options = [])
{
return $this->instance->deleteMatchingObjects($bucket, $prefix, $regex, $options);
}
|
[
"public",
"function",
"deleteMatchingObjects",
"(",
"$",
"bucket",
",",
"$",
"prefix",
"=",
"''",
",",
"$",
"regex",
"=",
"''",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"instance",
"->",
"deleteMatchingObjects",
"(",
"$",
"bucket",
",",
"$",
"prefix",
",",
"$",
"regex",
",",
"$",
"options",
")",
";",
"}"
] |
Deletes objects from Amazon S3 that match the result of a ListObjects operation. For example, this allows you
to do things like delete all objects that match a specific key prefix.
@param string $bucket Bucket that contains the object keys
@param string $prefix Optionally delete only objects under this key prefix
@param string $regex Delete only objects that match this regex
@param array $options Options used when deleting the object:
- before_delete: Callback to invoke before each delete. The callback will receive a
Guzzle\Common\Event object with context.
@see Aws\S3\S3Client::listObjects
@see Aws\S3\Model\ClearBucket For more options or customization
@return int Returns the number of deleted keys
@throws \RuntimeException if no prefix and no regex is given
|
[
"Deletes",
"objects",
"from",
"Amazon",
"S3",
"that",
"match",
"the",
"result",
"of",
"a",
"ListObjects",
"operation",
".",
"For",
"example",
"this",
"allows",
"you",
"to",
"do",
"things",
"like",
"delete",
"all",
"objects",
"that",
"match",
"a",
"specific",
"key",
"prefix",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L180-L183
|
229,763
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.restoreObject
|
public function restoreObject($bucket, $key, $days)
{
$params = [
'Bucket' => $bucket,
'Key' => $key,
'Days' => $days
];
return $this->instance->restoreObject($params);
}
|
php
|
public function restoreObject($bucket, $key, $days)
{
$params = [
'Bucket' => $bucket,
'Key' => $key,
'Days' => $days
];
return $this->instance->restoreObject($params);
}
|
[
"public",
"function",
"restoreObject",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"$",
"days",
")",
"{",
"$",
"params",
"=",
"[",
"'Bucket'",
"=>",
"$",
"bucket",
",",
"'Key'",
"=>",
"$",
"key",
",",
"'Days'",
"=>",
"$",
"days",
"]",
";",
"return",
"$",
"this",
"->",
"instance",
"->",
"restoreObject",
"(",
"$",
"params",
")",
";",
"}"
] |
Restores an archived copy of an object back into Amazon S3
@param string $bucket
@param string $key
@param int $days
@internal param array $args
@return mixed
|
[
"Restores",
"an",
"archived",
"copy",
"of",
"an",
"object",
"back",
"into",
"Amazon",
"S3"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L212-L221
|
229,764
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.uploadDirectory
|
public function uploadDirectory($directory, $bucket, $keyPrefix = null, array $options = [])
{
return $this->instance->uploadDirectory($directory, $bucket, $keyPrefix, $options);
}
|
php
|
public function uploadDirectory($directory, $bucket, $keyPrefix = null, array $options = [])
{
return $this->instance->uploadDirectory($directory, $bucket, $keyPrefix, $options);
}
|
[
"public",
"function",
"uploadDirectory",
"(",
"$",
"directory",
",",
"$",
"bucket",
",",
"$",
"keyPrefix",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"instance",
"->",
"uploadDirectory",
"(",
"$",
"directory",
",",
"$",
"bucket",
",",
"$",
"keyPrefix",
",",
"$",
"options",
")",
";",
"}"
] |
Recursively uploads all files in a given directory to a given bucket.
@param string $directory Full path to a directory to upload
@param string $bucket Name of the bucket
@param string $keyPrefix Virtual directory key prefix to add to each upload
@param array $options Associative array of upload options
- params: Array of parameters to use with each PutObject operation performed during the transfer
- base_dir: Base directory to remove from each object key
- force: Set to true to upload every file, even if the file is already in Amazon S3 and has not changed
- concurrency: Maximum number of parallel uploads (defaults to 10)
- debug: Set to true or an fopen resource to enable debug mode to print information about each upload
- multipart_upload_size: When the size of a file exceeds this value, the file will be uploaded using a
multipart upload.
@see Aws\S3\S3Sync\S3Sync for more options and customization
|
[
"Recursively",
"uploads",
"all",
"files",
"in",
"a",
"given",
"directory",
"to",
"a",
"given",
"bucket",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L338-L341
|
229,765
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.copyObject
|
public function copyObject($sourceBucket, $sourceKey, $targetBucket, $targetKey, array $params = [])
{
$params['Bucket'] = $targetBucket;
$params['Key'] = $targetKey;
$params['CopySource'] = urlencode($sourceBucket . '/' . $sourceKey);
return $this->instance->copyObject($params);
}
|
php
|
public function copyObject($sourceBucket, $sourceKey, $targetBucket, $targetKey, array $params = [])
{
$params['Bucket'] = $targetBucket;
$params['Key'] = $targetKey;
$params['CopySource'] = urlencode($sourceBucket . '/' . $sourceKey);
return $this->instance->copyObject($params);
}
|
[
"public",
"function",
"copyObject",
"(",
"$",
"sourceBucket",
",",
"$",
"sourceKey",
",",
"$",
"targetBucket",
",",
"$",
"targetKey",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'Bucket'",
"]",
"=",
"$",
"targetBucket",
";",
"$",
"params",
"[",
"'Key'",
"]",
"=",
"$",
"targetKey",
";",
"$",
"params",
"[",
"'CopySource'",
"]",
"=",
"urlencode",
"(",
"$",
"sourceBucket",
".",
"'/'",
".",
"$",
"sourceKey",
")",
";",
"return",
"$",
"this",
"->",
"instance",
"->",
"copyObject",
"(",
"$",
"params",
")",
";",
"}"
] |
Creates a copy of an object that is already stored in Amazon S3.
@param string $sourceBucket
@param string $sourceKey
@param string $targetBucket
@param string $targetKey
@param array $params
@return mixed
|
[
"Creates",
"a",
"copy",
"of",
"an",
"object",
"that",
"is",
"already",
"stored",
"in",
"Amazon",
"S3",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L354-L361
|
229,766
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.deleteObjects
|
public function deleteObjects($bucket, array $objects)
{
$params = [
'Bucket' => $bucket,
'Objects' => []
];
foreach ($objects as $object) {
$objects[] = [
'Key' => $object
];
}
return $this->instance->deleteObjects($params);
}
|
php
|
public function deleteObjects($bucket, array $objects)
{
$params = [
'Bucket' => $bucket,
'Objects' => []
];
foreach ($objects as $object) {
$objects[] = [
'Key' => $object
];
}
return $this->instance->deleteObjects($params);
}
|
[
"public",
"function",
"deleteObjects",
"(",
"$",
"bucket",
",",
"array",
"$",
"objects",
")",
"{",
"$",
"params",
"=",
"[",
"'Bucket'",
"=>",
"$",
"bucket",
",",
"'Objects'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"objects",
"[",
"]",
"=",
"[",
"'Key'",
"=>",
"$",
"object",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"instance",
"->",
"deleteObjects",
"(",
"$",
"params",
")",
";",
"}"
] |
This operation enables you to delete multiple objects from a bucket using a single HTTP request.
You may specify up to 1000 keys.
@param string $bucket
@param array $objects
@return mixed
|
[
"This",
"operation",
"enables",
"you",
"to",
"delete",
"multiple",
"objects",
"from",
"a",
"bucket",
"using",
"a",
"single",
"HTTP",
"request",
".",
"You",
"may",
"specify",
"up",
"to",
"1000",
"keys",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L420-L433
|
229,767
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.getObjectUrl
|
public function getObjectUrl($bucket, $key, $expires = null, array $args = [])
{
return $this->instance->getObjectUrl($bucket, $key, $expires, $args);
}
|
php
|
public function getObjectUrl($bucket, $key, $expires = null, array $args = [])
{
return $this->instance->getObjectUrl($bucket, $key, $expires, $args);
}
|
[
"public",
"function",
"getObjectUrl",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"$",
"expires",
"=",
"null",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"instance",
"->",
"getObjectUrl",
"(",
"$",
"bucket",
",",
"$",
"key",
",",
"$",
"expires",
",",
"$",
"args",
")",
";",
"}"
] |
Returns the URL to an object identified by its bucket and key. If an expiration time is provided, the URL will
be signed and set to expire at the provided time.
@param string $bucket The name of the bucket where the object is located
@param string $key The key of the object
@param mixed $expires The time at which the URL should expire
@param array $args Arguments to the GetObject command. Additionally you can specify a "Scheme" if you would
like the URL to use a different scheme than what the client is configured to use
@return string The URL to the object
|
[
"Returns",
"the",
"URL",
"to",
"an",
"object",
"identified",
"by",
"its",
"bucket",
"and",
"key",
".",
"If",
"an",
"expiration",
"time",
"is",
"provided",
"the",
"URL",
"will",
"be",
"signed",
"and",
"set",
"to",
"expire",
"at",
"the",
"provided",
"time",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L457-L460
|
229,768
|
Webiny/Framework
|
src/Webiny/Component/Amazon/Bridge/S3/S3.php
|
S3.downloadBucket
|
public function downloadBucket($directory, $bucket, $keyPrefix = '', array $options = [])
{
return $this->instance->downloadBucket($directory, $bucket, $keyPrefix, $options);
}
|
php
|
public function downloadBucket($directory, $bucket, $keyPrefix = '', array $options = [])
{
return $this->instance->downloadBucket($directory, $bucket, $keyPrefix, $options);
}
|
[
"public",
"function",
"downloadBucket",
"(",
"$",
"directory",
",",
"$",
"bucket",
",",
"$",
"keyPrefix",
"=",
"''",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"instance",
"->",
"downloadBucket",
"(",
"$",
"directory",
",",
"$",
"bucket",
",",
"$",
"keyPrefix",
",",
"$",
"options",
")",
";",
"}"
] |
Downloads a bucket to the local filesystem
@param string $directory Directory to download to
@param string $bucket Bucket to download from
@param string $keyPrefix Only download objects that use this key prefix
@param array $options Associative array of download options
- params: Array of parameters to use with each GetObject operation performed during the transfer
- base_dir: Base directory to remove from each object key when storing in the local filesystem
- force: Set to true to download every file, even if the file is already on the local filesystem and has not
changed
- concurrency: Maximum number of parallel downloads (defaults to 10)
- debug: Set to true or a fopen resource to enable debug mode to print information about each download
- allow_resumable: Set to true to allow previously interrupted downloads to be resumed using a Range GET
|
[
"Downloads",
"a",
"bucket",
"to",
"the",
"local",
"filesystem"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Amazon/Bridge/S3/S3.php#L477-L480
|
229,769
|
Webiny/Framework
|
src/Webiny/Component/Entity/Attribute/AbstractAttribute.php
|
AbstractAttribute.attr
|
public function attr($attribute = null)
{
if ($this->isNull($attribute)) {
return $this->attribute;
}
return $this->parent->attr($attribute);
}
|
php
|
public function attr($attribute = null)
{
if ($this->isNull($attribute)) {
return $this->attribute;
}
return $this->parent->attr($attribute);
}
|
[
"public",
"function",
"attr",
"(",
"$",
"attribute",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNull",
"(",
"$",
"attribute",
")",
")",
"{",
"return",
"$",
"this",
"->",
"attribute",
";",
"}",
"return",
"$",
"this",
"->",
"parent",
"->",
"attr",
"(",
"$",
"attribute",
")",
";",
"}"
] |
Create new attribute or get name of current attribute
@param null|string $attribute
@return EntityAttributeContainer|string
|
[
"Create",
"new",
"attribute",
"or",
"get",
"name",
"of",
"current",
"attribute"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Entity/Attribute/AbstractAttribute.php#L339-L346
|
229,770
|
Webiny/Framework
|
src/Webiny/Component/Entity/Attribute/AbstractAttribute.php
|
AbstractAttribute.setValidators
|
public function setValidators($validators = [])
{
if (is_array($validators)) {
$this->validators = $validators;
} else {
$this->validators = func_get_args();
if (count($this->validators) == 1 && is_string($this->validators[0])) {
$this->validators = explode(',', $this->validators[0]);
}
}
if (in_array('required', $this->validators)) {
$this->setRequired();
unset($this->validators[array_search('required', $this->validators)]);
}
return $this;
}
|
php
|
public function setValidators($validators = [])
{
if (is_array($validators)) {
$this->validators = $validators;
} else {
$this->validators = func_get_args();
if (count($this->validators) == 1 && is_string($this->validators[0])) {
$this->validators = explode(',', $this->validators[0]);
}
}
if (in_array('required', $this->validators)) {
$this->setRequired();
unset($this->validators[array_search('required', $this->validators)]);
}
return $this;
}
|
[
"public",
"function",
"setValidators",
"(",
"$",
"validators",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"validators",
")",
")",
"{",
"$",
"this",
"->",
"validators",
"=",
"$",
"validators",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"validators",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"validators",
")",
"==",
"1",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"validators",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"validators",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"validators",
"[",
"0",
"]",
")",
";",
"}",
"}",
"if",
"(",
"in_array",
"(",
"'required'",
",",
"$",
"this",
"->",
"validators",
")",
")",
"{",
"$",
"this",
"->",
"setRequired",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"validators",
"[",
"array_search",
"(",
"'required'",
",",
"$",
"this",
"->",
"validators",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set attribute validators
@param array|string $validators
@return $this
|
[
"Set",
"attribute",
"validators"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Entity/Attribute/AbstractAttribute.php#L576-L595
|
229,771
|
Webiny/Framework
|
src/Webiny/Component/Entity/Attribute/AbstractAttribute.php
|
AbstractAttribute.getValidationMessages
|
public function getValidationMessages($validator = null)
{
if ($validator) {
return isset($this->validationMessages[$validator]) ? $this->validationMessages[$validator] : null;
}
return $this->validationMessages;
}
|
php
|
public function getValidationMessages($validator = null)
{
if ($validator) {
return isset($this->validationMessages[$validator]) ? $this->validationMessages[$validator] : null;
}
return $this->validationMessages;
}
|
[
"public",
"function",
"getValidationMessages",
"(",
"$",
"validator",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"validator",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"validationMessages",
"[",
"$",
"validator",
"]",
")",
"?",
"$",
"this",
"->",
"validationMessages",
"[",
"$",
"validator",
"]",
":",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"validationMessages",
";",
"}"
] |
Get validation messages
@param string|null $validator If given, returns validation message for given validator
@return mixed
|
[
"Get",
"validation",
"messages"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Entity/Attribute/AbstractAttribute.php#L627-L634
|
229,772
|
Webiny/Framework
|
src/Webiny/Component/Entity/Attribute/AbstractAttribute.php
|
AbstractAttribute.applyValidator
|
protected function applyValidator($validator, $key, $value, $messages = [])
{
try {
if ($this->isString($validator)) {
$params = $this->arr(explode(':', $validator));
$vName = '';
$validatorParams = [$this, $value, $params->removeFirst($vName)->val()];
$validator = Entity::getInstance()->getValidator($vName);
if (!$validator) {
throw new ValidationException('Validator does not exist');
}
$validator->validate(...$validatorParams);
} elseif ($this->isCallable($validator)) {
$vName = 'callable';
$validator($value, $this);
}
} catch (ValidationException $e) {
$msg = isset($messages[$vName]) ? $messages[$vName] : $e->getMessage();
$ex = new ValidationException($msg);
$ex->addError($key, $msg);
throw $ex;
}
}
|
php
|
protected function applyValidator($validator, $key, $value, $messages = [])
{
try {
if ($this->isString($validator)) {
$params = $this->arr(explode(':', $validator));
$vName = '';
$validatorParams = [$this, $value, $params->removeFirst($vName)->val()];
$validator = Entity::getInstance()->getValidator($vName);
if (!$validator) {
throw new ValidationException('Validator does not exist');
}
$validator->validate(...$validatorParams);
} elseif ($this->isCallable($validator)) {
$vName = 'callable';
$validator($value, $this);
}
} catch (ValidationException $e) {
$msg = isset($messages[$vName]) ? $messages[$vName] : $e->getMessage();
$ex = new ValidationException($msg);
$ex->addError($key, $msg);
throw $ex;
}
}
|
[
"protected",
"function",
"applyValidator",
"(",
"$",
"validator",
",",
"$",
"key",
",",
"$",
"value",
",",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"isString",
"(",
"$",
"validator",
")",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"arr",
"(",
"explode",
"(",
"':'",
",",
"$",
"validator",
")",
")",
";",
"$",
"vName",
"=",
"''",
";",
"$",
"validatorParams",
"=",
"[",
"$",
"this",
",",
"$",
"value",
",",
"$",
"params",
"->",
"removeFirst",
"(",
"$",
"vName",
")",
"->",
"val",
"(",
")",
"]",
";",
"$",
"validator",
"=",
"Entity",
"::",
"getInstance",
"(",
")",
"->",
"getValidator",
"(",
"$",
"vName",
")",
";",
"if",
"(",
"!",
"$",
"validator",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"'Validator does not exist'",
")",
";",
"}",
"$",
"validator",
"->",
"validate",
"(",
"...",
"$",
"validatorParams",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isCallable",
"(",
"$",
"validator",
")",
")",
"{",
"$",
"vName",
"=",
"'callable'",
";",
"$",
"validator",
"(",
"$",
"value",
",",
"$",
"this",
")",
";",
"}",
"}",
"catch",
"(",
"ValidationException",
"$",
"e",
")",
"{",
"$",
"msg",
"=",
"isset",
"(",
"$",
"messages",
"[",
"$",
"vName",
"]",
")",
"?",
"$",
"messages",
"[",
"$",
"vName",
"]",
":",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"ex",
"=",
"new",
"ValidationException",
"(",
"$",
"msg",
")",
";",
"$",
"ex",
"->",
"addError",
"(",
"$",
"key",
",",
"$",
"msg",
")",
";",
"throw",
"$",
"ex",
";",
"}",
"}"
] |
Apply validator to given value
@param string $validator
@param string $key
@param mixed $value
@param array $messages
@throws ValidationException
@throws \Webiny\Component\StdLib\Exception\Exception
|
[
"Apply",
"validator",
"to",
"given",
"value"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Entity/Attribute/AbstractAttribute.php#L742-L766
|
229,773
|
Webiny/Framework
|
src/Webiny/Component/Entity/Attribute/AbstractAttribute.php
|
AbstractAttribute.expected
|
protected function expected($expecting, $got, $return = false)
{
$ex = new ValidationException(ValidationException::VALIDATION_FAILED);
$ex->addError($this->attribute, ValidationException::DATA_TYPE, [
$expecting,
$got
]);
if ($return) {
return $ex;
}
throw $ex;
}
|
php
|
protected function expected($expecting, $got, $return = false)
{
$ex = new ValidationException(ValidationException::VALIDATION_FAILED);
$ex->addError($this->attribute, ValidationException::DATA_TYPE, [
$expecting,
$got
]);
if ($return) {
return $ex;
}
throw $ex;
}
|
[
"protected",
"function",
"expected",
"(",
"$",
"expecting",
",",
"$",
"got",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"ex",
"=",
"new",
"ValidationException",
"(",
"ValidationException",
"::",
"VALIDATION_FAILED",
")",
";",
"$",
"ex",
"->",
"addError",
"(",
"$",
"this",
"->",
"attribute",
",",
"ValidationException",
"::",
"DATA_TYPE",
",",
"[",
"$",
"expecting",
",",
"$",
"got",
"]",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"ex",
";",
"}",
"throw",
"$",
"ex",
";",
"}"
] |
Throw or return attribute validation exception
@param string $expecting
@param string $got
@param bool $return
@return ValidationException
@throws ValidationException
|
[
"Throw",
"or",
"return",
"attribute",
"validation",
"exception"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Entity/Attribute/AbstractAttribute.php#L778-L791
|
229,774
|
Webiny/Framework
|
src/Webiny/Component/Annotations/Annotations.php
|
Annotations.getClassAnnotations
|
public static function getClassAnnotations($class)
{
$annotationBag = Bridge\Loader::getInstance()->getClassAnnotations($class);
$annotationBag = self::explodeNamespaces($annotationBag);
return new ConfigObject($annotationBag);
}
|
php
|
public static function getClassAnnotations($class)
{
$annotationBag = Bridge\Loader::getInstance()->getClassAnnotations($class);
$annotationBag = self::explodeNamespaces($annotationBag);
return new ConfigObject($annotationBag);
}
|
[
"public",
"static",
"function",
"getClassAnnotations",
"(",
"$",
"class",
")",
"{",
"$",
"annotationBag",
"=",
"Bridge",
"\\",
"Loader",
"::",
"getInstance",
"(",
")",
"->",
"getClassAnnotations",
"(",
"$",
"class",
")",
";",
"$",
"annotationBag",
"=",
"self",
"::",
"explodeNamespaces",
"(",
"$",
"annotationBag",
")",
";",
"return",
"new",
"ConfigObject",
"(",
"$",
"annotationBag",
")",
";",
"}"
] |
Get all annotations for the given class.
@param string $class Fully qualified class name
@return ConfigObject ConfigObject instance containing all annotations.
|
[
"Get",
"all",
"annotations",
"for",
"the",
"given",
"class",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Annotations/Annotations.php#L30-L36
|
229,775
|
Webiny/Framework
|
src/Webiny/Component/Annotations/Annotations.php
|
Annotations.getPropertyAnnotations
|
public static function getPropertyAnnotations($class, $property)
{
$annotationBag = Bridge\Loader::getInstance()->getPropertyAnnotations($class, str_replace('$', '', $property));
$annotationBag = self::explodeNamespaces($annotationBag);
return new ConfigObject($annotationBag);
}
|
php
|
public static function getPropertyAnnotations($class, $property)
{
$annotationBag = Bridge\Loader::getInstance()->getPropertyAnnotations($class, str_replace('$', '', $property));
$annotationBag = self::explodeNamespaces($annotationBag);
return new ConfigObject($annotationBag);
}
|
[
"public",
"static",
"function",
"getPropertyAnnotations",
"(",
"$",
"class",
",",
"$",
"property",
")",
"{",
"$",
"annotationBag",
"=",
"Bridge",
"\\",
"Loader",
"::",
"getInstance",
"(",
")",
"->",
"getPropertyAnnotations",
"(",
"$",
"class",
",",
"str_replace",
"(",
"'$'",
",",
"''",
",",
"$",
"property",
")",
")",
";",
"$",
"annotationBag",
"=",
"self",
"::",
"explodeNamespaces",
"(",
"$",
"annotationBag",
")",
";",
"return",
"new",
"ConfigObject",
"(",
"$",
"annotationBag",
")",
";",
"}"
] |
Get all annotations for the property name on the given class.
@param string $class Fully qualified class name
@param string $property Property name
@return ConfigObject ConfigObject instance containing all annotations.
|
[
"Get",
"all",
"annotations",
"for",
"the",
"property",
"name",
"on",
"the",
"given",
"class",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Annotations/Annotations.php#L46-L52
|
229,776
|
Webiny/Framework
|
src/Webiny/Component/Annotations/Annotations.php
|
Annotations.getMethodAnnotations
|
public static function getMethodAnnotations($class, $method)
{
$annotationBag = Bridge\Loader::getInstance()->getMethodAnnotations($class, $method);
$annotationBag = self::explodeNamespaces($annotationBag);
return new ConfigObject($annotationBag);
}
|
php
|
public static function getMethodAnnotations($class, $method)
{
$annotationBag = Bridge\Loader::getInstance()->getMethodAnnotations($class, $method);
$annotationBag = self::explodeNamespaces($annotationBag);
return new ConfigObject($annotationBag);
}
|
[
"public",
"static",
"function",
"getMethodAnnotations",
"(",
"$",
"class",
",",
"$",
"method",
")",
"{",
"$",
"annotationBag",
"=",
"Bridge",
"\\",
"Loader",
"::",
"getInstance",
"(",
")",
"->",
"getMethodAnnotations",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"$",
"annotationBag",
"=",
"self",
"::",
"explodeNamespaces",
"(",
"$",
"annotationBag",
")",
";",
"return",
"new",
"ConfigObject",
"(",
"$",
"annotationBag",
")",
";",
"}"
] |
Get all annotations for the method name on the given class.
@param string $class Fully qualified class name
@param string $method Method name
@return ConfigObject ConfigObject instance containing all annotations.
|
[
"Get",
"all",
"annotations",
"for",
"the",
"method",
"name",
"on",
"the",
"given",
"class",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Annotations/Annotations.php#L62-L68
|
229,777
|
Webiny/Framework
|
src/Webiny/Component/Annotations/Annotations.php
|
Annotations.explodeNamespaces
|
private static function explodeNamespaces($annotationBag)
{
foreach ($annotationBag as $k => $v) {
// fix for empty newlines that cause that a "\n/" is appended to the annotation value
if (!is_array($v)) {
$v = str_replace("\n/", "", trim($v));
}
if (strpos($k, ".") !== false) {
unset($annotationBag[$k]);
self::setArrayValue($annotationBag, $k, $v);
} else {
$annotationBag[$k] = $v;
}
}
return $annotationBag;
}
|
php
|
private static function explodeNamespaces($annotationBag)
{
foreach ($annotationBag as $k => $v) {
// fix for empty newlines that cause that a "\n/" is appended to the annotation value
if (!is_array($v)) {
$v = str_replace("\n/", "", trim($v));
}
if (strpos($k, ".") !== false) {
unset($annotationBag[$k]);
self::setArrayValue($annotationBag, $k, $v);
} else {
$annotationBag[$k] = $v;
}
}
return $annotationBag;
}
|
[
"private",
"static",
"function",
"explodeNamespaces",
"(",
"$",
"annotationBag",
")",
"{",
"foreach",
"(",
"$",
"annotationBag",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"// fix for empty newlines that cause that a \"\\n/\" is appended to the annotation value",
"if",
"(",
"!",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"$",
"v",
"=",
"str_replace",
"(",
"\"\\n/\"",
",",
"\"\"",
",",
"trim",
"(",
"$",
"v",
")",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"k",
",",
"\".\"",
")",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"annotationBag",
"[",
"$",
"k",
"]",
")",
";",
"self",
"::",
"setArrayValue",
"(",
"$",
"annotationBag",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"else",
"{",
"$",
"annotationBag",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"return",
"$",
"annotationBag",
";",
"}"
] |
Converts the dotted annotations inside array key names into a multidimensional array.
@param array $annotationBag
@return array
|
[
"Converts",
"the",
"dotted",
"annotations",
"inside",
"array",
"key",
"names",
"into",
"a",
"multidimensional",
"array",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Annotations/Annotations.php#L77-L94
|
229,778
|
Webiny/Framework
|
src/Webiny/Component/Annotations/Annotations.php
|
Annotations.setArrayValue
|
private static function setArrayValue(&$root, $compositeKey, $value)
{
$keys = explode('.', $compositeKey);
while (count($keys) > 1) {
$key = array_shift($keys);
if (!isset($root[$key])) {
$root[$key] = [];
}
$root = &$root[$key];
}
$key = reset($keys);
$root[$key] = $value;
}
|
php
|
private static function setArrayValue(&$root, $compositeKey, $value)
{
$keys = explode('.', $compositeKey);
while (count($keys) > 1) {
$key = array_shift($keys);
if (!isset($root[$key])) {
$root[$key] = [];
}
$root = &$root[$key];
}
$key = reset($keys);
$root[$key] = $value;
}
|
[
"private",
"static",
"function",
"setArrayValue",
"(",
"&",
"$",
"root",
",",
"$",
"compositeKey",
",",
"$",
"value",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"compositeKey",
")",
";",
"while",
"(",
"count",
"(",
"$",
"keys",
")",
">",
"1",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"keys",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"root",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"root",
"[",
"$",
"key",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"root",
"=",
"&",
"$",
"root",
"[",
"$",
"key",
"]",
";",
"}",
"$",
"key",
"=",
"reset",
"(",
"$",
"keys",
")",
";",
"$",
"root",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}"
] |
Changes the dotted annotation of one key into a multidimensional array.
@param array $root Array on which the conversion is done.
@param string $compositeKey The dotted key.
@param string $value Value of the key.
|
[
"Changes",
"the",
"dotted",
"annotation",
"of",
"one",
"key",
"into",
"a",
"multidimensional",
"array",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Annotations/Annotations.php#L103-L116
|
229,779
|
Webiny/Framework
|
src/Webiny/Component/Mongo/Index/AbstractIndex.php
|
AbstractIndex.getOptions
|
public function getOptions()
{
$options = [
'name' => $this->name,
'sparse' => is_bool($this->sparse) ? $this->sparse : false,
'dropDups' => $this->dropDuplicates,
'unique' => $this->unique
];
if (is_array($this->sparse)) {
$options['partialFilterExpression'] = $this->sparse;
}
return $options;
}
|
php
|
public function getOptions()
{
$options = [
'name' => $this->name,
'sparse' => is_bool($this->sparse) ? $this->sparse : false,
'dropDups' => $this->dropDuplicates,
'unique' => $this->unique
];
if (is_array($this->sparse)) {
$options['partialFilterExpression'] = $this->sparse;
}
return $options;
}
|
[
"public",
"function",
"getOptions",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'sparse'",
"=>",
"is_bool",
"(",
"$",
"this",
"->",
"sparse",
")",
"?",
"$",
"this",
"->",
"sparse",
":",
"false",
",",
"'dropDups'",
"=>",
"$",
"this",
"->",
"dropDuplicates",
",",
"'unique'",
"=>",
"$",
"this",
"->",
"unique",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"sparse",
")",
")",
"{",
"$",
"options",
"[",
"'partialFilterExpression'",
"]",
"=",
"$",
"this",
"->",
"sparse",
";",
"}",
"return",
"$",
"options",
";",
"}"
] |
Get mongo index options
@return array
|
[
"Get",
"mongo",
"index",
"options"
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/Mongo/Index/AbstractIndex.php#L89-L103
|
229,780
|
Webiny/Framework
|
src/Webiny/Component/EventManager/EventListener.php
|
EventListener.handler
|
public function handler($handler)
{
if ($this->isNumber($handler) || $this->isBoolean($handler) || $this->isEmpty($handler)) {
throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
}
if ($this->isString($handler) || $this->isStringObject($handler)) {
$handler = StdObjectWrapper::toString($handler);
if (!class_exists($handler)) {
throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
}
$handler = new $handler;
}
$this->handler = $handler;
return $this;
}
|
php
|
public function handler($handler)
{
if ($this->isNumber($handler) || $this->isBoolean($handler) || $this->isEmpty($handler)) {
throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
}
if ($this->isString($handler) || $this->isStringObject($handler)) {
$handler = StdObjectWrapper::toString($handler);
if (!class_exists($handler)) {
throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
}
$handler = new $handler;
}
$this->handler = $handler;
return $this;
}
|
[
"public",
"function",
"handler",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNumber",
"(",
"$",
"handler",
")",
"||",
"$",
"this",
"->",
"isBoolean",
"(",
"$",
"handler",
")",
"||",
"$",
"this",
"->",
"isEmpty",
"(",
"$",
"handler",
")",
")",
"{",
"throw",
"new",
"EventManagerException",
"(",
"EventManagerException",
"::",
"INVALID_EVENT_HANDLER",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isString",
"(",
"$",
"handler",
")",
"||",
"$",
"this",
"->",
"isStringObject",
"(",
"$",
"handler",
")",
")",
"{",
"$",
"handler",
"=",
"StdObjectWrapper",
"::",
"toString",
"(",
"$",
"handler",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"handler",
")",
")",
"{",
"throw",
"new",
"EventManagerException",
"(",
"EventManagerException",
"::",
"INVALID_EVENT_HANDLER",
")",
";",
"}",
"$",
"handler",
"=",
"new",
"$",
"handler",
";",
"}",
"$",
"this",
"->",
"handler",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
] |
Set handler for event. Can be a callable, class name or class instance.
@param $handler
@throws EventManagerException
@return $this
|
[
"Set",
"handler",
"for",
"event",
".",
"Can",
"be",
"a",
"callable",
"class",
"name",
"or",
"class",
"instance",
"."
] |
2ca7fb238999387e54a1eea8c5cb4735de9022a7
|
https://github.com/Webiny/Framework/blob/2ca7fb238999387e54a1eea8c5cb4735de9022a7/src/Webiny/Component/EventManager/EventListener.php#L35-L52
|
229,781
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp._TransactionSearch
|
function _TransactionSearch($startDate = '', $oID = '', $criteria = '') {
global $db, $messageStack, $doPayPal;
$doPayPal = $this->paypal_init();
// look up history on this order from PayPal table
$sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID AND parent_txn_id = '' ";
$sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
$zc_ppHist = $db->Execute($sql);
if ($zc_ppHist->RecordCount() == 0) return false;
$txnID = $zc_ppHist->fields['txn_id'];
$startDate = $zc_ppHist->fields['payment_date'];
$timeval = time();
if ($startDate == '') $startDate = date('Y-m-d', $timeval) . 'T' . date('h:i:s', $timeval) . 'Z';
/**
* Read data from PayPal
*/
$response = $doPayPal->TransactionSearch($startDate, $txnID, $email, $criteria);
$error = $this->_errorHandler($response, 'TransactionSearch');
if ($error === false) {
return false;
} else {
return $response;
}
}
|
php
|
function _TransactionSearch($startDate = '', $oID = '', $criteria = '') {
global $db, $messageStack, $doPayPal;
$doPayPal = $this->paypal_init();
// look up history on this order from PayPal table
$sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID AND parent_txn_id = '' ";
$sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
$zc_ppHist = $db->Execute($sql);
if ($zc_ppHist->RecordCount() == 0) return false;
$txnID = $zc_ppHist->fields['txn_id'];
$startDate = $zc_ppHist->fields['payment_date'];
$timeval = time();
if ($startDate == '') $startDate = date('Y-m-d', $timeval) . 'T' . date('h:i:s', $timeval) . 'Z';
/**
* Read data from PayPal
*/
$response = $doPayPal->TransactionSearch($startDate, $txnID, $email, $criteria);
$error = $this->_errorHandler($response, 'TransactionSearch');
if ($error === false) {
return false;
} else {
return $response;
}
}
|
[
"function",
"_TransactionSearch",
"(",
"$",
"startDate",
"=",
"''",
",",
"$",
"oID",
"=",
"''",
",",
"$",
"criteria",
"=",
"''",
")",
"{",
"global",
"$",
"db",
",",
"$",
"messageStack",
",",
"$",
"doPayPal",
";",
"$",
"doPayPal",
"=",
"$",
"this",
"->",
"paypal_init",
"(",
")",
";",
"// look up history on this order from PayPal table",
"$",
"sql",
"=",
"\"select * from \"",
".",
"TABLE_PAYPAL",
".",
"\" where order_id = :orderID AND parent_txn_id = '' \"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':orderID'",
",",
"$",
"oID",
",",
"'integer'",
")",
";",
"$",
"zc_ppHist",
"=",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"zc_ppHist",
"->",
"RecordCount",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"$",
"txnID",
"=",
"$",
"zc_ppHist",
"->",
"fields",
"[",
"'txn_id'",
"]",
";",
"$",
"startDate",
"=",
"$",
"zc_ppHist",
"->",
"fields",
"[",
"'payment_date'",
"]",
";",
"$",
"timeval",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"startDate",
"==",
"''",
")",
"$",
"startDate",
"=",
"date",
"(",
"'Y-m-d'",
",",
"$",
"timeval",
")",
".",
"'T'",
".",
"date",
"(",
"'h:i:s'",
",",
"$",
"timeval",
")",
".",
"'Z'",
";",
"/**\n * Read data from PayPal\n */",
"$",
"response",
"=",
"$",
"doPayPal",
"->",
"TransactionSearch",
"(",
"$",
"startDate",
",",
"$",
"txnID",
",",
"$",
"email",
",",
"$",
"criteria",
")",
";",
"$",
"error",
"=",
"$",
"this",
"->",
"_errorHandler",
"(",
"$",
"response",
",",
"'TransactionSearch'",
")",
";",
"if",
"(",
"$",
"error",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"response",
";",
"}",
"}"
] |
Used to read details of existing transactions. FOR FUTURE USE.
|
[
"Used",
"to",
"read",
"details",
"of",
"existing",
"transactions",
".",
"FOR",
"FUTURE",
"USE",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L531-L554
|
229,782
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.remove
|
function remove() {
global $messageStack;
// cannot remove EC if DP installed:
if (defined('MODULE_PAYMENT_PAYPALDP_STATUS')) {
// this language text is hard-coded in english since Website Payments Pro is not yet available in any countries that speak any other language at this time.
$messageStack->add_session('<strong>Sorry, you must remove PayPal Payments Pro (paypaldp) first.</strong> PayPal Payments Pro (Website Payments Pro) requires that you offer Express Checkout to your customers.<br /><a href="' . zen_href_link('modules.php?set=payment&module=paypaldp', '', 'NONSSL') . '">Click here to edit or remove your PayPal Payments Pro module.</a>' , 'error');
zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=paypalwpp', 'NONSSL'));
return 'failed';
}
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE\_PAYMENT\_PAYPALWPP\_%' or configuration_key like 'MODULE\_PAYMENT\_PAYPALEC\_%'");
$this->notify('NOTIFY_PAYMENT_PAYPALWPP_UNINSTALLED');
}
|
php
|
function remove() {
global $messageStack;
// cannot remove EC if DP installed:
if (defined('MODULE_PAYMENT_PAYPALDP_STATUS')) {
// this language text is hard-coded in english since Website Payments Pro is not yet available in any countries that speak any other language at this time.
$messageStack->add_session('<strong>Sorry, you must remove PayPal Payments Pro (paypaldp) first.</strong> PayPal Payments Pro (Website Payments Pro) requires that you offer Express Checkout to your customers.<br /><a href="' . zen_href_link('modules.php?set=payment&module=paypaldp', '', 'NONSSL') . '">Click here to edit or remove your PayPal Payments Pro module.</a>' , 'error');
zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=paypalwpp', 'NONSSL'));
return 'failed';
}
global $db;
$db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key LIKE 'MODULE\_PAYMENT\_PAYPALWPP\_%' or configuration_key like 'MODULE\_PAYMENT\_PAYPALEC\_%'");
$this->notify('NOTIFY_PAYMENT_PAYPALWPP_UNINSTALLED');
}
|
[
"function",
"remove",
"(",
")",
"{",
"global",
"$",
"messageStack",
";",
"// cannot remove EC if DP installed:",
"if",
"(",
"defined",
"(",
"'MODULE_PAYMENT_PAYPALDP_STATUS'",
")",
")",
"{",
"// this language text is hard-coded in english since Website Payments Pro is not yet available in any countries that speak any other language at this time.",
"$",
"messageStack",
"->",
"add_session",
"(",
"'<strong>Sorry, you must remove PayPal Payments Pro (paypaldp) first.</strong> PayPal Payments Pro (Website Payments Pro) requires that you offer Express Checkout to your customers.<br /><a href=\"'",
".",
"zen_href_link",
"(",
"'modules.php?set=payment&module=paypaldp'",
",",
"''",
",",
"'NONSSL'",
")",
".",
"'\">Click here to edit or remove your PayPal Payments Pro module.</a>'",
",",
"'error'",
")",
";",
"zen_redirect",
"(",
"zen_href_link",
"(",
"FILENAME_MODULES",
",",
"'set=payment&module=paypalwpp'",
",",
"'NONSSL'",
")",
")",
";",
"return",
"'failed'",
";",
"}",
"global",
"$",
"db",
";",
"$",
"db",
"->",
"Execute",
"(",
"\"delete from \"",
".",
"TABLE_CONFIGURATION",
".",
"\" where configuration_key LIKE 'MODULE\\_PAYMENT\\_PAYPALWPP\\_%' or configuration_key like 'MODULE\\_PAYMENT\\_PAYPALEC\\_%'\"",
")",
";",
"$",
"this",
"->",
"notify",
"(",
"'NOTIFY_PAYMENT_PAYPALWPP_UNINSTALLED'",
")",
";",
"}"
] |
De-install this module
|
[
"De",
"-",
"install",
"this",
"module"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L638-L651
|
229,783
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.alterShippingEditButton
|
function alterShippingEditButton() {
return false;
if ($this->in_special_checkout() && empty($_SESSION['paypal_ec_markflow'])) {
return zen_href_link('ipn_main_handler.php', 'type=ec&clearSess=1', 'SSL', true,true, true);
}
}
|
php
|
function alterShippingEditButton() {
return false;
if ($this->in_special_checkout() && empty($_SESSION['paypal_ec_markflow'])) {
return zen_href_link('ipn_main_handler.php', 'type=ec&clearSess=1', 'SSL', true,true, true);
}
}
|
[
"function",
"alterShippingEditButton",
"(",
")",
"{",
"return",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"in_special_checkout",
"(",
")",
"&&",
"empty",
"(",
"$",
"_SESSION",
"[",
"'paypal_ec_markflow'",
"]",
")",
")",
"{",
"return",
"zen_href_link",
"(",
"'ipn_main_handler.php'",
",",
"'type=ec&clearSess=1'",
",",
"'SSL'",
",",
"true",
",",
"true",
",",
"true",
")",
";",
"}",
"}"
] |
Determine whether the shipping-edit button should be displayed or not
|
[
"Determine",
"whether",
"the",
"shipping",
"-",
"edit",
"button",
"should",
"be",
"displayed",
"or",
"not"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L667-L672
|
229,784
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.zcLog
|
function zcLog($stage, $message) {
static $tokenHash;
if ($tokenHash == '') $tokenHash = '_' . zen_create_random_value(4);
if (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log and Email' || MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log File') {
$token = (isset($_SESSION['paypal_ec_token'])) ? $_SESSION['paypal_ec_token'] : preg_replace('/[^0-9.A-Z\-]/', '', $_GET['token']);
$token = ($token == '') ? date('m-d-Y-H-i') : $token; // or time()
$token .= $tokenHash;
$file = $this->_logDir . '/' . $this->code . '_Paypal_Action_' . $token . '.log';
if (defined('PAYPAL_DEV_MODE') && PAYPAL_DEV_MODE == 'true') $file = $this->_logDir . '/' . $this->code . '_Paypal_Debug_' . $token . '.log';
$fp = @fopen($file, 'a');
@fwrite($fp, date('M-d-Y H:i:s') . ' (' . time() . ')' . "\n" . $stage . "\n" . $message . "\n=================================\n\n");
@fclose($fp);
}
$this->_doDebug($stage, $message, false);
}
|
php
|
function zcLog($stage, $message) {
static $tokenHash;
if ($tokenHash == '') $tokenHash = '_' . zen_create_random_value(4);
if (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log and Email' || MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log File') {
$token = (isset($_SESSION['paypal_ec_token'])) ? $_SESSION['paypal_ec_token'] : preg_replace('/[^0-9.A-Z\-]/', '', $_GET['token']);
$token = ($token == '') ? date('m-d-Y-H-i') : $token; // or time()
$token .= $tokenHash;
$file = $this->_logDir . '/' . $this->code . '_Paypal_Action_' . $token . '.log';
if (defined('PAYPAL_DEV_MODE') && PAYPAL_DEV_MODE == 'true') $file = $this->_logDir . '/' . $this->code . '_Paypal_Debug_' . $token . '.log';
$fp = @fopen($file, 'a');
@fwrite($fp, date('M-d-Y H:i:s') . ' (' . time() . ')' . "\n" . $stage . "\n" . $message . "\n=================================\n\n");
@fclose($fp);
}
$this->_doDebug($stage, $message, false);
}
|
[
"function",
"zcLog",
"(",
"$",
"stage",
",",
"$",
"message",
")",
"{",
"static",
"$",
"tokenHash",
";",
"if",
"(",
"$",
"tokenHash",
"==",
"''",
")",
"$",
"tokenHash",
"=",
"'_'",
".",
"zen_create_random_value",
"(",
"4",
")",
";",
"if",
"(",
"MODULE_PAYMENT_PAYPALWPP_DEBUGGING",
"==",
"'Log and Email'",
"||",
"MODULE_PAYMENT_PAYPALWPP_DEBUGGING",
"==",
"'Log File'",
")",
"{",
"$",
"token",
"=",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"'paypal_ec_token'",
"]",
")",
")",
"?",
"$",
"_SESSION",
"[",
"'paypal_ec_token'",
"]",
":",
"preg_replace",
"(",
"'/[^0-9.A-Z\\-]/'",
",",
"''",
",",
"$",
"_GET",
"[",
"'token'",
"]",
")",
";",
"$",
"token",
"=",
"(",
"$",
"token",
"==",
"''",
")",
"?",
"date",
"(",
"'m-d-Y-H-i'",
")",
":",
"$",
"token",
";",
"// or time()",
"$",
"token",
".=",
"$",
"tokenHash",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"_logDir",
".",
"'/'",
".",
"$",
"this",
"->",
"code",
".",
"'_Paypal_Action_'",
".",
"$",
"token",
".",
"'.log'",
";",
"if",
"(",
"defined",
"(",
"'PAYPAL_DEV_MODE'",
")",
"&&",
"PAYPAL_DEV_MODE",
"==",
"'true'",
")",
"$",
"file",
"=",
"$",
"this",
"->",
"_logDir",
".",
"'/'",
".",
"$",
"this",
"->",
"code",
".",
"'_Paypal_Debug_'",
".",
"$",
"token",
".",
"'.log'",
";",
"$",
"fp",
"=",
"@",
"fopen",
"(",
"$",
"file",
",",
"'a'",
")",
";",
"@",
"fwrite",
"(",
"$",
"fp",
",",
"date",
"(",
"'M-d-Y H:i:s'",
")",
".",
"' ('",
".",
"time",
"(",
")",
".",
"')'",
".",
"\"\\n\"",
".",
"$",
"stage",
".",
"\"\\n\"",
".",
"$",
"message",
".",
"\"\\n=================================\\n\\n\"",
")",
";",
"@",
"fclose",
"(",
"$",
"fp",
")",
";",
"}",
"$",
"this",
"->",
"_doDebug",
"(",
"$",
"stage",
",",
"$",
"message",
",",
"false",
")",
";",
"}"
] |
Debug Logging support
|
[
"Debug",
"Logging",
"support"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L676-L690
|
229,785
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp._doDebug
|
function _doDebug($subject = 'PayPal debug data', $data, $useSession = true) {
if (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log and Email') {
$data = urldecode($data) . "\n\n";
if ($useSession) $data .= "\nSession data: " . print_r($_SESSION, true);
zen_mail(STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $subject, $this->code . "\n" . $data, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, array('EMAIL_MESSAGE_HTML'=>nl2br($this->code . "\n" . $data)), 'debug');
}
}
|
php
|
function _doDebug($subject = 'PayPal debug data', $data, $useSession = true) {
if (MODULE_PAYMENT_PAYPALWPP_DEBUGGING == 'Log and Email') {
$data = urldecode($data) . "\n\n";
if ($useSession) $data .= "\nSession data: " . print_r($_SESSION, true);
zen_mail(STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, $subject, $this->code . "\n" . $data, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, array('EMAIL_MESSAGE_HTML'=>nl2br($this->code . "\n" . $data)), 'debug');
}
}
|
[
"function",
"_doDebug",
"(",
"$",
"subject",
"=",
"'PayPal debug data'",
",",
"$",
"data",
",",
"$",
"useSession",
"=",
"true",
")",
"{",
"if",
"(",
"MODULE_PAYMENT_PAYPALWPP_DEBUGGING",
"==",
"'Log and Email'",
")",
"{",
"$",
"data",
"=",
"urldecode",
"(",
"$",
"data",
")",
".",
"\"\\n\\n\"",
";",
"if",
"(",
"$",
"useSession",
")",
"$",
"data",
".=",
"\"\\nSession data: \"",
".",
"print_r",
"(",
"$",
"_SESSION",
",",
"true",
")",
";",
"zen_mail",
"(",
"STORE_NAME",
",",
"STORE_OWNER_EMAIL_ADDRESS",
",",
"$",
"subject",
",",
"$",
"this",
"->",
"code",
".",
"\"\\n\"",
".",
"$",
"data",
",",
"STORE_OWNER",
",",
"STORE_OWNER_EMAIL_ADDRESS",
",",
"array",
"(",
"'EMAIL_MESSAGE_HTML'",
"=>",
"nl2br",
"(",
"$",
"this",
"->",
"code",
".",
"\"\\n\"",
".",
"$",
"data",
")",
")",
",",
"'debug'",
")",
";",
"}",
"}"
] |
Debug Emailing support
|
[
"Debug",
"Emailing",
"support"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L694-L700
|
229,786
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp._doAuth
|
function _doAuth($oID, $amt, $currency = 'USD') {
global $db, $doPayPal, $messageStack;
$doPayPal = $this->paypal_init();
$authAmt = $amt;
$new_order_status = (int)MODULE_PAYMENT_PAYPALWPP_ORDER_PENDING_STATUS_ID;
if (isset($_POST['orderauth']) && $_POST['orderauth'] == MODULE_PAYMENT_PAYPAL_ENTRY_AUTH_BUTTON_TEXT_PARTIAL) {
$authAmt = (float)$_POST['authamt'];
$new_order_status = MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID;
if (isset($_POST['authconfirm']) && $_POST['authconfirm'] == 'on') {
$proceedToAuth = true;
} else {
$messageStack->add_session(MODULE_PAYMENT_PAYPALWPP_TEXT_AUTH_CONFIRM_ERROR, 'error');
$proceedToAuth = false;
}
if ($authAmt == 0) {
$messageStack->add_session(MODULE_PAYMENT_PAYPALWPP_TEXT_INVALID_AUTH_AMOUNT, 'error');
$proceedToAuth = false;
}
}
// look up history on this order from PayPal table
$sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID AND parent_txn_id = '' ";
$sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
$zc_ppHist = $db->Execute($sql);
if ($zc_ppHist->RecordCount() == 0) return false;
$txnID = $zc_ppHist->fields['txn_id'];
/**
* Submit auth request to PayPal
*/
if ($proceedToAuth) {
$response = $doPayPal->DoAuthorization($txnID, $authAmt, $currency);
$error = $this->_errorHandler($response, 'DoAuthorization');
$new_order_status = ($new_order_status > 0 ? $new_order_status : 1);
if (!$error) {
// Success, so save the results
$sql_data_array = array('orders_id' => (int)$oID,
'orders_status_id' => (int)$new_order_status,
'date_added' => 'now()',
'comments' => 'AUTHORIZATION ADDED. Trans ID: ' . urldecode($response['TRANSACTIONID']) . "\n" . ' Amount:' . urldecode($response['AMT']) . ' ' . $currency,
'customer_notified' => -1
);
zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
$db->Execute("update " . TABLE_ORDERS . "
set orders_status = '" . (int)$new_order_status . "'
where orders_id = '" . (int)$oID . "'");
$messageStack->add_session(sprintf(MODULE_PAYMENT_PAYPALWPP_TEXT_AUTH_INITIATED, urldecode($response['AMT'])), 'success');
return true;
}
}
}
|
php
|
function _doAuth($oID, $amt, $currency = 'USD') {
global $db, $doPayPal, $messageStack;
$doPayPal = $this->paypal_init();
$authAmt = $amt;
$new_order_status = (int)MODULE_PAYMENT_PAYPALWPP_ORDER_PENDING_STATUS_ID;
if (isset($_POST['orderauth']) && $_POST['orderauth'] == MODULE_PAYMENT_PAYPAL_ENTRY_AUTH_BUTTON_TEXT_PARTIAL) {
$authAmt = (float)$_POST['authamt'];
$new_order_status = MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID;
if (isset($_POST['authconfirm']) && $_POST['authconfirm'] == 'on') {
$proceedToAuth = true;
} else {
$messageStack->add_session(MODULE_PAYMENT_PAYPALWPP_TEXT_AUTH_CONFIRM_ERROR, 'error');
$proceedToAuth = false;
}
if ($authAmt == 0) {
$messageStack->add_session(MODULE_PAYMENT_PAYPALWPP_TEXT_INVALID_AUTH_AMOUNT, 'error');
$proceedToAuth = false;
}
}
// look up history on this order from PayPal table
$sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID AND parent_txn_id = '' ";
$sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
$zc_ppHist = $db->Execute($sql);
if ($zc_ppHist->RecordCount() == 0) return false;
$txnID = $zc_ppHist->fields['txn_id'];
/**
* Submit auth request to PayPal
*/
if ($proceedToAuth) {
$response = $doPayPal->DoAuthorization($txnID, $authAmt, $currency);
$error = $this->_errorHandler($response, 'DoAuthorization');
$new_order_status = ($new_order_status > 0 ? $new_order_status : 1);
if (!$error) {
// Success, so save the results
$sql_data_array = array('orders_id' => (int)$oID,
'orders_status_id' => (int)$new_order_status,
'date_added' => 'now()',
'comments' => 'AUTHORIZATION ADDED. Trans ID: ' . urldecode($response['TRANSACTIONID']) . "\n" . ' Amount:' . urldecode($response['AMT']) . ' ' . $currency,
'customer_notified' => -1
);
zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
$db->Execute("update " . TABLE_ORDERS . "
set orders_status = '" . (int)$new_order_status . "'
where orders_id = '" . (int)$oID . "'");
$messageStack->add_session(sprintf(MODULE_PAYMENT_PAYPALWPP_TEXT_AUTH_INITIATED, urldecode($response['AMT'])), 'success');
return true;
}
}
}
|
[
"function",
"_doAuth",
"(",
"$",
"oID",
",",
"$",
"amt",
",",
"$",
"currency",
"=",
"'USD'",
")",
"{",
"global",
"$",
"db",
",",
"$",
"doPayPal",
",",
"$",
"messageStack",
";",
"$",
"doPayPal",
"=",
"$",
"this",
"->",
"paypal_init",
"(",
")",
";",
"$",
"authAmt",
"=",
"$",
"amt",
";",
"$",
"new_order_status",
"=",
"(",
"int",
")",
"MODULE_PAYMENT_PAYPALWPP_ORDER_PENDING_STATUS_ID",
";",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'orderauth'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'orderauth'",
"]",
"==",
"MODULE_PAYMENT_PAYPAL_ENTRY_AUTH_BUTTON_TEXT_PARTIAL",
")",
"{",
"$",
"authAmt",
"=",
"(",
"float",
")",
"$",
"_POST",
"[",
"'authamt'",
"]",
";",
"$",
"new_order_status",
"=",
"MODULE_PAYMENT_PAYPALWPP_ORDER_STATUS_ID",
";",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'authconfirm'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'authconfirm'",
"]",
"==",
"'on'",
")",
"{",
"$",
"proceedToAuth",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"messageStack",
"->",
"add_session",
"(",
"MODULE_PAYMENT_PAYPALWPP_TEXT_AUTH_CONFIRM_ERROR",
",",
"'error'",
")",
";",
"$",
"proceedToAuth",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"authAmt",
"==",
"0",
")",
"{",
"$",
"messageStack",
"->",
"add_session",
"(",
"MODULE_PAYMENT_PAYPALWPP_TEXT_INVALID_AUTH_AMOUNT",
",",
"'error'",
")",
";",
"$",
"proceedToAuth",
"=",
"false",
";",
"}",
"}",
"// look up history on this order from PayPal table",
"$",
"sql",
"=",
"\"select * from \"",
".",
"TABLE_PAYPAL",
".",
"\" where order_id = :orderID AND parent_txn_id = '' \"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':orderID'",
",",
"$",
"oID",
",",
"'integer'",
")",
";",
"$",
"zc_ppHist",
"=",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"zc_ppHist",
"->",
"RecordCount",
"(",
")",
"==",
"0",
")",
"return",
"false",
";",
"$",
"txnID",
"=",
"$",
"zc_ppHist",
"->",
"fields",
"[",
"'txn_id'",
"]",
";",
"/**\n * Submit auth request to PayPal\n */",
"if",
"(",
"$",
"proceedToAuth",
")",
"{",
"$",
"response",
"=",
"$",
"doPayPal",
"->",
"DoAuthorization",
"(",
"$",
"txnID",
",",
"$",
"authAmt",
",",
"$",
"currency",
")",
";",
"$",
"error",
"=",
"$",
"this",
"->",
"_errorHandler",
"(",
"$",
"response",
",",
"'DoAuthorization'",
")",
";",
"$",
"new_order_status",
"=",
"(",
"$",
"new_order_status",
">",
"0",
"?",
"$",
"new_order_status",
":",
"1",
")",
";",
"if",
"(",
"!",
"$",
"error",
")",
"{",
"// Success, so save the results",
"$",
"sql_data_array",
"=",
"array",
"(",
"'orders_id'",
"=>",
"(",
"int",
")",
"$",
"oID",
",",
"'orders_status_id'",
"=>",
"(",
"int",
")",
"$",
"new_order_status",
",",
"'date_added'",
"=>",
"'now()'",
",",
"'comments'",
"=>",
"'AUTHORIZATION ADDED. Trans ID: '",
".",
"urldecode",
"(",
"$",
"response",
"[",
"'TRANSACTIONID'",
"]",
")",
".",
"\"\\n\"",
".",
"' Amount:'",
".",
"urldecode",
"(",
"$",
"response",
"[",
"'AMT'",
"]",
")",
".",
"' '",
".",
"$",
"currency",
",",
"'customer_notified'",
"=>",
"-",
"1",
")",
";",
"zen_db_perform",
"(",
"TABLE_ORDERS_STATUS_HISTORY",
",",
"$",
"sql_data_array",
")",
";",
"$",
"db",
"->",
"Execute",
"(",
"\"update \"",
".",
"TABLE_ORDERS",
".",
"\"\n set orders_status = '\"",
".",
"(",
"int",
")",
"$",
"new_order_status",
".",
"\"'\n where orders_id = '\"",
".",
"(",
"int",
")",
"$",
"oID",
".",
"\"'\"",
")",
";",
"$",
"messageStack",
"->",
"add_session",
"(",
"sprintf",
"(",
"MODULE_PAYMENT_PAYPALWPP_TEXT_AUTH_INITIATED",
",",
"urldecode",
"(",
"$",
"response",
"[",
"'AMT'",
"]",
")",
")",
",",
"'success'",
")",
";",
"return",
"true",
";",
"}",
"}",
"}"
] |
Used to authorize part of a given previously-initiated transaction. FOR FUTURE USE.
|
[
"Used",
"to",
"authorize",
"part",
"of",
"a",
"given",
"previously",
"-",
"initiated",
"transaction",
".",
"FOR",
"FUTURE",
"USE",
"."
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L826-L875
|
229,787
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.getLanguageCode
|
function getLanguageCode() {
global $order;
$lang_code = '';
$orderISO = zen_get_countries($order->customer['country']['id'], true);
$storeISO = zen_get_countries(STORE_COUNTRY, true);
if (in_array(strtoupper($orderISO['countries_iso_code_2']), array('US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'))) {
$lang_code = strtoupper($orderISO['countries_iso_code_2']);
} elseif (in_array(strtoupper($storeISO['countries_iso_code_2']), array('US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'))) {
$lang_code = strtoupper($storeISO['countries_iso_code_2']);
}
else
if (in_array(strtoupper($_SESSION['languages_code']), array('EN', 'US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'))) {
$lang_code = $_SESSION['languages_code'];
}
if (strtoupper($lang_code) == 'EN') $lang_code = 'US';
return strtoupper($lang_code);
}
|
php
|
function getLanguageCode() {
global $order;
$lang_code = '';
$orderISO = zen_get_countries($order->customer['country']['id'], true);
$storeISO = zen_get_countries(STORE_COUNTRY, true);
if (in_array(strtoupper($orderISO['countries_iso_code_2']), array('US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'))) {
$lang_code = strtoupper($orderISO['countries_iso_code_2']);
} elseif (in_array(strtoupper($storeISO['countries_iso_code_2']), array('US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'))) {
$lang_code = strtoupper($storeISO['countries_iso_code_2']);
}
else
if (in_array(strtoupper($_SESSION['languages_code']), array('EN', 'US', 'AU', 'DE', 'FR', 'IT', 'GB', 'ES', 'AT', 'BE', 'CA', 'CH', 'CN', 'NL', 'PL'))) {
$lang_code = $_SESSION['languages_code'];
}
if (strtoupper($lang_code) == 'EN') $lang_code = 'US';
return strtoupper($lang_code);
}
|
[
"function",
"getLanguageCode",
"(",
")",
"{",
"global",
"$",
"order",
";",
"$",
"lang_code",
"=",
"''",
";",
"$",
"orderISO",
"=",
"zen_get_countries",
"(",
"$",
"order",
"->",
"customer",
"[",
"'country'",
"]",
"[",
"'id'",
"]",
",",
"true",
")",
";",
"$",
"storeISO",
"=",
"zen_get_countries",
"(",
"STORE_COUNTRY",
",",
"true",
")",
";",
"if",
"(",
"in_array",
"(",
"strtoupper",
"(",
"$",
"orderISO",
"[",
"'countries_iso_code_2'",
"]",
")",
",",
"array",
"(",
"'US'",
",",
"'AU'",
",",
"'DE'",
",",
"'FR'",
",",
"'IT'",
",",
"'GB'",
",",
"'ES'",
",",
"'AT'",
",",
"'BE'",
",",
"'CA'",
",",
"'CH'",
",",
"'CN'",
",",
"'NL'",
",",
"'PL'",
")",
")",
")",
"{",
"$",
"lang_code",
"=",
"strtoupper",
"(",
"$",
"orderISO",
"[",
"'countries_iso_code_2'",
"]",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"strtoupper",
"(",
"$",
"storeISO",
"[",
"'countries_iso_code_2'",
"]",
")",
",",
"array",
"(",
"'US'",
",",
"'AU'",
",",
"'DE'",
",",
"'FR'",
",",
"'IT'",
",",
"'GB'",
",",
"'ES'",
",",
"'AT'",
",",
"'BE'",
",",
"'CA'",
",",
"'CH'",
",",
"'CN'",
",",
"'NL'",
",",
"'PL'",
")",
")",
")",
"{",
"$",
"lang_code",
"=",
"strtoupper",
"(",
"$",
"storeISO",
"[",
"'countries_iso_code_2'",
"]",
")",
";",
"}",
"else",
"if",
"(",
"in_array",
"(",
"strtoupper",
"(",
"$",
"_SESSION",
"[",
"'languages_code'",
"]",
")",
",",
"array",
"(",
"'EN'",
",",
"'US'",
",",
"'AU'",
",",
"'DE'",
",",
"'FR'",
",",
"'IT'",
",",
"'GB'",
",",
"'ES'",
",",
"'AT'",
",",
"'BE'",
",",
"'CA'",
",",
"'CH'",
",",
"'CN'",
",",
"'NL'",
",",
"'PL'",
")",
")",
")",
"{",
"$",
"lang_code",
"=",
"$",
"_SESSION",
"[",
"'languages_code'",
"]",
";",
"}",
"if",
"(",
"strtoupper",
"(",
"$",
"lang_code",
")",
"==",
"'EN'",
")",
"$",
"lang_code",
"=",
"'US'",
";",
"return",
"strtoupper",
"(",
"$",
"lang_code",
")",
";",
"}"
] |
Determine the language to use when visiting the PayPal site
|
[
"Determine",
"the",
"language",
"to",
"use",
"when",
"visiting",
"the",
"PayPal",
"site"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L993-L1009
|
229,788
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.calc_order_amount
|
function calc_order_amount($amount, $paypalCurrency, $applyFormatting = false) {
global $currencies;
$amount = ($amount * $currencies->get_value($paypalCurrency));
if ($paypalCurrency == 'JPY' || (int)$currencies->get_decimal_places($paypalCurrency) == 0) {
$amount = (int)$amount;
$applyFormatting = FALSE;
}
return ($applyFormatting ? number_format($amount, $currencies->get_decimal_places($paypalCurrency)) : $amount);
}
|
php
|
function calc_order_amount($amount, $paypalCurrency, $applyFormatting = false) {
global $currencies;
$amount = ($amount * $currencies->get_value($paypalCurrency));
if ($paypalCurrency == 'JPY' || (int)$currencies->get_decimal_places($paypalCurrency) == 0) {
$amount = (int)$amount;
$applyFormatting = FALSE;
}
return ($applyFormatting ? number_format($amount, $currencies->get_decimal_places($paypalCurrency)) : $amount);
}
|
[
"function",
"calc_order_amount",
"(",
"$",
"amount",
",",
"$",
"paypalCurrency",
",",
"$",
"applyFormatting",
"=",
"false",
")",
"{",
"global",
"$",
"currencies",
";",
"$",
"amount",
"=",
"(",
"$",
"amount",
"*",
"$",
"currencies",
"->",
"get_value",
"(",
"$",
"paypalCurrency",
")",
")",
";",
"if",
"(",
"$",
"paypalCurrency",
"==",
"'JPY'",
"||",
"(",
"int",
")",
"$",
"currencies",
"->",
"get_decimal_places",
"(",
"$",
"paypalCurrency",
")",
"==",
"0",
")",
"{",
"$",
"amount",
"=",
"(",
"int",
")",
"$",
"amount",
";",
"$",
"applyFormatting",
"=",
"FALSE",
";",
"}",
"return",
"(",
"$",
"applyFormatting",
"?",
"number_format",
"(",
"$",
"amount",
",",
"$",
"currencies",
"->",
"get_decimal_places",
"(",
"$",
"paypalCurrency",
")",
")",
":",
"$",
"amount",
")",
";",
"}"
] |
Calculate the amount based on acceptable currencies
|
[
"Calculate",
"the",
"amount",
"based",
"on",
"acceptable",
"currencies"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L1034-L1042
|
229,789
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.setShippingMethod
|
function setShippingMethod() {
global $total_count, $total_weight;
// ensure that cart contents is calculated properly for weight and value
if (!isset($total_weight)) $total_weight = $_SESSION['cart']->show_weight();
if (!isset($total_count)) $total_count = $_SESSION['cart']->count_contents();
// set the shipping method if one is not already set
// defaults to the cheapest shipping method
if ( !$_SESSION['shipping'] || ( $_SESSION['shipping'] && ($_SESSION['shipping'] == false) && (zen_count_shipping_modules() > 1) ) ) {
require_once(DIR_WS_CLASSES . 'http_client.php');
require_once(DIR_WS_CLASSES . 'shipping.php');
$shipping_Obj = new shipping;
// generate the quotes
$shipping_Obj->quote();
// set the cheapest one
$_SESSION['shipping'] = $shipping_Obj->cheapest();
}
}
|
php
|
function setShippingMethod() {
global $total_count, $total_weight;
// ensure that cart contents is calculated properly for weight and value
if (!isset($total_weight)) $total_weight = $_SESSION['cart']->show_weight();
if (!isset($total_count)) $total_count = $_SESSION['cart']->count_contents();
// set the shipping method if one is not already set
// defaults to the cheapest shipping method
if ( !$_SESSION['shipping'] || ( $_SESSION['shipping'] && ($_SESSION['shipping'] == false) && (zen_count_shipping_modules() > 1) ) ) {
require_once(DIR_WS_CLASSES . 'http_client.php');
require_once(DIR_WS_CLASSES . 'shipping.php');
$shipping_Obj = new shipping;
// generate the quotes
$shipping_Obj->quote();
// set the cheapest one
$_SESSION['shipping'] = $shipping_Obj->cheapest();
}
}
|
[
"function",
"setShippingMethod",
"(",
")",
"{",
"global",
"$",
"total_count",
",",
"$",
"total_weight",
";",
"// ensure that cart contents is calculated properly for weight and value",
"if",
"(",
"!",
"isset",
"(",
"$",
"total_weight",
")",
")",
"$",
"total_weight",
"=",
"$",
"_SESSION",
"[",
"'cart'",
"]",
"->",
"show_weight",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"total_count",
")",
")",
"$",
"total_count",
"=",
"$",
"_SESSION",
"[",
"'cart'",
"]",
"->",
"count_contents",
"(",
")",
";",
"// set the shipping method if one is not already set",
"// defaults to the cheapest shipping method",
"if",
"(",
"!",
"$",
"_SESSION",
"[",
"'shipping'",
"]",
"||",
"(",
"$",
"_SESSION",
"[",
"'shipping'",
"]",
"&&",
"(",
"$",
"_SESSION",
"[",
"'shipping'",
"]",
"==",
"false",
")",
"&&",
"(",
"zen_count_shipping_modules",
"(",
")",
">",
"1",
")",
")",
")",
"{",
"require_once",
"(",
"DIR_WS_CLASSES",
".",
"'http_client.php'",
")",
";",
"require_once",
"(",
"DIR_WS_CLASSES",
".",
"'shipping.php'",
")",
";",
"$",
"shipping_Obj",
"=",
"new",
"shipping",
";",
"// generate the quotes",
"$",
"shipping_Obj",
"->",
"quote",
"(",
")",
";",
"// set the cheapest one",
"$",
"_SESSION",
"[",
"'shipping'",
"]",
"=",
"$",
"shipping_Obj",
"->",
"cheapest",
"(",
")",
";",
"}",
"}"
] |
Determine the appropriate shipping method if applicable
By default, selects the lowest-cost quote
|
[
"Determine",
"the",
"appropriate",
"shipping",
"method",
"if",
"applicable",
"By",
"default",
"selects",
"the",
"lowest",
"-",
"cost",
"quote"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L2125-L2143
|
229,790
|
ZenMagick/ZenCart
|
includes/modules/payment/paypalwpp.php
|
paypalwpp.user_login
|
function user_login($email_address, $redirect = true) {
global $db, $order, $messageStack;
global $session_started;
if ($session_started == false) {
zen_redirect(zen_href_link(FILENAME_COOKIE_USAGE));
}
$sql = "SELECT * FROM " . TABLE_CUSTOMERS . "
WHERE customers_email_address = :custEmail ";
$sql = $db->bindVars($sql, ':custEmail', $email_address, 'string');
$check_customer = $db->Execute($sql);
if ($check_customer->EOF) {
$this->terminateEC(MODULE_PAYMENT_PAYPALWPP_TEXT_BAD_LOGIN, true);
}
if (SESSION_RECREATE == 'True') {
zen_session_recreate();
}
$sql = "SELECT entry_country_id, entry_zone_id
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :custID
AND address_book_id = :addrID ";
$sql = $db->bindVars($sql, ':custID', $check_customer->fields['customers_id'], 'integer');
$sql = $db->bindVars($sql, ':addrID', $check_customer->fields['customers_default_address_id'], 'integer');
$check_country = $db->Execute($sql);
$_SESSION['customer_id'] = (int)$check_customer->fields['customers_id'];
$_SESSION['customer_default_address_id'] = $check_customer->fields['customers_default_address_id'];
$_SESSION['customer_first_name'] = $check_customer->fields['customers_firstname'];
$_SESSION['customer_country_id'] = $check_country->fields['entry_country_id'];
$_SESSION['customer_zone_id'] = $check_country->fields['entry_zone_id'];
$order->customer['id'] = $_SESSION['customer_id'];
$sql = "UPDATE " . TABLE_CUSTOMERS_INFO . "
SET customers_info_date_of_last_logon = now(),
customers_info_number_of_logons = customers_info_number_of_logons+1
WHERE customers_info_id = :custID ";
$sql = $db->bindVars($sql, ':custID', $_SESSION['customer_id'], 'integer');
$db->Execute($sql);
// bof: contents merge notice
// save current cart contents count if required
if (SHOW_SHOPPING_CART_COMBINED > 0) {
$zc_check_basket_before = $_SESSION['cart']->count_contents();
}
// bof: not require part of contents merge notice
// restore cart contents
$_SESSION['cart']->restore_contents();
// eof: not require part of contents merge notice
// check current cart contents count if required
if (SHOW_SHOPPING_CART_COMBINED > 0 && $zc_check_basket_before > 0) {
$zc_check_basket_after = $_SESSION['cart']->count_contents();
if (($zc_check_basket_before != $zc_check_basket_after) && $_SESSION['cart']->count_contents() > 0 && SHOW_SHOPPING_CART_COMBINED > 0) {
if (SHOW_SHOPPING_CART_COMBINED == 2) {
// warning only do not send to cart
$messageStack->add_session('header', WARNING_SHOPPING_CART_COMBINED, 'caution');
}
if (SHOW_SHOPPING_CART_COMBINED == 1) {
// show warning and send to shopping cart for review
$messageStack->add_session('shopping_cart', WARNING_SHOPPING_CART_COMBINED, 'caution');
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));
}
}
}
// eof: contents merge notice
if ($redirect) {
$this->terminateEC();
}
return true;
}
|
php
|
function user_login($email_address, $redirect = true) {
global $db, $order, $messageStack;
global $session_started;
if ($session_started == false) {
zen_redirect(zen_href_link(FILENAME_COOKIE_USAGE));
}
$sql = "SELECT * FROM " . TABLE_CUSTOMERS . "
WHERE customers_email_address = :custEmail ";
$sql = $db->bindVars($sql, ':custEmail', $email_address, 'string');
$check_customer = $db->Execute($sql);
if ($check_customer->EOF) {
$this->terminateEC(MODULE_PAYMENT_PAYPALWPP_TEXT_BAD_LOGIN, true);
}
if (SESSION_RECREATE == 'True') {
zen_session_recreate();
}
$sql = "SELECT entry_country_id, entry_zone_id
FROM " . TABLE_ADDRESS_BOOK . "
WHERE customers_id = :custID
AND address_book_id = :addrID ";
$sql = $db->bindVars($sql, ':custID', $check_customer->fields['customers_id'], 'integer');
$sql = $db->bindVars($sql, ':addrID', $check_customer->fields['customers_default_address_id'], 'integer');
$check_country = $db->Execute($sql);
$_SESSION['customer_id'] = (int)$check_customer->fields['customers_id'];
$_SESSION['customer_default_address_id'] = $check_customer->fields['customers_default_address_id'];
$_SESSION['customer_first_name'] = $check_customer->fields['customers_firstname'];
$_SESSION['customer_country_id'] = $check_country->fields['entry_country_id'];
$_SESSION['customer_zone_id'] = $check_country->fields['entry_zone_id'];
$order->customer['id'] = $_SESSION['customer_id'];
$sql = "UPDATE " . TABLE_CUSTOMERS_INFO . "
SET customers_info_date_of_last_logon = now(),
customers_info_number_of_logons = customers_info_number_of_logons+1
WHERE customers_info_id = :custID ";
$sql = $db->bindVars($sql, ':custID', $_SESSION['customer_id'], 'integer');
$db->Execute($sql);
// bof: contents merge notice
// save current cart contents count if required
if (SHOW_SHOPPING_CART_COMBINED > 0) {
$zc_check_basket_before = $_SESSION['cart']->count_contents();
}
// bof: not require part of contents merge notice
// restore cart contents
$_SESSION['cart']->restore_contents();
// eof: not require part of contents merge notice
// check current cart contents count if required
if (SHOW_SHOPPING_CART_COMBINED > 0 && $zc_check_basket_before > 0) {
$zc_check_basket_after = $_SESSION['cart']->count_contents();
if (($zc_check_basket_before != $zc_check_basket_after) && $_SESSION['cart']->count_contents() > 0 && SHOW_SHOPPING_CART_COMBINED > 0) {
if (SHOW_SHOPPING_CART_COMBINED == 2) {
// warning only do not send to cart
$messageStack->add_session('header', WARNING_SHOPPING_CART_COMBINED, 'caution');
}
if (SHOW_SHOPPING_CART_COMBINED == 1) {
// show warning and send to shopping cart for review
$messageStack->add_session('shopping_cart', WARNING_SHOPPING_CART_COMBINED, 'caution');
zen_redirect(zen_href_link(FILENAME_SHOPPING_CART, '', 'NONSSL'));
}
}
}
// eof: contents merge notice
if ($redirect) {
$this->terminateEC();
}
return true;
}
|
[
"function",
"user_login",
"(",
"$",
"email_address",
",",
"$",
"redirect",
"=",
"true",
")",
"{",
"global",
"$",
"db",
",",
"$",
"order",
",",
"$",
"messageStack",
";",
"global",
"$",
"session_started",
";",
"if",
"(",
"$",
"session_started",
"==",
"false",
")",
"{",
"zen_redirect",
"(",
"zen_href_link",
"(",
"FILENAME_COOKIE_USAGE",
")",
")",
";",
"}",
"$",
"sql",
"=",
"\"SELECT * FROM \"",
".",
"TABLE_CUSTOMERS",
".",
"\"\n WHERE customers_email_address = :custEmail \"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':custEmail'",
",",
"$",
"email_address",
",",
"'string'",
")",
";",
"$",
"check_customer",
"=",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"check_customer",
"->",
"EOF",
")",
"{",
"$",
"this",
"->",
"terminateEC",
"(",
"MODULE_PAYMENT_PAYPALWPP_TEXT_BAD_LOGIN",
",",
"true",
")",
";",
"}",
"if",
"(",
"SESSION_RECREATE",
"==",
"'True'",
")",
"{",
"zen_session_recreate",
"(",
")",
";",
"}",
"$",
"sql",
"=",
"\"SELECT entry_country_id, entry_zone_id\n FROM \"",
".",
"TABLE_ADDRESS_BOOK",
".",
"\"\n WHERE customers_id = :custID\n AND address_book_id = :addrID \"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':custID'",
",",
"$",
"check_customer",
"->",
"fields",
"[",
"'customers_id'",
"]",
",",
"'integer'",
")",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':addrID'",
",",
"$",
"check_customer",
"->",
"fields",
"[",
"'customers_default_address_id'",
"]",
",",
"'integer'",
")",
";",
"$",
"check_country",
"=",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"$",
"_SESSION",
"[",
"'customer_id'",
"]",
"=",
"(",
"int",
")",
"$",
"check_customer",
"->",
"fields",
"[",
"'customers_id'",
"]",
";",
"$",
"_SESSION",
"[",
"'customer_default_address_id'",
"]",
"=",
"$",
"check_customer",
"->",
"fields",
"[",
"'customers_default_address_id'",
"]",
";",
"$",
"_SESSION",
"[",
"'customer_first_name'",
"]",
"=",
"$",
"check_customer",
"->",
"fields",
"[",
"'customers_firstname'",
"]",
";",
"$",
"_SESSION",
"[",
"'customer_country_id'",
"]",
"=",
"$",
"check_country",
"->",
"fields",
"[",
"'entry_country_id'",
"]",
";",
"$",
"_SESSION",
"[",
"'customer_zone_id'",
"]",
"=",
"$",
"check_country",
"->",
"fields",
"[",
"'entry_zone_id'",
"]",
";",
"$",
"order",
"->",
"customer",
"[",
"'id'",
"]",
"=",
"$",
"_SESSION",
"[",
"'customer_id'",
"]",
";",
"$",
"sql",
"=",
"\"UPDATE \"",
".",
"TABLE_CUSTOMERS_INFO",
".",
"\"\n SET customers_info_date_of_last_logon = now(),\n customers_info_number_of_logons = customers_info_number_of_logons+1\n WHERE customers_info_id = :custID \"",
";",
"$",
"sql",
"=",
"$",
"db",
"->",
"bindVars",
"(",
"$",
"sql",
",",
"':custID'",
",",
"$",
"_SESSION",
"[",
"'customer_id'",
"]",
",",
"'integer'",
")",
";",
"$",
"db",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"// bof: contents merge notice",
"// save current cart contents count if required",
"if",
"(",
"SHOW_SHOPPING_CART_COMBINED",
">",
"0",
")",
"{",
"$",
"zc_check_basket_before",
"=",
"$",
"_SESSION",
"[",
"'cart'",
"]",
"->",
"count_contents",
"(",
")",
";",
"}",
"// bof: not require part of contents merge notice",
"// restore cart contents",
"$",
"_SESSION",
"[",
"'cart'",
"]",
"->",
"restore_contents",
"(",
")",
";",
"// eof: not require part of contents merge notice",
"// check current cart contents count if required",
"if",
"(",
"SHOW_SHOPPING_CART_COMBINED",
">",
"0",
"&&",
"$",
"zc_check_basket_before",
">",
"0",
")",
"{",
"$",
"zc_check_basket_after",
"=",
"$",
"_SESSION",
"[",
"'cart'",
"]",
"->",
"count_contents",
"(",
")",
";",
"if",
"(",
"(",
"$",
"zc_check_basket_before",
"!=",
"$",
"zc_check_basket_after",
")",
"&&",
"$",
"_SESSION",
"[",
"'cart'",
"]",
"->",
"count_contents",
"(",
")",
">",
"0",
"&&",
"SHOW_SHOPPING_CART_COMBINED",
">",
"0",
")",
"{",
"if",
"(",
"SHOW_SHOPPING_CART_COMBINED",
"==",
"2",
")",
"{",
"// warning only do not send to cart",
"$",
"messageStack",
"->",
"add_session",
"(",
"'header'",
",",
"WARNING_SHOPPING_CART_COMBINED",
",",
"'caution'",
")",
";",
"}",
"if",
"(",
"SHOW_SHOPPING_CART_COMBINED",
"==",
"1",
")",
"{",
"// show warning and send to shopping cart for review",
"$",
"messageStack",
"->",
"add_session",
"(",
"'shopping_cart'",
",",
"WARNING_SHOPPING_CART_COMBINED",
",",
"'caution'",
")",
";",
"zen_redirect",
"(",
"zen_href_link",
"(",
"FILENAME_SHOPPING_CART",
",",
"''",
",",
"'NONSSL'",
")",
")",
";",
"}",
"}",
"}",
"// eof: contents merge notice",
"if",
"(",
"$",
"redirect",
")",
"{",
"$",
"this",
"->",
"terminateEC",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
If we created an account for the customer, this logs them in and notes that the record was created for PayPal EC purposes
|
[
"If",
"we",
"created",
"an",
"account",
"for",
"the",
"customer",
"this",
"logs",
"them",
"in",
"and",
"notes",
"that",
"the",
"record",
"was",
"created",
"for",
"PayPal",
"EC",
"purposes"
] |
00438ebc0faee786489aab4a6d70fc0d0c1461c7
|
https://github.com/ZenMagick/ZenCart/blob/00438ebc0faee786489aab4a6d70fc0d0c1461c7/includes/modules/payment/paypalwpp.php#L2516-L2584
|
229,791
|
pingpong-labs/widget
|
Widget.php
|
Widget.register
|
public function register($name, $callback)
{
$this->widgets[$name] = $callback;
$this->registerBlade($name);
}
|
php
|
public function register($name, $callback)
{
$this->widgets[$name] = $callback;
$this->registerBlade($name);
}
|
[
"public",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"widgets",
"[",
"$",
"name",
"]",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"registerBlade",
"(",
"$",
"name",
")",
";",
"}"
] |
Register new widget.
@param string $name
@param string|callable $callback
|
[
"Register",
"new",
"widget",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L50-L55
|
229,792
|
pingpong-labs/widget
|
Widget.php
|
Widget.subscribe
|
public function subscribe($subscriber)
{
list($className, $method) = Str::parseCallback($subscriber, 'subscribe');
$instance = $this->container->make($className);
call_user_func_array([$instance, $method], [$this]);
}
|
php
|
public function subscribe($subscriber)
{
list($className, $method) = Str::parseCallback($subscriber, 'subscribe');
$instance = $this->container->make($className);
call_user_func_array([$instance, $method], [$this]);
}
|
[
"public",
"function",
"subscribe",
"(",
"$",
"subscriber",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"method",
")",
"=",
"Str",
"::",
"parseCallback",
"(",
"$",
"subscriber",
",",
"'subscribe'",
")",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"className",
")",
";",
"call_user_func_array",
"(",
"[",
"$",
"instance",
",",
"$",
"method",
"]",
",",
"[",
"$",
"this",
"]",
")",
";",
"}"
] |
Register widget using a specified handler class.
@param string $subscriber
|
[
"Register",
"widget",
"using",
"a",
"specified",
"handler",
"class",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L62-L69
|
229,793
|
pingpong-labs/widget
|
Widget.php
|
Widget.registerBlade
|
protected function registerBlade($name)
{
$this->blade->extend(function ($view, $compiler) use ($name) {
$pattern = $this->createMatcher($name);
$replace = '$1<?php echo Widget::'.$name.'$2; ?>';
return preg_replace($pattern, $replace, $view);
});
}
|
php
|
protected function registerBlade($name)
{
$this->blade->extend(function ($view, $compiler) use ($name) {
$pattern = $this->createMatcher($name);
$replace = '$1<?php echo Widget::'.$name.'$2; ?>';
return preg_replace($pattern, $replace, $view);
});
}
|
[
"protected",
"function",
"registerBlade",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"blade",
"->",
"extend",
"(",
"function",
"(",
"$",
"view",
",",
"$",
"compiler",
")",
"use",
"(",
"$",
"name",
")",
"{",
"$",
"pattern",
"=",
"$",
"this",
"->",
"createMatcher",
"(",
"$",
"name",
")",
";",
"$",
"replace",
"=",
"'$1<?php echo Widget::'",
".",
"$",
"name",
".",
"'$2; ?>'",
";",
"return",
"preg_replace",
"(",
"$",
"pattern",
",",
"$",
"replace",
",",
"$",
"view",
")",
";",
"}",
")",
";",
"}"
] |
Register blade syntax for a specific widget.
@param string $name
|
[
"Register",
"blade",
"syntax",
"for",
"a",
"specific",
"widget",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L76-L85
|
229,794
|
pingpong-labs/widget
|
Widget.php
|
Widget.get
|
public function get($name, array $parameters = array())
{
if ($this->hasGroup($name)) {
return $this->callGroup($name, $parameters);
}
if ($this->has($name)) {
$callback = $this->widgets[$name];
return $this->getCallback($callback, $parameters);
}
return null;
}
|
php
|
public function get($name, array $parameters = array())
{
if ($this->hasGroup($name)) {
return $this->callGroup($name, $parameters);
}
if ($this->has($name)) {
$callback = $this->widgets[$name];
return $this->getCallback($callback, $parameters);
}
return null;
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
",",
"array",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasGroup",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"callGroup",
"(",
"$",
"name",
",",
"$",
"parameters",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"widgets",
"[",
"$",
"name",
"]",
";",
"return",
"$",
"this",
"->",
"getCallback",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Calling a specific widget.
@param string $name
@param array $parameters
@return mixed
|
[
"Calling",
"a",
"specific",
"widget",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L131-L144
|
229,795
|
pingpong-labs/widget
|
Widget.php
|
Widget.getCallback
|
protected function getCallback($callback, array $parameters)
{
if ($callback instanceof Closure) {
return $this->createCallableCallback($callback, $parameters);
} elseif (is_string($callback)) {
return $this->createStringCallback($callback, $parameters);
} else {
return;
}
}
|
php
|
protected function getCallback($callback, array $parameters)
{
if ($callback instanceof Closure) {
return $this->createCallableCallback($callback, $parameters);
} elseif (is_string($callback)) {
return $this->createStringCallback($callback, $parameters);
} else {
return;
}
}
|
[
"protected",
"function",
"getCallback",
"(",
"$",
"callback",
",",
"array",
"$",
"parameters",
")",
"{",
"if",
"(",
"$",
"callback",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"this",
"->",
"createCallableCallback",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createStringCallback",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"else",
"{",
"return",
";",
"}",
"}"
] |
Get a callback from specific widget.
@param mixed $callback
@param array $parameters
@return mixed
|
[
"Get",
"a",
"callback",
"from",
"specific",
"widget",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L154-L163
|
229,796
|
pingpong-labs/widget
|
Widget.php
|
Widget.createStringCallback
|
protected function createStringCallback($callback, array $parameters)
{
if (function_exists($callback)) {
return $this->createCallableCallback($callback, $parameters);
} else {
return $this->createClassesCallback($callback, $parameters);
}
}
|
php
|
protected function createStringCallback($callback, array $parameters)
{
if (function_exists($callback)) {
return $this->createCallableCallback($callback, $parameters);
} else {
return $this->createClassesCallback($callback, $parameters);
}
}
|
[
"protected",
"function",
"createStringCallback",
"(",
"$",
"callback",
",",
"array",
"$",
"parameters",
")",
"{",
"if",
"(",
"function_exists",
"(",
"$",
"callback",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createCallableCallback",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"createClassesCallback",
"(",
"$",
"callback",
",",
"$",
"parameters",
")",
";",
"}",
"}"
] |
Get a result from string callback.
@param string $callback
@param array $parameters
@return mixed
|
[
"Get",
"a",
"result",
"from",
"string",
"callback",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L173-L180
|
229,797
|
pingpong-labs/widget
|
Widget.php
|
Widget.createClassesCallback
|
protected function createClassesCallback($callback, array $parameters)
{
list($className, $method) = Str::parseCallback($callback, 'register');
$instance = $this->container->make($className);
$callable = array($instance, $method);
return $this->createCallableCallback($callable, $parameters);
}
|
php
|
protected function createClassesCallback($callback, array $parameters)
{
list($className, $method) = Str::parseCallback($callback, 'register');
$instance = $this->container->make($className);
$callable = array($instance, $method);
return $this->createCallableCallback($callable, $parameters);
}
|
[
"protected",
"function",
"createClassesCallback",
"(",
"$",
"callback",
",",
"array",
"$",
"parameters",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"method",
")",
"=",
"Str",
"::",
"parseCallback",
"(",
"$",
"callback",
",",
"'register'",
")",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"className",
")",
";",
"$",
"callable",
"=",
"array",
"(",
"$",
"instance",
",",
"$",
"method",
")",
";",
"return",
"$",
"this",
"->",
"createCallableCallback",
"(",
"$",
"callable",
",",
"$",
"parameters",
")",
";",
"}"
] |
Get a result from classes callback.
@param string $callback
@param array $parameters
@return mixed
|
[
"Get",
"a",
"result",
"from",
"classes",
"callback",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L203-L212
|
229,798
|
pingpong-labs/widget
|
Widget.php
|
Widget.group
|
public function group($name, array $widgets)
{
$this->groups[$name] = $widgets;
$this->registerBlade($name);
}
|
php
|
public function group($name, array $widgets)
{
$this->groups[$name] = $widgets;
$this->registerBlade($name);
}
|
[
"public",
"function",
"group",
"(",
"$",
"name",
",",
"array",
"$",
"widgets",
")",
"{",
"$",
"this",
"->",
"groups",
"[",
"$",
"name",
"]",
"=",
"$",
"widgets",
";",
"$",
"this",
"->",
"registerBlade",
"(",
"$",
"name",
")",
";",
"}"
] |
Group some widgets.
@param string $name
@param array $widgets
|
[
"Group",
"some",
"widgets",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L220-L225
|
229,799
|
pingpong-labs/widget
|
Widget.php
|
Widget.mergeGroup
|
public function mergeGroup($name, array $newWidgets)
{
$widgets = $this->hasGroup($name) ? $this->groups[$name] : [];
$this->groups[$name] = array_merge($widgets, $newWidgets);
$this->registerBlade($name);
}
|
php
|
public function mergeGroup($name, array $newWidgets)
{
$widgets = $this->hasGroup($name) ? $this->groups[$name] : [];
$this->groups[$name] = array_merge($widgets, $newWidgets);
$this->registerBlade($name);
}
|
[
"public",
"function",
"mergeGroup",
"(",
"$",
"name",
",",
"array",
"$",
"newWidgets",
")",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"hasGroup",
"(",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"groups",
"[",
"$",
"name",
"]",
":",
"[",
"]",
";",
"$",
"this",
"->",
"groups",
"[",
"$",
"name",
"]",
"=",
"array_merge",
"(",
"$",
"widgets",
",",
"$",
"newWidgets",
")",
";",
"$",
"this",
"->",
"registerBlade",
"(",
"$",
"name",
")",
";",
"}"
] |
Group some widgets, merging if previously set.
@param string $name
@param array $newWidgets
|
[
"Group",
"some",
"widgets",
"merging",
"if",
"previously",
"set",
"."
] |
4d3d4667da4b7037a0d00c42d1017e1edc0b8315
|
https://github.com/pingpong-labs/widget/blob/4d3d4667da4b7037a0d00c42d1017e1edc0b8315/Widget.php#L233-L240
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.