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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,100 | ldaptools/ldaptools | src/LdapTools/LdapManager.php | LdapManager.getSchemaFactory | public function getSchemaFactory()
{
if (!$this->schemaFactory) {
$this->schemaFactory = new LdapObjectSchemaFactory(
$this->getCache(), $this->getSchemaParser(), $this->config->getEventDispatcher()
);
}
return $this->schemaFactory;
} | php | public function getSchemaFactory()
{
if (!$this->schemaFactory) {
$this->schemaFactory = new LdapObjectSchemaFactory(
$this->getCache(), $this->getSchemaParser(), $this->config->getEventDispatcher()
);
}
return $this->schemaFactory;
} | [
"public",
"function",
"getSchemaFactory",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"schemaFactory",
")",
"{",
"$",
"this",
"->",
"schemaFactory",
"=",
"new",
"LdapObjectSchemaFactory",
"(",
"$",
"this",
"->",
"getCache",
"(",
")",
",",
"$",
"this",
"->",
"getSchemaParser",
"(",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getEventDispatcher",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"schemaFactory",
";",
"}"
] | Retrieve the schema factory instance.
@return LdapObjectSchemaFactory | [
"Retrieve",
"the",
"schema",
"factory",
"instance",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L336-L345 |
28,101 | ldaptools/ldaptools | src/LdapTools/LdapManager.php | LdapManager.getCache | public function getCache()
{
if (!$this->config->getCache()) {
// This will be removed eventually. The default cache will be instantiated directly in the config class.
$this->config->setCache(CacheFactory::get($this->config->getCacheType(), $this->config->getCacheOptions()));
}
return $this->config->getCache();
} | php | public function getCache()
{
if (!$this->config->getCache()) {
// This will be removed eventually. The default cache will be instantiated directly in the config class.
$this->config->setCache(CacheFactory::get($this->config->getCacheType(), $this->config->getCacheOptions()));
}
return $this->config->getCache();
} | [
"public",
"function",
"getCache",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"->",
"getCache",
"(",
")",
")",
"{",
"// This will be removed eventually. The default cache will be instantiated directly in the config class.",
"$",
"this",
"->",
"config",
"->",
"setCache",
"(",
"CacheFactory",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
"->",
"getCacheType",
"(",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getCacheOptions",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"config",
"->",
"getCache",
"(",
")",
";",
"}"
] | Retrieve the cache instance.
@return Cache\CacheInterface | [
"Retrieve",
"the",
"cache",
"instance",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L352-L360 |
28,102 | ldaptools/ldaptools | src/LdapTools/LdapManager.php | LdapManager.getSchemaParser | public function getSchemaParser()
{
if (!$this->schemaParser) {
$this->schemaParser = SchemaParserFactory::get(
$this->config->getSchemaFormat(),
$this->config->getSchemaFolder()
);
}
return $this->schemaParser;
} | php | public function getSchemaParser()
{
if (!$this->schemaParser) {
$this->schemaParser = SchemaParserFactory::get(
$this->config->getSchemaFormat(),
$this->config->getSchemaFolder()
);
}
return $this->schemaParser;
} | [
"public",
"function",
"getSchemaParser",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"schemaParser",
")",
"{",
"$",
"this",
"->",
"schemaParser",
"=",
"SchemaParserFactory",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
"->",
"getSchemaFormat",
"(",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getSchemaFolder",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"schemaParser",
";",
"}"
] | Retrieve the schema parser instance.
@return Schema\Parser\SchemaParserInterface | [
"Retrieve",
"the",
"schema",
"parser",
"instance",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L367-L377 |
28,103 | ldaptools/ldaptools | src/LdapTools/LdapManager.php | LdapManager.validateDomainName | protected function validateDomainName($domain)
{
if (!array_key_exists($domain, $this->domains)) {
throw new InvalidArgumentException(sprintf(
'Domain "%s" is not valid. Valid domains are: %s',
$domain,
implode(', ', array_keys($this->domains))
));
}
} | php | protected function validateDomainName($domain)
{
if (!array_key_exists($domain, $this->domains)) {
throw new InvalidArgumentException(sprintf(
'Domain "%s" is not valid. Valid domains are: %s',
$domain,
implode(', ', array_keys($this->domains))
));
}
} | [
"protected",
"function",
"validateDomainName",
"(",
"$",
"domain",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"domain",
",",
"$",
"this",
"->",
"domains",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Domain \"%s\" is not valid. Valid domains are: %s'",
",",
"$",
"domain",
",",
"implode",
"(",
"', '",
",",
"array_keys",
"(",
"$",
"this",
"->",
"domains",
")",
")",
")",
")",
";",
"}",
"}"
] | Validates that the domain name actually exists.
@param string $domain | [
"Validates",
"that",
"the",
"domain",
"name",
"actually",
"exists",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L394-L403 |
28,104 | ldaptools/ldaptools | src/LdapTools/LdapManager.php | LdapManager.getObjectManager | protected function getObjectManager()
{
if (!isset($this->ldapObjectManager[$this->context])) {
$this->ldapObjectManager[$this->context] = new LdapObjectManager(
$this->getConnection(),
$this->getSchemaFactory(),
$this->config->getEventDispatcher()
);
}
return $this->ldapObjectManager[$this->context];
} | php | protected function getObjectManager()
{
if (!isset($this->ldapObjectManager[$this->context])) {
$this->ldapObjectManager[$this->context] = new LdapObjectManager(
$this->getConnection(),
$this->getSchemaFactory(),
$this->config->getEventDispatcher()
);
}
return $this->ldapObjectManager[$this->context];
} | [
"protected",
"function",
"getObjectManager",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"ldapObjectManager",
"[",
"$",
"this",
"->",
"context",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ldapObjectManager",
"[",
"$",
"this",
"->",
"context",
"]",
"=",
"new",
"LdapObjectManager",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
",",
"$",
"this",
"->",
"getSchemaFactory",
"(",
")",
",",
"$",
"this",
"->",
"config",
"->",
"getEventDispatcher",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"ldapObjectManager",
"[",
"$",
"this",
"->",
"context",
"]",
";",
"}"
] | Retrieve the LdapObjectManager for the current domain context.
@return LdapObjectManager | [
"Retrieve",
"the",
"LdapObjectManager",
"for",
"the",
"current",
"domain",
"context",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L410-L421 |
28,105 | ldaptools/ldaptools | src/LdapTools/LdapManager.php | LdapManager.getLdapObjectSchema | protected function getLdapObjectSchema($type)
{
return $this->getSchemaFactory()->get($this->getConnection()->getConfig()->getSchemaName(), $type);
} | php | protected function getLdapObjectSchema($type)
{
return $this->getSchemaFactory()->get($this->getConnection()->getConfig()->getSchemaName(), $type);
} | [
"protected",
"function",
"getLdapObjectSchema",
"(",
"$",
"type",
")",
"{",
"return",
"$",
"this",
"->",
"getSchemaFactory",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"getConfig",
"(",
")",
"->",
"getSchemaName",
"(",
")",
",",
"$",
"type",
")",
";",
"}"
] | Get the LDAP object schema from the factory by its type.
@param string $type
@return Schema\LdapObjectSchema | [
"Get",
"the",
"LDAP",
"object",
"schema",
"from",
"the",
"factory",
"by",
"its",
"type",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/LdapManager.php#L429-L432 |
28,106 | ldaptools/ldaptools | src/LdapTools/Cache/DoctrineCache.php | DoctrineCache.parseOptions | protected function parseOptions(array $options)
{
if (isset($options['cache_folder'])) {
$this->setCacheFolder($options['cache_folder']);
}
if (isset($options['cache_prefix'])) {
$this->cachePrefix = $options['cache_prefix'];
}
} | php | protected function parseOptions(array $options)
{
if (isset($options['cache_folder'])) {
$this->setCacheFolder($options['cache_folder']);
}
if (isset($options['cache_prefix'])) {
$this->cachePrefix = $options['cache_prefix'];
}
} | [
"protected",
"function",
"parseOptions",
"(",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'cache_folder'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setCacheFolder",
"(",
"$",
"options",
"[",
"'cache_folder'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'cache_prefix'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cachePrefix",
"=",
"$",
"options",
"[",
"'cache_prefix'",
"]",
";",
"}",
"}"
] | Check for any options that apply to the Doctrine cache.
@param array $options | [
"Check",
"for",
"any",
"options",
"that",
"apply",
"to",
"the",
"Doctrine",
"cache",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Cache/DoctrineCache.php#L155-L163 |
28,107 | ldaptools/ldaptools | src/LdapTools/Security/SddlParser.php | SddlParser.parse | public function parse($sddl)
{
if (!preg_match(self::MATCH_SDDL, (string) $sddl, $matches)) {
throw new SddlParserException('The SDDL string is not valid.');
}
$sd = (new SecurityDescriptor())
->setOwner($this->getSid($matches[1], 'owner'))
->setGroup($this->getSid($matches[2], 'group'));
$this->parseAcl(strtoupper($matches[4]), $matches[5], $sd);
if (isset($matches[7])) {
$this->parseAcl(strtoupper($matches[7]), $matches[8], $sd);
}
return $sd;
} | php | public function parse($sddl)
{
if (!preg_match(self::MATCH_SDDL, (string) $sddl, $matches)) {
throw new SddlParserException('The SDDL string is not valid.');
}
$sd = (new SecurityDescriptor())
->setOwner($this->getSid($matches[1], 'owner'))
->setGroup($this->getSid($matches[2], 'group'));
$this->parseAcl(strtoupper($matches[4]), $matches[5], $sd);
if (isset($matches[7])) {
$this->parseAcl(strtoupper($matches[7]), $matches[8], $sd);
}
return $sd;
} | [
"public",
"function",
"parse",
"(",
"$",
"sddl",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"MATCH_SDDL",
",",
"(",
"string",
")",
"$",
"sddl",
",",
"$",
"matches",
")",
")",
"{",
"throw",
"new",
"SddlParserException",
"(",
"'The SDDL string is not valid.'",
")",
";",
"}",
"$",
"sd",
"=",
"(",
"new",
"SecurityDescriptor",
"(",
")",
")",
"->",
"setOwner",
"(",
"$",
"this",
"->",
"getSid",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"'owner'",
")",
")",
"->",
"setGroup",
"(",
"$",
"this",
"->",
"getSid",
"(",
"$",
"matches",
"[",
"2",
"]",
",",
"'group'",
")",
")",
";",
"$",
"this",
"->",
"parseAcl",
"(",
"strtoupper",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
",",
"$",
"matches",
"[",
"5",
"]",
",",
"$",
"sd",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"7",
"]",
")",
")",
"{",
"$",
"this",
"->",
"parseAcl",
"(",
"strtoupper",
"(",
"$",
"matches",
"[",
"7",
"]",
")",
",",
"$",
"matches",
"[",
"8",
"]",
",",
"$",
"sd",
")",
";",
"}",
"return",
"$",
"sd",
";",
"}"
] | Given a full SDDL string, parse it and return the SecurityDescriptor object that it represents.
@param string $sddl
@return SecurityDescriptor
@throws SddlParserException | [
"Given",
"a",
"full",
"SDDL",
"string",
"parse",
"it",
"and",
"return",
"the",
"SecurityDescriptor",
"object",
"that",
"it",
"represents",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/SddlParser.php#L71-L87 |
28,108 | ldaptools/ldaptools | src/LdapTools/AttributeConverter/ConvertFlags.php | ConvertFlags.modifyFlagValue | protected function modifyFlagValue($value)
{
$this->setDefaultLastValue($this->getEnumAttribute(), $this->getDefaultEnumValue());
$flags = $this->getFlagFromLastValue($this->getLastValue());
$value = $this->options['invert'] ? !$value : $value;
if ($value) {
$flags->add($this->flagName);
} else {
$flags->remove($this->flagName);
}
return $flags->getValue();
} | php | protected function modifyFlagValue($value)
{
$this->setDefaultLastValue($this->getEnumAttribute(), $this->getDefaultEnumValue());
$flags = $this->getFlagFromLastValue($this->getLastValue());
$value = $this->options['invert'] ? !$value : $value;
if ($value) {
$flags->add($this->flagName);
} else {
$flags->remove($this->flagName);
}
return $flags->getValue();
} | [
"protected",
"function",
"modifyFlagValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setDefaultLastValue",
"(",
"$",
"this",
"->",
"getEnumAttribute",
"(",
")",
",",
"$",
"this",
"->",
"getDefaultEnumValue",
"(",
")",
")",
";",
"$",
"flags",
"=",
"$",
"this",
"->",
"getFlagFromLastValue",
"(",
"$",
"this",
"->",
"getLastValue",
"(",
")",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"options",
"[",
"'invert'",
"]",
"?",
"!",
"$",
"value",
":",
"$",
"value",
";",
"if",
"(",
"$",
"value",
")",
"{",
"$",
"flags",
"->",
"add",
"(",
"$",
"this",
"->",
"flagName",
")",
";",
"}",
"else",
"{",
"$",
"flags",
"->",
"remove",
"(",
"$",
"this",
"->",
"flagName",
")",
";",
"}",
"return",
"$",
"flags",
"->",
"getValue",
"(",
")",
";",
"}"
] | Given a bool value, do the needed bitwise comparison against the flag value to either remove or add the bit from
the overall value.
@param bool $value
@return int | [
"Given",
"a",
"bool",
"value",
"do",
"the",
"needed",
"bitwise",
"comparison",
"against",
"the",
"flag",
"value",
"to",
"either",
"remove",
"or",
"add",
"the",
"bit",
"from",
"the",
"overall",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertFlags.php#L102-L115 |
28,109 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.executeOperation | protected function executeOperation(LdapOperationInterface $operation, LogOperation $log = null)
{
$lastServer = $this->connection->getServer();
try {
$this->connectIfNotBound($operation);
$lastServer = $this->connection->getServer();
$handler = $this->getOperationHandler($operation);
$handler->setOperationDefaults($operation);
$this->logStart($log);
$this->invalidateCacheIfNeeded($operation);
list($result, $usedCache, $cacheKey) = $this->getCacheOrHandlerResult($operation, $handler, $log);
$this->cacheResultIfNeeded($operation, $result, $usedCache, $cacheKey);
return $result;
} catch (\Throwable $e) {
$this->logExceptionAndThrow($e, $log);
} catch (\Exception $e) {
$this->logExceptionAndThrow($e, $log);
} finally {
$this->logEnd($log);
// It would not have set controls or switched servers if the cache was used...
if (isset($usedCache) && $usedCache === false) {
$this->resetLdapControls($operation);
$this->switchServerIfNeeded($this->connection->getServer(), $lastServer, $operation);
}
$this->dispatcher->dispatch(new LdapOperationEvent(Event::LDAP_OPERATION_EXECUTE_AFTER, $operation, $this->connection));
}
} | php | protected function executeOperation(LdapOperationInterface $operation, LogOperation $log = null)
{
$lastServer = $this->connection->getServer();
try {
$this->connectIfNotBound($operation);
$lastServer = $this->connection->getServer();
$handler = $this->getOperationHandler($operation);
$handler->setOperationDefaults($operation);
$this->logStart($log);
$this->invalidateCacheIfNeeded($operation);
list($result, $usedCache, $cacheKey) = $this->getCacheOrHandlerResult($operation, $handler, $log);
$this->cacheResultIfNeeded($operation, $result, $usedCache, $cacheKey);
return $result;
} catch (\Throwable $e) {
$this->logExceptionAndThrow($e, $log);
} catch (\Exception $e) {
$this->logExceptionAndThrow($e, $log);
} finally {
$this->logEnd($log);
// It would not have set controls or switched servers if the cache was used...
if (isset($usedCache) && $usedCache === false) {
$this->resetLdapControls($operation);
$this->switchServerIfNeeded($this->connection->getServer(), $lastServer, $operation);
}
$this->dispatcher->dispatch(new LdapOperationEvent(Event::LDAP_OPERATION_EXECUTE_AFTER, $operation, $this->connection));
}
} | [
"protected",
"function",
"executeOperation",
"(",
"LdapOperationInterface",
"$",
"operation",
",",
"LogOperation",
"$",
"log",
"=",
"null",
")",
"{",
"$",
"lastServer",
"=",
"$",
"this",
"->",
"connection",
"->",
"getServer",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"connectIfNotBound",
"(",
"$",
"operation",
")",
";",
"$",
"lastServer",
"=",
"$",
"this",
"->",
"connection",
"->",
"getServer",
"(",
")",
";",
"$",
"handler",
"=",
"$",
"this",
"->",
"getOperationHandler",
"(",
"$",
"operation",
")",
";",
"$",
"handler",
"->",
"setOperationDefaults",
"(",
"$",
"operation",
")",
";",
"$",
"this",
"->",
"logStart",
"(",
"$",
"log",
")",
";",
"$",
"this",
"->",
"invalidateCacheIfNeeded",
"(",
"$",
"operation",
")",
";",
"list",
"(",
"$",
"result",
",",
"$",
"usedCache",
",",
"$",
"cacheKey",
")",
"=",
"$",
"this",
"->",
"getCacheOrHandlerResult",
"(",
"$",
"operation",
",",
"$",
"handler",
",",
"$",
"log",
")",
";",
"$",
"this",
"->",
"cacheResultIfNeeded",
"(",
"$",
"operation",
",",
"$",
"result",
",",
"$",
"usedCache",
",",
"$",
"cacheKey",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logExceptionAndThrow",
"(",
"$",
"e",
",",
"$",
"log",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logExceptionAndThrow",
"(",
"$",
"e",
",",
"$",
"log",
")",
";",
"}",
"finally",
"{",
"$",
"this",
"->",
"logEnd",
"(",
"$",
"log",
")",
";",
"// It would not have set controls or switched servers if the cache was used...",
"if",
"(",
"isset",
"(",
"$",
"usedCache",
")",
"&&",
"$",
"usedCache",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"resetLdapControls",
"(",
"$",
"operation",
")",
";",
"$",
"this",
"->",
"switchServerIfNeeded",
"(",
"$",
"this",
"->",
"connection",
"->",
"getServer",
"(",
")",
",",
"$",
"lastServer",
",",
"$",
"operation",
")",
";",
"}",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"LdapOperationEvent",
"(",
"Event",
"::",
"LDAP_OPERATION_EXECUTE_AFTER",
",",
"$",
"operation",
",",
"$",
"this",
"->",
"connection",
")",
")",
";",
"}",
"}"
] | Execute a given operation with an operation handler.
@param LdapOperationInterface $operation
@param LogOperation|null $log
@return mixed
@throws \Throwable | [
"Execute",
"a",
"given",
"operation",
"with",
"an",
"operation",
"handler",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L76-L103 |
28,110 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.getLogObject | protected function getLogObject(LdapOperationInterface $operation)
{
if (!$this->logger) {
return null;
}
return (new LogOperation($operation))->setDomain($this->connection->getConfig()->getDomainName());
} | php | protected function getLogObject(LdapOperationInterface $operation)
{
if (!$this->logger) {
return null;
}
return (new LogOperation($operation))->setDomain($this->connection->getConfig()->getDomainName());
} | [
"protected",
"function",
"getLogObject",
"(",
"LdapOperationInterface",
"$",
"operation",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"logger",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"new",
"LogOperation",
"(",
"$",
"operation",
")",
")",
"->",
"setDomain",
"(",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getDomainName",
"(",
")",
")",
";",
"}"
] | Construct the LogOperation object for the operation.
@param LdapOperationInterface $operation
@return LogOperation|null | [
"Construct",
"the",
"LogOperation",
"object",
"for",
"the",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L111-L118 |
28,111 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.getOperationHandler | protected function getOperationHandler(LdapOperationInterface $operation)
{
foreach ($this->handler as $handler) {
if ($handler->supports($operation)) {
$handler->setConnection($this->connection);
$handler->setEventDispatcher($this->dispatcher);
return $handler;
}
}
throw new LdapConnectionException(sprintf(
'Operation "%s" with a class name "%s" does not have a supported operation handler.',
$operation->getName(),
get_class($operation)
));
} | php | protected function getOperationHandler(LdapOperationInterface $operation)
{
foreach ($this->handler as $handler) {
if ($handler->supports($operation)) {
$handler->setConnection($this->connection);
$handler->setEventDispatcher($this->dispatcher);
return $handler;
}
}
throw new LdapConnectionException(sprintf(
'Operation "%s" with a class name "%s" does not have a supported operation handler.',
$operation->getName(),
get_class($operation)
));
} | [
"protected",
"function",
"getOperationHandler",
"(",
"LdapOperationInterface",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handler",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"supports",
"(",
"$",
"operation",
")",
")",
"{",
"$",
"handler",
"->",
"setConnection",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"handler",
"->",
"setEventDispatcher",
"(",
"$",
"this",
"->",
"dispatcher",
")",
";",
"return",
"$",
"handler",
";",
"}",
"}",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"'Operation \"%s\" with a class name \"%s\" does not have a supported operation handler.'",
",",
"$",
"operation",
"->",
"getName",
"(",
")",
",",
"get_class",
"(",
"$",
"operation",
")",
")",
")",
";",
"}"
] | Find and return a supported handler for the operation.
@param LdapOperationInterface $operation
@return \LdapTools\Operation\Handler\OperationHandlerInterface
@throws LdapConnectionException | [
"Find",
"and",
"return",
"a",
"supported",
"handler",
"for",
"the",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L127-L143 |
28,112 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.cacheResultIfNeeded | protected function cacheResultIfNeeded(LdapOperationInterface $operation, $result, $usedCache, $cacheKey)
{
if (!is_null($cacheKey) && !$usedCache) {
/** @var CacheableOperationInterface $operation */
$this->cache->set(new CacheItem($cacheKey, $result, $operation->getExpireCacheAt()));
}
return $result;
} | php | protected function cacheResultIfNeeded(LdapOperationInterface $operation, $result, $usedCache, $cacheKey)
{
if (!is_null($cacheKey) && !$usedCache) {
/** @var CacheableOperationInterface $operation */
$this->cache->set(new CacheItem($cacheKey, $result, $operation->getExpireCacheAt()));
}
return $result;
} | [
"protected",
"function",
"cacheResultIfNeeded",
"(",
"LdapOperationInterface",
"$",
"operation",
",",
"$",
"result",
",",
"$",
"usedCache",
",",
"$",
"cacheKey",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"cacheKey",
")",
"&&",
"!",
"$",
"usedCache",
")",
"{",
"/** @var CacheableOperationInterface $operation */",
"$",
"this",
"->",
"cache",
"->",
"set",
"(",
"new",
"CacheItem",
"(",
"$",
"cacheKey",
",",
"$",
"result",
",",
"$",
"operation",
"->",
"getExpireCacheAt",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Cache the result of the operation if needed.
@param LdapOperationInterface $operation
@param mixed $result
@param bool $usedCache
@param string|null $cacheKey
@return mixed | [
"Cache",
"the",
"result",
"of",
"the",
"operation",
"if",
"needed",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L200-L208 |
28,113 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.switchServerIfNeeded | protected function switchServerIfNeeded($currentServer, $wantedServer, LdapOperationInterface $operation)
{
if ($operation instanceof AuthenticationOperation || MBString::strtolower($currentServer) == MBString::strtolower($wantedServer)) {
return;
}
if ($this->connection->isBound()) {
$this->connection->close();
}
$this->connection->connect(null, null, false, $wantedServer);
} | php | protected function switchServerIfNeeded($currentServer, $wantedServer, LdapOperationInterface $operation)
{
if ($operation instanceof AuthenticationOperation || MBString::strtolower($currentServer) == MBString::strtolower($wantedServer)) {
return;
}
if ($this->connection->isBound()) {
$this->connection->close();
}
$this->connection->connect(null, null, false, $wantedServer);
} | [
"protected",
"function",
"switchServerIfNeeded",
"(",
"$",
"currentServer",
",",
"$",
"wantedServer",
",",
"LdapOperationInterface",
"$",
"operation",
")",
"{",
"if",
"(",
"$",
"operation",
"instanceof",
"AuthenticationOperation",
"||",
"MBString",
"::",
"strtolower",
"(",
"$",
"currentServer",
")",
"==",
"MBString",
"::",
"strtolower",
"(",
"$",
"wantedServer",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"connection",
"->",
"isBound",
"(",
")",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"close",
"(",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"connect",
"(",
"null",
",",
"null",
",",
"false",
",",
"$",
"wantedServer",
")",
";",
"}"
] | Performs the logic for switching the LDAP server connection.
@param string|null $currentServer The server we are currently on.
@param string|null $wantedServer The server we want the connection to be on.
@param LdapOperationInterface $operation | [
"Performs",
"the",
"logic",
"for",
"switching",
"the",
"LDAP",
"server",
"connection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L226-L235 |
28,114 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.idleReconnectIfNeeded | protected function idleReconnectIfNeeded(LdapOperationInterface $operation)
{
// An auth operation will force a reconnect anyways, so avoid extra work
if (!$this->connection->getConfig()->getIdleReconnect() || $operation instanceof AuthenticationOperation) {
return;
}
if ($this->connection->getIdleTime() >= $this->connection->getConfig()->getIdleReconnect()) {
$this->connection->close()->connect();
}
} | php | protected function idleReconnectIfNeeded(LdapOperationInterface $operation)
{
// An auth operation will force a reconnect anyways, so avoid extra work
if (!$this->connection->getConfig()->getIdleReconnect() || $operation instanceof AuthenticationOperation) {
return;
}
if ($this->connection->getIdleTime() >= $this->connection->getConfig()->getIdleReconnect()) {
$this->connection->close()->connect();
}
} | [
"protected",
"function",
"idleReconnectIfNeeded",
"(",
"LdapOperationInterface",
"$",
"operation",
")",
"{",
"// An auth operation will force a reconnect anyways, so avoid extra work",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getIdleReconnect",
"(",
")",
"||",
"$",
"operation",
"instanceof",
"AuthenticationOperation",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"connection",
"->",
"getIdleTime",
"(",
")",
">=",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getIdleReconnect",
"(",
")",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"close",
"(",
")",
"->",
"connect",
"(",
")",
";",
"}",
"}"
] | If the connection has been open as long as, or longer than, the configured idle reconnect time, then close and
reconnect the LDAP connection.
@param LdapOperationInterface $operation | [
"If",
"the",
"connection",
"has",
"been",
"open",
"as",
"long",
"as",
"or",
"longer",
"than",
"the",
"configured",
"idle",
"reconnect",
"time",
"then",
"close",
"and",
"reconnect",
"the",
"LDAP",
"connection",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L243-L253 |
28,115 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.setLdapControls | protected function setLdapControls(LdapOperationInterface $operation)
{
foreach ($operation->getControls() as $control) {
$this->connection->setControl($control);
}
} | php | protected function setLdapControls(LdapOperationInterface $operation)
{
foreach ($operation->getControls() as $control) {
$this->connection->setControl($control);
}
} | [
"protected",
"function",
"setLdapControls",
"(",
"LdapOperationInterface",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"operation",
"->",
"getControls",
"(",
")",
"as",
"$",
"control",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"setControl",
"(",
"$",
"control",
")",
";",
"}",
"}"
] | Set any specific LDAP controls for this operation.
@param LdapOperationInterface $operation | [
"Set",
"any",
"specific",
"LDAP",
"controls",
"for",
"this",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L283-L288 |
28,116 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvoker.php | LdapOperationInvoker.resetLdapControls | protected function resetLdapControls(LdapOperationInterface $operation)
{
foreach ($operation->getControls() as $control) {
$value = $control->getValue();
$control->setValue($control->getResetValue());
$this->connection->setControl($control);
$control->setValue($value);
}
} | php | protected function resetLdapControls(LdapOperationInterface $operation)
{
foreach ($operation->getControls() as $control) {
$value = $control->getValue();
$control->setValue($control->getResetValue());
$this->connection->setControl($control);
$control->setValue($value);
}
} | [
"protected",
"function",
"resetLdapControls",
"(",
"LdapOperationInterface",
"$",
"operation",
")",
"{",
"foreach",
"(",
"$",
"operation",
"->",
"getControls",
"(",
")",
"as",
"$",
"control",
")",
"{",
"$",
"value",
"=",
"$",
"control",
"->",
"getValue",
"(",
")",
";",
"$",
"control",
"->",
"setValue",
"(",
"$",
"control",
"->",
"getResetValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"setControl",
"(",
"$",
"control",
")",
";",
"$",
"control",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"}"
] | Reset any specific LDAP controls used with this operation. This is to make sure they are not accidentally used in
future operations when it is not expected.
@param LdapOperationInterface $operation | [
"Reset",
"any",
"specific",
"LDAP",
"controls",
"used",
"with",
"this",
"operation",
".",
"This",
"is",
"to",
"make",
"sure",
"they",
"are",
"not",
"accidentally",
"used",
"in",
"future",
"operations",
"when",
"it",
"is",
"not",
"expected",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvoker.php#L296-L304 |
28,117 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectRepository.php | LdapObjectRepository.buildLdapQuery | public function buildLdapQuery()
{
$lqb = new LdapQueryBuilder($this->ldap);
if (!empty($this->attributes)) {
$lqb->select($this->attributes);
}
return $lqb->from($this->schema);
} | php | public function buildLdapQuery()
{
$lqb = new LdapQueryBuilder($this->ldap);
if (!empty($this->attributes)) {
$lqb->select($this->attributes);
}
return $lqb->from($this->schema);
} | [
"public",
"function",
"buildLdapQuery",
"(",
")",
"{",
"$",
"lqb",
"=",
"new",
"LdapQueryBuilder",
"(",
"$",
"this",
"->",
"ldap",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"attributes",
")",
")",
"{",
"$",
"lqb",
"->",
"select",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"}",
"return",
"$",
"lqb",
"->",
"from",
"(",
"$",
"this",
"->",
"schema",
")",
";",
"}"
] | Get the LdapQueryBuilder with the defaults for this repository type.
@return LdapQueryBuilder | [
"Get",
"the",
"LdapQueryBuilder",
"with",
"the",
"defaults",
"for",
"this",
"repository",
"type",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectRepository.php#L120-L129 |
28,118 | ldaptools/ldaptools | src/LdapTools/Connection/LdapConnection.php | LdapConnection.initiateLdapConnection | protected function initiateLdapConnection($server = null)
{
list($ldapUrl, $server) = $this->getLdapUrl($server);
$this->connection = @ldap_connect($ldapUrl);
if (!$this->connection) {
throw new LdapConnectionException(
sprintf("Failed to initiate LDAP connection with URI: %s", $ldapUrl)
);
}
foreach ($this->config->getLdapOptions() as $option => $value) {
if (!ldap_set_option($this->connection, $option, $value)) {
throw new LdapConnectionException("Failed to set LDAP connection option.");
}
}
if ($this->config->getUseTls() && !@ldap_start_tls($this->connection)) {
throw new LdapConnectionException(
sprintf("Failed to start TLS: %s", $this->getLastError()),
$this->getExtendedErrorNumber()
);
}
$this->server = $server;
} | php | protected function initiateLdapConnection($server = null)
{
list($ldapUrl, $server) = $this->getLdapUrl($server);
$this->connection = @ldap_connect($ldapUrl);
if (!$this->connection) {
throw new LdapConnectionException(
sprintf("Failed to initiate LDAP connection with URI: %s", $ldapUrl)
);
}
foreach ($this->config->getLdapOptions() as $option => $value) {
if (!ldap_set_option($this->connection, $option, $value)) {
throw new LdapConnectionException("Failed to set LDAP connection option.");
}
}
if ($this->config->getUseTls() && !@ldap_start_tls($this->connection)) {
throw new LdapConnectionException(
sprintf("Failed to start TLS: %s", $this->getLastError()),
$this->getExtendedErrorNumber()
);
}
$this->server = $server;
} | [
"protected",
"function",
"initiateLdapConnection",
"(",
"$",
"server",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"ldapUrl",
",",
"$",
"server",
")",
"=",
"$",
"this",
"->",
"getLdapUrl",
"(",
"$",
"server",
")",
";",
"$",
"this",
"->",
"connection",
"=",
"@",
"ldap_connect",
"(",
"$",
"ldapUrl",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"connection",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"\"Failed to initiate LDAP connection with URI: %s\"",
",",
"$",
"ldapUrl",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"config",
"->",
"getLdapOptions",
"(",
")",
"as",
"$",
"option",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"ldap_set_option",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"option",
",",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"\"Failed to set LDAP connection option.\"",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"getUseTls",
"(",
")",
"&&",
"!",
"@",
"ldap_start_tls",
"(",
"$",
"this",
"->",
"connection",
")",
")",
"{",
"throw",
"new",
"LdapConnectionException",
"(",
"sprintf",
"(",
"\"Failed to start TLS: %s\"",
",",
"$",
"this",
"->",
"getLastError",
"(",
")",
")",
",",
"$",
"this",
"->",
"getExtendedErrorNumber",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"server",
"=",
"$",
"server",
";",
"}"
] | Makes the initial connection to LDAP, sets connection options, and starts TLS if specified.
@param null|string $server
@throws LdapConnectionException | [
"Makes",
"the",
"initial",
"connection",
"to",
"LDAP",
"sets",
"connection",
"options",
"and",
"starts",
"TLS",
"if",
"specified",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapConnection.php#L270-L295 |
28,119 | ldaptools/ldaptools | src/LdapTools/Connection/LdapConnection.php | LdapConnection.bind | protected function bind($username, $password, $anonymous = false)
{
if ($anonymous) {
$this->isBound = @ldap_bind($this->connection);
} else {
$this->isBound = @ldap_bind(
$this->connection,
LdapUtilities::encode($username, $this->config->getEncoding()),
LdapUtilities::encode($password, $this->config->getEncoding())
);
}
if (!$this->isBound) {
throw new LdapBindException(
sprintf('Unable to bind to LDAP: %s', $this->getLastError()),
$this->getExtendedErrorNumber()
);
}
} | php | protected function bind($username, $password, $anonymous = false)
{
if ($anonymous) {
$this->isBound = @ldap_bind($this->connection);
} else {
$this->isBound = @ldap_bind(
$this->connection,
LdapUtilities::encode($username, $this->config->getEncoding()),
LdapUtilities::encode($password, $this->config->getEncoding())
);
}
if (!$this->isBound) {
throw new LdapBindException(
sprintf('Unable to bind to LDAP: %s', $this->getLastError()),
$this->getExtendedErrorNumber()
);
}
} | [
"protected",
"function",
"bind",
"(",
"$",
"username",
",",
"$",
"password",
",",
"$",
"anonymous",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"anonymous",
")",
"{",
"$",
"this",
"->",
"isBound",
"=",
"@",
"ldap_bind",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"isBound",
"=",
"@",
"ldap_bind",
"(",
"$",
"this",
"->",
"connection",
",",
"LdapUtilities",
"::",
"encode",
"(",
"$",
"username",
",",
"$",
"this",
"->",
"config",
"->",
"getEncoding",
"(",
")",
")",
",",
"LdapUtilities",
"::",
"encode",
"(",
"$",
"password",
",",
"$",
"this",
"->",
"config",
"->",
"getEncoding",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isBound",
")",
"{",
"throw",
"new",
"LdapBindException",
"(",
"sprintf",
"(",
"'Unable to bind to LDAP: %s'",
",",
"$",
"this",
"->",
"getLastError",
"(",
")",
")",
",",
"$",
"this",
"->",
"getExtendedErrorNumber",
"(",
")",
")",
";",
"}",
"}"
] | Binds to LDAP with the supplied credentials or anonymously if specified.
@param string $username The username to bind with.
@param string $password The password to bind with.
@param bool $anonymous Whether this is an anonymous bind attempt.
@throws LdapBindException | [
"Binds",
"to",
"LDAP",
"with",
"the",
"supplied",
"credentials",
"or",
"anonymously",
"if",
"specified",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapConnection.php#L305-L323 |
28,120 | ldaptools/ldaptools | src/LdapTools/Connection/LdapConnection.php | LdapConnection.getLdapUrl | protected function getLdapUrl($server = null)
{
$server = $server ?: $this->serverPool->getServer();
$ldapUrl = ($this->config->getUseSsl() ? 'ldaps' : 'ldap').'://'.$server.':'.$this->config->getPort();
return [$ldapUrl, $server];
} | php | protected function getLdapUrl($server = null)
{
$server = $server ?: $this->serverPool->getServer();
$ldapUrl = ($this->config->getUseSsl() ? 'ldaps' : 'ldap').'://'.$server.':'.$this->config->getPort();
return [$ldapUrl, $server];
} | [
"protected",
"function",
"getLdapUrl",
"(",
"$",
"server",
"=",
"null",
")",
"{",
"$",
"server",
"=",
"$",
"server",
"?",
":",
"$",
"this",
"->",
"serverPool",
"->",
"getServer",
"(",
")",
";",
"$",
"ldapUrl",
"=",
"(",
"$",
"this",
"->",
"config",
"->",
"getUseSsl",
"(",
")",
"?",
"'ldaps'",
":",
"'ldap'",
")",
".",
"'://'",
".",
"$",
"server",
".",
"':'",
".",
"$",
"this",
"->",
"config",
"->",
"getPort",
"(",
")",
";",
"return",
"[",
"$",
"ldapUrl",
",",
"$",
"server",
"]",
";",
"}"
] | Get the LDAP URL to connect to.
@param null|string $server
@return string[]
@throws LdapConnectionException | [
"Get",
"the",
"LDAP",
"URL",
"to",
"connect",
"to",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapConnection.php#L332-L338 |
28,121 | ldaptools/ldaptools | src/LdapTools/Connection/LdapConnection.php | LdapConnection.setupOperationInvoker | protected function setupOperationInvoker()
{
$this->config->getOperationInvoker()->setEventDispatcher($this->dispatcher);
$this->config->getOperationInvoker()->setConnection($this);
if ($this->logger) {
$this->config->getOperationInvoker()->setLogger($this->logger);
}
if ($this->cache) {
$this->config->getOperationInvoker()->setCache($this->cache);
}
} | php | protected function setupOperationInvoker()
{
$this->config->getOperationInvoker()->setEventDispatcher($this->dispatcher);
$this->config->getOperationInvoker()->setConnection($this);
if ($this->logger) {
$this->config->getOperationInvoker()->setLogger($this->logger);
}
if ($this->cache) {
$this->config->getOperationInvoker()->setCache($this->cache);
}
} | [
"protected",
"function",
"setupOperationInvoker",
"(",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"getOperationInvoker",
"(",
")",
"->",
"setEventDispatcher",
"(",
"$",
"this",
"->",
"dispatcher",
")",
";",
"$",
"this",
"->",
"config",
"->",
"getOperationInvoker",
"(",
")",
"->",
"setConnection",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"getOperationInvoker",
"(",
")",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"logger",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cache",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"getOperationInvoker",
"(",
")",
"->",
"setCache",
"(",
"$",
"this",
"->",
"cache",
")",
";",
"}",
"}"
] | Sets the needed objects on the operation invoker. | [
"Sets",
"the",
"needed",
"objects",
"on",
"the",
"operation",
"invoker",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Connection/LdapConnection.php#L343-L353 |
28,122 | ldaptools/ldaptools | src/LdapTools/Resolver/BaseValueResolver.php | BaseValueResolver.getInstance | public static function getInstance(LdapObjectSchema $schema = null, $values, $type)
{
$instance = AttributeValueResolver::class;
if ($values instanceof BatchCollection) {
$instance = BatchValueResolver::class;
} elseif ($values instanceof OperatorCollection) {
$instance = OperatorValueResolver::class;
}
return new $instance($schema, $values, $type);
} | php | public static function getInstance(LdapObjectSchema $schema = null, $values, $type)
{
$instance = AttributeValueResolver::class;
if ($values instanceof BatchCollection) {
$instance = BatchValueResolver::class;
} elseif ($values instanceof OperatorCollection) {
$instance = OperatorValueResolver::class;
}
return new $instance($schema, $values, $type);
} | [
"public",
"static",
"function",
"getInstance",
"(",
"LdapObjectSchema",
"$",
"schema",
"=",
"null",
",",
"$",
"values",
",",
"$",
"type",
")",
"{",
"$",
"instance",
"=",
"AttributeValueResolver",
"::",
"class",
";",
"if",
"(",
"$",
"values",
"instanceof",
"BatchCollection",
")",
"{",
"$",
"instance",
"=",
"BatchValueResolver",
"::",
"class",
";",
"}",
"elseif",
"(",
"$",
"values",
"instanceof",
"OperatorCollection",
")",
"{",
"$",
"instance",
"=",
"OperatorValueResolver",
"::",
"class",
";",
"}",
"return",
"new",
"$",
"instance",
"(",
"$",
"schema",
",",
"$",
"values",
",",
"$",
"type",
")",
";",
"}"
] | Factory method for instantiation.
@param LdapObjectSchema|null $schema
@param BatchCollection|OperatorCollection|array $values
@param int $type
@return AttributeValueResolver|BatchValueResolver | [
"Factory",
"method",
"for",
"instantiation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BaseValueResolver.php#L123-L134 |
28,123 | ldaptools/ldaptools | src/LdapTools/Resolver/BaseValueResolver.php | BaseValueResolver.getConvertedValues | protected function getConvertedValues($values, $attribute, $direction, AttributeConverterInterface $aggregate = null)
{
$values = is_array($values) ? $values : [$values];
$converter = $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);
if (!$aggregate && $converter->getShouldAggregateValues() && $direction == 'toLdap') {
$values = $this->convertAggregateValues($attribute, $values);
} else {
$values = $this->doConvertValues($attribute, $values, $direction, $aggregate);
}
return $values;
} | php | protected function getConvertedValues($values, $attribute, $direction, AttributeConverterInterface $aggregate = null)
{
$values = is_array($values) ? $values : [$values];
$converter = $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);
if (!$aggregate && $converter->getShouldAggregateValues() && $direction == 'toLdap') {
$values = $this->convertAggregateValues($attribute, $values);
} else {
$values = $this->doConvertValues($attribute, $values, $direction, $aggregate);
}
return $values;
} | [
"protected",
"function",
"getConvertedValues",
"(",
"$",
"values",
",",
"$",
"attribute",
",",
"$",
"direction",
",",
"AttributeConverterInterface",
"$",
"aggregate",
"=",
"null",
")",
"{",
"$",
"values",
"=",
"is_array",
"(",
"$",
"values",
")",
"?",
"$",
"values",
":",
"[",
"$",
"values",
"]",
";",
"$",
"converter",
"=",
"$",
"this",
"->",
"getConverterWithOptions",
"(",
"$",
"this",
"->",
"schema",
"->",
"getConverter",
"(",
"$",
"attribute",
")",
",",
"$",
"attribute",
")",
";",
"if",
"(",
"!",
"$",
"aggregate",
"&&",
"$",
"converter",
"->",
"getShouldAggregateValues",
"(",
")",
"&&",
"$",
"direction",
"==",
"'toLdap'",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"convertAggregateValues",
"(",
"$",
"attribute",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"doConvertValues",
"(",
"$",
"attribute",
",",
"$",
"values",
",",
"$",
"direction",
",",
"$",
"aggregate",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Get the values for an attribute after applying any converters.
@param mixed $values
@param string $attribute
@param string $direction
@param AttributeConverterInterface|null $aggregate
@return array | [
"Get",
"the",
"values",
"for",
"an",
"attribute",
"after",
"applying",
"any",
"converters",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BaseValueResolver.php#L145-L157 |
28,124 | ldaptools/ldaptools | src/LdapTools/Resolver/BaseValueResolver.php | BaseValueResolver.convertAggregateValues | protected function convertAggregateValues($attribute, array $values)
{
$this->aggregated[] = $attribute;
$converterName = $this->schema->getConverter($attribute);
$toAggregate = array_keys($this->schema->getConverterMap(), $converterName);
/**
* Only aggregate values going back the same LDAP attribute, as it's possible for the a converter to have many
* different attributes assigned to it.
*
* @todo Probably a better way to do this...
*/
$aggregateToLdap = $this->schema->getAttributeToLdap($attribute);
foreach ($toAggregate as $i => $aggregate) {
if ($this->schema->getAttributeToLdap($aggregate) !== $aggregateToLdap) {
unset($toAggregate[$i]);
}
}
$values = $this->iterateAggregates($toAggregate, $values, $converterName);
return is_array($values) ? $values : [$values];
} | php | protected function convertAggregateValues($attribute, array $values)
{
$this->aggregated[] = $attribute;
$converterName = $this->schema->getConverter($attribute);
$toAggregate = array_keys($this->schema->getConverterMap(), $converterName);
/**
* Only aggregate values going back the same LDAP attribute, as it's possible for the a converter to have many
* different attributes assigned to it.
*
* @todo Probably a better way to do this...
*/
$aggregateToLdap = $this->schema->getAttributeToLdap($attribute);
foreach ($toAggregate as $i => $aggregate) {
if ($this->schema->getAttributeToLdap($aggregate) !== $aggregateToLdap) {
unset($toAggregate[$i]);
}
}
$values = $this->iterateAggregates($toAggregate, $values, $converterName);
return is_array($values) ? $values : [$values];
} | [
"protected",
"function",
"convertAggregateValues",
"(",
"$",
"attribute",
",",
"array",
"$",
"values",
")",
"{",
"$",
"this",
"->",
"aggregated",
"[",
"]",
"=",
"$",
"attribute",
";",
"$",
"converterName",
"=",
"$",
"this",
"->",
"schema",
"->",
"getConverter",
"(",
"$",
"attribute",
")",
";",
"$",
"toAggregate",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"schema",
"->",
"getConverterMap",
"(",
")",
",",
"$",
"converterName",
")",
";",
"/**\n * Only aggregate values going back the same LDAP attribute, as it's possible for the a converter to have many\n * different attributes assigned to it.\n *\n * @todo Probably a better way to do this...\n */",
"$",
"aggregateToLdap",
"=",
"$",
"this",
"->",
"schema",
"->",
"getAttributeToLdap",
"(",
"$",
"attribute",
")",
";",
"foreach",
"(",
"$",
"toAggregate",
"as",
"$",
"i",
"=>",
"$",
"aggregate",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"schema",
"->",
"getAttributeToLdap",
"(",
"$",
"aggregate",
")",
"!==",
"$",
"aggregateToLdap",
")",
"{",
"unset",
"(",
"$",
"toAggregate",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"$",
"values",
"=",
"$",
"this",
"->",
"iterateAggregates",
"(",
"$",
"toAggregate",
",",
"$",
"values",
",",
"$",
"converterName",
")",
";",
"return",
"is_array",
"(",
"$",
"values",
")",
"?",
"$",
"values",
":",
"[",
"$",
"values",
"]",
";",
"}"
] | Loops through all the attributes that are to be aggregated into a single attribute for a specific converter.
@param string $attribute
@param array $values
@return array | [
"Loops",
"through",
"all",
"the",
"attributes",
"that",
"are",
"to",
"be",
"aggregated",
"into",
"a",
"single",
"attribute",
"for",
"a",
"specific",
"converter",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BaseValueResolver.php#L166-L187 |
28,125 | ldaptools/ldaptools | src/LdapTools/Resolver/BaseValueResolver.php | BaseValueResolver.getConverterWithOptions | protected function getConverterWithOptions($converterName, $attribute)
{
$converter = AttributeConverterFactory::get($converterName);
$converter->setOptions(array_merge(
$this->schema->getConverterOptions($converterName, '_default'),
$this->schema->getConverterOptions($converterName, $attribute)
));
$converter->setOperationType($this->type);
$converter->setLdapConnection($this->connection);
$converter->setDn($this->dn);
if ($converter instanceof OperationGeneratorInterface) {
$converter->setOperation($this->operation);
}
return $converter;
} | php | protected function getConverterWithOptions($converterName, $attribute)
{
$converter = AttributeConverterFactory::get($converterName);
$converter->setOptions(array_merge(
$this->schema->getConverterOptions($converterName, '_default'),
$this->schema->getConverterOptions($converterName, $attribute)
));
$converter->setOperationType($this->type);
$converter->setLdapConnection($this->connection);
$converter->setDn($this->dn);
if ($converter instanceof OperationGeneratorInterface) {
$converter->setOperation($this->operation);
}
return $converter;
} | [
"protected",
"function",
"getConverterWithOptions",
"(",
"$",
"converterName",
",",
"$",
"attribute",
")",
"{",
"$",
"converter",
"=",
"AttributeConverterFactory",
"::",
"get",
"(",
"$",
"converterName",
")",
";",
"$",
"converter",
"->",
"setOptions",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"schema",
"->",
"getConverterOptions",
"(",
"$",
"converterName",
",",
"'_default'",
")",
",",
"$",
"this",
"->",
"schema",
"->",
"getConverterOptions",
"(",
"$",
"converterName",
",",
"$",
"attribute",
")",
")",
")",
";",
"$",
"converter",
"->",
"setOperationType",
"(",
"$",
"this",
"->",
"type",
")",
";",
"$",
"converter",
"->",
"setLdapConnection",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"converter",
"->",
"setDn",
"(",
"$",
"this",
"->",
"dn",
")",
";",
"if",
"(",
"$",
"converter",
"instanceof",
"OperationGeneratorInterface",
")",
"{",
"$",
"converter",
"->",
"setOperation",
"(",
"$",
"this",
"->",
"operation",
")",
";",
"}",
"return",
"$",
"converter",
";",
"}"
] | Get an instance of a converter with its options set.
@param string $converterName The name of the converter from the schema.
@param string $attribute The name of the attribute.
@return AttributeConverterInterface | [
"Get",
"an",
"instance",
"of",
"a",
"converter",
"with",
"its",
"options",
"set",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BaseValueResolver.php#L196-L212 |
28,126 | ldaptools/ldaptools | src/LdapTools/Resolver/BaseValueResolver.php | BaseValueResolver.doConvertValues | protected function doConvertValues($attribute, array $values, $direction, AttributeConverterInterface $aggregate = null)
{
$converter = $aggregate ?: $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);
$converter->setAttribute($attribute);
if ($converter->isMultiValuedConverter()) {
$values = $converter->$direction($values);
} else {
foreach ($values as $index => $value) {
$values[$index] = $converter->$direction($value);
}
}
if ($converter instanceof OperationGeneratorInterface && $converter->getRemoveOriginalValue() && !in_array($attribute, $this->remove)) {
$this->remove[] = $attribute;
}
return $values;
} | php | protected function doConvertValues($attribute, array $values, $direction, AttributeConverterInterface $aggregate = null)
{
$converter = $aggregate ?: $this->getConverterWithOptions($this->schema->getConverter($attribute), $attribute);
$converter->setAttribute($attribute);
if ($converter->isMultiValuedConverter()) {
$values = $converter->$direction($values);
} else {
foreach ($values as $index => $value) {
$values[$index] = $converter->$direction($value);
}
}
if ($converter instanceof OperationGeneratorInterface && $converter->getRemoveOriginalValue() && !in_array($attribute, $this->remove)) {
$this->remove[] = $attribute;
}
return $values;
} | [
"protected",
"function",
"doConvertValues",
"(",
"$",
"attribute",
",",
"array",
"$",
"values",
",",
"$",
"direction",
",",
"AttributeConverterInterface",
"$",
"aggregate",
"=",
"null",
")",
"{",
"$",
"converter",
"=",
"$",
"aggregate",
"?",
":",
"$",
"this",
"->",
"getConverterWithOptions",
"(",
"$",
"this",
"->",
"schema",
"->",
"getConverter",
"(",
"$",
"attribute",
")",
",",
"$",
"attribute",
")",
";",
"$",
"converter",
"->",
"setAttribute",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"$",
"converter",
"->",
"isMultiValuedConverter",
"(",
")",
")",
"{",
"$",
"values",
"=",
"$",
"converter",
"->",
"$",
"direction",
"(",
"$",
"values",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"$",
"values",
"[",
"$",
"index",
"]",
"=",
"$",
"converter",
"->",
"$",
"direction",
"(",
"$",
"value",
")",
";",
"}",
"}",
"if",
"(",
"$",
"converter",
"instanceof",
"OperationGeneratorInterface",
"&&",
"$",
"converter",
"->",
"getRemoveOriginalValue",
"(",
")",
"&&",
"!",
"in_array",
"(",
"$",
"attribute",
",",
"$",
"this",
"->",
"remove",
")",
")",
"{",
"$",
"this",
"->",
"remove",
"[",
"]",
"=",
"$",
"attribute",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Convert a set of values for an attribute.
@param string $attribute
@param array $values
@param string $direction
@param AttributeConverterInterface|null $aggregate
@return mixed | [
"Convert",
"a",
"set",
"of",
"values",
"for",
"an",
"attribute",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BaseValueResolver.php#L223-L240 |
28,127 | ldaptools/ldaptools | src/LdapTools/Resolver/BaseValueResolver.php | BaseValueResolver.encodeValues | protected function encodeValues($values)
{
if (is_null($this->connection) || $this->type == AttributeConverterInterface::TYPE_SEARCH_FROM) {
return $values;
}
$encoded = is_array($values) ? $values : [$values];
foreach ($encoded as $index => $value) {
if (is_string($value)) {
$encoded[$index] = LdapUtilities::encode($value, $this->connection->getConfig()->getEncoding());
}
}
// This is to pass it back the same way it was received. ldap_modify_batch is picky about values being an array.
return is_array($values) ? $encoded : reset($encoded);
} | php | protected function encodeValues($values)
{
if (is_null($this->connection) || $this->type == AttributeConverterInterface::TYPE_SEARCH_FROM) {
return $values;
}
$encoded = is_array($values) ? $values : [$values];
foreach ($encoded as $index => $value) {
if (is_string($value)) {
$encoded[$index] = LdapUtilities::encode($value, $this->connection->getConfig()->getEncoding());
}
}
// This is to pass it back the same way it was received. ldap_modify_batch is picky about values being an array.
return is_array($values) ? $encoded : reset($encoded);
} | [
"protected",
"function",
"encodeValues",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"connection",
")",
"||",
"$",
"this",
"->",
"type",
"==",
"AttributeConverterInterface",
"::",
"TYPE_SEARCH_FROM",
")",
"{",
"return",
"$",
"values",
";",
"}",
"$",
"encoded",
"=",
"is_array",
"(",
"$",
"values",
")",
"?",
"$",
"values",
":",
"[",
"$",
"values",
"]",
";",
"foreach",
"(",
"$",
"encoded",
"as",
"$",
"index",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"encoded",
"[",
"$",
"index",
"]",
"=",
"LdapUtilities",
"::",
"encode",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getEncoding",
"(",
")",
")",
";",
"}",
"}",
"// This is to pass it back the same way it was received. ldap_modify_batch is picky about values being an array.",
"return",
"is_array",
"(",
"$",
"values",
")",
"?",
"$",
"encoded",
":",
"reset",
"(",
"$",
"encoded",
")",
";",
"}"
] | Encodes any values with the needed type for LDAP.
@param array|string $values
@return array | [
"Encodes",
"any",
"values",
"with",
"the",
"needed",
"type",
"for",
"LDAP",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BaseValueResolver.php#L248-L263 |
28,128 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.escapeValue | public static function escapeValue($value, $ignore = null, $flags = null)
{
// If this is a hexadecimal escaped string, then do not escape it.
$value = preg_match('/^(\\\[0-9a-fA-F]{2})+$/', (string) $value) ? $value : ldap_escape($value, $ignore, $flags);
// Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns.
if ((int)$flags & LDAP_ESCAPE_DN) {
if (!empty($value) && $value[0] === ' ') {
$value = '\\20' . substr($value, 1);
}
if (!empty($value) && $value[strlen($value) - 1] === ' ') {
$value = substr($value, 0, -1) . '\\20';
}
// Only carriage returns seem to be valid, not line feeds (per testing of AD anyway).
$value = str_replace("\r", '\0d', $value);
}
return $value;
} | php | public static function escapeValue($value, $ignore = null, $flags = null)
{
// If this is a hexadecimal escaped string, then do not escape it.
$value = preg_match('/^(\\\[0-9a-fA-F]{2})+$/', (string) $value) ? $value : ldap_escape($value, $ignore, $flags);
// Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns.
if ((int)$flags & LDAP_ESCAPE_DN) {
if (!empty($value) && $value[0] === ' ') {
$value = '\\20' . substr($value, 1);
}
if (!empty($value) && $value[strlen($value) - 1] === ' ') {
$value = substr($value, 0, -1) . '\\20';
}
// Only carriage returns seem to be valid, not line feeds (per testing of AD anyway).
$value = str_replace("\r", '\0d', $value);
}
return $value;
} | [
"public",
"static",
"function",
"escapeValue",
"(",
"$",
"value",
",",
"$",
"ignore",
"=",
"null",
",",
"$",
"flags",
"=",
"null",
")",
"{",
"// If this is a hexadecimal escaped string, then do not escape it.",
"$",
"value",
"=",
"preg_match",
"(",
"'/^(\\\\\\[0-9a-fA-F]{2})+$/'",
",",
"(",
"string",
")",
"$",
"value",
")",
"?",
"$",
"value",
":",
"ldap_escape",
"(",
"$",
"value",
",",
"$",
"ignore",
",",
"$",
"flags",
")",
";",
"// Per RFC 4514, leading/trailing spaces should be encoded in DNs, as well as carriage returns.",
"if",
"(",
"(",
"int",
")",
"$",
"flags",
"&",
"LDAP_ESCAPE_DN",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"[",
"0",
"]",
"===",
"' '",
")",
"{",
"$",
"value",
"=",
"'\\\\20'",
".",
"substr",
"(",
"$",
"value",
",",
"1",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"[",
"strlen",
"(",
"$",
"value",
")",
"-",
"1",
"]",
"===",
"' '",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"-",
"1",
")",
".",
"'\\\\20'",
";",
"}",
"// Only carriage returns seem to be valid, not line feeds (per testing of AD anyway).",
"$",
"value",
"=",
"str_replace",
"(",
"\"\\r\"",
",",
"'\\0d'",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Escape any special characters for LDAP to their hexadecimal representation.
@param mixed $value The value to escape.
@param null|string $ignore The characters to ignore.
@param null|int $flags The context for the escaped string. LDAP_ESCAPE_FILTER or LDAP_ESCAPE_DN.
@return string The escaped value. | [
"Escape",
"any",
"special",
"characters",
"for",
"LDAP",
"to",
"their",
"hexadecimal",
"representation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L79-L97 |
28,129 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.unescapeValue | public static function unescapeValue($value)
{
$callback = function ($matches) {
return chr(hexdec($matches[1]));
};
return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', $callback, $value);
} | php | public static function unescapeValue($value)
{
$callback = function ($matches) {
return chr(hexdec($matches[1]));
};
return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', $callback, $value);
} | [
"public",
"static",
"function",
"unescapeValue",
"(",
"$",
"value",
")",
"{",
"$",
"callback",
"=",
"function",
"(",
"$",
"matches",
")",
"{",
"return",
"chr",
"(",
"hexdec",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
";",
"}",
";",
"return",
"preg_replace_callback",
"(",
"'/\\\\\\([0-9A-Fa-f]{2})/'",
",",
"$",
"callback",
",",
"$",
"value",
")",
";",
"}"
] | Un-escapes a value from its hexadecimal form back to its string representation.
@param string $value
@return string | [
"Un",
"-",
"escapes",
"a",
"value",
"from",
"its",
"hexadecimal",
"form",
"back",
"to",
"its",
"string",
"representation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L105-L112 |
28,130 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.explodeDn | public static function explodeDn($dn, $withAttributes = 1)
{
$pieces = ldap_explode_dn($dn, $withAttributes);
if ($pieces === false || !isset($pieces['count']) || $pieces['count'] == 0) {
throw new InvalidArgumentException(sprintf('Unable to parse DN "%s".', $dn));
}
for ($i = 0; $i < $pieces['count']; $i++) {
$pieces[$i] = self::unescapeValue($pieces[$i]);
}
unset($pieces['count']);
return $pieces;
} | php | public static function explodeDn($dn, $withAttributes = 1)
{
$pieces = ldap_explode_dn($dn, $withAttributes);
if ($pieces === false || !isset($pieces['count']) || $pieces['count'] == 0) {
throw new InvalidArgumentException(sprintf('Unable to parse DN "%s".', $dn));
}
for ($i = 0; $i < $pieces['count']; $i++) {
$pieces[$i] = self::unescapeValue($pieces[$i]);
}
unset($pieces['count']);
return $pieces;
} | [
"public",
"static",
"function",
"explodeDn",
"(",
"$",
"dn",
",",
"$",
"withAttributes",
"=",
"1",
")",
"{",
"$",
"pieces",
"=",
"ldap_explode_dn",
"(",
"$",
"dn",
",",
"$",
"withAttributes",
")",
";",
"if",
"(",
"$",
"pieces",
"===",
"false",
"||",
"!",
"isset",
"(",
"$",
"pieces",
"[",
"'count'",
"]",
")",
"||",
"$",
"pieces",
"[",
"'count'",
"]",
"==",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unable to parse DN \"%s\".'",
",",
"$",
"dn",
")",
")",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"pieces",
"[",
"'count'",
"]",
";",
"$",
"i",
"++",
")",
"{",
"$",
"pieces",
"[",
"$",
"i",
"]",
"=",
"self",
"::",
"unescapeValue",
"(",
"$",
"pieces",
"[",
"$",
"i",
"]",
")",
";",
"}",
"unset",
"(",
"$",
"pieces",
"[",
"'count'",
"]",
")",
";",
"return",
"$",
"pieces",
";",
"}"
] | Converts a string distinguished name into its separate pieces.
@param string $dn
@param int $withAttributes Set to 0 to get the attribute names along with the value.
@return array | [
"Converts",
"a",
"string",
"distinguished",
"name",
"into",
"its",
"separate",
"pieces",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L121-L134 |
28,131 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.explodeExchangeLegacyDn | public static function explodeExchangeLegacyDn($dn, $withAttributes = false)
{
preg_match(self::MATCH_LEGACY_DN, $dn, $matches);
if (!isset($matches[2])) {
throw new InvalidArgumentException(sprintf('Unable to parse legacy exchange dn "%s".', $dn));
}
$pieces = [];
for ($i = 3; $i < count($matches); $i += 3) {
$pieces[] = $withAttributes ? $matches[$i - 1].'='.$matches[$i] : $matches[$i];
}
return $pieces;
} | php | public static function explodeExchangeLegacyDn($dn, $withAttributes = false)
{
preg_match(self::MATCH_LEGACY_DN, $dn, $matches);
if (!isset($matches[2])) {
throw new InvalidArgumentException(sprintf('Unable to parse legacy exchange dn "%s".', $dn));
}
$pieces = [];
for ($i = 3; $i < count($matches); $i += 3) {
$pieces[] = $withAttributes ? $matches[$i - 1].'='.$matches[$i] : $matches[$i];
}
return $pieces;
} | [
"public",
"static",
"function",
"explodeExchangeLegacyDn",
"(",
"$",
"dn",
",",
"$",
"withAttributes",
"=",
"false",
")",
"{",
"preg_match",
"(",
"self",
"::",
"MATCH_LEGACY_DN",
",",
"$",
"dn",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unable to parse legacy exchange dn \"%s\".'",
",",
"$",
"dn",
")",
")",
";",
"}",
"$",
"pieces",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"3",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"matches",
")",
";",
"$",
"i",
"+=",
"3",
")",
"{",
"$",
"pieces",
"[",
"]",
"=",
"$",
"withAttributes",
"?",
"$",
"matches",
"[",
"$",
"i",
"-",
"1",
"]",
".",
"'='",
".",
"$",
"matches",
"[",
"$",
"i",
"]",
":",
"$",
"matches",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"pieces",
";",
"}"
] | Converts an Exchange Legacy DN into its separate pieces.
@param string $dn
@param bool $withAttributes
@return array | [
"Converts",
"an",
"Exchange",
"Legacy",
"DN",
"into",
"its",
"separate",
"pieces",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L163-L176 |
28,132 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.encode | public static function encode($value, $toEncoding)
{
// If the encoding is already UTF-8, and that's what was requested, then just send the value back.
if ($toEncoding == 'UTF-8' && self::isBinary($value)) {
return $value;
}
if (function_exists('mb_detect_encoding')) {
$value = iconv(mb_detect_encoding($value, mb_detect_order(), true), $toEncoding, $value);
} else {
// How else to better handle if they don't have mb_* ? The below is definitely not an optimal solution.
$value = utf8_encode($value);
}
return $value;
} | php | public static function encode($value, $toEncoding)
{
// If the encoding is already UTF-8, and that's what was requested, then just send the value back.
if ($toEncoding == 'UTF-8' && self::isBinary($value)) {
return $value;
}
if (function_exists('mb_detect_encoding')) {
$value = iconv(mb_detect_encoding($value, mb_detect_order(), true), $toEncoding, $value);
} else {
// How else to better handle if they don't have mb_* ? The below is definitely not an optimal solution.
$value = utf8_encode($value);
}
return $value;
} | [
"public",
"static",
"function",
"encode",
"(",
"$",
"value",
",",
"$",
"toEncoding",
")",
"{",
"// If the encoding is already UTF-8, and that's what was requested, then just send the value back.",
"if",
"(",
"$",
"toEncoding",
"==",
"'UTF-8'",
"&&",
"self",
"::",
"isBinary",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"function_exists",
"(",
"'mb_detect_encoding'",
")",
")",
"{",
"$",
"value",
"=",
"iconv",
"(",
"mb_detect_encoding",
"(",
"$",
"value",
",",
"mb_detect_order",
"(",
")",
",",
"true",
")",
",",
"$",
"toEncoding",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"// How else to better handle if they don't have mb_* ? The below is definitely not an optimal solution.",
"$",
"value",
"=",
"utf8_encode",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Encode a string for LDAP with a specific encoding type.
@param string $value The value to encode.
@param string $toEncoding The encoding type to use (ie. UTF-8)
@return string The encoded value. | [
"Encode",
"a",
"string",
"for",
"LDAP",
"with",
"a",
"specific",
"encoding",
"type",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L185-L200 |
28,133 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.isValidAttributeFormat | public static function isValidAttributeFormat($value)
{
return (preg_match(self::MATCH_DESCRIPTOR, $value) || preg_match(self::MATCH_OID, $value));
} | php | public static function isValidAttributeFormat($value)
{
return (preg_match(self::MATCH_DESCRIPTOR, $value) || preg_match(self::MATCH_OID, $value));
} | [
"public",
"static",
"function",
"isValidAttributeFormat",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"preg_match",
"(",
"self",
"::",
"MATCH_DESCRIPTOR",
",",
"$",
"value",
")",
"||",
"preg_match",
"(",
"self",
"::",
"MATCH_OID",
",",
"$",
"value",
")",
")",
";",
"}"
] | Determine whether a value is a valid attribute name or OID. The name should meet the format described in RFC 2252.
However, the regex is fairly forgiving for each.
@param string $value
@return bool | [
"Determine",
"whether",
"a",
"value",
"is",
"a",
"valid",
"attribute",
"name",
"or",
"OID",
".",
"The",
"name",
"should",
"meet",
"the",
"format",
"described",
"in",
"RFC",
"2252",
".",
"However",
"the",
"regex",
"is",
"fairly",
"forgiving",
"for",
"each",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L222-L225 |
28,134 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.getLdapServersForDomain | public static function getLdapServersForDomain($domain)
{
$hosts = (new Dns())->getRecord(self::SRV_PREFIX.$domain, DNS_SRV);
return is_array($hosts) ? array_column($hosts, 'target') : [];
} | php | public static function getLdapServersForDomain($domain)
{
$hosts = (new Dns())->getRecord(self::SRV_PREFIX.$domain, DNS_SRV);
return is_array($hosts) ? array_column($hosts, 'target') : [];
} | [
"public",
"static",
"function",
"getLdapServersForDomain",
"(",
"$",
"domain",
")",
"{",
"$",
"hosts",
"=",
"(",
"new",
"Dns",
"(",
")",
")",
"->",
"getRecord",
"(",
"self",
"::",
"SRV_PREFIX",
".",
"$",
"domain",
",",
"DNS_SRV",
")",
";",
"return",
"is_array",
"(",
"$",
"hosts",
")",
"?",
"array_column",
"(",
"$",
"hosts",
",",
"'target'",
")",
":",
"[",
"]",
";",
"}"
] | Get an array of all the LDAP servers for a domain by querying DNS.
@param string $domain The domain name to query.
@return string[] | [
"Get",
"an",
"array",
"of",
"all",
"the",
"LDAP",
"servers",
"for",
"a",
"domain",
"by",
"querying",
"DNS",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L322-L327 |
28,135 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.getLdapSslCertificates | public static function getLdapSslCertificates($server, $port = 389)
{
// This is the hex encoded extendedRequest for the STARTTLS operation...
$startTls = hex2bin("301d02010177188016312e332e362e312e342e312e313436362e3230303337");
$certificates = [
'peer_certificate' => '',
'peer_certificate_chain' => [],
];
$tcpSocket = new TcpSocket([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => true,
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
$tcpSocket->connect($server, $port, 5);
$tcpSocket->setOperationTimeout(2);
$tcpSocket->write($startTls);
$tcpSocket->read(10240);
$tcpSocket->enableEncryption(STREAM_CRYPTO_METHOD_TLS_CLIENT);
$info = $tcpSocket->getParams();
if (!$info) {
return $certificates;
}
openssl_x509_export($info['options']['ssl']['peer_certificate'], $certificates['peer_certificate']);
foreach ($info['options']['ssl']['peer_certificate_chain'] as $cert) {
$certChain = '';
openssl_x509_export($cert, $certChain);
$certificates['peer_certificate_chain'][] = $certChain;
}
$tcpSocket->close();
return $certificates;
} | php | public static function getLdapSslCertificates($server, $port = 389)
{
// This is the hex encoded extendedRequest for the STARTTLS operation...
$startTls = hex2bin("301d02010177188016312e332e362e312e342e312e313436362e3230303337");
$certificates = [
'peer_certificate' => '',
'peer_certificate_chain' => [],
];
$tcpSocket = new TcpSocket([
'ssl' => [
'capture_peer_cert' => true,
'capture_peer_cert_chain' => true,
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
$tcpSocket->connect($server, $port, 5);
$tcpSocket->setOperationTimeout(2);
$tcpSocket->write($startTls);
$tcpSocket->read(10240);
$tcpSocket->enableEncryption(STREAM_CRYPTO_METHOD_TLS_CLIENT);
$info = $tcpSocket->getParams();
if (!$info) {
return $certificates;
}
openssl_x509_export($info['options']['ssl']['peer_certificate'], $certificates['peer_certificate']);
foreach ($info['options']['ssl']['peer_certificate_chain'] as $cert) {
$certChain = '';
openssl_x509_export($cert, $certChain);
$certificates['peer_certificate_chain'][] = $certChain;
}
$tcpSocket->close();
return $certificates;
} | [
"public",
"static",
"function",
"getLdapSslCertificates",
"(",
"$",
"server",
",",
"$",
"port",
"=",
"389",
")",
"{",
"// This is the hex encoded extendedRequest for the STARTTLS operation...",
"$",
"startTls",
"=",
"hex2bin",
"(",
"\"301d02010177188016312e332e362e312e342e312e313436362e3230303337\"",
")",
";",
"$",
"certificates",
"=",
"[",
"'peer_certificate'",
"=>",
"''",
",",
"'peer_certificate_chain'",
"=>",
"[",
"]",
",",
"]",
";",
"$",
"tcpSocket",
"=",
"new",
"TcpSocket",
"(",
"[",
"'ssl'",
"=>",
"[",
"'capture_peer_cert'",
"=>",
"true",
",",
"'capture_peer_cert_chain'",
"=>",
"true",
",",
"'allow_self_signed'",
"=>",
"true",
",",
"'verify_peer'",
"=>",
"false",
",",
"'verify_peer_name'",
"=>",
"false",
",",
"]",
",",
"]",
")",
";",
"$",
"tcpSocket",
"->",
"connect",
"(",
"$",
"server",
",",
"$",
"port",
",",
"5",
")",
";",
"$",
"tcpSocket",
"->",
"setOperationTimeout",
"(",
"2",
")",
";",
"$",
"tcpSocket",
"->",
"write",
"(",
"$",
"startTls",
")",
";",
"$",
"tcpSocket",
"->",
"read",
"(",
"10240",
")",
";",
"$",
"tcpSocket",
"->",
"enableEncryption",
"(",
"STREAM_CRYPTO_METHOD_TLS_CLIENT",
")",
";",
"$",
"info",
"=",
"$",
"tcpSocket",
"->",
"getParams",
"(",
")",
";",
"if",
"(",
"!",
"$",
"info",
")",
"{",
"return",
"$",
"certificates",
";",
"}",
"openssl_x509_export",
"(",
"$",
"info",
"[",
"'options'",
"]",
"[",
"'ssl'",
"]",
"[",
"'peer_certificate'",
"]",
",",
"$",
"certificates",
"[",
"'peer_certificate'",
"]",
")",
";",
"foreach",
"(",
"$",
"info",
"[",
"'options'",
"]",
"[",
"'ssl'",
"]",
"[",
"'peer_certificate_chain'",
"]",
"as",
"$",
"cert",
")",
"{",
"$",
"certChain",
"=",
"''",
";",
"openssl_x509_export",
"(",
"$",
"cert",
",",
"$",
"certChain",
")",
";",
"$",
"certificates",
"[",
"'peer_certificate_chain'",
"]",
"[",
"]",
"=",
"$",
"certChain",
";",
"}",
"$",
"tcpSocket",
"->",
"close",
"(",
")",
";",
"return",
"$",
"certificates",
";",
"}"
] | Get an array containing the SSL certificates of the LDAP server. This runs over the standard LDAP port and
initiates a TlsStart operation.
@param string $server The server name to connect to
@param int $port The standard LDAP port
@return array In the form of ['peer_certificate' => '', 'peer_certificate_chain' => []] | [
"Get",
"an",
"array",
"containing",
"the",
"SSL",
"certificates",
"of",
"the",
"LDAP",
"server",
".",
"This",
"runs",
"over",
"the",
"standard",
"LDAP",
"port",
"and",
"initiates",
"a",
"TlsStart",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L337-L375 |
28,136 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.getRdnFromDn | public static function getRdnFromDn($dn)
{
$rdn = self::explodeDn($dn, 0)[0];
$rdn = explode('=', $rdn, 2);
return $rdn[0].'='.self::escapeValue($rdn[1], null, LDAP_ESCAPE_DN);
} | php | public static function getRdnFromDn($dn)
{
$rdn = self::explodeDn($dn, 0)[0];
$rdn = explode('=', $rdn, 2);
return $rdn[0].'='.self::escapeValue($rdn[1], null, LDAP_ESCAPE_DN);
} | [
"public",
"static",
"function",
"getRdnFromDn",
"(",
"$",
"dn",
")",
"{",
"$",
"rdn",
"=",
"self",
"::",
"explodeDn",
"(",
"$",
"dn",
",",
"0",
")",
"[",
"0",
"]",
";",
"$",
"rdn",
"=",
"explode",
"(",
"'='",
",",
"$",
"rdn",
",",
"2",
")",
";",
"return",
"$",
"rdn",
"[",
"0",
"]",
".",
"'='",
".",
"self",
"::",
"escapeValue",
"(",
"$",
"rdn",
"[",
"1",
"]",
",",
"null",
",",
"LDAP_ESCAPE_DN",
")",
";",
"}"
] | Given a full escaped DN return the RDN in escaped form.
@param string $dn
@return string | [
"Given",
"a",
"full",
"escaped",
"DN",
"return",
"the",
"RDN",
"in",
"escaped",
"form",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L383-L389 |
28,137 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.getParentDn | public static function getParentDn($dn)
{
$parts = self::explodeDn($dn, 0);
if (count($parts) === 1) {
throw new InvalidArgumentException(sprintf('DN "%s" has no parent.', $dn));
}
array_shift($parts);
return self::implodeDn($parts);
} | php | public static function getParentDn($dn)
{
$parts = self::explodeDn($dn, 0);
if (count($parts) === 1) {
throw new InvalidArgumentException(sprintf('DN "%s" has no parent.', $dn));
}
array_shift($parts);
return self::implodeDn($parts);
} | [
"public",
"static",
"function",
"getParentDn",
"(",
"$",
"dn",
")",
"{",
"$",
"parts",
"=",
"self",
"::",
"explodeDn",
"(",
"$",
"dn",
",",
"0",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"1",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'DN \"%s\" has no parent.'",
",",
"$",
"dn",
")",
")",
";",
"}",
"array_shift",
"(",
"$",
"parts",
")",
";",
"return",
"self",
"::",
"implodeDn",
"(",
"$",
"parts",
")",
";",
"}"
] | Return the parent of a given DN.
@param string $dn
@return string | [
"Return",
"the",
"parent",
"of",
"a",
"given",
"DN",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L397-L406 |
28,138 | ldaptools/ldaptools | src/LdapTools/Utilities/LdapUtilities.php | LdapUtilities.getAliasAndAttribute | public static function getAliasAndAttribute($attribute)
{
$alias = null;
if (strpos($attribute, '.') !== false) {
$pieces = explode('.', $attribute, 2);
$alias = $pieces[0];
$attribute = $pieces[1];
}
return [$alias, $attribute];
} | php | public static function getAliasAndAttribute($attribute)
{
$alias = null;
if (strpos($attribute, '.') !== false) {
$pieces = explode('.', $attribute, 2);
$alias = $pieces[0];
$attribute = $pieces[1];
}
return [$alias, $attribute];
} | [
"public",
"static",
"function",
"getAliasAndAttribute",
"(",
"$",
"attribute",
")",
"{",
"$",
"alias",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"attribute",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"pieces",
"=",
"explode",
"(",
"'.'",
",",
"$",
"attribute",
",",
"2",
")",
";",
"$",
"alias",
"=",
"$",
"pieces",
"[",
"0",
"]",
";",
"$",
"attribute",
"=",
"$",
"pieces",
"[",
"1",
"]",
";",
"}",
"return",
"[",
"$",
"alias",
",",
"$",
"attribute",
"]",
";",
"}"
] | Given an attribute, split it between its alias and attribute. This will return an array where the first value
is the alias and the second is the attribute name. If there is no alias then the first value will be null.
ie. list($alias, $attribute) = LdapUtilities::getAliasAndAttribute($attribute);
@param string $attribute
@return array | [
"Given",
"an",
"attribute",
"split",
"it",
"between",
"its",
"alias",
"and",
"attribute",
".",
"This",
"will",
"return",
"an",
"array",
"where",
"the",
"first",
"value",
"is",
"the",
"alias",
"and",
"the",
"second",
"is",
"the",
"attribute",
"name",
".",
"If",
"there",
"is",
"no",
"alias",
"then",
"the",
"first",
"value",
"will",
"be",
"null",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/LdapUtilities.php#L427-L438 |
28,139 | ldaptools/ldaptools | src/LdapTools/Security/Acl/Dacl.php | Dacl.orderAcesCanonically | protected function orderAcesCanonically()
{
$explicitDeny = [];
$explicitAllow = [];
$objectDeny = [];
$objectAllow = [];
$inherited = [];
foreach ($this->aces as $ace) {
$isDenied = $ace->isDenyAce();
$isObject = $ace->isObjectAce();
if ($ace->getFlags()->isInherited()) {
$inherited[] = $ace;
} elseif ($isDenied && $isObject) {
$objectDeny[] = $ace;
} elseif ($isDenied) {
$explicitDeny[] = $ace;
} elseif ($isObject) {
$objectAllow[] = $ace;
} else {
$explicitAllow[] = $ace;
}
}
return array_merge(
$objectDeny,
$explicitDeny,
$objectAllow,
$explicitAllow,
$inherited
);
} | php | protected function orderAcesCanonically()
{
$explicitDeny = [];
$explicitAllow = [];
$objectDeny = [];
$objectAllow = [];
$inherited = [];
foreach ($this->aces as $ace) {
$isDenied = $ace->isDenyAce();
$isObject = $ace->isObjectAce();
if ($ace->getFlags()->isInherited()) {
$inherited[] = $ace;
} elseif ($isDenied && $isObject) {
$objectDeny[] = $ace;
} elseif ($isDenied) {
$explicitDeny[] = $ace;
} elseif ($isObject) {
$objectAllow[] = $ace;
} else {
$explicitAllow[] = $ace;
}
}
return array_merge(
$objectDeny,
$explicitDeny,
$objectAllow,
$explicitAllow,
$inherited
);
} | [
"protected",
"function",
"orderAcesCanonically",
"(",
")",
"{",
"$",
"explicitDeny",
"=",
"[",
"]",
";",
"$",
"explicitAllow",
"=",
"[",
"]",
";",
"$",
"objectDeny",
"=",
"[",
"]",
";",
"$",
"objectAllow",
"=",
"[",
"]",
";",
"$",
"inherited",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"aces",
"as",
"$",
"ace",
")",
"{",
"$",
"isDenied",
"=",
"$",
"ace",
"->",
"isDenyAce",
"(",
")",
";",
"$",
"isObject",
"=",
"$",
"ace",
"->",
"isObjectAce",
"(",
")",
";",
"if",
"(",
"$",
"ace",
"->",
"getFlags",
"(",
")",
"->",
"isInherited",
"(",
")",
")",
"{",
"$",
"inherited",
"[",
"]",
"=",
"$",
"ace",
";",
"}",
"elseif",
"(",
"$",
"isDenied",
"&&",
"$",
"isObject",
")",
"{",
"$",
"objectDeny",
"[",
"]",
"=",
"$",
"ace",
";",
"}",
"elseif",
"(",
"$",
"isDenied",
")",
"{",
"$",
"explicitDeny",
"[",
"]",
"=",
"$",
"ace",
";",
"}",
"elseif",
"(",
"$",
"isObject",
")",
"{",
"$",
"objectAllow",
"[",
"]",
"=",
"$",
"ace",
";",
"}",
"else",
"{",
"$",
"explicitAllow",
"[",
"]",
"=",
"$",
"ace",
";",
"}",
"}",
"return",
"array_merge",
"(",
"$",
"objectDeny",
",",
"$",
"explicitDeny",
",",
"$",
"objectAllow",
",",
"$",
"explicitAllow",
",",
"$",
"inherited",
")",
";",
"}"
] | Returns all ACEs in canonical order as expected by AD.
@return Ace[] | [
"Returns",
"all",
"ACEs",
"in",
"canonical",
"order",
"as",
"expected",
"by",
"AD",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Security/Acl/Dacl.php#L105-L137 |
28,140 | ldaptools/ldaptools | src/LdapTools/AttributeConverter/ConvertValueToDn.php | ConvertValueToDn.getAttributeFromLdapQuery | protected function getAttributeFromLdapQuery($value, $toSelect)
{
$query = $this->buildLdapQuery($this->options['filter'], $this->options['or_filter'], $toSelect);
$bOr = $this->getQueryOrStatement($query, $value);
$eq = $this->getQueryComparisonStatement($value, $query);
if (!empty($bOr->getChildren())) {
$bOr->add($eq);
$query->where($bOr);
} else {
$query->where($eq);
}
$query->setBaseDn($this->options['base_dn']);
try {
return $query->getLdapQuery()->getSingleScalarResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf(
'Unable to convert value "%s" to a %s for attribute "%s"',
$value,
$toSelect,
$this->getAttribute()
));
}
} | php | protected function getAttributeFromLdapQuery($value, $toSelect)
{
$query = $this->buildLdapQuery($this->options['filter'], $this->options['or_filter'], $toSelect);
$bOr = $this->getQueryOrStatement($query, $value);
$eq = $this->getQueryComparisonStatement($value, $query);
if (!empty($bOr->getChildren())) {
$bOr->add($eq);
$query->where($bOr);
} else {
$query->where($eq);
}
$query->setBaseDn($this->options['base_dn']);
try {
return $query->getLdapQuery()->getSingleScalarResult();
} catch (EmptyResultException $e) {
throw new AttributeConverterException(sprintf(
'Unable to convert value "%s" to a %s for attribute "%s"',
$value,
$toSelect,
$this->getAttribute()
));
}
} | [
"protected",
"function",
"getAttributeFromLdapQuery",
"(",
"$",
"value",
",",
"$",
"toSelect",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"buildLdapQuery",
"(",
"$",
"this",
"->",
"options",
"[",
"'filter'",
"]",
",",
"$",
"this",
"->",
"options",
"[",
"'or_filter'",
"]",
",",
"$",
"toSelect",
")",
";",
"$",
"bOr",
"=",
"$",
"this",
"->",
"getQueryOrStatement",
"(",
"$",
"query",
",",
"$",
"value",
")",
";",
"$",
"eq",
"=",
"$",
"this",
"->",
"getQueryComparisonStatement",
"(",
"$",
"value",
",",
"$",
"query",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"bOr",
"->",
"getChildren",
"(",
")",
")",
")",
"{",
"$",
"bOr",
"->",
"add",
"(",
"$",
"eq",
")",
";",
"$",
"query",
"->",
"where",
"(",
"$",
"bOr",
")",
";",
"}",
"else",
"{",
"$",
"query",
"->",
"where",
"(",
"$",
"eq",
")",
";",
"}",
"$",
"query",
"->",
"setBaseDn",
"(",
"$",
"this",
"->",
"options",
"[",
"'base_dn'",
"]",
")",
";",
"try",
"{",
"return",
"$",
"query",
"->",
"getLdapQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}",
"catch",
"(",
"EmptyResultException",
"$",
"e",
")",
"{",
"throw",
"new",
"AttributeConverterException",
"(",
"sprintf",
"(",
"'Unable to convert value \"%s\" to a %s for attribute \"%s\"'",
",",
"$",
"value",
",",
"$",
"toSelect",
",",
"$",
"this",
"->",
"getAttribute",
"(",
")",
")",
")",
";",
"}",
"}"
] | Attempt to look-up the attribute from a LDAP query based on the value.
@param string $value
@param string $toSelect
@return string The distinguished name.
@throws AttributeConverterException | [
"Attempt",
"to",
"look",
"-",
"up",
"the",
"attribute",
"from",
"a",
"LDAP",
"query",
"based",
"on",
"the",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertValueToDn.php#L109-L134 |
28,141 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectCreator.php | LdapObjectCreator.create | public function create($type)
{
if (!is_string($type) && !($type instanceof LdapObjectSchema)) {
throw new InvalidArgumentException(
'You must either pass the schema object type as a string to this method, or pass the schema types '
. 'LdapObjectSchema to this method.'
);
}
if (!($type instanceof LdapObjectSchema)) {
$type = $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type);
}
$this->schema = $type;
$this->container = $type->getDefaultContainer();
return $this;
} | php | public function create($type)
{
if (!is_string($type) && !($type instanceof LdapObjectSchema)) {
throw new InvalidArgumentException(
'You must either pass the schema object type as a string to this method, or pass the schema types '
. 'LdapObjectSchema to this method.'
);
}
if (!($type instanceof LdapObjectSchema)) {
$type = $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type);
}
$this->schema = $type;
$this->container = $type->getDefaultContainer();
return $this;
} | [
"public",
"function",
"create",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"&&",
"!",
"(",
"$",
"type",
"instanceof",
"LdapObjectSchema",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'You must either pass the schema object type as a string to this method, or pass the schema types '",
".",
"'LdapObjectSchema to this method.'",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"type",
"instanceof",
"LdapObjectSchema",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"schemaFactory",
"->",
"get",
"(",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getSchemaName",
"(",
")",
",",
"$",
"type",
")",
";",
"}",
"$",
"this",
"->",
"schema",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"container",
"=",
"$",
"type",
"->",
"getDefaultContainer",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Specify the object type to create. Either by its string name type from the schema of the LdapObjectSchema.
@param string|LdapObjectSchema $type
@return $this | [
"Specify",
"the",
"object",
"type",
"to",
"create",
".",
"Either",
"by",
"its",
"string",
"name",
"type",
"from",
"the",
"schema",
"of",
"the",
"LdapObjectSchema",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectCreator.php#L101-L116 |
28,142 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectCreator.php | LdapObjectCreator.execute | public function execute()
{
$this->triggerBeforeCreationEvent();
$operation = $this->getAddOperation()->setServer($this->server);
$this->connection->execute($operation);
$this->triggerAfterCreationEvent($operation);
} | php | public function execute()
{
$this->triggerBeforeCreationEvent();
$operation = $this->getAddOperation()->setServer($this->server);
$this->connection->execute($operation);
$this->triggerAfterCreationEvent($operation);
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"this",
"->",
"triggerBeforeCreationEvent",
"(",
")",
";",
"$",
"operation",
"=",
"$",
"this",
"->",
"getAddOperation",
"(",
")",
"->",
"setServer",
"(",
"$",
"this",
"->",
"server",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"execute",
"(",
"$",
"operation",
")",
";",
"$",
"this",
"->",
"triggerAfterCreationEvent",
"(",
"$",
"operation",
")",
";",
"}"
] | Add the object with the selected attributes into LDAP. | [
"Add",
"the",
"object",
"with",
"the",
"selected",
"attributes",
"into",
"LDAP",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectCreator.php#L249-L255 |
28,143 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectCreator.php | LdapObjectCreator.getAddOperation | protected function getAddOperation()
{
$operation = new AddOperation($this->dn, $this->attributes);
$operation->setLocation($this->container);
foreach ($this->parameters as $parameter => $value) {
$this->hydrator->setParameter($parameter, $value);
}
$this->hydrator->setLdapObjectSchema($this->schema);
$this->hydrator->setLdapConnection($this->connection);
$this->hydrator->setOperationType(AttributeConverterInterface::TYPE_CREATE);
return $this->hydrator->hydrateToLdap($operation);
} | php | protected function getAddOperation()
{
$operation = new AddOperation($this->dn, $this->attributes);
$operation->setLocation($this->container);
foreach ($this->parameters as $parameter => $value) {
$this->hydrator->setParameter($parameter, $value);
}
$this->hydrator->setLdapObjectSchema($this->schema);
$this->hydrator->setLdapConnection($this->connection);
$this->hydrator->setOperationType(AttributeConverterInterface::TYPE_CREATE);
return $this->hydrator->hydrateToLdap($operation);
} | [
"protected",
"function",
"getAddOperation",
"(",
")",
"{",
"$",
"operation",
"=",
"new",
"AddOperation",
"(",
"$",
"this",
"->",
"dn",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"$",
"operation",
"->",
"setLocation",
"(",
"$",
"this",
"->",
"container",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"parameter",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"hydrator",
"->",
"setParameter",
"(",
"$",
"parameter",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"hydrator",
"->",
"setLdapObjectSchema",
"(",
"$",
"this",
"->",
"schema",
")",
";",
"$",
"this",
"->",
"hydrator",
"->",
"setLdapConnection",
"(",
"$",
"this",
"->",
"connection",
")",
";",
"$",
"this",
"->",
"hydrator",
"->",
"setOperationType",
"(",
"AttributeConverterInterface",
"::",
"TYPE_CREATE",
")",
";",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrateToLdap",
"(",
"$",
"operation",
")",
";",
"}"
] | Get the add operation and take care of the hydration process.
@return AddOperation | [
"Get",
"the",
"add",
"operation",
"and",
"take",
"care",
"of",
"the",
"hydration",
"process",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectCreator.php#L262-L275 |
28,144 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectCreator.php | LdapObjectCreator.triggerBeforeCreationEvent | protected function triggerBeforeCreationEvent()
{
$event = new LdapObjectCreationEvent(Event::LDAP_OBJECT_BEFORE_CREATE, $this->schema ? $this->schema->getObjectType() : null);
$event->setData($this->attributes);
$event->setContainer($this->container);
$event->setDn($this->dn);
$this->dispatcher->dispatch($event);
$this->attributes = $event->getData();
$this->container = $event->getContainer();
$this->dn = $event->getDn();
} | php | protected function triggerBeforeCreationEvent()
{
$event = new LdapObjectCreationEvent(Event::LDAP_OBJECT_BEFORE_CREATE, $this->schema ? $this->schema->getObjectType() : null);
$event->setData($this->attributes);
$event->setContainer($this->container);
$event->setDn($this->dn);
$this->dispatcher->dispatch($event);
$this->attributes = $event->getData();
$this->container = $event->getContainer();
$this->dn = $event->getDn();
} | [
"protected",
"function",
"triggerBeforeCreationEvent",
"(",
")",
"{",
"$",
"event",
"=",
"new",
"LdapObjectCreationEvent",
"(",
"Event",
"::",
"LDAP_OBJECT_BEFORE_CREATE",
",",
"$",
"this",
"->",
"schema",
"?",
"$",
"this",
"->",
"schema",
"->",
"getObjectType",
"(",
")",
":",
"null",
")",
";",
"$",
"event",
"->",
"setData",
"(",
"$",
"this",
"->",
"attributes",
")",
";",
"$",
"event",
"->",
"setContainer",
"(",
"$",
"this",
"->",
"container",
")",
";",
"$",
"event",
"->",
"setDn",
"(",
"$",
"this",
"->",
"dn",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"this",
"->",
"attributes",
"=",
"$",
"event",
"->",
"getData",
"(",
")",
";",
"$",
"this",
"->",
"container",
"=",
"$",
"event",
"->",
"getContainer",
"(",
")",
";",
"$",
"this",
"->",
"dn",
"=",
"$",
"event",
"->",
"getDn",
"(",
")",
";",
"}"
] | Trigger a LDAP object before creation event. | [
"Trigger",
"a",
"LDAP",
"object",
"before",
"creation",
"event",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectCreator.php#L280-L292 |
28,145 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectCreator.php | LdapObjectCreator.triggerAfterCreationEvent | protected function triggerAfterCreationEvent(AddOperation $operation)
{
$event = new LdapObjectCreationEvent(Event::LDAP_OBJECT_AFTER_CREATE, $this->schema ? $this->schema->getObjectType() : null);
$event->setData((new ParameterResolver($this->attributes, $this->hydrator->getParameters()))->resolve());
$event->setContainer($operation->getLocation());
$event->setDn($operation->getDn());
$this->dispatcher->dispatch($event);
} | php | protected function triggerAfterCreationEvent(AddOperation $operation)
{
$event = new LdapObjectCreationEvent(Event::LDAP_OBJECT_AFTER_CREATE, $this->schema ? $this->schema->getObjectType() : null);
$event->setData((new ParameterResolver($this->attributes, $this->hydrator->getParameters()))->resolve());
$event->setContainer($operation->getLocation());
$event->setDn($operation->getDn());
$this->dispatcher->dispatch($event);
} | [
"protected",
"function",
"triggerAfterCreationEvent",
"(",
"AddOperation",
"$",
"operation",
")",
"{",
"$",
"event",
"=",
"new",
"LdapObjectCreationEvent",
"(",
"Event",
"::",
"LDAP_OBJECT_AFTER_CREATE",
",",
"$",
"this",
"->",
"schema",
"?",
"$",
"this",
"->",
"schema",
"->",
"getObjectType",
"(",
")",
":",
"null",
")",
";",
"$",
"event",
"->",
"setData",
"(",
"(",
"new",
"ParameterResolver",
"(",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"hydrator",
"->",
"getParameters",
"(",
")",
")",
")",
"->",
"resolve",
"(",
")",
")",
";",
"$",
"event",
"->",
"setContainer",
"(",
"$",
"operation",
"->",
"getLocation",
"(",
")",
")",
";",
"$",
"event",
"->",
"setDn",
"(",
"$",
"operation",
"->",
"getDn",
"(",
")",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"}"
] | Trigger a LDAP object after creation event.
@param AddOperation $operation | [
"Trigger",
"a",
"LDAP",
"object",
"after",
"creation",
"event",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectCreator.php#L299-L307 |
28,146 | ldaptools/ldaptools | src/LdapTools/AttributeConverter/ConvertGroupType.php | ConvertGroupType.modifyFlagValue | protected function modifyFlagValue($value)
{
$this->setDefaultLastValue('groupType', $this->getDefaultEnumValue());
$flags = $this->getFlagFromLastValue($this->getLastValue());
if (!in_array($this->flagName, self::SCOPES)) {
$this->modifyBitmaskValue(
$flags,
$this->options['invert'] ? !$value : $value,
$this->flagName
);
} else {
$this->modifyGroupScopeBit($flags, $value);
}
return $flags->getValue();
} | php | protected function modifyFlagValue($value)
{
$this->setDefaultLastValue('groupType', $this->getDefaultEnumValue());
$flags = $this->getFlagFromLastValue($this->getLastValue());
if (!in_array($this->flagName, self::SCOPES)) {
$this->modifyBitmaskValue(
$flags,
$this->options['invert'] ? !$value : $value,
$this->flagName
);
} else {
$this->modifyGroupScopeBit($flags, $value);
}
return $flags->getValue();
} | [
"protected",
"function",
"modifyFlagValue",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setDefaultLastValue",
"(",
"'groupType'",
",",
"$",
"this",
"->",
"getDefaultEnumValue",
"(",
")",
")",
";",
"$",
"flags",
"=",
"$",
"this",
"->",
"getFlagFromLastValue",
"(",
"$",
"this",
"->",
"getLastValue",
"(",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"flagName",
",",
"self",
"::",
"SCOPES",
")",
")",
"{",
"$",
"this",
"->",
"modifyBitmaskValue",
"(",
"$",
"flags",
",",
"$",
"this",
"->",
"options",
"[",
"'invert'",
"]",
"?",
"!",
"$",
"value",
":",
"$",
"value",
",",
"$",
"this",
"->",
"flagName",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"modifyGroupScopeBit",
"(",
"$",
"flags",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"flags",
"->",
"getValue",
"(",
")",
";",
"}"
] | Given a bool value, do the needed bitwise comparison against the groupType value to either remove or
add the bit from the overall value.
@param bool $value
@return int | [
"Given",
"a",
"bool",
"value",
"do",
"the",
"needed",
"bitwise",
"comparison",
"against",
"the",
"groupType",
"value",
"to",
"either",
"remove",
"or",
"add",
"the",
"bit",
"from",
"the",
"overall",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertGroupType.php#L44-L60 |
28,147 | ldaptools/ldaptools | src/LdapTools/AttributeConverter/ConvertGroupType.php | ConvertGroupType.modifyBitmaskValue | protected function modifyBitmaskValue($flags, $toggle, $flagName)
{
$bit = $this->getBitForAttribute($flagName);
if ($toggle) {
$flags->add($bit);
} else {
$flags->remove($bit);
}
} | php | protected function modifyBitmaskValue($flags, $toggle, $flagName)
{
$bit = $this->getBitForAttribute($flagName);
if ($toggle) {
$flags->add($bit);
} else {
$flags->remove($bit);
}
} | [
"protected",
"function",
"modifyBitmaskValue",
"(",
"$",
"flags",
",",
"$",
"toggle",
",",
"$",
"flagName",
")",
"{",
"$",
"bit",
"=",
"$",
"this",
"->",
"getBitForAttribute",
"(",
"$",
"flagName",
")",
";",
"if",
"(",
"$",
"toggle",
")",
"{",
"$",
"flags",
"->",
"add",
"(",
"$",
"bit",
")",
";",
"}",
"else",
"{",
"$",
"flags",
"->",
"remove",
"(",
"$",
"bit",
")",
";",
"}",
"}"
] | Modify the existing value based on the attributes bit.
@param FlagEnumInterface $flags
@param bool $toggle
@param string $flagName | [
"Modify",
"the",
"existing",
"value",
"based",
"on",
"the",
"attributes",
"bit",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/AttributeConverter/ConvertGroupType.php#L92-L101 |
28,148 | ldaptools/ldaptools | src/LdapTools/Resolver/BatchValueResolver.php | BatchValueResolver.batchCanConvert | protected function batchCanConvert(Batch $batch)
{
return ($this->schema->hasConverter($batch->getAttribute()) && !$batch->isTypeRemoveAll());
} | php | protected function batchCanConvert(Batch $batch)
{
return ($this->schema->hasConverter($batch->getAttribute()) && !$batch->isTypeRemoveAll());
} | [
"protected",
"function",
"batchCanConvert",
"(",
"Batch",
"$",
"batch",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"schema",
"->",
"hasConverter",
"(",
"$",
"batch",
"->",
"getAttribute",
"(",
")",
")",
"&&",
"!",
"$",
"batch",
"->",
"isTypeRemoveAll",
"(",
")",
")",
";",
"}"
] | Determine if a specific batch is correctly formatted and needs conversion.
@param Batch $batch
@return bool | [
"Determine",
"if",
"a",
"specific",
"batch",
"is",
"correctly",
"formatted",
"and",
"needs",
"conversion",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BatchValueResolver.php#L81-L84 |
28,149 | ldaptools/ldaptools | src/LdapTools/Resolver/BatchValueResolver.php | BatchValueResolver.getBatchesForAttributes | protected function getBatchesForAttributes(array $attributes)
{
$batches = [];
$lcAttributes = array_map('strtolower', $attributes);
foreach ($this->batches as $index => $batch) {
/** @var Batch $batch */
if (in_array(strtolower($batch->getAttribute()), $lcAttributes)) {
$batches[$index] = $batch;
}
}
return $batches;
} | php | protected function getBatchesForAttributes(array $attributes)
{
$batches = [];
$lcAttributes = array_map('strtolower', $attributes);
foreach ($this->batches as $index => $batch) {
/** @var Batch $batch */
if (in_array(strtolower($batch->getAttribute()), $lcAttributes)) {
$batches[$index] = $batch;
}
}
return $batches;
} | [
"protected",
"function",
"getBatchesForAttributes",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"batches",
"=",
"[",
"]",
";",
"$",
"lcAttributes",
"=",
"array_map",
"(",
"'strtolower'",
",",
"$",
"attributes",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"batches",
"as",
"$",
"index",
"=>",
"$",
"batch",
")",
"{",
"/** @var Batch $batch */",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"$",
"batch",
"->",
"getAttribute",
"(",
")",
")",
",",
"$",
"lcAttributes",
")",
")",
"{",
"$",
"batches",
"[",
"$",
"index",
"]",
"=",
"$",
"batch",
";",
"}",
"}",
"return",
"$",
"batches",
";",
"}"
] | Given an array of attribute names, get all of the batches they have with their respective indexes
@param array $attributes
@return array | [
"Given",
"an",
"array",
"of",
"attribute",
"names",
"get",
"all",
"of",
"the",
"batches",
"they",
"have",
"with",
"their",
"respective",
"indexes"
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Resolver/BatchValueResolver.php#L115-L128 |
28,150 | ldaptools/ldaptools | src/LdapTools/Factory/CacheFactory.php | CacheFactory.get | public static function get($type, array $options)
{
if (self::TYPE_STASH == $type) {
$cache = new StashCache();
} elseif (self::TYPE_DOCTRINE == $type) {
$cache = new DoctrineCache();
} elseif (self::TYPE_NONE == $type) {
$cache = new NoCache();
} else {
throw new InvalidArgumentException(sprintf('Unknown cache type "%s".', $type));
}
$cache->setOptions($options);
return $cache;
} | php | public static function get($type, array $options)
{
if (self::TYPE_STASH == $type) {
$cache = new StashCache();
} elseif (self::TYPE_DOCTRINE == $type) {
$cache = new DoctrineCache();
} elseif (self::TYPE_NONE == $type) {
$cache = new NoCache();
} else {
throw new InvalidArgumentException(sprintf('Unknown cache type "%s".', $type));
}
$cache->setOptions($options);
return $cache;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"type",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"self",
"::",
"TYPE_STASH",
"==",
"$",
"type",
")",
"{",
"$",
"cache",
"=",
"new",
"StashCache",
"(",
")",
";",
"}",
"elseif",
"(",
"self",
"::",
"TYPE_DOCTRINE",
"==",
"$",
"type",
")",
"{",
"$",
"cache",
"=",
"new",
"DoctrineCache",
"(",
")",
";",
"}",
"elseif",
"(",
"self",
"::",
"TYPE_NONE",
"==",
"$",
"type",
")",
"{",
"$",
"cache",
"=",
"new",
"NoCache",
"(",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unknown cache type \"%s\".'",
",",
"$",
"type",
")",
")",
";",
"}",
"$",
"cache",
"->",
"setOptions",
"(",
"$",
"options",
")",
";",
"return",
"$",
"cache",
";",
"}"
] | Retrieve the Cache object by its configured type and options.
@param $type
@param array $options
@return CacheInterface | [
"Retrieve",
"the",
"Cache",
"object",
"by",
"its",
"configured",
"type",
"and",
"options",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Factory/CacheFactory.php#L48-L62 |
28,151 | ldaptools/ldaptools | src/LdapTools/Utilities/TSProperty.php | TSProperty.getDecodedValueForProp | protected function getDecodedValueForProp($propName, $propValue)
{
if (in_array($propName, $this->propTypes['string'])) {
// Strip away null terminators. I think this should be desired, otherwise it just ends in confusion.
$value = str_replace("\0", '', $this->decodePropValue($propValue, true));
} elseif (in_array($propName, $this->propTypes['time'])) {
// Convert from microseconds to minutes (how ADUC displays it anyway, and seems the most practical).
$value = hexdec($this->decodePropValue($propValue)) / self::TIME_CONVERSION;
} elseif (in_array($propName, $this->propTypes['int'])) {
$value = hexdec($this->decodePropValue($propValue));
} else {
$value = $this->decodePropValue($propValue);
}
return $value;
} | php | protected function getDecodedValueForProp($propName, $propValue)
{
if (in_array($propName, $this->propTypes['string'])) {
// Strip away null terminators. I think this should be desired, otherwise it just ends in confusion.
$value = str_replace("\0", '', $this->decodePropValue($propValue, true));
} elseif (in_array($propName, $this->propTypes['time'])) {
// Convert from microseconds to minutes (how ADUC displays it anyway, and seems the most practical).
$value = hexdec($this->decodePropValue($propValue)) / self::TIME_CONVERSION;
} elseif (in_array($propName, $this->propTypes['int'])) {
$value = hexdec($this->decodePropValue($propValue));
} else {
$value = $this->decodePropValue($propValue);
}
return $value;
} | [
"protected",
"function",
"getDecodedValueForProp",
"(",
"$",
"propName",
",",
"$",
"propValue",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"propName",
",",
"$",
"this",
"->",
"propTypes",
"[",
"'string'",
"]",
")",
")",
"{",
"// Strip away null terminators. I think this should be desired, otherwise it just ends in confusion.",
"$",
"value",
"=",
"str_replace",
"(",
"\"\\0\"",
",",
"''",
",",
"$",
"this",
"->",
"decodePropValue",
"(",
"$",
"propValue",
",",
"true",
")",
")",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"propName",
",",
"$",
"this",
"->",
"propTypes",
"[",
"'time'",
"]",
")",
")",
"{",
"// Convert from microseconds to minutes (how ADUC displays it anyway, and seems the most practical).",
"$",
"value",
"=",
"hexdec",
"(",
"$",
"this",
"->",
"decodePropValue",
"(",
"$",
"propValue",
")",
")",
"/",
"self",
"::",
"TIME_CONVERSION",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"propName",
",",
"$",
"this",
"->",
"propTypes",
"[",
"'int'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"hexdec",
"(",
"$",
"this",
"->",
"decodePropValue",
"(",
"$",
"propValue",
")",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"decodePropValue",
"(",
"$",
"propValue",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Based on the property name in question, get its actual value from the binary blob value.
@param string $propName
@param string $propValue
@return string|int | [
"Based",
"on",
"the",
"property",
"name",
"in",
"question",
"get",
"its",
"actual",
"value",
"from",
"the",
"binary",
"blob",
"value",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TSProperty.php#L210-L225 |
28,152 | ldaptools/ldaptools | src/LdapTools/Utilities/TSProperty.php | TSProperty.nibbleControl | protected function nibbleControl($nibble, $control)
{
// This control stays constant for the low/high nibbles, so it doesn't matter which we compare to
if ($control == self::NIBBLE_CONTROL['X'][1]) {
$dec = bindec($nibble);
$dec += 9;
$nibble = str_pad(decbin($dec), 4, '0', STR_PAD_LEFT);
}
return $nibble;
} | php | protected function nibbleControl($nibble, $control)
{
// This control stays constant for the low/high nibbles, so it doesn't matter which we compare to
if ($control == self::NIBBLE_CONTROL['X'][1]) {
$dec = bindec($nibble);
$dec += 9;
$nibble = str_pad(decbin($dec), 4, '0', STR_PAD_LEFT);
}
return $nibble;
} | [
"protected",
"function",
"nibbleControl",
"(",
"$",
"nibble",
",",
"$",
"control",
")",
"{",
"// This control stays constant for the low/high nibbles, so it doesn't matter which we compare to",
"if",
"(",
"$",
"control",
"==",
"self",
"::",
"NIBBLE_CONTROL",
"[",
"'X'",
"]",
"[",
"1",
"]",
")",
"{",
"$",
"dec",
"=",
"bindec",
"(",
"$",
"nibble",
")",
";",
"$",
"dec",
"+=",
"9",
";",
"$",
"nibble",
"=",
"str_pad",
"(",
"decbin",
"(",
"$",
"dec",
")",
",",
"4",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"}",
"return",
"$",
"nibble",
";",
"}"
] | Based on the control, adjust the nibble accordingly.
@param string $nibble
@param string $control
@return string | [
"Based",
"on",
"the",
"control",
"adjust",
"the",
"nibble",
"accordingly",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Utilities/TSProperty.php#L322-L332 |
28,153 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectManager.php | LdapObjectManager.persist | public function persist(LdapObject $ldapObject)
{
if (empty($ldapObject->getBatchCollection()->toArray())) {
return;
}
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_BEFORE_MODIFY, $ldapObject));
$this->validateObject($ldapObject);
$this->executeBatchOperation($ldapObject);
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_AFTER_MODIFY, $ldapObject));
} | php | public function persist(LdapObject $ldapObject)
{
if (empty($ldapObject->getBatchCollection()->toArray())) {
return;
}
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_BEFORE_MODIFY, $ldapObject));
$this->validateObject($ldapObject);
$this->executeBatchOperation($ldapObject);
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_AFTER_MODIFY, $ldapObject));
} | [
"public",
"function",
"persist",
"(",
"LdapObject",
"$",
"ldapObject",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ldapObject",
"->",
"getBatchCollection",
"(",
")",
"->",
"toArray",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"LdapObjectEvent",
"(",
"Event",
"::",
"LDAP_OBJECT_BEFORE_MODIFY",
",",
"$",
"ldapObject",
")",
")",
";",
"$",
"this",
"->",
"validateObject",
"(",
"$",
"ldapObject",
")",
";",
"$",
"this",
"->",
"executeBatchOperation",
"(",
"$",
"ldapObject",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"LdapObjectEvent",
"(",
"Event",
"::",
"LDAP_OBJECT_AFTER_MODIFY",
",",
"$",
"ldapObject",
")",
")",
";",
"}"
] | Updates an object in LDAP. It will only update attributes that actually changed on the object.
@param LdapObject $ldapObject | [
"Updates",
"an",
"object",
"in",
"LDAP",
".",
"It",
"will",
"only",
"update",
"attributes",
"that",
"actually",
"changed",
"on",
"the",
"object",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectManager.php#L74-L85 |
28,154 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectManager.php | LdapObjectManager.delete | public function delete(LdapObject $ldapObject, $recursively = false)
{
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_BEFORE_DELETE, $ldapObject));
$this->validateObject($ldapObject);
$operation = new DeleteOperation($ldapObject->get('dn'));
if ($recursively) {
$operation->addControl((new LdapControl(LdapControlOid::SubTreeDelete))->setCriticality(true));
}
$this->connection->execute($operation);
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_AFTER_DELETE, $ldapObject));
} | php | public function delete(LdapObject $ldapObject, $recursively = false)
{
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_BEFORE_DELETE, $ldapObject));
$this->validateObject($ldapObject);
$operation = new DeleteOperation($ldapObject->get('dn'));
if ($recursively) {
$operation->addControl((new LdapControl(LdapControlOid::SubTreeDelete))->setCriticality(true));
}
$this->connection->execute($operation);
$this->dispatcher->dispatch(new LdapObjectEvent(Event::LDAP_OBJECT_AFTER_DELETE, $ldapObject));
} | [
"public",
"function",
"delete",
"(",
"LdapObject",
"$",
"ldapObject",
",",
"$",
"recursively",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"LdapObjectEvent",
"(",
"Event",
"::",
"LDAP_OBJECT_BEFORE_DELETE",
",",
"$",
"ldapObject",
")",
")",
";",
"$",
"this",
"->",
"validateObject",
"(",
"$",
"ldapObject",
")",
";",
"$",
"operation",
"=",
"new",
"DeleteOperation",
"(",
"$",
"ldapObject",
"->",
"get",
"(",
"'dn'",
")",
")",
";",
"if",
"(",
"$",
"recursively",
")",
"{",
"$",
"operation",
"->",
"addControl",
"(",
"(",
"new",
"LdapControl",
"(",
"LdapControlOid",
"::",
"SubTreeDelete",
")",
")",
"->",
"setCriticality",
"(",
"true",
")",
")",
";",
"}",
"$",
"this",
"->",
"connection",
"->",
"execute",
"(",
"$",
"operation",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"new",
"LdapObjectEvent",
"(",
"Event",
"::",
"LDAP_OBJECT_AFTER_DELETE",
",",
"$",
"ldapObject",
")",
")",
";",
"}"
] | Removes an object from LDAP.
@param LdapObject $ldapObject
@param bool $recursively | [
"Removes",
"an",
"object",
"from",
"LDAP",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectManager.php#L93-L105 |
28,155 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectManager.php | LdapObjectManager.getObjectRestoreLocation | protected function getObjectRestoreLocation(LdapObject $ldapObject, $location)
{
// If a location was defined, use that.
if ($location) {
$newLocation = (string) $location;
// Check the attribute for the last known location first...
} elseif ($ldapObject->has('lastKnownLocation')) {
$newLocation = $ldapObject->get('lastKnownLocation');
// All else failed, so query it from the DN...
} else {
try {
$newLocation = (new LdapQueryBuilder($this->connection, $this->schemaFactory))
->select('lastKnownParent')
->from(LdapObjectType::DELETED)
->where(['dn' => $ldapObject->get('dn')])
->getLdapQuery()
->getSingleScalarOrNullResult();
} catch (Exception $e) {
$newLocation = null;
}
}
// Either this was not a deleted object or it no longer exists?
if (is_null($newLocation)) {
throw new InvalidArgumentException(sprintf(
'No restore location specified and cannot find the last known location for "%s".',
$ldapObject->get('dn')
));
}
return $newLocation;
} | php | protected function getObjectRestoreLocation(LdapObject $ldapObject, $location)
{
// If a location was defined, use that.
if ($location) {
$newLocation = (string) $location;
// Check the attribute for the last known location first...
} elseif ($ldapObject->has('lastKnownLocation')) {
$newLocation = $ldapObject->get('lastKnownLocation');
// All else failed, so query it from the DN...
} else {
try {
$newLocation = (new LdapQueryBuilder($this->connection, $this->schemaFactory))
->select('lastKnownParent')
->from(LdapObjectType::DELETED)
->where(['dn' => $ldapObject->get('dn')])
->getLdapQuery()
->getSingleScalarOrNullResult();
} catch (Exception $e) {
$newLocation = null;
}
}
// Either this was not a deleted object or it no longer exists?
if (is_null($newLocation)) {
throw new InvalidArgumentException(sprintf(
'No restore location specified and cannot find the last known location for "%s".',
$ldapObject->get('dn')
));
}
return $newLocation;
} | [
"protected",
"function",
"getObjectRestoreLocation",
"(",
"LdapObject",
"$",
"ldapObject",
",",
"$",
"location",
")",
"{",
"// If a location was defined, use that.",
"if",
"(",
"$",
"location",
")",
"{",
"$",
"newLocation",
"=",
"(",
"string",
")",
"$",
"location",
";",
"// Check the attribute for the last known location first...",
"}",
"elseif",
"(",
"$",
"ldapObject",
"->",
"has",
"(",
"'lastKnownLocation'",
")",
")",
"{",
"$",
"newLocation",
"=",
"$",
"ldapObject",
"->",
"get",
"(",
"'lastKnownLocation'",
")",
";",
"// All else failed, so query it from the DN...",
"}",
"else",
"{",
"try",
"{",
"$",
"newLocation",
"=",
"(",
"new",
"LdapQueryBuilder",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"this",
"->",
"schemaFactory",
")",
")",
"->",
"select",
"(",
"'lastKnownParent'",
")",
"->",
"from",
"(",
"LdapObjectType",
"::",
"DELETED",
")",
"->",
"where",
"(",
"[",
"'dn'",
"=>",
"$",
"ldapObject",
"->",
"get",
"(",
"'dn'",
")",
"]",
")",
"->",
"getLdapQuery",
"(",
")",
"->",
"getSingleScalarOrNullResult",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"newLocation",
"=",
"null",
";",
"}",
"}",
"// Either this was not a deleted object or it no longer exists?",
"if",
"(",
"is_null",
"(",
"$",
"newLocation",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'No restore location specified and cannot find the last known location for \"%s\".'",
",",
"$",
"ldapObject",
"->",
"get",
"(",
"'dn'",
")",
")",
")",
";",
"}",
"return",
"$",
"newLocation",
";",
"}"
] | It's possible a new location was not explicitly given and the attribute that contains the last know location
was not queried for when the object was originally found. In that case attempt to retrieve the last known
location from a separate LDAP query.
@param LdapObject $ldapObject
@param string|null $location
@return string | [
"It",
"s",
"possible",
"a",
"new",
"location",
"was",
"not",
"explicitly",
"given",
"and",
"the",
"attribute",
"that",
"contains",
"the",
"last",
"know",
"location",
"was",
"not",
"queried",
"for",
"when",
"the",
"object",
"was",
"originally",
"found",
".",
"In",
"that",
"case",
"attempt",
"to",
"retrieve",
"the",
"last",
"known",
"location",
"from",
"a",
"separate",
"LDAP",
"query",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectManager.php#L193-L224 |
28,156 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectManager.php | LdapObjectManager.hydrateOperation | protected function hydrateOperation(BatchModifyOperation $operation, $type)
{
$this->hydrator->setOperationType(AttributeConverterInterface::TYPE_MODIFY);
$this->hydrator->setLdapObjectSchema($type ? $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type) : null);
$this->hydrator->hydrateToLdap($operation);
$this->hydrator->setLdapObjectSchema(null);
} | php | protected function hydrateOperation(BatchModifyOperation $operation, $type)
{
$this->hydrator->setOperationType(AttributeConverterInterface::TYPE_MODIFY);
$this->hydrator->setLdapObjectSchema($type ? $this->schemaFactory->get($this->connection->getConfig()->getSchemaName(), $type) : null);
$this->hydrator->hydrateToLdap($operation);
$this->hydrator->setLdapObjectSchema(null);
} | [
"protected",
"function",
"hydrateOperation",
"(",
"BatchModifyOperation",
"$",
"operation",
",",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"hydrator",
"->",
"setOperationType",
"(",
"AttributeConverterInterface",
"::",
"TYPE_MODIFY",
")",
";",
"$",
"this",
"->",
"hydrator",
"->",
"setLdapObjectSchema",
"(",
"$",
"type",
"?",
"$",
"this",
"->",
"schemaFactory",
"->",
"get",
"(",
"$",
"this",
"->",
"connection",
"->",
"getConfig",
"(",
")",
"->",
"getSchemaName",
"(",
")",
",",
"$",
"type",
")",
":",
"null",
")",
";",
"$",
"this",
"->",
"hydrator",
"->",
"hydrateToLdap",
"(",
"$",
"operation",
")",
";",
"$",
"this",
"->",
"hydrator",
"->",
"setLdapObjectSchema",
"(",
"null",
")",
";",
"}"
] | Get the batch modification array that ldap_modify_batch expects.
@param BatchModifyOperation $operation
@param string $type | [
"Get",
"the",
"batch",
"modification",
"array",
"that",
"ldap_modify_batch",
"expects",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectManager.php#L244-L250 |
28,157 | ldaptools/ldaptools | src/LdapTools/Object/LdapObjectManager.php | LdapObjectManager.refreshDnIfNeeded | protected function refreshDnIfNeeded(LdapOperationInterface $operation, LdapObject $ldapObject)
{
foreach ($operation->getPreOperations() as $childOp) {
$this->refreshDnIfNeeded($childOp, $ldapObject);
}
if ($operation instanceof RenameOperation) {
$ldapObject->refresh(['dn' => $this->getNewDnFromOperation($operation, $ldapObject)]);
}
foreach ($operation->getPostOperations() as $childOp) {
$this->refreshDnIfNeeded($childOp, $ldapObject);
}
} | php | protected function refreshDnIfNeeded(LdapOperationInterface $operation, LdapObject $ldapObject)
{
foreach ($operation->getPreOperations() as $childOp) {
$this->refreshDnIfNeeded($childOp, $ldapObject);
}
if ($operation instanceof RenameOperation) {
$ldapObject->refresh(['dn' => $this->getNewDnFromOperation($operation, $ldapObject)]);
}
foreach ($operation->getPostOperations() as $childOp) {
$this->refreshDnIfNeeded($childOp, $ldapObject);
}
} | [
"protected",
"function",
"refreshDnIfNeeded",
"(",
"LdapOperationInterface",
"$",
"operation",
",",
"LdapObject",
"$",
"ldapObject",
")",
"{",
"foreach",
"(",
"$",
"operation",
"->",
"getPreOperations",
"(",
")",
"as",
"$",
"childOp",
")",
"{",
"$",
"this",
"->",
"refreshDnIfNeeded",
"(",
"$",
"childOp",
",",
"$",
"ldapObject",
")",
";",
"}",
"if",
"(",
"$",
"operation",
"instanceof",
"RenameOperation",
")",
"{",
"$",
"ldapObject",
"->",
"refresh",
"(",
"[",
"'dn'",
"=>",
"$",
"this",
"->",
"getNewDnFromOperation",
"(",
"$",
"operation",
",",
"$",
"ldapObject",
")",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"operation",
"->",
"getPostOperations",
"(",
")",
"as",
"$",
"childOp",
")",
"{",
"$",
"this",
"->",
"refreshDnIfNeeded",
"(",
"$",
"childOp",
",",
"$",
"ldapObject",
")",
";",
"}",
"}"
] | Based on the operation type, refresh the DN if needed. The order is important here. Older 'pre' operations are
refreshed first, then the operation itself, and finally any 'post' operations.
@param LdapOperationInterface $operation
@param LdapObject $ldapObject | [
"Based",
"on",
"the",
"operation",
"type",
"refresh",
"the",
"DN",
"if",
"needed",
".",
"The",
"order",
"is",
"important",
"here",
".",
"Older",
"pre",
"operations",
"are",
"refreshed",
"first",
"then",
"the",
"operation",
"itself",
"and",
"finally",
"any",
"post",
"operations",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Object/LdapObjectManager.php#L259-L272 |
28,158 | ldaptools/ldaptools | src/LdapTools/Operation/LdapOperationTrait.php | LdapOperationTrait.addControl | public function addControl(LdapControl ...$controls)
{
foreach ($controls as $control) {
$this->controls[] = $control;
}
return $this;
} | php | public function addControl(LdapControl ...$controls)
{
foreach ($controls as $control) {
$this->controls[] = $control;
}
return $this;
} | [
"public",
"function",
"addControl",
"(",
"LdapControl",
"...",
"$",
"controls",
")",
"{",
"foreach",
"(",
"$",
"controls",
"as",
"$",
"control",
")",
"{",
"$",
"this",
"->",
"controls",
"[",
"]",
"=",
"$",
"control",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add a control to the operation.
@param LdapControl[] ...$controls
@return $this | [
"Add",
"a",
"control",
"to",
"the",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/LdapOperationTrait.php#L81-L88 |
28,159 | ldaptools/ldaptools | src/LdapTools/Operation/LdapOperationTrait.php | LdapOperationTrait.addPreOperation | public function addPreOperation(LdapOperationInterface ...$operations)
{
foreach ($operations as $operation) {
$this->preOperations[] = $operation;
}
return $this;
} | php | public function addPreOperation(LdapOperationInterface ...$operations)
{
foreach ($operations as $operation) {
$this->preOperations[] = $operation;
}
return $this;
} | [
"public",
"function",
"addPreOperation",
"(",
"LdapOperationInterface",
"...",
"$",
"operations",
")",
"{",
"foreach",
"(",
"$",
"operations",
"as",
"$",
"operation",
")",
"{",
"$",
"this",
"->",
"preOperations",
"[",
"]",
"=",
"$",
"operation",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add an operation that should be executed before this operation.
@param LdapOperationInterface[] ...$operations
@return $this | [
"Add",
"an",
"operation",
"that",
"should",
"be",
"executed",
"before",
"this",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/LdapOperationTrait.php#L96-L103 |
28,160 | ldaptools/ldaptools | src/LdapTools/Operation/LdapOperationTrait.php | LdapOperationTrait.addPostOperation | public function addPostOperation(LdapOperationInterface ...$operations)
{
foreach ($operations as $operation) {
$this->postOperations[] = $operation;
}
return $this;
} | php | public function addPostOperation(LdapOperationInterface ...$operations)
{
foreach ($operations as $operation) {
$this->postOperations[] = $operation;
}
return $this;
} | [
"public",
"function",
"addPostOperation",
"(",
"LdapOperationInterface",
"...",
"$",
"operations",
")",
"{",
"foreach",
"(",
"$",
"operations",
"as",
"$",
"operation",
")",
"{",
"$",
"this",
"->",
"postOperations",
"[",
"]",
"=",
"$",
"operation",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Add an operation that should be executed after this operation.
@param LdapOperationInterface[] ...$operations
@return $this | [
"Add",
"an",
"operation",
"that",
"should",
"be",
"executed",
"after",
"this",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/LdapOperationTrait.php#L121-L128 |
28,161 | ldaptools/ldaptools | src/LdapTools/Operation/LdapOperationTrait.php | LdapOperationTrait.mergeLogDefaults | protected function mergeLogDefaults(array $log)
{
$defaults = [];
$controls = [];
if (!empty($this->controls)) {
foreach ($this->controls as $control) {
$controls[] = $control->toArray();
}
}
if ($this instanceof CacheableOperationInterface) {
$defaults['Use Cache'] = var_export($this->getUseCache(), true);
$defaults['Execute on Cache Miss'] = var_export($this->getExecuteOnCacheMiss(), true);
$defaults['Invalidate Cache'] = var_export($this->getInvalidateCache(), true);
}
$defaults['Server'] = $this->server;
$defaults['Controls'] = var_export($controls, true);
return array_merge($log, $defaults);
} | php | protected function mergeLogDefaults(array $log)
{
$defaults = [];
$controls = [];
if (!empty($this->controls)) {
foreach ($this->controls as $control) {
$controls[] = $control->toArray();
}
}
if ($this instanceof CacheableOperationInterface) {
$defaults['Use Cache'] = var_export($this->getUseCache(), true);
$defaults['Execute on Cache Miss'] = var_export($this->getExecuteOnCacheMiss(), true);
$defaults['Invalidate Cache'] = var_export($this->getInvalidateCache(), true);
}
$defaults['Server'] = $this->server;
$defaults['Controls'] = var_export($controls, true);
return array_merge($log, $defaults);
} | [
"protected",
"function",
"mergeLogDefaults",
"(",
"array",
"$",
"log",
")",
"{",
"$",
"defaults",
"=",
"[",
"]",
";",
"$",
"controls",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"controls",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"controls",
"as",
"$",
"control",
")",
"{",
"$",
"controls",
"[",
"]",
"=",
"$",
"control",
"->",
"toArray",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"instanceof",
"CacheableOperationInterface",
")",
"{",
"$",
"defaults",
"[",
"'Use Cache'",
"]",
"=",
"var_export",
"(",
"$",
"this",
"->",
"getUseCache",
"(",
")",
",",
"true",
")",
";",
"$",
"defaults",
"[",
"'Execute on Cache Miss'",
"]",
"=",
"var_export",
"(",
"$",
"this",
"->",
"getExecuteOnCacheMiss",
"(",
")",
",",
"true",
")",
";",
"$",
"defaults",
"[",
"'Invalidate Cache'",
"]",
"=",
"var_export",
"(",
"$",
"this",
"->",
"getInvalidateCache",
"(",
")",
",",
"true",
")",
";",
"}",
"$",
"defaults",
"[",
"'Server'",
"]",
"=",
"$",
"this",
"->",
"server",
";",
"$",
"defaults",
"[",
"'Controls'",
"]",
"=",
"var_export",
"(",
"$",
"controls",
",",
"true",
")",
";",
"return",
"array_merge",
"(",
"$",
"log",
",",
"$",
"defaults",
")",
";",
"}"
] | Merges the log array with common log properties.
@param array $log
@return array | [
"Merges",
"the",
"log",
"array",
"with",
"common",
"log",
"properties",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/LdapOperationTrait.php#L146-L164 |
28,162 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvokerTrait.php | LdapOperationInvokerTrait.logExceptionAndThrow | protected function logExceptionAndThrow($exception, LogOperation $log = null)
{
if ($this->shouldLog($log) && is_null($log->getStartTime())) {
$this->logStart($log);
}
if ($this->shouldLog($log)) {
$log->setError($exception->getMessage());
}
throw $exception;
} | php | protected function logExceptionAndThrow($exception, LogOperation $log = null)
{
if ($this->shouldLog($log) && is_null($log->getStartTime())) {
$this->logStart($log);
}
if ($this->shouldLog($log)) {
$log->setError($exception->getMessage());
}
throw $exception;
} | [
"protected",
"function",
"logExceptionAndThrow",
"(",
"$",
"exception",
",",
"LogOperation",
"$",
"log",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shouldLog",
"(",
"$",
"log",
")",
"&&",
"is_null",
"(",
"$",
"log",
"->",
"getStartTime",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"logStart",
"(",
"$",
"log",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"shouldLog",
"(",
"$",
"log",
")",
")",
"{",
"$",
"log",
"->",
"setError",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"throw",
"$",
"exception",
";",
"}"
] | Handles exception error message logging if logging is enabled then re-throws the exception.
@param LogOperation|null $log
@param \Throwable|\Exception $exception
@throws \LdapTools\Exception\LdapConnectionException | [
"Handles",
"exception",
"error",
"message",
"logging",
"if",
"logging",
"is",
"enabled",
"then",
"re",
"-",
"throws",
"the",
"exception",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvokerTrait.php#L99-L109 |
28,163 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvokerTrait.php | LdapOperationInvokerTrait.logStart | protected function logStart(LogOperation $log = null)
{
if ($this->shouldLog($log)) {
$this->logger->start($log->start());
}
} | php | protected function logStart(LogOperation $log = null)
{
if ($this->shouldLog($log)) {
$this->logger->start($log->start());
}
} | [
"protected",
"function",
"logStart",
"(",
"LogOperation",
"$",
"log",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shouldLog",
"(",
"$",
"log",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"start",
"(",
"$",
"log",
"->",
"start",
"(",
")",
")",
";",
"}",
"}"
] | Start a logging operation.
@param LogOperation|null $log | [
"Start",
"a",
"logging",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvokerTrait.php#L116-L121 |
28,164 | ldaptools/ldaptools | src/LdapTools/Operation/Invoker/LdapOperationInvokerTrait.php | LdapOperationInvokerTrait.logEnd | protected function logEnd(LogOperation $log = null)
{
if ($this->shouldLog($log)) {
$this->logger->end($log->stop());
}
} | php | protected function logEnd(LogOperation $log = null)
{
if ($this->shouldLog($log)) {
$this->logger->end($log->stop());
}
} | [
"protected",
"function",
"logEnd",
"(",
"LogOperation",
"$",
"log",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"shouldLog",
"(",
"$",
"log",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"end",
"(",
"$",
"log",
"->",
"stop",
"(",
")",
")",
";",
"}",
"}"
] | End a logging operation.
@param LogOperation|null $log | [
"End",
"a",
"logging",
"operation",
"."
] | b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7 | https://github.com/ldaptools/ldaptools/blob/b7a4f6df96ef83e82c7ed6238e4d0346c0f666f7/src/LdapTools/Operation/Invoker/LdapOperationInvokerTrait.php#L128-L133 |
28,165 | Laralum/Laralum | src/Controllers/LoginController.php | LoginController.login | public function login(Request $request)
{
$this->validate($request, [
'email' => 'required|max:255',
'password' => 'required|max:255',
]);
if (Auth::attempt(['email' => $request->email, 'password' => $request->password], $request->remember ? true : false)) {
return redirect()->intended(route('laralum::index'));
}
return redirect()->route('laralum::login')->with('error', trans('auth.failed'))->withInput();
} | php | public function login(Request $request)
{
$this->validate($request, [
'email' => 'required|max:255',
'password' => 'required|max:255',
]);
if (Auth::attempt(['email' => $request->email, 'password' => $request->password], $request->remember ? true : false)) {
return redirect()->intended(route('laralum::index'));
}
return redirect()->route('laralum::login')->with('error', trans('auth.failed'))->withInput();
} | [
"public",
"function",
"login",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
",",
"[",
"'email'",
"=>",
"'required|max:255'",
",",
"'password'",
"=>",
"'required|max:255'",
",",
"]",
")",
";",
"if",
"(",
"Auth",
"::",
"attempt",
"(",
"[",
"'email'",
"=>",
"$",
"request",
"->",
"email",
",",
"'password'",
"=>",
"$",
"request",
"->",
"password",
"]",
",",
"$",
"request",
"->",
"remember",
"?",
"true",
":",
"false",
")",
")",
"{",
"return",
"redirect",
"(",
")",
"->",
"intended",
"(",
"route",
"(",
"'laralum::index'",
")",
")",
";",
"}",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'laralum::login'",
")",
"->",
"with",
"(",
"'error'",
",",
"trans",
"(",
"'auth.failed'",
")",
")",
"->",
"withInput",
"(",
")",
";",
"}"
] | Manual user login.
@param $request | [
"Manual",
"user",
"login",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Controllers/LoginController.php#L29-L41 |
28,166 | Laralum/Laralum | src/Injector.php | Injector.inject | public static function inject($injector, $package)
{
$dir = __DIR__."/../../$package/src/Injectors";
$files = is_dir($dir) ? scandir($dir) : [];
foreach ($files as $file) {
if (substr($file, 0, -4) == $injector and substr($file, -4) == '.php') {
$file = $dir.'/'.$file;
return include $file;
}
}
return '';
} | php | public static function inject($injector, $package)
{
$dir = __DIR__."/../../$package/src/Injectors";
$files = is_dir($dir) ? scandir($dir) : [];
foreach ($files as $file) {
if (substr($file, 0, -4) == $injector and substr($file, -4) == '.php') {
$file = $dir.'/'.$file;
return include $file;
}
}
return '';
} | [
"public",
"static",
"function",
"inject",
"(",
"$",
"injector",
",",
"$",
"package",
")",
"{",
"$",
"dir",
"=",
"__DIR__",
".",
"\"/../../$package/src/Injectors\"",
";",
"$",
"files",
"=",
"is_dir",
"(",
"$",
"dir",
")",
"?",
"scandir",
"(",
"$",
"dir",
")",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"-",
"4",
")",
"==",
"$",
"injector",
"and",
"substr",
"(",
"$",
"file",
",",
"-",
"4",
")",
"==",
"'.php'",
")",
"{",
"$",
"file",
"=",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
";",
"return",
"include",
"$",
"file",
";",
"}",
"}",
"return",
"''",
";",
"}"
] | Returns the injection of the specified injector and package.
@param string $package | [
"Returns",
"the",
"injection",
"of",
"the",
"specified",
"injector",
"and",
"package",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Injector.php#L28-L42 |
28,167 | Laralum/Laralum | src/Packages.php | Packages.get | public static function get()
{
// Check for Laralum packages
$packages = [];
$location = __DIR__.'/../../';
$files = is_dir($location) ? scandir($location) : [];
foreach ($files as $package) {
if ($package != '.' and $package != '..' and ucfirst($package) != 'Laralum') {
array_push($packages, strtolower($package));
}
}
return $packages;
} | php | public static function get()
{
// Check for Laralum packages
$packages = [];
$location = __DIR__.'/../../';
$files = is_dir($location) ? scandir($location) : [];
foreach ($files as $package) {
if ($package != '.' and $package != '..' and ucfirst($package) != 'Laralum') {
array_push($packages, strtolower($package));
}
}
return $packages;
} | [
"public",
"static",
"function",
"get",
"(",
")",
"{",
"// Check for Laralum packages",
"$",
"packages",
"=",
"[",
"]",
";",
"$",
"location",
"=",
"__DIR__",
".",
"'/../../'",
";",
"$",
"files",
"=",
"is_dir",
"(",
"$",
"location",
")",
"?",
"scandir",
"(",
"$",
"location",
")",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"package",
")",
"{",
"if",
"(",
"$",
"package",
"!=",
"'.'",
"and",
"$",
"package",
"!=",
"'..'",
"and",
"ucfirst",
"(",
"$",
"package",
")",
"!=",
"'Laralum'",
")",
"{",
"array_push",
"(",
"$",
"packages",
",",
"strtolower",
"(",
"$",
"package",
")",
")",
";",
"}",
"}",
"return",
"$",
"packages",
";",
"}"
] | Returns an array of all the installed packages. | [
"Returns",
"an",
"array",
"of",
"all",
"the",
"installed",
"packages",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Packages.php#L26-L41 |
28,168 | Laralum/Laralum | src/Packages.php | Packages.provider | public static function provider($package)
{
$location = __DIR__.'/../../'.$package.'/src';
$files = is_dir($location) ? scandir($location) : [];
foreach ($files as $file) {
if (strpos($file, 'ServiceProvider') !== false) {
return str_replace('.php', '', $file);
}
}
return false;
} | php | public static function provider($package)
{
$location = __DIR__.'/../../'.$package.'/src';
$files = is_dir($location) ? scandir($location) : [];
foreach ($files as $file) {
if (strpos($file, 'ServiceProvider') !== false) {
return str_replace('.php', '', $file);
}
}
return false;
} | [
"public",
"static",
"function",
"provider",
"(",
"$",
"package",
")",
"{",
"$",
"location",
"=",
"__DIR__",
".",
"'/../../'",
".",
"$",
"package",
".",
"'/src'",
";",
"$",
"files",
"=",
"is_dir",
"(",
"$",
"location",
")",
"?",
"scandir",
"(",
"$",
"location",
")",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"file",
",",
"'ServiceProvider'",
")",
"!==",
"false",
")",
"{",
"return",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the package service provider if exists.
@param string $package | [
"Returns",
"the",
"package",
"service",
"provider",
"if",
"exists",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Packages.php#L48-L61 |
28,169 | Laralum/Laralum | src/Packages.php | Packages.menu | public static function menu($package)
{
$dir = __DIR__.'/../../'.$package.'/src';
$files = is_dir($dir) ? scandir($dir) : [];
foreach ($files as $file) {
if ($file == 'Menu.json') {
$file_r = file_get_contents($dir.'/'.$file);
return json_decode($file_r, true);
}
}
return [];
} | php | public static function menu($package)
{
$dir = __DIR__.'/../../'.$package.'/src';
$files = is_dir($dir) ? scandir($dir) : [];
foreach ($files as $file) {
if ($file == 'Menu.json') {
$file_r = file_get_contents($dir.'/'.$file);
return json_decode($file_r, true);
}
}
return [];
} | [
"public",
"static",
"function",
"menu",
"(",
"$",
"package",
")",
"{",
"$",
"dir",
"=",
"__DIR__",
".",
"'/../../'",
".",
"$",
"package",
".",
"'/src'",
";",
"$",
"files",
"=",
"is_dir",
"(",
"$",
"dir",
")",
"?",
"scandir",
"(",
"$",
"dir",
")",
":",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"==",
"'Menu.json'",
")",
"{",
"$",
"file_r",
"=",
"file_get_contents",
"(",
"$",
"dir",
".",
"'/'",
".",
"$",
"file",
")",
";",
"return",
"json_decode",
"(",
"$",
"file_r",
",",
"true",
")",
";",
"}",
"}",
"return",
"[",
"]",
";",
"}"
] | Returns the package menu if exists.
@param string $package | [
"Returns",
"the",
"package",
"menu",
"if",
"exists",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Packages.php#L78-L92 |
28,170 | Laralum/Laralum | src/Packages.php | Packages.all | public static function all()
{
$preference = collect(['laralum', 'dashboard', 'users', 'roles', 'permissions']);
collect(static::get())->each(function ($package) use ($preference) {
if (!$preference->contains($package)) {
$preference->push($package);
}
});
return $preference->toArray();
} | php | public static function all()
{
$preference = collect(['laralum', 'dashboard', 'users', 'roles', 'permissions']);
collect(static::get())->each(function ($package) use ($preference) {
if (!$preference->contains($package)) {
$preference->push($package);
}
});
return $preference->toArray();
} | [
"public",
"static",
"function",
"all",
"(",
")",
"{",
"$",
"preference",
"=",
"collect",
"(",
"[",
"'laralum'",
",",
"'dashboard'",
",",
"'users'",
",",
"'roles'",
",",
"'permissions'",
"]",
")",
";",
"collect",
"(",
"static",
"::",
"get",
"(",
")",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"package",
")",
"use",
"(",
"$",
"preference",
")",
"{",
"if",
"(",
"!",
"$",
"preference",
"->",
"contains",
"(",
"$",
"package",
")",
")",
"{",
"$",
"preference",
"->",
"push",
"(",
"$",
"package",
")",
";",
"}",
"}",
")",
";",
"return",
"$",
"preference",
"->",
"toArray",
"(",
")",
";",
"}"
] | Gets all packages and orders them by preference.
@return array | [
"Gets",
"all",
"packages",
"and",
"orders",
"them",
"by",
"preference",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Packages.php#L99-L110 |
28,171 | Laralum/Laralum | src/Menu.php | Menu.getCustomMenuItems | public static function getCustomMenuItems($user)
{
$menuItems = [];
if (array_key_exists('menu', config('laralum'))) {
foreach (config('laralum.menu') as $custom_menu) {
$pm = new self();
$pm->name(ucfirst($custom_menu['title']));
$pm->items = array_merge($pm->items, static::getPackageMenuItems($custom_menu, $user));
if (count($pm->items) > 0) {
array_push($menuItems, $pm);
}
}
}
return $menuItems;
} | php | public static function getCustomMenuItems($user)
{
$menuItems = [];
if (array_key_exists('menu', config('laralum'))) {
foreach (config('laralum.menu') as $custom_menu) {
$pm = new self();
$pm->name(ucfirst($custom_menu['title']));
$pm->items = array_merge($pm->items, static::getPackageMenuItems($custom_menu, $user));
if (count($pm->items) > 0) {
array_push($menuItems, $pm);
}
}
}
return $menuItems;
} | [
"public",
"static",
"function",
"getCustomMenuItems",
"(",
"$",
"user",
")",
"{",
"$",
"menuItems",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'menu'",
",",
"config",
"(",
"'laralum'",
")",
")",
")",
"{",
"foreach",
"(",
"config",
"(",
"'laralum.menu'",
")",
"as",
"$",
"custom_menu",
")",
"{",
"$",
"pm",
"=",
"new",
"self",
"(",
")",
";",
"$",
"pm",
"->",
"name",
"(",
"ucfirst",
"(",
"$",
"custom_menu",
"[",
"'title'",
"]",
")",
")",
";",
"$",
"pm",
"->",
"items",
"=",
"array_merge",
"(",
"$",
"pm",
"->",
"items",
",",
"static",
"::",
"getPackageMenuItems",
"(",
"$",
"custom_menu",
",",
"$",
"user",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"pm",
"->",
"items",
")",
">",
"0",
")",
"{",
"array_push",
"(",
"$",
"menuItems",
",",
"$",
"pm",
")",
";",
"}",
"}",
"}",
"return",
"$",
"menuItems",
";",
"}"
] | Get custom menus defined in the laralum config.
@return [type] [description] | [
"Get",
"custom",
"menus",
"defined",
"in",
"the",
"laralum",
"config",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Menu.php#L89-L106 |
28,172 | Laralum/Laralum | src/Menu.php | Menu.getPackageMenuItems | public static function getPackageMenuItems($menu, $user)
{
$packageItems = [];
foreach ($menu['items'] as $i) {
$item = new Item();
$item->text = array_key_exists('trans', $i) ? __($i['trans']) : $i['text'];
$item->url = array_key_exists('route', $i) ? route($i['route']) : url($i['link']);
if (array_key_exists('permission', $i) && !$user->superAdmin()) {
if (!$user->hasPermission($i['permission'])) {
continue;
}
}
array_push($packageItems, $item);
}
return $packageItems;
} | php | public static function getPackageMenuItems($menu, $user)
{
$packageItems = [];
foreach ($menu['items'] as $i) {
$item = new Item();
$item->text = array_key_exists('trans', $i) ? __($i['trans']) : $i['text'];
$item->url = array_key_exists('route', $i) ? route($i['route']) : url($i['link']);
if (array_key_exists('permission', $i) && !$user->superAdmin()) {
if (!$user->hasPermission($i['permission'])) {
continue;
}
}
array_push($packageItems, $item);
}
return $packageItems;
} | [
"public",
"static",
"function",
"getPackageMenuItems",
"(",
"$",
"menu",
",",
"$",
"user",
")",
"{",
"$",
"packageItems",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"menu",
"[",
"'items'",
"]",
"as",
"$",
"i",
")",
"{",
"$",
"item",
"=",
"new",
"Item",
"(",
")",
";",
"$",
"item",
"->",
"text",
"=",
"array_key_exists",
"(",
"'trans'",
",",
"$",
"i",
")",
"?",
"__",
"(",
"$",
"i",
"[",
"'trans'",
"]",
")",
":",
"$",
"i",
"[",
"'text'",
"]",
";",
"$",
"item",
"->",
"url",
"=",
"array_key_exists",
"(",
"'route'",
",",
"$",
"i",
")",
"?",
"route",
"(",
"$",
"i",
"[",
"'route'",
"]",
")",
":",
"url",
"(",
"$",
"i",
"[",
"'link'",
"]",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'permission'",
",",
"$",
"i",
")",
"&&",
"!",
"$",
"user",
"->",
"superAdmin",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"user",
"->",
"hasPermission",
"(",
"$",
"i",
"[",
"'permission'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"}",
"array_push",
"(",
"$",
"packageItems",
",",
"$",
"item",
")",
";",
"}",
"return",
"$",
"packageItems",
";",
"}"
] | Get package menu Items.
@param [type] $packageMenu [description]
@param [type] $items [description]
@return [type] [description] | [
"Get",
"package",
"menu",
"Items",
"."
] | 6f13eec2c898bcc523fb6c19bc78146b9898e689 | https://github.com/Laralum/Laralum/blob/6f13eec2c898bcc523fb6c19bc78146b9898e689/src/Menu.php#L116-L135 |
28,173 | quazardous/ImageStack | src/ImageStack/ImageManipulator/OptimizerImageManipulator.php | OptimizerImageManipulator.registerImageOptimizer | public function registerImageOptimizer(ImageOptimizerInterface $imageOptimizer)
{
foreach ($imageOptimizer->getSupportedMimeTypes() as $mimeType) {
$this->imageOptimizers[$mimeType][] = $imageOptimizer;
}
} | php | public function registerImageOptimizer(ImageOptimizerInterface $imageOptimizer)
{
foreach ($imageOptimizer->getSupportedMimeTypes() as $mimeType) {
$this->imageOptimizers[$mimeType][] = $imageOptimizer;
}
} | [
"public",
"function",
"registerImageOptimizer",
"(",
"ImageOptimizerInterface",
"$",
"imageOptimizer",
")",
"{",
"foreach",
"(",
"$",
"imageOptimizer",
"->",
"getSupportedMimeTypes",
"(",
")",
"as",
"$",
"mimeType",
")",
"{",
"$",
"this",
"->",
"imageOptimizers",
"[",
"$",
"mimeType",
"]",
"[",
"]",
"=",
"$",
"imageOptimizer",
";",
"}",
"}"
] | Register an image optimizer.
@param string $mimeType
@param ImageOptimizerInterface $imageOptimizer | [
"Register",
"an",
"image",
"optimizer",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageManipulator/OptimizerImageManipulator.php#L36-L41 |
28,174 | peakphp/framework | src/Backpack/Bootstrap/Routing.php | Routing.boot | public function boot()
{
if ($this->app->getProps() === null) {
return;
}
$routes = [];
$pathPrefix = $this->app->getProp($this->routesPathPrefixPropName, '');
$propRoutes = $this->app->getProp($this->routesPropName, []);
if (!is_array($propRoutes)) {
throw new \Exception('Routes definitions must be an array!');
}
foreach ($this->app->getProp($this->routesPropName, []) as $route) {
$this->validate($route);
$routes[] = $this->app->createRoute(
$route['method'] ?? null,
$pathPrefix.$route['path'],
$route['stack']
);
}
$this->app->stack($routes);
} | php | public function boot()
{
if ($this->app->getProps() === null) {
return;
}
$routes = [];
$pathPrefix = $this->app->getProp($this->routesPathPrefixPropName, '');
$propRoutes = $this->app->getProp($this->routesPropName, []);
if (!is_array($propRoutes)) {
throw new \Exception('Routes definitions must be an array!');
}
foreach ($this->app->getProp($this->routesPropName, []) as $route) {
$this->validate($route);
$routes[] = $this->app->createRoute(
$route['method'] ?? null,
$pathPrefix.$route['path'],
$route['stack']
);
}
$this->app->stack($routes);
} | [
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"getProps",
"(",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"routes",
"=",
"[",
"]",
";",
"$",
"pathPrefix",
"=",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"routesPathPrefixPropName",
",",
"''",
")",
";",
"$",
"propRoutes",
"=",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"routesPropName",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"propRoutes",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Routes definitions must be an array!'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"app",
"->",
"getProp",
"(",
"$",
"this",
"->",
"routesPropName",
",",
"[",
"]",
")",
"as",
"$",
"route",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"route",
")",
";",
"$",
"routes",
"[",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"createRoute",
"(",
"$",
"route",
"[",
"'method'",
"]",
"??",
"null",
",",
"$",
"pathPrefix",
".",
"$",
"route",
"[",
"'path'",
"]",
",",
"$",
"route",
"[",
"'stack'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"stack",
"(",
"$",
"routes",
")",
";",
"}"
] | Look for routes to register in application properties
@throws \Exception | [
"Look",
"for",
"routes",
"to",
"register",
"in",
"application",
"properties"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Backpack/Bootstrap/Routing.php#L49-L73 |
28,175 | milejko/mmi | src/Mmi/Navigation/Navigation.php | Navigation._setupBreadcrumbs | private function _setupBreadcrumbs($tree)
{
//iteracja po drzewie
foreach ($tree as $item) {
//jeśli nieaktywny przechodzi do następnego
if (!$item['active']) {
continue;
}
$this->_breadcrumbs[] = $item;
//jeśli dzieci
if (isset($item['children'])) {
//zejście rekurencyjne
$this->_setupBreadcrumbs($item['children']);
}
//optymalizacja wydajności
break;
}
//brak breadcrumbs
if (count($this->_breadcrumbs) == 0) {
return;
}
//ostatni item
$currentItem = $this->_breadcrumbs[count($this->_breadcrumbs) - 1];
//jeśli jest niezależny kasujemy wszystko poza nim
if (isset($currentItem['independent']) && $currentItem['independent']) {
$this->_breadcrumbs = [$this->_breadcrumbs[count($this->_breadcrumbs) - 1]];
}
} | php | private function _setupBreadcrumbs($tree)
{
//iteracja po drzewie
foreach ($tree as $item) {
//jeśli nieaktywny przechodzi do następnego
if (!$item['active']) {
continue;
}
$this->_breadcrumbs[] = $item;
//jeśli dzieci
if (isset($item['children'])) {
//zejście rekurencyjne
$this->_setupBreadcrumbs($item['children']);
}
//optymalizacja wydajności
break;
}
//brak breadcrumbs
if (count($this->_breadcrumbs) == 0) {
return;
}
//ostatni item
$currentItem = $this->_breadcrumbs[count($this->_breadcrumbs) - 1];
//jeśli jest niezależny kasujemy wszystko poza nim
if (isset($currentItem['independent']) && $currentItem['independent']) {
$this->_breadcrumbs = [$this->_breadcrumbs[count($this->_breadcrumbs) - 1]];
}
} | [
"private",
"function",
"_setupBreadcrumbs",
"(",
"$",
"tree",
")",
"{",
"//iteracja po drzewie",
"foreach",
"(",
"$",
"tree",
"as",
"$",
"item",
")",
"{",
"//jeśli nieaktywny przechodzi do następnego",
"if",
"(",
"!",
"$",
"item",
"[",
"'active'",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"_breadcrumbs",
"[",
"]",
"=",
"$",
"item",
";",
"//jeśli dzieci",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'children'",
"]",
")",
")",
"{",
"//zejście rekurencyjne",
"$",
"this",
"->",
"_setupBreadcrumbs",
"(",
"$",
"item",
"[",
"'children'",
"]",
")",
";",
"}",
"//optymalizacja wydajności",
"break",
";",
"}",
"//brak breadcrumbs",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_breadcrumbs",
")",
"==",
"0",
")",
"{",
"return",
";",
"}",
"//ostatni item",
"$",
"currentItem",
"=",
"$",
"this",
"->",
"_breadcrumbs",
"[",
"count",
"(",
"$",
"this",
"->",
"_breadcrumbs",
")",
"-",
"1",
"]",
";",
"//jeśli jest niezależny kasujemy wszystko poza nim",
"if",
"(",
"isset",
"(",
"$",
"currentItem",
"[",
"'independent'",
"]",
")",
"&&",
"$",
"currentItem",
"[",
"'independent'",
"]",
")",
"{",
"$",
"this",
"->",
"_breadcrumbs",
"=",
"[",
"$",
"this",
"->",
"_breadcrumbs",
"[",
"count",
"(",
"$",
"this",
"->",
"_breadcrumbs",
")",
"-",
"1",
"]",
"]",
";",
"}",
"}"
] | Buduje breadcrumbs z aktywowanego drzewa
@param array $tree drzewo | [
"Buduje",
"breadcrumbs",
"z",
"aktywowanego",
"drzewa"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/Navigation.php#L127-L154 |
28,176 | honeybee/honeybee | src/Infrastructure/DataAccess/Connector/RabbitMqConnector.php | RabbitMqConnector.getStatus | public function getStatus()
{
if ($this->config->has('fake_status')) {
return new Status($this, $this->config->get('fake_status'));
}
try {
$conn = $this->getFreshConnection();
$conn->reconnect();
$info = $conn->getServerProperties();
return Status::working($this, [
'message' => 'Could reconnect to rabbitmq server.',
'server_properties' => $info
]);
} catch (Exception $e) {
error_log(
'[' . static::CLASS . '] Error on status check: ' . $e->getMessage() . "\n" . $e->getTraceAsString()
);
return Status::failing($this, [ 'error' => $e->getMessage() ]);
}
} | php | public function getStatus()
{
if ($this->config->has('fake_status')) {
return new Status($this, $this->config->get('fake_status'));
}
try {
$conn = $this->getFreshConnection();
$conn->reconnect();
$info = $conn->getServerProperties();
return Status::working($this, [
'message' => 'Could reconnect to rabbitmq server.',
'server_properties' => $info
]);
} catch (Exception $e) {
error_log(
'[' . static::CLASS . '] Error on status check: ' . $e->getMessage() . "\n" . $e->getTraceAsString()
);
return Status::failing($this, [ 'error' => $e->getMessage() ]);
}
} | [
"public",
"function",
"getStatus",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"->",
"has",
"(",
"'fake_status'",
")",
")",
"{",
"return",
"new",
"Status",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'fake_status'",
")",
")",
";",
"}",
"try",
"{",
"$",
"conn",
"=",
"$",
"this",
"->",
"getFreshConnection",
"(",
")",
";",
"$",
"conn",
"->",
"reconnect",
"(",
")",
";",
"$",
"info",
"=",
"$",
"conn",
"->",
"getServerProperties",
"(",
")",
";",
"return",
"Status",
"::",
"working",
"(",
"$",
"this",
",",
"[",
"'message'",
"=>",
"'Could reconnect to rabbitmq server.'",
",",
"'server_properties'",
"=>",
"$",
"info",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"error_log",
"(",
"'['",
".",
"static",
"::",
"CLASS",
".",
"'] Error on status check: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
".",
"$",
"e",
"->",
"getTraceAsString",
"(",
")",
")",
";",
"return",
"Status",
"::",
"failing",
"(",
"$",
"this",
",",
"[",
"'error'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
";",
"}",
"}"
] | Tries to connect to rabbitmq server and get the server properties.
@return Status of this connector | [
"Tries",
"to",
"connect",
"to",
"rabbitmq",
"server",
"and",
"get",
"the",
"server",
"properties",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/DataAccess/Connector/RabbitMqConnector.php#L142-L162 |
28,177 | milejko/mmi | src/Mmi/Mvc/ViewHelper/HeadMeta.php | HeadMeta.openGraph | public function openGraph($property, $content, $replace = false, $conditional = '')
{
return $this->headMeta(['property' => $property, 'content' => $content], $replace, $conditional);
} | php | public function openGraph($property, $content, $replace = false, $conditional = '')
{
return $this->headMeta(['property' => $property, 'content' => $content], $replace, $conditional);
} | [
"public",
"function",
"openGraph",
"(",
"$",
"property",
",",
"$",
"content",
",",
"$",
"replace",
"=",
"false",
",",
"$",
"conditional",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"headMeta",
"(",
"[",
"'property'",
"=>",
"$",
"property",
",",
"'content'",
"=>",
"$",
"content",
"]",
",",
"$",
"replace",
",",
"$",
"conditional",
")",
";",
"}"
] | Dodaje znacznik dla Open Graph
@param string $property nazwa właściwości, np. og:image
@param string $content zawartość
@param boolean $replace nadpisz definicję dla klucza
@param string $conditional warunek np. ie6
@return \Mmi\Mvc\ViewHelper\HeadMeta | [
"Dodaje",
"znacznik",
"dla",
"Open",
"Graph"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadMeta.php#L52-L55 |
28,178 | milejko/mmi | src/Mmi/Validator/EmailAddressList.php | EmailAddressList.isValid | public function isValid($value)
{
$emails = explode(((false !== strpos($value, ',')) ? ',' : ';'), $value);
//iteracja po mailach
foreach ($emails as $email) {
//niepoprawny email
if (!(new EmailAddress)->isValid($email)) {
return $this->_error(self::INVALID);
}
}
return true;
} | php | public function isValid($value)
{
$emails = explode(((false !== strpos($value, ',')) ? ',' : ';'), $value);
//iteracja po mailach
foreach ($emails as $email) {
//niepoprawny email
if (!(new EmailAddress)->isValid($email)) {
return $this->_error(self::INVALID);
}
}
return true;
} | [
"public",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"emails",
"=",
"explode",
"(",
"(",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"value",
",",
"','",
")",
")",
"?",
"','",
":",
"';'",
")",
",",
"$",
"value",
")",
";",
"//iteracja po mailach",
"foreach",
"(",
"$",
"emails",
"as",
"$",
"email",
")",
"{",
"//niepoprawny email",
"if",
"(",
"!",
"(",
"new",
"EmailAddress",
")",
"->",
"isValid",
"(",
"$",
"email",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_error",
"(",
"self",
"::",
"INVALID",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Sprawdza czy tekst jest e-mailem
@param string $value
@return boolean | [
"Sprawdza",
"czy",
"tekst",
"jest",
"e",
"-",
"mailem"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Validator/EmailAddressList.php#L29-L40 |
28,179 | peakphp/framework | src/Http/Request/RouteExpression.php | RouteExpression.compile | private function compile()
{
// replace pseudo {param}:type syntax to valid regex
if (strpos($this->regex, '}:') !== false) {
$this->regex = preg_replace('#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#', '(?P<$1>:$2)', $this->expression);
$this->regex = str_replace(
array_keys($this->regexExpression),
array_values($this->regexExpression),
$this->regex
);
}
// replace pseudo {param} syntax without type to valid regex
if (strpos($this->regex, '}') !== false) {
$this->regex = preg_replace('#\{([a-zA-Z_]+)\}#', '(?P<$1>[^\/]+)', $this->regex);
}
// allow optional trailing slash at the end
if (substr($this->regex, -1) !== '/') {
$this->regex .= '[\/]?';
}
} | php | private function compile()
{
// replace pseudo {param}:type syntax to valid regex
if (strpos($this->regex, '}:') !== false) {
$this->regex = preg_replace('#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#', '(?P<$1>:$2)', $this->expression);
$this->regex = str_replace(
array_keys($this->regexExpression),
array_values($this->regexExpression),
$this->regex
);
}
// replace pseudo {param} syntax without type to valid regex
if (strpos($this->regex, '}') !== false) {
$this->regex = preg_replace('#\{([a-zA-Z_]+)\}#', '(?P<$1>[^\/]+)', $this->regex);
}
// allow optional trailing slash at the end
if (substr($this->regex, -1) !== '/') {
$this->regex .= '[\/]?';
}
} | [
"private",
"function",
"compile",
"(",
")",
"{",
"// replace pseudo {param}:type syntax to valid regex",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"regex",
",",
"'}:'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"regex",
"=",
"preg_replace",
"(",
"'#\\{([a-zA-Z0-9_-]+)\\}:([a-z]+)#'",
",",
"'(?P<$1>:$2)'",
",",
"$",
"this",
"->",
"expression",
")",
";",
"$",
"this",
"->",
"regex",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"regexExpression",
")",
",",
"array_values",
"(",
"$",
"this",
"->",
"regexExpression",
")",
",",
"$",
"this",
"->",
"regex",
")",
";",
"}",
"// replace pseudo {param} syntax without type to valid regex",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"regex",
",",
"'}'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"regex",
"=",
"preg_replace",
"(",
"'#\\{([a-zA-Z_]+)\\}#'",
",",
"'(?P<$1>[^\\/]+)'",
",",
"$",
"this",
"->",
"regex",
")",
";",
"}",
"// allow optional trailing slash at the end",
"if",
"(",
"substr",
"(",
"$",
"this",
"->",
"regex",
",",
"-",
"1",
")",
"!==",
"'/'",
")",
"{",
"$",
"this",
"->",
"regex",
".=",
"'[\\/]?'",
";",
"}",
"}"
] | Compile expression to valid regex | [
"Compile",
"expression",
"to",
"valid",
"regex"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Http/Request/RouteExpression.php#L77-L98 |
28,180 | milejko/mmi | src/Mmi/Mvc/ActionHelper.php | ActionHelper._checkAcl | private function _checkAcl(Request $request)
{
//brak acl lub brak auth lub dozwolone acl
return !$this->_acl || !$this->_auth || $this->_acl->isAllowed($this->_auth->getRoles(), $request->getAsColonSeparatedString());
} | php | private function _checkAcl(Request $request)
{
//brak acl lub brak auth lub dozwolone acl
return !$this->_acl || !$this->_auth || $this->_acl->isAllowed($this->_auth->getRoles(), $request->getAsColonSeparatedString());
} | [
"private",
"function",
"_checkAcl",
"(",
"Request",
"$",
"request",
")",
"{",
"//brak acl lub brak auth lub dozwolone acl",
"return",
"!",
"$",
"this",
"->",
"_acl",
"||",
"!",
"$",
"this",
"->",
"_auth",
"||",
"$",
"this",
"->",
"_acl",
"->",
"isAllowed",
"(",
"$",
"this",
"->",
"_auth",
"->",
"getRoles",
"(",
")",
",",
"$",
"request",
"->",
"getAsColonSeparatedString",
"(",
")",
")",
";",
"}"
] | Sprawdza uprawnienie do widgetu
@param \Mmi\Http\Request $request
@return boolean | [
"Sprawdza",
"uprawnienie",
"do",
"widgetu"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ActionHelper.php#L160-L164 |
28,181 | quazardous/ImageStack | src/ImageStack/Cache/RawFileCache.php | RawFileCache.assertValidId | protected function assertValidId($id)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$bad = preg_match('/[\x00-\x1F\x7F]\<\>\:\"\|\?\*]/', $id);
} else {
$bad = preg_match('/\x00/', $id);
}
if ($bad) {
throw new RawFileCacheException('Invalid character found in cache ID', RawFileCacheException::INVALID_CHARACTER);
}
} | php | protected function assertValidId($id)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$bad = preg_match('/[\x00-\x1F\x7F]\<\>\:\"\|\?\*]/', $id);
} else {
$bad = preg_match('/\x00/', $id);
}
if ($bad) {
throw new RawFileCacheException('Invalid character found in cache ID', RawFileCacheException::INVALID_CHARACTER);
}
} | [
"protected",
"function",
"assertValidId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"defined",
"(",
"'PHP_WINDOWS_VERSION_BUILD'",
")",
")",
"{",
"$",
"bad",
"=",
"preg_match",
"(",
"'/[\\x00-\\x1F\\x7F]\\<\\>\\:\\\"\\|\\?\\*]/'",
",",
"$",
"id",
")",
";",
"}",
"else",
"{",
"$",
"bad",
"=",
"preg_match",
"(",
"'/\\x00/'",
",",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"bad",
")",
"{",
"throw",
"new",
"RawFileCacheException",
"(",
"'Invalid character found in cache ID'",
",",
"RawFileCacheException",
"::",
"INVALID_CHARACTER",
")",
";",
"}",
"}"
] | Assert that cache ID is usable as file path.
@param string $id
@throws \InvalidArgumentException | [
"Assert",
"that",
"cache",
"ID",
"is",
"usable",
"as",
"file",
"path",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Cache/RawFileCache.php#L157-L167 |
28,182 | quazardous/ImageStack | src/ImageStack/Cache/RawFileCache.php | RawFileCache.getFilename | protected function getFilename($id, $metadata = false)
{
$this->assertValidId($id);
$path = rtrim(dirname($id), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if ($level = $this->getOption('hash_tree', 0)) {
$level = min(32, $level);
$md5 = md5($id);
for ($i = 0; $i < $level; ++$i) {
$path .= $md5[$i] . DIRECTORY_SEPARATOR;
}
}
$path .= basename($id);
if ($metadata) {
$root = $this->getOption('metadata_root', $this->getOption('root') . DIRECTORY_SEPARATOR . '.cache_metadata');
} else {
$root = $this->getOption('root');
}
return rtrim(sanitize_path($root . DIRECTORY_SEPARATOR . $path), DIRECTORY_SEPARATOR);
} | php | protected function getFilename($id, $metadata = false)
{
$this->assertValidId($id);
$path = rtrim(dirname($id), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
if ($level = $this->getOption('hash_tree', 0)) {
$level = min(32, $level);
$md5 = md5($id);
for ($i = 0; $i < $level; ++$i) {
$path .= $md5[$i] . DIRECTORY_SEPARATOR;
}
}
$path .= basename($id);
if ($metadata) {
$root = $this->getOption('metadata_root', $this->getOption('root') . DIRECTORY_SEPARATOR . '.cache_metadata');
} else {
$root = $this->getOption('root');
}
return rtrim(sanitize_path($root . DIRECTORY_SEPARATOR . $path), DIRECTORY_SEPARATOR);
} | [
"protected",
"function",
"getFilename",
"(",
"$",
"id",
",",
"$",
"metadata",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"assertValidId",
"(",
"$",
"id",
")",
";",
"$",
"path",
"=",
"rtrim",
"(",
"dirname",
"(",
"$",
"id",
")",
",",
"DIRECTORY_SEPARATOR",
")",
".",
"DIRECTORY_SEPARATOR",
";",
"if",
"(",
"$",
"level",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'hash_tree'",
",",
"0",
")",
")",
"{",
"$",
"level",
"=",
"min",
"(",
"32",
",",
"$",
"level",
")",
";",
"$",
"md5",
"=",
"md5",
"(",
"$",
"id",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"level",
";",
"++",
"$",
"i",
")",
"{",
"$",
"path",
".=",
"$",
"md5",
"[",
"$",
"i",
"]",
".",
"DIRECTORY_SEPARATOR",
";",
"}",
"}",
"$",
"path",
".=",
"basename",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"metadata",
")",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'metadata_root'",
",",
"$",
"this",
"->",
"getOption",
"(",
"'root'",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'.cache_metadata'",
")",
";",
"}",
"else",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'root'",
")",
";",
"}",
"return",
"rtrim",
"(",
"sanitize_path",
"(",
"$",
"root",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"path",
")",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"}"
] | Get the filename for the given ID.
@param string $id
@param string $metadata get the metadata filename
@return string | [
"Get",
"the",
"filename",
"for",
"the",
"given",
"ID",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Cache/RawFileCache.php#L175-L193 |
28,183 | quazardous/ImageStack | src/ImageStack/Cache/RawFileCache.php | RawFileCache.writeMetadata | protected function writeMetadata($id, array $metadata)
{
$filename = $this->getFilename($id, true);
$this->assertDirectory($filename);
$this->assertFile($filename);
if (false === file_put_contents($filename, serialize($metadata))) {
throw new RawFileCacheException(sprintf('Cannot write file : %s', $filename), RawFileCacheException::CANNOT_WRITE_FILE);
}
} | php | protected function writeMetadata($id, array $metadata)
{
$filename = $this->getFilename($id, true);
$this->assertDirectory($filename);
$this->assertFile($filename);
if (false === file_put_contents($filename, serialize($metadata))) {
throw new RawFileCacheException(sprintf('Cannot write file : %s', $filename), RawFileCacheException::CANNOT_WRITE_FILE);
}
} | [
"protected",
"function",
"writeMetadata",
"(",
"$",
"id",
",",
"array",
"$",
"metadata",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFilename",
"(",
"$",
"id",
",",
"true",
")",
";",
"$",
"this",
"->",
"assertDirectory",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"assertFile",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"false",
"===",
"file_put_contents",
"(",
"$",
"filename",
",",
"serialize",
"(",
"$",
"metadata",
")",
")",
")",
"{",
"throw",
"new",
"RawFileCacheException",
"(",
"sprintf",
"(",
"'Cannot write file : %s'",
",",
"$",
"filename",
")",
",",
"RawFileCacheException",
"::",
"CANNOT_WRITE_FILE",
")",
";",
"}",
"}"
] | Read metadata.
@param string $id
@param array $metadata
@throws RawFileCacheException | [
"Read",
"metadata",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Cache/RawFileCache.php#L201-L209 |
28,184 | quazardous/ImageStack | src/ImageStack/Cache/RawFileCache.php | RawFileCache.readMetadata | protected function readMetadata($id)
{
$filename = $this->getFilename($id, true);
$this->assertFile($filename);
if (is_file($filename)) {
if (false === ($data = file_get_contents($filename))) {
throw new RawFileCacheException(sprintf('Cannot read file : %s', $filename), RawFileCacheException::CANNOT_READ_FILE);
}
return (array)unserialize($data);
}
return [];
} | php | protected function readMetadata($id)
{
$filename = $this->getFilename($id, true);
$this->assertFile($filename);
if (is_file($filename)) {
if (false === ($data = file_get_contents($filename))) {
throw new RawFileCacheException(sprintf('Cannot read file : %s', $filename), RawFileCacheException::CANNOT_READ_FILE);
}
return (array)unserialize($data);
}
return [];
} | [
"protected",
"function",
"readMetadata",
"(",
"$",
"id",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"getFilename",
"(",
"$",
"id",
",",
"true",
")",
";",
"$",
"this",
"->",
"assertFile",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"filename",
")",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
")",
"{",
"throw",
"new",
"RawFileCacheException",
"(",
"sprintf",
"(",
"'Cannot read file : %s'",
",",
"$",
"filename",
")",
",",
"RawFileCacheException",
"::",
"CANNOT_READ_FILE",
")",
";",
"}",
"return",
"(",
"array",
")",
"unserialize",
"(",
"$",
"data",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Write metadata.
@param string $id
@throws RawFileCacheException
@return array | [
"Write",
"metadata",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Cache/RawFileCache.php#L217-L228 |
28,185 | quazardous/ImageStack | src/ImageStack/Cache/RawFileCache.php | RawFileCache.assertDirectory | protected function assertDirectory($filename)
{
$dirname = dirname($filename);
if (!is_dir($dirname)) {
if (is_file($dirname)) {
throw new RawFileCacheException(sprintf('File with same name : %s', $dirname), RawFileCacheException::FILE_WITH_SAME_NAME);
}
@mkdir($dirname, $this->getOption('dir_mode', 0755), true);
if (!is_dir($dirname)) {
throw new RawFileCacheException(sprintf('Cannot create directory : %s', $dirname), RawFileCacheException::CANNOT_CREATE_DIRECTORY);
}
}
} | php | protected function assertDirectory($filename)
{
$dirname = dirname($filename);
if (!is_dir($dirname)) {
if (is_file($dirname)) {
throw new RawFileCacheException(sprintf('File with same name : %s', $dirname), RawFileCacheException::FILE_WITH_SAME_NAME);
}
@mkdir($dirname, $this->getOption('dir_mode', 0755), true);
if (!is_dir($dirname)) {
throw new RawFileCacheException(sprintf('Cannot create directory : %s', $dirname), RawFileCacheException::CANNOT_CREATE_DIRECTORY);
}
}
} | [
"protected",
"function",
"assertDirectory",
"(",
"$",
"filename",
")",
"{",
"$",
"dirname",
"=",
"dirname",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"dirname",
")",
")",
"{",
"throw",
"new",
"RawFileCacheException",
"(",
"sprintf",
"(",
"'File with same name : %s'",
",",
"$",
"dirname",
")",
",",
"RawFileCacheException",
"::",
"FILE_WITH_SAME_NAME",
")",
";",
"}",
"@",
"mkdir",
"(",
"$",
"dirname",
",",
"$",
"this",
"->",
"getOption",
"(",
"'dir_mode'",
",",
"0755",
")",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"throw",
"new",
"RawFileCacheException",
"(",
"sprintf",
"(",
"'Cannot create directory : %s'",
",",
"$",
"dirname",
")",
",",
"RawFileCacheException",
"::",
"CANNOT_CREATE_DIRECTORY",
")",
";",
"}",
"}",
"}"
] | Assert that the parent directory can or will exist.
@param string $filename
@throws RawFileCacheException | [
"Assert",
"that",
"the",
"parent",
"directory",
"can",
"or",
"will",
"exist",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Cache/RawFileCache.php#L235-L247 |
28,186 | quazardous/ImageStack | src/ImageStack/Cache/RawFileCache.php | RawFileCache.assertFile | protected function assertFile($filename)
{
if (is_dir($filename)) {
throw new RawFileCacheException(sprintf('Directory with same name : %s', $filename), RawFileCacheException::DIRECTORY_WITH_SAME_NAME);
}
return is_file($filename);
} | php | protected function assertFile($filename)
{
if (is_dir($filename)) {
throw new RawFileCacheException(sprintf('Directory with same name : %s', $filename), RawFileCacheException::DIRECTORY_WITH_SAME_NAME);
}
return is_file($filename);
} | [
"protected",
"function",
"assertFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"RawFileCacheException",
"(",
"sprintf",
"(",
"'Directory with same name : %s'",
",",
"$",
"filename",
")",
",",
"RawFileCacheException",
"::",
"DIRECTORY_WITH_SAME_NAME",
")",
";",
"}",
"return",
"is_file",
"(",
"$",
"filename",
")",
";",
"}"
] | Assert that the filename can be used.
@param string $filename
@throws RawFileCacheException
@return boolean | [
"Assert",
"that",
"the",
"filename",
"can",
"be",
"used",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Cache/RawFileCache.php#L255-L261 |
28,187 | milejko/mmi | src/Mmi/Orm/RecordRo.php | RecordRo.setFromArray | public function setFromArray(array $row = [])
{
$joinedRows = [];
foreach ($row as $key => $value) {
//przyjęcie pól z joinów
if (false !== strpos($key, '__')) {
$keyParts = explode('__', $key);
$joinedRows[$keyParts[0]][$keyParts[1]][$keyParts[2]] = $value;
continue;
}
$field = \Mmi\Orm\Convert::underscoreToCamelcase($key);
if (property_exists($this, $field)) {
$this->$field = $value;
continue;
}
$this->setOption($field, $value);
}
//podpięcie joinów pod główny rekord
foreach ($joinedRows as $alias => $tables) {
foreach ($tables as $tableName => $fields) {
$recordClass = \Mmi\Orm\DbConnector::getRecordNameByTable($tableName);
$record = new $recordClass;
$record->setFromArray($fields)
->clearModified();
$this->_joined[$alias] = $record;
}
}
//wypełniony
$this->_filled = true;
return $this;
} | php | public function setFromArray(array $row = [])
{
$joinedRows = [];
foreach ($row as $key => $value) {
//przyjęcie pól z joinów
if (false !== strpos($key, '__')) {
$keyParts = explode('__', $key);
$joinedRows[$keyParts[0]][$keyParts[1]][$keyParts[2]] = $value;
continue;
}
$field = \Mmi\Orm\Convert::underscoreToCamelcase($key);
if (property_exists($this, $field)) {
$this->$field = $value;
continue;
}
$this->setOption($field, $value);
}
//podpięcie joinów pod główny rekord
foreach ($joinedRows as $alias => $tables) {
foreach ($tables as $tableName => $fields) {
$recordClass = \Mmi\Orm\DbConnector::getRecordNameByTable($tableName);
$record = new $recordClass;
$record->setFromArray($fields)
->clearModified();
$this->_joined[$alias] = $record;
}
}
//wypełniony
$this->_filled = true;
return $this;
} | [
"public",
"function",
"setFromArray",
"(",
"array",
"$",
"row",
"=",
"[",
"]",
")",
"{",
"$",
"joinedRows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//przyjęcie pól z joinów",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"key",
",",
"'__'",
")",
")",
"{",
"$",
"keyParts",
"=",
"explode",
"(",
"'__'",
",",
"$",
"key",
")",
";",
"$",
"joinedRows",
"[",
"$",
"keyParts",
"[",
"0",
"]",
"]",
"[",
"$",
"keyParts",
"[",
"1",
"]",
"]",
"[",
"$",
"keyParts",
"[",
"2",
"]",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"$",
"field",
"=",
"\\",
"Mmi",
"\\",
"Orm",
"\\",
"Convert",
"::",
"underscoreToCamelcase",
"(",
"$",
"key",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"this",
",",
"$",
"field",
")",
")",
"{",
"$",
"this",
"->",
"$",
"field",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"setOption",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"//podpięcie joinów pod główny rekord",
"foreach",
"(",
"$",
"joinedRows",
"as",
"$",
"alias",
"=>",
"$",
"tables",
")",
"{",
"foreach",
"(",
"$",
"tables",
"as",
"$",
"tableName",
"=>",
"$",
"fields",
")",
"{",
"$",
"recordClass",
"=",
"\\",
"Mmi",
"\\",
"Orm",
"\\",
"DbConnector",
"::",
"getRecordNameByTable",
"(",
"$",
"tableName",
")",
";",
"$",
"record",
"=",
"new",
"$",
"recordClass",
";",
"$",
"record",
"->",
"setFromArray",
"(",
"$",
"fields",
")",
"->",
"clearModified",
"(",
")",
";",
"$",
"this",
"->",
"_joined",
"[",
"$",
"alias",
"]",
"=",
"$",
"record",
";",
"}",
"}",
"//wypełniony",
"$",
"this",
"->",
"_filled",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Ustawia dane w obiekcie na podstawie tabeli
@param array $row tabela z danymi
@param bool $fromDb czy z bazy danych
@return \Mmi\Orm\Record | [
"Ustawia",
"dane",
"w",
"obiekcie",
"na",
"podstawie",
"tabeli"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/RecordRo.php#L156-L186 |
28,188 | milejko/mmi | src/Mmi/Orm/RecordRo.php | RecordRo.isModified | public final function isModified($field)
{
//brak klucza w tablicy stanu - niezmodyfikowane
if (!array_key_exists($field, $this->_state)) {
return false;
}
//wartość liczbowa - porównanie proste
if (is_numeric($this->$field) && $this->_state[$field] == $this->$field) {
return false;
}
//porównanie z typem
return ($this->_state[$field] !== $this->$field);
} | php | public final function isModified($field)
{
//brak klucza w tablicy stanu - niezmodyfikowane
if (!array_key_exists($field, $this->_state)) {
return false;
}
//wartość liczbowa - porównanie proste
if (is_numeric($this->$field) && $this->_state[$field] == $this->$field) {
return false;
}
//porównanie z typem
return ($this->_state[$field] !== $this->$field);
} | [
"public",
"final",
"function",
"isModified",
"(",
"$",
"field",
")",
"{",
"//brak klucza w tablicy stanu - niezmodyfikowane",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"_state",
")",
")",
"{",
"return",
"false",
";",
"}",
"//wartość liczbowa - porównanie proste",
"if",
"(",
"is_numeric",
"(",
"$",
"this",
"->",
"$",
"field",
")",
"&&",
"$",
"this",
"->",
"_state",
"[",
"$",
"field",
"]",
"==",
"$",
"this",
"->",
"$",
"field",
")",
"{",
"return",
"false",
";",
"}",
"//porównanie z typem",
"return",
"(",
"$",
"this",
"->",
"_state",
"[",
"$",
"field",
"]",
"!==",
"$",
"this",
"->",
"$",
"field",
")",
";",
"}"
] | Zwraca czy zmodyfikowano pole
@param string $field nazwa pola
@return boolean | [
"Zwraca",
"czy",
"zmodyfikowano",
"pole"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/RecordRo.php#L205-L217 |
28,189 | milejko/mmi | src/Mmi/Orm/RecordRo.php | RecordRo.toArray | public function toArray()
{
//tworzy array z opcji
$array = $this->_options;
//dołącza joinowane tabele
foreach ($this->_joined as $name => $value) {
if ($value instanceof \Mmi\Orm\RecordRo) {
$value = $value->toArray();
}
$array[$name] = $value;
}
//dołącza pola obiektu
foreach ($this as $name => $value) {
//tylko publiczne zmienne
if (substr($name, 0, 1) == '_') {
continue;
}
$array[$name] = $value;
}
return $array;
} | php | public function toArray()
{
//tworzy array z opcji
$array = $this->_options;
//dołącza joinowane tabele
foreach ($this->_joined as $name => $value) {
if ($value instanceof \Mmi\Orm\RecordRo) {
$value = $value->toArray();
}
$array[$name] = $value;
}
//dołącza pola obiektu
foreach ($this as $name => $value) {
//tylko publiczne zmienne
if (substr($name, 0, 1) == '_') {
continue;
}
$array[$name] = $value;
}
return $array;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"//tworzy array z opcji",
"$",
"array",
"=",
"$",
"this",
"->",
"_options",
";",
"//dołącza joinowane tabele",
"foreach",
"(",
"$",
"this",
"->",
"_joined",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Mmi",
"\\",
"Orm",
"\\",
"RecordRo",
")",
"{",
"$",
"value",
"=",
"$",
"value",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"array",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"//dołącza pola obiektu",
"foreach",
"(",
"$",
"this",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"//tylko publiczne zmienne",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"1",
")",
"==",
"'_'",
")",
"{",
"continue",
";",
"}",
"$",
"array",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Zwraca dane z obiektu w postaci tablicy
@return array | [
"Zwraca",
"dane",
"z",
"obiektu",
"w",
"postaci",
"tablicy"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/RecordRo.php#L233-L253 |
28,190 | quazardous/ImageStack | src/ImageStack/ImageBackend/FileImageBackend.php | FileImageBackend.getImageFilename | protected function getImageFilename(ImagePathInterface $path) {
return sanitize_path(implode(DIRECTORY_SEPARATOR, [
$this->getOption('root'),
$path->getPath(),
]));
} | php | protected function getImageFilename(ImagePathInterface $path) {
return sanitize_path(implode(DIRECTORY_SEPARATOR, [
$this->getOption('root'),
$path->getPath(),
]));
} | [
"protected",
"function",
"getImageFilename",
"(",
"ImagePathInterface",
"$",
"path",
")",
"{",
"return",
"sanitize_path",
"(",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"[",
"$",
"this",
"->",
"getOption",
"(",
"'root'",
")",
",",
"$",
"path",
"->",
"getPath",
"(",
")",
",",
"]",
")",
")",
";",
"}"
] | Get the image filename.
@param ImagePathInterface $path
@return string | [
"Get",
"the",
"image",
"filename",
"."
] | bca5632edfc7703300407984bbaefb3c91c1560c | https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageBackend/FileImageBackend.php#L37-L42 |
28,191 | peakphp/framework | src/Config/ConfigResolver.php | ConfigResolver.resolve | public function resolve($resource): Stream
{
// detect best way to load and process configuration content
if (is_array($resource)) {
return new DataStream($resource, new ArrayProcessor());
} elseif (is_callable($resource)) {
return new DataStream($resource, new CallableProcessor());
} elseif ($resource instanceof Config) {
return new DataStream($resource, new ConfigProcessor());
} elseif ($resource instanceof Collection) {
return new DataStream($resource, new CollectionProcessor());
} elseif ($resource instanceof Stream) {
return $resource;
} elseif ($resource instanceof stdClass) {
return new DataStream($resource, new StdClassProcessor());
} elseif (is_string($resource)) {
$filesHandlers = $this->filesHandlers;
if (null === $filesHandlers) {
$filesHandlers = new FilesHandlers(null);
}
return new FileStream($resource, $filesHandlers);
}
throw new UnknownResourceException($resource);
} | php | public function resolve($resource): Stream
{
// detect best way to load and process configuration content
if (is_array($resource)) {
return new DataStream($resource, new ArrayProcessor());
} elseif (is_callable($resource)) {
return new DataStream($resource, new CallableProcessor());
} elseif ($resource instanceof Config) {
return new DataStream($resource, new ConfigProcessor());
} elseif ($resource instanceof Collection) {
return new DataStream($resource, new CollectionProcessor());
} elseif ($resource instanceof Stream) {
return $resource;
} elseif ($resource instanceof stdClass) {
return new DataStream($resource, new StdClassProcessor());
} elseif (is_string($resource)) {
$filesHandlers = $this->filesHandlers;
if (null === $filesHandlers) {
$filesHandlers = new FilesHandlers(null);
}
return new FileStream($resource, $filesHandlers);
}
throw new UnknownResourceException($resource);
} | [
"public",
"function",
"resolve",
"(",
"$",
"resource",
")",
":",
"Stream",
"{",
"// detect best way to load and process configuration content",
"if",
"(",
"is_array",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"new",
"DataStream",
"(",
"$",
"resource",
",",
"new",
"ArrayProcessor",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"resource",
")",
")",
"{",
"return",
"new",
"DataStream",
"(",
"$",
"resource",
",",
"new",
"CallableProcessor",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"resource",
"instanceof",
"Config",
")",
"{",
"return",
"new",
"DataStream",
"(",
"$",
"resource",
",",
"new",
"ConfigProcessor",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"resource",
"instanceof",
"Collection",
")",
"{",
"return",
"new",
"DataStream",
"(",
"$",
"resource",
",",
"new",
"CollectionProcessor",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"resource",
"instanceof",
"Stream",
")",
"{",
"return",
"$",
"resource",
";",
"}",
"elseif",
"(",
"$",
"resource",
"instanceof",
"stdClass",
")",
"{",
"return",
"new",
"DataStream",
"(",
"$",
"resource",
",",
"new",
"StdClassProcessor",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"resource",
")",
")",
"{",
"$",
"filesHandlers",
"=",
"$",
"this",
"->",
"filesHandlers",
";",
"if",
"(",
"null",
"===",
"$",
"filesHandlers",
")",
"{",
"$",
"filesHandlers",
"=",
"new",
"FilesHandlers",
"(",
"null",
")",
";",
"}",
"return",
"new",
"FileStream",
"(",
"$",
"resource",
",",
"$",
"filesHandlers",
")",
";",
"}",
"throw",
"new",
"UnknownResourceException",
"(",
"$",
"resource",
")",
";",
"}"
] | Resolve a config resource to a valid StreamInterface
@param mixed $resource
@return Stream
@throws UnknownResourceException | [
"Resolve",
"a",
"config",
"resource",
"to",
"a",
"valid",
"StreamInterface"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Config/ConfigResolver.php#L49-L73 |
28,192 | milejko/mmi | src/Mmi/Mvc/Dispatcher.php | Dispatcher.routeStartup | public function routeStartup()
{
//iteracja po pluginach
foreach (FrontController::getInstance()->getPlugins() as $plugin) {
//wykonywanie routeStartup() na kolejnych pluginach
$plugin->routeStartup(FrontController::getInstance()->getRequest());
}
//profiler
FrontController::getInstance()->getProfiler()->event('Mvc\Dispatcher: plugins route startup');
} | php | public function routeStartup()
{
//iteracja po pluginach
foreach (FrontController::getInstance()->getPlugins() as $plugin) {
//wykonywanie routeStartup() na kolejnych pluginach
$plugin->routeStartup(FrontController::getInstance()->getRequest());
}
//profiler
FrontController::getInstance()->getProfiler()->event('Mvc\Dispatcher: plugins route startup');
} | [
"public",
"function",
"routeStartup",
"(",
")",
"{",
"//iteracja po pluginach",
"foreach",
"(",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getPlugins",
"(",
")",
"as",
"$",
"plugin",
")",
"{",
"//wykonywanie routeStartup() na kolejnych pluginach",
"$",
"plugin",
"->",
"routeStartup",
"(",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getRequest",
"(",
")",
")",
";",
"}",
"//profiler",
"FrontController",
"::",
"getInstance",
"(",
")",
"->",
"getProfiler",
"(",
")",
"->",
"event",
"(",
"'Mvc\\Dispatcher: plugins route startup'",
")",
";",
"}"
] | Uruchamianie metody routeStartup na zarejestrowanych pluginach | [
"Uruchamianie",
"metody",
"routeStartup",
"na",
"zarejestrowanych",
"pluginach"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/Dispatcher.php#L24-L33 |
28,193 | honeybee/honeybee | src/Infrastructure/Filesystem/FilesystemService.php | FilesystemService.generatePath | public static function generatePath(
AttributeInterface $attribute,
$additional_prefix = '',
$extension = '',
$uuid = null
) {
$uuid = $uuid ? UuidGenerator::fromString($uuid) : UuidGenerator::uuid4();
$uuid_string = $uuid->toString();
$uuid_parts = $uuid->getClockSeqLow(); // 8 bit int => 256 folders
$root_type = $attribute->getRootType();
$root_type_name = $root_type->getName();
if ($root_type instanceof EntityTypeInterface) {
$root_type_name = $root_type->getPrefix();
}
$attribute_path = $attribute->getPath();
$identifier = '';
if (!empty($additional_prefix)) {
$identifier = $additional_prefix . '/';
}
$identifier .= sprintf('%s/%s/%s/%s', $root_type_name, $attribute_path, $uuid_parts, $uuid_string);
if (!empty($extension)) {
$identifier .= '.' . $extension;
}
return $identifier;
} | php | public static function generatePath(
AttributeInterface $attribute,
$additional_prefix = '',
$extension = '',
$uuid = null
) {
$uuid = $uuid ? UuidGenerator::fromString($uuid) : UuidGenerator::uuid4();
$uuid_string = $uuid->toString();
$uuid_parts = $uuid->getClockSeqLow(); // 8 bit int => 256 folders
$root_type = $attribute->getRootType();
$root_type_name = $root_type->getName();
if ($root_type instanceof EntityTypeInterface) {
$root_type_name = $root_type->getPrefix();
}
$attribute_path = $attribute->getPath();
$identifier = '';
if (!empty($additional_prefix)) {
$identifier = $additional_prefix . '/';
}
$identifier .= sprintf('%s/%s/%s/%s', $root_type_name, $attribute_path, $uuid_parts, $uuid_string);
if (!empty($extension)) {
$identifier .= '.' . $extension;
}
return $identifier;
} | [
"public",
"static",
"function",
"generatePath",
"(",
"AttributeInterface",
"$",
"attribute",
",",
"$",
"additional_prefix",
"=",
"''",
",",
"$",
"extension",
"=",
"''",
",",
"$",
"uuid",
"=",
"null",
")",
"{",
"$",
"uuid",
"=",
"$",
"uuid",
"?",
"UuidGenerator",
"::",
"fromString",
"(",
"$",
"uuid",
")",
":",
"UuidGenerator",
"::",
"uuid4",
"(",
")",
";",
"$",
"uuid_string",
"=",
"$",
"uuid",
"->",
"toString",
"(",
")",
";",
"$",
"uuid_parts",
"=",
"$",
"uuid",
"->",
"getClockSeqLow",
"(",
")",
";",
"// 8 bit int => 256 folders",
"$",
"root_type",
"=",
"$",
"attribute",
"->",
"getRootType",
"(",
")",
";",
"$",
"root_type_name",
"=",
"$",
"root_type",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"root_type",
"instanceof",
"EntityTypeInterface",
")",
"{",
"$",
"root_type_name",
"=",
"$",
"root_type",
"->",
"getPrefix",
"(",
")",
";",
"}",
"$",
"attribute_path",
"=",
"$",
"attribute",
"->",
"getPath",
"(",
")",
";",
"$",
"identifier",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"additional_prefix",
")",
")",
"{",
"$",
"identifier",
"=",
"$",
"additional_prefix",
".",
"'/'",
";",
"}",
"$",
"identifier",
".=",
"sprintf",
"(",
"'%s/%s/%s/%s'",
",",
"$",
"root_type_name",
",",
"$",
"attribute_path",
",",
"$",
"uuid_parts",
",",
"$",
"uuid_string",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"extension",
")",
")",
"{",
"$",
"identifier",
".=",
"'.'",
".",
"$",
"extension",
";",
"}",
"return",
"$",
"identifier",
";",
"}"
] | Generates a unique file identifier that may be used as a relative file path.
@param AttributeInterface $attribute attribute to generate a file identifier for
@param string $additional_prefix a string to add in front of the generated identifier
@param string $extension a (file) extension to append to the generated identifier (e.g. 'jpg')
@return string unique relative file path | [
"Generates",
"a",
"unique",
"file",
"identifier",
"that",
"may",
"be",
"used",
"as",
"a",
"relative",
"file",
"path",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Filesystem/FilesystemService.php#L291-L322 |
28,194 | honeybee/honeybee | src/Projection/ProjectionType.php | ProjectionType.createEntity | public function createEntity(array $data = [], EntityInterface $parent_entity = null, $apply_default_values = false)
{
return parent::createEntity($data, $parent_entity, true);
} | php | public function createEntity(array $data = [], EntityInterface $parent_entity = null, $apply_default_values = false)
{
return parent::createEntity($data, $parent_entity, true);
} | [
"public",
"function",
"createEntity",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"EntityInterface",
"$",
"parent_entity",
"=",
"null",
",",
"$",
"apply_default_values",
"=",
"false",
")",
"{",
"return",
"parent",
"::",
"createEntity",
"(",
"$",
"data",
",",
"$",
"parent_entity",
",",
"true",
")",
";",
"}"
] | Creates a new Projection instance.
@param array $data Optional data for initial hydration.
@param EntityInterface $parent_entity
@param boolean $apply_default_values
@return ProjectionInterface
@throws InvalidTypeException | [
"Creates",
"a",
"new",
"Projection",
"instance",
"."
] | 6e46b4f20a0b8a3ce686565440f739960e325a05 | https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Projection/ProjectionType.php#L61-L64 |
28,195 | peakphp/framework | src/Common/TextUtils.php | TextUtils.countWords | public static function countWords(string $text): int
{
// split text by ' ',\r,\n,\f,\t
$split_array = preg_split('/\s+/', $text);
// count matches that contain alphanumerics
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
return count($word_count);
} | php | public static function countWords(string $text): int
{
// split text by ' ',\r,\n,\f,\t
$split_array = preg_split('/\s+/', $text);
// count matches that contain alphanumerics
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
return count($word_count);
} | [
"public",
"static",
"function",
"countWords",
"(",
"string",
"$",
"text",
")",
":",
"int",
"{",
"// split text by ' ',\\r,\\n,\\f,\\t",
"$",
"split_array",
"=",
"preg_split",
"(",
"'/\\s+/'",
",",
"$",
"text",
")",
";",
"// count matches that contain alphanumerics",
"$",
"word_count",
"=",
"preg_grep",
"(",
"'/[a-zA-Z0-9\\\\x80-\\\\xff]/'",
",",
"$",
"split_array",
")",
";",
"return",
"count",
"(",
"$",
"word_count",
")",
";",
"}"
] | Count the number of words in a text
@param string $text
@return int | [
"Count",
"the",
"number",
"of",
"words",
"in",
"a",
"text"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TextUtils.php#L24-L32 |
28,196 | peakphp/framework | src/Common/TextUtils.php | TextUtils.countChars | public static function countChars(string $text, bool $includeSpaces = false): int
{
if ($includeSpaces === false) {
$text = preg_replace("/[\s]/", '', $text);
}
return mb_strlen($text);
} | php | public static function countChars(string $text, bool $includeSpaces = false): int
{
if ($includeSpaces === false) {
$text = preg_replace("/[\s]/", '', $text);
}
return mb_strlen($text);
} | [
"public",
"static",
"function",
"countChars",
"(",
"string",
"$",
"text",
",",
"bool",
"$",
"includeSpaces",
"=",
"false",
")",
":",
"int",
"{",
"if",
"(",
"$",
"includeSpaces",
"===",
"false",
")",
"{",
"$",
"text",
"=",
"preg_replace",
"(",
"\"/[\\s]/\"",
",",
"''",
",",
"$",
"text",
")",
";",
"}",
"return",
"mb_strlen",
"(",
"$",
"text",
")",
";",
"}"
] | Count the number of characters in a text
@param string $text
@param bool $includeSpaces
@return int | [
"Count",
"the",
"number",
"of",
"characters",
"in",
"a",
"text"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TextUtils.php#L51-L57 |
28,197 | peakphp/framework | src/Common/TextUtils.php | TextUtils.wordwrap | public static function wordwrap(string $string, int $length = 80, string $break = "\n", bool $cut = false): string
{
return wordwrap($string, $length, $break, $cut);
} | php | public static function wordwrap(string $string, int $length = 80, string $break = "\n", bool $cut = false): string
{
return wordwrap($string, $length, $break, $cut);
} | [
"public",
"static",
"function",
"wordwrap",
"(",
"string",
"$",
"string",
",",
"int",
"$",
"length",
"=",
"80",
",",
"string",
"$",
"break",
"=",
"\"\\n\"",
",",
"bool",
"$",
"cut",
"=",
"false",
")",
":",
"string",
"{",
"return",
"wordwrap",
"(",
"$",
"string",
",",
"$",
"length",
",",
"$",
"break",
",",
"$",
"cut",
")",
";",
"}"
] | Wrap a string of text at a given length
@param string $string
@param integer $length
@param string $break
@param bool $cut
@return string | [
"Wrap",
"a",
"string",
"of",
"text",
"at",
"a",
"given",
"length"
] | 412c13c2a0f165ee645eb3636f23a74a81429d3a | https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TextUtils.php#L106-L109 |
28,198 | milejko/mmi | src/Mmi/Mvc/RouterMatcher.php | RouterMatcher._routeMatch | protected function _routeMatch($matches)
{
if (isset($this->_tmpMatches[$matches[1]])) {
return $this->_tmpMatches[$matches[1]];
}
if (isset($this->_tmpDefault[$this->_tmpKey])) {
return $this->_tmpDefault[$this->_tmpKey];
}
throw new \Mmi\Mvc\MvcException('Router failed due to invalid route definition - no default param for key: ' . $this->_tmpKey);
} | php | protected function _routeMatch($matches)
{
if (isset($this->_tmpMatches[$matches[1]])) {
return $this->_tmpMatches[$matches[1]];
}
if (isset($this->_tmpDefault[$this->_tmpKey])) {
return $this->_tmpDefault[$this->_tmpKey];
}
throw new \Mmi\Mvc\MvcException('Router failed due to invalid route definition - no default param for key: ' . $this->_tmpKey);
} | [
"protected",
"function",
"_routeMatch",
"(",
"$",
"matches",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_tmpMatches",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_tmpMatches",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_tmpDefault",
"[",
"$",
"this",
"->",
"_tmpKey",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_tmpDefault",
"[",
"$",
"this",
"->",
"_tmpKey",
"]",
";",
"}",
"throw",
"new",
"\\",
"Mmi",
"\\",
"Mvc",
"\\",
"MvcException",
"(",
"'Router failed due to invalid route definition - no default param for key: '",
".",
"$",
"this",
"->",
"_tmpKey",
")",
";",
"}"
] | Callback dla zmieniania rout
@param array $matches dopasowania
@return mixed
@throws \Mmi\Mvc\MvcException | [
"Callback",
"dla",
"zmieniania",
"rout"
] | c1e8dddf83665ad3463ff801074aa2b0875db19b | https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/RouterMatcher.php#L137-L146 |
28,199 | boekkooi/TwigJackBundle | src/Twig/Loader/DoctrineLoader.php | DoctrineLoader.isLoadableTemplate | protected function isLoadableTemplate($name)
{
return !empty($name) && (empty($this->prefix) || strlen($name) > strlen($this->prefix) && strpos($name, $this->prefix) === 0);
} | php | protected function isLoadableTemplate($name)
{
return !empty($name) && (empty($this->prefix) || strlen($name) > strlen($this->prefix) && strpos($name, $this->prefix) === 0);
} | [
"protected",
"function",
"isLoadableTemplate",
"(",
"$",
"name",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"name",
")",
"&&",
"(",
"empty",
"(",
"$",
"this",
"->",
"prefix",
")",
"||",
"strlen",
"(",
"$",
"name",
")",
">",
"strlen",
"(",
"$",
"this",
"->",
"prefix",
")",
"&&",
"strpos",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"prefix",
")",
"===",
"0",
")",
";",
"}"
] | Check if the given name has the correct prefix for loading.
@param string $name The name of the template to check
@return bool | [
"Check",
"if",
"the",
"given",
"name",
"has",
"the",
"correct",
"prefix",
"for",
"loading",
"."
] | 8aa9fe7681eaabe6285aa76d0a52e9da4ff67ffa | https://github.com/boekkooi/TwigJackBundle/blob/8aa9fe7681eaabe6285aa76d0a52e9da4ff67ffa/src/Twig/Loader/DoctrineLoader.php#L100-L103 |
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.