repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
listlengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
listlengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
movoin/one-swoole
|
src/Middleware/Manager.php
|
Manager.executeTerminators
|
public function executeTerminators(Request $request, Response $response): Response
{
$middlewares = $this->filterMiddleware(Terminator::class);
foreach ($middlewares as $middleware) {
$response = $middleware->doTerminate($request, $response);
}
unset($middlewares);
return $response;
}
|
php
|
public function executeTerminators(Request $request, Response $response): Response
{
$middlewares = $this->filterMiddleware(Terminator::class);
foreach ($middlewares as $middleware) {
$response = $middleware->doTerminate($request, $response);
}
unset($middlewares);
return $response;
}
|
[
"public",
"function",
"executeTerminators",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
":",
"Response",
"{",
"$",
"middlewares",
"=",
"$",
"this",
"->",
"filterMiddleware",
"(",
"Terminator",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"middlewares",
"as",
"$",
"middleware",
")",
"{",
"$",
"response",
"=",
"$",
"middleware",
"->",
"doTerminate",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"unset",
"(",
"$",
"middlewares",
")",
";",
"return",
"$",
"response",
";",
"}"
] |
执行匹配的结束器
@param \One\Protocol\Contracts\Request $request
@param \One\Protocol\Contracts\Response $response
@return \One\Protocol\Contracts\Response
|
[
"执行匹配的结束器"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Middleware/Manager.php#L162-L173
|
movoin/one-swoole
|
src/Middleware/Manager.php
|
Manager.addMatched
|
protected function addMatched(string $name)
{
if (! isset($this->matched[$name])) {
$this->matched[$name] = $this->newMiddleware($name);
}
}
|
php
|
protected function addMatched(string $name)
{
if (! isset($this->matched[$name])) {
$this->matched[$name] = $this->newMiddleware($name);
}
}
|
[
"protected",
"function",
"addMatched",
"(",
"string",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"matched",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"matched",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"newMiddleware",
"(",
"$",
"name",
")",
";",
"}",
"}"
] |
添加已匹配的中间件
@param string $name
@throws \One\Middleware\Exceptions\MiddlewareException
|
[
"添加已匹配的中间件"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Middleware/Manager.php#L196-L201
|
movoin/one-swoole
|
src/Middleware/Manager.php
|
Manager.newMiddleware
|
protected function newMiddleware(string $name): Middleware
{
try {
$middleware = Reflection::newInstance($name);
} catch (ReflectionException $e) {
throw new MiddlewareException('Middleware error while retrieving "%s"', $name, 0, $e);
}
return $middleware;
}
|
php
|
protected function newMiddleware(string $name): Middleware
{
try {
$middleware = Reflection::newInstance($name);
} catch (ReflectionException $e) {
throw new MiddlewareException('Middleware error while retrieving "%s"', $name, 0, $e);
}
return $middleware;
}
|
[
"protected",
"function",
"newMiddleware",
"(",
"string",
"$",
"name",
")",
":",
"Middleware",
"{",
"try",
"{",
"$",
"middleware",
"=",
"Reflection",
"::",
"newInstance",
"(",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"MiddlewareException",
"(",
"'Middleware error while retrieving \"%s\"'",
",",
"$",
"name",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"return",
"$",
"middleware",
";",
"}"
] |
实例化中间件
@param string $name
@return \One\Middleware\Contracts\Middleware
@throws \One\Middleware\Exceptions\MiddlewareException
|
[
"实例化中间件"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Middleware/Manager.php#L211-L220
|
ekyna/GlsUniBox
|
Api/Service.php
|
Service.getLabel
|
static public function getLabel($code)
{
static::isValid($code);
switch ($code) {
case static::EBP :
return 'Euro Business Parcel';
case static::GBP :
return 'Global Business Parcel';
case static::EP :
return 'Express Parcel Guaranteed';
case static::SHD :
return 'Shop Delivery Service';
case static::FDF :
return 'Flex Delivery Service';
case static::BP :
default:
return 'Business Parcel';
}
}
|
php
|
static public function getLabel($code)
{
static::isValid($code);
switch ($code) {
case static::EBP :
return 'Euro Business Parcel';
case static::GBP :
return 'Global Business Parcel';
case static::EP :
return 'Express Parcel Guaranteed';
case static::SHD :
return 'Shop Delivery Service';
case static::FDF :
return 'Flex Delivery Service';
case static::BP :
default:
return 'Business Parcel';
}
}
|
[
"static",
"public",
"function",
"getLabel",
"(",
"$",
"code",
")",
"{",
"static",
"::",
"isValid",
"(",
"$",
"code",
")",
";",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"static",
"::",
"EBP",
":",
"return",
"'Euro Business Parcel'",
";",
"case",
"static",
"::",
"GBP",
":",
"return",
"'Global Business Parcel'",
";",
"case",
"static",
"::",
"EP",
":",
"return",
"'Express Parcel Guaranteed'",
";",
"case",
"static",
"::",
"SHD",
":",
"return",
"'Shop Delivery Service'",
";",
"case",
"static",
"::",
"FDF",
":",
"return",
"'Flex Delivery Service'",
";",
"case",
"static",
"::",
"BP",
":",
"default",
":",
"return",
"'Business Parcel'",
";",
"}",
"}"
] |
Returns the label for the given product code.
@param string $code
@return string
|
[
"Returns",
"the",
"label",
"for",
"the",
"given",
"product",
"code",
"."
] |
train
|
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Service.php#L90-L109
|
ekyna/GlsUniBox
|
Api/Service.php
|
Service.getChoices
|
static public function getChoices()
{
$choices = [];
foreach (static::getCodes() as $code) {
$choices[static::getLabel($code)] = $code;
}
return $choices;
}
|
php
|
static public function getChoices()
{
$choices = [];
foreach (static::getCodes() as $code) {
$choices[static::getLabel($code)] = $code;
}
return $choices;
}
|
[
"static",
"public",
"function",
"getChoices",
"(",
")",
"{",
"$",
"choices",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"getCodes",
"(",
")",
"as",
"$",
"code",
")",
"{",
"$",
"choices",
"[",
"static",
"::",
"getLabel",
"(",
"$",
"code",
")",
"]",
"=",
"$",
"code",
";",
"}",
"return",
"$",
"choices",
";",
"}"
] |
Returns the choices.
@return array
|
[
"Returns",
"the",
"choices",
"."
] |
train
|
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Service.php#L116-L125
|
ekyna/GlsUniBox
|
Api/Service.php
|
Service.getUniShip
|
static function getUniShip($code)
{
static::isValid($code);
switch ($code) {
case static::EBP :
return 'CC';
case static::GBP :
return 'FF';
case static::EP :
case static::SHD :
case static::FDF :
return null;
case static::BP :
default:
return 'AA';
}
}
|
php
|
static function getUniShip($code)
{
static::isValid($code);
switch ($code) {
case static::EBP :
return 'CC';
case static::GBP :
return 'FF';
case static::EP :
case static::SHD :
case static::FDF :
return null;
case static::BP :
default:
return 'AA';
}
}
|
[
"static",
"function",
"getUniShip",
"(",
"$",
"code",
")",
"{",
"static",
"::",
"isValid",
"(",
"$",
"code",
")",
";",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"static",
"::",
"EBP",
":",
"return",
"'CC'",
";",
"case",
"static",
"::",
"GBP",
":",
"return",
"'FF'",
";",
"case",
"static",
"::",
"EP",
":",
"case",
"static",
"::",
"SHD",
":",
"case",
"static",
"::",
"FDF",
":",
"return",
"null",
";",
"case",
"static",
"::",
"BP",
":",
"default",
":",
"return",
"'AA'",
";",
"}",
"}"
] |
Returns the "UNI Ship" equivalent product code.
@param string $code
@return string
|
[
"Returns",
"the",
"UNI",
"Ship",
"equivalent",
"product",
"code",
"."
] |
train
|
https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Api/Service.php#L162-L179
|
fuzz-productions/laravel-api-data
|
src/Traits/Transformations.php
|
Transformations.transformEntity
|
public function transformEntity($entity, $transformer = null, SerializerAbstract $serializer = null): array
{
$transformer = $transformer ?: $this->getTransformerFromClassProperty();
$results = $this->transform()->resourceWith($entity, $transformer)->usingPaginatorIfPaged();
if ($serializer) {
return $results->serialize($serializer);
}
return $results->serialize();
}
|
php
|
public function transformEntity($entity, $transformer = null, SerializerAbstract $serializer = null): array
{
$transformer = $transformer ?: $this->getTransformerFromClassProperty();
$results = $this->transform()->resourceWith($entity, $transformer)->usingPaginatorIfPaged();
if ($serializer) {
return $results->serialize($serializer);
}
return $results->serialize();
}
|
[
"public",
"function",
"transformEntity",
"(",
"$",
"entity",
",",
"$",
"transformer",
"=",
"null",
",",
"SerializerAbstract",
"$",
"serializer",
"=",
"null",
")",
":",
"array",
"{",
"$",
"transformer",
"=",
"$",
"transformer",
"?",
":",
"$",
"this",
"->",
"getTransformerFromClassProperty",
"(",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"transform",
"(",
")",
"->",
"resourceWith",
"(",
"$",
"entity",
",",
"$",
"transformer",
")",
"->",
"usingPaginatorIfPaged",
"(",
")",
";",
"if",
"(",
"$",
"serializer",
")",
"{",
"return",
"$",
"results",
"->",
"serialize",
"(",
"$",
"serializer",
")",
";",
"}",
"return",
"$",
"results",
"->",
"serialize",
"(",
")",
";",
"}"
] |
Shortcut method for serializing and transforming an entity.
@param $entity
@param TransformerAbstract|callable|string|null $transformer
@param SerializerAbstract|null $serializer
@return array
|
[
"Shortcut",
"method",
"for",
"serializing",
"and",
"transforming",
"an",
"entity",
"."
] |
train
|
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Traits/Transformations.php#L36-L47
|
fuzz-productions/laravel-api-data
|
src/Traits/Transformations.php
|
Transformations.getTransformerFromClassProperty
|
protected function getTransformerFromClassProperty()
{
if (! isset($this->transformer) || ! $this->isTransformer($this->transformer)) {
throw new \InvalidArgumentException('You cannot transform the entity without providing a valid Transformer. Verify your transformer extends ' . TransformerAbstract::class);
}
return (is_a($this->transformer, TransformerAbstract::class, true) && ! is_object($this->transformer)) ?
new $this->transformer : $this->transformer;
}
|
php
|
protected function getTransformerFromClassProperty()
{
if (! isset($this->transformer) || ! $this->isTransformer($this->transformer)) {
throw new \InvalidArgumentException('You cannot transform the entity without providing a valid Transformer. Verify your transformer extends ' . TransformerAbstract::class);
}
return (is_a($this->transformer, TransformerAbstract::class, true) && ! is_object($this->transformer)) ?
new $this->transformer : $this->transformer;
}
|
[
"protected",
"function",
"getTransformerFromClassProperty",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"transformer",
")",
"||",
"!",
"$",
"this",
"->",
"isTransformer",
"(",
"$",
"this",
"->",
"transformer",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You cannot transform the entity without providing a valid Transformer. Verify your transformer extends '",
".",
"TransformerAbstract",
"::",
"class",
")",
";",
"}",
"return",
"(",
"is_a",
"(",
"$",
"this",
"->",
"transformer",
",",
"TransformerAbstract",
"::",
"class",
",",
"true",
")",
"&&",
"!",
"is_object",
"(",
"$",
"this",
"->",
"transformer",
")",
")",
"?",
"new",
"$",
"this",
"->",
"transformer",
":",
"$",
"this",
"->",
"transformer",
";",
"}"
] |
Gets the transformer from the class and validates it's a correct serializer.
@throws \InvalidArgumentException - If the class property does not set a proper Transformer.
@return TransformerAbstract
|
[
"Gets",
"the",
"transformer",
"from",
"the",
"class",
"and",
"validates",
"it",
"s",
"a",
"correct",
"serializer",
"."
] |
train
|
https://github.com/fuzz-productions/laravel-api-data/blob/25e181860d2f269b3b212195944c2bca95b411bb/src/Traits/Transformations.php#L56-L65
|
huasituo/hstcms
|
src/Providers/RouteServiceProvider.php
|
RouteServiceProvider.mapApiRoutes
|
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace.'\Api',
'domain' => config('hstcms.apiDomain') ? config('hstcms.apiDomain') : env('APP_URL'),
'prefix' => config('hstcms.apiDomain') ? '' : config('hstcms.apiPrefix') ? config('hstcms.apiPrefix') : 'api',
], function ($router) {
require __DIR__.'/../Routes/api.php';
});
}
|
php
|
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace.'\Api',
'domain' => config('hstcms.apiDomain') ? config('hstcms.apiDomain') : env('APP_URL'),
'prefix' => config('hstcms.apiDomain') ? '' : config('hstcms.apiPrefix') ? config('hstcms.apiPrefix') : 'api',
], function ($router) {
require __DIR__.'/../Routes/api.php';
});
}
|
[
"protected",
"function",
"mapApiRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'middleware'",
"=>",
"'api'",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"namespace",
".",
"'\\Api'",
",",
"'domain'",
"=>",
"config",
"(",
"'hstcms.apiDomain'",
")",
"?",
"config",
"(",
"'hstcms.apiDomain'",
")",
":",
"env",
"(",
"'APP_URL'",
")",
",",
"'prefix'",
"=>",
"config",
"(",
"'hstcms.apiDomain'",
")",
"?",
"''",
":",
"config",
"(",
"'hstcms.apiPrefix'",
")",
"?",
"config",
"(",
"'hstcms.apiPrefix'",
")",
":",
"'api'",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"require",
"__DIR__",
".",
"'/../Routes/api.php'",
";",
"}",
")",
";",
"}"
] |
Define the "api" routes for the module.
These routes are typically stateless.
@return void
|
[
"Define",
"the",
"api",
"routes",
"for",
"the",
"module",
"."
] |
train
|
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Providers/RouteServiceProvider.php#L72-L82
|
huasituo/hstcms
|
src/Providers/RouteServiceProvider.php
|
RouteServiceProvider.mapOpenRoutes
|
protected function mapOpenRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace.'\Open',
'prefix' => config('open.apiDomain') ? config('open.apiDomain') : env('APP_URL'),
'prefix' => config('open.apiDomain') ? 'api/cms' : 'open/api/cms',
], function ($router) {
require __DIR__.'/../Routes/open.php';
});
}
|
php
|
protected function mapOpenRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace.'\Open',
'prefix' => config('open.apiDomain') ? config('open.apiDomain') : env('APP_URL'),
'prefix' => config('open.apiDomain') ? 'api/cms' : 'open/api/cms',
], function ($router) {
require __DIR__.'/../Routes/open.php';
});
}
|
[
"protected",
"function",
"mapOpenRoutes",
"(",
")",
"{",
"Route",
"::",
"group",
"(",
"[",
"'middleware'",
"=>",
"'api'",
",",
"'namespace'",
"=>",
"$",
"this",
"->",
"namespace",
".",
"'\\Open'",
",",
"'prefix'",
"=>",
"config",
"(",
"'open.apiDomain'",
")",
"?",
"config",
"(",
"'open.apiDomain'",
")",
":",
"env",
"(",
"'APP_URL'",
")",
",",
"'prefix'",
"=>",
"config",
"(",
"'open.apiDomain'",
")",
"?",
"'api/cms'",
":",
"'open/api/cms'",
",",
"]",
",",
"function",
"(",
"$",
"router",
")",
"{",
"require",
"__DIR__",
".",
"'/../Routes/open.php'",
";",
"}",
")",
";",
"}"
] |
开放平台API
|
[
"开放平台API"
] |
train
|
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Providers/RouteServiceProvider.php#L85-L95
|
muxtor/yii2-pkk5-module
|
src/controllers/Pkk5consoleController.php
|
Pkk5consoleController.actionParse
|
public function actionParse($param)
{
$model = new ParseForm();
$model->kadastr = $param;
$data = $model->parse();
echo $this->render('parse',['data'=>$data]);
}
|
php
|
public function actionParse($param)
{
$model = new ParseForm();
$model->kadastr = $param;
$data = $model->parse();
echo $this->render('parse',['data'=>$data]);
}
|
[
"public",
"function",
"actionParse",
"(",
"$",
"param",
")",
"{",
"$",
"model",
"=",
"new",
"ParseForm",
"(",
")",
";",
"$",
"model",
"->",
"kadastr",
"=",
"$",
"param",
";",
"$",
"data",
"=",
"$",
"model",
"->",
"parse",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"render",
"(",
"'parse'",
",",
"[",
"'data'",
"=>",
"$",
"data",
"]",
")",
";",
"}"
] |
Lists all Pkk5kadastr models.
@return mixed
|
[
"Lists",
"all",
"Pkk5kadastr",
"models",
"."
] |
train
|
https://github.com/muxtor/yii2-pkk5-module/blob/09be77ddd171c66df53ec89d229d0cc5c0a9ad94/src/controllers/Pkk5consoleController.php#L21-L28
|
pageon/SlackWebhookMonolog
|
src/Slack/Webhook.php
|
Webhook.setUrl
|
private function setUrl(Url $url)
{
$urlValidationRegex = '_https:\/\/hooks.slack.com\/services\/[\w\/]+$_iuS';
if (!preg_match($urlValidationRegex, (string) $url)) {
throw new InvalidUrlException(
sprintf(
'The url: "%s" is not a valid url.
Slack webhook urls should always start with "https://hooks.slack.com/services/"',
$url
),
400
);
}
$this->url = $url;
return $this;
}
|
php
|
private function setUrl(Url $url)
{
$urlValidationRegex = '_https:\/\/hooks.slack.com\/services\/[\w\/]+$_iuS';
if (!preg_match($urlValidationRegex, (string) $url)) {
throw new InvalidUrlException(
sprintf(
'The url: "%s" is not a valid url.
Slack webhook urls should always start with "https://hooks.slack.com/services/"',
$url
),
400
);
}
$this->url = $url;
return $this;
}
|
[
"private",
"function",
"setUrl",
"(",
"Url",
"$",
"url",
")",
"{",
"$",
"urlValidationRegex",
"=",
"'_https:\\/\\/hooks.slack.com\\/services\\/[\\w\\/]+$_iuS'",
";",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"urlValidationRegex",
",",
"(",
"string",
")",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"InvalidUrlException",
"(",
"sprintf",
"(",
"'The url: \"%s\" is not a valid url.\n Slack webhook urls should always start with \"https://hooks.slack.com/services/\"'",
",",
"$",
"url",
")",
",",
"400",
")",
";",
"}",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"return",
"$",
"this",
";",
"}"
] |
This wil set the url if it is valid.
@param Url $url
@throws InvalidUrlException When it is not a valid webhook url of slack
@return self
|
[
"This",
"wil",
"set",
"the",
"url",
"if",
"it",
"is",
"valid",
"."
] |
train
|
https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Webhook.php#L58-L74
|
rozdol/bi
|
src/Utils/Html.php
|
Html.tabs_ajax
|
function tabs_ajax($items = [], $placeholder = '')
{
if ($placeholder=='') {
$placeholder='tab_page_'.uniqid();
$placeholder_div="<div id='$placeholder'></div>";
}
foreach ($items as $name => $link) {
$list.="<li><a href='#' data-toggle='tab' onclick='ajaxFunction(\"$placeholder\", \"$link\");'onmouseover=\"this.style.cursor='pointer';\">$name</a></li>\n";
}
$out.="
<ul class='nav nav-tabs'>
$list
</ul>
$placeholder_div
";
return $out;
}
|
php
|
function tabs_ajax($items = [], $placeholder = '')
{
if ($placeholder=='') {
$placeholder='tab_page_'.uniqid();
$placeholder_div="<div id='$placeholder'></div>";
}
foreach ($items as $name => $link) {
$list.="<li><a href='#' data-toggle='tab' onclick='ajaxFunction(\"$placeholder\", \"$link\");'onmouseover=\"this.style.cursor='pointer';\">$name</a></li>\n";
}
$out.="
<ul class='nav nav-tabs'>
$list
</ul>
$placeholder_div
";
return $out;
}
|
[
"function",
"tabs_ajax",
"(",
"$",
"items",
"=",
"[",
"]",
",",
"$",
"placeholder",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"placeholder",
"==",
"''",
")",
"{",
"$",
"placeholder",
"=",
"'tab_page_'",
".",
"uniqid",
"(",
")",
";",
"$",
"placeholder_div",
"=",
"\"<div id='$placeholder'></div>\"",
";",
"}",
"foreach",
"(",
"$",
"items",
"as",
"$",
"name",
"=>",
"$",
"link",
")",
"{",
"$",
"list",
".=",
"\"<li><a href='#' data-toggle='tab' onclick='ajaxFunction(\\\"$placeholder\\\", \\\"$link\\\");'onmouseover=\\\"this.style.cursor='pointer';\\\">$name</a></li>\\n\"",
";",
"}",
"$",
"out",
".=",
"\"\n <ul class='nav nav-tabs'>\n $list\n </ul>\n $placeholder_div\n \"",
";",
"return",
"$",
"out",
";",
"}"
] |
====
|
[
"===="
] |
train
|
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Utils/Html.php#L1149-L1167
|
rozdol/bi
|
src/Utils/Html.php
|
Html.dropzoneJS
|
function dropzoneJS($formdata = '', $text = 'Drop files here')
{
$related_data=json_decode($formdata, true);
//echo $this->pre_display($related_data,$formdata); exit;
foreach ($related_data as $key => $value) {
$hidden.=$this->form_hidden($key, $value);
}
$out='
<span id="up-ack"></span>
<form id="file-up" class="dropzone">
'.$hidden.'
</form>
<!-- here you display files -->
<span id="show-files"></span>
<div class="col-md-2">
<!-- Right Side-->
</div>
</div>
</div><!-- jQuery -->
<script src="assets/js/dropzone.js"></script>
<script language="JavaScript">
$(document).ready(function () {
//prevent error: "Error: Dropzone already attached."
Dropzone.autoDiscover = false;
$("#file-up").dropzone({
url: "?act=save&what=dropzone&plain=1",
addRemoveLinks: true,
parallelUploads: 10,
uploadMultiple: false,
dictDefaultMessage:"'.$text.'",
maxFilesize: 256, // MB // you can add more or less
//acceptedFiles: ".jpeg, .jpg, .jpe, .bmp, .png, .gif, .ico, .tiff, .tif, .svg, .svgz,.doc,.docx,.txt, .pdf,.rtf,.xlsx,.xls,.xlsb,.csv, .ppt,.zip,.zipx,.tar,.gz,.z,.rar,.eml,.xml", // files you accepting
success: function (file, response) {
var imgName = response;
file.previewElement.classList.add("dz-success");
$(\'#up-ack\').html(response); // get the file upload responses
},
error: function (file, response) {
file.previewElement.classList.add("dz-error");
$(\'#up-ack\').css(\'color\',\'red\').html(response);
}
});
});
</script>
';
return $out;
}
|
php
|
function dropzoneJS($formdata = '', $text = 'Drop files here')
{
$related_data=json_decode($formdata, true);
//echo $this->pre_display($related_data,$formdata); exit;
foreach ($related_data as $key => $value) {
$hidden.=$this->form_hidden($key, $value);
}
$out='
<span id="up-ack"></span>
<form id="file-up" class="dropzone">
'.$hidden.'
</form>
<!-- here you display files -->
<span id="show-files"></span>
<div class="col-md-2">
<!-- Right Side-->
</div>
</div>
</div><!-- jQuery -->
<script src="assets/js/dropzone.js"></script>
<script language="JavaScript">
$(document).ready(function () {
//prevent error: "Error: Dropzone already attached."
Dropzone.autoDiscover = false;
$("#file-up").dropzone({
url: "?act=save&what=dropzone&plain=1",
addRemoveLinks: true,
parallelUploads: 10,
uploadMultiple: false,
dictDefaultMessage:"'.$text.'",
maxFilesize: 256, // MB // you can add more or less
//acceptedFiles: ".jpeg, .jpg, .jpe, .bmp, .png, .gif, .ico, .tiff, .tif, .svg, .svgz,.doc,.docx,.txt, .pdf,.rtf,.xlsx,.xls,.xlsb,.csv, .ppt,.zip,.zipx,.tar,.gz,.z,.rar,.eml,.xml", // files you accepting
success: function (file, response) {
var imgName = response;
file.previewElement.classList.add("dz-success");
$(\'#up-ack\').html(response); // get the file upload responses
},
error: function (file, response) {
file.previewElement.classList.add("dz-error");
$(\'#up-ack\').css(\'color\',\'red\').html(response);
}
});
});
</script>
';
return $out;
}
|
[
"function",
"dropzoneJS",
"(",
"$",
"formdata",
"=",
"''",
",",
"$",
"text",
"=",
"'Drop files here'",
")",
"{",
"$",
"related_data",
"=",
"json_decode",
"(",
"$",
"formdata",
",",
"true",
")",
";",
"//echo $this->pre_display($related_data,$formdata); exit;",
"foreach",
"(",
"$",
"related_data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"hidden",
".=",
"$",
"this",
"->",
"form_hidden",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"out",
"=",
"'\n <span id=\"up-ack\"></span>\n <form id=\"file-up\" class=\"dropzone\">\n '",
".",
"$",
"hidden",
".",
"'\n </form>\n\n <!-- here you display files -->\n <span id=\"show-files\"></span>\n\n <div class=\"col-md-2\">\n <!-- Right Side-->\n </div>\n </div>\n </div><!-- jQuery -->\n\n <script src=\"assets/js/dropzone.js\"></script>\n\n <script language=\"JavaScript\">\n $(document).ready(function () {\n //prevent error: \"Error: Dropzone already attached.\"\n Dropzone.autoDiscover = false;\n $(\"#file-up\").dropzone({\n url: \"?act=save&what=dropzone&plain=1\",\n addRemoveLinks: true,\n parallelUploads: 10,\n uploadMultiple: false,\n dictDefaultMessage:\"'",
".",
"$",
"text",
".",
"'\",\n maxFilesize: 256, // MB // you can add more or less\n //acceptedFiles: \".jpeg, .jpg, .jpe, .bmp, .png, .gif, .ico, .tiff, .tif, .svg, .svgz,.doc,.docx,.txt, .pdf,.rtf,.xlsx,.xls,.xlsb,.csv, .ppt,.zip,.zipx,.tar,.gz,.z,.rar,.eml,.xml\", // files you accepting\n\n success: function (file, response) {\n var imgName = response;\n file.previewElement.classList.add(\"dz-success\");\n $(\\'#up-ack\\').html(response); // get the file upload responses\n },\n\n error: function (file, response) {\n file.previewElement.classList.add(\"dz-error\");\n $(\\'#up-ack\\').css(\\'color\\',\\'red\\').html(response);\n }\n });\n });\n </script>\n '",
";",
"return",
"$",
"out",
";",
"}"
] |
}
|
[
"}"
] |
train
|
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Utils/Html.php#L2741-L2794
|
jpuck/color-mixer
|
src/Color.php
|
Color.dec
|
public function dec() : array
{
$colors = str_split( $this->hex('no-hash'), 2 );
return array_map(function($color){
return hexdec($color);
}, $colors);
}
|
php
|
public function dec() : array
{
$colors = str_split( $this->hex('no-hash'), 2 );
return array_map(function($color){
return hexdec($color);
}, $colors);
}
|
[
"public",
"function",
"dec",
"(",
")",
":",
"array",
"{",
"$",
"colors",
"=",
"str_split",
"(",
"$",
"this",
"->",
"hex",
"(",
"'no-hash'",
")",
",",
"2",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"color",
")",
"{",
"return",
"hexdec",
"(",
"$",
"color",
")",
";",
"}",
",",
"$",
"colors",
")",
";",
"}"
] |
Get the CSS decimal color.
@return array Returns rgb integer decimal colors.
|
[
"Get",
"the",
"CSS",
"decimal",
"color",
"."
] |
train
|
https://github.com/jpuck/color-mixer/blob/cea01c3082a921a35e00ae0a287c795d9fd73ada/src/Color.php#L58-L65
|
jpuck/color-mixer
|
src/Color.php
|
Color.validateHexColorString
|
public static function validateHexColorString(string $hex) : bool
{
// optional leading hash #
$length = strlen( ltrim($hex, '#') );
// must be 3 or 6 characters
switch ($length) {
case 3: break;
case 6: break;
default: return false;
}
return preg_match('/^#?[0-9a-fA-F]{3,6}$/', $hex) === 1;
}
|
php
|
public static function validateHexColorString(string $hex) : bool
{
// optional leading hash #
$length = strlen( ltrim($hex, '#') );
// must be 3 or 6 characters
switch ($length) {
case 3: break;
case 6: break;
default: return false;
}
return preg_match('/^#?[0-9a-fA-F]{3,6}$/', $hex) === 1;
}
|
[
"public",
"static",
"function",
"validateHexColorString",
"(",
"string",
"$",
"hex",
")",
":",
"bool",
"{",
"// optional leading hash #",
"$",
"length",
"=",
"strlen",
"(",
"ltrim",
"(",
"$",
"hex",
",",
"'#'",
")",
")",
";",
"// must be 3 or 6 characters",
"switch",
"(",
"$",
"length",
")",
"{",
"case",
"3",
":",
"break",
";",
"case",
"6",
":",
"break",
";",
"default",
":",
"return",
"false",
";",
"}",
"return",
"preg_match",
"(",
"'/^#?[0-9a-fA-F]{3,6}$/'",
",",
"$",
"hex",
")",
"===",
"1",
";",
"}"
] |
Validates CSS hexadecimal color.
@param string $hex CSS hexadecimal color with optional leading hash #
@return bool Returns true if valid CSS hexadecimal color, otherwise false.
|
[
"Validates",
"CSS",
"hexadecimal",
"color",
"."
] |
train
|
https://github.com/jpuck/color-mixer/blob/cea01c3082a921a35e00ae0a287c795d9fd73ada/src/Color.php#L74-L87
|
jan-dolata/crude-crud
|
src/Http/Controllers/ThumbnailController.php
|
ThumbnailController.upload
|
public function upload(ThumbnailRequest $request)
{
$crudeName = $request->input('crudeName');
$crude = CrudeInstance::get($crudeName);
$column = $request->input('columnName');
$file = $request->file()['file'];
$id = $request->input('modelId');
$model = $crude->uploadThumbnailByIdAndColumn($id, $column, $file);
return ['success' => true, 'model' => $model];
}
|
php
|
public function upload(ThumbnailRequest $request)
{
$crudeName = $request->input('crudeName');
$crude = CrudeInstance::get($crudeName);
$column = $request->input('columnName');
$file = $request->file()['file'];
$id = $request->input('modelId');
$model = $crude->uploadThumbnailByIdAndColumn($id, $column, $file);
return ['success' => true, 'model' => $model];
}
|
[
"public",
"function",
"upload",
"(",
"ThumbnailRequest",
"$",
"request",
")",
"{",
"$",
"crudeName",
"=",
"$",
"request",
"->",
"input",
"(",
"'crudeName'",
")",
";",
"$",
"crude",
"=",
"CrudeInstance",
"::",
"get",
"(",
"$",
"crudeName",
")",
";",
"$",
"column",
"=",
"$",
"request",
"->",
"input",
"(",
"'columnName'",
")",
";",
"$",
"file",
"=",
"$",
"request",
"->",
"file",
"(",
")",
"[",
"'file'",
"]",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"input",
"(",
"'modelId'",
")",
";",
"$",
"model",
"=",
"$",
"crude",
"->",
"uploadThumbnailByIdAndColumn",
"(",
"$",
"id",
",",
"$",
"column",
",",
"$",
"file",
")",
";",
"return",
"[",
"'success'",
"=>",
"true",
",",
"'model'",
"=>",
"$",
"model",
"]",
";",
"}"
] |
Handle thumbnail upload
@author Wojciech Jurkowski <[email protected]>
|
[
"Handle",
"thumbnail",
"upload"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ThumbnailController.php#L18-L29
|
jan-dolata/crude-crud
|
src/Http/Controllers/ThumbnailController.php
|
ThumbnailController.delete
|
public function delete(ThumbnailRequest $request)
{
$crudeName = $request->input('crudeName');
$crude = CrudeInstance::get($crudeName);
$id = $request->input('model_id');
$column = $request->input('model_column');
$model = $crude->deleteThumbnailByIdAndColumn($id, $column);
return ['model' => $model];
}
|
php
|
public function delete(ThumbnailRequest $request)
{
$crudeName = $request->input('crudeName');
$crude = CrudeInstance::get($crudeName);
$id = $request->input('model_id');
$column = $request->input('model_column');
$model = $crude->deleteThumbnailByIdAndColumn($id, $column);
return ['model' => $model];
}
|
[
"public",
"function",
"delete",
"(",
"ThumbnailRequest",
"$",
"request",
")",
"{",
"$",
"crudeName",
"=",
"$",
"request",
"->",
"input",
"(",
"'crudeName'",
")",
";",
"$",
"crude",
"=",
"CrudeInstance",
"::",
"get",
"(",
"$",
"crudeName",
")",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"input",
"(",
"'model_id'",
")",
";",
"$",
"column",
"=",
"$",
"request",
"->",
"input",
"(",
"'model_column'",
")",
";",
"$",
"model",
"=",
"$",
"crude",
"->",
"deleteThumbnailByIdAndColumn",
"(",
"$",
"id",
",",
"$",
"column",
")",
";",
"return",
"[",
"'model'",
"=>",
"$",
"model",
"]",
";",
"}"
] |
delete thumbnail file
@author Wojciech Jurkowski <[email protected]>
|
[
"delete",
"thumbnail",
"file"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ThumbnailController.php#L35-L45
|
WellCommerce/CoreBundle
|
Form/DataTransformer/EntityToIdentifierTransformer.php
|
EntityToIdentifierTransformer.transform
|
public function transform($modelData)
{
if (null === $modelData) {
return 0;
}
$meta = $this->getRepository()->getMetadata();
$identifier = $meta->getSingleIdentifierFieldName();
return $this->propertyAccessor->getValue($modelData, $identifier);
}
|
php
|
public function transform($modelData)
{
if (null === $modelData) {
return 0;
}
$meta = $this->getRepository()->getMetadata();
$identifier = $meta->getSingleIdentifierFieldName();
return $this->propertyAccessor->getValue($modelData, $identifier);
}
|
[
"public",
"function",
"transform",
"(",
"$",
"modelData",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"modelData",
")",
"{",
"return",
"0",
";",
"}",
"$",
"meta",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"getMetadata",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"meta",
"->",
"getSingleIdentifierFieldName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"modelData",
",",
"$",
"identifier",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/WellCommerce/CoreBundle/blob/984fbd544d4b10cf11e54e0f3c304d100deb6842/Form/DataTransformer/EntityToIdentifierTransformer.php#L27-L37
|
WellCommerce/CoreBundle
|
Form/DataTransformer/EntityToIdentifierTransformer.php
|
EntityToIdentifierTransformer.reverseTransform
|
public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value)
{
if (null !== $value) {
$entity = $this->getRepository()->find($value);
$this->propertyAccessor->setValue($modelData, $propertyPath, $entity);
}
}
|
php
|
public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value)
{
if (null !== $value) {
$entity = $this->getRepository()->find($value);
$this->propertyAccessor->setValue($modelData, $propertyPath, $entity);
}
}
|
[
"public",
"function",
"reverseTransform",
"(",
"$",
"modelData",
",",
"PropertyPathInterface",
"$",
"propertyPath",
",",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"value",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"find",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"propertyAccessor",
"->",
"setValue",
"(",
"$",
"modelData",
",",
"$",
"propertyPath",
",",
"$",
"entity",
")",
";",
"}",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/WellCommerce/CoreBundle/blob/984fbd544d4b10cf11e54e0f3c304d100deb6842/Form/DataTransformer/EntityToIdentifierTransformer.php#L42-L48
|
huasituo/hstcms
|
src/Libraries/HuasituoApi/ApiBase.php
|
ApiBase.request
|
protected function request($url, $data, $headers=array())
{
try{
$result = $this->validate($url, $data);
if($result !== true) {
return $result;
}
$params = array();
// 特殊处理
$this->proccessRequest($url, $params, $data, $headers);
if($this->methods == 'get') {
$response = $this->client->get($url, $data);
} else {
$response = $this->client->post($url, $data, $params);
}
$obj = $this->proccessResult($response['content']);
}catch(Exception $e){
return array(
'error_code' => 'SDK108',
'error_msg' => 'connection or read data timeout',
);
}
return $obj;
}
|
php
|
protected function request($url, $data, $headers=array())
{
try{
$result = $this->validate($url, $data);
if($result !== true) {
return $result;
}
$params = array();
// 特殊处理
$this->proccessRequest($url, $params, $data, $headers);
if($this->methods == 'get') {
$response = $this->client->get($url, $data);
} else {
$response = $this->client->post($url, $data, $params);
}
$obj = $this->proccessResult($response['content']);
}catch(Exception $e){
return array(
'error_code' => 'SDK108',
'error_msg' => 'connection or read data timeout',
);
}
return $obj;
}
|
[
"protected",
"function",
"request",
"(",
"$",
"url",
",",
"$",
"data",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"validate",
"(",
"$",
"url",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"result",
"!==",
"true",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"params",
"=",
"array",
"(",
")",
";",
"// 特殊处理",
"$",
"this",
"->",
"proccessRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"data",
",",
"$",
"headers",
")",
";",
"if",
"(",
"$",
"this",
"->",
"methods",
"==",
"'get'",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"data",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"post",
"(",
"$",
"url",
",",
"$",
"data",
",",
"$",
"params",
")",
";",
"}",
"$",
"obj",
"=",
"$",
"this",
"->",
"proccessResult",
"(",
"$",
"response",
"[",
"'content'",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"array",
"(",
"'error_code'",
"=>",
"'SDK108'",
",",
"'error_msg'",
"=>",
"'connection or read data timeout'",
",",
")",
";",
"}",
"return",
"$",
"obj",
";",
"}"
] |
Api 请求
@param string $url
@param mixed $data
@return mixed
|
[
"Api",
"请求"
] |
train
|
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Libraries/HuasituoApi/ApiBase.php#L88-L112
|
BugBuster1701/banner
|
public/conban_clicks.php
|
BannerClicks.run
|
public function run()
{
// Input a digit >0 ?
if ( 0 == (int)$this->intBID )
{
if ( 0 == (int)$this->intDEFBID )
{
header('HTTP/1.1 501 Not Implemented');
throw new \ErrorException('Invalid Banner ID (' . \Input::get('bid') . ')',2,1,basename(__FILE__),__LINE__);
}
}
//Banner oder Kategorie Banner (Default Banner)
if ( 0 < (int)$this->intBID )
{
//normaler Banner
$banner_not_viewed = false;
// Check whether the Banner ID exists
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_url
, tb.banner_jumpTo
, tbs.banner_clicks
FROM
tl_banner tb
, tl_banner_stat tbs
WHERE
tb.id=tbs.id
AND
tb.id=?")
->execute($this->intBID);
if (!$objBanners->next())
{
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_url
, tb.banner_jumpTo
FROM
tl_banner tb
WHERE
tb.id=?")
->execute($this->intBID);
if (!$objBanners->next())
{
header('HTTP/1.1 501 Not Implemented');
throw new \ErrorException('Banner ID not found',2,1,basename(__FILE__),__LINE__);
}
else
{
$banner_not_viewed = true;
}
}
$banner_stat_update = false;
if ($this->checkUserAgent() === false
&& $this->checkBot() === false
&& $this->getSetReClickBlocker() === false
)
{
// keine User Agent Filterung
// kein Bot
// kein ReClick
$banner_stat_update = true;
}
if ($banner_stat_update === true)
{
if ($banner_not_viewed === false)
{
//Update
$tstamp = time();
$banner_clicks = $objBanners->banner_clicks + 1;
\Database::getInstance()->prepare("UPDATE
tl_banner_stat
SET
tstamp=?
, banner_clicks=?
WHERE
id=?")
->executeUncached($tstamp, $banner_clicks, $this->intBID);
}
else
{
//Insert
$arrSet = array
(
'id' => $this->intBID,
'tstamp' => time(),
'banner_clicks' => 1
);
\Database::getInstance()->prepare("INSERT IGNORE INTO tl_banner_stat %s")
->set($arrSet)
->execute();
}
}
//Banner Ziel per Page?
if ($objBanners->banner_jumpTo >0)
{
//url generieren
$objBannerNextPage = \Database::getInstance()
->prepare("SELECT
id
, alias
FROM
tl_page
WHERE
id=?")
->limit(1)
->execute($objBanners->banner_jumpTo);
if ($objBannerNextPage->numRows)
{
$objPage = \PageModel::findWithDetails($objBanners->banner_jumpTo);
$objBanners->banner_url = \Controller::generateFrontendUrl($objBannerNextPage->fetchAssoc(),
null,
$objPage->rootLanguage);
}
}
$banner_redirect = $this->getRedirectType($this->intBID);
}
else
{
// Default Banner from Category
// Check whether the Banner ID exists
$objBanners = \Database::getInstance()
->prepare("SELECT
id
, banner_default_url AS banner_url
FROM
tl_banner_category
WHERE
id=?")
->execute($this->intDEFBID);
if (!$objBanners->next())
{
header('HTTP/1.1 501 Not Implemented');
throw new \ErrorException('Default Banner ID not found',2,1,basename(__FILE__),__LINE__);
}
$banner_redirect = '303';
}
$banner_url = ampersand($objBanners->banner_url);
// 301 Moved Permanently
// 302 Found
// 303 See Other
// 307 Temporary Redirect (ab Contao 3.1)
$this->redirect($banner_url, $banner_redirect);
}
|
php
|
public function run()
{
// Input a digit >0 ?
if ( 0 == (int)$this->intBID )
{
if ( 0 == (int)$this->intDEFBID )
{
header('HTTP/1.1 501 Not Implemented');
throw new \ErrorException('Invalid Banner ID (' . \Input::get('bid') . ')',2,1,basename(__FILE__),__LINE__);
}
}
//Banner oder Kategorie Banner (Default Banner)
if ( 0 < (int)$this->intBID )
{
//normaler Banner
$banner_not_viewed = false;
// Check whether the Banner ID exists
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_url
, tb.banner_jumpTo
, tbs.banner_clicks
FROM
tl_banner tb
, tl_banner_stat tbs
WHERE
tb.id=tbs.id
AND
tb.id=?")
->execute($this->intBID);
if (!$objBanners->next())
{
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_url
, tb.banner_jumpTo
FROM
tl_banner tb
WHERE
tb.id=?")
->execute($this->intBID);
if (!$objBanners->next())
{
header('HTTP/1.1 501 Not Implemented');
throw new \ErrorException('Banner ID not found',2,1,basename(__FILE__),__LINE__);
}
else
{
$banner_not_viewed = true;
}
}
$banner_stat_update = false;
if ($this->checkUserAgent() === false
&& $this->checkBot() === false
&& $this->getSetReClickBlocker() === false
)
{
// keine User Agent Filterung
// kein Bot
// kein ReClick
$banner_stat_update = true;
}
if ($banner_stat_update === true)
{
if ($banner_not_viewed === false)
{
//Update
$tstamp = time();
$banner_clicks = $objBanners->banner_clicks + 1;
\Database::getInstance()->prepare("UPDATE
tl_banner_stat
SET
tstamp=?
, banner_clicks=?
WHERE
id=?")
->executeUncached($tstamp, $banner_clicks, $this->intBID);
}
else
{
//Insert
$arrSet = array
(
'id' => $this->intBID,
'tstamp' => time(),
'banner_clicks' => 1
);
\Database::getInstance()->prepare("INSERT IGNORE INTO tl_banner_stat %s")
->set($arrSet)
->execute();
}
}
//Banner Ziel per Page?
if ($objBanners->banner_jumpTo >0)
{
//url generieren
$objBannerNextPage = \Database::getInstance()
->prepare("SELECT
id
, alias
FROM
tl_page
WHERE
id=?")
->limit(1)
->execute($objBanners->banner_jumpTo);
if ($objBannerNextPage->numRows)
{
$objPage = \PageModel::findWithDetails($objBanners->banner_jumpTo);
$objBanners->banner_url = \Controller::generateFrontendUrl($objBannerNextPage->fetchAssoc(),
null,
$objPage->rootLanguage);
}
}
$banner_redirect = $this->getRedirectType($this->intBID);
}
else
{
// Default Banner from Category
// Check whether the Banner ID exists
$objBanners = \Database::getInstance()
->prepare("SELECT
id
, banner_default_url AS banner_url
FROM
tl_banner_category
WHERE
id=?")
->execute($this->intDEFBID);
if (!$objBanners->next())
{
header('HTTP/1.1 501 Not Implemented');
throw new \ErrorException('Default Banner ID not found',2,1,basename(__FILE__),__LINE__);
}
$banner_redirect = '303';
}
$banner_url = ampersand($objBanners->banner_url);
// 301 Moved Permanently
// 302 Found
// 303 See Other
// 307 Temporary Redirect (ab Contao 3.1)
$this->redirect($banner_url, $banner_redirect);
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"// Input a digit >0 ?",
"if",
"(",
"0",
"==",
"(",
"int",
")",
"$",
"this",
"->",
"intBID",
")",
"{",
"if",
"(",
"0",
"==",
"(",
"int",
")",
"$",
"this",
"->",
"intDEFBID",
")",
"{",
"header",
"(",
"'HTTP/1.1 501 Not Implemented'",
")",
";",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Invalid Banner ID ('",
".",
"\\",
"Input",
"::",
"get",
"(",
"'bid'",
")",
".",
"')'",
",",
"2",
",",
"1",
",",
"basename",
"(",
"__FILE__",
")",
",",
"__LINE__",
")",
";",
"}",
"}",
"//Banner oder Kategorie Banner (Default Banner)",
"if",
"(",
"0",
"<",
"(",
"int",
")",
"$",
"this",
"->",
"intBID",
")",
"{",
"//normaler Banner",
"$",
"banner_not_viewed",
"=",
"false",
";",
"// Check whether the Banner ID exists",
"$",
"objBanners",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n tb.id\n , tb.banner_url\n , tb.banner_jumpTo\n , tbs.banner_clicks\n FROM \n tl_banner tb\n , tl_banner_stat tbs\n WHERE \n tb.id=tbs.id \n AND \n tb.id=?\"",
")",
"->",
"execute",
"(",
"$",
"this",
"->",
"intBID",
")",
";",
"if",
"(",
"!",
"$",
"objBanners",
"->",
"next",
"(",
")",
")",
"{",
"$",
"objBanners",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n tb.id\n , tb.banner_url\n , tb.banner_jumpTo\n FROM \n tl_banner tb\n WHERE \n tb.id=?\"",
")",
"->",
"execute",
"(",
"$",
"this",
"->",
"intBID",
")",
";",
"if",
"(",
"!",
"$",
"objBanners",
"->",
"next",
"(",
")",
")",
"{",
"header",
"(",
"'HTTP/1.1 501 Not Implemented'",
")",
";",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Banner ID not found'",
",",
"2",
",",
"1",
",",
"basename",
"(",
"__FILE__",
")",
",",
"__LINE__",
")",
";",
"}",
"else",
"{",
"$",
"banner_not_viewed",
"=",
"true",
";",
"}",
"}",
"$",
"banner_stat_update",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"checkUserAgent",
"(",
")",
"===",
"false",
"&&",
"$",
"this",
"->",
"checkBot",
"(",
")",
"===",
"false",
"&&",
"$",
"this",
"->",
"getSetReClickBlocker",
"(",
")",
"===",
"false",
")",
"{",
"// keine User Agent Filterung",
"// kein Bot",
"// kein ReClick ",
"$",
"banner_stat_update",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"banner_stat_update",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"banner_not_viewed",
"===",
"false",
")",
"{",
"//Update",
"$",
"tstamp",
"=",
"time",
"(",
")",
";",
"$",
"banner_clicks",
"=",
"$",
"objBanners",
"->",
"banner_clicks",
"+",
"1",
";",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"UPDATE \n tl_banner_stat \n SET \n tstamp=?\n , banner_clicks=? \n WHERE \n id=?\"",
")",
"->",
"executeUncached",
"(",
"$",
"tstamp",
",",
"$",
"banner_clicks",
",",
"$",
"this",
"->",
"intBID",
")",
";",
"}",
"else",
"{",
"//Insert",
"$",
"arrSet",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"intBID",
",",
"'tstamp'",
"=>",
"time",
"(",
")",
",",
"'banner_clicks'",
"=>",
"1",
")",
";",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"INSERT IGNORE INTO tl_banner_stat %s\"",
")",
"->",
"set",
"(",
"$",
"arrSet",
")",
"->",
"execute",
"(",
")",
";",
"}",
"}",
"//Banner Ziel per Page?",
"if",
"(",
"$",
"objBanners",
"->",
"banner_jumpTo",
">",
"0",
")",
"{",
"//url generieren",
"$",
"objBannerNextPage",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n id\n , alias \n FROM \n tl_page \n WHERE \n id=?\"",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"execute",
"(",
"$",
"objBanners",
"->",
"banner_jumpTo",
")",
";",
"if",
"(",
"$",
"objBannerNextPage",
"->",
"numRows",
")",
"{",
"$",
"objPage",
"=",
"\\",
"PageModel",
"::",
"findWithDetails",
"(",
"$",
"objBanners",
"->",
"banner_jumpTo",
")",
";",
"$",
"objBanners",
"->",
"banner_url",
"=",
"\\",
"Controller",
"::",
"generateFrontendUrl",
"(",
"$",
"objBannerNextPage",
"->",
"fetchAssoc",
"(",
")",
",",
"null",
",",
"$",
"objPage",
"->",
"rootLanguage",
")",
";",
"}",
"}",
"$",
"banner_redirect",
"=",
"$",
"this",
"->",
"getRedirectType",
"(",
"$",
"this",
"->",
"intBID",
")",
";",
"}",
"else",
"{",
"// Default Banner from Category",
"// Check whether the Banner ID exists",
"$",
"objBanners",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n id\n , banner_default_url AS banner_url\n FROM \n tl_banner_category\n WHERE \n id=?\"",
")",
"->",
"execute",
"(",
"$",
"this",
"->",
"intDEFBID",
")",
";",
"if",
"(",
"!",
"$",
"objBanners",
"->",
"next",
"(",
")",
")",
"{",
"header",
"(",
"'HTTP/1.1 501 Not Implemented'",
")",
";",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Default Banner ID not found'",
",",
"2",
",",
"1",
",",
"basename",
"(",
"__FILE__",
")",
",",
"__LINE__",
")",
";",
"}",
"$",
"banner_redirect",
"=",
"'303'",
";",
"}",
"$",
"banner_url",
"=",
"ampersand",
"(",
"$",
"objBanners",
"->",
"banner_url",
")",
";",
"// 301 Moved Permanently",
"// 302 Found",
"// 303 See Other",
"// 307 Temporary Redirect (ab Contao 3.1)",
"$",
"this",
"->",
"redirect",
"(",
"$",
"banner_url",
",",
"$",
"banner_redirect",
")",
";",
"}"
] |
Get URL, Count Click, ReDirect
|
[
"Get",
"URL",
"Count",
"Click",
"ReDirect"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L82-L235
|
BugBuster1701/banner
|
public/conban_clicks.php
|
BannerClicks.getRedirectType
|
protected function getRedirectType($BID)
{
// aus BID die CatID
// über CatID in tl_module.banner_categories die tl_module.banner_redirect
// Schleife über alle zeilen, falls mehrere
$objCat = \Database::getInstance()->prepare("SELECT
pid as CatID
FROM
`tl_banner`
WHERE
id=?")
->execute($BID);
if (0 == $objCat->numRows)
{
return '301'; // error, but the show must go on
}
$objCat->next();
$objBRT = \Database::getInstance()->prepare("SELECT
`banner_categories`
,`banner_redirect`
FROM
`tl_module`
WHERE
type=?
AND
banner_categories=?")
->execute('banner', $objCat->CatID);
if (0 == $objBRT->numRows)
{
return '301'; // error, but the show must go on
}
$arrBRT = array();
while ($objBRT->next())
{
$arrBRT[] = ($objBRT->banner_redirect == 'temporary') ? '302' : '301';
}
if (count($arrBRT) == 1)
{
return $arrBRT[0]; // Nur ein Modul importiert, eindeutig
}
else
{
// mindestens 2 FE Module mit derselben Kategorie, zaehlen
$anz301=$anz302=0;
foreach ($arrBRT as $type)
{
if ($type=='301')
{
$anz301++;
}
else
{
$anz302++;
}
}
if ($anz301 >= $anz302)
{ // 301 hat bei Gleichstand Vorrang
return '301';
}
else
{
return '302';
}
}
}
|
php
|
protected function getRedirectType($BID)
{
// aus BID die CatID
// über CatID in tl_module.banner_categories die tl_module.banner_redirect
// Schleife über alle zeilen, falls mehrere
$objCat = \Database::getInstance()->prepare("SELECT
pid as CatID
FROM
`tl_banner`
WHERE
id=?")
->execute($BID);
if (0 == $objCat->numRows)
{
return '301'; // error, but the show must go on
}
$objCat->next();
$objBRT = \Database::getInstance()->prepare("SELECT
`banner_categories`
,`banner_redirect`
FROM
`tl_module`
WHERE
type=?
AND
banner_categories=?")
->execute('banner', $objCat->CatID);
if (0 == $objBRT->numRows)
{
return '301'; // error, but the show must go on
}
$arrBRT = array();
while ($objBRT->next())
{
$arrBRT[] = ($objBRT->banner_redirect == 'temporary') ? '302' : '301';
}
if (count($arrBRT) == 1)
{
return $arrBRT[0]; // Nur ein Modul importiert, eindeutig
}
else
{
// mindestens 2 FE Module mit derselben Kategorie, zaehlen
$anz301=$anz302=0;
foreach ($arrBRT as $type)
{
if ($type=='301')
{
$anz301++;
}
else
{
$anz302++;
}
}
if ($anz301 >= $anz302)
{ // 301 hat bei Gleichstand Vorrang
return '301';
}
else
{
return '302';
}
}
}
|
[
"protected",
"function",
"getRedirectType",
"(",
"$",
"BID",
")",
"{",
"// aus BID die CatID",
"// über CatID in tl_module.banner_categories die tl_module.banner_redirect",
"// Schleife über alle zeilen, falls mehrere",
"$",
"objCat",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n pid as CatID \n FROM \n `tl_banner` \n WHERE \n id=?\"",
")",
"->",
"execute",
"(",
"$",
"BID",
")",
";",
"if",
"(",
"0",
"==",
"$",
"objCat",
"->",
"numRows",
")",
"{",
"return",
"'301'",
";",
"// error, but the show must go on",
"}",
"$",
"objCat",
"->",
"next",
"(",
")",
";",
"$",
"objBRT",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n `banner_categories`\n ,`banner_redirect` \n FROM \n `tl_module` \n WHERE \n type=?\n AND \n banner_categories=?\"",
")",
"->",
"execute",
"(",
"'banner'",
",",
"$",
"objCat",
"->",
"CatID",
")",
";",
"if",
"(",
"0",
"==",
"$",
"objBRT",
"->",
"numRows",
")",
"{",
"return",
"'301'",
";",
"// error, but the show must go on",
"}",
"$",
"arrBRT",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"objBRT",
"->",
"next",
"(",
")",
")",
"{",
"$",
"arrBRT",
"[",
"]",
"=",
"(",
"$",
"objBRT",
"->",
"banner_redirect",
"==",
"'temporary'",
")",
"?",
"'302'",
":",
"'301'",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"arrBRT",
")",
"==",
"1",
")",
"{",
"return",
"$",
"arrBRT",
"[",
"0",
"]",
";",
"// Nur ein Modul importiert, eindeutig",
"}",
"else",
"{",
"// mindestens 2 FE Module mit derselben Kategorie, zaehlen",
"$",
"anz301",
"=",
"$",
"anz302",
"=",
"0",
";",
"foreach",
"(",
"$",
"arrBRT",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'301'",
")",
"{",
"$",
"anz301",
"++",
";",
"}",
"else",
"{",
"$",
"anz302",
"++",
";",
"}",
"}",
"if",
"(",
"$",
"anz301",
">=",
"$",
"anz302",
")",
"{",
"// 301 hat bei Gleichstand Vorrang",
"return",
"'301'",
";",
"}",
"else",
"{",
"return",
"'302'",
";",
"}",
"}",
"}"
] |
Search Banner Redirect Definition
@return int 301,302
|
[
"Search",
"Banner",
"Redirect",
"Definition"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L243-L308
|
BugBuster1701/banner
|
public/conban_clicks.php
|
BannerClicks.getSetReClickBlocker
|
protected function getSetReClickBlocker()
{
//$ClientIP = bin2hex(sha1(\Environment::get('remoteAddr'),true)); // sha1 20 Zeichen, bin2hex 40 zeichen
$BannerID = $this->intBID;
if ( $this->getReClickBlockerId($BannerID) === false )
{
// nichts geblockt, also blocken fürs den nächsten Aufruf
$this->setReClickBlockerId($BannerID);
// kein ReClickBlocker block gefunden, Zaehlung erlaubt, nicht blocken
return false;
}
else
{
// Eintrag innerhalb der Blockzeit, blocken
return true;
}
}
|
php
|
protected function getSetReClickBlocker()
{
//$ClientIP = bin2hex(sha1(\Environment::get('remoteAddr'),true)); // sha1 20 Zeichen, bin2hex 40 zeichen
$BannerID = $this->intBID;
if ( $this->getReClickBlockerId($BannerID) === false )
{
// nichts geblockt, also blocken fürs den nächsten Aufruf
$this->setReClickBlockerId($BannerID);
// kein ReClickBlocker block gefunden, Zaehlung erlaubt, nicht blocken
return false;
}
else
{
// Eintrag innerhalb der Blockzeit, blocken
return true;
}
}
|
[
"protected",
"function",
"getSetReClickBlocker",
"(",
")",
"{",
"//$ClientIP = bin2hex(sha1(\\Environment::get('remoteAddr'),true)); // sha1 20 Zeichen, bin2hex 40 zeichen",
"$",
"BannerID",
"=",
"$",
"this",
"->",
"intBID",
";",
"if",
"(",
"$",
"this",
"->",
"getReClickBlockerId",
"(",
"$",
"BannerID",
")",
"===",
"false",
")",
"{",
"// nichts geblockt, also blocken fürs den nächsten Aufruf",
"$",
"this",
"->",
"setReClickBlockerId",
"(",
"$",
"BannerID",
")",
";",
"// kein ReClickBlocker block gefunden, Zaehlung erlaubt, nicht blocken",
"return",
"false",
";",
"}",
"else",
"{",
"// Eintrag innerhalb der Blockzeit, blocken",
"return",
"true",
";",
"}",
"}"
] |
ReClick Blocker
@return bool false/true = no ban / ban
|
[
"ReClick",
"Blocker"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L316-L334
|
BugBuster1701/banner
|
public/conban_clicks.php
|
BannerClicks.checkBot
|
protected function checkBot()
{
if (isset($GLOBALS['TL_CONFIG']['mod_banner_bot_check'])
&& (int)$GLOBALS['TL_CONFIG']['mod_banner_bot_check'] == 0
)
{
//fuer debug log_message('bannerCheckBot abgeschaltet','Banner.log');
return false; //Bot Suche abgeschaltet ueber localconfig.php
}
if ($this->BD_CheckBotAgent() || $this->BD_CheckBotIP())
{
//fuer debug log_message('bannerCheckBot True','Banner.log');
return true;
}
//fuer debug log_message('bannerCheckBot False','Banner.log');
return false;
}
|
php
|
protected function checkBot()
{
if (isset($GLOBALS['TL_CONFIG']['mod_banner_bot_check'])
&& (int)$GLOBALS['TL_CONFIG']['mod_banner_bot_check'] == 0
)
{
//fuer debug log_message('bannerCheckBot abgeschaltet','Banner.log');
return false; //Bot Suche abgeschaltet ueber localconfig.php
}
if ($this->BD_CheckBotAgent() || $this->BD_CheckBotIP())
{
//fuer debug log_message('bannerCheckBot True','Banner.log');
return true;
}
//fuer debug log_message('bannerCheckBot False','Banner.log');
return false;
}
|
[
"protected",
"function",
"checkBot",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'mod_banner_bot_check'",
"]",
")",
"&&",
"(",
"int",
")",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'mod_banner_bot_check'",
"]",
"==",
"0",
")",
"{",
"//fuer debug log_message('bannerCheckBot abgeschaltet','Banner.log');",
"return",
"false",
";",
"//Bot Suche abgeschaltet ueber localconfig.php",
"}",
"if",
"(",
"$",
"this",
"->",
"BD_CheckBotAgent",
"(",
")",
"||",
"$",
"this",
"->",
"BD_CheckBotIP",
"(",
")",
")",
"{",
"//fuer debug log_message('bannerCheckBot True','Banner.log');",
"return",
"true",
";",
"}",
"//fuer debug log_message('bannerCheckBot False','Banner.log');",
"return",
"false",
";",
"}"
] |
Spider Bot Check
@return true = found, false = not found
|
[
"Spider",
"Bot",
"Check"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L340-L356
|
BugBuster1701/banner
|
public/conban_clicks.php
|
BannerClicks.checkUserAgent
|
protected function checkUserAgent()
{
if ( \Environment::get('httpUserAgent') )
{
$UserAgent = trim( \Environment::get('httpUserAgent') );
}
else
{
return false; // Ohne Absender keine Suche
}
$objUserAgent = \Database::getInstance()->prepare("SELECT
`banner_useragent`
FROM
`tl_module`
WHERE
`banner_useragent` !=?")
->limit(1)
->execute('');
if (!$objUserAgent->next())
{
return false; // keine Angaben im Modul
}
$arrUserAgents = explode(",", $objUserAgent->banner_useragent);
if (strlen(trim($arrUserAgents[0])) == 0)
{
return false; // keine Angaben im Modul
}
array_walk($arrUserAgents, array('self','bannerclickTrimArrayValue')); // trim der array values
// grobe Suche
$CheckUserAgent=str_replace($arrUserAgents, '#', $UserAgent);
if ($UserAgent != $CheckUserAgent)
{ // es wurde ersetzt also was gefunden
//fuer debug log_message('CheckUserAgent Click Filterung: Treffer!','Banner.log');
return true;
}
return false;
}
|
php
|
protected function checkUserAgent()
{
if ( \Environment::get('httpUserAgent') )
{
$UserAgent = trim( \Environment::get('httpUserAgent') );
}
else
{
return false; // Ohne Absender keine Suche
}
$objUserAgent = \Database::getInstance()->prepare("SELECT
`banner_useragent`
FROM
`tl_module`
WHERE
`banner_useragent` !=?")
->limit(1)
->execute('');
if (!$objUserAgent->next())
{
return false; // keine Angaben im Modul
}
$arrUserAgents = explode(",", $objUserAgent->banner_useragent);
if (strlen(trim($arrUserAgents[0])) == 0)
{
return false; // keine Angaben im Modul
}
array_walk($arrUserAgents, array('self','bannerclickTrimArrayValue')); // trim der array values
// grobe Suche
$CheckUserAgent=str_replace($arrUserAgents, '#', $UserAgent);
if ($UserAgent != $CheckUserAgent)
{ // es wurde ersetzt also was gefunden
//fuer debug log_message('CheckUserAgent Click Filterung: Treffer!','Banner.log');
return true;
}
return false;
}
|
[
"protected",
"function",
"checkUserAgent",
"(",
")",
"{",
"if",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpUserAgent'",
")",
")",
"{",
"$",
"UserAgent",
"=",
"trim",
"(",
"\\",
"Environment",
"::",
"get",
"(",
"'httpUserAgent'",
")",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"// Ohne Absender keine Suche",
"}",
"$",
"objUserAgent",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n `banner_useragent` \n FROM \n `tl_module` \n WHERE \n `banner_useragent` !=?\"",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"execute",
"(",
"''",
")",
";",
"if",
"(",
"!",
"$",
"objUserAgent",
"->",
"next",
"(",
")",
")",
"{",
"return",
"false",
";",
"// keine Angaben im Modul",
"}",
"$",
"arrUserAgents",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"objUserAgent",
"->",
"banner_useragent",
")",
";",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"arrUserAgents",
"[",
"0",
"]",
")",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"// keine Angaben im Modul",
"}",
"array_walk",
"(",
"$",
"arrUserAgents",
",",
"array",
"(",
"'self'",
",",
"'bannerclickTrimArrayValue'",
")",
")",
";",
"// trim der array values",
"// grobe Suche",
"$",
"CheckUserAgent",
"=",
"str_replace",
"(",
"$",
"arrUserAgents",
",",
"'#'",
",",
"$",
"UserAgent",
")",
";",
"if",
"(",
"$",
"UserAgent",
"!=",
"$",
"CheckUserAgent",
")",
"{",
"// es wurde ersetzt also was gefunden",
"//fuer debug log_message('CheckUserAgent Click Filterung: Treffer!','Banner.log');",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
HTTP_USER_AGENT Special Check
|
[
"HTTP_USER_AGENT",
"Special",
"Check"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L361-L398
|
BugBuster1701/banner
|
public/conban_clicks.php
|
BannerClicks.getReClickBlockerId
|
protected function getReClickBlockerId($banner_id=0)
{
$this->getSession('ReClickBlocker');
if ( count($this->_session) )
{
reset($this->_session);
foreach ($this->_session as $key => $val)
{
if ( $key == $banner_id &&
$this->removeReClickBlockerId($key, $val) === true )
{
// Key ist noch gültig und es muss daher geblockt werden
//fuer debug log_message('getReClickBlockerId Banner ID:'.$key,'Banner.log');
return true;
}
}
}
return false;
}
|
php
|
protected function getReClickBlockerId($banner_id=0)
{
$this->getSession('ReClickBlocker');
if ( count($this->_session) )
{
reset($this->_session);
foreach ($this->_session as $key => $val)
{
if ( $key == $banner_id &&
$this->removeReClickBlockerId($key, $val) === true )
{
// Key ist noch gültig und es muss daher geblockt werden
//fuer debug log_message('getReClickBlockerId Banner ID:'.$key,'Banner.log');
return true;
}
}
}
return false;
}
|
[
"protected",
"function",
"getReClickBlockerId",
"(",
"$",
"banner_id",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"getSession",
"(",
"'ReClickBlocker'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_session",
")",
")",
"{",
"reset",
"(",
"$",
"this",
"->",
"_session",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_session",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"$",
"banner_id",
"&&",
"$",
"this",
"->",
"removeReClickBlockerId",
"(",
"$",
"key",
",",
"$",
"val",
")",
"===",
"true",
")",
"{",
"// Key ist noch gültig und es muss daher geblockt werden",
"//fuer debug log_message('getReClickBlockerId Banner ID:'.$key,'Banner.log');",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Get ReClick Blocker, Get Banner ID if the timestamp ....
@param boolean true if blocked | false
|
[
"Get",
"ReClick",
"Blocker",
"Get",
"Banner",
"ID",
"if",
"the",
"timestamp",
"...."
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/public/conban_clicks.php#L433-L451
|
czim/laravel-pxlcms
|
src/Generator/Writer/Model/Steps/StubReplaceScopes.php
|
StubReplaceScopes.getCmsOrderedConfigReplace
|
protected function getCmsOrderedConfigReplace()
{
$orderColumns = $this->data['ordered_by'] ?: [];
// for now, ignore the ordering if the column to order on is translated
$translatedOrderColumns = array_intersect(array_keys($orderColumns
), $this->data['translated_attributes']);
if (count($translatedOrderColumns)) {
foreach ($translatedOrderColumns as $column) {
unset($orderColumns[ $column ]);
}
}
if ( ! count($orderColumns)) return '';
// we only need to set a config if the scope method is global
if (config('pxlcms.generator.models.scopes.position_order') !== CmsModelWriter::SCOPE_GLOBAL) return '';
// align assignment signs by longest attribute
$longestLength = 0;
foreach ($orderColumns as $attribute => $direction) {
if (strlen($attribute) > $longestLength) {
$longestLength = strlen($attribute);
}
}
$replace = $this->tab() . "protected \$cmsOrderBy = [\n";
foreach ($orderColumns as $attribute => $direction) {
$replace .= $this->tab(2)
. "'" . str_pad($attribute . "'", $longestLength + 1)
. " => '" . $direction . "',\n";
}
$replace .= $this->tab() . "];\n\n";
return $replace;
}
|
php
|
protected function getCmsOrderedConfigReplace()
{
$orderColumns = $this->data['ordered_by'] ?: [];
// for now, ignore the ordering if the column to order on is translated
$translatedOrderColumns = array_intersect(array_keys($orderColumns
), $this->data['translated_attributes']);
if (count($translatedOrderColumns)) {
foreach ($translatedOrderColumns as $column) {
unset($orderColumns[ $column ]);
}
}
if ( ! count($orderColumns)) return '';
// we only need to set a config if the scope method is global
if (config('pxlcms.generator.models.scopes.position_order') !== CmsModelWriter::SCOPE_GLOBAL) return '';
// align assignment signs by longest attribute
$longestLength = 0;
foreach ($orderColumns as $attribute => $direction) {
if (strlen($attribute) > $longestLength) {
$longestLength = strlen($attribute);
}
}
$replace = $this->tab() . "protected \$cmsOrderBy = [\n";
foreach ($orderColumns as $attribute => $direction) {
$replace .= $this->tab(2)
. "'" . str_pad($attribute . "'", $longestLength + 1)
. " => '" . $direction . "',\n";
}
$replace .= $this->tab() . "];\n\n";
return $replace;
}
|
[
"protected",
"function",
"getCmsOrderedConfigReplace",
"(",
")",
"{",
"$",
"orderColumns",
"=",
"$",
"this",
"->",
"data",
"[",
"'ordered_by'",
"]",
"?",
":",
"[",
"]",
";",
"// for now, ignore the ordering if the column to order on is translated",
"$",
"translatedOrderColumns",
"=",
"array_intersect",
"(",
"array_keys",
"(",
"$",
"orderColumns",
")",
",",
"$",
"this",
"->",
"data",
"[",
"'translated_attributes'",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"translatedOrderColumns",
")",
")",
"{",
"foreach",
"(",
"$",
"translatedOrderColumns",
"as",
"$",
"column",
")",
"{",
"unset",
"(",
"$",
"orderColumns",
"[",
"$",
"column",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"count",
"(",
"$",
"orderColumns",
")",
")",
"return",
"''",
";",
"// we only need to set a config if the scope method is global",
"if",
"(",
"config",
"(",
"'pxlcms.generator.models.scopes.position_order'",
")",
"!==",
"CmsModelWriter",
"::",
"SCOPE_GLOBAL",
")",
"return",
"''",
";",
"// align assignment signs by longest attribute",
"$",
"longestLength",
"=",
"0",
";",
"foreach",
"(",
"$",
"orderColumns",
"as",
"$",
"attribute",
"=>",
"$",
"direction",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"attribute",
")",
">",
"$",
"longestLength",
")",
"{",
"$",
"longestLength",
"=",
"strlen",
"(",
"$",
"attribute",
")",
";",
"}",
"}",
"$",
"replace",
"=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"protected \\$cmsOrderBy = [\\n\"",
";",
"foreach",
"(",
"$",
"orderColumns",
"as",
"$",
"attribute",
"=>",
"$",
"direction",
")",
"{",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
"2",
")",
".",
"\"'\"",
".",
"str_pad",
"(",
"$",
"attribute",
".",
"\"'\"",
",",
"$",
"longestLength",
"+",
"1",
")",
".",
"\" => '\"",
".",
"$",
"direction",
".",
"\"',\\n\"",
";",
"}",
"$",
"replace",
".=",
"$",
"this",
"->",
"tab",
"(",
")",
".",
"\"];\\n\\n\"",
";",
"return",
"$",
"replace",
";",
"}"
] |
Returns the replace required depending on whether the CMS module has
automatic sorting for defined columns
@return string
|
[
"Returns",
"the",
"replace",
"required",
"depending",
"on",
"whether",
"the",
"CMS",
"module",
"has",
"automatic",
"sorting",
"for",
"defined",
"columns"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceScopes.php#L87-L131
|
czim/laravel-pxlcms
|
src/Generator/Writer/Model/Steps/StubReplaceScopes.php
|
StubReplaceScopes.useScopeActive
|
protected function useScopeActive()
{
if (is_null($this->data['scope_active'])) {
return config('pxlcms.generator.models.scopes.only_active') === CmsModelWriter::SCOPE_METHOD;
}
return (bool) $this->data['scope_active'];
}
|
php
|
protected function useScopeActive()
{
if (is_null($this->data['scope_active'])) {
return config('pxlcms.generator.models.scopes.only_active') === CmsModelWriter::SCOPE_METHOD;
}
return (bool) $this->data['scope_active'];
}
|
[
"protected",
"function",
"useScopeActive",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"data",
"[",
"'scope_active'",
"]",
")",
")",
"{",
"return",
"config",
"(",
"'pxlcms.generator.models.scopes.only_active'",
")",
"===",
"CmsModelWriter",
"::",
"SCOPE_METHOD",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"data",
"[",
"'scope_active'",
"]",
";",
"}"
] |
Returns whether we're using a global scope for active
@return bool
|
[
"Returns",
"whether",
"we",
"re",
"using",
"a",
"global",
"scope",
"for",
"active"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceScopes.php#L149-L156
|
czim/laravel-pxlcms
|
src/Generator/Writer/Model/Steps/StubReplaceScopes.php
|
StubReplaceScopes.useScopePosition
|
protected function useScopePosition()
{
if (is_null($this->data['scope_position'])) {
return config('pxlcms.generator.models.scopes.position_order') === CmsModelWriter::SCOPE_METHOD;
}
return (bool) $this->data['scope_position'];
}
|
php
|
protected function useScopePosition()
{
if (is_null($this->data['scope_position'])) {
return config('pxlcms.generator.models.scopes.position_order') === CmsModelWriter::SCOPE_METHOD;
}
return (bool) $this->data['scope_position'];
}
|
[
"protected",
"function",
"useScopePosition",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"data",
"[",
"'scope_position'",
"]",
")",
")",
"{",
"return",
"config",
"(",
"'pxlcms.generator.models.scopes.position_order'",
")",
"===",
"CmsModelWriter",
"::",
"SCOPE_METHOD",
";",
"}",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"data",
"[",
"'scope_position'",
"]",
";",
"}"
] |
Returns whether we're using a global scope for position
@return bool
|
[
"Returns",
"whether",
"we",
"re",
"using",
"a",
"global",
"scope",
"for",
"position"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Writer/Model/Steps/StubReplaceScopes.php#L163-L170
|
huasituo/hstcms
|
src/Database/Migrations/2016_11_23_152536_create_common_config_table.php
|
CreateCommonConfigTable.up
|
public function up()
{
//
Schema::create('common_config', function (Blueprint $table)
{
$table->increments('id')->comment('ID');
$table->string('name', 30)->default('')->comment(hst_lang('hstcms::public.name'));
$table->string('namespace', 30)->default('')->comment(hst_lang('hstcms::public.namespace'));
$table->text('value', 255)->comment(hst_lang('hstcms::public.cvalue'));
$table->enum('vtype', ['string','array','object'])->default('string')->nullable();
$table->text('desc', 255)->comment(hst_lang('hstcms::public.desc'));
$table->tinyInteger('issystem', false)->default(0)->comment(hst_lang('hstcms::public.issystem'));
$table->unique(['name','namespace']);
});
}
|
php
|
public function up()
{
//
Schema::create('common_config', function (Blueprint $table)
{
$table->increments('id')->comment('ID');
$table->string('name', 30)->default('')->comment(hst_lang('hstcms::public.name'));
$table->string('namespace', 30)->default('')->comment(hst_lang('hstcms::public.namespace'));
$table->text('value', 255)->comment(hst_lang('hstcms::public.cvalue'));
$table->enum('vtype', ['string','array','object'])->default('string')->nullable();
$table->text('desc', 255)->comment(hst_lang('hstcms::public.desc'));
$table->tinyInteger('issystem', false)->default(0)->comment(hst_lang('hstcms::public.issystem'));
$table->unique(['name','namespace']);
});
}
|
[
"public",
"function",
"up",
"(",
")",
"{",
"//",
"Schema",
"::",
"create",
"(",
"'common_config'",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
"->",
"comment",
"(",
"'ID'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'name'",
",",
"30",
")",
"->",
"default",
"(",
"''",
")",
"->",
"comment",
"(",
"hst_lang",
"(",
"'hstcms::public.name'",
")",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'namespace'",
",",
"30",
")",
"->",
"default",
"(",
"''",
")",
"->",
"comment",
"(",
"hst_lang",
"(",
"'hstcms::public.namespace'",
")",
")",
";",
"$",
"table",
"->",
"text",
"(",
"'value'",
",",
"255",
")",
"->",
"comment",
"(",
"hst_lang",
"(",
"'hstcms::public.cvalue'",
")",
")",
";",
"$",
"table",
"->",
"enum",
"(",
"'vtype'",
",",
"[",
"'string'",
",",
"'array'",
",",
"'object'",
"]",
")",
"->",
"default",
"(",
"'string'",
")",
"->",
"nullable",
"(",
")",
";",
"$",
"table",
"->",
"text",
"(",
"'desc'",
",",
"255",
")",
"->",
"comment",
"(",
"hst_lang",
"(",
"'hstcms::public.desc'",
")",
")",
";",
"$",
"table",
"->",
"tinyInteger",
"(",
"'issystem'",
",",
"false",
")",
"->",
"default",
"(",
"0",
")",
"->",
"comment",
"(",
"hst_lang",
"(",
"'hstcms::public.issystem'",
")",
")",
";",
"$",
"table",
"->",
"unique",
"(",
"[",
"'name'",
",",
"'namespace'",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Run the migrations.
@return void
|
[
"Run",
"the",
"migrations",
"."
] |
train
|
https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Database/Migrations/2016_11_23_152536_create_common_config_table.php#L18-L32
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.getCatID
|
protected function getCatID()
{
$objBannerCatID = \Database::getInstance()->prepare("SELECT
MIN(pid) AS ID
FROM
tl_banner")
->execute();
$objBannerCatID->next();
if ($objBannerCatID->ID === null)
{
return 0;
}
else
{
return $objBannerCatID->ID;
}
}
|
php
|
protected function getCatID()
{
$objBannerCatID = \Database::getInstance()->prepare("SELECT
MIN(pid) AS ID
FROM
tl_banner")
->execute();
$objBannerCatID->next();
if ($objBannerCatID->ID === null)
{
return 0;
}
else
{
return $objBannerCatID->ID;
}
}
|
[
"protected",
"function",
"getCatID",
"(",
")",
"{",
"$",
"objBannerCatID",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n MIN(pid) AS ID \n FROM \n tl_banner\"",
")",
"->",
"execute",
"(",
")",
";",
"$",
"objBannerCatID",
"->",
"next",
"(",
")",
";",
"if",
"(",
"$",
"objBannerCatID",
"->",
"ID",
"===",
"null",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"$",
"objBannerCatID",
"->",
"ID",
";",
"}",
"}"
] |
Get min category id
@deprecated
@return number CatID 0|min(pid)
|
[
"Get",
"min",
"category",
"id"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L89-L105
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.getBannersByCatID
|
protected function getBannersByCatID($CatID = 0)
{
$arrBanners = array();
if ($CatID == -1)
{ // all Categories
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_type
, tb.banner_name
, tb.banner_url
, tb.banner_jumpTo
, tb.banner_image
, tb.banner_image_extern
, tb.banner_weighting
, tb.banner_start
, tb.banner_stop
, tb.banner_published
, tb.banner_until
, tb.banner_comment
, tb.banner_views_until
, tb.banner_clicks_until
, tbs.banner_views
, tbs.banner_clicks
FROM
tl_banner tb
, tl_banner_stat tbs
WHERE
tb.id=tbs.id
ORDER BY
tb.pid
, tb.sorting")
->execute();
}
else
{
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_type
, tb.banner_name
, tb.banner_url
, tb.banner_jumpTo
, tb.banner_image
, tb.banner_image_extern
, tb.banner_weighting
, tb.banner_start
, tb.banner_stop
, tb.banner_published
, tb.banner_until
, tb.banner_comment
, tb.banner_views_until
, tb.banner_clicks_until
, tbs.banner_views
, tbs.banner_clicks
FROM
tl_banner tb
, tl_banner_stat tbs
WHERE
tb.id=tbs.id
AND
tb.pid =?
ORDER BY
tb.sorting")
->execute($CatID);
}
$intRows = $objBanners->numRows;
if ($intRows > 0)
{
while ($objBanners->next())
{
$arrBanners[] = array('id' => $objBanners->id
, 'banner_type' => $objBanners->banner_type
, 'banner_name' => $objBanners->banner_name
, 'banner_url' => $objBanners->banner_url
, 'banner_jumpTo' => $objBanners->banner_jumpTo
, 'banner_image' => $objBanners->banner_image
, 'banner_image_extern' => $objBanners->banner_image_extern
, 'banner_weighting' => $objBanners->banner_weighting
, 'banner_start' => $objBanners->banner_start
, 'banner_stop' => $objBanners->banner_stop
, 'banner_published' => $objBanners->banner_published
, 'banner_until' => $objBanners->banner_until
, 'banner_comment' => $objBanners->banner_comment
, 'banner_views_until' => $objBanners->banner_views_until
, 'banner_clicks_until' => $objBanners->banner_clicks_until
, 'banner_views' => $objBanners->banner_views
, 'banner_clicks' => $objBanners->banner_clicks
);
} // while
}
return $arrBanners;
}
|
php
|
protected function getBannersByCatID($CatID = 0)
{
$arrBanners = array();
if ($CatID == -1)
{ // all Categories
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_type
, tb.banner_name
, tb.banner_url
, tb.banner_jumpTo
, tb.banner_image
, tb.banner_image_extern
, tb.banner_weighting
, tb.banner_start
, tb.banner_stop
, tb.banner_published
, tb.banner_until
, tb.banner_comment
, tb.banner_views_until
, tb.banner_clicks_until
, tbs.banner_views
, tbs.banner_clicks
FROM
tl_banner tb
, tl_banner_stat tbs
WHERE
tb.id=tbs.id
ORDER BY
tb.pid
, tb.sorting")
->execute();
}
else
{
$objBanners = \Database::getInstance()
->prepare("SELECT
tb.id
, tb.banner_type
, tb.banner_name
, tb.banner_url
, tb.banner_jumpTo
, tb.banner_image
, tb.banner_image_extern
, tb.banner_weighting
, tb.banner_start
, tb.banner_stop
, tb.banner_published
, tb.banner_until
, tb.banner_comment
, tb.banner_views_until
, tb.banner_clicks_until
, tbs.banner_views
, tbs.banner_clicks
FROM
tl_banner tb
, tl_banner_stat tbs
WHERE
tb.id=tbs.id
AND
tb.pid =?
ORDER BY
tb.sorting")
->execute($CatID);
}
$intRows = $objBanners->numRows;
if ($intRows > 0)
{
while ($objBanners->next())
{
$arrBanners[] = array('id' => $objBanners->id
, 'banner_type' => $objBanners->banner_type
, 'banner_name' => $objBanners->banner_name
, 'banner_url' => $objBanners->banner_url
, 'banner_jumpTo' => $objBanners->banner_jumpTo
, 'banner_image' => $objBanners->banner_image
, 'banner_image_extern' => $objBanners->banner_image_extern
, 'banner_weighting' => $objBanners->banner_weighting
, 'banner_start' => $objBanners->banner_start
, 'banner_stop' => $objBanners->banner_stop
, 'banner_published' => $objBanners->banner_published
, 'banner_until' => $objBanners->banner_until
, 'banner_comment' => $objBanners->banner_comment
, 'banner_views_until' => $objBanners->banner_views_until
, 'banner_clicks_until' => $objBanners->banner_clicks_until
, 'banner_views' => $objBanners->banner_views
, 'banner_clicks' => $objBanners->banner_clicks
);
} // while
}
return $arrBanners;
}
|
[
"protected",
"function",
"getBannersByCatID",
"(",
"$",
"CatID",
"=",
"0",
")",
"{",
"$",
"arrBanners",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"CatID",
"==",
"-",
"1",
")",
"{",
"// all Categories",
"$",
"objBanners",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n tb.id\n , tb.banner_type\n , tb.banner_name\n , tb.banner_url\n , tb.banner_jumpTo\n , tb.banner_image\n , tb.banner_image_extern\n , tb.banner_weighting\n , tb.banner_start\n , tb.banner_stop\n , tb.banner_published\n , tb.banner_until\n , tb.banner_comment\n , tb.banner_views_until\n , tb.banner_clicks_until\n , tbs.banner_views\n , tbs.banner_clicks\n FROM \n tl_banner tb\n , tl_banner_stat tbs\n WHERE \n tb.id=tbs.id\n ORDER BY \n tb.pid\n , tb.sorting\"",
")",
"->",
"execute",
"(",
")",
";",
"}",
"else",
"{",
"$",
"objBanners",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT\n tb.id\n , tb.banner_type\n , tb.banner_name\n , tb.banner_url\n , tb.banner_jumpTo\n , tb.banner_image\n , tb.banner_image_extern\n , tb.banner_weighting\n , tb.banner_start\n , tb.banner_stop\n , tb.banner_published\n , tb.banner_until\n , tb.banner_comment\n , tb.banner_views_until\n , tb.banner_clicks_until\n , tbs.banner_views\n , tbs.banner_clicks\n FROM\n tl_banner tb\n , tl_banner_stat tbs\n WHERE\n tb.id=tbs.id\n AND\n tb.pid =?\n ORDER BY\n tb.sorting\"",
")",
"->",
"execute",
"(",
"$",
"CatID",
")",
";",
"}",
"$",
"intRows",
"=",
"$",
"objBanners",
"->",
"numRows",
";",
"if",
"(",
"$",
"intRows",
">",
"0",
")",
"{",
"while",
"(",
"$",
"objBanners",
"->",
"next",
"(",
")",
")",
"{",
"$",
"arrBanners",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"objBanners",
"->",
"id",
",",
"'banner_type'",
"=>",
"$",
"objBanners",
"->",
"banner_type",
",",
"'banner_name'",
"=>",
"$",
"objBanners",
"->",
"banner_name",
",",
"'banner_url'",
"=>",
"$",
"objBanners",
"->",
"banner_url",
",",
"'banner_jumpTo'",
"=>",
"$",
"objBanners",
"->",
"banner_jumpTo",
",",
"'banner_image'",
"=>",
"$",
"objBanners",
"->",
"banner_image",
",",
"'banner_image_extern'",
"=>",
"$",
"objBanners",
"->",
"banner_image_extern",
",",
"'banner_weighting'",
"=>",
"$",
"objBanners",
"->",
"banner_weighting",
",",
"'banner_start'",
"=>",
"$",
"objBanners",
"->",
"banner_start",
",",
"'banner_stop'",
"=>",
"$",
"objBanners",
"->",
"banner_stop",
",",
"'banner_published'",
"=>",
"$",
"objBanners",
"->",
"banner_published",
",",
"'banner_until'",
"=>",
"$",
"objBanners",
"->",
"banner_until",
",",
"'banner_comment'",
"=>",
"$",
"objBanners",
"->",
"banner_comment",
",",
"'banner_views_until'",
"=>",
"$",
"objBanners",
"->",
"banner_views_until",
",",
"'banner_clicks_until'",
"=>",
"$",
"objBanners",
"->",
"banner_clicks_until",
",",
"'banner_views'",
"=>",
"$",
"objBanners",
"->",
"banner_views",
",",
"'banner_clicks'",
"=>",
"$",
"objBanners",
"->",
"banner_clicks",
")",
";",
"}",
"// while",
"}",
"return",
"$",
"arrBanners",
";",
"}"
] |
Get banners by category id
@param integer $CatID
@return array $arrBanners
|
[
"Get",
"banners",
"by",
"category",
"id"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L125-L219
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.getBannerCategories
|
protected function getBannerCategories($banner_number)
{
// Kat sammeln
$objBannerCat = \Database::getInstance()
->prepare("SELECT
id
, title
FROM
tl_banner_category
WHERE
id
IN
(SELECT
pid
FROM
tl_banner
LEFT JOIN
tl_banner_category
ON
tl_banner.pid = tl_banner_category.id
GROUP BY
tl_banner.pid
)
ORDER BY
title")
->execute();
if ($objBannerCat->numRows > 0)
{
if ($banner_number == 0)
{ // gewählte Kategorie hat keine Banner, es gibt aber weitere Kategorien
$arrBannerCats[] = array
(
'id' => '0',
'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['select']
);
$this->intCatID = 0; // template soll nichts anzeigen
}
$arrBannerCats[] = array
(
'id' => '-1',
'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['allkat']
);
while ($objBannerCat->next())
{
$arrBannerCats[] = array
(
'id' => $objBannerCat->id,
'title' => $objBannerCat->title
);
}
}
else
{ // es gibt keine Kategorie mit Banner
$arrBannerCats[] = array
(
'id' => '0',
'title' => '---------'
);
}
return $arrBannerCats;
}
|
php
|
protected function getBannerCategories($banner_number)
{
// Kat sammeln
$objBannerCat = \Database::getInstance()
->prepare("SELECT
id
, title
FROM
tl_banner_category
WHERE
id
IN
(SELECT
pid
FROM
tl_banner
LEFT JOIN
tl_banner_category
ON
tl_banner.pid = tl_banner_category.id
GROUP BY
tl_banner.pid
)
ORDER BY
title")
->execute();
if ($objBannerCat->numRows > 0)
{
if ($banner_number == 0)
{ // gewählte Kategorie hat keine Banner, es gibt aber weitere Kategorien
$arrBannerCats[] = array
(
'id' => '0',
'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['select']
);
$this->intCatID = 0; // template soll nichts anzeigen
}
$arrBannerCats[] = array
(
'id' => '-1',
'title' => $GLOBALS['TL_LANG']['tl_banner_stat']['allkat']
);
while ($objBannerCat->next())
{
$arrBannerCats[] = array
(
'id' => $objBannerCat->id,
'title' => $objBannerCat->title
);
}
}
else
{ // es gibt keine Kategorie mit Banner
$arrBannerCats[] = array
(
'id' => '0',
'title' => '---------'
);
}
return $arrBannerCats;
}
|
[
"protected",
"function",
"getBannerCategories",
"(",
"$",
"banner_number",
")",
"{",
"// Kat sammeln",
"$",
"objBannerCat",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n id \n , title \n FROM \n tl_banner_category \n WHERE \n id \n IN \n (SELECT \n pid\n FROM\n tl_banner\n LEFT JOIN\n tl_banner_category \n ON \n tl_banner.pid = tl_banner_category.id\n GROUP BY \n tl_banner.pid\n )\n ORDER BY \n title\"",
")",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"objBannerCat",
"->",
"numRows",
">",
"0",
")",
"{",
"if",
"(",
"$",
"banner_number",
"==",
"0",
")",
"{",
"// gewählte Kategorie hat keine Banner, es gibt aber weitere Kategorien",
"$",
"arrBannerCats",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"'0'",
",",
"'title'",
"=>",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'select'",
"]",
")",
";",
"$",
"this",
"->",
"intCatID",
"=",
"0",
";",
"// template soll nichts anzeigen",
"}",
"$",
"arrBannerCats",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"'-1'",
",",
"'title'",
"=>",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'allkat'",
"]",
")",
";",
"while",
"(",
"$",
"objBannerCat",
"->",
"next",
"(",
")",
")",
"{",
"$",
"arrBannerCats",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"objBannerCat",
"->",
"id",
",",
"'title'",
"=>",
"$",
"objBannerCat",
"->",
"title",
")",
";",
"}",
"}",
"else",
"{",
"// es gibt keine Kategorie mit Banner",
"$",
"arrBannerCats",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"'0'",
",",
"'title'",
"=>",
"'---------'",
")",
";",
"}",
"return",
"$",
"arrBannerCats",
";",
"}"
] |
Get banner categories
@deprecated
@param integer $banner_number
@return array $arrBannerCats
|
[
"Get",
"banner",
"categories"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L228-L290
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.getBannerCategoriesByUsergroups
|
protected function getBannerCategoriesByUsergroups()
{
$arrBannerCats = array();
$objBannerCat = \Database::getInstance()
->prepare("SELECT
`id`
, `title`
, `banner_stat_protected`
, `banner_stat_groups`
FROM
tl_banner_category
WHERE 1
ORDER BY
title
")
->execute();
while ($objBannerCat->next())
{
if ( true === $this->isUserInBannerStatGroups($objBannerCat->banner_stat_groups,
(bool) $objBannerCat->banner_stat_protected))
{
$arrBannerCats[] = array
(
'id' => $objBannerCat->id,
'title' => $objBannerCat->title
);
}
}
if (0 == count($arrBannerCats))
{
$arrBannerCats[] = array('id' => '0', 'title' => '---------');
}
return $arrBannerCats;
}
|
php
|
protected function getBannerCategoriesByUsergroups()
{
$arrBannerCats = array();
$objBannerCat = \Database::getInstance()
->prepare("SELECT
`id`
, `title`
, `banner_stat_protected`
, `banner_stat_groups`
FROM
tl_banner_category
WHERE 1
ORDER BY
title
")
->execute();
while ($objBannerCat->next())
{
if ( true === $this->isUserInBannerStatGroups($objBannerCat->banner_stat_groups,
(bool) $objBannerCat->banner_stat_protected))
{
$arrBannerCats[] = array
(
'id' => $objBannerCat->id,
'title' => $objBannerCat->title
);
}
}
if (0 == count($arrBannerCats))
{
$arrBannerCats[] = array('id' => '0', 'title' => '---------');
}
return $arrBannerCats;
}
|
[
"protected",
"function",
"getBannerCategoriesByUsergroups",
"(",
")",
"{",
"$",
"arrBannerCats",
"=",
"array",
"(",
")",
";",
"$",
"objBannerCat",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT\n `id`\n , `title`\n , `banner_stat_protected`\n , `banner_stat_groups`\n FROM\n tl_banner_category\n WHERE 1\n ORDER BY \n title\n \"",
")",
"->",
"execute",
"(",
")",
";",
"while",
"(",
"$",
"objBannerCat",
"->",
"next",
"(",
")",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"isUserInBannerStatGroups",
"(",
"$",
"objBannerCat",
"->",
"banner_stat_groups",
",",
"(",
"bool",
")",
"$",
"objBannerCat",
"->",
"banner_stat_protected",
")",
")",
"{",
"$",
"arrBannerCats",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"objBannerCat",
"->",
"id",
",",
"'title'",
"=>",
"$",
"objBannerCat",
"->",
"title",
")",
";",
"}",
"}",
"if",
"(",
"0",
"==",
"count",
"(",
"$",
"arrBannerCats",
")",
")",
"{",
"$",
"arrBannerCats",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"'0'",
",",
"'title'",
"=>",
"'---------'",
")",
";",
"}",
"return",
"$",
"arrBannerCats",
";",
"}"
] |
Get banner categories by usergroups
@param array $Usergroups
@return array
|
[
"Get",
"banner",
"categories",
"by",
"usergroups"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L298-L334
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.setBannerURL
|
protected function setBannerURL( &$Banner )
{
//Banner Ziel per Page?
if ($Banner['banner_jumpTo'] > 0)
{
//url generieren
$objBannerNextPage = \Database::getInstance()
->prepare("SELECT
id
, alias
FROM
tl_page
WHERE
id=?")
->limit(1)
->execute($Banner['banner_jumpTo']);
if ($objBannerNextPage->numRows)
{
$Banner['banner_url'] = $this->generateFrontendUrl($objBannerNextPage->fetchAssoc());
}
}
if ($Banner['banner_url'] == '')
{
$Banner['banner_url'] = $GLOBALS['TL_LANG']['tl_banner_stat']['NoURL'];
if ($Banner['banner_clicks'] == 0)
{
$Banner['banner_clicks'] = '--';
}
}
}
|
php
|
protected function setBannerURL( &$Banner )
{
//Banner Ziel per Page?
if ($Banner['banner_jumpTo'] > 0)
{
//url generieren
$objBannerNextPage = \Database::getInstance()
->prepare("SELECT
id
, alias
FROM
tl_page
WHERE
id=?")
->limit(1)
->execute($Banner['banner_jumpTo']);
if ($objBannerNextPage->numRows)
{
$Banner['banner_url'] = $this->generateFrontendUrl($objBannerNextPage->fetchAssoc());
}
}
if ($Banner['banner_url'] == '')
{
$Banner['banner_url'] = $GLOBALS['TL_LANG']['tl_banner_stat']['NoURL'];
if ($Banner['banner_clicks'] == 0)
{
$Banner['banner_clicks'] = '--';
}
}
}
|
[
"protected",
"function",
"setBannerURL",
"(",
"&",
"$",
"Banner",
")",
"{",
"//Banner Ziel per Page?",
"if",
"(",
"$",
"Banner",
"[",
"'banner_jumpTo'",
"]",
">",
"0",
")",
"{",
"//url generieren",
"$",
"objBannerNextPage",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT \n id\n , alias \n FROM \n tl_page \n WHERE \n id=?\"",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"execute",
"(",
"$",
"Banner",
"[",
"'banner_jumpTo'",
"]",
")",
";",
"if",
"(",
"$",
"objBannerNextPage",
"->",
"numRows",
")",
"{",
"$",
"Banner",
"[",
"'banner_url'",
"]",
"=",
"$",
"this",
"->",
"generateFrontendUrl",
"(",
"$",
"objBannerNextPage",
"->",
"fetchAssoc",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"Banner",
"[",
"'banner_url'",
"]",
"==",
"''",
")",
"{",
"$",
"Banner",
"[",
"'banner_url'",
"]",
"=",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'NoURL'",
"]",
";",
"if",
"(",
"$",
"Banner",
"[",
"'banner_clicks'",
"]",
"==",
"0",
")",
"{",
"$",
"Banner",
"[",
"'banner_clicks'",
"]",
"=",
"'--'",
";",
"}",
"}",
"}"
] |
Set banner_url
@param referenz $Banner
|
[
"Set",
"banner_url"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L342-L371
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.setBannerPublishedActive
|
protected function setBannerPublishedActive( &$Banner )
{
if ( ($Banner['banner_published'] == 1)
&& ($Banner['banner_start'] == '' || $Banner['banner_start'] <= time() )
&& ($Banner['banner_stop'] == '' || $Banner['banner_stop'] > time() )
)
{
$Banner['banner_active'] = '<span class="banner_stat_yes">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_yes'].'</span>';
$Banner['banner_published_class'] = 'published';
if ($Banner['banner_until'] == 1
&& $Banner['banner_views_until'] != ''
&& $Banner['banner_views'] >= $Banner['banner_views_until']
)
{
//max views erreicht
$Banner['banner_active'] = '<span class="banner_stat_no">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_no'].'</span>';
$Banner['banner_published_class'] = 'unpublished';
}
if ($Banner['banner_until'] == 1
&& $Banner['banner_clicks_until'] !=''
&& $Banner['banner_clicks'] >= $Banner['banner_clicks_until']
)
{
//max clicks erreicht
$Banner['banner_active'] = '<span class="banner_stat_no">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_no'].'</span>';
$Banner['banner_published_class'] = 'unpublished';
}
}
else
{
$Banner['banner_active'] = '<span class="banner_stat_no">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_no'].'</span>';
$Banner['banner_published_class'] = 'unpublished';
}
}
|
php
|
protected function setBannerPublishedActive( &$Banner )
{
if ( ($Banner['banner_published'] == 1)
&& ($Banner['banner_start'] == '' || $Banner['banner_start'] <= time() )
&& ($Banner['banner_stop'] == '' || $Banner['banner_stop'] > time() )
)
{
$Banner['banner_active'] = '<span class="banner_stat_yes">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_yes'].'</span>';
$Banner['banner_published_class'] = 'published';
if ($Banner['banner_until'] == 1
&& $Banner['banner_views_until'] != ''
&& $Banner['banner_views'] >= $Banner['banner_views_until']
)
{
//max views erreicht
$Banner['banner_active'] = '<span class="banner_stat_no">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_no'].'</span>';
$Banner['banner_published_class'] = 'unpublished';
}
if ($Banner['banner_until'] == 1
&& $Banner['banner_clicks_until'] !=''
&& $Banner['banner_clicks'] >= $Banner['banner_clicks_until']
)
{
//max clicks erreicht
$Banner['banner_active'] = '<span class="banner_stat_no">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_no'].'</span>';
$Banner['banner_published_class'] = 'unpublished';
}
}
else
{
$Banner['banner_active'] = '<span class="banner_stat_no">'.$GLOBALS['TL_LANG']['tl_banner_stat']['pub_no'].'</span>';
$Banner['banner_published_class'] = 'unpublished';
}
}
|
[
"protected",
"function",
"setBannerPublishedActive",
"(",
"&",
"$",
"Banner",
")",
"{",
"if",
"(",
"(",
"$",
"Banner",
"[",
"'banner_published'",
"]",
"==",
"1",
")",
"&&",
"(",
"$",
"Banner",
"[",
"'banner_start'",
"]",
"==",
"''",
"||",
"$",
"Banner",
"[",
"'banner_start'",
"]",
"<=",
"time",
"(",
")",
")",
"&&",
"(",
"$",
"Banner",
"[",
"'banner_stop'",
"]",
"==",
"''",
"||",
"$",
"Banner",
"[",
"'banner_stop'",
"]",
">",
"time",
"(",
")",
")",
")",
"{",
"$",
"Banner",
"[",
"'banner_active'",
"]",
"=",
"'<span class=\"banner_stat_yes\">'",
".",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'pub_yes'",
"]",
".",
"'</span>'",
";",
"$",
"Banner",
"[",
"'banner_published_class'",
"]",
"=",
"'published'",
";",
"if",
"(",
"$",
"Banner",
"[",
"'banner_until'",
"]",
"==",
"1",
"&&",
"$",
"Banner",
"[",
"'banner_views_until'",
"]",
"!=",
"''",
"&&",
"$",
"Banner",
"[",
"'banner_views'",
"]",
">=",
"$",
"Banner",
"[",
"'banner_views_until'",
"]",
")",
"{",
"//max views erreicht",
"$",
"Banner",
"[",
"'banner_active'",
"]",
"=",
"'<span class=\"banner_stat_no\">'",
".",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'pub_no'",
"]",
".",
"'</span>'",
";",
"$",
"Banner",
"[",
"'banner_published_class'",
"]",
"=",
"'unpublished'",
";",
"}",
"if",
"(",
"$",
"Banner",
"[",
"'banner_until'",
"]",
"==",
"1",
"&&",
"$",
"Banner",
"[",
"'banner_clicks_until'",
"]",
"!=",
"''",
"&&",
"$",
"Banner",
"[",
"'banner_clicks'",
"]",
">=",
"$",
"Banner",
"[",
"'banner_clicks_until'",
"]",
")",
"{",
"//max clicks erreicht",
"$",
"Banner",
"[",
"'banner_active'",
"]",
"=",
"'<span class=\"banner_stat_no\">'",
".",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'pub_no'",
"]",
".",
"'</span>'",
";",
"$",
"Banner",
"[",
"'banner_published_class'",
"]",
"=",
"'unpublished'",
";",
"}",
"}",
"else",
"{",
"$",
"Banner",
"[",
"'banner_active'",
"]",
"=",
"'<span class=\"banner_stat_no\">'",
".",
"$",
"GLOBALS",
"[",
"'TL_LANG'",
"]",
"[",
"'tl_banner_stat'",
"]",
"[",
"'pub_no'",
"]",
".",
"'</span>'",
";",
"$",
"Banner",
"[",
"'banner_published_class'",
"]",
"=",
"'unpublished'",
";",
"}",
"}"
] |
Set banner_published
@param referenz $Banner
|
[
"Set",
"banner_published"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L378-L413
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.getMaxViewsClicksStatus
|
protected function getMaxViewsClicksStatus( &$Banner )
{
$intMaxViews = false;
$intMaxClicks= false;
if ($Banner['banner_until'] == 1
&& $Banner['banner_views_until'] != ''
&& $Banner['banner_views'] >= $Banner['banner_views_until']
)
{
//max views erreicht
$intMaxViews = true;
}
if ($Banner['banner_until'] == 1
&& $Banner['banner_clicks_until'] !=''
&& $Banner['banner_clicks'] >= $Banner['banner_clicks_until']
)
{
//max clicks erreicht
$intMaxClicks = true;
}
return array($intMaxViews,$intMaxClicks);
}
|
php
|
protected function getMaxViewsClicksStatus( &$Banner )
{
$intMaxViews = false;
$intMaxClicks= false;
if ($Banner['banner_until'] == 1
&& $Banner['banner_views_until'] != ''
&& $Banner['banner_views'] >= $Banner['banner_views_until']
)
{
//max views erreicht
$intMaxViews = true;
}
if ($Banner['banner_until'] == 1
&& $Banner['banner_clicks_until'] !=''
&& $Banner['banner_clicks'] >= $Banner['banner_clicks_until']
)
{
//max clicks erreicht
$intMaxClicks = true;
}
return array($intMaxViews,$intMaxClicks);
}
|
[
"protected",
"function",
"getMaxViewsClicksStatus",
"(",
"&",
"$",
"Banner",
")",
"{",
"$",
"intMaxViews",
"=",
"false",
";",
"$",
"intMaxClicks",
"=",
"false",
";",
"if",
"(",
"$",
"Banner",
"[",
"'banner_until'",
"]",
"==",
"1",
"&&",
"$",
"Banner",
"[",
"'banner_views_until'",
"]",
"!=",
"''",
"&&",
"$",
"Banner",
"[",
"'banner_views'",
"]",
">=",
"$",
"Banner",
"[",
"'banner_views_until'",
"]",
")",
"{",
"//max views erreicht",
"$",
"intMaxViews",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"Banner",
"[",
"'banner_until'",
"]",
"==",
"1",
"&&",
"$",
"Banner",
"[",
"'banner_clicks_until'",
"]",
"!=",
"''",
"&&",
"$",
"Banner",
"[",
"'banner_clicks'",
"]",
">=",
"$",
"Banner",
"[",
"'banner_clicks_until'",
"]",
")",
"{",
"//max clicks erreicht",
"$",
"intMaxClicks",
"=",
"true",
";",
"}",
"return",
"array",
"(",
"$",
"intMaxViews",
",",
"$",
"intMaxClicks",
")",
";",
"}"
] |
Get status of maxviews and maxclicks
@param array $Banner
@return array array(bool $intMaxViews, bool $intMaxClicks)
|
[
"Get",
"status",
"of",
"maxviews",
"and",
"maxclicks"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L421-L445
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.setZero
|
protected function setZero()
{
//Banner
$intBID = (int)\Input::post('zid',true) ;
if ($intBID>0)
{
\Database::getInstance()->prepare("UPDATE
tl_banner_stat
SET
tstamp=?
, banner_views=0
, banner_clicks=0
WHERE
id=?")
->execute( time() , $intBID );
return ;
}
//Category
$intCatBID = (int)\Input::post('catzid',true) ;
if ($intCatBID>0)
{
\Database::getInstance()->prepare("UPDATE
tl_banner_stat
INNER JOIN
tl_banner
USING ( id )
SET
tl_banner_stat.tstamp=?
, banner_views=0
, banner_clicks=0
WHERE
pid=?")
->execute( time() , $intCatBID );
}
return ;
}
|
php
|
protected function setZero()
{
//Banner
$intBID = (int)\Input::post('zid',true) ;
if ($intBID>0)
{
\Database::getInstance()->prepare("UPDATE
tl_banner_stat
SET
tstamp=?
, banner_views=0
, banner_clicks=0
WHERE
id=?")
->execute( time() , $intBID );
return ;
}
//Category
$intCatBID = (int)\Input::post('catzid',true) ;
if ($intCatBID>0)
{
\Database::getInstance()->prepare("UPDATE
tl_banner_stat
INNER JOIN
tl_banner
USING ( id )
SET
tl_banner_stat.tstamp=?
, banner_views=0
, banner_clicks=0
WHERE
pid=?")
->execute( time() , $intCatBID );
}
return ;
}
|
[
"protected",
"function",
"setZero",
"(",
")",
"{",
"//Banner",
"$",
"intBID",
"=",
"(",
"int",
")",
"\\",
"Input",
"::",
"post",
"(",
"'zid'",
",",
"true",
")",
";",
"if",
"(",
"$",
"intBID",
">",
"0",
")",
"{",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"UPDATE\n tl_banner_stat\n SET\n tstamp=?\n , banner_views=0\n , banner_clicks=0\n WHERE\n id=?\"",
")",
"->",
"execute",
"(",
"time",
"(",
")",
",",
"$",
"intBID",
")",
";",
"return",
";",
"}",
"//Category",
"$",
"intCatBID",
"=",
"(",
"int",
")",
"\\",
"Input",
"::",
"post",
"(",
"'catzid'",
",",
"true",
")",
";",
"if",
"(",
"$",
"intCatBID",
">",
"0",
")",
"{",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"UPDATE\n tl_banner_stat\n INNER JOIN\n tl_banner\n USING ( id )\n SET\n tl_banner_stat.tstamp=?\n , banner_views=0\n , banner_clicks=0\n WHERE\n pid=?\"",
")",
"->",
"execute",
"(",
"time",
"(",
")",
",",
"$",
"intCatBID",
")",
";",
"}",
"return",
";",
"}"
] |
Statistic, set on zero
|
[
"Statistic",
"set",
"on",
"zero"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L450-L485
|
BugBuster1701/banner
|
classes/BannerStatisticsHelper.php
|
BannerStatisticsHelper.isUserInBannerStatGroups
|
protected function isUserInBannerStatGroups($banner_stat_groups, $banner_stat_protected)
{
if ( true === $this->User->isAdmin )
{
//DEBUG log_message('Ich bin Admin', 'banner.log');
return true; // Admin darf immer
}
//wenn Schutz nicht aktiviert ist, darf jeder
if (false === $banner_stat_protected)
{
//Debug log_message('Schutz nicht aktiviert', 'banner.log');
return true;
}
//Schutz aktiviert, Einschränkungen vorhanden?
if (0 == strlen($banner_stat_groups))
{
//DEBUG log_message('banner_stat_groups ist leer', 'banner.log');
return false; //nicht gefiltert, also darf keiner außer Admin
}
//mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist
foreach (deserialize($banner_stat_groups) as $id => $groupid)
{
if ( true === $this->User->isMemberOf($groupid) )
{
//DEBUG log_message('Ich bin in der richtigen Gruppe '.$groupid, 'banner.log');
return true; // User is Member of banner_stat_group
}
}
//Debug log_message('Ich bin in der falschen Gruppe', 'banner.log');
return false;
}
|
php
|
protected function isUserInBannerStatGroups($banner_stat_groups, $banner_stat_protected)
{
if ( true === $this->User->isAdmin )
{
//DEBUG log_message('Ich bin Admin', 'banner.log');
return true; // Admin darf immer
}
//wenn Schutz nicht aktiviert ist, darf jeder
if (false === $banner_stat_protected)
{
//Debug log_message('Schutz nicht aktiviert', 'banner.log');
return true;
}
//Schutz aktiviert, Einschränkungen vorhanden?
if (0 == strlen($banner_stat_groups))
{
//DEBUG log_message('banner_stat_groups ist leer', 'banner.log');
return false; //nicht gefiltert, also darf keiner außer Admin
}
//mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist
foreach (deserialize($banner_stat_groups) as $id => $groupid)
{
if ( true === $this->User->isMemberOf($groupid) )
{
//DEBUG log_message('Ich bin in der richtigen Gruppe '.$groupid, 'banner.log');
return true; // User is Member of banner_stat_group
}
}
//Debug log_message('Ich bin in der falschen Gruppe', 'banner.log');
return false;
}
|
[
"protected",
"function",
"isUserInBannerStatGroups",
"(",
"$",
"banner_stat_groups",
",",
"$",
"banner_stat_protected",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"User",
"->",
"isAdmin",
")",
"{",
"//DEBUG log_message('Ich bin Admin', 'banner.log');",
"return",
"true",
";",
"// Admin darf immer",
"}",
"//wenn Schutz nicht aktiviert ist, darf jeder",
"if",
"(",
"false",
"===",
"$",
"banner_stat_protected",
")",
"{",
"//Debug log_message('Schutz nicht aktiviert', 'banner.log');",
"return",
"true",
";",
"}",
"//Schutz aktiviert, Einschränkungen vorhanden?",
"if",
"(",
"0",
"==",
"strlen",
"(",
"$",
"banner_stat_groups",
")",
")",
"{",
"//DEBUG log_message('banner_stat_groups ist leer', 'banner.log');",
"return",
"false",
";",
"//nicht gefiltert, also darf keiner außer Admin",
"}",
"//mit isMemberOf ermitteln, ob user Member einer der Cat Groups ist",
"foreach",
"(",
"deserialize",
"(",
"$",
"banner_stat_groups",
")",
"as",
"$",
"id",
"=>",
"$",
"groupid",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"User",
"->",
"isMemberOf",
"(",
"$",
"groupid",
")",
")",
"{",
"//DEBUG log_message('Ich bin in der richtigen Gruppe '.$groupid, 'banner.log');",
"return",
"true",
";",
"// User is Member of banner_stat_group ",
"}",
"}",
"//Debug log_message('Ich bin in der falschen Gruppe', 'banner.log');",
"return",
"false",
";",
"}"
] |
Check if User member of group in banner statistik groups
@param string DB Field "banner_stat_groups", serialized array
@return bool true / false
|
[
"Check",
"if",
"User",
"member",
"of",
"group",
"in",
"banner",
"statistik",
"groups"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerStatisticsHelper.php#L493-L524
|
BugBuster1701/banner
|
classes/BannerReferrer.php
|
BannerReferrer.reset
|
protected function reset()
{
//NEVER TRUST USER INPUT
if (function_exists('filter_var')) // Adjustment for hoster without the filter extension
{
$this->_http_referrer = isset($_SERVER['HTTP_REFERER']) ? filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL) : self::REFERRER_UNKNOWN ;
}
else
{
$this->_http_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : self::REFERRER_UNKNOWN ;
}
$this->_referrer_DNS = self::REFERRER_UNKNOWN;
if ($this->_http_referrer == '' ||
$this->_http_referrer == '-')
{
//ungueltiger Referrer
$this->_referrer_DNS = self::REFERRER_WRONG;
}
}
|
php
|
protected function reset()
{
//NEVER TRUST USER INPUT
if (function_exists('filter_var')) // Adjustment for hoster without the filter extension
{
$this->_http_referrer = isset($_SERVER['HTTP_REFERER']) ? filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL) : self::REFERRER_UNKNOWN ;
}
else
{
$this->_http_referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : self::REFERRER_UNKNOWN ;
}
$this->_referrer_DNS = self::REFERRER_UNKNOWN;
if ($this->_http_referrer == '' ||
$this->_http_referrer == '-')
{
//ungueltiger Referrer
$this->_referrer_DNS = self::REFERRER_WRONG;
}
}
|
[
"protected",
"function",
"reset",
"(",
")",
"{",
"//NEVER TRUST USER INPUT",
"if",
"(",
"function_exists",
"(",
"'filter_var'",
")",
")",
"// Adjustment for hoster without the filter extension",
"{",
"$",
"this",
"->",
"_http_referrer",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_REFERER'",
"]",
")",
"?",
"filter_var",
"(",
"$",
"_SERVER",
"[",
"'HTTP_REFERER'",
"]",
",",
"FILTER_SANITIZE_URL",
")",
":",
"self",
"::",
"REFERRER_UNKNOWN",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_http_referrer",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_REFERER'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_REFERER'",
"]",
":",
"self",
"::",
"REFERRER_UNKNOWN",
";",
"}",
"$",
"this",
"->",
"_referrer_DNS",
"=",
"self",
"::",
"REFERRER_UNKNOWN",
";",
"if",
"(",
"$",
"this",
"->",
"_http_referrer",
"==",
"''",
"||",
"$",
"this",
"->",
"_http_referrer",
"==",
"'-'",
")",
"{",
"//ungueltiger Referrer",
"$",
"this",
"->",
"_referrer_DNS",
"=",
"self",
"::",
"REFERRER_WRONG",
";",
"}",
"}"
] |
Reset all properties
|
[
"Reset",
"all",
"properties"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerReferrer.php#L72-L90
|
BugBuster1701/banner
|
classes/BannerReferrer.php
|
BannerReferrer.vhost
|
protected function vhost()
{
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
{
return preg_replace('/[^A-Za-z0-9\[\]\.:-]/', '', rtrim($_SERVER['HTTP_X_FORWARDED_HOST'],'/'));
}
$host = rtrim($_SERVER['HTTP_HOST']);
if ($host == '')
{
$host = rtrim($_SERVER['SERVER_NAME']);
}
$host = preg_replace('/[^A-Za-z0-9\[\]\.:-]/', '', $host);
return $host;
}
|
php
|
protected function vhost()
{
if (isset($_SERVER['HTTP_X_FORWARDED_HOST']))
{
return preg_replace('/[^A-Za-z0-9\[\]\.:-]/', '', rtrim($_SERVER['HTTP_X_FORWARDED_HOST'],'/'));
}
$host = rtrim($_SERVER['HTTP_HOST']);
if ($host == '')
{
$host = rtrim($_SERVER['SERVER_NAME']);
}
$host = preg_replace('/[^A-Za-z0-9\[\]\.:-]/', '', $host);
return $host;
}
|
[
"protected",
"function",
"vhost",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_HOST'",
"]",
")",
")",
"{",
"return",
"preg_replace",
"(",
"'/[^A-Za-z0-9\\[\\]\\.:-]/'",
",",
"''",
",",
"rtrim",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_HOST'",
"]",
",",
"'/'",
")",
")",
";",
"}",
"$",
"host",
"=",
"rtrim",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
";",
"if",
"(",
"$",
"host",
"==",
"''",
")",
"{",
"$",
"host",
"=",
"rtrim",
"(",
"$",
"_SERVER",
"[",
"'SERVER_NAME'",
"]",
")",
";",
"}",
"$",
"host",
"=",
"preg_replace",
"(",
"'/[^A-Za-z0-9\\[\\]\\.:-]/'",
",",
"''",
",",
"$",
"host",
")",
";",
"return",
"$",
"host",
";",
"}"
] |
Return the current URL without path or query string or protocol
@return string
|
[
"Return",
"the",
"current",
"URL",
"without",
"path",
"or",
"query",
"string",
"or",
"protocol"
] |
train
|
https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerReferrer.php#L132-L146
|
tequila/mongodb-php-lib
|
src/OptionsResolver/Command/CreateCollectionResolver.php
|
CreateCollectionResolver.resolve
|
public function resolve(array $options = [])
{
$options = parent::resolve($options);
if (!isset($options['size']) && isset($options['capped']) && true === $options['capped']) {
throw new InvalidArgumentException(
'The option "size" is required for capped collections.'
);
}
foreach (['max', 'size'] as $optionName) {
if (isset($options[$optionName]) && (!isset($options['capped']) || false === $options['capped'])) {
throw new InvalidArgumentException(
sprintf(
'The "%s" option is meaningless until "capped" option has been set to true.',
$optionName
)
);
}
}
return $options;
}
|
php
|
public function resolve(array $options = [])
{
$options = parent::resolve($options);
if (!isset($options['size']) && isset($options['capped']) && true === $options['capped']) {
throw new InvalidArgumentException(
'The option "size" is required for capped collections.'
);
}
foreach (['max', 'size'] as $optionName) {
if (isset($options[$optionName]) && (!isset($options['capped']) || false === $options['capped'])) {
throw new InvalidArgumentException(
sprintf(
'The "%s" option is meaningless until "capped" option has been set to true.',
$optionName
)
);
}
}
return $options;
}
|
[
"public",
"function",
"resolve",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"parent",
"::",
"resolve",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'size'",
"]",
")",
"&&",
"isset",
"(",
"$",
"options",
"[",
"'capped'",
"]",
")",
"&&",
"true",
"===",
"$",
"options",
"[",
"'capped'",
"]",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The option \"size\" is required for capped collections.'",
")",
";",
"}",
"foreach",
"(",
"[",
"'max'",
",",
"'size'",
"]",
"as",
"$",
"optionName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"optionName",
"]",
")",
"&&",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'capped'",
"]",
")",
"||",
"false",
"===",
"$",
"options",
"[",
"'capped'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" option is meaningless until \"capped\" option has been set to true.'",
",",
"$",
"optionName",
")",
")",
";",
"}",
"}",
"return",
"$",
"options",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/tequila/mongodb-php-lib/blob/49a25f45268df358f5ceb40a655d9a7ddc6db4f7/src/OptionsResolver/Command/CreateCollectionResolver.php#L15-L37
|
tequila/mongodb-php-lib
|
src/OptionsResolver/Command/CreateCollectionResolver.php
|
CreateCollectionResolver.configureOptions
|
protected function configureOptions()
{
CollationConfigurator::configure($this);
WriteConcernConfigurator::configure($this);
$this->setDefined([
'capped',
'size',
'max',
'flags',
'storageEngine',
'validator',
'validationLevel',
'validationAction',
'indexOptionDefaults',
]);
$this
->setAllowedTypes('capped', 'bool')
->setAllowedTypes('size', 'integer')
->setAllowedTypes('max', 'integer')
->setAllowedTypes('flags', 'integer')
->setAllowedTypes('storageEngine', ['array', 'object'])
->setAllowedTypes('validator', ['array', 'object'])
->setAllowedValues('validationLevel', [
'off',
'strict',
'moderate',
])
->setAllowedValues('validationAction', [
'error',
'warn',
])
->setAllowedTypes('indexOptionDefaults', ['array', 'object']);
}
|
php
|
protected function configureOptions()
{
CollationConfigurator::configure($this);
WriteConcernConfigurator::configure($this);
$this->setDefined([
'capped',
'size',
'max',
'flags',
'storageEngine',
'validator',
'validationLevel',
'validationAction',
'indexOptionDefaults',
]);
$this
->setAllowedTypes('capped', 'bool')
->setAllowedTypes('size', 'integer')
->setAllowedTypes('max', 'integer')
->setAllowedTypes('flags', 'integer')
->setAllowedTypes('storageEngine', ['array', 'object'])
->setAllowedTypes('validator', ['array', 'object'])
->setAllowedValues('validationLevel', [
'off',
'strict',
'moderate',
])
->setAllowedValues('validationAction', [
'error',
'warn',
])
->setAllowedTypes('indexOptionDefaults', ['array', 'object']);
}
|
[
"protected",
"function",
"configureOptions",
"(",
")",
"{",
"CollationConfigurator",
"::",
"configure",
"(",
"$",
"this",
")",
";",
"WriteConcernConfigurator",
"::",
"configure",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"setDefined",
"(",
"[",
"'capped'",
",",
"'size'",
",",
"'max'",
",",
"'flags'",
",",
"'storageEngine'",
",",
"'validator'",
",",
"'validationLevel'",
",",
"'validationAction'",
",",
"'indexOptionDefaults'",
",",
"]",
")",
";",
"$",
"this",
"->",
"setAllowedTypes",
"(",
"'capped'",
",",
"'bool'",
")",
"->",
"setAllowedTypes",
"(",
"'size'",
",",
"'integer'",
")",
"->",
"setAllowedTypes",
"(",
"'max'",
",",
"'integer'",
")",
"->",
"setAllowedTypes",
"(",
"'flags'",
",",
"'integer'",
")",
"->",
"setAllowedTypes",
"(",
"'storageEngine'",
",",
"[",
"'array'",
",",
"'object'",
"]",
")",
"->",
"setAllowedTypes",
"(",
"'validator'",
",",
"[",
"'array'",
",",
"'object'",
"]",
")",
"->",
"setAllowedValues",
"(",
"'validationLevel'",
",",
"[",
"'off'",
",",
"'strict'",
",",
"'moderate'",
",",
"]",
")",
"->",
"setAllowedValues",
"(",
"'validationAction'",
",",
"[",
"'error'",
",",
"'warn'",
",",
"]",
")",
"->",
"setAllowedTypes",
"(",
"'indexOptionDefaults'",
",",
"[",
"'array'",
",",
"'object'",
"]",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/tequila/mongodb-php-lib/blob/49a25f45268df358f5ceb40a655d9a7ddc6db4f7/src/OptionsResolver/Command/CreateCollectionResolver.php#L42-L76
|
gintonicweb/GintonicCMS
|
src/Controller/Component/SetupComponent.php
|
SetupComponent.runMigration
|
public function runMigration($plugin)
{
$command = new Migrate();
$output = new NullOutput();
$input = new ArrayInput(['--plugin' => $plugin]);
$resultCode = $command->run($input, $output);
}
|
php
|
public function runMigration($plugin)
{
$command = new Migrate();
$output = new NullOutput();
$input = new ArrayInput(['--plugin' => $plugin]);
$resultCode = $command->run($input, $output);
}
|
[
"public",
"function",
"runMigration",
"(",
"$",
"plugin",
")",
"{",
"$",
"command",
"=",
"new",
"Migrate",
"(",
")",
";",
"$",
"output",
"=",
"new",
"NullOutput",
"(",
")",
";",
"$",
"input",
"=",
"new",
"ArrayInput",
"(",
"[",
"'--plugin'",
"=>",
"$",
"plugin",
"]",
")",
";",
"$",
"resultCode",
"=",
"$",
"command",
"->",
"run",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"}"
] |
Runs the migrations for a given plugin
@param string $plugin Name of the plugin
@return void
|
[
"Runs",
"the",
"migrations",
"for",
"a",
"given",
"plugin"
] |
train
|
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Component/SetupComponent.php#L19-L25
|
gintonicweb/GintonicCMS
|
src/Controller/Component/SetupComponent.php
|
SetupComponent.tableExists
|
public function tableExists($tableName, $connectionName = 'default')
{
try {
$db = ConnectionManager::get($connectionName);
$collection = $db->schemaCollection();
$tables = $collection->listTables();
if (in_array($tableName, $tables)) {
return true;
}
} catch (PDOException $connectionError) {
return false;
}
return false;
}
|
php
|
public function tableExists($tableName, $connectionName = 'default')
{
try {
$db = ConnectionManager::get($connectionName);
$collection = $db->schemaCollection();
$tables = $collection->listTables();
if (in_array($tableName, $tables)) {
return true;
}
} catch (PDOException $connectionError) {
return false;
}
return false;
}
|
[
"public",
"function",
"tableExists",
"(",
"$",
"tableName",
",",
"$",
"connectionName",
"=",
"'default'",
")",
"{",
"try",
"{",
"$",
"db",
"=",
"ConnectionManager",
"::",
"get",
"(",
"$",
"connectionName",
")",
";",
"$",
"collection",
"=",
"$",
"db",
"->",
"schemaCollection",
"(",
")",
";",
"$",
"tables",
"=",
"$",
"collection",
"->",
"listTables",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"tableName",
",",
"$",
"tables",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"PDOException",
"$",
"connectionError",
")",
"{",
"return",
"false",
";",
"}",
"return",
"false",
";",
"}"
] |
Check whether table is exists in database or not.
@param string $tableName Name of the table to check.
@param string $connectionName Connection to use
@return bool True if table exists, False else.
|
[
"Check",
"whether",
"table",
"is",
"exists",
"in",
"database",
"or",
"not",
"."
] |
train
|
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Component/SetupComponent.php#L34-L47
|
gintonicweb/GintonicCMS
|
src/Controller/Component/SetupComponent.php
|
SetupComponent.databaseConnection
|
public function databaseConnection($dataSource = 'default')
{
try {
$connection = ConnectionManager::get($dataSource);
$connected = $connection->connect();
} catch (MissingConnectionException $connectionError) {
$connected = false;
}
return $connected;
}
|
php
|
public function databaseConnection($dataSource = 'default')
{
try {
$connection = ConnectionManager::get($dataSource);
$connected = $connection->connect();
} catch (MissingConnectionException $connectionError) {
$connected = false;
}
return $connected;
}
|
[
"public",
"function",
"databaseConnection",
"(",
"$",
"dataSource",
"=",
"'default'",
")",
"{",
"try",
"{",
"$",
"connection",
"=",
"ConnectionManager",
"::",
"get",
"(",
"$",
"dataSource",
")",
";",
"$",
"connected",
"=",
"$",
"connection",
"->",
"connect",
"(",
")",
";",
"}",
"catch",
"(",
"MissingConnectionException",
"$",
"connectionError",
")",
"{",
"$",
"connected",
"=",
"false",
";",
"}",
"return",
"$",
"connected",
";",
"}"
] |
Test database connection.
@param type $dataSource name of data source.
@return bool True if we're able to connect to the database
|
[
"Test",
"database",
"connection",
"."
] |
train
|
https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Controller/Component/SetupComponent.php#L55-L64
|
Atlantic18/CoralCoreBundle
|
Service/Connector/CoralConnector.php
|
CoralConnector.doRequest
|
public function doRequest($method, $uri, $data = null)
{
$method = strtoupper($method);
if(
$method != Request::GET &&
$method != Request::POST &&
$method != Request::DELETE
)
{
throw new ConnectorException("Invalid method [$method] for connector.");
}
$dtime = time();
$handle = $this->request->createHandle($method, $this->host . $uri);
if(null === $data)
{
$signatureSource = $this->key . '|' . $dtime . '|' . $this->host . $uri;
}
else
{
$payload = json_encode($data);
$signatureSource = $this->key . '|' . $dtime . '|' . $this->host . $uri . '|' . $payload;
$handle->setPayload($payload);
}
$handle->setHeader('X-CORAL-SIGN', hash('sha256', $signatureSource));
$handle->setHeader('X-CORAL-ACCOUNT', $this->account);
$handle->setHeader('X-CORAL-DTIME', $dtime);
return $this->request->doRequestAndParse($handle);
}
|
php
|
public function doRequest($method, $uri, $data = null)
{
$method = strtoupper($method);
if(
$method != Request::GET &&
$method != Request::POST &&
$method != Request::DELETE
)
{
throw new ConnectorException("Invalid method [$method] for connector.");
}
$dtime = time();
$handle = $this->request->createHandle($method, $this->host . $uri);
if(null === $data)
{
$signatureSource = $this->key . '|' . $dtime . '|' . $this->host . $uri;
}
else
{
$payload = json_encode($data);
$signatureSource = $this->key . '|' . $dtime . '|' . $this->host . $uri . '|' . $payload;
$handle->setPayload($payload);
}
$handle->setHeader('X-CORAL-SIGN', hash('sha256', $signatureSource));
$handle->setHeader('X-CORAL-ACCOUNT', $this->account);
$handle->setHeader('X-CORAL-DTIME', $dtime);
return $this->request->doRequestAndParse($handle);
}
|
[
"public",
"function",
"doRequest",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"strtoupper",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"method",
"!=",
"Request",
"::",
"GET",
"&&",
"$",
"method",
"!=",
"Request",
"::",
"POST",
"&&",
"$",
"method",
"!=",
"Request",
"::",
"DELETE",
")",
"{",
"throw",
"new",
"ConnectorException",
"(",
"\"Invalid method [$method] for connector.\"",
")",
";",
"}",
"$",
"dtime",
"=",
"time",
"(",
")",
";",
"$",
"handle",
"=",
"$",
"this",
"->",
"request",
"->",
"createHandle",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"host",
".",
"$",
"uri",
")",
";",
"if",
"(",
"null",
"===",
"$",
"data",
")",
"{",
"$",
"signatureSource",
"=",
"$",
"this",
"->",
"key",
".",
"'|'",
".",
"$",
"dtime",
".",
"'|'",
".",
"$",
"this",
"->",
"host",
".",
"$",
"uri",
";",
"}",
"else",
"{",
"$",
"payload",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"signatureSource",
"=",
"$",
"this",
"->",
"key",
".",
"'|'",
".",
"$",
"dtime",
".",
"'|'",
".",
"$",
"this",
"->",
"host",
".",
"$",
"uri",
".",
"'|'",
".",
"$",
"payload",
";",
"$",
"handle",
"->",
"setPayload",
"(",
"$",
"payload",
")",
";",
"}",
"$",
"handle",
"->",
"setHeader",
"(",
"'X-CORAL-SIGN'",
",",
"hash",
"(",
"'sha256'",
",",
"$",
"signatureSource",
")",
")",
";",
"$",
"handle",
"->",
"setHeader",
"(",
"'X-CORAL-ACCOUNT'",
",",
"$",
"this",
"->",
"account",
")",
";",
"$",
"handle",
"->",
"setHeader",
"(",
"'X-CORAL-DTIME'",
",",
"$",
"dtime",
")",
";",
"return",
"$",
"this",
"->",
"request",
"->",
"doRequestAndParse",
"(",
"$",
"handle",
")",
";",
"}"
] |
Create request to CORAL backend
@param string $method Method name
@param string $uri Service URI
@param array $payload Data to be sent
@return JsonParser Response
|
[
"Create",
"request",
"to",
"CORAL",
"backend"
] |
train
|
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Connector/CoralConnector.php#L51-L83
|
movoin/one-swoole
|
src/Routing/Provider.php
|
Provider.register
|
public function register()
{
$this->bind('router', function ($server) {
$router = new Router;
$docs = $server->get('annotation');
foreach ($docs as $class => $doc) {
$router->addRoute($doc['methods'], $doc['route'], $class);
}
unset($docs);
return $router;
});
}
|
php
|
public function register()
{
$this->bind('router', function ($server) {
$router = new Router;
$docs = $server->get('annotation');
foreach ($docs as $class => $doc) {
$router->addRoute($doc['methods'], $doc['route'], $class);
}
unset($docs);
return $router;
});
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"bind",
"(",
"'router'",
",",
"function",
"(",
"$",
"server",
")",
"{",
"$",
"router",
"=",
"new",
"Router",
";",
"$",
"docs",
"=",
"$",
"server",
"->",
"get",
"(",
"'annotation'",
")",
";",
"foreach",
"(",
"$",
"docs",
"as",
"$",
"class",
"=>",
"$",
"doc",
")",
"{",
"$",
"router",
"->",
"addRoute",
"(",
"$",
"doc",
"[",
"'methods'",
"]",
",",
"$",
"doc",
"[",
"'route'",
"]",
",",
"$",
"class",
")",
";",
"}",
"unset",
"(",
"$",
"docs",
")",
";",
"return",
"$",
"router",
";",
"}",
")",
";",
"}"
] |
注册服务
|
[
"注册服务"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Routing/Provider.php#L22-L36
|
stubbles/stubbles-webapp-core
|
src/main/php/auth/session/CachingAuthorizationProvider.php
|
CachingAuthorizationProvider.roles
|
public function roles(User $user)
{
if ($this->session->hasValue(Roles::SESSION_KEY)) {
return $this->session->value(Roles::SESSION_KEY);
}
$roles = $this->authorizationProvider->roles($user);
$this->session->putValue(Roles::SESSION_KEY, $roles);
return $roles;
}
|
php
|
public function roles(User $user)
{
if ($this->session->hasValue(Roles::SESSION_KEY)) {
return $this->session->value(Roles::SESSION_KEY);
}
$roles = $this->authorizationProvider->roles($user);
$this->session->putValue(Roles::SESSION_KEY, $roles);
return $roles;
}
|
[
"public",
"function",
"roles",
"(",
"User",
"$",
"user",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"session",
"->",
"hasValue",
"(",
"Roles",
"::",
"SESSION_KEY",
")",
")",
"{",
"return",
"$",
"this",
"->",
"session",
"->",
"value",
"(",
"Roles",
"::",
"SESSION_KEY",
")",
";",
"}",
"$",
"roles",
"=",
"$",
"this",
"->",
"authorizationProvider",
"->",
"roles",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"session",
"->",
"putValue",
"(",
"Roles",
"::",
"SESSION_KEY",
",",
"$",
"roles",
")",
";",
"return",
"$",
"roles",
";",
"}"
] |
returns the roles available for this request and user
@param \stubbles\webapp\auth\User $user
@return \stubbles\webapp\auth\Roles|null
|
[
"returns",
"the",
"roles",
"available",
"for",
"this",
"request",
"and",
"user"
] |
train
|
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/auth/session/CachingAuthorizationProvider.php#L55-L64
|
comelyio/comely
|
src/Comely/IO/Translator/Translator.php
|
Translator.translate
|
public function translate(string $key, ?string $lang = null): ?string
{
try {
// Validate key
$key = strtolower($key);
if (!preg_match('/^[a-z0-9\.\-\_]+$/', $key)) {
throw new TranslatorException('Invalid translation key');
}
// Get current language
$language = $this->_language($lang);
$translation = $language->get($key);
if ($translation) { // Translation found
return $translation;
}
// Fallback
try {
$fallback = $this->_fallback();
} catch (LanguageException $e) {
throw new LanguageException('[Fallback] ' . $e->getMessage());
}
if ($fallback && $fallback->name() !== $language->name()) {
$translation = $fallback->get($key);
if ($translation) {
return $translation;
}
}
} catch (TranslatorException $e) {
trigger_error(sprintf('Translation error [%s]: %s', $key, $e->getMessage()), E_USER_WARNING);
}
return null;
}
|
php
|
public function translate(string $key, ?string $lang = null): ?string
{
try {
// Validate key
$key = strtolower($key);
if (!preg_match('/^[a-z0-9\.\-\_]+$/', $key)) {
throw new TranslatorException('Invalid translation key');
}
// Get current language
$language = $this->_language($lang);
$translation = $language->get($key);
if ($translation) { // Translation found
return $translation;
}
// Fallback
try {
$fallback = $this->_fallback();
} catch (LanguageException $e) {
throw new LanguageException('[Fallback] ' . $e->getMessage());
}
if ($fallback && $fallback->name() !== $language->name()) {
$translation = $fallback->get($key);
if ($translation) {
return $translation;
}
}
} catch (TranslatorException $e) {
trigger_error(sprintf('Translation error [%s]: %s', $key, $e->getMessage()), E_USER_WARNING);
}
return null;
}
|
[
"public",
"function",
"translate",
"(",
"string",
"$",
"key",
",",
"?",
"string",
"$",
"lang",
"=",
"null",
")",
":",
"?",
"string",
"{",
"try",
"{",
"// Validate key",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-z0-9\\.\\-\\_]+$/'",
",",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"TranslatorException",
"(",
"'Invalid translation key'",
")",
";",
"}",
"// Get current language",
"$",
"language",
"=",
"$",
"this",
"->",
"_language",
"(",
"$",
"lang",
")",
";",
"$",
"translation",
"=",
"$",
"language",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"translation",
")",
"{",
"// Translation found",
"return",
"$",
"translation",
";",
"}",
"// Fallback",
"try",
"{",
"$",
"fallback",
"=",
"$",
"this",
"->",
"_fallback",
"(",
")",
";",
"}",
"catch",
"(",
"LanguageException",
"$",
"e",
")",
"{",
"throw",
"new",
"LanguageException",
"(",
"'[Fallback] '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"fallback",
"&&",
"$",
"fallback",
"->",
"name",
"(",
")",
"!==",
"$",
"language",
"->",
"name",
"(",
")",
")",
"{",
"$",
"translation",
"=",
"$",
"fallback",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"translation",
")",
"{",
"return",
"$",
"translation",
";",
"}",
"}",
"}",
"catch",
"(",
"TranslatorException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'Translation error [%s]: %s'",
",",
"$",
"key",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"E_USER_WARNING",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Return string translation or NULL (if translation is not found)
On failure to read/compile language files, an E_USER_WARNING will be triggered and NULL returned
@param string $key
@param null|string $lang
@return null|string
|
[
"Return",
"string",
"translation",
"or",
"NULL",
"(",
"if",
"translation",
"is",
"not",
"found",
")",
"On",
"failure",
"to",
"read",
"/",
"compile",
"language",
"files",
"an",
"E_USER_WARNING",
"will",
"be",
"triggered",
"and",
"NULL",
"returned"
] |
train
|
https://github.com/comelyio/comely/blob/561ea7aef36fea347a1a79d3ee5597d4057ddf82/src/Comely/IO/Translator/Translator.php#L230-L265
|
gintonicweb/requirejs
|
src/View/Helper/RequireHelper.php
|
RequireHelper.load
|
public function load(array $configFiles = [])
{
$this->config('configFiles', $configFiles);
$inlineConfig = $this->_getInlineConfig();
$loader = $this->_getLoader();
$modules = $this->_getModules();
$this->_requireLoaded = true;
return $inlineConfig . $loader . $modules;
}
|
php
|
public function load(array $configFiles = [])
{
$this->config('configFiles', $configFiles);
$inlineConfig = $this->_getInlineConfig();
$loader = $this->_getLoader();
$modules = $this->_getModules();
$this->_requireLoaded = true;
return $inlineConfig . $loader . $modules;
}
|
[
"public",
"function",
"load",
"(",
"array",
"$",
"configFiles",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"config",
"(",
"'configFiles'",
",",
"$",
"configFiles",
")",
";",
"$",
"inlineConfig",
"=",
"$",
"this",
"->",
"_getInlineConfig",
"(",
")",
";",
"$",
"loader",
"=",
"$",
"this",
"->",
"_getLoader",
"(",
")",
";",
"$",
"modules",
"=",
"$",
"this",
"->",
"_getModules",
"(",
")",
";",
"$",
"this",
"->",
"_requireLoaded",
"=",
"true",
";",
"return",
"$",
"inlineConfig",
".",
"$",
"loader",
".",
"$",
"modules",
";",
"}"
] |
Fetch all previously loaded modules and requirejs lib path and outputs the
`<script>` tag to initialize the loader.
Parameters accept the plugin notation so it's possible to load the files
like this $this->Require->load('Requirejs.require', 'TwbsTheme.main');
@param array $configFiles additional config files to load on the fly
@return string full `<script>` tag to initialize requirejs
|
[
"Fetch",
"all",
"previously",
"loaded",
"modules",
"and",
"requirejs",
"lib",
"path",
"and",
"outputs",
"the",
"<script",
">",
"tag",
"to",
"initialize",
"the",
"loader",
"."
] |
train
|
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L61-L69
|
gintonicweb/requirejs
|
src/View/Helper/RequireHelper.php
|
RequireHelper._getAppBase
|
protected function _getAppBase()
{
$baseUrl = Configure::read('App.base');
if (!$baseUrl) {
$request = Router::getRequest(true);
if (!$request) {
$baseUrl = '';
} else {
$baseUrl = $request->base;
}
}
return $baseUrl . '/';
}
|
php
|
protected function _getAppBase()
{
$baseUrl = Configure::read('App.base');
if (!$baseUrl) {
$request = Router::getRequest(true);
if (!$request) {
$baseUrl = '';
} else {
$baseUrl = $request->base;
}
}
return $baseUrl . '/';
}
|
[
"protected",
"function",
"_getAppBase",
"(",
")",
"{",
"$",
"baseUrl",
"=",
"Configure",
"::",
"read",
"(",
"'App.base'",
")",
";",
"if",
"(",
"!",
"$",
"baseUrl",
")",
"{",
"$",
"request",
"=",
"Router",
"::",
"getRequest",
"(",
"true",
")",
";",
"if",
"(",
"!",
"$",
"request",
")",
"{",
"$",
"baseUrl",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"baseUrl",
"=",
"$",
"request",
"->",
"base",
";",
"}",
"}",
"return",
"$",
"baseUrl",
".",
"'/'",
";",
"}"
] |
Return the content of CakePHP App.base.
If the App.base value is false, it returns the generated URL automatically
by mimicking how CakePHP add the base to its URL.
@return string the application base directory
|
[
"Return",
"the",
"content",
"of",
"CakePHP",
"App",
".",
"base",
".",
"If",
"the",
"App",
".",
"base",
"value",
"is",
"false",
"it",
"returns",
"the",
"generated",
"URL",
"automatically",
"by",
"mimicking",
"how",
"CakePHP",
"add",
"the",
"base",
"to",
"its",
"URL",
"."
] |
train
|
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L78-L90
|
gintonicweb/requirejs
|
src/View/Helper/RequireHelper.php
|
RequireHelper._getInlineConfig
|
protected function _getInlineConfig()
{
$script = "var require = ";
$script .= json_encode($this->config('inlineConfig'), JSON_UNESCAPED_SLASHES);
return $this->Html->scriptBlock($script);
}
|
php
|
protected function _getInlineConfig()
{
$script = "var require = ";
$script .= json_encode($this->config('inlineConfig'), JSON_UNESCAPED_SLASHES);
return $this->Html->scriptBlock($script);
}
|
[
"protected",
"function",
"_getInlineConfig",
"(",
")",
"{",
"$",
"script",
"=",
"\"var require = \"",
";",
"$",
"script",
".=",
"json_encode",
"(",
"$",
"this",
"->",
"config",
"(",
"'inlineConfig'",
")",
",",
"JSON_UNESCAPED_SLASHES",
")",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"scriptBlock",
"(",
"$",
"script",
")",
";",
"}"
] |
Return a `<script>` block that initializes the requirejs main configuration
file and loads all modules that have been loaded.
Note that the requirejs library must be loaded before this block
@return string content of the `<script>` tag that initialize requirejs
|
[
"Return",
"a",
"<script",
">",
"block",
"that",
"initializes",
"the",
"requirejs",
"main",
"configuration",
"file",
"and",
"loads",
"all",
"modules",
"that",
"have",
"been",
"loaded",
"."
] |
train
|
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L100-L105
|
gintonicweb/requirejs
|
src/View/Helper/RequireHelper.php
|
RequireHelper._getModules
|
protected function _getModules()
{
$modules = implode(',', $this->_modules);
$configFiles = $this->config('configFiles');
foreach ($configFiles as $key => $config) {
$config = $this->Url->assetUrl($config, [
'pathPrefix' => Configure::read('App.jsBaseUrl'),
'ext' => '.js'
]);
$configFiles[$key] = $config;
}
$dependencies = implode("', '", $configFiles);
$script = "require(['" . $dependencies . "'], function(){require([";
$script .= $modules;
$script .= "]);});";
return $this->Html->scriptBlock($script);
}
|
php
|
protected function _getModules()
{
$modules = implode(',', $this->_modules);
$configFiles = $this->config('configFiles');
foreach ($configFiles as $key => $config) {
$config = $this->Url->assetUrl($config, [
'pathPrefix' => Configure::read('App.jsBaseUrl'),
'ext' => '.js'
]);
$configFiles[$key] = $config;
}
$dependencies = implode("', '", $configFiles);
$script = "require(['" . $dependencies . "'], function(){require([";
$script .= $modules;
$script .= "]);});";
return $this->Html->scriptBlock($script);
}
|
[
"protected",
"function",
"_getModules",
"(",
")",
"{",
"$",
"modules",
"=",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"_modules",
")",
";",
"$",
"configFiles",
"=",
"$",
"this",
"->",
"config",
"(",
"'configFiles'",
")",
";",
"foreach",
"(",
"$",
"configFiles",
"as",
"$",
"key",
"=>",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"Url",
"->",
"assetUrl",
"(",
"$",
"config",
",",
"[",
"'pathPrefix'",
"=>",
"Configure",
"::",
"read",
"(",
"'App.jsBaseUrl'",
")",
",",
"'ext'",
"=>",
"'.js'",
"]",
")",
";",
"$",
"configFiles",
"[",
"$",
"key",
"]",
"=",
"$",
"config",
";",
"}",
"$",
"dependencies",
"=",
"implode",
"(",
"\"', '\"",
",",
"$",
"configFiles",
")",
";",
"$",
"script",
"=",
"\"require(['\"",
".",
"$",
"dependencies",
".",
"\"'], function(){require([\"",
";",
"$",
"script",
".=",
"$",
"modules",
";",
"$",
"script",
".=",
"\"]);});\"",
";",
"return",
"$",
"this",
"->",
"Html",
"->",
"scriptBlock",
"(",
"$",
"script",
")",
";",
"}"
] |
Return a `<script>` block that initializes the requirejs main configuration
file and loads all modules that have been loaded.
Note that the requirejs library must be loaded before this block
@return string content of the `<script>` tag that initialize requirejs
|
[
"Return",
"a",
"<script",
">",
"block",
"that",
"initializes",
"the",
"requirejs",
"main",
"configuration",
"file",
"and",
"loads",
"all",
"modules",
"that",
"have",
"been",
"loaded",
"."
] |
train
|
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L115-L135
|
gintonicweb/requirejs
|
src/View/Helper/RequireHelper.php
|
RequireHelper.module
|
public function module($name)
{
list($plugin, $path) = $this->_View->pluginSplit($name, false);
if (!empty($plugin)) {
$name = $this->Url->assetUrl($name, [
'pathPrefix' => Configure::read('App.jsBaseUrl'),
'ext' => '.js',
]);
}
if (!$this->_requireLoaded) {
return $this->_preLoadModule($name);
}
return $this->_loadModule($name);
}
|
php
|
public function module($name)
{
list($plugin, $path) = $this->_View->pluginSplit($name, false);
if (!empty($plugin)) {
$name = $this->Url->assetUrl($name, [
'pathPrefix' => Configure::read('App.jsBaseUrl'),
'ext' => '.js',
]);
}
if (!$this->_requireLoaded) {
return $this->_preLoadModule($name);
}
return $this->_loadModule($name);
}
|
[
"public",
"function",
"module",
"(",
"$",
"name",
")",
"{",
"list",
"(",
"$",
"plugin",
",",
"$",
"path",
")",
"=",
"$",
"this",
"->",
"_View",
"->",
"pluginSplit",
"(",
"$",
"name",
",",
"false",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"plugin",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"Url",
"->",
"assetUrl",
"(",
"$",
"name",
",",
"[",
"'pathPrefix'",
"=>",
"Configure",
"::",
"read",
"(",
"'App.jsBaseUrl'",
")",
",",
"'ext'",
"=>",
"'.js'",
",",
"]",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_requireLoaded",
")",
"{",
"return",
"$",
"this",
"->",
"_preLoadModule",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_loadModule",
"(",
"$",
"name",
")",
";",
"}"
] |
Add a javascript module to be loaded on the page.
Every module that is called prior to the load() command should be pre-loaded
and will be outputted along with the loader.
Every module that comes after the loader, for example via ajax, should
be loaded right away by setting the "preLoad" option to false
@param string $name name of the js module to load
@return void|string loader tag is outputted on post-load
|
[
"Add",
"a",
"javascript",
"module",
"to",
"be",
"loaded",
"on",
"the",
"page",
"."
] |
train
|
https://github.com/gintonicweb/requirejs/blob/befcd9f2e2f4b0f321e9af5b2ad3f37991d2a9e2/src/View/Helper/RequireHelper.php#L159-L172
|
aboutcoders/enum-serializer-bundle
|
DependencyInjection/AbcEnumSerializerExtension.php
|
AbcEnumSerializerExtension.load
|
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
if (isset($config['serializer']['types']) && is_array($config['serializer']['types'])) {
foreach ($config['serializer']['types'] as $enumClass) {
/**
* Note: The class is registered here directly instead of using $registry->addMethodCall()
* because then it is not ensured that types are set before the JMSSerializerBundle processes
* the listeners and thus, the type would not be registered at all.
*/
EnumHandler::register($enumClass);
}
$loader->load('handler.xml');
}
}
|
php
|
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
if (isset($config['serializer']['types']) && is_array($config['serializer']['types'])) {
foreach ($config['serializer']['types'] as $enumClass) {
/**
* Note: The class is registered here directly instead of using $registry->addMethodCall()
* because then it is not ensured that types are set before the JMSSerializerBundle processes
* the listeners and thus, the type would not be registered at all.
*/
EnumHandler::register($enumClass);
}
$loader->load('handler.xml');
}
}
|
[
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"configuration",
",",
"$",
"configs",
")",
";",
"$",
"loader",
"=",
"new",
"XmlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"__DIR__",
".",
"'/../Resources/config'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'serializer'",
"]",
"[",
"'types'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'serializer'",
"]",
"[",
"'types'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'serializer'",
"]",
"[",
"'types'",
"]",
"as",
"$",
"enumClass",
")",
"{",
"/**\n * Note: The class is registered here directly instead of using $registry->addMethodCall()\n * because then it is not ensured that types are set before the JMSSerializerBundle processes\n * the listeners and thus, the type would not be registered at all.\n */",
"EnumHandler",
"::",
"register",
"(",
"$",
"enumClass",
")",
";",
"}",
"$",
"loader",
"->",
"load",
"(",
"'handler.xml'",
")",
";",
"}",
"}"
] |
{@inheritDoc}
|
[
"{"
] |
train
|
https://github.com/aboutcoders/enum-serializer-bundle/blob/e8a48e8d6d52b2f8fc896e9789fbb9fbbc38164f/DependencyInjection/AbcEnumSerializerExtension.php#L27-L46
|
Eye4web/E4WZfcUserRedirectUrl
|
src/E4W/ZfcUser/RedirectUrl/Factory/Options/ModuleOptionsFactory.php
|
ModuleOptionsFactory.createService
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$service = new ModuleOptions($config['e4wzfcuserredirecturl']);
return $service;
}
|
php
|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config');
$service = new ModuleOptions($config['e4wzfcuserredirecturl']);
return $service;
}
|
[
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"config",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"'Config'",
")",
";",
"$",
"service",
"=",
"new",
"ModuleOptions",
"(",
"$",
"config",
"[",
"'e4wzfcuserredirecturl'",
"]",
")",
";",
"return",
"$",
"service",
";",
"}"
] |
Create options
@param ServiceLocatorInterface $serviceLocator
@return SocialService
|
[
"Create",
"options"
] |
train
|
https://github.com/Eye4web/E4WZfcUserRedirectUrl/blob/e757f4a127b9c48a4e14fbaf4fc0bf271735874e/src/E4W/ZfcUser/RedirectUrl/Factory/Options/ModuleOptionsFactory.php#L17-L23
|
yosmanyga/resource
|
src/Yosmanyga/Resource/Reader/Iterator/IniFileReader.php
|
IniFileReader.supports
|
public function supports(Resource $resource)
{
if ($resource->hasType()) {
if ('ini' == $resource->getType()) {
return true;
}
return false;
}
if ($resource->hasMetadata('file') && in_array(pathinfo($resource->getMetadata('file'), PATHINFO_EXTENSION), ['ini'])) {
return true;
}
return false;
}
|
php
|
public function supports(Resource $resource)
{
if ($resource->hasType()) {
if ('ini' == $resource->getType()) {
return true;
}
return false;
}
if ($resource->hasMetadata('file') && in_array(pathinfo($resource->getMetadata('file'), PATHINFO_EXTENSION), ['ini'])) {
return true;
}
return false;
}
|
[
"public",
"function",
"supports",
"(",
"Resource",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"resource",
"->",
"hasType",
"(",
")",
")",
"{",
"if",
"(",
"'ini'",
"==",
"$",
"resource",
"->",
"getType",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"resource",
"->",
"hasMetadata",
"(",
"'file'",
")",
"&&",
"in_array",
"(",
"pathinfo",
"(",
"$",
"resource",
"->",
"getMetadata",
"(",
"'file'",
")",
",",
"PATHINFO_EXTENSION",
")",
",",
"[",
"'ini'",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/IniFileReader.php#L17-L32
|
yosmanyga/resource
|
src/Yosmanyga/Resource/Reader/Iterator/IniFileReader.php
|
IniFileReader.open
|
public function open(Resource $resource)
{
$file = $resource->getMetadata('file');
if (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $file));
}
try {
$data = parse_ini_file($file, true);
} catch (\Exception $e) {
throw new \InvalidArgumentException($e->getMessage(), 0, $e);
}
$this->inMemoryReader = new InMemoryReader();
$this->inMemoryReader->open(new Resource(['data' => $data], 'in_memory'));
}
|
php
|
public function open(Resource $resource)
{
$file = $resource->getMetadata('file');
if (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $file));
}
try {
$data = parse_ini_file($file, true);
} catch (\Exception $e) {
throw new \InvalidArgumentException($e->getMessage(), 0, $e);
}
$this->inMemoryReader = new InMemoryReader();
$this->inMemoryReader->open(new Resource(['data' => $data], 'in_memory'));
}
|
[
"public",
"function",
"open",
"(",
"Resource",
"$",
"resource",
")",
"{",
"$",
"file",
"=",
"$",
"resource",
"->",
"getMetadata",
"(",
"'file'",
")",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'File \"%s\" not found.'",
",",
"$",
"file",
")",
")",
";",
"}",
"try",
"{",
"$",
"data",
"=",
"parse_ini_file",
"(",
"$",
"file",
",",
"true",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"$",
"this",
"->",
"inMemoryReader",
"=",
"new",
"InMemoryReader",
"(",
")",
";",
"$",
"this",
"->",
"inMemoryReader",
"->",
"open",
"(",
"new",
"Resource",
"(",
"[",
"'data'",
"=>",
"$",
"data",
"]",
",",
"'in_memory'",
")",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/IniFileReader.php#L37-L53
|
yosmanyga/resource
|
src/Yosmanyga/Resource/Reader/Iterator/IniFileReader.php
|
IniFileReader.close
|
public function close()
{
if (!isset($this->inMemoryReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
$this->inMemoryReader->close();
unset($this->inMemoryReader);
}
|
php
|
public function close()
{
if (!isset($this->inMemoryReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
$this->inMemoryReader->close();
unset($this->inMemoryReader);
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"inMemoryReader",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The resource needs to be open.'",
")",
";",
"}",
"$",
"this",
"->",
"inMemoryReader",
"->",
"close",
"(",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"inMemoryReader",
")",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/IniFileReader.php#L82-L90
|
braincrafted/arrayquery
|
src/Braincrafted/ArrayQuery/WhereEvaluation.php
|
WhereEvaluation.evaluate
|
public function evaluate(array $item, array $clause)
{
if (false === isset($clause['key']) ||
false === isset($clause['value']) ||
false === isset($clause['operator'])
) {
throw new \InvalidArgumentException('Clause must contain "key", "value" and operator.');
}
$value = isset($item[$clause['key']]) ? $item[$clause['key']] : null;
$value = $this->evaluateFilters($value, $clause);
if (false === isset($this->operators[$clause['operator']])) {
throw new UnkownOperatorException(sprintf('The operator "%s" does not exist.', $clause['operator']));
}
if (false === $this->operators[$clause['operator']]->evaluate($value, $clause['value'])) {
return false;
}
return true;
}
|
php
|
public function evaluate(array $item, array $clause)
{
if (false === isset($clause['key']) ||
false === isset($clause['value']) ||
false === isset($clause['operator'])
) {
throw new \InvalidArgumentException('Clause must contain "key", "value" and operator.');
}
$value = isset($item[$clause['key']]) ? $item[$clause['key']] : null;
$value = $this->evaluateFilters($value, $clause);
if (false === isset($this->operators[$clause['operator']])) {
throw new UnkownOperatorException(sprintf('The operator "%s" does not exist.', $clause['operator']));
}
if (false === $this->operators[$clause['operator']]->evaluate($value, $clause['value'])) {
return false;
}
return true;
}
|
[
"public",
"function",
"evaluate",
"(",
"array",
"$",
"item",
",",
"array",
"$",
"clause",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"clause",
"[",
"'key'",
"]",
")",
"||",
"false",
"===",
"isset",
"(",
"$",
"clause",
"[",
"'value'",
"]",
")",
"||",
"false",
"===",
"isset",
"(",
"$",
"clause",
"[",
"'operator'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Clause must contain \"key\", \"value\" and operator.'",
")",
";",
"}",
"$",
"value",
"=",
"isset",
"(",
"$",
"item",
"[",
"$",
"clause",
"[",
"'key'",
"]",
"]",
")",
"?",
"$",
"item",
"[",
"$",
"clause",
"[",
"'key'",
"]",
"]",
":",
"null",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"evaluateFilters",
"(",
"$",
"value",
",",
"$",
"clause",
")",
";",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"this",
"->",
"operators",
"[",
"$",
"clause",
"[",
"'operator'",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"UnkownOperatorException",
"(",
"sprintf",
"(",
"'The operator \"%s\" does not exist.'",
",",
"$",
"clause",
"[",
"'operator'",
"]",
")",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"operators",
"[",
"$",
"clause",
"[",
"'operator'",
"]",
"]",
"->",
"evaluate",
"(",
"$",
"value",
",",
"$",
"clause",
"[",
"'value'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Evaluates the given item with the given clause.
@param array $item The item to evaluate.
@param array $clause The clause to evaluate the item with. Has to contain `key`, `value` and `operator` and can
optionally also contain `filters`. `filters` can be either a string or an array.
@return boolean `true` if the item evaluates to `true`, `false` otherwise.
@throws \InvalidArgumentException if `key`, `value` or `operator` is missing in `$clause`.
@throws Braincrafted\ArrayQuery\Exception\UnkownFilterException if a filter does not exist.
@throws Braincrafted\ArrayQuery\Exception\UnkownOperatorException if the operator does not exist.
|
[
"Evaluates",
"the",
"given",
"item",
"with",
"the",
"given",
"clause",
"."
] |
train
|
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/WhereEvaluation.php#L77-L98
|
braincrafted/arrayquery
|
src/Braincrafted/ArrayQuery/WhereEvaluation.php
|
WhereEvaluation.evaluateFilters
|
protected function evaluateFilters($value, array $clause)
{
if (true === isset($clause['filters'])) {
if (false === is_array($clause['filters'])) {
$clause['filters'] = [ $clause['filters'] ];
}
foreach ($clause['filters'] as $filter) {
$value = $this->evaluateFilter($value, $filter);
}
}
return $value;
}
|
php
|
protected function evaluateFilters($value, array $clause)
{
if (true === isset($clause['filters'])) {
if (false === is_array($clause['filters'])) {
$clause['filters'] = [ $clause['filters'] ];
}
foreach ($clause['filters'] as $filter) {
$value = $this->evaluateFilter($value, $filter);
}
}
return $value;
}
|
[
"protected",
"function",
"evaluateFilters",
"(",
"$",
"value",
",",
"array",
"$",
"clause",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"clause",
"[",
"'filters'",
"]",
")",
")",
"{",
"if",
"(",
"false",
"===",
"is_array",
"(",
"$",
"clause",
"[",
"'filters'",
"]",
")",
")",
"{",
"$",
"clause",
"[",
"'filters'",
"]",
"=",
"[",
"$",
"clause",
"[",
"'filters'",
"]",
"]",
";",
"}",
"foreach",
"(",
"$",
"clause",
"[",
"'filters'",
"]",
"as",
"$",
"filter",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"evaluateFilter",
"(",
"$",
"value",
",",
"$",
"filter",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] |
Evaluates the given value with the given clause.
@param mixed $value The value to evaluate.
@param array $clause The clause to evaluate the item with.
@return mixed The evaluated value.
@throws Braincrafted\ArrayQuery\Exception\UnkownFilterException if the given filter does not exist.
@see evaluate()
|
[
"Evaluates",
"the",
"given",
"value",
"with",
"the",
"given",
"clause",
"."
] |
train
|
https://github.com/braincrafted/arrayquery/blob/8b0c44ee76cea796589422f52e2f7130676b9bd1/src/Braincrafted/ArrayQuery/WhereEvaluation.php#L112-L124
|
vardius/list-bundle
|
Column/Column.php
|
Column.getData
|
public function getData($entity, string $responseType = 'html')
{
$data = $this->type->getData($entity, $this->options);
if ($responseType === 'html') {
return $this->templating->render(
$this->options['view'],
$data,
$this->options
);
}
return array_key_exists('property', $data) ? $data['property'] : null;
}
|
php
|
public function getData($entity, string $responseType = 'html')
{
$data = $this->type->getData($entity, $this->options);
if ($responseType === 'html') {
return $this->templating->render(
$this->options['view'],
$data,
$this->options
);
}
return array_key_exists('property', $data) ? $data['property'] : null;
}
|
[
"public",
"function",
"getData",
"(",
"$",
"entity",
",",
"string",
"$",
"responseType",
"=",
"'html'",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"type",
"->",
"getData",
"(",
"$",
"entity",
",",
"$",
"this",
"->",
"options",
")",
";",
"if",
"(",
"$",
"responseType",
"===",
"'html'",
")",
"{",
"return",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"$",
"this",
"->",
"options",
"[",
"'view'",
"]",
",",
"$",
"data",
",",
"$",
"this",
"->",
"options",
")",
";",
"}",
"return",
"array_key_exists",
"(",
"'property'",
",",
"$",
"data",
")",
"?",
"$",
"data",
"[",
"'property'",
"]",
":",
"null",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/vardius/list-bundle/blob/70d3079ce22eed7dad7c467fee532aa2f18c68c9/Column/Column.php#L51-L63
|
vespolina/VespolinaCommerceBundle
|
Controller/Product/ProductAdminController.php
|
ProductController.listAction
|
public function listAction()
{
$products = $this->container->get('vespolina.product_manager')->findBy(array());
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:list.html.'.$this->getEngine(), array('products' => $products));
}
|
php
|
public function listAction()
{
$products = $this->container->get('vespolina.product_manager')->findBy(array());
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:list.html.'.$this->getEngine(), array('products' => $products));
}
|
[
"public",
"function",
"listAction",
"(",
")",
"{",
"$",
"products",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product_manager'",
")",
"->",
"findBy",
"(",
"array",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"renderResponse",
"(",
"'VespolinaCommerceBundle:Product:list.html.'",
".",
"$",
"this",
"->",
"getEngine",
"(",
")",
",",
"array",
"(",
"'products'",
"=>",
"$",
"products",
")",
")",
";",
"}"
] |
Show all products
|
[
"Show",
"all",
"products"
] |
train
|
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L28-L33
|
vespolina/VespolinaCommerceBundle
|
Controller/Product/ProductAdminController.php
|
ProductController.detailAction
|
public function detailAction($id)
{
$product = $this->container->get('vespolina.product_manager')->findProductById($id);
if (!$product) {
throw new NotFoundHttpException('The product does not exist!');
}
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:show.html.'.$this->getEngine(), array('product' => $product));
}
|
php
|
public function detailAction($id)
{
$product = $this->container->get('vespolina.product_manager')->findProductById($id);
if (!$product) {
throw new NotFoundHttpException('The product does not exist!');
}
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:show.html.'.$this->getEngine(), array('product' => $product));
}
|
[
"public",
"function",
"detailAction",
"(",
"$",
"id",
")",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product_manager'",
")",
"->",
"findProductById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"product",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The product does not exist!'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"renderResponse",
"(",
"'VespolinaCommerceBundle:Product:show.html.'",
".",
"$",
"this",
"->",
"getEngine",
"(",
")",
",",
"array",
"(",
"'product'",
"=>",
"$",
"product",
")",
")",
";",
"}"
] |
Show one product by object id
|
[
"Show",
"one",
"product",
"by",
"object",
"id"
] |
train
|
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L38-L47
|
vespolina/VespolinaCommerceBundle
|
Controller/Product/ProductAdminController.php
|
ProductController.editAction
|
public function editAction($id)
{
$product = $this->container->get('vespolina.product_manager')->findProductById($id);
if (!$product) {
throw new NotFoundHttpException('The product does not exist!');
}
$formHandler = $this->container->get('vespolina.product.form.handler');
$process = $formHandler->process($product);
if ($process) {
$this->setFlash('vespolina_product_updated', 'success');
$url = $this->container->get('router')->generate('vespolina_product_list');
return new RedirectResponse($url);
}
$form = $this->container->get('vespolina.product.form');
$form->setData($product);
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:edit.html.'.$this->getEngine(), array(
'form' => $form->createView(),
'id' => $id,
'configuredOptionGroups' => $this->getConfiguredOptionsGroups(),
));
}
|
php
|
public function editAction($id)
{
$product = $this->container->get('vespolina.product_manager')->findProductById($id);
if (!$product) {
throw new NotFoundHttpException('The product does not exist!');
}
$formHandler = $this->container->get('vespolina.product.form.handler');
$process = $formHandler->process($product);
if ($process) {
$this->setFlash('vespolina_product_updated', 'success');
$url = $this->container->get('router')->generate('vespolina_product_list');
return new RedirectResponse($url);
}
$form = $this->container->get('vespolina.product.form');
$form->setData($product);
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:edit.html.'.$this->getEngine(), array(
'form' => $form->createView(),
'id' => $id,
'configuredOptionGroups' => $this->getConfiguredOptionsGroups(),
));
}
|
[
"public",
"function",
"editAction",
"(",
"$",
"id",
")",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product_manager'",
")",
"->",
"findProductById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"product",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The product does not exist!'",
")",
";",
"}",
"$",
"formHandler",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product.form.handler'",
")",
";",
"$",
"process",
"=",
"$",
"formHandler",
"->",
"process",
"(",
"$",
"product",
")",
";",
"if",
"(",
"$",
"process",
")",
"{",
"$",
"this",
"->",
"setFlash",
"(",
"'vespolina_product_updated'",
",",
"'success'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'vespolina_product_list'",
")",
";",
"return",
"new",
"RedirectResponse",
"(",
"$",
"url",
")",
";",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product.form'",
")",
";",
"$",
"form",
"->",
"setData",
"(",
"$",
"product",
")",
";",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"renderResponse",
"(",
"'VespolinaCommerceBundle:Product:edit.html.'",
".",
"$",
"this",
"->",
"getEngine",
"(",
")",
",",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'id'",
"=>",
"$",
"id",
",",
"'configuredOptionGroups'",
"=>",
"$",
"this",
"->",
"getConfiguredOptionsGroups",
"(",
")",
",",
")",
")",
";",
"}"
] |
Edit one product, show the edit form
|
[
"Edit",
"one",
"product",
"show",
"the",
"edit",
"form"
] |
train
|
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L52-L78
|
vespolina/VespolinaCommerceBundle
|
Controller/Product/ProductAdminController.php
|
ProductController.deleteAction
|
public function deleteAction($id)
{
$product = $this->container->get('vespolina.product_manager')->findProductById($id);
if (!$product) {
throw new NotFoundHttpException('The product does not exist!');
}
$dm = $this->container->get('doctrine.odm.mongodb.document_manager');
$dm->remove($product);
$dm->flush();
$this->setFlash('vespolina_product_deleted', 'success');
$url = $this->container->get('router')->generate('vespolina_product_list');
return new RedirectResponse($url);
}
|
php
|
public function deleteAction($id)
{
$product = $this->container->get('vespolina.product_manager')->findProductById($id);
if (!$product) {
throw new NotFoundHttpException('The product does not exist!');
}
$dm = $this->container->get('doctrine.odm.mongodb.document_manager');
$dm->remove($product);
$dm->flush();
$this->setFlash('vespolina_product_deleted', 'success');
$url = $this->container->get('router')->generate('vespolina_product_list');
return new RedirectResponse($url);
}
|
[
"public",
"function",
"deleteAction",
"(",
"$",
"id",
")",
"{",
"$",
"product",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product_manager'",
")",
"->",
"findProductById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"product",
")",
"{",
"throw",
"new",
"NotFoundHttpException",
"(",
"'The product does not exist!'",
")",
";",
"}",
"$",
"dm",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.odm.mongodb.document_manager'",
")",
";",
"$",
"dm",
"->",
"remove",
"(",
"$",
"product",
")",
";",
"$",
"dm",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"setFlash",
"(",
"'vespolina_product_deleted'",
",",
"'success'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'vespolina_product_list'",
")",
";",
"return",
"new",
"RedirectResponse",
"(",
"$",
"url",
")",
";",
"}"
] |
Delete one product, then show list
|
[
"Delete",
"one",
"product",
"then",
"show",
"list"
] |
train
|
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L83-L98
|
vespolina/VespolinaCommerceBundle
|
Controller/Product/ProductAdminController.php
|
ProductController.newAction
|
public function newAction()
{
$form = $this->container->get('vespolina.product.form');
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:new.html.'.$this->getEngine(), array(
'form' => $form->createView(),
'configuredOptionGroups' => $this->getConfiguredOptionsGroups(),
'product' => $this->container->get('vespolina.product_manager')->createProduct(),
));
}
|
php
|
public function newAction()
{
$form = $this->container->get('vespolina.product.form');
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:new.html.'.$this->getEngine(), array(
'form' => $form->createView(),
'configuredOptionGroups' => $this->getConfiguredOptionsGroups(),
'product' => $this->container->get('vespolina.product_manager')->createProduct(),
));
}
|
[
"public",
"function",
"newAction",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product.form'",
")",
";",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"renderResponse",
"(",
"'VespolinaCommerceBundle:Product:new.html.'",
".",
"$",
"this",
"->",
"getEngine",
"(",
")",
",",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
"'configuredOptionGroups'",
"=>",
"$",
"this",
"->",
"getConfiguredOptionsGroups",
"(",
")",
",",
"'product'",
"=>",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product_manager'",
")",
"->",
"createProduct",
"(",
")",
",",
")",
")",
";",
"}"
] |
Show the new form
|
[
"Show",
"the",
"new",
"form"
] |
train
|
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L103-L112
|
vespolina/VespolinaCommerceBundle
|
Controller/Product/ProductAdminController.php
|
ProductController.createAction
|
public function createAction()
{
$form = $this->container->get('vespolina.product.form');
$formHandler = $this->container->get('vespolina.product.form.handler');
$process = $formHandler->process();
if ($process) {
$user = $form->getData();
$this->setFlash('vespolina_product_created', 'success');
$url = $this->container->get('router')->generate('vespolina_product_list');
return new RedirectResponse($url);
}
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:new.html.'.$this->getEngine(), array(
'form' => $form->createView(),
));
}
|
php
|
public function createAction()
{
$form = $this->container->get('vespolina.product.form');
$formHandler = $this->container->get('vespolina.product.form.handler');
$process = $formHandler->process();
if ($process) {
$user = $form->getData();
$this->setFlash('vespolina_product_created', 'success');
$url = $this->container->get('router')->generate('vespolina_product_list');
return new RedirectResponse($url);
}
return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:new.html.'.$this->getEngine(), array(
'form' => $form->createView(),
));
}
|
[
"public",
"function",
"createAction",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product.form'",
")",
";",
"$",
"formHandler",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'vespolina.product.form.handler'",
")",
";",
"$",
"process",
"=",
"$",
"formHandler",
"->",
"process",
"(",
")",
";",
"if",
"(",
"$",
"process",
")",
"{",
"$",
"user",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"$",
"this",
"->",
"setFlash",
"(",
"'vespolina_product_created'",
",",
"'success'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'vespolina_product_list'",
")",
";",
"return",
"new",
"RedirectResponse",
"(",
"$",
"url",
")",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'templating'",
")",
"->",
"renderResponse",
"(",
"'VespolinaCommerceBundle:Product:new.html.'",
".",
"$",
"this",
"->",
"getEngine",
"(",
")",
",",
"array",
"(",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] |
Create a product
|
[
"Create",
"a",
"product"
] |
train
|
https://github.com/vespolina/VespolinaCommerceBundle/blob/0644dd2c0fb39637a0a6c2838b02e17bc480bdbc/Controller/Product/ProductAdminController.php#L117-L135
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.bootstrap
|
public function bootstrap($app)
{
$this->buildModelMap();
$app->on(Application::EVENT_AFTER_REQUEST, function () {
$this->process();
});
}
|
php
|
public function bootstrap($app)
{
$this->buildModelMap();
$app->on(Application::EVENT_AFTER_REQUEST, function () {
$this->process();
});
}
|
[
"public",
"function",
"bootstrap",
"(",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"buildModelMap",
"(",
")",
";",
"$",
"app",
"->",
"on",
"(",
"Application",
"::",
"EVENT_AFTER_REQUEST",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"process",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Bootstrap method to be called during application bootstrap stage.
@param Application $app the application currently running
|
[
"Bootstrap",
"method",
"to",
"be",
"called",
"during",
"application",
"bootstrap",
"stage",
"."
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L131-L137
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.buildModelMap
|
private function buildModelMap()
{
$this->modelMap = ArrayHelper::merge($this->defaultModelMap, $this->modelMap);
foreach ($this->modelMap as $modelName => $configuration) {
Yii::$container->set($configuration['class'], $configuration);
}
}
|
php
|
private function buildModelMap()
{
$this->modelMap = ArrayHelper::merge($this->defaultModelMap, $this->modelMap);
foreach ($this->modelMap as $modelName => $configuration) {
Yii::$container->set($configuration['class'], $configuration);
}
}
|
[
"private",
"function",
"buildModelMap",
"(",
")",
"{",
"$",
"this",
"->",
"modelMap",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"this",
"->",
"defaultModelMap",
",",
"$",
"this",
"->",
"modelMap",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"modelMap",
"as",
"$",
"modelName",
"=>",
"$",
"configuration",
")",
"{",
"Yii",
"::",
"$",
"container",
"->",
"set",
"(",
"$",
"configuration",
"[",
"'class'",
"]",
",",
"$",
"configuration",
")",
";",
"}",
"}"
] |
Builds model map, setups di container
|
[
"Builds",
"model",
"map",
"setups",
"di",
"container"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L142-L148
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.createVisitor
|
private function createVisitor()
{
$this->visitor = Yii::$container->get($this->modelMap['Visitor']['class']);
$this->visitor->save();
return $this->visitor;
}
|
php
|
private function createVisitor()
{
$this->visitor = Yii::$container->get($this->modelMap['Visitor']['class']);
$this->visitor->save();
return $this->visitor;
}
|
[
"private",
"function",
"createVisitor",
"(",
")",
"{",
"$",
"this",
"->",
"visitor",
"=",
"Yii",
"::",
"$",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"modelMap",
"[",
"'Visitor'",
"]",
"[",
"'class'",
"]",
")",
";",
"$",
"this",
"->",
"visitor",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
"->",
"visitor",
";",
"}"
] |
Create Visitor record
@return Visitor
@throws \yii\base\InvalidConfigException
|
[
"Create",
"Visitor",
"record"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L156-L161
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.saveVisitor
|
private function saveVisitor()
{
Yii::$app->session->set($this->visitorCookieName, $this->visitor->getPrimaryKey());
if (!Yii::$app->request->cookies->has($this->visitorCookieName)) {
$this->setVisitorCookie();
return;
}
$cookie = Yii::$app->request->cookies->get($this->visitorCookieName);
if ($cookie->expire - time() <= $this->visitorCookieExpireTime) {
$this->setVisitorCookie();
}
}
|
php
|
private function saveVisitor()
{
Yii::$app->session->set($this->visitorCookieName, $this->visitor->getPrimaryKey());
if (!Yii::$app->request->cookies->has($this->visitorCookieName)) {
$this->setVisitorCookie();
return;
}
$cookie = Yii::$app->request->cookies->get($this->visitorCookieName);
if ($cookie->expire - time() <= $this->visitorCookieExpireTime) {
$this->setVisitorCookie();
}
}
|
[
"private",
"function",
"saveVisitor",
"(",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"visitorCookieName",
",",
"$",
"this",
"->",
"visitor",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"if",
"(",
"!",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"cookies",
"->",
"has",
"(",
"$",
"this",
"->",
"visitorCookieName",
")",
")",
"{",
"$",
"this",
"->",
"setVisitorCookie",
"(",
")",
";",
"return",
";",
"}",
"$",
"cookie",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"cookies",
"->",
"get",
"(",
"$",
"this",
"->",
"visitorCookieName",
")",
";",
"if",
"(",
"$",
"cookie",
"->",
"expire",
"-",
"time",
"(",
")",
"<=",
"$",
"this",
"->",
"visitorCookieExpireTime",
")",
"{",
"$",
"this",
"->",
"setVisitorCookie",
"(",
")",
";",
"}",
"}"
] |
Store visitor_id in session and if require in cookie
|
[
"Store",
"visitor_id",
"in",
"session",
"and",
"if",
"require",
"in",
"cookie"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L166-L179
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.setVisitorCookie
|
private function setVisitorCookie()
{
Yii::$app->response->cookies->add(new Cookie([
'name' => $this->visitorCookieName,
'value' => $this->visitor->getPrimaryKey(),
'expire' => time() + $this->visitorCookieTime,
]));
}
|
php
|
private function setVisitorCookie()
{
Yii::$app->response->cookies->add(new Cookie([
'name' => $this->visitorCookieName,
'value' => $this->visitor->getPrimaryKey(),
'expire' => time() + $this->visitorCookieTime,
]));
}
|
[
"private",
"function",
"setVisitorCookie",
"(",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"response",
"->",
"cookies",
"->",
"add",
"(",
"new",
"Cookie",
"(",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"visitorCookieName",
",",
"'value'",
"=>",
"$",
"this",
"->",
"visitor",
"->",
"getPrimaryKey",
"(",
")",
",",
"'expire'",
"=>",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"visitorCookieTime",
",",
"]",
")",
")",
";",
"}"
] |
Add visitor cookie
|
[
"Add",
"visitor",
"cookie"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L184-L191
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.hasVisitor
|
public function hasVisitor($visitor_id)
{
if ($this->visitor !== null) {
return true;
}
/**
* @var Visitor $model
*/
$model = Yii::$container->get($this->modelMap['Visitor']['class']);
$this->visitor = $model->find()
->where(['id' => $visitor_id])
->one();
return $this->visitor !== null;
}
|
php
|
public function hasVisitor($visitor_id)
{
if ($this->visitor !== null) {
return true;
}
/**
* @var Visitor $model
*/
$model = Yii::$container->get($this->modelMap['Visitor']['class']);
$this->visitor = $model->find()
->where(['id' => $visitor_id])
->one();
return $this->visitor !== null;
}
|
[
"public",
"function",
"hasVisitor",
"(",
"$",
"visitor_id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"visitor",
"!==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"/**\n * @var Visitor $model\n */",
"$",
"model",
"=",
"Yii",
"::",
"$",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"modelMap",
"[",
"'Visitor'",
"]",
"[",
"'class'",
"]",
")",
";",
"$",
"this",
"->",
"visitor",
"=",
"$",
"model",
"->",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"visitor_id",
"]",
")",
"->",
"one",
"(",
")",
";",
"return",
"$",
"this",
"->",
"visitor",
"!==",
"null",
";",
"}"
] |
Check if visitor exists
@param int $visitor_id
@return bool
@throws \yii\base\InvalidConfigException
|
[
"Check",
"if",
"visitor",
"exists"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L200-L213
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.getVisitor
|
public function getVisitor()
{
if ($this->visitor !== null) {
return $this->visitor;
}
if (Yii::$app->session->has($this->visitorCookieName)) {
$visitor_id = Yii::$app->session->get($this->visitorCookieName);
} elseif (Yii::$app->request->cookies->has($this->visitorCookieName)) {
$visitor_id = Yii::$app->request->cookies->getValue($this->visitorCookieName);
}
if (isset($visitor_id) && $this->hasVisitor($visitor_id)) {
return $this->visitor;
}
return $this->createVisitor();
}
|
php
|
public function getVisitor()
{
if ($this->visitor !== null) {
return $this->visitor;
}
if (Yii::$app->session->has($this->visitorCookieName)) {
$visitor_id = Yii::$app->session->get($this->visitorCookieName);
} elseif (Yii::$app->request->cookies->has($this->visitorCookieName)) {
$visitor_id = Yii::$app->request->cookies->getValue($this->visitorCookieName);
}
if (isset($visitor_id) && $this->hasVisitor($visitor_id)) {
return $this->visitor;
}
return $this->createVisitor();
}
|
[
"public",
"function",
"getVisitor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"visitor",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"visitor",
";",
"}",
"if",
"(",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"has",
"(",
"$",
"this",
"->",
"visitorCookieName",
")",
")",
"{",
"$",
"visitor_id",
"=",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"visitorCookieName",
")",
";",
"}",
"elseif",
"(",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"cookies",
"->",
"has",
"(",
"$",
"this",
"->",
"visitorCookieName",
")",
")",
"{",
"$",
"visitor_id",
"=",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"cookies",
"->",
"getValue",
"(",
"$",
"this",
"->",
"visitorCookieName",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"visitor_id",
")",
"&&",
"$",
"this",
"->",
"hasVisitor",
"(",
"$",
"visitor_id",
")",
")",
"{",
"return",
"$",
"this",
"->",
"visitor",
";",
"}",
"return",
"$",
"this",
"->",
"createVisitor",
"(",
")",
";",
"}"
] |
Return current Visitor
@return Visitor
|
[
"Return",
"current",
"Visitor"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L220-L236
|
DevGroup-ru/yii2-intent-analytics
|
src/IntentAnalyticsModule.php
|
IntentAnalyticsModule.process
|
public function process()
{
$this->getVisitor();
$this->saveVisitor();
if (!$this->visitor->hasUserId() && !Yii::$app->user->isGuest) {
$this->visitor->setUserId(Yii::$app->user->identity->getId());
}
if ($this->detectFirstVisitSource) {
}
if ($this->detectAllVisitsSources) {
}
if ($this->storeLastActivity) {
$this->visitor->save();
}
if ($this->storeVisitedPages) {
}
}
|
php
|
public function process()
{
$this->getVisitor();
$this->saveVisitor();
if (!$this->visitor->hasUserId() && !Yii::$app->user->isGuest) {
$this->visitor->setUserId(Yii::$app->user->identity->getId());
}
if ($this->detectFirstVisitSource) {
}
if ($this->detectAllVisitsSources) {
}
if ($this->storeLastActivity) {
$this->visitor->save();
}
if ($this->storeVisitedPages) {
}
}
|
[
"public",
"function",
"process",
"(",
")",
"{",
"$",
"this",
"->",
"getVisitor",
"(",
")",
";",
"$",
"this",
"->",
"saveVisitor",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"visitor",
"->",
"hasUserId",
"(",
")",
"&&",
"!",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
")",
"{",
"$",
"this",
"->",
"visitor",
"->",
"setUserId",
"(",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
"->",
"getId",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"detectFirstVisitSource",
")",
"{",
"}",
"if",
"(",
"$",
"this",
"->",
"detectAllVisitsSources",
")",
"{",
"}",
"if",
"(",
"$",
"this",
"->",
"storeLastActivity",
")",
"{",
"$",
"this",
"->",
"visitor",
"->",
"save",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"storeVisitedPages",
")",
"{",
"}",
"}"
] |
Fills $this->visitor
|
[
"Fills",
"$this",
"-",
">",
"visitor"
] |
train
|
https://github.com/DevGroup-ru/yii2-intent-analytics/blob/53937d44df8c73dca402cc7351b018e6758c3af6/src/IntentAnalyticsModule.php#L241-L265
|
movoin/one-swoole
|
src/Validation/Validators/RequiredValidator.php
|
RequiredValidator.validate
|
protected function validate(array $attributes, string $name, array $parameters): bool
{
if (isset($attributes[$name]) && ! empty($attributes[$name])) {
return true;
}
$this->addError($name, $parameters, '%s 必须填写');
return false;
}
|
php
|
protected function validate(array $attributes, string $name, array $parameters): bool
{
if (isset($attributes[$name]) && ! empty($attributes[$name])) {
return true;
}
$this->addError($name, $parameters, '%s 必须填写');
return false;
}
|
[
"protected",
"function",
"validate",
"(",
"array",
"$",
"attributes",
",",
"string",
"$",
"name",
",",
"array",
"$",
"parameters",
")",
":",
"bool",
"{",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"attributes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"addError",
"(",
"$",
"name",
",",
"$",
"parameters",
",",
"'%s 必须填写');",
"",
"",
"return",
"false",
";",
"}"
] |
校验规则
@param array $attributes
@param string $name
@param array $parameters
@return bool
|
[
"校验规则"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Validation/Validators/RequiredValidator.php#L33-L42
|
avoo/SerializerTranslation
|
Configuration/Metadata/Driver/YamlDriver.php
|
YamlDriver.loadMetadataFromFile
|
protected function loadMetadataFromFile(\ReflectionClass $class, $file)
{
$config = Yaml::parse(file_get_contents($file));
if (!isset($config[$name = $class->getName()])) {
throw new \RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $name, $file));
}
$config = $config[$name];
$classMetadata = new ClassMetadata($name);
$classMetadata->fileResources[] = $file;
$classMetadata->fileResources[] = $class->getFileName();
if (!isset($config['properties'])) {
return $classMetadata;
}
foreach ($config['properties'] as $key => $property) {
if (isset($property['translate'])) {
$options = $this->createOptions($property);
$propertyMetadata = new VirtualPropertyMetadata($class->getName(), $key, $options);
$classMetadata->addPropertyToTranslate($propertyMetadata);
}
}
return $classMetadata;
}
|
php
|
protected function loadMetadataFromFile(\ReflectionClass $class, $file)
{
$config = Yaml::parse(file_get_contents($file));
if (!isset($config[$name = $class->getName()])) {
throw new \RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $name, $file));
}
$config = $config[$name];
$classMetadata = new ClassMetadata($name);
$classMetadata->fileResources[] = $file;
$classMetadata->fileResources[] = $class->getFileName();
if (!isset($config['properties'])) {
return $classMetadata;
}
foreach ($config['properties'] as $key => $property) {
if (isset($property['translate'])) {
$options = $this->createOptions($property);
$propertyMetadata = new VirtualPropertyMetadata($class->getName(), $key, $options);
$classMetadata->addPropertyToTranslate($propertyMetadata);
}
}
return $classMetadata;
}
|
[
"protected",
"function",
"loadMetadataFromFile",
"(",
"\\",
"ReflectionClass",
"$",
"class",
",",
"$",
"file",
")",
"{",
"$",
"config",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"name",
"=",
"$",
"class",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Expected metadata for class %s to be defined in %s.'",
",",
"$",
"name",
",",
"$",
"file",
")",
")",
";",
"}",
"$",
"config",
"=",
"$",
"config",
"[",
"$",
"name",
"]",
";",
"$",
"classMetadata",
"=",
"new",
"ClassMetadata",
"(",
"$",
"name",
")",
";",
"$",
"classMetadata",
"->",
"fileResources",
"[",
"]",
"=",
"$",
"file",
";",
"$",
"classMetadata",
"->",
"fileResources",
"[",
"]",
"=",
"$",
"class",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'properties'",
"]",
")",
")",
"{",
"return",
"$",
"classMetadata",
";",
"}",
"foreach",
"(",
"$",
"config",
"[",
"'properties'",
"]",
"as",
"$",
"key",
"=>",
"$",
"property",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"property",
"[",
"'translate'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"createOptions",
"(",
"$",
"property",
")",
";",
"$",
"propertyMetadata",
"=",
"new",
"VirtualPropertyMetadata",
"(",
"$",
"class",
"->",
"getName",
"(",
")",
",",
"$",
"key",
",",
"$",
"options",
")",
";",
"$",
"classMetadata",
"->",
"addPropertyToTranslate",
"(",
"$",
"propertyMetadata",
")",
";",
"}",
"}",
"return",
"$",
"classMetadata",
";",
"}"
] |
{@inheritdoc}
|
[
"{"
] |
train
|
https://github.com/avoo/SerializerTranslation/blob/e66de5482adb944197a36874465ef144b293a157/Configuration/Metadata/Driver/YamlDriver.php#L44-L70
|
czim/laravel-pxlcms
|
src/Models/Scopes/CmsOrdered.php
|
CmsOrdered.getQualifiedOrderByColumns
|
public function getQualifiedOrderByColumns()
{
$columns = $this->cmsOrderBy;
$qualified = [];
if (empty($columns)) return [];
foreach ($columns as $column => $direction) {
$qualified[ $this->getTable() . '.' . $column ] = $direction;
}
return $qualified;
}
|
php
|
public function getQualifiedOrderByColumns()
{
$columns = $this->cmsOrderBy;
$qualified = [];
if (empty($columns)) return [];
foreach ($columns as $column => $direction) {
$qualified[ $this->getTable() . '.' . $column ] = $direction;
}
return $qualified;
}
|
[
"public",
"function",
"getQualifiedOrderByColumns",
"(",
")",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"cmsOrderBy",
";",
"$",
"qualified",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"columns",
")",
")",
"return",
"[",
"]",
";",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"column",
"=>",
"$",
"direction",
")",
"{",
"$",
"qualified",
"[",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"'.'",
".",
"$",
"column",
"]",
"=",
"$",
"direction",
";",
"}",
"return",
"$",
"qualified",
";",
"}"
] |
Get the fully qualified column name for applying the scope
@return string
|
[
"Get",
"the",
"fully",
"qualified",
"column",
"name",
"for",
"applying",
"the",
"scope"
] |
train
|
https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/CmsOrdered.php#L20-L32
|
jan-dolata/crude-crud
|
src/Http/Controllers/ApiController.php
|
ApiController.index
|
public function index(ApiRequest $request)
{
$this->crude = CrudeInstance::get($request->crudeName);
$page = $request->input('page', 1);
$numRows = $request->input('numRows', config('crude.defaults.numRows'));
$sortAttr = $request->input('sortAttr', config('crude.defaults.sortAttr'));
$sortOrder = $request->input('sortOrder', config('crude.defaults.sortOrder'));
$searchAttr = $request->input('searchAttr', config('crude.defaults.searchAttr'));
$searchValue = $request->input('searchValue', '');
$richFilters = $request->input('richFilters', []);
$count = $this->crude->countFiltered($searchAttr, $searchValue, $richFilters);
$numPages = $numRows > 0
? ceil($count / $numRows)
: 1;
if ($page < 1)
$page = 1;
if ($page > $numPages)
$page = $numPages;
$collection = $this->crude->getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters);
return $this->successResponse([
'collection' => $collection,
'pagination' => [
'page' => $page,
'numRows' => $numRows,
'numPages' => $numPages,
'count' => $count,
],
'sort' => [
'attr' => $sortAttr,
'order' => $sortOrder
],
'search' => [
'attr' => $searchAttr,
'value' => $searchValue
],
'setup' => $this->crude->getCrudeSetupData()
]);
}
|
php
|
public function index(ApiRequest $request)
{
$this->crude = CrudeInstance::get($request->crudeName);
$page = $request->input('page', 1);
$numRows = $request->input('numRows', config('crude.defaults.numRows'));
$sortAttr = $request->input('sortAttr', config('crude.defaults.sortAttr'));
$sortOrder = $request->input('sortOrder', config('crude.defaults.sortOrder'));
$searchAttr = $request->input('searchAttr', config('crude.defaults.searchAttr'));
$searchValue = $request->input('searchValue', '');
$richFilters = $request->input('richFilters', []);
$count = $this->crude->countFiltered($searchAttr, $searchValue, $richFilters);
$numPages = $numRows > 0
? ceil($count / $numRows)
: 1;
if ($page < 1)
$page = 1;
if ($page > $numPages)
$page = $numPages;
$collection = $this->crude->getFiltered($page, $numRows, $sortAttr, $sortOrder, $searchAttr, $searchValue, $richFilters);
return $this->successResponse([
'collection' => $collection,
'pagination' => [
'page' => $page,
'numRows' => $numRows,
'numPages' => $numPages,
'count' => $count,
],
'sort' => [
'attr' => $sortAttr,
'order' => $sortOrder
],
'search' => [
'attr' => $searchAttr,
'value' => $searchValue
],
'setup' => $this->crude->getCrudeSetupData()
]);
}
|
[
"public",
"function",
"index",
"(",
"ApiRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"crude",
"=",
"CrudeInstance",
"::",
"get",
"(",
"$",
"request",
"->",
"crudeName",
")",
";",
"$",
"page",
"=",
"$",
"request",
"->",
"input",
"(",
"'page'",
",",
"1",
")",
";",
"$",
"numRows",
"=",
"$",
"request",
"->",
"input",
"(",
"'numRows'",
",",
"config",
"(",
"'crude.defaults.numRows'",
")",
")",
";",
"$",
"sortAttr",
"=",
"$",
"request",
"->",
"input",
"(",
"'sortAttr'",
",",
"config",
"(",
"'crude.defaults.sortAttr'",
")",
")",
";",
"$",
"sortOrder",
"=",
"$",
"request",
"->",
"input",
"(",
"'sortOrder'",
",",
"config",
"(",
"'crude.defaults.sortOrder'",
")",
")",
";",
"$",
"searchAttr",
"=",
"$",
"request",
"->",
"input",
"(",
"'searchAttr'",
",",
"config",
"(",
"'crude.defaults.searchAttr'",
")",
")",
";",
"$",
"searchValue",
"=",
"$",
"request",
"->",
"input",
"(",
"'searchValue'",
",",
"''",
")",
";",
"$",
"richFilters",
"=",
"$",
"request",
"->",
"input",
"(",
"'richFilters'",
",",
"[",
"]",
")",
";",
"$",
"count",
"=",
"$",
"this",
"->",
"crude",
"->",
"countFiltered",
"(",
"$",
"searchAttr",
",",
"$",
"searchValue",
",",
"$",
"richFilters",
")",
";",
"$",
"numPages",
"=",
"$",
"numRows",
">",
"0",
"?",
"ceil",
"(",
"$",
"count",
"/",
"$",
"numRows",
")",
":",
"1",
";",
"if",
"(",
"$",
"page",
"<",
"1",
")",
"$",
"page",
"=",
"1",
";",
"if",
"(",
"$",
"page",
">",
"$",
"numPages",
")",
"$",
"page",
"=",
"$",
"numPages",
";",
"$",
"collection",
"=",
"$",
"this",
"->",
"crude",
"->",
"getFiltered",
"(",
"$",
"page",
",",
"$",
"numRows",
",",
"$",
"sortAttr",
",",
"$",
"sortOrder",
",",
"$",
"searchAttr",
",",
"$",
"searchValue",
",",
"$",
"richFilters",
")",
";",
"return",
"$",
"this",
"->",
"successResponse",
"(",
"[",
"'collection'",
"=>",
"$",
"collection",
",",
"'pagination'",
"=>",
"[",
"'page'",
"=>",
"$",
"page",
",",
"'numRows'",
"=>",
"$",
"numRows",
",",
"'numPages'",
"=>",
"$",
"numPages",
",",
"'count'",
"=>",
"$",
"count",
",",
"]",
",",
"'sort'",
"=>",
"[",
"'attr'",
"=>",
"$",
"sortAttr",
",",
"'order'",
"=>",
"$",
"sortOrder",
"]",
",",
"'search'",
"=>",
"[",
"'attr'",
"=>",
"$",
"searchAttr",
",",
"'value'",
"=>",
"$",
"searchValue",
"]",
",",
"'setup'",
"=>",
"$",
"this",
"->",
"crude",
"->",
"getCrudeSetupData",
"(",
")",
"]",
")",
";",
"}"
] |
Fetch collection
|
[
"Fetch",
"collection"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ApiController.php#L27-L70
|
jan-dolata/crude-crud
|
src/Http/Controllers/ApiController.php
|
ApiController.store
|
public function store(ApiStoreRequest $request, $crudeName)
{
$this->crude = CrudeInstance::get($request->crudeName);
$model = $this->crude->store($request->all());
return $this->successResponse([
'model' => $model,
'message' => $this->crude->getCrudeSetup()->trans('item_has_been_saved')
]);
}
|
php
|
public function store(ApiStoreRequest $request, $crudeName)
{
$this->crude = CrudeInstance::get($request->crudeName);
$model = $this->crude->store($request->all());
return $this->successResponse([
'model' => $model,
'message' => $this->crude->getCrudeSetup()->trans('item_has_been_saved')
]);
}
|
[
"public",
"function",
"store",
"(",
"ApiStoreRequest",
"$",
"request",
",",
"$",
"crudeName",
")",
"{",
"$",
"this",
"->",
"crude",
"=",
"CrudeInstance",
"::",
"get",
"(",
"$",
"request",
"->",
"crudeName",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"crude",
"->",
"store",
"(",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"successResponse",
"(",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'message'",
"=>",
"$",
"this",
"->",
"crude",
"->",
"getCrudeSetup",
"(",
")",
"->",
"trans",
"(",
"'item_has_been_saved'",
")",
"]",
")",
";",
"}"
] |
Add new model
|
[
"Add",
"new",
"model"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ApiController.php#L75-L85
|
jan-dolata/crude-crud
|
src/Http/Controllers/ApiController.php
|
ApiController.update
|
public function update(ApiUpdateRequest $request, $crudeName, $id)
{
$this->crude = CrudeInstance::get($request->crudeName);
$model = $this->crude->updateById($id, $request->all());
return $this->successResponse([
'model' => $model,
'message' => $this->crude->getCrudeSetup()->trans('item_has_been_updated')
]);
}
|
php
|
public function update(ApiUpdateRequest $request, $crudeName, $id)
{
$this->crude = CrudeInstance::get($request->crudeName);
$model = $this->crude->updateById($id, $request->all());
return $this->successResponse([
'model' => $model,
'message' => $this->crude->getCrudeSetup()->trans('item_has_been_updated')
]);
}
|
[
"public",
"function",
"update",
"(",
"ApiUpdateRequest",
"$",
"request",
",",
"$",
"crudeName",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"crude",
"=",
"CrudeInstance",
"::",
"get",
"(",
"$",
"request",
"->",
"crudeName",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"crude",
"->",
"updateById",
"(",
"$",
"id",
",",
"$",
"request",
"->",
"all",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"successResponse",
"(",
"[",
"'model'",
"=>",
"$",
"model",
",",
"'message'",
"=>",
"$",
"this",
"->",
"crude",
"->",
"getCrudeSetup",
"(",
")",
"->",
"trans",
"(",
"'item_has_been_updated'",
")",
"]",
")",
";",
"}"
] |
Update model
|
[
"Update",
"model"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ApiController.php#L90-L100
|
jan-dolata/crude-crud
|
src/Http/Controllers/ApiController.php
|
ApiController.destroy
|
public function destroy(ApiDeleteRequest $request, $crudeName, $id)
{
$this->crude = CrudeInstance::get($request->crudeName);
$model = $this->crude->deleteById($id);
return $this->successResponse([
'message' => $this->crude->getCrudeSetup()->trans('item_has_been_removed')
]);
}
|
php
|
public function destroy(ApiDeleteRequest $request, $crudeName, $id)
{
$this->crude = CrudeInstance::get($request->crudeName);
$model = $this->crude->deleteById($id);
return $this->successResponse([
'message' => $this->crude->getCrudeSetup()->trans('item_has_been_removed')
]);
}
|
[
"public",
"function",
"destroy",
"(",
"ApiDeleteRequest",
"$",
"request",
",",
"$",
"crudeName",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"crude",
"=",
"CrudeInstance",
"::",
"get",
"(",
"$",
"request",
"->",
"crudeName",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"crude",
"->",
"deleteById",
"(",
"$",
"id",
")",
";",
"return",
"$",
"this",
"->",
"successResponse",
"(",
"[",
"'message'",
"=>",
"$",
"this",
"->",
"crude",
"->",
"getCrudeSetup",
"(",
")",
"->",
"trans",
"(",
"'item_has_been_removed'",
")",
"]",
")",
";",
"}"
] |
Remove model
|
[
"Remove",
"model"
] |
train
|
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Http/Controllers/ApiController.php#L105-L114
|
movoin/one-swoole
|
src/Event/Listener.php
|
Listener.setHandler
|
public function setHandler($handler)
{
if (Assert::array($handler)) {
$this->handler = function (Event $event) use ($handler) {
return call_user_func_array($handler, [$event]);
};
} elseif (Assert::instanceOf($handler, '\\Closure')) {
$this->handler = $handler;
} else {
throw new InvalidArgumentException('`Listener::$handler` must be `array` or `Closure`');
}
}
|
php
|
public function setHandler($handler)
{
if (Assert::array($handler)) {
$this->handler = function (Event $event) use ($handler) {
return call_user_func_array($handler, [$event]);
};
} elseif (Assert::instanceOf($handler, '\\Closure')) {
$this->handler = $handler;
} else {
throw new InvalidArgumentException('`Listener::$handler` must be `array` or `Closure`');
}
}
|
[
"public",
"function",
"setHandler",
"(",
"$",
"handler",
")",
"{",
"if",
"(",
"Assert",
"::",
"array",
"(",
"$",
"handler",
")",
")",
"{",
"$",
"this",
"->",
"handler",
"=",
"function",
"(",
"Event",
"$",
"event",
")",
"use",
"(",
"$",
"handler",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"handler",
",",
"[",
"$",
"event",
"]",
")",
";",
"}",
";",
"}",
"elseif",
"(",
"Assert",
"::",
"instanceOf",
"(",
"$",
"handler",
",",
"'\\\\Closure'",
")",
")",
"{",
"$",
"this",
"->",
"handler",
"=",
"$",
"handler",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'`Listener::$handler` must be `array` or `Closure`'",
")",
";",
"}",
"}"
] |
设置事件处理句柄
@param \Closure|array $handler
@throws \InvalidArgumentException
|
[
"设置事件处理句柄"
] |
train
|
https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Event/Listener.php#L68-L79
|
kderyabin/logger
|
src/OptionsTrait.php
|
OptionsTrait.getOptionOrDefault
|
public function getOptionOrDefault($name)
{
return isset($this->options[$name]) ? $this->options[$name] : $this->getDefault($name);
}
|
php
|
public function getOptionOrDefault($name)
{
return isset($this->options[$name]) ? $this->options[$name] : $this->getDefault($name);
}
|
[
"public",
"function",
"getOptionOrDefault",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
":",
"$",
"this",
"->",
"getDefault",
"(",
"$",
"name",
")",
";",
"}"
] |
Get an option value by name or a default option with the same name.
@param $name
@return mixed
|
[
"Get",
"an",
"option",
"value",
"by",
"name",
"or",
"a",
"default",
"option",
"with",
"the",
"same",
"name",
"."
] |
train
|
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/OptionsTrait.php#L56-L59
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php
|
Item.getPriceFormatted
|
public function getPriceFormatted($locale = null)
{
$formatter = $this->getFormatter($locale);
return $formatter->format((float)$this->entity->getPrice());
}
|
php
|
public function getPriceFormatted($locale = null)
{
$formatter = $this->getFormatter($locale);
return $formatter->format((float)$this->entity->getPrice());
}
|
[
"public",
"function",
"getPriceFormatted",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"formatter",
"->",
"format",
"(",
"(",
"float",
")",
"$",
"this",
"->",
"entity",
"->",
"getPrice",
"(",
")",
")",
";",
"}"
] |
@VirtualProperty
@SerializedName("priceFormatted")
@Groups({"Default","cart"})
@return string
|
[
"@VirtualProperty",
"@SerializedName",
"(",
"priceFormatted",
")",
"@Groups",
"(",
"{",
"Default",
"cart",
"}",
")"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php#L404-L409
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php
|
Item.getUnitPriceFormatted
|
public function getUnitPriceFormatted($locale = null)
{
$formatter = $this->getFormatter($locale);
return $formatter->format((float)$this->getUnitPrice());
}
|
php
|
public function getUnitPriceFormatted($locale = null)
{
$formatter = $this->getFormatter($locale);
return $formatter->format((float)$this->getUnitPrice());
}
|
[
"public",
"function",
"getUnitPriceFormatted",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"formatter",
"->",
"format",
"(",
"(",
"float",
")",
"$",
"this",
"->",
"getUnitPrice",
"(",
")",
")",
";",
"}"
] |
@VirtualProperty
@SerializedName("unitPriceFormatted")
@Groups({"Default","cart"})
@return string
|
[
"@VirtualProperty",
"@SerializedName",
"(",
"unitPriceFormatted",
")",
"@Groups",
"(",
"{",
"Default",
"cart",
"}",
")"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php#L438-L443
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php
|
Item.getTotalNetPriceFormatted
|
public function getTotalNetPriceFormatted($locale = null)
{
$formatter = $this->getFormatter($locale);
return $formatter->format((float)$this->entity->getTotalNetPrice());
}
|
php
|
public function getTotalNetPriceFormatted($locale = null)
{
$formatter = $this->getFormatter($locale);
return $formatter->format((float)$this->entity->getTotalNetPrice());
}
|
[
"public",
"function",
"getTotalNetPriceFormatted",
"(",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
"$",
"locale",
")",
";",
"return",
"$",
"formatter",
"->",
"format",
"(",
"(",
"float",
")",
"$",
"this",
"->",
"entity",
"->",
"getTotalNetPrice",
"(",
")",
")",
";",
"}"
] |
@VirtualProperty
@SerializedName("totalNetPriceFormatted")
@Groups({"Default","cart"})
@return string
|
[
"@VirtualProperty",
"@SerializedName",
"(",
"totalNetPriceFormatted",
")",
"@Groups",
"(",
"{",
"Default",
"cart",
"}",
")"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php#L452-L457
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php
|
Item.setProduct
|
public function setProduct($product = null)
{
$productEntity = $product;
// if api-product - temporarily save
if ($product instanceof ApiProductInterface) {
$this->tempProduct = $product;
$productEntity = $product->getEntity();
}
$this->entity->setProduct($productEntity);
return $this;
}
|
php
|
public function setProduct($product = null)
{
$productEntity = $product;
// if api-product - temporarily save
if ($product instanceof ApiProductInterface) {
$this->tempProduct = $product;
$productEntity = $product->getEntity();
}
$this->entity->setProduct($productEntity);
return $this;
}
|
[
"public",
"function",
"setProduct",
"(",
"$",
"product",
"=",
"null",
")",
"{",
"$",
"productEntity",
"=",
"$",
"product",
";",
"// if api-product - temporarily save",
"if",
"(",
"$",
"product",
"instanceof",
"ApiProductInterface",
")",
"{",
"$",
"this",
"->",
"tempProduct",
"=",
"$",
"product",
";",
"$",
"productEntity",
"=",
"$",
"product",
"->",
"getEntity",
"(",
")",
";",
"}",
"$",
"this",
"->",
"entity",
"->",
"setProduct",
"(",
"$",
"productEntity",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
@param $product
@return Item
|
[
"@param",
"$product"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php#L719-L730
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php
|
Item.getFormatter
|
private function getFormatter($locale = 'de-AT')
{
$formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 2);
$formatter->setAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);
return $formatter;
}
|
php
|
private function getFormatter($locale = 'de-AT')
{
$formatter = new \NumberFormatter($locale, \NumberFormatter::DECIMAL);
$formatter->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, 2);
$formatter->setAttribute(\NumberFormatter::DECIMAL_ALWAYS_SHOWN, 1);
return $formatter;
}
|
[
"private",
"function",
"getFormatter",
"(",
"$",
"locale",
"=",
"'de-AT'",
")",
"{",
"$",
"formatter",
"=",
"new",
"\\",
"NumberFormatter",
"(",
"$",
"locale",
",",
"\\",
"NumberFormatter",
"::",
"DECIMAL",
")",
";",
"$",
"formatter",
"->",
"setAttribute",
"(",
"\\",
"NumberFormatter",
"::",
"MIN_FRACTION_DIGITS",
",",
"2",
")",
";",
"$",
"formatter",
"->",
"setAttribute",
"(",
"\\",
"NumberFormatter",
"::",
"DECIMAL_ALWAYS_SHOWN",
",",
"1",
")",
";",
"return",
"$",
"formatter",
";",
"}"
] |
@param $locale
@return Formatter
|
[
"@param",
"$locale"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Api/Item.php#L791-L798
|
dantleech/glob
|
lib/DTL/Glob/Finder/AbstractTraversalFinder.php
|
AbstractTraversalFinder.find
|
public function find($selector)
{
if ($selector == '/') {
return array($this->getNode(array()));
}
$segments = $this->parser->parse($selector);
$result = array();
$this->traverse($segments, $result);
return $result;
}
|
php
|
public function find($selector)
{
if ($selector == '/') {
return array($this->getNode(array()));
}
$segments = $this->parser->parse($selector);
$result = array();
$this->traverse($segments, $result);
return $result;
}
|
[
"public",
"function",
"find",
"(",
"$",
"selector",
")",
"{",
"if",
"(",
"$",
"selector",
"==",
"'/'",
")",
"{",
"return",
"array",
"(",
"$",
"this",
"->",
"getNode",
"(",
"array",
"(",
")",
")",
")",
";",
"}",
"$",
"segments",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"selector",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"traverse",
"(",
"$",
"segments",
",",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
{@inheritDoc}
|
[
"{"
] |
train
|
https://github.com/dantleech/glob/blob/1f618e6b77a5de4c6b0538d82572fe19cbb1c446/lib/DTL/Glob/Finder/AbstractTraversalFinder.php#L45-L57
|
dantleech/glob
|
lib/DTL/Glob/Finder/AbstractTraversalFinder.php
|
AbstractTraversalFinder.traverse
|
private function traverse(array $segments, &$result = array(), $node = null)
{
$path = array();
if (null !== $node) {
$path = explode('/', substr($node->getPath(), 1));
}
do {
list($element, $bitmask) = array_shift($segments);
if ($bitmask & SelectorParser::T_STATIC) {
$path[] = $element;
if ($bitmask & SelectorParser::T_LAST) {
if ($node = $this->getNode($path)) {
$result[] = $node;
break;
}
}
}
if ($bitmask & SelectorParser::T_PATTERN) {
if (null === $parentNode = $this->getNode($path)) {
return;
}
$children = $this->getChildren($parentNode, $element);
foreach ($children as $child) {
if ($bitmask & SelectorParser::T_LAST) {
$result[] = $child;
} else {
$this->traverse($segments, $result, $child);
}
}
return;
}
} while ($segments);
}
|
php
|
private function traverse(array $segments, &$result = array(), $node = null)
{
$path = array();
if (null !== $node) {
$path = explode('/', substr($node->getPath(), 1));
}
do {
list($element, $bitmask) = array_shift($segments);
if ($bitmask & SelectorParser::T_STATIC) {
$path[] = $element;
if ($bitmask & SelectorParser::T_LAST) {
if ($node = $this->getNode($path)) {
$result[] = $node;
break;
}
}
}
if ($bitmask & SelectorParser::T_PATTERN) {
if (null === $parentNode = $this->getNode($path)) {
return;
}
$children = $this->getChildren($parentNode, $element);
foreach ($children as $child) {
if ($bitmask & SelectorParser::T_LAST) {
$result[] = $child;
} else {
$this->traverse($segments, $result, $child);
}
}
return;
}
} while ($segments);
}
|
[
"private",
"function",
"traverse",
"(",
"array",
"$",
"segments",
",",
"&",
"$",
"result",
"=",
"array",
"(",
")",
",",
"$",
"node",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"array",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"node",
")",
"{",
"$",
"path",
"=",
"explode",
"(",
"'/'",
",",
"substr",
"(",
"$",
"node",
"->",
"getPath",
"(",
")",
",",
"1",
")",
")",
";",
"}",
"do",
"{",
"list",
"(",
"$",
"element",
",",
"$",
"bitmask",
")",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"if",
"(",
"$",
"bitmask",
"&",
"SelectorParser",
"::",
"T_STATIC",
")",
"{",
"$",
"path",
"[",
"]",
"=",
"$",
"element",
";",
"if",
"(",
"$",
"bitmask",
"&",
"SelectorParser",
"::",
"T_LAST",
")",
"{",
"if",
"(",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"path",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"node",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"bitmask",
"&",
"SelectorParser",
"::",
"T_PATTERN",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"parentNode",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"path",
")",
")",
"{",
"return",
";",
"}",
"$",
"children",
"=",
"$",
"this",
"->",
"getChildren",
"(",
"$",
"parentNode",
",",
"$",
"element",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"bitmask",
"&",
"SelectorParser",
"::",
"T_LAST",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"child",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"traverse",
"(",
"$",
"segments",
",",
"$",
"result",
",",
"$",
"child",
")",
";",
"}",
"}",
"return",
";",
"}",
"}",
"while",
"(",
"$",
"segments",
")",
";",
"}"
] |
Traverse the node
@param NodeInterface|null $node The node to traverse, if it exists yet
@param array $segments The element => token stack
@param array $result The result
@return null
|
[
"Traverse",
"the",
"node"
] |
train
|
https://github.com/dantleech/glob/blob/1f618e6b77a5de4c6b0538d82572fe19cbb1c446/lib/DTL/Glob/Finder/AbstractTraversalFinder.php#L68-L108
|
sulu/SuluSalesShippingBundle
|
src/Sulu/Bundle/Sales/CoreBundle/Widgets/FlowOfDocuments.php
|
FlowOfDocuments.addEntry
|
protected function addEntry($id, $number, $type, DateTime $date, $route, $pdfUrl, $translationKey = '')
{
$this->entries[] = array(
'id' => $id,
'number' => $number,
'type' => $type,
'date' => $date,
'route' => $route,
'pdfUrl' => $pdfUrl,
'translationKey' => $translationKey
);
}
|
php
|
protected function addEntry($id, $number, $type, DateTime $date, $route, $pdfUrl, $translationKey = '')
{
$this->entries[] = array(
'id' => $id,
'number' => $number,
'type' => $type,
'date' => $date,
'route' => $route,
'pdfUrl' => $pdfUrl,
'translationKey' => $translationKey
);
}
|
[
"protected",
"function",
"addEntry",
"(",
"$",
"id",
",",
"$",
"number",
",",
"$",
"type",
",",
"DateTime",
"$",
"date",
",",
"$",
"route",
",",
"$",
"pdfUrl",
",",
"$",
"translationKey",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"entries",
"[",
"]",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'number'",
"=>",
"$",
"number",
",",
"'type'",
"=>",
"$",
"type",
",",
"'date'",
"=>",
"$",
"date",
",",
"'route'",
"=>",
"$",
"route",
",",
"'pdfUrl'",
"=>",
"$",
"pdfUrl",
",",
"'translationKey'",
"=>",
"$",
"translationKey",
")",
";",
"}"
] |
Creates and adds an entry to the exisiting entries
@param String|Number $id
@param String $number
@param String $type
@param DateTime $date
@param String $route
@param String $pdfUrl
@param String $translationKey
|
[
"Creates",
"and",
"adds",
"an",
"entry",
"to",
"the",
"exisiting",
"entries"
] |
train
|
https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/CoreBundle/Widgets/FlowOfDocuments.php#L48-L59
|
cabalphp/route
|
src/Route.php
|
Route.map
|
public function map($optionsOrMethod, $path, $handler)
{
$this->options = $this->defaultOptions($optionsOrMethod);
$this->path = $path;
$this->handler = $handler;
return $this;
}
|
php
|
public function map($optionsOrMethod, $path, $handler)
{
$this->options = $this->defaultOptions($optionsOrMethod);
$this->path = $path;
$this->handler = $handler;
return $this;
}
|
[
"public",
"function",
"map",
"(",
"$",
"optionsOrMethod",
",",
"$",
"path",
",",
"$",
"handler",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"this",
"->",
"defaultOptions",
"(",
"$",
"optionsOrMethod",
")",
";",
"$",
"this",
"->",
"path",
"=",
"$",
"path",
";",
"$",
"this",
"->",
"handler",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
] |
Undocumented function
@param string $optionsOrMethod
@param string|mixed $path
@param \Cabal\Route\Route $handler
@return void
|
[
"Undocumented",
"function"
] |
train
|
https://github.com/cabalphp/route/blob/13959fa0c3f6777cb9a9290c9b032dd514cd33b7/src/Route.php#L31-L37
|
yoanm/php-jsonrpc-http-server-openapi-doc-sdk
|
src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php
|
ExternalSchemaListDocNormalizer.normalize
|
public function normalize(ServerDoc $doc) : array
{
return array_merge(
$this->getMethodsExternalSchemaList($doc),
$this->getMethodErrorsExternalSchemaList($doc),
$this->getServerErrorsExtraSchemaList($doc)
);
}
|
php
|
public function normalize(ServerDoc $doc) : array
{
return array_merge(
$this->getMethodsExternalSchemaList($doc),
$this->getMethodErrorsExternalSchemaList($doc),
$this->getServerErrorsExtraSchemaList($doc)
);
}
|
[
"public",
"function",
"normalize",
"(",
"ServerDoc",
"$",
"doc",
")",
":",
"array",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"getMethodsExternalSchemaList",
"(",
"$",
"doc",
")",
",",
"$",
"this",
"->",
"getMethodErrorsExternalSchemaList",
"(",
"$",
"doc",
")",
",",
"$",
"this",
"->",
"getServerErrorsExtraSchemaList",
"(",
"$",
"doc",
")",
")",
";",
"}"
] |
@param ServerDoc $doc
@return array
@throws \ReflectionException
|
[
"@param",
"ServerDoc",
"$doc"
] |
train
|
https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/blob/52d6bb5d0671e0363bbf482c3c75fef97d7d1d5e/src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php#L42-L49
|
yoanm/php-jsonrpc-http-server-openapi-doc-sdk
|
src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php
|
ExternalSchemaListDocNormalizer.getMethodsExternalSchemaList
|
protected function getMethodsExternalSchemaList(ServerDoc $doc) : array
{
$list = [];
foreach ($doc->getMethodList() as $method) {
// Merge extra definitions
$list = array_merge($list, $this->getMethodExternalSchemaList($method));
}
return $list;
}
|
php
|
protected function getMethodsExternalSchemaList(ServerDoc $doc) : array
{
$list = [];
foreach ($doc->getMethodList() as $method) {
// Merge extra definitions
$list = array_merge($list, $this->getMethodExternalSchemaList($method));
}
return $list;
}
|
[
"protected",
"function",
"getMethodsExternalSchemaList",
"(",
"ServerDoc",
"$",
"doc",
")",
":",
"array",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"doc",
"->",
"getMethodList",
"(",
")",
"as",
"$",
"method",
")",
"{",
"// Merge extra definitions",
"$",
"list",
"=",
"array_merge",
"(",
"$",
"list",
",",
"$",
"this",
"->",
"getMethodExternalSchemaList",
"(",
"$",
"method",
")",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
@param ServerDoc $doc
@return array
@throws \ReflectionException
|
[
"@param",
"ServerDoc",
"$doc"
] |
train
|
https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/blob/52d6bb5d0671e0363bbf482c3c75fef97d7d1d5e/src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php#L58-L67
|
yoanm/php-jsonrpc-http-server-openapi-doc-sdk
|
src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php
|
ExternalSchemaListDocNormalizer.getMethodErrorsExternalSchemaList
|
protected function getMethodErrorsExternalSchemaList(ServerDoc $doc) : array
{
$list = [];
foreach ($doc->getMethodList() as $method) {
foreach ($method->getCustomErrorList() as $errorDoc) {
$key = $this->definitionRefResolver->getErrorDefinitionId(
$errorDoc,
DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
);
$list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
}
}
return $list;
}
|
php
|
protected function getMethodErrorsExternalSchemaList(ServerDoc $doc) : array
{
$list = [];
foreach ($doc->getMethodList() as $method) {
foreach ($method->getCustomErrorList() as $errorDoc) {
$key = $this->definitionRefResolver->getErrorDefinitionId(
$errorDoc,
DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
);
$list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
}
}
return $list;
}
|
[
"protected",
"function",
"getMethodErrorsExternalSchemaList",
"(",
"ServerDoc",
"$",
"doc",
")",
":",
"array",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"doc",
"->",
"getMethodList",
"(",
")",
"as",
"$",
"method",
")",
"{",
"foreach",
"(",
"$",
"method",
"->",
"getCustomErrorList",
"(",
")",
"as",
"$",
"errorDoc",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"definitionRefResolver",
"->",
"getErrorDefinitionId",
"(",
"$",
"errorDoc",
",",
"DefinitionRefResolver",
"::",
"CUSTOM_ERROR_DEFINITION_TYPE",
")",
";",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"errorDocNormalizer",
"->",
"normalize",
"(",
"$",
"errorDoc",
")",
";",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] |
@param ServerDoc $doc
@return array
@throws \ReflectionException
|
[
"@param",
"ServerDoc",
"$doc"
] |
train
|
https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/blob/52d6bb5d0671e0363bbf482c3c75fef97d7d1d5e/src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php#L76-L90
|
yoanm/php-jsonrpc-http-server-openapi-doc-sdk
|
src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php
|
ExternalSchemaListDocNormalizer.getServerErrorsExtraSchemaList
|
protected function getServerErrorsExtraSchemaList(ServerDoc $doc) : array
{
$list = [];
foreach ($doc->getGlobalErrorList() as $errorDoc) {
$key = $this->definitionRefResolver->getErrorDefinitionId(
$errorDoc,
DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
);
$list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
}
foreach ($doc->getServerErrorList() as $errorDoc) {
$key = $this->definitionRefResolver->getErrorDefinitionId(
$errorDoc,
DefinitionRefResolver::SERVER_ERROR_DEFINITION_TYPE
);
$list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
}
return $list;
}
|
php
|
protected function getServerErrorsExtraSchemaList(ServerDoc $doc) : array
{
$list = [];
foreach ($doc->getGlobalErrorList() as $errorDoc) {
$key = $this->definitionRefResolver->getErrorDefinitionId(
$errorDoc,
DefinitionRefResolver::CUSTOM_ERROR_DEFINITION_TYPE
);
$list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
}
foreach ($doc->getServerErrorList() as $errorDoc) {
$key = $this->definitionRefResolver->getErrorDefinitionId(
$errorDoc,
DefinitionRefResolver::SERVER_ERROR_DEFINITION_TYPE
);
$list[$key] = $this->errorDocNormalizer->normalize($errorDoc);
}
return $list;
}
|
[
"protected",
"function",
"getServerErrorsExtraSchemaList",
"(",
"ServerDoc",
"$",
"doc",
")",
":",
"array",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"doc",
"->",
"getGlobalErrorList",
"(",
")",
"as",
"$",
"errorDoc",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"definitionRefResolver",
"->",
"getErrorDefinitionId",
"(",
"$",
"errorDoc",
",",
"DefinitionRefResolver",
"::",
"CUSTOM_ERROR_DEFINITION_TYPE",
")",
";",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"errorDocNormalizer",
"->",
"normalize",
"(",
"$",
"errorDoc",
")",
";",
"}",
"foreach",
"(",
"$",
"doc",
"->",
"getServerErrorList",
"(",
")",
"as",
"$",
"errorDoc",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"definitionRefResolver",
"->",
"getErrorDefinitionId",
"(",
"$",
"errorDoc",
",",
"DefinitionRefResolver",
"::",
"SERVER_ERROR_DEFINITION_TYPE",
")",
";",
"$",
"list",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"errorDocNormalizer",
"->",
"normalize",
"(",
"$",
"errorDoc",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] |
@param ServerDoc $doc
@return array
@throws \ReflectionException
|
[
"@param",
"ServerDoc",
"$doc"
] |
train
|
https://github.com/yoanm/php-jsonrpc-http-server-openapi-doc-sdk/blob/52d6bb5d0671e0363bbf482c3c75fef97d7d1d5e/src/App/Normalizer/Component/ExternalSchemaListDocNormalizer.php#L100-L120
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.