repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
matrozov/yii2-couchbase | src/Connection.php | Connection.createPrimaryIndex | public function createPrimaryIndex($bucketName, $indexName = null, $options = [])
{
return $this->createCommand()->createPrimaryIndex($bucketName, $indexName, $options)->execute();
} | php | public function createPrimaryIndex($bucketName, $indexName = null, $options = [])
{
return $this->createCommand()->createPrimaryIndex($bucketName, $indexName, $options)->execute();
} | [
"public",
"function",
"createPrimaryIndex",
"(",
"$",
"bucketName",
",",
"$",
"indexName",
"=",
"null",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"createCommand",
"(",
")",
"->",
"createPrimaryIndex",
"(",
"$",
"bucketName"... | Create primary index.
@param string $bucketName
@param string|null $indexName name of primary index (optional)
@param array $options
@return bool
@throws Exception
@throws InvalidConfigException | [
"Create",
"primary",
"index",
"."
] | train | https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L557-L560 |
matrozov/yii2-couchbase | src/Connection.php | Connection.createIndex | public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = [])
{
return $this->createCommand()->createIndex($bucketName, $indexName, $columns, $condition, $params, $options)->execute();
} | php | public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = [])
{
return $this->createCommand()->createIndex($bucketName, $indexName, $columns, $condition, $params, $options)->execute();
} | [
"public",
"function",
"createIndex",
"(",
"$",
"bucketName",
",",
"$",
"indexName",
",",
"$",
"columns",
",",
"$",
"condition",
"=",
"null",
",",
"&",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this"... | Creates index.
@param string $bucketName
@param string $indexName
@param array $columns
@param array|null $condition
@param array $params
@param array $options
@return bool
@throws Exception
@throws InvalidConfigException | [
"Creates",
"index",
"."
] | train | https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Connection.php#L590-L593 |
baleen/migrations | src/Delta/Collection/Resolver/FilenameResolver.php | FilenameResolver.doResolve | protected function doResolve($alias, Collection $collection)
{
if (strlen($alias) <= 4 || substr($alias, -4) != '.php') {
return null;
}
$result = null;
foreach ($collection as $version) {
/** @var DeltaInterface $version */
$file = $version->getMigrationFileName();
if (strpos($file, $alias) !== false) {
$result = $version;
break;
}
}
return $result;
} | php | protected function doResolve($alias, Collection $collection)
{
if (strlen($alias) <= 4 || substr($alias, -4) != '.php') {
return null;
}
$result = null;
foreach ($collection as $version) {
/** @var DeltaInterface $version */
$file = $version->getMigrationFileName();
if (strpos($file, $alias) !== false) {
$result = $version;
break;
}
}
return $result;
} | [
"protected",
"function",
"doResolve",
"(",
"$",
"alias",
",",
"Collection",
"$",
"collection",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"alias",
")",
"<=",
"4",
"||",
"substr",
"(",
"$",
"alias",
",",
"-",
"4",
")",
"!=",
"'.php'",
")",
"{",
"retur... | doResolve
@param $alias
@param Collection $collection
@return DeltaInterface|null | [
"doResolve"
] | train | https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Resolver/FilenameResolver.php#L39-L55 |
wardrobecms/core-archived | src/Wardrobe/Core/Console/ThemeCommand.php | ThemeCommand.fire | public function fire()
{
$this->call('asset:publish', array('package' => 'wardrobe/core'));
$assetPath = public_path().'/packages/wardrobe/core/themes';
$themePath = public_path().'/'.Config::get('core::wardrobe.theme_dir');
$this->copyDir($assetPath, $themePath);
} | php | public function fire()
{
$this->call('asset:publish', array('package' => 'wardrobe/core'));
$assetPath = public_path().'/packages/wardrobe/core/themes';
$themePath = public_path().'/'.Config::get('core::wardrobe.theme_dir');
$this->copyDir($assetPath, $themePath);
} | [
"public",
"function",
"fire",
"(",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'asset:publish'",
",",
"array",
"(",
"'package'",
"=>",
"'wardrobe/core'",
")",
")",
";",
"$",
"assetPath",
"=",
"public_path",
"(",
")",
".",
"'/packages/wardrobe/core/themes'",
"... | Execute the console command.
@return void | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Console/ThemeCommand.php#L39-L45 |
wardrobecms/core-archived | src/Wardrobe/Core/Controllers/LoginController.php | LoginController.store | public function store()
{
$email = mb_strtolower(Input::get('email'));
$password = Input::get('password');
if ($this->users->login($email, $password, Input::get('remember') == 'yes'))
{
return Redirect::route('wardrobe.admin.index');
}
return Redirect::back()
->withInput()
->with('login_errors', true);
} | php | public function store()
{
$email = mb_strtolower(Input::get('email'));
$password = Input::get('password');
if ($this->users->login($email, $password, Input::get('remember') == 'yes'))
{
return Redirect::route('wardrobe.admin.index');
}
return Redirect::back()
->withInput()
->with('login_errors', true);
} | [
"public",
"function",
"store",
"(",
")",
"{",
"$",
"email",
"=",
"mb_strtolower",
"(",
"Input",
"::",
"get",
"(",
"'email'",
")",
")",
";",
"$",
"password",
"=",
"Input",
"::",
"get",
"(",
"'password'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"user... | Handle a user login attempt. | [
"Handle",
"a",
"user",
"login",
"attempt",
"."
] | train | https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/LoginController.php#L41-L55 |
wardrobecms/core-archived | src/Wardrobe/Core/Controllers/LoginController.php | LoginController.remindSend | public function remindSend()
{
$credentials = array('email' => Input::get('email'));
return Password::remind($credentials, function($message, $user)
{
$message->subject('Reset your password');
});
} | php | public function remindSend()
{
$credentials = array('email' => Input::get('email'));
return Password::remind($credentials, function($message, $user)
{
$message->subject('Reset your password');
});
} | [
"public",
"function",
"remindSend",
"(",
")",
"{",
"$",
"credentials",
"=",
"array",
"(",
"'email'",
"=>",
"Input",
"::",
"get",
"(",
"'email'",
")",
")",
";",
"return",
"Password",
"::",
"remind",
"(",
"$",
"credentials",
",",
"function",
"(",
"$",
"m... | Send an email to reset your password. | [
"Send",
"an",
"email",
"to",
"reset",
"your",
"password",
"."
] | train | https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/LoginController.php#L77-L85 |
budde377/Part | lib/util/task/ExecuteDelayedExecutionTaskQueueTaskImpl.php | ExecuteDelayedExecutionTaskQueueTaskImpl.execute | public function execute()
{
$queue = $this->container->getDelayedExecutionTaskQueue();
if($queue->length() == 0){
return;
}
ignore_user_abort(true);
$queue->execute();
} | php | public function execute()
{
$queue = $this->container->getDelayedExecutionTaskQueue();
if($queue->length() == 0){
return;
}
ignore_user_abort(true);
$queue->execute();
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"queue",
"=",
"$",
"this",
"->",
"container",
"->",
"getDelayedExecutionTaskQueue",
"(",
")",
";",
"if",
"(",
"$",
"queue",
"->",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"ignor... | This function runs the script
@return mixed | [
"This",
"function",
"runs",
"the",
"script"
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/task/ExecuteDelayedExecutionTaskQueueTaskImpl.php#L31-L39 |
yeephp/yeephp | Yee/Middleware/Flash.php | Flash.call | public function call()
{
//Read flash messaging from previous request if available
$this->loadMessages();
//Prepare flash messaging for current request
$env = $this->app->environment();
$env['yee.flash'] = $this;
$this->next->call();
$this->save();
} | php | public function call()
{
//Read flash messaging from previous request if available
$this->loadMessages();
//Prepare flash messaging for current request
$env = $this->app->environment();
$env['yee.flash'] = $this;
$this->next->call();
$this->save();
} | [
"public",
"function",
"call",
"(",
")",
"{",
"//Read flash messaging from previous request if available",
"$",
"this",
"->",
"loadMessages",
"(",
")",
";",
"//Prepare flash messaging for current request",
"$",
"env",
"=",
"$",
"this",
"->",
"app",
"->",
"environment",
... | Call | [
"Call"
] | train | https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Middleware/Flash.php#L77-L87 |
yeephp/yeephp | Yee/Middleware/Flash.php | Flash.loadMessages | public function loadMessages()
{
if (isset($_SESSION[$this->settings['key']])) {
$this->messages['prev'] = $_SESSION[$this->settings['key']];
}
} | php | public function loadMessages()
{
if (isset($_SESSION[$this->settings['key']])) {
$this->messages['prev'] = $_SESSION[$this->settings['key']];
}
} | [
"public",
"function",
"loadMessages",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"settings",
"[",
"'key'",
"]",
"]",
")",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"'prev'",
"]",
"=",
"$",
"_SESSION",
"[",
... | Load messages from previous request if available | [
"Load",
"messages",
"from",
"previous",
"request",
"if",
"available"
] | train | https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Middleware/Flash.php#L138-L143 |
yeephp/yeephp | Yee/Helper/Set.php | Set.singleton | public function singleton($key, $value)
{
$this->set($key, function ($c) use ($value) {
static $object;
if (null === $object) {
$object = $value($c);
}
return $object;
});
} | php | public function singleton($key, $value)
{
$this->set($key, function ($c) use ($value) {
static $object;
if (null === $object) {
$object = $value($c);
}
return $object;
});
} | [
"public",
"function",
"singleton",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"function",
"(",
"$",
"c",
")",
"use",
"(",
"$",
"value",
")",
"{",
"static",
"$",
"object",
";",
"if",
"(",
"null"... | Ensure a value or object will remain globally unique
@param string $key The value or object name
@param Closure The closure that defines the object
@return mixed | [
"Ensure",
"a",
"value",
"or",
"object",
"will",
"remain",
"globally",
"unique"
] | train | https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Helper/Set.php#L222-L233 |
skrz/meta | gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php | ServiceDescriptorProtoMeta.create | public static function create()
{
switch (func_num_args()) {
case 0:
return new ServiceDescriptorProto();
case 1:
return new ServiceDescriptorProto(func_get_arg(0));
case 2:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
} | php | public static function create()
{
switch (func_num_args()) {
case 0:
return new ServiceDescriptorProto();
case 1:
return new ServiceDescriptorProto(func_get_arg(0));
case 2:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1));
case 3:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ServiceDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
} | [
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ServiceDescriptorProto",
"(",
"func... | Creates new instance of \Google\Protobuf\ServiceDescriptorProto
@throws \InvalidArgumentException
@return ServiceDescriptorProto | [
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L59-L83 |
skrz/meta | gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php | ServiceDescriptorProtoMeta.reset | public static function reset($object)
{
if (!($object instanceof ServiceDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceDescriptorProto.');
}
$object->name = NULL;
$object->method = NULL;
$object->options = NULL;
} | php | public static function reset($object)
{
if (!($object instanceof ServiceDescriptorProto)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\ServiceDescriptorProto.');
}
$object->name = NULL;
$object->method = NULL;
$object->options = NULL;
} | [
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"ServiceDescriptorProto",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protob... | Resets properties of \Google\Protobuf\ServiceDescriptorProto to default values
@param ServiceDescriptorProto $object
@throws \InvalidArgumentException
@return void | [
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto",
"to",
"default",
"values"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L96-L104 |
skrz/meta | gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php | ServiceDescriptorProtoMeta.hash | public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
hash_update($ctx, (string)$object->name);
}
if (isset($object->method)) {
hash_update($ctx, 'method');
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $v0) {
MethodDescriptorProtoMeta::hash($v0, $ctx);
}
}
if (isset($object->options)) {
hash_update($ctx, 'options');
ServiceOptionsMeta::hash($object->options, $ctx);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
} | php | public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->name)) {
hash_update($ctx, 'name');
hash_update($ctx, (string)$object->name);
}
if (isset($object->method)) {
hash_update($ctx, 'method');
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $v0) {
MethodDescriptorProtoMeta::hash($v0, $ctx);
}
}
if (isset($object->options)) {
hash_update($ctx, 'options');
ServiceOptionsMeta::hash($object->options, $ctx);
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
} | [
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrC... | Computes hash of \Google\Protobuf\ServiceDescriptorProto
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void | [
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L116-L146 |
skrz/meta | gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php | ServiceDescriptorProtoMeta.fromProtobuf | public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ServiceDescriptorProto();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->name = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 2:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
if (!(isset($object->method) && is_array($object->method))) {
$object->method = array();
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->method[] = MethodDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 3:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->options = ServiceOptionsMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
} | php | public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ServiceDescriptorProto();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->name = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 2:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
if (!(isset($object->method) && is_array($object->method))) {
$object->method = array();
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->method[] = MethodDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 3:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->options = ServiceOptionsMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
} | [
"public",
"static",
"function",
"fromProtobuf",
"(",
"$",
"input",
",",
"$",
"object",
"=",
"NULL",
",",
"&",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
... | Creates \Google\Protobuf\ServiceDescriptorProto object from serialized Protocol Buffers message.
@param string $input
@param ServiceDescriptorProto $object
@param int $start
@param int $end
@throws \Exception
@return ServiceDescriptorProto | [
"Creates",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L161-L243 |
skrz/meta | gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php | ServiceDescriptorProtoMeta.toProtobuf | public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->name) && ($filter === null || isset($filter['name']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->name));
$output .= $object->name;
}
if (isset($object->method) && ($filter === null || isset($filter['method']))) {
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $k => $v) {
$output .= "\x12";
$buffer = MethodDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['method']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x1a";
$buffer = ServiceOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
return $output;
} | php | public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->name) && ($filter === null || isset($filter['name']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->name));
$output .= $object->name;
}
if (isset($object->method) && ($filter === null || isset($filter['method']))) {
foreach ($object->method instanceof \Traversable ? $object->method : (array)$object->method as $k => $v) {
$output .= "\x12";
$buffer = MethodDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['method']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
if (isset($object->options) && ($filter === null || isset($filter['options']))) {
$output .= "\x1a";
$buffer = ServiceOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
return $output;
} | [
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"name",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
... | Serialized \Google\Protobuf\ServiceDescriptorProto to Protocol Buffers message.
@param ServiceDescriptorProto $object
@param array $filter
@throws \Exception
@return string | [
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"ServiceDescriptorProto",
"to",
"Protocol",
"Buffers",
"message",
"."
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/ServiceDescriptorProtoMeta.php#L256-L283 |
wardrobecms/core-archived | src/migrations/2013_11_28_205454_add_id_to_tags_table.php | AddIdToTagsTable.up | public function up()
{
Schema::create('tags_new', function($table)
{
$table->increments('id');
$table->integer('post_id');
$table->string('tag');
$table->unique(array('post_id', 'tag'));
});
DB::statement('INSERT INTO tags_new(`post_id`, `tag`) SELECT `post_id`, `tag` FROM tags');
Schema::drop('tags');
Schema::rename('tags_new', 'tags');
} | php | public function up()
{
Schema::create('tags_new', function($table)
{
$table->increments('id');
$table->integer('post_id');
$table->string('tag');
$table->unique(array('post_id', 'tag'));
});
DB::statement('INSERT INTO tags_new(`post_id`, `tag`) SELECT `post_id`, `tag` FROM tags');
Schema::drop('tags');
Schema::rename('tags_new', 'tags');
} | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'tags_new'",
",",
"function",
"(",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table",
"->",
"integer",
"(",
"'post_id'",
")",
";",
... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/migrations/2013_11_28_205454_add_id_to_tags_table.php#L12-L24 |
wardrobecms/core-archived | src/migrations/2013_11_28_205454_add_id_to_tags_table.php | AddIdToTagsTable.down | public function down()
{
Schema::create('tags_old', function($table)
{
$table->integer('post_id');
$table->string('tag');
$table->unique(array('post_id', 'tag'));
});
DB::statement('INSERT INTO tags_old(`post_id`, `tag`) SELECT `post_id`, `tag` FROM tags');
Schema::drop('tags');
Schema::rename('tags_old', 'tags');
} | php | public function down()
{
Schema::create('tags_old', function($table)
{
$table->integer('post_id');
$table->string('tag');
$table->unique(array('post_id', 'tag'));
});
DB::statement('INSERT INTO tags_old(`post_id`, `tag`) SELECT `post_id`, `tag` FROM tags');
Schema::drop('tags');
Schema::rename('tags_old', 'tags');
} | [
"public",
"function",
"down",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"'tags_old'",
",",
"function",
"(",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"integer",
"(",
"'post_id'",
")",
";",
"$",
"table",
"->",
"string",
"(",
"'tag'",
")",
";",
... | Reverse the migrations.
@return void | [
"Reverse",
"the",
"migrations",
"."
] | train | https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/migrations/2013_11_28_205454_add_id_to_tags_table.php#L31-L42 |
budde377/Part | lib/model/site/SiteImpl.php | SiteImpl.getVariables | public function getVariables()
{
return $this->variables == null?$this->variables = new SiteVariablesImpl($this->db):$this->variables;
} | php | public function getVariables()
{
return $this->variables == null?$this->variables = new SiteVariablesImpl($this->db):$this->variables;
} | [
"public",
"function",
"getVariables",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"variables",
"==",
"null",
"?",
"$",
"this",
"->",
"variables",
"=",
"new",
"SiteVariablesImpl",
"(",
"$",
"this",
"->",
"db",
")",
":",
"$",
"this",
"->",
"variables",
"... | Returns and reuses instance of site scoped variables
@return Variables | [
"Returns",
"and",
"reuses",
"instance",
"of",
"site",
"scoped",
"variables"
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/site/SiteImpl.php#L46-L49 |
budde377/Part | lib/model/site/SiteImpl.php | SiteImpl.lastModified | public function lastModified()
{
return $this->lastMod == 0?$this->lastMod = $this->getVariables()->getValue("last_modified"):$this->lastMod;
} | php | public function lastModified()
{
return $this->lastMod == 0?$this->lastMod = $this->getVariables()->getValue("last_modified"):$this->lastMod;
} | [
"public",
"function",
"lastModified",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"lastMod",
"==",
"0",
"?",
"$",
"this",
"->",
"lastMod",
"=",
"$",
"this",
"->",
"getVariables",
"(",
")",
"->",
"getValue",
"(",
"\"last_modified\"",
")",
":",
"$",
"thi... | Returns last modified timestamp, 0 if site hasnot been modified
@return int 0 | [
"Returns",
"last",
"modified",
"timestamp",
"0",
"if",
"site",
"hasnot",
"been",
"modified"
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/site/SiteImpl.php#L55-L58 |
budde377/Part | lib/model/site/SiteImpl.php | SiteImpl.getContentLibrary | public function getContentLibrary()
{
return $this->contentLibrary == null?
$this->contentLibrary = new SiteContentLibraryImpl($this->container):
$this->contentLibrary;
} | php | public function getContentLibrary()
{
return $this->contentLibrary == null?
$this->contentLibrary = new SiteContentLibraryImpl($this->container):
$this->contentLibrary;
} | [
"public",
"function",
"getContentLibrary",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"contentLibrary",
"==",
"null",
"?",
"$",
"this",
"->",
"contentLibrary",
"=",
"new",
"SiteContentLibraryImpl",
"(",
"$",
"this",
"->",
"container",
")",
":",
"$",
"this",... | Will get and reuse instance of content library.
@return ContentLibrary | [
"Will",
"get",
"and",
"reuse",
"instance",
"of",
"content",
"library",
"."
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/site/SiteImpl.php#L75-L80 |
meare/juggler | src/Imposter/Stub/Predicate/Predicate.php | Predicate.normalizeFields | private function normalizeFields()
{
foreach ($this->fields as $key => $field) {
if (is_array($field)) {
$this->fields[$key] = \Meare\Juggler\json_object($field);
}
}
} | php | private function normalizeFields()
{
foreach ($this->fields as $key => $field) {
if (is_array($field)) {
$this->fields[$key] = \Meare\Juggler\json_object($field);
}
}
} | [
"private",
"function",
"normalizeFields",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"key",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"field",
")",
")",
"{",
"$",
"this",
"->",
"fields",
"[",
"$",
... | There is no arrays in predicate fields - all empty fields must serialize as {}
@return array | [
"There",
"is",
"no",
"arrays",
"in",
"predicate",
"fields",
"-",
"all",
"empty",
"fields",
"must",
"serialize",
"as",
"{}"
] | train | https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Imposter/Stub/Predicate/Predicate.php#L122-L129 |
matrozov/yii2-couchbase | src/ActiveQuery.php | ActiveQuery.createCommand | public function createCommand($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
list($sql, $params) = $db->getQueryBuilder()->build($this);
$bucketName = is_array($this->from) ? reset($this->from) : $this->from;
return $db->createCommand($sql, $params)->setBucketName($bucketName);
} | php | public function createCommand($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
list($sql, $params) = $db->getQueryBuilder()->build($this);
$bucketName = is_array($this->from) ? reset($this->from) : $this->from;
return $db->createCommand($sql, $params)->setBucketName($bucketName);
} | [
"public",
"function",
"createCommand",
"(",
"$",
"db",
"=",
"null",
")",
"{",
"/* @var $modelClass ActiveRecord */",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"modelClass",
";",
"if",
"(",
"$",
"db",
"===",
"null",
")",
"{",
"$",
"db",
"=",
"$",
"modelC... | Creates a DB command that can be used to execute this query.
@param Connection|null $db the DB connection used to create the DB command.
If `null`, the DB connection returned by [[modelClass]] will be used.
@return Command the created DB command instance.
@throws Exception
@throws \yii\base\InvalidConfigException | [
"Creates",
"a",
"DB",
"command",
"that",
"can",
"be",
"used",
"to",
"execute",
"this",
"query",
"."
] | train | https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveQuery.php#L105-L119 |
matrozov/yii2-couchbase | src/ActiveQuery.php | ActiveQuery.getBucket | public function getBucket($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
if ($this->select === null) {
$bucketName = $db->quoteBucketName($modelClass::bucketName());
$primaryModel = $this->primaryModel ?: ActiveRecord::className();
$primaryKey = $primaryModel::primaryKey()[0];
$primaryKey = $db->quoteColumnName($primaryKey);
$this->select = "meta($bucketName).id AS $primaryKey, $bucketName.*";
}
if ($this->from === null) {
$this->from = $modelClass::bucketName();
}
return $db->getBucket($this->from);
} | php | public function getBucket($db = null)
{
/* @var $modelClass ActiveRecord */
$modelClass = $this->modelClass;
if ($db === null) {
$db = $modelClass::getDb();
}
if ($this->select === null) {
$bucketName = $db->quoteBucketName($modelClass::bucketName());
$primaryModel = $this->primaryModel ?: ActiveRecord::className();
$primaryKey = $primaryModel::primaryKey()[0];
$primaryKey = $db->quoteColumnName($primaryKey);
$this->select = "meta($bucketName).id AS $primaryKey, $bucketName.*";
}
if ($this->from === null) {
$this->from = $modelClass::bucketName();
}
return $db->getBucket($this->from);
} | [
"public",
"function",
"getBucket",
"(",
"$",
"db",
"=",
"null",
")",
"{",
"/* @var $modelClass ActiveRecord */",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"modelClass",
";",
"if",
"(",
"$",
"db",
"===",
"null",
")",
"{",
"$",
"db",
"=",
"$",
"modelClass... | Returns the Couchbase bucket for this query.
@param Connection $db Couchbase connection.
@return Bucket bucket instance.
@throws Exception
@throws \yii\base\InvalidConfigException | [
"Returns",
"the",
"Couchbase",
"bucket",
"for",
"this",
"query",
"."
] | train | https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveQuery.php#L188-L213 |
xylemical/php-expressions | src/Parser.php | Parser.parse | public function parse($string) {
$output = new \SplQueue();
$operator = new \SplStack();
// Convert the string to tokens for the lexer.
$tokens = $this->lexer->tokenize($string);
// while there are tokens to be read:
while (count($tokens)) {
// read a token.
$token = array_shift($tokens);
// if the token is a number, then push it to the output queue.
if ($token->isValue()) {
$output->push($token);
continue;
}
// if the token is a function, then push it onto the operator stack.
if ($token->isFunction()) {
$operator->push($token);
continue;
}
// if the token is a function argument separator:
if ($token->getValue() === ',') {
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
$output->push($operator->pop());
}
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
continue;
}
// if the token is an operator, then:
if ($token->isOperator()) {
// while (
// (there is an operator at the top of the operator stack with greater precedence) or
// (the operator at the top of the operator stack has equal precedence and the operator is left associative)) and
// (the operator at the top of the stack is not a left bracket):
// pop operators from the operator stack, onto the output queue.
while (($op = $this->getTop($operator)) && $op->isOperator() && $token->hasHigherPriority($op)) {
$output->push($operator->pop());
}
// push the read operator onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a left bracket (i.e. "("), then:
if ($token->getValue() === '(') {
// push it onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a right bracket (i.e. ")"), then:
if ($token->getValue() === ')') {
// while the operator at the top of the operator stack is not a left bracket:
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
// pop operators from the operator stack onto the output queue.
$output->push($operator->pop());
}
// /* if the stack runs out without finding a left bracket, then there are mismatched parentheses. */
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses');
}
// pop the left bracket from the stack.
$operator->pop();
// If the token at the top of the stack is a function token, pop it onto the output queue.
if (($op = $this->getTop($operator)) && $op->isFunction()) {
$output->push($operator->pop());
}
}
}
// if there are no more tokens to read:
// while there are still operator tokens on the stack:
while (!$operator->isEmpty()) {
// /* if the operator token on the top of the stack is a bracket, then there are mismatched parentheses. */
if (is_null($operator->top()->getOperator())) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
// pop the operator onto the output queue.
$output->push($operator->pop());
}
// exit.
return iterator_to_array($output);
} | php | public function parse($string) {
$output = new \SplQueue();
$operator = new \SplStack();
// Convert the string to tokens for the lexer.
$tokens = $this->lexer->tokenize($string);
// while there are tokens to be read:
while (count($tokens)) {
// read a token.
$token = array_shift($tokens);
// if the token is a number, then push it to the output queue.
if ($token->isValue()) {
$output->push($token);
continue;
}
// if the token is a function, then push it onto the operator stack.
if ($token->isFunction()) {
$operator->push($token);
continue;
}
// if the token is a function argument separator:
if ($token->getValue() === ',') {
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
$output->push($operator->pop());
}
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
continue;
}
// if the token is an operator, then:
if ($token->isOperator()) {
// while (
// (there is an operator at the top of the operator stack with greater precedence) or
// (the operator at the top of the operator stack has equal precedence and the operator is left associative)) and
// (the operator at the top of the stack is not a left bracket):
// pop operators from the operator stack, onto the output queue.
while (($op = $this->getTop($operator)) && $op->isOperator() && $token->hasHigherPriority($op)) {
$output->push($operator->pop());
}
// push the read operator onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a left bracket (i.e. "("), then:
if ($token->getValue() === '(') {
// push it onto the operator stack.
$operator->push($token);
continue;
}
// if the token is a right bracket (i.e. ")"), then:
if ($token->getValue() === ')') {
// while the operator at the top of the operator stack is not a left bracket:
while (($op = $this->getTop($operator)) && $op->getValue() !== '(') {
// pop operators from the operator stack onto the output queue.
$output->push($operator->pop());
}
// /* if the stack runs out without finding a left bracket, then there are mismatched parentheses. */
if ($operator->isEmpty()) {
throw new ParserException('Mismatched parentheses');
}
// pop the left bracket from the stack.
$operator->pop();
// If the token at the top of the stack is a function token, pop it onto the output queue.
if (($op = $this->getTop($operator)) && $op->isFunction()) {
$output->push($operator->pop());
}
}
}
// if there are no more tokens to read:
// while there are still operator tokens on the stack:
while (!$operator->isEmpty()) {
// /* if the operator token on the top of the stack is a bracket, then there are mismatched parentheses. */
if (is_null($operator->top()->getOperator())) {
throw new ParserException('Mismatched parentheses or misplaced comma.');
}
// pop the operator onto the output queue.
$output->push($operator->pop());
}
// exit.
return iterator_to_array($output);
} | [
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"$",
"output",
"=",
"new",
"\\",
"SplQueue",
"(",
")",
";",
"$",
"operator",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"// Convert the string to tokens for the lexer.",
"$",
"tokens",
"=",
"$"... | Parses a string into a series of tokens in Reverse Polish Notation order.
@param string $string
@return \Xylemical\Expressions\Token[]
@throws \Xylemical\Expressions\ParserException
@see https://en.wikipedia.org/wiki/Shunting-yard_algorithm | [
"Parses",
"a",
"string",
"into",
"a",
"series",
"of",
"tokens",
"in",
"Reverse",
"Polish",
"Notation",
"order",
"."
] | train | https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Parser.php#L58-L155 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.initialize | public function initialize(array $config): void
{
$this->table('model_history');
$this->displayField('id');
$this->primaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id'
]);
$this->schema()->columnType('data', 'json');
$this->schema()->columnType('context', 'json');
} | php | public function initialize(array $config): void
{
$this->table('model_history');
$this->displayField('id');
$this->primaryKey('id');
$this->addBehavior('Timestamp');
$this->belongsTo('Users', [
'foreignKey' => 'user_id'
]);
$this->schema()->columnType('data', 'json');
$this->schema()->columnType('context', 'json');
} | [
"public",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
":",
"void",
"{",
"$",
"this",
"->",
"table",
"(",
"'model_history'",
")",
";",
"$",
"this",
"->",
"displayField",
"(",
"'id'",
")",
";",
"$",
"this",
"->",
"primaryKey",
"(",
"'id'"... | Initialize method
@param array $config The configuration for the Table.
@return void | [
"Initialize",
"method"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L26-L37 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.validationDefault | public function validationDefault(Validator $validator): \Cake\Validation\Validator
{
$validator->add('data', 'custom', [
'rule' => function ($value, $context) {
if ($context['data']['action'] != ModelHistory::ACTION_COMMENT) {
return true;
}
return !empty($value['comment']);
},
'message' => __d('model_history', 'comment_empty')
]);
return $validator;
} | php | public function validationDefault(Validator $validator): \Cake\Validation\Validator
{
$validator->add('data', 'custom', [
'rule' => function ($value, $context) {
if ($context['data']['action'] != ModelHistory::ACTION_COMMENT) {
return true;
}
return !empty($value['comment']);
},
'message' => __d('model_history', 'comment_empty')
]);
return $validator;
} | [
"public",
"function",
"validationDefault",
"(",
"Validator",
"$",
"validator",
")",
":",
"\\",
"Cake",
"\\",
"Validation",
"\\",
"Validator",
"{",
"$",
"validator",
"->",
"add",
"(",
"'data'",
",",
"'custom'",
",",
"[",
"'rule'",
"=>",
"function",
"(",
"$"... | Default validation rules.
@param \Cake\Validation\Validator $validator Validator instance.
@return \Cake\Validation\Validator | [
"Default",
"validation",
"rules",
"."
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L45-L59 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.add | public function add(EntityInterface $entity, string $action, string $userId = null, array $options = [])
{
$options = Hash::merge([
'dirtyFields' => null,
'data' => null
], $options);
if (!$options['data']) {
$options['data'] = $entity->toArray();
}
$hiddenProperties = $entity->hiddenProperties();
if (!empty($hiddenProperties)) {
$options['data'] = Hash::merge($options['data'], $entity->extract($hiddenProperties));
}
$saveFields = [];
$model = $entity->source();
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
if (!in_array($model, ['ArticlesUsersTable', 'ArticlesItemsTable'])) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\\' . $model];
}
}
$saveableFields = TableRegistry::get($model, $tableConfig)->getSaveableFields();
$entries = [];
if ($action === ModelHistory::ACTION_COMMENT) {
$saveFields = [
'comment' => $options['data']['comment']
];
} else {
foreach ($saveableFields as $fieldName => $data) {
if (isset($options['data'][$fieldName])) {
if (isset($data['saveParser']) && is_callable($data['saveParser'])) {
$callback = $data['saveParser'];
$options['data'][$fieldName] = $callback($fieldName, $options['data'][$fieldName], $entity);
} else {
if (isset($data['type'])) {
$filterClass = Transform::get($data['type']);
if ($data['type'] == 'association' && isset($data['associationKey'])) {
$tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldName)));
$foreignEntity = TableRegistry::get($tableName)->get($entity->$fieldName);
$entries[] = $this->newEntity([
'model' => $this->getEntityModel($foreignEntity),
'foreign_key' => $foreignEntity->id,
'action' => $action,
'data' => [$data['associationKey'] => $filterClass->save($fieldName, $data, $entity)],
'revision' => $this->getNextRevisionNumberForEntity($foreignEntity)
]);
} else {
$options['data'][$fieldName] = $filterClass->save($fieldName, $data, $entity);
}
}
}
if ($data['obfuscated'] === true) {
$options['data'][$fieldName] = '****************';
}
$saveFields[$fieldName] = $options['data'][$fieldName];
}
}
}
if ($action !== ModelHistory::ACTION_DELETE && empty($saveFields)) {
return false;
}
$options['data'] = $saveFields;
if ($action === ModelHistory::ACTION_DELETE) {
$options['data'] = [];
}
if ($action === ModelHistory::ACTION_UPDATE && $options['dirtyFields']) {
$newData = [];
foreach ($options['dirtyFields'] as $field) {
if (is_array($field)) {
continue;
}
if (isset($options['data'][$field])) {
$newData[$field] = $options['data'][$field];
}
}
$options['data'] = $newData;
}
$context = null;
if (method_exists($entity, 'getHistoryContext')) {
$context = $entity->getHistoryContext();
}
$contextSlug = null;
if (method_exists($entity, 'getHistoryContextSlug')) {
$contextSlug = $entity->getHistoryContextSlug();
}
$contextType = null;
if (method_exists($entity, 'getHistoryContextType')) {
$contextType = $entity->getHistoryContextType();
}
$entry = false;
if (!empty($entries)) {
foreach ($entries as $entry) {
$entry = $this->patchEntity($entry, [
'context_type' => $contextType,
'context' => $context,
'context_slug' => $contextSlug,
'user_id' => $userId,
]);
$this->save($entry);
}
}
if (!empty($entity->id)) {
$entry = $this->newEntity([
'model' => $this->getEntityModel($entity),
'foreign_key' => $entity->id,
'action' => $action,
'data' => $options['data'],
'context_type' => $contextType,
'context' => $context,
'context_slug' => $contextSlug,
'save_hash' => $entity->save_hash,
'user_id' => $userId,
'revision' => $this->getNextRevisionNumberForEntity($entity)
]);
$this->save($entry);
}
return $entry;
} | php | public function add(EntityInterface $entity, string $action, string $userId = null, array $options = [])
{
$options = Hash::merge([
'dirtyFields' => null,
'data' => null
], $options);
if (!$options['data']) {
$options['data'] = $entity->toArray();
}
$hiddenProperties = $entity->hiddenProperties();
if (!empty($hiddenProperties)) {
$options['data'] = Hash::merge($options['data'], $entity->extract($hiddenProperties));
}
$saveFields = [];
$model = $entity->source();
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
if (!in_array($model, ['ArticlesUsersTable', 'ArticlesItemsTable'])) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\\' . $model];
}
}
$saveableFields = TableRegistry::get($model, $tableConfig)->getSaveableFields();
$entries = [];
if ($action === ModelHistory::ACTION_COMMENT) {
$saveFields = [
'comment' => $options['data']['comment']
];
} else {
foreach ($saveableFields as $fieldName => $data) {
if (isset($options['data'][$fieldName])) {
if (isset($data['saveParser']) && is_callable($data['saveParser'])) {
$callback = $data['saveParser'];
$options['data'][$fieldName] = $callback($fieldName, $options['data'][$fieldName], $entity);
} else {
if (isset($data['type'])) {
$filterClass = Transform::get($data['type']);
if ($data['type'] == 'association' && isset($data['associationKey'])) {
$tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldName)));
$foreignEntity = TableRegistry::get($tableName)->get($entity->$fieldName);
$entries[] = $this->newEntity([
'model' => $this->getEntityModel($foreignEntity),
'foreign_key' => $foreignEntity->id,
'action' => $action,
'data' => [$data['associationKey'] => $filterClass->save($fieldName, $data, $entity)],
'revision' => $this->getNextRevisionNumberForEntity($foreignEntity)
]);
} else {
$options['data'][$fieldName] = $filterClass->save($fieldName, $data, $entity);
}
}
}
if ($data['obfuscated'] === true) {
$options['data'][$fieldName] = '****************';
}
$saveFields[$fieldName] = $options['data'][$fieldName];
}
}
}
if ($action !== ModelHistory::ACTION_DELETE && empty($saveFields)) {
return false;
}
$options['data'] = $saveFields;
if ($action === ModelHistory::ACTION_DELETE) {
$options['data'] = [];
}
if ($action === ModelHistory::ACTION_UPDATE && $options['dirtyFields']) {
$newData = [];
foreach ($options['dirtyFields'] as $field) {
if (is_array($field)) {
continue;
}
if (isset($options['data'][$field])) {
$newData[$field] = $options['data'][$field];
}
}
$options['data'] = $newData;
}
$context = null;
if (method_exists($entity, 'getHistoryContext')) {
$context = $entity->getHistoryContext();
}
$contextSlug = null;
if (method_exists($entity, 'getHistoryContextSlug')) {
$contextSlug = $entity->getHistoryContextSlug();
}
$contextType = null;
if (method_exists($entity, 'getHistoryContextType')) {
$contextType = $entity->getHistoryContextType();
}
$entry = false;
if (!empty($entries)) {
foreach ($entries as $entry) {
$entry = $this->patchEntity($entry, [
'context_type' => $contextType,
'context' => $context,
'context_slug' => $contextSlug,
'user_id' => $userId,
]);
$this->save($entry);
}
}
if (!empty($entity->id)) {
$entry = $this->newEntity([
'model' => $this->getEntityModel($entity),
'foreign_key' => $entity->id,
'action' => $action,
'data' => $options['data'],
'context_type' => $contextType,
'context' => $context,
'context_slug' => $contextSlug,
'save_hash' => $entity->save_hash,
'user_id' => $userId,
'revision' => $this->getNextRevisionNumberForEntity($entity)
]);
$this->save($entry);
}
return $entry;
} | [
"public",
"function",
"add",
"(",
"EntityInterface",
"$",
"entity",
",",
"string",
"$",
"action",
",",
"string",
"$",
"userId",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
... | Add a record to the ModelHistory
@param EntityInterface $entity Entity
@param string $action One of ModelHistory::ACTION_*
@param string $userId User ID to assign this history entry to
@param array $options Additional options
@return ModelHistory|false | [
"Add",
"a",
"record",
"to",
"the",
"ModelHistory"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L70-L204 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable._transformDataFields | protected function _transformDataFields(array $history, string $model): array
{
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\\' . ucfirst($model) . 'Table'];
$model = ucfirst($model) . 'Table';
}
$fieldConfig = TableRegistry::get($model, $tableConfig)->getFields();
foreach ($history as $index => $entity) {
$entityData = $entity->data;
foreach ($entityData as $field => $value) {
if (!isset($fieldConfig[$field]) || $fieldConfig[$field]['searchable'] !== true) {
continue;
}
if (isset($fieldConfig[$field]['displayParser']) && is_callable($fieldConfig[$field]['displayParser'])) {
$callback = $fieldConfig[$field]['displayParser'];
$entityData[$field] = $callback($field, $value, $entity);
continue;
}
$filterClass = Transform::get($fieldConfig[$field]['type']);
$entityData[$field] = $filterClass->display($field, $value, $model);
}
$history[$index]->data = $entityData;
}
return $history;
} | php | protected function _transformDataFields(array $history, string $model): array
{
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\\' . ucfirst($model) . 'Table'];
$model = ucfirst($model) . 'Table';
}
$fieldConfig = TableRegistry::get($model, $tableConfig)->getFields();
foreach ($history as $index => $entity) {
$entityData = $entity->data;
foreach ($entityData as $field => $value) {
if (!isset($fieldConfig[$field]) || $fieldConfig[$field]['searchable'] !== true) {
continue;
}
if (isset($fieldConfig[$field]['displayParser']) && is_callable($fieldConfig[$field]['displayParser'])) {
$callback = $fieldConfig[$field]['displayParser'];
$entityData[$field] = $callback($field, $value, $entity);
continue;
}
$filterClass = Transform::get($fieldConfig[$field]['type']);
$entityData[$field] = $filterClass->display($field, $value, $model);
}
$history[$index]->data = $entityData;
}
return $history;
} | [
"protected",
"function",
"_transformDataFields",
"(",
"array",
"$",
"history",
",",
"string",
"$",
"model",
")",
":",
"array",
"{",
"$",
"tableConfig",
"=",
"[",
"]",
";",
"if",
"(",
"defined",
"(",
"'PHPUNIT_TESTSUITE'",
")",
")",
"{",
"$",
"tableConfig",... | Transforms data fields to human readable form
@param array $history Data
@param string $model Model name
@return array | [
"Transforms",
"data",
"fields",
"to",
"human",
"readable",
"form"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L213-L239 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.addComment | public function addComment(EntityInterface $entity, string $comment, string $userId = null): ModelHistory
{
$add = $this->add($entity, ModelHistory::ACTION_COMMENT, $userId, [
'data' => [
'comment' => $comment
]
]);
return $add;
} | php | public function addComment(EntityInterface $entity, string $comment, string $userId = null): ModelHistory
{
$add = $this->add($entity, ModelHistory::ACTION_COMMENT, $userId, [
'data' => [
'comment' => $comment
]
]);
return $add;
} | [
"public",
"function",
"addComment",
"(",
"EntityInterface",
"$",
"entity",
",",
"string",
"$",
"comment",
",",
"string",
"$",
"userId",
"=",
"null",
")",
":",
"ModelHistory",
"{",
"$",
"add",
"=",
"$",
"this",
"->",
"add",
"(",
"$",
"entity",
",",
"Mod... | Add comment
@param EntityInterface $entity Entity to add the comment to
@param string $comment Comment
@param string $userId User which wrote the note
@return ModelHistory | [
"Add",
"comment"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L249-L258 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.getNextRevisionNumberForEntity | public function getNextRevisionNumberForEntity(EntityInterface $entity): int
{
$revision = 1;
$last = $this->find()
->select('revision')
->where([
'model' => $this->getEntityModel($entity),
'foreign_key' => $entity->id
])
->order(['revision DESC'])
->hydrate(false)
->first();
if (isset($last['revision'])) {
$revision = $last['revision'] + 1;
}
return $revision;
} | php | public function getNextRevisionNumberForEntity(EntityInterface $entity): int
{
$revision = 1;
$last = $this->find()
->select('revision')
->where([
'model' => $this->getEntityModel($entity),
'foreign_key' => $entity->id
])
->order(['revision DESC'])
->hydrate(false)
->first();
if (isset($last['revision'])) {
$revision = $last['revision'] + 1;
}
return $revision;
} | [
"public",
"function",
"getNextRevisionNumberForEntity",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"int",
"{",
"$",
"revision",
"=",
"1",
";",
"$",
"last",
"=",
"$",
"this",
"->",
"find",
"(",
")",
"->",
"select",
"(",
"'revision'",
")",
"->",
"whe... | Handles the revision sequence
@param EntityInterface $entity Entity to get the revision number for
@return int | [
"Handles",
"the",
"revision",
"sequence"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L266-L284 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.getEntityModel | public function getEntityModel(EntityInterface $entity): string
{
$source = $entity->source();
if (substr($source, -5) == 'Table') {
$source = substr($source, 0, -5);
}
return $source;
} | php | public function getEntityModel(EntityInterface $entity): string
{
$source = $entity->source();
if (substr($source, -5) == 'Table') {
$source = substr($source, 0, -5);
}
return $source;
} | [
"public",
"function",
"getEntityModel",
"(",
"EntityInterface",
"$",
"entity",
")",
":",
"string",
"{",
"$",
"source",
"=",
"$",
"entity",
"->",
"source",
"(",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"source",
",",
"-",
"5",
")",
"==",
"'Table'",
")... | Extracts the string to be saved to the model field from an entity
@param EntityInterface $entity Entity
@return string | [
"Extracts",
"the",
"string",
"to",
"be",
"saved",
"to",
"the",
"model",
"field",
"from",
"an",
"entity"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L292-L300 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.getEntityWithHistory | public function getEntityWithHistory(string $model, string $foreignKey, array $options = []): EntityInterface
{
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\ArticlesTable'];
}
$Table = TableRegistry::get($model, $tableConfig);
$userFields = $Table->getUserNameFields();
$options = Hash::merge([
'contain' => [
'ModelHistory' => [
'fields' => [
'id',
'user_id',
'action',
'revision',
'created',
'model',
'foreign_key',
'data',
'context',
'context_slug'
],
'sort' => ['ModelHistory.revision DESC'],
'Users' => [
'fields' => $userFields
]
]
]
], $options);
$entity = $Table->get($foreignKey, $options);
return $entity;
} | php | public function getEntityWithHistory(string $model, string $foreignKey, array $options = []): EntityInterface
{
$tableConfig = [];
if (defined('PHPUNIT_TESTSUITE')) {
$tableConfig = ['className' => 'ModelHistoryTestApp\Model\Table\ArticlesTable'];
}
$Table = TableRegistry::get($model, $tableConfig);
$userFields = $Table->getUserNameFields();
$options = Hash::merge([
'contain' => [
'ModelHistory' => [
'fields' => [
'id',
'user_id',
'action',
'revision',
'created',
'model',
'foreign_key',
'data',
'context',
'context_slug'
],
'sort' => ['ModelHistory.revision DESC'],
'Users' => [
'fields' => $userFields
]
]
]
], $options);
$entity = $Table->get($foreignKey, $options);
return $entity;
} | [
"public",
"function",
"getEntityWithHistory",
"(",
"string",
"$",
"model",
",",
"string",
"$",
"foreignKey",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"EntityInterface",
"{",
"$",
"tableConfig",
"=",
"[",
"]",
";",
"if",
"(",
"defined",
"(",... | GetEntityWithHistory function
@param string $model Model
@param string $foreignKey ForeignKey
@param array $options Options
@return \Cake\Datasource\EntityInterface | [
"GetEntityWithHistory",
"function"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L310-L343 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.getModelHistory | public function getModelHistory(string $model, $foreignKey, int $itemsToShow, int $page, array $conditions = [], array $options = []): array
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
$history = $history->order([
'revision' => 'DESC',
'ModelHistory.created' => 'DESC'
])
->contain(['Users'])
->limit($itemsToShow)
->page($page)
->toArray();
return $this->_transformDataFields($history, $model);
} | php | public function getModelHistory(string $model, $foreignKey, int $itemsToShow, int $page, array $conditions = [], array $options = []): array
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
$history = $history->order([
'revision' => 'DESC',
'ModelHistory.created' => 'DESC'
])
->contain(['Users'])
->limit($itemsToShow)
->page($page)
->toArray();
return $this->_transformDataFields($history, $model);
} | [
"public",
"function",
"getModelHistory",
"(",
"string",
"$",
"model",
",",
"$",
"foreignKey",
",",
"int",
"$",
"itemsToShow",
",",
"int",
"$",
"page",
",",
"array",
"$",
"conditions",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"... | Get Model History
@param string $model Model name
@param mixed $foreignKey Foreign key
@param int $itemsToShow Amount of items to be shown
@param int $page Current position
@param array $conditions Additional conditions for find
@param array $options Additional options
@return array | [
"Get",
"Model",
"History"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L356-L390 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.getModelHistoryCount | public function getModelHistoryCount(string $model, $foreignKey, array $conditions = [], array $options = []): int
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
return $history->count();
} | php | public function getModelHistoryCount(string $model, $foreignKey, array $conditions = [], array $options = []): int
{
$conditions = Hash::merge([
'model' => $model,
'foreign_key' => $foreignKey
], $conditions);
$options = Hash::merge([
'includeAssociated' => false
], $options);
if ($options['includeAssociated']) {
$hashes = $this->find()
->select(['save_hash'])
->where($conditions);
$history = $this->find()
->where([
'save_hash IN' => $hashes
]);
} else {
$history = $this->find()
->where($conditions);
}
return $history->count();
} | [
"public",
"function",
"getModelHistoryCount",
"(",
"string",
"$",
"model",
",",
"$",
"foreignKey",
",",
"array",
"$",
"conditions",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"conditions",
"=",
"Hash",
"::",
... | Get Model History entries count
@param string $model model name
@param mixed $foreignKey foreign key
@param array $conditions additional conditions for find
@return int | [
"Get",
"Model",
"History",
"entries",
"count"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L400-L425 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable.buildDiff | public function buildDiff(ModelHistory $historyEntry): array
{
if ($historyEntry->revision == 1) {
return [];
}
$previousRevisions = $this->find()
->where([
'model' => $historyEntry->model,
'foreign_key' => $historyEntry->foreign_key,
'revision <' => $historyEntry->revision
])
->order(['revision' => 'DESC'])
->toArray();
$entity = $this->getEntityWithHistory($historyEntry->model, $historyEntry->foreign_key);
$diffOutput = [
'changed' => [],
'changedBefore' => [],
'unchanged' => []
];
$fieldConfig = TableRegistry::get($historyEntry->model)->getFields();
$transformers = [];
// 1. Get old values for changed fields in passed entry, ignore arrays
foreach ($historyEntry->data as $fieldName => $newValue) {
foreach ($previousRevisions as $revision) {
if (isset($revision->data[$fieldName])) {
if (!isset($fieldConfig[$fieldName])) {
continue 2;
}
if (isset($fieldConfig[$fieldName]['displayParser']) && is_callable($fieldConfig[$fieldName]['displayParser'])) {
$callback = $fieldConfig[$fieldName]['displayParser'];
$diffOutput['changed'][$fieldName] = [
'old' => $callback($fieldName, $revision->data[$fieldName], $entity),
'new' => $callback($fieldName, $newValue, $entity)
];
continue 2;
}
$type = $fieldConfig[$fieldName]['type'];
if (!isset($transformers[$type])) {
$transformers[$type] = Transform::get($type);
}
$diffOutput['changed'][$fieldName] = [
'old' => $transformers[$type]->display($fieldName, $revision->data[$fieldName], $historyEntry->model),
'new' => $transformers[$type]->display($fieldName, $newValue, $historyEntry->model)
];
continue 2;
}
}
}
$currentEntity = TableRegistry::get($historyEntry->model)->get($historyEntry->foreign_key);
// 2. Try to get old values for any other fields defined in searchableFields and
foreach ($fieldConfig as $fieldName => $data) {
foreach ($previousRevisions as $revisionIndex => $revision) {
if (!isset($revision->data[$fieldName])) {
continue;
}
if (isset($diffOutput['changed'][$fieldName])) {
continue 2;
}
if ($revision->data[$fieldName] != $currentEntity->{$fieldName}) {
if (isset($data['displayParser']) && is_callable($data['displayParser'])) {
$callback = $data['displayParser'];
$diffOutput['changedBefore'][$fieldName] = [
'old' => $callback($fieldName, $revision->data[$fieldName], $entity),
'new' => $callback($fieldName, $currentEntity->{$fieldName}, $entity)
];
continue 2;
}
$type = $data['type'];
if (!isset($transformers[$type])) {
$transformers[$type] = Transform::get($type);
}
$diffOutput['changedBefore'][$fieldName] = [
'old' => $transformers[$type]->display($fieldName, $revision->data[$fieldName], $historyEntry->model),
'new' => $transformers[$type]->display($fieldName, $currentEntity->{$fieldName}, $historyEntry->model)
];
continue 2;
}
}
}
// 3. Get all unchanged fields
foreach ($fieldConfig as $fieldName => $data) {
foreach ($previousRevisions as $revision) {
if (!isset($revision->data[$fieldName])) {
continue;
}
if (isset($diffOutput['changed'][$fieldName]) || isset($diffOutput['changedBefore'][$fieldName])) {
continue 2;
}
if (isset($data['displayParser']) && is_callable($data['displayParser'])) {
$callback = $data['displayParser'];
$diffOutput['unchanged'][$fieldName] = $callback($fieldName, $currentEntity->{$fieldName}, $entity);
continue 2;
}
$type = $data['type'];
if (!isset($transformers[$type])) {
$transformers[$type] = Transform::get($type);
}
$diffOutput['unchanged'][$fieldName] = $transformers[$type]->display($fieldName, $currentEntity->{$fieldName}, $historyEntry->model);
continue 2;
}
}
// Translate all the fieldnames
foreach ($diffOutput as $type => $dataArr) {
if (!empty($dataArr)) {
foreach ($dataArr as $fieldName => $values) {
$localizedField = $this->_translateFieldname($fieldName, $historyEntry->model);
if ($localizedField != $fieldName) {
$dataArr[$localizedField] = $values;
unset($dataArr[$fieldName]);
}
}
$diffOutput[$type] = $dataArr;
}
}
return $diffOutput;
} | php | public function buildDiff(ModelHistory $historyEntry): array
{
if ($historyEntry->revision == 1) {
return [];
}
$previousRevisions = $this->find()
->where([
'model' => $historyEntry->model,
'foreign_key' => $historyEntry->foreign_key,
'revision <' => $historyEntry->revision
])
->order(['revision' => 'DESC'])
->toArray();
$entity = $this->getEntityWithHistory($historyEntry->model, $historyEntry->foreign_key);
$diffOutput = [
'changed' => [],
'changedBefore' => [],
'unchanged' => []
];
$fieldConfig = TableRegistry::get($historyEntry->model)->getFields();
$transformers = [];
// 1. Get old values for changed fields in passed entry, ignore arrays
foreach ($historyEntry->data as $fieldName => $newValue) {
foreach ($previousRevisions as $revision) {
if (isset($revision->data[$fieldName])) {
if (!isset($fieldConfig[$fieldName])) {
continue 2;
}
if (isset($fieldConfig[$fieldName]['displayParser']) && is_callable($fieldConfig[$fieldName]['displayParser'])) {
$callback = $fieldConfig[$fieldName]['displayParser'];
$diffOutput['changed'][$fieldName] = [
'old' => $callback($fieldName, $revision->data[$fieldName], $entity),
'new' => $callback($fieldName, $newValue, $entity)
];
continue 2;
}
$type = $fieldConfig[$fieldName]['type'];
if (!isset($transformers[$type])) {
$transformers[$type] = Transform::get($type);
}
$diffOutput['changed'][$fieldName] = [
'old' => $transformers[$type]->display($fieldName, $revision->data[$fieldName], $historyEntry->model),
'new' => $transformers[$type]->display($fieldName, $newValue, $historyEntry->model)
];
continue 2;
}
}
}
$currentEntity = TableRegistry::get($historyEntry->model)->get($historyEntry->foreign_key);
// 2. Try to get old values for any other fields defined in searchableFields and
foreach ($fieldConfig as $fieldName => $data) {
foreach ($previousRevisions as $revisionIndex => $revision) {
if (!isset($revision->data[$fieldName])) {
continue;
}
if (isset($diffOutput['changed'][$fieldName])) {
continue 2;
}
if ($revision->data[$fieldName] != $currentEntity->{$fieldName}) {
if (isset($data['displayParser']) && is_callable($data['displayParser'])) {
$callback = $data['displayParser'];
$diffOutput['changedBefore'][$fieldName] = [
'old' => $callback($fieldName, $revision->data[$fieldName], $entity),
'new' => $callback($fieldName, $currentEntity->{$fieldName}, $entity)
];
continue 2;
}
$type = $data['type'];
if (!isset($transformers[$type])) {
$transformers[$type] = Transform::get($type);
}
$diffOutput['changedBefore'][$fieldName] = [
'old' => $transformers[$type]->display($fieldName, $revision->data[$fieldName], $historyEntry->model),
'new' => $transformers[$type]->display($fieldName, $currentEntity->{$fieldName}, $historyEntry->model)
];
continue 2;
}
}
}
// 3. Get all unchanged fields
foreach ($fieldConfig as $fieldName => $data) {
foreach ($previousRevisions as $revision) {
if (!isset($revision->data[$fieldName])) {
continue;
}
if (isset($diffOutput['changed'][$fieldName]) || isset($diffOutput['changedBefore'][$fieldName])) {
continue 2;
}
if (isset($data['displayParser']) && is_callable($data['displayParser'])) {
$callback = $data['displayParser'];
$diffOutput['unchanged'][$fieldName] = $callback($fieldName, $currentEntity->{$fieldName}, $entity);
continue 2;
}
$type = $data['type'];
if (!isset($transformers[$type])) {
$transformers[$type] = Transform::get($type);
}
$diffOutput['unchanged'][$fieldName] = $transformers[$type]->display($fieldName, $currentEntity->{$fieldName}, $historyEntry->model);
continue 2;
}
}
// Translate all the fieldnames
foreach ($diffOutput as $type => $dataArr) {
if (!empty($dataArr)) {
foreach ($dataArr as $fieldName => $values) {
$localizedField = $this->_translateFieldname($fieldName, $historyEntry->model);
if ($localizedField != $fieldName) {
$dataArr[$localizedField] = $values;
unset($dataArr[$fieldName]);
}
}
$diffOutput[$type] = $dataArr;
}
}
return $diffOutput;
} | [
"public",
"function",
"buildDiff",
"(",
"ModelHistory",
"$",
"historyEntry",
")",
":",
"array",
"{",
"if",
"(",
"$",
"historyEntry",
"->",
"revision",
"==",
"1",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"previousRevisions",
"=",
"$",
"this",
"->",
... | Builds a diff for a given history entry
@param ModelHistory $historyEntry ModelHistory Entry to build diff for
@return array | [
"Builds",
"a",
"diff",
"for",
"a",
"given",
"history",
"entry"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L433-L567 |
scherersoftware/cake-model-history | src/Model/Table/ModelHistoryTable.php | ModelHistoryTable._translateFieldname | protected function _translateFieldname(string $fieldname, string $model): string
{
// Try to get the generic model.field translation string
$localeSlug = strtolower(Inflector::singularize(Inflector::delimit($model))) . '.' . strtolower($fieldname);
$translatedString = __($localeSlug);
// Return original value when no translation was made
if ($localeSlug == $translatedString) {
return $fieldname;
}
return $translatedString;
} | php | protected function _translateFieldname(string $fieldname, string $model): string
{
// Try to get the generic model.field translation string
$localeSlug = strtolower(Inflector::singularize(Inflector::delimit($model))) . '.' . strtolower($fieldname);
$translatedString = __($localeSlug);
// Return original value when no translation was made
if ($localeSlug == $translatedString) {
return $fieldname;
}
return $translatedString;
} | [
"protected",
"function",
"_translateFieldname",
"(",
"string",
"$",
"fieldname",
",",
"string",
"$",
"model",
")",
":",
"string",
"{",
"// Try to get the generic model.field translation string",
"$",
"localeSlug",
"=",
"strtolower",
"(",
"Inflector",
"::",
"singularize"... | Try to translate fieldname
@param string $fieldname Fieldname
@param string $model Model
@return string | [
"Try",
"to",
"translate",
"fieldname"
] | train | https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Table/ModelHistoryTable.php#L576-L588 |
nfephp-org/sped-console | src/Processors/XsdGeneratePhp.php | XsdGeneratePhp.printMappedNamespaces | protected function printMappedNamespaces(PhpConverter $converter)
{
$this->outputWriteLine("Namespaces:");
foreach ($converter->getNamespaces() as $xsdTargetNamespace => $phpNamespace) {
$this->outputWriteLine(
" + <comment>{$this->outputFormatterEscape($xsdTargetNamespace)}</comment>" .
" => <info>{$this->outputFormatterEscape($phpNamespace)}</info>"
);
}
} | php | protected function printMappedNamespaces(PhpConverter $converter)
{
$this->outputWriteLine("Namespaces:");
foreach ($converter->getNamespaces() as $xsdTargetNamespace => $phpNamespace) {
$this->outputWriteLine(
" + <comment>{$this->outputFormatterEscape($xsdTargetNamespace)}</comment>" .
" => <info>{$this->outputFormatterEscape($phpNamespace)}</info>"
);
}
} | [
"protected",
"function",
"printMappedNamespaces",
"(",
"PhpConverter",
"$",
"converter",
")",
"{",
"$",
"this",
"->",
"outputWriteLine",
"(",
"\"Namespaces:\"",
")",
";",
"foreach",
"(",
"$",
"converter",
"->",
"getNamespaces",
"(",
")",
"as",
"$",
"xsdTargetNam... | Print all mapped namespaces from converter.
@param PhpConverter $converter | [
"Print",
"all",
"mapped",
"namespaces",
"from",
"converter",
"."
] | train | https://github.com/nfephp-org/sped-console/blob/eaedaa8065744b2e47d8f7c711ae993ff238126f/src/Processors/XsdGeneratePhp.php#L103-L112 |
kaliop-uk/kueueingbundle | Service/MessageConsumer/SymfonyService.php | SymfonyService.validateService | protected function validateService($serviceName, $methodName, $arguments = array())
{
$service = $this->container->get($serviceName);
if (!is_callable(array($service, $methodName))) {
throw new \UnexpectedValueException("Method $methodName not found in class " . get_class($service) . " implementing service $serviceName");
}
} | php | protected function validateService($serviceName, $methodName, $arguments = array())
{
$service = $this->container->get($serviceName);
if (!is_callable(array($service, $methodName))) {
throw new \UnexpectedValueException("Method $methodName not found in class " . get_class($service) . " implementing service $serviceName");
}
} | [
"protected",
"function",
"validateService",
"(",
"$",
"serviceName",
",",
"$",
"methodName",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"serviceName",
")",
";",
"... | Throws an error if service is not declared or methodName does not apply
@param string $serviceName
@param string $methodName
@param array $arguments
@throws | [
"Throws",
"an",
"error",
"if",
"service",
"is",
"not",
"declared",
"or",
"methodName",
"does",
"not",
"apply"
] | train | https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageConsumer/SymfonyService.php#L63-L69 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.connect | protected function connect( $pgHost, $pgPort = 22, $pgProtocol, $pgTimeout = 10 ) {
pecho( "Connecting to $pgHost:$pgPort...\n\n", PECHO_NORMAL );
switch( $pgProtocol ){
case 1:
$this->SSHObject = new Net_SSH1($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
case 2:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
default:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
}
return $this->SFTPObject = new Net_SFTP($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
} | php | protected function connect( $pgHost, $pgPort = 22, $pgProtocol, $pgTimeout = 10 ) {
pecho( "Connecting to $pgHost:$pgPort...\n\n", PECHO_NORMAL );
switch( $pgProtocol ){
case 1:
$this->SSHObject = new Net_SSH1($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
case 2:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
default:
$this->SSHObject = new Net_SSH2($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
break;
}
return $this->SFTPObject = new Net_SFTP($pgHost, $pgPort, $pgTimeout); // FIXME Directory doesn't exist
} | [
"protected",
"function",
"connect",
"(",
"$",
"pgHost",
",",
"$",
"pgPort",
"=",
"22",
",",
"$",
"pgProtocol",
",",
"$",
"pgTimeout",
"=",
"10",
")",
"{",
"pecho",
"(",
"\"Connecting to $pgHost:$pgPort...\\n\\n\"",
",",
"PECHO_NORMAL",
")",
";",
"switch",
"(... | Establishes a connection to the remote server.
@FIXME: Codebase no longer includes SSH-related classes
@access protected
@param string $pgHost Host of server to connect to.
@param int $pgPort Port of server.
@param int $pgProtocol Which SSH protocol to use.
@param int $pgTimeout How long before the connection times out. (Milliseconds)
@return bool | [
"Establishes",
"a",
"connection",
"to",
"the",
"remote",
"server",
"."
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L201-L216 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.authenticate | protected function authenticate($pgUsername, $pgPassphrase, $pgPrivateKey)
{
//Determine the type of authentication to use.
if( is_null( $pgUsername ) ) {
pecho( "A username must at least be specified to authenticate to the server,\neven if there is authentication is none.\n\n", PECHO_FATAL );
return false;
}
$fails = 0;
if (!is_null($pgUsername) && !is_null($pgPrivateKey) && $this->protocol == 2) {
pecho( "Authenticating with Private Key Authentication...\n\n", PECHO_NORMAL );
$key = new Crypt_RSA(); // FIXME Class doesn't exist
if (!is_null($pgPassphrase)) {
$key->setPassword($pgPassphrase);
} // FIXME Method doesn't exist
$key->loadKey(file_get_contents($pgPrivateKey)); // FIXME Method doesn't exist
if ($this->SSHObject->login($pgUsername, $key) && $this->SFTPObject->login($pgUsername, $key)) {
pecho( "Successfully authenticated using Private Key Authentication.\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) && !is_null( $pgPassphrase ) ) {
pecho( "Authenticating with Password Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername, $pgPassphrase) && $this->SFTPObject->login($pgUsername,
$pgPassphrase)
) {
pecho( "Successfully authenticated using Password Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) ) {
pecho( "Authenticating with No Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername) && $this->SFTPObject->login($pgUsername)) {
pecho( "Successfully authenticated with No Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( $fails == 15 ) {
pecho( "An incorrect combination of parameters was used and therefore, no proper authentication can be established.\n\n", PECHO_FATAL );
return false;
} else {
pecho( "Peachy was unable to authenticate with any method of authentication.\nPlease check your connection settings and try again.\n\n", PECHO_FATAL );
return false;
}
} | php | protected function authenticate($pgUsername, $pgPassphrase, $pgPrivateKey)
{
//Determine the type of authentication to use.
if( is_null( $pgUsername ) ) {
pecho( "A username must at least be specified to authenticate to the server,\neven if there is authentication is none.\n\n", PECHO_FATAL );
return false;
}
$fails = 0;
if (!is_null($pgUsername) && !is_null($pgPrivateKey) && $this->protocol == 2) {
pecho( "Authenticating with Private Key Authentication...\n\n", PECHO_NORMAL );
$key = new Crypt_RSA(); // FIXME Class doesn't exist
if (!is_null($pgPassphrase)) {
$key->setPassword($pgPassphrase);
} // FIXME Method doesn't exist
$key->loadKey(file_get_contents($pgPrivateKey)); // FIXME Method doesn't exist
if ($this->SSHObject->login($pgUsername, $key) && $this->SFTPObject->login($pgUsername, $key)) {
pecho( "Successfully authenticated using Private Key Authentication.\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) && !is_null( $pgPassphrase ) ) {
pecho( "Authenticating with Password Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername, $pgPassphrase) && $this->SFTPObject->login($pgUsername,
$pgPassphrase)
) {
pecho( "Successfully authenticated using Password Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( !is_null( $pgUsername ) ) {
pecho( "Authenticating with No Authentication...\n\n", PECHO_NORMAL );
if ($this->SSHObject->login($pgUsername) && $this->SFTPObject->login($pgUsername)) {
pecho( "Successfully authenticated with No Authentication\n\n", PECHO_NORMAL );
return true;
}
$fails++;
} else $fails += 5;
if( $fails == 15 ) {
pecho( "An incorrect combination of parameters was used and therefore, no proper authentication can be established.\n\n", PECHO_FATAL );
return false;
} else {
pecho( "Peachy was unable to authenticate with any method of authentication.\nPlease check your connection settings and try again.\n\n", PECHO_FATAL );
return false;
}
} | [
"protected",
"function",
"authenticate",
"(",
"$",
"pgUsername",
",",
"$",
"pgPassphrase",
",",
"$",
"pgPrivateKey",
")",
"{",
"//Determine the type of authentication to use.",
"if",
"(",
"is_null",
"(",
"$",
"pgUsername",
")",
")",
"{",
"pecho",
"(",
"\"A usernam... | Authenticates to the remote server.
@access protected
@param string $pgUsername Username
@param string $pgPassphrase Password or passphrase of key file
@param string $pgPrivateKey File path of key file.
@return bool | [
"Authenticates",
"to",
"the",
"remote",
"server",
"."
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L227-L274 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.exec | public function exec( $command, $callback = null, $displayError = false, $exitstatus = false ) {
if( $this->protocol === 2 ) {
if( $displayError ) {
$this->SSHObject->enableQuietMode();
} else $this->SSHObject->disableQuietMode();
}
if( $this->protocol === 2 && $exitstatus ) {
return array(
'result' => $this->SSHObject->exec($command, $callback),
'exit_status' => $this->SSHObject->getExitStatus()
);
} else return $this->SSHObject->exec($command, $callback);
} | php | public function exec( $command, $callback = null, $displayError = false, $exitstatus = false ) {
if( $this->protocol === 2 ) {
if( $displayError ) {
$this->SSHObject->enableQuietMode();
} else $this->SSHObject->disableQuietMode();
}
if( $this->protocol === 2 && $exitstatus ) {
return array(
'result' => $this->SSHObject->exec($command, $callback),
'exit_status' => $this->SSHObject->getExitStatus()
);
} else return $this->SSHObject->exec($command, $callback);
} | [
"public",
"function",
"exec",
"(",
"$",
"command",
",",
"$",
"callback",
"=",
"null",
",",
"$",
"displayError",
"=",
"false",
",",
"$",
"exitstatus",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"protocol",
"===",
"2",
")",
"{",
"if",
"(",... | Opens a shell, sends a command and returns output and closes the shell.
NOTICE: Using a command that opens a new shell will cause hangups.
@access public
@param string $command Command to execute
@param string $callback Function to call upon executing task.
@param bool $displayError Should stderr be outputted as well. Only available with SSH2.
@param bool $exitstatus Returns the exit status along with output. Output becomes array. Only available with SSH2.
@returns bool|string|array | [
"Opens",
"a",
"shell",
"sends",
"a",
"command",
"and",
"returns",
"output",
"and",
"closes",
"the",
"shell",
".",
"NOTICE",
":",
"Using",
"a",
"command",
"that",
"opens",
"a",
"new",
"shell",
"will",
"cause",
"hangups",
"."
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L287-L299 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.iExec | public function iExec($command, $expect = "", $expectRegex = false) {
trim( $command, "\n" );
if ($this->SSHObject->write($command . "\n")) {
return $this->SSHObject->read($expect,
($expectRegex ? NET_SSH . $this->protocol . _READ_REGEX : NET_SSH . $this->protocol . _READ_SIMPLE));
} else return false;
} | php | public function iExec($command, $expect = "", $expectRegex = false) {
trim( $command, "\n" );
if ($this->SSHObject->write($command . "\n")) {
return $this->SSHObject->read($expect,
($expectRegex ? NET_SSH . $this->protocol . _READ_REGEX : NET_SSH . $this->protocol . _READ_SIMPLE));
} else return false;
} | [
"public",
"function",
"iExec",
"(",
"$",
"command",
",",
"$",
"expect",
"=",
"\"\"",
",",
"$",
"expectRegex",
"=",
"false",
")",
"{",
"trim",
"(",
"$",
"command",
",",
"\"\\n\"",
")",
";",
"if",
"(",
"$",
"this",
"->",
"SSHObject",
"->",
"write",
"... | Opens an interactive shell if not done already and transmits commands and returns output.
@access public
@param string $command Command to execute
@param string $expect String of output to expect and remove from output.
@param bool $expectRegex Switches string expectation to regular expressions.
@returns bool|string
FIXME Contains undefined constants | [
"Opens",
"an",
"interactive",
"shell",
"if",
"not",
"done",
"already",
"and",
"transmits",
"commands",
"and",
"returns",
"output",
"."
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L312-L318 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.file_put_contents | public function file_put_contents( $to, $data, $resume = false ) {
if( $resume ) {
return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING) | NET_SFTP_RESUME);
} else return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING));
} | php | public function file_put_contents( $to, $data, $resume = false ) {
if( $resume ) {
return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING) | NET_SFTP_RESUME);
} else return $this->SFTPObject->put($to, $data,
(is_file($data) && file_exists($data) ? NET_SFTP_LOCAL_FILE : NET_SFTP_STRING));
} | [
"public",
"function",
"file_put_contents",
"(",
"$",
"to",
",",
"$",
"data",
",",
"$",
"resume",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"resume",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"put",
"(",
"$",
"to",
",",
"$",
"data",
... | Write a file to a remote server
@access public
@param string $to location of file to be placed
@param string $data data to write or file location of file to upload
@param bool $resume resume an interrupted transfer
@return bool
FIXME Contains undefined constants | [
"Write",
"a",
"file",
"to",
"a",
"remote",
"server"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L355-L362 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.file_get_contents | public function file_get_contents( $from, $to = false, $offset = 0, $length = -1 )
{
return $this->SFTPObject->get($from, $to, $offset, $length);
} | php | public function file_get_contents( $from, $to = false, $offset = 0, $length = -1 )
{
return $this->SFTPObject->get($from, $to, $offset, $length);
} | [
"public",
"function",
"file_get_contents",
"(",
"$",
"from",
",",
"$",
"to",
"=",
"false",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"-",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"get",
"(",
"$",
"from",
",",
"... | Retrieve a file from a remote server
@access public
@param string $from Location on remote server to retrieve from.
@param string|bool $to Location to write to. If left blank, file contents is returned.
@param int $offset Where to start retrieving files from.
@param int $length How much of the file to retrieve.
@returns bool|string | [
"Retrieve",
"a",
"file",
"from",
"a",
"remote",
"server"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L374-L377 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.mkdir | public function mkdir( $pathname, $mode = 0777, $recursive = false )
{
return $this->SFTPObject->mkdir($pathname, $mode, $recursive);
} | php | public function mkdir( $pathname, $mode = 0777, $recursive = false )
{
return $this->SFTPObject->mkdir($pathname, $mode, $recursive);
} | [
"public",
"function",
"mkdir",
"(",
"$",
"pathname",
",",
"$",
"mode",
"=",
"0777",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"mkdir",
"(",
"$",
"pathname",
",",
"$",
"mode",
",",
"$",
"recursive"... | Makes directory
@param string $pathname The directory path.
@param int $mode The mode is 0777 by default, which means the widest possible access.
@param bool $recursive Allows the creation of nested directories specified in the pathname.
@return bool
@access public | [
"Makes",
"directory"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L388-L391 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.chmod | public function chmod( $path, $mode, $recursive = false )
{
return $this->SFTPObject->chmod($mode, $path, $recursive);
} | php | public function chmod( $path, $mode, $recursive = false )
{
return $this->SFTPObject->chmod($mode, $path, $recursive);
} | [
"public",
"function",
"chmod",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"chmod",
"(",
"$",
"mode",
",",
"$",
"path",
",",
"$",
"recursive",
")",
";",
"}"
] | Changes file mode
@access public
@param string $path Path to the directory or file
@param int $mode Mode to change to
@param bool $recursive Apply it to files within directory and children directories.
@return bool|int | [
"Changes",
"file",
"mode"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L450-L453 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.touch | public function touch( $filename, $time = null, $atime = null )
{
return $this->SFTPObject->touch($filename, $time, $atime);
} | php | public function touch( $filename, $time = null, $atime = null )
{
return $this->SFTPObject->touch($filename, $time, $atime);
} | [
"public",
"function",
"touch",
"(",
"$",
"filename",
",",
"$",
"time",
"=",
"null",
",",
"$",
"atime",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"touch",
"(",
"$",
"filename",
",",
"$",
"time",
",",
"$",
"atime",
")",
... | Sets access and modification time of file
@access public
@param string $filename The name of the file being touched.
@param int $time The touch time. If time is not supplied, the current system time is used.
@param int $atime If present, the access time of the given filename is set to the value of atime. Otherwise, it is set to the value passed to the time parameter. If neither are present, the current system time is used.
@return bool | [
"Sets",
"access",
"and",
"modification",
"time",
"of",
"file"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L464-L467 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.chown | public function chown( $filename, $user, $recursive = false )
{
return $this->SFTPObject->chown($filename, $user, $recursive);
} | php | public function chown( $filename, $user, $recursive = false )
{
return $this->SFTPObject->chown($filename, $user, $recursive);
} | [
"public",
"function",
"chown",
"(",
"$",
"filename",
",",
"$",
"user",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"chown",
"(",
"$",
"filename",
",",
"$",
"user",
",",
"$",
"recursive",
")",
";",
... | Changes file or directory owner
@param string $filename Path to the file or directory.
@param int $user A user number.
@param bool $recursive Apply to all files and directories within dirctory.
@access public
@return bool | [
"Changes",
"file",
"or",
"directory",
"owner"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L478-L481 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.chgrp | public function chgrp( $filename, $group, $recursive = false )
{
return $this->SFTPObject->chgrp($filename, $group, $recursive);
} | php | public function chgrp( $filename, $group, $recursive = false )
{
return $this->SFTPObject->chgrp($filename, $group, $recursive);
} | [
"public",
"function",
"chgrp",
"(",
"$",
"filename",
",",
"$",
"group",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"SFTPObject",
"->",
"chgrp",
"(",
"$",
"filename",
",",
"$",
"group",
",",
"$",
"recursive",
")",
";",... | Changes file or directory group
@param string $filename Path to the file or directory.
@param int $group A group number.
@param bool $recursive Apply to all files and directories within dirctory.
@access public
@return bool | [
"Changes",
"file",
"or",
"directory",
"group"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L492-L495 |
MW-Peachy/Peachy | Includes/SSH.php | SSH.CheckForUpdate | protected function CheckForUpdate() {
global $pgIP;
$data = json_decode( $this->http->get( 'https://api.github.com/repos/phpseclib/phpseclib/branches/master', null, array(), false ), true );
$this->commits = $data;
if( !file_exists( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) ) return false;
$log = unserialize( file_get_contents( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) );
if( isset( $data['commit']['sha'] ) && $log['commit']['sha'] != $data['commit']['sha'] ) {
pecho( "Updating SSH class!\n\n", PECHO_NOTICE );
return false;
}
return true;
} | php | protected function CheckForUpdate() {
global $pgIP;
$data = json_decode( $this->http->get( 'https://api.github.com/repos/phpseclib/phpseclib/branches/master', null, array(), false ), true );
$this->commits = $data;
if( !file_exists( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) ) return false;
$log = unserialize( file_get_contents( $pgIP . 'Includes' . DIRECTORY_SEPARATOR . 'phpseclibupdate' ) );
if( isset( $data['commit']['sha'] ) && $log['commit']['sha'] != $data['commit']['sha'] ) {
pecho( "Updating SSH class!\n\n", PECHO_NOTICE );
return false;
}
return true;
} | [
"protected",
"function",
"CheckForUpdate",
"(",
")",
"{",
"global",
"$",
"pgIP",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"http",
"->",
"get",
"(",
"'https://api.github.com/repos/phpseclib/phpseclib/branches/master'",
",",
"null",
",",
"array"... | Check for Update Function
Checks the phpseclib/phpseclib library for updates.
@return bool Returns true if no updates
Returns false if updates needed
FIXME The .json file may no longer contain ['commit']['sha'], but possibly ['tree']['sha'] | [
"Check",
"for",
"Update",
"Function"
] | train | https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/SSH.php#L581-L592 |
skrz/meta | gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php | CodeGeneratorResponseMeta.create | public static function create()
{
switch (func_num_args()) {
case 0:
return new CodeGeneratorResponse();
case 1:
return new CodeGeneratorResponse(func_get_arg(0));
case 2:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1));
case 3:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
} | php | public static function create()
{
switch (func_num_args()) {
case 0:
return new CodeGeneratorResponse();
case 1:
return new CodeGeneratorResponse(func_get_arg(0));
case 2:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1));
case 3:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new CodeGeneratorResponse(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
} | [
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"CodeGeneratorResponse",
"(",
"func_g... | Creates new instance of \Google\Protobuf\Compiler\CodeGeneratorResponse
@throws \InvalidArgumentException
@return CodeGeneratorResponse | [
"Creates",
"new",
"instance",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L59-L83 |
skrz/meta | gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php | CodeGeneratorResponseMeta.reset | public static function reset($object)
{
if (!($object instanceof CodeGeneratorResponse)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse.');
}
$object->error = NULL;
$object->file = NULL;
} | php | public static function reset($object)
{
if (!($object instanceof CodeGeneratorResponse)) {
throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse.');
}
$object->error = NULL;
$object->file = NULL;
} | [
"public",
"static",
"function",
"reset",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"CodeGeneratorResponse",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You have to pass object of class Google\\Protobu... | Resets properties of \Google\Protobuf\Compiler\CodeGeneratorResponse to default values
@param CodeGeneratorResponse $object
@throws \InvalidArgumentException
@return void | [
"Resets",
"properties",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse",
"to",
"default",
"values"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L96-L103 |
skrz/meta | gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php | CodeGeneratorResponseMeta.hash | public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->error)) {
hash_update($ctx, 'error');
hash_update($ctx, (string)$object->error);
}
if (isset($object->file)) {
hash_update($ctx, 'file');
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $v0) {
FileMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
} | php | public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
{
if (is_string($algoOrCtx)) {
$ctx = hash_init($algoOrCtx);
} else {
$ctx = $algoOrCtx;
}
if (isset($object->error)) {
hash_update($ctx, 'error');
hash_update($ctx, (string)$object->error);
}
if (isset($object->file)) {
hash_update($ctx, 'file');
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $v0) {
FileMeta::hash($v0, $ctx);
}
}
if (is_string($algoOrCtx)) {
return hash_final($ctx, $raw);
} else {
return null;
}
} | [
"public",
"static",
"function",
"hash",
"(",
"$",
"object",
",",
"$",
"algoOrCtx",
"=",
"'md5'",
",",
"$",
"raw",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"algoOrCtx",
")",
")",
"{",
"$",
"ctx",
"=",
"hash_init",
"(",
"$",
"algoOrC... | Computes hash of \Google\Protobuf\Compiler\CodeGeneratorResponse
@param object $object
@param string|resource $algoOrCtx
@param bool $raw
@return string|void | [
"Computes",
"hash",
"of",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L115-L140 |
skrz/meta | gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php | CodeGeneratorResponseMeta.fromProtobuf | public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new CodeGeneratorResponse();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->error = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 15:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
if (!(isset($object->file) && is_array($object->file))) {
$object->file = array();
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->file[] = FileMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
} | php | public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new CodeGeneratorResponse();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->error = substr($input, $start, $length);
$start += $length;
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
case 15:
if ($wireType !== 2) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
}
if (!(isset($object->file) && is_array($object->file))) {
$object->file = array();
}
$length = Binary::decodeVarint($input, $start);
$expectedStart = $start + $length;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->file[] = FileMeta::fromProtobuf($input, null, $start, $start + $length);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
} | [
"public",
"static",
"function",
"fromProtobuf",
"(",
"$",
"input",
",",
"$",
"object",
"=",
"NULL",
",",
"&",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
... | Creates \Google\Protobuf\Compiler\CodeGeneratorResponse object from serialized Protocol Buffers message.
@param string $input
@param CodeGeneratorResponse $object
@param int $start
@param int $end
@throws \Exception
@return CodeGeneratorResponse | [
"Creates",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L155-L223 |
skrz/meta | gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php | CodeGeneratorResponseMeta.toProtobuf | public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->error) && ($filter === null || isset($filter['error']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->error));
$output .= $object->error;
}
if (isset($object->file) && ($filter === null || isset($filter['file']))) {
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
$output .= "\x7a";
$buffer = FileMeta::toProtobuf($v, $filter === null ? null : $filter['file']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
} | php | public static function toProtobuf($object, $filter = NULL)
{
$output = '';
if (isset($object->error) && ($filter === null || isset($filter['error']))) {
$output .= "\x0a";
$output .= Binary::encodeVarint(strlen($object->error));
$output .= $object->error;
}
if (isset($object->file) && ($filter === null || isset($filter['file']))) {
foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
$output .= "\x7a";
$buffer = FileMeta::toProtobuf($v, $filter === null ? null : $filter['file']);
$output .= Binary::encodeVarint(strlen($buffer));
$output .= $buffer;
}
}
return $output;
} | [
"public",
"static",
"function",
"toProtobuf",
"(",
"$",
"object",
",",
"$",
"filter",
"=",
"NULL",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"object",
"->",
"error",
")",
"&&",
"(",
"$",
"filter",
"===",
"null",
"||",
... | Serialized \Google\Protobuf\Compiler\CodeGeneratorResponse to Protocol Buffers message.
@param CodeGeneratorResponse $object
@param array $filter
@throws \Exception
@return string | [
"Serialized",
"\\",
"Google",
"\\",
"Protobuf",
"\\",
"Compiler",
"\\",
"CodeGeneratorResponse",
"to",
"Protocol",
"Buffers",
"message",
"."
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/Meta/CodeGeneratorResponseMeta.php#L236-L256 |
budde377/Part | lib/model/ContentLibraryImpl.php | ContentLibraryImpl.listContents | public function listContents($time = 0)
{
$this->setUpList();
return array_filter($this->idArray, function (Content $content) use ($time) {
return $content->latestTime() >= $time;
});
} | php | public function listContents($time = 0)
{
$this->setUpList();
return array_filter($this->idArray, function (Content $content) use ($time) {
return $content->latestTime() >= $time;
});
} | [
"public",
"function",
"listContents",
"(",
"$",
"time",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"setUpList",
"(",
")",
";",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"idArray",
",",
"function",
"(",
"Content",
"$",
"content",
")",
"use",
"(",
... | This will list site content.
It the timestamp is given, the latest time will be newer
than the timestamp.
@param int $time A Unix timestamp
@return array A array of PageContent. | [
"This",
"will",
"list",
"site",
"content",
".",
"It",
"the",
"timestamp",
"is",
"given",
"the",
"latest",
"time",
"will",
"be",
"newer",
"than",
"the",
"timestamp",
"."
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentLibraryImpl.php#L39-L45 |
budde377/Part | lib/model/ContentLibraryImpl.php | ContentLibraryImpl.getContent | public function getContent($id = "")
{
$this->setUpList();
return isset($this->idArray[$id]) ?
$this->idArray[$id] :
$this->idArray[$id] = $this->createContent($id);
} | php | public function getContent($id = "")
{
$this->setUpList();
return isset($this->idArray[$id]) ?
$this->idArray[$id] :
$this->idArray[$id] = $this->createContent($id);
} | [
"public",
"function",
"getContent",
"(",
"$",
"id",
"=",
"\"\"",
")",
"{",
"$",
"this",
"->",
"setUpList",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"idArray",
"[",
"$",
"id",
"]",
")",
"?",
"$",
"this",
"->",
"idArray",
"[",
"$",... | This will return and reuse a instance of content related to the given id.
@param string $id
@return Content | [
"This",
"will",
"return",
"and",
"reuse",
"a",
"instance",
"of",
"content",
"related",
"to",
"the",
"given",
"id",
"."
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentLibraryImpl.php#L53-L60 |
budde377/Part | lib/model/ContentLibraryImpl.php | ContentLibraryImpl.searchLibrary | public function searchLibrary($string, $time = null)
{
$this->setUpList();
$this->search_library_stm->bindValue(':like', "%$string%");
$this->search_library_stm->bindValue(':time', $time == null ? 0 : $time);
$this->search_library_stm->execute();
$retArray = [];
foreach ($this->search_library_stm->fetchAll(PDO::FETCH_ASSOC) as $val) {
$id = $val["id"];
if (!isset($this->idArray[$id])) {
continue;
}
$retArray[$id] = $this->idArray[$id];
}
return $retArray;
} | php | public function searchLibrary($string, $time = null)
{
$this->setUpList();
$this->search_library_stm->bindValue(':like', "%$string%");
$this->search_library_stm->bindValue(':time', $time == null ? 0 : $time);
$this->search_library_stm->execute();
$retArray = [];
foreach ($this->search_library_stm->fetchAll(PDO::FETCH_ASSOC) as $val) {
$id = $val["id"];
if (!isset($this->idArray[$id])) {
continue;
}
$retArray[$id] = $this->idArray[$id];
}
return $retArray;
} | [
"public",
"function",
"searchLibrary",
"(",
"$",
"string",
",",
"$",
"time",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setUpList",
"(",
")",
";",
"$",
"this",
"->",
"search_library_stm",
"->",
"bindValue",
"(",
"':like'",
",",
"\"%$string%\"",
")",
";",... | This will search the content of each content
and return an array containing all contents matching
the search string.
@param String $string
@param int $time Will limit the search to those contents after given timestamp
@return array | [
"This",
"will",
"search",
"the",
"content",
"of",
"each",
"content",
"and",
"return",
"an",
"array",
"containing",
"all",
"contents",
"matching",
"the",
"search",
"string",
"."
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/ContentLibraryImpl.php#L87-L104 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.setSource | public function setSource($source)
{
if ($source instanceof DataList) {
$this->setDataClass($source->dataClass());
}
return parent::setSource($source);
} | php | public function setSource($source)
{
if ($source instanceof DataList) {
$this->setDataClass($source->dataClass());
}
return parent::setSource($source);
} | [
"public",
"function",
"setSource",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"DataList",
")",
"{",
"$",
"this",
"->",
"setDataClass",
"(",
"$",
"source",
"->",
"dataClass",
"(",
")",
")",
";",
"}",
"return",
"parent",
"::",
... | Defines the source for the receiver.
@param array|ArrayAccess
@return $this | [
"Defines",
"the",
"source",
"for",
"the",
"receiver",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L197-L204 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.setAjaxConfig | public function setAjaxConfig($arg1, $arg2 = null)
{
if (is_array($arg1)) {
$this->ajaxConfig = $arg1;
} else {
$this->ajaxConfig[$arg1] = $arg2;
}
return $this;
} | php | public function setAjaxConfig($arg1, $arg2 = null)
{
if (is_array($arg1)) {
$this->ajaxConfig = $arg1;
} else {
$this->ajaxConfig[$arg1] = $arg2;
}
return $this;
} | [
"public",
"function",
"setAjaxConfig",
"(",
"$",
"arg1",
",",
"$",
"arg2",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"arg1",
")",
")",
"{",
"$",
"this",
"->",
"ajaxConfig",
"=",
"$",
"arg1",
";",
"}",
"else",
"{",
"$",
"this",
"->",... | Defines either the named Ajax config value, or the Ajax config array.
@param string|array $arg1
@param mixed $arg2
@return $this | [
"Defines",
"either",
"the",
"named",
"Ajax",
"config",
"value",
"or",
"the",
"Ajax",
"config",
"array",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L214-L223 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getAjaxConfig | public function getAjaxConfig($name = null)
{
if (!is_null($name)) {
return isset($this->ajaxConfig[$name]) ? $this->ajaxConfig[$name] : null;
}
return $this->ajaxConfig;
} | php | public function getAjaxConfig($name = null)
{
if (!is_null($name)) {
return isset($this->ajaxConfig[$name]) ? $this->ajaxConfig[$name] : null;
}
return $this->ajaxConfig;
} | [
"public",
"function",
"getAjaxConfig",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"ajaxConfig",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->... | Answers either the named Ajax config value, or the Ajax config array.
@param string $name
@return mixed | [
"Answers",
"either",
"the",
"named",
"Ajax",
"config",
"value",
"or",
"the",
"Ajax",
"config",
"array",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L232-L239 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.setDescriptor | public function setDescriptor($field, $order = 'ASC')
{
// Define Attributes:
$this->setTextField($field);
$this->setSearchFields([$field]);
$this->setSortBy([$field => $order]);
// Answer Self:
return $this;
} | php | public function setDescriptor($field, $order = 'ASC')
{
// Define Attributes:
$this->setTextField($field);
$this->setSearchFields([$field]);
$this->setSortBy([$field => $order]);
// Answer Self:
return $this;
} | [
"public",
"function",
"setDescriptor",
"(",
"$",
"field",
",",
"$",
"order",
"=",
"'ASC'",
")",
"{",
"// Define Attributes:",
"$",
"this",
"->",
"setTextField",
"(",
"$",
"field",
")",
";",
"$",
"this",
"->",
"setSearchFields",
"(",
"[",
"$",
"field",
"]... | Updates the text field, search fields and sort order to the specified field name.
@param string $field
@param string $order
@return $this | [
"Updates",
"the",
"text",
"field",
"search",
"fields",
"and",
"sort",
"order",
"to",
"the",
"specified",
"field",
"name",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L489-L500 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getDataAttributes | public function getDataAttributes()
{
$attributes = parent::getDataAttributes();
if ($this->isAjaxEnabled()) {
foreach ($this->getFieldAjaxConfig() as $key => $value) {
$attributes[sprintf('data-ajax--%s', $key)] = $this->getDataValue($value);
}
}
return $attributes;
} | php | public function getDataAttributes()
{
$attributes = parent::getDataAttributes();
if ($this->isAjaxEnabled()) {
foreach ($this->getFieldAjaxConfig() as $key => $value) {
$attributes[sprintf('data-ajax--%s', $key)] = $this->getDataValue($value);
}
}
return $attributes;
} | [
"public",
"function",
"getDataAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"parent",
"::",
"getDataAttributes",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isAjaxEnabled",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getFieldAjaxConfig"... | Answers an array of data attributes for the field.
@return array | [
"Answers",
"an",
"array",
"of",
"data",
"attributes",
"for",
"the",
"field",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L507-L520 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.search | public function search(HTTPRequest $request)
{
// Detect Ajax:
if (!$request->isAjax()) {
return;
}
// Initialise:
$data = ['results' => []];
// Create Data List:
$list = $this->getList();
// Filter Data List:
if ($term = $request->getVar('term')) {
$list = $list->filterAny($this->getSearchFilters($term))->exclude($this->getExclude());
}
// Sort Data List:
if ($sort = $this->getSortBy()) {
$list = $list->sort($sort);
}
// Limit Data List:
if ($limit = $this->getLimit()) {
$list = $list->limit($limit);
}
// Define Results:
foreach ($list as $record) {
$data['results'][] = $this->getResultData($record);
}
// Answer JSON Response:
return $this->respond($data);
} | php | public function search(HTTPRequest $request)
{
// Detect Ajax:
if (!$request->isAjax()) {
return;
}
// Initialise:
$data = ['results' => []];
// Create Data List:
$list = $this->getList();
// Filter Data List:
if ($term = $request->getVar('term')) {
$list = $list->filterAny($this->getSearchFilters($term))->exclude($this->getExclude());
}
// Sort Data List:
if ($sort = $this->getSortBy()) {
$list = $list->sort($sort);
}
// Limit Data List:
if ($limit = $this->getLimit()) {
$list = $list->limit($limit);
}
// Define Results:
foreach ($list as $record) {
$data['results'][] = $this->getResultData($record);
}
// Answer JSON Response:
return $this->respond($data);
} | [
"public",
"function",
"search",
"(",
"HTTPRequest",
"$",
"request",
")",
"{",
"// Detect Ajax:",
"if",
"(",
"!",
"$",
"request",
"->",
"isAjax",
"(",
")",
")",
"{",
"return",
";",
"}",
"// Initialise:",
"$",
"data",
"=",
"[",
"'results'",
"=>",
"[",
"]... | Answers an HTTP response containing JSON results matching the given search parameters.
@param HTTPRequest $request
@return HTTPResponse | [
"Answers",
"an",
"HTTP",
"response",
"containing",
"JSON",
"results",
"matching",
"the",
"given",
"search",
"parameters",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L539-L582 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getSearchFilters | public function getSearchFilters($term)
{
$filters = [];
foreach ($this->getSearchFields() as $field) {
$filters[$this->getSearchFilterName($field)] = $term;
}
return $filters;
} | php | public function getSearchFilters($term)
{
$filters = [];
foreach ($this->getSearchFields() as $field) {
$filters[$this->getSearchFilterName($field)] = $term;
}
return $filters;
} | [
"public",
"function",
"getSearchFilters",
"(",
"$",
"term",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getSearchFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"$",
"filters",
"[",
"$",
"this",
"->",
"getSearch... | Answers an array of search filters for the given term.
@param string $term
@return array | [
"Answers",
"an",
"array",
"of",
"search",
"filters",
"for",
"the",
"given",
"term",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L591-L600 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.saveIntoRelation | public function saveIntoRelation(Relation $relation)
{
$ids = [];
if ($values = $this->getValueArray()) {
$ids = $this->getList()->filter($this->getIDField(), $values)->getIDList();
}
$relation->setByIDList($ids);
} | php | public function saveIntoRelation(Relation $relation)
{
$ids = [];
if ($values = $this->getValueArray()) {
$ids = $this->getList()->filter($this->getIDField(), $values)->getIDList();
}
$relation->setByIDList($ids);
} | [
"public",
"function",
"saveIntoRelation",
"(",
"Relation",
"$",
"relation",
")",
"{",
"$",
"ids",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"values",
"=",
"$",
"this",
"->",
"getValueArray",
"(",
")",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"getLis... | Saves the value of the field into the given relation.
@param Relation $relation
@return void | [
"Saves",
"the",
"value",
"of",
"the",
"field",
"into",
"the",
"given",
"relation",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L633-L642 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.isSelectedValue | public function isSelectedValue($dataValue, $userValue)
{
if (is_array($userValue) && in_array($dataValue, $userValue)) {
return true;
}
return parent::isSelectedValue($dataValue, $userValue);
} | php | public function isSelectedValue($dataValue, $userValue)
{
if (is_array($userValue) && in_array($dataValue, $userValue)) {
return true;
}
return parent::isSelectedValue($dataValue, $userValue);
} | [
"public",
"function",
"isSelectedValue",
"(",
"$",
"dataValue",
",",
"$",
"userValue",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"userValue",
")",
"&&",
"in_array",
"(",
"$",
"dataValue",
",",
"$",
"userValue",
")",
")",
"{",
"return",
"true",
";",
"}... | Answers true if the given data value and user value match (i.e. the value is selected).
@param mixed $dataValue
@param mixed $userValue
@return boolean | [
"Answers",
"true",
"if",
"the",
"given",
"data",
"value",
"and",
"user",
"value",
"match",
"(",
"i",
".",
"e",
".",
"the",
"value",
"is",
"selected",
")",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L652-L659 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getResultData | protected function getResultData(ViewableData $record, $selected = false)
{
return [
'id' => $record->{$this->getIDField()},
'text' => $record->{$this->getTextField()},
'formattedResult' => $this->getFormattedResult($record),
'formattedSelection' => $this->getFormattedSelection($record),
'selected' => $selected
];
} | php | protected function getResultData(ViewableData $record, $selected = false)
{
return [
'id' => $record->{$this->getIDField()},
'text' => $record->{$this->getTextField()},
'formattedResult' => $this->getFormattedResult($record),
'formattedSelection' => $this->getFormattedSelection($record),
'selected' => $selected
];
} | [
"protected",
"function",
"getResultData",
"(",
"ViewableData",
"$",
"record",
",",
"$",
"selected",
"=",
"false",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"record",
"->",
"{",
"$",
"this",
"->",
"getIDField",
"(",
")",
"}",
",",
"'text'",
"=>",
"$",... | Answers a result data array for the given record object.
@param ViewableData $record
@param boolean $selected
@return array | [
"Answers",
"a",
"result",
"data",
"array",
"for",
"the",
"given",
"record",
"object",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L719-L728 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getFormattedResult | protected function getFormattedResult(ViewableData $record)
{
if ($format = $this->getFormatResult()) {
return SSViewer::fromString($format)->process($record);
}
} | php | protected function getFormattedResult(ViewableData $record)
{
if ($format = $this->getFormatResult()) {
return SSViewer::fromString($format)->process($record);
}
} | [
"protected",
"function",
"getFormattedResult",
"(",
"ViewableData",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormatResult",
"(",
")",
")",
"{",
"return",
"SSViewer",
"::",
"fromString",
"(",
"$",
"format",
")",
"->",
... | Answers a formatted result string for the given record object.
@param ViewableData $record
@return string | [
"Answers",
"a",
"formatted",
"result",
"string",
"for",
"the",
"given",
"record",
"object",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L737-L742 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getFormattedSelection | protected function getFormattedSelection(ViewableData $record)
{
if ($format = $this->getFormatSelection()) {
return SSViewer::fromString($format)->process($record);
}
} | php | protected function getFormattedSelection(ViewableData $record)
{
if ($format = $this->getFormatSelection()) {
return SSViewer::fromString($format)->process($record);
}
} | [
"protected",
"function",
"getFormattedSelection",
"(",
"ViewableData",
"$",
"record",
")",
"{",
"if",
"(",
"$",
"format",
"=",
"$",
"this",
"->",
"getFormatSelection",
"(",
")",
")",
"{",
"return",
"SSViewer",
"::",
"fromString",
"(",
"$",
"format",
")",
"... | Answers a formatted selection string for the given record object.
@param ViewableData $record
@return string | [
"Answers",
"a",
"formatted",
"selection",
"string",
"for",
"the",
"given",
"record",
"object",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L751-L756 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getListMap | protected function getListMap($source)
{
// Extract Map from ID / Text Fields:
if ($source instanceof SS_List) {
$source = $source->map($this->getIDField(), $this->getTextField());
}
// Convert Map to Array:
if ($source instanceof Map) {
$source = $source->toArray();
}
// Determine Invalid Types:
if (!is_array($source) && !($source instanceof ArrayAccess)) {
user_error('$source passed in as invalid type', E_USER_ERROR);
}
// Answer Data Source:
return $source;
} | php | protected function getListMap($source)
{
// Extract Map from ID / Text Fields:
if ($source instanceof SS_List) {
$source = $source->map($this->getIDField(), $this->getTextField());
}
// Convert Map to Array:
if ($source instanceof Map) {
$source = $source->toArray();
}
// Determine Invalid Types:
if (!is_array($source) && !($source instanceof ArrayAccess)) {
user_error('$source passed in as invalid type', E_USER_ERROR);
}
// Answer Data Source:
return $source;
} | [
"protected",
"function",
"getListMap",
"(",
"$",
"source",
")",
"{",
"// Extract Map from ID / Text Fields:",
"if",
"(",
"$",
"source",
"instanceof",
"SS_List",
")",
"{",
"$",
"source",
"=",
"$",
"source",
"->",
"map",
"(",
"$",
"this",
"->",
"getIDField",
"... | Converts the given data source into an array.
@param array|ArrayAccess $source
@return array | [
"Converts",
"the",
"given",
"data",
"source",
"into",
"an",
"array",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L765-L788 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getFieldConfig | protected function getFieldConfig()
{
$config = parent::getFieldConfig();
if ($values = $this->getValueArray()) {
$data = [];
foreach ($values as $value) {
if ($record = $this->getValueRecord($value)) {
$data[] = $this->getResultData($record, true);
}
}
$config['data'] = $data;
}
return $config;
} | php | protected function getFieldConfig()
{
$config = parent::getFieldConfig();
if ($values = $this->getValueArray()) {
$data = [];
foreach ($values as $value) {
if ($record = $this->getValueRecord($value)) {
$data[] = $this->getResultData($record, true);
}
}
$config['data'] = $data;
}
return $config;
} | [
"protected",
"function",
"getFieldConfig",
"(",
")",
"{",
"$",
"config",
"=",
"parent",
"::",
"getFieldConfig",
"(",
")",
";",
"if",
"(",
"$",
"values",
"=",
"$",
"this",
"->",
"getValueArray",
"(",
")",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"... | Answers the field config for the receiver.
@return array | [
"Answers",
"the",
"field",
"config",
"for",
"the",
"receiver",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L795-L816 |
praxisnetau/silverware-select2 | src/Forms/Select2AjaxField.php | Select2AjaxField.getFieldAjaxConfig | protected function getFieldAjaxConfig()
{
$config = $this->getAjaxConfig();
if (!isset($config['url'])) {
$config['url'] = $this->Link('search');
}
return $config;
} | php | protected function getFieldAjaxConfig()
{
$config = $this->getAjaxConfig();
if (!isset($config['url'])) {
$config['url'] = $this->Link('search');
}
return $config;
} | [
"protected",
"function",
"getFieldAjaxConfig",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"getAjaxConfig",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'url'",
"]",
"=... | Answers the field Ajax config for the receiver.
@return array | [
"Answers",
"the",
"field",
"Ajax",
"config",
"for",
"the",
"receiver",
"."
] | train | https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2AjaxField.php#L823-L832 |
lamoni/junosnetconf | JunosNetConf.php | JunosNetConf.loadConfigurationRaw | public function loadConfigurationRaw($configData="", $configNode="", array $customAttributes)
{
if ($configData !== "" && $configNode !== "") {
$loadConfig = "<load-configuration>".
"<{$configNode}>".
"{$configData}".
"</{$configNode}>".
"</load-configuration>";
}
else {
$loadConfig = "<load-configuration/>";
}
$loadConfig = new \SimpleXMLElement($loadConfig);
foreach ($customAttributes as $attributeName=>$attributeValue) {
$loadConfig->addAttribute($attributeName, $attributeValue);
}
return $this->netConf()->sendRPC($loadConfig->asXML());
} | php | public function loadConfigurationRaw($configData="", $configNode="", array $customAttributes)
{
if ($configData !== "" && $configNode !== "") {
$loadConfig = "<load-configuration>".
"<{$configNode}>".
"{$configData}".
"</{$configNode}>".
"</load-configuration>";
}
else {
$loadConfig = "<load-configuration/>";
}
$loadConfig = new \SimpleXMLElement($loadConfig);
foreach ($customAttributes as $attributeName=>$attributeValue) {
$loadConfig->addAttribute($attributeName, $attributeValue);
}
return $this->netConf()->sendRPC($loadConfig->asXML());
} | [
"public",
"function",
"loadConfigurationRaw",
"(",
"$",
"configData",
"=",
"\"\"",
",",
"$",
"configNode",
"=",
"\"\"",
",",
"array",
"$",
"customAttributes",
")",
"{",
"if",
"(",
"$",
"configData",
"!==",
"\"\"",
"&&",
"$",
"configNode",
"!==",
"\"\"",
")... | Base method for loading configuration into the device's candidate configuration.
@param string $configData
@param string $configNode
@param array $customAttributes
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC | [
"Base",
"method",
"for",
"loading",
"configuration",
"into",
"the",
"device",
"s",
"candidate",
"configuration",
"."
] | train | https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L101-L128 |
lamoni/junosnetconf | JunosNetConf.php | JunosNetConf.commitConfigurationRaw | public function commitConfigurationRaw(array $customParams, $synchronize=true)
{
if ($synchronize === true) {
$customParams['synchronize'] = '';
}
$commitConfig = new \SimpleXMLElement('<commit-configuration/>');
foreach ($customParams as $paramName => $paramValue) {
$commitConfig->addChild(
$paramName,
$paramValue
);
}
return $this->netConf()->sendRPC($commitConfig->asXML());
} | php | public function commitConfigurationRaw(array $customParams, $synchronize=true)
{
if ($synchronize === true) {
$customParams['synchronize'] = '';
}
$commitConfig = new \SimpleXMLElement('<commit-configuration/>');
foreach ($customParams as $paramName => $paramValue) {
$commitConfig->addChild(
$paramName,
$paramValue
);
}
return $this->netConf()->sendRPC($commitConfig->asXML());
} | [
"public",
"function",
"commitConfigurationRaw",
"(",
"array",
"$",
"customParams",
",",
"$",
"synchronize",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"synchronize",
"===",
"true",
")",
"{",
"$",
"customParams",
"[",
"'synchronize'",
"]",
"=",
"''",
";",
"}",
... | Base for committing the candidate configuration to the active configuration.
@param array $customParams
@param bool $synchronize
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC | [
"Base",
"for",
"committing",
"the",
"candidate",
"configuration",
"to",
"the",
"active",
"configuration",
"."
] | train | https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L372-L394 |
lamoni/junosnetconf | JunosNetConf.php | JunosNetConf.commitConfigurationAtTimeWithComment | public function commitConfigurationAtTimeWithComment($atTime, $comment, $synchronize=true)
{
return $this->commitConfigurationRaw(
[
'at-time' => $atTime,
'log' => $comment
],
$synchronize
);
} | php | public function commitConfigurationAtTimeWithComment($atTime, $comment, $synchronize=true)
{
return $this->commitConfigurationRaw(
[
'at-time' => $atTime,
'log' => $comment
],
$synchronize
);
} | [
"public",
"function",
"commitConfigurationAtTimeWithComment",
"(",
"$",
"atTime",
",",
"$",
"comment",
",",
"$",
"synchronize",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"commitConfigurationRaw",
"(",
"[",
"'at-time'",
"=>",
"$",
"atTime",
",",
"'log... | Commits the candidate configuration to the active configuration at a certain time, with a comment.
Equivalent to "commit at-time $atTime comment $comment" or "commit synchronize at-time $atTime comment $comment",
based on $synchronize's value.
@param $atTime
@param $comment
@param bool $synchronize
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC | [
"Commits",
"the",
"candidate",
"configuration",
"to",
"the",
"active",
"configuration",
"at",
"a",
"certain",
"time",
"with",
"a",
"comment",
".",
"Equivalent",
"to",
"commit",
"at",
"-",
"time",
"$atTime",
"comment",
"$comment",
"or",
"commit",
"synchronize",
... | train | https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L460-L471 |
lamoni/junosnetconf | JunosNetConf.php | JunosNetConf.commitConfigurationConfirmed | public function commitConfigurationConfirmed($confirmTimeout=600, $comment='', $synchronize=true)
{
return $this->commitConfigurationRaw(
[
'confirmed' => '',
'confirm-timeout' => $confirmTimeout,
'log' => $comment
],
$synchronize
);
} | php | public function commitConfigurationConfirmed($confirmTimeout=600, $comment='', $synchronize=true)
{
return $this->commitConfigurationRaw(
[
'confirmed' => '',
'confirm-timeout' => $confirmTimeout,
'log' => $comment
],
$synchronize
);
} | [
"public",
"function",
"commitConfigurationConfirmed",
"(",
"$",
"confirmTimeout",
"=",
"600",
",",
"$",
"comment",
"=",
"''",
",",
"$",
"synchronize",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"commitConfigurationRaw",
"(",
"[",
"'confirmed'",
"=>",
... | Commits the candidate configuration to the active configuration, with the requirement that the
configuration be rolled back to its previous state if no follow-up commit is sent. A commit comment
is also allowed but not required.
Equivalent to "commit confirmed" or "commit confirmed synchronize", based on $synchronize's value
@param int $confirmTimeout
@param string $comment
@param bool $synchronize
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC | [
"Commits",
"the",
"candidate",
"configuration",
"to",
"the",
"active",
"configuration",
"with",
"the",
"requirement",
"that",
"the",
"configuration",
"be",
"rolled",
"back",
"to",
"its",
"previous",
"state",
"if",
"no",
"follow",
"-",
"up",
"commit",
"is",
"se... | train | https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L484-L496 |
lamoni/junosnetconf | JunosNetConf.php | JunosNetConf.getConfigurationRaw | public function getConfigurationRaw($configData, array $customAttributes=[])
{
$getConfig = new \SimpleXMLElement(
"<get-configuration>".
"{$configData}".
"</get-configuration>"
);
foreach ($customAttributes as $attrName => $attrValue) {
$getConfig->addAttribute($attrName, $attrValue);
}
return $this->netConf()->sendRPC($getConfig->asXML());
} | php | public function getConfigurationRaw($configData, array $customAttributes=[])
{
$getConfig = new \SimpleXMLElement(
"<get-configuration>".
"{$configData}".
"</get-configuration>"
);
foreach ($customAttributes as $attrName => $attrValue) {
$getConfig->addAttribute($attrName, $attrValue);
}
return $this->netConf()->sendRPC($getConfig->asXML());
} | [
"public",
"function",
"getConfigurationRaw",
"(",
"$",
"configData",
",",
"array",
"$",
"customAttributes",
"=",
"[",
"]",
")",
"{",
"$",
"getConfig",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"\"<get-configuration>\"",
".",
"\"{$configData}\"",
".",
"\"</get-con... | Base for getting the device's configuration.
@param $configData
@param array $customAttributes
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC | [
"Base",
"for",
"getting",
"the",
"device",
"s",
"configuration",
"."
] | train | https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L505-L523 |
lamoni/junosnetconf | JunosNetConf.php | JunosNetConf.getConfigurationRollbackComparison | public function getConfigurationRollbackComparison($rollbackID, $compareID=null)
{
$rollbackCompare = new \SimpleXMLElement('<get-rollback-information/>');
$rollbackCompare->addChild('rollback', $rollbackID);
if (!is_null($compareID)) {
$rollbackCompare->addChild('compare', $compareID);
}
return $this->netConf()->sendRPC($rollbackCompare->asXML());
} | php | public function getConfigurationRollbackComparison($rollbackID, $compareID=null)
{
$rollbackCompare = new \SimpleXMLElement('<get-rollback-information/>');
$rollbackCompare->addChild('rollback', $rollbackID);
if (!is_null($compareID)) {
$rollbackCompare->addChild('compare', $compareID);
}
return $this->netConf()->sendRPC($rollbackCompare->asXML());
} | [
"public",
"function",
"getConfigurationRollbackComparison",
"(",
"$",
"rollbackID",
",",
"$",
"compareID",
"=",
"null",
")",
"{",
"$",
"rollbackCompare",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"'<get-rollback-information/>'",
")",
";",
"$",
"rollbackCompare",
"-... | Gets the comparison between two different rollbacks.
Equivalent to a "show system rollback $rollbackID compare $compareID".
@param $rollbackID
@param null $compareID
@return \Lamoni\NetConf\NetConfMessage\NetConfMessageRecv\NetConfMessageRecvRPC | [
"Gets",
"the",
"comparison",
"between",
"two",
"different",
"rollbacks",
".",
"Equivalent",
"to",
"a",
"show",
"system",
"rollback",
"$rollbackID",
"compare",
"$compareID",
"."
] | train | https://github.com/lamoni/junosnetconf/blob/fc74d9c0c4eb32578e7c91c5457dd43841f327b2/JunosNetConf.php#L603-L618 |
xylemical/php-expressions | src/Lexer.php | Lexer.tokenize | public function tokenize($string)
{
// Get the list of sorted operators.
$operators = $this->factory->getOperators();
// Get the operator regular expression.
$regex = $this->getRegex($operators);
// Check that we have matched all the tokens in the string.
if (!preg_match_all($regex, $string, $matches, PREG_SET_ORDER)) {
throw new LexerException('Unable to tokenize string.');
}
// Cycle through all available tokens.
$tokens = [];
foreach ($matches as $match) {
$item = $match[0];
// Process the parentheses as special cases.
if (in_array($item, ['(', ')', ','])) {
$tokens[] = new Token($item);
continue;
}
// Locate the first operator that matches the token.
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator) {
if (preg_match('#^' . $operator->getRegex() . '$#i', $item)) {
$tokens[] = new Token($item, $operator);
break;
}
}
}
return $tokens;
} | php | public function tokenize($string)
{
// Get the list of sorted operators.
$operators = $this->factory->getOperators();
// Get the operator regular expression.
$regex = $this->getRegex($operators);
// Check that we have matched all the tokens in the string.
if (!preg_match_all($regex, $string, $matches, PREG_SET_ORDER)) {
throw new LexerException('Unable to tokenize string.');
}
// Cycle through all available tokens.
$tokens = [];
foreach ($matches as $match) {
$item = $match[0];
// Process the parentheses as special cases.
if (in_array($item, ['(', ')', ','])) {
$tokens[] = new Token($item);
continue;
}
// Locate the first operator that matches the token.
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator) {
if (preg_match('#^' . $operator->getRegex() . '$#i', $item)) {
$tokens[] = new Token($item, $operator);
break;
}
}
}
return $tokens;
} | [
"public",
"function",
"tokenize",
"(",
"$",
"string",
")",
"{",
"// Get the list of sorted operators.",
"$",
"operators",
"=",
"$",
"this",
"->",
"factory",
"->",
"getOperators",
"(",
")",
";",
"// Get the operator regular expression.",
"$",
"regex",
"=",
"$",
"th... | Converts a string into tokens.
@param $string
@return \Xylemical\Expressions\Token[]
@throws \Xylemical\Expressions\LexerException | [
"Converts",
"a",
"string",
"into",
"tokens",
"."
] | train | https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Lexer.php#L41-L76 |
xylemical/php-expressions | src/Lexer.php | Lexer.getRegex | protected function getRegex($operators)
{
$regexes = [];
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator)
{
$regexes[] = $operator->getRegex();
}
// Add parentheses regexes.
$regexes[] = '\(';
$regexes[] = '\)';
$regexes[] = ',';
// Generate the full regex.
return '#(?:' . implode('|', $regexes) . ')#i';
} | php | protected function getRegex($operators)
{
$regexes = [];
/** @var \Xylemical\Expressions\Operator $operator */
foreach ($operators as $operator)
{
$regexes[] = $operator->getRegex();
}
// Add parentheses regexes.
$regexes[] = '\(';
$regexes[] = '\)';
$regexes[] = ',';
// Generate the full regex.
return '#(?:' . implode('|', $regexes) . ')#i';
} | [
"protected",
"function",
"getRegex",
"(",
"$",
"operators",
")",
"{",
"$",
"regexes",
"=",
"[",
"]",
";",
"/** @var \\Xylemical\\Expressions\\Operator $operator */",
"foreach",
"(",
"$",
"operators",
"as",
"$",
"operator",
")",
"{",
"$",
"regexes",
"[",
"]",
"... | Get the regex used to locate tokens.
@return string | [
"Get",
"the",
"regex",
"used",
"to",
"locate",
"tokens",
"."
] | train | https://github.com/xylemical/php-expressions/blob/4dc7c3a4bb3f335a04cb05b0d41871529cfc9b73/src/Lexer.php#L83-L100 |
baleen/migrations | src/Delta/Collection/Collection.php | Collection.find | public function find($element, $resolve = true)
{
$result = null;
if (is_object($element)) {
$element = (string) $element;
}
if ($resolve && is_string($element)) {
$result = $this->getResolver()->resolve($element, $this);
}
if (null === $result && is_scalar($element)) {
$result = $this->get($element);
}
return $result;
} | php | public function find($element, $resolve = true)
{
$result = null;
if (is_object($element)) {
$element = (string) $element;
}
if ($resolve && is_string($element)) {
$result = $this->getResolver()->resolve($element, $this);
}
if (null === $result && is_scalar($element)) {
$result = $this->get($element);
}
return $result;
} | [
"public",
"function",
"find",
"(",
"$",
"element",
",",
"$",
"resolve",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"is_object",
"(",
"$",
"element",
")",
")",
"{",
"$",
"element",
"=",
"(",
"string",
")",
"$",
"element",
"... | Gets an element.
@param mixed $element If an alias is given then it will be resolved to an element. Otherwise the $key will be used
to fetch the element by index.
@param bool $resolve Whether to use the resolver or not.
@return DeltaInterface|null Null if not present | [
"Gets",
"an",
"element",
"."
] | train | https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L93-L110 |
baleen/migrations | src/Delta/Collection/Collection.php | Collection.add | public function add(DeltaInterface $version)
{
$this->validate($version);
$result = parent::add($version);
if ($result) {
$this->invalidateResolverCache();
}
return $result;
} | php | public function add(DeltaInterface $version)
{
$this->validate($version);
$result = parent::add($version);
if ($result) {
$this->invalidateResolverCache();
}
return $result;
} | [
"public",
"function",
"add",
"(",
"DeltaInterface",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"version",
")",
";",
"$",
"result",
"=",
"parent",
"::",
"add",
"(",
"$",
"version",
")",
";",
"if",
"(",
"$",
"result",
")",
"{"... | Add a version to the collection
@param mixed $version
@return bool
@throws CollectionException
@throws InvalidArgumentException | [
"Add",
"a",
"version",
"to",
"the",
"collection"
] | train | https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L151-L160 |
baleen/migrations | src/Delta/Collection/Collection.php | Collection.remove | public function remove($key)
{
$result = parent::remove($key);
if ($result) {
$this->invalidateResolverCache();
}
return $result;
} | php | public function remove($key)
{
$result = parent::remove($key);
if ($result) {
$this->invalidateResolverCache();
}
return $result;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"parent",
"::",
"remove",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"invalidateResolverCache",
"(",
")",
";",
"}",
"return",
"$",... | @param $key
@return DeltaInterface|null | [
"@param",
"$key"
] | train | https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L167-L175 |
baleen/migrations | src/Delta/Collection/Collection.php | Collection.replace | public function replace(DeltaInterface $version)
{
$this->validate($version);
$removedElement = parent::replace($version);
$this->invalidateResolverCache();
return $removedElement;
} | php | public function replace(DeltaInterface $version)
{
$this->validate($version);
$removedElement = parent::replace($version);
$this->invalidateResolverCache();
return $removedElement;
} | [
"public",
"function",
"replace",
"(",
"DeltaInterface",
"$",
"version",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"version",
")",
";",
"$",
"removedElement",
"=",
"parent",
"::",
"replace",
"(",
"$",
"version",
")",
";",
"$",
"this",
"->",
"in... | {@inheritDoc} | [
"{"
] | train | https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L180-L187 |
baleen/migrations | src/Delta/Collection/Collection.php | Collection.sort | public function sort(ComparatorInterface $comparator = null)
{
if (null === $comparator) {
$comparator = $this->comparator;
}
$elements = $this->toArray();
uasort($elements, $comparator);
return new static($elements, $this->getResolver(), $comparator);
} | php | public function sort(ComparatorInterface $comparator = null)
{
if (null === $comparator) {
$comparator = $this->comparator;
}
$elements = $this->toArray();
uasort($elements, $comparator);
return new static($elements, $this->getResolver(), $comparator);
} | [
"public",
"function",
"sort",
"(",
"ComparatorInterface",
"$",
"comparator",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparator",
")",
"{",
"$",
"comparator",
"=",
"$",
"this",
"->",
"comparator",
";",
"}",
"$",
"elements",
"=",
"$",
"th... | Sort the collection
@param ComparatorInterface $comparator
@return static | [
"Sort",
"the",
"collection"
] | train | https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Collection/Collection.php#L203-L211 |
yeephp/yeephp | Yee/LogWriter.php | LogWriter.write | public function write($message, $level = null)
{
return fwrite($this->resource, (string) $message . PHP_EOL);
} | php | public function write($message, $level = null)
{
return fwrite($this->resource, (string) $message . PHP_EOL);
} | [
"public",
"function",
"write",
"(",
"$",
"message",
",",
"$",
"level",
"=",
"null",
")",
"{",
"return",
"fwrite",
"(",
"$",
"this",
"->",
"resource",
",",
"(",
"string",
")",
"$",
"message",
".",
"PHP_EOL",
")",
";",
"}"
] | Write message
@param mixed $message
@param int $level
@return int|bool | [
"Write",
"message"
] | train | https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/LogWriter.php#L71-L74 |
kaliop-uk/kueueingbundle | Adapter/RabbitMq/Consumer.php | Consumer.setCallback | public function setCallback($callback)
{
if ($callback instanceof \OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface) {
$callback = array($callback, 'execute');
}
$this->callback = $callback;
return $this;
} | php | public function setCallback($callback)
{
if ($callback instanceof \OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface) {
$callback = array($callback, 'execute');
}
$this->callback = $callback;
return $this;
} | [
"public",
"function",
"setCallback",
"(",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"callback",
"instanceof",
"\\",
"OldSound",
"\\",
"RabbitMqBundle",
"\\",
"RabbitMq",
"\\",
"ConsumerInterface",
")",
"{",
"$",
"callback",
"=",
"array",
"(",
"$",
"callback... | Overridden to make it fluent, plus accept an object as well
@param callable|\OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface $callback
@return Consumer | [
"Overridden",
"to",
"make",
"it",
"fluent",
"plus",
"accept",
"an",
"object",
"as",
"well"
] | train | https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L77-L85 |
kaliop-uk/kueueingbundle | Adapter/RabbitMq/Consumer.php | Consumer.setRoutingKey | public function setRoutingKey($routingKey)
{
// we have to throw an exception, otherwise the new routing key will just be ignored
if ($this->queueDeclared && $this->routingKey != $routingKey) {
throw new \RuntimeException('AMQP Consumer can not use a new routing key: queue has already been declared');
}
$this->routingKey = $routingKey;
return $this;
} | php | public function setRoutingKey($routingKey)
{
// we have to throw an exception, otherwise the new routing key will just be ignored
if ($this->queueDeclared && $this->routingKey != $routingKey) {
throw new \RuntimeException('AMQP Consumer can not use a new routing key: queue has already been declared');
}
$this->routingKey = $routingKey;
return $this;
} | [
"public",
"function",
"setRoutingKey",
"(",
"$",
"routingKey",
")",
"{",
"// we have to throw an exception, otherwise the new routing key will just be ignored",
"if",
"(",
"$",
"this",
"->",
"queueDeclared",
"&&",
"$",
"this",
"->",
"routingKey",
"!=",
"$",
"routingKey",
... | Overridden to make it fluent
@param string $routingKey
@return Consumer
@throws \RuntimeException | [
"Overridden",
"to",
"make",
"it",
"fluent"
] | train | https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L106-L115 |
kaliop-uk/kueueingbundle | Adapter/RabbitMq/Consumer.php | Consumer.consume | public function consume($msgAmount, $timeout=0)
{
if ($timeout > 0) {
// save initial time
$loopBegin = time();
$remaining = $timeout;
// reimplement parent::consume() to inject the timeout
$this->target = $msgAmount;
$this->setupConsumer();
while (count($this->getChannel()->callbacks)) {
// avoid waiting more than timeout seconds for message reception
$this->setIdleTimeout($remaining);
$this->maybeStopConsumer();
try {
$this->getChannel()->wait(null, true, $this->getIdleTimeout());
} catch (AMQPTimeoutException $e) {
return;
}
$remaining = $loopBegin + $timeout - time();
if ($remaining <= 0) {
$this->forceStopConsumer();
}
}
} else {
$this->loopBegin = null;
parent::consume($msgAmount);
}
} | php | public function consume($msgAmount, $timeout=0)
{
if ($timeout > 0) {
// save initial time
$loopBegin = time();
$remaining = $timeout;
// reimplement parent::consume() to inject the timeout
$this->target = $msgAmount;
$this->setupConsumer();
while (count($this->getChannel()->callbacks)) {
// avoid waiting more than timeout seconds for message reception
$this->setIdleTimeout($remaining);
$this->maybeStopConsumer();
try {
$this->getChannel()->wait(null, true, $this->getIdleTimeout());
} catch (AMQPTimeoutException $e) {
return;
}
$remaining = $loopBegin + $timeout - time();
if ($remaining <= 0) {
$this->forceStopConsumer();
}
}
} else {
$this->loopBegin = null;
parent::consume($msgAmount);
}
} | [
"public",
"function",
"consume",
"(",
"$",
"msgAmount",
",",
"$",
"timeout",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"timeout",
">",
"0",
")",
"{",
"// save initial time",
"$",
"loopBegin",
"=",
"time",
"(",
")",
";",
"$",
"remaining",
"=",
"$",
"timeout... | Overridden to add support for timeout
@param int $msgAmount
@param int $timeout | [
"Overridden",
"to",
"add",
"support",
"for",
"timeout"
] | train | https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L122-L150 |
kaliop-uk/kueueingbundle | Adapter/RabbitMq/Consumer.php | Consumer.processMessage | public function processMessage(BaseAMQPMessage $msg)
{
$newMsg = new AMQPMessage($msg->body, $msg->get_properties());
$newMsg->delivery_info = $msg->delivery_info;
$newMsg->body_size = $msg->body_size;
$newMsg->is_truncated = $msg->is_truncated;
$newMsg->setQueueName($this->queueName);
$processFlag = call_user_func($this->callback, $newMsg);
$this->handleProcessMessage($newMsg, $processFlag);
} | php | public function processMessage(BaseAMQPMessage $msg)
{
$newMsg = new AMQPMessage($msg->body, $msg->get_properties());
$newMsg->delivery_info = $msg->delivery_info;
$newMsg->body_size = $msg->body_size;
$newMsg->is_truncated = $msg->is_truncated;
$newMsg->setQueueName($this->queueName);
$processFlag = call_user_func($this->callback, $newMsg);
$this->handleProcessMessage($newMsg, $processFlag);
} | [
"public",
"function",
"processMessage",
"(",
"BaseAMQPMessage",
"$",
"msg",
")",
"{",
"$",
"newMsg",
"=",
"new",
"AMQPMessage",
"(",
"$",
"msg",
"->",
"body",
",",
"$",
"msg",
"->",
"get_properties",
"(",
")",
")",
";",
"$",
"newMsg",
"->",
"delivery_inf... | Overridden to inject the queue name into the AMQP message
@param BaseAMQPMessage $msg | [
"Overridden",
"to",
"inject",
"the",
"queue",
"name",
"into",
"the",
"AMQP",
"message"
] | train | https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/RabbitMq/Consumer.php#L156-L166 |
budde377/Part | lib/util/file/FileImpl.php | FileImpl.move | public function move($path)
{
if($this->isDirectory()){
return false;
}
$path = $this->relativeToAbsolute($path);
if (($ret = @rename($this->filePath, $path)) === true) {
$this->filePath = $path;
}
return $ret;
} | php | public function move($path)
{
if($this->isDirectory()){
return false;
}
$path = $this->relativeToAbsolute($path);
if (($ret = @rename($this->filePath, $path)) === true) {
$this->filePath = $path;
}
return $ret;
} | [
"public",
"function",
"move",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDirectory",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"relativeToAbsolute",
"(",
"$",
"path",
")",
";",
"if",
"... | Will move the file to specified path
@param string $path
@return bool TRUE if success FALSE if failure | [
"Will",
"move",
"the",
"file",
"to",
"specified",
"path"
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileImpl.php#L93-L104 |
budde377/Part | lib/util/file/FileImpl.php | FileImpl.write | public function write($string)
{
$handle = @fopen($this->filePath, $this->mode);
if ($handle === false) {
return $handle;
}
return @fwrite($handle, $string);
} | php | public function write($string)
{
$handle = @fopen($this->filePath, $this->mode);
if ($handle === false) {
return $handle;
}
return @fwrite($handle, $string);
} | [
"public",
"function",
"write",
"(",
"$",
"string",
")",
"{",
"$",
"handle",
"=",
"@",
"fopen",
"(",
"$",
"this",
"->",
"filePath",
",",
"$",
"this",
"->",
"mode",
")",
";",
"if",
"(",
"$",
"handle",
"===",
"false",
")",
"{",
"return",
"$",
"handl... | Writes to file
@param $string
@return int | bool Returns the number of bytes written, or FALSE on error. | [
"Writes",
"to",
"file"
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileImpl.php#L138-L147 |
budde377/Part | lib/util/file/FileImpl.php | FileImpl.setAccessMode | public function setAccessMode($permissions)
{
switch ($permissions) {
case File::FILE_MODE_RW_POINTER_AT_END:
case File::FILE_MODE_W_POINTER_AT_END:
case File::FILE_MODE_R_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH:
case File::FILE_MODE_W_TRUNCATE_FILE_TO_ZERO_LENGTH:
$this->mode = $permissions;
}
} | php | public function setAccessMode($permissions)
{
switch ($permissions) {
case File::FILE_MODE_RW_POINTER_AT_END:
case File::FILE_MODE_W_POINTER_AT_END:
case File::FILE_MODE_R_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_POINTER_AT_BEGINNING:
case File::FILE_MODE_RW_TRUNCATE_FILE_TO_ZERO_LENGTH:
case File::FILE_MODE_W_TRUNCATE_FILE_TO_ZERO_LENGTH:
$this->mode = $permissions;
}
} | [
"public",
"function",
"setAccessMode",
"(",
"$",
"permissions",
")",
"{",
"switch",
"(",
"$",
"permissions",
")",
"{",
"case",
"File",
"::",
"FILE_MODE_RW_POINTER_AT_END",
":",
"case",
"File",
"::",
"FILE_MODE_W_POINTER_AT_END",
":",
"case",
"File",
"::",
"FILE_... | Sets the access mode, available options is in FileModeEnum
@param string $permissions
@return void | [
"Sets",
"the",
"access",
"mode",
"available",
"options",
"is",
"in",
"FileModeEnum"
] | train | https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/file/FileImpl.php#L154-L167 |
skrz/meta | gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php | ClassWithFixed64PropertyMeta.create | public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithFixed64Property();
case 1:
return new ClassWithFixed64Property(func_get_arg(0));
case 2:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
} | php | public static function create()
{
switch (func_num_args()) {
case 0:
return new ClassWithFixed64Property();
case 1:
return new ClassWithFixed64Property(func_get_arg(0));
case 2:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1));
case 3:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2));
case 4:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
case 5:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4));
case 6:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5));
case 7:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6));
case 8:
return new ClassWithFixed64Property(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7));
default:
throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.');
}
} | [
"public",
"static",
"function",
"create",
"(",
")",
"{",
"switch",
"(",
"func_num_args",
"(",
")",
")",
"{",
"case",
"0",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
")",
";",
"case",
"1",
":",
"return",
"new",
"ClassWithFixed64Property",
"(",
"... | Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithFixed64Property
@throws \InvalidArgumentException
@return ClassWithFixed64Property | [
"Creates",
"new",
"instance",
"of",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithFixed64Property"
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php#L66-L90 |
skrz/meta | gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php | ClassWithFixed64PropertyMeta.fromProtobuf | public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ClassWithFixed64Property();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 1) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number);
}
$expectedStart = $start + 8;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->x = Binary::decodeUint64($input, $start);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
} | php | public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
{
if ($object === null) {
$object = new ClassWithFixed64Property();
}
if ($end === null) {
$end = strlen($input);
}
while ($start < $end) {
$tag = Binary::decodeVarint($input, $start);
$wireType = $tag & 0x7;
$number = $tag >> 3;
switch ($number) {
case 1:
if ($wireType !== 1) {
throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 1.', $number);
}
$expectedStart = $start + 8;
if ($expectedStart > $end) {
throw new ProtobufException('Not enough data.');
}
$object->x = Binary::decodeUint64($input, $start);
if ($start !== $expectedStart) {
throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
}
break;
default:
switch ($wireType) {
case 0:
Binary::decodeVarint($input, $start);
break;
case 1:
$start += 8;
break;
case 2:
$start += Binary::decodeVarint($input, $start);
break;
case 5:
$start += 4;
break;
default:
throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
}
}
}
return $object;
} | [
"public",
"static",
"function",
"fromProtobuf",
"(",
"$",
"input",
",",
"$",
"object",
"=",
"NULL",
",",
"&",
"$",
"start",
"=",
"0",
",",
"$",
"end",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"object",
"===",
"null",
")",
"{",
"$",
"object",
"=",
... | Creates \Skrz\Meta\Fixtures\Protobuf\ClassWithFixed64Property object from serialized Protocol Buffers message.
@param string $input
@param ClassWithFixed64Property $object
@param int $start
@param int $end
@throws \Exception
@return ClassWithFixed64Property | [
"Creates",
"\\",
"Skrz",
"\\",
"Meta",
"\\",
"Fixtures",
"\\",
"Protobuf",
"\\",
"ClassWithFixed64Property",
"object",
"from",
"serialized",
"Protocol",
"Buffers",
"message",
"."
] | train | https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithFixed64PropertyMeta.php#L332-L381 |
OpenBuildings/postmark | src/Swift_Transport_PostmarkTransport.php | Swift_Transport_PostmarkTransport.send | public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
{
if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) {
$this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
if ($evt->bubbleCancelled()) {
return 0;
}
}
$data = array(
'From' => join(',', static::convertEmailsArray($message->getFrom())),
'To' => join(',', static::convertEmailsArray($message->getTo())),
'Subject' => $message->getSubject(),
);
if ($cc = $message->getCc()) {
$data['Cc'] = join(',', static::convertEmailsArray($cc));
}
if ($reply_to = $message->getReplyTo()) {
$data['ReplyTo'] = join(',', static::convertEmailsArray($reply_to));
}
if ($bcc = $message->getBcc()) {
$data['Bcc'] = join(',', static::convertEmailsArray($bcc));
}
switch ($message->getContentType()) {
case 'text/html':
case 'multipart/related':
case 'multipart/alternative':
$data['HtmlBody'] = $message->getBody();
break;
default:
$data['TextBody'] = $message->getBody();
break;
}
if ($plain = $this->getMIMEPart($message, 'text/plain')) {
$data['TextBody'] = $plain->getBody();
}
if ($html = $this->getMIMEPart($message, 'text/html')) {
$data['HtmlBody'] = $html->getBody();
}
if ($message->getChildren()) {
$data['Attachments'] = array();
foreach ($message->getChildren() as $attachment) {
if (is_object($attachment) and $attachment instanceof \Swift_Mime_Attachment) {
$attachmentData = array(
'Name' => $attachment->getFilename(),
'Content' => base64_encode($attachment->getBody()),
'ContentType' => $attachment->getContentType(),
);
if ($attachment->getDisposition() != 'attachment' && $attachment->getId() != null) {
$attachmentData['ContentID'] = 'cid:'.$attachment->getId();
}
$data['Attachments'][] = $attachmentData;
}
}
}
$response = $this->getApi()->send($data);
if ($evt) {
$evt->setResult(\Swift_Events_SendEvent::RESULT_SUCCESS);
$this->eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
if (isset($response['MessageID'])) {
$responseEvent = $this->eventDispatcher->createResponseEvent(
$this,
$response['MessageID'],
true
);
$this->eventDispatcher->dispatchEvent($responseEvent, 'responseReceived');
}
return 1;
} | php | public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
{
if ($evt = $this->eventDispatcher->createSendEvent($this, $message)) {
$this->eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
if ($evt->bubbleCancelled()) {
return 0;
}
}
$data = array(
'From' => join(',', static::convertEmailsArray($message->getFrom())),
'To' => join(',', static::convertEmailsArray($message->getTo())),
'Subject' => $message->getSubject(),
);
if ($cc = $message->getCc()) {
$data['Cc'] = join(',', static::convertEmailsArray($cc));
}
if ($reply_to = $message->getReplyTo()) {
$data['ReplyTo'] = join(',', static::convertEmailsArray($reply_to));
}
if ($bcc = $message->getBcc()) {
$data['Bcc'] = join(',', static::convertEmailsArray($bcc));
}
switch ($message->getContentType()) {
case 'text/html':
case 'multipart/related':
case 'multipart/alternative':
$data['HtmlBody'] = $message->getBody();
break;
default:
$data['TextBody'] = $message->getBody();
break;
}
if ($plain = $this->getMIMEPart($message, 'text/plain')) {
$data['TextBody'] = $plain->getBody();
}
if ($html = $this->getMIMEPart($message, 'text/html')) {
$data['HtmlBody'] = $html->getBody();
}
if ($message->getChildren()) {
$data['Attachments'] = array();
foreach ($message->getChildren() as $attachment) {
if (is_object($attachment) and $attachment instanceof \Swift_Mime_Attachment) {
$attachmentData = array(
'Name' => $attachment->getFilename(),
'Content' => base64_encode($attachment->getBody()),
'ContentType' => $attachment->getContentType(),
);
if ($attachment->getDisposition() != 'attachment' && $attachment->getId() != null) {
$attachmentData['ContentID'] = 'cid:'.$attachment->getId();
}
$data['Attachments'][] = $attachmentData;
}
}
}
$response = $this->getApi()->send($data);
if ($evt) {
$evt->setResult(\Swift_Events_SendEvent::RESULT_SUCCESS);
$this->eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
if (isset($response['MessageID'])) {
$responseEvent = $this->eventDispatcher->createResponseEvent(
$this,
$response['MessageID'],
true
);
$this->eventDispatcher->dispatchEvent($responseEvent, 'responseReceived');
}
return 1;
} | [
"public",
"function",
"send",
"(",
"\\",
"Swift_Mime_Message",
"$",
"message",
",",
"&",
"$",
"failedRecipients",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"evt",
"=",
"$",
"this",
"->",
"eventDispatcher",
"->",
"createSendEvent",
"(",
"$",
"this",
",",
"$"... | {@inheritdoc} | [
"{"
] | train | https://github.com/OpenBuildings/postmark/blob/8187aee702fb5bb058281f9ac083f223308106f0/src/Swift_Transport_PostmarkTransport.php#L116-L199 |
willmorgan/silverstripe-cropperfield | code/CropperField.php | CropperField.saveInto | public function saveInto(DataObjectInterface $object) {
if(!$this->canCrop() || !$this->hasSourceFile()) {
return;
}
$object->setField($this->getName() . 'ID', $this->generateCropped()->ID);
$object->write();
} | php | public function saveInto(DataObjectInterface $object) {
if(!$this->canCrop() || !$this->hasSourceFile()) {
return;
}
$object->setField($this->getName() . 'ID', $this->generateCropped()->ID);
$object->write();
} | [
"public",
"function",
"saveInto",
"(",
"DataObjectInterface",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canCrop",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"hasSourceFile",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"object",
"->",... | If enabled, crop the image, save as a new file, and link it via relation
@return void | [
"If",
"enabled",
"crop",
"the",
"image",
"save",
"as",
"a",
"new",
"file",
"and",
"link",
"it",
"via",
"relation"
] | train | https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/CropperField.php#L269-L275 |
willmorgan/silverstripe-cropperfield | code/CropperField.php | CropperField.getRecord | public function getRecord() {
$form = $this->getForm();
if (!$this->record && $form) {
if (($record = $form->getRecord()) && ($record instanceof DataObject)) {
$this->record = $record;
} elseif (($controller = $form->Controller())
&& $controller->hasMethod('data')
&& ($record = $controller->data())
&& ($record instanceof DataObject)
) {
$this->setRecord($record);
}
}
return $this->record;
} | php | public function getRecord() {
$form = $this->getForm();
if (!$this->record && $form) {
if (($record = $form->getRecord()) && ($record instanceof DataObject)) {
$this->record = $record;
} elseif (($controller = $form->Controller())
&& $controller->hasMethod('data')
&& ($record = $controller->data())
&& ($record instanceof DataObject)
) {
$this->setRecord($record);
}
}
return $this->record;
} | [
"public",
"function",
"getRecord",
"(",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getForm",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"record",
"&&",
"$",
"form",
")",
"{",
"if",
"(",
"(",
"$",
"record",
"=",
"$",
"form",
"->",
... | Get the record to use as "Parent" for uploaded Files (eg a Page with a has_one to File) If none is set, it will
use Form->getRecord() or Form->Controller()->data()
@return DataObject | [
"Get",
"the",
"record",
"to",
"use",
"as",
"Parent",
"for",
"uploaded",
"Files",
"(",
"eg",
"a",
"Page",
"with",
"a",
"has_one",
"to",
"File",
")",
"If",
"none",
"is",
"set",
"it",
"will",
"use",
"Form",
"-",
">",
"getRecord",
"()",
"or",
"Form",
"... | train | https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/CropperField.php#L291-L305 |
willmorgan/silverstripe-cropperfield | code/CropperField.php | CropperField.requireFrontend | protected function requireFrontend() {
$extension = Director::isLive() ? '.min' : '';
$cssFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.css',
CROPPERFIELD_PATH . '/cropper/CropperField.css',
);
$jsFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.js',
CROPPERFIELD_PATH . '/cropper/CropperField.js',
);
Requirements::combine_files('cropperfield-all.css', $cssFiles);
Requirements::combine_files('cropperfield-all.js', $jsFiles);
} | php | protected function requireFrontend() {
$extension = Director::isLive() ? '.min' : '';
$cssFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.css',
CROPPERFIELD_PATH . '/cropper/CropperField.css',
);
$jsFiles = array(
CROPPERFIELD_PATH . '/cropper/cropper' . $extension . '.js',
CROPPERFIELD_PATH . '/cropper/CropperField.js',
);
Requirements::combine_files('cropperfield-all.css', $cssFiles);
Requirements::combine_files('cropperfield-all.js', $jsFiles);
} | [
"protected",
"function",
"requireFrontend",
"(",
")",
"{",
"$",
"extension",
"=",
"Director",
"::",
"isLive",
"(",
")",
"?",
"'.min'",
":",
"''",
";",
"$",
"cssFiles",
"=",
"array",
"(",
"CROPPERFIELD_PATH",
".",
"'/cropper/cropper'",
".",
"$",
"extension",
... | Pull in the cropper.js requirements. If in dev mode, bring in unminified.
@return void | [
"Pull",
"in",
"the",
"cropper",
".",
"js",
"requirements",
".",
"If",
"in",
"dev",
"mode",
"bring",
"in",
"unminified",
"."
] | train | https://github.com/willmorgan/silverstripe-cropperfield/blob/855ca4f44dd392b1cf9d36f411a2c145b4b3d975/code/CropperField.php#L391-L403 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.