repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
zircote/AMQP | library/AMQP/Connection.php | Connection._close | protected function _close(Reader $args)
{
$replyCode = $args->readShort();
$replyText = $args->readShortstr();
$classId = $args->readShort();
$methodId = $args->readShort();
$this->xCloseOk();
throw new ConnectionException(
$replyCode, $replyText, array(
$classId,
$methodId
)
);
} | php | protected function _close(Reader $args)
{
$replyCode = $args->readShort();
$replyText = $args->readShortstr();
$classId = $args->readShort();
$methodId = $args->readShort();
$this->xCloseOk();
throw new ConnectionException(
$replyCode, $replyText, array(
$classId,
$methodId
)
);
} | [
"protected",
"function",
"_close",
"(",
"Reader",
"$",
"args",
")",
"{",
"$",
"replyCode",
"=",
"$",
"args",
"->",
"readShort",
"(",
")",
";",
"$",
"replyText",
"=",
"$",
"args",
"->",
"readShortstr",
"(",
")",
";",
"$",
"classId",
"=",
"$",
"args",
"->",
"readShort",
"(",
")",
";",
"$",
"methodId",
"=",
"$",
"args",
"->",
"readShort",
"(",
")",
";",
"$",
"this",
"->",
"xCloseOk",
"(",
")",
";",
"throw",
"new",
"ConnectionException",
"(",
"$",
"replyCode",
",",
"$",
"replyText",
",",
"array",
"(",
"$",
"classId",
",",
"$",
"methodId",
")",
")",
";",
"}"
] | @param \AMQP\Wire\Reader $args
@throws \AMQP\Exception\ConnectionException | [
"@param",
"\\",
"AMQP",
"\\",
"Wire",
"\\",
"Reader",
"$args"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L615-L630 |
zircote/AMQP | library/AMQP/Connection.php | Connection.xOpen | protected function xOpen($virtualHost, $capabilities = '', $insist = false)
{
$args = new Writer();
$args->writeShortStr($virtualHost);
$args->writeShortStr($capabilities);
$args->writeBit($insist);
$this->sendMethodFrame(array(10, 40), $args);
return $this->wait(
array(
"10,41", // Connection.openOk
"10,50" // Connection.redirect
)
);
} | php | protected function xOpen($virtualHost, $capabilities = '', $insist = false)
{
$args = new Writer();
$args->writeShortStr($virtualHost);
$args->writeShortStr($capabilities);
$args->writeBit($insist);
$this->sendMethodFrame(array(10, 40), $args);
return $this->wait(
array(
"10,41", // Connection.openOk
"10,50" // Connection.redirect
)
);
} | [
"protected",
"function",
"xOpen",
"(",
"$",
"virtualHost",
",",
"$",
"capabilities",
"=",
"''",
",",
"$",
"insist",
"=",
"false",
")",
"{",
"$",
"args",
"=",
"new",
"Writer",
"(",
")",
";",
"$",
"args",
"->",
"writeShortStr",
"(",
"$",
"virtualHost",
")",
";",
"$",
"args",
"->",
"writeShortStr",
"(",
"$",
"capabilities",
")",
";",
"$",
"args",
"->",
"writeBit",
"(",
"$",
"insist",
")",
";",
"$",
"this",
"->",
"sendMethodFrame",
"(",
"array",
"(",
"10",
",",
"40",
")",
",",
"$",
"args",
")",
";",
"return",
"$",
"this",
"->",
"wait",
"(",
"array",
"(",
"\"10,41\"",
",",
"// Connection.openOk",
"\"10,50\"",
"// Connection.redirect",
")",
")",
";",
"}"
] | @param $virtualHost
@param string $capabilities
@param bool $insist
@return mixed|null | [
"@param",
"$virtualHost",
"@param",
"string",
"$capabilities",
"@param",
"bool",
"$insist"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L657-L670 |
zircote/AMQP | library/AMQP/Connection.php | Connection.openOk | protected function openOk(Reader $args)
{
$this->knownHosts = $args->readShortstr();
if ($this->debug) {
Helper::debugMsg("Open OK! known_hosts: " . $this->knownHosts);
}
return null;
} | php | protected function openOk(Reader $args)
{
$this->knownHosts = $args->readShortstr();
if ($this->debug) {
Helper::debugMsg("Open OK! known_hosts: " . $this->knownHosts);
}
return null;
} | [
"protected",
"function",
"openOk",
"(",
"Reader",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"knownHosts",
"=",
"$",
"args",
"->",
"readShortstr",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"Helper",
"::",
"debugMsg",
"(",
"\"Open OK! known_hosts: \"",
".",
"$",
"this",
"->",
"knownHosts",
")",
";",
"}",
"return",
"null",
";",
"}"
] | signal that the connection is ready | [
"signal",
"that",
"the",
"connection",
"is",
"ready"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L675-L683 |
zircote/AMQP | library/AMQP/Connection.php | Connection.redirect | protected function redirect(Reader $args)
{
$host = $args->readShortstr();
$this->knownHosts = $args->readShortstr();
if ($this->debug) {
Helper::debugMsg(
sprintf(
'Redirected to [%s], known_hosts [%s]',
$host, $this->knownHosts
)
);
}
return $host;
} | php | protected function redirect(Reader $args)
{
$host = $args->readShortstr();
$this->knownHosts = $args->readShortstr();
if ($this->debug) {
Helper::debugMsg(
sprintf(
'Redirected to [%s], known_hosts [%s]',
$host, $this->knownHosts
)
);
}
return $host;
} | [
"protected",
"function",
"redirect",
"(",
"Reader",
"$",
"args",
")",
"{",
"$",
"host",
"=",
"$",
"args",
"->",
"readShortstr",
"(",
")",
";",
"$",
"this",
"->",
"knownHosts",
"=",
"$",
"args",
"->",
"readShortstr",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"Helper",
"::",
"debugMsg",
"(",
"sprintf",
"(",
"'Redirected to [%s], known_hosts [%s]'",
",",
"$",
"host",
",",
"$",
"this",
"->",
"knownHosts",
")",
")",
";",
"}",
"return",
"$",
"host",
";",
"}"
] | asks the client to use a different server
@param \AMQP\Wire\Reader $args
@return string | [
"asks",
"the",
"client",
"to",
"use",
"a",
"different",
"server"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L692-L705 |
zircote/AMQP | library/AMQP/Connection.php | Connection._xSecureOk | protected function _xSecureOk($response)
{
$args = new Writer();
$args->writeLongStr($response);
$this->sendMethodFrame(array(10, 21), $args);
} | php | protected function _xSecureOk($response)
{
$args = new Writer();
$args->writeLongStr($response);
$this->sendMethodFrame(array(10, 21), $args);
} | [
"protected",
"function",
"_xSecureOk",
"(",
"$",
"response",
")",
"{",
"$",
"args",
"=",
"new",
"Writer",
"(",
")",
";",
"$",
"args",
"->",
"writeLongStr",
"(",
"$",
"response",
")",
";",
"$",
"this",
"->",
"sendMethodFrame",
"(",
"array",
"(",
"10",
",",
"21",
")",
",",
"$",
"args",
")",
";",
"}"
] | security mechanism response
@param string $response | [
"security",
"mechanism",
"response"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L722-L727 |
zircote/AMQP | library/AMQP/Connection.php | Connection.start | protected function start(Reader $args)
{
$this->versionMajor = $args->readOctet();
$this->versionMinor = $args->readOctet();
$this->serverProperties = $args->readTable();
$this->mechanisms = explode(" ", $args->readLongstr());
$this->locales = explode(" ", $args->readLongstr());
if ($this->debug) {
Helper::debugMsg(
sprintf(
'Start from server, version: %d.%d, properties: %s, ' .
'mechanisms: %s, locales: %s',
$this->versionMajor,
$this->versionMinor,
self::dumpTable($this->serverProperties),
implode(', ', $this->mechanisms),
implode(', ', $this->locales)
)
);
}
} | php | protected function start(Reader $args)
{
$this->versionMajor = $args->readOctet();
$this->versionMinor = $args->readOctet();
$this->serverProperties = $args->readTable();
$this->mechanisms = explode(" ", $args->readLongstr());
$this->locales = explode(" ", $args->readLongstr());
if ($this->debug) {
Helper::debugMsg(
sprintf(
'Start from server, version: %d.%d, properties: %s, ' .
'mechanisms: %s, locales: %s',
$this->versionMajor,
$this->versionMinor,
self::dumpTable($this->serverProperties),
implode(', ', $this->mechanisms),
implode(', ', $this->locales)
)
);
}
} | [
"protected",
"function",
"start",
"(",
"Reader",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"versionMajor",
"=",
"$",
"args",
"->",
"readOctet",
"(",
")",
";",
"$",
"this",
"->",
"versionMinor",
"=",
"$",
"args",
"->",
"readOctet",
"(",
")",
";",
"$",
"this",
"->",
"serverProperties",
"=",
"$",
"args",
"->",
"readTable",
"(",
")",
";",
"$",
"this",
"->",
"mechanisms",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"args",
"->",
"readLongstr",
"(",
")",
")",
";",
"$",
"this",
"->",
"locales",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"args",
"->",
"readLongstr",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
")",
"{",
"Helper",
"::",
"debugMsg",
"(",
"sprintf",
"(",
"'Start from server, version: %d.%d, properties: %s, '",
".",
"'mechanisms: %s, locales: %s'",
",",
"$",
"this",
"->",
"versionMajor",
",",
"$",
"this",
"->",
"versionMinor",
",",
"self",
"::",
"dumpTable",
"(",
"$",
"this",
"->",
"serverProperties",
")",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"mechanisms",
")",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"locales",
")",
")",
")",
";",
"}",
"}"
] | start connection negotiation | [
"start",
"connection",
"negotiation"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L732-L753 |
zircote/AMQP | library/AMQP/Connection.php | Connection.tune | protected function tune(Reader $args)
{
$v = $args->readShort();
if ($v) {
$this->channelMax = $v;
}
$v = $args->readLong();
if ($v) {
$this->frameMax = $v;
}
$this->heartbeat = $args->readShort();
$this->xTuneOk($this->channelMax, $this->frameMax, 0);
} | php | protected function tune(Reader $args)
{
$v = $args->readShort();
if ($v) {
$this->channelMax = $v;
}
$v = $args->readLong();
if ($v) {
$this->frameMax = $v;
}
$this->heartbeat = $args->readShort();
$this->xTuneOk($this->channelMax, $this->frameMax, 0);
} | [
"protected",
"function",
"tune",
"(",
"Reader",
"$",
"args",
")",
"{",
"$",
"v",
"=",
"$",
"args",
"->",
"readShort",
"(",
")",
";",
"if",
"(",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"channelMax",
"=",
"$",
"v",
";",
"}",
"$",
"v",
"=",
"$",
"args",
"->",
"readLong",
"(",
")",
";",
"if",
"(",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"frameMax",
"=",
"$",
"v",
";",
"}",
"$",
"this",
"->",
"heartbeat",
"=",
"$",
"args",
"->",
"readShort",
"(",
")",
";",
"$",
"this",
"->",
"xTuneOk",
"(",
"$",
"this",
"->",
"channelMax",
",",
"$",
"this",
"->",
"frameMax",
",",
"0",
")",
";",
"}"
] | propose connection tuning parameters
@param \AMQP\Wire\Reader $args | [
"propose",
"connection",
"tuning",
"parameters"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L776-L792 |
zircote/AMQP | library/AMQP/Connection.php | Connection.xTuneOk | protected function xTuneOk($channelMax, $frameMax, $heartbeat)
{
$args = new Writer();
$args->writeShort($channelMax);
$args->writeLong($frameMax);
$args->writeShort($heartbeat);
$this->sendMethodFrame(array(10, 31), $args);
$this->waitTuneOk = False;
} | php | protected function xTuneOk($channelMax, $frameMax, $heartbeat)
{
$args = new Writer();
$args->writeShort($channelMax);
$args->writeLong($frameMax);
$args->writeShort($heartbeat);
$this->sendMethodFrame(array(10, 31), $args);
$this->waitTuneOk = False;
} | [
"protected",
"function",
"xTuneOk",
"(",
"$",
"channelMax",
",",
"$",
"frameMax",
",",
"$",
"heartbeat",
")",
"{",
"$",
"args",
"=",
"new",
"Writer",
"(",
")",
";",
"$",
"args",
"->",
"writeShort",
"(",
"$",
"channelMax",
")",
";",
"$",
"args",
"->",
"writeLong",
"(",
"$",
"frameMax",
")",
";",
"$",
"args",
"->",
"writeShort",
"(",
"$",
"heartbeat",
")",
";",
"$",
"this",
"->",
"sendMethodFrame",
"(",
"array",
"(",
"10",
",",
"31",
")",
",",
"$",
"args",
")",
";",
"$",
"this",
"->",
"waitTuneOk",
"=",
"False",
";",
"}"
] | negotiate connection tuning parameters
@param $channelMax
@param $frameMax
@param $heartbeat | [
"negotiate",
"connection",
"tuning",
"parameters"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L801-L809 |
zircote/AMQP | library/AMQP/Connection.php | Connection.dumpTable | public static function dumpTable($table)
{
$tokens = array();
foreach ($table as $name => $value) {
switch ($value[0]) {
case 'D':
$val = $value[1]->n . 'E' . $value[1]->e;
break;
case 'F':
$val = '(' . self::dumpTable($value[1]) . ')';
break;
case 'T':
$val = date('Y-m-d H:i:s', $value[1]);
break;
default:
$val = $value[1];
}
$tokens[] = $name . '=' . $val;
}
return implode(', ', $tokens);
} | php | public static function dumpTable($table)
{
$tokens = array();
foreach ($table as $name => $value) {
switch ($value[0]) {
case 'D':
$val = $value[1]->n . 'E' . $value[1]->e;
break;
case 'F':
$val = '(' . self::dumpTable($value[1]) . ')';
break;
case 'T':
$val = date('Y-m-d H:i:s', $value[1]);
break;
default:
$val = $value[1];
}
$tokens[] = $name . '=' . $val;
}
return implode(', ', $tokens);
} | [
"public",
"static",
"function",
"dumpTable",
"(",
"$",
"table",
")",
"{",
"$",
"tokens",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"table",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
"[",
"0",
"]",
")",
"{",
"case",
"'D'",
":",
"$",
"val",
"=",
"$",
"value",
"[",
"1",
"]",
"->",
"n",
".",
"'E'",
".",
"$",
"value",
"[",
"1",
"]",
"->",
"e",
";",
"break",
";",
"case",
"'F'",
":",
"$",
"val",
"=",
"'('",
".",
"self",
"::",
"dumpTable",
"(",
"$",
"value",
"[",
"1",
"]",
")",
".",
"')'",
";",
"break",
";",
"case",
"'T'",
":",
"$",
"val",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"value",
"[",
"1",
"]",
")",
";",
"break",
";",
"default",
":",
"$",
"val",
"=",
"$",
"value",
"[",
"1",
"]",
";",
"}",
"$",
"tokens",
"[",
"]",
"=",
"$",
"name",
".",
"'='",
".",
"$",
"val",
";",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"tokens",
")",
";",
"}"
] | @static
@param $table
@return string | [
"@static"
] | train | https://github.com/zircote/AMQP/blob/b96777b372f556797db4fd0ba02edb18d4bf4a1e/library/AMQP/Connection.php#L848-L868 |
freearhey/sparql | src/QueryBuilder.php | QueryBuilder.service | public function service( $service, $subject, $predicate = null, $object = null ) {
$this->graphBuilder->service( $service, $subject, $predicate, $object );
return $this;
} | php | public function service( $service, $subject, $predicate = null, $object = null ) {
$this->graphBuilder->service( $service, $subject, $predicate, $object );
return $this;
} | [
"public",
"function",
"service",
"(",
"$",
"service",
",",
"$",
"subject",
",",
"$",
"predicate",
"=",
"null",
",",
"$",
"object",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"graphBuilder",
"->",
"service",
"(",
"$",
"service",
",",
"$",
"subject",
",",
"$",
"predicate",
",",
"$",
"object",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds the given graph or triple as an service condition.
@param string|GraphBuilder $subject
@param string|null $predicate
@param string|null $object
@return self
@throws InvalidArgumentException | [
"Adds",
"the",
"given",
"graph",
"or",
"triple",
"as",
"an",
"service",
"condition",
"."
] | train | https://github.com/freearhey/sparql/blob/622a8ea661dc5939122b0e8b430a6a94b3bc49c7/src/QueryBuilder.php#L257-L260 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.get | public function get($key, $default = null)
{
try {
$value = $this->pool->getItem($key)->get();
if ($value !== null) {
return $value;
} else {
return $default;
}
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function get($key, $default = null)
{
try {
$value = $this->pool->getItem($key)->get();
if ($value !== null) {
return $value;
} else {
return $default;
}
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"key",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"return",
"$",
"value",
";",
"}",
"else",
"{",
"return",
"$",
"default",
";",
"}",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L30-L42 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.set | public function set($key, $value, $ttl = null)
{
try {
$item = $this->pool
->getItem($key)
->set($value);
if (is_int($ttl) || $ttl instanceof \DateInterval) {
$item->expiresAfter($ttl);
}
return $this->pool->save($item);
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function set($key, $value, $ttl = null)
{
try {
$item = $this->pool
->getItem($key)
->set($value);
if (is_int($ttl) || $ttl instanceof \DateInterval) {
$item->expiresAfter($ttl);
}
return $this->pool->save($item);
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"key",
")",
"->",
"set",
"(",
"$",
"value",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"ttl",
")",
"||",
"$",
"ttl",
"instanceof",
"\\",
"DateInterval",
")",
"{",
"$",
"item",
"->",
"expiresAfter",
"(",
"$",
"ttl",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pool",
"->",
"save",
"(",
"$",
"item",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L47-L61 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.delete | public function delete($key)
{
try {
return $this->pool->deleteItem($key);
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function delete($key)
{
try {
return $this->pool->deleteItem($key);
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"deleteItem",
"(",
"$",
"key",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L66-L73 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.clear | public function clear()
{
try {
return $this->pool->clear();
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function clear()
{
try {
return $this->pool->clear();
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"clear",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L78-L85 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.getMultiple | public function getMultiple($keys, $default = null)
{
try {
return array_map(function (ExtendedCacheItemInterface $item) {
return $item->get();
}, $this->pool->getItems($keys));
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function getMultiple($keys, $default = null)
{
try {
return array_map(function (ExtendedCacheItemInterface $item) {
return $item->get();
}, $this->pool->getItems($keys));
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"getMultiple",
"(",
"$",
"keys",
",",
"$",
"default",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"array_map",
"(",
"function",
"(",
"ExtendedCacheItemInterface",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"->",
"get",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"pool",
"->",
"getItems",
"(",
"$",
"keys",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L90-L99 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.setMultiple | public function setMultiple($values, $ttl = null)
{
try {
foreach ($values as $key => $value) {
$item = $this->pool->getItem($key)->set($value);
$this->pool->saveDeferred($item);
unset($item);
}
return $this->pool->commit();
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function setMultiple($values, $ttl = null)
{
try {
foreach ($values as $key => $value) {
$item = $this->pool->getItem($key)->set($value);
$this->pool->saveDeferred($item);
unset($item);
}
return $this->pool->commit();
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"setMultiple",
"(",
"$",
"values",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"key",
")",
"->",
"set",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"pool",
"->",
"saveDeferred",
"(",
"$",
"item",
")",
";",
"unset",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"this",
"->",
"pool",
"->",
"commit",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L104-L117 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.deleteMultiple | public function deleteMultiple($keys)
{
try {
return $this->pool->deleteItems($keys);
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function deleteMultiple($keys)
{
try {
return $this->pool->deleteItems($keys);
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"deleteMultiple",
"(",
"$",
"keys",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"deleteItems",
"(",
"$",
"keys",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L122-L129 |
spiral-modules/phpFastCache-bridge | source/PhpFastCache/SimpleCacheAdapter.php | SimpleCacheAdapter.has | public function has($key)
{
try {
return $this->pool->getItem($key)->isHit();
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | php | public function has($key)
{
try {
return $this->pool->getItem($key)->isHit();
} catch (\Throwable $e) {
throw new SpiralFastCacheException($e->getMessage(), $e->getMessage(), $e);
}
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"key",
")",
"->",
"isHit",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"SpiralFastCacheException",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/spiral-modules/phpFastCache-bridge/blob/d4ffa95daf9e04b79f50486cba6c9857918c2b79/source/PhpFastCache/SimpleCacheAdapter.php#L134-L141 |
phpmob/changmin | src/PhpMob/MediaBundle/Controller/ImageController.php | ImageController.filterRuntimeAction | public function filterRuntimeAction($path, $sizing, $mode = 'inset', $filter = 'strip')
{
if ($path instanceof ImageInterface) {
$path = $path->getPath();
}
$runtimeConfig = [
'thumbnail' => [
'size' => explode('x', strtolower($sizing)),
'mode' => $mode,
],
];
return $this->redirect(
$this->getImagineCacheManager()->getBrowserPath($path, $filter, $runtimeConfig
));
} | php | public function filterRuntimeAction($path, $sizing, $mode = 'inset', $filter = 'strip')
{
if ($path instanceof ImageInterface) {
$path = $path->getPath();
}
$runtimeConfig = [
'thumbnail' => [
'size' => explode('x', strtolower($sizing)),
'mode' => $mode,
],
];
return $this->redirect(
$this->getImagineCacheManager()->getBrowserPath($path, $filter, $runtimeConfig
));
} | [
"public",
"function",
"filterRuntimeAction",
"(",
"$",
"path",
",",
"$",
"sizing",
",",
"$",
"mode",
"=",
"'inset'",
",",
"$",
"filter",
"=",
"'strip'",
")",
"{",
"if",
"(",
"$",
"path",
"instanceof",
"ImageInterface",
")",
"{",
"$",
"path",
"=",
"$",
"path",
"->",
"getPath",
"(",
")",
";",
"}",
"$",
"runtimeConfig",
"=",
"[",
"'thumbnail'",
"=>",
"[",
"'size'",
"=>",
"explode",
"(",
"'x'",
",",
"strtolower",
"(",
"$",
"sizing",
")",
")",
",",
"'mode'",
"=>",
"$",
"mode",
",",
"]",
",",
"]",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"getImagineCacheManager",
"(",
")",
"->",
"getBrowserPath",
"(",
"$",
"path",
",",
"$",
"filter",
",",
"$",
"runtimeConfig",
")",
")",
";",
"}"
] | @param string $path
@param string $sizing
@param string $mode
@param string $filter
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"@param",
"string",
"$path",
"@param",
"string",
"$sizing",
"@param",
"string",
"$mode",
"@param",
"string",
"$filter"
] | train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/MediaBundle/Controller/ImageController.php#L27-L43 |
thienhungho/yii2-order-management | src/modules/MyOrder/search/OrderSearch.php | OrderSearch.search | public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'ref_by' => $this->ref_by,
'created_by' => $this->created_by,
'updated_by' => $this->updated_by,
]);
$query->andFilterWhere(['like', 'status', $this->status])
->andFilterWhere(['like', 'payment_method', $this->payment_method])
->andFilterWhere(['like', 'note', $this->note])
->andFilterWhere(['like', 'include_vat', $this->include_vat])
->andFilterWhere(['like', 'customer_username', $this->customer_username])
->andFilterWhere(['like', 'customer_phone', $this->customer_phone])
->andFilterWhere(['like', 'customer_name', $this->customer_name])
->andFilterWhere(['like', 'customer_email', $this->customer_email])
->andFilterWhere(['like', 'customer_address', $this->customer_address])
->andFilterWhere(['like', 'customer_company', $this->customer_company])
->andFilterWhere(['like', 'customer_area', $this->customer_area])
->andFilterWhere(['like', 'customer_tax_number', $this->customer_tax_number])
->andFilterWhere(['like', 'real_value', $this->real_value])
->andFilterWhere(['like', 'discount_value', $this->discount_value])
->andFilterWhere(['like', 'total_price', $this->total_price])
->andFilterWhere(['like', 'created_at', $this->created_at])
->andFilterWhere(['like', 'updated_at', $this->created_at]);
return $dataProvider;
} | php | public function search($params)
{
$query = Order::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'ref_by' => $this->ref_by,
'created_by' => $this->created_by,
'updated_by' => $this->updated_by,
]);
$query->andFilterWhere(['like', 'status', $this->status])
->andFilterWhere(['like', 'payment_method', $this->payment_method])
->andFilterWhere(['like', 'note', $this->note])
->andFilterWhere(['like', 'include_vat', $this->include_vat])
->andFilterWhere(['like', 'customer_username', $this->customer_username])
->andFilterWhere(['like', 'customer_phone', $this->customer_phone])
->andFilterWhere(['like', 'customer_name', $this->customer_name])
->andFilterWhere(['like', 'customer_email', $this->customer_email])
->andFilterWhere(['like', 'customer_address', $this->customer_address])
->andFilterWhere(['like', 'customer_company', $this->customer_company])
->andFilterWhere(['like', 'customer_area', $this->customer_area])
->andFilterWhere(['like', 'customer_tax_number', $this->customer_tax_number])
->andFilterWhere(['like', 'real_value', $this->real_value])
->andFilterWhere(['like', 'discount_value', $this->discount_value])
->andFilterWhere(['like', 'total_price', $this->total_price])
->andFilterWhere(['like', 'created_at', $this->created_at])
->andFilterWhere(['like', 'updated_at', $this->created_at]);
return $dataProvider;
} | [
"public",
"function",
"search",
"(",
"$",
"params",
")",
"{",
"$",
"query",
"=",
"Order",
"::",
"find",
"(",
")",
";",
"$",
"dataProvider",
"=",
"new",
"ActiveDataProvider",
"(",
"[",
"'query'",
"=>",
"$",
"query",
",",
"]",
")",
";",
"$",
"this",
"->",
"load",
"(",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"// uncomment the following line if you do not want to return any records when validation fails\r",
"// $query->where('0=1');\r",
"return",
"$",
"dataProvider",
";",
"}",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'ref_by'",
"=>",
"$",
"this",
"->",
"ref_by",
",",
"'created_by'",
"=>",
"$",
"this",
"->",
"created_by",
",",
"'updated_by'",
"=>",
"$",
"this",
"->",
"updated_by",
",",
"]",
")",
";",
"$",
"query",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'status'",
",",
"$",
"this",
"->",
"status",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'payment_method'",
",",
"$",
"this",
"->",
"payment_method",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'note'",
",",
"$",
"this",
"->",
"note",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'include_vat'",
",",
"$",
"this",
"->",
"include_vat",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_username'",
",",
"$",
"this",
"->",
"customer_username",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_phone'",
",",
"$",
"this",
"->",
"customer_phone",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_name'",
",",
"$",
"this",
"->",
"customer_name",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_email'",
",",
"$",
"this",
"->",
"customer_email",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_address'",
",",
"$",
"this",
"->",
"customer_address",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_company'",
",",
"$",
"this",
"->",
"customer_company",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_area'",
",",
"$",
"this",
"->",
"customer_area",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'customer_tax_number'",
",",
"$",
"this",
"->",
"customer_tax_number",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'real_value'",
",",
"$",
"this",
"->",
"real_value",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'discount_value'",
",",
"$",
"this",
"->",
"discount_value",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'total_price'",
",",
"$",
"this",
"->",
"total_price",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'created_at'",
",",
"$",
"this",
"->",
"created_at",
"]",
")",
"->",
"andFilterWhere",
"(",
"[",
"'like'",
",",
"'updated_at'",
",",
"$",
"this",
"->",
"created_at",
"]",
")",
";",
"return",
"$",
"dataProvider",
";",
"}"
] | Creates data provider instance with search query applied
@param array $params
@return ActiveDataProvider | [
"Creates",
"data",
"provider",
"instance",
"with",
"search",
"query",
"applied"
] | train | https://github.com/thienhungho/yii2-order-management/blob/f263f0b2168d6f5e99cee2e20a5878d09d4e81c0/src/modules/MyOrder/search/OrderSearch.php#L42-L84 |
gries/rcon | src/Message.php | Message.convertToRconData | public function convertToRconData($id)
{
$idAndTypePacked = pack('VV', $id, $this->type);
$endOfMessage = chr(0) . chr(0);
$message = $idAndTypePacked . $this->body . $endOfMessage;
$data = pack("V", strlen($message)) . $message;
return $data;
} | php | public function convertToRconData($id)
{
$idAndTypePacked = pack('VV', $id, $this->type);
$endOfMessage = chr(0) . chr(0);
$message = $idAndTypePacked . $this->body . $endOfMessage;
$data = pack("V", strlen($message)) . $message;
return $data;
} | [
"public",
"function",
"convertToRconData",
"(",
"$",
"id",
")",
"{",
"$",
"idAndTypePacked",
"=",
"pack",
"(",
"'VV'",
",",
"$",
"id",
",",
"$",
"this",
"->",
"type",
")",
";",
"$",
"endOfMessage",
"=",
"chr",
"(",
"0",
")",
".",
"chr",
"(",
"0",
")",
";",
"$",
"message",
"=",
"$",
"idAndTypePacked",
".",
"$",
"this",
"->",
"body",
".",
"$",
"endOfMessage",
";",
"$",
"data",
"=",
"pack",
"(",
"\"V\"",
",",
"strlen",
"(",
"$",
"message",
")",
")",
".",
"$",
"message",
";",
"return",
"$",
"data",
";",
"}"
] | The message id used for this message.
This will be encoded in the RconData.
@param int $id
@return string | [
"The",
"message",
"id",
"used",
"for",
"this",
"message",
".",
"This",
"will",
"be",
"encoded",
"in",
"the",
"RconData",
"."
] | train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Message.php#L82-L92 |
gries/rcon | src/Message.php | Message.initializeFromRconData | public function initializeFromRconData($data, $fragmented = false)
{
if ($fragmented) {
$packet = unpack("V1id/a*body", $data);
$packet['type'] = static::TYPE_RESPONSE_VALUE;
} else {
// 8 byte for id + type and atleast 2 byte if the body is empty
if (mb_strlen($data) < 10) {
throw new InvalidPacketException();
}
$packet = unpack("V1id/V1type/a*body", $data);
}
if (!is_array($packet) ||
!isset($packet['id']) ||
!isset($packet['body']) ||
!isset($packet['type'])
) {
throw new InvalidPacketException();
}
$this->id = $packet['id'];
$this->type = $packet['type'];
$this->body = rtrim($packet['body']); // removes null bytes at the end of the string
} | php | public function initializeFromRconData($data, $fragmented = false)
{
if ($fragmented) {
$packet = unpack("V1id/a*body", $data);
$packet['type'] = static::TYPE_RESPONSE_VALUE;
} else {
// 8 byte for id + type and atleast 2 byte if the body is empty
if (mb_strlen($data) < 10) {
throw new InvalidPacketException();
}
$packet = unpack("V1id/V1type/a*body", $data);
}
if (!is_array($packet) ||
!isset($packet['id']) ||
!isset($packet['body']) ||
!isset($packet['type'])
) {
throw new InvalidPacketException();
}
$this->id = $packet['id'];
$this->type = $packet['type'];
$this->body = rtrim($packet['body']); // removes null bytes at the end of the string
} | [
"public",
"function",
"initializeFromRconData",
"(",
"$",
"data",
",",
"$",
"fragmented",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"fragmented",
")",
"{",
"$",
"packet",
"=",
"unpack",
"(",
"\"V1id/a*body\"",
",",
"$",
"data",
")",
";",
"$",
"packet",
"[",
"'type'",
"]",
"=",
"static",
"::",
"TYPE_RESPONSE_VALUE",
";",
"}",
"else",
"{",
"// 8 byte for id + type and atleast 2 byte if the body is empty",
"if",
"(",
"mb_strlen",
"(",
"$",
"data",
")",
"<",
"10",
")",
"{",
"throw",
"new",
"InvalidPacketException",
"(",
")",
";",
"}",
"$",
"packet",
"=",
"unpack",
"(",
"\"V1id/V1type/a*body\"",
",",
"$",
"data",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"packet",
")",
"||",
"!",
"isset",
"(",
"$",
"packet",
"[",
"'id'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"packet",
"[",
"'body'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"packet",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidPacketException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"id",
"=",
"$",
"packet",
"[",
"'id'",
"]",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"packet",
"[",
"'type'",
"]",
";",
"$",
"this",
"->",
"body",
"=",
"rtrim",
"(",
"$",
"packet",
"[",
"'body'",
"]",
")",
";",
"// removes null bytes at the end of the string",
"}"
] | Parses data from a RCON Response.
Note: the first 4 bytes that indicate the size of the packet MUST not be included.
@param $data
@param bool|$fragmented If the data comes from a fragmented response only the id and body will be present.
@throws InvalidPacketException | [
"Parses",
"data",
"from",
"a",
"RCON",
"Response",
".",
"Note",
":",
"the",
"first",
"4",
"bytes",
"that",
"indicate",
"the",
"size",
"of",
"the",
"packet",
"MUST",
"not",
"be",
"included",
"."
] | train | https://github.com/gries/rcon/blob/7fada05b329d89542692af00ab80db02ad59d45d/src/Message.php#L113-L138 |
titon/db | src/Titon/Db/Driver/Type/BlobType.php | BlobType.from | public function from($value) {
if ($value === null) {
return null;
}
if (is_string($value)) {
$value = fopen('data://text/plain;base64,' . base64_encode($value), 'rb');
}
if (!is_resource($value)) {
throw new ConversionFailureException('Failed to convert value to a binary resource');
}
return $value;
} | php | public function from($value) {
if ($value === null) {
return null;
}
if (is_string($value)) {
$value = fopen('data://text/plain;base64,' . base64_encode($value), 'rb');
}
if (!is_resource($value)) {
throw new ConversionFailureException('Failed to convert value to a binary resource');
}
return $value;
} | [
"public",
"function",
"from",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"fopen",
"(",
"'data://text/plain;base64,'",
".",
"base64_encode",
"(",
"$",
"value",
")",
",",
"'rb'",
")",
";",
"}",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"ConversionFailureException",
"(",
"'Failed to convert value to a binary resource'",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | {@inheritdoc}
@throws \Titon\Db\Exception\ConversionFailureException | [
"{",
"@inheritdoc",
"}"
] | train | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Driver/Type/BlobType.php#L26-L40 |
steeffeen/FancyManiaLinks | FML/Script/Features/GraphCurve.php | GraphCurve.addPoint | public function addPoint($coordX, $coordY = null)
{
if (is_array($coordX)) {
$coordY = (isset($coordX[1]) ? $coordX[1] : 0.);
$coordX = (isset($coordX[0]) ? $coordX[0] : 0.);
}
array_push($this->points, array($coordX, $coordY));
return $this;
} | php | public function addPoint($coordX, $coordY = null)
{
if (is_array($coordX)) {
$coordY = (isset($coordX[1]) ? $coordX[1] : 0.);
$coordX = (isset($coordX[0]) ? $coordX[0] : 0.);
}
array_push($this->points, array($coordX, $coordY));
return $this;
} | [
"public",
"function",
"addPoint",
"(",
"$",
"coordX",
",",
"$",
"coordY",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"coordX",
")",
")",
"{",
"$",
"coordY",
"=",
"(",
"isset",
"(",
"$",
"coordX",
"[",
"1",
"]",
")",
"?",
"$",
"coordX",
"[",
"1",
"]",
":",
"0.",
")",
";",
"$",
"coordX",
"=",
"(",
"isset",
"(",
"$",
"coordX",
"[",
"0",
"]",
")",
"?",
"$",
"coordX",
"[",
"0",
"]",
":",
"0.",
")",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"points",
",",
"array",
"(",
"$",
"coordX",
",",
"$",
"coordY",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add point
@api
@param float|float[] $coordX X-coordinate or point
@param float $coordY (optional) Y-coordinate
@return static | [
"Add",
"point"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/GraphCurve.php#L111-L119 |
steeffeen/FancyManiaLinks | FML/Script/Features/GraphCurve.php | GraphCurve.getScriptText | protected function getScriptText()
{
$graphId = Builder::escapeText($this->graph->getId(), false);
$scriptText = "
declare Graph <=> (Page.GetFirstChild(\"{$graphId}\") as CMlGraph);
if (Graph != Null) {
declare GraphCurve <=> Graph.AddCurve();
";
foreach ($this->points as $point) {
$pointVec2 = Builder::getVec2($point);
$scriptText .= "
GraphCurve.Points.add({$pointVec2});";
}
if ($this->sortPoints) {
$scriptText .= "
GraphCurve.SortPoints();";
}
if ($this->color) {
$colorVec3 = Builder::getVec3($this->color);
$scriptText .= "
GraphCurve.Color = {$colorVec3};";
}
if ($this->style) {
$scriptText .= "
GraphCurve.Style = {$this->style};";
}
if ($this->width) {
$scriptText .= "
GraphCurve.Width = {$this->width};";
}
return $scriptText . "
}";
} | php | protected function getScriptText()
{
$graphId = Builder::escapeText($this->graph->getId(), false);
$scriptText = "
declare Graph <=> (Page.GetFirstChild(\"{$graphId}\") as CMlGraph);
if (Graph != Null) {
declare GraphCurve <=> Graph.AddCurve();
";
foreach ($this->points as $point) {
$pointVec2 = Builder::getVec2($point);
$scriptText .= "
GraphCurve.Points.add({$pointVec2});";
}
if ($this->sortPoints) {
$scriptText .= "
GraphCurve.SortPoints();";
}
if ($this->color) {
$colorVec3 = Builder::getVec3($this->color);
$scriptText .= "
GraphCurve.Color = {$colorVec3};";
}
if ($this->style) {
$scriptText .= "
GraphCurve.Style = {$this->style};";
}
if ($this->width) {
$scriptText .= "
GraphCurve.Width = {$this->width};";
}
return $scriptText . "
}";
} | [
"protected",
"function",
"getScriptText",
"(",
")",
"{",
"$",
"graphId",
"=",
"Builder",
"::",
"escapeText",
"(",
"$",
"this",
"->",
"graph",
"->",
"getId",
"(",
")",
",",
"false",
")",
";",
"$",
"scriptText",
"=",
"\"\ndeclare Graph <=> (Page.GetFirstChild(\\\"{$graphId}\\\") as CMlGraph);\nif (Graph != Null) {\n declare GraphCurve <=> Graph.AddCurve();\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"points",
"as",
"$",
"point",
")",
"{",
"$",
"pointVec2",
"=",
"Builder",
"::",
"getVec2",
"(",
"$",
"point",
")",
";",
"$",
"scriptText",
".=",
"\"\n GraphCurve.Points.add({$pointVec2});\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"sortPoints",
")",
"{",
"$",
"scriptText",
".=",
"\"\n GraphCurve.SortPoints();\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"color",
")",
"{",
"$",
"colorVec3",
"=",
"Builder",
"::",
"getVec3",
"(",
"$",
"this",
"->",
"color",
")",
";",
"$",
"scriptText",
".=",
"\"\n GraphCurve.Color = {$colorVec3};\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"style",
")",
"{",
"$",
"scriptText",
".=",
"\"\n GraphCurve.Style = {$this->style};\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"width",
")",
"{",
"$",
"scriptText",
".=",
"\"\n GraphCurve.Width = {$this->width};\"",
";",
"}",
"return",
"$",
"scriptText",
".",
"\"\n}\"",
";",
"}"
] | Get the script text
@return string | [
"Get",
"the",
"script",
"text"
] | train | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/GraphCurve.php#L269-L301 |
mustardandrew/muan-laravel-comments | app/Traits/CanComment.php | CanComment.addComment | public function addComment(Model $model, string $comment) : Comment
{
return $model->comments()->create([
'user_id' => $this->id,
'comment' => $comment,
]);
} | php | public function addComment(Model $model, string $comment) : Comment
{
return $model->comments()->create([
'user_id' => $this->id,
'comment' => $comment,
]);
} | [
"public",
"function",
"addComment",
"(",
"Model",
"$",
"model",
",",
"string",
"$",
"comment",
")",
":",
"Comment",
"{",
"return",
"$",
"model",
"->",
"comments",
"(",
")",
"->",
"create",
"(",
"[",
"'user_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'comment'",
"=>",
"$",
"comment",
",",
"]",
")",
";",
"}"
] | Add comment
@param Model $model
@param string $comment
@return Comment | [
"Add",
"comment"
] | train | https://github.com/mustardandrew/muan-laravel-comments/blob/4dea64e6a2269f6a780df110a382acf9c97fa9b3/app/Traits/CanComment.php#L32-L38 |
inc2734/wp-seo | src/App/Controller/Posts.php | Posts._add_meta_boxes | public function _add_meta_boxes( $post_type, $post ) {
$post_type_object = get_post_type_object( $post_type );
if ( empty( $post_type_object ) || empty( $post_type_object->public ) ) {
return;
}
add_meta_box(
'wp-seo',
__( 'SEO', 'inc2734-wp-seo' ),
array( $this, '_wp_seo_meta_box' ),
$post_type,
'normal'
);
} | php | public function _add_meta_boxes( $post_type, $post ) {
$post_type_object = get_post_type_object( $post_type );
if ( empty( $post_type_object ) || empty( $post_type_object->public ) ) {
return;
}
add_meta_box(
'wp-seo',
__( 'SEO', 'inc2734-wp-seo' ),
array( $this, '_wp_seo_meta_box' ),
$post_type,
'normal'
);
} | [
"public",
"function",
"_add_meta_boxes",
"(",
"$",
"post_type",
",",
"$",
"post",
")",
"{",
"$",
"post_type_object",
"=",
"get_post_type_object",
"(",
"$",
"post_type",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"post_type_object",
")",
"||",
"empty",
"(",
"$",
"post_type_object",
"->",
"public",
")",
")",
"{",
"return",
";",
"}",
"add_meta_box",
"(",
"'wp-seo'",
",",
"__",
"(",
"'SEO'",
",",
"'inc2734-wp-seo'",
")",
",",
"array",
"(",
"$",
"this",
",",
"'_wp_seo_meta_box'",
")",
",",
"$",
"post_type",
",",
"'normal'",
")",
";",
"}"
] | Add meta box in pages of public post type
@param [string] $post_type
@param [WP_Post] $post
@return void | [
"Add",
"meta",
"box",
"in",
"pages",
"of",
"public",
"post",
"type"
] | train | https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L25-L38 |
inc2734/wp-seo | src/App/Controller/Posts.php | Posts._wp_seo_meta_box | public function _wp_seo_meta_box( $post ) {
?>
<?php wp_nonce_field( 'wp-seo-meta-box-action', 'wp-seo-meta-box-nonce' ); ?>
<p>
<label for="wp-seo-meta-description">
<b><?php esc_html_e( 'Meta description', 'inc2734-wp-seo' ); ?></b>
</label><br />
<input
type="text"
name="wp-seo-meta-description"
class="widefat"
id="wp-seo-meta-description"
value="<?php echo esc_attr( get_post_meta( $post->ID, 'wp-seo-meta-description', true ) ); ?>"
/>
</p>
<p>
<b><?php esc_html_e( 'Meta robots', 'inc2734-wp-seo' ); ?></b><br />
<?php
$robots = (array) get_post_meta( $post->ID, 'wp-seo-meta-robots', true );
$robots_choices = [
'noindex',
'nofollow',
]
?>
<?php foreach ( $robots_choices as $robot ) : ?>
<label for="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" style="margin-right: 1em;">
<input
type="checkbox"
name="wp-seo-meta-robots[]"
id="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>"
value="<?php echo esc_attr( $robot ); ?>"
<?php checked( in_array( $robot, $robots ) ); ?>
/>
<?php echo esc_html( $robot ); ?>
</label>
<?php endforeach; ?>
</p>
<?php
} | php | public function _wp_seo_meta_box( $post ) {
?>
<?php wp_nonce_field( 'wp-seo-meta-box-action', 'wp-seo-meta-box-nonce' ); ?>
<p>
<label for="wp-seo-meta-description">
<b><?php esc_html_e( 'Meta description', 'inc2734-wp-seo' ); ?></b>
</label><br />
<input
type="text"
name="wp-seo-meta-description"
class="widefat"
id="wp-seo-meta-description"
value="<?php echo esc_attr( get_post_meta( $post->ID, 'wp-seo-meta-description', true ) ); ?>"
/>
</p>
<p>
<b><?php esc_html_e( 'Meta robots', 'inc2734-wp-seo' ); ?></b><br />
<?php
$robots = (array) get_post_meta( $post->ID, 'wp-seo-meta-robots', true );
$robots_choices = [
'noindex',
'nofollow',
]
?>
<?php foreach ( $robots_choices as $robot ) : ?>
<label for="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>" style="margin-right: 1em;">
<input
type="checkbox"
name="wp-seo-meta-robots[]"
id="wp-seo-meta-robots-<?php echo esc_attr( $robot ); ?>"
value="<?php echo esc_attr( $robot ); ?>"
<?php checked( in_array( $robot, $robots ) ); ?>
/>
<?php echo esc_html( $robot ); ?>
</label>
<?php endforeach; ?>
</p>
<?php
} | [
"public",
"function",
"_wp_seo_meta_box",
"(",
"$",
"post",
")",
"{",
"?>\n\t\t<?php",
"wp_nonce_field",
"(",
"'wp-seo-meta-box-action'",
",",
"'wp-seo-meta-box-nonce'",
")",
";",
"?>\n\t\t<p>\n\t\t\t<label for=\"wp-seo-meta-description\">\n\t\t\t\t<b><?php",
"esc_html_e",
"(",
"'Meta description'",
",",
"'inc2734-wp-seo'",
")",
";",
"?></b>\n\t\t\t</label><br />\n\t\t\t<input\n\t\t\t\ttype=\"text\"\n\t\t\t\tname=\"wp-seo-meta-description\"\n\t\t\t\tclass=\"widefat\"\n\t\t\t\tid=\"wp-seo-meta-description\"\n\t\t\t\tvalue=\"<?php",
"echo",
"esc_attr",
"(",
"get_post_meta",
"(",
"$",
"post",
"->",
"ID",
",",
"'wp-seo-meta-description'",
",",
"true",
")",
")",
";",
"?>\"\n\t\t\t/>\n\t\t</p>\n\t\t<p>\n\t\t\t<b><?php",
"esc_html_e",
"(",
"'Meta robots'",
",",
"'inc2734-wp-seo'",
")",
";",
"?></b><br />\n\t\t\t<?php",
"$",
"robots",
"=",
"(",
"array",
")",
"get_post_meta",
"(",
"$",
"post",
"->",
"ID",
",",
"'wp-seo-meta-robots'",
",",
"true",
")",
";",
"$",
"robots_choices",
"=",
"[",
"'noindex'",
",",
"'nofollow'",
",",
"]",
"?>\n\t\t\t<?php",
"foreach",
"(",
"$",
"robots_choices",
"as",
"$",
"robot",
")",
":",
"?>\n\t\t\t\t<label for=\"wp-seo-meta-robots-<?php",
"echo",
"esc_attr",
"(",
"$",
"robot",
")",
";",
"?>\" style=\"margin-right: 1em;\">\n\t\t\t\t\t<input\n\t\t\t\t\t\ttype=\"checkbox\"\n\t\t\t\t\t\tname=\"wp-seo-meta-robots[]\"\n\t\t\t\t\t\tid=\"wp-seo-meta-robots-<?php",
"echo",
"esc_attr",
"(",
"$",
"robot",
")",
";",
"?>\"\n\t\t\t\t\t\tvalue=\"<?php",
"echo",
"esc_attr",
"(",
"$",
"robot",
")",
";",
"?>\"\n\t\t\t\t\t\t<?php",
"checked",
"(",
"in_array",
"(",
"$",
"robot",
",",
"$",
"robots",
")",
")",
";",
"?>\n\t\t\t\t\t/>\n\t\t\t\t\t<?php",
"echo",
"esc_html",
"(",
"$",
"robot",
")",
";",
"?>\n\t\t\t\t</label>\n\t\t\t<?php",
"endforeach",
";",
"?>\n\t\t</p>\n\t\t<?php",
"}"
] | Display meta box
@param [WP_Post] $post
@return void | [
"Display",
"meta",
"box"
] | train | https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L46-L84 |
inc2734/wp-seo | src/App/Controller/Posts.php | Posts._save_meta_description | public function _save_meta_description( $post_id ) {
if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) {
return;
}
if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) {
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( ! isset( $_POST['wp-seo-meta-description'] ) ) {
return;
}
if ( is_array( $_POST['wp-seo-meta-description'] ) ) {
return;
}
$meta_description = wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-description' ) );
update_post_meta( $post_id, 'wp-seo-meta-description', $meta_description );
} | php | public function _save_meta_description( $post_id ) {
if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) {
return;
}
if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) {
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( ! isset( $_POST['wp-seo-meta-description'] ) ) {
return;
}
if ( is_array( $_POST['wp-seo-meta-description'] ) ) {
return;
}
$meta_description = wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-description' ) );
update_post_meta( $post_id, 'wp-seo-meta-description', $meta_description );
} | [
"public",
"function",
"_save_meta_description",
"(",
"$",
"post_id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_POST",
"[",
"'wp-seo-meta-box-nonce'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"wp_verify_nonce",
"(",
"wp_unslash",
"(",
"filter_input",
"(",
"INPUT_POST",
",",
"'wp-seo-meta-box-nonce'",
")",
")",
",",
"'wp-seo-meta-box-action'",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"defined",
"(",
"'DOING_AUTOSAVE'",
")",
"&&",
"DOING_AUTOSAVE",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"current_user_can",
"(",
"'edit_post'",
",",
"$",
"post_id",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_POST",
"[",
"'wp-seo-meta-description'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"_POST",
"[",
"'wp-seo-meta-description'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"meta_description",
"=",
"wp_unslash",
"(",
"filter_input",
"(",
"INPUT_POST",
",",
"'wp-seo-meta-description'",
")",
")",
";",
"update_post_meta",
"(",
"$",
"post_id",
",",
"'wp-seo-meta-description'",
",",
"$",
"meta_description",
")",
";",
"}"
] | Save meta description
@param [int] $post_id
@return void | [
"Save",
"meta",
"description"
] | train | https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L92-L119 |
inc2734/wp-seo | src/App/Controller/Posts.php | Posts._save_meta_robots | public function _save_meta_robots( $post_id ) {
if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) {
return;
}
if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) {
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( ! isset( $_POST['wp-seo-meta-robots'] ) || ! is_array( $_POST['wp-seo-meta-robots'] ) ) {
update_post_meta( $post_id, 'wp-seo-meta-robots', [] );
return;
}
$meta_robots = filter_input( INPUT_POST, 'wp-seo-meta-robots', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
update_post_meta( $post_id, 'wp-seo-meta-robots', $meta_robots );
} | php | public function _save_meta_robots( $post_id ) {
if ( empty( $_POST['wp-seo-meta-box-nonce'] ) ) {
return;
}
if ( ! wp_verify_nonce( wp_unslash( filter_input( INPUT_POST, 'wp-seo-meta-box-nonce' ) ), 'wp-seo-meta-box-action' ) ) {
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return;
}
if ( ! isset( $_POST['wp-seo-meta-robots'] ) || ! is_array( $_POST['wp-seo-meta-robots'] ) ) {
update_post_meta( $post_id, 'wp-seo-meta-robots', [] );
return;
}
$meta_robots = filter_input( INPUT_POST, 'wp-seo-meta-robots', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
update_post_meta( $post_id, 'wp-seo-meta-robots', $meta_robots );
} | [
"public",
"function",
"_save_meta_robots",
"(",
"$",
"post_id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"_POST",
"[",
"'wp-seo-meta-box-nonce'",
"]",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"wp_verify_nonce",
"(",
"wp_unslash",
"(",
"filter_input",
"(",
"INPUT_POST",
",",
"'wp-seo-meta-box-nonce'",
")",
")",
",",
"'wp-seo-meta-box-action'",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"defined",
"(",
"'DOING_AUTOSAVE'",
")",
"&&",
"DOING_AUTOSAVE",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"current_user_can",
"(",
"'edit_post'",
",",
"$",
"post_id",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"_POST",
"[",
"'wp-seo-meta-robots'",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"_POST",
"[",
"'wp-seo-meta-robots'",
"]",
")",
")",
"{",
"update_post_meta",
"(",
"$",
"post_id",
",",
"'wp-seo-meta-robots'",
",",
"[",
"]",
")",
";",
"return",
";",
"}",
"$",
"meta_robots",
"=",
"filter_input",
"(",
"INPUT_POST",
",",
"'wp-seo-meta-robots'",
",",
"FILTER_DEFAULT",
",",
"FILTER_REQUIRE_ARRAY",
")",
";",
"update_post_meta",
"(",
"$",
"post_id",
",",
"'wp-seo-meta-robots'",
",",
"$",
"meta_robots",
")",
";",
"}"
] | Save meta robots
@param [int] $post_id
@return void | [
"Save",
"meta",
"robots"
] | train | https://github.com/inc2734/wp-seo/blob/d08f3fad346751232859c335d289237a82f9eef3/src/App/Controller/Posts.php#L127-L151 |
ruvents/ruwork-upload-bundle | Metadata/CachedMetadataFactory.php | CachedMetadataFactory.getMetadata | public function getMetadata(string $class): Metadata
{
$item = $this->cache->getItem(str_replace('\\', '.', $class));
if ($item->isHit()) {
[$mTime, $metadata] = $item->get();
if (!$this->debug || $mTime >= $classMTime = $this->getClassMTime($class)) {
return $metadata;
}
}
$metadata = $this->factory->getMetadata($class);
$item->set([$classMTime ?? $this->getClassMTime($class), $metadata]);
$this->cache->save($item);
return $metadata;
} | php | public function getMetadata(string $class): Metadata
{
$item = $this->cache->getItem(str_replace('\\', '.', $class));
if ($item->isHit()) {
[$mTime, $metadata] = $item->get();
if (!$this->debug || $mTime >= $classMTime = $this->getClassMTime($class)) {
return $metadata;
}
}
$metadata = $this->factory->getMetadata($class);
$item->set([$classMTime ?? $this->getClassMTime($class), $metadata]);
$this->cache->save($item);
return $metadata;
} | [
"public",
"function",
"getMetadata",
"(",
"string",
"$",
"class",
")",
":",
"Metadata",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"cache",
"->",
"getItem",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'.'",
",",
"$",
"class",
")",
")",
";",
"if",
"(",
"$",
"item",
"->",
"isHit",
"(",
")",
")",
"{",
"[",
"$",
"mTime",
",",
"$",
"metadata",
"]",
"=",
"$",
"item",
"->",
"get",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"debug",
"||",
"$",
"mTime",
">=",
"$",
"classMTime",
"=",
"$",
"this",
"->",
"getClassMTime",
"(",
"$",
"class",
")",
")",
"{",
"return",
"$",
"metadata",
";",
"}",
"}",
"$",
"metadata",
"=",
"$",
"this",
"->",
"factory",
"->",
"getMetadata",
"(",
"$",
"class",
")",
";",
"$",
"item",
"->",
"set",
"(",
"[",
"$",
"classMTime",
"??",
"$",
"this",
"->",
"getClassMTime",
"(",
"$",
"class",
")",
",",
"$",
"metadata",
"]",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"item",
")",
";",
"return",
"$",
"metadata",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/ruvents/ruwork-upload-bundle/blob/8ad09cc2dce6ab389105c440d791346696da43af/Metadata/CachedMetadataFactory.php#L28-L45 |
jfusion/org.jfusion.framework | src/Api/Platform.php | Platform.getTypeInstance | public static function getTypeInstance($type)
{
$type = ucfirst(strtolower($type));
if (!isset(self::$instances[$type])) {
$class = 'JFusion\\Api\\Platform\\' . $type;
self::$instances[$type] = new $class();
}
return self::$instances[$type];
} | php | public static function getTypeInstance($type)
{
$type = ucfirst(strtolower($type));
if (!isset(self::$instances[$type])) {
$class = 'JFusion\\Api\\Platform\\' . $type;
self::$instances[$type] = new $class();
}
return self::$instances[$type];
} | [
"public",
"static",
"function",
"getTypeInstance",
"(",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"type",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"class",
"=",
"'JFusion\\\\Api\\\\Platform\\\\'",
".",
"$",
"type",
";",
"self",
"::",
"$",
"instances",
"[",
"$",
"type",
"]",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instances",
"[",
"$",
"type",
"]",
";",
"}"
] | Get a platform type object.
@param string $type
@return Platform | [
"Get",
"a",
"platform",
"type",
"object",
"."
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L43-L51 |
jfusion/org.jfusion.framework | src/Api/Platform.php | Platform.login | public function login($username, $password, $remember = 1)
{
$event = new Event('onPlatformLogin');
$event->addArgument('username', $username);
$event->addArgument('password', $password);
$event->addArgument('remember', $remember);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
} | php | public function login($username, $password, $remember = 1)
{
$event = new Event('onPlatformLogin');
$event->addArgument('username', $username);
$event->addArgument('password', $password);
$event->addArgument('remember', $remember);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
} | [
"public",
"function",
"login",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"remember",
"=",
"1",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"'onPlatformLogin'",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'username'",
",",
"$",
"username",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'password'",
",",
"$",
"password",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'remember'",
",",
"$",
"remember",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'activePlugin'",
",",
"$",
"this",
"->",
"activePlugin",
")",
";",
"Factory",
"::",
"getDispatcher",
"(",
")",
"->",
"triggerEvent",
"(",
"$",
"event",
")",
";",
"}"
] | @param string $username
@param string $password
@param int $remember
@return void | [
"@param",
"string",
"$username",
"@param",
"string",
"$password",
"@param",
"int",
"$remember"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L103-L112 |
jfusion/org.jfusion.framework | src/Api/Platform.php | Platform.logout | public function logout($username = null)
{
$event = new Event('onPlatformLogout');
$event->addArgument('username', $username);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
} | php | public function logout($username = null)
{
$event = new Event('onPlatformLogout');
$event->addArgument('username', $username);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
} | [
"public",
"function",
"logout",
"(",
"$",
"username",
"=",
"null",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"'onPlatformLogout'",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'username'",
",",
"$",
"username",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'activePlugin'",
",",
"$",
"this",
"->",
"activePlugin",
")",
";",
"Factory",
"::",
"getDispatcher",
"(",
")",
"->",
"triggerEvent",
"(",
"$",
"event",
")",
";",
"}"
] | @param null|string $username
@return void | [
"@param",
"null|string",
"$username"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L119-L126 |
jfusion/org.jfusion.framework | src/Api/Platform.php | Platform.register | public function register(Userinfo $userinfo)
{
$event = new Event('onPlatformUserRegister');
$event->addArgument('userinfo', $userinfo);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
$debug = $event->getArgument('debug', null);
if ($debug) {
$this->debug[] = $debug;
}
$error = $event->getArgument('error', null);
if ($error) {
$this->error[] = $error;
}
} | php | public function register(Userinfo $userinfo)
{
$event = new Event('onPlatformUserRegister');
$event->addArgument('userinfo', $userinfo);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
$debug = $event->getArgument('debug', null);
if ($debug) {
$this->debug[] = $debug;
}
$error = $event->getArgument('error', null);
if ($error) {
$this->error[] = $error;
}
} | [
"public",
"function",
"register",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"'onPlatformUserRegister'",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'userinfo'",
",",
"$",
"userinfo",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'activePlugin'",
",",
"$",
"this",
"->",
"activePlugin",
")",
";",
"Factory",
"::",
"getDispatcher",
"(",
")",
"->",
"triggerEvent",
"(",
"$",
"event",
")",
";",
"$",
"debug",
"=",
"$",
"event",
"->",
"getArgument",
"(",
"'debug'",
",",
"null",
")",
";",
"if",
"(",
"$",
"debug",
")",
"{",
"$",
"this",
"->",
"debug",
"[",
"]",
"=",
"$",
"debug",
";",
"}",
"$",
"error",
"=",
"$",
"event",
"->",
"getArgument",
"(",
"'error'",
",",
"null",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"error",
"[",
"]",
"=",
"$",
"error",
";",
"}",
"}"
] | @param Userinfo $userinfo
@return void | [
"@param",
"Userinfo",
"$userinfo"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L133-L150 |
jfusion/org.jfusion.framework | src/Api/Platform.php | Platform.update | public function update($userinfo, $overwrite)
{
$event = new Event('onPlatformUserUpdate');
$event->addArgument('userinfo', $userinfo);
$event->addArgument('overwrite', $overwrite);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
$debug = $event->getArgument('debug', null);
if ($debug) {
$this->debug[] = $debug;
}
$error = $event->getArgument('error', null);
if ($error) {
$this->error[] = $error;
}
} | php | public function update($userinfo, $overwrite)
{
$event = new Event('onPlatformUserUpdate');
$event->addArgument('userinfo', $userinfo);
$event->addArgument('overwrite', $overwrite);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
$debug = $event->getArgument('debug', null);
if ($debug) {
$this->debug[] = $debug;
}
$error = $event->getArgument('error', null);
if ($error) {
$this->error[] = $error;
}
} | [
"public",
"function",
"update",
"(",
"$",
"userinfo",
",",
"$",
"overwrite",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"'onPlatformUserUpdate'",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'userinfo'",
",",
"$",
"userinfo",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'overwrite'",
",",
"$",
"overwrite",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'activePlugin'",
",",
"$",
"this",
"->",
"activePlugin",
")",
";",
"Factory",
"::",
"getDispatcher",
"(",
")",
"->",
"triggerEvent",
"(",
"$",
"event",
")",
";",
"$",
"debug",
"=",
"$",
"event",
"->",
"getArgument",
"(",
"'debug'",
",",
"null",
")",
";",
"if",
"(",
"$",
"debug",
")",
"{",
"$",
"this",
"->",
"debug",
"[",
"]",
"=",
"$",
"debug",
";",
"}",
"$",
"error",
"=",
"$",
"event",
"->",
"getArgument",
"(",
"'error'",
",",
"null",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"error",
"[",
"]",
"=",
"$",
"error",
";",
"}",
"}"
] | @param array $userinfo
@param $overwrite
@return void | [
"@param",
"array",
"$userinfo",
"@param",
"$overwrite"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L158-L176 |
jfusion/org.jfusion.framework | src/Api/Platform.php | Platform.delete | public function delete($userid)
{
$event = new Event('onPlatformUserDelete');
$event->addArgument('userid', $userid);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
$debug = $event->getArgument('debug', null);
if ($debug) {
$this->debug[] = $debug;
}
$error = $event->getArgument('error', null);
if ($error) {
$this->error[] = $error;
}
} | php | public function delete($userid)
{
$event = new Event('onPlatformUserDelete');
$event->addArgument('userid', $userid);
$event->addArgument('activePlugin', $this->activePlugin);
Factory::getDispatcher()->triggerEvent($event);
$debug = $event->getArgument('debug', null);
if ($debug) {
$this->debug[] = $debug;
}
$error = $event->getArgument('error', null);
if ($error) {
$this->error[] = $error;
}
} | [
"public",
"function",
"delete",
"(",
"$",
"userid",
")",
"{",
"$",
"event",
"=",
"new",
"Event",
"(",
"'onPlatformUserDelete'",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'userid'",
",",
"$",
"userid",
")",
";",
"$",
"event",
"->",
"addArgument",
"(",
"'activePlugin'",
",",
"$",
"this",
"->",
"activePlugin",
")",
";",
"Factory",
"::",
"getDispatcher",
"(",
")",
"->",
"triggerEvent",
"(",
"$",
"event",
")",
";",
"$",
"debug",
"=",
"$",
"event",
"->",
"getArgument",
"(",
"'debug'",
",",
"null",
")",
";",
"if",
"(",
"$",
"debug",
")",
"{",
"$",
"this",
"->",
"debug",
"[",
"]",
"=",
"$",
"debug",
";",
"}",
"$",
"error",
"=",
"$",
"event",
"->",
"getArgument",
"(",
"'error'",
",",
"null",
")",
";",
"if",
"(",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"error",
"[",
"]",
"=",
"$",
"error",
";",
"}",
"}"
] | @param int $userid
@return void | [
"@param",
"int",
"$userid"
] | train | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Api/Platform.php#L183-L200 |
netgen/metadata-bundle | bundle/Core/FieldType/Metadata/Value.php | Value.offsetGet | public function offsetGet($offset)
{
if (is_array($this->{$offset})) {
return implode(',', $this->{$offset});
}
return $this->{$offset};
} | php | public function offsetGet($offset)
{
if (is_array($this->{$offset})) {
return implode(',', $this->{$offset});
}
return $this->{$offset};
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"{",
"$",
"offset",
"}",
")",
")",
"{",
"return",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"{",
"$",
"offset",
"}",
")",
";",
"}",
"return",
"$",
"this",
"->",
"{",
"$",
"offset",
"}",
";",
"}"
] | Offset to retrieve.
@param mixed $offset The offset to retrieve
@return mixed | [
"Offset",
"to",
"retrieve",
"."
] | train | https://github.com/netgen/metadata-bundle/blob/12bfca68e8e8f4be409c7151f99dff665c53755b/bundle/Core/FieldType/Metadata/Value.php#L101-L108 |
phossa2/config | src/Config/Delegator.php | Delegator.set | public function set(/*# string */ $id, $value)/*# : bool */
{
if ($this->isWritable()) {
$this->writable->set($id, $value);
return $this->writable->has($id);
} else {
throw new LogicException(
Message::get(Message::CONFIG_NOT_WRITABLE, $id),
Message::CONFIG_NOT_WRITABLE
);
}
} | php | public function set(/*# string */ $id, $value)/*# : bool */
{
if ($this->isWritable()) {
$this->writable->set($id, $value);
return $this->writable->has($id);
} else {
throw new LogicException(
Message::get(Message::CONFIG_NOT_WRITABLE, $id),
Message::CONFIG_NOT_WRITABLE
);
}
} | [
"public",
"function",
"set",
"(",
"/*# string */",
"$",
"id",
",",
"$",
"value",
")",
"/*# : bool */",
"{",
"if",
"(",
"$",
"this",
"->",
"isWritable",
"(",
")",
")",
"{",
"$",
"this",
"->",
"writable",
"->",
"set",
"(",
"$",
"id",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"writable",
"->",
"has",
"(",
"$",
"id",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"LogicException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"CONFIG_NOT_WRITABLE",
",",
"$",
"id",
")",
",",
"Message",
"::",
"CONFIG_NOT_WRITABLE",
")",
";",
"}",
"}"
] | @since 2.0.12 changed return value
{@inheritDoc} | [
"@since",
"2",
".",
"0",
".",
"12",
"changed",
"return",
"value"
] | train | https://github.com/phossa2/config/blob/7c046fd2c97633b69545b4745d8bffe28e19b1df/src/Config/Delegator.php#L81-L92 |
lode/fem | src/text.php | text.generate_token | public static function generate_token($length) {
$byte_length = ($length / 2);
$new_token = bin2hex(openssl_random_pseudo_bytes($byte_length, $strong_enough));
if ($strong_enough == false || empty($new_token)) {
$exception = bootstrap::get_library('exception');
throw new $exception('can not generate cryptographically strong enough token');
}
return $new_token;
} | php | public static function generate_token($length) {
$byte_length = ($length / 2);
$new_token = bin2hex(openssl_random_pseudo_bytes($byte_length, $strong_enough));
if ($strong_enough == false || empty($new_token)) {
$exception = bootstrap::get_library('exception');
throw new $exception('can not generate cryptographically strong enough token');
}
return $new_token;
} | [
"public",
"static",
"function",
"generate_token",
"(",
"$",
"length",
")",
"{",
"$",
"byte_length",
"=",
"(",
"$",
"length",
"/",
"2",
")",
";",
"$",
"new_token",
"=",
"bin2hex",
"(",
"openssl_random_pseudo_bytes",
"(",
"$",
"byte_length",
",",
"$",
"strong_enough",
")",
")",
";",
"if",
"(",
"$",
"strong_enough",
"==",
"false",
"||",
"empty",
"(",
"$",
"new_token",
")",
")",
"{",
"$",
"exception",
"=",
"bootstrap",
"::",
"get_library",
"(",
"'exception'",
")",
";",
"throw",
"new",
"$",
"exception",
"(",
"'can not generate cryptographically strong enough token'",
")",
";",
"}",
"return",
"$",
"new_token",
";",
"}"
] | generates cryptographically strong tokens
@param int $length of the returned string
@return string | [
"generates",
"cryptographically",
"strong",
"tokens"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/text.php#L13-L22 |
lode/fem | src/text.php | text.slugify | public static function slugify($data) {
// flatten the data
$data = self::normalize($data);
$data = mb_strtolower($data);
// remove certain chars
$data = str_replace(['"', "'"], '', $data);
// replace most chars
$data = preg_replace('/[^a-z0-9]/', '-', $data);
// cleanup
$data = trim($data, '-');
return $data;
} | php | public static function slugify($data) {
// flatten the data
$data = self::normalize($data);
$data = mb_strtolower($data);
// remove certain chars
$data = str_replace(['"', "'"], '', $data);
// replace most chars
$data = preg_replace('/[^a-z0-9]/', '-', $data);
// cleanup
$data = trim($data, '-');
return $data;
} | [
"public",
"static",
"function",
"slugify",
"(",
"$",
"data",
")",
"{",
"// flatten the data",
"$",
"data",
"=",
"self",
"::",
"normalize",
"(",
"$",
"data",
")",
";",
"$",
"data",
"=",
"mb_strtolower",
"(",
"$",
"data",
")",
";",
"// remove certain chars",
"$",
"data",
"=",
"str_replace",
"(",
"[",
"'\"'",
",",
"\"'\"",
"]",
",",
"''",
",",
"$",
"data",
")",
";",
"// replace most chars",
"$",
"data",
"=",
"preg_replace",
"(",
"'/[^a-z0-9]/'",
",",
"'-'",
",",
"$",
"data",
")",
";",
"// cleanup",
"$",
"data",
"=",
"trim",
"(",
"$",
"data",
",",
"'-'",
")",
";",
"return",
"$",
"data",
";",
"}"
] | slugify strings for usage in urls
- normalizes and lowers the string
- replaces non-ascii chars with a dash (-)
- some chars (i.e. quotes) are plain removed
@note uses ::normalize, see notes there
@param string $data utf-8 encoded
@return string | [
"slugify",
"strings",
"for",
"usage",
"in",
"urls",
"-",
"normalizes",
"and",
"lowers",
"the",
"string",
"-",
"replaces",
"non",
"-",
"ascii",
"chars",
"with",
"a",
"dash",
"(",
"-",
")",
"-",
"some",
"chars",
"(",
"i",
".",
"e",
".",
"quotes",
")",
"are",
"plain",
"removed"
] | train | https://github.com/lode/fem/blob/c1c466c1a904d99452b341c5ae7cbc3e22b106e1/src/text.php#L61-L76 |
factorio-item-browser/export-data | src/Entity/Icon.php | Icon.setLayers | public function setLayers(array $layers)
{
$this->layers = array_values(array_filter($layers, function ($layer): bool {
return $layer instanceof Layer;
}));
return $this;
} | php | public function setLayers(array $layers)
{
$this->layers = array_values(array_filter($layers, function ($layer): bool {
return $layer instanceof Layer;
}));
return $this;
} | [
"public",
"function",
"setLayers",
"(",
"array",
"$",
"layers",
")",
"{",
"$",
"this",
"->",
"layers",
"=",
"array_values",
"(",
"array_filter",
"(",
"$",
"layers",
",",
"function",
"(",
"$",
"layer",
")",
":",
"bool",
"{",
"return",
"$",
"layer",
"instanceof",
"Layer",
";",
"}",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the layers of the icon.
@param array|Layer[] $layers
@return $this Implementing fluent interface. | [
"Sets",
"the",
"layers",
"of",
"the",
"icon",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon.php#L98-L104 |
factorio-item-browser/export-data | src/Entity/Icon.php | Icon.writeData | public function writeData(): array
{
$dataBuilder = new DataBuilder();
$dataBuilder->setInteger('s', $this->size, self::DEFAULT_SIZE)
->setInteger('r', $this->renderedSize, self::DEFAULT_SIZE)
->setArray('l', $this->layers, function (Layer $layer): array {
return $layer->writeData();
}, []);
return $dataBuilder->getData();
} | php | public function writeData(): array
{
$dataBuilder = new DataBuilder();
$dataBuilder->setInteger('s', $this->size, self::DEFAULT_SIZE)
->setInteger('r', $this->renderedSize, self::DEFAULT_SIZE)
->setArray('l', $this->layers, function (Layer $layer): array {
return $layer->writeData();
}, []);
return $dataBuilder->getData();
} | [
"public",
"function",
"writeData",
"(",
")",
":",
"array",
"{",
"$",
"dataBuilder",
"=",
"new",
"DataBuilder",
"(",
")",
";",
"$",
"dataBuilder",
"->",
"setInteger",
"(",
"'s'",
",",
"$",
"this",
"->",
"size",
",",
"self",
"::",
"DEFAULT_SIZE",
")",
"->",
"setInteger",
"(",
"'r'",
",",
"$",
"this",
"->",
"renderedSize",
",",
"self",
"::",
"DEFAULT_SIZE",
")",
"->",
"setArray",
"(",
"'l'",
",",
"$",
"this",
"->",
"layers",
",",
"function",
"(",
"Layer",
"$",
"layer",
")",
":",
"array",
"{",
"return",
"$",
"layer",
"->",
"writeData",
"(",
")",
";",
"}",
",",
"[",
"]",
")",
";",
"return",
"$",
"dataBuilder",
"->",
"getData",
"(",
")",
";",
"}"
] | Writes the entity data to an array.
@return array | [
"Writes",
"the",
"entity",
"data",
"to",
"an",
"array",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon.php#L130-L139 |
factorio-item-browser/export-data | src/Entity/Icon.php | Icon.readData | public function readData(DataContainer $data)
{
$this->size = $data->getInteger('s', self::DEFAULT_SIZE);
$this->renderedSize = $data->getInteger('r', self::DEFAULT_SIZE);
$this->layers = array_map(function (DataContainer $data): Layer {
return (new Layer())->readData($data);
}, $data->getObjectArray('l'));
return $this;
} | php | public function readData(DataContainer $data)
{
$this->size = $data->getInteger('s', self::DEFAULT_SIZE);
$this->renderedSize = $data->getInteger('r', self::DEFAULT_SIZE);
$this->layers = array_map(function (DataContainer $data): Layer {
return (new Layer())->readData($data);
}, $data->getObjectArray('l'));
return $this;
} | [
"public",
"function",
"readData",
"(",
"DataContainer",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"size",
"=",
"$",
"data",
"->",
"getInteger",
"(",
"'s'",
",",
"self",
"::",
"DEFAULT_SIZE",
")",
";",
"$",
"this",
"->",
"renderedSize",
"=",
"$",
"data",
"->",
"getInteger",
"(",
"'r'",
",",
"self",
"::",
"DEFAULT_SIZE",
")",
";",
"$",
"this",
"->",
"layers",
"=",
"array_map",
"(",
"function",
"(",
"DataContainer",
"$",
"data",
")",
":",
"Layer",
"{",
"return",
"(",
"new",
"Layer",
"(",
")",
")",
"->",
"readData",
"(",
"$",
"data",
")",
";",
"}",
",",
"$",
"data",
"->",
"getObjectArray",
"(",
"'l'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Reads the entity data.
@param DataContainer $data
@return $this | [
"Reads",
"the",
"entity",
"data",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon.php#L146-L154 |
factorio-item-browser/export-data | src/Entity/Icon.php | Icon.calculateHash | public function calculateHash(): string
{
return EntityUtils::calculateHashOfArray([
$this->size,
$this->renderedSize,
array_map(function (Layer $layer): string {
return $layer->calculateHash();
}, $this->layers)
]);
} | php | public function calculateHash(): string
{
return EntityUtils::calculateHashOfArray([
$this->size,
$this->renderedSize,
array_map(function (Layer $layer): string {
return $layer->calculateHash();
}, $this->layers)
]);
} | [
"public",
"function",
"calculateHash",
"(",
")",
":",
"string",
"{",
"return",
"EntityUtils",
"::",
"calculateHashOfArray",
"(",
"[",
"$",
"this",
"->",
"size",
",",
"$",
"this",
"->",
"renderedSize",
",",
"array_map",
"(",
"function",
"(",
"Layer",
"$",
"layer",
")",
":",
"string",
"{",
"return",
"$",
"layer",
"->",
"calculateHash",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"layers",
")",
"]",
")",
";",
"}"
] | Calculates a hash value representing the entity.
@return string | [
"Calculates",
"a",
"hash",
"value",
"representing",
"the",
"entity",
"."
] | train | https://github.com/factorio-item-browser/export-data/blob/1413b2eed0fbfed0521457ac7ef0d668ac30c212/src/Entity/Icon.php#L160-L169 |
askupasoftware/amarkal | Loaders/AssetLoader.php | AssetLoader.register_asset | public function register_asset( \Amarkal\Assets\AbstractAsset $new_asset )
{
if( NULL == $this->assets ) {
$this->assets = array();
$this->assets[] = $new_asset;
}
else {
foreach( $this->assets as $asset ) {
if( $asset->handle == $new_asset->handle && get_class($asset) == get_class($new_asset) ) {
throw new DuplicateAssetException("An asset with the handle {$new_asset->handle} already exists");
}
}
$this->assets[] = $new_asset;
}
} | php | public function register_asset( \Amarkal\Assets\AbstractAsset $new_asset )
{
if( NULL == $this->assets ) {
$this->assets = array();
$this->assets[] = $new_asset;
}
else {
foreach( $this->assets as $asset ) {
if( $asset->handle == $new_asset->handle && get_class($asset) == get_class($new_asset) ) {
throw new DuplicateAssetException("An asset with the handle {$new_asset->handle} already exists");
}
}
$this->assets[] = $new_asset;
}
} | [
"public",
"function",
"register_asset",
"(",
"\\",
"Amarkal",
"\\",
"Assets",
"\\",
"AbstractAsset",
"$",
"new_asset",
")",
"{",
"if",
"(",
"NULL",
"==",
"$",
"this",
"->",
"assets",
")",
"{",
"$",
"this",
"->",
"assets",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"assets",
"[",
"]",
"=",
"$",
"new_asset",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"assets",
"as",
"$",
"asset",
")",
"{",
"if",
"(",
"$",
"asset",
"->",
"handle",
"==",
"$",
"new_asset",
"->",
"handle",
"&&",
"get_class",
"(",
"$",
"asset",
")",
"==",
"get_class",
"(",
"$",
"new_asset",
")",
")",
"{",
"throw",
"new",
"DuplicateAssetException",
"(",
"\"An asset with the handle {$new_asset->handle} already exists\"",
")",
";",
"}",
"}",
"$",
"this",
"->",
"assets",
"[",
"]",
"=",
"$",
"new_asset",
";",
"}",
"}"
] | Register a single asset
@param \Amarkal\Assets\AbstractAsset $new_asset The asset to enqueue
@throws DuplicateAssetException If the a duplicated asset handle exists | [
"Register",
"a",
"single",
"asset"
] | train | https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Loaders/AssetLoader.php#L79-L93 |
yuncms/framework | src/filters/BackendAccessControl.php | BackendAccessControl.getUser | public function getUser(): User
{
if (!$this->_user instanceof User) {
$this->_user = Instance::ensure($this->_user, User::class);
}
return $this->_user;
} | php | public function getUser(): User
{
if (!$this->_user instanceof User) {
$this->_user = Instance::ensure($this->_user, User::class);
}
return $this->_user;
} | [
"public",
"function",
"getUser",
"(",
")",
":",
"User",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_user",
"instanceof",
"User",
")",
"{",
"$",
"this",
"->",
"_user",
"=",
"Instance",
"::",
"ensure",
"(",
"$",
"this",
"->",
"_user",
",",
"User",
"::",
"class",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_user",
";",
"}"
] | Get user
@return User
@throws \yii\base\InvalidConfigException | [
"Get",
"user"
] | train | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filters/BackendAccessControl.php#L54-L60 |
latrell/AliyunOss | src/AliyunOssServiceProvider.php | AliyunOssServiceProvider.register | public function register()
{
$this->app->singleton('aliyun.oss', function ($app) {
$config = $app->config->get('latrell-aliyun-oss');
$access_key_id = array_get($config, 'access_key_id', '');
$access_key_secret = array_get($config, 'access_key_secret', '');
$endpoint = array_get($config, 'endpoint', '');
$is_cname = array_get($config, 'is_cname', false);
$security_token = array_get($config, 'security_token', null);
return new OssClient($access_key_id, $access_key_secret, $endpoint, $is_cname, $security_token);
});
} | php | public function register()
{
$this->app->singleton('aliyun.oss', function ($app) {
$config = $app->config->get('latrell-aliyun-oss');
$access_key_id = array_get($config, 'access_key_id', '');
$access_key_secret = array_get($config, 'access_key_secret', '');
$endpoint = array_get($config, 'endpoint', '');
$is_cname = array_get($config, 'is_cname', false);
$security_token = array_get($config, 'security_token', null);
return new OssClient($access_key_id, $access_key_secret, $endpoint, $is_cname, $security_token);
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'aliyun.oss'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'latrell-aliyun-oss'",
")",
";",
"$",
"access_key_id",
"=",
"array_get",
"(",
"$",
"config",
",",
"'access_key_id'",
",",
"''",
")",
";",
"$",
"access_key_secret",
"=",
"array_get",
"(",
"$",
"config",
",",
"'access_key_secret'",
",",
"''",
")",
";",
"$",
"endpoint",
"=",
"array_get",
"(",
"$",
"config",
",",
"'endpoint'",
",",
"''",
")",
";",
"$",
"is_cname",
"=",
"array_get",
"(",
"$",
"config",
",",
"'is_cname'",
",",
"false",
")",
";",
"$",
"security_token",
"=",
"array_get",
"(",
"$",
"config",
",",
"'security_token'",
",",
"null",
")",
";",
"return",
"new",
"OssClient",
"(",
"$",
"access_key_id",
",",
"$",
"access_key_secret",
",",
"$",
"endpoint",
",",
"$",
"is_cname",
",",
"$",
"security_token",
")",
";",
"}",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/latrell/AliyunOss/blob/a50a796fdf7754af3128fbf68405e7ca589c43f9/src/AliyunOssServiceProvider.php#L32-L43 |
AydinHassan/cli-md-renderer | src/InlineRenderer/NewlineRenderer.php | NewlineRenderer.render | public function render(AbstractInline $inline, CliRenderer $renderer)
{
if (!($inline instanceof Newline)) {
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
}
return "\n";
} | php | public function render(AbstractInline $inline, CliRenderer $renderer)
{
if (!($inline instanceof Newline)) {
throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
}
return "\n";
} | [
"public",
"function",
"render",
"(",
"AbstractInline",
"$",
"inline",
",",
"CliRenderer",
"$",
"renderer",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"inline",
"instanceof",
"Newline",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Incompatible inline type: \"%s\"'",
",",
"get_class",
"(",
"$",
"inline",
")",
")",
")",
";",
"}",
"return",
"\"\\n\"",
";",
"}"
] | @param AbstractInline $inline
@param CliRenderer $renderer
@return string | [
"@param",
"AbstractInline",
"$inline",
"@param",
"CliRenderer",
"$renderer"
] | train | https://github.com/AydinHassan/cli-md-renderer/blob/521f9ace2aeadd58bf8a3910704be8360f5bd7b2/src/InlineRenderer/NewlineRenderer.php#L23-L30 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.value | public static function value($value) {
$values = func_get_args();
array_shift($values); // value entfernen
if (!in_array($value,$values)) {
throw new \Psc\Code\WrongValueException('Wert: "'.$value.'" ist unbekannt / nicht erlaubt. Erlaubt sind: ('.implode('|',$values).')');
}
return $value;
} | php | public static function value($value) {
$values = func_get_args();
array_shift($values); // value entfernen
if (!in_array($value,$values)) {
throw new \Psc\Code\WrongValueException('Wert: "'.$value.'" ist unbekannt / nicht erlaubt. Erlaubt sind: ('.implode('|',$values).')');
}
return $value;
} | [
"public",
"static",
"function",
"value",
"(",
"$",
"value",
")",
"{",
"$",
"values",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"values",
")",
";",
"// value entfernen",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"\\",
"Psc",
"\\",
"Code",
"\\",
"WrongValueException",
"(",
"'Wert: \"'",
".",
"$",
"value",
".",
"'\" ist unbekannt / nicht erlaubt. Erlaubt sind: ('",
".",
"implode",
"(",
"'|'",
",",
"$",
"values",
")",
".",
"')'",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Überprüft ob $value ein Wert aus den angegebenen erlaubten Werten ist
ist dies nicht der Fall wird eine Psc\Code\WrongValueException geworfen
ist dies der Fall wird $value zurückgegeben
@param mixed $value
@param mixed $value1,... | [
"Überprüft",
"ob",
"$value",
"ein",
"Wert",
"aus",
"den",
"angegebenen",
"erlaubten",
"Werten",
"ist"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L34-L43 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.dvalue | public static function dvalue(&$value, $defaultValue = NULL) {
$values = func_get_args();
array_shift($values); // value entfernen
if (!in_array($value,$values)) {
$value = array_shift($values);
}
return $value;
} | php | public static function dvalue(&$value, $defaultValue = NULL) {
$values = func_get_args();
array_shift($values); // value entfernen
if (!in_array($value,$values)) {
$value = array_shift($values);
}
return $value;
} | [
"public",
"static",
"function",
"dvalue",
"(",
"&",
"$",
"value",
",",
"$",
"defaultValue",
"=",
"NULL",
")",
"{",
"$",
"values",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"values",
")",
";",
"// value entfernen",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"values",
")",
")",
"{",
"$",
"value",
"=",
"array_shift",
"(",
"$",
"values",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Überprüft ob $value ein Wert aus den angegebenen erlaubten Werten ist, gibt einen Default zurück
ist $value nicht mit einem der angegeben Values identisch, wird keine Psc\Code\WrongValueException geworfen, sondern die erste angegeben Value auf $value gesetzt
diese Funktion modifiziert für den defaultFall also $value by reference
@param mixed $value
@param mixed $defaultValue
@param mixed $value2,... | [
"Überprüft",
"ob",
"$value",
"ein",
"Wert",
"aus",
"den",
"angegebenen",
"erlaubten",
"Werten",
"ist",
"gibt",
"einen",
"Default",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L55-L64 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.castId | public static function castId($id, $default = NULL) {
if (is_integer($id) && $id > 0) return $id;
if (ctype_digit($id) && ($id = (int) $id) && $id > 0) {
return $id;
} else {
return $default;
}
} | php | public static function castId($id, $default = NULL) {
if (is_integer($id) && $id > 0) return $id;
if (ctype_digit($id) && ($id = (int) $id) && $id > 0) {
return $id;
} else {
return $default;
}
} | [
"public",
"static",
"function",
"castId",
"(",
"$",
"id",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"id",
")",
"&&",
"$",
"id",
">",
"0",
")",
"return",
"$",
"id",
";",
"if",
"(",
"ctype_digit",
"(",
"$",
"id",
")",
"&&",
"(",
"$",
"id",
"=",
"(",
"int",
")",
"$",
"id",
")",
"&&",
"$",
"id",
">",
"0",
")",
"{",
"return",
"$",
"id",
";",
"}",
"else",
"{",
"return",
"$",
"default",
";",
"}",
"}"
] | Gibt die id als int zurück wenn $id > 0 ist ansonsten $default
sieht blöd aus, macht aber total viel Schreibarbeit wett
ist äquivalent zu:
self::cast($id, function ($id) { return $id > 0; }, 'integer', $default); | [
"Gibt",
"die",
"id",
"als",
"int",
"zurück",
"wenn",
"$id",
">",
"0",
"ist",
"ansonsten",
"$default"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L149-L156 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.cast | public static function cast($value, Closure $condition, $type, $default = NULL) {
return $condition($value) == TRUE ? settype($value, $type) : $default;
} | php | public static function cast($value, Closure $condition, $type, $default = NULL) {
return $condition($value) == TRUE ? settype($value, $type) : $default;
} | [
"public",
"static",
"function",
"cast",
"(",
"$",
"value",
",",
"Closure",
"$",
"condition",
",",
"$",
"type",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"return",
"$",
"condition",
"(",
"$",
"value",
")",
"==",
"TRUE",
"?",
"settype",
"(",
"$",
"value",
",",
"$",
"type",
")",
":",
"$",
"default",
";",
"}"
] | Gibt die $value als $type zurück wenn die $condition($value) TRUE ergibt, ansonsten $default
@param string $type object|array|bool|integer|null|string|float | [
"Gibt",
"die",
"$value",
"als",
"$type",
"zurück",
"wenn",
"die",
"$condition",
"(",
"$value",
")",
"TRUE",
"ergibt",
"ansonsten",
"$default"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L162-L164 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.getClass | public static function getClass($object) {
if (!is_object($object))
throw new \Psc\Exception('Cannot get Class from non-object value. '.self::varInfo($object));
return get_class($object);
} | php | public static function getClass($object) {
if (!is_object($object))
throw new \Psc\Exception('Cannot get Class from non-object value. '.self::varInfo($object));
return get_class($object);
} | [
"public",
"static",
"function",
"getClass",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"object",
")",
")",
"throw",
"new",
"\\",
"Psc",
"\\",
"Exception",
"(",
"'Cannot get Class from non-object value. '",
".",
"self",
"::",
"varInfo",
"(",
"$",
"object",
")",
")",
";",
"return",
"get_class",
"(",
"$",
"object",
")",
";",
"}"
] | Gibt die Klasse des Objektes zurück
@throws Exception wenn $object kein Objekt ist
@param mixed $object
@return string | [
"Gibt",
"die",
"Klasse",
"des",
"Objektes",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L173-L178 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.getNamespace | public static function getNamespace($className) {
$ns = NULL;
if (($p = mb_strrpos($className,'\\')) !== FALSE) {
$ns = mb_substr($className,0,$p);
}
if ($ns == '')
return NULL;
if (mb_strpos($className,'\\') !== 0) {
$ns = '\\'.$ns;
}
return $ns;
} | php | public static function getNamespace($className) {
$ns = NULL;
if (($p = mb_strrpos($className,'\\')) !== FALSE) {
$ns = mb_substr($className,0,$p);
}
if ($ns == '')
return NULL;
if (mb_strpos($className,'\\') !== 0) {
$ns = '\\'.$ns;
}
return $ns;
} | [
"public",
"static",
"function",
"getNamespace",
"(",
"$",
"className",
")",
"{",
"$",
"ns",
"=",
"NULL",
";",
"if",
"(",
"(",
"$",
"p",
"=",
"mb_strrpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
")",
"!==",
"FALSE",
")",
"{",
"$",
"ns",
"=",
"mb_substr",
"(",
"$",
"className",
",",
"0",
",",
"$",
"p",
")",
";",
"}",
"if",
"(",
"$",
"ns",
"==",
"''",
")",
"return",
"NULL",
";",
"if",
"(",
"mb_strpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
"!==",
"0",
")",
"{",
"$",
"ns",
"=",
"'\\\\'",
".",
"$",
"ns",
";",
"}",
"return",
"$",
"ns",
";",
"}"
] | Gibt den Namespace der Klasse zurück
gibt NULL zurück für Klassen die im Root-Namespace sind
deshalb ist es hiermit schwierig zu unterscheiden, ob ein nicht-FQN einen Namespace hat
getNamespace('\stdClass') === NULL // true
getNamespace('stdClass') === NULL // auch true
es kommt also jeweils auf den Kontext an in dem getNamespace auf einem String aufgerufen wird (vergleiche use in php)
dieser ist immer MIT \ davor
p.S: @TODO schöner wäre hier als immer immer immer mit \ zurückzugeben, dann wäre nämlich obiges Beispiel auch unterscheidbar | [
"Gibt",
"den",
"Namespace",
"der",
"Klasse",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L200-L213 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.expandNamespace | public static function expandNamespace($classOrClassName, $expandNamespace) {
if (mb_strpos($classOrClassName, '\\') !== 0 && self::getNamespace($classOrClassName) === NULL) {
return $expandNamespace.'\\'.ltrim($classOrClassName,'\\');
}
return $classOrClassName;
} | php | public static function expandNamespace($classOrClassName, $expandNamespace) {
if (mb_strpos($classOrClassName, '\\') !== 0 && self::getNamespace($classOrClassName) === NULL) {
return $expandNamespace.'\\'.ltrim($classOrClassName,'\\');
}
return $classOrClassName;
} | [
"public",
"static",
"function",
"expandNamespace",
"(",
"$",
"classOrClassName",
",",
"$",
"expandNamespace",
")",
"{",
"if",
"(",
"mb_strpos",
"(",
"$",
"classOrClassName",
",",
"'\\\\'",
")",
"!==",
"0",
"&&",
"self",
"::",
"getNamespace",
"(",
"$",
"classOrClassName",
")",
"===",
"NULL",
")",
"{",
"return",
"$",
"expandNamespace",
".",
"'\\\\'",
".",
"ltrim",
"(",
"$",
"classOrClassName",
",",
"'\\\\'",
")",
";",
"}",
"return",
"$",
"classOrClassName",
";",
"}"
] | Erweitert einen nicht qualifzierten Klassenamen mit einem Namespace
nicht qualifizierte Klassenamen sind diese ohne \ am Anfang und ohne self::getNamespace()
wird root als leer übergeben, ist nicht gewährleistet, dass für alle parameter ein \ vor der Klasse steht:
z. B. (blubb\className) wird nicht \blubb\className da blubb der namespace der klasse ist und somit nicht expanded wird
@param $expandNamespace ohne \ am Ende (für "root" also NULL übergeben) | [
"Erweitert",
"einen",
"nicht",
"qualifzierten",
"Klassenamen",
"mit",
"einem",
"Namespace"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L223-L229 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.getClassName | public static function getClassName($className) {
if (is_object($className)) $className = self::getClass($className);
$c = $className;
if (mb_strpos($className,'\\') !== FALSE) {
$p = explode('\\',$className);
$c = array_pop($p);
}
return $c;
} | php | public static function getClassName($className) {
if (is_object($className)) $className = self::getClass($className);
$c = $className;
if (mb_strpos($className,'\\') !== FALSE) {
$p = explode('\\',$className);
$c = array_pop($p);
}
return $c;
} | [
"public",
"static",
"function",
"getClassName",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"className",
")",
")",
"$",
"className",
"=",
"self",
"::",
"getClass",
"(",
"$",
"className",
")",
";",
"$",
"c",
"=",
"$",
"className",
";",
"if",
"(",
"mb_strpos",
"(",
"$",
"className",
",",
"'\\\\'",
")",
"!==",
"FALSE",
")",
"{",
"$",
"p",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"className",
")",
";",
"$",
"c",
"=",
"array_pop",
"(",
"$",
"p",
")",
";",
"}",
"return",
"$",
"c",
";",
"}"
] | Gibt nur den Namen (ohne Namespace) ohne \ davor zurück
@param string|object $className | [
"Gibt",
"nur",
"den",
"Namen",
"(",
"ohne",
"Namespace",
")",
"ohne",
"\\",
"davor",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L235-L244 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.namespaceToPath | public static function namespaceToPath($namespace, Dir $classPath = NULL) {
// end und anfangs backslashs weg
$namespace = trim($namespace,'\\');
if (!isset($classPath)) {
$classPath = new Dir('.'.DIRECTORY_SEPARATOR);
}
return $classPath->sub(str_replace('\\','/',$namespace).'/');
} | php | public static function namespaceToPath($namespace, Dir $classPath = NULL) {
// end und anfangs backslashs weg
$namespace = trim($namespace,'\\');
if (!isset($classPath)) {
$classPath = new Dir('.'.DIRECTORY_SEPARATOR);
}
return $classPath->sub(str_replace('\\','/',$namespace).'/');
} | [
"public",
"static",
"function",
"namespaceToPath",
"(",
"$",
"namespace",
",",
"Dir",
"$",
"classPath",
"=",
"NULL",
")",
"{",
"// end und anfangs backslashs weg",
"$",
"namespace",
"=",
"trim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"classPath",
")",
")",
"{",
"$",
"classPath",
"=",
"new",
"Dir",
"(",
"'.'",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"}",
"return",
"$",
"classPath",
"->",
"sub",
"(",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"namespace",
")",
".",
"'/'",
")",
";",
"}"
] | Gibt das Verzeichnis eines Namespaces in einem Verzeichnis zurück
dies nimmt einfach den Namespace
@return Dir absolute im angebenen $classPath oder relatives Verzeichnis | [
"Gibt",
"das",
"Verzeichnis",
"eines",
"Namespaces",
"in",
"einem",
"Verzeichnis",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L253-L262 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.mapClassToFile | public static function mapClassToFile($classFQN, Dir $root = NULL) {
$ns = self::getNamespace($classFQN);
$c = self::getClassName($classFQN);
if (!isset($root)) {
$root = new Dir('.'.DIRECTORY_SEPARATOR);
}
return new File(self::namespaceToPath($ns, $root), $c.'.php');
} | php | public static function mapClassToFile($classFQN, Dir $root = NULL) {
$ns = self::getNamespace($classFQN);
$c = self::getClassName($classFQN);
if (!isset($root)) {
$root = new Dir('.'.DIRECTORY_SEPARATOR);
}
return new File(self::namespaceToPath($ns, $root), $c.'.php');
} | [
"public",
"static",
"function",
"mapClassToFile",
"(",
"$",
"classFQN",
",",
"Dir",
"$",
"root",
"=",
"NULL",
")",
"{",
"$",
"ns",
"=",
"self",
"::",
"getNamespace",
"(",
"$",
"classFQN",
")",
";",
"$",
"c",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"classFQN",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"root",
")",
")",
"{",
"$",
"root",
"=",
"new",
"Dir",
"(",
"'.'",
".",
"DIRECTORY_SEPARATOR",
")",
";",
"}",
"return",
"new",
"File",
"(",
"self",
"::",
"namespaceToPath",
"(",
"$",
"ns",
",",
"$",
"root",
")",
",",
"$",
"c",
".",
"'.php'",
")",
";",
"}"
] | Gibt den Dateinamen zu einer Klasse zurück
Konvention: der relative Pfad zur Datei der Namespace wird mit Verzeichnissen abgebildet der Klassenname als php-Datei
@return File wenn $root gesetzt ist dies der absolute pfad, sonst relativ | [
"Gibt",
"den",
"Dateinamen",
"zu",
"einer",
"Klasse",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L270-L279 |
webforge-labs/psc-cms | lib/Psc/Code/Code.php | Code.mapFileToClass | public static function mapFileToClass(File $classFile, Dir $root = NULL, $style = '\\') {
$classDir = clone $classFile->getDirectory();
if (isset($root))
$classDir->makeRelativeTo($root);
$pa = $classDir->getPathArray();
if ($style === '\\') {
$ns = (count($pa) > 1) ? '\\'.implode('\\',array_slice($pa,1)) : NULL;
return $ns.'\\'.$classFile->getName(File::WITHOUT_EXTENSION);
} elseif ($style === '_') {
$parts = (count($pa) > 1) ? array_slice($pa,1) : array();
$parts[] = $classFile->getName(File::WITHOUT_EXTENSION);
return implode('_',$parts);
} else {
\Psc\Exception('Der Style: '.self::varInfo($style).' ist nicht bekannt');
}
} | php | public static function mapFileToClass(File $classFile, Dir $root = NULL, $style = '\\') {
$classDir = clone $classFile->getDirectory();
if (isset($root))
$classDir->makeRelativeTo($root);
$pa = $classDir->getPathArray();
if ($style === '\\') {
$ns = (count($pa) > 1) ? '\\'.implode('\\',array_slice($pa,1)) : NULL;
return $ns.'\\'.$classFile->getName(File::WITHOUT_EXTENSION);
} elseif ($style === '_') {
$parts = (count($pa) > 1) ? array_slice($pa,1) : array();
$parts[] = $classFile->getName(File::WITHOUT_EXTENSION);
return implode('_',$parts);
} else {
\Psc\Exception('Der Style: '.self::varInfo($style).' ist nicht bekannt');
}
} | [
"public",
"static",
"function",
"mapFileToClass",
"(",
"File",
"$",
"classFile",
",",
"Dir",
"$",
"root",
"=",
"NULL",
",",
"$",
"style",
"=",
"'\\\\'",
")",
"{",
"$",
"classDir",
"=",
"clone",
"$",
"classFile",
"->",
"getDirectory",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"root",
")",
")",
"$",
"classDir",
"->",
"makeRelativeTo",
"(",
"$",
"root",
")",
";",
"$",
"pa",
"=",
"$",
"classDir",
"->",
"getPathArray",
"(",
")",
";",
"if",
"(",
"$",
"style",
"===",
"'\\\\'",
")",
"{",
"$",
"ns",
"=",
"(",
"count",
"(",
"$",
"pa",
")",
">",
"1",
")",
"?",
"'\\\\'",
".",
"implode",
"(",
"'\\\\'",
",",
"array_slice",
"(",
"$",
"pa",
",",
"1",
")",
")",
":",
"NULL",
";",
"return",
"$",
"ns",
".",
"'\\\\'",
".",
"$",
"classFile",
"->",
"getName",
"(",
"File",
"::",
"WITHOUT_EXTENSION",
")",
";",
"}",
"elseif",
"(",
"$",
"style",
"===",
"'_'",
")",
"{",
"$",
"parts",
"=",
"(",
"count",
"(",
"$",
"pa",
")",
">",
"1",
")",
"?",
"array_slice",
"(",
"$",
"pa",
",",
"1",
")",
":",
"array",
"(",
")",
";",
"$",
"parts",
"[",
"]",
"=",
"$",
"classFile",
"->",
"getName",
"(",
"File",
"::",
"WITHOUT_EXTENSION",
")",
";",
"return",
"implode",
"(",
"'_'",
",",
"$",
"parts",
")",
";",
"}",
"else",
"{",
"\\",
"Psc",
"\\",
"Exception",
"(",
"'Der Style: '",
".",
"self",
"::",
"varInfo",
"(",
"$",
"style",
")",
".",
"' ist nicht bekannt'",
")",
";",
"}",
"}"
] | Gibt den Namen der Klasse für eine Datei zurück
beruht auf der Konvention, dass jedes Verzeichnis ein Namespace ist und der Dateiname der Klassename ist
Beispiel siehe Test
@param Dir $root darf nicht das verzeichnis des Namespaces sein. also nicht base\src\SerienLoader sondern base\src\
@param string $style wird _ übergeben wird z. B. der PHPWord Style benutzt (PSR-0 mit Underscore)
@return string class mit \ davor | [
"Gibt",
"den",
"Namen",
"der",
"Klasse",
"für",
"eine",
"Datei",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Code.php#L293-L312 |
Chill-project/Main | Security/Authorization/AuthorizationHelper.php | AuthorizationHelper.userCanReachCenter | public function userCanReachCenter(User $user, Center $center)
{
foreach ($user->getGroupCenters() as $groupCenter) {
if ($center->getId() === $groupCenter->getCenter()->getId()) {
return true;
}
}
return false;
} | php | public function userCanReachCenter(User $user, Center $center)
{
foreach ($user->getGroupCenters() as $groupCenter) {
if ($center->getId() === $groupCenter->getCenter()->getId()) {
return true;
}
}
return false;
} | [
"public",
"function",
"userCanReachCenter",
"(",
"User",
"$",
"user",
",",
"Center",
"$",
"center",
")",
"{",
"foreach",
"(",
"$",
"user",
"->",
"getGroupCenters",
"(",
")",
"as",
"$",
"groupCenter",
")",
"{",
"if",
"(",
"$",
"center",
"->",
"getId",
"(",
")",
"===",
"$",
"groupCenter",
"->",
"getCenter",
"(",
")",
"->",
"getId",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Determines if a user is active on this center
@param User $user
@param Center $center
@return bool | [
"Determines",
"if",
"a",
"user",
"is",
"active",
"on",
"this",
"center"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L60-L70 |
Chill-project/Main | Security/Authorization/AuthorizationHelper.php | AuthorizationHelper.getReachableCenters | public function getReachableCenters(User $user, Role $role, Scope $scope = null)
{
$centers = array();
foreach ($user->getGroupCenters() as $groupCenter){
$permissionGroup = $groupCenter->getPermissionsGroup();
//iterate on roleScopes
foreach($permissionGroup->getRoleScopes() as $roleScope) {
//check that the role is in the reachable roles
if ($this->isRoleReached($role,
new Role($roleScope->getRole()))) {
if ($scope === null) {
$centers[] = $groupCenter->getCenter();
break 1;
} else {
if ($scope->getId() == $roleScope->getScope()->getId()){
$centers[] = $groupCenter->getCenter();
break 1;
}
}
}
}
}
return $centers;
} | php | public function getReachableCenters(User $user, Role $role, Scope $scope = null)
{
$centers = array();
foreach ($user->getGroupCenters() as $groupCenter){
$permissionGroup = $groupCenter->getPermissionsGroup();
//iterate on roleScopes
foreach($permissionGroup->getRoleScopes() as $roleScope) {
//check that the role is in the reachable roles
if ($this->isRoleReached($role,
new Role($roleScope->getRole()))) {
if ($scope === null) {
$centers[] = $groupCenter->getCenter();
break 1;
} else {
if ($scope->getId() == $roleScope->getScope()->getId()){
$centers[] = $groupCenter->getCenter();
break 1;
}
}
}
}
}
return $centers;
} | [
"public",
"function",
"getReachableCenters",
"(",
"User",
"$",
"user",
",",
"Role",
"$",
"role",
",",
"Scope",
"$",
"scope",
"=",
"null",
")",
"{",
"$",
"centers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"user",
"->",
"getGroupCenters",
"(",
")",
"as",
"$",
"groupCenter",
")",
"{",
"$",
"permissionGroup",
"=",
"$",
"groupCenter",
"->",
"getPermissionsGroup",
"(",
")",
";",
"//iterate on roleScopes",
"foreach",
"(",
"$",
"permissionGroup",
"->",
"getRoleScopes",
"(",
")",
"as",
"$",
"roleScope",
")",
"{",
"//check that the role is in the reachable roles",
"if",
"(",
"$",
"this",
"->",
"isRoleReached",
"(",
"$",
"role",
",",
"new",
"Role",
"(",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
")",
")",
")",
"{",
"if",
"(",
"$",
"scope",
"===",
"null",
")",
"{",
"$",
"centers",
"[",
"]",
"=",
"$",
"groupCenter",
"->",
"getCenter",
"(",
")",
";",
"break",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"scope",
"->",
"getId",
"(",
")",
"==",
"$",
"roleScope",
"->",
"getScope",
"(",
")",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"centers",
"[",
"]",
"=",
"$",
"groupCenter",
"->",
"getCenter",
"(",
")",
";",
"break",
"1",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"centers",
";",
"}"
] | Get reachable Centers for the given user, role,
and optionnaly Scope
@param User $user
@param Role $role
@param null|Scope $scope
@return Center[] | [
"Get",
"reachable",
"Centers",
"for",
"the",
"given",
"user",
"role",
"and",
"optionnaly",
"Scope"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L136-L162 |
Chill-project/Main | Security/Authorization/AuthorizationHelper.php | AuthorizationHelper.getReachableScopes | public function getReachableScopes(User $user, Role $role, Center $center)
{
return $this->getReachableCircles($user, $role, $center);
} | php | public function getReachableScopes(User $user, Role $role, Center $center)
{
return $this->getReachableCircles($user, $role, $center);
} | [
"public",
"function",
"getReachableScopes",
"(",
"User",
"$",
"user",
",",
"Role",
"$",
"role",
",",
"Center",
"$",
"center",
")",
"{",
"return",
"$",
"this",
"->",
"getReachableCircles",
"(",
"$",
"user",
",",
"$",
"role",
",",
"$",
"center",
")",
";",
"}"
] | Return all reachable scope for a given user, center and role
@deprecated Use getReachableCircles
@param User $user
@param Role $role
@param Center $center
@return Scope[] | [
"Return",
"all",
"reachable",
"scope",
"for",
"a",
"given",
"user",
"center",
"and",
"role"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L174-L177 |
Chill-project/Main | Security/Authorization/AuthorizationHelper.php | AuthorizationHelper.getReachableCircles | public function getReachableCircles(User $user, Role $role, Center $center)
{
$scopes = array();
foreach ($user->getGroupCenters() as $groupCenter){
if ($center->getId() === $groupCenter->getCenter()->getId()) {
//iterate on permissionGroup
$permissionGroup = $groupCenter->getPermissionsGroup();
//iterate on roleScopes
foreach($permissionGroup->getRoleScopes() as $roleScope) {
//check that the role is in the reachable roles
if ($this->isRoleReached($role,
new Role($roleScope->getRole()))) {
$scopes[] = $roleScope->getScope();
}
}
}
}
return $scopes;
} | php | public function getReachableCircles(User $user, Role $role, Center $center)
{
$scopes = array();
foreach ($user->getGroupCenters() as $groupCenter){
if ($center->getId() === $groupCenter->getCenter()->getId()) {
//iterate on permissionGroup
$permissionGroup = $groupCenter->getPermissionsGroup();
//iterate on roleScopes
foreach($permissionGroup->getRoleScopes() as $roleScope) {
//check that the role is in the reachable roles
if ($this->isRoleReached($role,
new Role($roleScope->getRole()))) {
$scopes[] = $roleScope->getScope();
}
}
}
}
return $scopes;
} | [
"public",
"function",
"getReachableCircles",
"(",
"User",
"$",
"user",
",",
"Role",
"$",
"role",
",",
"Center",
"$",
"center",
")",
"{",
"$",
"scopes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"user",
"->",
"getGroupCenters",
"(",
")",
"as",
"$",
"groupCenter",
")",
"{",
"if",
"(",
"$",
"center",
"->",
"getId",
"(",
")",
"===",
"$",
"groupCenter",
"->",
"getCenter",
"(",
")",
"->",
"getId",
"(",
")",
")",
"{",
"//iterate on permissionGroup",
"$",
"permissionGroup",
"=",
"$",
"groupCenter",
"->",
"getPermissionsGroup",
"(",
")",
";",
"//iterate on roleScopes",
"foreach",
"(",
"$",
"permissionGroup",
"->",
"getRoleScopes",
"(",
")",
"as",
"$",
"roleScope",
")",
"{",
"//check that the role is in the reachable roles",
"if",
"(",
"$",
"this",
"->",
"isRoleReached",
"(",
"$",
"role",
",",
"new",
"Role",
"(",
"$",
"roleScope",
"->",
"getRole",
"(",
")",
")",
")",
")",
"{",
"$",
"scopes",
"[",
"]",
"=",
"$",
"roleScope",
"->",
"getScope",
"(",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"scopes",
";",
"}"
] | Return all reachable circle for a given user, center and role
@param User $user
@param Role $role
@param Center $center
@return Scope[] | [
"Return",
"all",
"reachable",
"circle",
"for",
"a",
"given",
"user",
"center",
"and",
"role"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L187-L208 |
Chill-project/Main | Security/Authorization/AuthorizationHelper.php | AuthorizationHelper.isRoleReached | protected function isRoleReached(Role $childRole, Role $parentRole)
{
$reachableRoles = $this->roleHierarchy
->getReachableRoles([$parentRole]);
return in_array($childRole, $reachableRoles);
} | php | protected function isRoleReached(Role $childRole, Role $parentRole)
{
$reachableRoles = $this->roleHierarchy
->getReachableRoles([$parentRole]);
return in_array($childRole, $reachableRoles);
} | [
"protected",
"function",
"isRoleReached",
"(",
"Role",
"$",
"childRole",
",",
"Role",
"$",
"parentRole",
")",
"{",
"$",
"reachableRoles",
"=",
"$",
"this",
"->",
"roleHierarchy",
"->",
"getReachableRoles",
"(",
"[",
"$",
"parentRole",
"]",
")",
";",
"return",
"in_array",
"(",
"$",
"childRole",
",",
"$",
"reachableRoles",
")",
";",
"}"
] | Test if a parent role may give access to a given child role
@param Role $childRole The role we want to test if he is reachable
@param Role $parentRole The role which should give access to $childRole
@return boolean true if the child role is granted by parent role | [
"Test",
"if",
"a",
"parent",
"role",
"may",
"give",
"access",
"to",
"a",
"given",
"child",
"role"
] | train | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Security/Authorization/AuthorizationHelper.php#L219-L225 |
vi-kon/laravel-auth | src/database/migrations/2014_08_27_000003_create_user_password_reminders_table.php | CreateUserPasswordRemindersTable.up | public function up()
{
$schema = app()->make('db')->connection()->getSchemaBuilder();
$schema->create(config('vi-kon.auth.table.user_password_reminders'), function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->unsignedInteger('user_id');
$table->foreign('user_id')
->references('id')
->on('users')
->onUpdate('cascade')
->onDelete('cascade');
$table->string('token');
$table->timestamps();
});
} | php | public function up()
{
$schema = app()->make('db')->connection()->getSchemaBuilder();
$schema->create(config('vi-kon.auth.table.user_password_reminders'), function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->unsignedInteger('user_id');
$table->foreign('user_id')
->references('id')
->on('users')
->onUpdate('cascade')
->onDelete('cascade');
$table->string('token');
$table->timestamps();
});
} | [
"public",
"function",
"up",
"(",
")",
"{",
"$",
"schema",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"'db'",
")",
"->",
"connection",
"(",
")",
"->",
"getSchemaBuilder",
"(",
")",
";",
"$",
"schema",
"->",
"create",
"(",
"config",
"(",
"'vi-kon.auth.table.user_password_reminders'",
")",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"engine",
"=",
"'InnoDB'",
";",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"unsignedInteger",
"(",
"'user_id'",
")",
";",
"$",
"table",
"->",
"foreign",
"(",
"'user_id'",
")",
"->",
"references",
"(",
"'id'",
")",
"->",
"on",
"(",
"'users'",
")",
"->",
"onUpdate",
"(",
"'cascade'",
")",
"->",
"onDelete",
"(",
"'cascade'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'token'",
")",
";",
"$",
"table",
"->",
"timestamps",
"(",
")",
";",
"}",
")",
";",
"}"
] | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/vi-kon/laravel-auth/blob/501c20128f43347a2ca271a53435297f9ef7f567/src/database/migrations/2014_08_27_000003_create_user_password_reminders_table.php#L18-L35 |
aedart/laravel-helpers | src/Traits/Cache/CacheStoreTrait.php | CacheStoreTrait.getCacheStore | public function getCacheStore(): ?Store
{
if (!$this->hasCacheStore()) {
$this->setCacheStore($this->getDefaultCacheStore());
}
return $this->cacheStore;
} | php | public function getCacheStore(): ?Store
{
if (!$this->hasCacheStore()) {
$this->setCacheStore($this->getDefaultCacheStore());
}
return $this->cacheStore;
} | [
"public",
"function",
"getCacheStore",
"(",
")",
":",
"?",
"Store",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasCacheStore",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setCacheStore",
"(",
"$",
"this",
"->",
"getDefaultCacheStore",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cacheStore",
";",
"}"
] | Get cache store
If no cache store has been set, this method will
set and return a default cache store, if any such
value is available
@see getDefaultCacheStore()
@return Store|null cache store or null if none cache store has been set | [
"Get",
"cache",
"store"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Cache/CacheStoreTrait.php#L54-L60 |
aedart/laravel-helpers | src/Traits/Cache/CacheStoreTrait.php | CacheStoreTrait.getDefaultCacheStore | public function getDefaultCacheStore(): ?Store
{
// We do not know what store is desired. Therefore,
// the safest bet is to obtain the default
$manager = Cache::getFacadeRoot();
if (isset($manager)) {
/** @var Repository $repository */
$repository = $manager->store();
return $repository->getStore();
}
return $manager;
} | php | public function getDefaultCacheStore(): ?Store
{
// We do not know what store is desired. Therefore,
// the safest bet is to obtain the default
$manager = Cache::getFacadeRoot();
if (isset($manager)) {
/** @var Repository $repository */
$repository = $manager->store();
return $repository->getStore();
}
return $manager;
} | [
"public",
"function",
"getDefaultCacheStore",
"(",
")",
":",
"?",
"Store",
"{",
"// We do not know what store is desired. Therefore,",
"// the safest bet is to obtain the default",
"$",
"manager",
"=",
"Cache",
"::",
"getFacadeRoot",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"manager",
")",
")",
"{",
"/** @var Repository $repository */",
"$",
"repository",
"=",
"$",
"manager",
"->",
"store",
"(",
")",
";",
"return",
"$",
"repository",
"->",
"getStore",
"(",
")",
";",
"}",
"return",
"$",
"manager",
";",
"}"
] | Get a default cache store value, if any is available
@return Store|null A default cache store value or Null if no default value is available | [
"Get",
"a",
"default",
"cache",
"store",
"value",
"if",
"any",
"is",
"available"
] | train | https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Cache/CacheStoreTrait.php#L77-L88 |
prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/CasThreadedMemberTrait.php | CasThreadedMemberTrait.casMember | public function casMember($member, $oldValue, $newValue)
{
$set = false;
$this->lock();
if ($this[$member] == $oldValue) {
$this[$member] = $newValue;
$set = true;
}
$this->unlock();
return $set;
} | php | public function casMember($member, $oldValue, $newValue)
{
$set = false;
$this->lock();
if ($this[$member] == $oldValue) {
$this[$member] = $newValue;
$set = true;
}
$this->unlock();
return $set;
} | [
"public",
"function",
"casMember",
"(",
"$",
"member",
",",
"$",
"oldValue",
",",
"$",
"newValue",
")",
"{",
"$",
"set",
"=",
"false",
";",
"$",
"this",
"->",
"lock",
"(",
")",
";",
"if",
"(",
"$",
"this",
"[",
"$",
"member",
"]",
"==",
"$",
"oldValue",
")",
"{",
"$",
"this",
"[",
"$",
"member",
"]",
"=",
"$",
"newValue",
";",
"$",
"set",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"unlock",
"(",
")",
";",
"return",
"$",
"set",
";",
"}"
] | Performs a compare and swap operation on a class member
@param string $member
@param mixed $oldValue
@param mixed $newValue
@return bool | [
"Performs",
"a",
"compare",
"and",
"swap",
"operation",
"on",
"a",
"class",
"member"
] | train | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/CasThreadedMemberTrait.php#L20-L33 |
dunkelfrosch/phpcoverfish | src/PHPCoverFish/Validator/ValidatorClassName.php | ValidatorClassName.getMapping | public function getMapping(CoverFishPHPUnitFile $phpUnitFile)
{
$class = $this->getResult()['class'];
// fqn detected? fully qualified classNames will be used directly without any kind of counterCheck
// against use statement(s) - otherwise classFQN will be taken from use statement directly.
$classFQN = $this->coverFishHelper->getClassFromUse($class, $phpUnitFile->getUsedClasses());
if (true === $this->coverFishHelper->checkClassHasFQN($class)) {
$classFQN = $class;
$class = $this->coverFishHelper->getClassNameFromClassFQN($classFQN);
}
$mappingOptions = array(
'coverToken' => $this->coversToken,
'coverMethod' => null,
'coverAccessor' => null,
'coverClass' => $class,
'coverClassFQN' => $classFQN,
'validatorMatch' => $this->getValidationTag(),
'validatorClass' => get_class($this)
);
return $this->setMapping($mappingOptions);
} | php | public function getMapping(CoverFishPHPUnitFile $phpUnitFile)
{
$class = $this->getResult()['class'];
// fqn detected? fully qualified classNames will be used directly without any kind of counterCheck
// against use statement(s) - otherwise classFQN will be taken from use statement directly.
$classFQN = $this->coverFishHelper->getClassFromUse($class, $phpUnitFile->getUsedClasses());
if (true === $this->coverFishHelper->checkClassHasFQN($class)) {
$classFQN = $class;
$class = $this->coverFishHelper->getClassNameFromClassFQN($classFQN);
}
$mappingOptions = array(
'coverToken' => $this->coversToken,
'coverMethod' => null,
'coverAccessor' => null,
'coverClass' => $class,
'coverClassFQN' => $classFQN,
'validatorMatch' => $this->getValidationTag(),
'validatorClass' => get_class($this)
);
return $this->setMapping($mappingOptions);
} | [
"public",
"function",
"getMapping",
"(",
"CoverFishPHPUnitFile",
"$",
"phpUnitFile",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getResult",
"(",
")",
"[",
"'class'",
"]",
";",
"// fqn detected? fully qualified classNames will be used directly without any kind of counterCheck",
"// against use statement(s) - otherwise classFQN will be taken from use statement directly.",
"$",
"classFQN",
"=",
"$",
"this",
"->",
"coverFishHelper",
"->",
"getClassFromUse",
"(",
"$",
"class",
",",
"$",
"phpUnitFile",
"->",
"getUsedClasses",
"(",
")",
")",
";",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"coverFishHelper",
"->",
"checkClassHasFQN",
"(",
"$",
"class",
")",
")",
"{",
"$",
"classFQN",
"=",
"$",
"class",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"coverFishHelper",
"->",
"getClassNameFromClassFQN",
"(",
"$",
"classFQN",
")",
";",
"}",
"$",
"mappingOptions",
"=",
"array",
"(",
"'coverToken'",
"=>",
"$",
"this",
"->",
"coversToken",
",",
"'coverMethod'",
"=>",
"null",
",",
"'coverAccessor'",
"=>",
"null",
",",
"'coverClass'",
"=>",
"$",
"class",
",",
"'coverClassFQN'",
"=>",
"$",
"classFQN",
",",
"'validatorMatch'",
"=>",
"$",
"this",
"->",
"getValidationTag",
"(",
")",
",",
"'validatorClass'",
"=>",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"return",
"$",
"this",
"->",
"setMapping",
"(",
"$",
"mappingOptions",
")",
";",
"}"
] | @param CoverFishPHPUnitFile $phpUnitFile
@return array | [
"@param",
"CoverFishPHPUnitFile",
"$phpUnitFile"
] | train | https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Validator/ValidatorClassName.php#L52-L74 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/NotificationCenterController.php | NotificationCenterController.indexAction | public function indexAction()
{
$id = $this->getUser()->getId();
/** @var User $oUser */
$oUser = UserQuery::create()->findOneById($id);
$form = $this->createFormBuilder($oUser)
->setAction($this->generateUrl("notification_center_update"))
->add('notification_change', 'checkbox')
->add('notification_error', 'checkbox')
->add('save', 'submit', array('label' => $this->get('translator')->trans('notificationcenter.form.save')))
->getForm();
return $this->render('SlashworksAppBundle:NotificationCenter:index.html.twig', array(
'user' => $oUser,
'form' => $form->createView()
));
} | php | public function indexAction()
{
$id = $this->getUser()->getId();
/** @var User $oUser */
$oUser = UserQuery::create()->findOneById($id);
$form = $this->createFormBuilder($oUser)
->setAction($this->generateUrl("notification_center_update"))
->add('notification_change', 'checkbox')
->add('notification_error', 'checkbox')
->add('save', 'submit', array('label' => $this->get('translator')->trans('notificationcenter.form.save')))
->getForm();
return $this->render('SlashworksAppBundle:NotificationCenter:index.html.twig', array(
'user' => $oUser,
'form' => $form->createView()
));
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
";",
"/** @var User $oUser */",
"$",
"oUser",
"=",
"UserQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createFormBuilder",
"(",
"$",
"oUser",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"\"notification_center_update\"",
")",
")",
"->",
"add",
"(",
"'notification_change'",
",",
"'checkbox'",
")",
"->",
"add",
"(",
"'notification_error'",
",",
"'checkbox'",
")",
"->",
"add",
"(",
"'save'",
",",
"'submit'",
",",
"array",
"(",
"'label'",
"=>",
"$",
"this",
"->",
"get",
"(",
"'translator'",
")",
"->",
"trans",
"(",
"'notificationcenter.form.save'",
")",
")",
")",
"->",
"getForm",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'SlashworksAppBundle:NotificationCenter:index.html.twig'",
",",
"array",
"(",
"'user'",
"=>",
"$",
"oUser",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
")",
")",
";",
"}"
] | Display form for notification settings
@return \Symfony\Component\HttpFoundation\Response | [
"Display",
"form",
"for",
"notification",
"settings"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/NotificationCenterController.php#L41-L61 |
slashworks/control-bundle | src/Slashworks/AppBundle/Controller/NotificationCenterController.php | NotificationCenterController.updateAction | public function updateAction(Request $request)
{
try {
$id = $this->getUser()->getId();
/** @var User $oUser */
$oUser = UserQuery::create()->findOneById($id);
if ($oUser === null) {
throw $this->createNotFoundException('Unable to find User entity.');
}
$aPost = $request->request->get("form");
$nbUpdatedRows = UserQuery::create()
->filterById($id)
->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change'])));
$aResult = array(
"success" => true,
"message" => $this->get("translator")->trans("notificationcenter.save.successful")
);
} catch (\Exception $e) {
$aResult = array(
"success" => false,
"message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage()
);
}
$sResult = json_encode($aResult);
$response = new Response($sResult);
$response->headers->set('Content-Type', 'application/json');
return $response;
} | php | public function updateAction(Request $request)
{
try {
$id = $this->getUser()->getId();
/** @var User $oUser */
$oUser = UserQuery::create()->findOneById($id);
if ($oUser === null) {
throw $this->createNotFoundException('Unable to find User entity.');
}
$aPost = $request->request->get("form");
$nbUpdatedRows = UserQuery::create()
->filterById($id)
->update(array('NotificationError' => isset($aPost['notification_error']), 'NotificationChange' => isset($aPost['notification_change'])));
$aResult = array(
"success" => true,
"message" => $this->get("translator")->trans("notificationcenter.save.successful")
);
} catch (\Exception $e) {
$aResult = array(
"success" => false,
"message" => $this->get("translator")->trans("notificationcenter.save.failed") . ":<br>" . $e->getMessage()
);
}
$sResult = json_encode($aResult);
$response = new Response($sResult);
$response->headers->set('Content-Type', 'application/json');
return $response;
} | [
"public",
"function",
"updateAction",
"(",
"Request",
"$",
"request",
")",
"{",
"try",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
";",
"/** @var User $oUser */",
"$",
"oUser",
"=",
"UserQuery",
"::",
"create",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"oUser",
"===",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find User entity.'",
")",
";",
"}",
"$",
"aPost",
"=",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"\"form\"",
")",
";",
"$",
"nbUpdatedRows",
"=",
"UserQuery",
"::",
"create",
"(",
")",
"->",
"filterById",
"(",
"$",
"id",
")",
"->",
"update",
"(",
"array",
"(",
"'NotificationError'",
"=>",
"isset",
"(",
"$",
"aPost",
"[",
"'notification_error'",
"]",
")",
",",
"'NotificationChange'",
"=>",
"isset",
"(",
"$",
"aPost",
"[",
"'notification_change'",
"]",
")",
")",
")",
";",
"$",
"aResult",
"=",
"array",
"(",
"\"success\"",
"=>",
"true",
",",
"\"message\"",
"=>",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"notificationcenter.save.successful\"",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"aResult",
"=",
"array",
"(",
"\"success\"",
"=>",
"false",
",",
"\"message\"",
"=>",
"$",
"this",
"->",
"get",
"(",
"\"translator\"",
")",
"->",
"trans",
"(",
"\"notificationcenter.save.failed\"",
")",
".",
"\":<br>\"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"sResult",
"=",
"json_encode",
"(",
"$",
"aResult",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"$",
"sResult",
")",
";",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Update notification settings
@param \Symfony\Component\HttpFoundation\Request $request
@return \Symfony\Component\HttpFoundation\Response | [
"Update",
"notification",
"settings"
] | train | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Controller/NotificationCenterController.php#L71-L110 |
jenwachter/html-form | src/Elements/Parents/Option.php | Option.compile | public function compile($value = "")
{
$html = $this->compiledLabel;
if (!empty($this->help)) {
$html .= "<div class='help'>{$this->help}</div>";
}
$html .= "<div class=\"elements\">";
$hasOptionValue = $this->hasOptionValue($this->options);
foreach ($this->options as $k => $v) {
$html .= "<div class=\"element\"><input type=\"{$this->type}\" {$this->compiledAttr} ";
$html .= "name=\"" . $this->name;
if ($this->type == "checkbox") {
$html .= "[]";
}
$html .= "\" ";
// handle options in an associative array differently than ones in a numeric array
if ($hasOptionValue || $this->useNumericValue) {
$html .= "value=\"{$k}\" ";
if ($k === $value || (is_array($value) && in_array($k, $value))) {
$html .= "checked=\"checked\"";
}
} else {
$html .= "value=\"{$v}\" ";
if ($v === $value || (is_array($value) && in_array($v, $value))) {
$html .= "checked=\"checked\"";
}
}
$html .= " /> <span>{$v}</span></div>";
}
$html .= "</div>";
return $html;
} | php | public function compile($value = "")
{
$html = $this->compiledLabel;
if (!empty($this->help)) {
$html .= "<div class='help'>{$this->help}</div>";
}
$html .= "<div class=\"elements\">";
$hasOptionValue = $this->hasOptionValue($this->options);
foreach ($this->options as $k => $v) {
$html .= "<div class=\"element\"><input type=\"{$this->type}\" {$this->compiledAttr} ";
$html .= "name=\"" . $this->name;
if ($this->type == "checkbox") {
$html .= "[]";
}
$html .= "\" ";
// handle options in an associative array differently than ones in a numeric array
if ($hasOptionValue || $this->useNumericValue) {
$html .= "value=\"{$k}\" ";
if ($k === $value || (is_array($value) && in_array($k, $value))) {
$html .= "checked=\"checked\"";
}
} else {
$html .= "value=\"{$v}\" ";
if ($v === $value || (is_array($value) && in_array($v, $value))) {
$html .= "checked=\"checked\"";
}
}
$html .= " /> <span>{$v}</span></div>";
}
$html .= "</div>";
return $html;
} | [
"public",
"function",
"compile",
"(",
"$",
"value",
"=",
"\"\"",
")",
"{",
"$",
"html",
"=",
"$",
"this",
"->",
"compiledLabel",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"help",
")",
")",
"{",
"$",
"html",
".=",
"\"<div class='help'>{$this->help}</div>\"",
";",
"}",
"$",
"html",
".=",
"\"<div class=\\\"elements\\\">\"",
";",
"$",
"hasOptionValue",
"=",
"$",
"this",
"->",
"hasOptionValue",
"(",
"$",
"this",
"->",
"options",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"html",
".=",
"\"<div class=\\\"element\\\"><input type=\\\"{$this->type}\\\" {$this->compiledAttr} \"",
";",
"$",
"html",
".=",
"\"name=\\\"\"",
".",
"$",
"this",
"->",
"name",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"\"checkbox\"",
")",
"{",
"$",
"html",
".=",
"\"[]\"",
";",
"}",
"$",
"html",
".=",
"\"\\\" \"",
";",
"// handle options in an associative array differently than ones in a numeric array",
"if",
"(",
"$",
"hasOptionValue",
"||",
"$",
"this",
"->",
"useNumericValue",
")",
"{",
"$",
"html",
".=",
"\"value=\\\"{$k}\\\" \"",
";",
"if",
"(",
"$",
"k",
"===",
"$",
"value",
"||",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"in_array",
"(",
"$",
"k",
",",
"$",
"value",
")",
")",
")",
"{",
"$",
"html",
".=",
"\"checked=\\\"checked\\\"\"",
";",
"}",
"}",
"else",
"{",
"$",
"html",
".=",
"\"value=\\\"{$v}\\\" \"",
";",
"if",
"(",
"$",
"v",
"===",
"$",
"value",
"||",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"in_array",
"(",
"$",
"v",
",",
"$",
"value",
")",
")",
")",
"{",
"$",
"html",
".=",
"\"checked=\\\"checked\\\"\"",
";",
"}",
"}",
"$",
"html",
".=",
"\" /> <span>{$v}</span></div>\"",
";",
"}",
"$",
"html",
".=",
"\"</div>\"",
";",
"return",
"$",
"html",
";",
"}"
] | Builds the HTML of the form field.
@param string $value Value of the form field
@return null | [
"Builds",
"the",
"HTML",
"of",
"the",
"form",
"field",
"."
] | train | https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Elements/Parents/Option.php#L59-L102 |
afrittella/back-project | src/app/Http/Requests/AccountStore.php | AccountStore.rules | public function rules()
{
$user = $this->users->findBy('id', \Auth::user()->id);
return [
'username' => 'required|max:255|unique:users,username,'.$user->id,
'email' => 'required|email|max:255|unique:users,email,'.$user->id,
'password' => 'sometimes|required|min:6|confirmed'
];
} | php | public function rules()
{
$user = $this->users->findBy('id', \Auth::user()->id);
return [
'username' => 'required|max:255|unique:users,username,'.$user->id,
'email' => 'required|email|max:255|unique:users,email,'.$user->id,
'password' => 'sometimes|required|min:6|confirmed'
];
} | [
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"users",
"->",
"findBy",
"(",
"'id'",
",",
"\\",
"Auth",
"::",
"user",
"(",
")",
"->",
"id",
")",
";",
"return",
"[",
"'username'",
"=>",
"'required|max:255|unique:users,username,'",
".",
"$",
"user",
"->",
"id",
",",
"'email'",
"=>",
"'required|email|max:255|unique:users,email,'",
".",
"$",
"user",
"->",
"id",
",",
"'password'",
"=>",
"'sometimes|required|min:6|confirmed'",
"]",
";",
"}"
] | Get the validation rules that apply to the request.
@return array | [
"Get",
"the",
"validation",
"rules",
"that",
"apply",
"to",
"the",
"request",
"."
] | train | https://github.com/afrittella/back-project/blob/e1aa2e3ee03d453033f75a4b16f073c60b5f32d1/src/app/Http/Requests/AccountStore.php#L32-L41 |
inpsyde/inpsyde-filter | src/WordPress/SanitizePostField.php | SanitizePostField.filter | public function filter( $value ) {
if ( ! is_scalar( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not scalar or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
if ( ! isset( $this->options[ 'field' ] ) ) {
return $value;
}
$context = (string) $this->options[ 'context' ];
$field = (string) $this->options[ 'field' ];
return sanitize_post_field( $field, $value, 0, $context );
} | php | public function filter( $value ) {
if ( ! is_scalar( $value ) || empty( $value ) ) {
do_action( 'inpsyde.filter.error', 'The given value is not scalar or empty.', [ 'method' => __METHOD__, 'value' => $value ] );
return $value;
}
if ( ! isset( $this->options[ 'field' ] ) ) {
return $value;
}
$context = (string) $this->options[ 'context' ];
$field = (string) $this->options[ 'field' ];
return sanitize_post_field( $field, $value, 0, $context );
} | [
"public",
"function",
"filter",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
"||",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"do_action",
"(",
"'inpsyde.filter.error'",
",",
"'The given value is not scalar or empty.'",
",",
"[",
"'method'",
"=>",
"__METHOD__",
",",
"'value'",
"=>",
"$",
"value",
"]",
")",
";",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'field'",
"]",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"context",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"options",
"[",
"'context'",
"]",
";",
"$",
"field",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"options",
"[",
"'field'",
"]",
";",
"return",
"sanitize_post_field",
"(",
"$",
"field",
",",
"$",
"value",
",",
"0",
",",
"$",
"context",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/inpsyde/inpsyde-filter/blob/777a6208ea4dfbeed89e6d0712a35dc25eab498b/src/WordPress/SanitizePostField.php#L26-L43 |
CakeCMS/Core | src/Event/CoreEventHandler.php | CoreEventHandler.onControllerSetup | public function onControllerSetup(Event $event)
{
/** @var AppController $controller */
$controller = $event->getSubject();
$isAdmin = ($controller->request->getParam('prefix') === 'admin');
$plugins = Plugin::loaded();
foreach ($plugins as $plugin) {
$path = Plugin::path($plugin);
$menuFile = ($isAdmin) ? 'admin_menu' : 'menu';
$navConf = $path . 'config/' . $menuFile . '.php';
if (FS::isFile($navConf)) {
/** @noinspection PhpIncludeInspection */
require_once $navConf;
}
}
} | php | public function onControllerSetup(Event $event)
{
/** @var AppController $controller */
$controller = $event->getSubject();
$isAdmin = ($controller->request->getParam('prefix') === 'admin');
$plugins = Plugin::loaded();
foreach ($plugins as $plugin) {
$path = Plugin::path($plugin);
$menuFile = ($isAdmin) ? 'admin_menu' : 'menu';
$navConf = $path . 'config/' . $menuFile . '.php';
if (FS::isFile($navConf)) {
/** @noinspection PhpIncludeInspection */
require_once $navConf;
}
}
} | [
"public",
"function",
"onControllerSetup",
"(",
"Event",
"$",
"event",
")",
"{",
"/** @var AppController $controller */",
"$",
"controller",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
";",
"$",
"isAdmin",
"=",
"(",
"$",
"controller",
"->",
"request",
"->",
"getParam",
"(",
"'prefix'",
")",
"===",
"'admin'",
")",
";",
"$",
"plugins",
"=",
"Plugin",
"::",
"loaded",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"$",
"path",
"=",
"Plugin",
"::",
"path",
"(",
"$",
"plugin",
")",
";",
"$",
"menuFile",
"=",
"(",
"$",
"isAdmin",
")",
"?",
"'admin_menu'",
":",
"'menu'",
";",
"$",
"navConf",
"=",
"$",
"path",
".",
"'config/'",
".",
"$",
"menuFile",
".",
"'.php'",
";",
"if",
"(",
"FS",
"::",
"isFile",
"(",
"$",
"navConf",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"require_once",
"$",
"navConf",
";",
"}",
"}",
"}"
] | On controller setup.
@param Event $event
@return void | [
"On",
"controller",
"setup",
"."
] | train | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Event/CoreEventHandler.php#L50-L67 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.setPropertiesHints | public function setPropertiesHints(Array $hints) {
foreach ($hints as $propertyName => $hint) {
$this->getPropertyMeta($propertyName)
->setHint($hint);
}
return $this;
} | php | public function setPropertiesHints(Array $hints) {
foreach ($hints as $propertyName => $hint) {
$this->getPropertyMeta($propertyName)
->setHint($hint);
}
return $this;
} | [
"public",
"function",
"setPropertiesHints",
"(",
"Array",
"$",
"hints",
")",
"{",
"foreach",
"(",
"$",
"hints",
"as",
"$",
"propertyName",
"=>",
"$",
"hint",
")",
"{",
"$",
"this",
"->",
"getPropertyMeta",
"(",
"$",
"propertyName",
")",
"->",
"setHint",
"(",
"$",
"hint",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Setzt die Hints für mehrere Properties
(werden unter der Komponente angezeigt)
@param array $hints string $propertyName => string $propertyHint | [
"Setzt",
"die",
"Hints",
"für",
"mehrere",
"Properties"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L209-L215 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.getNewRequestMeta | public function getNewRequestMeta($clone = TRUE, $subResource = NULL) {
if (!isset($this->newRequestMeta)) {
$this->newRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::POST,
$this->constructUrl(array($this->getEntityNamePlural()))
);
}
if ($clone) {
$meta = clone $this->newRequestMeta;
if ($subResource != NULL) {
$meta->appendUrl('/'.$subResource);
}
return $meta;
}
return $this->newRequestMeta;
} | php | public function getNewRequestMeta($clone = TRUE, $subResource = NULL) {
if (!isset($this->newRequestMeta)) {
$this->newRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::POST,
$this->constructUrl(array($this->getEntityNamePlural()))
);
}
if ($clone) {
$meta = clone $this->newRequestMeta;
if ($subResource != NULL) {
$meta->appendUrl('/'.$subResource);
}
return $meta;
}
return $this->newRequestMeta;
} | [
"public",
"function",
"getNewRequestMeta",
"(",
"$",
"clone",
"=",
"TRUE",
",",
"$",
"subResource",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"newRequestMeta",
")",
")",
"{",
"$",
"this",
"->",
"newRequestMeta",
"=",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"POST",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityNamePlural",
"(",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"clone",
")",
"{",
"$",
"meta",
"=",
"clone",
"$",
"this",
"->",
"newRequestMeta",
";",
"if",
"(",
"$",
"subResource",
"!=",
"NULL",
")",
"{",
"$",
"meta",
"->",
"appendUrl",
"(",
"'/'",
".",
"$",
"subResource",
")",
";",
"}",
"return",
"$",
"meta",
";",
"}",
"return",
"$",
"this",
"->",
"newRequestMeta",
";",
"}"
] | Neues Entity Erstellen (POST)
@param Psc\CMS\RequestMeta $NewRequestMeta
@chainable | [
"Neues",
"Entity",
"Erstellen",
"(",
"POST",
")"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L486-L500 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.getSaveRequestMeta | public function getSaveRequestMeta(Entity $entity = NULL, $subResource = NULL) {
$idIsInt = ($type = $this->getIdentifier()->getType()) instanceof IntegerType;
// custom save request
if ($subResource != NULL) {
$requestMeta = new RequestMeta(\Psc\Net\HTTP\Request::PUT,
$this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'), $subResource)),
array($type)
);
if (isset($entity)) {
$requestMeta->setInput($entity->getIdentifier());
}
return $requestMeta;
} else {
if (!isset($this->saveRequestMeta)) {
$this->saveRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::PUT,
$this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'))),
array($type)
);
}
if (isset($entity)) {
$meta = clone $this->saveRequestMeta;
return $meta->setInput($entity->getIdentifier());
}
return $this->saveRequestMeta;
}
} | php | public function getSaveRequestMeta(Entity $entity = NULL, $subResource = NULL) {
$idIsInt = ($type = $this->getIdentifier()->getType()) instanceof IntegerType;
// custom save request
if ($subResource != NULL) {
$requestMeta = new RequestMeta(\Psc\Net\HTTP\Request::PUT,
$this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'), $subResource)),
array($type)
);
if (isset($entity)) {
$requestMeta->setInput($entity->getIdentifier());
}
return $requestMeta;
} else {
if (!isset($this->saveRequestMeta)) {
$this->saveRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::PUT,
$this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'))),
array($type)
);
}
if (isset($entity)) {
$meta = clone $this->saveRequestMeta;
return $meta->setInput($entity->getIdentifier());
}
return $this->saveRequestMeta;
}
} | [
"public",
"function",
"getSaveRequestMeta",
"(",
"Entity",
"$",
"entity",
"=",
"NULL",
",",
"$",
"subResource",
"=",
"NULL",
")",
"{",
"$",
"idIsInt",
"=",
"(",
"$",
"type",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"getType",
"(",
")",
")",
"instanceof",
"IntegerType",
";",
"// custom save request",
"if",
"(",
"$",
"subResource",
"!=",
"NULL",
")",
"{",
"$",
"requestMeta",
"=",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"PUT",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityName",
"(",
")",
",",
"(",
"$",
"idIsInt",
"?",
"'%d'",
":",
"'%s'",
")",
",",
"$",
"subResource",
")",
")",
",",
"array",
"(",
"$",
"type",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"requestMeta",
"->",
"setInput",
"(",
"$",
"entity",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"return",
"$",
"requestMeta",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"saveRequestMeta",
")",
")",
"{",
"$",
"this",
"->",
"saveRequestMeta",
"=",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"PUT",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityName",
"(",
")",
",",
"(",
"$",
"idIsInt",
"?",
"'%d'",
":",
"'%s'",
")",
")",
")",
",",
"array",
"(",
"$",
"type",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"meta",
"=",
"clone",
"$",
"this",
"->",
"saveRequestMeta",
";",
"return",
"$",
"meta",
"->",
"setInput",
"(",
"$",
"entity",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"saveRequestMeta",
";",
"}",
"}"
] | "Formular" Speichern (PUT)
@return Psc\CMS\RequestMeta | [
"Formular",
"Speichern",
"(",
"PUT",
")"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L507-L536 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.getGridRequestMeta | public function getGridRequestMeta($clone = TRUE, $save = FALSE) {
if ($save) {
return new RequestMeta(\Psc\Net\HTTP\Request::PUT,
$this->constructUrl(array($this->getEntityNamePlural(), 'grid'))
);
}
if (!isset($this->gridRequestMeta)) {
$this->gridRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
$this->constructUrl(array($this->getEntityNamePlural(), 'grid'))
);
}
if ($clone) {
return clone $this->gridRequestMeta;
} else {
return $this->gridRequestMeta;
}
} | php | public function getGridRequestMeta($clone = TRUE, $save = FALSE) {
if ($save) {
return new RequestMeta(\Psc\Net\HTTP\Request::PUT,
$this->constructUrl(array($this->getEntityNamePlural(), 'grid'))
);
}
if (!isset($this->gridRequestMeta)) {
$this->gridRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
$this->constructUrl(array($this->getEntityNamePlural(), 'grid'))
);
}
if ($clone) {
return clone $this->gridRequestMeta;
} else {
return $this->gridRequestMeta;
}
} | [
"public",
"function",
"getGridRequestMeta",
"(",
"$",
"clone",
"=",
"TRUE",
",",
"$",
"save",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"save",
")",
"{",
"return",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"PUT",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityNamePlural",
"(",
")",
",",
"'grid'",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"gridRequestMeta",
")",
")",
"{",
"$",
"this",
"->",
"gridRequestMeta",
"=",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"GET",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityNamePlural",
"(",
")",
",",
"'grid'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"clone",
")",
"{",
"return",
"clone",
"$",
"this",
"->",
"gridRequestMeta",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"gridRequestMeta",
";",
"}",
"}"
] | Zeigt die Tabellen-Übersicht für ein Entity an
@return Psc\CMS\RequestMeta | [
"Zeigt",
"die",
"Tabellen",
"-",
"Übersicht",
"für",
"ein",
"Entity",
"an"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L565-L583 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.getActionRequestMeta | public function getActionRequestMeta($action, Entity $entity = NULL, $method = \Psc\Net\HTTP\Request::GET) {
if (!array_key_exists($action, $this->actionsRequestMeta)) {
$idIsInt = ($identifierType = $this->getIdentifier()->getType()) instanceof IntegerType;
$this->actionsRequestMeta[$action] = new RequestMeta($method,
$this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'), $action)),
array($identifierType)
);
}
if (isset($entity)) {
$meta = clone $this->actionsRequestMeta[$action];
return $meta->setInput($entity->getIdentifier());
} else {
return $this->actionsRequestMeta[$action];
}
} | php | public function getActionRequestMeta($action, Entity $entity = NULL, $method = \Psc\Net\HTTP\Request::GET) {
if (!array_key_exists($action, $this->actionsRequestMeta)) {
$idIsInt = ($identifierType = $this->getIdentifier()->getType()) instanceof IntegerType;
$this->actionsRequestMeta[$action] = new RequestMeta($method,
$this->constructUrl(array($this->getEntityName(), ($idIsInt ? '%d' : '%s'), $action)),
array($identifierType)
);
}
if (isset($entity)) {
$meta = clone $this->actionsRequestMeta[$action];
return $meta->setInput($entity->getIdentifier());
} else {
return $this->actionsRequestMeta[$action];
}
} | [
"public",
"function",
"getActionRequestMeta",
"(",
"$",
"action",
",",
"Entity",
"$",
"entity",
"=",
"NULL",
",",
"$",
"method",
"=",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"GET",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"action",
",",
"$",
"this",
"->",
"actionsRequestMeta",
")",
")",
"{",
"$",
"idIsInt",
"=",
"(",
"$",
"identifierType",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"getType",
"(",
")",
")",
"instanceof",
"IntegerType",
";",
"$",
"this",
"->",
"actionsRequestMeta",
"[",
"$",
"action",
"]",
"=",
"new",
"RequestMeta",
"(",
"$",
"method",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityName",
"(",
")",
",",
"(",
"$",
"idIsInt",
"?",
"'%d'",
":",
"'%s'",
")",
",",
"$",
"action",
")",
")",
",",
"array",
"(",
"$",
"identifierType",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"meta",
"=",
"clone",
"$",
"this",
"->",
"actionsRequestMeta",
"[",
"$",
"action",
"]",
";",
"return",
"$",
"meta",
"->",
"setInput",
"(",
"$",
"entity",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"actionsRequestMeta",
"[",
"$",
"action",
"]",
";",
"}",
"}"
] | Gibt die Custom-Action zu einem Entity zurück
also sowas wie entities/<entityName>/<identifier>/$action
@return requestMeta | [
"Gibt",
"die",
"Custom",
"-",
"Action",
"zu",
"einem",
"Entity",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L592-L607 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.getNewFormRequestMeta | public function getNewFormRequestMeta($clone = TRUE) {
if (!isset($this->newFormRequestMeta)) {
$this->newFormRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
$this->constructUrl(array($this->getEntityNamePlural(), 'form'))
);
}
if ($clone) {
return clone $this->newFormRequestMeta;
} else {
return $this->newFormRequestMeta;
}
} | php | public function getNewFormRequestMeta($clone = TRUE) {
if (!isset($this->newFormRequestMeta)) {
$this->newFormRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
$this->constructUrl(array($this->getEntityNamePlural(), 'form'))
);
}
if ($clone) {
return clone $this->newFormRequestMeta;
} else {
return $this->newFormRequestMeta;
}
} | [
"public",
"function",
"getNewFormRequestMeta",
"(",
"$",
"clone",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"newFormRequestMeta",
")",
")",
"{",
"$",
"this",
"->",
"newFormRequestMeta",
"=",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"GET",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityNamePlural",
"(",
")",
",",
"'form'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"clone",
")",
"{",
"return",
"clone",
"$",
"this",
"->",
"newFormRequestMeta",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"newFormRequestMeta",
";",
"}",
"}"
] | Zeigt das "Entity erstellen" Formular an
@return Psc\CMS\RequestMeta | [
"Zeigt",
"das",
"Entity",
"erstellen",
"Formular",
"an"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L614-L626 |
webforge-labs/psc-cms | lib/Psc/CMS/EntityMeta.php | EntityMeta.getSearchRequestMeta | public function getSearchRequestMeta(Array $query = NULL) {
if (!isset($this->searchRequestMeta)) {
$this->searchRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
$this->constructUrl(array($this->getEntityNamePlural(), '%s')),
array(RequestMeta::QUERY)
);
}
if (isset($query)) {
$meta = clone $this->searchRequestMeta;
return $meta->setInput($query);
}
return $this->searchRequestMeta;
} | php | public function getSearchRequestMeta(Array $query = NULL) {
if (!isset($this->searchRequestMeta)) {
$this->searchRequestMeta = new RequestMeta(\Psc\Net\HTTP\Request::GET,
$this->constructUrl(array($this->getEntityNamePlural(), '%s')),
array(RequestMeta::QUERY)
);
}
if (isset($query)) {
$meta = clone $this->searchRequestMeta;
return $meta->setInput($query);
}
return $this->searchRequestMeta;
} | [
"public",
"function",
"getSearchRequestMeta",
"(",
"Array",
"$",
"query",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"searchRequestMeta",
")",
")",
"{",
"$",
"this",
"->",
"searchRequestMeta",
"=",
"new",
"RequestMeta",
"(",
"\\",
"Psc",
"\\",
"Net",
"\\",
"HTTP",
"\\",
"Request",
"::",
"GET",
",",
"$",
"this",
"->",
"constructUrl",
"(",
"array",
"(",
"$",
"this",
"->",
"getEntityNamePlural",
"(",
")",
",",
"'%s'",
")",
")",
",",
"array",
"(",
"RequestMeta",
"::",
"QUERY",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"query",
")",
")",
"{",
"$",
"meta",
"=",
"clone",
"$",
"this",
"->",
"searchRequestMeta",
";",
"return",
"$",
"meta",
"->",
"setInput",
"(",
"$",
"query",
")",
";",
"}",
"return",
"$",
"this",
"->",
"searchRequestMeta",
";",
"}"
] | Request zum Suchen von Entities und zur LowLevel Ausgabe
@return Psc\CMS\RequestMeta | [
"Request",
"zum",
"Suchen",
"von",
"Entities",
"und",
"zur",
"LowLevel",
"Ausgabe"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/EntityMeta.php#L633-L646 |
webforge-labs/psc-cms | lib/Psc/CMS/Controller/GPCController.php | GPCController.initTodo | public function initTodo() {
$todo = $this->getVar(array('todo'),'GP');
$this->assertTodo($todo);
$this->setTodo($todo);
if (!isset($this->todo))
$this->todo = $this->defaultTodo;
} | php | public function initTodo() {
$todo = $this->getVar(array('todo'),'GP');
$this->assertTodo($todo);
$this->setTodo($todo);
if (!isset($this->todo))
$this->todo = $this->defaultTodo;
} | [
"public",
"function",
"initTodo",
"(",
")",
"{",
"$",
"todo",
"=",
"$",
"this",
"->",
"getVar",
"(",
"array",
"(",
"'todo'",
")",
",",
"'GP'",
")",
";",
"$",
"this",
"->",
"assertTodo",
"(",
"$",
"todo",
")",
";",
"$",
"this",
"->",
"setTodo",
"(",
"$",
"todo",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"todo",
")",
")",
"$",
"this",
"->",
"todo",
"=",
"$",
"this",
"->",
"defaultTodo",
";",
"}"
] | Initialisiert das Todo des Controllers
der Schlüssel 'todo' muss in $this->vars gesetzt sein, damit ein todo aus der Map genommen wird
ist der Schlüssel gesetzt, aber der Wert nicht in der todoMap wird eine Exception geworfen
ist der Schlüssel nicht gesetzt, wird $this->todo auf $this->defaultTodo gessetzt
$_POST['todo'] hat Vorrang vor $_GET['todo']
Es wird immer setTodo() mit dem gefundenen Wert aufgerufen
@uses validateTodo(), setTodo() | [
"Initialisiert",
"das",
"Todo",
"des",
"Controllers"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/GPCController.php#L52-L59 |
webforge-labs/psc-cms | lib/Psc/CMS/Controller/GPCController.php | GPCController.getVar | public function getVar($keys, $precendence = 'GP') {
/* Performance Tweak */
if ($precendence == 'GP') {
if (($p = $this->post->get($keys, self::RETURN_NULL)) != NULL) return $p;
if (($g = $this->get->get($keys, self::RETURN_NULL)) != NULL) return $g;
}
if ($precendence == 'PG') {
if (($g = $this->get->get($keys, self::RETURN_NULL)) != NULL) return $g;
if (($p = $this->post->get($keys, self::RETURN_NULL)) != NULL) return $p;
}
foreach (preg_split('/[a-z]/',$precendence) as $type) {
switch($type) {
case 'g':
case 'p':
$this->$type($keys, self::RETURN_NULL);
case 'c':
case 's':
throw new \Psc\Exception('c und s nocht nicht implementiert');
}
}
return NULL;
} | php | public function getVar($keys, $precendence = 'GP') {
/* Performance Tweak */
if ($precendence == 'GP') {
if (($p = $this->post->get($keys, self::RETURN_NULL)) != NULL) return $p;
if (($g = $this->get->get($keys, self::RETURN_NULL)) != NULL) return $g;
}
if ($precendence == 'PG') {
if (($g = $this->get->get($keys, self::RETURN_NULL)) != NULL) return $g;
if (($p = $this->post->get($keys, self::RETURN_NULL)) != NULL) return $p;
}
foreach (preg_split('/[a-z]/',$precendence) as $type) {
switch($type) {
case 'g':
case 'p':
$this->$type($keys, self::RETURN_NULL);
case 'c':
case 's':
throw new \Psc\Exception('c und s nocht nicht implementiert');
}
}
return NULL;
} | [
"public",
"function",
"getVar",
"(",
"$",
"keys",
",",
"$",
"precendence",
"=",
"'GP'",
")",
"{",
"/* Performance Tweak */",
"if",
"(",
"$",
"precendence",
"==",
"'GP'",
")",
"{",
"if",
"(",
"(",
"$",
"p",
"=",
"$",
"this",
"->",
"post",
"->",
"get",
"(",
"$",
"keys",
",",
"self",
"::",
"RETURN_NULL",
")",
")",
"!=",
"NULL",
")",
"return",
"$",
"p",
";",
"if",
"(",
"(",
"$",
"g",
"=",
"$",
"this",
"->",
"get",
"->",
"get",
"(",
"$",
"keys",
",",
"self",
"::",
"RETURN_NULL",
")",
")",
"!=",
"NULL",
")",
"return",
"$",
"g",
";",
"}",
"if",
"(",
"$",
"precendence",
"==",
"'PG'",
")",
"{",
"if",
"(",
"(",
"$",
"g",
"=",
"$",
"this",
"->",
"get",
"->",
"get",
"(",
"$",
"keys",
",",
"self",
"::",
"RETURN_NULL",
")",
")",
"!=",
"NULL",
")",
"return",
"$",
"g",
";",
"if",
"(",
"(",
"$",
"p",
"=",
"$",
"this",
"->",
"post",
"->",
"get",
"(",
"$",
"keys",
",",
"self",
"::",
"RETURN_NULL",
")",
")",
"!=",
"NULL",
")",
"return",
"$",
"p",
";",
"}",
"foreach",
"(",
"preg_split",
"(",
"'/[a-z]/'",
",",
"$",
"precendence",
")",
"as",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'g'",
":",
"case",
"'p'",
":",
"$",
"this",
"->",
"$",
"type",
"(",
"$",
"keys",
",",
"self",
"::",
"RETURN_NULL",
")",
";",
"case",
"'c'",
":",
"case",
"'s'",
":",
"throw",
"new",
"\\",
"Psc",
"\\",
"Exception",
"(",
"'c und s nocht nicht implementiert'",
")",
";",
"}",
"}",
"return",
"NULL",
";",
"}"
] | Gibt eine Variable zurück
die Precendence gibt an welche Variable gewinnt, wenn beide definiert sind
@param mixed $keys wenn $keys NULL ist wird angenommen, dass es array($varname) ist
@param array $precendence
@return mixed|NULL gibt NULL zurück wenn die Variable nicht gesetzt, oder nicht gefunden wurde | [
"Gibt",
"eine",
"Variable",
"zurück"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Controller/GPCController.php#L70-L96 |
webforge-labs/psc-cms | lib/Psc/CMS/Service/MetadataGenerator.php | MetadataGenerator.entity | public function entity(Entity $entity, Array $linkRelations = array()) {
if (!isset($this->meta['links']))
$this->meta['links'] = array();
foreach ($linkRelations as $linkRelation) {
$this->meta['links'][] = (object) array(
'rel'=>$linkRelation->getName(),
'href'=>$linkRelation->getHref()
);
}
return $this;
} | php | public function entity(Entity $entity, Array $linkRelations = array()) {
if (!isset($this->meta['links']))
$this->meta['links'] = array();
foreach ($linkRelations as $linkRelation) {
$this->meta['links'][] = (object) array(
'rel'=>$linkRelation->getName(),
'href'=>$linkRelation->getHref()
);
}
return $this;
} | [
"public",
"function",
"entity",
"(",
"Entity",
"$",
"entity",
",",
"Array",
"$",
"linkRelations",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"meta",
"[",
"'links'",
"]",
")",
")",
"$",
"this",
"->",
"meta",
"[",
"'links'",
"]",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"linkRelations",
"as",
"$",
"linkRelation",
")",
"{",
"$",
"this",
"->",
"meta",
"[",
"'links'",
"]",
"[",
"]",
"=",
"(",
"object",
")",
"array",
"(",
"'rel'",
"=>",
"$",
"linkRelation",
"->",
"getName",
"(",
")",
",",
"'href'",
"=>",
"$",
"linkRelation",
"->",
"getHref",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Adds metadata for the reponse from an Entity
@param Psc\Net\Service\LinkRelation[] $linkRelations | [
"Adds",
"metadata",
"for",
"the",
"reponse",
"from",
"an",
"Entity"
] | train | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Service/MetadataGenerator.php#L47-L59 |
phpmob/changmin | src/PhpMob/CoreBundle/OAuth/UserProvider.php | UserProvider.createUserByOAuthUserResponse | private function createUserByOAuthUserResponse(UserResponseInterface $response): WebUserInterface
{
/** @var WebUserInterface $user */
$user = $this->userFactory->createNew();
if (!$canonicalEmail = $this->canonicalizer->canonicalize($response->getEmail())) {
throw new AuthorizationException('phpmob.ui.oauth_response_not_found_email');
}
$user->setEmailCanonical($canonicalEmail);
if ($firstName = $response->getFirstName()) {
$user->setFirstName($firstName);
}
if ($lastName = $response->getLastName()) {
$user->setLastName($lastName);
}
if ($displayName = $response->getRealName()) {
$user->setDisplayName($displayName);
}
// set random password to prevent issue with not nullable field & potential security hole
$user->setPlainPassword(substr(sha1($response->getAccessToken()), 0, 10));
$user->setEnabled(true);
return $this->updateUserByOAuthUserResponse($user, $response);
} | php | private function createUserByOAuthUserResponse(UserResponseInterface $response): WebUserInterface
{
/** @var WebUserInterface $user */
$user = $this->userFactory->createNew();
if (!$canonicalEmail = $this->canonicalizer->canonicalize($response->getEmail())) {
throw new AuthorizationException('phpmob.ui.oauth_response_not_found_email');
}
$user->setEmailCanonical($canonicalEmail);
if ($firstName = $response->getFirstName()) {
$user->setFirstName($firstName);
}
if ($lastName = $response->getLastName()) {
$user->setLastName($lastName);
}
if ($displayName = $response->getRealName()) {
$user->setDisplayName($displayName);
}
// set random password to prevent issue with not nullable field & potential security hole
$user->setPlainPassword(substr(sha1($response->getAccessToken()), 0, 10));
$user->setEnabled(true);
return $this->updateUserByOAuthUserResponse($user, $response);
} | [
"private",
"function",
"createUserByOAuthUserResponse",
"(",
"UserResponseInterface",
"$",
"response",
")",
":",
"WebUserInterface",
"{",
"/** @var WebUserInterface $user */",
"$",
"user",
"=",
"$",
"this",
"->",
"userFactory",
"->",
"createNew",
"(",
")",
";",
"if",
"(",
"!",
"$",
"canonicalEmail",
"=",
"$",
"this",
"->",
"canonicalizer",
"->",
"canonicalize",
"(",
"$",
"response",
"->",
"getEmail",
"(",
")",
")",
")",
"{",
"throw",
"new",
"AuthorizationException",
"(",
"'phpmob.ui.oauth_response_not_found_email'",
")",
";",
"}",
"$",
"user",
"->",
"setEmailCanonical",
"(",
"$",
"canonicalEmail",
")",
";",
"if",
"(",
"$",
"firstName",
"=",
"$",
"response",
"->",
"getFirstName",
"(",
")",
")",
"{",
"$",
"user",
"->",
"setFirstName",
"(",
"$",
"firstName",
")",
";",
"}",
"if",
"(",
"$",
"lastName",
"=",
"$",
"response",
"->",
"getLastName",
"(",
")",
")",
"{",
"$",
"user",
"->",
"setLastName",
"(",
"$",
"lastName",
")",
";",
"}",
"if",
"(",
"$",
"displayName",
"=",
"$",
"response",
"->",
"getRealName",
"(",
")",
")",
"{",
"$",
"user",
"->",
"setDisplayName",
"(",
"$",
"displayName",
")",
";",
"}",
"// set random password to prevent issue with not nullable field & potential security hole",
"$",
"user",
"->",
"setPlainPassword",
"(",
"substr",
"(",
"sha1",
"(",
"$",
"response",
"->",
"getAccessToken",
"(",
")",
")",
",",
"0",
",",
"10",
")",
")",
";",
"$",
"user",
"->",
"setEnabled",
"(",
"true",
")",
";",
"return",
"$",
"this",
"->",
"updateUserByOAuthUserResponse",
"(",
"$",
"user",
",",
"$",
"response",
")",
";",
"}"
] | Ad-hoc creation of user.
@param UserResponseInterface $response
@return WebUserInterface|UserInterface | [
"Ad",
"-",
"hoc",
"creation",
"of",
"user",
"."
] | train | https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/CoreBundle/OAuth/UserProvider.php#L118-L146 |
danrevah/shortify-punit | src/Mock/MockTrait.php | MockTrait.generateResponse | protected static function generateResponse(&$mockResponse, $arguments)
{
self::updateCallCounter($mockResponse);
list($action, $value) = self::extractResponseValues($mockResponse);
if ($action == MockAction::THROWS) {
throw is_object($value) ? $value : new $value;
}
else if ($action == MockAction::CALLBACK) {
return call_user_func_array($value, $arguments);
}
return $value;
} | php | protected static function generateResponse(&$mockResponse, $arguments)
{
self::updateCallCounter($mockResponse);
list($action, $value) = self::extractResponseValues($mockResponse);
if ($action == MockAction::THROWS) {
throw is_object($value) ? $value : new $value;
}
else if ($action == MockAction::CALLBACK) {
return call_user_func_array($value, $arguments);
}
return $value;
} | [
"protected",
"static",
"function",
"generateResponse",
"(",
"&",
"$",
"mockResponse",
",",
"$",
"arguments",
")",
"{",
"self",
"::",
"updateCallCounter",
"(",
"$",
"mockResponse",
")",
";",
"list",
"(",
"$",
"action",
",",
"$",
"value",
")",
"=",
"self",
"::",
"extractResponseValues",
"(",
"$",
"mockResponse",
")",
";",
"if",
"(",
"$",
"action",
"==",
"MockAction",
"::",
"THROWS",
")",
"{",
"throw",
"is_object",
"(",
"$",
"value",
")",
"?",
"$",
"value",
":",
"new",
"$",
"value",
";",
"}",
"else",
"if",
"(",
"$",
"action",
"==",
"MockAction",
"::",
"CALLBACK",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"value",
",",
"$",
"arguments",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Creating response by response options (Return/Throw/Callback)
@param $mockResponse
@param $arguments
@return mixed | [
"Creating",
"response",
"by",
"response",
"options",
"(",
"Return",
"/",
"Throw",
"/",
"Callback",
")"
] | train | https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Mock/MockTrait.php#L179-L193 |
xtcommerce/shop-appstore-lib | src/XTCommerce/ShopAppstoreLib/Logger.php | Logger.log | public function log($level, $message, array $context = array())
{
if(defined("XTCOMMERCE_DEBUG")) {
$status = XTCOMMERCE_DEBUG;
}else{
$status = false;
}
if($level == LogLevel::DEBUG){
if(!in_array($level, array(
LogLevel::ERROR,
LogLevel::CRITICAL,
LogLevel::EMERGENCY
)) && !$status){
// debug mode disabled
return;
}
}
if($context){
$message .= sprintf(', context: %s', var_export($context, true));
}
$str = date('Y-m-d H:i:s') . ' ['.$level.']: ' . $message . PHP_EOL;
if(defined("XTCOMMERCE_LOG_FILE")) {
if(XTCOMMERCE_LOG_FILE) {
file_put_contents(XTCOMMERCE_LOG_FILE, $str, FILE_APPEND);
}
}
} | php | public function log($level, $message, array $context = array())
{
if(defined("XTCOMMERCE_DEBUG")) {
$status = XTCOMMERCE_DEBUG;
}else{
$status = false;
}
if($level == LogLevel::DEBUG){
if(!in_array($level, array(
LogLevel::ERROR,
LogLevel::CRITICAL,
LogLevel::EMERGENCY
)) && !$status){
// debug mode disabled
return;
}
}
if($context){
$message .= sprintf(', context: %s', var_export($context, true));
}
$str = date('Y-m-d H:i:s') . ' ['.$level.']: ' . $message . PHP_EOL;
if(defined("XTCOMMERCE_LOG_FILE")) {
if(XTCOMMERCE_LOG_FILE) {
file_put_contents(XTCOMMERCE_LOG_FILE, $str, FILE_APPEND);
}
}
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"defined",
"(",
"\"XTCOMMERCE_DEBUG\"",
")",
")",
"{",
"$",
"status",
"=",
"XTCOMMERCE_DEBUG",
";",
"}",
"else",
"{",
"$",
"status",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"level",
"==",
"LogLevel",
"::",
"DEBUG",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"level",
",",
"array",
"(",
"LogLevel",
"::",
"ERROR",
",",
"LogLevel",
"::",
"CRITICAL",
",",
"LogLevel",
"::",
"EMERGENCY",
")",
")",
"&&",
"!",
"$",
"status",
")",
"{",
"// debug mode disabled",
"return",
";",
"}",
"}",
"if",
"(",
"$",
"context",
")",
"{",
"$",
"message",
".=",
"sprintf",
"(",
"', context: %s'",
",",
"var_export",
"(",
"$",
"context",
",",
"true",
")",
")",
";",
"}",
"$",
"str",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
".",
"' ['",
".",
"$",
"level",
".",
"']: '",
".",
"$",
"message",
".",
"PHP_EOL",
";",
"if",
"(",
"defined",
"(",
"\"XTCOMMERCE_LOG_FILE\"",
")",
")",
"{",
"if",
"(",
"XTCOMMERCE_LOG_FILE",
")",
"{",
"file_put_contents",
"(",
"XTCOMMERCE_LOG_FILE",
",",
"$",
"str",
",",
"FILE_APPEND",
")",
";",
"}",
"}",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/xtcommerce/shop-appstore-lib/blob/b12637502f74e8d1288cf47817e4c02b7f507c3b/src/XTCommerce/ShopAppstoreLib/Logger.php#L12-L41 |
hametuha/gapiwp | src/Hametuha/GapiWP/Service/Analytics.php | Analytics.admin_menu | public function admin_menu(){
$title = __('Google Analytics設定', 'gapiwp');
$menu = __('Analytics設定', 'gapiwp');
add_options_page($title, $menu, 'manage_options', 'gapiwp-analytics', array($this, 'admin_render'));
} | php | public function admin_menu(){
$title = __('Google Analytics設定', 'gapiwp');
$menu = __('Analytics設定', 'gapiwp');
add_options_page($title, $menu, 'manage_options', 'gapiwp-analytics', array($this, 'admin_render'));
} | [
"public",
"function",
"admin_menu",
"(",
")",
"{",
"$",
"title",
"=",
"__",
"(",
"'Google Analytics設定', 'g",
"a",
"iwp');",
"",
"",
"$",
"menu",
"=",
"__",
"(",
"'Analytics設定', 'g",
"a",
"iwp');",
"",
"",
"add_options_page",
"(",
"$",
"title",
",",
"$",
"menu",
",",
"'manage_options'",
",",
"'gapiwp-analytics'",
",",
"array",
"(",
"$",
"this",
",",
"'admin_render'",
")",
")",
";",
"}"
] | Register admin screen | [
"Register",
"admin",
"screen"
] | train | https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L52-L56 |
hametuha/gapiwp | src/Hametuha/GapiWP/Service/Analytics.php | Analytics.admin_init | public function admin_init(){
if( !defined('DOING_AJAX') || !DOING_AJAX ){
if( 'gapiwp-analytics' == $this->input->get('page') ){
// Load assets
$css = $this->asset_url.'/css/admin-analytics.css';
$css_path = $this->base_dir.'/assets/css/admin-analytics.css';
add_action('admin_enqueue_scripts', function() use ($css, $css_path){
wp_enqueue_style('gapiwp-admin', $css, array(), filemtime($css_path));
});
// Form send
if( $this->input->verify_nonce('ga_token_update') ){
// Update token
$token = $this->input->post('consumer_key');
update_option('gapiwp_key', $token);
$secret = $this->input->post('consumer_secret');
update_option('gapiwp_secret', $secret);
// Try redirect
if( $token && $secret && $this->client ){
try{
$this->client->setApprovalPrompt('force');
$url = $this->client->createAuthUrl();
wp_redirect($url);
exit;
}catch ( \Exception $e ){
$this->show_message($e->getMessage(), true);
}
}
}
// Save token when callback
try{
if( ($code = $this->input->get('code')) && $this->client->authenticate($code) ){
$token = $this->client->getAccessToken();
update_option('gapiwp_token', $token);
wp_redirect(admin_url('options-general.php?page=gapiwp-analytics&save_token=true'));
exit;
}
}catch ( \Exception $e ){
$this->show_message($e->getMessage(), true);
}
// Show success message
if( 'true' === $this->input->get('save_token') ){
$this->show_message(__('トークンの取得に成功しました', 'gapiwp'));
}
// Save view
if( $this->input->verify_nonce('ga_account_save') ){
update_option('gapiwp_view_id', $this->input->post('view'));
}
}
}
} | php | public function admin_init(){
if( !defined('DOING_AJAX') || !DOING_AJAX ){
if( 'gapiwp-analytics' == $this->input->get('page') ){
// Load assets
$css = $this->asset_url.'/css/admin-analytics.css';
$css_path = $this->base_dir.'/assets/css/admin-analytics.css';
add_action('admin_enqueue_scripts', function() use ($css, $css_path){
wp_enqueue_style('gapiwp-admin', $css, array(), filemtime($css_path));
});
// Form send
if( $this->input->verify_nonce('ga_token_update') ){
// Update token
$token = $this->input->post('consumer_key');
update_option('gapiwp_key', $token);
$secret = $this->input->post('consumer_secret');
update_option('gapiwp_secret', $secret);
// Try redirect
if( $token && $secret && $this->client ){
try{
$this->client->setApprovalPrompt('force');
$url = $this->client->createAuthUrl();
wp_redirect($url);
exit;
}catch ( \Exception $e ){
$this->show_message($e->getMessage(), true);
}
}
}
// Save token when callback
try{
if( ($code = $this->input->get('code')) && $this->client->authenticate($code) ){
$token = $this->client->getAccessToken();
update_option('gapiwp_token', $token);
wp_redirect(admin_url('options-general.php?page=gapiwp-analytics&save_token=true'));
exit;
}
}catch ( \Exception $e ){
$this->show_message($e->getMessage(), true);
}
// Show success message
if( 'true' === $this->input->get('save_token') ){
$this->show_message(__('トークンの取得に成功しました', 'gapiwp'));
}
// Save view
if( $this->input->verify_nonce('ga_account_save') ){
update_option('gapiwp_view_id', $this->input->post('view'));
}
}
}
} | [
"public",
"function",
"admin_init",
"(",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'DOING_AJAX'",
")",
"||",
"!",
"DOING_AJAX",
")",
"{",
"if",
"(",
"'gapiwp-analytics'",
"==",
"$",
"this",
"->",
"input",
"->",
"get",
"(",
"'page'",
")",
")",
"{",
"// Load assets",
"$",
"css",
"=",
"$",
"this",
"->",
"asset_url",
".",
"'/css/admin-analytics.css'",
";",
"$",
"css_path",
"=",
"$",
"this",
"->",
"base_dir",
".",
"'/assets/css/admin-analytics.css'",
";",
"add_action",
"(",
"'admin_enqueue_scripts'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"css",
",",
"$",
"css_path",
")",
"{",
"wp_enqueue_style",
"(",
"'gapiwp-admin'",
",",
"$",
"css",
",",
"array",
"(",
")",
",",
"filemtime",
"(",
"$",
"css_path",
")",
")",
";",
"}",
")",
";",
"// Form send",
"if",
"(",
"$",
"this",
"->",
"input",
"->",
"verify_nonce",
"(",
"'ga_token_update'",
")",
")",
"{",
"// Update token",
"$",
"token",
"=",
"$",
"this",
"->",
"input",
"->",
"post",
"(",
"'consumer_key'",
")",
";",
"update_option",
"(",
"'gapiwp_key'",
",",
"$",
"token",
")",
";",
"$",
"secret",
"=",
"$",
"this",
"->",
"input",
"->",
"post",
"(",
"'consumer_secret'",
")",
";",
"update_option",
"(",
"'gapiwp_secret'",
",",
"$",
"secret",
")",
";",
"// Try redirect",
"if",
"(",
"$",
"token",
"&&",
"$",
"secret",
"&&",
"$",
"this",
"->",
"client",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"client",
"->",
"setApprovalPrompt",
"(",
"'force'",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"client",
"->",
"createAuthUrl",
"(",
")",
";",
"wp_redirect",
"(",
"$",
"url",
")",
";",
"exit",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"show_message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"true",
")",
";",
"}",
"}",
"}",
"// Save token when callback",
"try",
"{",
"if",
"(",
"(",
"$",
"code",
"=",
"$",
"this",
"->",
"input",
"->",
"get",
"(",
"'code'",
")",
")",
"&&",
"$",
"this",
"->",
"client",
"->",
"authenticate",
"(",
"$",
"code",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"client",
"->",
"getAccessToken",
"(",
")",
";",
"update_option",
"(",
"'gapiwp_token'",
",",
"$",
"token",
")",
";",
"wp_redirect",
"(",
"admin_url",
"(",
"'options-general.php?page=gapiwp-analytics&save_token=true'",
")",
")",
";",
"exit",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"show_message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"true",
")",
";",
"}",
"// Show success message",
"if",
"(",
"'true'",
"===",
"$",
"this",
"->",
"input",
"->",
"get",
"(",
"'save_token'",
")",
")",
"{",
"$",
"this",
"->",
"show_message",
"(",
"__",
"(",
"'トークンの取得に成功しました', 'gapiwp'));",
"",
"",
"",
"",
"",
"}",
"// Save view",
"if",
"(",
"$",
"this",
"->",
"input",
"->",
"verify_nonce",
"(",
"'ga_account_save'",
")",
")",
"{",
"update_option",
"(",
"'gapiwp_view_id'",
",",
"$",
"this",
"->",
"input",
"->",
"post",
"(",
"'view'",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Parse Token | [
"Parse",
"Token"
] | train | https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L62-L112 |
hametuha/gapiwp | src/Hametuha/GapiWP/Service/Analytics.php | Analytics.get_accounts | public function get_accounts(){
static $ga_accounts = null;
if( !is_null($ga_accounts) ){
return $ga_accounts;
}
$ga_accounts = array();
if( $this->ga ){
try{
$accounts = $this->ga->management_accounts->listManagementAccounts();
if( count($accounts->getItems()) > 0 ){
$ga_accounts = $accounts;
}
}catch (\Exception $e){
// Do nothing.
error_log($e->getMessage(), $e->getCode());
}
}
return $ga_accounts;
} | php | public function get_accounts(){
static $ga_accounts = null;
if( !is_null($ga_accounts) ){
return $ga_accounts;
}
$ga_accounts = array();
if( $this->ga ){
try{
$accounts = $this->ga->management_accounts->listManagementAccounts();
if( count($accounts->getItems()) > 0 ){
$ga_accounts = $accounts;
}
}catch (\Exception $e){
// Do nothing.
error_log($e->getMessage(), $e->getCode());
}
}
return $ga_accounts;
} | [
"public",
"function",
"get_accounts",
"(",
")",
"{",
"static",
"$",
"ga_accounts",
"=",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"ga_accounts",
")",
")",
"{",
"return",
"$",
"ga_accounts",
";",
"}",
"$",
"ga_accounts",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"ga",
")",
"{",
"try",
"{",
"$",
"accounts",
"=",
"$",
"this",
"->",
"ga",
"->",
"management_accounts",
"->",
"listManagementAccounts",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"accounts",
"->",
"getItems",
"(",
")",
")",
">",
"0",
")",
"{",
"$",
"ga_accounts",
"=",
"$",
"accounts",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Do nothing.",
"error_log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"ga_accounts",
";",
"}"
] | Get account list
@return array|\Google_Service_Analytics_Accounts | [
"Get",
"account",
"list"
] | train | https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L127-L145 |
hametuha/gapiwp | src/Hametuha/GapiWP/Service/Analytics.php | Analytics.get_properties | public function get_properties($account_id) {
$result = array();
try {
if ( $this->ga ) {
$properties = $this->ga
->management_webproperties
->listManagementWebproperties( $account_id );
$result = $properties->getItems();
}
} catch ( \Exception $e ) {
// Do nothing.
error_log($e->getMessage(), $e->getCode());
}
return $result;
} | php | public function get_properties($account_id) {
$result = array();
try {
if ( $this->ga ) {
$properties = $this->ga
->management_webproperties
->listManagementWebproperties( $account_id );
$result = $properties->getItems();
}
} catch ( \Exception $e ) {
// Do nothing.
error_log($e->getMessage(), $e->getCode());
}
return $result;
} | [
"public",
"function",
"get_properties",
"(",
"$",
"account_id",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"ga",
")",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"ga",
"->",
"management_webproperties",
"->",
"listManagementWebproperties",
"(",
"$",
"account_id",
")",
";",
"$",
"result",
"=",
"$",
"properties",
"->",
"getItems",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Do nothing.",
"error_log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get Web Properties
@param $account_id
@return array | [
"Get",
"Web",
"Properties"
] | train | https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L153-L167 |
hametuha/gapiwp | src/Hametuha/GapiWP/Service/Analytics.php | Analytics.get_views | public function get_views($account_id, $profile_id){
$result = array();
try{
$views = $this->ga
->management_profiles
->listManagementProfiles($account_id, $profile_id);
$result =$views->getItems();
}catch ( \Exception $e ){
// Do nothing.
error_log($e->getMessage(), $e->getCode());
}
return $result;
} | php | public function get_views($account_id, $profile_id){
$result = array();
try{
$views = $this->ga
->management_profiles
->listManagementProfiles($account_id, $profile_id);
$result =$views->getItems();
}catch ( \Exception $e ){
// Do nothing.
error_log($e->getMessage(), $e->getCode());
}
return $result;
} | [
"public",
"function",
"get_views",
"(",
"$",
"account_id",
",",
"$",
"profile_id",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"try",
"{",
"$",
"views",
"=",
"$",
"this",
"->",
"ga",
"->",
"management_profiles",
"->",
"listManagementProfiles",
"(",
"$",
"account_id",
",",
"$",
"profile_id",
")",
";",
"$",
"result",
"=",
"$",
"views",
"->",
"getItems",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Do nothing.",
"error_log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Get Views
@param $account_id
@param $profile_id
@return array | [
"Get",
"Views"
] | train | https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L176-L188 |
hametuha/gapiwp | src/Hametuha/GapiWP/Service/Analytics.php | Analytics.fetch | public function fetch($from, $to, $metrics, array $args, $view_id = null ){
if( !$this->ga ){
return new \WP_Error(500, __('Google Analtyisとの連携が完了していません。', 'gapiwp'));
}
if( is_null($view_id) ){
$view_id = $this->view_id;
}
try{
$result = $this->ga->data_ga->get('ga:'.$view_id, $from, $to, $metrics, $args);
}catch ( \Exception $e ){
$result = new \WP_Error($e->getCode(), $e->getMessage());
}
return $result;
} | php | public function fetch($from, $to, $metrics, array $args, $view_id = null ){
if( !$this->ga ){
return new \WP_Error(500, __('Google Analtyisとの連携が完了していません。', 'gapiwp'));
}
if( is_null($view_id) ){
$view_id = $this->view_id;
}
try{
$result = $this->ga->data_ga->get('ga:'.$view_id, $from, $to, $metrics, $args);
}catch ( \Exception $e ){
$result = new \WP_Error($e->getCode(), $e->getMessage());
}
return $result;
} | [
"public",
"function",
"fetch",
"(",
"$",
"from",
",",
"$",
"to",
",",
"$",
"metrics",
",",
"array",
"$",
"args",
",",
"$",
"view_id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"ga",
")",
"{",
"return",
"new",
"\\",
"WP_Error",
"(",
"500",
",",
"__",
"(",
"'Google Analtyisとの連携が完了していません。', 'gapiwp'));",
"",
"",
"",
"",
"",
"}",
"if",
"(",
"is_null",
"(",
"$",
"view_id",
")",
")",
"{",
"$",
"view_id",
"=",
"$",
"this",
"->",
"view_id",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"ga",
"->",
"data_ga",
"->",
"get",
"(",
"'ga:'",
".",
"$",
"view_id",
",",
"$",
"from",
",",
"$",
"to",
",",
"$",
"metrics",
",",
"$",
"args",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"result",
"=",
"new",
"\\",
"WP_Error",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Fetch data
@param string $from
@param string $to
@param string $metrics
@param array $args
@return \Google_Service_Analytics_GaData|\WP_Error | [
"Fetch",
"data"
] | train | https://github.com/hametuha/gapiwp/blob/7b9716d0ebd54c4ab79cca94a4c5aef099a54266/src/Hametuha/GapiWP/Service/Analytics.php#L200-L213 |
fond-of/spryker-brand | src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php | Brand.add | public function add(BrandTransfer $brandTransfer): BrandResponseTransfer
{
$brandEntity = $this->createFosBrandEntity($brandTransfer);
$brandEntity->save();
$brandTransfer->setIdBrand($brandEntity->getPrimaryKey());
$brandResponseTransfer = new BrandResponseTransfer();
$brandResponseTransfer
->setIsSuccess(true)
->setBrandTransfer($brandTransfer);
return $brandResponseTransfer;
} | php | public function add(BrandTransfer $brandTransfer): BrandResponseTransfer
{
$brandEntity = $this->createFosBrandEntity($brandTransfer);
$brandEntity->save();
$brandTransfer->setIdBrand($brandEntity->getPrimaryKey());
$brandResponseTransfer = new BrandResponseTransfer();
$brandResponseTransfer
->setIsSuccess(true)
->setBrandTransfer($brandTransfer);
return $brandResponseTransfer;
} | [
"public",
"function",
"add",
"(",
"BrandTransfer",
"$",
"brandTransfer",
")",
":",
"BrandResponseTransfer",
"{",
"$",
"brandEntity",
"=",
"$",
"this",
"->",
"createFosBrandEntity",
"(",
"$",
"brandTransfer",
")",
";",
"$",
"brandEntity",
"->",
"save",
"(",
")",
";",
"$",
"brandTransfer",
"->",
"setIdBrand",
"(",
"$",
"brandEntity",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"$",
"brandResponseTransfer",
"=",
"new",
"BrandResponseTransfer",
"(",
")",
";",
"$",
"brandResponseTransfer",
"->",
"setIsSuccess",
"(",
"true",
")",
"->",
"setBrandTransfer",
"(",
"$",
"brandTransfer",
")",
";",
"return",
"$",
"brandResponseTransfer",
";",
"}"
] | @param \Generated\Shared\Transfer\BrandTransfer $brandTransfer
@return \Generated\Shared\Transfer\BrandResponseTransfer | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"BrandTransfer",
"$brandTransfer"
] | train | https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php#L50-L63 |
fond-of/spryker-brand | src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php | Brand.createFosBrandEntity | protected function createFosBrandEntity(BrandTransfer $brandTransfer): FosBrand
{
$brandEntity = new FosBrand();
$brandEntity->fromArray($brandTransfer->toArray());
return $brandEntity;
} | php | protected function createFosBrandEntity(BrandTransfer $brandTransfer): FosBrand
{
$brandEntity = new FosBrand();
$brandEntity->fromArray($brandTransfer->toArray());
return $brandEntity;
} | [
"protected",
"function",
"createFosBrandEntity",
"(",
"BrandTransfer",
"$",
"brandTransfer",
")",
":",
"FosBrand",
"{",
"$",
"brandEntity",
"=",
"new",
"FosBrand",
"(",
")",
";",
"$",
"brandEntity",
"->",
"fromArray",
"(",
"$",
"brandTransfer",
"->",
"toArray",
"(",
")",
")",
";",
"return",
"$",
"brandEntity",
";",
"}"
] | @param \Generated\Shared\Transfer\BrandTransfer $brandTransfer
@return \Orm\Zed\Brand\Persistence\FosBrand | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"BrandTransfer",
"$brandTransfer"
] | train | https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php#L70-L76 |
fond-of/spryker-brand | src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php | Brand.createBrandResponseTransfer | protected function createBrandResponseTransfer($isSuccess = true): BrandResponseTransfer
{
$brandResponseTransfer = new BrandResponseTransfer();
$brandResponseTransfer->setIsSuccess($isSuccess);
return $brandResponseTransfer;
} | php | protected function createBrandResponseTransfer($isSuccess = true): BrandResponseTransfer
{
$brandResponseTransfer = new BrandResponseTransfer();
$brandResponseTransfer->setIsSuccess($isSuccess);
return $brandResponseTransfer;
} | [
"protected",
"function",
"createBrandResponseTransfer",
"(",
"$",
"isSuccess",
"=",
"true",
")",
":",
"BrandResponseTransfer",
"{",
"$",
"brandResponseTransfer",
"=",
"new",
"BrandResponseTransfer",
"(",
")",
";",
"$",
"brandResponseTransfer",
"->",
"setIsSuccess",
"(",
"$",
"isSuccess",
")",
";",
"return",
"$",
"brandResponseTransfer",
";",
"}"
] | @param bool $isSuccess
@return \Generated\Shared\Transfer\BrandResponseTransfer | [
"@param",
"bool",
"$isSuccess"
] | train | https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php#L83-L89 |
fond-of/spryker-brand | src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php | Brand.delete | public function delete(BrandTransfer $brandTransfer): bool
{
$brandEntity = $this->getBrand($brandTransfer);
$brandEntity->delete();
return true;
} | php | public function delete(BrandTransfer $brandTransfer): bool
{
$brandEntity = $this->getBrand($brandTransfer);
$brandEntity->delete();
return true;
} | [
"public",
"function",
"delete",
"(",
"BrandTransfer",
"$",
"brandTransfer",
")",
":",
"bool",
"{",
"$",
"brandEntity",
"=",
"$",
"this",
"->",
"getBrand",
"(",
"$",
"brandTransfer",
")",
";",
"$",
"brandEntity",
"->",
"delete",
"(",
")",
";",
"return",
"true",
";",
"}"
] | @param \Generated\Shared\Transfer\BrandTransfer $brandTransfer
@return bool | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"BrandTransfer",
"$brandTransfer"
] | train | https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php#L96-L102 |
fond-of/spryker-brand | src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php | Brand.get | public function get(BrandTransfer $brandTransfer): BrandTransfer
{
$brandEntity = $this->getBrand($brandTransfer);
$brandTransfer->fromArray($brandEntity->toArray(), true);
$brandTransfer = $this->brandExpander->expand($brandTransfer);
return $brandTransfer;
} | php | public function get(BrandTransfer $brandTransfer): BrandTransfer
{
$brandEntity = $this->getBrand($brandTransfer);
$brandTransfer->fromArray($brandEntity->toArray(), true);
$brandTransfer = $this->brandExpander->expand($brandTransfer);
return $brandTransfer;
} | [
"public",
"function",
"get",
"(",
"BrandTransfer",
"$",
"brandTransfer",
")",
":",
"BrandTransfer",
"{",
"$",
"brandEntity",
"=",
"$",
"this",
"->",
"getBrand",
"(",
"$",
"brandTransfer",
")",
";",
"$",
"brandTransfer",
"->",
"fromArray",
"(",
"$",
"brandEntity",
"->",
"toArray",
"(",
")",
",",
"true",
")",
";",
"$",
"brandTransfer",
"=",
"$",
"this",
"->",
"brandExpander",
"->",
"expand",
"(",
"$",
"brandTransfer",
")",
";",
"return",
"$",
"brandTransfer",
";",
"}"
] | @param \Generated\Shared\Transfer\BrandTransfer $brandTransfer
@return \Generated\Shared\Transfer\BrandTransfer | [
"@param",
"\\",
"Generated",
"\\",
"Shared",
"\\",
"Transfer",
"\\",
"BrandTransfer",
"$brandTransfer"
] | train | https://github.com/fond-of/spryker-brand/blob/0ae25c381649b70845016606de9cf4e7dfdccffa/src/FondOfSpryker/Zed/Brand/Business/Brand/Brand.php#L109-L116 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.