repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
psbhanu/whatsapi | src/MessageManager.php | MessageManager.video | public function video($file, $caption = null)
{
$this->messages[] = $this->media->compile($file, $caption, 'video');
} | php | public function video($file, $caption = null)
{
$this->messages[] = $this->media->compile($file, $caption, 'video');
} | [
"public",
"function",
"video",
"(",
"$",
"file",
",",
"$",
"caption",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"]",
"=",
"$",
"this",
"->",
"media",
"->",
"compile",
"(",
"$",
"file",
",",
"$",
"caption",
",",
"'video'",
")",
";... | Send video message
<code>
WA::send('Watch this !', function($send)
{
$send->to('5219622222222');
// From local storage
$send->video('/home/xaamin/example.mp4', 'Fun video');
// or from web url
$send->video('http://itnovado.com/example.mp4', 'Fun video');
}):
</code>
@param string $file File location
@param string|null Caption
@return void | [
"Send",
"video",
"message"
] | be34f35bb5e0fd3c6f2196260865bef65c1240c2 | https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/MessageManager.php#L252-L255 | train |
psbhanu/whatsapi | src/MessageManager.php | MessageManager.transformMessages | public function transformMessages(array $messages)
{
$transformed = null;
if(count($messages))
{
$transformed = [];
foreach ($messages as $message)
{
$attributes = (object) $message->getAttributes();
$attributes->timestamp = $attributes->t;
unset($attributes->t);
// Add encryption check
$child = is_null($message->getChild(1)) ? $message->getChild(0) : $message->getChild(1);
$node = new stdClass();
$node->tag = $child->getTag();
$node->attributes = (object) $child->getAttributes();
$node->data = $child->getData();
$attributes->body = $node;
if($attributes->type == 'media')
{
if($attributes->body->attributes->type == 'vcard')
{
$vcard = new VCardReader(null, $child->getChild(0)->getData());
if(count($vcard) == 1)
{
$attributes->body->vcard[] = $vcard->parse($vcard);
}
else
{
foreach ($vcard as $card)
{
$attributes->body->vcard[] = $vcard->parse($card);
}
}
}
else
{
$tmp = $this->media->link($attributes);
$attributes->body->file = $tmp->file;
$attributes->body->html = $tmp->html;
$attributes->body->attributes2 = $node->attributes;
}
}
$transformed[] = $attributes;
}
}
return $transformed;
} | php | public function transformMessages(array $messages)
{
$transformed = null;
if(count($messages))
{
$transformed = [];
foreach ($messages as $message)
{
$attributes = (object) $message->getAttributes();
$attributes->timestamp = $attributes->t;
unset($attributes->t);
// Add encryption check
$child = is_null($message->getChild(1)) ? $message->getChild(0) : $message->getChild(1);
$node = new stdClass();
$node->tag = $child->getTag();
$node->attributes = (object) $child->getAttributes();
$node->data = $child->getData();
$attributes->body = $node;
if($attributes->type == 'media')
{
if($attributes->body->attributes->type == 'vcard')
{
$vcard = new VCardReader(null, $child->getChild(0)->getData());
if(count($vcard) == 1)
{
$attributes->body->vcard[] = $vcard->parse($vcard);
}
else
{
foreach ($vcard as $card)
{
$attributes->body->vcard[] = $vcard->parse($card);
}
}
}
else
{
$tmp = $this->media->link($attributes);
$attributes->body->file = $tmp->file;
$attributes->body->html = $tmp->html;
$attributes->body->attributes2 = $node->attributes;
}
}
$transformed[] = $attributes;
}
}
return $transformed;
} | [
"public",
"function",
"transformMessages",
"(",
"array",
"$",
"messages",
")",
"{",
"$",
"transformed",
"=",
"null",
";",
"if",
"(",
"count",
"(",
"$",
"messages",
")",
")",
"{",
"$",
"transformed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"messages",
... | Parse messages and determines message type and set captions and links
@param array $messages
@return array|null | [
"Parse",
"messages",
"and",
"determines",
"message",
"type",
"and",
"set",
"captions",
"and",
"links"
] | be34f35bb5e0fd3c6f2196260865bef65c1240c2 | https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/MessageManager.php#L317-L376 | train |
tlapnet/report | src/Service/CacheService.php | CacheService.findCached | public function findCached(): array
{
$output = [];
$introspect = $this->introspection->introspect();
$tags = $this->introspection->findTags(CachedDataSource::class);
foreach ($tags as $tag) {
foreach ($tag as $key => $value) {
foreach ($introspect as $item) {
if ($item->tags['services']['subreport'] === $value) {
$output[] = [
'id' => $item->rid . '.' . $item->sid,
'report_id' => $item->rid,
'subreport_id' => $item->sid,
'report' => $item->tags['services']['report'],
'subreport' => $item->tags['services']['subreport'],
'key' => $item->tags['services']['subreport'],
'cache' => $item->tags['cache'],
];
}
}
}
}
return $output;
} | php | public function findCached(): array
{
$output = [];
$introspect = $this->introspection->introspect();
$tags = $this->introspection->findTags(CachedDataSource::class);
foreach ($tags as $tag) {
foreach ($tag as $key => $value) {
foreach ($introspect as $item) {
if ($item->tags['services']['subreport'] === $value) {
$output[] = [
'id' => $item->rid . '.' . $item->sid,
'report_id' => $item->rid,
'subreport_id' => $item->sid,
'report' => $item->tags['services']['report'],
'subreport' => $item->tags['services']['subreport'],
'key' => $item->tags['services']['subreport'],
'cache' => $item->tags['cache'],
];
}
}
}
}
return $output;
} | [
"public",
"function",
"findCached",
"(",
")",
":",
"array",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"introspect",
"=",
"$",
"this",
"->",
"introspection",
"->",
"introspect",
"(",
")",
";",
"$",
"tags",
"=",
"$",
"this",
"->",
"introspection",
"... | Returns array of subreports which have cached datasource. All lazy-loaded.
@return mixed[] | [
"Returns",
"array",
"of",
"subreports",
"which",
"have",
"cached",
"datasource",
".",
"All",
"lazy",
"-",
"loaded",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Service/CacheService.php#L26-L51 | train |
tlapnet/report | src/Service/CacheService.php | CacheService.warmupSubreport | public function warmupSubreport(string $subreport): Resultable
{
$subreport = $this->introspection->getService($subreport);
if (!($subreport instanceof Subreport)) {
throw new InvalidStateException(sprintf('Service "%s" is not subreport', get_class($subreport)));
}
return $subreport->getDataSource()->compile($subreport->getParameters());
} | php | public function warmupSubreport(string $subreport): Resultable
{
$subreport = $this->introspection->getService($subreport);
if (!($subreport instanceof Subreport)) {
throw new InvalidStateException(sprintf('Service "%s" is not subreport', get_class($subreport)));
}
return $subreport->getDataSource()->compile($subreport->getParameters());
} | [
"public",
"function",
"warmupSubreport",
"(",
"string",
"$",
"subreport",
")",
":",
"Resultable",
"{",
"$",
"subreport",
"=",
"$",
"this",
"->",
"introspection",
"->",
"getService",
"(",
"$",
"subreport",
")",
";",
"if",
"(",
"!",
"(",
"$",
"subreport",
... | Warmup subreport cache | [
"Warmup",
"subreport",
"cache"
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Service/CacheService.php#L56-L65 | train |
QuickenLoans/mcp-common | src/Time/TimeInterval.php | TimeInterval.addDays | private function addDays($extraSpec)
{
if (preg_match('/(\d+)D$/', $extraSpec, $matches)) {
$days = end($matches);
$this->dateInterval = DateInterval::__set_state(
array(
'y' => $this->dateInterval->y,
'm' => $this->dateInterval->m,
'd' => $this->dateInterval->d,
'h' => $this->dateInterval->h,
'i' => $this->dateInterval->i,
's' => $this->dateInterval->s,
'invert' => $this->dateInterval->invert,
'days' => $days
)
);
}
} | php | private function addDays($extraSpec)
{
if (preg_match('/(\d+)D$/', $extraSpec, $matches)) {
$days = end($matches);
$this->dateInterval = DateInterval::__set_state(
array(
'y' => $this->dateInterval->y,
'm' => $this->dateInterval->m,
'd' => $this->dateInterval->d,
'h' => $this->dateInterval->h,
'i' => $this->dateInterval->i,
's' => $this->dateInterval->s,
'invert' => $this->dateInterval->invert,
'days' => $days
)
);
}
} | [
"private",
"function",
"addDays",
"(",
"$",
"extraSpec",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/(\\d+)D$/'",
",",
"$",
"extraSpec",
",",
"$",
"matches",
")",
")",
"{",
"$",
"days",
"=",
"end",
"(",
"$",
"matches",
")",
";",
"$",
"this",
"->",
"... | Add days property that is lost when constructing a new DateInterval
@param string $extraSpec
@return null | [
"Add",
"days",
"property",
"that",
"is",
"lost",
"when",
"constructing",
"a",
"new",
"DateInterval"
] | 46ca6e2c5c9df4ec102808f8494ad1774f190021 | https://github.com/QuickenLoans/mcp-common/blob/46ca6e2c5c9df4ec102808f8494ad1774f190021/src/Time/TimeInterval.php#L108-L126 | train |
ynloultratech/graphql-bundle | src/Error/ControlledErrorManager.php | ControlledErrorManager.clear | public function clear(): void
{
$this->errors = [];
if (file_exists($this->cacheFileName())) {
@unlink($this->cacheFileName());
}
} | php | public function clear(): void
{
$this->errors = [];
if (file_exists($this->cacheFileName())) {
@unlink($this->cacheFileName());
}
} | [
"public",
"function",
"clear",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"cacheFileName",
"(",
")",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"this",
"->",
"cacheF... | Clear errors and cache | [
"Clear",
"errors",
"and",
"cache"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Error/ControlledErrorManager.php#L102-L108 | train |
jsifuentes/php-image-upload | src/Services/Imgur.php | Imgur.upload | public function upload($file, $format = 'json', $album = null, $name = null, $title = null, $description = null)
{
return $this->post('https://api.imgur.com/3/image.' . $format, array(
'image' => $file,
'album' => $album,
'name' => $name,
'title' => $title,
'description' => $description
), array(
'Authorization: Client-ID ' . $this->key
));
} | php | public function upload($file, $format = 'json', $album = null, $name = null, $title = null, $description = null)
{
return $this->post('https://api.imgur.com/3/image.' . $format, array(
'image' => $file,
'album' => $album,
'name' => $name,
'title' => $title,
'description' => $description
), array(
'Authorization: Client-ID ' . $this->key
));
} | [
"public",
"function",
"upload",
"(",
"$",
"file",
",",
"$",
"format",
"=",
"'json'",
",",
"$",
"album",
"=",
"null",
",",
"$",
"name",
"=",
"null",
",",
"$",
"title",
"=",
"null",
",",
"$",
"description",
"=",
"null",
")",
"{",
"return",
"$",
"th... | Upload an image to Imgur
@param string File you will be uploading (URL, Binary, Base64)
@param int Album ID to upload the file in
@param string Name of image
@param string Title of image
@param string Description of image
@return mixed Response | [
"Upload",
"an",
"image",
"to",
"Imgur"
] | 4b130655ed2ab380f5f2eb051551aa8b388a90a7 | https://github.com/jsifuentes/php-image-upload/blob/4b130655ed2ab380f5f2eb051551aa8b388a90a7/src/Services/Imgur.php#L25-L36 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.store | public static function store(FileSystemCacheKey $key, $data, $ttl=null) {
$filename = $key->getFileName();
$data = new FileSystemCacheValue($key,$data,$ttl);
$fh = self::getFileHandle($filename,'c');
if(!$fh) return false;
if(!self::putContents($fh,$data)) return false;
return true;
} | php | public static function store(FileSystemCacheKey $key, $data, $ttl=null) {
$filename = $key->getFileName();
$data = new FileSystemCacheValue($key,$data,$ttl);
$fh = self::getFileHandle($filename,'c');
if(!$fh) return false;
if(!self::putContents($fh,$data)) return false;
return true;
} | [
"public",
"static",
"function",
"store",
"(",
"FileSystemCacheKey",
"$",
"key",
",",
"$",
"data",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"filename",
"=",
"$",
"key",
"->",
"getFileName",
"(",
")",
";",
"$",
"data",
"=",
"new",
"FileSystemCacheVal... | Stores data in the cache
@param FileSystemCacheKey $key The cache key
@param mixed $data The data to store (will be serialized before storing)
@param int $ttl The number of seconds until the cache expires. (optional)
@return boolean True on success, false on failure | [
"Stores",
"data",
"in",
"the",
"cache"
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L39-L51 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.retrieve | public static function retrieve(FileSystemCacheKey $key, $newer_than=null) {
$filename = $key->getFileName();
if(!file_exists($filename)) return false;
//if cached data is not newer than $newer_than
if($newer_than && filemtime($filename) < $newer_than) return false;
$fh = self::getFileHandle($filename,'r');
if(!$fh) return false;
$data = self::getContents($fh,$key);
if(!$data) return false;
self::closeFile($fh);
return $data->value;
} | php | public static function retrieve(FileSystemCacheKey $key, $newer_than=null) {
$filename = $key->getFileName();
if(!file_exists($filename)) return false;
//if cached data is not newer than $newer_than
if($newer_than && filemtime($filename) < $newer_than) return false;
$fh = self::getFileHandle($filename,'r');
if(!$fh) return false;
$data = self::getContents($fh,$key);
if(!$data) return false;
self::closeFile($fh);
return $data->value;
} | [
"public",
"static",
"function",
"retrieve",
"(",
"FileSystemCacheKey",
"$",
"key",
",",
"$",
"newer_than",
"=",
"null",
")",
"{",
"$",
"filename",
"=",
"$",
"key",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
... | Retrieve data from cache
@param FileSystemCacheKey $key The cache key
@param int $newer_than If passed, only return if the cached value was created after this time
@return mixed The cached data or FALSE if not found or expired | [
"Retrieve",
"data",
"from",
"cache"
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L59-L76 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.getAndModify | public static function getAndModify(FileSystemCacheKey $key, \Closure $callback, $resetTtl=false) {
$filename = $key->getFileName();
if(!file_exists($filename)) return false;
//open a file handle
$fh = self::getFileHandle($filename,'c+');
if(!$fh) return false;
//get the data
$data = self::getContents($fh,$key);
if(!$data) return false;
//get new value from callback function
$old_value = $data->value;
$data->value = $callback($data->value);
//if the callback function returns false
if($data->value === false) {
self::closeFile($fh);
//delete the cache file
self::invalidate($key);
return false;
}
//if value didn't change
if(!$resetTtl && $data->value === $old_value) {
self::closeFile($fh);
return $data->value;
}
//if we're resetting the ttl to now
if($resetTtl) {
$data->created = time();
if($data->ttl) {
$data->expires = $data->created + $data->ttl;
}
}
if(!self::emptyFile($fh)) return false;
//write contents and close the file handle
self::putContents($fh,$data);
//return the new value after modifying
return $data->value;
} | php | public static function getAndModify(FileSystemCacheKey $key, \Closure $callback, $resetTtl=false) {
$filename = $key->getFileName();
if(!file_exists($filename)) return false;
//open a file handle
$fh = self::getFileHandle($filename,'c+');
if(!$fh) return false;
//get the data
$data = self::getContents($fh,$key);
if(!$data) return false;
//get new value from callback function
$old_value = $data->value;
$data->value = $callback($data->value);
//if the callback function returns false
if($data->value === false) {
self::closeFile($fh);
//delete the cache file
self::invalidate($key);
return false;
}
//if value didn't change
if(!$resetTtl && $data->value === $old_value) {
self::closeFile($fh);
return $data->value;
}
//if we're resetting the ttl to now
if($resetTtl) {
$data->created = time();
if($data->ttl) {
$data->expires = $data->created + $data->ttl;
}
}
if(!self::emptyFile($fh)) return false;
//write contents and close the file handle
self::putContents($fh,$data);
//return the new value after modifying
return $data->value;
} | [
"public",
"static",
"function",
"getAndModify",
"(",
"FileSystemCacheKey",
"$",
"key",
",",
"\\",
"Closure",
"$",
"callback",
",",
"$",
"resetTtl",
"=",
"false",
")",
"{",
"$",
"filename",
"=",
"$",
"key",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
... | Atomically retrieve data from cache, modify it, and store it back
@param FileSystemCacheKey $key The cache key
@param Closure $callback A closure function to modify the cache value.
Takes the old value as an argument and returns new value.
If this function returns false, the cached value will be invalidated.
@param bool $resetTtl If set to true, the expiration date will be recalculated using the previous TTL
@return mixed The new value if it was stored successfully or false if it wasn't
@throws Exception If an invalid callback method is given | [
"Atomically",
"retrieve",
"data",
"from",
"cache",
"modify",
"it",
"and",
"store",
"it",
"back"
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L88-L135 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.invalidate | public static function invalidate(FileSystemCacheKey $key) {
$filename = $key->getFileName();
if(file_exists($filename)) {
try{
unlink($filename);
} catch (\Exception $ex) {
}
}
return true;
} | php | public static function invalidate(FileSystemCacheKey $key) {
$filename = $key->getFileName();
if(file_exists($filename)) {
try{
unlink($filename);
} catch (\Exception $ex) {
}
}
return true;
} | [
"public",
"static",
"function",
"invalidate",
"(",
"FileSystemCacheKey",
"$",
"key",
")",
"{",
"$",
"filename",
"=",
"$",
"key",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"try",
"{",
"unlink",
"(... | Invalidate a specific cache key
@param FileSystemCacheKey $key The cache key
@return boolean True on success. Currently never returns false. | [
"Invalidate",
"a",
"specific",
"cache",
"key"
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L142-L151 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.invalidateGroup | public static function invalidateGroup($name=null, $recursive=true) {
//if invalidating a group, make sure it's valid
if($name) {
//it needs to have a trailing slash and no leading slashes
$name = trim($name,'/').'/';
//make sure the key isn't going up a directory
if(strpos($name,'..') !== false) {
throw new Exception("Invalidate path cannot go up directories.");
}
}
array_map("unlink", glob(self::$cacheDir.'/'.$name.'*.cache'));
//if recursively invalidating
if($recursive) {
$subdirs = glob(self::$cacheDir.'/'.$name.'*',GLOB_ONLYDIR);
foreach($subdirs as $dir) {
$dir = basename($dir);
//skip all subdirectories that start with '.'
if($dir[0] == '.') continue;
self::invalidateGroup($name.$dir,true);
}
}
} | php | public static function invalidateGroup($name=null, $recursive=true) {
//if invalidating a group, make sure it's valid
if($name) {
//it needs to have a trailing slash and no leading slashes
$name = trim($name,'/').'/';
//make sure the key isn't going up a directory
if(strpos($name,'..') !== false) {
throw new Exception("Invalidate path cannot go up directories.");
}
}
array_map("unlink", glob(self::$cacheDir.'/'.$name.'*.cache'));
//if recursively invalidating
if($recursive) {
$subdirs = glob(self::$cacheDir.'/'.$name.'*',GLOB_ONLYDIR);
foreach($subdirs as $dir) {
$dir = basename($dir);
//skip all subdirectories that start with '.'
if($dir[0] == '.') continue;
self::invalidateGroup($name.$dir,true);
}
}
} | [
"public",
"static",
"function",
"invalidateGroup",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"//if invalidating a group, make sure it's valid",
"if",
"(",
"$",
"name",
")",
"{",
"//it needs to have a trailing slash and no leading slash... | Invalidate a group of cache keys
@param string $name The name of the group to invalidate (e.g. 'groupname', 'groupname/subgroupname', etc.). If null, the entire cache will be invalidated.
@param boolean $recursive If set to false, none of the subgroups will be invalidated.
@throws Exception If an invalid group name is given | [
"Invalidate",
"a",
"group",
"of",
"cache",
"keys"
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L159-L186 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.getFileHandle | private static function getFileHandle($filename, $mode='c') {
$write = in_array($mode,array('c','c+'));
if($write) {
//make sure the directory exists and is writable
$directory = dirname($filename);
if(!file_exists($directory)) {
if(!mkdir($directory,0777,true)) {
return false;
}
}
elseif(!is_dir($directory)) {
return false;
}
elseif(!is_writable($directory)) {
return false;
}
}
//get file pointer
$fh = fopen($filename,$mode);
if(!$fh) return false;
//lock file with appropriate lock type
if($write) {
if(!flock($fh,LOCK_EX)) {
self::closeFile($fh);
return false;
}
}
else {
if(!flock($fh,LOCK_SH)) {
self::closeFile($fh);
return false;
}
}
return $fh;
} | php | private static function getFileHandle($filename, $mode='c') {
$write = in_array($mode,array('c','c+'));
if($write) {
//make sure the directory exists and is writable
$directory = dirname($filename);
if(!file_exists($directory)) {
if(!mkdir($directory,0777,true)) {
return false;
}
}
elseif(!is_dir($directory)) {
return false;
}
elseif(!is_writable($directory)) {
return false;
}
}
//get file pointer
$fh = fopen($filename,$mode);
if(!$fh) return false;
//lock file with appropriate lock type
if($write) {
if(!flock($fh,LOCK_EX)) {
self::closeFile($fh);
return false;
}
}
else {
if(!flock($fh,LOCK_SH)) {
self::closeFile($fh);
return false;
}
}
return $fh;
} | [
"private",
"static",
"function",
"getFileHandle",
"(",
"$",
"filename",
",",
"$",
"mode",
"=",
"'c'",
")",
"{",
"$",
"write",
"=",
"in_array",
"(",
"$",
"mode",
",",
"array",
"(",
"'c'",
",",
"'c+'",
")",
")",
";",
"if",
"(",
"$",
"write",
")",
"... | Get a file handle from a file name. Will create the directory if it doesn't exist already. Also, automatically locks the file with the proper read or write lock.
@param String $filename The full file path.
@param String $mode The file mode. Accepted modes are 'c', 'c+', and 'r'.
@return resource The file handle | [
"Get",
"a",
"file",
"handle",
"from",
"a",
"file",
"name",
".",
"Will",
"create",
"the",
"directory",
"if",
"it",
"doesn",
"t",
"exist",
"already",
".",
"Also",
"automatically",
"locks",
"the",
"file",
"with",
"the",
"proper",
"read",
"or",
"write",
"loc... | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L195-L234 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.emptyFile | private static function emptyFile($fh) {
rewind($fh);
if(!ftruncate($fh,0)) {
//release lock
self::closeFile($fh);
return false;
}
else {
return true;
}
} | php | private static function emptyFile($fh) {
rewind($fh);
if(!ftruncate($fh,0)) {
//release lock
self::closeFile($fh);
return false;
}
else {
return true;
}
} | [
"private",
"static",
"function",
"emptyFile",
"(",
"$",
"fh",
")",
"{",
"rewind",
"(",
"$",
"fh",
")",
";",
"if",
"(",
"!",
"ftruncate",
"(",
"$",
"fh",
",",
"0",
")",
")",
"{",
"//release lock",
"self",
"::",
"closeFile",
"(",
"$",
"fh",
")",
";... | Empties a file. If empty fails, the file will be closed and it will return false.
@param resource $fh The file handle
@return boolean true for success, false for failure | [
"Empties",
"a",
"file",
".",
"If",
"empty",
"fails",
"the",
"file",
"will",
"be",
"closed",
"and",
"it",
"will",
"return",
"false",
"."
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L241-L251 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.getContents | private static function getContents($fh,FileSystemCacheKey $key) {
//get the existing file contents
$contents = stream_get_contents($fh);
$data = @unserialize($contents);
//if we can't unserialize the data or if the data is expired
if(!$data || !($data instanceof FileSystemCacheValue) || $data->isExpired()) {
//release lock
self::closeFile($fh);
//delete the cache file so we don't try to retrieve it again
self::invalidate($key);
return false;
}
return $data;
} | php | private static function getContents($fh,FileSystemCacheKey $key) {
//get the existing file contents
$contents = stream_get_contents($fh);
$data = @unserialize($contents);
//if we can't unserialize the data or if the data is expired
if(!$data || !($data instanceof FileSystemCacheValue) || $data->isExpired()) {
//release lock
self::closeFile($fh);
//delete the cache file so we don't try to retrieve it again
self::invalidate($key);
return false;
}
return $data;
} | [
"private",
"static",
"function",
"getContents",
"(",
"$",
"fh",
",",
"FileSystemCacheKey",
"$",
"key",
")",
"{",
"//get the existing file contents",
"$",
"contents",
"=",
"stream_get_contents",
"(",
"$",
"fh",
")",
";",
"$",
"data",
"=",
"@",
"unserialize",
"(... | Returns the contents of a cache file. If the data is not in the right form or expired, it will be invalidated.
@param resource $fh The file handle
@param FileSystemCacheKey $key The cache key. This is used to invalidate the key when the data is expired.
@return boolean|FileSystemCacheValue FALSE if something went wrong or the data is expired. Otherwise, a FileSystemCacheValue object will be returned. | [
"Returns",
"the",
"contents",
"of",
"a",
"cache",
"file",
".",
"If",
"the",
"data",
"is",
"not",
"in",
"the",
"right",
"form",
"or",
"expired",
"it",
"will",
"be",
"invalidated",
"."
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L268-L285 | train |
eidsonator/SemanticReportsBundle | lib/FileSystemCache/lib/FileSystemCache.php | FileSystemCache.putContents | private static function putContents($fh,FileSystemCacheValue $data) {
try{
fwrite($fh,serialize($data));
fflush($fh);
} catch (\Exception $ex){}
//release lock
self::closeFile($fh);
return true;
} | php | private static function putContents($fh,FileSystemCacheValue $data) {
try{
fwrite($fh,serialize($data));
fflush($fh);
} catch (\Exception $ex){}
//release lock
self::closeFile($fh);
return true;
} | [
"private",
"static",
"function",
"putContents",
"(",
"$",
"fh",
",",
"FileSystemCacheValue",
"$",
"data",
")",
"{",
"try",
"{",
"fwrite",
"(",
"$",
"fh",
",",
"serialize",
"(",
"$",
"data",
")",
")",
";",
"fflush",
"(",
"$",
"fh",
")",
";",
"}",
"c... | Writes to a file. Also closes and releases any locks on the file.
@param resource $fh The file handle
@param FileSystemCacheValue $data The cache value to store in the file.
@return boolean True on success. Currently, never returns false. | [
"Writes",
"to",
"a",
"file",
".",
"Also",
"closes",
"and",
"releases",
"any",
"locks",
"on",
"the",
"file",
"."
] | 11c82be87551eae232280a74b2de7e3255666f85 | https://github.com/eidsonator/SemanticReportsBundle/blob/11c82be87551eae232280a74b2de7e3255666f85/lib/FileSystemCache/lib/FileSystemCache.php#L293-L303 | train |
ynloultratech/graphql-bundle | src/Definition/Registry/DefinitionRegistry.php | DefinitionRegistry.getEndpoint | public function getEndpoint($name = self::DEFAULT_ENDPOINT): Endpoint
{
$endpoints = $this->endpointsConfig;
unset($endpoints[self::DEFAULT_ENDPOINT]);
$endpointsNames = array_keys($endpoints);
if (self::DEFAULT_ENDPOINT !== $name && !\in_array($name, $endpointsNames)) {
throw new EndpointNotValidException($name, $endpointsNames);
}
//use first static cache
if (isset(self::$endpoints[$name])) {
return self::$endpoints[$name];
}
//use file cache
self::$endpoints[$name] = $this->loadCache($name);
//retry after load from file
if (isset(self::$endpoints[$name]) && self::$endpoints[$name] instanceof Endpoint) {
return self::$endpoints[$name];
}
$this->initialize($name);
return self::$endpoints[$name];
} | php | public function getEndpoint($name = self::DEFAULT_ENDPOINT): Endpoint
{
$endpoints = $this->endpointsConfig;
unset($endpoints[self::DEFAULT_ENDPOINT]);
$endpointsNames = array_keys($endpoints);
if (self::DEFAULT_ENDPOINT !== $name && !\in_array($name, $endpointsNames)) {
throw new EndpointNotValidException($name, $endpointsNames);
}
//use first static cache
if (isset(self::$endpoints[$name])) {
return self::$endpoints[$name];
}
//use file cache
self::$endpoints[$name] = $this->loadCache($name);
//retry after load from file
if (isset(self::$endpoints[$name]) && self::$endpoints[$name] instanceof Endpoint) {
return self::$endpoints[$name];
}
$this->initialize($name);
return self::$endpoints[$name];
} | [
"public",
"function",
"getEndpoint",
"(",
"$",
"name",
"=",
"self",
"::",
"DEFAULT_ENDPOINT",
")",
":",
"Endpoint",
"{",
"$",
"endpoints",
"=",
"$",
"this",
"->",
"endpointsConfig",
";",
"unset",
"(",
"$",
"endpoints",
"[",
"self",
"::",
"DEFAULT_ENDPOINT",
... | Get endpoint schema
For internal use can get the default endpoint (contains all definitions)
For consumers must get the endpoint for current consumer.
@param string $name
@return Endpoint
@throws EndpointNotValidException | [
"Get",
"endpoint",
"schema"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Definition/Registry/DefinitionRegistry.php#L101-L126 | train |
ynloultratech/graphql-bundle | src/Definition/Registry/DefinitionRegistry.php | DefinitionRegistry.clearCache | public function clearCache($warmUp = false)
{
@unlink($this->cacheFileName('default.raw'));
foreach ($this->endpointsConfig as $name => $config) {
unset(self::$endpoints[$name]);
@unlink($this->cacheFileName($name));
if ($warmUp) {
$this->initialize($name);
}
}
} | php | public function clearCache($warmUp = false)
{
@unlink($this->cacheFileName('default.raw'));
foreach ($this->endpointsConfig as $name => $config) {
unset(self::$endpoints[$name]);
@unlink($this->cacheFileName($name));
if ($warmUp) {
$this->initialize($name);
}
}
} | [
"public",
"function",
"clearCache",
"(",
"$",
"warmUp",
"=",
"false",
")",
"{",
"@",
"unlink",
"(",
"$",
"this",
"->",
"cacheFileName",
"(",
"'default.raw'",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"endpointsConfig",
"as",
"$",
"name",
"=>",
... | remove the specification cache
@param bool $warmUp recreate the cache after clear | [
"remove",
"the",
"specification",
"cache"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Definition/Registry/DefinitionRegistry.php#L133-L143 | train |
ynloultratech/graphql-bundle | src/Definition/Registry/DefinitionRegistry.php | DefinitionRegistry.compile | protected function compile(Endpoint $endpoint): void
{
//run all extensions for each definition
foreach ($this->plugins as $plugin) {
//run extensions recursively in all types and fields
foreach ($endpoint->allTypes() as $type) {
$this->configureDefinition($plugin, $type, $endpoint);
if ($type instanceof FieldsAwareDefinitionInterface) {
foreach ($type->getFields() as $field) {
$this->configureDefinition($plugin, $field, $endpoint);
foreach ($field->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
}
}
//run extension in all queries
foreach ($endpoint->allQueries() as $query) {
$this->configureDefinition($plugin, $query, $endpoint);
foreach ($query->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
//run extensions in all mutations
foreach ($endpoint->allMutations() as $mutation) {
$this->configureDefinition($plugin, $mutation, $endpoint);
foreach ($mutation->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
//run extensions in all subscriptions
foreach ($endpoint->allSubscriptions() as $subscription) {
$this->configureDefinition($plugin, $subscription, $endpoint);
foreach ($subscription->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
$plugin->configureEndpoint($endpoint);
}
} | php | protected function compile(Endpoint $endpoint): void
{
//run all extensions for each definition
foreach ($this->plugins as $plugin) {
//run extensions recursively in all types and fields
foreach ($endpoint->allTypes() as $type) {
$this->configureDefinition($plugin, $type, $endpoint);
if ($type instanceof FieldsAwareDefinitionInterface) {
foreach ($type->getFields() as $field) {
$this->configureDefinition($plugin, $field, $endpoint);
foreach ($field->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
}
}
//run extension in all queries
foreach ($endpoint->allQueries() as $query) {
$this->configureDefinition($plugin, $query, $endpoint);
foreach ($query->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
//run extensions in all mutations
foreach ($endpoint->allMutations() as $mutation) {
$this->configureDefinition($plugin, $mutation, $endpoint);
foreach ($mutation->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
//run extensions in all subscriptions
foreach ($endpoint->allSubscriptions() as $subscription) {
$this->configureDefinition($plugin, $subscription, $endpoint);
foreach ($subscription->getArguments() as $argument) {
$this->configureDefinition($plugin, $argument, $endpoint);
}
}
$plugin->configureEndpoint($endpoint);
}
} | [
"protected",
"function",
"compile",
"(",
"Endpoint",
"$",
"endpoint",
")",
":",
"void",
"{",
"//run all extensions for each definition",
"foreach",
"(",
"$",
"this",
"->",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"//run extensions recursively in all types and fields",
... | Verify endpoint definitions and do some tasks to prepare the endpoint
@param Endpoint $endpoint | [
"Verify",
"endpoint",
"definitions",
"and",
"do",
"some",
"tasks",
"to",
"prepare",
"the",
"endpoint"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Definition/Registry/DefinitionRegistry.php#L204-L247 | train |
o2system/kernel | src/Cli/Writers/Table.php | Table.addColumn | public function addColumn($content, $columnIndex = null, $rowIndex = null)
{
$rowIndex = $rowIndex === null
? $this->rowIndex
: $rowIndex;
if ($columnIndex === null) {
$columnIndex = isset($this->rows[ $rowIndex ])
? count($this->rows[ $rowIndex ])
: 0;
}
$this->rows[ $rowIndex ][ $columnIndex ] = $content;
return $this;
} | php | public function addColumn($content, $columnIndex = null, $rowIndex = null)
{
$rowIndex = $rowIndex === null
? $this->rowIndex
: $rowIndex;
if ($columnIndex === null) {
$columnIndex = isset($this->rows[ $rowIndex ])
? count($this->rows[ $rowIndex ])
: 0;
}
$this->rows[ $rowIndex ][ $columnIndex ] = $content;
return $this;
} | [
"public",
"function",
"addColumn",
"(",
"$",
"content",
",",
"$",
"columnIndex",
"=",
"null",
",",
"$",
"rowIndex",
"=",
"null",
")",
"{",
"$",
"rowIndex",
"=",
"$",
"rowIndex",
"===",
"null",
"?",
"$",
"this",
"->",
"rowIndex",
":",
"$",
"rowIndex",
... | Adds a column to the table
@param mixed $content The data of the column
@param int $columnIndex The column index to populate
@param int $rowIndex The row index, if the row isn't starting from zero, specify it here.
@return static | [
"Adds",
"a",
"column",
"to",
"the",
"table"
] | b1bf7904159e9f1cf9160b79f998472a3c307fc4 | https://github.com/o2system/kernel/blob/b1bf7904159e9f1cf9160b79f998472a3c307fc4/src/Cli/Writers/Table.php#L175-L188 | train |
figdice/figdice | src/figdice/classes/tags/TagFigCdata.php | TagFigCdata.fig_cdata | private function fig_cdata(Context $context) {
$filename = $this->dataFile;
$realfilename = dirname($context->getFilename()).'/'.$filename;
if(! file_exists($realfilename)) {
$message = "File not found: $filename called from: " . $context->getFilename(). '(' . $this->xmlLineNumber . ')';
throw new FileNotFoundException($message, $filename);
}
$cdata = file_get_contents($realfilename);
return $cdata;
} | php | private function fig_cdata(Context $context) {
$filename = $this->dataFile;
$realfilename = dirname($context->getFilename()).'/'.$filename;
if(! file_exists($realfilename)) {
$message = "File not found: $filename called from: " . $context->getFilename(). '(' . $this->xmlLineNumber . ')';
throw new FileNotFoundException($message, $filename);
}
$cdata = file_get_contents($realfilename);
return $cdata;
} | [
"private",
"function",
"fig_cdata",
"(",
"Context",
"$",
"context",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"dataFile",
";",
"$",
"realfilename",
"=",
"dirname",
"(",
"$",
"context",
"->",
"getFilename",
"(",
")",
")",
".",
"'/'",
".",
"$",
... | Imports at the current output position
the contents of specified file unparsed, rendered as is.
@param Context $context
@return string
@throws FileNotFoundException | [
"Imports",
"at",
"the",
"current",
"output",
"position",
"the",
"contents",
"of",
"specified",
"file",
"unparsed",
"rendered",
"as",
"is",
"."
] | 896bbe3aec365c416e368dcc6b888a6cf1832afc | https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/tags/TagFigCdata.php#L54-L63 | train |
amphp/hpack | src/HPack.php | HPack.resizeTable | public function resizeTable(int $maxSize = null) {
if ($maxSize !== null) {
$this->maxSize = $maxSize;
}
while ($this->size > $this->maxSize) {
list($name, $value) = \array_pop($this->headers);
$this->size -= 32 + \strlen($name) + \strlen($value);
}
} | php | public function resizeTable(int $maxSize = null) {
if ($maxSize !== null) {
$this->maxSize = $maxSize;
}
while ($this->size > $this->maxSize) {
list($name, $value) = \array_pop($this->headers);
$this->size -= 32 + \strlen($name) + \strlen($value);
}
} | [
"public",
"function",
"resizeTable",
"(",
"int",
"$",
"maxSize",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"maxSize",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"maxSize",
"=",
"$",
"maxSize",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"size",
">",
... | Resizes the table to the given max size, removing old entries as per section 4.4 if necessary.
@param int|null $maxSize | [
"Resizes",
"the",
"table",
"to",
"the",
"given",
"max",
"size",
"removing",
"old",
"entries",
"as",
"per",
"section",
"4",
".",
"4",
"if",
"necessary",
"."
] | f6f95e015baa54aa3c0fdbe3ad142fbd18a835e6 | https://github.com/amphp/hpack/blob/f6f95e015baa54aa3c0fdbe3ad142fbd18a835e6/src/HPack.php#L366-L375 | train |
ynloultratech/graphql-bundle | src/Schema/SchemaSnapshot.php | SchemaSnapshot.collapseType | private function collapseType(array $originDefinition): ?array
{
$definition = [];
if ($type = $originDefinition['type'] ?? null) {
$typeName = $type['name'];
if (!empty($type['ofType'] ?? [])) {
$typeName = $type['ofType']['name'];
$ofType = $type;
if (in_array($ofType['kind'], ['NON_NULL', 'LIST'])) {
$typeName = '%s';
while ($ofType) {
if ($ofType['kind'] === 'NON_NULL') {
$typeName = str_replace('%s', '%s!', $typeName);
} elseif ($ofType['kind'] === 'LIST') {
$typeName = str_replace('%s', '[%s]', $typeName);
} else {
$typeName = sprintf($typeName, $ofType['name']);
break;
}
$ofType = $ofType['ofType'] ?? null;
}
}
}
$definition['type'] = $typeName;
}
if ($fields = $originDefinition['fields'] ?? null) {
foreach ($fields as $field) {
$definition['fields'][$field['name']] = $this->collapseType($field);
}
}
if ($inputFields = $originDefinition['inputFields'] ?? null) {
foreach ($inputFields as $inputField) {
$definition['inputFields'][$inputField['name']] = $this->collapseType($inputField);
}
}
if ($args = $originDefinition['args'] ?? null) {
foreach ($args as $arg) {
$definition['args'][$arg['name']] = $this->collapseType($arg);
}
}
if ($possibleTypes = $originDefinition['possibleTypes'] ?? null) {
foreach ($possibleTypes as $possibleType) {
$definition['possibleTypes'][$possibleType['name']] = $this->collapseType($possibleType);
}
}
if ($interfaces = $originDefinition['interfaces'] ?? null) {
foreach ($interfaces as $interface) {
$definition['interfaces'][] = $interface['name'];
}
}
if ($enumValues = $originDefinition['enumValues'] ?? null) {
foreach ($enumValues as $enumValue) {
$definition['enumValues'][] = $enumValue['name'];
}
}
return empty($definition) ? null : $definition;
} | php | private function collapseType(array $originDefinition): ?array
{
$definition = [];
if ($type = $originDefinition['type'] ?? null) {
$typeName = $type['name'];
if (!empty($type['ofType'] ?? [])) {
$typeName = $type['ofType']['name'];
$ofType = $type;
if (in_array($ofType['kind'], ['NON_NULL', 'LIST'])) {
$typeName = '%s';
while ($ofType) {
if ($ofType['kind'] === 'NON_NULL') {
$typeName = str_replace('%s', '%s!', $typeName);
} elseif ($ofType['kind'] === 'LIST') {
$typeName = str_replace('%s', '[%s]', $typeName);
} else {
$typeName = sprintf($typeName, $ofType['name']);
break;
}
$ofType = $ofType['ofType'] ?? null;
}
}
}
$definition['type'] = $typeName;
}
if ($fields = $originDefinition['fields'] ?? null) {
foreach ($fields as $field) {
$definition['fields'][$field['name']] = $this->collapseType($field);
}
}
if ($inputFields = $originDefinition['inputFields'] ?? null) {
foreach ($inputFields as $inputField) {
$definition['inputFields'][$inputField['name']] = $this->collapseType($inputField);
}
}
if ($args = $originDefinition['args'] ?? null) {
foreach ($args as $arg) {
$definition['args'][$arg['name']] = $this->collapseType($arg);
}
}
if ($possibleTypes = $originDefinition['possibleTypes'] ?? null) {
foreach ($possibleTypes as $possibleType) {
$definition['possibleTypes'][$possibleType['name']] = $this->collapseType($possibleType);
}
}
if ($interfaces = $originDefinition['interfaces'] ?? null) {
foreach ($interfaces as $interface) {
$definition['interfaces'][] = $interface['name'];
}
}
if ($enumValues = $originDefinition['enumValues'] ?? null) {
foreach ($enumValues as $enumValue) {
$definition['enumValues'][] = $enumValue['name'];
}
}
return empty($definition) ? null : $definition;
} | [
"private",
"function",
"collapseType",
"(",
"array",
"$",
"originDefinition",
")",
":",
"?",
"array",
"{",
"$",
"definition",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"type",
"=",
"$",
"originDefinition",
"[",
"'type'",
"]",
"??",
"null",
")",
"{",
"$",
"... | Collapse type definition
@param array $originDefinition
@return array|null | [
"Collapse",
"type",
"definition"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Schema/SchemaSnapshot.php#L183-L247 | train |
ekyna/Dpd | src/AbstractInput.php | AbstractInput.getDefinition | protected function getDefinition(): Definition
{
if (isset(self::$definitions[static::class])) {
return self::$definitions[static::class];
}
$definition = new Definition();
$this->buildDefinition($definition);
return self::$definitions[static::class] = $definition;
} | php | protected function getDefinition(): Definition
{
if (isset(self::$definitions[static::class])) {
return self::$definitions[static::class];
}
$definition = new Definition();
$this->buildDefinition($definition);
return self::$definitions[static::class] = $definition;
} | [
"protected",
"function",
"getDefinition",
"(",
")",
":",
"Definition",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"definitions",
"[",
"static",
"::",
"class",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"definitions",
"[",
"static",
"::",
"c... | Returns the definition.
@return Definition | [
"Returns",
"the",
"definition",
"."
] | 67eabcff840b310021d5ca7ebb824fa7d7cb700b | https://github.com/ekyna/Dpd/blob/67eabcff840b310021d5ca7ebb824fa7d7cb700b/src/AbstractInput.php#L105-L116 | train |
ynloultratech/graphql-bundle | src/Mutation/AbstractMutationResolver.php | AbstractMutationResolver.publicPropertyPath | private function publicPropertyPath(FormInterface $form, $path)
{
$pathArray = [$path];
if (strpos($path, '.') !== false) { // object.child.property
$pathArray = explode('.', $path);
}
if (strpos($path, '[') !== false) { //[array][child][property]
$path = str_replace(']', null, $path);
$pathArray = explode('[', $path);
}
if (in_array($pathArray[0], ['data', 'children'])) {
array_shift($pathArray);
}
$contextForm = $form;
foreach ($pathArray as &$propName) {
//for some reason some inputs are resolved as "inputName.data" or "inputName.children"
//because the original form property is children[inputName].data
//this is the case of DEMO AddUserInput form the login field is validated as path children[login].data
//the following statements remove the trailing ".data"
if (preg_match('/\.(data|children)$/', $propName)) {
$propName = preg_replace('/\.(data|children)/', null, $propName);
}
$index = null;
if (preg_match('/(\w+)(\[\d+\])$/', $propName, $matches)) {
list(, $propName, $index) = $matches;
}
if (!$contextForm->has($propName)) {
foreach ($contextForm->all() as $child) {
if ($child->getConfig()->getOption('property_path') === $propName) {
$propName = $child->getName();
}
}
}
if ($index) {
$propName = sprintf('%s%s', $propName, $index);
}
}
unset($propName);
return implode('.', $pathArray);
} | php | private function publicPropertyPath(FormInterface $form, $path)
{
$pathArray = [$path];
if (strpos($path, '.') !== false) { // object.child.property
$pathArray = explode('.', $path);
}
if (strpos($path, '[') !== false) { //[array][child][property]
$path = str_replace(']', null, $path);
$pathArray = explode('[', $path);
}
if (in_array($pathArray[0], ['data', 'children'])) {
array_shift($pathArray);
}
$contextForm = $form;
foreach ($pathArray as &$propName) {
//for some reason some inputs are resolved as "inputName.data" or "inputName.children"
//because the original form property is children[inputName].data
//this is the case of DEMO AddUserInput form the login field is validated as path children[login].data
//the following statements remove the trailing ".data"
if (preg_match('/\.(data|children)$/', $propName)) {
$propName = preg_replace('/\.(data|children)/', null, $propName);
}
$index = null;
if (preg_match('/(\w+)(\[\d+\])$/', $propName, $matches)) {
list(, $propName, $index) = $matches;
}
if (!$contextForm->has($propName)) {
foreach ($contextForm->all() as $child) {
if ($child->getConfig()->getOption('property_path') === $propName) {
$propName = $child->getName();
}
}
}
if ($index) {
$propName = sprintf('%s%s', $propName, $index);
}
}
unset($propName);
return implode('.', $pathArray);
} | [
"private",
"function",
"publicPropertyPath",
"(",
"FormInterface",
"$",
"form",
",",
"$",
"path",
")",
"{",
"$",
"pathArray",
"=",
"[",
"$",
"path",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"path",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"// objec... | Convert internal validation property path to the public one,
required when use `property_path` in the form
@param FormInterface $form
@param string $path
@return string | [
"Convert",
"internal",
"validation",
"property",
"path",
"to",
"the",
"public",
"one",
"required",
"when",
"use",
"property_path",
"in",
"the",
"form"
] | 390aa1ca77cf00ae02688839ea4fca1026954501 | https://github.com/ynloultratech/graphql-bundle/blob/390aa1ca77cf00ae02688839ea4fca1026954501/src/Mutation/AbstractMutationResolver.php#L306-L351 | train |
orchestral/control | src/Processor/Role.php | Role.index | public function index($listener)
{
$eloquent = $this->model->newQuery();
$table = $this->presenter->table($eloquent);
$this->fireEvent('list', [$eloquent, $table]);
// Once all event listening to `orchestra.list: role` is executed,
// we can add we can now add the final column, edit and delete
// action for roles.
$this->presenter->actions($table);
return $listener->indexSucceed(compact('eloquent', 'table'));
} | php | public function index($listener)
{
$eloquent = $this->model->newQuery();
$table = $this->presenter->table($eloquent);
$this->fireEvent('list', [$eloquent, $table]);
// Once all event listening to `orchestra.list: role` is executed,
// we can add we can now add the final column, edit and delete
// action for roles.
$this->presenter->actions($table);
return $listener->indexSucceed(compact('eloquent', 'table'));
} | [
"public",
"function",
"index",
"(",
"$",
"listener",
")",
"{",
"$",
"eloquent",
"=",
"$",
"this",
"->",
"model",
"->",
"newQuery",
"(",
")",
";",
"$",
"table",
"=",
"$",
"this",
"->",
"presenter",
"->",
"table",
"(",
"$",
"eloquent",
")",
";",
"$",... | View list roles page.
@param object $listener
@return mixed | [
"View",
"list",
"roles",
"page",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Role.php#L37-L50 | train |
orchestral/control | src/Processor/Role.php | Role.edit | public function edit($listener, $id)
{
$eloquent = $this->model->findOrFail($id);
$form = $this->presenter->form($eloquent);
$this->fireEvent('form', [$eloquent, $form]);
return $listener->editSucceed(compact('eloquent', 'form'));
} | php | public function edit($listener, $id)
{
$eloquent = $this->model->findOrFail($id);
$form = $this->presenter->form($eloquent);
$this->fireEvent('form', [$eloquent, $form]);
return $listener->editSucceed(compact('eloquent', 'form'));
} | [
"public",
"function",
"edit",
"(",
"$",
"listener",
",",
"$",
"id",
")",
"{",
"$",
"eloquent",
"=",
"$",
"this",
"->",
"model",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"presenter",
"->",
"form",
"(",
"$"... | View edit a role page.
@param object $listener
@param string|int $id
@return mixed | [
"View",
"edit",
"a",
"role",
"page",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Role.php#L77-L85 | train |
orchestral/control | src/Processor/Role.php | Role.store | public function store($listener, array $input)
{
$validation = $this->validator->on('create')->with($input);
if ($validation->fails()) {
return $listener->storeValidationFailed($validation);
}
$role = $this->model;
try {
$this->saving($role, $input, 'create');
} catch (Exception $e) {
return $listener->storeFailed(['error' => $e->getMessage()]);
}
return $listener->storeSucceed($role);
} | php | public function store($listener, array $input)
{
$validation = $this->validator->on('create')->with($input);
if ($validation->fails()) {
return $listener->storeValidationFailed($validation);
}
$role = $this->model;
try {
$this->saving($role, $input, 'create');
} catch (Exception $e) {
return $listener->storeFailed(['error' => $e->getMessage()]);
}
return $listener->storeSucceed($role);
} | [
"public",
"function",
"store",
"(",
"$",
"listener",
",",
"array",
"$",
"input",
")",
"{",
"$",
"validation",
"=",
"$",
"this",
"->",
"validator",
"->",
"on",
"(",
"'create'",
")",
"->",
"with",
"(",
"$",
"input",
")",
";",
"if",
"(",
"$",
"validat... | Store a role.
@param object $listener
@param array $input
@return mixed | [
"Store",
"a",
"role",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Role.php#L95-L112 | train |
orchestral/control | src/Processor/Role.php | Role.update | public function update($listener, array $input, $id)
{
if ((int) $id !== (int) $input['id']) {
return $listener->userVerificationFailed();
}
$validation = $this->validator->on('update')->bind(['roleID' => $id])->with($input);
if ($validation->fails()) {
return $listener->updateValidationFailed($validation, $id);
}
$role = $this->model->findOrFail($id);
try {
$this->saving($role, $input, 'update');
} catch (Exception $e) {
return $listener->updateFailed(['error' => $e->getMessage()]);
}
return $listener->updateSucceed($role);
} | php | public function update($listener, array $input, $id)
{
if ((int) $id !== (int) $input['id']) {
return $listener->userVerificationFailed();
}
$validation = $this->validator->on('update')->bind(['roleID' => $id])->with($input);
if ($validation->fails()) {
return $listener->updateValidationFailed($validation, $id);
}
$role = $this->model->findOrFail($id);
try {
$this->saving($role, $input, 'update');
} catch (Exception $e) {
return $listener->updateFailed(['error' => $e->getMessage()]);
}
return $listener->updateSucceed($role);
} | [
"public",
"function",
"update",
"(",
"$",
"listener",
",",
"array",
"$",
"input",
",",
"$",
"id",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"id",
"!==",
"(",
"int",
")",
"$",
"input",
"[",
"'id'",
"]",
")",
"{",
"return",
"$",
"listener",
"->"... | Update a role.
@param object $listener
@param array $input
@param int $id
@return mixed | [
"Update",
"a",
"role",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Role.php#L123-L144 | train |
orchestral/control | src/Processor/Role.php | Role.destroy | public function destroy($listener, $id)
{
$role = $this->model->findOrFail($id);
try {
DB::transaction(function () use ($role) {
$role->delete();
});
} catch (Exception $e) {
return $listener->destroyFailed(['error' => $e->getMessage()]);
}
return $listener->destroySucceed($role);
} | php | public function destroy($listener, $id)
{
$role = $this->model->findOrFail($id);
try {
DB::transaction(function () use ($role) {
$role->delete();
});
} catch (Exception $e) {
return $listener->destroyFailed(['error' => $e->getMessage()]);
}
return $listener->destroySucceed($role);
} | [
"public",
"function",
"destroy",
"(",
"$",
"listener",
",",
"$",
"id",
")",
"{",
"$",
"role",
"=",
"$",
"this",
"->",
"model",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"try",
"{",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
... | Delete a role.
@param object $listener
@param string|int $id
@return mixed | [
"Delete",
"a",
"role",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Role.php#L154-L167 | train |
orchestral/control | src/Processor/Role.php | Role.saving | protected function saving(Eloquent $role, $input = [], $type = 'create')
{
$beforeEvent = ($type === 'create' ? 'creating' : 'updating');
$afterEvent = ($type === 'create' ? 'created' : 'updated');
$role->setAttribute('name', $input['name']);
$this->fireEvent($beforeEvent, [$role]);
$this->fireEvent('saving', [$role]);
DB::transaction(function () use ($role) {
$role->save();
});
$this->fireEvent($afterEvent, [$role]);
$this->fireEvent('saved', [$role]);
return true;
} | php | protected function saving(Eloquent $role, $input = [], $type = 'create')
{
$beforeEvent = ($type === 'create' ? 'creating' : 'updating');
$afterEvent = ($type === 'create' ? 'created' : 'updated');
$role->setAttribute('name', $input['name']);
$this->fireEvent($beforeEvent, [$role]);
$this->fireEvent('saving', [$role]);
DB::transaction(function () use ($role) {
$role->save();
});
$this->fireEvent($afterEvent, [$role]);
$this->fireEvent('saved', [$role]);
return true;
} | [
"protected",
"function",
"saving",
"(",
"Eloquent",
"$",
"role",
",",
"$",
"input",
"=",
"[",
"]",
",",
"$",
"type",
"=",
"'create'",
")",
"{",
"$",
"beforeEvent",
"=",
"(",
"$",
"type",
"===",
"'create'",
"?",
"'creating'",
":",
"'updating'",
")",
"... | Save the role.
@param \Orchestra\Model\Role $role
@param array $input
@param string $type
@return bool | [
"Save",
"the",
"role",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Role.php#L178-L196 | train |
PlasmaPHP/core | src/StreamQueryResult.php | StreamQueryResult.all | function all(): \React\Promise\PromiseInterface {
return \React\Promise\Stream\all($this)->then(function (array $rows) {
return (new \Plasma\QueryResult($this->affectedRows, $this->warningsCount, $this->insertID, $this->columns, $rows));
});
} | php | function all(): \React\Promise\PromiseInterface {
return \React\Promise\Stream\all($this)->then(function (array $rows) {
return (new \Plasma\QueryResult($this->affectedRows, $this->warningsCount, $this->insertID, $this->columns, $rows));
});
} | [
"function",
"all",
"(",
")",
":",
"\\",
"React",
"\\",
"Promise",
"\\",
"PromiseInterface",
"{",
"return",
"\\",
"React",
"\\",
"Promise",
"\\",
"Stream",
"\\",
"all",
"(",
"$",
"this",
")",
"->",
"then",
"(",
"function",
"(",
"array",
"$",
"rows",
"... | Buffers all rows and returns a promise which resolves with an instance of `QueryResultInterface`.
This method does not guarantee that all rows get returned, as the buffering depends on when this
method gets invoked. There's no automatic buffering, as such rows may be missing if invoked too late.
@return \React\Promise\PromiseInterface | [
"Buffers",
"all",
"rows",
"and",
"returns",
"a",
"promise",
"which",
"resolves",
"with",
"an",
"instance",
"of",
"QueryResultInterface",
".",
"This",
"method",
"does",
"not",
"guarantee",
"that",
"all",
"rows",
"get",
"returned",
"as",
"the",
"buffering",
"dep... | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/StreamQueryResult.php#L153-L157 | train |
PlasmaPHP/core | src/StreamQueryResult.php | StreamQueryResult.pause | function pause() {
$this->paused = true;
if($this->started && !$this->closed) {
$this->driver->pauseStreamConsumption();
}
} | php | function pause() {
$this->paused = true;
if($this->started && !$this->closed) {
$this->driver->pauseStreamConsumption();
}
} | [
"function",
"pause",
"(",
")",
"{",
"$",
"this",
"->",
"paused",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"started",
"&&",
"!",
"$",
"this",
"->",
"closed",
")",
"{",
"$",
"this",
"->",
"driver",
"->",
"pauseStreamConsumption",
"(",
")",
";"... | Pauses the connection, where this stream is coming from.
This operation halts ALL read activities. You may still receive
`data` events until the underlying network buffer is drained.
@return void | [
"Pauses",
"the",
"connection",
"where",
"this",
"stream",
"is",
"coming",
"from",
".",
"This",
"operation",
"halts",
"ALL",
"read",
"activities",
".",
"You",
"may",
"still",
"receive",
"data",
"events",
"until",
"the",
"underlying",
"network",
"buffer",
"is",
... | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/StreamQueryResult.php#L173-L179 | train |
PlasmaPHP/core | src/StreamQueryResult.php | StreamQueryResult.resume | function resume() {
$this->paused = false;
if($this->started && !$this->closed) {
$this->driver->resumeStreamConsumption();
}
} | php | function resume() {
$this->paused = false;
if($this->started && !$this->closed) {
$this->driver->resumeStreamConsumption();
}
} | [
"function",
"resume",
"(",
")",
"{",
"$",
"this",
"->",
"paused",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"started",
"&&",
"!",
"$",
"this",
"->",
"closed",
")",
"{",
"$",
"this",
"->",
"driver",
"->",
"resumeStreamConsumption",
"(",
")",
... | Resumes the connection, where this stream is coming from.
@return void | [
"Resumes",
"the",
"connection",
"where",
"this",
"stream",
"is",
"coming",
"from",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/StreamQueryResult.php#L185-L191 | train |
PlasmaPHP/core | src/StreamQueryResult.php | StreamQueryResult.close | function close() {
if($this->closed) {
return;
}
$this->closed = true;
if($this->started && $this->paused) {
$this->driver->resumeStreamConsumption();
}
$this->emit('close');
$this->removeAllListeners();
} | php | function close() {
if($this->closed) {
return;
}
$this->closed = true;
if($this->started && $this->paused) {
$this->driver->resumeStreamConsumption();
}
$this->emit('close');
$this->removeAllListeners();
} | [
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"closed",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"started",
"&&",
"$",
"this",
"->",
"paused",
")",
"{",
"$",
... | Closes the stream. Resumes the connection stream.
@return void | [
"Closes",
"the",
"stream",
".",
"Resumes",
"the",
"connection",
"stream",
"."
] | ce9b1a206e3777f3cf884eec5eee686a073ddfb2 | https://github.com/PlasmaPHP/core/blob/ce9b1a206e3777f3cf884eec5eee686a073ddfb2/src/StreamQueryResult.php#L197-L209 | train |
orchestral/control | src/Processor/Authorization.php | Authorization.edit | public function edit($listener, $metric)
{
$collection = [];
$instances = $this->acl->all();
$eloquent = null;
foreach ($instances as $name => $instance) {
$collection[$name] = (string) $this->getAuthorizationName($name);
$name === $metric && $eloquent = $instance;
}
if (is_null($eloquent)) {
return $listener->aclVerificationFailed();
}
$actions = $this->getAuthorizationActions($eloquent, $metric);
$roles = $this->getAuthorizationRoles($eloquent);
return $listener->indexSucceed(compact('actions', 'roles', 'eloquent', 'collection', 'metric'));
} | php | public function edit($listener, $metric)
{
$collection = [];
$instances = $this->acl->all();
$eloquent = null;
foreach ($instances as $name => $instance) {
$collection[$name] = (string) $this->getAuthorizationName($name);
$name === $metric && $eloquent = $instance;
}
if (is_null($eloquent)) {
return $listener->aclVerificationFailed();
}
$actions = $this->getAuthorizationActions($eloquent, $metric);
$roles = $this->getAuthorizationRoles($eloquent);
return $listener->indexSucceed(compact('actions', 'roles', 'eloquent', 'collection', 'metric'));
} | [
"public",
"function",
"edit",
"(",
"$",
"listener",
",",
"$",
"metric",
")",
"{",
"$",
"collection",
"=",
"[",
"]",
";",
"$",
"instances",
"=",
"$",
"this",
"->",
"acl",
"->",
"all",
"(",
")",
";",
"$",
"eloquent",
"=",
"null",
";",
"foreach",
"(... | List ACL collection.
@param object $listener
@param string $metric
@return mixed | [
"List",
"ACL",
"collection",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Authorization.php#L51-L71 | train |
orchestral/control | src/Processor/Authorization.php | Authorization.update | public function update($listener, array $input)
{
$metric = $input['metric'];
$acl = $this->acl->get($metric);
if (is_null($acl)) {
return $listener->aclVerificationFailed();
}
$roles = $acl->roles()->get();
$actions = $acl->actions()->get();
foreach ($roles as $roleKey => $roleName) {
foreach ($actions as $actionKey => $actionName) {
$value = ('yes' === Arr::get($input, "acl-{$roleKey}-{$actionKey}", 'no'));
$acl->allow($roleName, $actionName, $value);
}
}
return $listener->updateSucceed($metric);
} | php | public function update($listener, array $input)
{
$metric = $input['metric'];
$acl = $this->acl->get($metric);
if (is_null($acl)) {
return $listener->aclVerificationFailed();
}
$roles = $acl->roles()->get();
$actions = $acl->actions()->get();
foreach ($roles as $roleKey => $roleName) {
foreach ($actions as $actionKey => $actionName) {
$value = ('yes' === Arr::get($input, "acl-{$roleKey}-{$actionKey}", 'no'));
$acl->allow($roleName, $actionName, $value);
}
}
return $listener->updateSucceed($metric);
} | [
"public",
"function",
"update",
"(",
"$",
"listener",
",",
"array",
"$",
"input",
")",
"{",
"$",
"metric",
"=",
"$",
"input",
"[",
"'metric'",
"]",
";",
"$",
"acl",
"=",
"$",
"this",
"->",
"acl",
"->",
"get",
"(",
"$",
"metric",
")",
";",
"if",
... | Update ACL metric.
@param object $listener
@param array $input
@return mixed | [
"Update",
"ACL",
"metric",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Authorization.php#L81-L102 | train |
orchestral/control | src/Processor/Authorization.php | Authorization.sync | public function sync($listener, $vendor, $package = null)
{
$roles = [];
$name = $this->getExtension($vendor, $package)->get('name');
$acl = $this->acl->get($name);
if (is_null($acl)) {
return $listener->aclVerificationFailed();
}
foreach ($this->model->all() as $role) {
$roles[] = $role->name;
}
$acl->roles()->attach($roles);
$acl->sync();
return $listener->syncSucceed(new Fluent(compact('vendor', 'package', 'name')));
} | php | public function sync($listener, $vendor, $package = null)
{
$roles = [];
$name = $this->getExtension($vendor, $package)->get('name');
$acl = $this->acl->get($name);
if (is_null($acl)) {
return $listener->aclVerificationFailed();
}
foreach ($this->model->all() as $role) {
$roles[] = $role->name;
}
$acl->roles()->attach($roles);
$acl->sync();
return $listener->syncSucceed(new Fluent(compact('vendor', 'package', 'name')));
} | [
"public",
"function",
"sync",
"(",
"$",
"listener",
",",
"$",
"vendor",
",",
"$",
"package",
"=",
"null",
")",
"{",
"$",
"roles",
"=",
"[",
"]",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"getExtension",
"(",
"$",
"vendor",
",",
"$",
"package",
")... | Sync role for an ACL instance.
@param object $listener
@param string $vendor
@param string|null $package
@return mixed | [
"Sync",
"role",
"for",
"an",
"ACL",
"instance",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Authorization.php#L113-L132 | train |
orchestral/control | src/Processor/Authorization.php | Authorization.getAuthorizationActions | protected function getAuthorizationActions(AuthorizationContract $acl, $metric)
{
return collect($acl->actions()->get())->map(function ($slug) use ($metric) {
$key = "orchestra/foundation::acl.{$metric}.{$slug}";
$name = $this->translator->has($key) ? $this->translator->get($key) : Str::humanize($slug);
return compact('slug', 'name');
});
} | php | protected function getAuthorizationActions(AuthorizationContract $acl, $metric)
{
return collect($acl->actions()->get())->map(function ($slug) use ($metric) {
$key = "orchestra/foundation::acl.{$metric}.{$slug}";
$name = $this->translator->has($key) ? $this->translator->get($key) : Str::humanize($slug);
return compact('slug', 'name');
});
} | [
"protected",
"function",
"getAuthorizationActions",
"(",
"AuthorizationContract",
"$",
"acl",
",",
"$",
"metric",
")",
"{",
"return",
"collect",
"(",
"$",
"acl",
"->",
"actions",
"(",
")",
"->",
"get",
"(",
")",
")",
"->",
"map",
"(",
"function",
"(",
"$... | Get authorization actions.
@param \Orchestra\Contracts\Authorization\Authorization $acl
@param string $metric
@return \Illuminate\Support\Collection | [
"Get",
"authorization",
"actions",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Authorization.php#L157-L165 | train |
orchestral/control | src/Processor/Authorization.php | Authorization.getAuthorizationRoles | protected function getAuthorizationRoles(AuthorizationContract $acl)
{
return collect($acl->roles()->get())->reject(function ($role) {
return in_array($role, ['guest']);
})->map(function ($slug) {
$name = Str::humanize($slug);
return compact('slug', 'name');
});
} | php | protected function getAuthorizationRoles(AuthorizationContract $acl)
{
return collect($acl->roles()->get())->reject(function ($role) {
return in_array($role, ['guest']);
})->map(function ($slug) {
$name = Str::humanize($slug);
return compact('slug', 'name');
});
} | [
"protected",
"function",
"getAuthorizationRoles",
"(",
"AuthorizationContract",
"$",
"acl",
")",
"{",
"return",
"collect",
"(",
"$",
"acl",
"->",
"roles",
"(",
")",
"->",
"get",
"(",
")",
")",
"->",
"reject",
"(",
"function",
"(",
"$",
"role",
")",
"{",
... | Get authorization roles.
@param \Orchestra\Contracts\Authorization\Authorization $acl
@return \Illuminate\Support\Collection | [
"Get",
"authorization",
"roles",
"."
] | 7c23db19373adbb0fe44491af12f370ba6547d2a | https://github.com/orchestral/control/blob/7c23db19373adbb0fe44491af12f370ba6547d2a/src/Processor/Authorization.php#L174-L183 | train |
psbhanu/whatsapi | src/Media/VCard.php | VCard.download | function download()
{
if (!$this->card) {
$this->build();
}
if (!$this->filename) {
$this->filename = $this->data['display_name'];
}
$this->filename = str_replace(' ', '_', $this->filename);
header("Content-type: text/directory");
header("Content-Disposition: attachment; filename=" . $this->filename . ".vcf");
header("Pragma: public");
echo $this->card;
return true;
} | php | function download()
{
if (!$this->card) {
$this->build();
}
if (!$this->filename) {
$this->filename = $this->data['display_name'];
}
$this->filename = str_replace(' ', '_', $this->filename);
header("Content-type: text/directory");
header("Content-Disposition: attachment; filename=" . $this->filename . ".vcf");
header("Pragma: public");
echo $this->card;
return true;
} | [
"function",
"download",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"card",
")",
"{",
"$",
"this",
"->",
"build",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"filename",
")",
"{",
"$",
"this",
"->",
"filename",
"=",
"$",
"thi... | Streams the vcard to the browser client.
@return bool | [
"Streams",
"the",
"vcard",
"to",
"the",
"browser",
"client",
"."
] | be34f35bb5e0fd3c6f2196260865bef65c1240c2 | https://github.com/psbhanu/whatsapi/blob/be34f35bb5e0fd3c6f2196260865bef65c1240c2/src/Media/VCard.php#L232-L250 | train |
contao-community-alliance/translator | src/AbstractTranslator.php | AbstractTranslator.buildChoiceLookupList | protected function buildChoiceLookupList($choices)
{
$array = array();
foreach ($choices as $range => $choice) {
$range = explode(':', $range);
if (count($range) < 2) {
$range[] = '';
}
$array[] = (object) array(
'range' => (object) array(
'from' => $range[0],
'to' => $range[1],
),
'string' => $choice
);
}
return $array;
} | php | protected function buildChoiceLookupList($choices)
{
$array = array();
foreach ($choices as $range => $choice) {
$range = explode(':', $range);
if (count($range) < 2) {
$range[] = '';
}
$array[] = (object) array(
'range' => (object) array(
'from' => $range[0],
'to' => $range[1],
),
'string' => $choice
);
}
return $array;
} | [
"protected",
"function",
"buildChoiceLookupList",
"(",
"$",
"choices",
")",
"{",
"$",
"array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"choices",
"as",
"$",
"range",
"=>",
"$",
"choice",
")",
"{",
"$",
"range",
"=",
"explode",
"(",
"':'",
"... | Build a choice lookup list from the passed language choice array.
The input array is something like:
array(
'1' => 'an apple',
'2:5' => 'a few apples',
'12' => 'a dozen of apples',
'13:' => 'a pile of apples'
)
@param array $choices The language strings.
@return array | [
"Build",
"a",
"choice",
"lookup",
"list",
"from",
"the",
"passed",
"language",
"choice",
"array",
"."
] | daa920897510c10ee400b29c83840a866c17623a | https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/AbstractTranslator.php#L105-L126 | train |
contao-community-alliance/translator | src/AbstractTranslator.php | AbstractTranslator.fetchChoice | protected function fetchChoice($choices, $index, $count)
{
$choice = $choices[$index];
// Set from number, if not set (notation ":X").
if (!$choice->range->from) {
if ($index > 0) {
$choice->range->from = ($choices[($index - 1)]->range->to + 1);
} else {
$choice->range->from = (-PHP_INT_MAX);
}
}
// Set to number, if not set (notation "X" or "X:").
if (!$choice->range->to) {
if ($index < ($count - 1)) {
$choice->range->to = ($choices[($index + 1)]->range->from - 1);
} else {
$choice->range->to = PHP_INT_MAX;
}
}
return $choice;
} | php | protected function fetchChoice($choices, $index, $count)
{
$choice = $choices[$index];
// Set from number, if not set (notation ":X").
if (!$choice->range->from) {
if ($index > 0) {
$choice->range->from = ($choices[($index - 1)]->range->to + 1);
} else {
$choice->range->from = (-PHP_INT_MAX);
}
}
// Set to number, if not set (notation "X" or "X:").
if (!$choice->range->to) {
if ($index < ($count - 1)) {
$choice->range->to = ($choices[($index + 1)]->range->from - 1);
} else {
$choice->range->to = PHP_INT_MAX;
}
}
return $choice;
} | [
"protected",
"function",
"fetchChoice",
"(",
"$",
"choices",
",",
"$",
"index",
",",
"$",
"count",
")",
"{",
"$",
"choice",
"=",
"$",
"choices",
"[",
"$",
"index",
"]",
";",
"// Set from number, if not set (notation \":X\").",
"if",
"(",
"!",
"$",
"choice",
... | Extract a single choice from the array of choices and sanitize its values.
@param array $choices The choice array.
@param int $index The index to extract.
@param int $count Amount of all choices in the array (passed to prevent calling count() multiple times).
@return object | [
"Extract",
"a",
"single",
"choice",
"from",
"the",
"array",
"of",
"choices",
"and",
"sanitize",
"its",
"values",
"."
] | daa920897510c10ee400b29c83840a866c17623a | https://github.com/contao-community-alliance/translator/blob/daa920897510c10ee400b29c83840a866c17623a/src/AbstractTranslator.php#L139-L161 | train |
tlapnet/report | src/Utils/DateTime.php | DateTime.from | public static function from($time): self
{
if ($time instanceof DateTimeInterface) {
return new static($time->format('Y-m-d H:i:s'), $time->getTimezone());
} elseif (is_numeric($time)) {
return (new static('@' . $time))
->setTimezone(new DateTimeZone(date_default_timezone_get()));
} else {
return new static($time);
}
} | php | public static function from($time): self
{
if ($time instanceof DateTimeInterface) {
return new static($time->format('Y-m-d H:i:s'), $time->getTimezone());
} elseif (is_numeric($time)) {
return (new static('@' . $time))
->setTimezone(new DateTimeZone(date_default_timezone_get()));
} else {
return new static($time);
}
} | [
"public",
"static",
"function",
"from",
"(",
"$",
"time",
")",
":",
"self",
"{",
"if",
"(",
"$",
"time",
"instanceof",
"DateTimeInterface",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"time",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
",",
"$",
"tim... | DateTime object factory.
@param string|int|DateTimeInterface $time | [
"DateTime",
"object",
"factory",
"."
] | 6852caf0d78422888795432242128d9ce6c491e2 | https://github.com/tlapnet/report/blob/6852caf0d78422888795432242128d9ce6c491e2/src/Utils/DateTime.php#L45-L57 | train |
figdice/figdice | src/figdice/classes/functions/Function_range.php | Function_range.evaluate | public function evaluate(Context $context, $arity, $arguments) {
$rangeSize = intval($arguments[0]);
$result = array();
for ($i = 1; $i <= $rangeSize; ++ $i) {
$result []= $i;
}
return $result;
} | php | public function evaluate(Context $context, $arity, $arguments) {
$rangeSize = intval($arguments[0]);
$result = array();
for ($i = 1; $i <= $rangeSize; ++ $i) {
$result []= $i;
}
return $result;
} | [
"public",
"function",
"evaluate",
"(",
"Context",
"$",
"context",
",",
"$",
"arity",
",",
"$",
"arguments",
")",
"{",
"$",
"rangeSize",
"=",
"intval",
"(",
"$",
"arguments",
"[",
"0",
"]",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"for"... | This function returns an array of N elements, from 1 to N.
It is useful for creating small "for" loops in your views.
@param Context $context
@param integer $arity
@param array $arguments one element: Size of the 1..N array
@return array|mixed | [
"This",
"function",
"returns",
"an",
"array",
"of",
"N",
"elements",
"from",
"1",
"to",
"N",
".",
"It",
"is",
"useful",
"for",
"creating",
"small",
"for",
"loops",
"in",
"your",
"views",
"."
] | 896bbe3aec365c416e368dcc6b888a6cf1832afc | https://github.com/figdice/figdice/blob/896bbe3aec365c416e368dcc6b888a6cf1832afc/src/figdice/classes/functions/Function_range.php#L28-L38 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/nusoap.php | soap_transport_http.sendHTTPS | function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies = NULL) {
return $this->send($data, $timeout, $response_timeout, $cookies);
} | php | function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies = NULL) {
return $this->send($data, $timeout, $response_timeout, $cookies);
} | [
"function",
"sendHTTPS",
"(",
"$",
"data",
",",
"$",
"timeout",
"=",
"0",
",",
"$",
"response_timeout",
"=",
"30",
",",
"$",
"cookies",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"send",
"(",
"$",
"data",
",",
"$",
"timeout",
",",
"$",
"... | sends the SOAP request and gets the SOAP response via HTTPS using CURL
@param string $data message data
@param integer $timeout set connection timeout in seconds
@param integer $response_timeout set response timeout in seconds
@param array $cookies cookies to send
@return string data
@access public
@deprecated | [
"sends",
"the",
"SOAP",
"request",
"and",
"gets",
"the",
"SOAP",
"response",
"via",
"HTTPS",
"using",
"CURL"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/nusoap.php#L2618-L2620 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/nusoap.php | nusoap_parser.decodeSimple | function decodeSimple($value, $type, $typens) {
// TODO: use the namespace!
if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
return (string) $value;
}
if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
return (int) $value;
}
if ($type == 'float' || $type == 'double' || $type == 'decimal') {
return (double) $value;
}
if ($type == 'boolean') {
if (strtolower($value) == 'false' || strtolower($value) == 'f') {
return false;
}
return (boolean) $value;
}
if ($type == 'base64' || $type == 'base64Binary') {
$this->debug('Decode base64 value');
return base64_decode($value);
}
// obscure numeric types
if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
|| $type == 'nonNegativeInteger' || $type == 'positiveInteger'
|| $type == 'unsignedInt'
|| $type == 'unsignedShort' || $type == 'unsignedByte') {
return (int) $value;
}
// bogus: parser treats array with no elements as a simple type
if ($type == 'array') {
return array();
}
// everything else
return (string) $value;
} | php | function decodeSimple($value, $type, $typens) {
// TODO: use the namespace!
if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
return (string) $value;
}
if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
return (int) $value;
}
if ($type == 'float' || $type == 'double' || $type == 'decimal') {
return (double) $value;
}
if ($type == 'boolean') {
if (strtolower($value) == 'false' || strtolower($value) == 'f') {
return false;
}
return (boolean) $value;
}
if ($type == 'base64' || $type == 'base64Binary') {
$this->debug('Decode base64 value');
return base64_decode($value);
}
// obscure numeric types
if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
|| $type == 'nonNegativeInteger' || $type == 'positiveInteger'
|| $type == 'unsignedInt'
|| $type == 'unsignedShort' || $type == 'unsignedByte') {
return (int) $value;
}
// bogus: parser treats array with no elements as a simple type
if ($type == 'array') {
return array();
}
// everything else
return (string) $value;
} | [
"function",
"decodeSimple",
"(",
"$",
"value",
",",
"$",
"type",
",",
"$",
"typens",
")",
"{",
"// TODO: use the namespace!\r",
"if",
"(",
"(",
"!",
"isset",
"(",
"$",
"type",
")",
")",
"||",
"$",
"type",
"==",
"'string'",
"||",
"$",
"type",
"==",
"'... | decodes simple types into PHP variables
@param string $value value to decode
@param string $type XML type to decode
@param string $typens XML type namespace to decode
@return mixed PHP value
@access private | [
"decodes",
"simple",
"types",
"into",
"PHP",
"variables"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/nusoap.php#L7011-L7045 | train |
mmoreram/SimpleDoctrineMapping | Configurator/LocatorConfigurator.php | LocatorConfigurator.configure | public function configure(SimpleDoctrineMappingLocator $locator)
{
$path = $locator->getPaths()[0];
$resourcePathExploded = explode('/', $path);
$resourcePathRoot = array_shift($resourcePathExploded);
if (strpos($resourcePathRoot, '@') === 0) {
$mappingFileBundle = ltrim($resourcePathRoot, '@');
$bundle = $this->kernel->getBundle($mappingFileBundle);
if ($bundle instanceof BundleInterface) {
$resourcePathRoot = $bundle->getPath();
}
}
array_unshift($resourcePathExploded, $resourcePathRoot);
$path = implode('/', $resourcePathExploded);
if (!file_exists($path)) {
throw new ConfigurationInvalidException('Mapping file "' . $path . '" does not exist');
}
$locator->setPaths([$path]);
} | php | public function configure(SimpleDoctrineMappingLocator $locator)
{
$path = $locator->getPaths()[0];
$resourcePathExploded = explode('/', $path);
$resourcePathRoot = array_shift($resourcePathExploded);
if (strpos($resourcePathRoot, '@') === 0) {
$mappingFileBundle = ltrim($resourcePathRoot, '@');
$bundle = $this->kernel->getBundle($mappingFileBundle);
if ($bundle instanceof BundleInterface) {
$resourcePathRoot = $bundle->getPath();
}
}
array_unshift($resourcePathExploded, $resourcePathRoot);
$path = implode('/', $resourcePathExploded);
if (!file_exists($path)) {
throw new ConfigurationInvalidException('Mapping file "' . $path . '" does not exist');
}
$locator->setPaths([$path]);
} | [
"public",
"function",
"configure",
"(",
"SimpleDoctrineMappingLocator",
"$",
"locator",
")",
"{",
"$",
"path",
"=",
"$",
"locator",
"->",
"getPaths",
"(",
")",
"[",
"0",
"]",
";",
"$",
"resourcePathExploded",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
... | If there is a parameter named like the driver locator path, replace it
with the value of such parameter.
@param SimpleDoctrineMappingLocator $locator Locator
@throws ConfigurationInvalidException Configuration invalid | [
"If",
"there",
"is",
"a",
"parameter",
"named",
"like",
"the",
"driver",
"locator",
"path",
"replace",
"it",
"with",
"the",
"value",
"of",
"such",
"parameter",
"."
] | 7b527eb4e4552fce600b094786d2f416948b1657 | https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/Configurator/LocatorConfigurator.php#L54-L79 | train |
BerliozFramework/Berlioz | src/Controller/Controller.php | Controller.getRoute | public function getRoute(): ?RouteInterface
{
if (!is_null($this->getApp())) {
return $this->getApp()->getService('routing')->getCurrentRoute();
}
return null;
} | php | public function getRoute(): ?RouteInterface
{
if (!is_null($this->getApp())) {
return $this->getApp()->getService('routing')->getCurrentRoute();
}
return null;
} | [
"public",
"function",
"getRoute",
"(",
")",
":",
"?",
"RouteInterface",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"getApp",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getApp",
"(",
")",
"->",
"getService",
"(",
"'routing'",
... | Get the Route object of the current path.
@return \Berlioz\Core\Services\Routing\RouteInterface|null
@throws \Berlioz\Core\Exception\RuntimeException if application not accessible | [
"Get",
"the",
"Route",
"object",
"of",
"the",
"current",
"path",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Controller/Controller.php#L105-L112 | train |
BerliozFramework/Berlioz | src/Controller/Controller.php | Controller.redirect | protected function redirect(string $url, int $httpResponseCode = 302): void
{
header('Location: ' . $url, true, $httpResponseCode);
exit;
} | php | protected function redirect(string $url, int $httpResponseCode = 302): void
{
header('Location: ' . $url, true, $httpResponseCode);
exit;
} | [
"protected",
"function",
"redirect",
"(",
"string",
"$",
"url",
",",
"int",
"$",
"httpResponseCode",
"=",
"302",
")",
":",
"void",
"{",
"header",
"(",
"'Location: '",
".",
"$",
"url",
",",
"true",
",",
"$",
"httpResponseCode",
")",
";",
"exit",
";",
"}... | Redirection to a specific URL.
@param string $url URL of redirection
@param int $httpResponseCode HTTP Redirection code (301, 302...)
@return void | [
"Redirection",
"to",
"a",
"specific",
"URL",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Controller/Controller.php#L122-L126 | train |
BerliozFramework/Berlioz | src/Controller/Controller.php | Controller.reload | protected function reload(array $get = [], bool $merge = false): void
{
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
// Query
{
$query = [];
if ($merge) {
parse_str(parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY), $query);
}
$query = array_merge($query, $get);
$queryString = http_build_query($query);
}
$this->redirect($path . (!empty($queryString) ? '?' . $queryString : ''));
} | php | protected function reload(array $get = [], bool $merge = false): void
{
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
// Query
{
$query = [];
if ($merge) {
parse_str(parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY), $query);
}
$query = array_merge($query, $get);
$queryString = http_build_query($query);
}
$this->redirect($path . (!empty($queryString) ? '?' . $queryString : ''));
} | [
"protected",
"function",
"reload",
"(",
"array",
"$",
"get",
"=",
"[",
"]",
",",
"bool",
"$",
"merge",
"=",
"false",
")",
":",
"void",
"{",
"$",
"path",
"=",
"parse_url",
"(",
"$",
"_SERVER",
"[",
"\"REQUEST_URI\"",
"]",
",",
"PHP_URL_PATH",
")",
";"... | Reload current page.
@param string[] $get Additional parameters for GET query string
@param bool $merge Merge parameters
@return void
@uses Controller::redirect() | [
"Reload",
"current",
"page",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Controller/Controller.php#L137-L154 | train |
BerliozFramework/Berlioz | src/Controller/Controller.php | Controller.render | protected function render(string $name, array $variables = []): string
{
$templateEngine = $this->getApp()->getService('templating');
return $templateEngine->render($name, $variables);
} | php | protected function render(string $name, array $variables = []): string
{
$templateEngine = $this->getApp()->getService('templating');
return $templateEngine->render($name, $variables);
} | [
"protected",
"function",
"render",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"templateEngine",
"=",
"$",
"this",
"->",
"getApp",
"(",
")",
"->",
"getService",
"(",
"'templating'",
")",
";",... | Do render of templates.
@param string $name Filename of template
@param mixed[] $variables Variables for template
@return string Output content
@throws \Berlioz\Core\Exception\RuntimeException if application not accessible
@see \Berlioz\Core\Services\Template\TemplateInterface | [
"Do",
"render",
"of",
"templates",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Controller/Controller.php#L181-L186 | train |
BerliozFramework/Berlioz | src/Controller/Controller.php | Controller.renderResponse | protected function renderResponse(string $name, array $variables = [], ResponseInterface $response = null): ResponseInterface
{
// Create new Response object if not given in parameter
if (is_null($response)) {
$response = new Response;
}
// Remove all headers
header_remove();
// Rendering
$rendering = $this->render($name, $variables);
// Get all headers defined in template engine and add to response
foreach (headers_list() as $header) {
$header = explode(':', $header, 2);
$response = $response->withAddedHeader($header[0], $header[1] ?? '');
}
// Get body of response
if ($response->getBody()->isWritable()) {
$response->getBody()->write($rendering);
} else {
$body = new Stream;
$body->write($rendering);
$response = $response->withBody($body);
}
return $response;
} | php | protected function renderResponse(string $name, array $variables = [], ResponseInterface $response = null): ResponseInterface
{
// Create new Response object if not given in parameter
if (is_null($response)) {
$response = new Response;
}
// Remove all headers
header_remove();
// Rendering
$rendering = $this->render($name, $variables);
// Get all headers defined in template engine and add to response
foreach (headers_list() as $header) {
$header = explode(':', $header, 2);
$response = $response->withAddedHeader($header[0], $header[1] ?? '');
}
// Get body of response
if ($response->getBody()->isWritable()) {
$response->getBody()->write($rendering);
} else {
$body = new Stream;
$body->write($rendering);
$response = $response->withBody($body);
}
return $response;
} | [
"protected",
"function",
"renderResponse",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
",",
"ResponseInterface",
"$",
"response",
"=",
"null",
")",
":",
"ResponseInterface",
"{",
"// Create new Response object if not given in parameter",... | Do render of templates in Response object.
@param string $name Filename of template
@param mixed[] $variables Variables for template
@param \Psr\Http\Message\ResponseInterface|null $response Response object to complete
@return \Psr\Http\Message\ResponseInterface
@throws \Berlioz\Core\Exception\RuntimeException if application not accessible | [
"Do",
"render",
"of",
"templates",
"in",
"Response",
"object",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Controller/Controller.php#L198-L228 | train |
SaftIng/Saft | src/Saft/Sparql/Query/GraphQueryImpl.php | GraphQueryImpl.getQueryParts | public function getQueryParts()
{
$this->queryParts = [
'graphs' => $this->extractGraphs($this->getQuery()),
'sub_type' => $this->determineSubType($this->getQuery()),
];
$this->unsetEmptyValues($this->queryParts);
return $this->queryParts;
} | php | public function getQueryParts()
{
$this->queryParts = [
'graphs' => $this->extractGraphs($this->getQuery()),
'sub_type' => $this->determineSubType($this->getQuery()),
];
$this->unsetEmptyValues($this->queryParts);
return $this->queryParts;
} | [
"public",
"function",
"getQueryParts",
"(",
")",
"{",
"$",
"this",
"->",
"queryParts",
"=",
"[",
"'graphs'",
"=>",
"$",
"this",
"->",
"extractGraphs",
"(",
"$",
"this",
"->",
"getQuery",
"(",
")",
")",
",",
"'sub_type'",
"=>",
"$",
"this",
"->",
"deter... | Return parts of the query on which this instance based on. It overrides the parent function and sets
all values to null.
@return array $queryParts query parts; parts which have no elements or are unset will be marked with null | [
"Return",
"parts",
"of",
"the",
"query",
"on",
"which",
"this",
"instance",
"based",
"on",
".",
"It",
"overrides",
"the",
"parent",
"function",
"and",
"sets",
"all",
"values",
"to",
"null",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/GraphQueryImpl.php#L157-L167 | train |
CarbonPackages/Carbon.Eel | Classes/StringHelper.php | StringHelper.toPascalCase | public function toPascalCase(string $string): string
{
$string = Transliterator::urlize((string)$string);
$string = str_replace('-', '', ucwords($string, '-'));
return $string;
} | php | public function toPascalCase(string $string): string
{
$string = Transliterator::urlize((string)$string);
$string = str_replace('-', '', ucwords($string, '-'));
return $string;
} | [
"public",
"function",
"toPascalCase",
"(",
"string",
"$",
"string",
")",
":",
"string",
"{",
"$",
"string",
"=",
"Transliterator",
"::",
"urlize",
"(",
"(",
"string",
")",
"$",
"string",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"'-'",
",",
"''... | Helper to convert strings to PascalCase
@param string $string A string
@return string The converted string | [
"Helper",
"to",
"convert",
"strings",
"to",
"PascalCase"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/StringHelper.php#L49-L55 | train |
CarbonPackages/Carbon.Eel | Classes/StringHelper.php | StringHelper.convertCamelCase | public function convertCamelCase($string, $separator = '-'): string
{
$string = (string)$string;
$separator = (string)$separator;
return strtolower(
preg_replace(
'/([a-zA-Z])(?=[A-Z])/',
'$1' . $separator,
$string
)
);
} | php | public function convertCamelCase($string, $separator = '-'): string
{
$string = (string)$string;
$separator = (string)$separator;
return strtolower(
preg_replace(
'/([a-zA-Z])(?=[A-Z])/',
'$1' . $separator,
$string
)
);
} | [
"public",
"function",
"convertCamelCase",
"(",
"$",
"string",
",",
"$",
"separator",
"=",
"'-'",
")",
":",
"string",
"{",
"$",
"string",
"=",
"(",
"string",
")",
"$",
"string",
";",
"$",
"separator",
"=",
"(",
"string",
")",
"$",
"separator",
";",
"r... | Helper to convert `CamelCaseStrings` to `hyphen-case-strings`
Examples:
Carbon.String.convertCamelCase('HelloWorld') == 'hello-world'
Carbon.String.convertCamelCase('HelloWorld', '_') == 'hello_world'
Carbon.String.convertCamelCase('HelloWorld', '') == 'helloworld'
@param string $string A string
@param string $separator The separator
@return string The converted string | [
"Helper",
"to",
"convert",
"CamelCaseStrings",
"to",
"hyphen",
"-",
"case",
"-",
"strings"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/StringHelper.php#L83-L95 | train |
CarbonPackages/Carbon.Eel | Classes/StringHelper.php | StringHelper.convertToString | public function convertToString($input, $separator = ' '): string
{
$separator = (string)$separator;
$string = is_array($input) ? implode($separator, $input) : (string)$input;
// Remove double space and trim the string
return trim(preg_replace('/(\s)+/', ' ', $string));
} | php | public function convertToString($input, $separator = ' '): string
{
$separator = (string)$separator;
$string = is_array($input) ? implode($separator, $input) : (string)$input;
// Remove double space and trim the string
return trim(preg_replace('/(\s)+/', ' ', $string));
} | [
"public",
"function",
"convertToString",
"(",
"$",
"input",
",",
"$",
"separator",
"=",
"' '",
")",
":",
"string",
"{",
"$",
"separator",
"=",
"(",
"string",
")",
"$",
"separator",
";",
"$",
"string",
"=",
"is_array",
"(",
"$",
"input",
")",
"?",
"im... | Helper to make sure we got a string back
Examples:
Carbon.String.convertToString(' helloworld ') == 'helloworld'
Carbon.String.convertToString([' hello', ' world']) == 'hello world'
Carbon.String.convertToString(['hello', 'world'], '-') == 'hello-world'
@param string|array $input A string or an array
@param string $separator The $separator
@return string The converted string | [
"Helper",
"to",
"make",
"sure",
"we",
"got",
"a",
"string",
"back"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/StringHelper.php#L111-L118 | train |
cymapgt/UserCredential | src/services/UserCredentialSmsTokenLoginService.php | UserCredentialSmsTokenLoginService.initialize | public function initialize() {
//revert to password only functionality if multi-factor flag is off
if ($this->_multiFactorFlag === false) {
parent::initialize();
return;
}
//verify that multi-factor stages is set
if (
!(isset($this->_multiFactorStages))
|| !(is_array($this->_multiFactorStages))
|| !(isset($this->_multiFactorStages['current']))
|| !(is_int($this->_multiFactorStages['current']))
|| !(isset($this->_multiFactorStages[1]))
|| !(is_array($this->_multiFactorStages[1]))
|| !(isset($this->keyLength))
) {
throw new UserCredentialException('The multi factor stages register is initialized with an an unknown state', 2100);
}
//get the current stage (1 or 2)
$currentStage = $this->_multiFactorStages['current'];
//bootstrap depends on which stage we are in
if ($currentStage == 1) {
$this->_multiFactorStages[1]['statuss'] = false;
parent::initialize();
return;
} elseif ($currentStage != 2) {
throw new UserCredentialException('The current stage of the multi factor auth process is in an unknown state', 2101);
}
//get the user TOTP profile
$userTotpProfile = $this->userTotpProfile;
//we are in stage 2, check that all items are in order
if (
!(is_array($userTotpProfile))
|| !(isset($userTotpProfile['enc_key']))
|| !(is_string($userTotpProfile['enc_key']))
|| !(isset($userTotpProfile['totp_timestamp']))
|| !($userTotpProfile['totp_timestamp'] instanceof \DateTime)
|| !(isset($userTotpProfile['totp_timelimit']))
|| !(is_int($userTotpProfile['totp_timelimit']))
|| !(isset($this->verificationHash))
|| !(is_string($this->verificationHash))
|| !(isset($this->oneTimeToken))
|| !(is_string($this->oneTimeToken))
|| !(isset($this->currentOneTimeToken))
|| !(is_string($this->currentOneTimeToken))
) {
throw new UserCredentialException('The user TOTP profile is not initialized properly', 2102);
}
} | php | public function initialize() {
//revert to password only functionality if multi-factor flag is off
if ($this->_multiFactorFlag === false) {
parent::initialize();
return;
}
//verify that multi-factor stages is set
if (
!(isset($this->_multiFactorStages))
|| !(is_array($this->_multiFactorStages))
|| !(isset($this->_multiFactorStages['current']))
|| !(is_int($this->_multiFactorStages['current']))
|| !(isset($this->_multiFactorStages[1]))
|| !(is_array($this->_multiFactorStages[1]))
|| !(isset($this->keyLength))
) {
throw new UserCredentialException('The multi factor stages register is initialized with an an unknown state', 2100);
}
//get the current stage (1 or 2)
$currentStage = $this->_multiFactorStages['current'];
//bootstrap depends on which stage we are in
if ($currentStage == 1) {
$this->_multiFactorStages[1]['statuss'] = false;
parent::initialize();
return;
} elseif ($currentStage != 2) {
throw new UserCredentialException('The current stage of the multi factor auth process is in an unknown state', 2101);
}
//get the user TOTP profile
$userTotpProfile = $this->userTotpProfile;
//we are in stage 2, check that all items are in order
if (
!(is_array($userTotpProfile))
|| !(isset($userTotpProfile['enc_key']))
|| !(is_string($userTotpProfile['enc_key']))
|| !(isset($userTotpProfile['totp_timestamp']))
|| !($userTotpProfile['totp_timestamp'] instanceof \DateTime)
|| !(isset($userTotpProfile['totp_timelimit']))
|| !(is_int($userTotpProfile['totp_timelimit']))
|| !(isset($this->verificationHash))
|| !(is_string($this->verificationHash))
|| !(isset($this->oneTimeToken))
|| !(is_string($this->oneTimeToken))
|| !(isset($this->currentOneTimeToken))
|| !(is_string($this->currentOneTimeToken))
) {
throw new UserCredentialException('The user TOTP profile is not initialized properly', 2102);
}
} | [
"public",
"function",
"initialize",
"(",
")",
"{",
"//revert to password only functionality if multi-factor flag is off\r",
"if",
"(",
"$",
"this",
"->",
"_multiFactorFlag",
"===",
"false",
")",
"{",
"parent",
"::",
"initialize",
"(",
")",
";",
"return",
";",
"}",
... | initialize the service, bootstrap before any processing
Cyril Ogana <cogana@gmail.com> - 2015-07-25
@access public | [
"initialize",
"the",
"service",
"bootstrap",
"before",
"any",
"processing"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/services/UserCredentialSmsTokenLoginService.php#L41-L94 | train |
cymapgt/UserCredential | src/services/UserCredentialSmsTokenLoginService.php | UserCredentialSmsTokenLoginService.authenticate | public function authenticate() {
$currentStage = $this->_multiFactorStages['current'];
//set stage as inactive
if ($currentStage == 1) {
$this->_multiFactorStages[1]['statuss'] = parent::authenticate();
//stage one sucessfull, bootstrap stage 2
if ($this->_multiFactorStages[1]['statuss'] === true ) {
$this->_multiFactorStages[2] = array (
'enc_key' => \openssl_random_pseudo_bytes($this->getEncKeyLength()),
'statuss' => false
);
}
return $this->_multiFactorStages;
} elseif ($currentStage != 2) {
throw new UserCredentialException('The current stage of the multi factor auth process is in an unknown state', 2101);
}
//authenticate stage 2
$totpTimestamp = $this->userTotpProfile['totp_timestamp'];
$totpTimelimit = $this->userTotpProfile['totp_timelimit'];
$currDateTime = new \DateTime();
$totpTimeElapsed = $currDateTime->getTimestamp() - $totpTimestamp->getTimestamp();
$encKey = $this->userTotpProfile['enc_key'];
$verificationHash = $this->getVerificationHash();
$comparisonHash = \crypt($this->getCurrentPassword(), $encKey);
$currentOneTimeToken = $this->getCurrentOneTimeToken();
$oneTimeToken = $this->oneTimeToken;
//initialize verification - comparison
$verificationEqualsComparison = false;
//verify if verification hash equals comparison hash. Use hash_equals function if exists
if (!\function_exists('hash_equals')) {
if ($verificationHash === $comparisonHash) {
$verificationEqualsComparison = true;
}
} else {
if (\hash_equals($verificationHash, $comparisonHash)) {
$verificationEqualsComparison = true;
}
}
if (
!($totpTimeElapsed < $totpTimelimit)
|| !($verificationEqualsComparison === true)
|| !(\password_verify($oneTimeToken,$currentOneTimeToken))
) {
return false;
} else {
return true;
}
} | php | public function authenticate() {
$currentStage = $this->_multiFactorStages['current'];
//set stage as inactive
if ($currentStage == 1) {
$this->_multiFactorStages[1]['statuss'] = parent::authenticate();
//stage one sucessfull, bootstrap stage 2
if ($this->_multiFactorStages[1]['statuss'] === true ) {
$this->_multiFactorStages[2] = array (
'enc_key' => \openssl_random_pseudo_bytes($this->getEncKeyLength()),
'statuss' => false
);
}
return $this->_multiFactorStages;
} elseif ($currentStage != 2) {
throw new UserCredentialException('The current stage of the multi factor auth process is in an unknown state', 2101);
}
//authenticate stage 2
$totpTimestamp = $this->userTotpProfile['totp_timestamp'];
$totpTimelimit = $this->userTotpProfile['totp_timelimit'];
$currDateTime = new \DateTime();
$totpTimeElapsed = $currDateTime->getTimestamp() - $totpTimestamp->getTimestamp();
$encKey = $this->userTotpProfile['enc_key'];
$verificationHash = $this->getVerificationHash();
$comparisonHash = \crypt($this->getCurrentPassword(), $encKey);
$currentOneTimeToken = $this->getCurrentOneTimeToken();
$oneTimeToken = $this->oneTimeToken;
//initialize verification - comparison
$verificationEqualsComparison = false;
//verify if verification hash equals comparison hash. Use hash_equals function if exists
if (!\function_exists('hash_equals')) {
if ($verificationHash === $comparisonHash) {
$verificationEqualsComparison = true;
}
} else {
if (\hash_equals($verificationHash, $comparisonHash)) {
$verificationEqualsComparison = true;
}
}
if (
!($totpTimeElapsed < $totpTimelimit)
|| !($verificationEqualsComparison === true)
|| !(\password_verify($oneTimeToken,$currentOneTimeToken))
) {
return false;
} else {
return true;
}
} | [
"public",
"function",
"authenticate",
"(",
")",
"{",
"$",
"currentStage",
"=",
"$",
"this",
"->",
"_multiFactorStages",
"[",
"'current'",
"]",
";",
"//set stage as inactive\r",
"if",
"(",
"$",
"currentStage",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"_multiFa... | authenticate the user after initialization
Cyril Ogana <cogana@gmail.com> - 2015-07-24
@access public | [
"authenticate",
"the",
"user",
"after",
"initialization"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/services/UserCredentialSmsTokenLoginService.php#L103-L157 | train |
cymapgt/UserCredential | src/services/UserCredentialSmsTokenLoginService.php | UserCredentialSmsTokenLoginService.setEncKeyLength | public function setEncKeyLength($keyLength) {
$keyLengthCast = (int) $keyLength;
if (!($keyLengthCast > 0)) {
throw new UserCredentialException('The encryption key length must be an integer', 2105);
}
$this->keyLength = $keyLengthCast;
} | php | public function setEncKeyLength($keyLength) {
$keyLengthCast = (int) $keyLength;
if (!($keyLengthCast > 0)) {
throw new UserCredentialException('The encryption key length must be an integer', 2105);
}
$this->keyLength = $keyLengthCast;
} | [
"public",
"function",
"setEncKeyLength",
"(",
"$",
"keyLength",
")",
"{",
"$",
"keyLengthCast",
"=",
"(",
"int",
")",
"$",
"keyLength",
";",
"if",
"(",
"!",
"(",
"$",
"keyLengthCast",
">",
"0",
")",
")",
"{",
"throw",
"new",
"UserCredentialException",
"(... | Set the encryption key length
Cyril Ogana <cogana@gmail.com> - 2015-07-22
@param int $keyLength - Length of the encryption key
@access public | [
"Set",
"the",
"encryption",
"key",
"length"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/services/UserCredentialSmsTokenLoginService.php#L214-L222 | train |
cymapgt/UserCredential | src/services/UserCredentialSmsTokenLoginService.php | UserCredentialSmsTokenLoginService.getOneTimeToken | public function getOneTimeToken($unhashed = false) {
if ((bool) $unhashed === true) {
return $this->oneTimeToken;
} else {
return \password_hash($this->oneTimeToken, \PASSWORD_DEFAULT);
}
} | php | public function getOneTimeToken($unhashed = false) {
if ((bool) $unhashed === true) {
return $this->oneTimeToken;
} else {
return \password_hash($this->oneTimeToken, \PASSWORD_DEFAULT);
}
} | [
"public",
"function",
"getOneTimeToken",
"(",
"$",
"unhashed",
"=",
"false",
")",
"{",
"if",
"(",
"(",
"bool",
")",
"$",
"unhashed",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"oneTimeToken",
";",
"}",
"else",
"{",
"return",
"\\",
"password_... | Return the verification token
Cyril Ogana <cogana@gmail.com> - 2015-07-24
@param $unhashed - flag if true, return unhashed
@return mixed - the hashed password
@access public | [
"Return",
"the",
"verification",
"token"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/services/UserCredentialSmsTokenLoginService.php#L309-L315 | train |
orchestral/notifier | src/Mailer.php | Mailer.push | public function push($view, array $data = [], $callback = null, ?string $queue = null): ReceiptContract
{
$method = $this->shouldBeQueued() ? 'queue' : 'send';
return $this->{$method}($view, $data, $callback, $queue);
} | php | public function push($view, array $data = [], $callback = null, ?string $queue = null): ReceiptContract
{
$method = $this->shouldBeQueued() ? 'queue' : 'send';
return $this->{$method}($view, $data, $callback, $queue);
} | [
"public",
"function",
"push",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
",",
"?",
"string",
"$",
"queue",
"=",
"null",
")",
":",
"ReceiptContract",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"... | Allow Orchestra Platform to either use send or queue based on
settings.
@param \Illuminate\Contracts\Mail\Mailable|string|array $view
@param array $data
@param \Closure|string|null $callback
@param string|null $queue
@return \Orchestra\Contracts\Notification\Receipt | [
"Allow",
"Orchestra",
"Platform",
"to",
"either",
"use",
"send",
"or",
"queue",
"based",
"on",
"settings",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Mailer.php#L77-L82 | train |
orchestral/notifier | src/Mailer.php | Mailer.send | public function send($view, array $data = [], $callback = null): ReceiptContract
{
$mailer = $this->getMailer();
if ($view instanceof MailableContract) {
$this->updateFromOnMailable($view)->send($mailer);
} else {
$mailer->send($view, $data, $callback);
}
return new Receipt($mailer, false);
} | php | public function send($view, array $data = [], $callback = null): ReceiptContract
{
$mailer = $this->getMailer();
if ($view instanceof MailableContract) {
$this->updateFromOnMailable($view)->send($mailer);
} else {
$mailer->send($view, $data, $callback);
}
return new Receipt($mailer, false);
} | [
"public",
"function",
"send",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
")",
":",
"ReceiptContract",
"{",
"$",
"mailer",
"=",
"$",
"this",
"->",
"getMailer",
"(",
")",
";",
"if",
"(",
"$",
"vie... | Force Orchestra Platform to send email directly.
@param \Illuminate\Contracts\Mail\Mailable|string|array $view
@param array $data
@param \Closure|string|null $callback
@return \Orchestra\Contracts\Notification\Receipt | [
"Force",
"Orchestra",
"Platform",
"to",
"send",
"email",
"directly",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Mailer.php#L93-L104 | train |
orchestral/notifier | src/Mailer.php | Mailer.queue | public function queue($view, array $data = [], $callback = null, ?string $queue = null): ReceiptContract
{
$mailer = $this->getMailer();
if ($view instanceof MailableContract) {
$this->updateFromOnMailable($view)->queue($this->queue);
} else {
$callback = $this->buildQueueCallable($callback);
$with = \compact('view', 'data', 'callback');
$this->queue->push('orchestra.mail@handleQueuedMessage', $with, $queue);
}
return new Receipt($mailer, true);
} | php | public function queue($view, array $data = [], $callback = null, ?string $queue = null): ReceiptContract
{
$mailer = $this->getMailer();
if ($view instanceof MailableContract) {
$this->updateFromOnMailable($view)->queue($this->queue);
} else {
$callback = $this->buildQueueCallable($callback);
$with = \compact('view', 'data', 'callback');
$this->queue->push('orchestra.mail@handleQueuedMessage', $with, $queue);
}
return new Receipt($mailer, true);
} | [
"public",
"function",
"queue",
"(",
"$",
"view",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
",",
"?",
"string",
"$",
"queue",
"=",
"null",
")",
":",
"ReceiptContract",
"{",
"$",
"mailer",
"=",
"$",
"this",
"->",
... | Force Orchestra Platform to send email using queue.
@param \Illuminate\Contracts\Mail\Mailable|string|array $view
@param array $data
@param \Closure|string|null $callback
@param string|null $queue
@return \Orchestra\Contracts\Notification\Receipt | [
"Force",
"Orchestra",
"Platform",
"to",
"send",
"email",
"using",
"queue",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Mailer.php#L116-L130 | train |
orchestral/notifier | src/Mailer.php | Mailer.updateFromOnMailable | protected function updateFromOnMailable(MailableContract $message): MailableContract
{
if (! empty($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
return $message;
} | php | protected function updateFromOnMailable(MailableContract $message): MailableContract
{
if (! empty($this->from['address'])) {
$message->from($this->from['address'], $this->from['name']);
}
return $message;
} | [
"protected",
"function",
"updateFromOnMailable",
"(",
"MailableContract",
"$",
"message",
")",
":",
"MailableContract",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"from",
"[",
"'address'",
"]",
")",
")",
"{",
"$",
"message",
"->",
"from",
"(",
... | Update from on mailable.
@param \Illuminate\Contracts\Mail\Mailable $message
@return \Illuminate\Contracts\Mail\Mailable | [
"Update",
"from",
"on",
"mailable",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Mailer.php#L176-L183 | train |
orchestral/notifier | src/Mailer.php | Mailer.configureIlluminateMailer | public function configureIlluminateMailer(MailerContract $mailer): MailerContract
{
$from = $this->memory->get('email.from');
// If a "from" address is set, we will set it on the mailer so that
// all mail messages sent by the applications will utilize the same
// "from" address on each one, which makes the developer's life a
// lot more convenient.
if (\is_array($from) && ! empty($from['address'])) {
$this->from = $from;
$mailer->alwaysFrom($from['address'], $from['name']);
}
if ($this->queue instanceof QueueContract) {
$mailer->setQueue($this->queue);
}
$mailer->setSwiftMailer(new Swift_Mailer($this->transport->driver()));
return $mailer;
} | php | public function configureIlluminateMailer(MailerContract $mailer): MailerContract
{
$from = $this->memory->get('email.from');
// If a "from" address is set, we will set it on the mailer so that
// all mail messages sent by the applications will utilize the same
// "from" address on each one, which makes the developer's life a
// lot more convenient.
if (\is_array($from) && ! empty($from['address'])) {
$this->from = $from;
$mailer->alwaysFrom($from['address'], $from['name']);
}
if ($this->queue instanceof QueueContract) {
$mailer->setQueue($this->queue);
}
$mailer->setSwiftMailer(new Swift_Mailer($this->transport->driver()));
return $mailer;
} | [
"public",
"function",
"configureIlluminateMailer",
"(",
"MailerContract",
"$",
"mailer",
")",
":",
"MailerContract",
"{",
"$",
"from",
"=",
"$",
"this",
"->",
"memory",
"->",
"get",
"(",
"'email.from'",
")",
";",
"// If a \"from\" address is set, we will set it on the... | Setup mailer.
@return \Illuminate\Contracts\Mail\Mailer | [
"Setup",
"mailer",
"."
] | a0036f924c51ead67f3e339cd2688163876f3b59 | https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Mailer.php#L204-L224 | train |
BerliozFramework/Berlioz | src/App.php | App.getServices | public function getServices(): ServiceContainer
{
if (is_null($this->services)) {
$this->services = new ServiceContainer();
$this->services->setConstraints(['caching' => '\Psr\SimpleCache\CacheInterface',
'events' => '\Psr\EventManager\EventManagerInterface',
'flashbag' => '\Berlioz\Core\Services\FlashBag',
'logging' => '\Psr\Log\LoggerInterface',
'routing' => '\Berlioz\Core\Services\Routing\RouterInterface',
'templating' => '\Berlioz\Core\Services\Template\TemplateInterface']);
$this->services->registerServices(['events' => ['class' => '\Berlioz\Core\Services\Events\EventManager'],
'flashbag' => ['class' => '\Berlioz\Core\Services\FlashBag'],
'logging' => ['class' => '\Berlioz\Core\Services\Logger'],
'routing' => ['class' => '\Berlioz\Core\Services\Routing\Router'],
'templating' => ['class' => '\Berlioz\Core\Services\Template\DefaultEngine']]);
$this->services->registerServices($this->getConfig()->get('app.services'));
$this->services->register('app', $this);
}
return $this->services;
} | php | public function getServices(): ServiceContainer
{
if (is_null($this->services)) {
$this->services = new ServiceContainer();
$this->services->setConstraints(['caching' => '\Psr\SimpleCache\CacheInterface',
'events' => '\Psr\EventManager\EventManagerInterface',
'flashbag' => '\Berlioz\Core\Services\FlashBag',
'logging' => '\Psr\Log\LoggerInterface',
'routing' => '\Berlioz\Core\Services\Routing\RouterInterface',
'templating' => '\Berlioz\Core\Services\Template\TemplateInterface']);
$this->services->registerServices(['events' => ['class' => '\Berlioz\Core\Services\Events\EventManager'],
'flashbag' => ['class' => '\Berlioz\Core\Services\FlashBag'],
'logging' => ['class' => '\Berlioz\Core\Services\Logger'],
'routing' => ['class' => '\Berlioz\Core\Services\Routing\Router'],
'templating' => ['class' => '\Berlioz\Core\Services\Template\DefaultEngine']]);
$this->services->registerServices($this->getConfig()->get('app.services'));
$this->services->register('app', $this);
}
return $this->services;
} | [
"public",
"function",
"getServices",
"(",
")",
":",
"ServiceContainer",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"services",
")",
")",
"{",
"$",
"this",
"->",
"services",
"=",
"new",
"ServiceContainer",
"(",
")",
";",
"$",
"this",
"->",
"serv... | Get service container.
@return \Berlioz\ServiceContainer\ServiceContainer
@throws \Psr\Container\ContainerExceptionInterface
@throws \Berlioz\Core\Exception\BerliozException | [
"Get",
"service",
"container",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/App.php#L118-L138 | train |
BerliozFramework/Berlioz | src/App.php | App.addExtension | public function addExtension(ExtensionInterface $extension): App
{
try {
if (!$extension->isInitialized()) {
$extension->init($this);
}
} catch (\Exception $e) {
throw new RuntimeException(sprintf('Unable to load extension "%s"', get_class($extension)));
}
return $this;
} | php | public function addExtension(ExtensionInterface $extension): App
{
try {
if (!$extension->isInitialized()) {
$extension->init($this);
}
} catch (\Exception $e) {
throw new RuntimeException(sprintf('Unable to load extension "%s"', get_class($extension)));
}
return $this;
} | [
"public",
"function",
"addExtension",
"(",
"ExtensionInterface",
"$",
"extension",
")",
":",
"App",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"extension",
"->",
"isInitialized",
"(",
")",
")",
"{",
"$",
"extension",
"->",
"init",
"(",
"$",
"this",
")",
";"... | Add extension.
@param \Berlioz\Core\ExtensionInterface $extension
@return \Berlioz\Core\App
@throws \Berlioz\Core\Exception\RuntimeException If unable to load extension | [
"Add",
"extension",
"."
] | cd5f28f93fdff254b9a123a30dad275e5bbfd78c | https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/App.php#L204-L215 | train |
danadesrosiers/silex-annotation-provider | src/AnnotationService.php | AnnotationService.registerController | private function registerController(string $controllerClassName)
{
$controllerAnnotation = $this->getControllerAnnotation($controllerClassName);
if ($controllerAnnotation instanceof Controller) {
$controllerName = trim($controllerClassName, "\\");
$this->app["$controllerName"] = function (Application $app) use ($controllerName) {
return new $controllerName($app);
};
$this->processClassAnnotation($controllerAnnotation);
}
} | php | private function registerController(string $controllerClassName)
{
$controllerAnnotation = $this->getControllerAnnotation($controllerClassName);
if ($controllerAnnotation instanceof Controller) {
$controllerName = trim($controllerClassName, "\\");
$this->app["$controllerName"] = function (Application $app) use ($controllerName) {
return new $controllerName($app);
};
$this->processClassAnnotation($controllerAnnotation);
}
} | [
"private",
"function",
"registerController",
"(",
"string",
"$",
"controllerClassName",
")",
"{",
"$",
"controllerAnnotation",
"=",
"$",
"this",
"->",
"getControllerAnnotation",
"(",
"$",
"controllerClassName",
")",
";",
"if",
"(",
"$",
"controllerAnnotation",
"inst... | Register the controller using the controller definition parsed from annotation.
@param string $controllerClassName
@throws InvalidArgumentException | [
"Register",
"the",
"controller",
"using",
"the",
"controller",
"definition",
"parsed",
"from",
"annotation",
"."
] | f1bdf18bba17f3842ef0aab231e0ac5c831bd61f | https://github.com/danadesrosiers/silex-annotation-provider/blob/f1bdf18bba17f3842ef0aab231e0ac5c831bd61f/src/AnnotationService.php#L108-L120 | train |
hypeJunction/hypeApps | classes/hypeJunction/Servers/Server.php | Server.getDatalistValue | protected function getDatalistValue(array $names = array()) {
$services = \hypeJunction\Integration::getServiceProvider();
foreach ($names as $name) {
$values[$name] = $services->datalist->get($name);
}
return $values;
} | php | protected function getDatalistValue(array $names = array()) {
$services = \hypeJunction\Integration::getServiceProvider();
foreach ($names as $name) {
$values[$name] = $services->datalist->get($name);
}
return $values;
} | [
"protected",
"function",
"getDatalistValue",
"(",
"array",
"$",
"names",
"=",
"array",
"(",
")",
")",
"{",
"$",
"services",
"=",
"\\",
"hypeJunction",
"\\",
"Integration",
"::",
"getServiceProvider",
"(",
")",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
... | Retreive values from datalists table
@param array $names Parameter names to retreive
@return array | [
"Retreive",
"values",
"from",
"datalists",
"table"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Servers/Server.php#L23-L31 | train |
hypeJunction/hypeApps | classes/hypeJunction/Controllers/Action.php | Action.setup | public function setup() {
$input_keys = array_keys((array) elgg_get_config('input'));
$request_keys = array_keys((array) $_REQUEST);
$keys = array_unique(array_merge($input_keys, $request_keys));
foreach ($keys as $key) {
if ($key) {
$this->params->$key = get_input($key);
}
}
} | php | public function setup() {
$input_keys = array_keys((array) elgg_get_config('input'));
$request_keys = array_keys((array) $_REQUEST);
$keys = array_unique(array_merge($input_keys, $request_keys));
foreach ($keys as $key) {
if ($key) {
$this->params->$key = get_input($key);
}
}
} | [
"public",
"function",
"setup",
"(",
")",
"{",
"$",
"input_keys",
"=",
"array_keys",
"(",
"(",
"array",
")",
"elgg_get_config",
"(",
"'input'",
")",
")",
";",
"$",
"request_keys",
"=",
"array_keys",
"(",
"(",
"array",
")",
"$",
"_REQUEST",
")",
";",
"$"... | Populate params from input values
@return void | [
"Populate",
"params",
"from",
"input",
"values"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Controllers/Action.php#L84-L93 | train |
shopgate/cart-integration-magento2-base | src/Model/Shopgate/Order.php | Order.getReportedShippingCollections | public function getReportedShippingCollections()
{
try {
return $this->encoder->decode($this->getData(self::FIELD_REPORTED_SHIPPING_COLLECTIONS)) ?: [];
} catch (\InvalidArgumentException $e) {
$this->_logger->error($e->getMessage());
return [];
}
} | php | public function getReportedShippingCollections()
{
try {
return $this->encoder->decode($this->getData(self::FIELD_REPORTED_SHIPPING_COLLECTIONS)) ?: [];
} catch (\InvalidArgumentException $e) {
$this->_logger->error($e->getMessage());
return [];
}
} | [
"public",
"function",
"getReportedShippingCollections",
"(",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"encoder",
"->",
"decode",
"(",
"$",
"this",
"->",
"getData",
"(",
"self",
"::",
"FIELD_REPORTED_SHIPPING_COLLECTIONS",
")",
")",
"?",
":",
"[",
"... | Get all shipments for the order
@return string[] | [
"Get",
"all",
"shipments",
"for",
"the",
"order"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Shopgate/Order.php#L149-L158 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.authenticateOnServer | protected function authenticateOnServer($authUrl, $username, $password)
{
$response = $this->sendDigestAuthentication($authUrl, $username, $password);
$httpCode = $response->getHttpCode();
// If status code is not 200, something went wrong
if (200 !== $httpCode) {
throw new \Exception('Response with Status Code [' . $httpCode . '].', 500);
}
} | php | protected function authenticateOnServer($authUrl, $username, $password)
{
$response = $this->sendDigestAuthentication($authUrl, $username, $password);
$httpCode = $response->getHttpCode();
// If status code is not 200, something went wrong
if (200 !== $httpCode) {
throw new \Exception('Response with Status Code [' . $httpCode . '].', 500);
}
} | [
"protected",
"function",
"authenticateOnServer",
"(",
"$",
"authUrl",
",",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendDigestAuthentication",
"(",
"$",
"authUrl",
",",
"$",
"username",
",",
"$",
"password",
... | Using digest authentication to authenticate user on the server.
@param string $authUrl URL to authenticate.
@param string $username Username to access.
@param string $password Password to access.
@throws \Exception If response | [
"Using",
"digest",
"authentication",
"to",
"authenticate",
"user",
"on",
"the",
"server",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L135-L145 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.getRights | public function getRights()
{
$rights = array(
'graphUpdate' => false,
'tripleQuerying' => false,
'tripleUpdate' => false
);
// generate a unique graph URI which we will use later on for our tests.
$graph = 'http://saft/'. hash('sha1', rand(0, time()) . microtime(true)) .'/';
/*
* check if we can create and drop graphs
*/
try {
$this->query('CREATE GRAPH <'. $graph .'>');
$this->query('DROP GRAPH <'. $graph .'>');
$rights['graphUpdate'] = true;
} catch (\Exception $e) {
// ignore exception here and assume we could not create or drop the graph.
}
/*
* check if we can query triples
*/
try {
$this->query('SELECT ?g { GRAPH ?g {?s ?p ?o} } LIMIT 1');
$rights['tripleQuerying'] = true;
} catch (\Exception $e) {
// ignore exception here and assume we could not query anything.
}
/*
* check if we can create and update queries.
*/
try {
if ($rights['graphUpdate']) {
// create graph
$this->query('CREATE GRAPH <'. $graph .'>');
// create a simple triple
$this->query('INSERT DATA { GRAPH <'. $graph .'> { <'. $graph .'1> <'. $graph .'2> "42" } }');
// remove all triples
$this->query('WITH <'. $graph .'> DELETE { ?s ?p ?o }');
// drop graph
$this->query('DROP GRAPH <'. $graph .'>');
$rights['tripleUpdate'] = true;
}
} catch (\Exception $e) {
// ignore exception here and assume we could not update a triple.
// whatever happens, try to remove the fresh graph.
try {
$this->query('DROP GRAPH <'. $graph .'>');
} catch (\Exception $e) {
}
}
return $rights;
} | php | public function getRights()
{
$rights = array(
'graphUpdate' => false,
'tripleQuerying' => false,
'tripleUpdate' => false
);
// generate a unique graph URI which we will use later on for our tests.
$graph = 'http://saft/'. hash('sha1', rand(0, time()) . microtime(true)) .'/';
/*
* check if we can create and drop graphs
*/
try {
$this->query('CREATE GRAPH <'. $graph .'>');
$this->query('DROP GRAPH <'. $graph .'>');
$rights['graphUpdate'] = true;
} catch (\Exception $e) {
// ignore exception here and assume we could not create or drop the graph.
}
/*
* check if we can query triples
*/
try {
$this->query('SELECT ?g { GRAPH ?g {?s ?p ?o} } LIMIT 1');
$rights['tripleQuerying'] = true;
} catch (\Exception $e) {
// ignore exception here and assume we could not query anything.
}
/*
* check if we can create and update queries.
*/
try {
if ($rights['graphUpdate']) {
// create graph
$this->query('CREATE GRAPH <'. $graph .'>');
// create a simple triple
$this->query('INSERT DATA { GRAPH <'. $graph .'> { <'. $graph .'1> <'. $graph .'2> "42" } }');
// remove all triples
$this->query('WITH <'. $graph .'> DELETE { ?s ?p ?o }');
// drop graph
$this->query('DROP GRAPH <'. $graph .'>');
$rights['tripleUpdate'] = true;
}
} catch (\Exception $e) {
// ignore exception here and assume we could not update a triple.
// whatever happens, try to remove the fresh graph.
try {
$this->query('DROP GRAPH <'. $graph .'>');
} catch (\Exception $e) {
}
}
return $rights;
} | [
"public",
"function",
"getRights",
"(",
")",
"{",
"$",
"rights",
"=",
"array",
"(",
"'graphUpdate'",
"=>",
"false",
",",
"'tripleQuerying'",
"=>",
"false",
",",
"'tripleUpdate'",
"=>",
"false",
")",
";",
"// generate a unique graph URI which we will use later on for o... | Checks, what rights the current user has to query and update graphs and triples. Be aware, that method
could polute your store by creating test graphs.
@return array An array with key value pairs. Keys are graphUpdate, tripleQuerying and tripleUpdate.
The values are boolean values, which depend on the according right if they are true or
false.
@todo Implement a safer way to check, if the current user can create and drop a graph
@todo Implement a safer way to check, if the current user can create a triple inside a graph
Problem here is to get a graph, in which you have write access. | [
"Checks",
"what",
"rights",
"the",
"current",
"user",
"has",
"to",
"query",
"and",
"update",
"graphs",
"and",
"triples",
".",
"Be",
"aware",
"that",
"method",
"could",
"polute",
"your",
"store",
"by",
"creating",
"test",
"graphs",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L166-L227 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.isGraphAvailable | public function isGraphAvailable(Node $graph)
{
$graphs = $this->getGraphs();
return isset($graphs[$graph->getUri()]);
} | php | public function isGraphAvailable(Node $graph)
{
$graphs = $this->getGraphs();
return isset($graphs[$graph->getUri()]);
} | [
"public",
"function",
"isGraphAvailable",
"(",
"Node",
"$",
"graph",
")",
"{",
"$",
"graphs",
"=",
"$",
"this",
"->",
"getGraphs",
"(",
")",
";",
"return",
"isset",
"(",
"$",
"graphs",
"[",
"$",
"graph",
"->",
"getUri",
"(",
")",
"]",
")",
";",
"}"... | Checks if a certain graph is available in the store.
@param Node $graph URI of the graph to check if it is available.
@return boolean True if graph is available, false otherwise.
@todo find a more precise way to check if a graph is available. | [
"Checks",
"if",
"a",
"certain",
"graph",
"is",
"available",
"in",
"the",
"store",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L245-L249 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.openConnection | public function openConnection()
{
if (null == $this->httpClient) {
return false;
}
$configuration = array_merge(array(
'authUrl' => '',
'password' => '',
'queryUrl' => '',
'username' => ''
), $this->configuration);
// authenticate only if an authUrl was given.
if ($this->RdfHelpers->simpleCheckURI($configuration['authUrl'])) {
$this->authenticateOnServer(
$configuration['authUrl'],
$configuration['username'],
$configuration['password']
);
}
// check query URL
if (false === $this->RdfHelpers->simpleCheckURI($configuration['queryUrl'])) {
throw new \Exception('Parameter queryUrl is not an URI or empty: '. $configuration['queryUrl']);
}
} | php | public function openConnection()
{
if (null == $this->httpClient) {
return false;
}
$configuration = array_merge(array(
'authUrl' => '',
'password' => '',
'queryUrl' => '',
'username' => ''
), $this->configuration);
// authenticate only if an authUrl was given.
if ($this->RdfHelpers->simpleCheckURI($configuration['authUrl'])) {
$this->authenticateOnServer(
$configuration['authUrl'],
$configuration['username'],
$configuration['password']
);
}
// check query URL
if (false === $this->RdfHelpers->simpleCheckURI($configuration['queryUrl'])) {
throw new \Exception('Parameter queryUrl is not an URI or empty: '. $configuration['queryUrl']);
}
} | [
"public",
"function",
"openConnection",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"httpClient",
")",
"{",
"return",
"false",
";",
"}",
"$",
"configuration",
"=",
"array_merge",
"(",
"array",
"(",
"'authUrl'",
"=>",
"''",
",",
"'password'... | Establish a connection to the endpoint and authenticate.
@return Client Setup HTTP client. | [
"Establish",
"a",
"connection",
"to",
"the",
"endpoint",
"and",
"authenticate",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L256-L282 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.sendDigestAuthentication | public function sendDigestAuthentication($url, $username, $password = null)
{
$this->httpClient->setDigestAuthentication($username, $password);
return $this->httpClient->get($url);
} | php | public function sendDigestAuthentication($url, $username, $password = null)
{
$this->httpClient->setDigestAuthentication($username, $password);
return $this->httpClient->get($url);
} | [
"public",
"function",
"sendDigestAuthentication",
"(",
"$",
"url",
",",
"$",
"username",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"httpClient",
"->",
"setDigestAuthentication",
"(",
"$",
"username",
",",
"$",
"password",
")",
";",
"r... | Send digest authentication to the server via GET.
@param string $username
@param string $password optional
@return string | [
"Send",
"digest",
"authentication",
"to",
"the",
"server",
"via",
"GET",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L408-L413 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.sendSparqlSelectQuery | public function sendSparqlSelectQuery($url, $query)
{
// because you can't just fire multiple requests with the same CURL class instance
// we have to be creative and re-create the class everytime a request is to be send.
// FYI: https://github.com/php-curl-class/php-curl-class/issues/326
$class = get_class($this->httpClient);
$phpVersionToOld = version_compare(phpversion(), '5.5.11', '<=');
// only reinstance the class if its not mocked
if ($phpVersionToOld && false === strpos($class, 'Mockery')) {
$this->httpClient = new $class();
}
$this->httpClient->setHeader('Accept', 'application/sparql-results+json');
$this->httpClient->setHeader('Content-Type', 'application/x-www-form-urlencoded');
return $this->httpClient->post($url, array('query' => $query));
} | php | public function sendSparqlSelectQuery($url, $query)
{
// because you can't just fire multiple requests with the same CURL class instance
// we have to be creative and re-create the class everytime a request is to be send.
// FYI: https://github.com/php-curl-class/php-curl-class/issues/326
$class = get_class($this->httpClient);
$phpVersionToOld = version_compare(phpversion(), '5.5.11', '<=');
// only reinstance the class if its not mocked
if ($phpVersionToOld && false === strpos($class, 'Mockery')) {
$this->httpClient = new $class();
}
$this->httpClient->setHeader('Accept', 'application/sparql-results+json');
$this->httpClient->setHeader('Content-Type', 'application/x-www-form-urlencoded');
return $this->httpClient->post($url, array('query' => $query));
} | [
"public",
"function",
"sendSparqlSelectQuery",
"(",
"$",
"url",
",",
"$",
"query",
")",
"{",
"// because you can't just fire multiple requests with the same CURL class instance",
"// we have to be creative and re-create the class everytime a request is to be send.",
"// FYI: https://github... | Sends a SPARQL select query to the server.
@param string $url
@param string $query
@return string Response of the POST request. | [
"Sends",
"a",
"SPARQL",
"select",
"query",
"to",
"the",
"server",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L422-L438 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.sendSparqlUpdateQuery | public function sendSparqlUpdateQuery($url, $query)
{
// because you can't just fire multiple requests with the same CURL class instance
// we have to be creative and re-create the class everytime a request is to be send.
// FYI: https://github.com/php-curl-class/php-curl-class/issues/326
$class = get_class($this->httpClient);
$phpVersionToOld = version_compare(phpversion(), '5.5.11', '<=');
// only reinstance the class if its not mocked
if ($phpVersionToOld && false === strpos($class, 'Mockery')) {
$this->httpClient = new $class;
}
// TODO extend Accept headers to further formats
$this->httpClient->setHeader('Accept', 'application/sparql-results+json');
$this->httpClient->setHeader('Content-Type', 'application/sparql-update');
return $this->httpClient->get($url, array('query' => $query));
} | php | public function sendSparqlUpdateQuery($url, $query)
{
// because you can't just fire multiple requests with the same CURL class instance
// we have to be creative and re-create the class everytime a request is to be send.
// FYI: https://github.com/php-curl-class/php-curl-class/issues/326
$class = get_class($this->httpClient);
$phpVersionToOld = version_compare(phpversion(), '5.5.11', '<=');
// only reinstance the class if its not mocked
if ($phpVersionToOld && false === strpos($class, 'Mockery')) {
$this->httpClient = new $class;
}
// TODO extend Accept headers to further formats
$this->httpClient->setHeader('Accept', 'application/sparql-results+json');
$this->httpClient->setHeader('Content-Type', 'application/sparql-update');
return $this->httpClient->get($url, array('query' => $query));
} | [
"public",
"function",
"sendSparqlUpdateQuery",
"(",
"$",
"url",
",",
"$",
"query",
")",
"{",
"// because you can't just fire multiple requests with the same CURL class instance",
"// we have to be creative and re-create the class everytime a request is to be send.",
"// FYI: https://github... | Sends a SPARQL update query to the server.
@param string $url
@param string $query
@return string Response of the GET request. | [
"Sends",
"a",
"SPARQL",
"update",
"query",
"to",
"the",
"server",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L447-L464 | train |
SaftIng/Saft | src/Saft/Addition/HttpStore/Store/Http.php | Http.transformResultToArray | public function transformResultToArray($receivedResult)
{
// transform object to array
if (is_object($receivedResult)) {
return json_decode(json_encode($receivedResult), true);
// transform json string to array
} else {
return json_decode($receivedResult, true);
}
} | php | public function transformResultToArray($receivedResult)
{
// transform object to array
if (is_object($receivedResult)) {
return json_decode(json_encode($receivedResult), true);
// transform json string to array
} else {
return json_decode($receivedResult, true);
}
} | [
"public",
"function",
"transformResultToArray",
"(",
"$",
"receivedResult",
")",
"{",
"// transform object to array",
"if",
"(",
"is_object",
"(",
"$",
"receivedResult",
")",
")",
"{",
"return",
"json_decode",
"(",
"json_encode",
"(",
"$",
"receivedResult",
")",
"... | Transforms server result to aray.
@param mixed $receivedResult
@return array | [
"Transforms",
"server",
"result",
"to",
"aray",
"."
] | ac2d9aed53da6ab3bb5ea05165644027df5248e8 | https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/HttpStore/Store/Http.php#L480-L489 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Tax/Retriever.php | Retriever.getProductTaxClasses | public function getProductTaxClasses()
{
/** @var \Magento\Tax\Model\ResourceModel\TaxClass\Collection $taxCollection */
$classes = [];
$taxCollection = $this->taxClass->getCollection();
$taxCollection->setClassTypeFilter(ClassModel::TAX_CLASS_TYPE_PRODUCT);
/** @var ClassModel $tax */
foreach ($taxCollection as $tax) {
$classes[] = [
'id' => $tax->getId(),
'key' => $tax->getClassName()
];
}
return $classes;
} | php | public function getProductTaxClasses()
{
/** @var \Magento\Tax\Model\ResourceModel\TaxClass\Collection $taxCollection */
$classes = [];
$taxCollection = $this->taxClass->getCollection();
$taxCollection->setClassTypeFilter(ClassModel::TAX_CLASS_TYPE_PRODUCT);
/** @var ClassModel $tax */
foreach ($taxCollection as $tax) {
$classes[] = [
'id' => $tax->getId(),
'key' => $tax->getClassName()
];
}
return $classes;
} | [
"public",
"function",
"getProductTaxClasses",
"(",
")",
"{",
"/** @var \\Magento\\Tax\\Model\\ResourceModel\\TaxClass\\Collection $taxCollection */",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"taxCollection",
"=",
"$",
"this",
"->",
"taxClass",
"->",
"getCollection",
"(",
... | Retrieves all product related tax classes
for Merchant API to pick up
@return array | [
"Retrieves",
"all",
"product",
"related",
"tax",
"classes",
"for",
"Merchant",
"API",
"to",
"pick",
"up"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Tax/Retriever.php#L98-L114 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Tax/Retriever.php | Retriever.getCustomerTaxClasses | public function getCustomerTaxClasses()
{
/** @var \Magento\Tax\Model\ResourceModel\TaxClass\Collection $taxCollection */
$classes = [];
$defaultTaxId = $this->customerGroup->getNotLoggedInGroup()->getTaxClassId();
$taxCollection = $this->taxClass->getCollection();
$taxCollection->setClassTypeFilter(ClassModel::TAX_CLASS_TYPE_CUSTOMER);
/** @var ClassModel $tax */
foreach ($taxCollection as $tax) {
$classes[] = [
'id' => $tax->getId(),
'key' => $tax->getClassName(),
'is_default' => intval($defaultTaxId == $tax->getId()),
];
}
return $classes;
} | php | public function getCustomerTaxClasses()
{
/** @var \Magento\Tax\Model\ResourceModel\TaxClass\Collection $taxCollection */
$classes = [];
$defaultTaxId = $this->customerGroup->getNotLoggedInGroup()->getTaxClassId();
$taxCollection = $this->taxClass->getCollection();
$taxCollection->setClassTypeFilter(ClassModel::TAX_CLASS_TYPE_CUSTOMER);
/** @var ClassModel $tax */
foreach ($taxCollection as $tax) {
$classes[] = [
'id' => $tax->getId(),
'key' => $tax->getClassName(),
'is_default' => intval($defaultTaxId == $tax->getId()),
];
}
return $classes;
} | [
"public",
"function",
"getCustomerTaxClasses",
"(",
")",
"{",
"/** @var \\Magento\\Tax\\Model\\ResourceModel\\TaxClass\\Collection $taxCollection */",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"defaultTaxId",
"=",
"$",
"this",
"->",
"customerGroup",
"->",
"getNotLoggedInGrou... | Retrieves all customer related tax classes
for Merchant API to pick up
@return array | [
"Retrieves",
"all",
"customer",
"related",
"tax",
"classes",
"for",
"Merchant",
"API",
"to",
"pick",
"up"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Tax/Retriever.php#L122-L140 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Tax/Retriever.php | Retriever.getTaxRates | public function getTaxRates()
{
$rates = [];
/** @var \Magento\Tax\Model\Calculation\Rate $rate */
foreach ($this->taxRates as $rate) {
$zipCodeType = self::ZIP_CODE_TYPE_ALL;
$zipCodePattern = '';
$zipCodeRangeFrom = '';
$zipCodeRangeTo = '';
if ($rate->getZipIsRange()) {
$zipCodeType = self::ZIP_CODE_TYPE_RANGE;
$zipCodeRangeFrom = $rate->getZipFrom();
$zipCodeRangeTo = $rate->getZipTo();
} elseif ($rate->getTaxPostcode() && $rate->getTaxPostcode() != '*') {
$zipCodeType = self::ZIP_CODE_TYPE_PATTERN;
$zipCodePattern = $rate->getTaxPostcode();
}
$state = '';
$regionId = $rate->getTaxRegionId();
if ($regionId) {
/** @var \Magento\Directory\Model\Region $region */
$region = $this->regionCollection->getItemById($regionId);
$state = $this->regionHelper->getIsoStateByMagentoRegion(
new DataObject(
[
'region_code' => $region->getCode(),
'country_id' => $rate->getTaxCountryId()
]
)
);
}
$rates[] = [
'id' => $rate->getId(),
'key' => $rate->getId(),
'display_name' => $rate->getCode(),
'tax_percent' => round($rate->getRate(), 4),
'country' => $rate->getTaxCountryId(),
'state' => $state,
'zipcode_type' => $zipCodeType,
'zipcode_pattern' => $zipCodePattern,
'zipcode_range_from' => $zipCodeRangeFrom,
'zipcode_range_to' => $zipCodeRangeTo
];
}
return $rates;
} | php | public function getTaxRates()
{
$rates = [];
/** @var \Magento\Tax\Model\Calculation\Rate $rate */
foreach ($this->taxRates as $rate) {
$zipCodeType = self::ZIP_CODE_TYPE_ALL;
$zipCodePattern = '';
$zipCodeRangeFrom = '';
$zipCodeRangeTo = '';
if ($rate->getZipIsRange()) {
$zipCodeType = self::ZIP_CODE_TYPE_RANGE;
$zipCodeRangeFrom = $rate->getZipFrom();
$zipCodeRangeTo = $rate->getZipTo();
} elseif ($rate->getTaxPostcode() && $rate->getTaxPostcode() != '*') {
$zipCodeType = self::ZIP_CODE_TYPE_PATTERN;
$zipCodePattern = $rate->getTaxPostcode();
}
$state = '';
$regionId = $rate->getTaxRegionId();
if ($regionId) {
/** @var \Magento\Directory\Model\Region $region */
$region = $this->regionCollection->getItemById($regionId);
$state = $this->regionHelper->getIsoStateByMagentoRegion(
new DataObject(
[
'region_code' => $region->getCode(),
'country_id' => $rate->getTaxCountryId()
]
)
);
}
$rates[] = [
'id' => $rate->getId(),
'key' => $rate->getId(),
'display_name' => $rate->getCode(),
'tax_percent' => round($rate->getRate(), 4),
'country' => $rate->getTaxCountryId(),
'state' => $state,
'zipcode_type' => $zipCodeType,
'zipcode_pattern' => $zipCodePattern,
'zipcode_range_from' => $zipCodeRangeFrom,
'zipcode_range_to' => $zipCodeRangeTo
];
}
return $rates;
} | [
"public",
"function",
"getTaxRates",
"(",
")",
"{",
"$",
"rates",
"=",
"[",
"]",
";",
"/** @var \\Magento\\Tax\\Model\\Calculation\\Rate $rate */",
"foreach",
"(",
"$",
"this",
"->",
"taxRates",
"as",
"$",
"rate",
")",
"{",
"$",
"zipCodeType",
"=",
"self",
"::... | Retrieve Magento tax rates for
Merchant API to pick up
@return array | [
"Retrieve",
"Magento",
"tax",
"rates",
"for",
"Merchant",
"API",
"to",
"pick",
"up"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Tax/Retriever.php#L148-L198 | train |
shopgate/cart-integration-magento2-base | src/Helper/Settings/Tax/Retriever.php | Retriever.getTaxRules | public function getTaxRules()
{
$rules = [];
/* @var \Magento\Tax\Model\Calculation\Rule $rule */
foreach ($this->taxRules as $rule) {
$_rule = [
'id' => $rule->getId(),
'name' => $rule->getCode(),
'priority' => $rule->getPriority(),
'product_tax_classes' => [],
'customer_tax_classes' => [],
'tax_rates' => [],
];
foreach (array_unique($rule->getProductTaxClasses()) as $taxClass) {
$_rule['product_tax_classes'][] = [
'id' => $taxClass,
'key' => $taxClass
];
}
foreach (array_unique($rule->getCustomerTaxClasses()) as $taxClass) {
$_rule['customer_tax_classes'][] = [
'id' => $taxClass,
'key' => $taxClass
];
}
foreach (array_unique($rule->getRates()) as $taxRates) {
$_rule['tax_rates'][] = [
'id' => $taxRates,
'key' => $taxRates
];
}
$rules[] = $_rule;
}
return $rules;
} | php | public function getTaxRules()
{
$rules = [];
/* @var \Magento\Tax\Model\Calculation\Rule $rule */
foreach ($this->taxRules as $rule) {
$_rule = [
'id' => $rule->getId(),
'name' => $rule->getCode(),
'priority' => $rule->getPriority(),
'product_tax_classes' => [],
'customer_tax_classes' => [],
'tax_rates' => [],
];
foreach (array_unique($rule->getProductTaxClasses()) as $taxClass) {
$_rule['product_tax_classes'][] = [
'id' => $taxClass,
'key' => $taxClass
];
}
foreach (array_unique($rule->getCustomerTaxClasses()) as $taxClass) {
$_rule['customer_tax_classes'][] = [
'id' => $taxClass,
'key' => $taxClass
];
}
foreach (array_unique($rule->getRates()) as $taxRates) {
$_rule['tax_rates'][] = [
'id' => $taxRates,
'key' => $taxRates
];
}
$rules[] = $_rule;
}
return $rules;
} | [
"public",
"function",
"getTaxRules",
"(",
")",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"/* @var \\Magento\\Tax\\Model\\Calculation\\Rule $rule */",
"foreach",
"(",
"$",
"this",
"->",
"taxRules",
"as",
"$",
"rule",
")",
"{",
"$",
"_rule",
"=",
"[",
"'id'",
"=>... | Retrieve Magento tax rules for
Merchant API to pick up
@return array | [
"Retrieve",
"Magento",
"tax",
"rules",
"for",
"Merchant",
"API",
"to",
"pick",
"up"
] | e7f8dec935aa9b23cd5b434484bc45033e62d270 | https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Tax/Retriever.php#L206-L245 | train |
CarbonPackages/Carbon.Eel | Classes/FileContentHelper.php | FileContentHelper._returnHash | private function _returnHash(string $hash, int $length)
{
try {
return substr($hash, 0, $length);
} catch (\Exception $e) { }
return false;
} | php | private function _returnHash(string $hash, int $length)
{
try {
return substr($hash, 0, $length);
} catch (\Exception $e) { }
return false;
} | [
"private",
"function",
"_returnHash",
"(",
"string",
"$",
"hash",
",",
"int",
"$",
"length",
")",
"{",
"try",
"{",
"return",
"substr",
"(",
"$",
"hash",
",",
"0",
",",
"$",
"length",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
... | Hashes a string
@param string $hash The string to hash
@param int $length The length of the hash
@return string | [
"Hashes",
"a",
"string"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/FileContentHelper.php#L37-L44 | train |
CarbonPackages/Carbon.Eel | Classes/FileContentHelper.php | FileContentHelper.pathHash | public function pathHash(string $path, int $length = 8)
{
return $this->_returnHash(
sha1_file($this->_generalizeResource($path)),
$length
);
} | php | public function pathHash(string $path, int $length = 8)
{
return $this->_returnHash(
sha1_file($this->_generalizeResource($path)),
$length
);
} | [
"public",
"function",
"pathHash",
"(",
"string",
"$",
"path",
",",
"int",
"$",
"length",
"=",
"8",
")",
"{",
"return",
"$",
"this",
"->",
"_returnHash",
"(",
"sha1_file",
"(",
"$",
"this",
"->",
"_generalizeResource",
"(",
"$",
"path",
")",
")",
",",
... | Returns a shorten sha1 value of a file path. Fails silent
@param string $path The path to the file
@param int $length The length of the hash, defaults to 8
@return string | boolean | [
"Returns",
"a",
"shorten",
"sha1",
"value",
"of",
"a",
"file",
"path",
".",
"Fails",
"silent"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/FileContentHelper.php#L82-L88 | train |
CarbonPackages/Carbon.Eel | Classes/FileContentHelper.php | FileContentHelper.resourceHash | public function resourceHash($resource, int $length = 8): string
{
return $this->_returnHash($resource->getResource()->getSha1(), $length);
} | php | public function resourceHash($resource, int $length = 8): string
{
return $this->_returnHash($resource->getResource()->getSha1(), $length);
} | [
"public",
"function",
"resourceHash",
"(",
"$",
"resource",
",",
"int",
"$",
"length",
"=",
"8",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"_returnHash",
"(",
"$",
"resource",
"->",
"getResource",
"(",
")",
"->",
"getSha1",
"(",
")",
",",
... | Returns a shorten sha1 value of a file property. Fails silent
@param $resource The resource
@param int $length The length of the hash, defaults to 8
@return string | boolean | [
"Returns",
"a",
"shorten",
"sha1",
"value",
"of",
"a",
"file",
"property",
".",
"Fails",
"silent"
] | 3892b2023255ad2b21136286ba8168c8ea6bd870 | https://github.com/CarbonPackages/Carbon.Eel/blob/3892b2023255ad2b21136286ba8168c8ea6bd870/Classes/FileContentHelper.php#L112-L115 | train |
hypeJunction/hypeApps | classes/hypeJunction/Filestore/UploadHandler.php | UploadHandler.makeFiles | public function makeFiles($input, array $attributes = array(), array $config = array()) {
$files = array();
$uploads = hypeApps()->uploader->handle($input, $attributes, $config);
foreach ($uploads as $upload) {
if ($upload->file instanceof \ElggEntity) {
$files[] = $upload->file;
}
}
return $files;
} | php | public function makeFiles($input, array $attributes = array(), array $config = array()) {
$files = array();
$uploads = hypeApps()->uploader->handle($input, $attributes, $config);
foreach ($uploads as $upload) {
if ($upload->file instanceof \ElggEntity) {
$files[] = $upload->file;
}
}
return $files;
} | [
"public",
"function",
"makeFiles",
"(",
"$",
"input",
",",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"$",
"uploads",
"=",
"hypeApps"... | Create new file entities
@param string $input Name of the file input
@param array $attributes Key value pairs, such as subtype, owner_guid, metadata.
@param array $config Additional config
@return ElggFile[] An array of file entities created | [
"Create",
"new",
"file",
"entities"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Filestore/UploadHandler.php#L24-L33 | train |
hypeJunction/hypeApps | classes/hypeJunction/Filestore/UploadHandler.php | UploadHandler.handle | public static function handle($input, array $attributes = array(), array $config = array()) {
return hypeApps()->uploader->handle($input, $attributes, $config);
} | php | public static function handle($input, array $attributes = array(), array $config = array()) {
return hypeApps()->uploader->handle($input, $attributes, $config);
} | [
"public",
"static",
"function",
"handle",
"(",
"$",
"input",
",",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"return",
"hypeApps",
"(",
")",
"->",
"uploader",
"->",
"handle",
"("... | Static counterpart of makeFiles, but returns data for processed uploads
@param string $input Name of the file input
@param array $attributes Key value pairs, such as subtype, owner_guid, metadata.
@param array $config Additional config
@return Upload[] An array of file entities created | [
"Static",
"counterpart",
"of",
"makeFiles",
"but",
"returns",
"data",
"for",
"processed",
"uploads"
] | 704a0aa57e817aa38bb9e40ad3710ba69d52e44c | https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Filestore/UploadHandler.php#L43-L45 | train |
webeweb/core-library | src/Network/FTP/AbstractFTPClient.php | AbstractFTPClient.newFTPException | protected function newFTPException($message) {
return new FTPException(sprintf("%s://%s:%s@%s:%d " . $message, $this->authenticator->getScheme(), $this->authenticator->getPasswordAuthentication()->getUsername(), $this->authenticator->getPasswordAuthentication()->getPassword(), $this->authenticator->getHost(), $this->authenticator->getPort()));
} | php | protected function newFTPException($message) {
return new FTPException(sprintf("%s://%s:%s@%s:%d " . $message, $this->authenticator->getScheme(), $this->authenticator->getPasswordAuthentication()->getUsername(), $this->authenticator->getPasswordAuthentication()->getPassword(), $this->authenticator->getHost(), $this->authenticator->getPort()));
} | [
"protected",
"function",
"newFTPException",
"(",
"$",
"message",
")",
"{",
"return",
"new",
"FTPException",
"(",
"sprintf",
"(",
"\"%s://%s:%s@%s:%d \"",
".",
"$",
"message",
",",
"$",
"this",
"->",
"authenticator",
"->",
"getScheme",
"(",
")",
",",
"$",
"th... | Construct a new FTP exception.
@param string $message The message.
@return FTPException Returns a new FTP exception. | [
"Construct",
"a",
"new",
"FTP",
"exception",
"."
] | bd454a47f6a28fbf6029635ee77ed01c9995cf60 | https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/AbstractFTPClient.php#L73-L75 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.ResetCacheArray | function ResetCacheArray()
{
// First, we reset all values (we know the key based on the schema)
reset($this->_sql_tables_schema['cache']);
while(list($valid_key, $valid_format) = @each($this->_sql_tables_schema['cache'])) {
$pos = mb_strpos(mb_strtoupper($valid_format), 'DEFAULT');
$value = "";
if ($pos !== FALSE) {
$value = trim(substr($valid_format, $pos + strlen("DEFAULT")));
if (("'" == substr($value,0,1)) && ("'" == substr($value,-1))) {
$value = substr($value,1,-1);
}
}
$this->_cache_data[$valid_key] = $value;
}
} | php | function ResetCacheArray()
{
// First, we reset all values (we know the key based on the schema)
reset($this->_sql_tables_schema['cache']);
while(list($valid_key, $valid_format) = @each($this->_sql_tables_schema['cache'])) {
$pos = mb_strpos(mb_strtoupper($valid_format), 'DEFAULT');
$value = "";
if ($pos !== FALSE) {
$value = trim(substr($valid_format, $pos + strlen("DEFAULT")));
if (("'" == substr($value,0,1)) && ("'" == substr($value,-1))) {
$value = substr($value,1,-1);
}
}
$this->_cache_data[$valid_key] = $value;
}
} | [
"function",
"ResetCacheArray",
"(",
")",
"{",
"// First, we reset all values (we know the key based on the schema)",
"reset",
"(",
"$",
"this",
"->",
"_sql_tables_schema",
"[",
"'cache'",
"]",
")",
";",
"while",
"(",
"list",
"(",
"$",
"valid_key",
",",
"$",
"valid_f... | Reset the cache array | [
"Reset",
"the",
"cache",
"array"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L2246-L2261 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.ResetConfigArray | function ResetConfigArray($array_to_reset = '')
{
if (!is_array($array_to_reset)) {
$array_to_reset = $this->_sql_tables_schema['config'];
}
// First, we reset all values (we know the key based on the schema)
reset($array_to_reset);
while(list($valid_key, $valid_format) = @each($array_to_reset)) {
$pos = mb_strpos(mb_strtoupper($valid_format), 'DEFAULT');
$value = "";
if ($pos !== FALSE) {
$value = trim(substr($valid_format, $pos + strlen("DEFAULT")));
if (("'" == substr($value,0,1)) && ("'" == substr($value,-1))) {
$value = substr($value,1,-1);
}
}
$this->_config_data[$valid_key] = $value;
}
} | php | function ResetConfigArray($array_to_reset = '')
{
if (!is_array($array_to_reset)) {
$array_to_reset = $this->_sql_tables_schema['config'];
}
// First, we reset all values (we know the key based on the schema)
reset($array_to_reset);
while(list($valid_key, $valid_format) = @each($array_to_reset)) {
$pos = mb_strpos(mb_strtoupper($valid_format), 'DEFAULT');
$value = "";
if ($pos !== FALSE) {
$value = trim(substr($valid_format, $pos + strlen("DEFAULT")));
if (("'" == substr($value,0,1)) && ("'" == substr($value,-1))) {
$value = substr($value,1,-1);
}
}
$this->_config_data[$valid_key] = $value;
}
} | [
"function",
"ResetConfigArray",
"(",
"$",
"array_to_reset",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array_to_reset",
")",
")",
"{",
"$",
"array_to_reset",
"=",
"$",
"this",
"->",
"_sql_tables_schema",
"[",
"'config'",
"]",
";",
"}",
"... | Reset the config array | [
"Reset",
"the",
"config",
"array"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L2987-L3005 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.ResetTempUserArray | function ResetTempUserArray()
{
$temp_user_array = array();
// First, we reset all values (we know the key based on the schema)
reset($this->_sql_tables_schema['users']);
while(list($valid_key, $valid_format) = @each($this->_sql_tables_schema['users'])) {
$pos = mb_strpos(mb_strtoupper($valid_format), 'DEFAULT');
$value = "";
if ($pos !== FALSE) {
$value = trim(substr($valid_format, $pos + strlen("DEFAULT")));
if (("'" == substr($value,0,1)) && ("'" == substr($value,-1))) {
$value = substr($value,1,-1);
}
}
$temp_user_array[$valid_key] = $value;
}
// Request the pin as a prefix of the returned token value
$temp_user_array['request_prefix_pin'] = $this->GetDefaultRequestPrefixPin();
return $temp_user_array;
} | php | function ResetTempUserArray()
{
$temp_user_array = array();
// First, we reset all values (we know the key based on the schema)
reset($this->_sql_tables_schema['users']);
while(list($valid_key, $valid_format) = @each($this->_sql_tables_schema['users'])) {
$pos = mb_strpos(mb_strtoupper($valid_format), 'DEFAULT');
$value = "";
if ($pos !== FALSE) {
$value = trim(substr($valid_format, $pos + strlen("DEFAULT")));
if (("'" == substr($value,0,1)) && ("'" == substr($value,-1))) {
$value = substr($value,1,-1);
}
}
$temp_user_array[$valid_key] = $value;
}
// Request the pin as a prefix of the returned token value
$temp_user_array['request_prefix_pin'] = $this->GetDefaultRequestPrefixPin();
return $temp_user_array;
} | [
"function",
"ResetTempUserArray",
"(",
")",
"{",
"$",
"temp_user_array",
"=",
"array",
"(",
")",
";",
"// First, we reset all values (we know the key based on the schema)",
"reset",
"(",
"$",
"this",
"->",
"_sql_tables_schema",
"[",
"'users'",
"]",
")",
";",
"while",
... | Reset the temporary user array | [
"Reset",
"the",
"temporary",
"user",
"array"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L5633-L5655 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.ResetUserArray | function ResetUserArray()
{
$this->_user_data = array();
$this->_user_data = $this->ResetTempUserArray();
// The user data array is not read actually
$this->SetUserDataReadFlag(false);
} | php | function ResetUserArray()
{
$this->_user_data = array();
$this->_user_data = $this->ResetTempUserArray();
// The user data array is not read actually
$this->SetUserDataReadFlag(false);
} | [
"function",
"ResetUserArray",
"(",
")",
"{",
"$",
"this",
"->",
"_user_data",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"_user_data",
"=",
"$",
"this",
"->",
"ResetTempUserArray",
"(",
")",
";",
"// The user data array is not read actually",
"$",
"this",... | Reset the user array | [
"Reset",
"the",
"user",
"array"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L5659-L5666 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.GetDetailedUsersArray | function GetDetailedUsersArray()
{
$users_array = array();
$result = $this->GetNextUserArray(TRUE);
if (isset($result['user'])) {
$users_array[$result['user']] = $result;
}
do {
if ($result = $this->GetNextUserArray()) {
if (isset($result['user'])) {
$users_array[$result['user']] = $result;
}
}
} while (FALSE !== $result);
return $users_array;
} | php | function GetDetailedUsersArray()
{
$users_array = array();
$result = $this->GetNextUserArray(TRUE);
if (isset($result['user'])) {
$users_array[$result['user']] = $result;
}
do {
if ($result = $this->GetNextUserArray()) {
if (isset($result['user'])) {
$users_array[$result['user']] = $result;
}
}
} while (FALSE !== $result);
return $users_array;
} | [
"function",
"GetDetailedUsersArray",
"(",
")",
"{",
"$",
"users_array",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"GetNextUserArray",
"(",
"TRUE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"'user'",
"]",
")",
")... | Completely new edition 2014-07-21 | [
"Completely",
"new",
"edition",
"2014",
"-",
"07",
"-",
"21"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L10444-L10459 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.ImportTokensFile | function ImportTokensFile(
$file,
$original_name = '',
$cipher_password = '',
$key_mac = ""
) {
if (!file_exists($file)) {
$result = FALSE;
} else {
$data1000 = @file_get_contents($file, FALSE, NULL, 0, 1000);
$file_name = ('' != $original_name)?$original_name:$file;
if (FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('"urn:ietf:params:xml:ns:keyprov:pskc"'))) {
$result = $this->ImportTokensFromPskc($file, $cipher_password, $key_mac);
} elseif (FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('LOGGING START'))) {
$result = $this->ImportYubikeyTraditional($file);
} elseif ((FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('AUTHENEXDB'))) && ('.sql' == mb_strtolower(substr($file_name, -4)))) {
$result = $this->ImportTokensFromAuthenexSql($file);
} elseif ((FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('SafeWord Authenticator Records'))) && ('.dat' == mb_strtolower(substr($file_name, -4)))) {
$result = $this->ImportTokensFromAlpineDat($file);
} elseif (FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('<ProductName>eTPass'))) {
// elseif (('.xml' == mb_strtolower(substr($file_name, -4))) && (FALSE !== mb_strpos(mb_strtolower($file_name), 'alpine')))
$result = $this->ImportTokensFromAlpineXml($file);
} elseif ('.xml' == mb_strtolower(substr($file_name, -4))) {
$result = $this->ImportTokensFromXml($file);
} else {
$result = $this->ImportTokensFromCsv($file);
}
}
return $result;
} | php | function ImportTokensFile(
$file,
$original_name = '',
$cipher_password = '',
$key_mac = ""
) {
if (!file_exists($file)) {
$result = FALSE;
} else {
$data1000 = @file_get_contents($file, FALSE, NULL, 0, 1000);
$file_name = ('' != $original_name)?$original_name:$file;
if (FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('"urn:ietf:params:xml:ns:keyprov:pskc"'))) {
$result = $this->ImportTokensFromPskc($file, $cipher_password, $key_mac);
} elseif (FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('LOGGING START'))) {
$result = $this->ImportYubikeyTraditional($file);
} elseif ((FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('AUTHENEXDB'))) && ('.sql' == mb_strtolower(substr($file_name, -4)))) {
$result = $this->ImportTokensFromAuthenexSql($file);
} elseif ((FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('SafeWord Authenticator Records'))) && ('.dat' == mb_strtolower(substr($file_name, -4)))) {
$result = $this->ImportTokensFromAlpineDat($file);
} elseif (FALSE !== mb_strpos(mb_strtolower($data1000), mb_strtolower('<ProductName>eTPass'))) {
// elseif (('.xml' == mb_strtolower(substr($file_name, -4))) && (FALSE !== mb_strpos(mb_strtolower($file_name), 'alpine')))
$result = $this->ImportTokensFromAlpineXml($file);
} elseif ('.xml' == mb_strtolower(substr($file_name, -4))) {
$result = $this->ImportTokensFromXml($file);
} else {
$result = $this->ImportTokensFromCsv($file);
}
}
return $result;
} | [
"function",
"ImportTokensFile",
"(",
"$",
"file",
",",
"$",
"original_name",
"=",
"''",
",",
"$",
"cipher_password",
"=",
"''",
",",
"$",
"key_mac",
"=",
"\"\"",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"result",... | End of SelfRegisterHardwareToken | [
"End",
"of",
"SelfRegisterHardwareToken"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L16981-L17010 | train |
cymapgt/UserCredential | lib/Multiotp/multiotp.class.php | Multiotp.qrcode | function qrcode(
$data = '',
$file_name = '',
$image_type = "P",
$ecc_level = "Q",
$module_size = 4,
$version = 0,
$structure_m = 0,
$structure_n = 0,
$parity = 0,
$original_data = ''
) {
$result = '';
$qrcode_folder = $this->GetQrCodeFolder();
$path = $qrcode_folder.'data';
$image_path = $qrcode_folder.'image';
if (!(file_exists($path) && file_exists($image_path))) {
$this->WriteLog("Error: QRcode files or folders are not available", FALSE, FALSE, 39, 'System', '', 3);
} else {
$result = MultiotpQrcode($data, $file_name, $image_type, $ecc_level, $module_size, $version, $structure_m, $structure_n, $parity, $original_data, $path, $image_path);
$output_name = NULL;
ob_start();
if (('' != trim($file_name)) && ('binary' != trim($file_name)) && ('' != $this->GetLinuxFileMode())) {
if (file_exists($file_name)) {
@chmod($file_name, octdec($this->GetLinuxFileMode()));
}
}
}
return $result;
} | php | function qrcode(
$data = '',
$file_name = '',
$image_type = "P",
$ecc_level = "Q",
$module_size = 4,
$version = 0,
$structure_m = 0,
$structure_n = 0,
$parity = 0,
$original_data = ''
) {
$result = '';
$qrcode_folder = $this->GetQrCodeFolder();
$path = $qrcode_folder.'data';
$image_path = $qrcode_folder.'image';
if (!(file_exists($path) && file_exists($image_path))) {
$this->WriteLog("Error: QRcode files or folders are not available", FALSE, FALSE, 39, 'System', '', 3);
} else {
$result = MultiotpQrcode($data, $file_name, $image_type, $ecc_level, $module_size, $version, $structure_m, $structure_n, $parity, $original_data, $path, $image_path);
$output_name = NULL;
ob_start();
if (('' != trim($file_name)) && ('binary' != trim($file_name)) && ('' != $this->GetLinuxFileMode())) {
if (file_exists($file_name)) {
@chmod($file_name, octdec($this->GetLinuxFileMode()));
}
}
}
return $result;
} | [
"function",
"qrcode",
"(",
"$",
"data",
"=",
"''",
",",
"$",
"file_name",
"=",
"''",
",",
"$",
"image_type",
"=",
"\"P\"",
",",
"$",
"ecc_level",
"=",
"\"Q\"",
",",
"$",
"module_size",
"=",
"4",
",",
"$",
"version",
"=",
"0",
",",
"$",
"structure_m... | This method is a stub that calls the MultiotpQrcode with the good pathes | [
"This",
"method",
"is",
"a",
"stub",
"that",
"calls",
"the",
"MultiotpQrcode",
"with",
"the",
"good",
"pathes"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/multiotp.class.php#L20352-L20386 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.authenticate | function authenticate($username,$password,$prevent_rebind=false){
if ($username==NULL || $password==NULL){ return (false); } //prevent null binding
//bind as the user
$this->_bind = @ldap_bind($this->_conn,$username.$this->_account_suffix,$password);
$this->_bind_paged = @ldap_bind($this->_conn_paged,$username.$this->_account_suffix,$password);
if (!$this->_bind){ return (false); }
//once we've checked their details, kick back into admin mode if we have it
if ($this->_ad_username!=NULL && !$prevent_rebind){
$this->_bind = @ldap_bind($this->_conn,$this->_ad_username.$this->_account_suffix,$this->_ad_password);
$this->_bind_paged = @ldap_bind($this->_conn_paged,$this->_ad_username.$this->_account_suffix,$this->_ad_password);
if (!$this->_bind){
// Modified by SysCo/al
$this->_error = TRUE;
$this->_error_message = 'FATAL: AD rebind failed.';
exit();
} //this should never happen in theory
}
return (true);
} | php | function authenticate($username,$password,$prevent_rebind=false){
if ($username==NULL || $password==NULL){ return (false); } //prevent null binding
//bind as the user
$this->_bind = @ldap_bind($this->_conn,$username.$this->_account_suffix,$password);
$this->_bind_paged = @ldap_bind($this->_conn_paged,$username.$this->_account_suffix,$password);
if (!$this->_bind){ return (false); }
//once we've checked their details, kick back into admin mode if we have it
if ($this->_ad_username!=NULL && !$prevent_rebind){
$this->_bind = @ldap_bind($this->_conn,$this->_ad_username.$this->_account_suffix,$this->_ad_password);
$this->_bind_paged = @ldap_bind($this->_conn_paged,$this->_ad_username.$this->_account_suffix,$this->_ad_password);
if (!$this->_bind){
// Modified by SysCo/al
$this->_error = TRUE;
$this->_error_message = 'FATAL: AD rebind failed.';
exit();
} //this should never happen in theory
}
return (true);
} | [
"function",
"authenticate",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"prevent_rebind",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"username",
"==",
"NULL",
"||",
"$",
"password",
"==",
"NULL",
")",
"{",
"return",
"(",
"false",
")",
";",
"}"... | validate a users login credentials | [
"validate",
"a",
"users",
"login",
"credentials"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L513-L534 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.group_add_group | function group_add_group($parent,$child){
//find the parent group's dn
$parent_group=$this->group_info($parent,array("cn"));
if ($parent_group[0]["dn"]==NULL){ return (false); }
$parent_dn=$parent_group[0]["dn"];
//find the child group's dn
$child_group=$this->group_info($child,array("cn"));
if ($child_group[0]["dn"]==NULL){ return (false); }
$child_dn=$child_group[0]["dn"];
$add=array();
$add["member"] = $child_dn;
$result=@ldap_mod_add($this->_conn,$parent_dn,$add);
if ($result==false){ return (false); }
return (true);
} | php | function group_add_group($parent,$child){
//find the parent group's dn
$parent_group=$this->group_info($parent,array("cn"));
if ($parent_group[0]["dn"]==NULL){ return (false); }
$parent_dn=$parent_group[0]["dn"];
//find the child group's dn
$child_group=$this->group_info($child,array("cn"));
if ($child_group[0]["dn"]==NULL){ return (false); }
$child_dn=$child_group[0]["dn"];
$add=array();
$add["member"] = $child_dn;
$result=@ldap_mod_add($this->_conn,$parent_dn,$add);
if ($result==false){ return (false); }
return (true);
} | [
"function",
"group_add_group",
"(",
"$",
"parent",
",",
"$",
"child",
")",
"{",
"//find the parent group's dn",
"$",
"parent_group",
"=",
"$",
"this",
"->",
"group_info",
"(",
"$",
"parent",
",",
"array",
"(",
"\"cn\"",
")",
")",
";",
"if",
"(",
"$",
"pa... | Add a group to a group | [
"Add",
"a",
"group",
"to",
"a",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L540-L558 | train |
cymapgt/UserCredential | lib/Multiotp/contrib/MultiotpAdLdap.php | MultiotpAdLdap.group_add_user | function group_add_user($group,$user){
//adding a user is a bit fiddly, we need to get the full DN of the user
//and add it using the full DN of the group
//find the user's dn
$user_info=$this->user_info($user,array("cn"));
if ($user_info[0]["dn"]==NULL){ return (false); }
$user_dn=$user_info[0]["dn"];
//find the group's dn
$group_info=$this->group_info($group,array("cn"));
if ($group_info[0]["dn"]==NULL){ return (false); }
$group_dn=$group_info[0]["dn"];
$add=array();
$add["member"] = $user_dn;
$result=@ldap_mod_add($this->_conn,$group_dn,$add);
if ($result==false){ return (false); }
return (true);
} | php | function group_add_user($group,$user){
//adding a user is a bit fiddly, we need to get the full DN of the user
//and add it using the full DN of the group
//find the user's dn
$user_info=$this->user_info($user,array("cn"));
if ($user_info[0]["dn"]==NULL){ return (false); }
$user_dn=$user_info[0]["dn"];
//find the group's dn
$group_info=$this->group_info($group,array("cn"));
if ($group_info[0]["dn"]==NULL){ return (false); }
$group_dn=$group_info[0]["dn"];
$add=array();
$add["member"] = $user_dn;
$result=@ldap_mod_add($this->_conn,$group_dn,$add);
if ($result==false){ return (false); }
return (true);
} | [
"function",
"group_add_user",
"(",
"$",
"group",
",",
"$",
"user",
")",
"{",
"//adding a user is a bit fiddly, we need to get the full DN of the user",
"//and add it using the full DN of the group",
"//find the user's dn",
"$",
"user_info",
"=",
"$",
"this",
"->",
"user_info",
... | Add a user to a group | [
"Add",
"a",
"user",
"to",
"a",
"group"
] | 06fc4539bda4aecb8342e49b4326497eb38ea28e | https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpAdLdap.php#L561-L581 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.