id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
22,400
|
kecik-framework/kecik
|
Kecik/Assets.php
|
Assets.images
|
public function images( $file, $version = '' ) {
if ( empty( $version ) ) {
$version = '?ver=' . Kecik::$version;
}
return $this->BaseUrl . Config::get( 'path.assets' ) . '/images/' . $file . $version;
}
|
php
|
public function images( $file, $version = '' ) {
if ( empty( $version ) ) {
$version = '?ver=' . Kecik::$version;
}
return $this->BaseUrl . Config::get( 'path.assets' ) . '/images/' . $file . $version;
}
|
[
"public",
"function",
"images",
"(",
"$",
"file",
",",
"$",
"version",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"version",
")",
")",
"{",
"$",
"version",
"=",
"'?ver='",
".",
"Kecik",
"::",
"$",
"version",
";",
"}",
"return",
"$",
"this",
"->",
"BaseUrl",
".",
"Config",
"::",
"get",
"(",
"'path.assets'",
")",
".",
"'/images/'",
".",
"$",
"file",
".",
"$",
"version",
";",
"}"
] |
Create of images Url from Assets
@param $file
@param string $version
@return string
|
[
"Create",
"of",
"images",
"Url",
"from",
"Assets"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Assets.php#L49-L56
|
22,401
|
kecik-framework/kecik
|
Kecik/Assets.php
|
Assets.url
|
public function url( $file = '', $version = '' ) {
if ( empty( $version ) ) {
$version = '?ver=' . Kecik::$version;
}
if ( ! empty( $file ) ) {
return $this->BaseUrl . Config::get( 'path.assets' ) . '/' . $file . $version;
} else {
return $this->BaseUrl . Config::get( 'path.assets' ) . '/';
}
}
|
php
|
public function url( $file = '', $version = '' ) {
if ( empty( $version ) ) {
$version = '?ver=' . Kecik::$version;
}
if ( ! empty( $file ) ) {
return $this->BaseUrl . Config::get( 'path.assets' ) . '/' . $file . $version;
} else {
return $this->BaseUrl . Config::get( 'path.assets' ) . '/';
}
}
|
[
"public",
"function",
"url",
"(",
"$",
"file",
"=",
"''",
",",
"$",
"version",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"version",
")",
")",
"{",
"$",
"version",
"=",
"'?ver='",
".",
"Kecik",
"::",
"$",
"version",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"return",
"$",
"this",
"->",
"BaseUrl",
".",
"Config",
"::",
"get",
"(",
"'path.assets'",
")",
".",
"'/'",
".",
"$",
"file",
".",
"$",
"version",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"BaseUrl",
".",
"Config",
"::",
"get",
"(",
"'path.assets'",
")",
".",
"'/'",
";",
"}",
"}"
] |
Create url from assets
@param string $file
@param string $version
@return string
|
[
"Create",
"url",
"from",
"assets"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Assets.php#L66-L78
|
22,402
|
kecik-framework/kecik
|
Kecik/Assets.php
|
AssetsBase.delete
|
public function delete( $file ) {
$key = array_search( $file, $this->assets[ $this->type ] );
unset( $this->assets[ $this->type ][ $key ] );
unset( $this->attr[ $this->type ][ $key ] );
}
|
php
|
public function delete( $file ) {
$key = array_search( $file, $this->assets[ $this->type ] );
unset( $this->assets[ $this->type ][ $key ] );
unset( $this->attr[ $this->type ][ $key ] );
}
|
[
"public",
"function",
"delete",
"(",
"$",
"file",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"assets",
"[",
"$",
"this",
"->",
"type",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"assets",
"[",
"$",
"this",
"->",
"type",
"]",
"[",
"$",
"key",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"attr",
"[",
"$",
"this",
"->",
"type",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}"
] |
Delete Assets from register
delete
@param $file
|
[
"Delete",
"Assets",
"from",
"register",
"delete"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Assets.php#L147-L151
|
22,403
|
hametuha/wpametu
|
src/WPametu/UI/Field/Input.php
|
Input.build_input
|
protected function build_input($data, array $fields = [] ){
$fields = implode(' ', $fields);
return sprintf('<input id="%1$s" name="%1$s" type="%2$s" %3$s value="%4$s" />',
$this->name, $this->type, $fields, esc_attr($data));
}
|
php
|
protected function build_input($data, array $fields = [] ){
$fields = implode(' ', $fields);
return sprintf('<input id="%1$s" name="%1$s" type="%2$s" %3$s value="%4$s" />',
$this->name, $this->type, $fields, esc_attr($data));
}
|
[
"protected",
"function",
"build_input",
"(",
"$",
"data",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"fields",
"=",
"implode",
"(",
"' '",
",",
"$",
"fields",
")",
";",
"return",
"sprintf",
"(",
"'<input id=\"%1$s\" name=\"%1$s\" type=\"%2$s\" %3$s value=\"%4$s\" />'",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"type",
",",
"$",
"fields",
",",
"esc_attr",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
build input field
@param mixed $data
@param array $fields
@return string
|
[
"build",
"input",
"field"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Input.php#L44-L49
|
22,404
|
mvccore/ext-router-module
|
src/MvcCore/Ext/Routers/Modules/Route/Instancing.php
|
Instancing.constructDataModuleNamespace
|
protected function constructDataModuleNamespace (& $data) {
if (isset($data->module))
$this->SetModule($data->module);
if (isset($data->namespace))
$this->SetNamespace($data->namespace);
}
|
php
|
protected function constructDataModuleNamespace (& $data) {
if (isset($data->module))
$this->SetModule($data->module);
if (isset($data->namespace))
$this->SetNamespace($data->namespace);
}
|
[
"protected",
"function",
"constructDataModuleNamespace",
"(",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"->",
"module",
")",
")",
"$",
"this",
"->",
"SetModule",
"(",
"$",
"data",
"->",
"module",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"->",
"namespace",
")",
")",
"$",
"this",
"->",
"SetNamespace",
"(",
"$",
"data",
"->",
"namespace",
")",
";",
"}"
] |
If route is initialized by single array argument with all data,
initialize route application module name and optional target controllers
namespace - used only if routed controller is not defined absolutely.
Initialize both properties by setter methods.
@param \stdClass $data Object containing properties `module` and `namespace`.
@return void
|
[
"If",
"route",
"is",
"initialized",
"by",
"single",
"array",
"argument",
"with",
"all",
"data",
"initialize",
"route",
"application",
"module",
"name",
"and",
"optional",
"target",
"controllers",
"namespace",
"-",
"used",
"only",
"if",
"routed",
"controller",
"is",
"not",
"defined",
"absolutely",
".",
"Initialize",
"both",
"properties",
"by",
"setter",
"methods",
"."
] |
7695784a451db86cca6a43c98d076803cd0a50a7
|
https://github.com/mvccore/ext-router-module/blob/7695784a451db86cca6a43c98d076803cd0a50a7/src/MvcCore/Ext/Routers/Modules/Route/Instancing.php#L111-L116
|
22,405
|
GrupaZero/api
|
src/Gzero/Api/Transformer/RouteTransformer.php
|
RouteTransformer.transform
|
public function transform($route)
{
$route = $this->entityToArray(Route::class, $route);
return [
'id' => (int) $route['id'],
'createdAt' => $route['created_at'],
'updatedAt' => $route['updated_at']
];
}
|
php
|
public function transform($route)
{
$route = $this->entityToArray(Route::class, $route);
return [
'id' => (int) $route['id'],
'createdAt' => $route['created_at'],
'updatedAt' => $route['updated_at']
];
}
|
[
"public",
"function",
"transform",
"(",
"$",
"route",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"Route",
"::",
"class",
",",
"$",
"route",
")",
";",
"return",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"route",
"[",
"'id'",
"]",
",",
"'createdAt'",
"=>",
"$",
"route",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"route",
"[",
"'updated_at'",
"]",
"]",
";",
"}"
] |
Transforms route entity
@param Route|array $route route entity
@return array
|
[
"Transforms",
"route",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/RouteTransformer.php#L35-L43
|
22,406
|
wenbinye/PhalconX
|
src/Di/ServiceProvider.php
|
ServiceProvider.provide
|
public function provide($name, $args)
{
$services = $this->getServices();
if (isset($services[$name])) {
return (new Service($name, $services[$name]))
->resolve($args, $this->getDi());
} else {
$method = self::METHOD_PREFIX . $name;
if (method_exists($this, $method)) {
if (empty($args)) {
return $this->$method();
} else {
return call_user_func_array([$this, $method], $args);
}
} else {
throw new Exception("Cannot load '{$name}' from " . get_class($this));
}
}
}
|
php
|
public function provide($name, $args)
{
$services = $this->getServices();
if (isset($services[$name])) {
return (new Service($name, $services[$name]))
->resolve($args, $this->getDi());
} else {
$method = self::METHOD_PREFIX . $name;
if (method_exists($this, $method)) {
if (empty($args)) {
return $this->$method();
} else {
return call_user_func_array([$this, $method], $args);
}
} else {
throw new Exception("Cannot load '{$name}' from " . get_class($this));
}
}
}
|
[
"public",
"function",
"provide",
"(",
"$",
"name",
",",
"$",
"args",
")",
"{",
"$",
"services",
"=",
"$",
"this",
"->",
"getServices",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"services",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"(",
"new",
"Service",
"(",
"$",
"name",
",",
"$",
"services",
"[",
"$",
"name",
"]",
")",
")",
"->",
"resolve",
"(",
"$",
"args",
",",
"$",
"this",
"->",
"getDi",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"method",
"=",
"self",
"::",
"METHOD_PREFIX",
".",
"$",
"name",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
")",
";",
"}",
"else",
"{",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"method",
"]",
",",
"$",
"args",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot load '{$name}' from \"",
".",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"}",
"}"
] |
Creates service instance
@param string $name service name
@param array $args arguments to create instance
|
[
"Creates",
"service",
"instance"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Di/ServiceProvider.php#L26-L44
|
22,407
|
wenbinye/PhalconX
|
src/Di/ServiceProvider.php
|
ServiceProvider.getNames
|
public function getNames()
{
$names = array_keys($this->getServices());
$len = strlen(self::METHOD_PREFIX);
foreach (get_class_methods($this) as $method) {
if (Text::startsWith($method, self::METHOD_PREFIX)) {
$name = lcfirst(substr($method, $len));
if ($name) {
$names[] = $name;
}
}
}
return $names;
}
|
php
|
public function getNames()
{
$names = array_keys($this->getServices());
$len = strlen(self::METHOD_PREFIX);
foreach (get_class_methods($this) as $method) {
if (Text::startsWith($method, self::METHOD_PREFIX)) {
$name = lcfirst(substr($method, $len));
if ($name) {
$names[] = $name;
}
}
}
return $names;
}
|
[
"public",
"function",
"getNames",
"(",
")",
"{",
"$",
"names",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"getServices",
"(",
")",
")",
";",
"$",
"len",
"=",
"strlen",
"(",
"self",
"::",
"METHOD_PREFIX",
")",
";",
"foreach",
"(",
"get_class_methods",
"(",
"$",
"this",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"Text",
"::",
"startsWith",
"(",
"$",
"method",
",",
"self",
"::",
"METHOD_PREFIX",
")",
")",
"{",
"$",
"name",
"=",
"lcfirst",
"(",
"substr",
"(",
"$",
"method",
",",
"$",
"len",
")",
")",
";",
"if",
"(",
"$",
"name",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"name",
";",
"}",
"}",
"}",
"return",
"$",
"names",
";",
"}"
] |
Gets all service names
|
[
"Gets",
"all",
"service",
"names"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Di/ServiceProvider.php#L49-L62
|
22,408
|
ienaga/SimpleApiClient
|
src/api/Client.php
|
Client.append
|
public function append()
{
if (!$this->hasMultiHandle()) {
$this->setMultiHandle(curl_multi_init());
}
// init
$this
->initOption()
->buildBody();
$curl = curl_init();
curl_setopt_array($curl, $this->getOptions());
curl_multi_add_handle($this->getMultiHandle(), $curl);
$this->curls[] = $curl;
}
|
php
|
public function append()
{
if (!$this->hasMultiHandle()) {
$this->setMultiHandle(curl_multi_init());
}
// init
$this
->initOption()
->buildBody();
$curl = curl_init();
curl_setopt_array($curl, $this->getOptions());
curl_multi_add_handle($this->getMultiHandle(), $curl);
$this->curls[] = $curl;
}
|
[
"public",
"function",
"append",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMultiHandle",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setMultiHandle",
"(",
"curl_multi_init",
"(",
")",
")",
";",
"}",
"// init",
"$",
"this",
"->",
"initOption",
"(",
")",
"->",
"buildBody",
"(",
")",
";",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt_array",
"(",
"$",
"curl",
",",
"$",
"this",
"->",
"getOptions",
"(",
")",
")",
";",
"curl_multi_add_handle",
"(",
"$",
"this",
"->",
"getMultiHandle",
"(",
")",
",",
"$",
"curl",
")",
";",
"$",
"this",
"->",
"curls",
"[",
"]",
"=",
"$",
"curl",
";",
"}"
] |
add multi handle
|
[
"add",
"multi",
"handle"
] |
834a5e5eb043ed901000bf769a4cf16b9dc28d15
|
https://github.com/ienaga/SimpleApiClient/blob/834a5e5eb043ed901000bf769a4cf16b9dc28d15/src/api/Client.php#L640-L656
|
22,409
|
FrenzelGmbH/cm-address
|
models/Address.php
|
Address.validateModelId
|
public function validateModelId($attribute, $params)
{
/** @var ActiveRecord $class */
$class = Model::findIdentity($this->model_class);
if ($class === null) {
$this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
} else {
$model = $class->name;
if ($model::find()->where(['id' => $this->entity_id]) === false) {
$this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
}
}
}
|
php
|
public function validateModelId($attribute, $params)
{
/** @var ActiveRecord $class */
$class = Model::findIdentity($this->model_class);
if ($class === null) {
$this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
} else {
$model = $class->name;
if ($model::find()->where(['id' => $this->entity_id]) === false) {
$this->addError($attribute, \Yii::t('net_frenzel_communication', 'ERROR_MSG_INVALID_MODEL_ID'));
}
}
}
|
[
"public",
"function",
"validateModelId",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"/** @var ActiveRecord $class */",
"$",
"class",
"=",
"Model",
"::",
"findIdentity",
"(",
"$",
"this",
"->",
"model_class",
")",
";",
"if",
"(",
"$",
"class",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_communication'",
",",
"'ERROR_MSG_INVALID_MODEL_ID'",
")",
")",
";",
"}",
"else",
"{",
"$",
"model",
"=",
"$",
"class",
"->",
"name",
";",
"if",
"(",
"$",
"model",
"::",
"find",
"(",
")",
"->",
"where",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"entity_id",
"]",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'net_frenzel_communication'",
",",
"'ERROR_MSG_INVALID_MODEL_ID'",
")",
")",
";",
"}",
"}",
"}"
] |
Model ID validation.
@param string $attribute Attribute name
@param array $params Attribute params
@return mixed
|
[
"Model",
"ID",
"validation",
"."
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/Address.php#L209-L221
|
22,410
|
FrenzelGmbH/cm-address
|
models/Address.php
|
Address.getIPLocation
|
public static function getIPLocation(){
//initialize the browser
$adapter = new GuzzleHttpAdapter();
//create geocoder
$geocoder = new \Geocoder\Provider\FreeGeoIp($adapter);
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$client_ip = $_SERVER['REMOTE_ADDR'];
}
else {
$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $geocoder->geocode($client_ip);
}
|
php
|
public static function getIPLocation(){
//initialize the browser
$adapter = new GuzzleHttpAdapter();
//create geocoder
$geocoder = new \Geocoder\Provider\FreeGeoIp($adapter);
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$client_ip = $_SERVER['REMOTE_ADDR'];
}
else {
$client_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $geocoder->geocode($client_ip);
}
|
[
"public",
"static",
"function",
"getIPLocation",
"(",
")",
"{",
"//initialize the browser",
"$",
"adapter",
"=",
"new",
"GuzzleHttpAdapter",
"(",
")",
";",
"//create geocoder",
"$",
"geocoder",
"=",
"new",
"\\",
"Geocoder",
"\\",
"Provider",
"\\",
"FreeGeoIp",
"(",
"$",
"adapter",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
")",
")",
"{",
"$",
"client_ip",
"=",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
";",
"}",
"else",
"{",
"$",
"client_ip",
"=",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
";",
"}",
"return",
"$",
"geocoder",
"->",
"geocode",
"(",
"$",
"client_ip",
")",
";",
"}"
] |
find the use location based upon his current IP address
@return mixed [description]
|
[
"find",
"the",
"use",
"location",
"based",
"upon",
"his",
"current",
"IP",
"address"
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/Address.php#L251-L266
|
22,411
|
RhubarbPHP/Module.RestApi
|
src/UrlHandlers/RestHandler.php
|
RestHandler.handleInvalidMethod
|
protected function handleInvalidMethod($method)
{
$emptyResponse = new Response();
$emptyResponse->setHeader("HTTP/1.1 405 Method $method Not Allowed", false);
$emptyResponse->setHeader("Allow", implode(", ", $this->getSupportedHttpMethods()));
throw new ForceResponseException($emptyResponse);
}
|
php
|
protected function handleInvalidMethod($method)
{
$emptyResponse = new Response();
$emptyResponse->setHeader("HTTP/1.1 405 Method $method Not Allowed", false);
$emptyResponse->setHeader("Allow", implode(", ", $this->getSupportedHttpMethods()));
throw new ForceResponseException($emptyResponse);
}
|
[
"protected",
"function",
"handleInvalidMethod",
"(",
"$",
"method",
")",
"{",
"$",
"emptyResponse",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"emptyResponse",
"->",
"setHeader",
"(",
"\"HTTP/1.1 405 Method $method Not Allowed\"",
",",
"false",
")",
";",
"$",
"emptyResponse",
"->",
"setHeader",
"(",
"\"Allow\"",
",",
"implode",
"(",
"\", \"",
",",
"$",
"this",
"->",
"getSupportedHttpMethods",
"(",
")",
")",
")",
";",
"throw",
"new",
"ForceResponseException",
"(",
"$",
"emptyResponse",
")",
";",
"}"
] |
Override to handle the case where an HTTP method is unsupported.
This should throw a ForceResponseException
@param $method
@throws \Rhubarb\Crown\Exceptions\ForceResponseException
|
[
"Override",
"to",
"handle",
"the",
"case",
"where",
"an",
"HTTP",
"method",
"is",
"unsupported",
"."
] |
825d2b920caed13811971c5eb2784a94417787bd
|
https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/UrlHandlers/RestHandler.php#L210-L217
|
22,412
|
magium/mcm-redis-factory
|
lib/Factory.php
|
Factory.factory
|
public function factory()
{
$redis = new \Redis();
$host = $this->getConfig()->getValue(self::CONFIG_HOST);
$port = $this->getConfig()->getValue(self::CONFIG_PORT);
$timeout = $this->getConfig()->getValue(self::CONFIG_TIMEOUT);
if ($this->getConfig()->getValueFlag(self::CONFIG_PERSISTENT)) {
$redis->pconnect($host, $port, $timeout);
} else {
$redis->connect($host, $port, $timeout);
}
if ($this->getConfig()->hasValue(self::CONFIG_DATABASE)) {
$redis->select($this->getConfig()->getValue(self::CONFIG_DATABASE));
}
return $redis;
}
|
php
|
public function factory()
{
$redis = new \Redis();
$host = $this->getConfig()->getValue(self::CONFIG_HOST);
$port = $this->getConfig()->getValue(self::CONFIG_PORT);
$timeout = $this->getConfig()->getValue(self::CONFIG_TIMEOUT);
if ($this->getConfig()->getValueFlag(self::CONFIG_PERSISTENT)) {
$redis->pconnect($host, $port, $timeout);
} else {
$redis->connect($host, $port, $timeout);
}
if ($this->getConfig()->hasValue(self::CONFIG_DATABASE)) {
$redis->select($this->getConfig()->getValue(self::CONFIG_DATABASE));
}
return $redis;
}
|
[
"public",
"function",
"factory",
"(",
")",
"{",
"$",
"redis",
"=",
"new",
"\\",
"Redis",
"(",
")",
";",
"$",
"host",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"CONFIG_HOST",
")",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"CONFIG_PORT",
")",
";",
"$",
"timeout",
"=",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"CONFIG_TIMEOUT",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getValueFlag",
"(",
"self",
"::",
"CONFIG_PERSISTENT",
")",
")",
"{",
"$",
"redis",
"->",
"pconnect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
")",
";",
"}",
"else",
"{",
"$",
"redis",
"->",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"hasValue",
"(",
"self",
"::",
"CONFIG_DATABASE",
")",
")",
"{",
"$",
"redis",
"->",
"select",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"getValue",
"(",
"self",
"::",
"CONFIG_DATABASE",
")",
")",
";",
"}",
"return",
"$",
"redis",
";",
"}"
] |
Creates a configured \Redis instance in the object context
@param ConfigInterface $config
@return \Redis
|
[
"Creates",
"a",
"configured",
"\\",
"Redis",
"instance",
"in",
"the",
"object",
"context"
] |
d5881a7d4834cc13d1f569bb2c94c892b3b48e76
|
https://github.com/magium/mcm-redis-factory/blob/d5881a7d4834cc13d1f569bb2c94c892b3b48e76/lib/Factory.php#L38-L56
|
22,413
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CakePHP/dwoo.php
|
DwooView.setTemplateDir
|
public function setTemplateDir($path = VIEW) {
$old = $this->_sv_template_dir;
$this->_sv_template_dir = $path;
return $old;
}
|
php
|
public function setTemplateDir($path = VIEW) {
$old = $this->_sv_template_dir;
$this->_sv_template_dir = $path;
return $old;
}
|
[
"public",
"function",
"setTemplateDir",
"(",
"$",
"path",
"=",
"VIEW",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"_sv_template_dir",
";",
"$",
"this",
"->",
"_sv_template_dir",
"=",
"$",
"path",
";",
"return",
"$",
"old",
";",
"}"
] |
changes the template directory
|
[
"changes",
"the",
"template",
"directory"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CakePHP/dwoo.php#L75-L80
|
22,414
|
stk2k/net-driver
|
src/Http/HttpResponse.php
|
HttpResponse.jsonDecode
|
public function jsonDecode()
{
$json = json_decode($this->body, true);
if ($json===null){
throw new JsonFormatException($this->body);
}
return $json;
}
|
php
|
public function jsonDecode()
{
$json = json_decode($this->body, true);
if ($json===null){
throw new JsonFormatException($this->body);
}
return $json;
}
|
[
"public",
"function",
"jsonDecode",
"(",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"body",
",",
"true",
")",
";",
"if",
"(",
"$",
"json",
"===",
"null",
")",
"{",
"throw",
"new",
"JsonFormatException",
"(",
"$",
"this",
"->",
"body",
")",
";",
"}",
"return",
"$",
"json",
";",
"}"
] |
Decode as JSON
@return array|object
@throws JsonFormatException
|
[
"Decode",
"as",
"JSON"
] |
75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c
|
https://github.com/stk2k/net-driver/blob/75e0bc1a95ba430dd9ed9e69f6a0a5dd8f2e7b1c/src/Http/HttpResponse.php#L82-L89
|
22,415
|
Visithor/visithor
|
src/Visithor/Compiler/Compiler.php
|
Compiler.addFile
|
protected function addFile(
Phar $phar,
SplFileInfo $file,
$strip = true
) {
$path = strtr(str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath()), '\\', '/');
$content = file_get_contents($file);
if ($strip) {
$content = $this->stripWhitespace($content);
} elseif ('LICENSE' === basename($file)) {
$content = "\n" . $content . "\n";
}
if ($path === 'src/Composer/Composer.php') {
$content = str_replace('@package_version@', $this->version, $content);
$content = str_replace('@release_date@', $this->versionDate, $content);
}
$phar->addFromString($path, $content);
return $this;
}
|
php
|
protected function addFile(
Phar $phar,
SplFileInfo $file,
$strip = true
) {
$path = strtr(str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath()), '\\', '/');
$content = file_get_contents($file);
if ($strip) {
$content = $this->stripWhitespace($content);
} elseif ('LICENSE' === basename($file)) {
$content = "\n" . $content . "\n";
}
if ($path === 'src/Composer/Composer.php') {
$content = str_replace('@package_version@', $this->version, $content);
$content = str_replace('@release_date@', $this->versionDate, $content);
}
$phar->addFromString($path, $content);
return $this;
}
|
[
"protected",
"function",
"addFile",
"(",
"Phar",
"$",
"phar",
",",
"SplFileInfo",
"$",
"file",
",",
"$",
"strip",
"=",
"true",
")",
"{",
"$",
"path",
"=",
"strtr",
"(",
"str_replace",
"(",
"dirname",
"(",
"dirname",
"(",
"dirname",
"(",
"__DIR__",
")",
")",
")",
".",
"DIRECTORY_SEPARATOR",
",",
"''",
",",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
",",
"'\\\\'",
",",
"'/'",
")",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"strip",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"stripWhitespace",
"(",
"$",
"content",
")",
";",
"}",
"elseif",
"(",
"'LICENSE'",
"===",
"basename",
"(",
"$",
"file",
")",
")",
"{",
"$",
"content",
"=",
"\"\\n\"",
".",
"$",
"content",
".",
"\"\\n\"",
";",
"}",
"if",
"(",
"$",
"path",
"===",
"'src/Composer/Composer.php'",
")",
"{",
"$",
"content",
"=",
"str_replace",
"(",
"'@package_version@'",
",",
"$",
"this",
"->",
"version",
",",
"$",
"content",
")",
";",
"$",
"content",
"=",
"str_replace",
"(",
"'@release_date@'",
",",
"$",
"this",
"->",
"versionDate",
",",
"$",
"content",
")",
";",
"}",
"$",
"phar",
"->",
"addFromString",
"(",
"$",
"path",
",",
"$",
"content",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a file into the phar package
@param Phar $phar Phar object
@param SplFileInfo $file File to add
@param bool $strip strip
@return Compiler self Object
|
[
"Add",
"a",
"file",
"into",
"the",
"phar",
"package"
] |
201ba2cfc536a0875983c79226947aa20b9f4dca
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Compiler/Compiler.php#L87-L108
|
22,416
|
Visithor/visithor
|
src/Visithor/Compiler/Compiler.php
|
Compiler.addBin
|
protected function addBin(Phar $phar)
{
$content = file_get_contents(__DIR__ . '/../../../bin/visithor');
$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
$phar->addFromString('bin/visithor', $content);
return $this;
}
|
php
|
protected function addBin(Phar $phar)
{
$content = file_get_contents(__DIR__ . '/../../../bin/visithor');
$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
$phar->addFromString('bin/visithor', $content);
return $this;
}
|
[
"protected",
"function",
"addBin",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../../../bin/visithor'",
")",
";",
"$",
"content",
"=",
"preg_replace",
"(",
"'{^#!/usr/bin/env php\\s*}'",
",",
"''",
",",
"$",
"content",
")",
";",
"$",
"phar",
"->",
"addFromString",
"(",
"'bin/visithor'",
",",
"$",
"content",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add bin into Phar
@param Phar $phar Phar
@return Compiler self Object
|
[
"Add",
"bin",
"into",
"Phar"
] |
201ba2cfc536a0875983c79226947aa20b9f4dca
|
https://github.com/Visithor/visithor/blob/201ba2cfc536a0875983c79226947aa20b9f4dca/src/Visithor/Compiler/Compiler.php#L117-L124
|
22,417
|
Smile-SA/CronBundle
|
Cron/CronHandler.php
|
CronHandler.addCron
|
public function addCron(CronInterface $cron, $alias, $priority, $arguments)
{
if (!isset($this->crons[$priority])) {
$this->crons[$priority] = array();
}
$cron->setAlias($alias);
$cron->addArguments($arguments);
$cron->addPriority($priority);
$this->crons[$priority][$alias] = $cron;
}
|
php
|
public function addCron(CronInterface $cron, $alias, $priority, $arguments)
{
if (!isset($this->crons[$priority])) {
$this->crons[$priority] = array();
}
$cron->setAlias($alias);
$cron->addArguments($arguments);
$cron->addPriority($priority);
$this->crons[$priority][$alias] = $cron;
}
|
[
"public",
"function",
"addCron",
"(",
"CronInterface",
"$",
"cron",
",",
"$",
"alias",
",",
"$",
"priority",
",",
"$",
"arguments",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"crons",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"$",
"this",
"->",
"crons",
"[",
"$",
"priority",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"cron",
"->",
"setAlias",
"(",
"$",
"alias",
")",
";",
"$",
"cron",
"->",
"addArguments",
"(",
"$",
"arguments",
")",
";",
"$",
"cron",
"->",
"addPriority",
"(",
"$",
"priority",
")",
";",
"$",
"this",
"->",
"crons",
"[",
"$",
"priority",
"]",
"[",
"$",
"alias",
"]",
"=",
"$",
"cron",
";",
"}"
] |
Add cron to crons list
@param CronInterface $cron cron
@param string $alias cron alias
@param integer $priority cron priority
@param string $arguments cron arguments
|
[
"Add",
"cron",
"to",
"crons",
"list"
] |
3e6d29112915fa957cc04386ba9c6d1fc134d31f
|
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Cron/CronHandler.php#L44-L53
|
22,418
|
42mate/towel
|
src/Towel/Controller/AssetsController.php
|
AssetsController.index
|
public function index($request) {
$application = $request->get('application');
$path = $request->get('path');
if (empty($application) || empty($path)) {
return new Response(
"Not a valid asset",
404
);
}
if (strpos('..', $path) === 0) {
return new Response(
"Only assets will be served",
404
);
}
if ($application !== 'Towel') {
$asset_path = APP_ROOT_DIR . '/Application/' . $application . '/Views/assets/' . $path;
} else {
$asset_path = APP_FW_DIR. '/Views/assets/' . $path;
}
if (!file_exists($asset_path)) {
return new Response(
"Asset does not exists",
404
);
}
$asset_type = mime_content_type($asset_path);
$asset_content = file_get_contents($asset_path);
$asset_info = pathinfo($asset_path);
if (!empty($asset_info['extension']) && in_array($asset_info['extension'], self::$validExtensions)) {
$response = new Response(
$asset_content,
200,
['Content-Type' => self::$extensionTypeMapping[$asset_info['extension']]]
);
//To cache in the client side.
$maxAge = 0;
if (!empty($this->appConfig['assets']['max-age'])) {
$maxAge = $this->appConfig['assets']['max-age'];
}
$response->headers->addCacheControlDirective('max-age', $maxAge);
if (!empty($this->appConfig['assets']['public']) && $this->appConfig['assets']['public'] == true) {
$response->headers->addCacheControlDirective('public', true);
}
return $response;
}
return new Response(
"Not a valid extension",
404
);
}
|
php
|
public function index($request) {
$application = $request->get('application');
$path = $request->get('path');
if (empty($application) || empty($path)) {
return new Response(
"Not a valid asset",
404
);
}
if (strpos('..', $path) === 0) {
return new Response(
"Only assets will be served",
404
);
}
if ($application !== 'Towel') {
$asset_path = APP_ROOT_DIR . '/Application/' . $application . '/Views/assets/' . $path;
} else {
$asset_path = APP_FW_DIR. '/Views/assets/' . $path;
}
if (!file_exists($asset_path)) {
return new Response(
"Asset does not exists",
404
);
}
$asset_type = mime_content_type($asset_path);
$asset_content = file_get_contents($asset_path);
$asset_info = pathinfo($asset_path);
if (!empty($asset_info['extension']) && in_array($asset_info['extension'], self::$validExtensions)) {
$response = new Response(
$asset_content,
200,
['Content-Type' => self::$extensionTypeMapping[$asset_info['extension']]]
);
//To cache in the client side.
$maxAge = 0;
if (!empty($this->appConfig['assets']['max-age'])) {
$maxAge = $this->appConfig['assets']['max-age'];
}
$response->headers->addCacheControlDirective('max-age', $maxAge);
if (!empty($this->appConfig['assets']['public']) && $this->appConfig['assets']['public'] == true) {
$response->headers->addCacheControlDirective('public', true);
}
return $response;
}
return new Response(
"Not a valid extension",
404
);
}
|
[
"public",
"function",
"index",
"(",
"$",
"request",
")",
"{",
"$",
"application",
"=",
"$",
"request",
"->",
"get",
"(",
"'application'",
")",
";",
"$",
"path",
"=",
"$",
"request",
"->",
"get",
"(",
"'path'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"application",
")",
"||",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"return",
"new",
"Response",
"(",
"\"Not a valid asset\"",
",",
"404",
")",
";",
"}",
"if",
"(",
"strpos",
"(",
"'..'",
",",
"$",
"path",
")",
"===",
"0",
")",
"{",
"return",
"new",
"Response",
"(",
"\"Only assets will be served\"",
",",
"404",
")",
";",
"}",
"if",
"(",
"$",
"application",
"!==",
"'Towel'",
")",
"{",
"$",
"asset_path",
"=",
"APP_ROOT_DIR",
".",
"'/Application/'",
".",
"$",
"application",
".",
"'/Views/assets/'",
".",
"$",
"path",
";",
"}",
"else",
"{",
"$",
"asset_path",
"=",
"APP_FW_DIR",
".",
"'/Views/assets/'",
".",
"$",
"path",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"asset_path",
")",
")",
"{",
"return",
"new",
"Response",
"(",
"\"Asset does not exists\"",
",",
"404",
")",
";",
"}",
"$",
"asset_type",
"=",
"mime_content_type",
"(",
"$",
"asset_path",
")",
";",
"$",
"asset_content",
"=",
"file_get_contents",
"(",
"$",
"asset_path",
")",
";",
"$",
"asset_info",
"=",
"pathinfo",
"(",
"$",
"asset_path",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"asset_info",
"[",
"'extension'",
"]",
")",
"&&",
"in_array",
"(",
"$",
"asset_info",
"[",
"'extension'",
"]",
",",
"self",
"::",
"$",
"validExtensions",
")",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"asset_content",
",",
"200",
",",
"[",
"'Content-Type'",
"=>",
"self",
"::",
"$",
"extensionTypeMapping",
"[",
"$",
"asset_info",
"[",
"'extension'",
"]",
"]",
"]",
")",
";",
"//To cache in the client side.",
"$",
"maxAge",
"=",
"0",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"appConfig",
"[",
"'assets'",
"]",
"[",
"'max-age'",
"]",
")",
")",
"{",
"$",
"maxAge",
"=",
"$",
"this",
"->",
"appConfig",
"[",
"'assets'",
"]",
"[",
"'max-age'",
"]",
";",
"}",
"$",
"response",
"->",
"headers",
"->",
"addCacheControlDirective",
"(",
"'max-age'",
",",
"$",
"maxAge",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"appConfig",
"[",
"'assets'",
"]",
"[",
"'public'",
"]",
")",
"&&",
"$",
"this",
"->",
"appConfig",
"[",
"'assets'",
"]",
"[",
"'public'",
"]",
"==",
"true",
")",
"{",
"$",
"response",
"->",
"headers",
"->",
"addCacheControlDirective",
"(",
"'public'",
",",
"true",
")",
";",
"}",
"return",
"$",
"response",
";",
"}",
"return",
"new",
"Response",
"(",
"\"Not a valid extension\"",
",",
"404",
")",
";",
"}"
] |
Serves assets from the Application directory.
To use this controller in your template use the function asset_url to get a valid url
for this controller.
@param $request
@return string|Response
|
[
"Serves",
"assets",
"from",
"the",
"Application",
"directory",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/AssetsController.php#L33-L93
|
22,419
|
GrupaZero/social
|
src/Gzero/Repository/SocialRepository.php
|
SocialRepository.createNewUser
|
public function createNewUser($serviceName, AbstractUser $response)
{
$data = $this->parseServiceResponse($response);
$existingUser = $this->userRepo->getByEmail($data['email']);
// duplicated user verification
if ($existingUser === null) {
$data['password'] = str_random(40);
$user = $this->userRepo->create($data);
// create relation for new user and social integration
$this->addSocialRelation($user, $serviceName, $response);
return $user;
} else {
session()->put('url.intended', route('register'));
throw new SocialException(
trans('gzero-social::common.email_already_in_use_message', ['service_name' => title_case($serviceName)])
);
}
}
|
php
|
public function createNewUser($serviceName, AbstractUser $response)
{
$data = $this->parseServiceResponse($response);
$existingUser = $this->userRepo->getByEmail($data['email']);
// duplicated user verification
if ($existingUser === null) {
$data['password'] = str_random(40);
$user = $this->userRepo->create($data);
// create relation for new user and social integration
$this->addSocialRelation($user, $serviceName, $response);
return $user;
} else {
session()->put('url.intended', route('register'));
throw new SocialException(
trans('gzero-social::common.email_already_in_use_message', ['service_name' => title_case($serviceName)])
);
}
}
|
[
"public",
"function",
"createNewUser",
"(",
"$",
"serviceName",
",",
"AbstractUser",
"$",
"response",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"parseServiceResponse",
"(",
"$",
"response",
")",
";",
"$",
"existingUser",
"=",
"$",
"this",
"->",
"userRepo",
"->",
"getByEmail",
"(",
"$",
"data",
"[",
"'email'",
"]",
")",
";",
"// duplicated user verification",
"if",
"(",
"$",
"existingUser",
"===",
"null",
")",
"{",
"$",
"data",
"[",
"'password'",
"]",
"=",
"str_random",
"(",
"40",
")",
";",
"$",
"user",
"=",
"$",
"this",
"->",
"userRepo",
"->",
"create",
"(",
"$",
"data",
")",
";",
"// create relation for new user and social integration",
"$",
"this",
"->",
"addSocialRelation",
"(",
"$",
"user",
",",
"$",
"serviceName",
",",
"$",
"response",
")",
";",
"return",
"$",
"user",
";",
"}",
"else",
"{",
"session",
"(",
")",
"->",
"put",
"(",
"'url.intended'",
",",
"route",
"(",
"'register'",
")",
")",
";",
"throw",
"new",
"SocialException",
"(",
"trans",
"(",
"'gzero-social::common.email_already_in_use_message'",
",",
"[",
"'service_name'",
"=>",
"title_case",
"(",
"$",
"serviceName",
")",
"]",
")",
")",
";",
"}",
"}"
] |
Function creates new user based on social service response and create relation with social integration in database.
@param $serviceName string name of social service
@param $response AbstractUser response data
@return User
@throws SocialException
|
[
"Function",
"creates",
"new",
"user",
"based",
"on",
"social",
"service",
"response",
"and",
"create",
"relation",
"with",
"social",
"integration",
"in",
"database",
"."
] |
f7cbf50765bd228010a2c61d950f915828306cf7
|
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Repository/SocialRepository.php#L92-L109
|
22,420
|
GrupaZero/social
|
src/Gzero/Repository/SocialRepository.php
|
SocialRepository.addUserSocialAccount
|
public function addUserSocialAccount(User $user, $serviceName, AbstractUser $response)
{
$user->has_social_integrations = true;
$user->save();
// create relation for new user and social integration
$this->addSocialRelation($user, $serviceName, $response);
return $user;
}
|
php
|
public function addUserSocialAccount(User $user, $serviceName, AbstractUser $response)
{
$user->has_social_integrations = true;
$user->save();
// create relation for new user and social integration
$this->addSocialRelation($user, $serviceName, $response);
return $user;
}
|
[
"public",
"function",
"addUserSocialAccount",
"(",
"User",
"$",
"user",
",",
"$",
"serviceName",
",",
"AbstractUser",
"$",
"response",
")",
"{",
"$",
"user",
"->",
"has_social_integrations",
"=",
"true",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"// create relation for new user and social integration",
"$",
"this",
"->",
"addSocialRelation",
"(",
"$",
"user",
",",
"$",
"serviceName",
",",
"$",
"response",
")",
";",
"return",
"$",
"user",
";",
"}"
] |
Function adds new social account for existing user.
@param $user User user entity
@param $serviceName string name of social service
@param $response AbstractUser response data
@return User
|
[
"Function",
"adds",
"new",
"social",
"account",
"for",
"existing",
"user",
"."
] |
f7cbf50765bd228010a2c61d950f915828306cf7
|
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Repository/SocialRepository.php#L120-L127
|
22,421
|
GrupaZero/social
|
src/Gzero/Repository/SocialRepository.php
|
SocialRepository.addSocialRelation
|
public function addSocialRelation(User $user, $serviceName, AbstractUser $response)
{
// create relation for new user and social integration
return $this->newQB()->insert(
[
'user_id' => $user->id,
'social_id' => $serviceName . '_' . $response->id,
'created_at' => \DB::raw('NOW()')
]
);
}
|
php
|
public function addSocialRelation(User $user, $serviceName, AbstractUser $response)
{
// create relation for new user and social integration
return $this->newQB()->insert(
[
'user_id' => $user->id,
'social_id' => $serviceName . '_' . $response->id,
'created_at' => \DB::raw('NOW()')
]
);
}
|
[
"public",
"function",
"addSocialRelation",
"(",
"User",
"$",
"user",
",",
"$",
"serviceName",
",",
"AbstractUser",
"$",
"response",
")",
"{",
"// create relation for new user and social integration",
"return",
"$",
"this",
"->",
"newQB",
"(",
")",
"->",
"insert",
"(",
"[",
"'user_id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'social_id'",
"=>",
"$",
"serviceName",
".",
"'_'",
".",
"$",
"response",
"->",
"id",
",",
"'created_at'",
"=>",
"\\",
"DB",
"::",
"raw",
"(",
"'NOW()'",
")",
"]",
")",
";",
"}"
] |
Function creates relation for given user and social integration.
@param $user User user entity
@param $serviceName string name of social service
@param $response AbstractUser response data
@return mixed
|
[
"Function",
"creates",
"relation",
"for",
"given",
"user",
"and",
"social",
"integration",
"."
] |
f7cbf50765bd228010a2c61d950f915828306cf7
|
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Repository/SocialRepository.php#L138-L148
|
22,422
|
GrupaZero/social
|
src/Gzero/Repository/SocialRepository.php
|
SocialRepository.parseServiceResponse
|
private function parseServiceResponse(AbstractUser $response)
{
$userData = [
'has_social_integrations' => true,
'nick' => $response->getNickname()
];
// set user email if exists (twitter returns as null)
if ($response->getEmail()) {
$userData['email'] = $response->getEmail();
} else {
$userData['email'] = uniqid('social_', true); // set unique email placeholder
}
// set user first and last name
$name = explode(" ", $response->getName());
if (count($name) >= 2) {
$userData['first_name'] = $name[0];
$userData['last_name'] = $name[1];
}
return $userData;
}
|
php
|
private function parseServiceResponse(AbstractUser $response)
{
$userData = [
'has_social_integrations' => true,
'nick' => $response->getNickname()
];
// set user email if exists (twitter returns as null)
if ($response->getEmail()) {
$userData['email'] = $response->getEmail();
} else {
$userData['email'] = uniqid('social_', true); // set unique email placeholder
}
// set user first and last name
$name = explode(" ", $response->getName());
if (count($name) >= 2) {
$userData['first_name'] = $name[0];
$userData['last_name'] = $name[1];
}
return $userData;
}
|
[
"private",
"function",
"parseServiceResponse",
"(",
"AbstractUser",
"$",
"response",
")",
"{",
"$",
"userData",
"=",
"[",
"'has_social_integrations'",
"=>",
"true",
",",
"'nick'",
"=>",
"$",
"response",
"->",
"getNickname",
"(",
")",
"]",
";",
"// set user email if exists (twitter returns as null)",
"if",
"(",
"$",
"response",
"->",
"getEmail",
"(",
")",
")",
"{",
"$",
"userData",
"[",
"'email'",
"]",
"=",
"$",
"response",
"->",
"getEmail",
"(",
")",
";",
"}",
"else",
"{",
"$",
"userData",
"[",
"'email'",
"]",
"=",
"uniqid",
"(",
"'social_'",
",",
"true",
")",
";",
"// set unique email placeholder",
"}",
"// set user first and last name",
"$",
"name",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"response",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"name",
")",
">=",
"2",
")",
"{",
"$",
"userData",
"[",
"'first_name'",
"]",
"=",
"$",
"name",
"[",
"0",
"]",
";",
"$",
"userData",
"[",
"'last_name'",
"]",
"=",
"$",
"name",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"userData",
";",
"}"
] |
Function parses social service response and prepares user data to insert to database.
@param $response AbstractUser response data
@return array parsed user data for database insertion
|
[
"Function",
"parses",
"social",
"service",
"response",
"and",
"prepares",
"user",
"data",
"to",
"insert",
"to",
"database",
"."
] |
f7cbf50765bd228010a2c61d950f915828306cf7
|
https://github.com/GrupaZero/social/blob/f7cbf50765bd228010a2c61d950f915828306cf7/src/Gzero/Repository/SocialRepository.php#L167-L187
|
22,423
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/FileIo.php
|
FileIo.executeQueryCopy
|
public function executeQueryCopy(Transformation $transformation)
{
$path = $transformation->getSourceAsPath();
if (!is_readable($path)) {
throw new Exception('Unable to read the source file: ' . $path);
}
if (!is_writable($transformation->getTransformer()->getTarget())) {
throw new Exception('Unable to write to: ' . dirname($transformation->getArtifact()));
}
$filesystem = new Filesystem();
if (is_file($path)) {
$filesystem->copy($path, $transformation->getArtifact(), true);
} else {
$filesystem->mirror($path, $transformation->getArtifact(), null, array('override' => true));
}
}
|
php
|
public function executeQueryCopy(Transformation $transformation)
{
$path = $transformation->getSourceAsPath();
if (!is_readable($path)) {
throw new Exception('Unable to read the source file: ' . $path);
}
if (!is_writable($transformation->getTransformer()->getTarget())) {
throw new Exception('Unable to write to: ' . dirname($transformation->getArtifact()));
}
$filesystem = new Filesystem();
if (is_file($path)) {
$filesystem->copy($path, $transformation->getArtifact(), true);
} else {
$filesystem->mirror($path, $transformation->getArtifact(), null, array('override' => true));
}
}
|
[
"public",
"function",
"executeQueryCopy",
"(",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"path",
"=",
"$",
"transformation",
"->",
"getSourceAsPath",
"(",
")",
";",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to read the source file: '",
".",
"$",
"path",
")",
";",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to write to: '",
".",
"dirname",
"(",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
")",
")",
";",
"}",
"$",
"filesystem",
"=",
"new",
"Filesystem",
"(",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"$",
"filesystem",
"->",
"copy",
"(",
"$",
"path",
",",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"filesystem",
"->",
"mirror",
"(",
"$",
"path",
",",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
",",
"null",
",",
"array",
"(",
"'override'",
"=>",
"true",
")",
")",
";",
"}",
"}"
] |
Copies files or folders to the Artifact location.
@param Transformation $transformation Transformation to use as data source.
@throws Exception
@return void
|
[
"Copies",
"files",
"or",
"folders",
"to",
"the",
"Artifact",
"location",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/FileIo.php#L68-L85
|
22,424
|
trunda/SmfMenu
|
src/Smf/Menu/Config/Extension.php
|
Extension.loadConfiguration
|
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults);
// Create instance of extension
$menuFactory = $builder->addDefinition($this->prefix('extension'))
->setClass('Smf\Menu\MenuExtension');
// Create instance of menufactory
$menuFactory = $builder->addDefinition($this->prefix('factory'))
->addSetup('addExtension', array($this->prefix('@extension')))
->setClass('Knp\Menu\MenuFactory');
// Create renderers manager
$rendererManager = $builder->addDefinition($this->prefix('rendererManager'))
->setClass('Smf\Menu\Renderer\Manager')
->addSetup(get_called_class() . '::setupRenderers', array('@self', '@container'))
->addSetup('setDefaultRenderer', array($config['defaultRenderer']));;
// Create a factory for control
$builder->addDefinition($this->prefix('controlFactory'))
->setClass('Smf\Menu\Control\Factory', array($menuFactory, $rendererManager));
// Matcher
$matcher = $builder->addDefinition($this->prefix('matcher'))
->addSetup(get_called_class() . '::setupVoters', array('@self', '@container'))
->setClass('Smf\Menu\Matcher\Matcher');
// Create a default renderers
$renderers = array(
'Smf\Menu\Renderer\ListRenderer',
'Smf\Menu\Renderer\BootstrapNavRenderer',
);
foreach ($renderers as $renderer) {
$name = explode('\\', $renderer);
$name = lcfirst(preg_replace('#Renderer$#', '', end($name)));
$builder->addDefinition($this->prefix('renderer_' . $name))
->setClass($renderer, array($matcher))
->addTag(self::RENDERER_TAG_NAME, $name);
}
// Create default voter
$builder->addDefinition($this->prefix('presenterVoter'))
->setClass('Smf\Menu\Matcher\Voter\PresenterVoter')
->addTag(self::VOTER_TAG_NAME);
}
|
php
|
public function loadConfiguration()
{
$builder = $this->getContainerBuilder();
$config = $this->getConfig($this->defaults);
// Create instance of extension
$menuFactory = $builder->addDefinition($this->prefix('extension'))
->setClass('Smf\Menu\MenuExtension');
// Create instance of menufactory
$menuFactory = $builder->addDefinition($this->prefix('factory'))
->addSetup('addExtension', array($this->prefix('@extension')))
->setClass('Knp\Menu\MenuFactory');
// Create renderers manager
$rendererManager = $builder->addDefinition($this->prefix('rendererManager'))
->setClass('Smf\Menu\Renderer\Manager')
->addSetup(get_called_class() . '::setupRenderers', array('@self', '@container'))
->addSetup('setDefaultRenderer', array($config['defaultRenderer']));;
// Create a factory for control
$builder->addDefinition($this->prefix('controlFactory'))
->setClass('Smf\Menu\Control\Factory', array($menuFactory, $rendererManager));
// Matcher
$matcher = $builder->addDefinition($this->prefix('matcher'))
->addSetup(get_called_class() . '::setupVoters', array('@self', '@container'))
->setClass('Smf\Menu\Matcher\Matcher');
// Create a default renderers
$renderers = array(
'Smf\Menu\Renderer\ListRenderer',
'Smf\Menu\Renderer\BootstrapNavRenderer',
);
foreach ($renderers as $renderer) {
$name = explode('\\', $renderer);
$name = lcfirst(preg_replace('#Renderer$#', '', end($name)));
$builder->addDefinition($this->prefix('renderer_' . $name))
->setClass($renderer, array($matcher))
->addTag(self::RENDERER_TAG_NAME, $name);
}
// Create default voter
$builder->addDefinition($this->prefix('presenterVoter'))
->setClass('Smf\Menu\Matcher\Voter\PresenterVoter')
->addTag(self::VOTER_TAG_NAME);
}
|
[
"public",
"function",
"loadConfiguration",
"(",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"getContainerBuilder",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"$",
"this",
"->",
"defaults",
")",
";",
"// Create instance of extension",
"$",
"menuFactory",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'extension'",
")",
")",
"->",
"setClass",
"(",
"'Smf\\Menu\\MenuExtension'",
")",
";",
"// Create instance of menufactory",
"$",
"menuFactory",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'factory'",
")",
")",
"->",
"addSetup",
"(",
"'addExtension'",
",",
"array",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'@extension'",
")",
")",
")",
"->",
"setClass",
"(",
"'Knp\\Menu\\MenuFactory'",
")",
";",
"// Create renderers manager",
"$",
"rendererManager",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'rendererManager'",
")",
")",
"->",
"setClass",
"(",
"'Smf\\Menu\\Renderer\\Manager'",
")",
"->",
"addSetup",
"(",
"get_called_class",
"(",
")",
".",
"'::setupRenderers'",
",",
"array",
"(",
"'@self'",
",",
"'@container'",
")",
")",
"->",
"addSetup",
"(",
"'setDefaultRenderer'",
",",
"array",
"(",
"$",
"config",
"[",
"'defaultRenderer'",
"]",
")",
")",
";",
";",
"// Create a factory for control",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'controlFactory'",
")",
")",
"->",
"setClass",
"(",
"'Smf\\Menu\\Control\\Factory'",
",",
"array",
"(",
"$",
"menuFactory",
",",
"$",
"rendererManager",
")",
")",
";",
"// Matcher",
"$",
"matcher",
"=",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'matcher'",
")",
")",
"->",
"addSetup",
"(",
"get_called_class",
"(",
")",
".",
"'::setupVoters'",
",",
"array",
"(",
"'@self'",
",",
"'@container'",
")",
")",
"->",
"setClass",
"(",
"'Smf\\Menu\\Matcher\\Matcher'",
")",
";",
"// Create a default renderers",
"$",
"renderers",
"=",
"array",
"(",
"'Smf\\Menu\\Renderer\\ListRenderer'",
",",
"'Smf\\Menu\\Renderer\\BootstrapNavRenderer'",
",",
")",
";",
"foreach",
"(",
"$",
"renderers",
"as",
"$",
"renderer",
")",
"{",
"$",
"name",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"renderer",
")",
";",
"$",
"name",
"=",
"lcfirst",
"(",
"preg_replace",
"(",
"'#Renderer$#'",
",",
"''",
",",
"end",
"(",
"$",
"name",
")",
")",
")",
";",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'renderer_'",
".",
"$",
"name",
")",
")",
"->",
"setClass",
"(",
"$",
"renderer",
",",
"array",
"(",
"$",
"matcher",
")",
")",
"->",
"addTag",
"(",
"self",
"::",
"RENDERER_TAG_NAME",
",",
"$",
"name",
")",
";",
"}",
"// Create default voter",
"$",
"builder",
"->",
"addDefinition",
"(",
"$",
"this",
"->",
"prefix",
"(",
"'presenterVoter'",
")",
")",
"->",
"setClass",
"(",
"'Smf\\Menu\\Matcher\\Voter\\PresenterVoter'",
")",
"->",
"addTag",
"(",
"self",
"::",
"VOTER_TAG_NAME",
")",
";",
"}"
] |
Configuration - container building
|
[
"Configuration",
"-",
"container",
"building"
] |
739e74fb664c1f018b4a74142bd28d20c004bac6
|
https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Config/Extension.php#L37-L83
|
22,425
|
trunda/SmfMenu
|
src/Smf/Menu/Config/Extension.php
|
Extension.register
|
public static function register(Nette\Configurator $configurator, $name = self::DEFAULT_EXTENSION_NAME)
{
$class = get_called_class();
$configurator->onCompile[] = function (Nette\Configurator $configurator, Nette\DI\Compiler $compiler) use ($class, $name) {
$compiler->addExtension($name, new $class);
};
}
|
php
|
public static function register(Nette\Configurator $configurator, $name = self::DEFAULT_EXTENSION_NAME)
{
$class = get_called_class();
$configurator->onCompile[] = function (Nette\Configurator $configurator, Nette\DI\Compiler $compiler) use ($class, $name) {
$compiler->addExtension($name, new $class);
};
}
|
[
"public",
"static",
"function",
"register",
"(",
"Nette",
"\\",
"Configurator",
"$",
"configurator",
",",
"$",
"name",
"=",
"self",
"::",
"DEFAULT_EXTENSION_NAME",
")",
"{",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"$",
"configurator",
"->",
"onCompile",
"[",
"]",
"=",
"function",
"(",
"Nette",
"\\",
"Configurator",
"$",
"configurator",
",",
"Nette",
"\\",
"DI",
"\\",
"Compiler",
"$",
"compiler",
")",
"use",
"(",
"$",
"class",
",",
"$",
"name",
")",
"{",
"$",
"compiler",
"->",
"addExtension",
"(",
"$",
"name",
",",
"new",
"$",
"class",
")",
";",
"}",
";",
"}"
] |
Register extension to compiler.
@param Configurator $configurator
@param string $name
|
[
"Register",
"extension",
"to",
"compiler",
"."
] |
739e74fb664c1f018b4a74142bd28d20c004bac6
|
https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Config/Extension.php#L113-L119
|
22,426
|
rhosocial/yii2-user
|
models/invitation/registration/UserInvitationRegistrationTrait.php
|
UserInvitationRegistrationTrait.hasEnabledInvitationRegistration
|
public function hasEnabledInvitationRegistration()
{
if ($this->invitationRegistrationClass === false || !is_string($this->invitationRegistrationClass) || !class_exists($this->invitationRegistrationClass)) {
return false;
}
return true;
}
|
php
|
public function hasEnabledInvitationRegistration()
{
if ($this->invitationRegistrationClass === false || !is_string($this->invitationRegistrationClass) || !class_exists($this->invitationRegistrationClass)) {
return false;
}
return true;
}
|
[
"public",
"function",
"hasEnabledInvitationRegistration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"invitationRegistrationClass",
"===",
"false",
"||",
"!",
"is_string",
"(",
"$",
"this",
"->",
"invitationRegistrationClass",
")",
"||",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"invitationRegistrationClass",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check whether this user enables the invitation from registration feature or not.
@return boolean
|
[
"Check",
"whether",
"this",
"user",
"enables",
"the",
"invitation",
"from",
"registration",
"feature",
"or",
"not",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/invitation/registration/UserInvitationRegistrationTrait.php#L86-L92
|
22,427
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.setColumn
|
public function setColumn($name, $value)
{
foreach ($this->entities as $entity) {
$entity->set($name, $value);
}
return $this;
}
|
php
|
public function setColumn($name, $value)
{
foreach ($this->entities as $entity) {
$entity->set($name, $value);
}
return $this;
}
|
[
"public",
"function",
"setColumn",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"entity",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the value of a column for all entities in this
collection. Setter methods will be called.
@param string $name The name of the column
@param mixed $value The value
@return EntityCollection This collection
|
[
"Set",
"the",
"value",
"of",
"a",
"column",
"for",
"all",
"entities",
"in",
"this",
"collection",
".",
"Setter",
"methods",
"will",
"be",
"called",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L68-L75
|
22,428
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.setColumnRaw
|
public function setColumnRaw($name, $value)
{
foreach ($this->entities as $entity) {
$entity->setRaw($name, $value);
}
return $this;
}
|
php
|
public function setColumnRaw($name, $value)
{
foreach ($this->entities as $entity) {
$entity->setRaw($name, $value);
}
return $this;
}
|
[
"public",
"function",
"setColumnRaw",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"entity",
"->",
"setRaw",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the value of a column for all entities in this
collection. Setter methods will not be called.
@param string $name The name of the column
@param mixed $value The value
@return EntityCollection This collection
|
[
"Set",
"the",
"value",
"of",
"a",
"column",
"for",
"all",
"entities",
"in",
"this",
"collection",
".",
"Setter",
"methods",
"will",
"not",
"be",
"called",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L85-L92
|
22,429
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.getColumn
|
public function getColumn($name)
{
$results = [];
foreach ($this->entities as $entity) {
$results[] = $entity->get($name);
}
return $results;
}
|
php
|
public function getColumn($name)
{
$results = [];
foreach ($this->entities as $entity) {
$results[] = $entity->get($name);
}
return $results;
}
|
[
"public",
"function",
"getColumn",
"(",
"$",
"name",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"entity",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Get the values of a single column from all entities in this
collection. Getter methods will be called.
@param string $name The name of the column
@return array A list of values
|
[
"Get",
"the",
"values",
"of",
"a",
"single",
"column",
"from",
"all",
"entities",
"in",
"this",
"collection",
".",
"Getter",
"methods",
"will",
"be",
"called",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L101-L109
|
22,430
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.getColumnRaw
|
public function getColumnRaw($name)
{
$results = [];
foreach ($this->entities as $entity) {
$results[] = $entity->getRaw($name);
}
return $results;
}
|
php
|
public function getColumnRaw($name)
{
$results = [];
foreach ($this->entities as $entity) {
$results[] = $entity->getRaw($name);
}
return $results;
}
|
[
"public",
"function",
"getColumnRaw",
"(",
"$",
"name",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"entity",
"->",
"getRaw",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Get the values of a single column from all entities in this
collection. Getter methods will not be called.
@param string $name The name of the column
@return array A list of values
|
[
"Get",
"the",
"values",
"of",
"a",
"single",
"column",
"from",
"all",
"entities",
"in",
"this",
"collection",
".",
"Getter",
"methods",
"will",
"not",
"be",
"called",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L118-L126
|
22,431
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.getOne
|
public function getOne($column, $value, $strict = true)
{
if ($strict) {
foreach ($this->entities as $entity) {
if ($entity->get($column) === $value) {
return $entity;
}
}
} else {
foreach ($this->entities as $entity) {
if ($entity->get($column) == $value) {
return $entity;
}
}
}
return;
}
|
php
|
public function getOne($column, $value, $strict = true)
{
if ($strict) {
foreach ($this->entities as $entity) {
if ($entity->get($column) === $value) {
return $entity;
}
}
} else {
foreach ($this->entities as $entity) {
if ($entity->get($column) == $value) {
return $entity;
}
}
}
return;
}
|
[
"public",
"function",
"getOne",
"(",
"$",
"column",
",",
"$",
"value",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"get",
"(",
"$",
"column",
")",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"entity",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"get",
"(",
"$",
"column",
")",
"==",
"$",
"value",
")",
"{",
"return",
"$",
"entity",
";",
"}",
"}",
"}",
"return",
";",
"}"
] |
Get a single Entity from this collection where column =
value. If more than one Entity is matched, the first will be
returned. If no Entity is matched, null will be returned.
@param string $column
@param string $value
@param bool $strict use strict comparison when comparing values
@return mixed Entity or NULL
|
[
"Get",
"a",
"single",
"Entity",
"from",
"this",
"collection",
"where",
"column",
"=",
"value",
".",
"If",
"more",
"than",
"one",
"Entity",
"is",
"matched",
"the",
"first",
"will",
"be",
"returned",
".",
"If",
"no",
"Entity",
"is",
"matched",
"null",
"will",
"be",
"returned",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L138-L155
|
22,432
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.getRandom
|
public function getRandom()
{
return empty($this->entities) ? null : $this->entities[array_rand($this->entities)];
}
|
php
|
public function getRandom()
{
return empty($this->entities) ? null : $this->entities[array_rand($this->entities)];
}
|
[
"public",
"function",
"getRandom",
"(",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"entities",
")",
"?",
"null",
":",
"$",
"this",
"->",
"entities",
"[",
"array_rand",
"(",
"$",
"this",
"->",
"entities",
")",
"]",
";",
"}"
] |
Get a random Entity from this collection, or null if the
collection is empty.
@return Entity|null
|
[
"Get",
"a",
"random",
"Entity",
"from",
"this",
"collection",
"or",
"null",
"if",
"the",
"collection",
"is",
"empty",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L163-L166
|
22,433
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.remove
|
public function remove($column, $value)
{
foreach ($this->entities as $index => $entity) {
if ($entity->get($column) === $value) {
//remove the entity and reset the keys
unset($this->entities[$index]);
$this->entities = array_values($this->entities);
return $entity;
}
}
return;
}
|
php
|
public function remove($column, $value)
{
foreach ($this->entities as $index => $entity) {
if ($entity->get($column) === $value) {
//remove the entity and reset the keys
unset($this->entities[$index]);
$this->entities = array_values($this->entities);
return $entity;
}
}
return;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"column",
",",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"entities",
"as",
"$",
"index",
"=>",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"entity",
"->",
"get",
"(",
"$",
"column",
")",
"===",
"$",
"value",
")",
"{",
"//remove the entity and reset the keys",
"unset",
"(",
"$",
"this",
"->",
"entities",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"entities",
"=",
"array_values",
"(",
"$",
"this",
"->",
"entities",
")",
";",
"return",
"$",
"entity",
";",
"}",
"}",
"return",
";",
"}"
] |
Remove a single Entity from this collection where column =
value. If more than one Entity is matched, the first will be
removed and returned. If no Entity is matched, null will be
returned.
@param string $column
@param string $value
@return mixed The removed Entity or NULL
|
[
"Remove",
"a",
"single",
"Entity",
"from",
"this",
"collection",
"where",
"column",
"=",
"value",
".",
"If",
"more",
"than",
"one",
"Entity",
"is",
"matched",
"the",
"first",
"will",
"be",
"removed",
"and",
"returned",
".",
"If",
"no",
"Entity",
"is",
"matched",
"null",
"will",
"be",
"returned",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L178-L191
|
22,434
|
glynnforrest/active-doctrine
|
src/ActiveDoctrine/Entity/EntityCollection.php
|
EntityCollection.removeRandom
|
public function removeRandom()
{
$index = array_rand($this->entities);
$entity = $this->entities[$index];
unset($this->entities[$index]);
return $entity;
}
|
php
|
public function removeRandom()
{
$index = array_rand($this->entities);
$entity = $this->entities[$index];
unset($this->entities[$index]);
return $entity;
}
|
[
"public",
"function",
"removeRandom",
"(",
")",
"{",
"$",
"index",
"=",
"array_rand",
"(",
"$",
"this",
"->",
"entities",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"entities",
"[",
"$",
"index",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"entities",
"[",
"$",
"index",
"]",
")",
";",
"return",
"$",
"entity",
";",
"}"
] |
Remove a random Entity from this collection, or null if the
collection is empty.
@return Entity|null
|
[
"Remove",
"a",
"random",
"Entity",
"from",
"this",
"collection",
"or",
"null",
"if",
"the",
"collection",
"is",
"empty",
"."
] |
fcf8c434c7df4704966107bf9a95c005a0b37168
|
https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Entity/EntityCollection.php#L199-L206
|
22,435
|
comodojo/daemon
|
src/Comodojo/Daemon/Utils/ProcessTools.php
|
ProcessTools.term
|
public static function term($pid, $lagger_timeout = 0, $signal = SIGTERM) {
$kill_time = time() + $lagger_timeout;
// $term = posix_kill($pid, $signal);
$term = self::signal($pid, $signal);
while ( time() < $kill_time ) {
if ( !self::isRunning($pid) ) return $term;
usleep(20000);
}
return self::kill($pid);
}
|
php
|
public static function term($pid, $lagger_timeout = 0, $signal = SIGTERM) {
$kill_time = time() + $lagger_timeout;
// $term = posix_kill($pid, $signal);
$term = self::signal($pid, $signal);
while ( time() < $kill_time ) {
if ( !self::isRunning($pid) ) return $term;
usleep(20000);
}
return self::kill($pid);
}
|
[
"public",
"static",
"function",
"term",
"(",
"$",
"pid",
",",
"$",
"lagger_timeout",
"=",
"0",
",",
"$",
"signal",
"=",
"SIGTERM",
")",
"{",
"$",
"kill_time",
"=",
"time",
"(",
")",
"+",
"$",
"lagger_timeout",
";",
"// $term = posix_kill($pid, $signal);",
"$",
"term",
"=",
"self",
"::",
"signal",
"(",
"$",
"pid",
",",
"$",
"signal",
")",
";",
"while",
"(",
"time",
"(",
")",
"<",
"$",
"kill_time",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isRunning",
"(",
"$",
"pid",
")",
")",
"return",
"$",
"term",
";",
"usleep",
"(",
"20000",
")",
";",
"}",
"return",
"self",
"::",
"kill",
"(",
"$",
"pid",
")",
";",
"}"
] |
Terminate a process, asking PID to terminate or killing it directly.
@param int $pid
@param int $lagger_timeout Timeout to wait before killing process if it refuses to terminate
@param int $signal Signal to send (default to SIGTERM)
@return bool
|
[
"Terminate",
"a",
"process",
"asking",
"PID",
"to",
"terminate",
"or",
"killing",
"it",
"directly",
"."
] |
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
|
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Utils/ProcessTools.php#L32-L48
|
22,436
|
comodojo/daemon
|
src/Comodojo/Daemon/Utils/ProcessTools.php
|
ProcessTools.setNiceness
|
public static function setNiceness($niceness, $pid = null) {
return is_null($pid) ? @proc_nice($niceness) : @pcntl_setpriority($pid, $niceness);
}
|
php
|
public static function setNiceness($niceness, $pid = null) {
return is_null($pid) ? @proc_nice($niceness) : @pcntl_setpriority($pid, $niceness);
}
|
[
"public",
"static",
"function",
"setNiceness",
"(",
"$",
"niceness",
",",
"$",
"pid",
"=",
"null",
")",
"{",
"return",
"is_null",
"(",
"$",
"pid",
")",
"?",
"@",
"proc_nice",
"(",
"$",
"niceness",
")",
":",
"@",
"pcntl_setpriority",
"(",
"$",
"pid",
",",
"$",
"niceness",
")",
";",
"}"
] |
Set niceness of a running process
@param int|null $pid The pid to query, or current process if null
@return bool
|
[
"Set",
"niceness",
"of",
"a",
"running",
"process"
] |
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
|
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Utils/ProcessTools.php#L99-L103
|
22,437
|
titledk/silverstripe-uploaddirrules
|
code/rules/UploadDirRules.php
|
UploadDirRules.calc_base_directory_for_object
|
public static function calc_base_directory_for_object(DataObject $do)
{
//the 2 base options - dataobjects / pages
$str = 'dataobjects';
$ancestry = $do->getClassAncestry();
foreach ($ancestry as $c) {
if ($c == 'SiteTree') {
$str = 'pages';
}
}
//other options
switch ($do->ClassName) {
//case 'Subsite':
// $str = 'subsites';
// break;
case 'SiteConfig':
$str = 'site';
break;
default:
}
return $str;
}
|
php
|
public static function calc_base_directory_for_object(DataObject $do)
{
//the 2 base options - dataobjects / pages
$str = 'dataobjects';
$ancestry = $do->getClassAncestry();
foreach ($ancestry as $c) {
if ($c == 'SiteTree') {
$str = 'pages';
}
}
//other options
switch ($do->ClassName) {
//case 'Subsite':
// $str = 'subsites';
// break;
case 'SiteConfig':
$str = 'site';
break;
default:
}
return $str;
}
|
[
"public",
"static",
"function",
"calc_base_directory_for_object",
"(",
"DataObject",
"$",
"do",
")",
"{",
"//the 2 base options - dataobjects / pages",
"$",
"str",
"=",
"'dataobjects'",
";",
"$",
"ancestry",
"=",
"$",
"do",
"->",
"getClassAncestry",
"(",
")",
";",
"foreach",
"(",
"$",
"ancestry",
"as",
"$",
"c",
")",
"{",
"if",
"(",
"$",
"c",
"==",
"'SiteTree'",
")",
"{",
"$",
"str",
"=",
"'pages'",
";",
"}",
"}",
"//other options",
"switch",
"(",
"$",
"do",
"->",
"ClassName",
")",
"{",
"//case 'Subsite':",
"//\t$str = 'subsites';",
"//\tbreak;",
"case",
"'SiteConfig'",
":",
"$",
"str",
"=",
"'site'",
";",
"break",
";",
"default",
":",
"}",
"return",
"$",
"str",
";",
"}"
] |
Base rules.
@param DataObject $do
@return string
|
[
"Base",
"rules",
"."
] |
ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c
|
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/rules/UploadDirRules.php#L32-L59
|
22,438
|
nabab/bbn
|
src/bbn/db/languages/sqlite.php
|
sqlite.delete_index
|
public function delete_index(string $table, string $key): bool
{
if ( ( $table = $this->table_full_name($table, 1) ) && bbn\str::check_name($key) ){
return (bool)$this->db->query("ALTER TABLE $table DROP INDEX `$key`");
}
return false;
}
|
php
|
public function delete_index(string $table, string $key): bool
{
if ( ( $table = $this->table_full_name($table, 1) ) && bbn\str::check_name($key) ){
return (bool)$this->db->query("ALTER TABLE $table DROP INDEX `$key`");
}
return false;
}
|
[
"public",
"function",
"delete_index",
"(",
"string",
"$",
"table",
",",
"string",
"$",
"key",
")",
":",
"bool",
"{",
"if",
"(",
"(",
"$",
"table",
"=",
"$",
"this",
"->",
"table_full_name",
"(",
"$",
"table",
",",
"1",
")",
")",
"&&",
"bbn",
"\\",
"str",
"::",
"check_name",
"(",
"$",
"key",
")",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"db",
"->",
"query",
"(",
"\"ALTER TABLE $table DROP INDEX `$key`\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Deletes an index
@param null|string $table
@param string $key
@return bool
|
[
"Deletes",
"an",
"index"
] |
439fea2faa0de22fdaae2611833bab8061f40c37
|
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/db/languages/sqlite.php#L979-L985
|
22,439
|
qlake/framework
|
src/Qlake/Routing/Collection.php
|
Collection.addRoute
|
public function addRoute(Route $route)
{
foreach ($route->getMethods() as $method)
{
$this->routes[$method][/*$route->uri*/] = $route;
}
$this->allRoutes[] = $route;
return $this;
}
|
php
|
public function addRoute(Route $route)
{
foreach ($route->getMethods() as $method)
{
$this->routes[$method][/*$route->uri*/] = $route;
}
$this->allRoutes[] = $route;
return $this;
}
|
[
"public",
"function",
"addRoute",
"(",
"Route",
"$",
"route",
")",
"{",
"foreach",
"(",
"$",
"route",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"$",
"method",
"]",
"[",
"/*$route->uri*/",
"]",
"=",
"$",
"route",
";",
"}",
"$",
"this",
"->",
"allRoutes",
"[",
"]",
"=",
"$",
"route",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a Route instans to application routes.
@param Qlake\Routing\Route
@return Qlake\Routing\Route
|
[
"Add",
"a",
"Route",
"instans",
"to",
"application",
"routes",
"."
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Collection.php#L33-L43
|
22,440
|
mridang/magazine
|
src/Magazine/Magazine.php
|
Magazine.rglob
|
protected function rglob($pattern, $excludes = array()) {
$files = array();
foreach (glob($pattern, 0) as $item) {
if (!empty($excludes) && in_array(ltrim($item, '\.\/'), $excludes)) {
$this->trace("Skipping excluded item ./%s", ltrim($item, '\.\/'));
continue;
}
if (is_dir($item)) {
$this->debug("Globbing files in directory %s", $item);
$files = array_merge($files, $this->rglob($item.'/*', $excludes));
} else {
array_push($files, ltrim($item, '\.\/'));
}
}
return $files;
}
|
php
|
protected function rglob($pattern, $excludes = array()) {
$files = array();
foreach (glob($pattern, 0) as $item) {
if (!empty($excludes) && in_array(ltrim($item, '\.\/'), $excludes)) {
$this->trace("Skipping excluded item ./%s", ltrim($item, '\.\/'));
continue;
}
if (is_dir($item)) {
$this->debug("Globbing files in directory %s", $item);
$files = array_merge($files, $this->rglob($item.'/*', $excludes));
} else {
array_push($files, ltrim($item, '\.\/'));
}
}
return $files;
}
|
[
"protected",
"function",
"rglob",
"(",
"$",
"pattern",
",",
"$",
"excludes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"glob",
"(",
"$",
"pattern",
",",
"0",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"excludes",
")",
"&&",
"in_array",
"(",
"ltrim",
"(",
"$",
"item",
",",
"'\\.\\/'",
")",
",",
"$",
"excludes",
")",
")",
"{",
"$",
"this",
"->",
"trace",
"(",
"\"Skipping excluded item ./%s\"",
",",
"ltrim",
"(",
"$",
"item",
",",
"'\\.\\/'",
")",
")",
";",
"continue",
";",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"item",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"\"Globbing files in directory %s\"",
",",
"$",
"item",
")",
";",
"$",
"files",
"=",
"array_merge",
"(",
"$",
"files",
",",
"$",
"this",
"->",
"rglob",
"(",
"$",
"item",
".",
"'/*'",
",",
"$",
"excludes",
")",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"files",
",",
"ltrim",
"(",
"$",
"item",
",",
"'\\.\\/'",
")",
")",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] |
Recursively globs all the files and directories using the given pattern.
If any file or directory exists in the list of excluded items, it is
skipped
@param $pattern string the glob pattern for selecting files and directories
@param array $excludes the array of files and directories to exclude
@return array the array of files and directories matching the glob pattern
|
[
"Recursively",
"globs",
"all",
"the",
"files",
"and",
"directories",
"using",
"the",
"given",
"pattern",
".",
"If",
"any",
"file",
"or",
"directory",
"exists",
"in",
"the",
"list",
"of",
"excluded",
"items",
"it",
"is",
"skipped"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/src/Magazine/Magazine.php#L173-L188
|
22,441
|
mridang/magazine
|
src/Magazine/Magazine.php
|
Magazine.amendDynamicAttributesToJson
|
private function amendDynamicAttributesToJson(array &$json) {
if (!is_null($this->package_version)) {
$json['version'] = array();
$json['version']['release'] = $this->package_version;
}
if (!is_null($this->package_name)) {
$json['name'] = $this->package_name;
}
}
|
php
|
private function amendDynamicAttributesToJson(array &$json) {
if (!is_null($this->package_version)) {
$json['version'] = array();
$json['version']['release'] = $this->package_version;
}
if (!is_null($this->package_name)) {
$json['name'] = $this->package_name;
}
}
|
[
"private",
"function",
"amendDynamicAttributesToJson",
"(",
"array",
"&",
"$",
"json",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"package_version",
")",
")",
"{",
"$",
"json",
"[",
"'version'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"json",
"[",
"'version'",
"]",
"[",
"'release'",
"]",
"=",
"$",
"this",
"->",
"package_version",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"package_name",
")",
")",
"{",
"$",
"json",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"package_name",
";",
"}",
"}"
] |
Adds attributes given from command line to the json
@param array $json array of the json in magazine.json
|
[
"Adds",
"attributes",
"given",
"from",
"command",
"line",
"to",
"the",
"json"
] |
5b3cfecc472c61fde6af63efe62690a30a267a04
|
https://github.com/mridang/magazine/blob/5b3cfecc472c61fde6af63efe62690a30a267a04/src/Magazine/Magazine.php#L233-L241
|
22,442
|
ekuiter/feature-php
|
FeaturePhp/Model/Configuration.php
|
Configuration.getValue
|
public function getValue($feature) {
// side effect: checks for instanceof ValueFeature
$defaultValue = $feature->getDefaultValue();
$values = $this->xmlConfiguration->getValues();
if (array_key_exists($feature->getName(), $values))
return $values[$feature->getName()];
else
return $defaultValue;
}
|
php
|
public function getValue($feature) {
// side effect: checks for instanceof ValueFeature
$defaultValue = $feature->getDefaultValue();
$values = $this->xmlConfiguration->getValues();
if (array_key_exists($feature->getName(), $values))
return $values[$feature->getName()];
else
return $defaultValue;
}
|
[
"public",
"function",
"getValue",
"(",
"$",
"feature",
")",
"{",
"// side effect: checks for instanceof ValueFeature",
"$",
"defaultValue",
"=",
"$",
"feature",
"->",
"getDefaultValue",
"(",
")",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"xmlConfiguration",
"->",
"getValues",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"feature",
"->",
"getName",
"(",
")",
",",
"$",
"values",
")",
")",
"return",
"$",
"values",
"[",
"$",
"feature",
"->",
"getName",
"(",
")",
"]",
";",
"else",
"return",
"$",
"defaultValue",
";",
"}"
] |
Returns the configuration's value for a value feature.
@param ValueFeature $feature
@return string
|
[
"Returns",
"the",
"configuration",
"s",
"value",
"for",
"a",
"value",
"feature",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Configuration.php#L96-L104
|
22,443
|
ekuiter/feature-php
|
FeaturePhp/Model/Configuration.php
|
Configuration.renderAnalysis
|
public function renderAnalysis($productLine = null, $textOnly = false) {
return (new ConfigurationRenderer($this, $productLine))->render($textOnly);
}
|
php
|
public function renderAnalysis($productLine = null, $textOnly = false) {
return (new ConfigurationRenderer($this, $productLine))->render($textOnly);
}
|
[
"public",
"function",
"renderAnalysis",
"(",
"$",
"productLine",
"=",
"null",
",",
"$",
"textOnly",
"=",
"false",
")",
"{",
"return",
"(",
"new",
"ConfigurationRenderer",
"(",
"$",
"this",
",",
"$",
"productLine",
")",
")",
"->",
"render",
"(",
"$",
"textOnly",
")",
";",
"}"
] |
Analyzes the model and configuration by returning a web page.
@param \FeaturePhp\ProductLine\ProductLine $productLine
optional product line to render more information
@param bool $textOnly whether to render text or HTML
@return string
|
[
"Analyzes",
"the",
"model",
"and",
"configuration",
"by",
"returning",
"a",
"web",
"page",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/Configuration.php#L121-L123
|
22,444
|
hametuha/wpametu
|
src/WPametu/UI/Field/Number.php
|
Number.get_field
|
protected function get_field( \WP_Post $post ){
$field = parent::get_field($post);
if( $this->prefix ){
$field = $this->prefix.' '.$field;
}
if( $this->suffix ){
$field .= $this->suffix;
}
return $field;
}
|
php
|
protected function get_field( \WP_Post $post ){
$field = parent::get_field($post);
if( $this->prefix ){
$field = $this->prefix.' '.$field;
}
if( $this->suffix ){
$field .= $this->suffix;
}
return $field;
}
|
[
"protected",
"function",
"get_field",
"(",
"\\",
"WP_Post",
"$",
"post",
")",
"{",
"$",
"field",
"=",
"parent",
"::",
"get_field",
"(",
"$",
"post",
")",
";",
"if",
"(",
"$",
"this",
"->",
"prefix",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"prefix",
".",
"' '",
".",
"$",
"field",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"suffix",
")",
"{",
"$",
"field",
".=",
"$",
"this",
"->",
"suffix",
";",
"}",
"return",
"$",
"field",
";",
"}"
] |
Add suffix or prefix to field
@param \WP_Post $post
@return array|string
|
[
"Add",
"suffix",
"or",
"prefix",
"to",
"field"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Number.php#L42-L51
|
22,445
|
opsbears/piccolo
|
src/Module/ModuleDependencyGraph.php
|
ModuleDependencyGraph.getSortedModuleList
|
public function getSortedModuleList() : array {
$moduleList = $this->modules;
foreach ($moduleList as $moduleSpec) {
$moduleClass = $moduleSpec['class'];
$module = $moduleSpec['object'];
if ($module instanceof OrderAwareModule) {
//All modules that should be loaded after this one
foreach ($module->getModulesAfter() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['after'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['before'][] = $moduleClass;
}
}
//All modules that should be loaded before this one
foreach ($module->getModulesBefore() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['before'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['after'][] = $moduleClass;
}
}
}
}
$sortedList = [];
$noIncomingNodes = [];
foreach ($moduleList as $moduleSpec) {
$moduleSpec['after'] = \array_unique($moduleSpec['after']);
$moduleSpec['before'] = \array_unique($moduleSpec['before']);
if (empty($moduleSpec['before'])) {
$noIncomingNodes[$moduleSpec['class']] = $moduleSpec;
}
}
//Do the topological sorting (Kahn's algorithm)
while (!empty($noIncomingNodes)) {
$moduleSpec = array_shift($noIncomingNodes);
\array_push($sortedList, $moduleSpec);
unset($moduleList[$moduleSpec['class']]);
foreach ($moduleSpec['after'] as $nextModuleKey => $nextModuleClass) {
unset($moduleList[$nextModuleClass]['before'][
\array_search($moduleSpec['class'], $moduleList[$nextModuleClass]['before'])
]);
if (empty($moduleList[$nextModuleClass]['before'])) {
$noIncomingNodes[] = $moduleList[$nextModuleClass];
}
unset($moduleSpec['after'][$nextModuleKey]);
}
}
foreach ($moduleList as $key => $remainingModuleSpec) {
if (empty($remainingModuleSpec['before'])) {
$sortedList[] = $moduleList[$remainingModuleSpec['class']];
unset($moduleList[$key]);
}
}
if (!empty($moduleList)) {
throw new CircularModuleLoadOrderDetectedException($this->getDotGraph());
} else {
$result = [];
foreach ($sortedList as $moduleSpec) {
$result[] = $moduleSpec['object'];
}
return $result;
}
}
|
php
|
public function getSortedModuleList() : array {
$moduleList = $this->modules;
foreach ($moduleList as $moduleSpec) {
$moduleClass = $moduleSpec['class'];
$module = $moduleSpec['object'];
if ($module instanceof OrderAwareModule) {
//All modules that should be loaded after this one
foreach ($module->getModulesAfter() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['after'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['before'][] = $moduleClass;
}
}
//All modules that should be loaded before this one
foreach ($module->getModulesBefore() as $afterModuleClass) {
if (\array_key_exists($afterModuleClass, $moduleList)) {
$moduleList[$moduleClass]['before'][] = $afterModuleClass;
$moduleList[$afterModuleClass]['after'][] = $moduleClass;
}
}
}
}
$sortedList = [];
$noIncomingNodes = [];
foreach ($moduleList as $moduleSpec) {
$moduleSpec['after'] = \array_unique($moduleSpec['after']);
$moduleSpec['before'] = \array_unique($moduleSpec['before']);
if (empty($moduleSpec['before'])) {
$noIncomingNodes[$moduleSpec['class']] = $moduleSpec;
}
}
//Do the topological sorting (Kahn's algorithm)
while (!empty($noIncomingNodes)) {
$moduleSpec = array_shift($noIncomingNodes);
\array_push($sortedList, $moduleSpec);
unset($moduleList[$moduleSpec['class']]);
foreach ($moduleSpec['after'] as $nextModuleKey => $nextModuleClass) {
unset($moduleList[$nextModuleClass]['before'][
\array_search($moduleSpec['class'], $moduleList[$nextModuleClass]['before'])
]);
if (empty($moduleList[$nextModuleClass]['before'])) {
$noIncomingNodes[] = $moduleList[$nextModuleClass];
}
unset($moduleSpec['after'][$nextModuleKey]);
}
}
foreach ($moduleList as $key => $remainingModuleSpec) {
if (empty($remainingModuleSpec['before'])) {
$sortedList[] = $moduleList[$remainingModuleSpec['class']];
unset($moduleList[$key]);
}
}
if (!empty($moduleList)) {
throw new CircularModuleLoadOrderDetectedException($this->getDotGraph());
} else {
$result = [];
foreach ($sortedList as $moduleSpec) {
$result[] = $moduleSpec['object'];
}
return $result;
}
}
|
[
"public",
"function",
"getSortedModuleList",
"(",
")",
":",
"array",
"{",
"$",
"moduleList",
"=",
"$",
"this",
"->",
"modules",
";",
"foreach",
"(",
"$",
"moduleList",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"moduleClass",
"=",
"$",
"moduleSpec",
"[",
"'class'",
"]",
";",
"$",
"module",
"=",
"$",
"moduleSpec",
"[",
"'object'",
"]",
";",
"if",
"(",
"$",
"module",
"instanceof",
"OrderAwareModule",
")",
"{",
"//All modules that should be loaded after this one",
"foreach",
"(",
"$",
"module",
"->",
"getModulesAfter",
"(",
")",
"as",
"$",
"afterModuleClass",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"afterModuleClass",
",",
"$",
"moduleList",
")",
")",
"{",
"$",
"moduleList",
"[",
"$",
"moduleClass",
"]",
"[",
"'after'",
"]",
"[",
"]",
"=",
"$",
"afterModuleClass",
";",
"$",
"moduleList",
"[",
"$",
"afterModuleClass",
"]",
"[",
"'before'",
"]",
"[",
"]",
"=",
"$",
"moduleClass",
";",
"}",
"}",
"//All modules that should be loaded before this one",
"foreach",
"(",
"$",
"module",
"->",
"getModulesBefore",
"(",
")",
"as",
"$",
"afterModuleClass",
")",
"{",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"afterModuleClass",
",",
"$",
"moduleList",
")",
")",
"{",
"$",
"moduleList",
"[",
"$",
"moduleClass",
"]",
"[",
"'before'",
"]",
"[",
"]",
"=",
"$",
"afterModuleClass",
";",
"$",
"moduleList",
"[",
"$",
"afterModuleClass",
"]",
"[",
"'after'",
"]",
"[",
"]",
"=",
"$",
"moduleClass",
";",
"}",
"}",
"}",
"}",
"$",
"sortedList",
"=",
"[",
"]",
";",
"$",
"noIncomingNodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"moduleList",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"moduleSpec",
"[",
"'after'",
"]",
"=",
"\\",
"array_unique",
"(",
"$",
"moduleSpec",
"[",
"'after'",
"]",
")",
";",
"$",
"moduleSpec",
"[",
"'before'",
"]",
"=",
"\\",
"array_unique",
"(",
"$",
"moduleSpec",
"[",
"'before'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"moduleSpec",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"noIncomingNodes",
"[",
"$",
"moduleSpec",
"[",
"'class'",
"]",
"]",
"=",
"$",
"moduleSpec",
";",
"}",
"}",
"//Do the topological sorting (Kahn's algorithm)",
"while",
"(",
"!",
"empty",
"(",
"$",
"noIncomingNodes",
")",
")",
"{",
"$",
"moduleSpec",
"=",
"array_shift",
"(",
"$",
"noIncomingNodes",
")",
";",
"\\",
"array_push",
"(",
"$",
"sortedList",
",",
"$",
"moduleSpec",
")",
";",
"unset",
"(",
"$",
"moduleList",
"[",
"$",
"moduleSpec",
"[",
"'class'",
"]",
"]",
")",
";",
"foreach",
"(",
"$",
"moduleSpec",
"[",
"'after'",
"]",
"as",
"$",
"nextModuleKey",
"=>",
"$",
"nextModuleClass",
")",
"{",
"unset",
"(",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
"[",
"'before'",
"]",
"[",
"\\",
"array_search",
"(",
"$",
"moduleSpec",
"[",
"'class'",
"]",
",",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
"[",
"'before'",
"]",
")",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"noIncomingNodes",
"[",
"]",
"=",
"$",
"moduleList",
"[",
"$",
"nextModuleClass",
"]",
";",
"}",
"unset",
"(",
"$",
"moduleSpec",
"[",
"'after'",
"]",
"[",
"$",
"nextModuleKey",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"moduleList",
"as",
"$",
"key",
"=>",
"$",
"remainingModuleSpec",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"remainingModuleSpec",
"[",
"'before'",
"]",
")",
")",
"{",
"$",
"sortedList",
"[",
"]",
"=",
"$",
"moduleList",
"[",
"$",
"remainingModuleSpec",
"[",
"'class'",
"]",
"]",
";",
"unset",
"(",
"$",
"moduleList",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"moduleList",
")",
")",
"{",
"throw",
"new",
"CircularModuleLoadOrderDetectedException",
"(",
"$",
"this",
"->",
"getDotGraph",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"sortedList",
"as",
"$",
"moduleSpec",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"moduleSpec",
"[",
"'object'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}",
"}"
] |
Returns a list of modules, sorted by dependencies.
@return Module[]
@throws CircularModuleLoadOrderDetectedException
|
[
"Returns",
"a",
"list",
"of",
"modules",
"sorted",
"by",
"dependencies",
"."
] |
ebba9f892ed35965140265ba1c61b2c645eab6e0
|
https://github.com/opsbears/piccolo/blob/ebba9f892ed35965140265ba1c61b2c645eab6e0/src/Module/ModuleDependencyGraph.php#L80-L148
|
22,446
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomcommentcommonmanager.php
|
ezcomCommentCommonManager.afterAddingComment
|
public function afterAddingComment( $comment, $notification )
{
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
//add subscription
$subscription = ezcomSubscriptionManager::instance();
$user = eZUser::instance();
if ( $notification === true )
{
$subscription->addSubscription( $comment->attribute('email'),
$user,
$contentID,
$languageID,
$subscriptionType,
$comment->attribute( 'created' ) );
}
// insert data into notification queue
// if there is no subscription,not adding to notification queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType, null, 1 ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute('contentobject_id') );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'Notification added to queue', __METHOD__ );
}
}
|
php
|
public function afterAddingComment( $comment, $notification )
{
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
//add subscription
$subscription = ezcomSubscriptionManager::instance();
$user = eZUser::instance();
if ( $notification === true )
{
$subscription->addSubscription( $comment->attribute('email'),
$user,
$contentID,
$languageID,
$subscriptionType,
$comment->attribute( 'created' ) );
}
// insert data into notification queue
// if there is no subscription,not adding to notification queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType, null, 1 ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute('contentobject_id') );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'Notification added to queue', __METHOD__ );
}
}
|
[
"public",
"function",
"afterAddingComment",
"(",
"$",
"comment",
",",
"$",
"notification",
")",
"{",
"$",
"contentID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";",
"$",
"languageID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
";",
"$",
"subscriptionType",
"=",
"'ezcomcomment'",
";",
"//add subscription",
"$",
"subscription",
"=",
"ezcomSubscriptionManager",
"::",
"instance",
"(",
")",
";",
"$",
"user",
"=",
"eZUser",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"notification",
"===",
"true",
")",
"{",
"$",
"subscription",
"->",
"addSubscription",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'email'",
")",
",",
"$",
"user",
",",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'created'",
")",
")",
";",
"}",
"// insert data into notification queue",
"// if there is no subscription,not adding to notification queue",
"if",
"(",
"ezcomSubscription",
"::",
"exists",
"(",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"null",
",",
"1",
")",
")",
"{",
"$",
"notification",
"=",
"ezcomNotification",
"::",
"create",
"(",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'contentobject_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'language_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'comment_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'id'",
")",
")",
";",
"$",
"notification",
"->",
"store",
"(",
")",
";",
"eZDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'Notification added to queue'",
",",
"__METHOD__",
")",
";",
"}",
"}"
] |
add subscription after adding comment
1) If 'notification' is true
add the user as a subscriber if subscriber with same email doesn't exist
otherwise get the subscriber
2) If 'notification' is true
if the subscription with user's email and contentid doesn't exist, add a new subscription,
3) If there is subscription, add the comment into notifiction queue
@see extension/ezcomments/classes/ezcomCommentManager#afterAddingComment($comment)
|
[
"add",
"subscription",
"after",
"adding",
"comment",
"1",
")",
"If",
"notification",
"is",
"true",
"add",
"the",
"user",
"as",
"a",
"subscriber",
"if",
"subscriber",
"with",
"same",
"email",
"doesn",
"t",
"exist",
"otherwise",
"get",
"the",
"subscriber",
"2",
")",
"If",
"notification",
"is",
"true",
"if",
"the",
"subscription",
"with",
"user",
"s",
"email",
"and",
"contentid",
"doesn",
"t",
"exist",
"add",
"a",
"new",
"subscription",
"3",
")",
"If",
"there",
"is",
"subscription",
"add",
"the",
"comment",
"into",
"notifiction",
"queue"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcommentcommonmanager.php#L40-L70
|
22,447
|
ezsystems/ezcomments-ls-extension
|
classes/ezcomcommentcommonmanager.php
|
ezcomCommentCommonManager.afterUpdatingComment
|
public function afterUpdatingComment( $comment, $notified, $time )
{
$user = eZUser::fetch( $comment->attribute( 'user_id' ) );
// if notified is true, add subscription, else cleanup the subscription on the user and content
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
if ( !is_null( $notified ) )
{
$subscriptionManager = ezcomSubscriptionManager::instance();
if ( $notified === true )
{
//add subscription but not send activation
try
{
$subscriptionManager->addSubscription( $comment->attribute( 'email' ),
$user,
$contentID,
$languageID,
$subscriptionType,
$time,
false );
}
catch ( Exception $e )
{
eZDebug::writeError( $e->getMessage(), __METHOD__ );
switch ( $e->getCode() )
{
case ezcomSubscriptionManager::ERROR_SUBSCRIBER_DISABLED:
return 'The subscriber is disabled.';
default:
return false;
}
}
}
else
{
$subscriptionManager->deleteSubscription( $comment->attribute( 'email' ),
$comment->attribute( 'contentobject_id' ),
$comment->attribute( 'language_id' ) );
}
}
//3. update queue. If there is subscription, add one record into queue table
// if there is subcription on this content, add one item into queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute( 'contentobject_id' ) );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'There are subscriptions, added an update notification to the queue.', __METHOD__ );
}
else
{
// todo: if there is no subscription on this content, consider to clean up the queue
}
return true;
}
|
php
|
public function afterUpdatingComment( $comment, $notified, $time )
{
$user = eZUser::fetch( $comment->attribute( 'user_id' ) );
// if notified is true, add subscription, else cleanup the subscription on the user and content
$contentID = $comment->attribute( 'contentobject_id' );
$languageID = $comment->attribute( 'language_id' );
$subscriptionType = 'ezcomcomment';
if ( !is_null( $notified ) )
{
$subscriptionManager = ezcomSubscriptionManager::instance();
if ( $notified === true )
{
//add subscription but not send activation
try
{
$subscriptionManager->addSubscription( $comment->attribute( 'email' ),
$user,
$contentID,
$languageID,
$subscriptionType,
$time,
false );
}
catch ( Exception $e )
{
eZDebug::writeError( $e->getMessage(), __METHOD__ );
switch ( $e->getCode() )
{
case ezcomSubscriptionManager::ERROR_SUBSCRIBER_DISABLED:
return 'The subscriber is disabled.';
default:
return false;
}
}
}
else
{
$subscriptionManager->deleteSubscription( $comment->attribute( 'email' ),
$comment->attribute( 'contentobject_id' ),
$comment->attribute( 'language_id' ) );
}
}
//3. update queue. If there is subscription, add one record into queue table
// if there is subcription on this content, add one item into queue
if ( ezcomSubscription::exists( $contentID, $languageID, $subscriptionType ) )
{
$notification = ezcomNotification::create();
$notification->setAttribute( 'contentobject_id', $comment->attribute( 'contentobject_id' ) );
$notification->setAttribute( 'language_id', $comment->attribute( 'language_id' ) );
$notification->setAttribute( 'comment_id', $comment->attribute( 'id' ) );
$notification->store();
eZDebugSetting::writeNotice( 'extension-ezcomments', 'There are subscriptions, added an update notification to the queue.', __METHOD__ );
}
else
{
// todo: if there is no subscription on this content, consider to clean up the queue
}
return true;
}
|
[
"public",
"function",
"afterUpdatingComment",
"(",
"$",
"comment",
",",
"$",
"notified",
",",
"$",
"time",
")",
"{",
"$",
"user",
"=",
"eZUser",
"::",
"fetch",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'user_id'",
")",
")",
";",
"// if notified is true, add subscription, else cleanup the subscription on the user and content",
"$",
"contentID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
";",
"$",
"languageID",
"=",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
";",
"$",
"subscriptionType",
"=",
"'ezcomcomment'",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"notified",
")",
")",
"{",
"$",
"subscriptionManager",
"=",
"ezcomSubscriptionManager",
"::",
"instance",
"(",
")",
";",
"if",
"(",
"$",
"notified",
"===",
"true",
")",
"{",
"//add subscription but not send activation",
"try",
"{",
"$",
"subscriptionManager",
"->",
"addSubscription",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'email'",
")",
",",
"$",
"user",
",",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
",",
"$",
"time",
",",
"false",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"eZDebug",
"::",
"writeError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"switch",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
"{",
"case",
"ezcomSubscriptionManager",
"::",
"ERROR_SUBSCRIBER_DISABLED",
":",
"return",
"'The subscriber is disabled.'",
";",
"default",
":",
"return",
"false",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"subscriptionManager",
"->",
"deleteSubscription",
"(",
"$",
"comment",
"->",
"attribute",
"(",
"'email'",
")",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
")",
";",
"}",
"}",
"//3. update queue. If there is subscription, add one record into queue table",
"// if there is subcription on this content, add one item into queue",
"if",
"(",
"ezcomSubscription",
"::",
"exists",
"(",
"$",
"contentID",
",",
"$",
"languageID",
",",
"$",
"subscriptionType",
")",
")",
"{",
"$",
"notification",
"=",
"ezcomNotification",
"::",
"create",
"(",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'contentobject_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'contentobject_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'language_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'language_id'",
")",
")",
";",
"$",
"notification",
"->",
"setAttribute",
"(",
"'comment_id'",
",",
"$",
"comment",
"->",
"attribute",
"(",
"'id'",
")",
")",
";",
"$",
"notification",
"->",
"store",
"(",
")",
";",
"eZDebugSetting",
"::",
"writeNotice",
"(",
"'extension-ezcomments'",
",",
"'There are subscriptions, added an update notification to the queue.'",
",",
"__METHOD__",
")",
";",
"}",
"else",
"{",
"// todo: if there is no subscription on this content, consider to clean up the queue",
"}",
"return",
"true",
";",
"}"
] |
clean up subscription after updating comment
@see extension/ezcomments/classes/ezcomCommentManager#afterUpdatingComment($comment, $notified)
|
[
"clean",
"up",
"subscription",
"after",
"updating",
"comment"
] |
2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5
|
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomcommentcommonmanager.php#L85-L144
|
22,448
|
willhoffmann/domuserp-php
|
src/DomusClient.php
|
DomusClient.authenticate
|
public function authenticate()
{
$request = new Request($this->handler);
$this->token = $request->execute(
RequestMethods::HTTP_POST,
$this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
[
'json' => [
'login' => $this->username,
'password' => $this->password
]
]
)->token;
return $this;
}
|
php
|
public function authenticate()
{
$request = new Request($this->handler);
$this->token = $request->execute(
RequestMethods::HTTP_POST,
$this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
[
'json' => [
'login' => $this->username,
'password' => $this->password
]
]
)->token;
return $this;
}
|
[
"public",
"function",
"authenticate",
"(",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
"$",
"this",
"->",
"handler",
")",
";",
"$",
"this",
"->",
"token",
"=",
"$",
"request",
"->",
"execute",
"(",
"RequestMethods",
"::",
"HTTP_POST",
",",
"$",
"this",
"->",
"makeUrl",
"(",
"RequestMethods",
"::",
"DOMUSERP_API_PEDIDOVENDA",
".",
"'/auth'",
")",
",",
"[",
"'json'",
"=>",
"[",
"'login'",
"=>",
"$",
"this",
"->",
"username",
",",
"'password'",
"=>",
"$",
"this",
"->",
"password",
"]",
"]",
")",
"->",
"token",
";",
"return",
"$",
"this",
";",
"}"
] |
Request an access token and sets it to the client.
@return $this
@throws \GuzzleHttp\Exception\GuzzleException
|
[
"Request",
"an",
"access",
"token",
"and",
"sets",
"it",
"to",
"the",
"client",
"."
] |
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
|
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/DomusClient.php#L156-L171
|
22,449
|
technote-space/wordpress-plugin-base
|
src/technote.php
|
Technote.plugins_loaded
|
private function plugins_loaded() {
if ( $this->_plugins_loaded ) {
return;
}
$this->_plugins_loaded = true;
spl_autoload_register( function ( $class ) {
return $this->get_main()->load_class( $class );
} );
$this->load_functions();
}
|
php
|
private function plugins_loaded() {
if ( $this->_plugins_loaded ) {
return;
}
$this->_plugins_loaded = true;
spl_autoload_register( function ( $class ) {
return $this->get_main()->load_class( $class );
} );
$this->load_functions();
}
|
[
"private",
"function",
"plugins_loaded",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_plugins_loaded",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_plugins_loaded",
"=",
"true",
";",
"spl_autoload_register",
"(",
"function",
"(",
"$",
"class",
")",
"{",
"return",
"$",
"this",
"->",
"get_main",
"(",
")",
"->",
"load_class",
"(",
"$",
"class",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"load_functions",
"(",
")",
";",
"}"
] |
load basic files
|
[
"load",
"basic",
"files"
] |
02cfcba358432a2539af07a69d9db00ff7c14eac
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L352-L363
|
22,450
|
technote-space/wordpress-plugin-base
|
src/technote.php
|
Technote.load_functions
|
private function load_functions() {
if ( $this->is_theme ) {
return;
}
$functions = $this->define->plugin_dir . DS . 'functions.php';
if ( is_readable( $functions ) ) {
/** @noinspection PhpIncludeInspection */
require_once $functions;
}
}
|
php
|
private function load_functions() {
if ( $this->is_theme ) {
return;
}
$functions = $this->define->plugin_dir . DS . 'functions.php';
if ( is_readable( $functions ) ) {
/** @noinspection PhpIncludeInspection */
require_once $functions;
}
}
|
[
"private",
"function",
"load_functions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_theme",
")",
"{",
"return",
";",
"}",
"$",
"functions",
"=",
"$",
"this",
"->",
"define",
"->",
"plugin_dir",
".",
"DS",
".",
"'functions.php'",
";",
"if",
"(",
"is_readable",
"(",
"$",
"functions",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"require_once",
"$",
"functions",
";",
"}",
"}"
] |
load functions file
@since 2.10.1 Improved: for theme (#115)
|
[
"load",
"functions",
"file"
] |
02cfcba358432a2539af07a69d9db00ff7c14eac
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/technote.php#L369-L378
|
22,451
|
heidelpay/PhpDoc
|
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
|
ResolveInlineLinkAndSeeTags.resolveQsen
|
private function resolveQsen($link)
{
if (!$this->isFqsen($link)) {
$typeCollection = new TypeCollection(array($link), $this->createDocBlockContext());
// only a single element reference is allowed!
$link = $typeCollection[0];
}
return $link;
}
|
php
|
private function resolveQsen($link)
{
if (!$this->isFqsen($link)) {
$typeCollection = new TypeCollection(array($link), $this->createDocBlockContext());
// only a single element reference is allowed!
$link = $typeCollection[0];
}
return $link;
}
|
[
"private",
"function",
"resolveQsen",
"(",
"$",
"link",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFqsen",
"(",
"$",
"link",
")",
")",
"{",
"$",
"typeCollection",
"=",
"new",
"TypeCollection",
"(",
"array",
"(",
"$",
"link",
")",
",",
"$",
"this",
"->",
"createDocBlockContext",
"(",
")",
")",
";",
"// only a single element reference is allowed!",
"$",
"link",
"=",
"$",
"typeCollection",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"link",
";",
"}"
] |
Resolves a QSEN to a FQSEN.
If a relative QSEN is provided then this method will attempt to resolve it given the current namespace and
namespace aliases.
@param string $link
@return string
|
[
"Resolves",
"a",
"QSEN",
"to",
"a",
"FQSEN",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L178-L188
|
22,452
|
heidelpay/PhpDoc
|
src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php
|
ResolveInlineLinkAndSeeTags.findElement
|
private function findElement($fqsen)
{
return isset($this->elementCollection[$fqsen]) ? $this->elementCollection[$fqsen] : null;
}
|
php
|
private function findElement($fqsen)
{
return isset($this->elementCollection[$fqsen]) ? $this->elementCollection[$fqsen] : null;
}
|
[
"private",
"function",
"findElement",
"(",
"$",
"fqsen",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"elementCollection",
"[",
"$",
"fqsen",
"]",
")",
"?",
"$",
"this",
"->",
"elementCollection",
"[",
"$",
"fqsen",
"]",
":",
"null",
";",
"}"
] |
Tries to find an element with the given FQSEN in the elements listing for this project.
@param string $fqsen
@return DescriptorAbstract|null
|
[
"Tries",
"to",
"find",
"an",
"element",
"with",
"the",
"given",
"FQSEN",
"in",
"the",
"elements",
"listing",
"for",
"this",
"project",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Compiler/Pass/ResolveInlineLinkAndSeeTags.php#L234-L237
|
22,453
|
i-lateral/silverstripe-users
|
code/control/Users_Register_Controller.php
|
Users_Register_Controller.getMenu
|
public function getMenu($level = 1)
{
if (class_exists(ContentController::class)) {
$controller = Injector::inst()->get(ContentController::class);
return $controller->getMenu($level);
}
}
|
php
|
public function getMenu($level = 1)
{
if (class_exists(ContentController::class)) {
$controller = Injector::inst()->get(ContentController::class);
return $controller->getMenu($level);
}
}
|
[
"public",
"function",
"getMenu",
"(",
"$",
"level",
"=",
"1",
")",
"{",
"if",
"(",
"class_exists",
"(",
"ContentController",
"::",
"class",
")",
")",
"{",
"$",
"controller",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"ContentController",
"::",
"class",
")",
";",
"return",
"$",
"controller",
"->",
"getMenu",
"(",
"$",
"level",
")",
";",
"}",
"}"
] |
If content controller exists, return it's menu function
@param int $level Menu level to return.
@return ArrayList
|
[
"If",
"content",
"controller",
"exists",
"return",
"it",
"s",
"menu",
"function"
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L104-L110
|
22,454
|
i-lateral/silverstripe-users
|
code/control/Users_Register_Controller.php
|
Users_Register_Controller.index
|
public function index(SS_HTTPRequest $request)
{
$this->customise(
array(
'Title' => _t('Users.Register', 'Register'),
'MetaTitle' => _t('Users.Register', 'Register'),
'Form' => $this->RegisterForm(),
)
);
$this->extend("updateIndexAction");
return $this->renderWith(
array(
"Users_Register",
"Users",
"Page"
)
);
}
|
php
|
public function index(SS_HTTPRequest $request)
{
$this->customise(
array(
'Title' => _t('Users.Register', 'Register'),
'MetaTitle' => _t('Users.Register', 'Register'),
'Form' => $this->RegisterForm(),
)
);
$this->extend("updateIndexAction");
return $this->renderWith(
array(
"Users_Register",
"Users",
"Page"
)
);
}
|
[
"public",
"function",
"index",
"(",
"SS_HTTPRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"customise",
"(",
"array",
"(",
"'Title'",
"=>",
"_t",
"(",
"'Users.Register'",
",",
"'Register'",
")",
",",
"'MetaTitle'",
"=>",
"_t",
"(",
"'Users.Register'",
",",
"'Register'",
")",
",",
"'Form'",
"=>",
"$",
"this",
"->",
"RegisterForm",
"(",
")",
",",
")",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"updateIndexAction\"",
")",
";",
"return",
"$",
"this",
"->",
"renderWith",
"(",
"array",
"(",
"\"Users_Register\"",
",",
"\"Users\"",
",",
"\"Page\"",
")",
")",
";",
"}"
] |
Default action this controller will deal with
@param SS_HTTPRequest $request Current request
@return HTMLText
|
[
"Default",
"action",
"this",
"controller",
"will",
"deal",
"with"
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/control/Users_Register_Controller.php#L131-L150
|
22,455
|
infinity-next/sleuth
|
src/FileSleuth.php
|
FileSleuth.check
|
public function check($file, $verify = null)
{
if (is_string($verify))
{
$verify = "lead" . strtoupper($verify);
}
$detectives = [];
foreach ($this->detectives as $detectiveClass)
{
if ($detectiveClass::on())
{
$detectives[] = $detectiveClass;
}
}
$case = null;
foreach ($detectives as $detectiveClass)
{
$detective = new $detectiveClass();
$case = $detective->check($file, $verify);
if ($case)
{
return $detective;
}
}
return false;
}
|
php
|
public function check($file, $verify = null)
{
if (is_string($verify))
{
$verify = "lead" . strtoupper($verify);
}
$detectives = [];
foreach ($this->detectives as $detectiveClass)
{
if ($detectiveClass::on())
{
$detectives[] = $detectiveClass;
}
}
$case = null;
foreach ($detectives as $detectiveClass)
{
$detective = new $detectiveClass();
$case = $detective->check($file, $verify);
if ($case)
{
return $detective;
}
}
return false;
}
|
[
"public",
"function",
"check",
"(",
"$",
"file",
",",
"$",
"verify",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"verify",
")",
")",
"{",
"$",
"verify",
"=",
"\"lead\"",
".",
"strtoupper",
"(",
"$",
"verify",
")",
";",
"}",
"$",
"detectives",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"detectives",
"as",
"$",
"detectiveClass",
")",
"{",
"if",
"(",
"$",
"detectiveClass",
"::",
"on",
"(",
")",
")",
"{",
"$",
"detectives",
"[",
"]",
"=",
"$",
"detectiveClass",
";",
"}",
"}",
"$",
"case",
"=",
"null",
";",
"foreach",
"(",
"$",
"detectives",
"as",
"$",
"detectiveClass",
")",
"{",
"$",
"detective",
"=",
"new",
"$",
"detectiveClass",
"(",
")",
";",
"$",
"case",
"=",
"$",
"detective",
"->",
"check",
"(",
"$",
"file",
",",
"$",
"verify",
")",
";",
"if",
"(",
"$",
"case",
")",
"{",
"return",
"$",
"detective",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Runs the file against all dectives.
@param string $file Optional parameter to automatically run a check.
@param string|null $verify Extension to verify against. Checks all possible if unset.
@return null|boolean
|
[
"Runs",
"the",
"file",
"against",
"all",
"dectives",
"."
] |
924b82e4d60f042fddd6b093b324cfa4bb885a13
|
https://github.com/infinity-next/sleuth/blob/924b82e4d60f042fddd6b093b324cfa4bb885a13/src/FileSleuth.php#L49-L79
|
22,456
|
endorphin-studio/browser-detector-data
|
src/Storage/AbstractStorage.php
|
AbstractStorage.setDataDirectory
|
public function setDataDirectory(string $directory)
{
if (!is_dir($directory)) {
$exception = new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $directory));
$exception->setDirectory($exception);
$exception->setProvider(static::class);
throw $exception;
}
$this->dataDirectory = $directory;
}
|
php
|
public function setDataDirectory(string $directory)
{
if (!is_dir($directory)) {
$exception = new StorageException(sprintf(StorageException::DIRECTORY_NOT_FOUND, $directory));
$exception->setDirectory($exception);
$exception->setProvider(static::class);
throw $exception;
}
$this->dataDirectory = $directory;
}
|
[
"public",
"function",
"setDataDirectory",
"(",
"string",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"exception",
"=",
"new",
"StorageException",
"(",
"sprintf",
"(",
"StorageException",
"::",
"DIRECTORY_NOT_FOUND",
",",
"$",
"directory",
")",
")",
";",
"$",
"exception",
"->",
"setDirectory",
"(",
"$",
"exception",
")",
";",
"$",
"exception",
"->",
"setProvider",
"(",
"static",
"::",
"class",
")",
";",
"throw",
"$",
"exception",
";",
"}",
"$",
"this",
"->",
"dataDirectory",
"=",
"$",
"directory",
";",
"}"
] |
Set data directory
@param string $directory
@throws StorageException
|
[
"Set",
"data",
"directory"
] |
cb1ace9f52f9677616c89f3b80c5148936d47b82
|
https://github.com/endorphin-studio/browser-detector-data/blob/cb1ace9f52f9677616c89f3b80c5148936d47b82/src/Storage/AbstractStorage.php#L36-L46
|
22,457
|
FrenzelGmbH/cm-address
|
models/scopes/AddressQuery.php
|
AddressQuery.active
|
public function active()
{
if(!\Yii::$app->user->isGuest && !\Yii::$app->user->identity->isAdmin)
{
$this->andWhere(['deleted_at' => NULL]);
}
return $this;
}
|
php
|
public function active()
{
if(!\Yii::$app->user->isGuest && !\Yii::$app->user->identity->isAdmin)
{
$this->andWhere(['deleted_at' => NULL]);
}
return $this;
}
|
[
"public",
"function",
"active",
"(",
")",
"{",
"if",
"(",
"!",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"isGuest",
"&&",
"!",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"identity",
"->",
"isAdmin",
")",
"{",
"$",
"this",
"->",
"andWhere",
"(",
"[",
"'deleted_at'",
"=>",
"NULL",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
only none delted records should be returned, deleted would mean they are not null anymore within field value
@return [type] [description]
|
[
"only",
"none",
"delted",
"records",
"should",
"be",
"returned",
"deleted",
"would",
"mean",
"they",
"are",
"not",
"null",
"anymore",
"within",
"field",
"value"
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/scopes/AddressQuery.php#L21-L28
|
22,458
|
FrenzelGmbH/cm-address
|
models/scopes/AddressQuery.php
|
AddressQuery.related
|
public function related($entity = NULL, $enity = NULL)
{
$this->andWhere(['entity' => $entity, 'entity_id' => $this->entity_id]);
return $this;
}
|
php
|
public function related($entity = NULL, $enity = NULL)
{
$this->andWhere(['entity' => $entity, 'entity_id' => $this->entity_id]);
return $this;
}
|
[
"public",
"function",
"related",
"(",
"$",
"entity",
"=",
"NULL",
",",
"$",
"enity",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"andWhere",
"(",
"[",
"'entity'",
"=>",
"$",
"entity",
",",
"'entity_id'",
"=>",
"$",
"this",
"->",
"entity_id",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
find all records which are related to the same entity
@param [type] $entity [description]
@param [type] $enity [description]
@return [type] [description]
|
[
"find",
"all",
"records",
"which",
"are",
"related",
"to",
"the",
"same",
"entity"
] |
4295671dc603beed4bea6c5a7f77dac9846127f3
|
https://github.com/FrenzelGmbH/cm-address/blob/4295671dc603beed4bea6c5a7f77dac9846127f3/models/scopes/AddressQuery.php#L46-L50
|
22,459
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Graphs/Writer/Graph.php
|
Graph.processClass
|
public function processClass(ProjectDescriptor $project, Transformation $transformation)
{
try {
$this->checkIfGraphVizIsInstalled();
} catch (\Exception $e) {
echo $e->getMessage();
return;
}
if ($transformation->getParameter('font') !== null && $transformation->getParameter('font')->getValue()) {
$this->nodeFont = $transformation->getParameter('font')->getValue();
} else {
$this->nodeFont = 'Courier';
}
$filename = $this->getDestinationPath($transformation);
$graph = GraphVizGraph::create()
->setRankSep('1.0')
->setCenter('true')
->setRank('source')
->setRankDir('RL')
->setSplines('true')
->setConcentrate('true');
$this->buildNamespaceTree($graph, $project->getNamespace());
$classes = $project->getIndexes()->get('classes', new Collection())->getAll();
$interfaces = $project->getIndexes()->get('interfaces', new Collection())->getAll();
$traits = $project->getIndexes()->get('traits', new Collection())->getAll();
/** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers */
$containers = array_merge($classes, $interfaces, $traits);
foreach ($containers as $container) {
$from_name = $container->getFullyQualifiedStructuralElementName();
$parents = array();
$implemented = array();
if ($container instanceof ClassDescriptor) {
if ($container->getParent()) {
$parents[] = $container->getParent();
}
$implemented = $container->getInterfaces()->getAll();
}
if ($container instanceof InterfaceDescriptor) {
$parents = $container->getParent()->getAll();
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($parents as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setArrowHead('empty');
$graph->link($edge);
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($implemented as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setStyle('dotted');
$edge->setArrowHead('empty');
$graph->link($edge);
}
}
$graph->export('svg', $filename);
}
|
php
|
public function processClass(ProjectDescriptor $project, Transformation $transformation)
{
try {
$this->checkIfGraphVizIsInstalled();
} catch (\Exception $e) {
echo $e->getMessage();
return;
}
if ($transformation->getParameter('font') !== null && $transformation->getParameter('font')->getValue()) {
$this->nodeFont = $transformation->getParameter('font')->getValue();
} else {
$this->nodeFont = 'Courier';
}
$filename = $this->getDestinationPath($transformation);
$graph = GraphVizGraph::create()
->setRankSep('1.0')
->setCenter('true')
->setRank('source')
->setRankDir('RL')
->setSplines('true')
->setConcentrate('true');
$this->buildNamespaceTree($graph, $project->getNamespace());
$classes = $project->getIndexes()->get('classes', new Collection())->getAll();
$interfaces = $project->getIndexes()->get('interfaces', new Collection())->getAll();
$traits = $project->getIndexes()->get('traits', new Collection())->getAll();
/** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers */
$containers = array_merge($classes, $interfaces, $traits);
foreach ($containers as $container) {
$from_name = $container->getFullyQualifiedStructuralElementName();
$parents = array();
$implemented = array();
if ($container instanceof ClassDescriptor) {
if ($container->getParent()) {
$parents[] = $container->getParent();
}
$implemented = $container->getInterfaces()->getAll();
}
if ($container instanceof InterfaceDescriptor) {
$parents = $container->getParent()->getAll();
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($parents as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setArrowHead('empty');
$graph->link($edge);
}
/** @var string|ClassDescriptor|InterfaceDescriptor $parent */
foreach ($implemented as $parent) {
$edge = $this->createEdge($graph, $from_name, $parent);
$edge->setStyle('dotted');
$edge->setArrowHead('empty');
$graph->link($edge);
}
}
$graph->export('svg', $filename);
}
|
[
"public",
"function",
"processClass",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"checkIfGraphVizIsInstalled",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"transformation",
"->",
"getParameter",
"(",
"'font'",
")",
"!==",
"null",
"&&",
"$",
"transformation",
"->",
"getParameter",
"(",
"'font'",
")",
"->",
"getValue",
"(",
")",
")",
"{",
"$",
"this",
"->",
"nodeFont",
"=",
"$",
"transformation",
"->",
"getParameter",
"(",
"'font'",
")",
"->",
"getValue",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"nodeFont",
"=",
"'Courier'",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"getDestinationPath",
"(",
"$",
"transformation",
")",
";",
"$",
"graph",
"=",
"GraphVizGraph",
"::",
"create",
"(",
")",
"->",
"setRankSep",
"(",
"'1.0'",
")",
"->",
"setCenter",
"(",
"'true'",
")",
"->",
"setRank",
"(",
"'source'",
")",
"->",
"setRankDir",
"(",
"'RL'",
")",
"->",
"setSplines",
"(",
"'true'",
")",
"->",
"setConcentrate",
"(",
"'true'",
")",
";",
"$",
"this",
"->",
"buildNamespaceTree",
"(",
"$",
"graph",
",",
"$",
"project",
"->",
"getNamespace",
"(",
")",
")",
";",
"$",
"classes",
"=",
"$",
"project",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'classes'",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"getAll",
"(",
")",
";",
"$",
"interfaces",
"=",
"$",
"project",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'interfaces'",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"getAll",
"(",
")",
";",
"$",
"traits",
"=",
"$",
"project",
"->",
"getIndexes",
"(",
")",
"->",
"get",
"(",
"'traits'",
",",
"new",
"Collection",
"(",
")",
")",
"->",
"getAll",
"(",
")",
";",
"/** @var ClassDescriptor[]|InterfaceDescriptor[]|TraitDescriptor[] $containers */",
"$",
"containers",
"=",
"array_merge",
"(",
"$",
"classes",
",",
"$",
"interfaces",
",",
"$",
"traits",
")",
";",
"foreach",
"(",
"$",
"containers",
"as",
"$",
"container",
")",
"{",
"$",
"from_name",
"=",
"$",
"container",
"->",
"getFullyQualifiedStructuralElementName",
"(",
")",
";",
"$",
"parents",
"=",
"array",
"(",
")",
";",
"$",
"implemented",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"container",
"instanceof",
"ClassDescriptor",
")",
"{",
"if",
"(",
"$",
"container",
"->",
"getParent",
"(",
")",
")",
"{",
"$",
"parents",
"[",
"]",
"=",
"$",
"container",
"->",
"getParent",
"(",
")",
";",
"}",
"$",
"implemented",
"=",
"$",
"container",
"->",
"getInterfaces",
"(",
")",
"->",
"getAll",
"(",
")",
";",
"}",
"if",
"(",
"$",
"container",
"instanceof",
"InterfaceDescriptor",
")",
"{",
"$",
"parents",
"=",
"$",
"container",
"->",
"getParent",
"(",
")",
"->",
"getAll",
"(",
")",
";",
"}",
"/** @var string|ClassDescriptor|InterfaceDescriptor $parent */",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"parent",
")",
"{",
"$",
"edge",
"=",
"$",
"this",
"->",
"createEdge",
"(",
"$",
"graph",
",",
"$",
"from_name",
",",
"$",
"parent",
")",
";",
"$",
"edge",
"->",
"setArrowHead",
"(",
"'empty'",
")",
";",
"$",
"graph",
"->",
"link",
"(",
"$",
"edge",
")",
";",
"}",
"/** @var string|ClassDescriptor|InterfaceDescriptor $parent */",
"foreach",
"(",
"$",
"implemented",
"as",
"$",
"parent",
")",
"{",
"$",
"edge",
"=",
"$",
"this",
"->",
"createEdge",
"(",
"$",
"graph",
",",
"$",
"from_name",
",",
"$",
"parent",
")",
";",
"$",
"edge",
"->",
"setStyle",
"(",
"'dotted'",
")",
";",
"$",
"edge",
"->",
"setArrowHead",
"(",
"'empty'",
")",
";",
"$",
"graph",
"->",
"link",
"(",
"$",
"edge",
")",
";",
"}",
"}",
"$",
"graph",
"->",
"export",
"(",
"'svg'",
",",
"$",
"filename",
")",
";",
"}"
] |
Creates a class inheritance diagram.
@param ProjectDescriptor $project
@param Transformation $transformation
@return void
|
[
"Creates",
"a",
"class",
"inheritance",
"diagram",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Graphs/Writer/Graph.php#L69-L136
|
22,460
|
JBZoo/Assets
|
src/Manager.php
|
Manager.add
|
public function add($alias, $source = null, $dependencies = [], $options = [])
{
if ($source !== null) {
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
}
$this->_queued[$alias] = true;
return $this;
}
|
php
|
public function add($alias, $source = null, $dependencies = [], $options = [])
{
if ($source !== null) {
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
}
$this->_queued[$alias] = true;
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"alias",
",",
"$",
"source",
"=",
"null",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"source",
"!==",
"null",
")",
"{",
"$",
"asset",
"=",
"$",
"this",
"->",
"_factory",
"->",
"create",
"(",
"$",
"alias",
",",
"$",
"source",
",",
"$",
"dependencies",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"_collection",
"->",
"add",
"(",
"$",
"asset",
")",
";",
"}",
"$",
"this",
"->",
"_queued",
"[",
"$",
"alias",
"]",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a registered asset or a new asset to the queue.
@param string $alias
@param string|null $source
@param string|array $dependencies
@param string|array $options
@return $this
|
[
"Adds",
"a",
"registered",
"asset",
"or",
"a",
"new",
"asset",
"to",
"the",
"queue",
"."
] |
134a109378f5b5e955dfb15e6ed2821581564991
|
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L107-L117
|
22,461
|
JBZoo/Assets
|
src/Manager.php
|
Manager.register
|
public function register($alias, $source = null, $dependencies = [], $options = [])
{
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
return $this;
}
|
php
|
public function register($alias, $source = null, $dependencies = [], $options = [])
{
$asset = $this->_factory->create($alias, $source, $dependencies, $options);
$this->_collection->add($asset);
return $this;
}
|
[
"public",
"function",
"register",
"(",
"$",
"alias",
",",
"$",
"source",
"=",
"null",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"asset",
"=",
"$",
"this",
"->",
"_factory",
"->",
"create",
"(",
"$",
"alias",
",",
"$",
"source",
",",
"$",
"dependencies",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"_collection",
"->",
"add",
"(",
"$",
"asset",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Registers an asset.
@param string $alias
@param null|string $source
@param array $dependencies
@param string|array $options
@return $this
|
[
"Registers",
"an",
"asset",
"."
] |
134a109378f5b5e955dfb15e6ed2821581564991
|
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L140-L146
|
22,462
|
JBZoo/Assets
|
src/Manager.php
|
Manager.unregister
|
public function unregister($alias)
{
$this->_collection->remove($alias);
$this->remove($alias);
return $this;
}
|
php
|
public function unregister($alias)
{
$this->_collection->remove($alias);
$this->remove($alias);
return $this;
}
|
[
"public",
"function",
"unregister",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"_collection",
"->",
"remove",
"(",
"$",
"alias",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"$",
"alias",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Unregisters an asset from collection.
@param string $alias
@return $this
|
[
"Unregisters",
"an",
"asset",
"from",
"collection",
"."
] |
134a109378f5b5e955dfb15e6ed2821581564991
|
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L154-L159
|
22,463
|
JBZoo/Assets
|
src/Manager.php
|
Manager.build
|
public function build(array $filters = [])
{
$assets = [];
foreach (array_keys($this->_queued) as $alias) {
$this->_resolveDependencies($this->_collection->get($alias), $assets);
}
/** @var Asset $asset */
$result = [
Asset::TYPE_JS_FILE => [],
Asset::TYPE_JS_CODE => [],
Asset::TYPE_JSX_FILE => [],
Asset::TYPE_JSX_CODE => [],
Asset::TYPE_CSS_FILE => [],
Asset::TYPE_CSS_CODE => [],
Asset::TYPE_CALLBACK => [],
];
foreach ($assets as $asset) {
$source = $asset->load($filters);
if (Asset::TYPE_COLLECTION === $source[0]) {
$source = $source[1];
} else {
$source = [$source];
}
foreach ($source as $sourceItem) {
$type = $sourceItem[0];
$src = $sourceItem[1];
if ($src && !Arr::in($src, $result[$type])) {
$result[$type][] = $src;
}
}
}
return $result;
}
|
php
|
public function build(array $filters = [])
{
$assets = [];
foreach (array_keys($this->_queued) as $alias) {
$this->_resolveDependencies($this->_collection->get($alias), $assets);
}
/** @var Asset $asset */
$result = [
Asset::TYPE_JS_FILE => [],
Asset::TYPE_JS_CODE => [],
Asset::TYPE_JSX_FILE => [],
Asset::TYPE_JSX_CODE => [],
Asset::TYPE_CSS_FILE => [],
Asset::TYPE_CSS_CODE => [],
Asset::TYPE_CALLBACK => [],
];
foreach ($assets as $asset) {
$source = $asset->load($filters);
if (Asset::TYPE_COLLECTION === $source[0]) {
$source = $source[1];
} else {
$source = [$source];
}
foreach ($source as $sourceItem) {
$type = $sourceItem[0];
$src = $sourceItem[1];
if ($src && !Arr::in($src, $result[$type])) {
$result[$type][] = $src;
}
}
}
return $result;
}
|
[
"public",
"function",
"build",
"(",
"array",
"$",
"filters",
"=",
"[",
"]",
")",
"{",
"$",
"assets",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_queued",
")",
"as",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"_resolveDependencies",
"(",
"$",
"this",
"->",
"_collection",
"->",
"get",
"(",
"$",
"alias",
")",
",",
"$",
"assets",
")",
";",
"}",
"/** @var Asset $asset */",
"$",
"result",
"=",
"[",
"Asset",
"::",
"TYPE_JS_FILE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_JS_CODE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_JSX_FILE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_JSX_CODE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_CSS_FILE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_CSS_CODE",
"=>",
"[",
"]",
",",
"Asset",
"::",
"TYPE_CALLBACK",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"assets",
"as",
"$",
"asset",
")",
"{",
"$",
"source",
"=",
"$",
"asset",
"->",
"load",
"(",
"$",
"filters",
")",
";",
"if",
"(",
"Asset",
"::",
"TYPE_COLLECTION",
"===",
"$",
"source",
"[",
"0",
"]",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"source",
"=",
"[",
"$",
"source",
"]",
";",
"}",
"foreach",
"(",
"$",
"source",
"as",
"$",
"sourceItem",
")",
"{",
"$",
"type",
"=",
"$",
"sourceItem",
"[",
"0",
"]",
";",
"$",
"src",
"=",
"$",
"sourceItem",
"[",
"1",
"]",
";",
"if",
"(",
"$",
"src",
"&&",
"!",
"Arr",
"::",
"in",
"(",
"$",
"src",
",",
"$",
"result",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"type",
"]",
"[",
"]",
"=",
"$",
"src",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Build assets.
@param array $filters
@return array
|
[
"Build",
"assets",
"."
] |
134a109378f5b5e955dfb15e6ed2821581564991
|
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L187-L226
|
22,464
|
JBZoo/Assets
|
src/Manager.php
|
Manager._resolveDependencies
|
protected function _resolveDependencies(Asset $asset, &$resolved = [], &$unresolved = [])
{
$unresolved[$asset->getAlias()] = $asset;
foreach ($asset->getDependencies() as $dependency) {
if (!Arr::key($dependency, $resolved)) {
if (isset($unresolved[$dependency])) {
throw new Exception(sprintf(
'Circular asset dependency "%s > %s" detected.',
$asset->getAlias(),
$dependency
));
}
if ($dep = $this->_collection->get($dependency)) {
$this->_resolveDependencies($dep, $resolved, $unresolved);
} else {
throw new Exception("Undefined depends: $dependency");
}
}
}
$resolved[$asset->getAlias()] = $asset;
unset($unresolved[$asset->getAlias()]);
return $resolved;
}
|
php
|
protected function _resolveDependencies(Asset $asset, &$resolved = [], &$unresolved = [])
{
$unresolved[$asset->getAlias()] = $asset;
foreach ($asset->getDependencies() as $dependency) {
if (!Arr::key($dependency, $resolved)) {
if (isset($unresolved[$dependency])) {
throw new Exception(sprintf(
'Circular asset dependency "%s > %s" detected.',
$asset->getAlias(),
$dependency
));
}
if ($dep = $this->_collection->get($dependency)) {
$this->_resolveDependencies($dep, $resolved, $unresolved);
} else {
throw new Exception("Undefined depends: $dependency");
}
}
}
$resolved[$asset->getAlias()] = $asset;
unset($unresolved[$asset->getAlias()]);
return $resolved;
}
|
[
"protected",
"function",
"_resolveDependencies",
"(",
"Asset",
"$",
"asset",
",",
"&",
"$",
"resolved",
"=",
"[",
"]",
",",
"&",
"$",
"unresolved",
"=",
"[",
"]",
")",
"{",
"$",
"unresolved",
"[",
"$",
"asset",
"->",
"getAlias",
"(",
")",
"]",
"=",
"$",
"asset",
";",
"foreach",
"(",
"$",
"asset",
"->",
"getDependencies",
"(",
")",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"Arr",
"::",
"key",
"(",
"$",
"dependency",
",",
"$",
"resolved",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"unresolved",
"[",
"$",
"dependency",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'Circular asset dependency \"%s > %s\" detected.'",
",",
"$",
"asset",
"->",
"getAlias",
"(",
")",
",",
"$",
"dependency",
")",
")",
";",
"}",
"if",
"(",
"$",
"dep",
"=",
"$",
"this",
"->",
"_collection",
"->",
"get",
"(",
"$",
"dependency",
")",
")",
"{",
"$",
"this",
"->",
"_resolveDependencies",
"(",
"$",
"dep",
",",
"$",
"resolved",
",",
"$",
"unresolved",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Undefined depends: $dependency\"",
")",
";",
"}",
"}",
"}",
"$",
"resolved",
"[",
"$",
"asset",
"->",
"getAlias",
"(",
")",
"]",
"=",
"$",
"asset",
";",
"unset",
"(",
"$",
"unresolved",
"[",
"$",
"asset",
"->",
"getAlias",
"(",
")",
"]",
")",
";",
"return",
"$",
"resolved",
";",
"}"
] |
Resolves asset dependencies.
@param Asset|null $asset
@param Asset[] $resolved
@param Asset[] $unresolved
@return Asset[]
@throws Exception
|
[
"Resolves",
"asset",
"dependencies",
"."
] |
134a109378f5b5e955dfb15e6ed2821581564991
|
https://github.com/JBZoo/Assets/blob/134a109378f5b5e955dfb15e6ed2821581564991/src/Manager.php#L237-L264
|
22,465
|
mslib/resource-proxy
|
Msl/ResourceProxy/Resource/Email/Message.php
|
Message.init
|
public function init($sourceId, $resourceId, $resource)
{
// Setting unique source and resource ids
$this->resourceId = $resourceId;
$this->sourceId = $sourceId;
// Setting message object
if (!$resource instanceof ZendMessage) {
throw new BadResourceConfigurationException(
sprintf(
'Remote resource handler is expected to be an instance of \'\Zend\Mail\Storage\Message\', but got \'%s\'.',
get_class($resource)
)
);
}
$this->message = $resource;
}
|
php
|
public function init($sourceId, $resourceId, $resource)
{
// Setting unique source and resource ids
$this->resourceId = $resourceId;
$this->sourceId = $sourceId;
// Setting message object
if (!$resource instanceof ZendMessage) {
throw new BadResourceConfigurationException(
sprintf(
'Remote resource handler is expected to be an instance of \'\Zend\Mail\Storage\Message\', but got \'%s\'.',
get_class($resource)
)
);
}
$this->message = $resource;
}
|
[
"public",
"function",
"init",
"(",
"$",
"sourceId",
",",
"$",
"resourceId",
",",
"$",
"resource",
")",
"{",
"// Setting unique source and resource ids",
"$",
"this",
"->",
"resourceId",
"=",
"$",
"resourceId",
";",
"$",
"this",
"->",
"sourceId",
"=",
"$",
"sourceId",
";",
"// Setting message object",
"if",
"(",
"!",
"$",
"resource",
"instanceof",
"ZendMessage",
")",
"{",
"throw",
"new",
"BadResourceConfigurationException",
"(",
"sprintf",
"(",
"'Remote resource handler is expected to be an instance of \\'\\Zend\\Mail\\Storage\\Message\\', but got \\'%s\\'.'",
",",
"get_class",
"(",
"$",
"resource",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"message",
"=",
"$",
"resource",
";",
"}"
] |
Initializes a Resource object
@param string $sourceId the source id for this resource (the source being the remote server in which the resource is allocated)
@param string $resourceId the resource id for the given resource object
@param mixed $resource the remote resource handler object (e.g. \Zend\Mail\Storage\Message)
@throws BadResourceConfigurationException
@return void
|
[
"Initializes",
"a",
"Resource",
"object"
] |
be3f8589753f738f5114443a3465f5e84aecd156
|
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L79-L95
|
22,466
|
mslib/resource-proxy
|
Msl/ResourceProxy/Resource/Email/Message.php
|
Message.moveToOutputFolder
|
public function moveToOutputFolder($outputFolder)
{
try {
if ($this->message->isMultipart()) {
// Getting the resource content (subject + body of the email)
$contentPart = $this->message->getPart(1);
$content = $contentPart->getContent();
// Check for attachment
// Getting second part of message object
$part = $this->message->getPart(2);
// Get the attachment file name
if ($part->getHeaders()->has('Content-Disposition')) {
$fileName = $part->getHeaderField('Content-Disposition', 'filename');
// Get the attachment and decode
$attachment = base64_decode($part->getContent());
// Save the attachment
$attachmentFileName = $this->getAttachmentFileName($fileName, $outputFolder);
$finalAttOutputDirectory = $this->getAttachmentFileFolder($outputFolder);
if (!file_exists($finalAttOutputDirectory)) {
mkdir($finalAttOutputDirectory, 0775, true);
}
file_put_contents($attachmentFileName, $attachment);
}
} else {
// Getting the resource content (subject + body of the email)
$content = $this->message->getContent();
}
// Writing content to file
// Setting the file name (output folder + message sub folder + current object string representation + timestamp)
$outputFileName = $this->getContentFileName($outputFolder);
// Writing the content to the output file
$finalOutputDirectory = $this->getContentFileFolder($outputFolder);
if (!file_exists($finalOutputDirectory)) {
mkdir($finalOutputDirectory, 0775, true);
}
file_put_contents($outputFileName, $content);
} catch (\Exception $e) {
throw new Exception\ResourceMoveContentException(
sprintf(
'Error while moving the content of resource \'%s\' to the output folder \'%s\'. Error message is: \'%s\'.',
$this->toString(),
$outputFolder,
$e->getMessage()
)
);
}
return true;
}
|
php
|
public function moveToOutputFolder($outputFolder)
{
try {
if ($this->message->isMultipart()) {
// Getting the resource content (subject + body of the email)
$contentPart = $this->message->getPart(1);
$content = $contentPart->getContent();
// Check for attachment
// Getting second part of message object
$part = $this->message->getPart(2);
// Get the attachment file name
if ($part->getHeaders()->has('Content-Disposition')) {
$fileName = $part->getHeaderField('Content-Disposition', 'filename');
// Get the attachment and decode
$attachment = base64_decode($part->getContent());
// Save the attachment
$attachmentFileName = $this->getAttachmentFileName($fileName, $outputFolder);
$finalAttOutputDirectory = $this->getAttachmentFileFolder($outputFolder);
if (!file_exists($finalAttOutputDirectory)) {
mkdir($finalAttOutputDirectory, 0775, true);
}
file_put_contents($attachmentFileName, $attachment);
}
} else {
// Getting the resource content (subject + body of the email)
$content = $this->message->getContent();
}
// Writing content to file
// Setting the file name (output folder + message sub folder + current object string representation + timestamp)
$outputFileName = $this->getContentFileName($outputFolder);
// Writing the content to the output file
$finalOutputDirectory = $this->getContentFileFolder($outputFolder);
if (!file_exists($finalOutputDirectory)) {
mkdir($finalOutputDirectory, 0775, true);
}
file_put_contents($outputFileName, $content);
} catch (\Exception $e) {
throw new Exception\ResourceMoveContentException(
sprintf(
'Error while moving the content of resource \'%s\' to the output folder \'%s\'. Error message is: \'%s\'.',
$this->toString(),
$outputFolder,
$e->getMessage()
)
);
}
return true;
}
|
[
"public",
"function",
"moveToOutputFolder",
"(",
"$",
"outputFolder",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"message",
"->",
"isMultipart",
"(",
")",
")",
"{",
"// Getting the resource content (subject + body of the email)",
"$",
"contentPart",
"=",
"$",
"this",
"->",
"message",
"->",
"getPart",
"(",
"1",
")",
";",
"$",
"content",
"=",
"$",
"contentPart",
"->",
"getContent",
"(",
")",
";",
"// Check for attachment",
"// Getting second part of message object",
"$",
"part",
"=",
"$",
"this",
"->",
"message",
"->",
"getPart",
"(",
"2",
")",
";",
"// Get the attachment file name",
"if",
"(",
"$",
"part",
"->",
"getHeaders",
"(",
")",
"->",
"has",
"(",
"'Content-Disposition'",
")",
")",
"{",
"$",
"fileName",
"=",
"$",
"part",
"->",
"getHeaderField",
"(",
"'Content-Disposition'",
",",
"'filename'",
")",
";",
"// Get the attachment and decode",
"$",
"attachment",
"=",
"base64_decode",
"(",
"$",
"part",
"->",
"getContent",
"(",
")",
")",
";",
"// Save the attachment",
"$",
"attachmentFileName",
"=",
"$",
"this",
"->",
"getAttachmentFileName",
"(",
"$",
"fileName",
",",
"$",
"outputFolder",
")",
";",
"$",
"finalAttOutputDirectory",
"=",
"$",
"this",
"->",
"getAttachmentFileFolder",
"(",
"$",
"outputFolder",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"finalAttOutputDirectory",
")",
")",
"{",
"mkdir",
"(",
"$",
"finalAttOutputDirectory",
",",
"0775",
",",
"true",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"attachmentFileName",
",",
"$",
"attachment",
")",
";",
"}",
"}",
"else",
"{",
"// Getting the resource content (subject + body of the email)",
"$",
"content",
"=",
"$",
"this",
"->",
"message",
"->",
"getContent",
"(",
")",
";",
"}",
"// Writing content to file",
"// Setting the file name (output folder + message sub folder + current object string representation + timestamp)",
"$",
"outputFileName",
"=",
"$",
"this",
"->",
"getContentFileName",
"(",
"$",
"outputFolder",
")",
";",
"// Writing the content to the output file",
"$",
"finalOutputDirectory",
"=",
"$",
"this",
"->",
"getContentFileFolder",
"(",
"$",
"outputFolder",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"finalOutputDirectory",
")",
")",
"{",
"mkdir",
"(",
"$",
"finalOutputDirectory",
",",
"0775",
",",
"true",
")",
";",
"}",
"file_put_contents",
"(",
"$",
"outputFileName",
",",
"$",
"content",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ResourceMoveContentException",
"(",
"sprintf",
"(",
"'Error while moving the content of resource \\'%s\\' to the output folder \\'%s\\'. Error message is: \\'%s\\'.'",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"$",
"outputFolder",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Saves the current resource to the given path. Returns true if move action was successful; false otherwise.
@param string $outputFolder the output folder path for this resource
@throws \Msl\ResourceProxy\Exception\ResourceMoveContentException
@return bool
|
[
"Saves",
"the",
"current",
"resource",
"to",
"the",
"given",
"path",
".",
"Returns",
"true",
"if",
"move",
"action",
"was",
"successful",
";",
"false",
"otherwise",
"."
] |
be3f8589753f738f5114443a3465f5e84aecd156
|
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L109-L161
|
22,467
|
mslib/resource-proxy
|
Msl/ResourceProxy/Resource/Email/Message.php
|
Message.getContentFileName
|
protected function getContentFileName($outputFolder)
{
// Returning the content file name (output folder + message sub folder + current object string representation + timestamp)
return sprintf(
"%s%s%s_%s",
$this->getContentFileFolder($outputFolder),
DIRECTORY_SEPARATOR,
$this->toString(),
time()
);
}
|
php
|
protected function getContentFileName($outputFolder)
{
// Returning the content file name (output folder + message sub folder + current object string representation + timestamp)
return sprintf(
"%s%s%s_%s",
$this->getContentFileFolder($outputFolder),
DIRECTORY_SEPARATOR,
$this->toString(),
time()
);
}
|
[
"protected",
"function",
"getContentFileName",
"(",
"$",
"outputFolder",
")",
"{",
"// Returning the content file name (output folder + message sub folder + current object string representation + timestamp)",
"return",
"sprintf",
"(",
"\"%s%s%s_%s\"",
",",
"$",
"this",
"->",
"getContentFileFolder",
"(",
"$",
"outputFolder",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"time",
"(",
")",
")",
";",
"}"
] |
Returns the content file name as the concatenation of the given output folder + message sub folder + current object string representation + timestamp.
@param string $outputFolder the output folder
@return string
|
[
"Returns",
"the",
"content",
"file",
"name",
"as",
"the",
"concatenation",
"of",
"the",
"given",
"output",
"folder",
"+",
"message",
"sub",
"folder",
"+",
"current",
"object",
"string",
"representation",
"+",
"timestamp",
"."
] |
be3f8589753f738f5114443a3465f5e84aecd156
|
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L229-L239
|
22,468
|
mslib/resource-proxy
|
Msl/ResourceProxy/Resource/Email/Message.php
|
Message.getAttachmentFileName
|
protected function getAttachmentFileName($originalAttachmentFileName, $baseOutputFolder)
{
// Getting extension from original file name
$pathInfo = pathinfo($originalAttachmentFileName);
$extension = '';
if (isset($pathInfo['extension'])) {
$extension = $pathInfo['extension'];
}
// Returning the attachment file name (output folder + message sub folder + message attachment sub folder
// + original attachment file name + current object string representation + timestamp + extension)
$attachmentFileName = sprintf(
"%s%s%s_%s_%s.%s",
$this->getAttachmentFileFolder($baseOutputFolder),
DIRECTORY_SEPARATOR,
$pathInfo['filename'],
$this->toString(),
time(),
$extension
);
return rtrim($attachmentFileName, '.');
}
|
php
|
protected function getAttachmentFileName($originalAttachmentFileName, $baseOutputFolder)
{
// Getting extension from original file name
$pathInfo = pathinfo($originalAttachmentFileName);
$extension = '';
if (isset($pathInfo['extension'])) {
$extension = $pathInfo['extension'];
}
// Returning the attachment file name (output folder + message sub folder + message attachment sub folder
// + original attachment file name + current object string representation + timestamp + extension)
$attachmentFileName = sprintf(
"%s%s%s_%s_%s.%s",
$this->getAttachmentFileFolder($baseOutputFolder),
DIRECTORY_SEPARATOR,
$pathInfo['filename'],
$this->toString(),
time(),
$extension
);
return rtrim($attachmentFileName, '.');
}
|
[
"protected",
"function",
"getAttachmentFileName",
"(",
"$",
"originalAttachmentFileName",
",",
"$",
"baseOutputFolder",
")",
"{",
"// Getting extension from original file name",
"$",
"pathInfo",
"=",
"pathinfo",
"(",
"$",
"originalAttachmentFileName",
")",
";",
"$",
"extension",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"pathInfo",
"[",
"'extension'",
"]",
")",
")",
"{",
"$",
"extension",
"=",
"$",
"pathInfo",
"[",
"'extension'",
"]",
";",
"}",
"// Returning the attachment file name (output folder + message sub folder + message attachment sub folder",
"// + original attachment file name + current object string representation + timestamp + extension)",
"$",
"attachmentFileName",
"=",
"sprintf",
"(",
"\"%s%s%s_%s_%s.%s\"",
",",
"$",
"this",
"->",
"getAttachmentFileFolder",
"(",
"$",
"baseOutputFolder",
")",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"pathInfo",
"[",
"'filename'",
"]",
",",
"$",
"this",
"->",
"toString",
"(",
")",
",",
"time",
"(",
")",
",",
"$",
"extension",
")",
";",
"return",
"rtrim",
"(",
"$",
"attachmentFileName",
",",
"'.'",
")",
";",
"}"
] |
Returns the attachment file name as the concatenation of the given output folder + message sub folder + current object string representation + timestamp.
@param string $originalAttachmentFileName the base attachment file name
@param string $baseOutputFolder the base output folder
@return string
|
[
"Returns",
"the",
"attachment",
"file",
"name",
"as",
"the",
"concatenation",
"of",
"the",
"given",
"output",
"folder",
"+",
"message",
"sub",
"folder",
"+",
"current",
"object",
"string",
"representation",
"+",
"timestamp",
"."
] |
be3f8589753f738f5114443a3465f5e84aecd156
|
https://github.com/mslib/resource-proxy/blob/be3f8589753f738f5114443a3465f5e84aecd156/Msl/ResourceProxy/Resource/Email/Message.php#L266-L286
|
22,469
|
xiewulong/yii2-fileupload
|
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php
|
WinCacheClassLoader.findFile
|
public function findFile($class)
{
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
}
return $file;
}
|
php
|
public function findFile($class)
{
if (false === $file = wincache_ucache_get($this->prefix.$class)) {
wincache_ucache_set($this->prefix.$class, $file = $this->decorated->findFile($class), 0);
}
return $file;
}
|
[
"public",
"function",
"findFile",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"file",
"=",
"wincache_ucache_get",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
")",
")",
"{",
"wincache_ucache_set",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"class",
",",
"$",
"file",
"=",
"$",
"this",
"->",
"decorated",
"->",
"findFile",
"(",
"$",
"class",
")",
",",
"0",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
Finds a file by class name while caching lookups to WinCache.
@param string $class A class name to resolve to file
@return string|null
|
[
"Finds",
"a",
"file",
"by",
"class",
"name",
"while",
"caching",
"lookups",
"to",
"WinCache",
"."
] |
3e75b17a4a18dd8466e3f57c63136de03470ca82
|
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/WinCacheClassLoader.php#L117-L124
|
22,470
|
trunda/SmfMenu
|
src/Smf/Menu/Renderer/ListRenderer.php
|
ListRenderer.render
|
public function render(ItemInterface $item, array $options = array())
{
$options = array_merge($this->defaultOptions, $options);
$options['rootLevel'] = $item->getLevel();
return $this->getMenu($item, $options) ?: '';
}
|
php
|
public function render(ItemInterface $item, array $options = array())
{
$options = array_merge($this->defaultOptions, $options);
$options['rootLevel'] = $item->getLevel();
return $this->getMenu($item, $options) ?: '';
}
|
[
"public",
"function",
"render",
"(",
"ItemInterface",
"$",
"item",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"defaultOptions",
",",
"$",
"options",
")",
";",
"$",
"options",
"[",
"'rootLevel'",
"]",
"=",
"$",
"item",
"->",
"getLevel",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getMenu",
"(",
"$",
"item",
",",
"$",
"options",
")",
"?",
":",
"''",
";",
"}"
] |
Renders menu tree.
Common options:
- depth: The depth at which the item is rendered
null: no limit
0: no children
1: only direct children
- currentAsLink: whether the current item should be a link
- currentClass: class added to the current item
- ancestorClass: class added to the ancestors of the current item
- firstClass: class added to the first child
- lastClass: class added to the last child
@param ItemInterface $item Menu item
@param array $options some rendering options
@return string
|
[
"Renders",
"menu",
"tree",
"."
] |
739e74fb664c1f018b4a74142bd28d20c004bac6
|
https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Renderer/ListRenderer.php#L74-L79
|
22,471
|
trunda/SmfMenu
|
src/Smf/Menu/Renderer/ListRenderer.php
|
ListRenderer.setParentControl
|
public function setParentControl(Control $parentControl = null)
{
$this->parentControl = $parentControl;
$this->matcher->setParentControl($parentControl);
}
|
php
|
public function setParentControl(Control $parentControl = null)
{
$this->parentControl = $parentControl;
$this->matcher->setParentControl($parentControl);
}
|
[
"public",
"function",
"setParentControl",
"(",
"Control",
"$",
"parentControl",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"parentControl",
"=",
"$",
"parentControl",
";",
"$",
"this",
"->",
"matcher",
"->",
"setParentControl",
"(",
"$",
"parentControl",
")",
";",
"}"
] |
Sets the parent control - this is important for link generation
@param Control $parentControl
|
[
"Sets",
"the",
"parent",
"control",
"-",
"this",
"is",
"important",
"for",
"link",
"generation"
] |
739e74fb664c1f018b4a74142bd28d20c004bac6
|
https://github.com/trunda/SmfMenu/blob/739e74fb664c1f018b4a74142bd28d20c004bac6/src/Smf/Menu/Renderer/ListRenderer.php#L266-L270
|
22,472
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_mssql.php
|
ezcQueryExpressionMssql.concat
|
public function concat()
{
$args = func_get_args();
$cols = ezcQuerySelect::arrayFlatten( $args );
if ( count( $cols ) < 1 )
{
throw new ezcQueryVariableParameterException( 'concat', count( $args ), 1 );
}
$cols = $this->getIdentifiers( $cols );
return join( ' + ', $cols );
}
|
php
|
public function concat()
{
$args = func_get_args();
$cols = ezcQuerySelect::arrayFlatten( $args );
if ( count( $cols ) < 1 )
{
throw new ezcQueryVariableParameterException( 'concat', count( $args ), 1 );
}
$cols = $this->getIdentifiers( $cols );
return join( ' + ', $cols );
}
|
[
"public",
"function",
"concat",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"cols",
"=",
"ezcQuerySelect",
"::",
"arrayFlatten",
"(",
"$",
"args",
")",
";",
"if",
"(",
"count",
"(",
"$",
"cols",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"ezcQueryVariableParameterException",
"(",
"'concat'",
",",
"count",
"(",
"$",
"args",
")",
",",
"1",
")",
";",
"}",
"$",
"cols",
"=",
"$",
"this",
"->",
"getIdentifiers",
"(",
"$",
"cols",
")",
";",
"return",
"join",
"(",
"' + '",
",",
"$",
"cols",
")",
";",
"}"
] |
Returns a series of strings concatinated
concat() accepts an arbitrary number of parameters. Each parameter
must contain an expression or an array with expressions.
@param string|array(string) $... strings that will be concatinated.
|
[
"Returns",
"a",
"series",
"of",
"strings",
"concatinated"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_mssql.php#L132-L144
|
22,473
|
inhere/php-librarys
|
src/Components/LiteErrorHandler.php
|
LiteErrorHandler.register
|
public function register()
{
$that = $this;
set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
if (!($errno & error_reporting())) {
return;
}
$options = [
'type' => $errno,
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'isError' => true,
];
$that->handle(new ErrorPayload($options));
});
set_exception_handler(function ($e) use ($that) {
/** @var \Exception|\Error $e */
$options = [
'type' => $e->getCode(),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'isException' => true,
'exception' => $e,
];
$that->handle(new ErrorPayload($options));
});
register_shutdown_function(function () use ($that) {
if (null !== ($options = error_get_last())) {
$that->handle(new ErrorPayload($options));
}
});
}
|
php
|
public function register()
{
$that = $this;
set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($that) {
if (!($errno & error_reporting())) {
return;
}
$options = [
'type' => $errno,
'message' => $errstr,
'file' => $errfile,
'line' => $errline,
'isError' => true,
];
$that->handle(new ErrorPayload($options));
});
set_exception_handler(function ($e) use ($that) {
/** @var \Exception|\Error $e */
$options = [
'type' => $e->getCode(),
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'isException' => true,
'exception' => $e,
];
$that->handle(new ErrorPayload($options));
});
register_shutdown_function(function () use ($that) {
if (null !== ($options = error_get_last())) {
$that->handle(new ErrorPayload($options));
}
});
}
|
[
"public",
"function",
"register",
"(",
")",
"{",
"$",
"that",
"=",
"$",
"this",
";",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"use",
"(",
"$",
"that",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"errno",
"&",
"error_reporting",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"options",
"=",
"[",
"'type'",
"=>",
"$",
"errno",
",",
"'message'",
"=>",
"$",
"errstr",
",",
"'file'",
"=>",
"$",
"errfile",
",",
"'line'",
"=>",
"$",
"errline",
",",
"'isError'",
"=>",
"true",
",",
"]",
";",
"$",
"that",
"->",
"handle",
"(",
"new",
"ErrorPayload",
"(",
"$",
"options",
")",
")",
";",
"}",
")",
";",
"set_exception_handler",
"(",
"function",
"(",
"$",
"e",
")",
"use",
"(",
"$",
"that",
")",
"{",
"/** @var \\Exception|\\Error $e */",
"$",
"options",
"=",
"[",
"'type'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'file'",
"=>",
"$",
"e",
"->",
"getFile",
"(",
")",
",",
"'line'",
"=>",
"$",
"e",
"->",
"getLine",
"(",
")",
",",
"'isException'",
"=>",
"true",
",",
"'exception'",
"=>",
"$",
"e",
",",
"]",
";",
"$",
"that",
"->",
"handle",
"(",
"new",
"ErrorPayload",
"(",
"$",
"options",
")",
")",
";",
"}",
")",
";",
"register_shutdown_function",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"that",
")",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"options",
"=",
"error_get_last",
"(",
")",
")",
")",
"{",
"$",
"that",
"->",
"handle",
"(",
"new",
"ErrorPayload",
"(",
"$",
"options",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Registers itself as error and exception handler.
|
[
"Registers",
"itself",
"as",
"error",
"and",
"exception",
"handler",
"."
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/LiteErrorHandler.php#L23-L59
|
22,474
|
inhere/php-librarys
|
src/Components/LiteErrorHandler.php
|
LiteErrorHandler.mapErrorsToLogType
|
public function mapErrorsToLogType($code)
{
switch ($code) {
case E_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
return Logger::ERROR;
case E_WARNING:
case E_USER_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
return Logger::WARNING;
case E_NOTICE:
case E_USER_NOTICE:
return Logger::NOTICE;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
return Logger::INFO;
}
return Logger::ERROR;
}
|
php
|
public function mapErrorsToLogType($code)
{
switch ($code) {
case E_ERROR:
case E_RECOVERABLE_ERROR:
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
case E_PARSE:
return Logger::ERROR;
case E_WARNING:
case E_USER_WARNING:
case E_CORE_WARNING:
case E_COMPILE_WARNING:
return Logger::WARNING;
case E_NOTICE:
case E_USER_NOTICE:
return Logger::NOTICE;
case E_STRICT:
case E_DEPRECATED:
case E_USER_DEPRECATED:
return Logger::INFO;
}
return Logger::ERROR;
}
|
[
"public",
"function",
"mapErrorsToLogType",
"(",
"$",
"code",
")",
"{",
"switch",
"(",
"$",
"code",
")",
"{",
"case",
"E_ERROR",
":",
"case",
"E_RECOVERABLE_ERROR",
":",
"case",
"E_CORE_ERROR",
":",
"case",
"E_COMPILE_ERROR",
":",
"case",
"E_USER_ERROR",
":",
"case",
"E_PARSE",
":",
"return",
"Logger",
"::",
"ERROR",
";",
"case",
"E_WARNING",
":",
"case",
"E_USER_WARNING",
":",
"case",
"E_CORE_WARNING",
":",
"case",
"E_COMPILE_WARNING",
":",
"return",
"Logger",
"::",
"WARNING",
";",
"case",
"E_NOTICE",
":",
"case",
"E_USER_NOTICE",
":",
"return",
"Logger",
"::",
"NOTICE",
";",
"case",
"E_STRICT",
":",
"case",
"E_DEPRECATED",
":",
"case",
"E_USER_DEPRECATED",
":",
"return",
"Logger",
"::",
"INFO",
";",
"}",
"return",
"Logger",
"::",
"ERROR",
";",
"}"
] |
Maps error code to a log type.
@param integer $code
@return integer
|
[
"Maps",
"error",
"code",
"to",
"a",
"log",
"type",
"."
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Components/LiteErrorHandler.php#L146-L171
|
22,475
|
antaresproject/notifications
|
src/Widgets/NotificationSender/Controller/NotificationController.php
|
NotificationController.fire
|
protected function fire(Model $model) : array
{
$recipient = $this->getRecipient();
if ($recipient->phone === null) {
$recipient->phone = config('antares/notifications::default.sms');
}
$params = ['variables' => ['user' => $recipient], 'recipients' => [$recipient]];
return event($model->event, $params);
}
|
php
|
protected function fire(Model $model) : array
{
$recipient = $this->getRecipient();
if ($recipient->phone === null) {
$recipient->phone = config('antares/notifications::default.sms');
}
$params = ['variables' => ['user' => $recipient], 'recipients' => [$recipient]];
return event($model->event, $params);
}
|
[
"protected",
"function",
"fire",
"(",
"Model",
"$",
"model",
")",
":",
"array",
"{",
"$",
"recipient",
"=",
"$",
"this",
"->",
"getRecipient",
"(",
")",
";",
"if",
"(",
"$",
"recipient",
"->",
"phone",
"===",
"null",
")",
"{",
"$",
"recipient",
"->",
"phone",
"=",
"config",
"(",
"'antares/notifications::default.sms'",
")",
";",
"}",
"$",
"params",
"=",
"[",
"'variables'",
"=>",
"[",
"'user'",
"=>",
"$",
"recipient",
"]",
",",
"'recipients'",
"=>",
"[",
"$",
"recipient",
"]",
"]",
";",
"return",
"event",
"(",
"$",
"model",
"->",
"event",
",",
"$",
"params",
")",
";",
"}"
] |
Fires notification events
@param Model $model
@return array
|
[
"Fires",
"notification",
"events"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/Controller/NotificationController.php#L107-L118
|
22,476
|
antaresproject/notifications
|
src/Widgets/NotificationSender/Controller/NotificationController.php
|
NotificationController.getRecipient
|
protected function getRecipient()
{
if (Input::get('test')) {
return user();
}
$route = app('router')->getRoutes()->match(app('request')->create(url()->previous()));
return (in_array('users', $route->parameterNames()) && $uid = $route->parameter('users')) ? user()->newQuery()->findOrFail($uid) : user();
}
|
php
|
protected function getRecipient()
{
if (Input::get('test')) {
return user();
}
$route = app('router')->getRoutes()->match(app('request')->create(url()->previous()));
return (in_array('users', $route->parameterNames()) && $uid = $route->parameter('users')) ? user()->newQuery()->findOrFail($uid) : user();
}
|
[
"protected",
"function",
"getRecipient",
"(",
")",
"{",
"if",
"(",
"Input",
"::",
"get",
"(",
"'test'",
")",
")",
"{",
"return",
"user",
"(",
")",
";",
"}",
"$",
"route",
"=",
"app",
"(",
"'router'",
")",
"->",
"getRoutes",
"(",
")",
"->",
"match",
"(",
"app",
"(",
"'request'",
")",
"->",
"create",
"(",
"url",
"(",
")",
"->",
"previous",
"(",
")",
")",
")",
";",
"return",
"(",
"in_array",
"(",
"'users'",
",",
"$",
"route",
"->",
"parameterNames",
"(",
")",
")",
"&&",
"$",
"uid",
"=",
"$",
"route",
"->",
"parameter",
"(",
"'users'",
")",
")",
"?",
"user",
"(",
")",
"->",
"newQuery",
"(",
")",
"->",
"findOrFail",
"(",
"$",
"uid",
")",
":",
"user",
"(",
")",
";",
"}"
] |
Gets recipient for notification
@return \Illuminate\Database\Eloquent\Model
|
[
"Gets",
"recipient",
"for",
"notification"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Widgets/NotificationSender/Controller/NotificationController.php#L125-L132
|
22,477
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.emoticonsToHtml
|
public static function emoticonsToHtml($str)
{
$str = str_replace (" :)", ' <img src="/media/emot/icon_biggrin.gif" alt="big_grin" />', $str);
$str = str_replace (" :(", ' <img src="/media/emot/icon_cry.gif" alt="cry" />', $str);
$str = str_replace (" ;)", ' <img src="/media/emot/icon_wink.gif" alt="wink" />', $str);
$str = str_replace (" 8*", ' <img src="/media/emot/icon_eek.gif" alt="eek" />', $str);
return $str;
}
|
php
|
public static function emoticonsToHtml($str)
{
$str = str_replace (" :)", ' <img src="/media/emot/icon_biggrin.gif" alt="big_grin" />', $str);
$str = str_replace (" :(", ' <img src="/media/emot/icon_cry.gif" alt="cry" />', $str);
$str = str_replace (" ;)", ' <img src="/media/emot/icon_wink.gif" alt="wink" />', $str);
$str = str_replace (" 8*", ' <img src="/media/emot/icon_eek.gif" alt="eek" />', $str);
return $str;
}
|
[
"public",
"static",
"function",
"emoticonsToHtml",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"\" :)\"",
",",
"' <img src=\"/media/emot/icon_biggrin.gif\" alt=\"big_grin\" />'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"\" :(\"",
",",
"' <img src=\"/media/emot/icon_cry.gif\" alt=\"cry\" />'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"\" ;)\"",
",",
"' <img src=\"/media/emot/icon_wink.gif\" alt=\"wink\" />'",
",",
"$",
"str",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"\" 8*\"",
",",
"' <img src=\"/media/emot/icon_eek.gif\" alt=\"eek\" />'",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Converts emoticons shortcuts to images
@param string $str
@return string
|
[
"Converts",
"emoticons",
"shortcuts",
"to",
"images"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L55-L64
|
22,478
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.clean
|
public static function clean($str, $allow_email=false)
{
$str = self::typoFix($str);
$str = \sb\String\HTML::escape($str);
$str = self::convertQuotes($str);
$str = self::listsToHtml($str);
$str = self::tablesToHtml($str);
$str = self::linksToHtml($str, $allow_email);
$str = self::colorizeInstantMessages($str);
$str = self::textStyles($str);
$str = self::parseCss($str);
$str = self::addSearches($str);
$str = self::miscTags($str);
//turn any tabs into 4 spaces
$str = str_replace("\t", " ", $str);
return $str;
}
|
php
|
public static function clean($str, $allow_email=false)
{
$str = self::typoFix($str);
$str = \sb\String\HTML::escape($str);
$str = self::convertQuotes($str);
$str = self::listsToHtml($str);
$str = self::tablesToHtml($str);
$str = self::linksToHtml($str, $allow_email);
$str = self::colorizeInstantMessages($str);
$str = self::textStyles($str);
$str = self::parseCss($str);
$str = self::addSearches($str);
$str = self::miscTags($str);
//turn any tabs into 4 spaces
$str = str_replace("\t", " ", $str);
return $str;
}
|
[
"public",
"static",
"function",
"clean",
"(",
"$",
"str",
",",
"$",
"allow_email",
"=",
"false",
")",
"{",
"$",
"str",
"=",
"self",
"::",
"typoFix",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"\\",
"sb",
"\\",
"String",
"\\",
"HTML",
"::",
"escape",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"convertQuotes",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"listsToHtml",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"tablesToHtml",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"linksToHtml",
"(",
"$",
"str",
",",
"$",
"allow_email",
")",
";",
"$",
"str",
"=",
"self",
"::",
"colorizeInstantMessages",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"textStyles",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"parseCss",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"addSearches",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"miscTags",
"(",
"$",
"str",
")",
";",
"//turn any tabs into 4 spaces",
"$",
"str",
"=",
"str_replace",
"(",
"\"\\t\"",
",",
"\" \"",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Clean up the text according to the textBling rules
@param string $str The text to clean
@param boolean $media Determines if media is parsed into html
@return string The cleaned text
|
[
"Clean",
"up",
"the",
"text",
"according",
"to",
"the",
"textBling",
"rules"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L88-L117
|
22,479
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.miscTags
|
public static function miscTags($str)
{
##hortizontal row
$str = str_replace('[hr]', '<hr style="clear:both;" />', $str);
##line break
$str = str_replace('[br]', '<br />', $str);
##puttext inside a scrolling box
$str = preg_replace( "~\[box\]\n?(.*?)\n?\[\/box\]\n{1,}?~is", "<div class=\"box\">\\1</div>", $str);
return $str;
}
|
php
|
public static function miscTags($str)
{
##hortizontal row
$str = str_replace('[hr]', '<hr style="clear:both;" />', $str);
##line break
$str = str_replace('[br]', '<br />', $str);
##puttext inside a scrolling box
$str = preg_replace( "~\[box\]\n?(.*?)\n?\[\/box\]\n{1,}?~is", "<div class=\"box\">\\1</div>", $str);
return $str;
}
|
[
"public",
"static",
"function",
"miscTags",
"(",
"$",
"str",
")",
"{",
"##hortizontal row",
"$",
"str",
"=",
"str_replace",
"(",
"'[hr]'",
",",
"'<hr style=\"clear:both;\" />'",
",",
"$",
"str",
")",
";",
"##line break",
"$",
"str",
"=",
"str_replace",
"(",
"'[br]'",
",",
"'<br />'",
",",
"$",
"str",
")",
";",
"##puttext inside a scrolling box",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[box\\]\\n?(.*?)\\n?\\[\\/box\\]\\n{1,}?~is\"",
",",
"\"<div class=\\\"box\\\">\\\\1</div>\"",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Parses out misc tags such as horizontal rule and a scrolling box
@param string $str
@return string $str;
|
[
"Parses",
"out",
"misc",
"tags",
"such",
"as",
"horizontal",
"rule",
"and",
"a",
"scrolling",
"box"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L125-L138
|
22,480
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.linksToHtml
|
public static function linksToHtml($str, $allow_email=false, $link_markup=null)
{
### Convert Email Tags ###
if(!$allow_email){
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", '<b> \\2 AT \\3 </b>', $str);
} else {
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", ' <a href="mailto:\\2@\\3">\\2@\\3</a>', $str);
}
### phrase links ###
$str = preg_replace( "~\[(?:url|link)=(http.*?)\](.*?)\[\/(?:url|link)\]~", "<a class=\"blank\" href=\"\\1\">\\2</a>", $str);
$link = $link_markup ? $link_markup : '(LINK)';
### url links ###\\2://\\3
//$str = preg_replace("#(\s|\n)([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", ' <a href="\\2://\\3" title="\\2://\\3">'.$link.'</a>', $str);
$str = preg_replace_callback("#(^|\s)([a-z]+?://[\w\-\.,\?!%\*\#:;~\\&$@\/=\+]+)#i", function($match) use($link){
$href = $match[2];
$end_punct = '';
if(preg_match("~[\.\?\!]$~", $href, $matchx)){
$end_punct = $matchx[0];
$href = substr($href,0,-1);
}
return $match[1].'<a href="'.$href.'" title="'.$href.'">'.$link.'</a>'.$end_punct;
}, $str);
return $str;
}
|
php
|
public static function linksToHtml($str, $allow_email=false, $link_markup=null)
{
### Convert Email Tags ###
if(!$allow_email){
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", '<b> \\2 AT \\3 </b>', $str);
} else {
$str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", ' <a href="mailto:\\2@\\3">\\2@\\3</a>', $str);
}
### phrase links ###
$str = preg_replace( "~\[(?:url|link)=(http.*?)\](.*?)\[\/(?:url|link)\]~", "<a class=\"blank\" href=\"\\1\">\\2</a>", $str);
$link = $link_markup ? $link_markup : '(LINK)';
### url links ###\\2://\\3
//$str = preg_replace("#(\s|\n)([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", ' <a href="\\2://\\3" title="\\2://\\3">'.$link.'</a>', $str);
$str = preg_replace_callback("#(^|\s)([a-z]+?://[\w\-\.,\?!%\*\#:;~\\&$@\/=\+]+)#i", function($match) use($link){
$href = $match[2];
$end_punct = '';
if(preg_match("~[\.\?\!]$~", $href, $matchx)){
$end_punct = $matchx[0];
$href = substr($href,0,-1);
}
return $match[1].'<a href="'.$href.'" title="'.$href.'">'.$link.'</a>'.$end_punct;
}, $str);
return $str;
}
|
[
"public",
"static",
"function",
"linksToHtml",
"(",
"$",
"str",
",",
"$",
"allow_email",
"=",
"false",
",",
"$",
"link_markup",
"=",
"null",
")",
"{",
"### Convert Email Tags ###",
"if",
"(",
"!",
"$",
"allow_email",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"\"#([\\n ])([a-z0-9\\-_.]+?)@([\\w\\-]+\\.([\\w\\-\\.]+\\.)?[\\w]+)#i\"",
",",
"'<b> \\\\2 AT \\\\3 </b>'",
",",
"$",
"str",
")",
";",
"}",
"else",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"\"#([\\n ])([a-z0-9\\-_.]+?)@([\\w\\-]+\\.([\\w\\-\\.]+\\.)?[\\w]+)#i\"",
",",
"' <a href=\"mailto:\\\\2@\\\\3\">\\\\2@\\\\3</a>'",
",",
"$",
"str",
")",
";",
"}",
"### phrase links ###",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[(?:url|link)=(http.*?)\\](.*?)\\[\\/(?:url|link)\\]~\"",
",",
"\"<a class=\\\"blank\\\" href=\\\"\\\\1\\\">\\\\2</a>\"",
",",
"$",
"str",
")",
";",
"$",
"link",
"=",
"$",
"link_markup",
"?",
"$",
"link_markup",
":",
"'(LINK)'",
";",
"### url links ###\\\\2://\\\\3",
"//$str = preg_replace(\"#(\\s|\\n)([a-z]+?)://([a-z0-9\\-\\.,\\?!%\\*_\\#:;~\\\\&$@\\/=\\+]+)#i\", ' <a href=\"\\\\2://\\\\3\" title=\"\\\\2://\\\\3\">'.$link.'</a>', $str);",
"$",
"str",
"=",
"preg_replace_callback",
"(",
"\"#(^|\\s)([a-z]+?://[\\w\\-\\.,\\?!%\\*\\#:;~\\\\&$@\\/=\\+]+)#i\"",
",",
"function",
"(",
"$",
"match",
")",
"use",
"(",
"$",
"link",
")",
"{",
"$",
"href",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"$",
"end_punct",
"=",
"''",
";",
"if",
"(",
"preg_match",
"(",
"\"~[\\.\\?\\!]$~\"",
",",
"$",
"href",
",",
"$",
"matchx",
")",
")",
"{",
"$",
"end_punct",
"=",
"$",
"matchx",
"[",
"0",
"]",
";",
"$",
"href",
"=",
"substr",
"(",
"$",
"href",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"return",
"$",
"match",
"[",
"1",
"]",
".",
"'<a href=\"'",
".",
"$",
"href",
".",
"'\" title=\"'",
".",
"$",
"href",
".",
"'\">'",
".",
"$",
"link",
".",
"'</a>'",
".",
"$",
"end_punct",
";",
"}",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Converts email and http links to HTML links
@param string $str
@return string
|
[
"Converts",
"email",
"and",
"http",
"links",
"to",
"HTML",
"links"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L254-L283
|
22,481
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.addSearches
|
public static function addSearches($str)
{
### make google searches ###
preg_match_all( "/\[google\](.*?)\[\/google\]/s", $str, $matches );
$match = $matches[0];
$data = $matches[1];
$count = count($match);
for($x=0;$x<$count;$x++){
$query = str_replace(" ", "+", $data[$x]);
$query = str_replace('"', "%22", $query);
$str = str_replace($match[$x], '<a class="blank" href="http://www.google.com/search?hl=en&ie=UTF-8&q='.$query.'" title="click to search google for '.$data[$x].'" >(GOOGLE - '.$data[$x].')</a>', $str);
}
### make wikipedia searches ###
$str = preg_replace( "~\[wikipedia\](.*?)\[\/wikipedia\]~s", '<a class="blank" href="http://en.wikipedia.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wikipedia for \\1" >(WIKIPEDIA - \\1)</a>', $str );
### make wiktionary searches ###
$str = preg_replace( "~\[wiktionary\](.*?)\[\/wiktionary\]~s", '<a class="blank" href="http://en.wiktionary.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wiktionary for \\1">(WIKTIONARY - \\1)</a>', $str );
return $str;
}
|
php
|
public static function addSearches($str)
{
### make google searches ###
preg_match_all( "/\[google\](.*?)\[\/google\]/s", $str, $matches );
$match = $matches[0];
$data = $matches[1];
$count = count($match);
for($x=0;$x<$count;$x++){
$query = str_replace(" ", "+", $data[$x]);
$query = str_replace('"', "%22", $query);
$str = str_replace($match[$x], '<a class="blank" href="http://www.google.com/search?hl=en&ie=UTF-8&q='.$query.'" title="click to search google for '.$data[$x].'" >(GOOGLE - '.$data[$x].')</a>', $str);
}
### make wikipedia searches ###
$str = preg_replace( "~\[wikipedia\](.*?)\[\/wikipedia\]~s", '<a class="blank" href="http://en.wikipedia.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wikipedia for \\1" >(WIKIPEDIA - \\1)</a>', $str );
### make wiktionary searches ###
$str = preg_replace( "~\[wiktionary\](.*?)\[\/wiktionary\]~s", '<a class="blank" href="http://en.wiktionary.org/wiki/Special:Search?search='.str_replace(" ", "_", "\\1").'&go=Go" title="click to search wiktionary for \\1">(WIKTIONARY - \\1)</a>', $str );
return $str;
}
|
[
"public",
"static",
"function",
"addSearches",
"(",
"$",
"str",
")",
"{",
"### make google searches ###",
"preg_match_all",
"(",
"\"/\\[google\\](.*?)\\[\\/google\\]/s\"",
",",
"$",
"str",
",",
"$",
"matches",
")",
";",
"$",
"match",
"=",
"$",
"matches",
"[",
"0",
"]",
";",
"$",
"data",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"match",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"count",
";",
"$",
"x",
"++",
")",
"{",
"$",
"query",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"+\"",
",",
"$",
"data",
"[",
"$",
"x",
"]",
")",
";",
"$",
"query",
"=",
"str_replace",
"(",
"'\"'",
",",
"\"%22\"",
",",
"$",
"query",
")",
";",
"$",
"str",
"=",
"str_replace",
"(",
"$",
"match",
"[",
"$",
"x",
"]",
",",
"'<a class=\"blank\" href=\"http://www.google.com/search?hl=en&ie=UTF-8&q='",
".",
"$",
"query",
".",
"'\" title=\"click to search google for '",
".",
"$",
"data",
"[",
"$",
"x",
"]",
".",
"'\" >(GOOGLE - '",
".",
"$",
"data",
"[",
"$",
"x",
"]",
".",
"')</a>'",
",",
"$",
"str",
")",
";",
"}",
"### make wikipedia searches ###",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[wikipedia\\](.*?)\\[\\/wikipedia\\]~s\"",
",",
"'<a class=\"blank\" href=\"http://en.wikipedia.org/wiki/Special:Search?search='",
".",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"\"\\\\1\"",
")",
".",
"'&go=Go\" title=\"click to search wikipedia for \\\\1\" >(WIKIPEDIA - \\\\1)</a>'",
",",
"$",
"str",
")",
";",
"### make wiktionary searches ###",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[wiktionary\\](.*?)\\[\\/wiktionary\\]~s\"",
",",
"'<a class=\"blank\" href=\"http://en.wiktionary.org/wiki/Special:Search?search='",
".",
"str_replace",
"(",
"\" \"",
",",
"\"_\"",
",",
"\"\\\\1\"",
")",
".",
"'&go=Go\" title=\"click to search wiktionary for \\\\1\">(WIKTIONARY - \\\\1)</a>'",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Adds search tags to link text to searches both on and off site
@param string $str
@return string
|
[
"Adds",
"search",
"tags",
"to",
"link",
"text",
"to",
"searches",
"both",
"on",
"and",
"off",
"site"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L292-L315
|
22,482
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.convertQuotes
|
public static function convertQuotes($str)
{
$r = "/\[q(?:uote)?\](.*?)\[\/q(?:uote)?\]/is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<blockquote class="quote"><p>\\1</p></blockquote>', $str);
}
return $str;
}
|
php
|
public static function convertQuotes($str)
{
$r = "/\[q(?:uote)?\](.*?)\[\/q(?:uote)?\]/is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<blockquote class="quote"><p>\\1</p></blockquote>', $str);
}
return $str;
}
|
[
"public",
"static",
"function",
"convertQuotes",
"(",
"$",
"str",
")",
"{",
"$",
"r",
"=",
"\"/\\[q(?:uote)?\\](.*?)\\[\\/q(?:uote)?\\]/is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<blockquote class=\"quote\"><p>\\\\1</p></blockquote>'",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Converts quotes into quoted text blocks
@param unknown_type $str
|
[
"Converts",
"quotes",
"into",
"quoted",
"text",
"blocks"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L355-L364
|
22,483
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.stripAll
|
public static function stripAll($str)
{
$str = stripslashes($str);
$str = strip_tags($str);
$str = \sb\Strings::unicodeUrldecode($str);
$str = self::stripBling($str);
$str = \sb\Strings::stripMicrosoftChars($str);
return $str;
}
|
php
|
public static function stripAll($str)
{
$str = stripslashes($str);
$str = strip_tags($str);
$str = \sb\Strings::unicodeUrldecode($str);
$str = self::stripBling($str);
$str = \sb\Strings::stripMicrosoftChars($str);
return $str;
}
|
[
"public",
"static",
"function",
"stripAll",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"stripslashes",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"strip_tags",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"\\",
"sb",
"\\",
"Strings",
"::",
"unicodeUrldecode",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"self",
"::",
"stripBling",
"(",
"$",
"str",
")",
";",
"$",
"str",
"=",
"\\",
"sb",
"\\",
"Strings",
"::",
"stripMicrosoftChars",
"(",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Strips everything including textBlng tags, this is useful for RSS feed and text summaries in search results
@param string $str
@return string
|
[
"Strips",
"everything",
"including",
"textBlng",
"tags",
"this",
"is",
"useful",
"for",
"RSS",
"feed",
"and",
"text",
"summaries",
"in",
"search",
"results"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L383-L391
|
22,484
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.typoFix
|
public static function typoFix($str)
{
//mistakes
$common_typos = array(
"adn"=>"and",
"agian"=>"again",
"ahve"=>"have",
"ahd"=>"had",
"alot"=>"a lot",
"amke"=>"make",
"arent"=>"aren't",
"beleif"=>"belief",
"beleive"=>"believe",
"broswer"=>"browser",
"cant"=>"can't",
"cheif"=>"chief",
"couldnt"=>"couldn't",
"comming"=>"coming",
"didnt"=>"didn't",
"doesnt"=>"doesn't",
"dont"=>"don't",
"ehr"=>"her",
"esle"=>"else",
"eyt"=>"yet",
"feild"=>"field",
"goign"=>"going",
"hadnt"=>"hadn't",
"hasnt"=>"hasn't",
"hda"=>"had",
"hed"=>"he'd",
"hel"=>"he'll",
"heres"=>"here's",
"hes"=>"he's",
"hows"=>"how's",
"hsa"=>"has",
"hte"=>"the",
"htere"=>"there",
"i'll"=>"I'll",
"infromation"=>"information",
"i'm"=>"I'm",
"isnt"=>"isn't",
"itll"=>"it'll",
"itsa"=>"its a",
"ive"=>"I've",
"mkae"=>"make",
"peice"=>"piece",
"seh"=>"she",
"shouldnt"=>"shouldn't",
"shouldve"=>"should've",
"shoudl"=>"should",
"somethign"=>"something",
"taht"=>"that",
"tahn"=>"than",
"Teh"=>"The",
"teh"=>"the",
"taht"=>"that",
"thier"=>"their",
"weve"=>"we've",
"workign"=>"working"
);
foreach($common_typos as $typo=>$correction){
$str = preg_replace("~\b".$typo."\b~", $correction, $str);
}
//fix ; fragments
$str = str_replace("n;t", "n't", $str);
return $str;
}
|
php
|
public static function typoFix($str)
{
//mistakes
$common_typos = array(
"adn"=>"and",
"agian"=>"again",
"ahve"=>"have",
"ahd"=>"had",
"alot"=>"a lot",
"amke"=>"make",
"arent"=>"aren't",
"beleif"=>"belief",
"beleive"=>"believe",
"broswer"=>"browser",
"cant"=>"can't",
"cheif"=>"chief",
"couldnt"=>"couldn't",
"comming"=>"coming",
"didnt"=>"didn't",
"doesnt"=>"doesn't",
"dont"=>"don't",
"ehr"=>"her",
"esle"=>"else",
"eyt"=>"yet",
"feild"=>"field",
"goign"=>"going",
"hadnt"=>"hadn't",
"hasnt"=>"hasn't",
"hda"=>"had",
"hed"=>"he'd",
"hel"=>"he'll",
"heres"=>"here's",
"hes"=>"he's",
"hows"=>"how's",
"hsa"=>"has",
"hte"=>"the",
"htere"=>"there",
"i'll"=>"I'll",
"infromation"=>"information",
"i'm"=>"I'm",
"isnt"=>"isn't",
"itll"=>"it'll",
"itsa"=>"its a",
"ive"=>"I've",
"mkae"=>"make",
"peice"=>"piece",
"seh"=>"she",
"shouldnt"=>"shouldn't",
"shouldve"=>"should've",
"shoudl"=>"should",
"somethign"=>"something",
"taht"=>"that",
"tahn"=>"than",
"Teh"=>"The",
"teh"=>"the",
"taht"=>"that",
"thier"=>"their",
"weve"=>"we've",
"workign"=>"working"
);
foreach($common_typos as $typo=>$correction){
$str = preg_replace("~\b".$typo."\b~", $correction, $str);
}
//fix ; fragments
$str = str_replace("n;t", "n't", $str);
return $str;
}
|
[
"public",
"static",
"function",
"typoFix",
"(",
"$",
"str",
")",
"{",
"//mistakes",
"$",
"common_typos",
"=",
"array",
"(",
"\"adn\"",
"=>",
"\"and\"",
",",
"\"agian\"",
"=>",
"\"again\"",
",",
"\"ahve\"",
"=>",
"\"have\"",
",",
"\"ahd\"",
"=>",
"\"had\"",
",",
"\"alot\"",
"=>",
"\"a lot\"",
",",
"\"amke\"",
"=>",
"\"make\"",
",",
"\"arent\"",
"=>",
"\"aren't\"",
",",
"\"beleif\"",
"=>",
"\"belief\"",
",",
"\"beleive\"",
"=>",
"\"believe\"",
",",
"\"broswer\"",
"=>",
"\"browser\"",
",",
"\"cant\"",
"=>",
"\"can't\"",
",",
"\"cheif\"",
"=>",
"\"chief\"",
",",
"\"couldnt\"",
"=>",
"\"couldn't\"",
",",
"\"comming\"",
"=>",
"\"coming\"",
",",
"\"didnt\"",
"=>",
"\"didn't\"",
",",
"\"doesnt\"",
"=>",
"\"doesn't\"",
",",
"\"dont\"",
"=>",
"\"don't\"",
",",
"\"ehr\"",
"=>",
"\"her\"",
",",
"\"esle\"",
"=>",
"\"else\"",
",",
"\"eyt\"",
"=>",
"\"yet\"",
",",
"\"feild\"",
"=>",
"\"field\"",
",",
"\"goign\"",
"=>",
"\"going\"",
",",
"\"hadnt\"",
"=>",
"\"hadn't\"",
",",
"\"hasnt\"",
"=>",
"\"hasn't\"",
",",
"\"hda\"",
"=>",
"\"had\"",
",",
"\"hed\"",
"=>",
"\"he'd\"",
",",
"\"hel\"",
"=>",
"\"he'll\"",
",",
"\"heres\"",
"=>",
"\"here's\"",
",",
"\"hes\"",
"=>",
"\"he's\"",
",",
"\"hows\"",
"=>",
"\"how's\"",
",",
"\"hsa\"",
"=>",
"\"has\"",
",",
"\"hte\"",
"=>",
"\"the\"",
",",
"\"htere\"",
"=>",
"\"there\"",
",",
"\"i'll\"",
"=>",
"\"I'll\"",
",",
"\"infromation\"",
"=>",
"\"information\"",
",",
"\"i'm\"",
"=>",
"\"I'm\"",
",",
"\"isnt\"",
"=>",
"\"isn't\"",
",",
"\"itll\"",
"=>",
"\"it'll\"",
",",
"\"itsa\"",
"=>",
"\"its a\"",
",",
"\"ive\"",
"=>",
"\"I've\"",
",",
"\"mkae\"",
"=>",
"\"make\"",
",",
"\"peice\"",
"=>",
"\"piece\"",
",",
"\"seh\"",
"=>",
"\"she\"",
",",
"\"shouldnt\"",
"=>",
"\"shouldn't\"",
",",
"\"shouldve\"",
"=>",
"\"should've\"",
",",
"\"shoudl\"",
"=>",
"\"should\"",
",",
"\"somethign\"",
"=>",
"\"something\"",
",",
"\"taht\"",
"=>",
"\"that\"",
",",
"\"tahn\"",
"=>",
"\"than\"",
",",
"\"Teh\"",
"=>",
"\"The\"",
",",
"\"teh\"",
"=>",
"\"the\"",
",",
"\"taht\"",
"=>",
"\"that\"",
",",
"\"thier\"",
"=>",
"\"their\"",
",",
"\"weve\"",
"=>",
"\"we've\"",
",",
"\"workign\"",
"=>",
"\"working\"",
")",
";",
"foreach",
"(",
"$",
"common_typos",
"as",
"$",
"typo",
"=>",
"$",
"correction",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\b\"",
".",
"$",
"typo",
".",
"\"\\b~\"",
",",
"$",
"correction",
",",
"$",
"str",
")",
";",
"}",
"//fix ; fragments",
"$",
"str",
"=",
"str_replace",
"(",
"\"n;t\"",
",",
"\"n't\"",
",",
"$",
"str",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Fixed common typos, can be used directly as it is a static property
<code>
textBling::typoFix('Teh bird cant fly');
//returns 'The bird can't fly'
</code>
@param the text to be cleaned $str
@return string
|
[
"Fixed",
"common",
"typos",
"can",
"be",
"used",
"directly",
"as",
"it",
"is",
"a",
"static",
"property"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L405-L479
|
22,485
|
surebert/surebert-framework
|
src/sb/Text/Bling.php
|
Bling.textStyles
|
public static function textStyles($str)
{
##bold
$str = preg_replace("~\[b\](.*?)\[/b\]~is", '<strong class="tb_b">$1</strong>', $str);
##sup
$str = preg_replace("~\[sup\](.*?)\[/sup\]~is", '<sup class="tb_sup">$1</sup>', $str);
##sub
$str = preg_replace("~\[sub\](.*?)\[/sub\]~is", '<sub class="tb_sub">$1</sub>', $str);
##italic
$str = preg_replace("~\[i\](.*?)\[/i\]~is", '<em class="tb_i">$1</em>', $str);
##underline
$str = preg_replace("~\[u\](.*?)\[/u\]~is", '<u class="tb_u">$1</u>', $str);
##cite
$str = preg_replace("~\[cite\](.*?)\[/cite\]~is", '<cite class="tb_cite">$1</cite>', $str);
##hilite
$str = preg_replace("~\[h(?:ilite)?\](.*?)\[/h(?:ilite)?\]~is", '<span class="tb_hilite">$1</span>', $str);
##line-though
$str = preg_replace("~\[strike](.*?)\[/strike]~is", '<del class="tb_strike">$1</del>', $str);
## add small caps
$str = preg_replace("~\[caps](.*?)\[/caps]~is", '<span class="tb_caps">$1</span>', $str);
## add center
$str = preg_replace("~\[center](.*?)\[/center]~is", '<center class="tb_center">$1</center>', $str);
## add code tag
## add small caps
$str = preg_replace("~\[code](.*?)\[/code]~is", '<pre style="background-color:black;color:green;overflow:auto;">$1</pre>', $str);
## font size
$r = "~\[size=([\d(?:\.\d+)]+(?:em|px)?)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font size
$r = "~\[size=(small|medium|large)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font color
$r = "~\[color=(.*?)\](.*?)\[\/color\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="color:\\1;">\\2</span>', $str);
}
return $str;
}
|
php
|
public static function textStyles($str)
{
##bold
$str = preg_replace("~\[b\](.*?)\[/b\]~is", '<strong class="tb_b">$1</strong>', $str);
##sup
$str = preg_replace("~\[sup\](.*?)\[/sup\]~is", '<sup class="tb_sup">$1</sup>', $str);
##sub
$str = preg_replace("~\[sub\](.*?)\[/sub\]~is", '<sub class="tb_sub">$1</sub>', $str);
##italic
$str = preg_replace("~\[i\](.*?)\[/i\]~is", '<em class="tb_i">$1</em>', $str);
##underline
$str = preg_replace("~\[u\](.*?)\[/u\]~is", '<u class="tb_u">$1</u>', $str);
##cite
$str = preg_replace("~\[cite\](.*?)\[/cite\]~is", '<cite class="tb_cite">$1</cite>', $str);
##hilite
$str = preg_replace("~\[h(?:ilite)?\](.*?)\[/h(?:ilite)?\]~is", '<span class="tb_hilite">$1</span>', $str);
##line-though
$str = preg_replace("~\[strike](.*?)\[/strike]~is", '<del class="tb_strike">$1</del>', $str);
## add small caps
$str = preg_replace("~\[caps](.*?)\[/caps]~is", '<span class="tb_caps">$1</span>', $str);
## add center
$str = preg_replace("~\[center](.*?)\[/center]~is", '<center class="tb_center">$1</center>', $str);
## add code tag
## add small caps
$str = preg_replace("~\[code](.*?)\[/code]~is", '<pre style="background-color:black;color:green;overflow:auto;">$1</pre>', $str);
## font size
$r = "~\[size=([\d(?:\.\d+)]+(?:em|px)?)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font size
$r = "~\[size=(small|medium|large)\](.*?)\[\/size\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="font-size:\\1;">\\2</span>', $str);
}
## font color
$r = "~\[color=(.*?)\](.*?)\[\/color\]~is";
while(preg_match($r, $str)){
$str = preg_replace($r, '<span style="color:\\1;">\\2</span>', $str);
}
return $str;
}
|
[
"public",
"static",
"function",
"textStyles",
"(",
"$",
"str",
")",
"{",
"##bold",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[b\\](.*?)\\[/b\\]~is\"",
",",
"'<strong class=\"tb_b\">$1</strong>'",
",",
"$",
"str",
")",
";",
"##sup",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[sup\\](.*?)\\[/sup\\]~is\"",
",",
"'<sup class=\"tb_sup\">$1</sup>'",
",",
"$",
"str",
")",
";",
"##sub",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[sub\\](.*?)\\[/sub\\]~is\"",
",",
"'<sub class=\"tb_sub\">$1</sub>'",
",",
"$",
"str",
")",
";",
"##italic",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[i\\](.*?)\\[/i\\]~is\"",
",",
"'<em class=\"tb_i\">$1</em>'",
",",
"$",
"str",
")",
";",
"##underline",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[u\\](.*?)\\[/u\\]~is\"",
",",
"'<u class=\"tb_u\">$1</u>'",
",",
"$",
"str",
")",
";",
"##cite",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[cite\\](.*?)\\[/cite\\]~is\"",
",",
"'<cite class=\"tb_cite\">$1</cite>'",
",",
"$",
"str",
")",
";",
"##hilite",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[h(?:ilite)?\\](.*?)\\[/h(?:ilite)?\\]~is\"",
",",
"'<span class=\"tb_hilite\">$1</span>'",
",",
"$",
"str",
")",
";",
"##line-though",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[strike](.*?)\\[/strike]~is\"",
",",
"'<del class=\"tb_strike\">$1</del>'",
",",
"$",
"str",
")",
";",
"## add small caps",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[caps](.*?)\\[/caps]~is\"",
",",
"'<span class=\"tb_caps\">$1</span>'",
",",
"$",
"str",
")",
";",
"## add center",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[center](.*?)\\[/center]~is\"",
",",
"'<center class=\"tb_center\">$1</center>'",
",",
"$",
"str",
")",
";",
"## add code tag",
"## add small caps",
"$",
"str",
"=",
"preg_replace",
"(",
"\"~\\[code](.*?)\\[/code]~is\"",
",",
"'<pre style=\"background-color:black;color:green;overflow:auto;\">$1</pre>'",
",",
"$",
"str",
")",
";",
"## font size",
"$",
"r",
"=",
"\"~\\[size=([\\d(?:\\.\\d+)]+(?:em|px)?)\\](.*?)\\[\\/size\\]~is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<span style=\"font-size:\\\\1;\">\\\\2</span>'",
",",
"$",
"str",
")",
";",
"}",
"## font size",
"$",
"r",
"=",
"\"~\\[size=(small|medium|large)\\](.*?)\\[\\/size\\]~is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<span style=\"font-size:\\\\1;\">\\\\2</span>'",
",",
"$",
"str",
")",
";",
"}",
"## font color",
"$",
"r",
"=",
"\"~\\[color=(.*?)\\](.*?)\\[\\/color\\]~is\"",
";",
"while",
"(",
"preg_match",
"(",
"$",
"r",
",",
"$",
"str",
")",
")",
"{",
"$",
"str",
"=",
"preg_replace",
"(",
"$",
"r",
",",
"'<span style=\"color:\\\\1;\">\\\\2</span>'",
",",
"$",
"str",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Converts text style tags
@param string $str
@return string $str;
|
[
"Converts",
"text",
"style",
"tags"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Text/Bling.php#L487-L543
|
22,486
|
Erdiko/core
|
src/Theme.php
|
Theme.getCss
|
public function getCss()
{
if (isset($this->_themeConfig['css'])) {
return array_merge($this->_themeConfig['css'], $this->_data['css']);
} else {
return $this->_data['css'];
}
}
|
php
|
public function getCss()
{
if (isset($this->_themeConfig['css'])) {
return array_merge($this->_themeConfig['css'], $this->_data['css']);
} else {
return $this->_data['css'];
}
}
|
[
"public",
"function",
"getCss",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'css'",
"]",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'css'",
"]",
",",
"$",
"this",
"->",
"_data",
"[",
"'css'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"'css'",
"]",
";",
"}",
"}"
] |
Get array of css files to include in theme
@return array css file paths
@todo sort by the 'order' value
|
[
"Get",
"array",
"of",
"css",
"files",
"to",
"include",
"in",
"theme"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L193-L200
|
22,487
|
Erdiko/core
|
src/Theme.php
|
Theme.getJs
|
public function getJs()
{
if (isset($this->_themeConfig['js'])) {
return array_merge($this->_themeConfig['js'], $this->_data['js']);
} else {
return $this->_data['js'];
}
}
|
php
|
public function getJs()
{
if (isset($this->_themeConfig['js'])) {
return array_merge($this->_themeConfig['js'], $this->_data['js']);
} else {
return $this->_data['js'];
}
}
|
[
"public",
"function",
"getJs",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'js'",
"]",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"_themeConfig",
"[",
"'js'",
"]",
",",
"$",
"this",
"->",
"_data",
"[",
"'js'",
"]",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"_data",
"[",
"'js'",
"]",
";",
"}",
"}"
] |
Get array of js files to include
@return array js file paths
@todo sort by the 'order' value
|
[
"Get",
"array",
"of",
"js",
"files",
"to",
"include"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L227-L234
|
22,488
|
Erdiko/core
|
src/Theme.php
|
Theme.addJs
|
public function addJs($name, $jsFile, $order = 10, $active = 1)
{
$this->_data['js'][$name] = array(
'file' => $jsFile,
'order' => $order,
'active' => $active
);
}
|
php
|
public function addJs($name, $jsFile, $order = 10, $active = 1)
{
$this->_data['js'][$name] = array(
'file' => $jsFile,
'order' => $order,
'active' => $active
);
}
|
[
"public",
"function",
"addJs",
"(",
"$",
"name",
",",
"$",
"jsFile",
",",
"$",
"order",
"=",
"10",
",",
"$",
"active",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"_data",
"[",
"'js'",
"]",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
"'file'",
"=>",
"$",
"jsFile",
",",
"'order'",
"=>",
"$",
"order",
",",
"'active'",
"=>",
"$",
"active",
")",
";",
"}"
] |
Add js file to page
@param string $name
@param string $jsFile URL of js file
@param int $order
@param boolean $active defaults to 1
@todo same issue as addCss
|
[
"Add",
"js",
"file",
"to",
"page"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L245-L252
|
22,489
|
Erdiko/core
|
src/Theme.php
|
Theme.getTemplateHtml
|
public function getTemplateHtml($partial)
{
$config = $this->getThemeConfig();
// @todo add check here to make sure partial exists, if missing log error
$filename = $this->getTemplateFolder().$config['templates'][$partial]['file'];
$html = $this->getTemplateFile($filename, $this->getContextConfig());
return $html;
}
|
php
|
public function getTemplateHtml($partial)
{
$config = $this->getThemeConfig();
// @todo add check here to make sure partial exists, if missing log error
$filename = $this->getTemplateFolder().$config['templates'][$partial]['file'];
$html = $this->getTemplateFile($filename, $this->getContextConfig());
return $html;
}
|
[
"public",
"function",
"getTemplateHtml",
"(",
"$",
"partial",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getThemeConfig",
"(",
")",
";",
"// @todo add check here to make sure partial exists, if missing log error",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTemplateFolder",
"(",
")",
".",
"$",
"config",
"[",
"'templates'",
"]",
"[",
"$",
"partial",
"]",
"[",
"'file'",
"]",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getTemplateFile",
"(",
"$",
"filename",
",",
"$",
"this",
"->",
"getContextConfig",
"(",
")",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Get template file populated by the config
@usage Partial render need to be declared in theme.json
e.g. get header/footer
@param string $partial
@return string html
|
[
"Get",
"template",
"file",
"populated",
"by",
"the",
"config"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L344-L353
|
22,490
|
Erdiko/core
|
src/Theme.php
|
Theme.toHtml
|
public function toHtml()
{
// load the theme and context (site) configs
$this->getContextConfig();
$this->getThemeConfig();
$filename = $this->getTemplateFolder().$this->getTemplate();
$html = $this->getTemplateFile($filename, $this);
return $html;
}
|
php
|
public function toHtml()
{
// load the theme and context (site) configs
$this->getContextConfig();
$this->getThemeConfig();
$filename = $this->getTemplateFolder().$this->getTemplate();
$html = $this->getTemplateFile($filename, $this);
return $html;
}
|
[
"public",
"function",
"toHtml",
"(",
")",
"{",
"// load the theme and context (site) configs",
"$",
"this",
"->",
"getContextConfig",
"(",
")",
";",
"$",
"this",
"->",
"getThemeConfig",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"getTemplateFolder",
"(",
")",
".",
"$",
"this",
"->",
"getTemplate",
"(",
")",
";",
"$",
"html",
"=",
"$",
"this",
"->",
"getTemplateFile",
"(",
"$",
"filename",
",",
"$",
"this",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Output content to html
@return string html
|
[
"Output",
"content",
"to",
"html"
] |
c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6
|
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/Theme.php#L360-L370
|
22,491
|
derhasi/buddy
|
src/CommandShortcut.php
|
CommandShortcut.processDir
|
protected function processDir($dir) {
$dir = $this->replacePattern($dir);
// The absolute path has to be calculated relative to the configuration file
if (Path::isRelative($dir)) {
$dir = Path::makeAbsolute($dir, dirname($this->configFile));
}
return rtrim($dir, '/');
}
|
php
|
protected function processDir($dir) {
$dir = $this->replacePattern($dir);
// The absolute path has to be calculated relative to the configuration file
if (Path::isRelative($dir)) {
$dir = Path::makeAbsolute($dir, dirname($this->configFile));
}
return rtrim($dir, '/');
}
|
[
"protected",
"function",
"processDir",
"(",
"$",
"dir",
")",
"{",
"$",
"dir",
"=",
"$",
"this",
"->",
"replacePattern",
"(",
"$",
"dir",
")",
";",
"// The absolute path has to be calculated relative to the configuration file",
"if",
"(",
"Path",
"::",
"isRelative",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"dir",
"=",
"Path",
"::",
"makeAbsolute",
"(",
"$",
"dir",
",",
"dirname",
"(",
"$",
"this",
"->",
"configFile",
")",
")",
";",
"}",
"return",
"rtrim",
"(",
"$",
"dir",
",",
"'/'",
")",
";",
"}"
] |
Process given dir with replacements and makes it absolute.
@param string $dir
@return string
Absolute path with placeholders replaced.
|
[
"Process",
"given",
"dir",
"with",
"replacements",
"and",
"makes",
"it",
"absolute",
"."
] |
a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165
|
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/CommandShortcut.php#L117-L124
|
22,492
|
derhasi/buddy
|
src/CommandShortcut.php
|
CommandShortcut.replacePattern
|
protected function replacePattern($pattern) {
$replace = array(
'$DIR' => dirname($this->configFile),
'$CWD' => getcwd(),
);
return str_replace(array_keys($replace), array_values($replace), $pattern);
}
|
php
|
protected function replacePattern($pattern) {
$replace = array(
'$DIR' => dirname($this->configFile),
'$CWD' => getcwd(),
);
return str_replace(array_keys($replace), array_values($replace), $pattern);
}
|
[
"protected",
"function",
"replacePattern",
"(",
"$",
"pattern",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
"'$DIR'",
"=>",
"dirname",
"(",
"$",
"this",
"->",
"configFile",
")",
",",
"'$CWD'",
"=>",
"getcwd",
"(",
")",
",",
")",
";",
"return",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replace",
")",
",",
"array_values",
"(",
"$",
"replace",
")",
",",
"$",
"pattern",
")",
";",
"}"
] |
Helper to replace certain patterns with actual values.
@param string $pattern
Pattern to be replaced
@return string
|
[
"Helper",
"to",
"replace",
"certain",
"patterns",
"with",
"actual",
"values",
"."
] |
a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165
|
https://github.com/derhasi/buddy/blob/a9f033470b61a9fc09bb1ba07f2a2d1fc16b4165/src/CommandShortcut.php#L135-L141
|
22,493
|
rhosocial/yii2-user
|
models/UserUsernameTrait.php
|
UserUsernameTrait.hasEnabledUsername
|
public function hasEnabledUsername()
{
if ($this->usernameClass === false || !is_string($this->usernameClass) || !class_exists($this->usernameClass)) {
return false;
}
return true;
}
|
php
|
public function hasEnabledUsername()
{
if ($this->usernameClass === false || !is_string($this->usernameClass) || !class_exists($this->usernameClass)) {
return false;
}
return true;
}
|
[
"public",
"function",
"hasEnabledUsername",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"usernameClass",
"===",
"false",
"||",
"!",
"is_string",
"(",
"$",
"this",
"->",
"usernameClass",
")",
"||",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"usernameClass",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check whether this user enables the username feature or not.
@return boolean
|
[
"Check",
"whether",
"this",
"user",
"enables",
"the",
"username",
"feature",
"or",
"not",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L33-L39
|
22,494
|
rhosocial/yii2-user
|
models/UserUsernameTrait.php
|
UserUsernameTrait.getUsername
|
public function getUsername()
{
if (!$this->hasEnabledUsername()) {
return null;
}
$usernameClass = $this->usernameClass;
$noInit = $usernameClass::buildNoInitModel();
/* @var $noInit Username */
return $this->hasOne($usernameClass, [$noInit->createdByAttribute => $this->guidAttribute]);
}
|
php
|
public function getUsername()
{
if (!$this->hasEnabledUsername()) {
return null;
}
$usernameClass = $this->usernameClass;
$noInit = $usernameClass::buildNoInitModel();
/* @var $noInit Username */
return $this->hasOne($usernameClass, [$noInit->createdByAttribute => $this->guidAttribute]);
}
|
[
"public",
"function",
"getUsername",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasEnabledUsername",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"usernameClass",
"=",
"$",
"this",
"->",
"usernameClass",
";",
"$",
"noInit",
"=",
"$",
"usernameClass",
"::",
"buildNoInitModel",
"(",
")",
";",
"/* @var $noInit Username */",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"$",
"usernameClass",
",",
"[",
"$",
"noInit",
"->",
"createdByAttribute",
"=>",
"$",
"this",
"->",
"guidAttribute",
"]",
")",
";",
"}"
] |
Get username.
This method may return null, please consider processing the abnormal conditions.
@return BaseBlameableQuery
|
[
"Get",
"username",
".",
"This",
"method",
"may",
"return",
"null",
"please",
"consider",
"processing",
"the",
"abnormal",
"conditions",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L46-L55
|
22,495
|
rhosocial/yii2-user
|
models/UserUsernameTrait.php
|
UserUsernameTrait.createUsername
|
public function createUsername($username)
{
if (!$this->hasEnabledUsername()) {
return null;
}
$usernameClass = $this->usernameClass;
$model = $usernameClass::findOne($this->getGUID());
if (!$model) {
$model = $this->create($usernameClass);
$model->setGUID($this->getGUID());
}
$model->content = $username;
return $model;
}
|
php
|
public function createUsername($username)
{
if (!$this->hasEnabledUsername()) {
return null;
}
$usernameClass = $this->usernameClass;
$model = $usernameClass::findOne($this->getGUID());
if (!$model) {
$model = $this->create($usernameClass);
$model->setGUID($this->getGUID());
}
$model->content = $username;
return $model;
}
|
[
"public",
"function",
"createUsername",
"(",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasEnabledUsername",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"usernameClass",
"=",
"$",
"this",
"->",
"usernameClass",
";",
"$",
"model",
"=",
"$",
"usernameClass",
"::",
"findOne",
"(",
"$",
"this",
"->",
"getGUID",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"model",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"create",
"(",
"$",
"usernameClass",
")",
";",
"$",
"model",
"->",
"setGUID",
"(",
"$",
"this",
"->",
"getGUID",
"(",
")",
")",
";",
"}",
"$",
"model",
"->",
"content",
"=",
"$",
"username",
";",
"return",
"$",
"model",
";",
"}"
] |
Create or get username.
@param $username
@return null|Username
|
[
"Create",
"or",
"get",
"username",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L62-L75
|
22,496
|
rhosocial/yii2-user
|
models/UserUsernameTrait.php
|
UserUsernameTrait.setUsername
|
public function setUsername($username = null)
{
if ($username === null && ($model = $this->getUsername()->one())) {
return $model->delete() > 0;
}
if ($username instanceof Username) {
$username = $username->content;
}
$model = $this->createUsername($username);
return $model->save();
}
|
php
|
public function setUsername($username = null)
{
if ($username === null && ($model = $this->getUsername()->one())) {
return $model->delete() > 0;
}
if ($username instanceof Username) {
$username = $username->content;
}
$model = $this->createUsername($username);
return $model->save();
}
|
[
"public",
"function",
"setUsername",
"(",
"$",
"username",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"username",
"===",
"null",
"&&",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"getUsername",
"(",
")",
"->",
"one",
"(",
")",
")",
")",
"{",
"return",
"$",
"model",
"->",
"delete",
"(",
")",
">",
"0",
";",
"}",
"if",
"(",
"$",
"username",
"instanceof",
"Username",
")",
"{",
"$",
"username",
"=",
"$",
"username",
"->",
"content",
";",
"}",
"$",
"model",
"=",
"$",
"this",
"->",
"createUsername",
"(",
"$",
"username",
")",
";",
"return",
"$",
"model",
"->",
"save",
"(",
")",
";",
"}"
] |
Set username.
@param string|Username $username
@return bool
|
[
"Set",
"username",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/UserUsernameTrait.php#L82-L92
|
22,497
|
42mate/towel
|
src/Towel/Controller/User.php
|
User.profileShow
|
public function profileShow()
{
if (!$this->isAuthenticated()) {
return $this->redirect('/login');
}
$userModel = $this->session()->get('user');
return $this->twig()->render('User\profile.twig', array('user' => $userModel));
}
|
php
|
public function profileShow()
{
if (!$this->isAuthenticated()) {
return $this->redirect('/login');
}
$userModel = $this->session()->get('user');
return $this->twig()->render('User\profile.twig', array('user' => $userModel));
}
|
[
"public",
"function",
"profileShow",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"'/login'",
")",
";",
"}",
"$",
"userModel",
"=",
"$",
"this",
"->",
"session",
"(",
")",
"->",
"get",
"(",
"'user'",
")",
";",
"return",
"$",
"this",
"->",
"twig",
"(",
")",
"->",
"render",
"(",
"'User\\profile.twig'",
",",
"array",
"(",
"'user'",
"=>",
"$",
"userModel",
")",
")",
";",
"}"
] |
Shows the profile page.
@return string|\Symfony\Component\HttpFoundation\RedirectResponse
|
[
"Shows",
"the",
"profile",
"page",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L14-L22
|
22,498
|
42mate/towel
|
src/Towel/Controller/User.php
|
User.loginShow
|
public function loginShow()
{
if ($this->isAuthenticated()) {
$this->setMessage('warning', 'you are already logged in');
return $this->redirect('/');
}
return $this->twig()->render('user\login.twig');
}
|
php
|
public function loginShow()
{
if ($this->isAuthenticated()) {
$this->setMessage('warning', 'you are already logged in');
return $this->redirect('/');
}
return $this->twig()->render('user\login.twig');
}
|
[
"public",
"function",
"loginShow",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setMessage",
"(",
"'warning'",
",",
"'you are already logged in'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"'/'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"twig",
"(",
")",
"->",
"render",
"(",
"'user\\login.twig'",
")",
";",
"}"
] |
Shows the login form.
@return string|\Symfony\Component\HttpFoundation\RedirectResponse
|
[
"Shows",
"the",
"login",
"form",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L29-L37
|
22,499
|
42mate/towel
|
src/Towel/Controller/User.php
|
User.loginAction
|
public function loginAction($request)
{
$data = $request->get('data');
$userModel = new ModelUser();
$validUser = $userModel->validateLogin($data['email'], $data['password']);
if (!$validUser) {
$this->setMessage('danger', 'Not valid user / password combination');
return $this->redirect(url('login'));
}
$this->session()->set('user', $userModel->record);
$this->sessionClearMessages();
return $this->redirect('/');
}
|
php
|
public function loginAction($request)
{
$data = $request->get('data');
$userModel = new ModelUser();
$validUser = $userModel->validateLogin($data['email'], $data['password']);
if (!$validUser) {
$this->setMessage('danger', 'Not valid user / password combination');
return $this->redirect(url('login'));
}
$this->session()->set('user', $userModel->record);
$this->sessionClearMessages();
return $this->redirect('/');
}
|
[
"public",
"function",
"loginAction",
"(",
"$",
"request",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"get",
"(",
"'data'",
")",
";",
"$",
"userModel",
"=",
"new",
"ModelUser",
"(",
")",
";",
"$",
"validUser",
"=",
"$",
"userModel",
"->",
"validateLogin",
"(",
"$",
"data",
"[",
"'email'",
"]",
",",
"$",
"data",
"[",
"'password'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"validUser",
")",
"{",
"$",
"this",
"->",
"setMessage",
"(",
"'danger'",
",",
"'Not valid user / password combination'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"url",
"(",
"'login'",
")",
")",
";",
"}",
"$",
"this",
"->",
"session",
"(",
")",
"->",
"set",
"(",
"'user'",
",",
"$",
"userModel",
"->",
"record",
")",
";",
"$",
"this",
"->",
"sessionClearMessages",
"(",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"'/'",
")",
";",
"}"
] |
Handles the login action.
@param $request
@return \Symfony\Component\HttpFoundation\RedirectResponse
|
[
"Handles",
"the",
"login",
"action",
"."
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Controller/User.php#L46-L60
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.