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,600
|
shipmile/shipmile-api-php
|
lib/Shipmile/HttpClient/AuthHandler.php
|
AuthHandler.httpPassword
|
public function httpPassword(Event $event)
{
$event['request']->setHeader('Authorization', sprintf('Basic %s', base64_encode($this->auth['username'] . ':' . $this->auth['password'])));
}
|
php
|
public function httpPassword(Event $event)
{
$event['request']->setHeader('Authorization', sprintf('Basic %s', base64_encode($this->auth['username'] . ':' . $this->auth['password'])));
}
|
[
"public",
"function",
"httpPassword",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"event",
"[",
"'request'",
"]",
"->",
"setHeader",
"(",
"'Authorization'",
",",
"sprintf",
"(",
"'Basic %s'",
",",
"base64_encode",
"(",
"$",
"this",
"->",
"auth",
"[",
"'username'",
"]",
".",
"':'",
".",
"$",
"this",
"->",
"auth",
"[",
"'password'",
"]",
")",
")",
")",
";",
"}"
] |
Basic Authorization with username and password
|
[
"Basic",
"Authorization",
"with",
"username",
"and",
"password"
] |
b8272613b3a27f0f27e8722cbee277e41e9dfe59
|
https://github.com/shipmile/shipmile-api-php/blob/b8272613b3a27f0f27e8722cbee277e41e9dfe59/lib/Shipmile/HttpClient/AuthHandler.php#L77-L80
|
22,601
|
shipmile/shipmile-api-php
|
lib/Shipmile/HttpClient/AuthHandler.php
|
AuthHandler.urlSecret
|
public function urlSecret(Event $event)
{
$query = $event['request']->getQuery();
$query->set('client_id', $this->auth['client_id']);
$query->set('client_secret', $this->auth['client_secret']);
}
|
php
|
public function urlSecret(Event $event)
{
$query = $event['request']->getQuery();
$query->set('client_id', $this->auth['client_id']);
$query->set('client_secret', $this->auth['client_secret']);
}
|
[
"public",
"function",
"urlSecret",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"query",
"=",
"$",
"event",
"[",
"'request'",
"]",
"->",
"getQuery",
"(",
")",
";",
"$",
"query",
"->",
"set",
"(",
"'client_id'",
",",
"$",
"this",
"->",
"auth",
"[",
"'client_id'",
"]",
")",
";",
"$",
"query",
"->",
"set",
"(",
"'client_secret'",
",",
"$",
"this",
"->",
"auth",
"[",
"'client_secret'",
"]",
")",
";",
"}"
] |
OAUTH2 Authorization with client secret
|
[
"OAUTH2",
"Authorization",
"with",
"client",
"secret"
] |
b8272613b3a27f0f27e8722cbee277e41e9dfe59
|
https://github.com/shipmile/shipmile-api-php/blob/b8272613b3a27f0f27e8722cbee277e41e9dfe59/lib/Shipmile/HttpClient/AuthHandler.php#L85-L91
|
22,602
|
nathan-fiscaletti/extended-arrays
|
src/ExtendedArrays/AssociativeArray.php
|
AssociativeArray.offsetSet
|
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new \Exception('Must supply key to modify arguments in an AssociativeArray.');
} else {
$this->_args[$offset] = $value;
}
}
|
php
|
public function offsetSet($offset, $value)
{
if (is_null($offset)) {
throw new \Exception('Must supply key to modify arguments in an AssociativeArray.');
} else {
$this->_args[$offset] = $value;
}
}
|
[
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"offset",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Must supply key to modify arguments in an AssociativeArray.'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_args",
"[",
"$",
"offset",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Override the offsetSet function to modify
values of the wrapped array. Key is enforced.
@param mixed $offset
@param mixed $value
@return mixed
@throws \Exception
|
[
"Override",
"the",
"offsetSet",
"function",
"to",
"modify",
"values",
"of",
"the",
"wrapped",
"array",
".",
"Key",
"is",
"enforced",
"."
] |
a641856115131f76417521d3e4aa2d951158050a
|
https://github.com/nathan-fiscaletti/extended-arrays/blob/a641856115131f76417521d3e4aa2d951158050a/src/ExtendedArrays/AssociativeArray.php#L34-L41
|
22,603
|
nblum/silverstripe-flexible-content
|
code/ContentPage.php
|
ContentPage_Controller.Elements
|
public function Elements()
{
$fcvdo = new \Nblum\FlexibleContent\FlexibleContentVersionedDataObject();
$defaultStage = $fcvdo->getDefaultStage();
if (isset($_GET['stage']) && $defaultStage == $_GET['stage'] && \Permission::check('CMS_ACCESS')) {
$stage = $defaultStage;
} else {
$stage = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_live_stage();
}
$results = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_by_stage(
\ContentElement::class,
$stage
, [
'Active' => '1',
'ParentID' => $this->getField('ID')
], [
'Sort' => 'ASC'
]);
return $results;
}
|
php
|
public function Elements()
{
$fcvdo = new \Nblum\FlexibleContent\FlexibleContentVersionedDataObject();
$defaultStage = $fcvdo->getDefaultStage();
if (isset($_GET['stage']) && $defaultStage == $_GET['stage'] && \Permission::check('CMS_ACCESS')) {
$stage = $defaultStage;
} else {
$stage = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_live_stage();
}
$results = \Nblum\FlexibleContent\FlexibleContentVersionedDataObject::get_by_stage(
\ContentElement::class,
$stage
, [
'Active' => '1',
'ParentID' => $this->getField('ID')
], [
'Sort' => 'ASC'
]);
return $results;
}
|
[
"public",
"function",
"Elements",
"(",
")",
"{",
"$",
"fcvdo",
"=",
"new",
"\\",
"Nblum",
"\\",
"FlexibleContent",
"\\",
"FlexibleContentVersionedDataObject",
"(",
")",
";",
"$",
"defaultStage",
"=",
"$",
"fcvdo",
"->",
"getDefaultStage",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'stage'",
"]",
")",
"&&",
"$",
"defaultStage",
"==",
"$",
"_GET",
"[",
"'stage'",
"]",
"&&",
"\\",
"Permission",
"::",
"check",
"(",
"'CMS_ACCESS'",
")",
")",
"{",
"$",
"stage",
"=",
"$",
"defaultStage",
";",
"}",
"else",
"{",
"$",
"stage",
"=",
"\\",
"Nblum",
"\\",
"FlexibleContent",
"\\",
"FlexibleContentVersionedDataObject",
"::",
"get_live_stage",
"(",
")",
";",
"}",
"$",
"results",
"=",
"\\",
"Nblum",
"\\",
"FlexibleContent",
"\\",
"FlexibleContentVersionedDataObject",
"::",
"get_by_stage",
"(",
"\\",
"ContentElement",
"::",
"class",
",",
"$",
"stage",
",",
"[",
"'Active'",
"=>",
"'1'",
",",
"'ParentID'",
"=>",
"$",
"this",
"->",
"getField",
"(",
"'ID'",
")",
"]",
",",
"[",
"'Sort'",
"=>",
"'ASC'",
"]",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
creates List of all rows with content
@return DataList
|
[
"creates",
"List",
"of",
"all",
"rows",
"with",
"content"
] |
e20a06ee98b7f884965a951653d98af11eb6bc67
|
https://github.com/nblum/silverstripe-flexible-content/blob/e20a06ee98b7f884965a951653d98af11eb6bc67/code/ContentPage.php#L197-L218
|
22,604
|
DevGroup-ru/yii2-measure
|
src/helpers/MeasureHelper.php
|
MeasureHelper.convert
|
public static function convert($value, $to, $from)
{
if ($from instanceof Measure === false || $to instanceof Measure === false) {
throw new Exception('`from` or `to` parameter is not a Measure');
}
if ($from->type !== $to->type) {
throw new Exception('Measures have different types');
}
if ($from->id == $to->id) {
return $value;
}
$converterClass = isset(static::$converters[$to->type]) === true
? static::$converters[$to->type]
: 'DevGroup\Measure\converters\DefaultMeasureTypeConverter';
return $converterClass::convert($value, $to, $from);
}
|
php
|
public static function convert($value, $to, $from)
{
if ($from instanceof Measure === false || $to instanceof Measure === false) {
throw new Exception('`from` or `to` parameter is not a Measure');
}
if ($from->type !== $to->type) {
throw new Exception('Measures have different types');
}
if ($from->id == $to->id) {
return $value;
}
$converterClass = isset(static::$converters[$to->type]) === true
? static::$converters[$to->type]
: 'DevGroup\Measure\converters\DefaultMeasureTypeConverter';
return $converterClass::convert($value, $to, $from);
}
|
[
"public",
"static",
"function",
"convert",
"(",
"$",
"value",
",",
"$",
"to",
",",
"$",
"from",
")",
"{",
"if",
"(",
"$",
"from",
"instanceof",
"Measure",
"===",
"false",
"||",
"$",
"to",
"instanceof",
"Measure",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'`from` or `to` parameter is not a Measure'",
")",
";",
"}",
"if",
"(",
"$",
"from",
"->",
"type",
"!==",
"$",
"to",
"->",
"type",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Measures have different types'",
")",
";",
"}",
"if",
"(",
"$",
"from",
"->",
"id",
"==",
"$",
"to",
"->",
"id",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"converterClass",
"=",
"isset",
"(",
"static",
"::",
"$",
"converters",
"[",
"$",
"to",
"->",
"type",
"]",
")",
"===",
"true",
"?",
"static",
"::",
"$",
"converters",
"[",
"$",
"to",
"->",
"type",
"]",
":",
"'DevGroup\\Measure\\converters\\DefaultMeasureTypeConverter'",
";",
"return",
"$",
"converterClass",
"::",
"convert",
"(",
"$",
"value",
",",
"$",
"to",
",",
"$",
"from",
")",
";",
"}"
] |
Convert a value from one measure to another
@param float $value
@param Measure $from
@param Measure $to
@return float
@throws Exception
|
[
"Convert",
"a",
"value",
"from",
"one",
"measure",
"to",
"another"
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/helpers/MeasureHelper.php#L30-L45
|
22,605
|
DevGroup-ru/yii2-measure
|
src/helpers/MeasureHelper.php
|
MeasureHelper.format
|
public static function format($value, $to, $from = null)
{
if ($to instanceof Measure === false) {
throw new Exception('Unknown object');
}
if ($from instanceof Measure) {
$value = static::convert($value, $to, $from);
}
$formatter = $to->use_custom_formatter == true ? $to->formatter : \Yii::$app->formatter;
return strtr(
$to->format,
[
'#' => $formatter->asDecimal($value),
'$' => static::t($to->unit),
]
);
}
|
php
|
public static function format($value, $to, $from = null)
{
if ($to instanceof Measure === false) {
throw new Exception('Unknown object');
}
if ($from instanceof Measure) {
$value = static::convert($value, $to, $from);
}
$formatter = $to->use_custom_formatter == true ? $to->formatter : \Yii::$app->formatter;
return strtr(
$to->format,
[
'#' => $formatter->asDecimal($value),
'$' => static::t($to->unit),
]
);
}
|
[
"public",
"static",
"function",
"format",
"(",
"$",
"value",
",",
"$",
"to",
",",
"$",
"from",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"to",
"instanceof",
"Measure",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unknown object'",
")",
";",
"}",
"if",
"(",
"$",
"from",
"instanceof",
"Measure",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"convert",
"(",
"$",
"value",
",",
"$",
"to",
",",
"$",
"from",
")",
";",
"}",
"$",
"formatter",
"=",
"$",
"to",
"->",
"use_custom_formatter",
"==",
"true",
"?",
"$",
"to",
"->",
"formatter",
":",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"formatter",
";",
"return",
"strtr",
"(",
"$",
"to",
"->",
"format",
",",
"[",
"'#'",
"=>",
"$",
"formatter",
"->",
"asDecimal",
"(",
"$",
"value",
")",
",",
"'$'",
"=>",
"static",
"::",
"t",
"(",
"$",
"to",
"->",
"unit",
")",
",",
"]",
")",
";",
"}"
] |
Format a value by rule as a string
@param double $value
@param Measure $to
@param Measure|null $from
@return string
@throws Exception
|
[
"Format",
"a",
"value",
"by",
"rule",
"as",
"a",
"string"
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/helpers/MeasureHelper.php#L55-L71
|
22,606
|
DevGroup-ru/yii2-measure
|
src/helpers/MeasureHelper.php
|
MeasureHelper.parseString
|
public static function parseString($source, $matchRules)
{
foreach ((array) $matchRules as $matchRule) {
if (is_callable($matchRule) === true) {
return call_user_func($matchRule, $source);
} else {
if (preg_match($matchRule, $source, $matches) === 1) {
$value = $matches['integral'];
if (isset($matches['fractional'])) {
$value .= '.' . $matches['fractional'];
}
return (double) $value;
}
}
}
return false;
}
|
php
|
public static function parseString($source, $matchRules)
{
foreach ((array) $matchRules as $matchRule) {
if (is_callable($matchRule) === true) {
return call_user_func($matchRule, $source);
} else {
if (preg_match($matchRule, $source, $matches) === 1) {
$value = $matches['integral'];
if (isset($matches['fractional'])) {
$value .= '.' . $matches['fractional'];
}
return (double) $value;
}
}
}
return false;
}
|
[
"public",
"static",
"function",
"parseString",
"(",
"$",
"source",
",",
"$",
"matchRules",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"matchRules",
"as",
"$",
"matchRule",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"matchRule",
")",
"===",
"true",
")",
"{",
"return",
"call_user_func",
"(",
"$",
"matchRule",
",",
"$",
"source",
")",
";",
"}",
"else",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"matchRule",
",",
"$",
"source",
",",
"$",
"matches",
")",
"===",
"1",
")",
"{",
"$",
"value",
"=",
"$",
"matches",
"[",
"'integral'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"'fractional'",
"]",
")",
")",
"{",
"$",
"value",
".=",
"'.'",
".",
"$",
"matches",
"[",
"'fractional'",
"]",
";",
"}",
"return",
"(",
"double",
")",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Parse string by regexp or closure.
@param string $source
@param \Closure[]|string[]|\Closure|string $matchRules
@return false|float
|
[
"Parse",
"string",
"by",
"regexp",
"or",
"closure",
"."
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/helpers/MeasureHelper.php#L79-L95
|
22,607
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/delivery_status.php
|
ezcMailDeliveryStatus.addHeadersSection
|
private function addHeadersSection( ezcMailHeadersHolder $headers )
{
$result = "";
foreach ( $headers->getCaseSensitiveArray() as $header => $value )
{
$result .= $header . ": " . $value . ezcMailTools::lineBreak();
}
return $result;
}
|
php
|
private function addHeadersSection( ezcMailHeadersHolder $headers )
{
$result = "";
foreach ( $headers->getCaseSensitiveArray() as $header => $value )
{
$result .= $header . ": " . $value . ezcMailTools::lineBreak();
}
return $result;
}
|
[
"private",
"function",
"addHeadersSection",
"(",
"ezcMailHeadersHolder",
"$",
"headers",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"headers",
"->",
"getCaseSensitiveArray",
"(",
")",
"as",
"$",
"header",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
".=",
"$",
"header",
".",
"\": \"",
".",
"$",
"value",
".",
"ezcMailTools",
"::",
"lineBreak",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the generated text for a section of the delivery-status part.
@param ezcMailHeadersHolder $headers
@return string
|
[
"Returns",
"the",
"generated",
"text",
"for",
"a",
"section",
"of",
"the",
"delivery",
"-",
"status",
"part",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/delivery_status.php#L155-L163
|
22,608
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/delivery_status.php
|
ezcMailDeliveryStatus.createRecipient
|
public function createRecipient()
{
$result = count( $this->recipients );
$this->recipients[$result] = new ezcMailHeadersHolder();
return $result;
}
|
php
|
public function createRecipient()
{
$result = count( $this->recipients );
$this->recipients[$result] = new ezcMailHeadersHolder();
return $result;
}
|
[
"public",
"function",
"createRecipient",
"(",
")",
"{",
"$",
"result",
"=",
"count",
"(",
"$",
"this",
"->",
"recipients",
")",
";",
"$",
"this",
"->",
"recipients",
"[",
"$",
"result",
"]",
"=",
"new",
"ezcMailHeadersHolder",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Adds a new recipient to this delivery-status message and returns the index
of the last added recipient.
@return int
|
[
"Adds",
"a",
"new",
"recipient",
"to",
"this",
"delivery",
"-",
"status",
"message",
"and",
"returns",
"the",
"index",
"of",
"the",
"last",
"added",
"recipient",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/delivery_status.php#L171-L176
|
22,609
|
phapi/cache-nullcache
|
src/Phapi/Di/Validator/Cache.php
|
Cache.validate
|
public function validate($cache)
{
$original = $cache;
// Make sure the cache is configured using a closure
if (is_callable($cache)) {
$failed = false;
try {
$cache = $cache($this->container);
} catch (\Exception $e) {
$failed = true;
// Add a note to the log that we are unable to connect to the cache backend
$this->container['log']->warning(
'Unable to connect to the cache backend.'
);
}
// Return original closure if connection didn't fail and if
// the cache is an instance of the Cache Contract
if (!$failed && $cache instanceof CacheContract) {
return $original;
}
} else {
// Add a note to the log that the configuration must be updated
$this->container['log']->warning(
'A cache must be configured as a closure. See the documentation for more information.'
);
}
// Return a NullCache as a fallback
return function ($app) {
return new NullCache();
};
}
|
php
|
public function validate($cache)
{
$original = $cache;
// Make sure the cache is configured using a closure
if (is_callable($cache)) {
$failed = false;
try {
$cache = $cache($this->container);
} catch (\Exception $e) {
$failed = true;
// Add a note to the log that we are unable to connect to the cache backend
$this->container['log']->warning(
'Unable to connect to the cache backend.'
);
}
// Return original closure if connection didn't fail and if
// the cache is an instance of the Cache Contract
if (!$failed && $cache instanceof CacheContract) {
return $original;
}
} else {
// Add a note to the log that the configuration must be updated
$this->container['log']->warning(
'A cache must be configured as a closure. See the documentation for more information.'
);
}
// Return a NullCache as a fallback
return function ($app) {
return new NullCache();
};
}
|
[
"public",
"function",
"validate",
"(",
"$",
"cache",
")",
"{",
"$",
"original",
"=",
"$",
"cache",
";",
"// Make sure the cache is configured using a closure",
"if",
"(",
"is_callable",
"(",
"$",
"cache",
")",
")",
"{",
"$",
"failed",
"=",
"false",
";",
"try",
"{",
"$",
"cache",
"=",
"$",
"cache",
"(",
"$",
"this",
"->",
"container",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"failed",
"=",
"true",
";",
"// Add a note to the log that we are unable to connect to the cache backend",
"$",
"this",
"->",
"container",
"[",
"'log'",
"]",
"->",
"warning",
"(",
"'Unable to connect to the cache backend.'",
")",
";",
"}",
"// Return original closure if connection didn't fail and if",
"// the cache is an instance of the Cache Contract",
"if",
"(",
"!",
"$",
"failed",
"&&",
"$",
"cache",
"instanceof",
"CacheContract",
")",
"{",
"return",
"$",
"original",
";",
"}",
"}",
"else",
"{",
"// Add a note to the log that the configuration must be updated",
"$",
"this",
"->",
"container",
"[",
"'log'",
"]",
"->",
"warning",
"(",
"'A cache must be configured as a closure. See the documentation for more information.'",
")",
";",
"}",
"// Return a NullCache as a fallback",
"return",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"NullCache",
"(",
")",
";",
"}",
";",
"}"
] |
Validate a cache to ensure it implements the Cache Contract and that
we are able to connect to the cache backend.
If we are unable to connect to the cache backend an Exception should be
thrown. That Exception will be handled by the validator.
A working cache is NOT a requirement for the application to run so it's
important to handle the exception and let the application run.
If the exception below is thrown a new NullCache will be created instead.
@param $cache
@return callable
|
[
"Validate",
"a",
"cache",
"to",
"ensure",
"it",
"implements",
"the",
"Cache",
"Contract",
"and",
"that",
"we",
"are",
"able",
"to",
"connect",
"to",
"the",
"cache",
"backend",
"."
] |
89e1c16f2d50b77cd112c27627d6733de32fb5c3
|
https://github.com/phapi/cache-nullcache/blob/89e1c16f2d50b77cd112c27627d6733de32fb5c3/src/Phapi/Di/Validator/Cache.php#L49-L82
|
22,610
|
old-town/workflow-designer-server
|
src/View/WorkflowDescriptorApiStrategy.php
|
WorkflowDescriptorApiStrategy.injectResponse
|
public function injectResponse(ViewEvent $e)
{
$renderer = $e->getRenderer();
if ($renderer !== $this->renderer) {
return;
}
$result = $e->getResult();
/** @var HttpResponse $response */
$response = $e->getResponse();
$response->setContent($result);
$headers = $response->getHeaders();
//$headers->addHeaderLine('Content-length', strlen($result));
$headers->addHeaderLine('content-type', 'text/xml');
}
|
php
|
public function injectResponse(ViewEvent $e)
{
$renderer = $e->getRenderer();
if ($renderer !== $this->renderer) {
return;
}
$result = $e->getResult();
/** @var HttpResponse $response */
$response = $e->getResponse();
$response->setContent($result);
$headers = $response->getHeaders();
//$headers->addHeaderLine('Content-length', strlen($result));
$headers->addHeaderLine('content-type', 'text/xml');
}
|
[
"public",
"function",
"injectResponse",
"(",
"ViewEvent",
"$",
"e",
")",
"{",
"$",
"renderer",
"=",
"$",
"e",
"->",
"getRenderer",
"(",
")",
";",
"if",
"(",
"$",
"renderer",
"!==",
"$",
"this",
"->",
"renderer",
")",
"{",
"return",
";",
"}",
"$",
"result",
"=",
"$",
"e",
"->",
"getResult",
"(",
")",
";",
"/** @var HttpResponse $response */",
"$",
"response",
"=",
"$",
"e",
"->",
"getResponse",
"(",
")",
";",
"$",
"response",
"->",
"setContent",
"(",
"$",
"result",
")",
";",
"$",
"headers",
"=",
"$",
"response",
"->",
"getHeaders",
"(",
")",
";",
"//$headers->addHeaderLine('Content-length', strlen($result));",
"$",
"headers",
"->",
"addHeaderLine",
"(",
"'content-type'",
",",
"'text/xml'",
")",
";",
"}"
] |
Inject the response with the feed payload and appropriate Content-Type header
@param ViewEvent $e
@return void
@throws \Zend\Http\Exception\InvalidArgumentException
|
[
"Inject",
"the",
"response",
"with",
"the",
"feed",
"payload",
"and",
"appropriate",
"Content",
"-",
"Type",
"header"
] |
6389c5a515861cc8e0b769f1ca7be12c6b78c611
|
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/WorkflowDescriptorApiStrategy.php#L73-L89
|
22,611
|
Daursu/xero
|
src/Daursu/Xero/models/Invoice.php
|
Invoice.getPdf
|
public function getPdf($id = '')
{
$id = $id ? : $this->attributes[$this->primary_column];
return $this->request('GET', sprintf('%s/%s', $this->getUrl(), $id), array(), "", "pdf");
}
|
php
|
public function getPdf($id = '')
{
$id = $id ? : $this->attributes[$this->primary_column];
return $this->request('GET', sprintf('%s/%s', $this->getUrl(), $id), array(), "", "pdf");
}
|
[
"public",
"function",
"getPdf",
"(",
"$",
"id",
"=",
"''",
")",
"{",
"$",
"id",
"=",
"$",
"id",
"?",
":",
"$",
"this",
"->",
"attributes",
"[",
"$",
"this",
"->",
"primary_column",
"]",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'GET'",
",",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getUrl",
"(",
")",
",",
"$",
"id",
")",
",",
"array",
"(",
")",
",",
"\"\"",
",",
"\"pdf\"",
")",
";",
"}"
] |
Retrieves a PDF file of an invoice
@return mixed
|
[
"Retrieves",
"a",
"PDF",
"file",
"of",
"an",
"invoice"
] |
f6ac2b0cd3123f9667fd07927bee6725d34df4a6
|
https://github.com/Daursu/xero/blob/f6ac2b0cd3123f9667fd07927bee6725d34df4a6/src/Daursu/Xero/models/Invoice.php#L17-L21
|
22,612
|
ekuiter/feature-php
|
FeaturePhp/Aspect/AspectKernel.php
|
AspectKernel.generateFiles
|
public function generateFiles($class, $target) {
$files = array();
$includes = "";
$registers = "";
foreach ($this->aspects as $aspect) {
$files[] = $aspect->getStoredFile();
$includes .= "require_once __DIR__ . '/" . str_replace("'", "\'", $aspect->getRelativeFileTarget($target)) . "';\n";
$registers .= ' $container->registerAspect(new ' . $aspect->getClassName() . "());\n";
}
$files[] = fphp\File\TemplateFile::fromSpecification(
fphp\Specification\TemplateSpecification::fromArrayAndSettings(
array(
"source" => "AspectKernel.php.template",
"target" => $target,
"rules" => array(
array("assign" => "class", "to" => $class),
array("assign" => "includes", "to" => trim($includes)),
array("assign" => "registers", "to" => trim($registers))
)
), fphp\Settings::inDirectory(__DIR__))
);
return $files;
}
|
php
|
public function generateFiles($class, $target) {
$files = array();
$includes = "";
$registers = "";
foreach ($this->aspects as $aspect) {
$files[] = $aspect->getStoredFile();
$includes .= "require_once __DIR__ . '/" . str_replace("'", "\'", $aspect->getRelativeFileTarget($target)) . "';\n";
$registers .= ' $container->registerAspect(new ' . $aspect->getClassName() . "());\n";
}
$files[] = fphp\File\TemplateFile::fromSpecification(
fphp\Specification\TemplateSpecification::fromArrayAndSettings(
array(
"source" => "AspectKernel.php.template",
"target" => $target,
"rules" => array(
array("assign" => "class", "to" => $class),
array("assign" => "includes", "to" => trim($includes)),
array("assign" => "registers", "to" => trim($registers))
)
), fphp\Settings::inDirectory(__DIR__))
);
return $files;
}
|
[
"public",
"function",
"generateFiles",
"(",
"$",
"class",
",",
"$",
"target",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"$",
"includes",
"=",
"\"\"",
";",
"$",
"registers",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"aspects",
"as",
"$",
"aspect",
")",
"{",
"$",
"files",
"[",
"]",
"=",
"$",
"aspect",
"->",
"getStoredFile",
"(",
")",
";",
"$",
"includes",
".=",
"\"require_once __DIR__ . '/\"",
".",
"str_replace",
"(",
"\"'\"",
",",
"\"\\'\"",
",",
"$",
"aspect",
"->",
"getRelativeFileTarget",
"(",
"$",
"target",
")",
")",
".",
"\"';\\n\"",
";",
"$",
"registers",
".=",
"' $container->registerAspect(new '",
".",
"$",
"aspect",
"->",
"getClassName",
"(",
")",
".",
"\"());\\n\"",
";",
"}",
"$",
"files",
"[",
"]",
"=",
"fphp",
"\\",
"File",
"\\",
"TemplateFile",
"::",
"fromSpecification",
"(",
"fphp",
"\\",
"Specification",
"\\",
"TemplateSpecification",
"::",
"fromArrayAndSettings",
"(",
"array",
"(",
"\"source\"",
"=>",
"\"AspectKernel.php.template\"",
",",
"\"target\"",
"=>",
"$",
"target",
",",
"\"rules\"",
"=>",
"array",
"(",
"array",
"(",
"\"assign\"",
"=>",
"\"class\"",
",",
"\"to\"",
"=>",
"$",
"class",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"includes\"",
",",
"\"to\"",
"=>",
"trim",
"(",
"$",
"includes",
")",
")",
",",
"array",
"(",
"\"assign\"",
"=>",
"\"registers\"",
",",
"\"to\"",
"=>",
"trim",
"(",
"$",
"registers",
")",
")",
")",
")",
",",
"fphp",
"\\",
"Settings",
"::",
"inDirectory",
"(",
"__DIR__",
")",
")",
")",
";",
"return",
"$",
"files",
";",
"}"
] |
Generates the aspect kernel's files.
This includes all aspect files and the aspect kernel itself.
@param string $class
@param string $target
|
[
"Generates",
"the",
"aspect",
"kernel",
"s",
"files",
".",
"This",
"includes",
"all",
"aspect",
"files",
"and",
"the",
"aspect",
"kernel",
"itself",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Aspect/AspectKernel.php#L44-L69
|
22,613
|
NuclearCMS/Hierarchy
|
src/Builders/ModelBuilder.php
|
ModelBuilder.build
|
public function build($name, Collection $fields = null)
{
$path = $this->getClassFilePath($name);
$tableName = source_table_name($name);
$contents = view('_hierarchy::entities.model', [
'tableName' => $tableName,
'name' => $this->getClassName($name),
'fields' => $this->makeFields($fields),
'searchableFields' => $this->makeSearchableFields($fields, $tableName),
'mutatables' => $this->makeMutatableFields($fields)
])->render();
$this->write($path, $contents);
}
|
php
|
public function build($name, Collection $fields = null)
{
$path = $this->getClassFilePath($name);
$tableName = source_table_name($name);
$contents = view('_hierarchy::entities.model', [
'tableName' => $tableName,
'name' => $this->getClassName($name),
'fields' => $this->makeFields($fields),
'searchableFields' => $this->makeSearchableFields($fields, $tableName),
'mutatables' => $this->makeMutatableFields($fields)
])->render();
$this->write($path, $contents);
}
|
[
"public",
"function",
"build",
"(",
"$",
"name",
",",
"Collection",
"$",
"fields",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getClassFilePath",
"(",
"$",
"name",
")",
";",
"$",
"tableName",
"=",
"source_table_name",
"(",
"$",
"name",
")",
";",
"$",
"contents",
"=",
"view",
"(",
"'_hierarchy::entities.model'",
",",
"[",
"'tableName'",
"=>",
"$",
"tableName",
",",
"'name'",
"=>",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"name",
")",
",",
"'fields'",
"=>",
"$",
"this",
"->",
"makeFields",
"(",
"$",
"fields",
")",
",",
"'searchableFields'",
"=>",
"$",
"this",
"->",
"makeSearchableFields",
"(",
"$",
"fields",
",",
"$",
"tableName",
")",
",",
"'mutatables'",
"=>",
"$",
"this",
"->",
"makeMutatableFields",
"(",
"$",
"fields",
")",
"]",
")",
"->",
"render",
"(",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"path",
",",
"$",
"contents",
")",
";",
"}"
] |
Builds a source model
@param string $name
@param Collection $fields
|
[
"Builds",
"a",
"source",
"model"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/ModelBuilder.php#L20-L34
|
22,614
|
NuclearCMS/Hierarchy
|
src/Builders/ModelBuilder.php
|
ModelBuilder.makeSearchableFields
|
protected function makeSearchableFields(Collection $fields = null, $tableName)
{
if (is_null($fields))
{
return '';
}
$searchables = [];
foreach ($fields as $field)
{
if (intval($field->search_priority) > 0)
{
$searchables[] = "'{$tableName}.{$field->name}' => {$field->search_priority}";
}
}
return implode(",", $searchables);
}
|
php
|
protected function makeSearchableFields(Collection $fields = null, $tableName)
{
if (is_null($fields))
{
return '';
}
$searchables = [];
foreach ($fields as $field)
{
if (intval($field->search_priority) > 0)
{
$searchables[] = "'{$tableName}.{$field->name}' => {$field->search_priority}";
}
}
return implode(",", $searchables);
}
|
[
"protected",
"function",
"makeSearchableFields",
"(",
"Collection",
"$",
"fields",
"=",
"null",
",",
"$",
"tableName",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fields",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"searchables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"intval",
"(",
"$",
"field",
"->",
"search_priority",
")",
">",
"0",
")",
"{",
"$",
"searchables",
"[",
"]",
"=",
"\"'{$tableName}.{$field->name}' => {$field->search_priority}\"",
";",
"}",
"}",
"return",
"implode",
"(",
"\",\"",
",",
"$",
"searchables",
")",
";",
"}"
] |
Makes searchable fields
@param Collection $fields
@param string $tableName
@return string
|
[
"Makes",
"searchable",
"fields"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/ModelBuilder.php#L61-L79
|
22,615
|
NuclearCMS/Hierarchy
|
src/Builders/ModelBuilder.php
|
ModelBuilder.makeMutatableFields
|
protected function makeMutatableFields(Collection $fields = null)
{
if (is_null($fields))
{
return '';
}
$mutatables = [];
foreach ($fields as $field)
{
if (in_array($field->type, ['document', 'gallery', 'markdown', 'node', 'node_collection']))
{
$mutatables[] = "'{$field->name}' => '{$field->type}'";
}
}
return implode(",", $mutatables);
}
|
php
|
protected function makeMutatableFields(Collection $fields = null)
{
if (is_null($fields))
{
return '';
}
$mutatables = [];
foreach ($fields as $field)
{
if (in_array($field->type, ['document', 'gallery', 'markdown', 'node', 'node_collection']))
{
$mutatables[] = "'{$field->name}' => '{$field->type}'";
}
}
return implode(",", $mutatables);
}
|
[
"protected",
"function",
"makeMutatableFields",
"(",
"Collection",
"$",
"fields",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fields",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"mutatables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"field",
"->",
"type",
",",
"[",
"'document'",
",",
"'gallery'",
",",
"'markdown'",
",",
"'node'",
",",
"'node_collection'",
"]",
")",
")",
"{",
"$",
"mutatables",
"[",
"]",
"=",
"\"'{$field->name}' => '{$field->type}'\"",
";",
"}",
"}",
"return",
"implode",
"(",
"\",\"",
",",
"$",
"mutatables",
")",
";",
"}"
] |
Makes mutatable fields
@param Collection $fields
@return string
|
[
"Makes",
"mutatable",
"fields"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/Builders/ModelBuilder.php#L87-L105
|
22,616
|
kusanagi/katana-sdk-php7
|
src/Component/Component.php
|
Component.run
|
public function run(): bool
{
if ($this->startup) {
$this->logger->debug('Calling startup callback');
call_user_func($this->startup, $this);
}
$actions = implode(', ', array_keys($this->callbacks));
$this->logger->info("Component running with callbacks for $actions");
$this->executor->execute(
$this->apiFactory,
$this->input,
$this->callbacks,
$this->error
);
if ($this->shutdown) {
$this->logger->debug('Calling shutdown callback');
call_user_func($this->shutdown, $this);
}
return true;
}
|
php
|
public function run(): bool
{
if ($this->startup) {
$this->logger->debug('Calling startup callback');
call_user_func($this->startup, $this);
}
$actions = implode(', ', array_keys($this->callbacks));
$this->logger->info("Component running with callbacks for $actions");
$this->executor->execute(
$this->apiFactory,
$this->input,
$this->callbacks,
$this->error
);
if ($this->shutdown) {
$this->logger->debug('Calling shutdown callback');
call_user_func($this->shutdown, $this);
}
return true;
}
|
[
"public",
"function",
"run",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"startup",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Calling startup callback'",
")",
";",
"call_user_func",
"(",
"$",
"this",
"->",
"startup",
",",
"$",
"this",
")",
";",
"}",
"$",
"actions",
"=",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"this",
"->",
"callbacks",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"Component running with callbacks for $actions\"",
")",
";",
"$",
"this",
"->",
"executor",
"->",
"execute",
"(",
"$",
"this",
"->",
"apiFactory",
",",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"callbacks",
",",
"$",
"this",
"->",
"error",
")",
";",
"if",
"(",
"$",
"this",
"->",
"shutdown",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Calling shutdown callback'",
")",
";",
"call_user_func",
"(",
"$",
"this",
"->",
"shutdown",
",",
"$",
"this",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Run the SDK.
@return bool
|
[
"Run",
"the",
"SDK",
"."
] |
91e7860a1852c3ce79a7034f8c36f41840e69e1f
|
https://github.com/kusanagi/katana-sdk-php7/blob/91e7860a1852c3ce79a7034f8c36f41840e69e1f/src/Component/Component.php#L131-L153
|
22,617
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/xGlobal/fexe.php
|
fexe.getFileData
|
public function getFileData($file = null, $offset = null){
if(null === $file)$file = &$this->file;
if(null === $offset)$offset = $this->file_offset;
$this->IO = fopen($file, 'r');
fseek($this->IO, $offset);
try{
$this->raw = stream_get_contents($this->IO);
}catch(\Exception $e){
$this->raw = '';
trigger_error($e->getMessage(), $this->e_level);
}
return $this->raw;
}
|
php
|
public function getFileData($file = null, $offset = null){
if(null === $file)$file = &$this->file;
if(null === $offset)$offset = $this->file_offset;
$this->IO = fopen($file, 'r');
fseek($this->IO, $offset);
try{
$this->raw = stream_get_contents($this->IO);
}catch(\Exception $e){
$this->raw = '';
trigger_error($e->getMessage(), $this->e_level);
}
return $this->raw;
}
|
[
"public",
"function",
"getFileData",
"(",
"$",
"file",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"file",
")",
"$",
"file",
"=",
"&",
"$",
"this",
"->",
"file",
";",
"if",
"(",
"null",
"===",
"$",
"offset",
")",
"$",
"offset",
"=",
"$",
"this",
"->",
"file_offset",
";",
"$",
"this",
"->",
"IO",
"=",
"fopen",
"(",
"$",
"file",
",",
"'r'",
")",
";",
"fseek",
"(",
"$",
"this",
"->",
"IO",
",",
"$",
"offset",
")",
";",
"try",
"{",
"$",
"this",
"->",
"raw",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"IO",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"raw",
"=",
"''",
";",
"trigger_error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"this",
"->",
"e_level",
")",
";",
"}",
"return",
"$",
"this",
"->",
"raw",
";",
"}"
] |
read file from offset
@param undefined $file __FILE__
@param undefined $offset __COMPILER_HALT_OFFSET__
@return string
|
[
"read",
"file",
"from",
"offset"
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/xGlobal/fexe.php#L651-L664
|
22,618
|
gn36/phpbb-oo-posting-api
|
functions_post_oo.php
|
post.get
|
static function get($post_id)
{
global $db;
//$sql = "SELECT p.*, t.topic_first_post_id, t.topic_last_post_id
// FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
// WHERE p.post_id=" . intval($this->post_id) . " AND t.topic_id = p.topic_id";
$sql = "SELECT * FROM " . POSTS_TABLE . " WHERE post_id=" . intval($post_id);
$result = $db->sql_query($sql);
$post_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if(!$post_data)
{
//post does not exist, return false
return false;
}
return post::from_array($post_data);
}
|
php
|
static function get($post_id)
{
global $db;
//$sql = "SELECT p.*, t.topic_first_post_id, t.topic_last_post_id
// FROM " . POSTS_TABLE . " p, " . TOPICS_TABLE . " t
// WHERE p.post_id=" . intval($this->post_id) . " AND t.topic_id = p.topic_id";
$sql = "SELECT * FROM " . POSTS_TABLE . " WHERE post_id=" . intval($post_id);
$result = $db->sql_query($sql);
$post_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if(!$post_data)
{
//post does not exist, return false
return false;
}
return post::from_array($post_data);
}
|
[
"static",
"function",
"get",
"(",
"$",
"post_id",
")",
"{",
"global",
"$",
"db",
";",
"//$sql = \"SELECT p.*, t.topic_first_post_id, t.topic_last_post_id",
"//\t\tFROM \" . POSTS_TABLE . \" p, \" . TOPICS_TABLE . \" t",
"//\t\tWHERE p.post_id=\" . intval($this->post_id) . \" AND t.topic_id = p.topic_id\";",
"$",
"sql",
"=",
"\"SELECT * FROM \"",
".",
"POSTS_TABLE",
".",
"\" WHERE post_id=\"",
".",
"intval",
"(",
"$",
"post_id",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"sql_query",
"(",
"$",
"sql",
")",
";",
"$",
"post_data",
"=",
"$",
"db",
"->",
"sql_fetchrow",
"(",
"$",
"result",
")",
";",
"$",
"db",
"->",
"sql_freeresult",
"(",
"$",
"result",
")",
";",
"if",
"(",
"!",
"$",
"post_data",
")",
"{",
"//post does not exist, return false",
"return",
"false",
";",
"}",
"return",
"post",
"::",
"from_array",
"(",
"$",
"post_data",
")",
";",
"}"
] |
static method, loads the post with a given post_id from database.
returns false if the post does not exist
|
[
"static",
"method",
"loads",
"the",
"post",
"with",
"a",
"given",
"post_id",
"from",
"database",
".",
"returns",
"false",
"if",
"the",
"post",
"does",
"not",
"exist"
] |
d0e19482a9e1e93a435c1758a66df9324145381a
|
https://github.com/gn36/phpbb-oo-posting-api/blob/d0e19482a9e1e93a435c1758a66df9324145381a/functions_post_oo.php#L776-L795
|
22,619
|
gn36/phpbb-oo-posting-api
|
functions_post_oo.php
|
post.get_topic
|
function get_topic($all_posts = false)
{
if(!$this->_topic)
{
if($this->post_id)
{
//existing post, load existing topic
$this->_topic = topic::get($this->topic_id, $all_posts);
//insert $this into topic->posts array
if($all_posts)
{
//this post was also loaded from database, replace it with $this
for($i=0; $i<sizeof($this->_topic->posts); $i++)
{
if($this->_topic->posts[$i]->post_id == $this->post_id)
{
//found it
$this->_topic->posts[$i] = &$this;
break;
}
}
}
else
{
//no posts were loaded in topic::get(), add our post to topic->posts
$this->_topic->posts[] = &$this;
}
}
else
{
//new post, generate topic
$this->_topic = topic::from_post($this);
}
}
return $this->_topic;
}
|
php
|
function get_topic($all_posts = false)
{
if(!$this->_topic)
{
if($this->post_id)
{
//existing post, load existing topic
$this->_topic = topic::get($this->topic_id, $all_posts);
//insert $this into topic->posts array
if($all_posts)
{
//this post was also loaded from database, replace it with $this
for($i=0; $i<sizeof($this->_topic->posts); $i++)
{
if($this->_topic->posts[$i]->post_id == $this->post_id)
{
//found it
$this->_topic->posts[$i] = &$this;
break;
}
}
}
else
{
//no posts were loaded in topic::get(), add our post to topic->posts
$this->_topic->posts[] = &$this;
}
}
else
{
//new post, generate topic
$this->_topic = topic::from_post($this);
}
}
return $this->_topic;
}
|
[
"function",
"get_topic",
"(",
"$",
"all_posts",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_topic",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"post_id",
")",
"{",
"//existing post, load existing topic",
"$",
"this",
"->",
"_topic",
"=",
"topic",
"::",
"get",
"(",
"$",
"this",
"->",
"topic_id",
",",
"$",
"all_posts",
")",
";",
"//insert $this into topic->posts array",
"if",
"(",
"$",
"all_posts",
")",
"{",
"//this post was also loaded from database, replace it with $this",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"this",
"->",
"_topic",
"->",
"posts",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_topic",
"->",
"posts",
"[",
"$",
"i",
"]",
"->",
"post_id",
"==",
"$",
"this",
"->",
"post_id",
")",
"{",
"//found it",
"$",
"this",
"->",
"_topic",
"->",
"posts",
"[",
"$",
"i",
"]",
"=",
"&",
"$",
"this",
";",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"//no posts were loaded in topic::get(), add our post to topic->posts",
"$",
"this",
"->",
"_topic",
"->",
"posts",
"[",
"]",
"=",
"&",
"$",
"this",
";",
"}",
"}",
"else",
"{",
"//new post, generate topic",
"$",
"this",
"->",
"_topic",
"=",
"topic",
"::",
"from_post",
"(",
"$",
"this",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_topic",
";",
"}"
] |
loads and returns the topic for this post
@param all_posts whether to load all other posts of the topic into topic->posts
|
[
"loads",
"and",
"returns",
"the",
"topic",
"for",
"this",
"post"
] |
d0e19482a9e1e93a435c1758a66df9324145381a
|
https://github.com/gn36/phpbb-oo-posting-api/blob/d0e19482a9e1e93a435c1758a66df9324145381a/functions_post_oo.php#L865-L901
|
22,620
|
gn36/phpbb-oo-posting-api
|
functions_post_oo.php
|
syncer.add
|
function add($type, $id, $field, $amount = 1)
{
$this->init($type, $id);
if(!isset($this->data[$type][$id]['add'][$field]))
{
$this->data[$type][$id]['add'][$field] = 0;
}
$this->data[$type][$id]['add'][$field] += $amount;
}
|
php
|
function add($type, $id, $field, $amount = 1)
{
$this->init($type, $id);
if(!isset($this->data[$type][$id]['add'][$field]))
{
$this->data[$type][$id]['add'][$field] = 0;
}
$this->data[$type][$id]['add'][$field] += $amount;
}
|
[
"function",
"add",
"(",
"$",
"type",
",",
"$",
"id",
",",
"$",
"field",
",",
"$",
"amount",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"init",
"(",
"$",
"type",
",",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"type",
"]",
"[",
"$",
"id",
"]",
"[",
"'add'",
"]",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"type",
"]",
"[",
"$",
"id",
"]",
"[",
"'add'",
"]",
"[",
"$",
"field",
"]",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"$",
"type",
"]",
"[",
"$",
"id",
"]",
"[",
"'add'",
"]",
"[",
"$",
"field",
"]",
"+=",
"$",
"amount",
";",
"}"
] |
increments or decrements a field.
@param $type which table (topic, user, forum or post)
@param $id topic_id, user_id etc.
@param $field field name (e.g. topic_replies)
@param $amount how much to add/subtract (default 1)
example: $sync->add('topic', 123, 'topic_replies', 1)
-> UPDATE phpbb_topics SET topic_replies = topic_replies + 1 WHERE topic_id = 123
|
[
"increments",
"or",
"decrements",
"a",
"field",
"."
] |
d0e19482a9e1e93a435c1758a66df9324145381a
|
https://github.com/gn36/phpbb-oo-posting-api/blob/d0e19482a9e1e93a435c1758a66df9324145381a/functions_post_oo.php#L1866-L1874
|
22,621
|
bfitech/zapstore
|
src/SQL.php
|
SQL.open_pdo_connection
|
private function open_pdo_connection() {
try {
$this->connection = in_array(
$this->dbtype, ['sqlite3', 'pgsql'])
? new \PDO($this->connection_string)
: new \PDO(
$this->connection_string,
$this->dbuser, $this->dbpass);
self::$logger->debug(sprintf(
"SQL: connection opened: '%s'.",
json_encode($this->verified_params)));
} catch (\PDOException $e) {
self::$logger->error(sprintf(
"SQL: connection failed: '%s'.",
json_encode($this->verified_params)));
throw new SQLError(SQLError::CONNECTION_ERROR,
$this->dbtype . " connection error.");
}
$this->connection->setAttribute(
\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
# set pragma for SQLite3
if ($this->dbtype == 'sqlite3')
$this->connection->exec("PRAGMA foreign_keys=ON");
}
|
php
|
private function open_pdo_connection() {
try {
$this->connection = in_array(
$this->dbtype, ['sqlite3', 'pgsql'])
? new \PDO($this->connection_string)
: new \PDO(
$this->connection_string,
$this->dbuser, $this->dbpass);
self::$logger->debug(sprintf(
"SQL: connection opened: '%s'.",
json_encode($this->verified_params)));
} catch (\PDOException $e) {
self::$logger->error(sprintf(
"SQL: connection failed: '%s'.",
json_encode($this->verified_params)));
throw new SQLError(SQLError::CONNECTION_ERROR,
$this->dbtype . " connection error.");
}
$this->connection->setAttribute(
\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
# set pragma for SQLite3
if ($this->dbtype == 'sqlite3')
$this->connection->exec("PRAGMA foreign_keys=ON");
}
|
[
"private",
"function",
"open_pdo_connection",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"connection",
"=",
"in_array",
"(",
"$",
"this",
"->",
"dbtype",
",",
"[",
"'sqlite3'",
",",
"'pgsql'",
"]",
")",
"?",
"new",
"\\",
"PDO",
"(",
"$",
"this",
"->",
"connection_string",
")",
":",
"new",
"\\",
"PDO",
"(",
"$",
"this",
"->",
"connection_string",
",",
"$",
"this",
"->",
"dbuser",
",",
"$",
"this",
"->",
"dbpass",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"sprintf",
"(",
"\"SQL: connection opened: '%s'.\"",
",",
"json_encode",
"(",
"$",
"this",
"->",
"verified_params",
")",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"\"SQL: connection failed: '%s'.\"",
",",
"json_encode",
"(",
"$",
"this",
"->",
"verified_params",
")",
")",
")",
";",
"throw",
"new",
"SQLError",
"(",
"SQLError",
"::",
"CONNECTION_ERROR",
",",
"$",
"this",
"->",
"dbtype",
".",
"\" connection error.\"",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"\\",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"# set pragma for SQLite3",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'sqlite3'",
")",
"$",
"this",
"->",
"connection",
"->",
"exec",
"(",
"\"PRAGMA foreign_keys=ON\"",
")",
";",
"}"
] |
Open PDO connection.
|
[
"Open",
"PDO",
"connection",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L126-L151
|
22,622
|
bfitech/zapstore
|
src/SQL.php
|
SQL.format_connection_string
|
private function format_connection_string() {
if (!in_array($this->dbtype, ['sqlite3', 'mysql', 'pgsql'])) {
$this->verified_params = null;
self::$logger->error(sprintf(
"SQL: database not supported: '%s'.",
$this->dbtype));
throw new SQLError(SQLError::DBTYPE_ERROR,
$this->dbtype . " not supported.");
}
if ($this->dbtype == 'sqlite3')
return $this->connection_string = 'sqlite:' . $this->dbname;
if (!$this->dbuser) {
$this->verified_params = null;
self::$logger->error(
"SQL: param not supplied: 'dbuser'.");
throw new SQLError(
SQLError::CONNECTION_ARGS_ERROR,
"'dbuser' not supplied.");
}
$cstr = sprintf("%s:dbname=%s", $this->dbtype, $this->dbname);
if ($this->dbhost) {
$cstr .= sprintf(';host=%s', $this->dbhost);
if ($this->dbport)
$cstr .= sprintf(';port=%s', $this->dbport);
}
if ($this->dbtype == 'mysql')
# mysql uses dbuser and dbpass on PDO constructor
return $this->connection_string = $cstr;
$cstr .= sprintf(";user=%s", $this->dbuser);
if ($this->dbpass)
$cstr .= sprintf(";password=%s", $this->dbpass);
return $this->connection_string = $cstr;
}
|
php
|
private function format_connection_string() {
if (!in_array($this->dbtype, ['sqlite3', 'mysql', 'pgsql'])) {
$this->verified_params = null;
self::$logger->error(sprintf(
"SQL: database not supported: '%s'.",
$this->dbtype));
throw new SQLError(SQLError::DBTYPE_ERROR,
$this->dbtype . " not supported.");
}
if ($this->dbtype == 'sqlite3')
return $this->connection_string = 'sqlite:' . $this->dbname;
if (!$this->dbuser) {
$this->verified_params = null;
self::$logger->error(
"SQL: param not supplied: 'dbuser'.");
throw new SQLError(
SQLError::CONNECTION_ARGS_ERROR,
"'dbuser' not supplied.");
}
$cstr = sprintf("%s:dbname=%s", $this->dbtype, $this->dbname);
if ($this->dbhost) {
$cstr .= sprintf(';host=%s', $this->dbhost);
if ($this->dbport)
$cstr .= sprintf(';port=%s', $this->dbport);
}
if ($this->dbtype == 'mysql')
# mysql uses dbuser and dbpass on PDO constructor
return $this->connection_string = $cstr;
$cstr .= sprintf(";user=%s", $this->dbuser);
if ($this->dbpass)
$cstr .= sprintf(";password=%s", $this->dbpass);
return $this->connection_string = $cstr;
}
|
[
"private",
"function",
"format_connection_string",
"(",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"dbtype",
",",
"[",
"'sqlite3'",
",",
"'mysql'",
",",
"'pgsql'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"verified_params",
"=",
"null",
";",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"\"SQL: database not supported: '%s'.\"",
",",
"$",
"this",
"->",
"dbtype",
")",
")",
";",
"throw",
"new",
"SQLError",
"(",
"SQLError",
"::",
"DBTYPE_ERROR",
",",
"$",
"this",
"->",
"dbtype",
".",
"\" not supported.\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'sqlite3'",
")",
"return",
"$",
"this",
"->",
"connection_string",
"=",
"'sqlite:'",
".",
"$",
"this",
"->",
"dbname",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"dbuser",
")",
"{",
"$",
"this",
"->",
"verified_params",
"=",
"null",
";",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"\"SQL: param not supplied: 'dbuser'.\"",
")",
";",
"throw",
"new",
"SQLError",
"(",
"SQLError",
"::",
"CONNECTION_ARGS_ERROR",
",",
"\"'dbuser' not supplied.\"",
")",
";",
"}",
"$",
"cstr",
"=",
"sprintf",
"(",
"\"%s:dbname=%s\"",
",",
"$",
"this",
"->",
"dbtype",
",",
"$",
"this",
"->",
"dbname",
")",
";",
"if",
"(",
"$",
"this",
"->",
"dbhost",
")",
"{",
"$",
"cstr",
".=",
"sprintf",
"(",
"';host=%s'",
",",
"$",
"this",
"->",
"dbhost",
")",
";",
"if",
"(",
"$",
"this",
"->",
"dbport",
")",
"$",
"cstr",
".=",
"sprintf",
"(",
"';port=%s'",
",",
"$",
"this",
"->",
"dbport",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'mysql'",
")",
"# mysql uses dbuser and dbpass on PDO constructor",
"return",
"$",
"this",
"->",
"connection_string",
"=",
"$",
"cstr",
";",
"$",
"cstr",
".=",
"sprintf",
"(",
"\";user=%s\"",
",",
"$",
"this",
"->",
"dbuser",
")",
";",
"if",
"(",
"$",
"this",
"->",
"dbpass",
")",
"$",
"cstr",
".=",
"sprintf",
"(",
"\";password=%s\"",
",",
"$",
"this",
"->",
"dbpass",
")",
";",
"return",
"$",
"this",
"->",
"connection_string",
"=",
"$",
"cstr",
";",
"}"
] |
Verify and format connection string.
|
[
"Verify",
"and",
"format",
"connection",
"string",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L156-L193
|
22,623
|
bfitech/zapstore
|
src/SQL.php
|
SQL.time
|
final public function time() {
if ($this->dbtype == 'pgsql')
return $this->query(
"SELECT EXTRACT('epoch' from CURRENT_TIMESTAMP) AS now"
)['now'];
if ($this->dbtype == 'mysql')
return $this->query(
"SELECT UNIX_TIMESTAMP() AS now")['now'];
return $this->query(
"SELECT strftime('%s', CURRENT_TIMESTAMP) AS now"
)['now'];
}
|
php
|
final public function time() {
if ($this->dbtype == 'pgsql')
return $this->query(
"SELECT EXTRACT('epoch' from CURRENT_TIMESTAMP) AS now"
)['now'];
if ($this->dbtype == 'mysql')
return $this->query(
"SELECT UNIX_TIMESTAMP() AS now")['now'];
return $this->query(
"SELECT strftime('%s', CURRENT_TIMESTAMP) AS now"
)['now'];
}
|
[
"final",
"public",
"function",
"time",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'pgsql'",
")",
"return",
"$",
"this",
"->",
"query",
"(",
"\"SELECT EXTRACT('epoch' from CURRENT_TIMESTAMP) AS now\"",
")",
"[",
"'now'",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'mysql'",
")",
"return",
"$",
"this",
"->",
"query",
"(",
"\"SELECT UNIX_TIMESTAMP() AS now\"",
")",
"[",
"'now'",
"]",
";",
"return",
"$",
"this",
"->",
"query",
"(",
"\"SELECT strftime('%s', CURRENT_TIMESTAMP) AS now\"",
")",
"[",
"'now'",
"]",
";",
"}"
] |
Get Unix timestamp from database server.
@return int Unix epoch.
|
[
"Get",
"Unix",
"timestamp",
"from",
"database",
"server",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L209-L220
|
22,624
|
bfitech/zapstore
|
src/SQL.php
|
SQL.stmt_fragment_datetime
|
private function stmt_fragment_datetime($delta) {
$sign = $delta >= 0 ? '+' : '-';
$delta = abs($delta);
$date = '';
switch ($this->dbtype) {
case 'sqlite3':
$date = "(datetime('now', '%s%s second'))";
break;
case 'pgsql':
$date = (
"(" .
"now() at time zone 'utc' %s " .
"interval '%s second'" .
")::timestamp(0)"
);
break;
case 'mysql':
# mysql cannot accept function default; do
# not use this on DDL
$date = (
"(date_add(utc_timestamp(), interval %s%s second))"
);
break;
}
return sprintf($date, $sign, $delta);
}
|
php
|
private function stmt_fragment_datetime($delta) {
$sign = $delta >= 0 ? '+' : '-';
$delta = abs($delta);
$date = '';
switch ($this->dbtype) {
case 'sqlite3':
$date = "(datetime('now', '%s%s second'))";
break;
case 'pgsql':
$date = (
"(" .
"now() at time zone 'utc' %s " .
"interval '%s second'" .
")::timestamp(0)"
);
break;
case 'mysql':
# mysql cannot accept function default; do
# not use this on DDL
$date = (
"(date_add(utc_timestamp(), interval %s%s second))"
);
break;
}
return sprintf($date, $sign, $delta);
}
|
[
"private",
"function",
"stmt_fragment_datetime",
"(",
"$",
"delta",
")",
"{",
"$",
"sign",
"=",
"$",
"delta",
">=",
"0",
"?",
"'+'",
":",
"'-'",
";",
"$",
"delta",
"=",
"abs",
"(",
"$",
"delta",
")",
";",
"$",
"date",
"=",
"''",
";",
"switch",
"(",
"$",
"this",
"->",
"dbtype",
")",
"{",
"case",
"'sqlite3'",
":",
"$",
"date",
"=",
"\"(datetime('now', '%s%s second'))\"",
";",
"break",
";",
"case",
"'pgsql'",
":",
"$",
"date",
"=",
"(",
"\"(\"",
".",
"\"now() at time zone 'utc' %s \"",
".",
"\"interval '%s second'\"",
".",
"\")::timestamp(0)\"",
")",
";",
"break",
";",
"case",
"'mysql'",
":",
"# mysql cannot accept function default; do",
"# not use this on DDL",
"$",
"date",
"=",
"(",
"\"(date_add(utc_timestamp(), interval %s%s second))\"",
")",
";",
"break",
";",
"}",
"return",
"sprintf",
"(",
"$",
"date",
",",
"$",
"sign",
",",
"$",
"delta",
")",
";",
"}"
] |
SQL datetime fragment.
|
[
"SQL",
"datetime",
"fragment",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L225-L250
|
22,625
|
bfitech/zapstore
|
src/SQL.php
|
SQL.stmt_fragment
|
public function stmt_fragment($part, $args=[]) {
$type = $this->dbtype;
if ($part == 'engine') {
if ($type == 'mysql')
# we only intent to support FOREIGN KEY-capable engines
return "ENGINE=InnoDB";
return '';
}
if ($part == "index") {
if ($type == 'pgsql')
return 'SERIAL PRIMARY KEY';
if ($type == 'mysql')
return 'INTEGER PRIMARY KEY AUTO_INCREMENT';
return 'INTEGER PRIMARY KEY AUTOINCREMENT';
}
if ($part == 'datetime') {
$delta = 0;
if ($args && isset($args['delta']))
$delta = (int)$args['delta'];
return $this->stmt_fragment_datetime($delta);
}
return "";
}
|
php
|
public function stmt_fragment($part, $args=[]) {
$type = $this->dbtype;
if ($part == 'engine') {
if ($type == 'mysql')
# we only intent to support FOREIGN KEY-capable engines
return "ENGINE=InnoDB";
return '';
}
if ($part == "index") {
if ($type == 'pgsql')
return 'SERIAL PRIMARY KEY';
if ($type == 'mysql')
return 'INTEGER PRIMARY KEY AUTO_INCREMENT';
return 'INTEGER PRIMARY KEY AUTOINCREMENT';
}
if ($part == 'datetime') {
$delta = 0;
if ($args && isset($args['delta']))
$delta = (int)$args['delta'];
return $this->stmt_fragment_datetime($delta);
}
return "";
}
|
[
"public",
"function",
"stmt_fragment",
"(",
"$",
"part",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"dbtype",
";",
"if",
"(",
"$",
"part",
"==",
"'engine'",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'mysql'",
")",
"# we only intent to support FOREIGN KEY-capable engines",
"return",
"\"ENGINE=InnoDB\"",
";",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"part",
"==",
"\"index\"",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'pgsql'",
")",
"return",
"'SERIAL PRIMARY KEY'",
";",
"if",
"(",
"$",
"type",
"==",
"'mysql'",
")",
"return",
"'INTEGER PRIMARY KEY AUTO_INCREMENT'",
";",
"return",
"'INTEGER PRIMARY KEY AUTOINCREMENT'",
";",
"}",
"if",
"(",
"$",
"part",
"==",
"'datetime'",
")",
"{",
"$",
"delta",
"=",
"0",
";",
"if",
"(",
"$",
"args",
"&&",
"isset",
"(",
"$",
"args",
"[",
"'delta'",
"]",
")",
")",
"$",
"delta",
"=",
"(",
"int",
")",
"$",
"args",
"[",
"'delta'",
"]",
";",
"return",
"$",
"this",
"->",
"stmt_fragment_datetime",
"(",
"$",
"delta",
")",
";",
"}",
"return",
"\"\"",
";",
"}"
] |
SQL statement fragment.
@param string $part A part sensitive to the database being used,
one of these: 'engine', 'index', 'datetime'.
@param array $args Dict of parameters for $part, for 'datetime'
only.
|
[
"SQL",
"statement",
"fragment",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L260-L282
|
22,626
|
bfitech/zapstore
|
src/SQL.php
|
SQL.table_exists
|
public function table_exists($table) {
# we can't use placeholder for table name
if (!preg_match('!^[0-9a-z_]+$!i', $table))
return false;
self::$logger->deactivate();
try {
$this->query(sprintf("SELECT 1 FROM %s LIMIT 1", $table));
self::$logger->activate();
return true;
} catch(SQLError $e) {
self::$logger->activate();
return false;
}
}
|
php
|
public function table_exists($table) {
# we can't use placeholder for table name
if (!preg_match('!^[0-9a-z_]+$!i', $table))
return false;
self::$logger->deactivate();
try {
$this->query(sprintf("SELECT 1 FROM %s LIMIT 1", $table));
self::$logger->activate();
return true;
} catch(SQLError $e) {
self::$logger->activate();
return false;
}
}
|
[
"public",
"function",
"table_exists",
"(",
"$",
"table",
")",
"{",
"# we can't use placeholder for table name",
"if",
"(",
"!",
"preg_match",
"(",
"'!^[0-9a-z_]+$!i'",
",",
"$",
"table",
")",
")",
"return",
"false",
";",
"self",
"::",
"$",
"logger",
"->",
"deactivate",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"query",
"(",
"sprintf",
"(",
"\"SELECT 1 FROM %s LIMIT 1\"",
",",
"$",
"table",
")",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"activate",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"SQLError",
"$",
"e",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"activate",
"(",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
Check if a table or view exists.
@param string $table Table or view name.
@return bool True if table or view does exist.
@fixme This will always re-activate logging at the end,
regardless the logging state. The fix must be in Logger
class itself where logging state must be exposed.
|
[
"Check",
"if",
"a",
"table",
"or",
"view",
"exists",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L293-L306
|
22,627
|
bfitech/zapstore
|
src/SQL.php
|
SQL.prepare_statement
|
private function prepare_statement($stmt, $args=[]) {
if (!$this->connection) {
self::$logger->error(sprintf(
"SQL: connection failed: '%s'.",
json_encode($this->verified_params)));
throw new SQLError(SQLError::CONNECTION_ERROR,
$this->dbtype . " connection error.");
}
$conn = $this->connection;
try {
$pstmt = $conn->prepare($stmt);
} catch (\PDOException $e) {
self::$logger->error(sprintf(
"SQL: execution failed: %s <- '%s': %s.",
$stmt, json_encode($args),
$e->getMessage()));
throw new SQLError(
SQLError::EXECUTION_ERROR,
sprintf("Execution error: %s.", $e->getMessage()),
$stmt, $args
);
}
try {
$pstmt->execute(array_values($args));
} catch (\PDOException $e) {
self::$logger->error(sprintf(
"SQL: execution failed: %s <- '%s': %s.",
$stmt, json_encode($args),
$e->getMessage()));
throw new SQLError(
SQLError::EXECUTION_ERROR,
sprintf("Execution error: %s.", $e->getMessage()),
$stmt, $args
);
}
return $pstmt;
}
|
php
|
private function prepare_statement($stmt, $args=[]) {
if (!$this->connection) {
self::$logger->error(sprintf(
"SQL: connection failed: '%s'.",
json_encode($this->verified_params)));
throw new SQLError(SQLError::CONNECTION_ERROR,
$this->dbtype . " connection error.");
}
$conn = $this->connection;
try {
$pstmt = $conn->prepare($stmt);
} catch (\PDOException $e) {
self::$logger->error(sprintf(
"SQL: execution failed: %s <- '%s': %s.",
$stmt, json_encode($args),
$e->getMessage()));
throw new SQLError(
SQLError::EXECUTION_ERROR,
sprintf("Execution error: %s.", $e->getMessage()),
$stmt, $args
);
}
try {
$pstmt->execute(array_values($args));
} catch (\PDOException $e) {
self::$logger->error(sprintf(
"SQL: execution failed: %s <- '%s': %s.",
$stmt, json_encode($args),
$e->getMessage()));
throw new SQLError(
SQLError::EXECUTION_ERROR,
sprintf("Execution error: %s.", $e->getMessage()),
$stmt, $args
);
}
return $pstmt;
}
|
[
"private",
"function",
"prepare_statement",
"(",
"$",
"stmt",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"\"SQL: connection failed: '%s'.\"",
",",
"json_encode",
"(",
"$",
"this",
"->",
"verified_params",
")",
")",
")",
";",
"throw",
"new",
"SQLError",
"(",
"SQLError",
"::",
"CONNECTION_ERROR",
",",
"$",
"this",
"->",
"dbtype",
".",
"\" connection error.\"",
")",
";",
"}",
"$",
"conn",
"=",
"$",
"this",
"->",
"connection",
";",
"try",
"{",
"$",
"pstmt",
"=",
"$",
"conn",
"->",
"prepare",
"(",
"$",
"stmt",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"\"SQL: execution failed: %s <- '%s': %s.\"",
",",
"$",
"stmt",
",",
"json_encode",
"(",
"$",
"args",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"throw",
"new",
"SQLError",
"(",
"SQLError",
"::",
"EXECUTION_ERROR",
",",
"sprintf",
"(",
"\"Execution error: %s.\"",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"$",
"stmt",
",",
"$",
"args",
")",
";",
"}",
"try",
"{",
"$",
"pstmt",
"->",
"execute",
"(",
"array_values",
"(",
"$",
"args",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"sprintf",
"(",
"\"SQL: execution failed: %s <- '%s': %s.\"",
",",
"$",
"stmt",
",",
"json_encode",
"(",
"$",
"args",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"throw",
"new",
"SQLError",
"(",
"SQLError",
"::",
"EXECUTION_ERROR",
",",
"sprintf",
"(",
"\"Execution error: %s.\"",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"$",
"stmt",
",",
"$",
"args",
")",
";",
"}",
"return",
"$",
"pstmt",
";",
"}"
] |
Prepare and execute statement.
|
[
"Prepare",
"and",
"execute",
"statement",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L311-L350
|
22,628
|
bfitech/zapstore
|
src/SQL.php
|
SQL.query_raw
|
final public function query_raw($stmt, $args=[]) {
$pstmt = $this->prepare_statement($stmt, $args);
self::$logger->info(sprintf(
"SQL: query raw ok: %s.", $stmt));
return $pstmt;
}
|
php
|
final public function query_raw($stmt, $args=[]) {
$pstmt = $this->prepare_statement($stmt, $args);
self::$logger->info(sprintf(
"SQL: query raw ok: %s.", $stmt));
return $pstmt;
}
|
[
"final",
"public",
"function",
"query_raw",
"(",
"$",
"stmt",
",",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"pstmt",
"=",
"$",
"this",
"->",
"prepare_statement",
"(",
"$",
"stmt",
",",
"$",
"args",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"info",
"(",
"sprintf",
"(",
"\"SQL: query raw ok: %s.\"",
",",
"$",
"stmt",
")",
")",
";",
"return",
"$",
"pstmt",
";",
"}"
] |
Execute raw query.
This will execute arbitray single SQL queries. Do not execute
multiple queries at once to avoid undocumented side effects.
To execute successive raw queries safely, disable autocommit as
follows:
@code
$connection = new SQL(...);
try {
$connection = $this->get_connection();
$connection->beginTransaction();
$this->query_raw(...);
$this->query_raw(...);
$this->query_raw(...);
$connection->commit();
} catch(SQLError $e) {
$connection->rollBack();
}
@endcode
@param string $stmt SQL statement.
@param array $args Arguments in numeric array.
@return object Executed statement which, depending on `$stmt`,
can be used for later processing. If `$stmt` is a SELECT
statement, rows can be fetched from this.
|
[
"Execute",
"raw",
"query",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L402-L407
|
22,629
|
bfitech/zapstore
|
src/SQL.php
|
SQL.insert
|
final public function insert($table, $args=[], $pk=null) {
$keys = $vals = [];
$keys = array_keys($args);
$vals = array_fill(0, count($args), '?');
$columns = implode(',', $keys);
$placeholders = implode(',', $vals);
$stmt = "INSERT INTO $table ($columns) VALUES ($placeholders)";
if ($this->dbtype == 'pgsql')
$stmt .= " RETURNING " . ($pk ? $pk : '*');
$pstmt = $this->prepare_statement($stmt, $args);
if ($this->dbtype == 'pgsql') {
$last = $pstmt->fetch(\PDO::FETCH_ASSOC);
$ret = $pk ? $last[$pk] : $last;
} else {
$ret = $this->connection->lastInsertId();
}
self::$logger->info(sprintf(
"SQL: insert ok: %s <- '%s'.",
$stmt, json_encode($args)));
return $ret;
}
|
php
|
final public function insert($table, $args=[], $pk=null) {
$keys = $vals = [];
$keys = array_keys($args);
$vals = array_fill(0, count($args), '?');
$columns = implode(',', $keys);
$placeholders = implode(',', $vals);
$stmt = "INSERT INTO $table ($columns) VALUES ($placeholders)";
if ($this->dbtype == 'pgsql')
$stmt .= " RETURNING " . ($pk ? $pk : '*');
$pstmt = $this->prepare_statement($stmt, $args);
if ($this->dbtype == 'pgsql') {
$last = $pstmt->fetch(\PDO::FETCH_ASSOC);
$ret = $pk ? $last[$pk] : $last;
} else {
$ret = $this->connection->lastInsertId();
}
self::$logger->info(sprintf(
"SQL: insert ok: %s <- '%s'.",
$stmt, json_encode($args)));
return $ret;
}
|
[
"final",
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"pk",
"=",
"null",
")",
"{",
"$",
"keys",
"=",
"$",
"vals",
"=",
"[",
"]",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"args",
")",
";",
"$",
"vals",
"=",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"args",
")",
",",
"'?'",
")",
";",
"$",
"columns",
"=",
"implode",
"(",
"','",
",",
"$",
"keys",
")",
";",
"$",
"placeholders",
"=",
"implode",
"(",
"','",
",",
"$",
"vals",
")",
";",
"$",
"stmt",
"=",
"\"INSERT INTO $table ($columns) VALUES ($placeholders)\"",
";",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'pgsql'",
")",
"$",
"stmt",
".=",
"\" RETURNING \"",
".",
"(",
"$",
"pk",
"?",
"$",
"pk",
":",
"'*'",
")",
";",
"$",
"pstmt",
"=",
"$",
"this",
"->",
"prepare_statement",
"(",
"$",
"stmt",
",",
"$",
"args",
")",
";",
"if",
"(",
"$",
"this",
"->",
"dbtype",
"==",
"'pgsql'",
")",
"{",
"$",
"last",
"=",
"$",
"pstmt",
"->",
"fetch",
"(",
"\\",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"$",
"ret",
"=",
"$",
"pk",
"?",
"$",
"last",
"[",
"$",
"pk",
"]",
":",
"$",
"last",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"connection",
"->",
"lastInsertId",
"(",
")",
";",
"}",
"self",
"::",
"$",
"logger",
"->",
"info",
"(",
"sprintf",
"(",
"\"SQL: insert ok: %s <- '%s'.\"",
",",
"$",
"stmt",
",",
"json_encode",
"(",
"$",
"args",
")",
")",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Insert statement.
@param string $table Table name.
@param array $args Dict of what to INSERT.
@param string $pk Primary key from which last insert ID should
be retrieved. This won't take any effect on databases other
than Postgres. This can take any column name, not necessarily
column with PRIMARY KEY attributes. If left null, the whole
new row is returned as an array. Using invalid column will
throw exception.
@return int|array Last insert ID or IDs on success. Exception
thrown on error.
|
[
"Insert",
"statement",
"."
] |
0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0
|
https://github.com/bfitech/zapstore/blob/0353a7a3f81cbc4e25fc1646fa2f98cb490b85d0/src/SQL.php#L423-L449
|
22,630
|
Danzabar/config-builder
|
src/Collections/Collection.php
|
Collection.registerStandardObjects
|
public function registerStandardObjects()
{
$this->extensionMap = new ExtensionMap();
$this->extensions = $this->extensionMap->getRegisteredExtensionNames();
$this->finder->files();
}
|
php
|
public function registerStandardObjects()
{
$this->extensionMap = new ExtensionMap();
$this->extensions = $this->extensionMap->getRegisteredExtensionNames();
$this->finder->files();
}
|
[
"public",
"function",
"registerStandardObjects",
"(",
")",
"{",
"$",
"this",
"->",
"extensionMap",
"=",
"new",
"ExtensionMap",
"(",
")",
";",
"$",
"this",
"->",
"extensions",
"=",
"$",
"this",
"->",
"extensionMap",
"->",
"getRegisteredExtensionNames",
"(",
")",
";",
"$",
"this",
"->",
"finder",
"->",
"files",
"(",
")",
";",
"}"
] |
Registers the extension map and sets the finder to look for files
@return void
@author Dan Cox
|
[
"Registers",
"the",
"extension",
"map",
"and",
"sets",
"the",
"finder",
"to",
"look",
"for",
"files"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Collections/Collection.php#L95-L100
|
22,631
|
Danzabar/config-builder
|
src/Collections/Collection.php
|
Collection.filterByExtension
|
public function filterByExtension()
{
// The call back that filters files through the finder
$filter = function (\SplFileInfo $file) {
return in_array($file->getExtension(), $this->extensions);
};
$this->filter($filter);
}
|
php
|
public function filterByExtension()
{
// The call back that filters files through the finder
$filter = function (\SplFileInfo $file) {
return in_array($file->getExtension(), $this->extensions);
};
$this->filter($filter);
}
|
[
"public",
"function",
"filterByExtension",
"(",
")",
"{",
"// The call back that filters files through the finder",
"$",
"filter",
"=",
"function",
"(",
"\\",
"SplFileInfo",
"$",
"file",
")",
"{",
"return",
"in_array",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
",",
"$",
"this",
"->",
"extensions",
")",
";",
"}",
";",
"$",
"this",
"->",
"filter",
"(",
"$",
"filter",
")",
";",
"}"
] |
Filters file results by their extension
@return void
@author Dan Cox
|
[
"Filters",
"file",
"results",
"by",
"their",
"extension"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Collections/Collection.php#L108-L117
|
22,632
|
Danzabar/config-builder
|
src/Collections/Collection.php
|
Collection.fetch
|
public function fetch()
{
$this->filterByExtension();
$results = Array();
foreach ($this->finder as $file)
{
$config = new ConfigFile($this->fs, $this->fileInfo, $this->extracter);
$config->load($file->getRealPath());
$results[] = $config;
}
$this->finder = new Finder();
return new CollectionResults($results);
}
|
php
|
public function fetch()
{
$this->filterByExtension();
$results = Array();
foreach ($this->finder as $file)
{
$config = new ConfigFile($this->fs, $this->fileInfo, $this->extracter);
$config->load($file->getRealPath());
$results[] = $config;
}
$this->finder = new Finder();
return new CollectionResults($results);
}
|
[
"public",
"function",
"fetch",
"(",
")",
"{",
"$",
"this",
"->",
"filterByExtension",
"(",
")",
";",
"$",
"results",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"finder",
"as",
"$",
"file",
")",
"{",
"$",
"config",
"=",
"new",
"ConfigFile",
"(",
"$",
"this",
"->",
"fs",
",",
"$",
"this",
"->",
"fileInfo",
",",
"$",
"this",
"->",
"extracter",
")",
";",
"$",
"config",
"->",
"load",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"$",
"results",
"[",
"]",
"=",
"$",
"config",
";",
"}",
"$",
"this",
"->",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"return",
"new",
"CollectionResults",
"(",
"$",
"results",
")",
";",
"}"
] |
Fetches results of current instance of the finder
@return CollectionResults
@author Dan Cox
|
[
"Fetches",
"results",
"of",
"current",
"instance",
"of",
"the",
"finder"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Collections/Collection.php#L192-L208
|
22,633
|
Danzabar/config-builder
|
src/Collections/Collection.php
|
Collection.setDirectory
|
public function setDirectory($directory)
{
$this->directory = $directory;
// Set the finder to use this directory as well
$this->finder->in($directory);
return $this;
}
|
php
|
public function setDirectory($directory)
{
$this->directory = $directory;
// Set the finder to use this directory as well
$this->finder->in($directory);
return $this;
}
|
[
"public",
"function",
"setDirectory",
"(",
"$",
"directory",
")",
"{",
"$",
"this",
"->",
"directory",
"=",
"$",
"directory",
";",
"// Set the finder to use this directory as well",
"$",
"this",
"->",
"finder",
"->",
"in",
"(",
"$",
"directory",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the directory value
@param String $directory
@return Collection
@author Dan Cox
|
[
"Sets",
"the",
"directory",
"value"
] |
3b237be578172c32498bbcdfb360e69a6243739d
|
https://github.com/Danzabar/config-builder/blob/3b237be578172c32498bbcdfb360e69a6243739d/src/Collections/Collection.php#L217-L225
|
22,634
|
alevilar/ristorantino-vendor
|
Risto/Console/Command/RistoSchemaShell.php
|
RistoSchemaShell._update
|
protected function _update(&$Schema, $table = null) {
$db = ConnectionManager::getDataSource($this->Schema->connection);
$this->out(__d('cake_console', 'Comparing Database to Schema...'));
$options = array();
$this->params['force'] = false;
if (isset($this->params['force'])) {
$options['models'] = false;
}
$Old = $this->Schema->read($options);
$compare = $this->Schema->compare($Old, $Schema);
$contents = array();
if (!empty($compare['media'])) {
unset($compare['media']);
}
if (empty($table)) {
foreach ($compare as $table => $changes) {
if (isset($compare[$table]['create'])) {
$contents[$table] = $db->createSchema($Schema, $table);
} else {
$contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table);
}
}
} elseif (isset($compare[$table])) {
if (isset($compare[$table]['create'])) {
$contents[$table] = $db->createSchema($Schema, $table);
} else {
$contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table);
}
}
if (empty($contents)) {
$this->out(__d('cake_console', 'Schema is up to date.'));
return false;
}
$this->out("\n" . __d('cake_console', 'The following statements will run.'));
$this->out(array_map('trim', $contents));
if (!empty($this->params['yes']) ||
$this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y'
) {
$this->out();
$this->out(__d('cake_console', 'Updating Database...'));
$this->_run($contents, 'update', $Schema);
}
$this->out(__d('cake_console', 'End update.'));
}
|
php
|
protected function _update(&$Schema, $table = null) {
$db = ConnectionManager::getDataSource($this->Schema->connection);
$this->out(__d('cake_console', 'Comparing Database to Schema...'));
$options = array();
$this->params['force'] = false;
if (isset($this->params['force'])) {
$options['models'] = false;
}
$Old = $this->Schema->read($options);
$compare = $this->Schema->compare($Old, $Schema);
$contents = array();
if (!empty($compare['media'])) {
unset($compare['media']);
}
if (empty($table)) {
foreach ($compare as $table => $changes) {
if (isset($compare[$table]['create'])) {
$contents[$table] = $db->createSchema($Schema, $table);
} else {
$contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table);
}
}
} elseif (isset($compare[$table])) {
if (isset($compare[$table]['create'])) {
$contents[$table] = $db->createSchema($Schema, $table);
} else {
$contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table);
}
}
if (empty($contents)) {
$this->out(__d('cake_console', 'Schema is up to date.'));
return false;
}
$this->out("\n" . __d('cake_console', 'The following statements will run.'));
$this->out(array_map('trim', $contents));
if (!empty($this->params['yes']) ||
$this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y'
) {
$this->out();
$this->out(__d('cake_console', 'Updating Database...'));
$this->_run($contents, 'update', $Schema);
}
$this->out(__d('cake_console', 'End update.'));
}
|
[
"protected",
"function",
"_update",
"(",
"&",
"$",
"Schema",
",",
"$",
"table",
"=",
"null",
")",
"{",
"$",
"db",
"=",
"ConnectionManager",
"::",
"getDataSource",
"(",
"$",
"this",
"->",
"Schema",
"->",
"connection",
")",
";",
"$",
"this",
"->",
"out",
"(",
"__d",
"(",
"'cake_console'",
",",
"'Comparing Database to Schema...'",
")",
")",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"params",
"[",
"'force'",
"]",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"'force'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'models'",
"]",
"=",
"false",
";",
"}",
"$",
"Old",
"=",
"$",
"this",
"->",
"Schema",
"->",
"read",
"(",
"$",
"options",
")",
";",
"$",
"compare",
"=",
"$",
"this",
"->",
"Schema",
"->",
"compare",
"(",
"$",
"Old",
",",
"$",
"Schema",
")",
";",
"$",
"contents",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"compare",
"[",
"'media'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"compare",
"[",
"'media'",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"table",
")",
")",
"{",
"foreach",
"(",
"$",
"compare",
"as",
"$",
"table",
"=>",
"$",
"changes",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"compare",
"[",
"$",
"table",
"]",
"[",
"'create'",
"]",
")",
")",
"{",
"$",
"contents",
"[",
"$",
"table",
"]",
"=",
"$",
"db",
"->",
"createSchema",
"(",
"$",
"Schema",
",",
"$",
"table",
")",
";",
"}",
"else",
"{",
"$",
"contents",
"[",
"$",
"table",
"]",
"=",
"$",
"db",
"->",
"alterSchema",
"(",
"array",
"(",
"$",
"table",
"=>",
"$",
"compare",
"[",
"$",
"table",
"]",
")",
",",
"$",
"table",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"compare",
"[",
"$",
"table",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"compare",
"[",
"$",
"table",
"]",
"[",
"'create'",
"]",
")",
")",
"{",
"$",
"contents",
"[",
"$",
"table",
"]",
"=",
"$",
"db",
"->",
"createSchema",
"(",
"$",
"Schema",
",",
"$",
"table",
")",
";",
"}",
"else",
"{",
"$",
"contents",
"[",
"$",
"table",
"]",
"=",
"$",
"db",
"->",
"alterSchema",
"(",
"array",
"(",
"$",
"table",
"=>",
"$",
"compare",
"[",
"$",
"table",
"]",
")",
",",
"$",
"table",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"contents",
")",
")",
"{",
"$",
"this",
"->",
"out",
"(",
"__d",
"(",
"'cake_console'",
",",
"'Schema is up to date.'",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"out",
"(",
"\"\\n\"",
".",
"__d",
"(",
"'cake_console'",
",",
"'The following statements will run.'",
")",
")",
";",
"$",
"this",
"->",
"out",
"(",
"array_map",
"(",
"'trim'",
",",
"$",
"contents",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"params",
"[",
"'yes'",
"]",
")",
"||",
"$",
"this",
"->",
"in",
"(",
"__d",
"(",
"'cake_console'",
",",
"'Are you sure you want to alter the tables?'",
")",
",",
"array",
"(",
"'y'",
",",
"'n'",
")",
",",
"'n'",
")",
"===",
"'y'",
")",
"{",
"$",
"this",
"->",
"out",
"(",
")",
";",
"$",
"this",
"->",
"out",
"(",
"__d",
"(",
"'cake_console'",
",",
"'Updating Database...'",
")",
")",
";",
"$",
"this",
"->",
"_run",
"(",
"$",
"contents",
",",
"'update'",
",",
"$",
"Schema",
")",
";",
"}",
"$",
"this",
"->",
"out",
"(",
"__d",
"(",
"'cake_console'",
",",
"'End update.'",
")",
")",
";",
"}"
] |
Update database with Schema object
Should be called via the run method
@param CakeSchema &$Schema The schema instance
@param string $table The table name.
@return void
|
[
"Update",
"database",
"with",
"Schema",
"object",
"Should",
"be",
"called",
"via",
"the",
"run",
"method"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Risto/Console/Command/RistoSchemaShell.php#L26-L74
|
22,635
|
mithun12000/yii2-process
|
src/components/ProcessControlTrait.php
|
ProcessControlTrait.createPidfile
|
public function createPidfile($appName, $path='/var/run'){
if(!$this->control){
$this->createControl();
}
return new Pidfile($this->control, strtolower($appName), $path);
}
|
php
|
public function createPidfile($appName, $path='/var/run'){
if(!$this->control){
$this->createControl();
}
return new Pidfile($this->control, strtolower($appName), $path);
}
|
[
"public",
"function",
"createPidfile",
"(",
"$",
"appName",
",",
"$",
"path",
"=",
"'/var/run'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"control",
")",
"{",
"$",
"this",
"->",
"createControl",
"(",
")",
";",
"}",
"return",
"new",
"Pidfile",
"(",
"$",
"this",
"->",
"control",
",",
"strtolower",
"(",
"$",
"appName",
")",
",",
"$",
"path",
")",
";",
"}"
] |
Create Pid file for process
@param string $appName
@param string $path
|
[
"Create",
"Pid",
"file",
"for",
"process"
] |
d4c660010381fee76159eb4c92d4b75e38442d3c
|
https://github.com/mithun12000/yii2-process/blob/d4c660010381fee76159eb4c92d4b75e38442d3c/src/components/ProcessControlTrait.php#L47-L52
|
22,636
|
mothership-ec/composer
|
src/Composer/DependencyResolver/DefaultPolicy.php
|
DefaultPolicy.replaces
|
protected function replaces(PackageInterface $source, PackageInterface $target)
{
foreach ($source->getReplaces() as $link) {
if ($link->getTarget() === $target->getName()
// && (null === $link->getConstraint() ||
// $link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) {
) {
return true;
}
}
return false;
}
|
php
|
protected function replaces(PackageInterface $source, PackageInterface $target)
{
foreach ($source->getReplaces() as $link) {
if ($link->getTarget() === $target->getName()
// && (null === $link->getConstraint() ||
// $link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) {
) {
return true;
}
}
return false;
}
|
[
"protected",
"function",
"replaces",
"(",
"PackageInterface",
"$",
"source",
",",
"PackageInterface",
"$",
"target",
")",
"{",
"foreach",
"(",
"$",
"source",
"->",
"getReplaces",
"(",
")",
"as",
"$",
"link",
")",
"{",
"if",
"(",
"$",
"link",
"->",
"getTarget",
"(",
")",
"===",
"$",
"target",
"->",
"getName",
"(",
")",
"// && (null === $link->getConstraint() ||",
"// $link->getConstraint()->matches(new VersionConstraint('==', $target->getVersion())))) {",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if source replaces a package with the same name as target.
Replace constraints are ignored. This method should only be used for
prioritisation, not for actual constraint verification.
@param PackageInterface $source
@param PackageInterface $target
@return bool
|
[
"Checks",
"if",
"source",
"replaces",
"a",
"package",
"with",
"the",
"same",
"name",
"as",
"target",
"."
] |
fa6ad031a939d8d33b211e428fdbdd28cfce238c
|
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/DependencyResolver/DefaultPolicy.php#L192-L204
|
22,637
|
inhere/php-librarys
|
src/Traits/StdObjectTrait.php
|
StdObjectTrait.className
|
final public static function className(string $fullName = null): string
{
$fullName = $fullName ?: self::fullName();
$fullName = str_replace('\\', '/', $fullName);
return basename($fullName);
}
|
php
|
final public static function className(string $fullName = null): string
{
$fullName = $fullName ?: self::fullName();
$fullName = str_replace('\\', '/', $fullName);
return basename($fullName);
}
|
[
"final",
"public",
"static",
"function",
"className",
"(",
"string",
"$",
"fullName",
"=",
"null",
")",
":",
"string",
"{",
"$",
"fullName",
"=",
"$",
"fullName",
"?",
":",
"self",
"::",
"fullName",
"(",
")",
";",
"$",
"fullName",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"fullName",
")",
";",
"return",
"basename",
"(",
"$",
"fullName",
")",
";",
"}"
] |
get called class name
@param null|string $fullName
@return string
|
[
"get",
"called",
"class",
"name"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Traits/StdObjectTrait.php#L47-L53
|
22,638
|
colorium/web
|
src/Colorium/Web/Logic.php
|
Logic.resolve
|
public static function resolve($name, $callable)
{
$invokable = Resolver::of($callable);
$annotations = $invokable->annotations();
$annotations['method'] = $invokable;
return new Logic($name, $annotations);
}
|
php
|
public static function resolve($name, $callable)
{
$invokable = Resolver::of($callable);
$annotations = $invokable->annotations();
$annotations['method'] = $invokable;
return new Logic($name, $annotations);
}
|
[
"public",
"static",
"function",
"resolve",
"(",
"$",
"name",
",",
"$",
"callable",
")",
"{",
"$",
"invokable",
"=",
"Resolver",
"::",
"of",
"(",
"$",
"callable",
")",
";",
"$",
"annotations",
"=",
"$",
"invokable",
"->",
"annotations",
"(",
")",
";",
"$",
"annotations",
"[",
"'method'",
"]",
"=",
"$",
"invokable",
";",
"return",
"new",
"Logic",
"(",
"$",
"name",
",",
"$",
"annotations",
")",
";",
"}"
] |
Resolve logic from callable
@param string $name
@param $callable
@return Logic
|
[
"Resolve",
"logic",
"from",
"callable"
] |
2a767658b8737022939b0cc4505b5f652c1683d2
|
https://github.com/colorium/web/blob/2a767658b8737022939b0cc4505b5f652c1683d2/src/Colorium/Web/Logic.php#L66-L73
|
22,639
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php
|
ezcQueryExpressionOracle.bitXor
|
public function bitXor( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "( {$value1} + {$value2} - bitand( {$value1}, {$value2} ) * 2 )";
}
|
php
|
public function bitXor( $value1, $value2 )
{
$value1 = $this->getIdentifier( $value1 );
$value2 = $this->getIdentifier( $value2 );
return "( {$value1} + {$value2} - bitand( {$value1}, {$value2} ) * 2 )";
}
|
[
"public",
"function",
"bitXor",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"value1",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value1",
")",
";",
"$",
"value2",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"value2",
")",
";",
"return",
"\"( {$value1} + {$value2} - bitand( {$value1}, {$value2} ) * 2 )\"",
";",
"}"
] |
Returns the SQL that performs the bitwise XOR on two values.
@param string $value1
@param string $value2
@return string
|
[
"Returns",
"the",
"SQL",
"that",
"performs",
"the",
"bitwise",
"XOR",
"on",
"two",
"values",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php#L141-L146
|
22,640
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php
|
ezcQueryExpressionOracle.unixTimestamp
|
public function unixTimestamp( $column )
{
$column = $this->getIdentifier( $column );
if ( $column != 'NOW()' )
{
$column = "CAST( {$column} AS TIMESTAMP )";
// // alternative
// if ( preg_match( '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/', $column ) ) {
// $column = "TO_TIMESTAMP( {$column}, 'YYYY-MM-DD HH24:MI:SS' )";
// }
}
$date1 = "CAST( SYS_EXTRACT_UTC( {$column} ) AS DATE )";
$date2 = "TO_DATE( '19700101000000', 'YYYYMMDDHH24MISS' )";
return " ROUND( ( {$date1} - {$date2} ) / ( 1 / 86400 ) ) ";
}
|
php
|
public function unixTimestamp( $column )
{
$column = $this->getIdentifier( $column );
if ( $column != 'NOW()' )
{
$column = "CAST( {$column} AS TIMESTAMP )";
// // alternative
// if ( preg_match( '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/', $column ) ) {
// $column = "TO_TIMESTAMP( {$column}, 'YYYY-MM-DD HH24:MI:SS' )";
// }
}
$date1 = "CAST( SYS_EXTRACT_UTC( {$column} ) AS DATE )";
$date2 = "TO_DATE( '19700101000000', 'YYYYMMDDHH24MISS' )";
return " ROUND( ( {$date1} - {$date2} ) / ( 1 / 86400 ) ) ";
}
|
[
"public",
"function",
"unixTimestamp",
"(",
"$",
"column",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"column",
")",
";",
"if",
"(",
"$",
"column",
"!=",
"'NOW()'",
")",
"{",
"$",
"column",
"=",
"\"CAST( {$column} AS TIMESTAMP )\"",
";",
"// // alternative",
"// if ( preg_match( '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/', $column ) ) {",
"// $column = \"TO_TIMESTAMP( {$column}, 'YYYY-MM-DD HH24:MI:SS' )\";",
"// }",
"}",
"$",
"date1",
"=",
"\"CAST( SYS_EXTRACT_UTC( {$column} ) AS DATE )\"",
";",
"$",
"date2",
"=",
"\"TO_DATE( '19700101000000', 'YYYYMMDDHH24MISS' )\"",
";",
"return",
"\" ROUND( ( {$date1} - {$date2} ) / ( 1 / 86400 ) ) \"",
";",
"}"
] |
Returns the SQL that converts a timestamp value to a unix timestamp.
@param string $column
@return string
|
[
"Returns",
"the",
"SQL",
"that",
"converts",
"a",
"timestamp",
"value",
"to",
"a",
"unix",
"timestamp",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php#L154-L170
|
22,641
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php
|
ezcQueryExpressionOracle.dateSub
|
public function dateSub( $column, $expr, $type )
{
$type = $this->intervalMap[$type];
$column = $this->getIdentifier( $column );
if ( $column != 'NOW()' )
{
$column = "CAST( {$column} AS TIMESTAMP )";
}
return " {$column} - INTERVAL '{$expr}' {$type} ";
}
|
php
|
public function dateSub( $column, $expr, $type )
{
$type = $this->intervalMap[$type];
$column = $this->getIdentifier( $column );
if ( $column != 'NOW()' )
{
$column = "CAST( {$column} AS TIMESTAMP )";
}
return " {$column} - INTERVAL '{$expr}' {$type} ";
}
|
[
"public",
"function",
"dateSub",
"(",
"$",
"column",
",",
"$",
"expr",
",",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"intervalMap",
"[",
"$",
"type",
"]",
";",
"$",
"column",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"column",
")",
";",
"if",
"(",
"$",
"column",
"!=",
"'NOW()'",
")",
"{",
"$",
"column",
"=",
"\"CAST( {$column} AS TIMESTAMP )\"",
";",
"}",
"return",
"\" {$column} - INTERVAL '{$expr}' {$type} \"",
";",
"}"
] |
Returns the SQL that subtracts an interval from a timestamp value.
@param string $column
@param numeric $expr
@param string $type one of SECOND, MINUTE, HOUR, DAY, MONTH, or YEAR
@return string
|
[
"Returns",
"the",
"SQL",
"that",
"subtracts",
"an",
"interval",
"from",
"a",
"timestamp",
"value",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php#L180-L191
|
22,642
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php
|
ezcQueryExpressionOracle.dateAdd
|
public function dateAdd( $column, $expr, $type )
{
$type = $this->intervalMap[$type];
$column = $this->getIdentifier( $column );
if ( $column != 'NOW()' )
{
$column = "CAST( {$column} AS TIMESTAMP )";
}
return " {$column} + INTERVAL '{$expr}' {$type} ";
}
|
php
|
public function dateAdd( $column, $expr, $type )
{
$type = $this->intervalMap[$type];
$column = $this->getIdentifier( $column );
if ( $column != 'NOW()' )
{
$column = "CAST( {$column} AS TIMESTAMP )";
}
return " {$column} + INTERVAL '{$expr}' {$type} ";
}
|
[
"public",
"function",
"dateAdd",
"(",
"$",
"column",
",",
"$",
"expr",
",",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"intervalMap",
"[",
"$",
"type",
"]",
";",
"$",
"column",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"column",
")",
";",
"if",
"(",
"$",
"column",
"!=",
"'NOW()'",
")",
"{",
"$",
"column",
"=",
"\"CAST( {$column} AS TIMESTAMP )\"",
";",
"}",
"return",
"\" {$column} + INTERVAL '{$expr}' {$type} \"",
";",
"}"
] |
Returns the SQL that adds an interval to a timestamp value.
@param string $column
@param numeric $expr
@param string $type one of SECOND, MINUTE, HOUR, DAY, MONTH, or YEAR
@return string
|
[
"Returns",
"the",
"SQL",
"that",
"adds",
"an",
"interval",
"to",
"a",
"timestamp",
"value",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php#L201-L212
|
22,643
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php
|
ezcQueryExpressionOracle.in
|
public function in( $column )
{
$args = func_get_args();
if ( count( $args ) < 2 )
{
throw new ezcQueryVariableParameterException( 'in', count( $args ), 2 );
}
if ( is_array( $args[1] ) && count( $args[1] ) == 0 )
{
throw new ezcQueryInvalidParameterException( 'in', 2, 'empty array', 'non-empty array' );
}
$values = ezcQuerySelect::arrayFlatten( array_slice( $args, 1 ) );
$values = $this->getIdentifiers( $values );
$column = $this->getIdentifier( $column );
if ( count( $values ) == 0 )
{
throw new ezcQueryVariableParameterException( 'in', count( $args ), 2 );
}
if ( $this->quoteValues )
{
foreach ( $values as $key => $value )
{
switch ( true )
{
case is_int( $value ):
case is_float( $value ):
case $value instanceof ezcQuerySubSelect:
$values[$key] = (string) $value;
break;
default:
$values[$key] = $this->db->quote( $value );
}
}
}
if ( count( $values ) <= 1000 )
{
return "{$column} IN ( " . join( ', ', $values ) . ' )';
}
else
{
$expression = '( ';
do {
$bunch = array_slice( $values, 0, 1000 );
$values = array_slice( $values, 1000 );
$expression .= "{$column} IN ( " . join( ', ', $bunch ) . ' ) OR ';
} while ( count( $values ) > 1000 );
$expression .= "{$column} IN ( " . join( ', ', $values ) . ' ) )';
return $expression;
}
}
|
php
|
public function in( $column )
{
$args = func_get_args();
if ( count( $args ) < 2 )
{
throw new ezcQueryVariableParameterException( 'in', count( $args ), 2 );
}
if ( is_array( $args[1] ) && count( $args[1] ) == 0 )
{
throw new ezcQueryInvalidParameterException( 'in', 2, 'empty array', 'non-empty array' );
}
$values = ezcQuerySelect::arrayFlatten( array_slice( $args, 1 ) );
$values = $this->getIdentifiers( $values );
$column = $this->getIdentifier( $column );
if ( count( $values ) == 0 )
{
throw new ezcQueryVariableParameterException( 'in', count( $args ), 2 );
}
if ( $this->quoteValues )
{
foreach ( $values as $key => $value )
{
switch ( true )
{
case is_int( $value ):
case is_float( $value ):
case $value instanceof ezcQuerySubSelect:
$values[$key] = (string) $value;
break;
default:
$values[$key] = $this->db->quote( $value );
}
}
}
if ( count( $values ) <= 1000 )
{
return "{$column} IN ( " . join( ', ', $values ) . ' )';
}
else
{
$expression = '( ';
do {
$bunch = array_slice( $values, 0, 1000 );
$values = array_slice( $values, 1000 );
$expression .= "{$column} IN ( " . join( ', ', $bunch ) . ' ) OR ';
} while ( count( $values ) > 1000 );
$expression .= "{$column} IN ( " . join( ', ', $values ) . ' ) )';
return $expression;
}
}
|
[
"public",
"function",
"in",
"(",
"$",
"column",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"<",
"2",
")",
"{",
"throw",
"new",
"ezcQueryVariableParameterException",
"(",
"'in'",
",",
"count",
"(",
"$",
"args",
")",
",",
"2",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"&&",
"count",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"ezcQueryInvalidParameterException",
"(",
"'in'",
",",
"2",
",",
"'empty array'",
",",
"'non-empty array'",
")",
";",
"}",
"$",
"values",
"=",
"ezcQuerySelect",
"::",
"arrayFlatten",
"(",
"array_slice",
"(",
"$",
"args",
",",
"1",
")",
")",
";",
"$",
"values",
"=",
"$",
"this",
"->",
"getIdentifiers",
"(",
"$",
"values",
")",
";",
"$",
"column",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"column",
")",
";",
"if",
"(",
"count",
"(",
"$",
"values",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"ezcQueryVariableParameterException",
"(",
"'in'",
",",
"count",
"(",
"$",
"args",
")",
",",
"2",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"quoteValues",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"is_int",
"(",
"$",
"value",
")",
":",
"case",
"is_float",
"(",
"$",
"value",
")",
":",
"case",
"$",
"value",
"instanceof",
"ezcQuerySubSelect",
":",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"break",
";",
"default",
":",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"db",
"->",
"quote",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"values",
")",
"<=",
"1000",
")",
"{",
"return",
"\"{$column} IN ( \"",
".",
"join",
"(",
"', '",
",",
"$",
"values",
")",
".",
"' )'",
";",
"}",
"else",
"{",
"$",
"expression",
"=",
"'( '",
";",
"do",
"{",
"$",
"bunch",
"=",
"array_slice",
"(",
"$",
"values",
",",
"0",
",",
"1000",
")",
";",
"$",
"values",
"=",
"array_slice",
"(",
"$",
"values",
",",
"1000",
")",
";",
"$",
"expression",
".=",
"\"{$column} IN ( \"",
".",
"join",
"(",
"', '",
",",
"$",
"bunch",
")",
".",
"' ) OR '",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"values",
")",
">",
"1000",
")",
";",
"$",
"expression",
".=",
"\"{$column} IN ( \"",
".",
"join",
"(",
"', '",
",",
"$",
"values",
")",
".",
"' ) )'",
";",
"return",
"$",
"expression",
";",
"}",
"}"
] |
Returns the SQL to check if a value is one in a set of
given values.
in() accepts an arbitrary number of parameters. The first parameter
must always specify the value that should be matched against. Successive
parameters must contain a logical expression or an array with logical
expressions. These expressions will be matched against the first
parameter.
Example:
<code>
$q->select( '*' )->from( 'table' )
->where( $q->expr->in( 'id', 1, 2, 3 ) );
</code>
Oracle limits the number of values in a single IN() to 1000. This
implementation creates a list of combined IN() expressions to bypass
this limitation.
@throws ezcQueryVariableParameterException if called with less than two
parameters.
@throws ezcQueryInvalidParameterException if the 2nd parameter is an
empty array.
@param string|array(string) values that will be matched against $column
@return string logical expression
|
[
"Returns",
"the",
"SQL",
"to",
"check",
"if",
"a",
"value",
"is",
"one",
"in",
"a",
"set",
"of",
"given",
"values",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Database/src/sqlabstraction/implementations/expression_oracle.php#L268-L326
|
22,644
|
HedronDev/hedron
|
src/Tools/ComposerHelperTrait.php
|
ComposerHelperTrait.mergeComposerJsonFiles
|
protected function mergeComposerJsonFiles(string $composer_file, \stdClass $original_composer, \stdClass $new_composer, callable $callback = NULL) {
$new_composer = $this->mergeComposerObjects($original_composer, $new_composer, $callback);
$composer_content = file_get_contents($composer_file);
$replace_composer = json_decode($composer_content);
$changes = $this->calculateRequirementChanges($replace_composer, $new_composer);
if (file_put_contents($composer_file, json_encode($new_composer, JSON_PRETTY_PRINT)) !== FALSE) {
return $changes;
}
}
|
php
|
protected function mergeComposerJsonFiles(string $composer_file, \stdClass $original_composer, \stdClass $new_composer, callable $callback = NULL) {
$new_composer = $this->mergeComposerObjects($original_composer, $new_composer, $callback);
$composer_content = file_get_contents($composer_file);
$replace_composer = json_decode($composer_content);
$changes = $this->calculateRequirementChanges($replace_composer, $new_composer);
if (file_put_contents($composer_file, json_encode($new_composer, JSON_PRETTY_PRINT)) !== FALSE) {
return $changes;
}
}
|
[
"protected",
"function",
"mergeComposerJsonFiles",
"(",
"string",
"$",
"composer_file",
",",
"\\",
"stdClass",
"$",
"original_composer",
",",
"\\",
"stdClass",
"$",
"new_composer",
",",
"callable",
"$",
"callback",
"=",
"NULL",
")",
"{",
"$",
"new_composer",
"=",
"$",
"this",
"->",
"mergeComposerObjects",
"(",
"$",
"original_composer",
",",
"$",
"new_composer",
",",
"$",
"callback",
")",
";",
"$",
"composer_content",
"=",
"file_get_contents",
"(",
"$",
"composer_file",
")",
";",
"$",
"replace_composer",
"=",
"json_decode",
"(",
"$",
"composer_content",
")",
";",
"$",
"changes",
"=",
"$",
"this",
"->",
"calculateRequirementChanges",
"(",
"$",
"replace_composer",
",",
"$",
"new_composer",
")",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"composer_file",
",",
"json_encode",
"(",
"$",
"new_composer",
",",
"JSON_PRETTY_PRINT",
")",
")",
"!==",
"FALSE",
")",
"{",
"return",
"$",
"changes",
";",
"}",
"}"
] |
Merges the original composer file with a new composer file.
This ensures that the composer.json file that is going to be installed
will have all the appropriate requirements documented by the git
repository that is kept up to date by the client.
@param string $composer_file
The absolute path to the composer file to write.
@param \stdClass $original_composer
The original composer.json file before it was removed as a php object.
@param \stdClass $new_composer
The new composer.json file as a php object.
@param callable $callback
A callback if necessary to customize the composer object further.
@return array
|
[
"Merges",
"the",
"original",
"composer",
"file",
"with",
"a",
"new",
"composer",
"file",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Tools/ComposerHelperTrait.php#L27-L35
|
22,645
|
HedronDev/hedron
|
src/Tools/ComposerHelperTrait.php
|
ComposerHelperTrait.mergeComposerObjects
|
protected function mergeComposerObjects(\stdClass $original_composer, \stdClass $new_composer, callable $callback = NULL) {
foreach ($original_composer as $key => $values) {
$is_array = is_array($values);
$values = (array) $values;
if (isset($new_composer->{$key})) {
$value = (array) $new_composer->{$key};
$values = array_merge($value, $values);
}
$new_composer->{$key} = $is_array ? $values : (object) $values;
}
if ($callback) {
call_user_func($callback, $new_composer);
}
return $new_composer;
}
|
php
|
protected function mergeComposerObjects(\stdClass $original_composer, \stdClass $new_composer, callable $callback = NULL) {
foreach ($original_composer as $key => $values) {
$is_array = is_array($values);
$values = (array) $values;
if (isset($new_composer->{$key})) {
$value = (array) $new_composer->{$key};
$values = array_merge($value, $values);
}
$new_composer->{$key} = $is_array ? $values : (object) $values;
}
if ($callback) {
call_user_func($callback, $new_composer);
}
return $new_composer;
}
|
[
"protected",
"function",
"mergeComposerObjects",
"(",
"\\",
"stdClass",
"$",
"original_composer",
",",
"\\",
"stdClass",
"$",
"new_composer",
",",
"callable",
"$",
"callback",
"=",
"NULL",
")",
"{",
"foreach",
"(",
"$",
"original_composer",
"as",
"$",
"key",
"=>",
"$",
"values",
")",
"{",
"$",
"is_array",
"=",
"is_array",
"(",
"$",
"values",
")",
";",
"$",
"values",
"=",
"(",
"array",
")",
"$",
"values",
";",
"if",
"(",
"isset",
"(",
"$",
"new_composer",
"->",
"{",
"$",
"key",
"}",
")",
")",
"{",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"new_composer",
"->",
"{",
"$",
"key",
"}",
";",
"$",
"values",
"=",
"array_merge",
"(",
"$",
"value",
",",
"$",
"values",
")",
";",
"}",
"$",
"new_composer",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"is_array",
"?",
"$",
"values",
":",
"(",
"object",
")",
"$",
"values",
";",
"}",
"if",
"(",
"$",
"callback",
")",
"{",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"new_composer",
")",
";",
"}",
"return",
"$",
"new_composer",
";",
"}"
] |
Merges two composer objects into one.
@param \stdClass $original_composer
The original composer.json file before it was removed as a php object.
@param \stdClass $new_composer
The new composer file to generate.
@param callable $callback
A callback if necessary to customize the composer object further.
@return \stdClass
An object representing the merged composer json files.
|
[
"Merges",
"two",
"composer",
"objects",
"into",
"one",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Tools/ComposerHelperTrait.php#L50-L64
|
22,646
|
HedronDev/hedron
|
src/Tools/ComposerHelperTrait.php
|
ComposerHelperTrait.calculateRequirementChanges
|
protected function calculateRequirementChanges($replace_composer, $new_composer) {
$changes = [
'install' => [],
'update' => [],
'remove' => [],
];
foreach (['require', 'require-dev'] as $key) {
$old_requirements = !empty($replace_composer->{$key}) ? $replace_composer->{$key} : [];
$new_requirements = !empty($new_composer->{$key}) ? $new_composer->{$key} : [];
foreach ($new_requirements as $requirement => $version) {
if (empty($old_requirements->{$requirement})) {
$changes['install'][$requirement] = $version;
}
if ((!empty($old_requirements->{$requirement}) && Comparator::greaterThan($version, $old_requirements->{$requirement}))) {
$changes['update'][$requirement] = $version;
}
}
foreach ($old_requirements as $requirement => $version) {
if (empty($new_requirements->{$requirement})) {
$changes['remove'][] = $requirement;
}
}
}
return $changes;
}
|
php
|
protected function calculateRequirementChanges($replace_composer, $new_composer) {
$changes = [
'install' => [],
'update' => [],
'remove' => [],
];
foreach (['require', 'require-dev'] as $key) {
$old_requirements = !empty($replace_composer->{$key}) ? $replace_composer->{$key} : [];
$new_requirements = !empty($new_composer->{$key}) ? $new_composer->{$key} : [];
foreach ($new_requirements as $requirement => $version) {
if (empty($old_requirements->{$requirement})) {
$changes['install'][$requirement] = $version;
}
if ((!empty($old_requirements->{$requirement}) && Comparator::greaterThan($version, $old_requirements->{$requirement}))) {
$changes['update'][$requirement] = $version;
}
}
foreach ($old_requirements as $requirement => $version) {
if (empty($new_requirements->{$requirement})) {
$changes['remove'][] = $requirement;
}
}
}
return $changes;
}
|
[
"protected",
"function",
"calculateRequirementChanges",
"(",
"$",
"replace_composer",
",",
"$",
"new_composer",
")",
"{",
"$",
"changes",
"=",
"[",
"'install'",
"=>",
"[",
"]",
",",
"'update'",
"=>",
"[",
"]",
",",
"'remove'",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"[",
"'require'",
",",
"'require-dev'",
"]",
"as",
"$",
"key",
")",
"{",
"$",
"old_requirements",
"=",
"!",
"empty",
"(",
"$",
"replace_composer",
"->",
"{",
"$",
"key",
"}",
")",
"?",
"$",
"replace_composer",
"->",
"{",
"$",
"key",
"}",
":",
"[",
"]",
";",
"$",
"new_requirements",
"=",
"!",
"empty",
"(",
"$",
"new_composer",
"->",
"{",
"$",
"key",
"}",
")",
"?",
"$",
"new_composer",
"->",
"{",
"$",
"key",
"}",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"new_requirements",
"as",
"$",
"requirement",
"=>",
"$",
"version",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"old_requirements",
"->",
"{",
"$",
"requirement",
"}",
")",
")",
"{",
"$",
"changes",
"[",
"'install'",
"]",
"[",
"$",
"requirement",
"]",
"=",
"$",
"version",
";",
"}",
"if",
"(",
"(",
"!",
"empty",
"(",
"$",
"old_requirements",
"->",
"{",
"$",
"requirement",
"}",
")",
"&&",
"Comparator",
"::",
"greaterThan",
"(",
"$",
"version",
",",
"$",
"old_requirements",
"->",
"{",
"$",
"requirement",
"}",
")",
")",
")",
"{",
"$",
"changes",
"[",
"'update'",
"]",
"[",
"$",
"requirement",
"]",
"=",
"$",
"version",
";",
"}",
"}",
"foreach",
"(",
"$",
"old_requirements",
"as",
"$",
"requirement",
"=>",
"$",
"version",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"new_requirements",
"->",
"{",
"$",
"requirement",
"}",
")",
")",
"{",
"$",
"changes",
"[",
"'remove'",
"]",
"[",
"]",
"=",
"$",
"requirement",
";",
"}",
"}",
"}",
"return",
"$",
"changes",
";",
"}"
] |
Calculated requirements that need to be removed from the system.
@param $replace_composer
Composer object about to be replaced.
@param $new_composer
Composer object doing the replacing.
@return array
An array of requirements to install, update or remove.
|
[
"Calculated",
"requirements",
"that",
"need",
"to",
"be",
"removed",
"from",
"the",
"system",
"."
] |
3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00
|
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Tools/ComposerHelperTrait.php#L77-L101
|
22,647
|
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Roles/Doc.php
|
Doc.toXhtml
|
public function toXhtml(\DOMDocument $document, \DOMElement $root)
{
$content = '';
$caption = '';
foreach ($this->node->nodes as $node) {
$content .= $node->token->content;
}
$matches = array();
if (preg_match('/([^<]*)<?([^>]*)>?/', $content, $matches)) {
// if the role uses the `caption<content>` notation; extract the two parts
if (isset($matches[2]) && $matches[2]) {
$content = $matches[2];
$caption = trim($matches[1]);
}
}
// check the table of contents for a caption.
if (!$caption && $this->visitor) {
$toc = $this->visitor->getTableOfContents();
$caption = isset($toc[$content]) ? $toc[$content]->getName() : '';
}
// if no caption is captured; create one.
if (!$caption) {
$caption = str_replace(
array('-', '_'),
' ',
ucfirst(ltrim(substr(htmlspecialchars($content), strrpos($content, '/')), '\\/'))
);
}
$link = $document->createElement('a', $caption);
$root->appendChild($link);
$link->setAttribute('href', str_replace('\\', '/', $content) . '.html');
}
|
php
|
public function toXhtml(\DOMDocument $document, \DOMElement $root)
{
$content = '';
$caption = '';
foreach ($this->node->nodes as $node) {
$content .= $node->token->content;
}
$matches = array();
if (preg_match('/([^<]*)<?([^>]*)>?/', $content, $matches)) {
// if the role uses the `caption<content>` notation; extract the two parts
if (isset($matches[2]) && $matches[2]) {
$content = $matches[2];
$caption = trim($matches[1]);
}
}
// check the table of contents for a caption.
if (!$caption && $this->visitor) {
$toc = $this->visitor->getTableOfContents();
$caption = isset($toc[$content]) ? $toc[$content]->getName() : '';
}
// if no caption is captured; create one.
if (!$caption) {
$caption = str_replace(
array('-', '_'),
' ',
ucfirst(ltrim(substr(htmlspecialchars($content), strrpos($content, '/')), '\\/'))
);
}
$link = $document->createElement('a', $caption);
$root->appendChild($link);
$link->setAttribute('href', str_replace('\\', '/', $content) . '.html');
}
|
[
"public",
"function",
"toXhtml",
"(",
"\\",
"DOMDocument",
"$",
"document",
",",
"\\",
"DOMElement",
"$",
"root",
")",
"{",
"$",
"content",
"=",
"''",
";",
"$",
"caption",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"node",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"content",
".=",
"$",
"node",
"->",
"token",
"->",
"content",
";",
"}",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/([^<]*)<?([^>]*)>?/'",
",",
"$",
"content",
",",
"$",
"matches",
")",
")",
"{",
"// if the role uses the `caption<content>` notation; extract the two parts",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"&&",
"$",
"matches",
"[",
"2",
"]",
")",
"{",
"$",
"content",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"caption",
"=",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}",
"}",
"// check the table of contents for a caption.",
"if",
"(",
"!",
"$",
"caption",
"&&",
"$",
"this",
"->",
"visitor",
")",
"{",
"$",
"toc",
"=",
"$",
"this",
"->",
"visitor",
"->",
"getTableOfContents",
"(",
")",
";",
"$",
"caption",
"=",
"isset",
"(",
"$",
"toc",
"[",
"$",
"content",
"]",
")",
"?",
"$",
"toc",
"[",
"$",
"content",
"]",
"->",
"getName",
"(",
")",
":",
"''",
";",
"}",
"// if no caption is captured; create one.",
"if",
"(",
"!",
"$",
"caption",
")",
"{",
"$",
"caption",
"=",
"str_replace",
"(",
"array",
"(",
"'-'",
",",
"'_'",
")",
",",
"' '",
",",
"ucfirst",
"(",
"ltrim",
"(",
"substr",
"(",
"htmlspecialchars",
"(",
"$",
"content",
")",
",",
"strrpos",
"(",
"$",
"content",
",",
"'/'",
")",
")",
",",
"'\\\\/'",
")",
")",
")",
";",
"}",
"$",
"link",
"=",
"$",
"document",
"->",
"createElement",
"(",
"'a'",
",",
"$",
"caption",
")",
";",
"$",
"root",
"->",
"appendChild",
"(",
"$",
"link",
")",
";",
"$",
"link",
"->",
"setAttribute",
"(",
"'href'",
",",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"content",
")",
".",
"'.html'",
")",
";",
"}"
] |
Transform text role to HTML.
Create a XHTML structure at the text roles position in the document.
@param \DOMDocument $document
@param \DOMElement $root
@return void
|
[
"Transform",
"text",
"role",
"to",
"HTML",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Scrybe/Converter/RestructuredText/Roles/Doc.php#L47-L83
|
22,648
|
kecik-framework/kecik
|
Kecik/Route.php
|
Route._getParams
|
public function _getParams( $key = - 1 ) {
if ( $key >= 0 ) {
if ( isset( self::$params[ $key ] ) ) {
return self::$params[ $key ];
} else {
return NULL;
}
} else {
return self::$params;
}
}
|
php
|
public function _getParams( $key = - 1 ) {
if ( $key >= 0 ) {
if ( isset( self::$params[ $key ] ) ) {
return self::$params[ $key ];
} else {
return NULL;
}
} else {
return self::$params;
}
}
|
[
"public",
"function",
"_getParams",
"(",
"$",
"key",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"key",
">=",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"params",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"params",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"return",
"NULL",
";",
"}",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"params",
";",
"}",
"}"
] |
get Route Paramenters
@param int $key
@return array|null
|
[
"get",
"Route",
"Paramenters"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Route.php#L196-L209
|
22,649
|
kecik-framework/kecik
|
Kecik/Route.php
|
Route.setParams
|
public function setParams( $key, $value = '' ) {
//if (!isset($this->params)) $this->params = array();
if ( is_array( $key ) ) {
self::$RealParams = $key;
} else {
self::$RealParams[ $key ] = $value;
}
}
|
php
|
public function setParams( $key, $value = '' ) {
//if (!isset($this->params)) $this->params = array();
if ( is_array( $key ) ) {
self::$RealParams = $key;
} else {
self::$RealParams[ $key ] = $value;
}
}
|
[
"public",
"function",
"setParams",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"''",
")",
"{",
"//if (!isset($this->params)) $this->params = array();",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
")",
"{",
"self",
"::",
"$",
"RealParams",
"=",
"$",
"key",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"RealParams",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Set route paramters
@param $key
@param string $value
|
[
"Set",
"route",
"paramters"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Route.php#L238-L247
|
22,650
|
kecik-framework/kecik
|
Kecik/Route.php
|
Route.isPut
|
public function isPut() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'PUT' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'PUT' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_PUT'] = $_PUT = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
php
|
public function isPut() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'PUT' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'PUT' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_PUT'] = $_PUT = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
[
"public",
"function",
"isPut",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'PUT'",
"||",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
"==",
"'PUT'",
")",
")",
"{",
"parse_str",
"(",
"file_get_contents",
"(",
"\"php://input\"",
")",
",",
"$",
"vars",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
";",
"}",
"$",
"GLOBALS",
"[",
"'_PUT'",
"]",
"=",
"$",
"_PUT",
"=",
"$",
"vars",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}"
] |
Check request of Put method
@return bool
|
[
"Check",
"request",
"of",
"Put",
"method"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Route.php#L335-L357
|
22,651
|
kecik-framework/kecik
|
Kecik/Route.php
|
Route.isDelete
|
public function isDelete() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'DELETE' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'DELETE' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_DELETE'] = $_DELETE = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
php
|
public function isDelete() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'DELETE' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'DELETE' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_DELETE'] = $_DELETE = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
[
"public",
"function",
"isDelete",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'DELETE'",
"||",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
"==",
"'DELETE'",
")",
")",
"{",
"parse_str",
"(",
"file_get_contents",
"(",
"\"php://input\"",
")",
",",
"$",
"vars",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
";",
"}",
"$",
"GLOBALS",
"[",
"'_DELETE'",
"]",
"=",
"$",
"_DELETE",
"=",
"$",
"vars",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}"
] |
Check request of delete method
@return bool
|
[
"Check",
"request",
"of",
"delete",
"method"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Route.php#L364-L385
|
22,652
|
kecik-framework/kecik
|
Kecik/Route.php
|
Route.isPatch
|
public function isPatch() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'PATCH' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'PATCH' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_PATCH'] = $_PATCH = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
php
|
public function isPatch() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'PATCH' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'PATCH' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_PATCH'] = $_PATCH = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
[
"public",
"function",
"isPatch",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'PATCH'",
"||",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
"==",
"'PATCH'",
")",
")",
"{",
"parse_str",
"(",
"file_get_contents",
"(",
"\"php://input\"",
")",
",",
"$",
"vars",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
";",
"}",
"$",
"GLOBALS",
"[",
"'_PATCH'",
"]",
"=",
"$",
"_PATCH",
"=",
"$",
"vars",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}"
] |
Check request of Patch method
@return bool
|
[
"Check",
"request",
"of",
"Patch",
"method"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Route.php#L392-L413
|
22,653
|
kecik-framework/kecik
|
Kecik/Route.php
|
Route.isOptions
|
public function isOptions() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'OPTIONS' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_OPTIONS'] = $_OPTIONS = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
php
|
public function isOptions() {
if ( isset( $_SERVER['REQUEST_METHOD'] ) ) {
if ( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' || ( isset( $_POST['_METHOD'] ) && $_POST['_METHOD'] == 'OPTIONS' ) ) {
parse_str( file_get_contents( "php://input" ), $vars );
if ( isset( $vars['_METHOD'] ) ) {
unset( $vars['_METHOD'] );
}
$GLOBALS['_OPTIONS'] = $_OPTIONS = $vars;
return TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
|
[
"public",
"function",
"isOptions",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"==",
"'OPTIONS'",
"||",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
")",
"&&",
"$",
"_POST",
"[",
"'_METHOD'",
"]",
"==",
"'OPTIONS'",
")",
")",
"{",
"parse_str",
"(",
"file_get_contents",
"(",
"\"php://input\"",
")",
",",
"$",
"vars",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"vars",
"[",
"'_METHOD'",
"]",
")",
";",
"}",
"$",
"GLOBALS",
"[",
"'_OPTIONS'",
"]",
"=",
"$",
"_OPTIONS",
"=",
"$",
"vars",
";",
"return",
"TRUE",
";",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}",
"else",
"{",
"return",
"FALSE",
";",
"}",
"}"
] |
Check request of Options method
@return bool
|
[
"Check",
"request",
"of",
"Options",
"method"
] |
fa87e593affe1c9c51a2acd264b85ec06df31d7c
|
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Route.php#L420-L441
|
22,654
|
GrupaZero/api
|
src/Gzero/Api/Transformer/BlockTransformer.php
|
BlockTransformer.transform
|
public function transform($block)
{
$block = $this->entityToArray(Block::class, $block);
return [
'id' => $this->setNullableValue($block['id']),
'type' => $block['type'],
'region' => $block['region'],
'filter' => $block['filter'],
'options' => $block['options'],
'theme' => $block['theme'],
'weight' => (int) $block['weight'],
'isActive' => (bool) $block['is_active'],
'isCacheable' => (bool) $block['is_cacheable'],
'createdAt' => $block['created_at'],
'updatedAt' => $block['updated_at']
];
}
|
php
|
public function transform($block)
{
$block = $this->entityToArray(Block::class, $block);
return [
'id' => $this->setNullableValue($block['id']),
'type' => $block['type'],
'region' => $block['region'],
'filter' => $block['filter'],
'options' => $block['options'],
'theme' => $block['theme'],
'weight' => (int) $block['weight'],
'isActive' => (bool) $block['is_active'],
'isCacheable' => (bool) $block['is_cacheable'],
'createdAt' => $block['created_at'],
'updatedAt' => $block['updated_at']
];
}
|
[
"public",
"function",
"transform",
"(",
"$",
"block",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"Block",
"::",
"class",
",",
"$",
"block",
")",
";",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"setNullableValue",
"(",
"$",
"block",
"[",
"'id'",
"]",
")",
",",
"'type'",
"=>",
"$",
"block",
"[",
"'type'",
"]",
",",
"'region'",
"=>",
"$",
"block",
"[",
"'region'",
"]",
",",
"'filter'",
"=>",
"$",
"block",
"[",
"'filter'",
"]",
",",
"'options'",
"=>",
"$",
"block",
"[",
"'options'",
"]",
",",
"'theme'",
"=>",
"$",
"block",
"[",
"'theme'",
"]",
",",
"'weight'",
"=>",
"(",
"int",
")",
"$",
"block",
"[",
"'weight'",
"]",
",",
"'isActive'",
"=>",
"(",
"bool",
")",
"$",
"block",
"[",
"'is_active'",
"]",
",",
"'isCacheable'",
"=>",
"(",
"bool",
")",
"$",
"block",
"[",
"'is_cacheable'",
"]",
",",
"'createdAt'",
"=>",
"$",
"block",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"block",
"[",
"'updated_at'",
"]",
"]",
";",
"}"
] |
Transforms block entity
@param Block|array $block Block entity
@return array
|
[
"Transforms",
"block",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/BlockTransformer.php#L45-L61
|
22,655
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php
|
Dwootemplate.add_js
|
public function add_js($js) {
$current = $this->dwoo_data->js_files;
$current[] = $js;
$this->dwoo_data->js_files = $current;
}
|
php
|
public function add_js($js) {
$current = $this->dwoo_data->js_files;
$current[] = $js;
$this->dwoo_data->js_files = $current;
}
|
[
"public",
"function",
"add_js",
"(",
"$",
"js",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"dwoo_data",
"->",
"js_files",
";",
"$",
"current",
"[",
"]",
"=",
"$",
"js",
";",
"$",
"this",
"->",
"dwoo_data",
"->",
"js_files",
"=",
"$",
"current",
";",
"}"
] |
Add Javascript files to template
@param string $js
|
[
"Add",
"Javascript",
"files",
"to",
"template"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php#L66-L70
|
22,656
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php
|
Dwootemplate.add_css
|
public function add_css($css) {
$current = $this->dwoo_data->css_files;
$current[] = $css;
$this->dwoo_data->css_files = $current;
}
|
php
|
public function add_css($css) {
$current = $this->dwoo_data->css_files;
$current[] = $css;
$this->dwoo_data->css_files = $current;
}
|
[
"public",
"function",
"add_css",
"(",
"$",
"css",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"dwoo_data",
"->",
"css_files",
";",
"$",
"current",
"[",
"]",
"=",
"$",
"css",
";",
"$",
"this",
"->",
"dwoo_data",
"->",
"css_files",
"=",
"$",
"current",
";",
"}"
] |
Add Css stylesheets to template
@param string $css
|
[
"Add",
"Css",
"stylesheets",
"to",
"template"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php#L78-L82
|
22,657
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php
|
Dwootemplate.display
|
public function display($sTemplate, $return = FALSE) {
// Start benchmark
$CI = get_instance();
$CI->benchmark->mark('dwoo_parse_start');
// Check if file exists
if ( !file_exists($this->template_dir . $sTemplate ) ) {
$message = sprintf('Template file \'%s\' not found.', $sTemplate);
show_error($message);
log_message('error', $message);
}
// Create new template
$tpl = new Dwoo_Template_File($this->template_dir . $sTemplate);
// render the template
$template = $this->get($tpl, $this->dwoo_data);
// Finish benchmark
$CI->benchmark->mark('dwoo_parse_end');
// Return results or not ?
if ($return == FALSE) {
$CI->output->final_output = $template;
} else {
return $template;
}
}
|
php
|
public function display($sTemplate, $return = FALSE) {
// Start benchmark
$CI = get_instance();
$CI->benchmark->mark('dwoo_parse_start');
// Check if file exists
if ( !file_exists($this->template_dir . $sTemplate ) ) {
$message = sprintf('Template file \'%s\' not found.', $sTemplate);
show_error($message);
log_message('error', $message);
}
// Create new template
$tpl = new Dwoo_Template_File($this->template_dir . $sTemplate);
// render the template
$template = $this->get($tpl, $this->dwoo_data);
// Finish benchmark
$CI->benchmark->mark('dwoo_parse_end');
// Return results or not ?
if ($return == FALSE) {
$CI->output->final_output = $template;
} else {
return $template;
}
}
|
[
"public",
"function",
"display",
"(",
"$",
"sTemplate",
",",
"$",
"return",
"=",
"FALSE",
")",
"{",
"// Start benchmark",
"$",
"CI",
"=",
"get_instance",
"(",
")",
";",
"$",
"CI",
"->",
"benchmark",
"->",
"mark",
"(",
"'dwoo_parse_start'",
")",
";",
"// Check if file exists",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"template_dir",
".",
"$",
"sTemplate",
")",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Template file \\'%s\\' not found.'",
",",
"$",
"sTemplate",
")",
";",
"show_error",
"(",
"$",
"message",
")",
";",
"log_message",
"(",
"'error'",
",",
"$",
"message",
")",
";",
"}",
"// Create new template",
"$",
"tpl",
"=",
"new",
"Dwoo_Template_File",
"(",
"$",
"this",
"->",
"template_dir",
".",
"$",
"sTemplate",
")",
";",
"// render the template",
"$",
"template",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"tpl",
",",
"$",
"this",
"->",
"dwoo_data",
")",
";",
"// Finish benchmark",
"$",
"CI",
"->",
"benchmark",
"->",
"mark",
"(",
"'dwoo_parse_end'",
")",
";",
"// Return results or not ?",
"if",
"(",
"$",
"return",
"==",
"FALSE",
")",
"{",
"$",
"CI",
"->",
"output",
"->",
"final_output",
"=",
"$",
"template",
";",
"}",
"else",
"{",
"return",
"$",
"template",
";",
"}",
"}"
] |
Display or return the compiled template
Since we assign the results to the standard CI output module
you can also use the helper from CI in your templates!!
@param string $sTemplate
@param boolean $return
@return mixed
|
[
"Display",
"or",
"return",
"the",
"compiled",
"template",
"Since",
"we",
"assign",
"the",
"results",
"to",
"the",
"standard",
"CI",
"output",
"module",
"you",
"can",
"also",
"use",
"the",
"helper",
"from",
"CI",
"in",
"your",
"templates!!"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php#L94-L121
|
22,658
|
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php
|
Dwootemplate.initialize
|
private function initialize() {
$CI = get_instance();
$CI->config->load('dwootemplate', TRUE);
$config = $CI->config->item('dwootemplate');
foreach ($config as $key => $val) {
$this->$key = $val;
}
}
|
php
|
private function initialize() {
$CI = get_instance();
$CI->config->load('dwootemplate', TRUE);
$config = $CI->config->item('dwootemplate');
foreach ($config as $key => $val) {
$this->$key = $val;
}
}
|
[
"private",
"function",
"initialize",
"(",
")",
"{",
"$",
"CI",
"=",
"get_instance",
"(",
")",
";",
"$",
"CI",
"->",
"config",
"->",
"load",
"(",
"'dwootemplate'",
",",
"TRUE",
")",
";",
"$",
"config",
"=",
"$",
"CI",
"->",
"config",
"->",
"item",
"(",
"'dwootemplate'",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"$",
"key",
"=",
"$",
"val",
";",
"}",
"}"
] |
Assign the dwootemplate config items to the instance
|
[
"Assign",
"the",
"dwootemplate",
"config",
"items",
"to",
"the",
"instance"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/CodeIgniter/libraries/Dwootemplate.php#L164-L171
|
22,659
|
i-lateral/silverstripe-modeladminplus
|
src/DataObjectExtension.php
|
DataObjectExtension.getModelAdminSearchContext
|
public function getModelAdminSearchContext()
{
return SearchContext::create(
get_class($this->getOwner()),
$this->getOwner()->scaffoldSearchFields(),
$this->getOwner()->defaultSearchFilters()
);
}
|
php
|
public function getModelAdminSearchContext()
{
return SearchContext::create(
get_class($this->getOwner()),
$this->getOwner()->scaffoldSearchFields(),
$this->getOwner()->defaultSearchFilters()
);
}
|
[
"public",
"function",
"getModelAdminSearchContext",
"(",
")",
"{",
"return",
"SearchContext",
"::",
"create",
"(",
"get_class",
"(",
"$",
"this",
"->",
"getOwner",
"(",
")",
")",
",",
"$",
"this",
"->",
"getOwner",
"(",
")",
"->",
"scaffoldSearchFields",
"(",
")",
",",
"$",
"this",
"->",
"getOwner",
"(",
")",
"->",
"defaultSearchFilters",
"(",
")",
")",
";",
"}"
] |
Get a custom search context for model admin plus
|
[
"Get",
"a",
"custom",
"search",
"context",
"for",
"model",
"admin",
"plus"
] |
c5209d9610cdb36ddc7b9231fad342df7e75ffc0
|
https://github.com/i-lateral/silverstripe-modeladminplus/blob/c5209d9610cdb36ddc7b9231fad342df7e75ffc0/src/DataObjectExtension.php#L12-L19
|
22,660
|
fccn/oai-pmh-core
|
src/schemas/ands_dces.php
|
DC_DataHolder.combine
|
public function combine($another)
{
if (is_a($another, DC_DataHolder::getKlass())) {
// debug_message("entering combine...");
// debug_var_dump("another", $another);
//identifier
if (empty($this->identifier)) {
debug_message("DC_DataHolder::identifier should not be empty!!");
$this->identifier = $another->identifier;
} elseif (strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier) !== 0) {
debug_var_dump('comparison', strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier));
error_log("found a different identifier for this element ".$this->identifier." != ".$another->identifier);
return;
}
//continue with other elements
$this->addElement('contributor', $another);
$this->addElement('coverage', $another);
$this->addElement('creator', $another);
$this->addElement('date_', $another);
$this->addElement('description', $another);
$this->addElement('format_', $another);
$this->addElement('language', $another);
$this->addElement('publisher', $another);
$this->addElement('relation', $another);
$this->addElement('rights', $another);
$this->addElement('source', $another);
$this->addElement('subject', $another);
$this->addElement('title', $another);
$this->addElement('type_', $another);
}
}
|
php
|
public function combine($another)
{
if (is_a($another, DC_DataHolder::getKlass())) {
// debug_message("entering combine...");
// debug_var_dump("another", $another);
//identifier
if (empty($this->identifier)) {
debug_message("DC_DataHolder::identifier should not be empty!!");
$this->identifier = $another->identifier;
} elseif (strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier) !== 0) {
debug_var_dump('comparison', strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier));
error_log("found a different identifier for this element ".$this->identifier." != ".$another->identifier);
return;
}
//continue with other elements
$this->addElement('contributor', $another);
$this->addElement('coverage', $another);
$this->addElement('creator', $another);
$this->addElement('date_', $another);
$this->addElement('description', $another);
$this->addElement('format_', $another);
$this->addElement('language', $another);
$this->addElement('publisher', $another);
$this->addElement('relation', $another);
$this->addElement('rights', $another);
$this->addElement('source', $another);
$this->addElement('subject', $another);
$this->addElement('title', $another);
$this->addElement('type_', $another);
}
}
|
[
"public",
"function",
"combine",
"(",
"$",
"another",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"another",
",",
"DC_DataHolder",
"::",
"getKlass",
"(",
")",
")",
")",
"{",
"// debug_message(\"entering combine...\");",
"// debug_var_dump(\"another\", $another);",
"//identifier",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"identifier",
")",
")",
"{",
"debug_message",
"(",
"\"DC_DataHolder::identifier should not be empty!!\"",
")",
";",
"$",
"this",
"->",
"identifier",
"=",
"$",
"another",
"->",
"identifier",
";",
"}",
"elseif",
"(",
"strcmp",
"(",
"substr",
"(",
"$",
"this",
"->",
"identifier",
",",
"-",
"strlen",
"(",
"$",
"another",
"->",
"identifier",
")",
")",
",",
"$",
"another",
"->",
"identifier",
")",
"!==",
"0",
")",
"{",
"debug_var_dump",
"(",
"'comparison'",
",",
"strcmp",
"(",
"substr",
"(",
"$",
"this",
"->",
"identifier",
",",
"-",
"strlen",
"(",
"$",
"another",
"->",
"identifier",
")",
")",
",",
"$",
"another",
"->",
"identifier",
")",
")",
";",
"error_log",
"(",
"\"found a different identifier for this element \"",
".",
"$",
"this",
"->",
"identifier",
".",
"\" != \"",
".",
"$",
"another",
"->",
"identifier",
")",
";",
"return",
";",
"}",
"//continue with other elements",
"$",
"this",
"->",
"addElement",
"(",
"'contributor'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'coverage'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'creator'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'date_'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'description'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'format_'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'language'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'publisher'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'relation'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'rights'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'source'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'subject'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'title'",
",",
"$",
"another",
")",
";",
"$",
"this",
"->",
"addElement",
"(",
"'type_'",
",",
"$",
"another",
")",
";",
"}",
"}"
] |
Combines this object with another DC_DataHolder object
|
[
"Combines",
"this",
"object",
"with",
"another",
"DC_DataHolder",
"object"
] |
a9c6852482c7bd7c48911a2165120325ecc27ea2
|
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_dces.php#L184-L214
|
22,661
|
OKTOTV/OktolabMediaBundle
|
Model/GenerateThumbnailSpriteJob.php
|
GenerateThumbnailSpriteJob.generateThumbs
|
private function generateThumbs($episode, $cache_asset)
{
$uri = $this->asset_helper->getAbsoluteUrl($episode->getVideo());
$path = $this->asset_helper->getPath($cache_asset, true);
$cmd = sprintf(
"ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1",
$uri,
$this->sprite_width,
$this->sprite_height,
$this->sprite_interval,
$path
);
// open (ffmpeg) process, read stdout to get duration if unknown to this point.
$fp = popen($cmd, "r");
while(!feof($fp)) {
// read outputstream of ffmpeg
$chunk = fread($fp, 1024);
// try to get the duration information at the beginning of the ffmpeg output.
if (!$episode->getDuration()) {
preg_match("/Duration: (.*?), start:/", $chunk, $matches);
if (array_key_exists(1, $matches)) {
list($hours,$minutes,$seconds) = explode(":",$matches[1]);
// calculate the duration in seconds. Used to calculate overall progress in percent.
$episode->setDuration((($hours * 3600) + ($minutes * 60) + $seconds));
}
}
// flush the content to the browser
flush();
}
fclose($fp);
}
|
php
|
private function generateThumbs($episode, $cache_asset)
{
$uri = $this->asset_helper->getAbsoluteUrl($episode->getVideo());
$path = $this->asset_helper->getPath($cache_asset, true);
$cmd = sprintf(
"ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1",
$uri,
$this->sprite_width,
$this->sprite_height,
$this->sprite_interval,
$path
);
// open (ffmpeg) process, read stdout to get duration if unknown to this point.
$fp = popen($cmd, "r");
while(!feof($fp)) {
// read outputstream of ffmpeg
$chunk = fread($fp, 1024);
// try to get the duration information at the beginning of the ffmpeg output.
if (!$episode->getDuration()) {
preg_match("/Duration: (.*?), start:/", $chunk, $matches);
if (array_key_exists(1, $matches)) {
list($hours,$minutes,$seconds) = explode(":",$matches[1]);
// calculate the duration in seconds. Used to calculate overall progress in percent.
$episode->setDuration((($hours * 3600) + ($minutes * 60) + $seconds));
}
}
// flush the content to the browser
flush();
}
fclose($fp);
}
|
[
"private",
"function",
"generateThumbs",
"(",
"$",
"episode",
",",
"$",
"cache_asset",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"asset_helper",
"->",
"getAbsoluteUrl",
"(",
"$",
"episode",
"->",
"getVideo",
"(",
")",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"asset_helper",
"->",
"getPath",
"(",
"$",
"cache_asset",
",",
"true",
")",
";",
"$",
"cmd",
"=",
"sprintf",
"(",
"\"ffmpeg -i %s -s %sx%s -vf fps=1/%s %s 2>&1\"",
",",
"$",
"uri",
",",
"$",
"this",
"->",
"sprite_width",
",",
"$",
"this",
"->",
"sprite_height",
",",
"$",
"this",
"->",
"sprite_interval",
",",
"$",
"path",
")",
";",
"// open (ffmpeg) process, read stdout to get duration if unknown to this point.",
"$",
"fp",
"=",
"popen",
"(",
"$",
"cmd",
",",
"\"r\"",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"fp",
")",
")",
"{",
"// read outputstream of ffmpeg",
"$",
"chunk",
"=",
"fread",
"(",
"$",
"fp",
",",
"1024",
")",
";",
"// try to get the duration information at the beginning of the ffmpeg output.",
"if",
"(",
"!",
"$",
"episode",
"->",
"getDuration",
"(",
")",
")",
"{",
"preg_match",
"(",
"\"/Duration: (.*?), start:/\"",
",",
"$",
"chunk",
",",
"$",
"matches",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"1",
",",
"$",
"matches",
")",
")",
"{",
"list",
"(",
"$",
"hours",
",",
"$",
"minutes",
",",
"$",
"seconds",
")",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"// calculate the duration in seconds. Used to calculate overall progress in percent.",
"$",
"episode",
"->",
"setDuration",
"(",
"(",
"(",
"$",
"hours",
"*",
"3600",
")",
"+",
"(",
"$",
"minutes",
"*",
"60",
")",
"+",
"$",
"seconds",
")",
")",
";",
"}",
"}",
"// flush the content to the browser",
"flush",
"(",
")",
";",
"}",
"fclose",
"(",
"$",
"fp",
")",
";",
"}"
] |
takes episode and creates thumbnails in given width and height
|
[
"takes",
"episode",
"and",
"creates",
"thumbnails",
"in",
"given",
"width",
"and",
"height"
] |
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
|
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/GenerateThumbnailSpriteJob.php#L59-L90
|
22,662
|
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Behaviour/Collection.php
|
Collection.removeBehaviour
|
public function removeBehaviour(BehaviourAbstract $behaviour)
{
foreach ($this->behaviours as $key => $thisBehaviour) {
if ($behaviour == $thisBehaviour) {
unset($this->behaviours[$key]);
}
}
}
|
php
|
public function removeBehaviour(BehaviourAbstract $behaviour)
{
foreach ($this->behaviours as $key => $thisBehaviour) {
if ($behaviour == $thisBehaviour) {
unset($this->behaviours[$key]);
}
}
}
|
[
"public",
"function",
"removeBehaviour",
"(",
"BehaviourAbstract",
"$",
"behaviour",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"behaviours",
"as",
"$",
"key",
"=>",
"$",
"thisBehaviour",
")",
"{",
"if",
"(",
"$",
"behaviour",
"==",
"$",
"thisBehaviour",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"behaviours",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"}"
] |
Removes a behaviour from the collection
@param BehaviourAbstract $behaviour Behaviour to remove from the collection.
@return void
|
[
"Removes",
"a",
"behaviour",
"from",
"the",
"collection"
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Behaviour/Collection.php#L53-L60
|
22,663
|
heidelpay/PhpDoc
|
src/phpDocumentor/Transformer/Behaviour/Collection.php
|
Collection.process
|
public function process(ProjectDescriptor $project)
{
foreach ($this->behaviours as $behaviour) {
$project = $behaviour->process($project);
}
return $project;
}
|
php
|
public function process(ProjectDescriptor $project)
{
foreach ($this->behaviours as $behaviour) {
$project = $behaviour->process($project);
}
return $project;
}
|
[
"public",
"function",
"process",
"(",
"ProjectDescriptor",
"$",
"project",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"behaviours",
"as",
"$",
"behaviour",
")",
"{",
"$",
"project",
"=",
"$",
"behaviour",
"->",
"process",
"(",
"$",
"project",
")",
";",
"}",
"return",
"$",
"project",
";",
"}"
] |
Executes the behaviour on the given object model,
@param ProjectDescriptor $project
@return ProjectDescriptor
|
[
"Executes",
"the",
"behaviour",
"on",
"the",
"given",
"object",
"model"
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Behaviour/Collection.php#L69-L76
|
22,664
|
gruzilla/hydra
|
src/Hydra/Commands/ConfigCommandTrait.php
|
ConfigCommandTrait.getConfigHelper
|
protected function getConfigHelper($serviceName)
{
$storage = new HydraTokenStorage();
$provider = new DefaultServiceProvider($storage);
$className = $this->getConfigHelperClassName($serviceName);
return new $className(
$storage,
$provider,
$serviceName
);
}
|
php
|
protected function getConfigHelper($serviceName)
{
$storage = new HydraTokenStorage();
$provider = new DefaultServiceProvider($storage);
$className = $this->getConfigHelperClassName($serviceName);
return new $className(
$storage,
$provider,
$serviceName
);
}
|
[
"protected",
"function",
"getConfigHelper",
"(",
"$",
"serviceName",
")",
"{",
"$",
"storage",
"=",
"new",
"HydraTokenStorage",
"(",
")",
";",
"$",
"provider",
"=",
"new",
"DefaultServiceProvider",
"(",
"$",
"storage",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"getConfigHelperClassName",
"(",
"$",
"serviceName",
")",
";",
"return",
"new",
"$",
"className",
"(",
"$",
"storage",
",",
"$",
"provider",
",",
"$",
"serviceName",
")",
";",
"}"
] |
overwrite for dependency injection
|
[
"overwrite",
"for",
"dependency",
"injection"
] |
47f381cc48e1a26bfe2e211d8dcb54c787ea0478
|
https://github.com/gruzilla/hydra/blob/47f381cc48e1a26bfe2e211d8dcb54c787ea0478/src/Hydra/Commands/ConfigCommandTrait.php#L156-L168
|
22,665
|
rhosocial/yii2-user
|
security/UserPasswordHistoryTrait.php
|
UserPasswordHistoryTrait.getPasswordHistories
|
public function getPasswordHistories()
{
if (empty($this->passwordHistoryClass) || !class_exists($this->passwordHistoryClass)) {
return false;
}
$class = $this->passwordHistoryClass;
return $class::find()->createdBy($this)->orderByCreatedAt(SORT_DESC)->all();
}
|
php
|
public function getPasswordHistories()
{
if (empty($this->passwordHistoryClass) || !class_exists($this->passwordHistoryClass)) {
return false;
}
$class = $this->passwordHistoryClass;
return $class::find()->createdBy($this)->orderByCreatedAt(SORT_DESC)->all();
}
|
[
"public",
"function",
"getPasswordHistories",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"passwordHistoryClass",
")",
"||",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"passwordHistoryClass",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"class",
"=",
"$",
"this",
"->",
"passwordHistoryClass",
";",
"return",
"$",
"class",
"::",
"find",
"(",
")",
"->",
"createdBy",
"(",
"$",
"this",
")",
"->",
"orderByCreatedAt",
"(",
"SORT_DESC",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Get all password histories sorted by creation time in descending order.
@return boolean|PasswordHistory[] False if password history class is invalid.
|
[
"Get",
"all",
"password",
"histories",
"sorted",
"by",
"creation",
"time",
"in",
"descending",
"order",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L43-L50
|
22,666
|
rhosocial/yii2-user
|
security/UserPasswordHistoryTrait.php
|
UserPasswordHistoryTrait.onAddPasswordToHistory
|
public function onAddPasswordToHistory($event)
{
$password = $event->data;
$sender = $event->sender;
/* @var $sender static */
if (empty($sender->passwordHistoryClass) ||
!class_exists($sender->passwordHistoryClass) ||
empty($sender->passwordHashAttribute) ||
!is_string($sender->passwordHashAttribute)) {
return false;
}
if (empty($password)) {
$password = ['pass_hash' => $sender->{$sender->passwordHashAttribute}];
}
$class = $sender->passwordHistoryClass;
if (array_key_exists('pass_hash', $password)) {
return $class::addHash($password['pass_hash'], $sender);
}
if (array_key_exists('password', $password)) {
return $class::add($password['password'], $sender);
}
return false;
}
|
php
|
public function onAddPasswordToHistory($event)
{
$password = $event->data;
$sender = $event->sender;
/* @var $sender static */
if (empty($sender->passwordHistoryClass) ||
!class_exists($sender->passwordHistoryClass) ||
empty($sender->passwordHashAttribute) ||
!is_string($sender->passwordHashAttribute)) {
return false;
}
if (empty($password)) {
$password = ['pass_hash' => $sender->{$sender->passwordHashAttribute}];
}
$class = $sender->passwordHistoryClass;
if (array_key_exists('pass_hash', $password)) {
return $class::addHash($password['pass_hash'], $sender);
}
if (array_key_exists('password', $password)) {
return $class::add($password['password'], $sender);
}
return false;
}
|
[
"public",
"function",
"onAddPasswordToHistory",
"(",
"$",
"event",
")",
"{",
"$",
"password",
"=",
"$",
"event",
"->",
"data",
";",
"$",
"sender",
"=",
"$",
"event",
"->",
"sender",
";",
"/* @var $sender static */",
"if",
"(",
"empty",
"(",
"$",
"sender",
"->",
"passwordHistoryClass",
")",
"||",
"!",
"class_exists",
"(",
"$",
"sender",
"->",
"passwordHistoryClass",
")",
"||",
"empty",
"(",
"$",
"sender",
"->",
"passwordHashAttribute",
")",
"||",
"!",
"is_string",
"(",
"$",
"sender",
"->",
"passwordHashAttribute",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"password",
")",
")",
"{",
"$",
"password",
"=",
"[",
"'pass_hash'",
"=>",
"$",
"sender",
"->",
"{",
"$",
"sender",
"->",
"passwordHashAttribute",
"}",
"]",
";",
"}",
"$",
"class",
"=",
"$",
"sender",
"->",
"passwordHistoryClass",
";",
"if",
"(",
"array_key_exists",
"(",
"'pass_hash'",
",",
"$",
"password",
")",
")",
"{",
"return",
"$",
"class",
"::",
"addHash",
"(",
"$",
"password",
"[",
"'pass_hash'",
"]",
",",
"$",
"sender",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'password'",
",",
"$",
"password",
")",
")",
"{",
"return",
"$",
"class",
"::",
"add",
"(",
"$",
"password",
"[",
"'password'",
"]",
",",
"$",
"sender",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
This event is ONLY used for adding password to history.
You SHOULD NOT call this method directly, or you know the consequences of doing so
@param ModelEvent $event
@return boolean False if no password was added to history.
|
[
"This",
"event",
"is",
"ONLY",
"used",
"for",
"adding",
"password",
"to",
"history",
".",
"You",
"SHOULD",
"NOT",
"call",
"this",
"method",
"directly",
"or",
"you",
"know",
"the",
"consequences",
"of",
"doing",
"so"
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L58-L80
|
22,667
|
rhosocial/yii2-user
|
security/UserPasswordHistoryTrait.php
|
UserPasswordHistoryTrait.checkPasswordNotUsed
|
public function checkPasswordNotUsed($attribute, $params, $validator)
{
$class = $this->passwordHistoryClass;
$result = $class::isUsed($this->_password, $this);
if ($result != false) {
$this->trigger(static::$eventPasswordUsed);
$this->addError($attribute, $this->passwordUsedMessage);
}
}
|
php
|
public function checkPasswordNotUsed($attribute, $params, $validator)
{
$class = $this->passwordHistoryClass;
$result = $class::isUsed($this->_password, $this);
if ($result != false) {
$this->trigger(static::$eventPasswordUsed);
$this->addError($attribute, $this->passwordUsedMessage);
}
}
|
[
"public",
"function",
"checkPasswordNotUsed",
"(",
"$",
"attribute",
",",
"$",
"params",
",",
"$",
"validator",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"passwordHistoryClass",
";",
"$",
"result",
"=",
"$",
"class",
"::",
"isUsed",
"(",
"$",
"this",
"->",
"_password",
",",
"$",
"this",
")",
";",
"if",
"(",
"$",
"result",
"!=",
"false",
")",
"{",
"$",
"this",
"->",
"trigger",
"(",
"static",
"::",
"$",
"eventPasswordUsed",
")",
";",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"$",
"this",
"->",
"passwordUsedMessage",
")",
";",
"}",
"}"
] |
This method is only used for password hash attribute validation.
If password is used, the `eventPasswordUsed` event will be triggered.
@param string $attribute
@param mixed $params
@param type $validator
|
[
"This",
"method",
"is",
"only",
"used",
"for",
"password",
"hash",
"attribute",
"validation",
".",
"If",
"password",
"is",
"used",
"the",
"eventPasswordUsed",
"event",
"will",
"be",
"triggered",
"."
] |
96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc
|
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/security/UserPasswordHistoryTrait.php#L149-L157
|
22,668
|
surebert/surebert-framework
|
src/sb/Web/Visitor.php
|
Visitor.log
|
public function log($db=null)
{
if($db instanceof \PDO){
\sb\Web\Visitors::$db=$db;
}
return \sb\Web\Visitors::log($this);
}
|
php
|
public function log($db=null)
{
if($db instanceof \PDO){
\sb\Web\Visitors::$db=$db;
}
return \sb\Web\Visitors::log($this);
}
|
[
"public",
"function",
"log",
"(",
"$",
"db",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"db",
"instanceof",
"\\",
"PDO",
")",
"{",
"\\",
"sb",
"\\",
"Web",
"\\",
"Visitors",
"::",
"$",
"db",
"=",
"$",
"db",
";",
"}",
"return",
"\\",
"sb",
"\\",
"Web",
"\\",
"Visitors",
"::",
"log",
"(",
"$",
"this",
")",
";",
"}"
] |
Logs a \sb\Web_Visitor in the database
@param PDO $db Optional database connection to use for \sb\Web_Vistors
|
[
"Logs",
"a",
"\\",
"sb",
"\\",
"Web_Visitor",
"in",
"the",
"database"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Web/Visitor.php#L75-L84
|
22,669
|
antaresproject/notifications
|
src/Http/Breadcrumb/Breadcrumb.php
|
Breadcrumb.onList
|
protected function onList()
{
Breadcrumbs::register('notifications', function($breadcrumbs) {
$breadcrumbs->push(trans('antares/notifications::messages.notification_templates'), handles('antares::notifications/index'));
});
view()->share('breadcrumbs', Breadcrumbs::render('notifications'));
}
|
php
|
protected function onList()
{
Breadcrumbs::register('notifications', function($breadcrumbs) {
$breadcrumbs->push(trans('antares/notifications::messages.notification_templates'), handles('antares::notifications/index'));
});
view()->share('breadcrumbs', Breadcrumbs::render('notifications'));
}
|
[
"protected",
"function",
"onList",
"(",
")",
"{",
"Breadcrumbs",
"::",
"register",
"(",
"'notifications'",
",",
"function",
"(",
"$",
"breadcrumbs",
")",
"{",
"$",
"breadcrumbs",
"->",
"push",
"(",
"trans",
"(",
"'antares/notifications::messages.notification_templates'",
")",
",",
"handles",
"(",
"'antares::notifications/index'",
")",
")",
";",
"}",
")",
";",
"view",
"(",
")",
"->",
"share",
"(",
"'breadcrumbs'",
",",
"Breadcrumbs",
"::",
"render",
"(",
"'notifications'",
")",
")",
";",
"}"
] |
on list notifications
|
[
"on",
"list",
"notifications"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L32-L38
|
22,670
|
antaresproject/notifications
|
src/Http/Breadcrumb/Breadcrumb.php
|
Breadcrumb.onTable
|
public function onTable($type = null)
{
if (!is_null($type)) {
Breadcrumbs::register('notifications-' . $type, function($breadcrumbs) use($type) {
$breadcrumbs->push('Notifications ' . ucfirst($type), handles('antares::notifications/index'));
});
view()->share('breadcrumbs', Breadcrumbs::render('notifications-' . $type));
}
}
|
php
|
public function onTable($type = null)
{
if (!is_null($type)) {
Breadcrumbs::register('notifications-' . $type, function($breadcrumbs) use($type) {
$breadcrumbs->push('Notifications ' . ucfirst($type), handles('antares::notifications/index'));
});
view()->share('breadcrumbs', Breadcrumbs::render('notifications-' . $type));
}
}
|
[
"public",
"function",
"onTable",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"type",
")",
")",
"{",
"Breadcrumbs",
"::",
"register",
"(",
"'notifications-'",
".",
"$",
"type",
",",
"function",
"(",
"$",
"breadcrumbs",
")",
"use",
"(",
"$",
"type",
")",
"{",
"$",
"breadcrumbs",
"->",
"push",
"(",
"'Notifications '",
".",
"ucfirst",
"(",
"$",
"type",
")",
",",
"handles",
"(",
"'antares::notifications/index'",
")",
")",
";",
"}",
")",
";",
"view",
"(",
")",
"->",
"share",
"(",
"'breadcrumbs'",
",",
"Breadcrumbs",
"::",
"render",
"(",
"'notifications-'",
".",
"$",
"type",
")",
")",
";",
"}",
"}"
] |
when shows notifications list
@param type $type
|
[
"when",
"shows",
"notifications",
"list"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L45-L53
|
22,671
|
antaresproject/notifications
|
src/Http/Breadcrumb/Breadcrumb.php
|
Breadcrumb.onCreate
|
public function onCreate($type = null)
{
$this->onList();
Breadcrumbs::register('notification-create', function($breadcrumbs) {
$breadcrumbs->parent('notifications');
$breadcrumbs->push(trans('antares/notifications::messages.notification_templates_create'));
});
view()->share('breadcrumbs', Breadcrumbs::render('notification-create'));
}
|
php
|
public function onCreate($type = null)
{
$this->onList();
Breadcrumbs::register('notification-create', function($breadcrumbs) {
$breadcrumbs->parent('notifications');
$breadcrumbs->push(trans('antares/notifications::messages.notification_templates_create'));
});
view()->share('breadcrumbs', Breadcrumbs::render('notification-create'));
}
|
[
"public",
"function",
"onCreate",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"onList",
"(",
")",
";",
"Breadcrumbs",
"::",
"register",
"(",
"'notification-create'",
",",
"function",
"(",
"$",
"breadcrumbs",
")",
"{",
"$",
"breadcrumbs",
"->",
"parent",
"(",
"'notifications'",
")",
";",
"$",
"breadcrumbs",
"->",
"push",
"(",
"trans",
"(",
"'antares/notifications::messages.notification_templates_create'",
")",
")",
";",
"}",
")",
";",
"view",
"(",
")",
"->",
"share",
"(",
"'breadcrumbs'",
",",
"Breadcrumbs",
"::",
"render",
"(",
"'notification-create'",
")",
")",
";",
"}"
] |
when shows create new notification form
@param String $type
|
[
"when",
"shows",
"create",
"new",
"notification",
"form"
] |
60de743477b7e9cbb51de66da5fd9461adc9dd8a
|
https://github.com/antaresproject/notifications/blob/60de743477b7e9cbb51de66da5fd9461adc9dd8a/src/Http/Breadcrumb/Breadcrumb.php#L83-L91
|
22,672
|
ouropencode/dachi
|
src/Request.php
|
Request.getUri
|
public static function getUri($index, $regex = ".*") {
if(self::$uri === array())
self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));
if(isset(self::$uri_variables[$index]))
if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri_variables[$index]))
return self::$uri_variables[$index];
if(isset(self::$uri[$index]))
if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri[$index]))
return self::$uri[$index];
throw new InvalidRequestURIException;
}
|
php
|
public static function getUri($index, $regex = ".*") {
if(self::$uri === array())
self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));
if(isset(self::$uri_variables[$index]))
if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri_variables[$index]))
return self::$uri_variables[$index];
if(isset(self::$uri[$index]))
if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$uri[$index]))
return self::$uri[$index];
throw new InvalidRequestURIException;
}
|
[
"public",
"static",
"function",
"getUri",
"(",
"$",
"index",
",",
"$",
"regex",
"=",
"\".*\"",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"uri",
"===",
"array",
"(",
")",
")",
"self",
"::",
"$",
"uri",
"=",
"explode",
"(",
"\"/\"",
",",
"trim",
"(",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
",",
"\" \\t\\n\\r\\0\\x0B/\"",
")",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"uri_variables",
"[",
"$",
"index",
"]",
")",
")",
"if",
"(",
"$",
"regex",
"==",
"\".*\"",
"||",
"preg_match",
"(",
"\"/^\"",
".",
"$",
"regex",
".",
"\"$/i\"",
",",
"self",
"::",
"$",
"uri_variables",
"[",
"$",
"index",
"]",
")",
")",
"return",
"self",
"::",
"$",
"uri_variables",
"[",
"$",
"index",
"]",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"uri",
"[",
"$",
"index",
"]",
")",
")",
"if",
"(",
"$",
"regex",
"==",
"\".*\"",
"||",
"preg_match",
"(",
"\"/^\"",
".",
"$",
"regex",
".",
"\"$/i\"",
",",
"self",
"::",
"$",
"uri",
"[",
"$",
"index",
"]",
")",
")",
"return",
"self",
"::",
"$",
"uri",
"[",
"$",
"index",
"]",
";",
"throw",
"new",
"InvalidRequestURIException",
";",
"}"
] |
Get a section of the URI
The URI is split by the '/' character.
@param string $index The index to retrieve
@param string $regex The regular expression pattern the index must conform too
@throws InvalidRequestURIException The specified index was not found or did not conform to the regex.
@return string
|
[
"Get",
"a",
"section",
"of",
"the",
"URI"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L37-L51
|
22,673
|
ouropencode/dachi
|
src/Request.php
|
Request.getFullUri
|
public static function getFullUri() {
if(!isset($_GET['dachi_uri']))
$_GET['dachi_uri'] = "";
if(self::$uri === array() && isset($_GET['dachi_uri']))
self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));
return self::$uri;
}
|
php
|
public static function getFullUri() {
if(!isset($_GET['dachi_uri']))
$_GET['dachi_uri'] = "";
if(self::$uri === array() && isset($_GET['dachi_uri']))
self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));
return self::$uri;
}
|
[
"public",
"static",
"function",
"getFullUri",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
")",
")",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
"=",
"\"\"",
";",
"if",
"(",
"self",
"::",
"$",
"uri",
"===",
"array",
"(",
")",
"&&",
"isset",
"(",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
")",
")",
"self",
"::",
"$",
"uri",
"=",
"explode",
"(",
"\"/\"",
",",
"trim",
"(",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
",",
"\" \\t\\n\\r\\0\\x0B/\"",
")",
")",
";",
"return",
"self",
"::",
"$",
"uri",
";",
"}"
] |
Get the whole URI
The URI is split by the '/' character.
@return array
|
[
"Get",
"the",
"whole",
"URI"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L60-L68
|
22,674
|
ouropencode/dachi
|
src/Request.php
|
Request.setRequestVariables
|
public static function setRequestVariables($uri_variables, $api_mode = false) {
if(self::$uri === array() && isset($_GET['dachi_uri']))
self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));
foreach($uri_variables as $var)
self::$uri_variables[$var[1]] = self::$uri[$var[0]];
self::$api_mode = $api_mode;
}
|
php
|
public static function setRequestVariables($uri_variables, $api_mode = false) {
if(self::$uri === array() && isset($_GET['dachi_uri']))
self::$uri = explode("/", trim($_GET['dachi_uri'], " \t\n\r\0\x0B/"));
foreach($uri_variables as $var)
self::$uri_variables[$var[1]] = self::$uri[$var[0]];
self::$api_mode = $api_mode;
}
|
[
"public",
"static",
"function",
"setRequestVariables",
"(",
"$",
"uri_variables",
",",
"$",
"api_mode",
"=",
"false",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"uri",
"===",
"array",
"(",
")",
"&&",
"isset",
"(",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
")",
")",
"self",
"::",
"$",
"uri",
"=",
"explode",
"(",
"\"/\"",
",",
"trim",
"(",
"$",
"_GET",
"[",
"'dachi_uri'",
"]",
",",
"\" \\t\\n\\r\\0\\x0B/\"",
")",
")",
";",
"foreach",
"(",
"$",
"uri_variables",
"as",
"$",
"var",
")",
"self",
"::",
"$",
"uri_variables",
"[",
"$",
"var",
"[",
"1",
"]",
"]",
"=",
"self",
"::",
"$",
"uri",
"[",
"$",
"var",
"[",
"0",
"]",
"]",
";",
"self",
"::",
"$",
"api_mode",
"=",
"$",
"api_mode",
";",
"}"
] |
Set the variable mapping for URI componants.
This is an internal function that allows the Router to assign the URI variables.
@internal
@see Router
@param array $uri_variables Format: array(array(uri index, variable name))
@param bool $api_mode Is this request serving an API method.
|
[
"Set",
"the",
"variable",
"mapping",
"for",
"URI",
"componants",
"."
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L80-L88
|
22,675
|
ouropencode/dachi
|
src/Request.php
|
Request.getArgument
|
public static function getArgument($key, $default = "default", $regex = ".*") {
if(self::$arguments === array())
self::$arguments = array_merge($_GET, $_POST, $_FILES);
if(isset(self::$arguments[$key])) {
if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$arguments[$key]))
return self::$arguments[$key];
throw new InvalidRequestArgumentException;
}
return $default;
}
|
php
|
public static function getArgument($key, $default = "default", $regex = ".*") {
if(self::$arguments === array())
self::$arguments = array_merge($_GET, $_POST, $_FILES);
if(isset(self::$arguments[$key])) {
if($regex == ".*" || preg_match("/^" . $regex . "$/i", self::$arguments[$key]))
return self::$arguments[$key];
throw new InvalidRequestArgumentException;
}
return $default;
}
|
[
"public",
"static",
"function",
"getArgument",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"\"default\"",
",",
"$",
"regex",
"=",
"\".*\"",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"arguments",
"===",
"array",
"(",
")",
")",
"self",
"::",
"$",
"arguments",
"=",
"array_merge",
"(",
"$",
"_GET",
",",
"$",
"_POST",
",",
"$",
"_FILES",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"arguments",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"$",
"regex",
"==",
"\".*\"",
"||",
"preg_match",
"(",
"\"/^\"",
".",
"$",
"regex",
".",
"\"$/i\"",
",",
"self",
"::",
"$",
"arguments",
"[",
"$",
"key",
"]",
")",
")",
"return",
"self",
"::",
"$",
"arguments",
"[",
"$",
"key",
"]",
";",
"throw",
"new",
"InvalidRequestArgumentException",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Get an argument passed to the page
This is used for _GET, _POST and _FILES.
@param string $key The key to retrieve
@param string $default The default value to return if the key was not found
@param string $regex The regular expression pattern the key must conform too
@throws InvalidRequestArgumentException The specified key did not conform to the regex.
@return string
|
[
"Get",
"an",
"argument",
"passed",
"to",
"the",
"page"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L127-L139
|
22,676
|
ouropencode/dachi
|
src/Request.php
|
Request.getAllArguments
|
public static function getAllArguments() {
if(self::$arguments === array())
self::$arguments = array_merge($_GET, $_POST, $_FILES);
return self::$arguments;
}
|
php
|
public static function getAllArguments() {
if(self::$arguments === array())
self::$arguments = array_merge($_GET, $_POST, $_FILES);
return self::$arguments;
}
|
[
"public",
"static",
"function",
"getAllArguments",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"arguments",
"===",
"array",
"(",
")",
")",
"self",
"::",
"$",
"arguments",
"=",
"array_merge",
"(",
"$",
"_GET",
",",
"$",
"_POST",
",",
"$",
"_FILES",
")",
";",
"return",
"self",
"::",
"$",
"arguments",
";",
"}"
] |
Get all arguments passed to the page
This is used for _GET, _POST and _FILES.
@return string
|
[
"Get",
"all",
"arguments",
"passed",
"to",
"the",
"page"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L148-L153
|
22,677
|
ouropencode/dachi
|
src/Request.php
|
Request.setCookie
|
public static function setCookie($key, $value, $expire = -1, $path = "/", $domain = null) {
if($expire == -1)
$expire = time() + 2592000; // 30 days
return setcookie($key, $value, $expire, $path, $domain);
}
|
php
|
public static function setCookie($key, $value, $expire = -1, $path = "/", $domain = null) {
if($expire == -1)
$expire = time() + 2592000; // 30 days
return setcookie($key, $value, $expire, $path, $domain);
}
|
[
"public",
"static",
"function",
"setCookie",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expire",
"=",
"-",
"1",
",",
"$",
"path",
"=",
"\"/\"",
",",
"$",
"domain",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"expire",
"==",
"-",
"1",
")",
"$",
"expire",
"=",
"time",
"(",
")",
"+",
"2592000",
";",
"// 30 days",
"return",
"setcookie",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expire",
",",
"$",
"path",
",",
"$",
"domain",
")",
";",
"}"
] |
Set a value in the user's cookie
@param string $key The key to set
@param string $value The value to set
@param integer $expire The time to expire (defaults to -1, -1 is 'now + 30 days')
@param string $path The cookie path inside the domain (defaults to '/')
@param string $domain The domain this cookie is assigned to (defaults to server default)
@return bool
|
[
"Set",
"a",
"value",
"in",
"the",
"user",
"s",
"cookie"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L203-L208
|
22,678
|
ouropencode/dachi
|
src/Request.php
|
Request.getData
|
public static function getData($key) {
if(!isset(self::$output_data[$key]))
return false;
return self::$output_data[$key];
}
|
php
|
public static function getData($key) {
if(!isset(self::$output_data[$key]))
return false;
return self::$output_data[$key];
}
|
[
"public",
"static",
"function",
"getData",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"output_data",
"[",
"$",
"key",
"]",
")",
")",
"return",
"false",
";",
"return",
"self",
"::",
"$",
"output_data",
"[",
"$",
"key",
"]",
";",
"}"
] |
Get an outgoing request data variable
@param string $key The key to get
@return mixed
|
[
"Get",
"an",
"outgoing",
"request",
"data",
"variable"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L215-L220
|
22,679
|
ouropencode/dachi
|
src/Request.php
|
Request.isAjax
|
public static function isAjax() {
if(Configuration::get("dachi.api-mode", false) == true)
return true;
return (self::getArgument("dachi-ui", "false") == "true" || self::getArgument("radon-ui-ajax", "false") == "true");
}
|
php
|
public static function isAjax() {
if(Configuration::get("dachi.api-mode", false) == true)
return true;
return (self::getArgument("dachi-ui", "false") == "true" || self::getArgument("radon-ui-ajax", "false") == "true");
}
|
[
"public",
"static",
"function",
"isAjax",
"(",
")",
"{",
"if",
"(",
"Configuration",
"::",
"get",
"(",
"\"dachi.api-mode\"",
",",
"false",
")",
"==",
"true",
")",
"return",
"true",
";",
"return",
"(",
"self",
"::",
"getArgument",
"(",
"\"dachi-ui\"",
",",
"\"false\"",
")",
"==",
"\"true\"",
"||",
"self",
"::",
"getArgument",
"(",
"\"radon-ui-ajax\"",
",",
"\"false\"",
")",
"==",
"\"true\"",
")",
";",
"}"
] |
Check if this request is being served via ajax
@return bool
|
[
"Check",
"if",
"this",
"request",
"is",
"being",
"served",
"via",
"ajax"
] |
a0e1daf269d0345afbb859ce20ef9da6decd7efe
|
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Request.php#L274-L279
|
22,680
|
openclerk/db
|
src/Migration.php
|
Migration.install
|
function install(Connection $db, Logger $log) {
// bail if we've already applied
if ($this->isApplied($db)) {
$log->info("Skipping " . $this->getName() . ": already applied");
return;
}
// simply make sure all parent migrations are applied
foreach ($this->getParents() as $migration) {
$migration->install($db, $log);
}
// check we have a valid name
if (strlen($this->getName()) == 0 || strlen($this->getName()) > 255) {
throw new DbException("Invalid migration name '" . $this->getName() . "'");
}
// and then install our own
try {
$log->info("Applying " . $this->getName());
if ($this->apply($db)) {
$log->info("Applied migration " . $this->getName());
} else {
$log->error("Could not apply migration '" . $this->getName() . "': " . $db->lastError());
throw new DbException("Could not apply migration " . $this->getName());
}
} catch (DbException $e) {
$log->error("Could not apply migration '" . $this->getName() . "': " . $e->getMessage());
throw new DbException("Could not apply migration " . $this->getName(), $e);
}
// save migration status
$q = $db->prepare("INSERT INTO migrations SET name=?");
$q->execute(array($this->getName()));
}
|
php
|
function install(Connection $db, Logger $log) {
// bail if we've already applied
if ($this->isApplied($db)) {
$log->info("Skipping " . $this->getName() . ": already applied");
return;
}
// simply make sure all parent migrations are applied
foreach ($this->getParents() as $migration) {
$migration->install($db, $log);
}
// check we have a valid name
if (strlen($this->getName()) == 0 || strlen($this->getName()) > 255) {
throw new DbException("Invalid migration name '" . $this->getName() . "'");
}
// and then install our own
try {
$log->info("Applying " . $this->getName());
if ($this->apply($db)) {
$log->info("Applied migration " . $this->getName());
} else {
$log->error("Could not apply migration '" . $this->getName() . "': " . $db->lastError());
throw new DbException("Could not apply migration " . $this->getName());
}
} catch (DbException $e) {
$log->error("Could not apply migration '" . $this->getName() . "': " . $e->getMessage());
throw new DbException("Could not apply migration " . $this->getName(), $e);
}
// save migration status
$q = $db->prepare("INSERT INTO migrations SET name=?");
$q->execute(array($this->getName()));
}
|
[
"function",
"install",
"(",
"Connection",
"$",
"db",
",",
"Logger",
"$",
"log",
")",
"{",
"// bail if we've already applied",
"if",
"(",
"$",
"this",
"->",
"isApplied",
"(",
"$",
"db",
")",
")",
"{",
"$",
"log",
"->",
"info",
"(",
"\"Skipping \"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"\": already applied\"",
")",
";",
"return",
";",
"}",
"// simply make sure all parent migrations are applied",
"foreach",
"(",
"$",
"this",
"->",
"getParents",
"(",
")",
"as",
"$",
"migration",
")",
"{",
"$",
"migration",
"->",
"install",
"(",
"$",
"db",
",",
"$",
"log",
")",
";",
"}",
"// check we have a valid name",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"==",
"0",
"||",
"strlen",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
">",
"255",
")",
"{",
"throw",
"new",
"DbException",
"(",
"\"Invalid migration name '\"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"\"'\"",
")",
";",
"}",
"// and then install our own",
"try",
"{",
"$",
"log",
"->",
"info",
"(",
"\"Applying \"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"apply",
"(",
"$",
"db",
")",
")",
"{",
"$",
"log",
"->",
"info",
"(",
"\"Applied migration \"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"log",
"->",
"error",
"(",
"\"Could not apply migration '\"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"\"': \"",
".",
"$",
"db",
"->",
"lastError",
"(",
")",
")",
";",
"throw",
"new",
"DbException",
"(",
"\"Could not apply migration \"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"DbException",
"$",
"e",
")",
"{",
"$",
"log",
"->",
"error",
"(",
"\"Could not apply migration '\"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"\"': \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"new",
"DbException",
"(",
"\"Could not apply migration \"",
".",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"// save migration status",
"$",
"q",
"=",
"$",
"db",
"->",
"prepare",
"(",
"\"INSERT INTO migrations SET name=?\"",
")",
";",
"$",
"q",
"->",
"execute",
"(",
"array",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] |
Install the current migration and any parent migrations that this migration depends on.
|
[
"Install",
"the",
"current",
"migration",
"and",
"any",
"parent",
"migrations",
"that",
"this",
"migration",
"depends",
"on",
"."
] |
923275ed6e9414d8952585b77331c28dbd032bac
|
https://github.com/openclerk/db/blob/923275ed6e9414d8952585b77331c28dbd032bac/src/Migration.php#L69-L103
|
22,681
|
accompli/chrono
|
src/Adapter/SubversionAdapter.php
|
SubversionAdapter.getRepositoryUrlWithVersionPath
|
private function getRepositoryUrlWithVersionPath($version)
{
$repositoryUrl = $this->repositoryUrl;
if (in_array($version, array('master', $this->trunkPath))) {
$repositoryUrl .= '/'.$this->trunkPath;
} elseif (in_array($version, $this->getBranches())) {
$repositoryUrl .= '/'.$this->branchesPath.'/'.$version;
} elseif (in_array($version, $this->getTags())) {
$repositoryUrl .= '/'.$this->tagsPath.'/'.$version;
} else {
return false;
}
return ProcessUtils::escapeArgument($repositoryUrl);
}
|
php
|
private function getRepositoryUrlWithVersionPath($version)
{
$repositoryUrl = $this->repositoryUrl;
if (in_array($version, array('master', $this->trunkPath))) {
$repositoryUrl .= '/'.$this->trunkPath;
} elseif (in_array($version, $this->getBranches())) {
$repositoryUrl .= '/'.$this->branchesPath.'/'.$version;
} elseif (in_array($version, $this->getTags())) {
$repositoryUrl .= '/'.$this->tagsPath.'/'.$version;
} else {
return false;
}
return ProcessUtils::escapeArgument($repositoryUrl);
}
|
[
"private",
"function",
"getRepositoryUrlWithVersionPath",
"(",
"$",
"version",
")",
"{",
"$",
"repositoryUrl",
"=",
"$",
"this",
"->",
"repositoryUrl",
";",
"if",
"(",
"in_array",
"(",
"$",
"version",
",",
"array",
"(",
"'master'",
",",
"$",
"this",
"->",
"trunkPath",
")",
")",
")",
"{",
"$",
"repositoryUrl",
".=",
"'/'",
".",
"$",
"this",
"->",
"trunkPath",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"getBranches",
"(",
")",
")",
")",
"{",
"$",
"repositoryUrl",
".=",
"'/'",
".",
"$",
"this",
"->",
"branchesPath",
".",
"'/'",
".",
"$",
"version",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"version",
",",
"$",
"this",
"->",
"getTags",
"(",
")",
")",
")",
"{",
"$",
"repositoryUrl",
".=",
"'/'",
".",
"$",
"this",
"->",
"tagsPath",
".",
"'/'",
".",
"$",
"version",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"return",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"$",
"repositoryUrl",
")",
";",
"}"
] |
Returns the escaped repository URL with version path.
Returns false when the repository URL for a version cannot be found.
@param string $version
@return string|bool
|
[
"Returns",
"the",
"escaped",
"repository",
"URL",
"with",
"version",
"path",
".",
"Returns",
"false",
"when",
"the",
"repository",
"URL",
"for",
"a",
"version",
"cannot",
"be",
"found",
"."
] |
5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc
|
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Adapter/SubversionAdapter.php#L145-L159
|
22,682
|
web2all/framework
|
src/Web2All/Email/MimeMail.class.php
|
Web2All_Email_MimeMail.build_message
|
private function build_message($part) {
$message = $part[ "message"];
// #### only base64 encoding supported
// #### other encodings you have to encode yourself
if ($part[ "encode"] == "base64"){
$message = chunk_split(base64_encode($message));
}else if ($part[ "encode"] == "quoted-printable"){
$message = $this->encode_qp($message);
}
return "Content-Type: ".$part[ "ctype"].
($part[ "charset"]? "; charset = \"".$part[ "charset"]. "\"" : "").
($part[ "name"]? "; name = \"".$part[ "name"]. "\"" : "").
(empty($part[ "encode"])? "" : "\nContent-Transfer-Encoding: ".$part[ "encode"] ).
(empty($part[ "contentid"])? "" : "\nContent-ID: ".$part[ "contentid"] ).
((empty($part["contentid"])&&($part["name"]))? "\nContent-Disposition: attachment; filename=\"".$part["name"].'"' : '' ).
"\n\n$message\n";
}
|
php
|
private function build_message($part) {
$message = $part[ "message"];
// #### only base64 encoding supported
// #### other encodings you have to encode yourself
if ($part[ "encode"] == "base64"){
$message = chunk_split(base64_encode($message));
}else if ($part[ "encode"] == "quoted-printable"){
$message = $this->encode_qp($message);
}
return "Content-Type: ".$part[ "ctype"].
($part[ "charset"]? "; charset = \"".$part[ "charset"]. "\"" : "").
($part[ "name"]? "; name = \"".$part[ "name"]. "\"" : "").
(empty($part[ "encode"])? "" : "\nContent-Transfer-Encoding: ".$part[ "encode"] ).
(empty($part[ "contentid"])? "" : "\nContent-ID: ".$part[ "contentid"] ).
((empty($part["contentid"])&&($part["name"]))? "\nContent-Disposition: attachment; filename=\"".$part["name"].'"' : '' ).
"\n\n$message\n";
}
|
[
"private",
"function",
"build_message",
"(",
"$",
"part",
")",
"{",
"$",
"message",
"=",
"$",
"part",
"[",
"\"message\"",
"]",
";",
"// #### only base64 encoding supported",
"// #### other encodings you have to encode yourself",
"if",
"(",
"$",
"part",
"[",
"\"encode\"",
"]",
"==",
"\"base64\"",
")",
"{",
"$",
"message",
"=",
"chunk_split",
"(",
"base64_encode",
"(",
"$",
"message",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"part",
"[",
"\"encode\"",
"]",
"==",
"\"quoted-printable\"",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"encode_qp",
"(",
"$",
"message",
")",
";",
"}",
"return",
"\"Content-Type: \"",
".",
"$",
"part",
"[",
"\"ctype\"",
"]",
".",
"(",
"$",
"part",
"[",
"\"charset\"",
"]",
"?",
"\"; charset = \\\"\"",
".",
"$",
"part",
"[",
"\"charset\"",
"]",
".",
"\"\\\"\"",
":",
"\"\"",
")",
".",
"(",
"$",
"part",
"[",
"\"name\"",
"]",
"?",
"\"; name = \\\"\"",
".",
"$",
"part",
"[",
"\"name\"",
"]",
".",
"\"\\\"\"",
":",
"\"\"",
")",
".",
"(",
"empty",
"(",
"$",
"part",
"[",
"\"encode\"",
"]",
")",
"?",
"\"\"",
":",
"\"\\nContent-Transfer-Encoding: \"",
".",
"$",
"part",
"[",
"\"encode\"",
"]",
")",
".",
"(",
"empty",
"(",
"$",
"part",
"[",
"\"contentid\"",
"]",
")",
"?",
"\"\"",
":",
"\"\\nContent-ID: \"",
".",
"$",
"part",
"[",
"\"contentid\"",
"]",
")",
".",
"(",
"(",
"empty",
"(",
"$",
"part",
"[",
"\"contentid\"",
"]",
")",
"&&",
"(",
"$",
"part",
"[",
"\"name\"",
"]",
")",
")",
"?",
"\"\\nContent-Disposition: attachment; filename=\\\"\"",
".",
"$",
"part",
"[",
"\"name\"",
"]",
".",
"'\"'",
":",
"''",
")",
".",
"\"\\n\\n$message\\n\"",
";",
"}"
] |
void build_message(array part=
Build message parts of an multipart mail
NOTE: base64 encoding messages will be encoded
automaticly my the class. all others will not.
|
[
"void",
"build_message",
"(",
"array",
"part",
"=",
"Build",
"message",
"parts",
"of",
"an",
"multipart",
"mail"
] |
6990dc3700efad3207ec6e710124f7ba18891b31
|
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L149-L165
|
22,683
|
web2all/framework
|
src/Web2All/Email/MimeMail.class.php
|
Web2All_Email_MimeMail.encodeSubject
|
function encodeSubject($input, $charset = 'ISO-8859-1')
{
// set the internal encoding to the encoding of the given input
// this way no conversion is done, because we only need the 'Q' encoding
$old_enc=mb_internal_encoding();
mb_internal_encoding($charset);
$output=mb_encode_mimeheader($input,$charset, 'Q', $this->LE);
// and when ready, restore the internal encoding again
mb_internal_encoding($old_enc);
return $output;
// below is a fallback mechanism which seems to work also
/*
preg_match_all('/(\\w*[\\x80-\\xFF]+\\w*)/', $input, $matches);
foreach ($matches[1] as $value) {
$replacement = preg_replace('/([\\x80-\\xFF])/e', '"=" . strtoupper(dechex(ord("\\1")))', $value);
$input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input);
}
return $input;
*/
}
|
php
|
function encodeSubject($input, $charset = 'ISO-8859-1')
{
// set the internal encoding to the encoding of the given input
// this way no conversion is done, because we only need the 'Q' encoding
$old_enc=mb_internal_encoding();
mb_internal_encoding($charset);
$output=mb_encode_mimeheader($input,$charset, 'Q', $this->LE);
// and when ready, restore the internal encoding again
mb_internal_encoding($old_enc);
return $output;
// below is a fallback mechanism which seems to work also
/*
preg_match_all('/(\\w*[\\x80-\\xFF]+\\w*)/', $input, $matches);
foreach ($matches[1] as $value) {
$replacement = preg_replace('/([\\x80-\\xFF])/e', '"=" . strtoupper(dechex(ord("\\1")))', $value);
$input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input);
}
return $input;
*/
}
|
[
"function",
"encodeSubject",
"(",
"$",
"input",
",",
"$",
"charset",
"=",
"'ISO-8859-1'",
")",
"{",
"// set the internal encoding to the encoding of the given input",
"// this way no conversion is done, because we only need the 'Q' encoding",
"$",
"old_enc",
"=",
"mb_internal_encoding",
"(",
")",
";",
"mb_internal_encoding",
"(",
"$",
"charset",
")",
";",
"$",
"output",
"=",
"mb_encode_mimeheader",
"(",
"$",
"input",
",",
"$",
"charset",
",",
"'Q'",
",",
"$",
"this",
"->",
"LE",
")",
";",
"// and when ready, restore the internal encoding again",
"mb_internal_encoding",
"(",
"$",
"old_enc",
")",
";",
"return",
"$",
"output",
";",
"// below is a fallback mechanism which seems to work also",
"/*\n preg_match_all('/(\\\\w*[\\\\x80-\\\\xFF]+\\\\w*)/', $input, $matches);\n foreach ($matches[1] as $value) {\n $replacement = preg_replace('/([\\\\x80-\\\\xFF])/e', '\"=\" . strtoupper(dechex(ord(\"\\\\1\")))', $value);\n $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input);\n }\n return $input;\n */",
"}"
] |
The method can be used to encode the subject which is
in a non ascii encoding.
encoding style: =?charset?Q?the encoded text?=
@param string $input
@param string $charset eg. UTF-8 or ISO-8859-1
@return string the encoded subject
|
[
"The",
"method",
"can",
"be",
"used",
"to",
"encode",
"the",
"subject",
"which",
"is",
"in",
"a",
"non",
"ascii",
"encoding",
"."
] |
6990dc3700efad3207ec6e710124f7ba18891b31
|
https://github.com/web2all/framework/blob/6990dc3700efad3207ec6e710124f7ba18891b31/src/Web2All/Email/MimeMail.class.php#L455-L474
|
22,684
|
42mate/towel
|
src/Towel/Cache/TowelMemcached.php
|
TowelMemcached.setOptions
|
public function setOptions($options)
{
// Adding hosts.
if (!empty($options['hosts'])) {
foreach ($options['hosts'] as $host => $port) {
$this->addserver($host, $port, false);
}
} else {
$this->addserver('127.0.0.1', '11211', false);
}
}
|
php
|
public function setOptions($options)
{
// Adding hosts.
if (!empty($options['hosts'])) {
foreach ($options['hosts'] as $host => $port) {
$this->addserver($host, $port, false);
}
} else {
$this->addserver('127.0.0.1', '11211', false);
}
}
|
[
"public",
"function",
"setOptions",
"(",
"$",
"options",
")",
"{",
"// Adding hosts.",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'hosts'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"[",
"'hosts'",
"]",
"as",
"$",
"host",
"=>",
"$",
"port",
")",
"{",
"$",
"this",
"->",
"addserver",
"(",
"$",
"host",
",",
"$",
"port",
",",
"false",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addserver",
"(",
"'127.0.0.1'",
",",
"'11211'",
",",
"false",
")",
";",
"}",
"}"
] |
Stablish Memcached options defined in config.php
@param $options
|
[
"Stablish",
"Memcached",
"options",
"defined",
"in",
"config",
".",
"php"
] |
5316c3075fc844e8a5cbae113712b26556227dff
|
https://github.com/42mate/towel/blob/5316c3075fc844e8a5cbae113712b26556227dff/src/Towel/Cache/TowelMemcached.php#L11-L21
|
22,685
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.match
|
public function match(string $variable = null, array $labels = []): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\MatchClause(
Clause\Expression\Path::startWithNode($variable, $labels)
)
);
return $query;
}
|
php
|
public function match(string $variable = null, array $labels = []): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\MatchClause(
Clause\Expression\Path::startWithNode($variable, $labels)
)
);
return $query;
}
|
[
"public",
"function",
"match",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"MatchClause",
"(",
"Clause",
"\\",
"Expression",
"\\",
"Path",
"::",
"startWithNode",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Match the given node
@param string $variable
@param array $labels
@return self
|
[
"Match",
"the",
"given",
"node"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L105-L115
|
22,686
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.maybeMatch
|
public function maybeMatch(string $variable = null, array $labels = []): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\OptionalMatchClause(
Clause\Expression\Path::startWithNode($variable, $labels)
)
);
return $query;
}
|
php
|
public function maybeMatch(string $variable = null, array $labels = []): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\OptionalMatchClause(
Clause\Expression\Path::startWithNode($variable, $labels)
)
);
return $query;
}
|
[
"public",
"function",
"maybeMatch",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"OptionalMatchClause",
"(",
"Clause",
"\\",
"Expression",
"\\",
"Path",
"::",
"startWithNode",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a OPTIONAL MATCh clause
@param string $variable
@param array $labels
@return self
|
[
"Add",
"a",
"OPTIONAL",
"MATCh",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L125-L135
|
22,687
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.withParameter
|
public function withParameter(string $key, $parameter): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\Parametrable) {
throw new NonParametrableClause;
}
$clause = $clause->withParameter($key, $parameter);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
php
|
public function withParameter(string $key, $parameter): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\Parametrable) {
throw new NonParametrableClause;
}
$clause = $clause->withParameter($key, $parameter);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
[
"public",
"function",
"withParameter",
"(",
"string",
"$",
"key",
",",
"$",
"parameter",
")",
":",
"self",
"{",
"$",
"clause",
"=",
"$",
"this",
"->",
"clauses",
"->",
"last",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clause",
"instanceof",
"Clause",
"\\",
"Parametrable",
")",
"{",
"throw",
"new",
"NonParametrableClause",
";",
"}",
"$",
"clause",
"=",
"$",
"clause",
"->",
"withParameter",
"(",
"$",
"key",
",",
"$",
"parameter",
")",
";",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"clause",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Attach the given parameter to the last clause
@param string $key
@param mixed $parameter
@throws NonParametrableClause
@return self
|
[
"Attach",
"the",
"given",
"parameter",
"to",
"the",
"last",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L167-L183
|
22,688
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.withProperties
|
public function withProperties(array $properties): self
{
$query = $this;
foreach ($properties as $property => $cypher) {
$query = $query->withProperty($property, $cypher);
}
return $query;
}
|
php
|
public function withProperties(array $properties): self
{
$query = $this;
foreach ($properties as $property => $cypher) {
$query = $query->withProperty($property, $cypher);
}
return $query;
}
|
[
"public",
"function",
"withProperties",
"(",
"array",
"$",
"properties",
")",
":",
"self",
"{",
"$",
"query",
"=",
"$",
"this",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
"=>",
"$",
"cypher",
")",
"{",
"$",
"query",
"=",
"$",
"query",
"->",
"withProperty",
"(",
"$",
"property",
",",
"$",
"cypher",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Specify a set of properties to be matched
@param array $properties
@throws NonPathAwareClause
@return self
|
[
"Specify",
"a",
"set",
"of",
"properties",
"to",
"be",
"matched"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L194-L203
|
22,689
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.withProperty
|
public function withProperty(string $property, string $cypher): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->withProperty($property, $cypher);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
php
|
public function withProperty(string $property, string $cypher): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->withProperty($property, $cypher);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
[
"public",
"function",
"withProperty",
"(",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"clause",
"=",
"$",
"this",
"->",
"clauses",
"->",
"last",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clause",
"instanceof",
"Clause",
"\\",
"PathAware",
")",
"{",
"throw",
"new",
"NonPathAwareClause",
";",
"}",
"$",
"clause",
"=",
"$",
"clause",
"->",
"withProperty",
"(",
"$",
"property",
",",
"$",
"cypher",
")",
";",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"clause",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Specify a property to be matched
@param string $property
@param string $cypher
@throws NonPathAwareClause
@return self
|
[
"Specify",
"a",
"property",
"to",
"be",
"matched"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L215-L231
|
22,690
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.linkedTo
|
public function linkedTo(string $variable = null, array $labels = []): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->linkedTo($variable, $labels);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
php
|
public function linkedTo(string $variable = null, array $labels = []): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->linkedTo($variable, $labels);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
[
"public",
"function",
"linkedTo",
"(",
"string",
"$",
"variable",
"=",
"null",
",",
"array",
"$",
"labels",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"clause",
"=",
"$",
"this",
"->",
"clauses",
"->",
"last",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clause",
"instanceof",
"Clause",
"\\",
"PathAware",
")",
"{",
"throw",
"new",
"NonPathAwareClause",
";",
"}",
"$",
"clause",
"=",
"$",
"clause",
"->",
"linkedTo",
"(",
"$",
"variable",
",",
"$",
"labels",
")",
";",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"clause",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Match the node linked to the previous declared node match
@param string $variable
@param array $labels
@throws NonPathAwareClause
@return self
|
[
"Match",
"the",
"node",
"linked",
"to",
"the",
"previous",
"declared",
"node",
"match"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L243-L259
|
22,691
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.through
|
public function through(
string $type,
string $variable = null,
string $direction = 'BOTH'
): self {
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->through($variable, $type, $direction);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
php
|
public function through(
string $type,
string $variable = null,
string $direction = 'BOTH'
): self {
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->through($variable, $type, $direction);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
[
"public",
"function",
"through",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"variable",
"=",
"null",
",",
"string",
"$",
"direction",
"=",
"'BOTH'",
")",
":",
"self",
"{",
"$",
"clause",
"=",
"$",
"this",
"->",
"clauses",
"->",
"last",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clause",
"instanceof",
"Clause",
"\\",
"PathAware",
")",
"{",
"throw",
"new",
"NonPathAwareClause",
";",
"}",
"$",
"clause",
"=",
"$",
"clause",
"->",
"through",
"(",
"$",
"variable",
",",
"$",
"type",
",",
"$",
"direction",
")",
";",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"clause",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Specify the type of relationship for the last match clause
@param string $type
@param string $variable
@param string $direction
@throws NonPathAwareClause
@return self
|
[
"Specify",
"the",
"type",
"of",
"relationship",
"for",
"the",
"last",
"match",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L272-L291
|
22,692
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.withADistanceOf
|
public function withADistanceOf(int $distance): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->withADistanceOf($distance);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
php
|
public function withADistanceOf(int $distance): self
{
$clause = $this->clauses->last();
if (!$clause instanceof Clause\PathAware) {
throw new NonPathAwareClause;
}
$clause = $clause->withADistanceOf($distance);
$query = new self;
$query->clauses = $this
->clauses
->dropEnd(1)
->add($clause);
return $query;
}
|
[
"public",
"function",
"withADistanceOf",
"(",
"int",
"$",
"distance",
")",
":",
"self",
"{",
"$",
"clause",
"=",
"$",
"this",
"->",
"clauses",
"->",
"last",
"(",
")",
";",
"if",
"(",
"!",
"$",
"clause",
"instanceof",
"Clause",
"\\",
"PathAware",
")",
"{",
"throw",
"new",
"NonPathAwareClause",
";",
"}",
"$",
"clause",
"=",
"$",
"clause",
"->",
"withADistanceOf",
"(",
"$",
"distance",
")",
";",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"dropEnd",
"(",
"1",
")",
"->",
"add",
"(",
"$",
"clause",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Define the deepness of the relationship
@param int $distance
@throws LogicException If no relationship in the path
@return self
|
[
"Define",
"the",
"deepness",
"of",
"the",
"relationship"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L302-L318
|
22,693
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.with
|
public function with(string ...$variables): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\WithClause(...$variables)
);
return $query;
}
|
php
|
public function with(string ...$variables): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\WithClause(...$variables)
);
return $query;
}
|
[
"public",
"function",
"with",
"(",
"string",
"...",
"$",
"variables",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"WithClause",
"(",
"...",
"$",
"variables",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a WITH clause
@param string[] $variables
@return self
|
[
"Add",
"a",
"WITH",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L436-L444
|
22,694
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.where
|
public function where(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\WhereClause($cypher)
);
return $query;
}
|
php
|
public function where(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\WhereClause($cypher)
);
return $query;
}
|
[
"public",
"function",
"where",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"WhereClause",
"(",
"$",
"cypher",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a WHERE clause
@param string $cypher
@return self
|
[
"Add",
"a",
"WHERE",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L453-L461
|
22,695
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.set
|
public function set(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\SetClause($cypher)
);
return $query;
}
|
php
|
public function set(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\SetClause($cypher)
);
return $query;
}
|
[
"public",
"function",
"set",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"SetClause",
"(",
"$",
"cypher",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a SET clause
@param string $cypher
@return self
|
[
"Add",
"a",
"SET",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L470-L478
|
22,696
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.using
|
public function using(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\UsingClause($cypher)
);
return $query;
}
|
php
|
public function using(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\UsingClause($cypher)
);
return $query;
}
|
[
"public",
"function",
"using",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"UsingClause",
"(",
"$",
"cypher",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a USING clause
@param string $cypher
@return self
|
[
"Add",
"a",
"USING",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L487-L495
|
22,697
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.unwind
|
public function unwind(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\UnwindClause($cypher)
);
return $query;
}
|
php
|
public function unwind(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\UnwindClause($cypher)
);
return $query;
}
|
[
"public",
"function",
"unwind",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"UnwindClause",
"(",
"$",
"cypher",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a UNWIND clause
@param string $cypher
@return self
|
[
"Add",
"a",
"UNWIND",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L504-L512
|
22,698
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.union
|
public function union(): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\UnionClause
);
return $query;
}
|
php
|
public function union(): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\UnionClause
);
return $query;
}
|
[
"public",
"function",
"union",
"(",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"UnionClause",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a UNION clause
@return self
|
[
"Add",
"a",
"UNION",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L519-L527
|
22,699
|
Innmind/neo4j-dbal
|
src/Query/Query.php
|
Query.skip
|
public function skip(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\SkipClause($cypher)
);
return $query;
}
|
php
|
public function skip(string $cypher): self
{
$query = new self;
$query->clauses = $this->clauses->add(
new Clause\SkipClause($cypher)
);
return $query;
}
|
[
"public",
"function",
"skip",
"(",
"string",
"$",
"cypher",
")",
":",
"self",
"{",
"$",
"query",
"=",
"new",
"self",
";",
"$",
"query",
"->",
"clauses",
"=",
"$",
"this",
"->",
"clauses",
"->",
"add",
"(",
"new",
"Clause",
"\\",
"SkipClause",
"(",
"$",
"cypher",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add a SKIP clause
@see http://neo4j.com/docs/stable/query-skip.html#skip-skip-first-from-expression
@param string $cypher Of type string as it may contain operations
@return self
|
[
"Add",
"a",
"SKIP",
"clause"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Query.php#L537-L545
|
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.