id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
27,900
|
RhubarbPHP/Rhubarb
|
src/Assets/Asset.php
|
Asset.writeToFile
|
public function writeToFile($filePath)
{
$out = @fopen($filePath,"w");
if (!$out){
throw new AssetException($this->token,
"The asset '".$this->token."' could not be written to path '$filePath'. Check the path is valid and the directory exists.");
}
$stream = $this->getStream();
if (!$stream){
throw new AssetException($this->token,
"The asset '".$this->token."' could not provide a valid stream.'");
}
while(!feof($stream)){
$bytes = fread($stream, 8192);
fwrite($out, $bytes);
}
fclose($stream);
fclose($out);
}
|
php
|
public function writeToFile($filePath)
{
$out = @fopen($filePath,"w");
if (!$out){
throw new AssetException($this->token,
"The asset '".$this->token."' could not be written to path '$filePath'. Check the path is valid and the directory exists.");
}
$stream = $this->getStream();
if (!$stream){
throw new AssetException($this->token,
"The asset '".$this->token."' could not provide a valid stream.'");
}
while(!feof($stream)){
$bytes = fread($stream, 8192);
fwrite($out, $bytes);
}
fclose($stream);
fclose($out);
}
|
[
"public",
"function",
"writeToFile",
"(",
"$",
"filePath",
")",
"{",
"$",
"out",
"=",
"@",
"fopen",
"(",
"$",
"filePath",
",",
"\"w\"",
")",
";",
"if",
"(",
"!",
"$",
"out",
")",
"{",
"throw",
"new",
"AssetException",
"(",
"$",
"this",
"->",
"token",
",",
"\"The asset '\"",
".",
"$",
"this",
"->",
"token",
".",
"\"' could not be written to path '$filePath'. Check the path is valid and the directory exists.\"",
")",
";",
"}",
"$",
"stream",
"=",
"$",
"this",
"->",
"getStream",
"(",
")",
";",
"if",
"(",
"!",
"$",
"stream",
")",
"{",
"throw",
"new",
"AssetException",
"(",
"$",
"this",
"->",
"token",
",",
"\"The asset '\"",
".",
"$",
"this",
"->",
"token",
".",
"\"' could not provide a valid stream.'\"",
")",
";",
"}",
"while",
"(",
"!",
"feof",
"(",
"$",
"stream",
")",
")",
"{",
"$",
"bytes",
"=",
"fread",
"(",
"$",
"stream",
",",
"8192",
")",
";",
"fwrite",
"(",
"$",
"out",
",",
"$",
"bytes",
")",
";",
"}",
"fclose",
"(",
"$",
"stream",
")",
";",
"fclose",
"(",
"$",
"out",
")",
";",
"}"
] |
Write the asset out to the corresponding file path.
@param $filePath
@throws AssetException
|
[
"Write",
"the",
"asset",
"out",
"to",
"the",
"corresponding",
"file",
"path",
"."
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/Assets/Asset.php#L105-L128
|
27,901
|
glorpen/GlorpenPropelBundle
|
src/Dispatcher/EventDispatcherProxy.php
|
EventDispatcherProxy.trigger
|
public static function trigger($name, Event $data)
{
if (self::$dispatcher) {
if (!is_array($name)) {
$name=array($name);
}
foreach ($name as $n) {
call_user_func_array(self::$dispatcher, self::$dispatcher_args)->dispatch($n, $data);
}
}
}
|
php
|
public static function trigger($name, Event $data)
{
if (self::$dispatcher) {
if (!is_array($name)) {
$name=array($name);
}
foreach ($name as $n) {
call_user_func_array(self::$dispatcher, self::$dispatcher_args)->dispatch($n, $data);
}
}
}
|
[
"public",
"static",
"function",
"trigger",
"(",
"$",
"name",
",",
"Event",
"$",
"data",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"dispatcher",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"array",
"(",
"$",
"name",
")",
";",
"}",
"foreach",
"(",
"$",
"name",
"as",
"$",
"n",
")",
"{",
"call_user_func_array",
"(",
"self",
"::",
"$",
"dispatcher",
",",
"self",
"::",
"$",
"dispatcher_args",
")",
"->",
"dispatch",
"(",
"$",
"n",
",",
"$",
"data",
")",
";",
"}",
"}",
"}"
] |
Triggers event.
@param string $name
@param Event $data one of Glorpen\Propel\PropelBundle\Events
|
[
"Triggers",
"event",
"."
] |
b679c83377c81ab582de179f84bc23eaeb1e86aa
|
https://github.com/glorpen/GlorpenPropelBundle/blob/b679c83377c81ab582de179f84bc23eaeb1e86aa/src/Dispatcher/EventDispatcherProxy.php#L33-L43
|
27,902
|
mediact/testing-suite
|
src/ProjectTypeResolver.php
|
ProjectTypeResolver.resolve
|
public function resolve(): string
{
$packageType = $this->composer->getPackage()->getType();
return array_key_exists($packageType, $this->mapping)
? $this->mapping[$packageType]
: 'default';
}
|
php
|
public function resolve(): string
{
$packageType = $this->composer->getPackage()->getType();
return array_key_exists($packageType, $this->mapping)
? $this->mapping[$packageType]
: 'default';
}
|
[
"public",
"function",
"resolve",
"(",
")",
":",
"string",
"{",
"$",
"packageType",
"=",
"$",
"this",
"->",
"composer",
"->",
"getPackage",
"(",
")",
"->",
"getType",
"(",
")",
";",
"return",
"array_key_exists",
"(",
"$",
"packageType",
",",
"$",
"this",
"->",
"mapping",
")",
"?",
"$",
"this",
"->",
"mapping",
"[",
"$",
"packageType",
"]",
":",
"'default'",
";",
"}"
] |
Get the type.
@return string
|
[
"Get",
"the",
"type",
"."
] |
98614fe3b5c174e9bda2ff88d36d30349094dbc2
|
https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/ProjectTypeResolver.php#L42-L48
|
27,903
|
mediact/testing-suite
|
src/ConfigResolver.php
|
ConfigResolver.resolve
|
public function resolve(): array
{
$file = sprintf($this->template, $this->typeResolver->resolve());
if (!file_exists($file)) {
$file = sprintf($this->template, 'default');
}
return json_decode(file_get_contents($file), true);
}
|
php
|
public function resolve(): array
{
$file = sprintf($this->template, $this->typeResolver->resolve());
if (!file_exists($file)) {
$file = sprintf($this->template, 'default');
}
return json_decode(file_get_contents($file), true);
}
|
[
"public",
"function",
"resolve",
"(",
")",
":",
"array",
"{",
"$",
"file",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"$",
"this",
"->",
"typeResolver",
"->",
"resolve",
"(",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"file",
"=",
"sprintf",
"(",
"$",
"this",
"->",
"template",
",",
"'default'",
")",
";",
"}",
"return",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
",",
"true",
")",
";",
"}"
] |
Resolve config.
@return array
|
[
"Resolve",
"config",
"."
] |
98614fe3b5c174e9bda2ff88d36d30349094dbc2
|
https://github.com/mediact/testing-suite/blob/98614fe3b5c174e9bda2ff88d36d30349094dbc2/src/ConfigResolver.php#L36-L45
|
27,904
|
RhubarbPHP/Rhubarb
|
src/String/StringTools.php
|
StringTools.implodeIgnoringBlanks
|
public static function implodeIgnoringBlanks($glue, $array, $itemCallback = null, $keysToInclude = null)
{
$array = array_filter($array);
if (!empty($itemCallback)) {
foreach ($array as $key => $value) {
$array[$key] = $itemCallback($value);
}
}
$keys = [$keysToInclude];
for ($i = 4; $i < func_num_args(); $i++) {
$keys[] = func_get_arg($i);
}
$keys = array_filter($keys);
$string = "";
if (count($keys)) {
foreach ($keys as $key) {
if (!empty($array[$key])) {
$string .= $array[$key] . $glue;
}
}
if (strlen($string) >= strlen($glue)) {
$string = substr($string, 0, strlen($string) - strlen($glue));
}
} else {
$string = implode($glue, $array);
}
return $string;
}
|
php
|
public static function implodeIgnoringBlanks($glue, $array, $itemCallback = null, $keysToInclude = null)
{
$array = array_filter($array);
if (!empty($itemCallback)) {
foreach ($array as $key => $value) {
$array[$key] = $itemCallback($value);
}
}
$keys = [$keysToInclude];
for ($i = 4; $i < func_num_args(); $i++) {
$keys[] = func_get_arg($i);
}
$keys = array_filter($keys);
$string = "";
if (count($keys)) {
foreach ($keys as $key) {
if (!empty($array[$key])) {
$string .= $array[$key] . $glue;
}
}
if (strlen($string) >= strlen($glue)) {
$string = substr($string, 0, strlen($string) - strlen($glue));
}
} else {
$string = implode($glue, $array);
}
return $string;
}
|
[
"public",
"static",
"function",
"implodeIgnoringBlanks",
"(",
"$",
"glue",
",",
"$",
"array",
",",
"$",
"itemCallback",
"=",
"null",
",",
"$",
"keysToInclude",
"=",
"null",
")",
"{",
"$",
"array",
"=",
"array_filter",
"(",
"$",
"array",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"itemCallback",
")",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"itemCallback",
"(",
"$",
"value",
")",
";",
"}",
"}",
"$",
"keys",
"=",
"[",
"$",
"keysToInclude",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"4",
";",
"$",
"i",
"<",
"func_num_args",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"keys",
"[",
"]",
"=",
"func_get_arg",
"(",
"$",
"i",
")",
";",
"}",
"$",
"keys",
"=",
"array_filter",
"(",
"$",
"keys",
")",
";",
"$",
"string",
"=",
"\"\"",
";",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
")",
"{",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"string",
".=",
"$",
"array",
"[",
"$",
"key",
"]",
".",
"$",
"glue",
";",
"}",
"}",
"if",
"(",
"strlen",
"(",
"$",
"string",
")",
">=",
"strlen",
"(",
"$",
"glue",
")",
")",
"{",
"$",
"string",
"=",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"strlen",
"(",
"$",
"string",
")",
"-",
"strlen",
"(",
"$",
"glue",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"string",
"=",
"implode",
"(",
"$",
"glue",
",",
"$",
"array",
")",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Removes all blanks in an array and merges them into a string
@param string $glue String to include between each element
@param array $array Array containing elements to be imploded
@param string $itemCallback A transformation closure to call on each element of the array
@param string $keysToInclude,... Keys of the array elements to include - if not supplied, all elements will be used
@return string String of concatenated elements
|
[
"Removes",
"all",
"blanks",
"in",
"an",
"array",
"and",
"merges",
"them",
"into",
"a",
"string"
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L35-L69
|
27,905
|
RhubarbPHP/Rhubarb
|
src/String/StringTools.php
|
StringTools.makeSingular
|
public static function makeSingular($plural)
{
$plurals = ["ies" => "y", "es" => "", "s" => ""];
foreach ($plurals as $pluralEnding => $singularEnding) {
$plural = preg_replace("/" . $pluralEnding . "$/i", $singularEnding, $plural);
}
return $plural;
}
|
php
|
public static function makeSingular($plural)
{
$plurals = ["ies" => "y", "es" => "", "s" => ""];
foreach ($plurals as $pluralEnding => $singularEnding) {
$plural = preg_replace("/" . $pluralEnding . "$/i", $singularEnding, $plural);
}
return $plural;
}
|
[
"public",
"static",
"function",
"makeSingular",
"(",
"$",
"plural",
")",
"{",
"$",
"plurals",
"=",
"[",
"\"ies\"",
"=>",
"\"y\"",
",",
"\"es\"",
"=>",
"\"\"",
",",
"\"s\"",
"=>",
"\"\"",
"]",
";",
"foreach",
"(",
"$",
"plurals",
"as",
"$",
"pluralEnding",
"=>",
"$",
"singularEnding",
")",
"{",
"$",
"plural",
"=",
"preg_replace",
"(",
"\"/\"",
".",
"$",
"pluralEnding",
".",
"\"$/i\"",
",",
"$",
"singularEnding",
",",
"$",
"plural",
")",
";",
"}",
"return",
"$",
"plural",
";",
"}"
] |
Returns the English singular form of a plural word.
@param $plural
@return string
|
[
"Returns",
"the",
"English",
"singular",
"form",
"of",
"a",
"plural",
"word",
"."
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L89-L98
|
27,906
|
RhubarbPHP/Rhubarb
|
src/String/StringTools.php
|
StringTools.makePlural
|
public static function makePlural($singular)
{
$singulars = [
'ey' => 'eys',
'day' => 'days',
"ch" => "ches",
"s" => "ses",
"x" => "xes",
"y" => "ies",
];
foreach ($singulars as $singularEnding => $pluralEnding) {
if (preg_match("/" . $singularEnding . "$/i", $singular)) {
return preg_replace("/" . $singularEnding . "$/i", $pluralEnding, $singular);
}
}
return $singular . "s";
}
|
php
|
public static function makePlural($singular)
{
$singulars = [
'ey' => 'eys',
'day' => 'days',
"ch" => "ches",
"s" => "ses",
"x" => "xes",
"y" => "ies",
];
foreach ($singulars as $singularEnding => $pluralEnding) {
if (preg_match("/" . $singularEnding . "$/i", $singular)) {
return preg_replace("/" . $singularEnding . "$/i", $pluralEnding, $singular);
}
}
return $singular . "s";
}
|
[
"public",
"static",
"function",
"makePlural",
"(",
"$",
"singular",
")",
"{",
"$",
"singulars",
"=",
"[",
"'ey'",
"=>",
"'eys'",
",",
"'day'",
"=>",
"'days'",
",",
"\"ch\"",
"=>",
"\"ches\"",
",",
"\"s\"",
"=>",
"\"ses\"",
",",
"\"x\"",
"=>",
"\"xes\"",
",",
"\"y\"",
"=>",
"\"ies\"",
",",
"]",
";",
"foreach",
"(",
"$",
"singulars",
"as",
"$",
"singularEnding",
"=>",
"$",
"pluralEnding",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/\"",
".",
"$",
"singularEnding",
".",
"\"$/i\"",
",",
"$",
"singular",
")",
")",
"{",
"return",
"preg_replace",
"(",
"\"/\"",
".",
"$",
"singularEnding",
".",
"\"$/i\"",
",",
"$",
"pluralEnding",
",",
"$",
"singular",
")",
";",
"}",
"}",
"return",
"$",
"singular",
".",
"\"s\"",
";",
"}"
] |
Returns the English plural form of a singular word.
@param $singular
@return mixed|string
|
[
"Returns",
"the",
"English",
"plural",
"form",
"of",
"a",
"singular",
"word",
"."
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L107-L125
|
27,907
|
RhubarbPHP/Rhubarb
|
src/String/StringTools.php
|
StringTools.replaceFirst
|
public static function replaceFirst($search, $replace, $subject, $caseSensitive = true)
{
if ($caseSensitive) {
$pos = strpos($subject, $search);
} else {
$pos = stripos($subject, $search);
}
if ($pos !== false) {
return substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
}
|
php
|
public static function replaceFirst($search, $replace, $subject, $caseSensitive = true)
{
if ($caseSensitive) {
$pos = strpos($subject, $search);
} else {
$pos = stripos($subject, $search);
}
if ($pos !== false) {
return substr_replace($subject, $replace, $pos, strlen($search));
}
return $subject;
}
|
[
"public",
"static",
"function",
"replaceFirst",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseSensitive",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"caseSensitive",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"subject",
",",
"$",
"search",
")",
";",
"}",
"else",
"{",
"$",
"pos",
"=",
"stripos",
"(",
"$",
"subject",
",",
"$",
"search",
")",
";",
"}",
"if",
"(",
"$",
"pos",
"!==",
"false",
")",
"{",
"return",
"substr_replace",
"(",
"$",
"subject",
",",
"$",
"replace",
",",
"$",
"pos",
",",
"strlen",
"(",
"$",
"search",
")",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}"
] |
Replaces only the first matched instance of a string
@param string $search
@param string $replace
@param string $subject
@param bool $caseSensitive
@return mixed
|
[
"Replaces",
"only",
"the",
"first",
"matched",
"instance",
"of",
"a",
"string"
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L391-L402
|
27,908
|
RhubarbPHP/Rhubarb
|
src/String/StringTools.php
|
StringTools.camelCaseToSeparated
|
public static function camelCaseToSeparated($string, $separator = '-', $toLowerCase = true)
{
$separated = preg_replace(['/([a-z\d])([A-Z])/', '/([^' . preg_quote($separator) . '])([A-Z][a-z])/'], '$1' . $separator . '$2', $string);
return $toLowerCase ? strtolower($separated) : $separated;
}
|
php
|
public static function camelCaseToSeparated($string, $separator = '-', $toLowerCase = true)
{
$separated = preg_replace(['/([a-z\d])([A-Z])/', '/([^' . preg_quote($separator) . '])([A-Z][a-z])/'], '$1' . $separator . '$2', $string);
return $toLowerCase ? strtolower($separated) : $separated;
}
|
[
"public",
"static",
"function",
"camelCaseToSeparated",
"(",
"$",
"string",
",",
"$",
"separator",
"=",
"'-'",
",",
"$",
"toLowerCase",
"=",
"true",
")",
"{",
"$",
"separated",
"=",
"preg_replace",
"(",
"[",
"'/([a-z\\d])([A-Z])/'",
",",
"'/([^'",
".",
"preg_quote",
"(",
"$",
"separator",
")",
".",
"'])([A-Z][a-z])/'",
"]",
",",
"'$1'",
".",
"$",
"separator",
".",
"'$2'",
",",
"$",
"string",
")",
";",
"return",
"$",
"toLowerCase",
"?",
"strtolower",
"(",
"$",
"separated",
")",
":",
"$",
"separated",
";",
"}"
] |
Converts a string from CamelCasing to separated-words, with specifiable separator and lowercase conversion.
@param $string
@param string $separator The character to separate the words with
@param bool $toLowerCase
@return string
|
[
"Converts",
"a",
"string",
"from",
"CamelCasing",
"to",
"separated",
"-",
"words",
"with",
"specifiable",
"separator",
"and",
"lowercase",
"conversion",
"."
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L412-L416
|
27,909
|
RhubarbPHP/Rhubarb
|
src/String/StringTools.php
|
StringTools.detectHashTags
|
public static function detectHashTags($text, callable $formatHashTag = null, $url = '', $openLinksInNewWindow = true)
{
if ($formatHashTag == null) {
$formatHashTag = function ($hashTag) use ($url, $openLinksInNewWindow) {
return '<a href="' . $url . urlencode($hashTag) . ($openLinksInNewWindow ? ' target="_blank"' : '') . '">' . $hashTag . '</a>';
};
}
$hashTagRegex = '/(^|\s)(#\w+)($|[^<])/';
while (preg_match($hashTagRegex, $text, $match, PREG_OFFSET_CAPTURE)) {
list($hashTag, $index) = $match[2];
$text = substr($text, 0, $index) . $formatHashTag($hashTag) . strpos($text, $index + strlen($hashTag));
}
return $text;
}
|
php
|
public static function detectHashTags($text, callable $formatHashTag = null, $url = '', $openLinksInNewWindow = true)
{
if ($formatHashTag == null) {
$formatHashTag = function ($hashTag) use ($url, $openLinksInNewWindow) {
return '<a href="' . $url . urlencode($hashTag) . ($openLinksInNewWindow ? ' target="_blank"' : '') . '">' . $hashTag . '</a>';
};
}
$hashTagRegex = '/(^|\s)(#\w+)($|[^<])/';
while (preg_match($hashTagRegex, $text, $match, PREG_OFFSET_CAPTURE)) {
list($hashTag, $index) = $match[2];
$text = substr($text, 0, $index) . $formatHashTag($hashTag) . strpos($text, $index + strlen($hashTag));
}
return $text;
}
|
[
"public",
"static",
"function",
"detectHashTags",
"(",
"$",
"text",
",",
"callable",
"$",
"formatHashTag",
"=",
"null",
",",
"$",
"url",
"=",
"''",
",",
"$",
"openLinksInNewWindow",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"formatHashTag",
"==",
"null",
")",
"{",
"$",
"formatHashTag",
"=",
"function",
"(",
"$",
"hashTag",
")",
"use",
"(",
"$",
"url",
",",
"$",
"openLinksInNewWindow",
")",
"{",
"return",
"'<a href=\"'",
".",
"$",
"url",
".",
"urlencode",
"(",
"$",
"hashTag",
")",
".",
"(",
"$",
"openLinksInNewWindow",
"?",
"' target=\"_blank\"'",
":",
"''",
")",
".",
"'\">'",
".",
"$",
"hashTag",
".",
"'</a>'",
";",
"}",
";",
"}",
"$",
"hashTagRegex",
"=",
"'/(^|\\s)(#\\w+)($|[^<])/'",
";",
"while",
"(",
"preg_match",
"(",
"$",
"hashTagRegex",
",",
"$",
"text",
",",
"$",
"match",
",",
"PREG_OFFSET_CAPTURE",
")",
")",
"{",
"list",
"(",
"$",
"hashTag",
",",
"$",
"index",
")",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"$",
"text",
"=",
"substr",
"(",
"$",
"text",
",",
"0",
",",
"$",
"index",
")",
".",
"$",
"formatHashTag",
"(",
"$",
"hashTag",
")",
".",
"strpos",
"(",
"$",
"text",
",",
"$",
"index",
"+",
"strlen",
"(",
"$",
"hashTag",
")",
")",
";",
"}",
"return",
"$",
"text",
";",
"}"
] |
Detects HashTags in a string and calls a callback function for each. Default behaviour is to insert HTML links for each HashTag.
@param string $text String to find HashTags in
@param callable|null $formatHashTag Will be called for each HashTag detected. If null, default behaviour will happen (inserting a link for each HashTag)
@param string $url If $formatHashTag is not set, this will prefix any linked HashTag
@param bool $openLinksInNewWindow If $formatHashTag is not set, created links will open in new browser window
@return string
|
[
"Detects",
"HashTags",
"in",
"a",
"string",
"and",
"calls",
"a",
"callback",
"function",
"for",
"each",
".",
"Default",
"behaviour",
"is",
"to",
"insert",
"HTML",
"links",
"for",
"each",
"HashTag",
"."
] |
327ff1f05d6a7e651d41c8e771f3551acfac18ae
|
https://github.com/RhubarbPHP/Rhubarb/blob/327ff1f05d6a7e651d41c8e771f3551acfac18ae/src/String/StringTools.php#L458-L473
|
27,910
|
byjg/cache-engine-php
|
src/Psr16/FileSystemCacheEngine.php
|
FileSystemCacheEngine.lock
|
public function lock($key)
{
$this->logger->info("[Filesystem cache] Lock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
try {
file_put_contents($lockFile, date('c'));
} catch (Exception $ex) {
// Ignoring... Set will cause an error
}
}
|
php
|
public function lock($key)
{
$this->logger->info("[Filesystem cache] Lock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
try {
file_put_contents($lockFile, date('c'));
} catch (Exception $ex) {
// Ignoring... Set will cause an error
}
}
|
[
"public",
"function",
"lock",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"[Filesystem cache] Lock '$key'\"",
")",
";",
"$",
"lockFile",
"=",
"$",
"this",
"->",
"fixKey",
"(",
"$",
"key",
")",
".",
"\".lock\"",
";",
"try",
"{",
"file_put_contents",
"(",
"$",
"lockFile",
",",
"date",
"(",
"'c'",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"// Ignoring... Set will cause an error",
"}",
"}"
] |
Lock resource before set it.
@param string $key
|
[
"Lock",
"resource",
"before",
"set",
"it",
"."
] |
001281edc3be6d908e7865b836cb6b43bd61a5cc
|
https://github.com/byjg/cache-engine-php/blob/001281edc3be6d908e7865b836cb6b43bd61a5cc/src/Psr16/FileSystemCacheEngine.php#L130-L141
|
27,911
|
byjg/cache-engine-php
|
src/Psr16/FileSystemCacheEngine.php
|
FileSystemCacheEngine.unlock
|
public function unlock($key)
{
$this->logger->info("[Filesystem cache] Unlock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
if (file_exists($lockFile)) {
unlink($lockFile);
}
}
|
php
|
public function unlock($key)
{
$this->logger->info("[Filesystem cache] Unlock '$key'");
$lockFile = $this->fixKey($key) . ".lock";
if (file_exists($lockFile)) {
unlink($lockFile);
}
}
|
[
"public",
"function",
"unlock",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"[Filesystem cache] Unlock '$key'\"",
")",
";",
"$",
"lockFile",
"=",
"$",
"this",
"->",
"fixKey",
"(",
"$",
"key",
")",
".",
"\".lock\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"lockFile",
")",
")",
"{",
"unlink",
"(",
"$",
"lockFile",
")",
";",
"}",
"}"
] |
UnLock resource after set it.
@param string $key
|
[
"UnLock",
"resource",
"after",
"set",
"it",
"."
] |
001281edc3be6d908e7865b836cb6b43bd61a5cc
|
https://github.com/byjg/cache-engine-php/blob/001281edc3be6d908e7865b836cb6b43bd61a5cc/src/Psr16/FileSystemCacheEngine.php#L147-L157
|
27,912
|
FoxyCart/foxyclient-php
|
src/Foxy/FoxyClient/FoxyClient.php
|
FoxyClient.saveLinks
|
public function saveLinks($data)
{
if (isset($data['_links'])) {
foreach ($data['_links'] as $rel => $link) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel != 'curies'
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
} else if (isset($data['links'])) {
foreach ($data['links'] as $link) {
foreach ($link['rel'] as $rel) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
}
}
}
|
php
|
public function saveLinks($data)
{
if (isset($data['_links'])) {
foreach ($data['_links'] as $rel => $link) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel != 'curies'
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
} else if (isset($data['links'])) {
foreach ($data['links'] as $link) {
foreach ($link['rel'] as $rel) {
if (!in_array($rel, $this->registered_link_relations)
&& $rel.'/' != static::LINK_RELATIONSHIPS_BASE_URI) {
$this->links[$rel] = $link['href'];
}
}
}
}
}
|
[
"public",
"function",
"saveLinks",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'_links'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'_links'",
"]",
"as",
"$",
"rel",
"=>",
"$",
"link",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"rel",
",",
"$",
"this",
"->",
"registered_link_relations",
")",
"&&",
"$",
"rel",
"!=",
"'curies'",
"&&",
"$",
"rel",
".",
"'/'",
"!=",
"static",
"::",
"LINK_RELATIONSHIPS_BASE_URI",
")",
"{",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"=",
"$",
"link",
"[",
"'href'",
"]",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'links'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'links'",
"]",
"as",
"$",
"link",
")",
"{",
"foreach",
"(",
"$",
"link",
"[",
"'rel'",
"]",
"as",
"$",
"rel",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"rel",
",",
"$",
"this",
"->",
"registered_link_relations",
")",
"&&",
"$",
"rel",
".",
"'/'",
"!=",
"static",
"::",
"LINK_RELATIONSHIPS_BASE_URI",
")",
"{",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"=",
"$",
"link",
"[",
"'href'",
"]",
";",
"}",
"}",
"}",
"}",
"}"
] |
Save Links to the Object For Easy Retrieval Later
|
[
"Save",
"Links",
"to",
"the",
"Object",
"For",
"Easy",
"Retrieval",
"Later"
] |
592fb81ec14afb04d6463682454c4d2263db4a04
|
https://github.com/FoxyCart/foxyclient-php/blob/592fb81ec14afb04d6463682454c4d2263db4a04/src/Foxy/FoxyClient/FoxyClient.php#L294-L314
|
27,913
|
FoxyCart/foxyclient-php
|
src/Foxy/FoxyClient/FoxyClient.php
|
FoxyClient.getErrors
|
public function getErrors($data)
{
$errors = array();
if ($this->getLastStatusCode() >= 400) {
if (isset($data['error_description'])) {
$errors[] = $data['error_description'];
} elseif (isset($data['_embedded']['fx:errors'])) {
foreach ($data['_embedded']['fx:errors'] as $error) {
$errors[] = $error['message'];
}
} else {
$errors[] = 'No data returned.';
}
}
return $errors;
}
|
php
|
public function getErrors($data)
{
$errors = array();
if ($this->getLastStatusCode() >= 400) {
if (isset($data['error_description'])) {
$errors[] = $data['error_description'];
} elseif (isset($data['_embedded']['fx:errors'])) {
foreach ($data['_embedded']['fx:errors'] as $error) {
$errors[] = $error['message'];
}
} else {
$errors[] = 'No data returned.';
}
}
return $errors;
}
|
[
"public",
"function",
"getErrors",
"(",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getLastStatusCode",
"(",
")",
">=",
"400",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'error_description'",
"]",
")",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"data",
"[",
"'error_description'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"data",
"[",
"'_embedded'",
"]",
"[",
"'fx:errors'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"[",
"'_embedded'",
"]",
"[",
"'fx:errors'",
"]",
"as",
"$",
"error",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"$",
"error",
"[",
"'message'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"errors",
"[",
"]",
"=",
"'No data returned.'",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Return any errors that exist in the response data.
|
[
"Return",
"any",
"errors",
"that",
"exist",
"in",
"the",
"response",
"data",
"."
] |
592fb81ec14afb04d6463682454c4d2263db4a04
|
https://github.com/FoxyCart/foxyclient-php/blob/592fb81ec14afb04d6463682454c4d2263db4a04/src/Foxy/FoxyClient/FoxyClient.php#L356-L371
|
27,914
|
FoxyCart/foxyclient-php
|
src/Foxy/FoxyClient/FoxyClient.php
|
FoxyClient.getHeaders
|
public function getHeaders()
{
$headers = array(
'FOXY-API-VERSION' => 1
);
if ($this->access_token && $this->include_auth_header) {
$headers['Authorization'] = "Bearer " . $this->access_token;
}
$headers['Accept'] = $this->getAcceptContentType();
return $headers;
}
|
php
|
public function getHeaders()
{
$headers = array(
'FOXY-API-VERSION' => 1
);
if ($this->access_token && $this->include_auth_header) {
$headers['Authorization'] = "Bearer " . $this->access_token;
}
$headers['Accept'] = $this->getAcceptContentType();
return $headers;
}
|
[
"public",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
"'FOXY-API-VERSION'",
"=>",
"1",
")",
";",
"if",
"(",
"$",
"this",
"->",
"access_token",
"&&",
"$",
"this",
"->",
"include_auth_header",
")",
"{",
"$",
"headers",
"[",
"'Authorization'",
"]",
"=",
"\"Bearer \"",
".",
"$",
"this",
"->",
"access_token",
";",
"}",
"$",
"headers",
"[",
"'Accept'",
"]",
"=",
"$",
"this",
"->",
"getAcceptContentType",
"(",
")",
";",
"return",
"$",
"headers",
";",
"}"
] |
Get headers for this call
|
[
"Get",
"headers",
"for",
"this",
"call"
] |
592fb81ec14afb04d6463682454c4d2263db4a04
|
https://github.com/FoxyCart/foxyclient-php/blob/592fb81ec14afb04d6463682454c4d2263db4a04/src/Foxy/FoxyClient/FoxyClient.php#L398-L409
|
27,915
|
ldaptools/ldaptools
|
src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php
|
AuthenticationOperationHandler.getAuthenticationResponse
|
protected function getAuthenticationResponse(AuthenticationOperation $operation)
{
$authenticated = false;
$errorMessage = null;
$errorCode = null;
// Only catch a bind failure. Let the others through, as it's probably a sign of other issues.
try {
$authenticated = (bool) $this->connection->close()->connect(...$operation->getArguments());
} catch (LdapBindException $e) {
$errorMessage = $this->connection->getLastError();
$errorCode = $this->connection->getExtendedErrorNumber();
}
return new AuthenticationResponse($authenticated, $errorMessage, $errorCode);
}
|
php
|
protected function getAuthenticationResponse(AuthenticationOperation $operation)
{
$authenticated = false;
$errorMessage = null;
$errorCode = null;
// Only catch a bind failure. Let the others through, as it's probably a sign of other issues.
try {
$authenticated = (bool) $this->connection->close()->connect(...$operation->getArguments());
} catch (LdapBindException $e) {
$errorMessage = $this->connection->getLastError();
$errorCode = $this->connection->getExtendedErrorNumber();
}
return new AuthenticationResponse($authenticated, $errorMessage, $errorCode);
}
|
[
"protected",
"function",
"getAuthenticationResponse",
"(",
"AuthenticationOperation",
"$",
"operation",
")",
"{",
"$",
"authenticated",
"=",
"false",
";",
"$",
"errorMessage",
"=",
"null",
";",
"$",
"errorCode",
"=",
"null",
";",
"// Only catch a bind failure. Let the others through, as it's probably a sign of other issues.",
"try",
"{",
"$",
"authenticated",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"connection",
"->",
"close",
"(",
")",
"->",
"connect",
"(",
"...",
"$",
"operation",
"->",
"getArguments",
"(",
")",
")",
";",
"}",
"catch",
"(",
"LdapBindException",
"$",
"e",
")",
"{",
"$",
"errorMessage",
"=",
"$",
"this",
"->",
"connection",
"->",
"getLastError",
"(",
")",
";",
"$",
"errorCode",
"=",
"$",
"this",
"->",
"connection",
"->",
"getExtendedErrorNumber",
"(",
")",
";",
"}",
"return",
"new",
"AuthenticationResponse",
"(",
"$",
"authenticated",
",",
"$",
"errorMessage",
",",
"$",
"errorCode",
")",
";",
"}"
] |
Attempts to connect with the given credentials and returns the response.
@param AuthenticationOperation $operation
@return AuthenticationResponse
|
[
"Attempts",
"to",
"connect",
"with",
"the",
"given",
"credentials",
"and",
"returns",
"the",
"response",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php#L66-L81
|
27,916
|
ldaptools/ldaptools
|
src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php
|
AuthenticationOperationHandler.switchCredentials
|
protected function switchCredentials(AuthenticationOperation $operation)
{
$this->connection->getConfig()->setUsername($operation->getUsername());
$this->connection->getConfig()->setPassword($operation->getPassword());
}
|
php
|
protected function switchCredentials(AuthenticationOperation $operation)
{
$this->connection->getConfig()->setUsername($operation->getUsername());
$this->connection->getConfig()->setPassword($operation->getPassword());
}
|
[
"protected",
"function",
"switchCredentials",
"(",
"AuthenticationOperation",
"$",
"operation",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"setUsername",
"(",
"$",
"operation",
"->",
"getUsername",
"(",
")",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"setPassword",
"(",
"$",
"operation",
"->",
"getPassword",
"(",
")",
")",
";",
"}"
] |
If the operation requested that the credentials be switched, then update the credential information in the
connections config. Otherwise it will switch again on other auth-attempts or re-connects.
@param AuthenticationOperation $operation
|
[
"If",
"the",
"operation",
"requested",
"that",
"the",
"credentials",
"be",
"switched",
"then",
"update",
"the",
"credential",
"information",
"in",
"the",
"connections",
"config",
".",
"Otherwise",
"it",
"will",
"switch",
"again",
"on",
"other",
"auth",
"-",
"attempts",
"or",
"re",
"-",
"connects",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Handler/AuthenticationOperationHandler.php#L89-L93
|
27,917
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ADTimeSpan.php
|
ADTimeSpan.getLdapValue
|
public function getLdapValue()
{
if ($this->never) {
$value = self::NEVER;
} else {
$total = 0;
foreach (self::UNIT as $unit => $conversion) {
$total += $this->$unit * $conversion;
}
$value = number_format($total, 0, '.', '');
}
return $value;
}
|
php
|
public function getLdapValue()
{
if ($this->never) {
$value = self::NEVER;
} else {
$total = 0;
foreach (self::UNIT as $unit => $conversion) {
$total += $this->$unit * $conversion;
}
$value = number_format($total, 0, '.', '');
}
return $value;
}
|
[
"public",
"function",
"getLdapValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"never",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"NEVER",
";",
"}",
"else",
"{",
"$",
"total",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"UNIT",
"as",
"$",
"unit",
"=>",
"$",
"conversion",
")",
"{",
"$",
"total",
"+=",
"$",
"this",
"->",
"$",
"unit",
"*",
"$",
"conversion",
";",
"}",
"$",
"value",
"=",
"number_format",
"(",
"$",
"total",
",",
"0",
",",
"'.'",
",",
"''",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Get the value of all the time units in the format that LDAP expects it in.
@return string
|
[
"Get",
"the",
"value",
"of",
"all",
"the",
"time",
"units",
"in",
"the",
"format",
"that",
"LDAP",
"expects",
"it",
"in",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L214-L227
|
27,918
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ADTimeSpan.php
|
ADTimeSpan.getInstance
|
public static function getInstance($value, $unit)
{
if (!array_key_exists($unit, self::UNIT)) {
throw new InvalidArgumentException('Time unit "%s" is not recognized.', $unit);
}
$setter = 'set'.ucfirst($unit);
return (new self)->$setter($value);
}
|
php
|
public static function getInstance($value, $unit)
{
if (!array_key_exists($unit, self::UNIT)) {
throw new InvalidArgumentException('Time unit "%s" is not recognized.', $unit);
}
$setter = 'set'.ucfirst($unit);
return (new self)->$setter($value);
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"$",
"value",
",",
"$",
"unit",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"unit",
",",
"self",
"::",
"UNIT",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Time unit \"%s\" is not recognized.'",
",",
"$",
"unit",
")",
";",
"}",
"$",
"setter",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"unit",
")",
";",
"return",
"(",
"new",
"self",
")",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"}"
] |
Get an instance of the class based on a specific time unit as the second parameter.
@param int $value The time value.
@param string $unit The time unit. One of the constants of this class: DAYS, HOURS, MINUTES, SECONDS.
@return $this
|
[
"Get",
"an",
"instance",
"of",
"the",
"class",
"based",
"on",
"a",
"specific",
"time",
"unit",
"as",
"the",
"second",
"parameter",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L236-L244
|
27,919
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ADTimeSpan.php
|
ADTimeSpan.setAndVerify
|
protected function setAndVerify($value, $interval)
{
if (!filter_var($value, FILTER_VALIDATE_INT) && $value != '0') {
throw new InvalidArgumentException(sprintf("The %s should be an integer.", $interval));
}
$this->$interval = $value;
}
|
php
|
protected function setAndVerify($value, $interval)
{
if (!filter_var($value, FILTER_VALIDATE_INT) && $value != '0') {
throw new InvalidArgumentException(sprintf("The %s should be an integer.", $interval));
}
$this->$interval = $value;
}
|
[
"protected",
"function",
"setAndVerify",
"(",
"$",
"value",
",",
"$",
"interval",
")",
"{",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"value",
",",
"FILTER_VALIDATE_INT",
")",
"&&",
"$",
"value",
"!=",
"'0'",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"The %s should be an integer.\"",
",",
"$",
"interval",
")",
")",
";",
"}",
"$",
"this",
"->",
"$",
"interval",
"=",
"$",
"value",
";",
"}"
] |
Verify the value is an integer and set the correct interval value.
@param int $value
@param string $interval
|
[
"Verify",
"the",
"value",
"is",
"an",
"integer",
"and",
"set",
"the",
"correct",
"interval",
"value",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L270-L276
|
27,920
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ADTimeSpan.php
|
ADTimeSpan.setValuesFromLdap
|
protected function setValuesFromLdap($time)
{
if ($time == self::NEVER) {
$this->setNever(true);
} else {
$seconds = $time / self::UNIT[self::SECONDS];
$dtBase = new \DateTime('@0');
$dtSeconds = new \DateTime('@' . $seconds);
$this->setDays($dtBase->diff($dtSeconds)->format('%a'));
$this->setHours($dtBase->diff($dtSeconds)->format('%h'));
$this->setMinutes($dtBase->diff($dtSeconds)->format('%i'));
$this->setSeconds($dtBase->diff($dtSeconds)->format('%s'));
}
}
|
php
|
protected function setValuesFromLdap($time)
{
if ($time == self::NEVER) {
$this->setNever(true);
} else {
$seconds = $time / self::UNIT[self::SECONDS];
$dtBase = new \DateTime('@0');
$dtSeconds = new \DateTime('@' . $seconds);
$this->setDays($dtBase->diff($dtSeconds)->format('%a'));
$this->setHours($dtBase->diff($dtSeconds)->format('%h'));
$this->setMinutes($dtBase->diff($dtSeconds)->format('%i'));
$this->setSeconds($dtBase->diff($dtSeconds)->format('%s'));
}
}
|
[
"protected",
"function",
"setValuesFromLdap",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"$",
"time",
"==",
"self",
"::",
"NEVER",
")",
"{",
"$",
"this",
"->",
"setNever",
"(",
"true",
")",
";",
"}",
"else",
"{",
"$",
"seconds",
"=",
"$",
"time",
"/",
"self",
"::",
"UNIT",
"[",
"self",
"::",
"SECONDS",
"]",
";",
"$",
"dtBase",
"=",
"new",
"\\",
"DateTime",
"(",
"'@0'",
")",
";",
"$",
"dtSeconds",
"=",
"new",
"\\",
"DateTime",
"(",
"'@'",
".",
"$",
"seconds",
")",
";",
"$",
"this",
"->",
"setDays",
"(",
"$",
"dtBase",
"->",
"diff",
"(",
"$",
"dtSeconds",
")",
"->",
"format",
"(",
"'%a'",
")",
")",
";",
"$",
"this",
"->",
"setHours",
"(",
"$",
"dtBase",
"->",
"diff",
"(",
"$",
"dtSeconds",
")",
"->",
"format",
"(",
"'%h'",
")",
")",
";",
"$",
"this",
"->",
"setMinutes",
"(",
"$",
"dtBase",
"->",
"diff",
"(",
"$",
"dtSeconds",
")",
"->",
"format",
"(",
"'%i'",
")",
")",
";",
"$",
"this",
"->",
"setSeconds",
"(",
"$",
"dtBase",
"->",
"diff",
"(",
"$",
"dtSeconds",
")",
"->",
"format",
"(",
"'%s'",
")",
")",
";",
"}",
"}"
] |
Given a time format from LDAP break it down into its individual time units and set them.
@param int $time
|
[
"Given",
"a",
"time",
"format",
"from",
"LDAP",
"break",
"it",
"down",
"into",
"its",
"individual",
"time",
"units",
"and",
"set",
"them",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ADTimeSpan.php#L283-L298
|
27,921
|
ldaptools/ldaptools
|
src/LdapTools/Log/LoggerChain.php
|
LoggerChain.start
|
public function start(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->start($operation);
}
}
|
php
|
public function start(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->start($operation);
}
}
|
[
"public",
"function",
"start",
"(",
"LogOperation",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"start",
"(",
"$",
"operation",
")",
";",
"}",
"}"
] |
The start of a logging operation. Initiated on each logger in the chain.
@param LogOperation $operation
|
[
"The",
"start",
"of",
"a",
"logging",
"operation",
".",
"Initiated",
"on",
"each",
"logger",
"in",
"the",
"chain",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Log/LoggerChain.php#L40-L45
|
27,922
|
ldaptools/ldaptools
|
src/LdapTools/Log/LoggerChain.php
|
LoggerChain.end
|
public function end(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->end($operation);
}
}
|
php
|
public function end(LogOperation $operation)
{
foreach ($this->loggers as $logger) {
$logger->end($operation);
}
}
|
[
"public",
"function",
"end",
"(",
"LogOperation",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loggers",
"as",
"$",
"logger",
")",
"{",
"$",
"logger",
"->",
"end",
"(",
"$",
"operation",
")",
";",
"}",
"}"
] |
The end of a logging operation. Initiated on each logger in the chain.
@param LogOperation $operation
|
[
"The",
"end",
"of",
"a",
"logging",
"operation",
".",
"Initiated",
"on",
"each",
"logger",
"in",
"the",
"chain",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Log/LoggerChain.php#L52-L57
|
27,923
|
ldaptools/ldaptools
|
src/LdapTools/Operation/AuthenticationOperation.php
|
AuthenticationOperation.validateArguments
|
protected function validateArguments()
{
if ($this->getIsAnonymousBind()) {
return;
}
if (empty($this->properties['username']) || empty($this->properties['password'])) {
throw new LdapBindException("You must specify a username and password.");
}
}
|
php
|
protected function validateArguments()
{
if ($this->getIsAnonymousBind()) {
return;
}
if (empty($this->properties['username']) || empty($this->properties['password'])) {
throw new LdapBindException("You must specify a username and password.");
}
}
|
[
"protected",
"function",
"validateArguments",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getIsAnonymousBind",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"properties",
"[",
"'username'",
"]",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"properties",
"[",
"'password'",
"]",
")",
")",
"{",
"throw",
"new",
"LdapBindException",
"(",
"\"You must specify a username and password.\"",
")",
";",
"}",
"}"
] |
Validates that the arguments given don't have any issues.
@throws LdapBindException
|
[
"Validates",
"that",
"the",
"arguments",
"given",
"don",
"t",
"have",
"any",
"issues",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/AuthenticationOperation.php#L190-L198
|
27,924
|
ldaptools/ldaptools
|
src/LdapTools/Query/Operator/bNot.php
|
bNot.isOperatorAllowed
|
protected function isOperatorAllowed(BaseOperator $operator)
{
if (!empty($this->children)) {
throw new \RuntimeException('The "Not" operator can only have 1 child operator.');
}
if ($operator instanceof ContainsOperatorsInterface) {
throw new LdapQueryException('Cannot add an operator to bNot that can contain other operators.');
}
}
|
php
|
protected function isOperatorAllowed(BaseOperator $operator)
{
if (!empty($this->children)) {
throw new \RuntimeException('The "Not" operator can only have 1 child operator.');
}
if ($operator instanceof ContainsOperatorsInterface) {
throw new LdapQueryException('Cannot add an operator to bNot that can contain other operators.');
}
}
|
[
"protected",
"function",
"isOperatorAllowed",
"(",
"BaseOperator",
"$",
"operator",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"children",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The \"Not\" operator can only have 1 child operator.'",
")",
";",
"}",
"if",
"(",
"$",
"operator",
"instanceof",
"ContainsOperatorsInterface",
")",
"{",
"throw",
"new",
"LdapQueryException",
"(",
"'Cannot add an operator to bNot that can contain other operators.'",
")",
";",
"}",
"}"
] |
The 'Not' operator has a few specific requirements. Check these here.
@param BaseOperator $operator
@throws LdapQueryException
|
[
"The",
"Not",
"operator",
"has",
"a",
"few",
"specific",
"requirements",
".",
"Check",
"these",
"here",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/bNot.php#L53-L61
|
27,925
|
ldaptools/ldaptools
|
src/LdapTools/Ldif/Entry/LdifEntryModify.php
|
LdifEntryModify.add
|
public function add($attribute, $value)
{
$this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value));
return $this;
}
|
php
|
public function add($attribute, $value)
{
$this->batches->add(new Batch(Batch::TYPE['ADD'], $attribute, $value));
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"batches",
"->",
"add",
"(",
"new",
"Batch",
"(",
"Batch",
"::",
"TYPE",
"[",
"'ADD'",
"]",
",",
"$",
"attribute",
",",
"$",
"value",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a value to the attribute for the LDAP object.
@param $attribute
@param $value
@return $this
|
[
"Add",
"a",
"value",
"to",
"the",
"attribute",
"for",
"the",
"LDAP",
"object",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryModify.php#L87-L92
|
27,926
|
ldaptools/ldaptools
|
src/LdapTools/Security/Acl/Acl.php
|
Acl.setRevision
|
public function setRevision($revision)
{
if (!in_array((int) $revision, self::REVISION)) {
throw new InvalidArgumentException(sprintf(
'The value "%s" is not a recognized revision number. Allowed revisions are: %s',
$revision,
implode(', ', self::REVISION)
));
}
$this->revision = (int) $revision;
return $this;
}
|
php
|
public function setRevision($revision)
{
if (!in_array((int) $revision, self::REVISION)) {
throw new InvalidArgumentException(sprintf(
'The value "%s" is not a recognized revision number. Allowed revisions are: %s',
$revision,
implode(', ', self::REVISION)
));
}
$this->revision = (int) $revision;
return $this;
}
|
[
"public",
"function",
"setRevision",
"(",
"$",
"revision",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"(",
"int",
")",
"$",
"revision",
",",
"self",
"::",
"REVISION",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The value \"%s\" is not a recognized revision number. Allowed revisions are: %s'",
",",
"$",
"revision",
",",
"implode",
"(",
"', '",
",",
"self",
"::",
"REVISION",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"revision",
"=",
"(",
"int",
")",
"$",
"revision",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the revision of the ACL.
@param int $revision
@return $this
|
[
"Set",
"the",
"revision",
"of",
"the",
"ACL",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L89-L101
|
27,927
|
ldaptools/ldaptools
|
src/LdapTools/Security/Acl/Acl.php
|
Acl.addAce
|
public function addAce(Ace ...$aces)
{
foreach ($aces as $ace) {
$this->validateAce($ace);
if (!$this->hasAce($ace)) {
$this->aces[] = $ace;
}
}
return $this;
}
|
php
|
public function addAce(Ace ...$aces)
{
foreach ($aces as $ace) {
$this->validateAce($ace);
if (!$this->hasAce($ace)) {
$this->aces[] = $ace;
}
}
return $this;
}
|
[
"public",
"function",
"addAce",
"(",
"Ace",
"...",
"$",
"aces",
")",
"{",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"this",
"->",
"validateAce",
"(",
"$",
"ace",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAce",
"(",
"$",
"ace",
")",
")",
"{",
"$",
"this",
"->",
"aces",
"[",
"]",
"=",
"$",
"ace",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add one or more ACEs to the ACL.
@param Ace[] ...$aces
@return $this
|
[
"Add",
"one",
"or",
"more",
"ACEs",
"to",
"the",
"ACL",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L168-L178
|
27,928
|
ldaptools/ldaptools
|
src/LdapTools/Security/Acl/Acl.php
|
Acl.removeAce
|
public function removeAce(Ace ...$aces)
{
foreach ($aces as $ace) {
if ($this->hasAce($ace)) {
unset($this->aces[array_search($ace, $this->aces)]);
}
}
return $this;
}
|
php
|
public function removeAce(Ace ...$aces)
{
foreach ($aces as $ace) {
if ($this->hasAce($ace)) {
unset($this->aces[array_search($ace, $this->aces)]);
}
}
return $this;
}
|
[
"public",
"function",
"removeAce",
"(",
"Ace",
"...",
"$",
"aces",
")",
"{",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAce",
"(",
"$",
"ace",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"aces",
"[",
"array_search",
"(",
"$",
"ace",
",",
"$",
"this",
"->",
"aces",
")",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove one or more ACEs from the ACL.
@param Ace[] ...$aces
@return $this
|
[
"Remove",
"one",
"or",
"more",
"ACEs",
"from",
"the",
"ACL",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L186-L195
|
27,929
|
ldaptools/ldaptools
|
src/LdapTools/Security/Acl/Acl.php
|
Acl.hasAce
|
public function hasAce(Ace ...$aces)
{
$inArray = false;
foreach ($aces as $ace) {
$inArray = in_array($ace, $this->aces, true);
}
return $inArray;
}
|
php
|
public function hasAce(Ace ...$aces)
{
$inArray = false;
foreach ($aces as $ace) {
$inArray = in_array($ace, $this->aces, true);
}
return $inArray;
}
|
[
"public",
"function",
"hasAce",
"(",
"Ace",
"...",
"$",
"aces",
")",
"{",
"$",
"inArray",
"=",
"false",
";",
"foreach",
"(",
"$",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"inArray",
"=",
"in_array",
"(",
"$",
"ace",
",",
"$",
"this",
"->",
"aces",
",",
"true",
")",
";",
"}",
"return",
"$",
"inArray",
";",
"}"
] |
Check if an ACE, or multiple ACEs, exist within this ACL.
@param Ace[] ...$aces
@return bool
|
[
"Check",
"if",
"an",
"ACE",
"or",
"multiple",
"ACEs",
"exist",
"within",
"this",
"ACL",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L203-L212
|
27,930
|
ldaptools/ldaptools
|
src/LdapTools/Security/Acl/Acl.php
|
Acl.toBinary
|
public function toBinary()
{
$aces = '';
foreach ($this->aces as $ace) {
$aces .= $ace->toBinary();
}
return pack(
'C1C1v1v1v1',
$this->revision,
$this->sbz1,
((16 + (strlen(bin2hex($aces)))) / 2),
count($this->aces),
$this->sbz2
).$aces;
}
|
php
|
public function toBinary()
{
$aces = '';
foreach ($this->aces as $ace) {
$aces .= $ace->toBinary();
}
return pack(
'C1C1v1v1v1',
$this->revision,
$this->sbz1,
((16 + (strlen(bin2hex($aces)))) / 2),
count($this->aces),
$this->sbz2
).$aces;
}
|
[
"public",
"function",
"toBinary",
"(",
")",
"{",
"$",
"aces",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"aces",
".=",
"$",
"ace",
"->",
"toBinary",
"(",
")",
";",
"}",
"return",
"pack",
"(",
"'C1C1v1v1v1'",
",",
"$",
"this",
"->",
"revision",
",",
"$",
"this",
"->",
"sbz1",
",",
"(",
"(",
"16",
"+",
"(",
"strlen",
"(",
"bin2hex",
"(",
"$",
"aces",
")",
")",
")",
")",
"/",
"2",
")",
",",
"count",
"(",
"$",
"this",
"->",
"aces",
")",
",",
"$",
"this",
"->",
"sbz2",
")",
".",
"$",
"aces",
";",
"}"
] |
Get the binary string representation of the ACL.
@return string
|
[
"Get",
"the",
"binary",
"string",
"representation",
"of",
"the",
"ACL",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Acl.php#L229-L244
|
27,931
|
ldaptools/ldaptools
|
src/LdapTools/Connection/RootDse.php
|
RootDse.get
|
public function get()
{
$anonymous = !$this->connection->isBound();
try {
$rootDse = self::doLdapQuery($anonymous);
} catch (\Exception $e) {
throw new LdapConnectionException(sprintf(
'Unable to query the RootDSE. %s',
$e->getMessage()
), $e->getCode());
} finally {
// Make sure to set things back to how they were...
if ($anonymous && $this->connection->isBound()) {
$this->connection->close();
}
}
return $rootDse;
}
|
php
|
public function get()
{
$anonymous = !$this->connection->isBound();
try {
$rootDse = self::doLdapQuery($anonymous);
} catch (\Exception $e) {
throw new LdapConnectionException(sprintf(
'Unable to query the RootDSE. %s',
$e->getMessage()
), $e->getCode());
} finally {
// Make sure to set things back to how they were...
if ($anonymous && $this->connection->isBound()) {
$this->connection->close();
}
}
return $rootDse;
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"$",
"anonymous",
"=",
"!",
"$",
"this",
"->",
"connection",
"->",
"isBound",
"(",
")",
";",
"try",
"{",
"$",
"rootDse",
"=",
"self",
"::",
"doLdapQuery",
"(",
"$",
"anonymous",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"'Unable to query the RootDSE. %s'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"finally",
"{",
"// Make sure to set things back to how they were...",
"if",
"(",
"$",
"anonymous",
"&&",
"$",
"this",
"->",
"connection",
"->",
"isBound",
"(",
")",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"close",
"(",
")",
";",
"}",
"}",
"return",
"$",
"rootDse",
";",
"}"
] |
Get the RootDSE LdapObject while accounting for the state of the connection.
@return \LdapTools\Object\LdapObject
@throws LdapConnectionException
|
[
"Get",
"the",
"RootDSE",
"LdapObject",
"while",
"accounting",
"for",
"the",
"state",
"of",
"the",
"connection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/RootDse.php#L73-L92
|
27,932
|
ldaptools/ldaptools
|
src/LdapTools/Connection/RootDse.php
|
RootDse.doLdapQuery
|
protected function doLdapQuery($anonymous)
{
if ($anonymous) {
$this->connection->connect('', '', true);
}
$schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
}
|
php
|
protected function doLdapQuery($anonymous)
{
if ($anonymous) {
$this->connection->connect('', '', true);
}
$schema = $this->schemaFactory->get(self::SCHEMA_ROOTDSE_NAME, $this->connection->getConfig()->getLdapType());
return (new LdapQueryBuilder($this->connection))->from($schema)->select('*')->getLdapQuery()->getSingleResult();
}
|
[
"protected",
"function",
"doLdapQuery",
"(",
"$",
"anonymous",
")",
"{",
"if",
"(",
"$",
"anonymous",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"connect",
"(",
"''",
",",
"''",
",",
"true",
")",
";",
"}",
"$",
"schema",
"=",
"$",
"this",
"->",
"schemaFactory",
"->",
"get",
"(",
"self",
"::",
"SCHEMA_ROOTDSE_NAME",
",",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getLdapType",
"(",
")",
")",
";",
"return",
"(",
"new",
"LdapQueryBuilder",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"->",
"from",
"(",
"$",
"schema",
")",
"->",
"select",
"(",
"'*'",
")",
"->",
"getLdapQuery",
"(",
")",
"->",
"getSingleResult",
"(",
")",
";",
"}"
] |
Do the LDAP query to get the LDAP object.
@param bool $anonymous
@return \LdapTools\Object\LdapObject
|
[
"Do",
"the",
"LDAP",
"query",
"to",
"get",
"the",
"LDAP",
"object",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/RootDse.php#L100-L108
|
27,933
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/TSPropertyArray.php
|
TSPropertyArray.toBinary
|
public function toBinary()
{
$binary = hex2bin(str_pad(dechex(ord($this->signature)), 2, 0, STR_PAD_LEFT));
$binary .= hex2bin(str_pad(dechex(count($this->tsProperty)), 2, 0, STR_PAD_LEFT));
foreach ($this->tsProperty as $tsProperty) {
$binary .= $tsProperty->toBinary();
}
return $binary;
}
|
php
|
public function toBinary()
{
$binary = hex2bin(str_pad(dechex(ord($this->signature)), 2, 0, STR_PAD_LEFT));
$binary .= hex2bin(str_pad(dechex(count($this->tsProperty)), 2, 0, STR_PAD_LEFT));
foreach ($this->tsProperty as $tsProperty) {
$binary .= $tsProperty->toBinary();
}
return $binary;
}
|
[
"public",
"function",
"toBinary",
"(",
")",
"{",
"$",
"binary",
"=",
"hex2bin",
"(",
"str_pad",
"(",
"dechex",
"(",
"ord",
"(",
"$",
"this",
"->",
"signature",
")",
")",
",",
"2",
",",
"0",
",",
"STR_PAD_LEFT",
")",
")",
";",
"$",
"binary",
".=",
"hex2bin",
"(",
"str_pad",
"(",
"dechex",
"(",
"count",
"(",
"$",
"this",
"->",
"tsProperty",
")",
")",
",",
"2",
",",
"0",
",",
"STR_PAD_LEFT",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"tsProperty",
"as",
"$",
"tsProperty",
")",
"{",
"$",
"binary",
".=",
"$",
"tsProperty",
"->",
"toBinary",
"(",
")",
";",
"}",
"return",
"$",
"binary",
";",
"}"
] |
Get the full binary representation of the userParameters containing the TSPropertyArray data.
@return string
|
[
"Get",
"the",
"full",
"binary",
"representation",
"of",
"the",
"userParameters",
"containing",
"the",
"TSPropertyArray",
"data",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TSPropertyArray.php#L163-L172
|
27,934
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/TSPropertyArray.php
|
TSPropertyArray.decode
|
protected function decode($tsPropArray)
{
$tsPropArray = bin2hex($tsPropArray);
// The signature is a 2-byte unicode character at the front
$this->signature = chr(hexdec(substr($tsPropArray, 0, 2)));
// The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray
// It starts at position 2. The actual variable data begins at position 4.
$length = $this->addTSPropData(substr($tsPropArray, 4), hexdec(substr($tsPropArray, 2, 2)));
// Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray
// This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there
if (strlen($tsPropArray) > (4 + $length)) {
$this->postBinary = hex2bin(substr($tsPropArray, (4 + $length)));
}
}
|
php
|
protected function decode($tsPropArray)
{
$tsPropArray = bin2hex($tsPropArray);
// The signature is a 2-byte unicode character at the front
$this->signature = chr(hexdec(substr($tsPropArray, 0, 2)));
// The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray
// It starts at position 2. The actual variable data begins at position 4.
$length = $this->addTSPropData(substr($tsPropArray, 4), hexdec(substr($tsPropArray, 2, 2)));
// Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray
// This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there
if (strlen($tsPropArray) > (4 + $length)) {
$this->postBinary = hex2bin(substr($tsPropArray, (4 + $length)));
}
}
|
[
"protected",
"function",
"decode",
"(",
"$",
"tsPropArray",
")",
"{",
"$",
"tsPropArray",
"=",
"bin2hex",
"(",
"$",
"tsPropArray",
")",
";",
"// The signature is a 2-byte unicode character at the front",
"$",
"this",
"->",
"signature",
"=",
"chr",
"(",
"hexdec",
"(",
"substr",
"(",
"$",
"tsPropArray",
",",
"0",
",",
"2",
")",
")",
")",
";",
"// The property count is a 2-byte unsigned integer indicating the number of elements for the tsPropertyArray",
"// It starts at position 2. The actual variable data begins at position 4.",
"$",
"length",
"=",
"$",
"this",
"->",
"addTSPropData",
"(",
"substr",
"(",
"$",
"tsPropArray",
",",
"4",
")",
",",
"hexdec",
"(",
"substr",
"(",
"$",
"tsPropArray",
",",
"2",
",",
"2",
")",
")",
")",
";",
"// Reserved data length + (count and sig length == 4) + the added lengths of the TSPropertyArray",
"// This saves anything after that variable TSPropertyArray data, so as to not squash anything stored there",
"if",
"(",
"strlen",
"(",
"$",
"tsPropArray",
")",
">",
"(",
"4",
"+",
"$",
"length",
")",
")",
"{",
"$",
"this",
"->",
"postBinary",
"=",
"hex2bin",
"(",
"substr",
"(",
"$",
"tsPropArray",
",",
"(",
"4",
"+",
"$",
"length",
")",
")",
")",
";",
"}",
"}"
] |
Given the TSPropertyArray binary data, extract out all of the TSProperty values.
@param string $tsPropArray
@return array
|
[
"Given",
"the",
"TSPropertyArray",
"binary",
"data",
"extract",
"out",
"all",
"of",
"the",
"TSProperty",
"values",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TSPropertyArray.php#L255-L268
|
27,935
|
ldaptools/ldaptools
|
src/LdapTools/Query/OperatorCollection.php
|
OperatorCollection.add
|
public function add(BaseOperator ...$operators)
{
foreach ($operators as $operator) {
if ($operator instanceof bAnd) {
$this->operators['and'][] = $operator;
} elseif ($operator instanceof bOr) {
$this->operators['or'][] = $operator;
} elseif ($operator instanceof bNot) {
$this->operators['not'][] = $operator;
} elseif ($operator instanceof Wildcard) {
$this->operators['wildcard'][] = $operator;
} elseif ($operator instanceof MatchingRule) {
$this->operators['matchingrule'][] = $operator;
} elseif ($operator instanceof Comparison) {
$this->operators['comparison'][] = $operator;
} else {
throw new InvalidArgumentException('Unknown operator type.');
}
}
return $this;
}
|
php
|
public function add(BaseOperator ...$operators)
{
foreach ($operators as $operator) {
if ($operator instanceof bAnd) {
$this->operators['and'][] = $operator;
} elseif ($operator instanceof bOr) {
$this->operators['or'][] = $operator;
} elseif ($operator instanceof bNot) {
$this->operators['not'][] = $operator;
} elseif ($operator instanceof Wildcard) {
$this->operators['wildcard'][] = $operator;
} elseif ($operator instanceof MatchingRule) {
$this->operators['matchingrule'][] = $operator;
} elseif ($operator instanceof Comparison) {
$this->operators['comparison'][] = $operator;
} else {
throw new InvalidArgumentException('Unknown operator type.');
}
}
return $this;
}
|
[
"public",
"function",
"add",
"(",
"BaseOperator",
"...",
"$",
"operators",
")",
"{",
"foreach",
"(",
"$",
"operators",
"as",
"$",
"operator",
")",
"{",
"if",
"(",
"$",
"operator",
"instanceof",
"bAnd",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'and'",
"]",
"[",
"]",
"=",
"$",
"operator",
";",
"}",
"elseif",
"(",
"$",
"operator",
"instanceof",
"bOr",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'or'",
"]",
"[",
"]",
"=",
"$",
"operator",
";",
"}",
"elseif",
"(",
"$",
"operator",
"instanceof",
"bNot",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'not'",
"]",
"[",
"]",
"=",
"$",
"operator",
";",
"}",
"elseif",
"(",
"$",
"operator",
"instanceof",
"Wildcard",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'wildcard'",
"]",
"[",
"]",
"=",
"$",
"operator",
";",
"}",
"elseif",
"(",
"$",
"operator",
"instanceof",
"MatchingRule",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'matchingrule'",
"]",
"[",
"]",
"=",
"$",
"operator",
";",
"}",
"elseif",
"(",
"$",
"operator",
"instanceof",
"Comparison",
")",
"{",
"$",
"this",
"->",
"operators",
"[",
"'comparison'",
"]",
"[",
"]",
"=",
"$",
"operator",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Unknown operator type.'",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add an Operator to the collection.
@param BaseOperator[] ...$operators
@return $this
@throws LdapQueryException
|
[
"Add",
"an",
"Operator",
"to",
"the",
"collection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L65-L86
|
27,936
|
ldaptools/ldaptools
|
src/LdapTools/Query/OperatorCollection.php
|
OperatorCollection.addLdapObjectSchema
|
public function addLdapObjectSchema(LdapObjectSchema $schema, $alias = null)
{
if (!is_null($alias) && !is_string($alias)) {
throw new InvalidArgumentException(sprintf(
'The alias for type "%s" must be a string, but "%s" was given.',
$schema->getObjectType(),
is_string($alias) ? $alias : gettype($alias)
));
}
$alias = $alias ?: $schema->getObjectType();
if (!preg_match(self::ALIAS_REGEX, $alias)) {
throw new InvalidArgumentException(sprintf(
'The alias "%s" for type "%s" is invalid. Allowed characters are: A-Z, a-z, 0-9, -, _',
$alias,
$schema->getObjectType()
));
}
$this->aliases[$alias] = $schema;
}
|
php
|
public function addLdapObjectSchema(LdapObjectSchema $schema, $alias = null)
{
if (!is_null($alias) && !is_string($alias)) {
throw new InvalidArgumentException(sprintf(
'The alias for type "%s" must be a string, but "%s" was given.',
$schema->getObjectType(),
is_string($alias) ? $alias : gettype($alias)
));
}
$alias = $alias ?: $schema->getObjectType();
if (!preg_match(self::ALIAS_REGEX, $alias)) {
throw new InvalidArgumentException(sprintf(
'The alias "%s" for type "%s" is invalid. Allowed characters are: A-Z, a-z, 0-9, -, _',
$alias,
$schema->getObjectType()
));
}
$this->aliases[$alias] = $schema;
}
|
[
"public",
"function",
"addLdapObjectSchema",
"(",
"LdapObjectSchema",
"$",
"schema",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"alias",
")",
"&&",
"!",
"is_string",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The alias for type \"%s\" must be a string, but \"%s\" was given.'",
",",
"$",
"schema",
"->",
"getObjectType",
"(",
")",
",",
"is_string",
"(",
"$",
"alias",
")",
"?",
"$",
"alias",
":",
"gettype",
"(",
"$",
"alias",
")",
")",
")",
";",
"}",
"$",
"alias",
"=",
"$",
"alias",
"?",
":",
"$",
"schema",
"->",
"getObjectType",
"(",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"ALIAS_REGEX",
",",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The alias \"%s\" for type \"%s\" is invalid. Allowed characters are: A-Z, a-z, 0-9, -, _'",
",",
"$",
"alias",
",",
"$",
"schema",
"->",
"getObjectType",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"aliases",
"[",
"$",
"alias",
"]",
"=",
"$",
"schema",
";",
"}"
] |
Add a LdapObjectSchema for a object type that will be selected for. Optionally specify a specific alias that is
used to reference it. If no alias is specified, then it uses the object type name for the schema.
@param LdapObjectSchema $schema
@param null|string $alias
|
[
"Add",
"a",
"LdapObjectSchema",
"for",
"a",
"object",
"type",
"that",
"will",
"be",
"selected",
"for",
".",
"Optionally",
"specify",
"a",
"specific",
"alias",
"that",
"is",
"used",
"to",
"reference",
"it",
".",
"If",
"no",
"alias",
"is",
"specified",
"then",
"it",
"uses",
"the",
"object",
"type",
"name",
"for",
"the",
"schema",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L95-L114
|
27,937
|
ldaptools/ldaptools
|
src/LdapTools/Query/OperatorCollection.php
|
OperatorCollection.toLdapFilter
|
public function toLdapFilter($alias = null)
{
if (is_null($alias) && !empty($this->aliases)) {
$filter = $this->getLdapFilterForAliases();
} else {
$filter = $this->getLdapFilter($alias);
}
return $filter;
}
|
php
|
public function toLdapFilter($alias = null)
{
if (is_null($alias) && !empty($this->aliases)) {
$filter = $this->getLdapFilterForAliases();
} else {
$filter = $this->getLdapFilter($alias);
}
return $filter;
}
|
[
"public",
"function",
"toLdapFilter",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"alias",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"aliases",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"getLdapFilterForAliases",
"(",
")",
";",
"}",
"else",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"getLdapFilter",
"(",
"$",
"alias",
")",
";",
"}",
"return",
"$",
"filter",
";",
"}"
] |
Get the LDAP filter string representation of all the operators in the collection.
@param string|null $alias The alias to narrow the filter to.
@return string
|
[
"Get",
"the",
"LDAP",
"filter",
"string",
"representation",
"of",
"all",
"the",
"operators",
"in",
"the",
"collection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L212-L221
|
27,938
|
ldaptools/ldaptools
|
src/LdapTools/Query/OperatorCollection.php
|
OperatorCollection.sortOperatorsToArray
|
protected function sortOperatorsToArray()
{
return array_merge(
$this->operators['and'],
$this->operators['or'],
$this->operators['not'],
$this->operators['comparison'],
$this->operators['wildcard'],
$this->operators['matchingrule']
);
}
|
php
|
protected function sortOperatorsToArray()
{
return array_merge(
$this->operators['and'],
$this->operators['or'],
$this->operators['not'],
$this->operators['comparison'],
$this->operators['wildcard'],
$this->operators['matchingrule']
);
}
|
[
"protected",
"function",
"sortOperatorsToArray",
"(",
")",
"{",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"operators",
"[",
"'and'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'or'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'not'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'comparison'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'wildcard'",
"]",
",",
"$",
"this",
"->",
"operators",
"[",
"'matchingrule'",
"]",
")",
";",
"}"
] |
Merges all the Operators into one large array in a specific order. Before doing so, it will apply any schemas
that exist.
@return BaseOperator[]
@throws LdapQueryException
|
[
"Merges",
"all",
"the",
"Operators",
"into",
"one",
"large",
"array",
"in",
"a",
"specific",
"order",
".",
"Before",
"doing",
"so",
"it",
"will",
"apply",
"any",
"schemas",
"that",
"exist",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L242-L252
|
27,939
|
ldaptools/ldaptools
|
src/LdapTools/Query/OperatorCollection.php
|
OperatorCollection.getLdapFilterForAliases
|
protected function getLdapFilterForAliases()
{
$filters = [];
foreach (array_keys($this->aliases) as $alias) {
$filters[] = $this->getLdapFilter($alias);
}
if (count($filters) == 1) {
return $filters[0];
} else {
return bOr::SEPARATOR_START.bOr::SYMBOL.implode('', $filters).bOr::SEPARATOR_END;
}
}
|
php
|
protected function getLdapFilterForAliases()
{
$filters = [];
foreach (array_keys($this->aliases) as $alias) {
$filters[] = $this->getLdapFilter($alias);
}
if (count($filters) == 1) {
return $filters[0];
} else {
return bOr::SEPARATOR_START.bOr::SYMBOL.implode('', $filters).bOr::SEPARATOR_END;
}
}
|
[
"protected",
"function",
"getLdapFilterForAliases",
"(",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"aliases",
")",
"as",
"$",
"alias",
")",
"{",
"$",
"filters",
"[",
"]",
"=",
"$",
"this",
"->",
"getLdapFilter",
"(",
"$",
"alias",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"filters",
")",
"==",
"1",
")",
"{",
"return",
"$",
"filters",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"bOr",
"::",
"SEPARATOR_START",
".",
"bOr",
"::",
"SYMBOL",
".",
"implode",
"(",
"''",
",",
"$",
"filters",
")",
".",
"bOr",
"::",
"SEPARATOR_END",
";",
"}",
"}"
] |
Constructs a filter for multiple aliases that would return the requested LDAP objects in a single query.
@return string
|
[
"Constructs",
"a",
"filter",
"for",
"multiple",
"aliases",
"that",
"would",
"return",
"the",
"requested",
"LDAP",
"objects",
"in",
"a",
"single",
"query",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/OperatorCollection.php#L286-L299
|
27,940
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ConverterUtilitiesTrait.php
|
ConverterUtilitiesTrait.getCurrentLdapAttributeValue
|
protected function getCurrentLdapAttributeValue($attribute)
{
if (!$this->getDn() || !$this->getLdapConnection()) {
throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
}
$query = new LdapQueryBuilder($this->getLdapConnection());
try {
return $query->select($attribute)
->where($query->filter()->present('objectClass'))
->setBaseDn($this->getDn())
->setScopeBase()
->getLdapQuery()
->getSingleScalarOrNullResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
}
}
|
php
|
protected function getCurrentLdapAttributeValue($attribute)
{
if (!$this->getDn() || !$this->getLdapConnection()) {
throw new AttributeConverterException(sprintf('Unable to query for the current "%s" attribute.', $attribute));
}
$query = new LdapQueryBuilder($this->getLdapConnection());
try {
return $query->select($attribute)
->where($query->filter()->present('objectClass'))
->setBaseDn($this->getDn())
->setScopeBase()
->getLdapQuery()
->getSingleScalarOrNullResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf('Unable to find LDAP object: %s', $this->getDn()));
}
}
|
[
"protected",
"function",
"getCurrentLdapAttributeValue",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getDn",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"getLdapConnection",
"(",
")",
")",
"{",
"throw",
"new",
"AttributeConverterException",
"(",
"sprintf",
"(",
"'Unable to query for the current \"%s\" attribute.'",
",",
"$",
"attribute",
")",
")",
";",
"}",
"$",
"query",
"=",
"new",
"LdapQueryBuilder",
"(",
"$",
"this",
"->",
"getLdapConnection",
"(",
")",
")",
";",
"try",
"{",
"return",
"$",
"query",
"->",
"select",
"(",
"$",
"attribute",
")",
"->",
"where",
"(",
"$",
"query",
"->",
"filter",
"(",
")",
"->",
"present",
"(",
"'objectClass'",
")",
")",
"->",
"setBaseDn",
"(",
"$",
"this",
"->",
"getDn",
"(",
")",
")",
"->",
"setScopeBase",
"(",
")",
"->",
"getLdapQuery",
"(",
")",
"->",
"getSingleScalarOrNullResult",
"(",
")",
";",
"}",
"catch",
"(",
"EmptyResultException",
"$",
"e",
")",
"{",
"throw",
"new",
"AttributeConverterException",
"(",
"sprintf",
"(",
"'Unable to find LDAP object: %s'",
",",
"$",
"this",
"->",
"getDn",
"(",
")",
")",
")",
";",
"}",
"}"
] |
This can be called to retrieve the current value of an attribute from LDAP.
@param string $attribute The attribute name to query for a value from the converter context
@return array|string|null
@throws AttributeConverterException
|
[
"This",
"can",
"be",
"called",
"to",
"retrieve",
"the",
"current",
"value",
"of",
"an",
"attribute",
"from",
"LDAP",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ConverterUtilitiesTrait.php#L69-L86
|
27,941
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ConverterUtilitiesTrait.php
|
ConverterUtilitiesTrait.modifyMultivaluedAttribute
|
protected function modifyMultivaluedAttribute(array $values, array $newValues)
{
if ($this->getOperationType() == AttributeConverterInterface::TYPE_CREATE || ($this->getBatch() && $this->getBatch()->isTypeAdd())) {
$values = array_merge($values, $newValues);
} elseif ($this->getBatch() && $this->getBatch()->isTypeReplace()) {
$values = $newValues;
} elseif ($this->getBatch() && $this->getBatch()->isTypeRemove()) {
$values = array_diff($values, $newValues);
}
return $values;
}
|
php
|
protected function modifyMultivaluedAttribute(array $values, array $newValues)
{
if ($this->getOperationType() == AttributeConverterInterface::TYPE_CREATE || ($this->getBatch() && $this->getBatch()->isTypeAdd())) {
$values = array_merge($values, $newValues);
} elseif ($this->getBatch() && $this->getBatch()->isTypeReplace()) {
$values = $newValues;
} elseif ($this->getBatch() && $this->getBatch()->isTypeRemove()) {
$values = array_diff($values, $newValues);
}
return $values;
}
|
[
"protected",
"function",
"modifyMultivaluedAttribute",
"(",
"array",
"$",
"values",
",",
"array",
"$",
"newValues",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getOperationType",
"(",
")",
"==",
"AttributeConverterInterface",
"::",
"TYPE_CREATE",
"||",
"(",
"$",
"this",
"->",
"getBatch",
"(",
")",
"&&",
"$",
"this",
"->",
"getBatch",
"(",
")",
"->",
"isTypeAdd",
"(",
")",
")",
")",
"{",
"$",
"values",
"=",
"array_merge",
"(",
"$",
"values",
",",
"$",
"newValues",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getBatch",
"(",
")",
"&&",
"$",
"this",
"->",
"getBatch",
"(",
")",
"->",
"isTypeReplace",
"(",
")",
")",
"{",
"$",
"values",
"=",
"$",
"newValues",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"getBatch",
"(",
")",
"&&",
"$",
"this",
"->",
"getBatch",
"(",
")",
"->",
"isTypeRemove",
"(",
")",
")",
"{",
"$",
"values",
"=",
"array_diff",
"(",
"$",
"values",
",",
"$",
"newValues",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] |
Modifies a multivalued attribute array based off the original values, the new values, and the modification type.
@param array $values
@param array $newValues
@return array
|
[
"Modifies",
"a",
"multivalued",
"attribute",
"array",
"based",
"off",
"the",
"original",
"values",
"the",
"new",
"values",
"and",
"the",
"modification",
"type",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ConverterUtilitiesTrait.php#L112-L123
|
27,942
|
ldaptools/ldaptools
|
src/LdapTools/Configuration.php
|
Configuration.getDomainConfiguration
|
public function getDomainConfiguration($domain = null)
{
if ($domain && isset($this->domains[$domain])) {
return $this->domains[$domain];
} elseif ($domain) {
throw new InvalidArgumentException(sprintf('Domain "%s" not found.', $domain));
} else {
return $this->domains;
}
}
|
php
|
public function getDomainConfiguration($domain = null)
{
if ($domain && isset($this->domains[$domain])) {
return $this->domains[$domain];
} elseif ($domain) {
throw new InvalidArgumentException(sprintf('Domain "%s" not found.', $domain));
} else {
return $this->domains;
}
}
|
[
"public",
"function",
"getDomainConfiguration",
"(",
"$",
"domain",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"domain",
"&&",
"isset",
"(",
"$",
"this",
"->",
"domains",
"[",
"$",
"domain",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"domains",
"[",
"$",
"domain",
"]",
";",
"}",
"elseif",
"(",
"$",
"domain",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Domain \"%s\" not found.'",
",",
"$",
"domain",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"domains",
";",
"}",
"}"
] |
Get the DomainConfiguration for a specific domain, or an array of all DomainConfiguration objects if none is
specified.
@param null|string $domain
@return DomainConfiguration[]|DomainConfiguration
|
[
"Get",
"the",
"DomainConfiguration",
"for",
"a",
"specific",
"domain",
"or",
"an",
"array",
"of",
"all",
"DomainConfiguration",
"objects",
"if",
"none",
"is",
"specified",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L98-L107
|
27,943
|
ldaptools/ldaptools
|
src/LdapTools/Configuration.php
|
Configuration.addDomain
|
public function addDomain(DomainConfiguration ...$domains)
{
foreach ($domains as $domain) {
$this->domains[$domain->getDomainName()] = $domain;
}
return $this;
}
|
php
|
public function addDomain(DomainConfiguration ...$domains)
{
foreach ($domains as $domain) {
$this->domains[$domain->getDomainName()] = $domain;
}
return $this;
}
|
[
"public",
"function",
"addDomain",
"(",
"DomainConfiguration",
"...",
"$",
"domains",
")",
"{",
"foreach",
"(",
"$",
"domains",
"as",
"$",
"domain",
")",
"{",
"$",
"this",
"->",
"domains",
"[",
"$",
"domain",
"->",
"getDomainName",
"(",
")",
"]",
"=",
"$",
"domain",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add domain configurations. Accepts an arbitrary amount of domain configurations.
@param DomainConfiguration $domains,...
@return $this
|
[
"Add",
"domain",
"configurations",
".",
"Accepts",
"an",
"arbitrary",
"amount",
"of",
"domain",
"configurations",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L115-L122
|
27,944
|
ldaptools/ldaptools
|
src/LdapTools/Configuration.php
|
Configuration.setSchemaFormat
|
public function setSchemaFormat($type)
{
if (!defined('\LdapTools\Factory\SchemaParserFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown schema format "%s".', $type));
}
$this->config['schemaFormat'] = $type;
return $this;
}
|
php
|
public function setSchemaFormat($type)
{
if (!defined('\LdapTools\Factory\SchemaParserFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown schema format "%s".', $type));
}
$this->config['schemaFormat'] = $type;
return $this;
}
|
[
"public",
"function",
"setSchemaFormat",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"defined",
"(",
"'\\LdapTools\\Factory\\SchemaParserFactory::TYPE_'",
".",
"strtoupper",
"(",
"$",
"type",
")",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Unknown schema format \"%s\".'",
",",
"$",
"type",
")",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"'schemaFormat'",
"]",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the schema definition format.
@param $type string The schema type (ie. yml).
@return $this
@throws ConfigurationException
|
[
"Set",
"the",
"schema",
"definition",
"format",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L181-L189
|
27,945
|
ldaptools/ldaptools
|
src/LdapTools/Configuration.php
|
Configuration.setCacheType
|
public function setCacheType($type)
{
trigger_error('The '.__METHOD__.' method is deprecated and will be removed in a later version. Use setCache() instead.', E_USER_DEPRECATED);
if (!defined('\LdapTools\Factory\CacheFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown cache type "%s".', $type));
}
$this->config['cacheType'] = $type;
return $this;
}
|
php
|
public function setCacheType($type)
{
trigger_error('The '.__METHOD__.' method is deprecated and will be removed in a later version. Use setCache() instead.', E_USER_DEPRECATED);
if (!defined('\LdapTools\Factory\CacheFactory::TYPE_'.strtoupper($type))) {
throw new ConfigurationException(sprintf('Unknown cache type "%s".', $type));
}
$this->config['cacheType'] = $type;
return $this;
}
|
[
"public",
"function",
"setCacheType",
"(",
"$",
"type",
")",
"{",
"trigger_error",
"(",
"'The '",
".",
"__METHOD__",
".",
"' method is deprecated and will be removed in a later version. Use setCache() instead.'",
",",
"E_USER_DEPRECATED",
")",
";",
"if",
"(",
"!",
"defined",
"(",
"'\\LdapTools\\Factory\\CacheFactory::TYPE_'",
".",
"strtoupper",
"(",
"$",
"type",
")",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Unknown cache type \"%s\".'",
",",
"$",
"type",
")",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"'cacheType'",
"]",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the cache type to use.
@param $type
@return $this
@throws ConfigurationException
@deprecated This function will be removed in a later version. Use setCache() instead.
|
[
"Set",
"the",
"cache",
"type",
"to",
"use",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L232-L242
|
27,946
|
ldaptools/ldaptools
|
src/LdapTools/Configuration.php
|
Configuration.loadDomainConfiguration
|
protected function loadDomainConfiguration(array $config)
{
try {
foreach ($config['domains'] as $domain => $options) {
$domain = new DomainConfiguration();
$domain->load($options);
$this->addDomain($domain);
}
} catch (ConfigurationException $e) {
throw new ConfigurationException(sprintf("Error in domain config section: %s", $e->getMessage()));
}
}
|
php
|
protected function loadDomainConfiguration(array $config)
{
try {
foreach ($config['domains'] as $domain => $options) {
$domain = new DomainConfiguration();
$domain->load($options);
$this->addDomain($domain);
}
} catch (ConfigurationException $e) {
throw new ConfigurationException(sprintf("Error in domain config section: %s", $e->getMessage()));
}
}
|
[
"protected",
"function",
"loadDomainConfiguration",
"(",
"array",
"$",
"config",
")",
"{",
"try",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'domains'",
"]",
"as",
"$",
"domain",
"=>",
"$",
"options",
")",
"{",
"$",
"domain",
"=",
"new",
"DomainConfiguration",
"(",
")",
";",
"$",
"domain",
"->",
"load",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"addDomain",
"(",
"$",
"domain",
")",
";",
"}",
"}",
"catch",
"(",
"ConfigurationException",
"$",
"e",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"\"Error in domain config section: %s\"",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Iterates through and loads the domain section of the configuration.
@param $config
@throws ConfigurationException
|
[
"Iterates",
"through",
"and",
"loads",
"the",
"domain",
"section",
"of",
"the",
"configuration",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Configuration.php#L410-L421
|
27,947
|
ldaptools/ldaptools
|
src/LdapTools/Factory/AttributeConverterFactory.php
|
AttributeConverterFactory.get
|
public static function get($name)
{
if (!isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(sprintf('Attribute converter "%s" is not valid.', $name));
}
return self::getInstanceOfConverter($name);
}
|
php
|
public static function get($name)
{
if (!isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(sprintf('Attribute converter "%s" is not valid.', $name));
}
return self::getInstanceOfConverter($name);
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Attribute converter \"%s\" is not valid.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"self",
"::",
"getInstanceOfConverter",
"(",
"$",
"name",
")",
";",
"}"
] |
Retrieve a registered attribute converter by name.
@param $name
@return AttributeConverterInterface
|
[
"Retrieve",
"a",
"registered",
"attribute",
"converter",
"by",
"name",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/AttributeConverterFactory.php#L66-L73
|
27,948
|
ldaptools/ldaptools
|
src/LdapTools/Factory/AttributeConverterFactory.php
|
AttributeConverterFactory.register
|
public static function register($name, $class)
{
if (isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(
sprintf('The attribute converter name "%s" is already registered.', $name)
);
}
self::$converterMap[$name] = $class;
}
|
php
|
public static function register($name, $class)
{
if (isset(self::$converterMap[$name])) {
throw new InvalidArgumentException(
sprintf('The attribute converter name "%s" is already registered.', $name)
);
}
self::$converterMap[$name] = $class;
}
|
[
"public",
"static",
"function",
"register",
"(",
"$",
"name",
",",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The attribute converter name \"%s\" is already registered.'",
",",
"$",
"name",
")",
")",
";",
"}",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
"=",
"$",
"class",
";",
"}"
] |
Registers a converter so it can be retrieved by its name.
@param string $name The actual name for the converter in the schema.
@param string $class The fully qualified class name (ie. '\Foo\Bar\Converter')
|
[
"Registers",
"a",
"converter",
"so",
"it",
"can",
"be",
"retrieved",
"by",
"its",
"name",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/AttributeConverterFactory.php#L81-L90
|
27,949
|
ldaptools/ldaptools
|
src/LdapTools/Factory/AttributeConverterFactory.php
|
AttributeConverterFactory.getInstanceOfConverter
|
protected static function getInstanceOfConverter($name)
{
try {
$converter = new self::$converterMap[$name]();
} catch (\Exception $e) {
throw new \RuntimeException(
sprintf('Unable to load attribute converter "%s": %s', $name, $e->getMessage())
);
}
if (!($converter instanceof AttributeConverterInterface)) {
throw new \RuntimeException(sprintf(
'The attribute converter "%s" must implement \LdapTools\AttributeConverter\AttributeConverterInterface.',
$name
));
}
return $converter;
}
|
php
|
protected static function getInstanceOfConverter($name)
{
try {
$converter = new self::$converterMap[$name]();
} catch (\Exception $e) {
throw new \RuntimeException(
sprintf('Unable to load attribute converter "%s": %s', $name, $e->getMessage())
);
}
if (!($converter instanceof AttributeConverterInterface)) {
throw new \RuntimeException(sprintf(
'The attribute converter "%s" must implement \LdapTools\AttributeConverter\AttributeConverterInterface.',
$name
));
}
return $converter;
}
|
[
"protected",
"static",
"function",
"getInstanceOfConverter",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"converter",
"=",
"new",
"self",
"::",
"$",
"converterMap",
"[",
"$",
"name",
"]",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Unable to load attribute converter \"%s\": %s'",
",",
"$",
"name",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"converter",
"instanceof",
"AttributeConverterInterface",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The attribute converter \"%s\" must implement \\LdapTools\\AttributeConverter\\AttributeConverterInterface.'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"converter",
";",
"}"
] |
Load a specific converter if needed and send it back.
@param string $name
@return AttributeConverterInterface
|
[
"Load",
"a",
"specific",
"converter",
"if",
"needed",
"and",
"send",
"it",
"back",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/AttributeConverterFactory.php#L98-L115
|
27,950
|
ldaptools/ldaptools
|
src/LdapTools/Ldif/Entry/LdifEntryTrait.php
|
LdifEntryTrait.addControlsToString
|
protected function addControlsToString($ldif)
{
foreach ($this->controls as $control) {
$value = $control->getOid().' '.$control->getCriticality();
if (!is_null($control->getValue())) {
$value .= ' '.$control->getValue();
}
$ldif .= $this->getLdifLine(Ldif::DIRECTIVE_CONTROL, $value);
}
return $ldif;
}
|
php
|
protected function addControlsToString($ldif)
{
foreach ($this->controls as $control) {
$value = $control->getOid().' '.$control->getCriticality();
if (!is_null($control->getValue())) {
$value .= ' '.$control->getValue();
}
$ldif .= $this->getLdifLine(Ldif::DIRECTIVE_CONTROL, $value);
}
return $ldif;
}
|
[
"protected",
"function",
"addControlsToString",
"(",
"$",
"ldif",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"controls",
"as",
"$",
"control",
")",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getOid",
"(",
")",
".",
"' '",
".",
"$",
"control",
"->",
"getCriticality",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"control",
"->",
"getValue",
"(",
")",
")",
")",
"{",
"$",
"value",
".=",
"' '",
".",
"$",
"control",
"->",
"getValue",
"(",
")",
";",
"}",
"$",
"ldif",
".=",
"$",
"this",
"->",
"getLdifLine",
"(",
"Ldif",
"::",
"DIRECTIVE_CONTROL",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"ldif",
";",
"}"
] |
Add any LDAP controls to the specified LDIF.
@param string $ldif
@return string
|
[
"Add",
"any",
"LDAP",
"controls",
"to",
"the",
"specified",
"LDIF",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryTrait.php#L145-L156
|
27,951
|
ldaptools/ldaptools
|
src/LdapTools/Ldif/Entry/LdifEntryTrait.php
|
LdifEntryTrait.isUnicodePwdHackNeeded
|
protected function isUnicodePwdHackNeeded()
{
if (!(isset($this->connection) && $this->connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD && isset($this->schema))) {
return false;
}
return $this->schema->hasNamesMappedToAttribute('unicodePwd');
}
|
php
|
protected function isUnicodePwdHackNeeded()
{
if (!(isset($this->connection) && $this->connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD && isset($this->schema))) {
return false;
}
return $this->schema->hasNamesMappedToAttribute('unicodePwd');
}
|
[
"protected",
"function",
"isUnicodePwdHackNeeded",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"this",
"->",
"connection",
")",
"&&",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getLdapType",
"(",
")",
"==",
"LdapConnection",
"::",
"TYPE_AD",
"&&",
"isset",
"(",
"$",
"this",
"->",
"schema",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"schema",
"->",
"hasNamesMappedToAttribute",
"(",
"'unicodePwd'",
")",
";",
"}"
] |
Determine if we might need to work around the unusual formatting for unicodePwd. This is pretty much the only
attribute that will ever need a special case for conversion for LDIF creation.
@todo How to get around this? Implementing another attribute conversion type for just a single attribute seems silly.
@link https://support.microsoft.com/en-us/kb/263991
@return bool
|
[
"Determine",
"if",
"we",
"might",
"need",
"to",
"work",
"around",
"the",
"unusual",
"formatting",
"for",
"unicodePwd",
".",
"This",
"is",
"pretty",
"much",
"the",
"only",
"attribute",
"that",
"will",
"ever",
"need",
"a",
"special",
"case",
"for",
"conversion",
"for",
"LDIF",
"creation",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Ldif/Entry/LdifEntryTrait.php#L183-L190
|
27,952
|
ldaptools/ldaptools
|
src/LdapTools/Security/Ace/AceType.php
|
AceType.setValue
|
public function setValue($type)
{
if (is_numeric($type) && in_array($type, self::TYPE)) {
$this->type = (int) $type;
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::TYPE)) {
$this->type = self::TYPE[strtoupper($type)];
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::SHORT_NAME)) {
$this->type = self::SHORT_NAME[strtoupper($type)];
} else {
throw new InvalidArgumentException(sprintf('The value "%s" is not a valid AceType.', $type));
}
return $this;
}
|
php
|
public function setValue($type)
{
if (is_numeric($type) && in_array($type, self::TYPE)) {
$this->type = (int) $type;
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::TYPE)) {
$this->type = self::TYPE[strtoupper($type)];
} elseif (is_string($type) && array_key_exists(strtoupper($type), self::SHORT_NAME)) {
$this->type = self::SHORT_NAME[strtoupper($type)];
} else {
throw new InvalidArgumentException(sprintf('The value "%s" is not a valid AceType.', $type));
}
return $this;
}
|
[
"public",
"function",
"setValue",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"type",
")",
"&&",
"in_array",
"(",
"$",
"type",
",",
"self",
"::",
"TYPE",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"(",
"int",
")",
"$",
"type",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"type",
")",
"&&",
"array_key_exists",
"(",
"strtoupper",
"(",
"$",
"type",
")",
",",
"self",
"::",
"TYPE",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"TYPE",
"[",
"strtoupper",
"(",
"$",
"type",
")",
"]",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"type",
")",
"&&",
"array_key_exists",
"(",
"strtoupper",
"(",
"$",
"type",
")",
",",
"self",
"::",
"SHORT_NAME",
")",
")",
"{",
"$",
"this",
"->",
"type",
"=",
"self",
"::",
"SHORT_NAME",
"[",
"strtoupper",
"(",
"$",
"type",
")",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The value \"%s\" is not a valid AceType.'",
",",
"$",
"type",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the type of the Ace.
@param string|int $type
@return $this
|
[
"Set",
"the",
"type",
"of",
"the",
"Ace",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Ace/AceType.php#L103-L116
|
27,953
|
ldaptools/ldaptools
|
src/LdapTools/Connection/LdapServerPool.php
|
LdapServerPool.getServer
|
public function getServer()
{
$servers = $this->getSortedServersArray();
foreach ($servers as $server) {
if ($this->isServerAvailable($server)) {
return $server;
}
}
throw new LdapConnectionException('No LDAP server is available.');
}
|
php
|
public function getServer()
{
$servers = $this->getSortedServersArray();
foreach ($servers as $server) {
if ($this->isServerAvailable($server)) {
return $server;
}
}
throw new LdapConnectionException('No LDAP server is available.');
}
|
[
"public",
"function",
"getServer",
"(",
")",
"{",
"$",
"servers",
"=",
"$",
"this",
"->",
"getSortedServersArray",
"(",
")",
";",
"foreach",
"(",
"$",
"servers",
"as",
"$",
"server",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isServerAvailable",
"(",
"$",
"server",
")",
")",
"{",
"return",
"$",
"server",
";",
"}",
"}",
"throw",
"new",
"LdapConnectionException",
"(",
"'No LDAP server is available.'",
")",
";",
"}"
] |
Retrieve the first available LDAP server.
@return string
@throws LdapConnectionException
|
[
"Retrieve",
"the",
"first",
"available",
"LDAP",
"server",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L88-L99
|
27,954
|
ldaptools/ldaptools
|
src/LdapTools/Connection/LdapServerPool.php
|
LdapServerPool.isServerAvailable
|
public function isServerAvailable($server)
{
$result = $this->tcp->connect($server, $this->config->getPort(), $this->config->getConnectTimeout());
if ($result) {
$this->tcp->close();
}
return $result;
}
|
php
|
public function isServerAvailable($server)
{
$result = $this->tcp->connect($server, $this->config->getPort(), $this->config->getConnectTimeout());
if ($result) {
$this->tcp->close();
}
return $result;
}
|
[
"public",
"function",
"isServerAvailable",
"(",
"$",
"server",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"tcp",
"->",
"connect",
"(",
"$",
"server",
",",
"$",
"this",
"->",
"config",
"->",
"getPort",
"(",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getConnectTimeout",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"tcp",
"->",
"close",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Check if a LDAP server is up and available.
@param string $server
@return bool
|
[
"Check",
"if",
"a",
"LDAP",
"server",
"is",
"up",
"and",
"available",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L107-L115
|
27,955
|
ldaptools/ldaptools
|
src/LdapTools/Connection/LdapServerPool.php
|
LdapServerPool.getSortedServersArray
|
public function getSortedServersArray()
{
$servers = empty($this->config->getServers()) ? $this->getServersFromDns() : $this->config->getServers();
if (self::SELECT_RANDOM == $this->selectionMethod) {
$servers = $this->shuffleServers($servers);
}
return $servers;
}
|
php
|
public function getSortedServersArray()
{
$servers = empty($this->config->getServers()) ? $this->getServersFromDns() : $this->config->getServers();
if (self::SELECT_RANDOM == $this->selectionMethod) {
$servers = $this->shuffleServers($servers);
}
return $servers;
}
|
[
"public",
"function",
"getSortedServersArray",
"(",
")",
"{",
"$",
"servers",
"=",
"empty",
"(",
"$",
"this",
"->",
"config",
"->",
"getServers",
"(",
")",
")",
"?",
"$",
"this",
"->",
"getServersFromDns",
"(",
")",
":",
"$",
"this",
"->",
"config",
"->",
"getServers",
"(",
")",
";",
"if",
"(",
"self",
"::",
"SELECT_RANDOM",
"==",
"$",
"this",
"->",
"selectionMethod",
")",
"{",
"$",
"servers",
"=",
"$",
"this",
"->",
"shuffleServers",
"(",
"$",
"servers",
")",
";",
"}",
"return",
"$",
"servers",
";",
"}"
] |
Uses the selected method to decide how to return the server array for the check.
@return array
|
[
"Uses",
"the",
"selected",
"method",
"to",
"decide",
"how",
"to",
"return",
"the",
"server",
"array",
"for",
"the",
"check",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L146-L155
|
27,956
|
ldaptools/ldaptools
|
src/LdapTools/Connection/LdapServerPool.php
|
LdapServerPool.getServersFromDns
|
protected function getServersFromDns()
{
$servers = $this->dns->getRecord(LdapUtilities::SRV_PREFIX.$this->config->getDomainName(), DNS_SRV);
if ($servers === false || empty($servers)) {
throw new LdapConnectionException(sprintf(
'No LDAP servers found via DNS for "%s".',
$this->config->getDomainName()
));
}
array_multisort(
array_column($servers, 'pri'), SORT_ASC|SORT_NUMERIC,
array_column($servers, 'weight'), SORT_DESC|SORT_NUMERIC,
$servers
);
return array_column($servers, 'target');
}
|
php
|
protected function getServersFromDns()
{
$servers = $this->dns->getRecord(LdapUtilities::SRV_PREFIX.$this->config->getDomainName(), DNS_SRV);
if ($servers === false || empty($servers)) {
throw new LdapConnectionException(sprintf(
'No LDAP servers found via DNS for "%s".',
$this->config->getDomainName()
));
}
array_multisort(
array_column($servers, 'pri'), SORT_ASC|SORT_NUMERIC,
array_column($servers, 'weight'), SORT_DESC|SORT_NUMERIC,
$servers
);
return array_column($servers, 'target');
}
|
[
"protected",
"function",
"getServersFromDns",
"(",
")",
"{",
"$",
"servers",
"=",
"$",
"this",
"->",
"dns",
"->",
"getRecord",
"(",
"LdapUtilities",
"::",
"SRV_PREFIX",
".",
"$",
"this",
"->",
"config",
"->",
"getDomainName",
"(",
")",
",",
"DNS_SRV",
")",
";",
"if",
"(",
"$",
"servers",
"===",
"false",
"||",
"empty",
"(",
"$",
"servers",
")",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"'No LDAP servers found via DNS for \"%s\".'",
",",
"$",
"this",
"->",
"config",
"->",
"getDomainName",
"(",
")",
")",
")",
";",
"}",
"array_multisort",
"(",
"array_column",
"(",
"$",
"servers",
",",
"'pri'",
")",
",",
"SORT_ASC",
"|",
"SORT_NUMERIC",
",",
"array_column",
"(",
"$",
"servers",
",",
"'weight'",
")",
",",
"SORT_DESC",
"|",
"SORT_NUMERIC",
",",
"$",
"servers",
")",
";",
"return",
"array_column",
"(",
"$",
"servers",
",",
"'target'",
")",
";",
"}"
] |
Attempt to lookup the LDAP servers from the DNS name.
@return array The LDAP servers.
@throws LdapConnectionException
|
[
"Attempt",
"to",
"lookup",
"the",
"LDAP",
"servers",
"from",
"the",
"DNS",
"name",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapServerPool.php#L176-L193
|
27,957
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.parseYamlForObject
|
protected function parseYamlForObject(array $schema, $schemaName, $objectType)
{
$objectSchema = $this->getObjectFromSchema($schema, $objectType);
$objectSchema = $this->mergeAnyExtendedSchemas($objectSchema, $schemaName);
$objectSchema = $this->cleanObjectArray($objectSchema);
$this->updateObjectArray($schemaName, $objectSchema);
$this->validateObjectDirectives($schemaName, $objectType, $objectSchema);
$ldapObjectSchema = new LdapObjectSchema($schemaName, $objectSchema['type']);
foreach ($this->optionMap as $option => $setter) {
if (!array_key_exists($option, $objectSchema)) {
continue;
}
$value = $objectSchema[$option];
if (array_key_exists($option, $this->normalizer)) {
$value = $this->{$this->normalizer[$option]}($value);
}
$ldapObjectSchema->$setter($value);
}
$this->parseConverterOptions($ldapObjectSchema, $objectSchema);
$ldapObjectSchema->setFilter($this->parseFilter($ldapObjectSchema, $objectSchema));
$ldapObjectSchema->setAttributeMap(isset($objectSchema['attributes']) ? $objectSchema['attributes'] : []);
$ldapObjectSchema->setConverterMap($this->parseConverterMap($objectSchema));
$ldapObjectSchema->setControls(...$this->parseControls($objectSchema));
$this->validateObjectSchema($ldapObjectSchema);
return $ldapObjectSchema;
}
|
php
|
protected function parseYamlForObject(array $schema, $schemaName, $objectType)
{
$objectSchema = $this->getObjectFromSchema($schema, $objectType);
$objectSchema = $this->mergeAnyExtendedSchemas($objectSchema, $schemaName);
$objectSchema = $this->cleanObjectArray($objectSchema);
$this->updateObjectArray($schemaName, $objectSchema);
$this->validateObjectDirectives($schemaName, $objectType, $objectSchema);
$ldapObjectSchema = new LdapObjectSchema($schemaName, $objectSchema['type']);
foreach ($this->optionMap as $option => $setter) {
if (!array_key_exists($option, $objectSchema)) {
continue;
}
$value = $objectSchema[$option];
if (array_key_exists($option, $this->normalizer)) {
$value = $this->{$this->normalizer[$option]}($value);
}
$ldapObjectSchema->$setter($value);
}
$this->parseConverterOptions($ldapObjectSchema, $objectSchema);
$ldapObjectSchema->setFilter($this->parseFilter($ldapObjectSchema, $objectSchema));
$ldapObjectSchema->setAttributeMap(isset($objectSchema['attributes']) ? $objectSchema['attributes'] : []);
$ldapObjectSchema->setConverterMap($this->parseConverterMap($objectSchema));
$ldapObjectSchema->setControls(...$this->parseControls($objectSchema));
$this->validateObjectSchema($ldapObjectSchema);
return $ldapObjectSchema;
}
|
[
"protected",
"function",
"parseYamlForObject",
"(",
"array",
"$",
"schema",
",",
"$",
"schemaName",
",",
"$",
"objectType",
")",
"{",
"$",
"objectSchema",
"=",
"$",
"this",
"->",
"getObjectFromSchema",
"(",
"$",
"schema",
",",
"$",
"objectType",
")",
";",
"$",
"objectSchema",
"=",
"$",
"this",
"->",
"mergeAnyExtendedSchemas",
"(",
"$",
"objectSchema",
",",
"$",
"schemaName",
")",
";",
"$",
"objectSchema",
"=",
"$",
"this",
"->",
"cleanObjectArray",
"(",
"$",
"objectSchema",
")",
";",
"$",
"this",
"->",
"updateObjectArray",
"(",
"$",
"schemaName",
",",
"$",
"objectSchema",
")",
";",
"$",
"this",
"->",
"validateObjectDirectives",
"(",
"$",
"schemaName",
",",
"$",
"objectType",
",",
"$",
"objectSchema",
")",
";",
"$",
"ldapObjectSchema",
"=",
"new",
"LdapObjectSchema",
"(",
"$",
"schemaName",
",",
"$",
"objectSchema",
"[",
"'type'",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"optionMap",
"as",
"$",
"option",
"=>",
"$",
"setter",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"objectSchema",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"objectSchema",
"[",
"$",
"option",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"option",
",",
"$",
"this",
"->",
"normalizer",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"normalizer",
"[",
"$",
"option",
"]",
"}",
"(",
"$",
"value",
")",
";",
"}",
"$",
"ldapObjectSchema",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"parseConverterOptions",
"(",
"$",
"ldapObjectSchema",
",",
"$",
"objectSchema",
")",
";",
"$",
"ldapObjectSchema",
"->",
"setFilter",
"(",
"$",
"this",
"->",
"parseFilter",
"(",
"$",
"ldapObjectSchema",
",",
"$",
"objectSchema",
")",
")",
";",
"$",
"ldapObjectSchema",
"->",
"setAttributeMap",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'attributes'",
"]",
")",
"?",
"$",
"objectSchema",
"[",
"'attributes'",
"]",
":",
"[",
"]",
")",
";",
"$",
"ldapObjectSchema",
"->",
"setConverterMap",
"(",
"$",
"this",
"->",
"parseConverterMap",
"(",
"$",
"objectSchema",
")",
")",
";",
"$",
"ldapObjectSchema",
"->",
"setControls",
"(",
"...",
"$",
"this",
"->",
"parseControls",
"(",
"$",
"objectSchema",
")",
")",
";",
"$",
"this",
"->",
"validateObjectSchema",
"(",
"$",
"ldapObjectSchema",
")",
";",
"return",
"$",
"ldapObjectSchema",
";",
"}"
] |
Attempt to find the object type definition in the schema and create its object representation.
@param array $schema
@param string $schemaName
@param string $objectType
@return LdapObjectSchema
@throws SchemaParserException
|
[
"Attempt",
"to",
"find",
"the",
"object",
"type",
"definition",
"in",
"the",
"schema",
"and",
"create",
"its",
"object",
"representation",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L179-L206
|
27,958
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.validateSchemaType
|
protected function validateSchemaType(LdapObjectSchema $schema, array $schemaArray)
{
if (!((bool)count(array_filter(array_keys($schemaArray['attributes']), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
}
|
php
|
protected function validateSchemaType(LdapObjectSchema $schema, array $schemaArray)
{
if (!((bool)count(array_filter(array_keys($schemaArray['attributes']), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
}
|
[
"protected",
"function",
"validateSchemaType",
"(",
"LdapObjectSchema",
"$",
"schema",
",",
"array",
"$",
"schemaArray",
")",
"{",
"if",
"(",
"!",
"(",
"(",
"bool",
")",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"schemaArray",
"[",
"'attributes'",
"]",
")",
",",
"'is_string'",
")",
")",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"'The attributes for a schema should be an associative array.'",
")",
";",
"}",
"if",
"(",
"$",
"schema",
"->",
"getScope",
"(",
")",
"&&",
"!",
"in_array",
"(",
"$",
"schema",
"->",
"getScope",
"(",
")",
",",
"QueryOperation",
"::",
"SCOPE",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'The scope \"%s\" is not valid. Valid types are: %s'",
",",
"$",
"schema",
"->",
"getScope",
"(",
")",
",",
"implode",
"(",
"', '",
",",
"QueryOperation",
"::",
"SCOPE",
")",
")",
")",
";",
"}",
"}"
] |
Validates some of the schema values to check that they are allowed.
@param LdapObjectSchema $schema
@param array $schemaArray
@throws SchemaParserException
|
[
"Validates",
"some",
"of",
"the",
"schema",
"values",
"to",
"check",
"that",
"they",
"are",
"allowed",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L261-L273
|
27,959
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.getObjectFromSchema
|
protected function getObjectFromSchema(array $schema, $objectType)
{
$objectSchema = null;
foreach ($schema['objects'] as $ldapObject) {
if (array_key_exists('type', $ldapObject) && strtolower($ldapObject['type']) == strtolower($objectType)) {
$objectSchema = $ldapObject;
}
}
if (is_null($objectSchema)) {
throw new SchemaParserException(sprintf('Cannot find object type "%s" in schema.', $objectType));
}
return $objectSchema;
}
|
php
|
protected function getObjectFromSchema(array $schema, $objectType)
{
$objectSchema = null;
foreach ($schema['objects'] as $ldapObject) {
if (array_key_exists('type', $ldapObject) && strtolower($ldapObject['type']) == strtolower($objectType)) {
$objectSchema = $ldapObject;
}
}
if (is_null($objectSchema)) {
throw new SchemaParserException(sprintf('Cannot find object type "%s" in schema.', $objectType));
}
return $objectSchema;
}
|
[
"protected",
"function",
"getObjectFromSchema",
"(",
"array",
"$",
"schema",
",",
"$",
"objectType",
")",
"{",
"$",
"objectSchema",
"=",
"null",
";",
"foreach",
"(",
"$",
"schema",
"[",
"'objects'",
"]",
"as",
"$",
"ldapObject",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'type'",
",",
"$",
"ldapObject",
")",
"&&",
"strtolower",
"(",
"$",
"ldapObject",
"[",
"'type'",
"]",
")",
"==",
"strtolower",
"(",
"$",
"objectType",
")",
")",
"{",
"$",
"objectSchema",
"=",
"$",
"ldapObject",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"objectSchema",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'Cannot find object type \"%s\" in schema.'",
",",
"$",
"objectType",
")",
")",
";",
"}",
"return",
"$",
"objectSchema",
";",
"}"
] |
Check for a specific object type in the schema and validate it.
@param array $schema
@param string $objectType
@return array
@throws SchemaParserException
|
[
"Check",
"for",
"a",
"specific",
"object",
"type",
"in",
"the",
"schema",
"and",
"validate",
"it",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L283-L296
|
27,960
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.updateObjectArray
|
protected function updateObjectArray($schemaName, $schemaObject)
{
foreach ($this->schemas[$this->schemaFolder][$schemaName]['objects'] as $name => $value) {
if (array_key_exists('type', $value) && $value['type'] == $schemaObject['type']) {
$this->schemas[$this->schemaFolder][$schemaName]['objects'][$name] = $schemaObject;
}
}
}
|
php
|
protected function updateObjectArray($schemaName, $schemaObject)
{
foreach ($this->schemas[$this->schemaFolder][$schemaName]['objects'] as $name => $value) {
if (array_key_exists('type', $value) && $value['type'] == $schemaObject['type']) {
$this->schemas[$this->schemaFolder][$schemaName]['objects'][$name] = $schemaObject;
}
}
}
|
[
"protected",
"function",
"updateObjectArray",
"(",
"$",
"schemaName",
",",
"$",
"schemaObject",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'type'",
",",
"$",
"value",
")",
"&&",
"$",
"value",
"[",
"'type'",
"]",
"==",
"$",
"schemaObject",
"[",
"'type'",
"]",
")",
"{",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"schemaObject",
";",
"}",
"}",
"}"
] |
Update the object in the schema array in case it extended a different object type.
@param string $schemaName
@param array $schemaObject
|
[
"Update",
"the",
"object",
"in",
"the",
"schema",
"array",
"in",
"case",
"it",
"extended",
"a",
"different",
"object",
"type",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L304-L311
|
27,961
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.parseConverterMap
|
protected function parseConverterMap(array $objectSchema)
{
$converterMap = [];
if (array_key_exists('converters', $objectSchema)) {
foreach ($objectSchema['converters'] as $converter => $attributes) {
if (is_array($attributes)) {
foreach ($attributes as $attribute) {
$converterMap[$attribute] = $converter;
}
} elseif (is_string($attributes)) {
$converterMap[$attributes] = $converter;
}
}
}
return $converterMap;
}
|
php
|
protected function parseConverterMap(array $objectSchema)
{
$converterMap = [];
if (array_key_exists('converters', $objectSchema)) {
foreach ($objectSchema['converters'] as $converter => $attributes) {
if (is_array($attributes)) {
foreach ($attributes as $attribute) {
$converterMap[$attribute] = $converter;
}
} elseif (is_string($attributes)) {
$converterMap[$attributes] = $converter;
}
}
}
return $converterMap;
}
|
[
"protected",
"function",
"parseConverterMap",
"(",
"array",
"$",
"objectSchema",
")",
"{",
"$",
"converterMap",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'converters'",
",",
"$",
"objectSchema",
")",
")",
"{",
"foreach",
"(",
"$",
"objectSchema",
"[",
"'converters'",
"]",
"as",
"$",
"converter",
"=>",
"$",
"attributes",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attributes",
")",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"$",
"converterMap",
"[",
"$",
"attribute",
"]",
"=",
"$",
"converter",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"attributes",
")",
")",
"{",
"$",
"converterMap",
"[",
"$",
"attributes",
"]",
"=",
"$",
"converter",
";",
"}",
"}",
"}",
"return",
"$",
"converterMap",
";",
"}"
] |
Parse the converters section of an object schema definition to generate the attribute converter map.
@param array $objectSchema
@return array
|
[
"Parse",
"the",
"converters",
"section",
"of",
"an",
"object",
"schema",
"definition",
"to",
"generate",
"the",
"attribute",
"converter",
"map",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L333-L350
|
27,962
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.parseFilter
|
protected function parseFilter(LdapObjectSchema $objectSchema, array $objectArray)
{
$filter = array_key_exists('filter', $objectArray) ? $objectArray['filter'] : [];
if (empty($filter) && empty($objectSchema->getObjectClass()) && empty($objectSchema->getObjectCategory())) {
throw new SchemaParserException(sprintf(
'Object type "%s" must have one of the following defined: %s',
$objectSchema->getObjectType(),
implode(', ', ['class', 'category', 'filter'])
));
}
return $this->arrayToOp->getOperatorForSchema($objectSchema, $filter);
}
|
php
|
protected function parseFilter(LdapObjectSchema $objectSchema, array $objectArray)
{
$filter = array_key_exists('filter', $objectArray) ? $objectArray['filter'] : [];
if (empty($filter) && empty($objectSchema->getObjectClass()) && empty($objectSchema->getObjectCategory())) {
throw new SchemaParserException(sprintf(
'Object type "%s" must have one of the following defined: %s',
$objectSchema->getObjectType(),
implode(', ', ['class', 'category', 'filter'])
));
}
return $this->arrayToOp->getOperatorForSchema($objectSchema, $filter);
}
|
[
"protected",
"function",
"parseFilter",
"(",
"LdapObjectSchema",
"$",
"objectSchema",
",",
"array",
"$",
"objectArray",
")",
"{",
"$",
"filter",
"=",
"array_key_exists",
"(",
"'filter'",
",",
"$",
"objectArray",
")",
"?",
"$",
"objectArray",
"[",
"'filter'",
"]",
":",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"filter",
")",
"&&",
"empty",
"(",
"$",
"objectSchema",
"->",
"getObjectClass",
"(",
")",
")",
"&&",
"empty",
"(",
"$",
"objectSchema",
"->",
"getObjectCategory",
"(",
")",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'Object type \"%s\" must have one of the following defined: %s'",
",",
"$",
"objectSchema",
"->",
"getObjectType",
"(",
")",
",",
"implode",
"(",
"', '",
",",
"[",
"'class'",
",",
"'category'",
",",
"'filter'",
"]",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"arrayToOp",
"->",
"getOperatorForSchema",
"(",
"$",
"objectSchema",
",",
"$",
"filter",
")",
";",
"}"
] |
Get the filter for the schema object.
@param LdapObjectSchema $objectSchema
@param array $objectArray
@return \LdapTools\Query\Operator\BaseOperator
@throws SchemaParserException
|
[
"Get",
"the",
"filter",
"for",
"the",
"schema",
"object",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L360-L373
|
27,963
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.validateObjectSchema
|
protected function validateObjectSchema($schema)
{
if (empty($schema->getAttributeMap())) {
throw new SchemaParserException(sprintf('Object type "%s" has no attributes defined.', $schema->getObjectType()));
} elseif (!((bool)count(array_filter(array_keys($schema->getAttributeMap()), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
}
|
php
|
protected function validateObjectSchema($schema)
{
if (empty($schema->getAttributeMap())) {
throw new SchemaParserException(sprintf('Object type "%s" has no attributes defined.', $schema->getObjectType()));
} elseif (!((bool)count(array_filter(array_keys($schema->getAttributeMap()), 'is_string')))) {
throw new SchemaParserException('The attributes for a schema should be an associative array.');
}
if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
throw new SchemaParserException(sprintf(
'The scope "%s" is not valid. Valid types are: %s',
$schema->getScope(),
implode(', ', QueryOperation::SCOPE)
));
}
}
|
[
"protected",
"function",
"validateObjectSchema",
"(",
"$",
"schema",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"schema",
"->",
"getAttributeMap",
"(",
")",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'Object type \"%s\" has no attributes defined.'",
",",
"$",
"schema",
"->",
"getObjectType",
"(",
")",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"(",
"(",
"bool",
")",
"count",
"(",
"array_filter",
"(",
"array_keys",
"(",
"$",
"schema",
"->",
"getAttributeMap",
"(",
")",
")",
",",
"'is_string'",
")",
")",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"'The attributes for a schema should be an associative array.'",
")",
";",
"}",
"if",
"(",
"$",
"schema",
"->",
"getScope",
"(",
")",
"&&",
"!",
"in_array",
"(",
"$",
"schema",
"->",
"getScope",
"(",
")",
",",
"QueryOperation",
"::",
"SCOPE",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'The scope \"%s\" is not valid. Valid types are: %s'",
",",
"$",
"schema",
"->",
"getScope",
"(",
")",
",",
"implode",
"(",
"', '",
",",
"QueryOperation",
"::",
"SCOPE",
")",
")",
")",
";",
"}",
"}"
] |
Validate that an object schema meets the minimum requirements.
@param LdapObjectSchema $schema
@throws SchemaParserException
|
[
"Validate",
"that",
"an",
"object",
"schema",
"meets",
"the",
"minimum",
"requirements",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L419-L434
|
27,964
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.parseSchemaNameToArray
|
protected function parseSchemaNameToArray($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName])) {
$file = $this->getSchemaFileName($this->schemaFolder, $schemaName);
try {
$this->schemas[$this->schemaFolder][$schemaName] = Yaml::parse(file_get_contents($file));
} catch (ParseException $e) {
throw new SchemaParserException(sprintf('Error in configuration file: %s', $e->getMessage()));
}
$this->mergeDefaultSchemaFile($schemaName);
$this->mergeIncludedSchemas($schemaName);
$this->validateSchemaDirectives($schemaName);
}
}
|
php
|
protected function parseSchemaNameToArray($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName])) {
$file = $this->getSchemaFileName($this->schemaFolder, $schemaName);
try {
$this->schemas[$this->schemaFolder][$schemaName] = Yaml::parse(file_get_contents($file));
} catch (ParseException $e) {
throw new SchemaParserException(sprintf('Error in configuration file: %s', $e->getMessage()));
}
$this->mergeDefaultSchemaFile($schemaName);
$this->mergeIncludedSchemas($schemaName);
$this->validateSchemaDirectives($schemaName);
}
}
|
[
"protected",
"function",
"parseSchemaNameToArray",
"(",
"$",
"schemaName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
")",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getSchemaFileName",
"(",
"$",
"this",
"->",
"schemaFolder",
",",
"$",
"schemaName",
")",
";",
"try",
"{",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"=",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
";",
"}",
"catch",
"(",
"ParseException",
"$",
"e",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'Error in configuration file: %s'",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"mergeDefaultSchemaFile",
"(",
"$",
"schemaName",
")",
";",
"$",
"this",
"->",
"mergeIncludedSchemas",
"(",
"$",
"schemaName",
")",
";",
"$",
"this",
"->",
"validateSchemaDirectives",
"(",
"$",
"schemaName",
")",
";",
"}",
"}"
] |
Given a schema name, parse it into the array.
@param string $schemaName
@throws SchemaParserException
|
[
"Given",
"a",
"schema",
"name",
"parse",
"it",
"into",
"the",
"array",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L442-L455
|
27,965
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.mergeIncludedSchemas
|
protected function mergeIncludedSchemas($schemaName)
{
$include = ['include' => [], 'include_default' => []];
foreach (array_keys($include) as $key) {
if (isset($this->schemas[$this->schemaFolder][$schemaName][$key])) {
$include[$key] = $this->schemas[$this->schemaFolder][$schemaName][$key];
$include[$key] = is_array($include[$key]) ? $include[$key] : [$include[$key]];
}
}
foreach ($include['include'] as $schema) {
$this->parseAll($schema);
$this->schemas[$this->schemaFolder][$schemaName]['objects'] = array_merge(
$this->schemas[$this->schemaFolder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
foreach ($include['include_default'] as $schema) {
$this->parseAll($schema);
$this->schemas[$folder][$schemaName]['objects'] = array_merge(
$this->schemas[$folder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$this->schemaFolder = $folder;
}
|
php
|
protected function mergeIncludedSchemas($schemaName)
{
$include = ['include' => [], 'include_default' => []];
foreach (array_keys($include) as $key) {
if (isset($this->schemas[$this->schemaFolder][$schemaName][$key])) {
$include[$key] = $this->schemas[$this->schemaFolder][$schemaName][$key];
$include[$key] = is_array($include[$key]) ? $include[$key] : [$include[$key]];
}
}
foreach ($include['include'] as $schema) {
$this->parseAll($schema);
$this->schemas[$this->schemaFolder][$schemaName]['objects'] = array_merge(
$this->schemas[$this->schemaFolder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
foreach ($include['include_default'] as $schema) {
$this->parseAll($schema);
$this->schemas[$folder][$schemaName]['objects'] = array_merge(
$this->schemas[$folder][$schemaName]['objects'],
$this->schemas[$this->schemaFolder][$schema]['objects']
);
}
$this->schemaFolder = $folder;
}
|
[
"protected",
"function",
"mergeIncludedSchemas",
"(",
"$",
"schemaName",
")",
"{",
"$",
"include",
"=",
"[",
"'include'",
"=>",
"[",
"]",
",",
"'include_default'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"include",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"include",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"$",
"key",
"]",
";",
"$",
"include",
"[",
"$",
"key",
"]",
"=",
"is_array",
"(",
"$",
"include",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"include",
"[",
"$",
"key",
"]",
":",
"[",
"$",
"include",
"[",
"$",
"key",
"]",
"]",
";",
"}",
"}",
"foreach",
"(",
"$",
"include",
"[",
"'include'",
"]",
"as",
"$",
"schema",
")",
"{",
"$",
"this",
"->",
"parseAll",
"(",
"$",
"schema",
")",
";",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
",",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schema",
"]",
"[",
"'objects'",
"]",
")",
";",
"}",
"$",
"folder",
"=",
"$",
"this",
"->",
"schemaFolder",
";",
"$",
"this",
"->",
"schemaFolder",
"=",
"$",
"this",
"->",
"defaultSchemaFolder",
";",
"foreach",
"(",
"$",
"include",
"[",
"'include_default'",
"]",
"as",
"$",
"schema",
")",
"{",
"$",
"this",
"->",
"parseAll",
"(",
"$",
"schema",
")",
";",
"$",
"this",
"->",
"schemas",
"[",
"$",
"folder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"folder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'objects'",
"]",
",",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schema",
"]",
"[",
"'objects'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"schemaFolder",
"=",
"$",
"folder",
";",
"}"
] |
If the 'include' directive is used, then merge the specified schemas into the current one.
@param string $schemaName
@throws SchemaParserException
|
[
"If",
"the",
"include",
"directive",
"is",
"used",
"then",
"merge",
"the",
"specified",
"schemas",
"into",
"the",
"current",
"one",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L463-L492
|
27,966
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.mergeDefaultSchemaFile
|
protected function mergeDefaultSchemaFile($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName]['extends_default'])) {
return;
}
$defaultSchemaName = $this->schemas[$this->schemaFolder][$schemaName]['extends_default'];
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll($defaultSchemaName);
// Perhaps an option at some point to specify the merge action/type? ie. replace vs merge.
$this->schemas[$folder][$schemaName] = array_merge_recursive(
$this->schemas[$this->schemaFolder][$defaultSchemaName],
$this->schemas[$folder][$schemaName]
);
$this->schemaFolder = $folder;
}
|
php
|
protected function mergeDefaultSchemaFile($schemaName)
{
if (!isset($this->schemas[$this->schemaFolder][$schemaName]['extends_default'])) {
return;
}
$defaultSchemaName = $this->schemas[$this->schemaFolder][$schemaName]['extends_default'];
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll($defaultSchemaName);
// Perhaps an option at some point to specify the merge action/type? ie. replace vs merge.
$this->schemas[$folder][$schemaName] = array_merge_recursive(
$this->schemas[$this->schemaFolder][$defaultSchemaName],
$this->schemas[$folder][$schemaName]
);
$this->schemaFolder = $folder;
}
|
[
"protected",
"function",
"mergeDefaultSchemaFile",
"(",
"$",
"schemaName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'extends_default'",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"defaultSchemaName",
"=",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
"[",
"'extends_default'",
"]",
";",
"$",
"folder",
"=",
"$",
"this",
"->",
"schemaFolder",
";",
"$",
"this",
"->",
"schemaFolder",
"=",
"$",
"this",
"->",
"defaultSchemaFolder",
";",
"$",
"this",
"->",
"parseAll",
"(",
"$",
"defaultSchemaName",
")",
";",
"// Perhaps an option at some point to specify the merge action/type? ie. replace vs merge.",
"$",
"this",
"->",
"schemas",
"[",
"$",
"folder",
"]",
"[",
"$",
"schemaName",
"]",
"=",
"array_merge_recursive",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"defaultSchemaName",
"]",
",",
"$",
"this",
"->",
"schemas",
"[",
"$",
"folder",
"]",
"[",
"$",
"schemaName",
"]",
")",
";",
"$",
"this",
"->",
"schemaFolder",
"=",
"$",
"folder",
";",
"}"
] |
If the 'extends_default' directive is used, then merge the specified default schema.
@param string $schemaName
@throws SchemaParserException
|
[
"If",
"the",
"extends_default",
"directive",
"is",
"used",
"then",
"merge",
"the",
"specified",
"default",
"schema",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L500-L517
|
27,967
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.mergeAnyExtendedSchemas
|
protected function mergeAnyExtendedSchemas(array $objectSchema, $schemaName)
{
if (!(isset($objectSchema['extends']) || isset($objectSchema['extends_default']))) {
return $objectSchema;
}
return $this->mergeSchemaObjectArrays($this->getParentSchemaObject($objectSchema, $schemaName), $objectSchema);
}
|
php
|
protected function mergeAnyExtendedSchemas(array $objectSchema, $schemaName)
{
if (!(isset($objectSchema['extends']) || isset($objectSchema['extends_default']))) {
return $objectSchema;
}
return $this->mergeSchemaObjectArrays($this->getParentSchemaObject($objectSchema, $schemaName), $objectSchema);
}
|
[
"protected",
"function",
"mergeAnyExtendedSchemas",
"(",
"array",
"$",
"objectSchema",
",",
"$",
"schemaName",
")",
"{",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
"||",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
")",
")",
"{",
"return",
"$",
"objectSchema",
";",
"}",
"return",
"$",
"this",
"->",
"mergeSchemaObjectArrays",
"(",
"$",
"this",
"->",
"getParentSchemaObject",
"(",
"$",
"objectSchema",
",",
"$",
"schemaName",
")",
",",
"$",
"objectSchema",
")",
";",
"}"
] |
If the 'extends' option is given, then merge this schema object with the requested schema object.
@param array $objectSchema
@param string $schemaName
@return array
@throws SchemaParserException
|
[
"If",
"the",
"extends",
"option",
"is",
"given",
"then",
"merge",
"this",
"schema",
"object",
"with",
"the",
"requested",
"schema",
"object",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L527-L534
|
27,968
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.mergeSchemaObjectArrays
|
protected function mergeSchemaObjectArrays($parent, $schema)
{
// Directives used that exist in the schema being extended, that are arrays, should be merged.
foreach (array_intersect_key($schema, $parent) as $key => $value) {
# Simple merge on non-multidimensional arrays...
if (is_array($value) && count($value) === count($value, COUNT_RECURSIVE)) {
$schema[$key] = array_merge($parent[$key], $value);
# Recursive merge on multidimensional arrays...
} elseif (is_array($value)) {
$schema[$key] = array_merge_recursive($parent[$key], $value);
}
}
// Directives in the parent that have not been defined should be added.
return array_replace($schema, array_diff_key($parent, $schema));
}
|
php
|
protected function mergeSchemaObjectArrays($parent, $schema)
{
// Directives used that exist in the schema being extended, that are arrays, should be merged.
foreach (array_intersect_key($schema, $parent) as $key => $value) {
# Simple merge on non-multidimensional arrays...
if (is_array($value) && count($value) === count($value, COUNT_RECURSIVE)) {
$schema[$key] = array_merge($parent[$key], $value);
# Recursive merge on multidimensional arrays...
} elseif (is_array($value)) {
$schema[$key] = array_merge_recursive($parent[$key], $value);
}
}
// Directives in the parent that have not been defined should be added.
return array_replace($schema, array_diff_key($parent, $schema));
}
|
[
"protected",
"function",
"mergeSchemaObjectArrays",
"(",
"$",
"parent",
",",
"$",
"schema",
")",
"{",
"// Directives used that exist in the schema being extended, that are arrays, should be merged.",
"foreach",
"(",
"array_intersect_key",
"(",
"$",
"schema",
",",
"$",
"parent",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"# Simple merge on non-multidimensional arrays...",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"count",
"(",
"$",
"value",
")",
"===",
"count",
"(",
"$",
"value",
",",
"COUNT_RECURSIVE",
")",
")",
"{",
"$",
"schema",
"[",
"$",
"key",
"]",
"=",
"array_merge",
"(",
"$",
"parent",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"# Recursive merge on multidimensional arrays...",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"schema",
"[",
"$",
"key",
"]",
"=",
"array_merge_recursive",
"(",
"$",
"parent",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"}",
"}",
"// Directives in the parent that have not been defined should be added.",
"return",
"array_replace",
"(",
"$",
"schema",
",",
"array_diff_key",
"(",
"$",
"parent",
",",
"$",
"schema",
")",
")",
";",
"}"
] |
Performs the logic for merging one schema object array with another.
@param array $parent The parent schema object being extended.
@param array $schema The base schema object being defined.
@return array
|
[
"Performs",
"the",
"logic",
"for",
"merging",
"one",
"schema",
"object",
"array",
"with",
"another",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L543-L558
|
27,969
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.getExtendedDefaultSchemaObject
|
protected function getExtendedDefaultSchemaObject(array $objectSchema)
{
if (!(is_array($objectSchema['extends_default']) && 2 == count($objectSchema['extends_default']))) {
throw new SchemaParserException('The "extends_default" directive should be an array with exactly 2 values.');
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll(reset($objectSchema['extends_default']));
$parent = $this->getObjectFromSchema(
$this->schemas[$this->defaultSchemaFolder][$objectSchema['extends_default'][0]],
$objectSchema['extends_default'][1]
);
$this->schemaFolder = $folder;
return $parent;
}
|
php
|
protected function getExtendedDefaultSchemaObject(array $objectSchema)
{
if (!(is_array($objectSchema['extends_default']) && 2 == count($objectSchema['extends_default']))) {
throw new SchemaParserException('The "extends_default" directive should be an array with exactly 2 values.');
}
$folder = $this->schemaFolder;
$this->schemaFolder = $this->defaultSchemaFolder;
$this->parseAll(reset($objectSchema['extends_default']));
$parent = $this->getObjectFromSchema(
$this->schemas[$this->defaultSchemaFolder][$objectSchema['extends_default'][0]],
$objectSchema['extends_default'][1]
);
$this->schemaFolder = $folder;
return $parent;
}
|
[
"protected",
"function",
"getExtendedDefaultSchemaObject",
"(",
"array",
"$",
"objectSchema",
")",
"{",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
"&&",
"2",
"==",
"count",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"'The \"extends_default\" directive should be an array with exactly 2 values.'",
")",
";",
"}",
"$",
"folder",
"=",
"$",
"this",
"->",
"schemaFolder",
";",
"$",
"this",
"->",
"schemaFolder",
"=",
"$",
"this",
"->",
"defaultSchemaFolder",
";",
"$",
"this",
"->",
"parseAll",
"(",
"reset",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"getObjectFromSchema",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"defaultSchemaFolder",
"]",
"[",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
"[",
"0",
"]",
"]",
",",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
"[",
"1",
"]",
")",
";",
"$",
"this",
"->",
"schemaFolder",
"=",
"$",
"folder",
";",
"return",
"$",
"parent",
";",
"}"
] |
If we need to retrieve one of the default schemas, then it's probably the case that the schema folder path was
manually defined. So retrieve the default schema object by parsing the name from the default folder path and then
reset the schema folder back to what it originally was.
@param array $objectSchema
@return array
@throws SchemaParserException
|
[
"If",
"we",
"need",
"to",
"retrieve",
"one",
"of",
"the",
"default",
"schemas",
"then",
"it",
"s",
"probably",
"the",
"case",
"that",
"the",
"schema",
"folder",
"path",
"was",
"manually",
"defined",
".",
"So",
"retrieve",
"the",
"default",
"schema",
"object",
"by",
"parsing",
"the",
"name",
"from",
"the",
"default",
"folder",
"path",
"and",
"then",
"reset",
"the",
"schema",
"folder",
"back",
"to",
"what",
"it",
"originally",
"was",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L569-L586
|
27,970
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.getParentSchemaObject
|
protected function getParentSchemaObject(array $objectSchema, $schemaName)
{
if (isset($objectSchema['extends_default'])) {
$parent = $this->getExtendedDefaultSchemaObject($objectSchema);
} elseif (isset($objectSchema['extends']) && is_string($objectSchema['extends'])) {
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$schemaName], $objectSchema['extends']);
} elseif (isset($objectSchema['extends']) && is_array($objectSchema['extends']) && 2 == count($objectSchema['extends'])) {
$name = reset($objectSchema['extends']);
$type = $objectSchema['extends'][1];
$this->parseAll($name);
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$name], $type);
} else {
throw new SchemaParserException('The directive "extends" must be a string or array with exactly 2 values.');
}
return $parent;
}
|
php
|
protected function getParentSchemaObject(array $objectSchema, $schemaName)
{
if (isset($objectSchema['extends_default'])) {
$parent = $this->getExtendedDefaultSchemaObject($objectSchema);
} elseif (isset($objectSchema['extends']) && is_string($objectSchema['extends'])) {
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$schemaName], $objectSchema['extends']);
} elseif (isset($objectSchema['extends']) && is_array($objectSchema['extends']) && 2 == count($objectSchema['extends'])) {
$name = reset($objectSchema['extends']);
$type = $objectSchema['extends'][1];
$this->parseAll($name);
$parent = $this->getObjectFromSchema($this->schemas[$this->schemaFolder][$name], $type);
} else {
throw new SchemaParserException('The directive "extends" must be a string or array with exactly 2 values.');
}
return $parent;
}
|
[
"protected",
"function",
"getParentSchemaObject",
"(",
"array",
"$",
"objectSchema",
",",
"$",
"schemaName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends_default'",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getExtendedDefaultSchemaObject",
"(",
"$",
"objectSchema",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getObjectFromSchema",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"schemaName",
"]",
",",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
"&&",
"2",
"==",
"count",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"reset",
"(",
"$",
"objectSchema",
"[",
"'extends'",
"]",
")",
";",
"$",
"type",
"=",
"$",
"objectSchema",
"[",
"'extends'",
"]",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"parseAll",
"(",
"$",
"name",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"getObjectFromSchema",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"this",
"->",
"schemaFolder",
"]",
"[",
"$",
"name",
"]",
",",
"$",
"type",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"'The directive \"extends\" must be a string or array with exactly 2 values.'",
")",
";",
"}",
"return",
"$",
"parent",
";",
"}"
] |
Determines what parent array object to get based on the directive used.
@param array $objectSchema
@param string $schemaName
@return array
@throws SchemaParserException
|
[
"Determines",
"what",
"parent",
"array",
"object",
"to",
"get",
"based",
"on",
"the",
"directive",
"used",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L596-L612
|
27,971
|
ldaptools/ldaptools
|
src/LdapTools/Schema/Parser/SchemaYamlParser.php
|
SchemaYamlParser.getSchemaFileName
|
protected function getSchemaFileName($folder, $schema)
{
$file = null;
foreach (['yml', 'yaml'] as $ext) {
$fileCheck = $folder.'/'.$schema.'.'.$ext;
if (is_readable($fileCheck)) {
$file = $fileCheck;
break;
}
}
if (is_null($file)) {
throw new SchemaParserException(sprintf('Cannot find schema for "%s" in "%s"', $schema, $folder));
}
return $file;
}
|
php
|
protected function getSchemaFileName($folder, $schema)
{
$file = null;
foreach (['yml', 'yaml'] as $ext) {
$fileCheck = $folder.'/'.$schema.'.'.$ext;
if (is_readable($fileCheck)) {
$file = $fileCheck;
break;
}
}
if (is_null($file)) {
throw new SchemaParserException(sprintf('Cannot find schema for "%s" in "%s"', $schema, $folder));
}
return $file;
}
|
[
"protected",
"function",
"getSchemaFileName",
"(",
"$",
"folder",
",",
"$",
"schema",
")",
"{",
"$",
"file",
"=",
"null",
";",
"foreach",
"(",
"[",
"'yml'",
",",
"'yaml'",
"]",
"as",
"$",
"ext",
")",
"{",
"$",
"fileCheck",
"=",
"$",
"folder",
".",
"'/'",
".",
"$",
"schema",
".",
"'.'",
".",
"$",
"ext",
";",
"if",
"(",
"is_readable",
"(",
"$",
"fileCheck",
")",
")",
"{",
"$",
"file",
"=",
"$",
"fileCheck",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"SchemaParserException",
"(",
"sprintf",
"(",
"'Cannot find schema for \"%s\" in \"%s\"'",
",",
"$",
"schema",
",",
"$",
"folder",
")",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
Check for a YML file of the specified schema name and return the full path.
@param string $folder
@param string $schema
@return string
@throws SchemaParserException
|
[
"Check",
"for",
"a",
"YML",
"file",
"of",
"the",
"specified",
"schema",
"name",
"and",
"return",
"the",
"full",
"path",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Schema/Parser/SchemaYamlParser.php#L622-L639
|
27,972
|
ldaptools/ldaptools
|
src/LdapTools/AttributeConverter/ConvertPrimaryGroup.php
|
ConvertPrimaryGroup.validateAndGetGroupSID
|
protected function validateAndGetGroupSID($name)
{
$query = new LdapQueryBuilder($this->getLdapConnection());
$query->select('objectSid')->where(['objectClass' => 'group', 'cn' => $name]);
// Only validate group group membership on modification.
if ($this->getOperationType() == AttributeConverterInterface::TYPE_MODIFY) {
$query->andWhere(['member' => $this->getDn()]);
}
try {
return $query->andWhere($query->filter()->bitwiseAnd('groupType', GroupType::SecurityEnabled))
->getLdapQuery()
->getSingleScalarResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf(
'Either the group "%s" doesn\'t exist, the user with DN "%s" is not a member of the group, the group'
.' is not a security group, or this group is already their primary group.',
$name,
$this->getDn()
));
}
}
|
php
|
protected function validateAndGetGroupSID($name)
{
$query = new LdapQueryBuilder($this->getLdapConnection());
$query->select('objectSid')->where(['objectClass' => 'group', 'cn' => $name]);
// Only validate group group membership on modification.
if ($this->getOperationType() == AttributeConverterInterface::TYPE_MODIFY) {
$query->andWhere(['member' => $this->getDn()]);
}
try {
return $query->andWhere($query->filter()->bitwiseAnd('groupType', GroupType::SecurityEnabled))
->getLdapQuery()
->getSingleScalarResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf(
'Either the group "%s" doesn\'t exist, the user with DN "%s" is not a member of the group, the group'
.' is not a security group, or this group is already their primary group.',
$name,
$this->getDn()
));
}
}
|
[
"protected",
"function",
"validateAndGetGroupSID",
"(",
"$",
"name",
")",
"{",
"$",
"query",
"=",
"new",
"LdapQueryBuilder",
"(",
"$",
"this",
"->",
"getLdapConnection",
"(",
")",
")",
";",
"$",
"query",
"->",
"select",
"(",
"'objectSid'",
")",
"->",
"where",
"(",
"[",
"'objectClass'",
"=>",
"'group'",
",",
"'cn'",
"=>",
"$",
"name",
"]",
")",
";",
"// Only validate group group membership on modification.",
"if",
"(",
"$",
"this",
"->",
"getOperationType",
"(",
")",
"==",
"AttributeConverterInterface",
"::",
"TYPE_MODIFY",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"[",
"'member'",
"=>",
"$",
"this",
"->",
"getDn",
"(",
")",
"]",
")",
";",
"}",
"try",
"{",
"return",
"$",
"query",
"->",
"andWhere",
"(",
"$",
"query",
"->",
"filter",
"(",
")",
"->",
"bitwiseAnd",
"(",
"'groupType'",
",",
"GroupType",
"::",
"SecurityEnabled",
")",
")",
"->",
"getLdapQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}",
"catch",
"(",
"EmptyResultException",
"$",
"e",
")",
"{",
"throw",
"new",
"AttributeConverterException",
"(",
"sprintf",
"(",
"'Either the group \"%s\" doesn\\'t exist, the user with DN \"%s\" is not a member of the group, the group'",
".",
"' is not a security group, or this group is already their primary group.'",
",",
"$",
"name",
",",
"$",
"this",
"->",
"getDn",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Make sure that the group exists and that the user is already a member of it. If not, at least give an informative
message.
@param string $name The group name.
@return string The text SID of the group.
@throws AttributeConverterException
|
[
"Make",
"sure",
"that",
"the",
"group",
"exists",
"and",
"that",
"the",
"user",
"is",
"already",
"a",
"member",
"of",
"it",
".",
"If",
"not",
"at",
"least",
"give",
"an",
"informative",
"message",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertPrimaryGroup.php#L73-L94
|
27,973
|
ldaptools/ldaptools
|
src/LdapTools/BatchModify/BatchCollection.php
|
BatchCollection.add
|
public function add(Batch ...$batches)
{
foreach ($batches as $batch) {
if (!$this->has($batch)) {
$this->batches[] = $batch;
}
}
return $this;
}
|
php
|
public function add(Batch ...$batches)
{
foreach ($batches as $batch) {
if (!$this->has($batch)) {
$this->batches[] = $batch;
}
}
return $this;
}
|
[
"public",
"function",
"add",
"(",
"Batch",
"...",
"$",
"batches",
")",
"{",
"foreach",
"(",
"$",
"batches",
"as",
"$",
"batch",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"batch",
")",
")",
"{",
"$",
"this",
"->",
"batches",
"[",
"]",
"=",
"$",
"batch",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add an individual batch action to the collection.
@param Batch[] ...$batches
@return $this
|
[
"Add",
"an",
"individual",
"batch",
"action",
"to",
"the",
"collection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L59-L68
|
27,974
|
ldaptools/ldaptools
|
src/LdapTools/BatchModify/BatchCollection.php
|
BatchCollection.remove
|
public function remove(Batch ...$batches)
{
foreach ($batches as $batch) {
foreach ($this->batches as $i => $batchItem) {
if ($batchItem === $batch) {
unset($this->batches[$i]);
}
}
}
return $this;
}
|
php
|
public function remove(Batch ...$batches)
{
foreach ($batches as $batch) {
foreach ($this->batches as $i => $batchItem) {
if ($batchItem === $batch) {
unset($this->batches[$i]);
}
}
}
return $this;
}
|
[
"public",
"function",
"remove",
"(",
"Batch",
"...",
"$",
"batches",
")",
"{",
"foreach",
"(",
"$",
"batches",
"as",
"$",
"batch",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"i",
"=>",
"$",
"batchItem",
")",
"{",
"if",
"(",
"$",
"batchItem",
"===",
"$",
"batch",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"batches",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove a specific batch from the collection.
@param Batch[] ...$batches
@return $this
|
[
"Remove",
"a",
"specific",
"batch",
"from",
"the",
"collection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L76-L87
|
27,975
|
ldaptools/ldaptools
|
src/LdapTools/BatchModify/BatchCollection.php
|
BatchCollection.has
|
public function has(Batch $batch)
{
foreach ($this->batches as $batchItem) {
if ($batchItem === $batch) {
return true;
}
}
return false;
}
|
php
|
public function has(Batch $batch)
{
foreach ($this->batches as $batchItem) {
if ($batchItem === $batch) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"has",
"(",
"Batch",
"$",
"batch",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"batchItem",
")",
"{",
"if",
"(",
"$",
"batchItem",
"===",
"$",
"batch",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if a specific batch index exists.
@param Batch $batch
@return bool
|
[
"Check",
"if",
"a",
"specific",
"batch",
"index",
"exists",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L95-L103
|
27,976
|
ldaptools/ldaptools
|
src/LdapTools/BatchModify/BatchCollection.php
|
BatchCollection.getBatchArray
|
public function getBatchArray()
{
$batchEntry = [];
foreach ($this->batches as $batch) {
$batchEntry[] = $batch->toArray();
}
return $batchEntry;
}
|
php
|
public function getBatchArray()
{
$batchEntry = [];
foreach ($this->batches as $batch) {
$batchEntry[] = $batch->toArray();
}
return $batchEntry;
}
|
[
"public",
"function",
"getBatchArray",
"(",
")",
"{",
"$",
"batchEntry",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"batch",
")",
"{",
"$",
"batchEntry",
"[",
"]",
"=",
"$",
"batch",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
"$",
"batchEntry",
";",
"}"
] |
Get an array that represents the array form of each batch action to be sent to LDAP.
@return array
|
[
"Get",
"an",
"array",
"that",
"represents",
"the",
"array",
"form",
"of",
"each",
"batch",
"action",
"to",
"be",
"sent",
"to",
"LDAP",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/BatchModify/BatchCollection.php#L143-L152
|
27,977
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/ArrayToOperator.php
|
ArrayToOperator.getOperatorForSchema
|
public function getOperatorForSchema(LdapObjectSchema $schema, array $filter)
{
$operator = null;
$categoryOperator = $this->getCategoryOperator($schema->getObjectCategory());
$classOperator = $this->getClassOperator($schema->getObjectClass());
if ($classOperator && $categoryOperator) {
$operator = $this->filterBuilder->bAnd($categoryOperator, $classOperator);
} elseif ($categoryOperator) {
$operator = $categoryOperator;
} elseif ($classOperator) {
$operator = $classOperator;
}
return $this->getOperatorForArray($filter, $operator);
}
|
php
|
public function getOperatorForSchema(LdapObjectSchema $schema, array $filter)
{
$operator = null;
$categoryOperator = $this->getCategoryOperator($schema->getObjectCategory());
$classOperator = $this->getClassOperator($schema->getObjectClass());
if ($classOperator && $categoryOperator) {
$operator = $this->filterBuilder->bAnd($categoryOperator, $classOperator);
} elseif ($categoryOperator) {
$operator = $categoryOperator;
} elseif ($classOperator) {
$operator = $classOperator;
}
return $this->getOperatorForArray($filter, $operator);
}
|
[
"public",
"function",
"getOperatorForSchema",
"(",
"LdapObjectSchema",
"$",
"schema",
",",
"array",
"$",
"filter",
")",
"{",
"$",
"operator",
"=",
"null",
";",
"$",
"categoryOperator",
"=",
"$",
"this",
"->",
"getCategoryOperator",
"(",
"$",
"schema",
"->",
"getObjectCategory",
"(",
")",
")",
";",
"$",
"classOperator",
"=",
"$",
"this",
"->",
"getClassOperator",
"(",
"$",
"schema",
"->",
"getObjectClass",
"(",
")",
")",
";",
"if",
"(",
"$",
"classOperator",
"&&",
"$",
"categoryOperator",
")",
"{",
"$",
"operator",
"=",
"$",
"this",
"->",
"filterBuilder",
"->",
"bAnd",
"(",
"$",
"categoryOperator",
",",
"$",
"classOperator",
")",
";",
"}",
"elseif",
"(",
"$",
"categoryOperator",
")",
"{",
"$",
"operator",
"=",
"$",
"categoryOperator",
";",
"}",
"elseif",
"(",
"$",
"classOperator",
")",
"{",
"$",
"operator",
"=",
"$",
"classOperator",
";",
"}",
"return",
"$",
"this",
"->",
"getOperatorForArray",
"(",
"$",
"filter",
",",
"$",
"operator",
")",
";",
"}"
] |
Given a schema object and a filter array, construct the operator to be used for the schema.
@param LdapObjectSchema $schema
@param array $filter
@return BaseOperator
|
[
"Given",
"a",
"schema",
"object",
"and",
"a",
"filter",
"array",
"construct",
"the",
"operator",
"to",
"be",
"used",
"for",
"the",
"schema",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/ArrayToOperator.php#L80-L96
|
27,978
|
ldaptools/ldaptools
|
src/LdapTools/Query/Builder/FilterBuilder.php
|
FilterBuilder.getInstance
|
public static function getInstance(LdapConnectionInterface $connection = null)
{
if ($connection && $connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD) {
$filterBuilder = new ADFilterBuilder();
} else {
$filterBuilder = new self();
}
return $filterBuilder;
}
|
php
|
public static function getInstance(LdapConnectionInterface $connection = null)
{
if ($connection && $connection->getConfig()->getLdapType() == LdapConnection::TYPE_AD) {
$filterBuilder = new ADFilterBuilder();
} else {
$filterBuilder = new self();
}
return $filterBuilder;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"LdapConnectionInterface",
"$",
"connection",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"connection",
"&&",
"$",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getLdapType",
"(",
")",
"==",
"LdapConnection",
"::",
"TYPE_AD",
")",
"{",
"$",
"filterBuilder",
"=",
"new",
"ADFilterBuilder",
"(",
")",
";",
"}",
"else",
"{",
"$",
"filterBuilder",
"=",
"new",
"self",
"(",
")",
";",
"}",
"return",
"$",
"filterBuilder",
";",
"}"
] |
Get a FilterBuilder instance based on the connection.
@param LdapConnectionInterface|null $connection
@return ADFilterBuilder|FilterBuilder
|
[
"Get",
"a",
"FilterBuilder",
"instance",
"based",
"on",
"the",
"connection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Builder/FilterBuilder.php#L37-L46
|
27,979
|
ldaptools/ldaptools
|
src/LdapTools/Query/Builder/FilterBuilder.php
|
FilterBuilder.in
|
public function in($attribute, array $values)
{
return new bOr(...array_map(function($v) use ($attribute) {
return $this->eq($attribute, $v);
}, $values));
}
|
php
|
public function in($attribute, array $values)
{
return new bOr(...array_map(function($v) use ($attribute) {
return $this->eq($attribute, $v);
}, $values));
}
|
[
"public",
"function",
"in",
"(",
"$",
"attribute",
",",
"array",
"$",
"values",
")",
"{",
"return",
"new",
"bOr",
"(",
"...",
"array_map",
"(",
"function",
"(",
"$",
"v",
")",
"use",
"(",
"$",
"attribute",
")",
"{",
"return",
"$",
"this",
"->",
"eq",
"(",
"$",
"attribute",
",",
"$",
"v",
")",
";",
"}",
",",
"$",
"values",
")",
")",
";",
"}"
] |
Check if an attribute value matches any of the values in the list of values provided.
@param string $attribute
@param array $values
@return bOr
|
[
"Check",
"if",
"an",
"attribute",
"value",
"matches",
"any",
"of",
"the",
"values",
"in",
"the",
"list",
"of",
"values",
"provided",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Builder/FilterBuilder.php#L88-L93
|
27,980
|
ldaptools/ldaptools
|
src/LdapTools/Query/Builder/FilterBuilder.php
|
FilterBuilder.match
|
public function match($attribute, $rule, $value, $dnFlag = false)
{
return new MatchingRule($attribute, $rule, $value, $dnFlag);
}
|
php
|
public function match($attribute, $rule, $value, $dnFlag = false)
{
return new MatchingRule($attribute, $rule, $value, $dnFlag);
}
|
[
"public",
"function",
"match",
"(",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"value",
",",
"$",
"dnFlag",
"=",
"false",
")",
"{",
"return",
"new",
"MatchingRule",
"(",
"$",
"attribute",
",",
"$",
"rule",
",",
"$",
"value",
",",
"$",
"dnFlag",
")",
";",
"}"
] |
Perform an extensible match.
@param string|null $attribute
@param string|null $rule
@param mixed $value
@param bool $dnFlag
@return MatchingRule
|
[
"Perform",
"an",
"extensible",
"match",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Builder/FilterBuilder.php#L263-L266
|
27,981
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/TcpSocket.php
|
TcpSocket.connect
|
public function connect($host, $port, $timeout = 1)
{
$this->socket = @stream_socket_client(
"tcp://$host:$port",
$errorNumber,
$errorMessage,
$timeout,
STREAM_CLIENT_CONNECT,
stream_context_create($this->options)
);
return (bool) $this->socket;
}
|
php
|
public function connect($host, $port, $timeout = 1)
{
$this->socket = @stream_socket_client(
"tcp://$host:$port",
$errorNumber,
$errorMessage,
$timeout,
STREAM_CLIENT_CONNECT,
stream_context_create($this->options)
);
return (bool) $this->socket;
}
|
[
"public",
"function",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"socket",
"=",
"@",
"stream_socket_client",
"(",
"\"tcp://$host:$port\"",
",",
"$",
"errorNumber",
",",
"$",
"errorMessage",
",",
"$",
"timeout",
",",
"STREAM_CLIENT_CONNECT",
",",
"stream_context_create",
"(",
"$",
"this",
"->",
"options",
")",
")",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"socket",
";",
"}"
] |
Connect to the host on the port defined for this TCP socket.
@param string $host
@param int $port
@param int $timeout
@return bool
|
[
"Connect",
"to",
"the",
"host",
"on",
"the",
"port",
"defined",
"for",
"this",
"TCP",
"socket",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TcpSocket.php#L46-L58
|
27,982
|
ldaptools/ldaptools
|
src/LdapTools/ConfigurationParseTrait.php
|
ConfigurationParseTrait.getParsedConfig
|
protected function getParsedConfig(array $config, array $existingConfig, array $configMap, array $required)
{
$parsedConfig = [];
foreach ($config as $key => $value) {
$cfgKey = strtolower($key);
if (!isset($configMap[$cfgKey])) {
throw new ConfigurationException(
sprintf('Option "%s" not recognized.', $key)
);
}
$parsedConfig[$configMap[$cfgKey]] = $value;
}
if (!$this->isParsedConfigValid($parsedConfig, $required)) {
$needed = [];
foreach ($required as $option) {
$needed[] = array_search($option, $configMap);
}
throw new ConfigurationException(
sprintf('Some required configuration options are missing. Required: %s', implode(', ', $needed))
);
}
$existingConfig = array_merge($existingConfig, $parsedConfig);
return array_filter($existingConfig, function ($v) {
return $v !== null && $v !== '';
});
}
|
php
|
protected function getParsedConfig(array $config, array $existingConfig, array $configMap, array $required)
{
$parsedConfig = [];
foreach ($config as $key => $value) {
$cfgKey = strtolower($key);
if (!isset($configMap[$cfgKey])) {
throw new ConfigurationException(
sprintf('Option "%s" not recognized.', $key)
);
}
$parsedConfig[$configMap[$cfgKey]] = $value;
}
if (!$this->isParsedConfigValid($parsedConfig, $required)) {
$needed = [];
foreach ($required as $option) {
$needed[] = array_search($option, $configMap);
}
throw new ConfigurationException(
sprintf('Some required configuration options are missing. Required: %s', implode(', ', $needed))
);
}
$existingConfig = array_merge($existingConfig, $parsedConfig);
return array_filter($existingConfig, function ($v) {
return $v !== null && $v !== '';
});
}
|
[
"protected",
"function",
"getParsedConfig",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"existingConfig",
",",
"array",
"$",
"configMap",
",",
"array",
"$",
"required",
")",
"{",
"$",
"parsedConfig",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"cfgKey",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"configMap",
"[",
"$",
"cfgKey",
"]",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Option \"%s\" not recognized.'",
",",
"$",
"key",
")",
")",
";",
"}",
"$",
"parsedConfig",
"[",
"$",
"configMap",
"[",
"$",
"cfgKey",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isParsedConfigValid",
"(",
"$",
"parsedConfig",
",",
"$",
"required",
")",
")",
"{",
"$",
"needed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"required",
"as",
"$",
"option",
")",
"{",
"$",
"needed",
"[",
"]",
"=",
"array_search",
"(",
"$",
"option",
",",
"$",
"configMap",
")",
";",
"}",
"throw",
"new",
"ConfigurationException",
"(",
"sprintf",
"(",
"'Some required configuration options are missing. Required: %s'",
",",
"implode",
"(",
"', '",
",",
"$",
"needed",
")",
")",
")",
";",
"}",
"$",
"existingConfig",
"=",
"array_merge",
"(",
"$",
"existingConfig",
",",
"$",
"parsedConfig",
")",
";",
"return",
"array_filter",
"(",
"$",
"existingConfig",
",",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"!==",
"null",
"&&",
"$",
"v",
"!==",
"''",
";",
"}",
")",
";",
"}"
] |
Parses a YAML config section and sends it back as the correct config values as an array.
@param array $config The YAML config section as an array.
@param array $existingConfig The config before merging the YAML config.
@param array $configMap The YAML to config key map array.
@param array $required The required options that must be in the array.
@return array The YAML config merged with the existing config.
@throws ConfigurationException
|
[
"Parses",
"a",
"YAML",
"config",
"section",
"and",
"sends",
"it",
"back",
"as",
"the",
"correct",
"config",
"values",
"as",
"an",
"array",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/ConfigurationParseTrait.php#L32-L60
|
27,983
|
ldaptools/ldaptools
|
src/LdapTools/ConfigurationParseTrait.php
|
ConfigurationParseTrait.isParsedConfigValid
|
protected function isParsedConfigValid(array $config, array $required)
{
$inConfig = count(array_intersect_key(array_flip($required), array_filter($config)));
return $inConfig === count($required);
}
|
php
|
protected function isParsedConfigValid(array $config, array $required)
{
$inConfig = count(array_intersect_key(array_flip($required), array_filter($config)));
return $inConfig === count($required);
}
|
[
"protected",
"function",
"isParsedConfigValid",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"required",
")",
"{",
"$",
"inConfig",
"=",
"count",
"(",
"array_intersect_key",
"(",
"array_flip",
"(",
"$",
"required",
")",
",",
"array_filter",
"(",
"$",
"config",
")",
")",
")",
";",
"return",
"$",
"inConfig",
"===",
"count",
"(",
"$",
"required",
")",
";",
"}"
] |
Checks whether all required values for the configuration have been set after the merge.
@param array $config
@param array $required
@return bool
|
[
"Checks",
"whether",
"all",
"required",
"values",
"for",
"the",
"configuration",
"have",
"been",
"set",
"after",
"the",
"merge",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/ConfigurationParseTrait.php#L69-L74
|
27,984
|
ldaptools/ldaptools
|
src/LdapTools/ConfigurationParseTrait.php
|
ConfigurationParseTrait.setParsedConfig
|
protected function setParsedConfig(array $config)
{
foreach ($config as $key => $value) {
$setter = 'set'.ucfirst($key);
$this->$setter($value);
}
}
|
php
|
protected function setParsedConfig(array $config)
{
foreach ($config as $key => $value) {
$setter = 'set'.ucfirst($key);
$this->$setter($value);
}
}
|
[
"protected",
"function",
"setParsedConfig",
"(",
"array",
"$",
"config",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"setter",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"$",
"this",
"->",
"$",
"setter",
"(",
"$",
"value",
")",
";",
"}",
"}"
] |
Given a config that has been parsed to what the config values should be, call the setters to make
sure all values are validated by any additional logic in the setters.
@param array $config
|
[
"Given",
"a",
"config",
"that",
"has",
"been",
"parsed",
"to",
"what",
"the",
"config",
"values",
"should",
"be",
"call",
"the",
"setters",
"to",
"make",
"sure",
"all",
"values",
"are",
"validated",
"by",
"any",
"additional",
"logic",
"in",
"the",
"setters",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/ConfigurationParseTrait.php#L82-L88
|
27,985
|
ldaptools/ldaptools
|
src/LdapTools/Utilities/UserParameters.php
|
UserParameters.toBinary
|
public function toBinary()
{
/**
* @todo There is no documentation on the reserved data, but this is how it seems to act. May need to change this.
*/
if (!$this->tsPropertyArray && !$this->dialInData) {
$binary = $this->encodeReservedData('');
} elseif ($this->tsPropertyArray && $this->dialInData) {
$binary = $this->encodeReservedData(self::RESERVED_DATA_VALUE['NPS_RDS']);
}
|
php
|
public function toBinary()
{
/**
* @todo There is no documentation on the reserved data, but this is how it seems to act. May need to change this.
*/
if (!$this->tsPropertyArray && !$this->dialInData) {
$binary = $this->encodeReservedData('');
} elseif ($this->tsPropertyArray && $this->dialInData) {
$binary = $this->encodeReservedData(self::RESERVED_DATA_VALUE['NPS_RDS']);
}
|
[
"public",
"function",
"toBinary",
"(",
")",
"{",
"/**\n * @todo There is no documentation on the reserved data, but this is how it seems to act. May need to change this.\n */",
"if",
"(",
"!",
"$",
"this",
"->",
"tsPropertyArray",
"&&",
"!",
"$",
"this",
"->",
"dialInData",
")",
"{",
"$",
"binary",
"=",
"$",
"this",
"->",
"encodeReservedData",
"(",
"''",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"tsPropertyArray",
"&&",
"$",
"this",
"->",
"dialInData",
")",
"{",
"$",
"binary",
"=",
"$",
"this",
"->",
"encodeReservedData",
"(",
"self",
"::",
"RESERVED_DATA_VALUE",
"",
"[",
"'NPS_RDS'",
"]",
")",
";",
"}"
] |
Get the userParameters in binary form that can be saved back to LDAP.
@return string
|
[
"Get",
"the",
"userParameters",
"in",
"binary",
"form",
"that",
"can",
"be",
"saved",
"back",
"to",
"LDAP",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/UserParameters.php#L115-L124
|
27,986
|
ldaptools/ldaptools
|
src/LdapTools/Hydrator/OperationHydrator.php
|
OperationHydrator.setDnToUse
|
protected function setDnToUse(AddOperation $operation)
{
// If the DN was explicitly set, don't do anything.
if ($operation->getDn()) {
return;
}
if (!$this->schema) {
throw new LogicException("You must explicitly set the DN or specify a schema type.");
}
$location = $operation->getLocation() ?: $this->schema->getDefaultContainer();
if (empty($location)) {
throw new LogicException('You must specify a container or OU to place this LDAP object in.');
}
// Handles a possible multi-valued RDN, where each RDN is pieced together with a '+'
$rdn = implode('+', array_map(function($rdn) use ($operation) {
return $rdn.'='.LdapUtilities::escapeValue($operation->getAttributes()[$rdn], null, LDAP_ESCAPE_DN);
}, $this->getRdnFromAttributes(array_keys($operation->getAttributes()))));
$operation->setDn($rdn.','.$this->resolveParameters(['container' => $location])['container']);
}
|
php
|
protected function setDnToUse(AddOperation $operation)
{
// If the DN was explicitly set, don't do anything.
if ($operation->getDn()) {
return;
}
if (!$this->schema) {
throw new LogicException("You must explicitly set the DN or specify a schema type.");
}
$location = $operation->getLocation() ?: $this->schema->getDefaultContainer();
if (empty($location)) {
throw new LogicException('You must specify a container or OU to place this LDAP object in.');
}
// Handles a possible multi-valued RDN, where each RDN is pieced together with a '+'
$rdn = implode('+', array_map(function($rdn) use ($operation) {
return $rdn.'='.LdapUtilities::escapeValue($operation->getAttributes()[$rdn], null, LDAP_ESCAPE_DN);
}, $this->getRdnFromAttributes(array_keys($operation->getAttributes()))));
$operation->setDn($rdn.','.$this->resolveParameters(['container' => $location])['container']);
}
|
[
"protected",
"function",
"setDnToUse",
"(",
"AddOperation",
"$",
"operation",
")",
"{",
"// If the DN was explicitly set, don't do anything.",
"if",
"(",
"$",
"operation",
"->",
"getDn",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"schema",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"You must explicitly set the DN or specify a schema type.\"",
")",
";",
"}",
"$",
"location",
"=",
"$",
"operation",
"->",
"getLocation",
"(",
")",
"?",
":",
"$",
"this",
"->",
"schema",
"->",
"getDefaultContainer",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"location",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'You must specify a container or OU to place this LDAP object in.'",
")",
";",
"}",
"// Handles a possible multi-valued RDN, where each RDN is pieced together with a '+'",
"$",
"rdn",
"=",
"implode",
"(",
"'+'",
",",
"array_map",
"(",
"function",
"(",
"$",
"rdn",
")",
"use",
"(",
"$",
"operation",
")",
"{",
"return",
"$",
"rdn",
".",
"'='",
".",
"LdapUtilities",
"::",
"escapeValue",
"(",
"$",
"operation",
"->",
"getAttributes",
"(",
")",
"[",
"$",
"rdn",
"]",
",",
"null",
",",
"LDAP_ESCAPE_DN",
")",
";",
"}",
",",
"$",
"this",
"->",
"getRdnFromAttributes",
"(",
"array_keys",
"(",
"$",
"operation",
"->",
"getAttributes",
"(",
")",
")",
")",
")",
")",
";",
"$",
"operation",
"->",
"setDn",
"(",
"$",
"rdn",
".",
"','",
".",
"$",
"this",
"->",
"resolveParameters",
"(",
"[",
"'container'",
"=>",
"$",
"location",
"]",
")",
"[",
"'container'",
"]",
")",
";",
"}"
] |
Builds the DN based off of the "name" attribute. The name attribute should be mapped to the "cn" attribute in
pretty much all cases except for creating an OU object. Then the "name" attribute should be mapped to "ou".
@param AddOperation $operation
|
[
"Builds",
"the",
"DN",
"based",
"off",
"of",
"the",
"name",
"attribute",
".",
"The",
"name",
"attribute",
"should",
"be",
"mapped",
"to",
"the",
"cn",
"attribute",
"in",
"pretty",
"much",
"all",
"cases",
"except",
"for",
"creating",
"an",
"OU",
"object",
".",
"Then",
"the",
"name",
"attribute",
"should",
"be",
"mapped",
"to",
"ou",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L158-L176
|
27,987
|
ldaptools/ldaptools
|
src/LdapTools/Hydrator/OperationHydrator.php
|
OperationHydrator.getRdnFromAttributes
|
protected function getRdnFromAttributes(array $attributes) {
$rdn = [];
$rdnAttributes = array_map('strtolower', $this->schema->getRdn());
foreach ($rdnAttributes as $rdnAttribute) {
$rdnAttribute = $this->schema->getAttributeToLdap($rdnAttribute);
foreach ($attributes as $attribute) {
if (strtolower($attribute) === $rdnAttribute) {
$rdn[] = $attribute;
}
}
}
if (empty($rdn)) {
throw new LogicException(sprintf(
'To create a LDAP object you must use a RDN attribute from the schema. It is needed to form the base of'
. ' the distinguished name. Expected one, or more, of these attributes: %s',
implode(', ', $this->schema->getRdn())
));
}
return $rdn;
}
|
php
|
protected function getRdnFromAttributes(array $attributes) {
$rdn = [];
$rdnAttributes = array_map('strtolower', $this->schema->getRdn());
foreach ($rdnAttributes as $rdnAttribute) {
$rdnAttribute = $this->schema->getAttributeToLdap($rdnAttribute);
foreach ($attributes as $attribute) {
if (strtolower($attribute) === $rdnAttribute) {
$rdn[] = $attribute;
}
}
}
if (empty($rdn)) {
throw new LogicException(sprintf(
'To create a LDAP object you must use a RDN attribute from the schema. It is needed to form the base of'
. ' the distinguished name. Expected one, or more, of these attributes: %s',
implode(', ', $this->schema->getRdn())
));
}
return $rdn;
}
|
[
"protected",
"function",
"getRdnFromAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"rdn",
"=",
"[",
"]",
";",
"$",
"rdnAttributes",
"=",
"array_map",
"(",
"'strtolower'",
",",
"$",
"this",
"->",
"schema",
"->",
"getRdn",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"rdnAttributes",
"as",
"$",
"rdnAttribute",
")",
"{",
"$",
"rdnAttribute",
"=",
"$",
"this",
"->",
"schema",
"->",
"getAttributeToLdap",
"(",
"$",
"rdnAttribute",
")",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"attribute",
")",
"===",
"$",
"rdnAttribute",
")",
"{",
"$",
"rdn",
"[",
"]",
"=",
"$",
"attribute",
";",
"}",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"rdn",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'To create a LDAP object you must use a RDN attribute from the schema. It is needed to form the base of'",
".",
"' the distinguished name. Expected one, or more, of these attributes: %s'",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"schema",
"->",
"getRdn",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"$",
"rdn",
";",
"}"
] |
Get the RDN attribute used to form the DN.
@param array $attributes The attribute names.
@return array
|
[
"Get",
"the",
"RDN",
"attribute",
"used",
"to",
"form",
"the",
"DN",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L184-L205
|
27,988
|
ldaptools/ldaptools
|
src/LdapTools/Hydrator/OperationHydrator.php
|
OperationHydrator.setDefaultParameters
|
protected function setDefaultParameters()
{
if (!$this->connection) {
return;
}
$this->parameters['_domainname_'] = $this->connection->getConfig()->getDomainName();
$rootDse = $this->connection->getRootDse();
// Would this ever not be true? I'm unable to find any RFCs specifically regarding Root DSE structure.
if ($rootDse->has('defaultNamingContext')) {
$this->parameters['_defaultnamingcontext_'] = $rootDse->get('defaultNamingContext');
}
if ($rootDse->has('configurationNamingContext')) {
$this->parameters['_configurationnamingcontext_'] = $rootDse->get('configurationNamingContext');
}
}
|
php
|
protected function setDefaultParameters()
{
if (!$this->connection) {
return;
}
$this->parameters['_domainname_'] = $this->connection->getConfig()->getDomainName();
$rootDse = $this->connection->getRootDse();
// Would this ever not be true? I'm unable to find any RFCs specifically regarding Root DSE structure.
if ($rootDse->has('defaultNamingContext')) {
$this->parameters['_defaultnamingcontext_'] = $rootDse->get('defaultNamingContext');
}
if ($rootDse->has('configurationNamingContext')) {
$this->parameters['_configurationnamingcontext_'] = $rootDse->get('configurationNamingContext');
}
}
|
[
"protected",
"function",
"setDefaultParameters",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"parameters",
"[",
"'_domainname_'",
"]",
"=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getDomainName",
"(",
")",
";",
"$",
"rootDse",
"=",
"$",
"this",
"->",
"connection",
"->",
"getRootDse",
"(",
")",
";",
"// Would this ever not be true? I'm unable to find any RFCs specifically regarding Root DSE structure.",
"if",
"(",
"$",
"rootDse",
"->",
"has",
"(",
"'defaultNamingContext'",
")",
")",
"{",
"$",
"this",
"->",
"parameters",
"[",
"'_defaultnamingcontext_'",
"]",
"=",
"$",
"rootDse",
"->",
"get",
"(",
"'defaultNamingContext'",
")",
";",
"}",
"if",
"(",
"$",
"rootDse",
"->",
"has",
"(",
"'configurationNamingContext'",
")",
")",
"{",
"$",
"this",
"->",
"parameters",
"[",
"'_configurationnamingcontext_'",
"]",
"=",
"$",
"rootDse",
"->",
"get",
"(",
"'configurationNamingContext'",
")",
";",
"}",
"}"
] |
Set some default parameters based off the connection.
|
[
"Set",
"some",
"default",
"parameters",
"based",
"off",
"the",
"connection",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L238-L253
|
27,989
|
ldaptools/ldaptools
|
src/LdapTools/Hydrator/OperationHydrator.php
|
OperationHydrator.filterAttributeValues
|
protected function filterAttributeValues(array $attributes)
{
return array_filter($attributes, function ($value) {
if (is_array($value) && empty($value)) {
return false;
}
return !($value === '' || $value === null);
});
}
|
php
|
protected function filterAttributeValues(array $attributes)
{
return array_filter($attributes, function ($value) {
if (is_array($value) && empty($value)) {
return false;
}
return !($value === '' || $value === null);
});
}
|
[
"protected",
"function",
"filterAttributeValues",
"(",
"array",
"$",
"attributes",
")",
"{",
"return",
"array_filter",
"(",
"$",
"attributes",
",",
"function",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
")",
";",
"}",
")",
";",
"}"
] |
Remove empty strings and null values from attribute value arrays. This prevents errors when saving to LDAP and
these are present for some reason.
@param array $attributes
@return array
|
[
"Remove",
"empty",
"strings",
"and",
"null",
"values",
"from",
"attribute",
"value",
"arrays",
".",
"This",
"prevents",
"errors",
"when",
"saving",
"to",
"LDAP",
"and",
"these",
"are",
"present",
"for",
"some",
"reason",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Hydrator/OperationHydrator.php#L271-L280
|
27,990
|
ldaptools/ldaptools
|
src/LdapTools/Connection/PageControl.php
|
PageControl.start
|
public function start($pageSize, $sizeLimit = 0)
{
if ($this->isEnabled) {
$this->cookie = '';
$this->pageSize = ($sizeLimit && $sizeLimit < $pageSize) ? $sizeLimit : $pageSize;
$this->sizeLimit = $sizeLimit;
}
}
|
php
|
public function start($pageSize, $sizeLimit = 0)
{
if ($this->isEnabled) {
$this->cookie = '';
$this->pageSize = ($sizeLimit && $sizeLimit < $pageSize) ? $sizeLimit : $pageSize;
$this->sizeLimit = $sizeLimit;
}
}
|
[
"public",
"function",
"start",
"(",
"$",
"pageSize",
",",
"$",
"sizeLimit",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"$",
"this",
"->",
"cookie",
"=",
"''",
";",
"$",
"this",
"->",
"pageSize",
"=",
"(",
"$",
"sizeLimit",
"&&",
"$",
"sizeLimit",
"<",
"$",
"pageSize",
")",
"?",
"$",
"sizeLimit",
":",
"$",
"pageSize",
";",
"$",
"this",
"->",
"sizeLimit",
"=",
"$",
"sizeLimit",
";",
"}",
"}"
] |
Start a paging operation by setting up the cookie and the page size. Optionally set a size limit.
@param int $pageSize
@param int $sizeLimit
@throws LdapConnectionException
|
[
"Start",
"a",
"paging",
"operation",
"by",
"setting",
"up",
"the",
"cookie",
"and",
"the",
"page",
"size",
".",
"Optionally",
"set",
"a",
"size",
"limit",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L67-L74
|
27,991
|
ldaptools/ldaptools
|
src/LdapTools/Connection/PageControl.php
|
PageControl.end
|
public function end()
{
if ($this->isEnabled) {
$this->resetPagingControl();
$this->cookie = null;
$this->resultNumber = 0;
}
}
|
php
|
public function end()
{
if ($this->isEnabled) {
$this->resetPagingControl();
$this->cookie = null;
$this->resultNumber = 0;
}
}
|
[
"public",
"function",
"end",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"$",
"this",
"->",
"resetPagingControl",
"(",
")",
";",
"$",
"this",
"->",
"cookie",
"=",
"null",
";",
"$",
"this",
"->",
"resultNumber",
"=",
"0",
";",
"}",
"}"
] |
End a paging operation.
@throws LdapConnectionException
|
[
"End",
"a",
"paging",
"operation",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L81-L88
|
27,992
|
ldaptools/ldaptools
|
src/LdapTools/Connection/PageControl.php
|
PageControl.next
|
public function next()
{
if (!$this->isEnabled) {
return;
}
// If the size limit exceeds the page size, and the next page would exceed the limit, reduce the page size...
if ($this->sizeLimit && ($this->resultNumber + $this->pageSize) > $this->sizeLimit) {
$this->pageSize = $this->sizeLimit - $this->resultNumber;
}
if (!@ldap_control_paged_result($this->connection->getResource(), $this->pageSize, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to enable paged results (%s): %s',
$this->connection->getLastErrorNumber(),
$this->connection->getLastError()
), $this->connection->getLastErrorNumber());
}
}
|
php
|
public function next()
{
if (!$this->isEnabled) {
return;
}
// If the size limit exceeds the page size, and the next page would exceed the limit, reduce the page size...
if ($this->sizeLimit && ($this->resultNumber + $this->pageSize) > $this->sizeLimit) {
$this->pageSize = $this->sizeLimit - $this->resultNumber;
}
if (!@ldap_control_paged_result($this->connection->getResource(), $this->pageSize, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to enable paged results (%s): %s',
$this->connection->getLastErrorNumber(),
$this->connection->getLastError()
), $this->connection->getLastErrorNumber());
}
}
|
[
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"return",
";",
"}",
"// If the size limit exceeds the page size, and the next page would exceed the limit, reduce the page size...",
"if",
"(",
"$",
"this",
"->",
"sizeLimit",
"&&",
"(",
"$",
"this",
"->",
"resultNumber",
"+",
"$",
"this",
"->",
"pageSize",
")",
">",
"$",
"this",
"->",
"sizeLimit",
")",
"{",
"$",
"this",
"->",
"pageSize",
"=",
"$",
"this",
"->",
"sizeLimit",
"-",
"$",
"this",
"->",
"resultNumber",
";",
"}",
"if",
"(",
"!",
"@",
"ldap_control_paged_result",
"(",
"$",
"this",
"->",
"connection",
"->",
"getResource",
"(",
")",
",",
"$",
"this",
"->",
"pageSize",
",",
"false",
",",
"$",
"this",
"->",
"cookie",
")",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"'Unable to enable paged results (%s): %s'",
",",
"$",
"this",
"->",
"connection",
"->",
"getLastErrorNumber",
"(",
")",
",",
"$",
"this",
"->",
"connection",
"->",
"getLastError",
"(",
")",
")",
",",
"$",
"this",
"->",
"connection",
"->",
"getLastErrorNumber",
"(",
")",
")",
";",
"}",
"}"
] |
Signifies to the connection to expect the next paged result with the current cookie and page size.
@throws LdapConnectionException
|
[
"Signifies",
"to",
"the",
"connection",
"to",
"expect",
"the",
"next",
"paged",
"result",
"with",
"the",
"current",
"cookie",
"and",
"page",
"size",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L95-L111
|
27,993
|
ldaptools/ldaptools
|
src/LdapTools/Connection/PageControl.php
|
PageControl.update
|
public function update($result)
{
if (!$this->isEnabled) {
return;
}
$this->resultNumber += $this->pageSize;
if (!@ldap_control_paged_result_response($this->connection->getResource(), $result, $this->cookie)) {
throw new LdapConnectionException(
sprintf('Unable to set paged results response: %s', $this->connection->getLastError())
);
}
}
|
php
|
public function update($result)
{
if (!$this->isEnabled) {
return;
}
$this->resultNumber += $this->pageSize;
if (!@ldap_control_paged_result_response($this->connection->getResource(), $result, $this->cookie)) {
throw new LdapConnectionException(
sprintf('Unable to set paged results response: %s', $this->connection->getLastError())
);
}
}
|
[
"public",
"function",
"update",
"(",
"$",
"result",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEnabled",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"resultNumber",
"+=",
"$",
"this",
"->",
"pageSize",
";",
"if",
"(",
"!",
"@",
"ldap_control_paged_result_response",
"(",
"$",
"this",
"->",
"connection",
"->",
"getResource",
"(",
")",
",",
"$",
"result",
",",
"$",
"this",
"->",
"cookie",
")",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"'Unable to set paged results response: %s'",
",",
"$",
"this",
"->",
"connection",
"->",
"getLastError",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Updating the paging operation based on the result resource returned from a query.
@param resource $result
@throws LdapConnectionException
|
[
"Updating",
"the",
"paging",
"operation",
"based",
"on",
"the",
"result",
"resource",
"returned",
"from",
"a",
"query",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L119-L130
|
27,994
|
ldaptools/ldaptools
|
src/LdapTools/Connection/PageControl.php
|
PageControl.resetPagingControl
|
public function resetPagingControl()
{
// Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.
// However, testing this it doesn't seem to completely work. Perhaps a PHP bug?
if (!@ldap_control_paged_result($this->connection->getResource(), 0, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to reset paged results control for read operation: %s',
$this->connection->getLastError()
));
}
}
|
php
|
public function resetPagingControl()
{
// Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.
// However, testing this it doesn't seem to completely work. Perhaps a PHP bug?
if (!@ldap_control_paged_result($this->connection->getResource(), 0, false, $this->cookie)) {
throw new LdapConnectionException(sprintf(
'Unable to reset paged results control for read operation: %s',
$this->connection->getLastError()
));
}
}
|
[
"public",
"function",
"resetPagingControl",
"(",
")",
"{",
"// Per RFC 2696, to abandon a paged search you should send a size of 0 along with the cookie used in the search.",
"// However, testing this it doesn't seem to completely work. Perhaps a PHP bug?",
"if",
"(",
"!",
"@",
"ldap_control_paged_result",
"(",
"$",
"this",
"->",
"connection",
"->",
"getResource",
"(",
")",
",",
"0",
",",
"false",
",",
"$",
"this",
"->",
"cookie",
")",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"'Unable to reset paged results control for read operation: %s'",
",",
"$",
"this",
"->",
"connection",
"->",
"getLastError",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Resets the paging control so that read operations work after a paging operation is used.
@throws LdapConnectionException
|
[
"Resets",
"the",
"paging",
"control",
"so",
"that",
"read",
"operations",
"work",
"after",
"a",
"paging",
"operation",
"is",
"used",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/PageControl.php#L137-L147
|
27,995
|
ldaptools/ldaptools
|
src/LdapTools/Query/Operator/BaseOperator.php
|
BaseOperator.getConvertedValue
|
public function getConvertedValue($alias = null)
{
if ($alias && isset($this->convertedAliasValue[$alias])) {
return $this->convertedAliasValue[$alias];
} else {
return $this->convertedValue;
}
}
|
php
|
public function getConvertedValue($alias = null)
{
if ($alias && isset($this->convertedAliasValue[$alias])) {
return $this->convertedAliasValue[$alias];
} else {
return $this->convertedValue;
}
}
|
[
"public",
"function",
"getConvertedValue",
"(",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
"&&",
"isset",
"(",
"$",
"this",
"->",
"convertedAliasValue",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"convertedAliasValue",
"[",
"$",
"alias",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"convertedValue",
";",
"}",
"}"
] |
Get the converted value.
@param string|null $alias
@return mixed
|
[
"Get",
"the",
"converted",
"value",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L124-L131
|
27,996
|
ldaptools/ldaptools
|
src/LdapTools/Query/Operator/BaseOperator.php
|
BaseOperator.setConvertedValue
|
public function setConvertedValue($value, $alias = null)
{
if ($alias) {
$this->convertedAliasValue[$alias] = $value;
} else {
$this->convertedValue = $value;
}
}
|
php
|
public function setConvertedValue($value, $alias = null)
{
if ($alias) {
$this->convertedAliasValue[$alias] = $value;
} else {
$this->convertedValue = $value;
}
}
|
[
"public",
"function",
"setConvertedValue",
"(",
"$",
"value",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"convertedAliasValue",
"[",
"$",
"alias",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"convertedValue",
"=",
"$",
"value",
";",
"}",
"}"
] |
Set the converted value.
@param string|null $alias
@param mixed $value
|
[
"Set",
"the",
"converted",
"value",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L139-L146
|
27,997
|
ldaptools/ldaptools
|
src/LdapTools/Query/Operator/BaseOperator.php
|
BaseOperator.setAttribute
|
public function setAttribute($attribute)
{
if (strpos($attribute, '.') !== false) {
$pieces = explode('.', $attribute, 2);
$this->setAlias($pieces[0]);
$attribute = $pieces[1];
// If an alias was already set then this must be set back to null.
} else {
$this->alias = null;
}
$this->attribute = $attribute;
}
|
php
|
public function setAttribute($attribute)
{
if (strpos($attribute, '.') !== false) {
$pieces = explode('.', $attribute, 2);
$this->setAlias($pieces[0]);
$attribute = $pieces[1];
// If an alias was already set then this must be set back to null.
} else {
$this->alias = null;
}
$this->attribute = $attribute;
}
|
[
"public",
"function",
"setAttribute",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"attribute",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"'.'",
",",
"$",
"attribute",
",",
"2",
")",
";",
"$",
"this",
"->",
"setAlias",
"(",
"$",
"pieces",
"[",
"0",
"]",
")",
";",
"$",
"attribute",
"=",
"$",
"pieces",
"[",
"1",
"]",
";",
"// If an alias was already set then this must be set back to null.",
"}",
"else",
"{",
"$",
"this",
"->",
"alias",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"attribute",
"=",
"$",
"attribute",
";",
"}"
] |
Set the attribute.
@param string $attribute
|
[
"Set",
"the",
"attribute",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L163-L174
|
27,998
|
ldaptools/ldaptools
|
src/LdapTools/Query/Operator/BaseOperator.php
|
BaseOperator.setOperatorSymbol
|
public function setOperatorSymbol($symbol)
{
if (!in_array($symbol, $this->validOperators)) {
throw new LdapQueryException(sprintf(
'Invalid operator symbol "%s". Valid operator symbols are: %s',
$symbol,
implode(', ', $this->validOperators)
));
}
$this->operatorSymbol = $symbol;
}
|
php
|
public function setOperatorSymbol($symbol)
{
if (!in_array($symbol, $this->validOperators)) {
throw new LdapQueryException(sprintf(
'Invalid operator symbol "%s". Valid operator symbols are: %s',
$symbol,
implode(', ', $this->validOperators)
));
}
$this->operatorSymbol = $symbol;
}
|
[
"public",
"function",
"setOperatorSymbol",
"(",
"$",
"symbol",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"symbol",
",",
"$",
"this",
"->",
"validOperators",
")",
")",
"{",
"throw",
"new",
"LdapQueryException",
"(",
"sprintf",
"(",
"'Invalid operator symbol \"%s\". Valid operator symbols are: %s'",
",",
"$",
"symbol",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"validOperators",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"operatorSymbol",
"=",
"$",
"symbol",
";",
"}"
] |
Set the operator symbol in use.
@param $symbol
@throws LdapQueryException
|
[
"Set",
"the",
"operator",
"symbol",
"in",
"use",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L222-L233
|
27,999
|
ldaptools/ldaptools
|
src/LdapTools/Query/Operator/BaseOperator.php
|
BaseOperator.setWasConverterUsed
|
public function setWasConverterUsed($value, $alias = null)
{
if ($alias) {
$this->converterAliasUsed[$alias] = (bool) $value;
} else {
$this->converterUsed = (bool) $value;
}
}
|
php
|
public function setWasConverterUsed($value, $alias = null)
{
if ($alias) {
$this->converterAliasUsed[$alias] = (bool) $value;
} else {
$this->converterUsed = (bool) $value;
}
}
|
[
"public",
"function",
"setWasConverterUsed",
"(",
"$",
"value",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"converterAliasUsed",
"[",
"$",
"alias",
"]",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"converterUsed",
"=",
"(",
"bool",
")",
"$",
"value",
";",
"}",
"}"
] |
Set whether a converter was used or not.
@param bool $value
@param string|null $alias
|
[
"Set",
"whether",
"a",
"converter",
"was",
"used",
"or",
"not",
"."
] |
b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7
|
https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Query/Operator/BaseOperator.php#L281-L288
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.