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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,000 | hostnet/entity-plugin-lib | src/EntityPackage.php | EntityPackage.getFlattenedRequiredPackages | public function getFlattenedRequiredPackages()
{
$result = [];
foreach ($this->getRequiredPackages() as $dependency) {
$name = $dependency->getPackage()->getName();
$result[$name] = $dependency;
$result = array_merge($result, $dependency->getFlattenedRequiredPackages());
}
return $result;
} | php | public function getFlattenedRequiredPackages()
{
$result = [];
foreach ($this->getRequiredPackages() as $dependency) {
$name = $dependency->getPackage()->getName();
$result[$name] = $dependency;
$result = array_merge($result, $dependency->getFlattenedRequiredPackages());
}
return $result;
} | [
"public",
"function",
"getFlattenedRequiredPackages",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRequiredPackages",
"(",
")",
"as",
"$",
"dependency",
")",
"{",
"$",
"name",
"=",
"$",
"dependency",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"$",
"dependency",
";",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"dependency",
"->",
"getFlattenedRequiredPackages",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Flattens the dependency tree of this package.
All the packages it directly or indirectly references will be uniquely in this list.
@return EntityPackage[] | [
"Flattens",
"the",
"dependency",
"tree",
"of",
"this",
"package",
".",
"All",
"the",
"packages",
"it",
"directly",
"or",
"indirectly",
"references",
"will",
"be",
"uniquely",
"in",
"this",
"list",
"."
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/EntityPackage.php#L102-L111 |
30,001 | mmoreram/BaseBundle | DependencyInjection/SimpleBaseExtension.php | SimpleBaseExtension.getConfigurationInstance | protected function getConfigurationInstance(): ? ConfigurationInterface
{
return $this->mappingBagProvider
? new BaseConfiguration(
$this->getAlias(),
$this->mappingBagProvider
)
: null;
} | php | protected function getConfigurationInstance(): ? ConfigurationInterface
{
return $this->mappingBagProvider
? new BaseConfiguration(
$this->getAlias(),
$this->mappingBagProvider
)
: null;
} | [
"protected",
"function",
"getConfigurationInstance",
"(",
")",
":",
"?",
"ConfigurationInterface",
"{",
"return",
"$",
"this",
"->",
"mappingBagProvider",
"?",
"new",
"BaseConfiguration",
"(",
"$",
"this",
"->",
"getAlias",
"(",
")",
",",
"$",
"this",
"->",
"mappingBagProvider",
")",
":",
"null",
";",
"}"
] | Return a new Configuration instance.
If object returned by this method is an instance of
ConfigurationInterface, extension will use the Configuration to read all
bundle config definitions.
Also will call getParametrizationValues method to load some config values
to internal parameters.
@return ConfigurationInterface|null | [
"Return",
"a",
"new",
"Configuration",
"instance",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/SimpleBaseExtension.php#L132-L140 |
30,002 | rinvex/cortex-contacts | src/Http/Controllers/Adminarea/ContactsController.php | ContactsController.stash | public function stash(ImportFormRequest $request, Contact $contact, DefaultImporter $importer)
{
// Handle the import
$importer->config['resource'] = $contact;
$importer->handleImport();
} | php | public function stash(ImportFormRequest $request, Contact $contact, DefaultImporter $importer)
{
// Handle the import
$importer->config['resource'] = $contact;
$importer->handleImport();
} | [
"public",
"function",
"stash",
"(",
"ImportFormRequest",
"$",
"request",
",",
"Contact",
"$",
"contact",
",",
"DefaultImporter",
"$",
"importer",
")",
"{",
"// Handle the import",
"$",
"importer",
"->",
"config",
"[",
"'resource'",
"]",
"=",
"$",
"contact",
";",
"$",
"importer",
"->",
"handleImport",
"(",
")",
";",
"}"
] | Stash contacts.
@param \Cortex\Foundation\Http\Requests\ImportFormRequest $request
@param \Cortex\Foundation\Importers\DefaultImporter $importer
@return void | [
"Stash",
"contacts",
"."
] | d27aef100c442bd560809be5a6653737434b2e62 | https://github.com/rinvex/cortex-contacts/blob/d27aef100c442bd560809be5a6653737434b2e62/src/Http/Controllers/Adminarea/ContactsController.php#L83-L88 |
30,003 | mmoreram/BaseBundle | DependencyInjection/BaseConfiguration.php | BaseConfiguration.addMappingNode | protected function addMappingNode(
string $nodeName,
string $entityClass,
string $entityMappingFile,
string $entityManager,
bool $entityEnabled
): NodeDefinition {
$builder = new TreeBuilder();
$node = $builder->root($nodeName);
$node
->treatFalseLike([
'enabled' => false,
])
->addDefaultsIfNotSet()
->children()
->scalarNode('class')
->defaultValue($entityClass)
->cannotBeEmpty()
->end()
->scalarNode('mapping_file')
->defaultValue($entityMappingFile)
->cannotBeEmpty()
->end()
->scalarNode('manager')
->defaultValue($entityManager)
->cannotBeEmpty()
->end()
->booleanNode('enabled')
->defaultValue($entityEnabled)
->end()
->end()
->end();
return $node;
} | php | protected function addMappingNode(
string $nodeName,
string $entityClass,
string $entityMappingFile,
string $entityManager,
bool $entityEnabled
): NodeDefinition {
$builder = new TreeBuilder();
$node = $builder->root($nodeName);
$node
->treatFalseLike([
'enabled' => false,
])
->addDefaultsIfNotSet()
->children()
->scalarNode('class')
->defaultValue($entityClass)
->cannotBeEmpty()
->end()
->scalarNode('mapping_file')
->defaultValue($entityMappingFile)
->cannotBeEmpty()
->end()
->scalarNode('manager')
->defaultValue($entityManager)
->cannotBeEmpty()
->end()
->booleanNode('enabled')
->defaultValue($entityEnabled)
->end()
->end()
->end();
return $node;
} | [
"protected",
"function",
"addMappingNode",
"(",
"string",
"$",
"nodeName",
",",
"string",
"$",
"entityClass",
",",
"string",
"$",
"entityMappingFile",
",",
"string",
"$",
"entityManager",
",",
"bool",
"$",
"entityEnabled",
")",
":",
"NodeDefinition",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"$",
"nodeName",
")",
";",
"$",
"node",
"->",
"treatFalseLike",
"(",
"[",
"'enabled'",
"=>",
"false",
",",
"]",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'class'",
")",
"->",
"defaultValue",
"(",
"$",
"entityClass",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'mapping_file'",
")",
"->",
"defaultValue",
"(",
"$",
"entityMappingFile",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'manager'",
")",
"->",
"defaultValue",
"(",
"$",
"entityManager",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"end",
"(",
")",
"->",
"booleanNode",
"(",
"'enabled'",
")",
"->",
"defaultValue",
"(",
"$",
"entityEnabled",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] | Add a mapping node into configuration.
@param string $nodeName
@param string $entityClass
@param string $entityMappingFile
@param string $entityManager
@param bool $entityEnabled
@return NodeDefinition Node | [
"Add",
"a",
"mapping",
"node",
"into",
"configuration",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseConfiguration.php#L101-L135 |
30,004 | mmoreram/BaseBundle | DependencyInjection/BaseConfiguration.php | BaseConfiguration.addDetectedMappingNodes | private function addDetectedMappingNodes(
ArrayNodeDefinition $rootNode,
MappingBagCollection $mappingBagCollection
) {
$mappingNode = $rootNode
->children()
->arrayNode('mapping')
->addDefaultsIfNotSet()
->children();
foreach ($mappingBagCollection->all() as $mappingBag) {
if ($mappingBag->isOverwritable()) {
$mappingNode->append($this->addMappingNode(
$mappingBag->getEntityName(),
$mappingBag->getEntityNamespace(),
$mappingBag->getEntityMappingFilePath(),
$mappingBag->getManagerName(),
$mappingBag->getEntityIsEnabled()
));
}
}
} | php | private function addDetectedMappingNodes(
ArrayNodeDefinition $rootNode,
MappingBagCollection $mappingBagCollection
) {
$mappingNode = $rootNode
->children()
->arrayNode('mapping')
->addDefaultsIfNotSet()
->children();
foreach ($mappingBagCollection->all() as $mappingBag) {
if ($mappingBag->isOverwritable()) {
$mappingNode->append($this->addMappingNode(
$mappingBag->getEntityName(),
$mappingBag->getEntityNamespace(),
$mappingBag->getEntityMappingFilePath(),
$mappingBag->getManagerName(),
$mappingBag->getEntityIsEnabled()
));
}
}
} | [
"private",
"function",
"addDetectedMappingNodes",
"(",
"ArrayNodeDefinition",
"$",
"rootNode",
",",
"MappingBagCollection",
"$",
"mappingBagCollection",
")",
"{",
"$",
"mappingNode",
"=",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'mapping'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
";",
"foreach",
"(",
"$",
"mappingBagCollection",
"->",
"all",
"(",
")",
"as",
"$",
"mappingBag",
")",
"{",
"if",
"(",
"$",
"mappingBag",
"->",
"isOverwritable",
"(",
")",
")",
"{",
"$",
"mappingNode",
"->",
"append",
"(",
"$",
"this",
"->",
"addMappingNode",
"(",
"$",
"mappingBag",
"->",
"getEntityName",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getEntityNamespace",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getEntityMappingFilePath",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getManagerName",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getEntityIsEnabled",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] | Add all mapping nodes injected in the mappingBagCollection.
@param ArrayNodeDefinition $rootNode
@param MappingBagCollection $mappingBagCollection | [
"Add",
"all",
"mapping",
"nodes",
"injected",
"in",
"the",
"mappingBagCollection",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseConfiguration.php#L143-L164 |
30,005 | mmoreram/BaseBundle | Mapping/MappingBag.php | MappingBag.getParamFormat | public function getParamFormat(string $type): string
{
return ltrim(($this->containerPrefix.'.entity.'.$this->entityName.'.'.$type), '.');
} | php | public function getParamFormat(string $type): string
{
return ltrim(($this->containerPrefix.'.entity.'.$this->entityName.'.'.$type), '.');
} | [
"public",
"function",
"getParamFormat",
"(",
"string",
"$",
"type",
")",
":",
"string",
"{",
"return",
"ltrim",
"(",
"(",
"$",
"this",
"->",
"containerPrefix",
".",
"'.entity.'",
".",
"$",
"this",
"->",
"entityName",
".",
"'.'",
".",
"$",
"type",
")",
",",
"'.'",
")",
";",
"}"
] | Get entity parametrization by type.
@param string $type
@return string | [
"Get",
"entity",
"parametrization",
"by",
"type",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Mapping/MappingBag.php#L328-L331 |
30,006 | mmoreram/BaseBundle | Mapping/MappingBag.php | MappingBag.createReducedMappingBag | private function createReducedMappingBag(bool $isOverwritable): ReducedMappingBag
{
return new ReducedMappingBag(
$isOverwritable ? $this->getParamFormat('class') : $this->getEntityNamespace(),
$isOverwritable ? $this->getParamFormat('mapping_file') : $this->getEntityMappingFilePath(),
$isOverwritable ? $this->getParamFormat('manager') : $this->managerName,
$isOverwritable ? $this->getParamFormat('enabled') : $this->entityIsEnabled
);
} | php | private function createReducedMappingBag(bool $isOverwritable): ReducedMappingBag
{
return new ReducedMappingBag(
$isOverwritable ? $this->getParamFormat('class') : $this->getEntityNamespace(),
$isOverwritable ? $this->getParamFormat('mapping_file') : $this->getEntityMappingFilePath(),
$isOverwritable ? $this->getParamFormat('manager') : $this->managerName,
$isOverwritable ? $this->getParamFormat('enabled') : $this->entityIsEnabled
);
} | [
"private",
"function",
"createReducedMappingBag",
"(",
"bool",
"$",
"isOverwritable",
")",
":",
"ReducedMappingBag",
"{",
"return",
"new",
"ReducedMappingBag",
"(",
"$",
"isOverwritable",
"?",
"$",
"this",
"->",
"getParamFormat",
"(",
"'class'",
")",
":",
"$",
"this",
"->",
"getEntityNamespace",
"(",
")",
",",
"$",
"isOverwritable",
"?",
"$",
"this",
"->",
"getParamFormat",
"(",
"'mapping_file'",
")",
":",
"$",
"this",
"->",
"getEntityMappingFilePath",
"(",
")",
",",
"$",
"isOverwritable",
"?",
"$",
"this",
"->",
"getParamFormat",
"(",
"'manager'",
")",
":",
"$",
"this",
"->",
"managerName",
",",
"$",
"isOverwritable",
"?",
"$",
"this",
"->",
"getParamFormat",
"(",
"'enabled'",
")",
":",
"$",
"this",
"->",
"entityIsEnabled",
")",
";",
"}"
] | Create a new instance of ReducedMappingBag given the local information
stored.
@param bool $isOverwritable
@return ReducedMappingBag | [
"Create",
"a",
"new",
"instance",
"of",
"ReducedMappingBag",
"given",
"the",
"local",
"information",
"stored",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Mapping/MappingBag.php#L341-L349 |
30,007 | gyselroth/micro-auth | src/Adapter/Oidc.php | Oidc.getDiscoveryDocument | public function getDiscoveryDocument(): array
{
if ($apc = extension_loaded('apc') && apc_exists($this->provider_url)) {
return apc_get($this->provider_url);
}
$ch = curl_init();
$url = $this->getDiscoveryUrl();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$this->logger->debug('fetch openid-connect discovery document from ['.$url.']', [
'category' => get_class($this),
]);
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (200 === $code) {
$discovery = json_decode($result, true);
$this->logger->debug('received openid-connect discovery document from ['.$url.']', [
'category' => get_class($this),
'discovery' => $discovery,
]);
if (true === $apc) {
apc_store($this->provider_url, $discovery);
}
return $discovery;
}
$this->logger->error('failed to receive openid-connect discovery document from ['.$url.'], request ended with status ['.$code.']', [
'category' => get_class($this),
]);
throw new OidcException\DiscoveryNotFound('failed to get openid-connect discovery document');
} | php | public function getDiscoveryDocument(): array
{
if ($apc = extension_loaded('apc') && apc_exists($this->provider_url)) {
return apc_get($this->provider_url);
}
$ch = curl_init();
$url = $this->getDiscoveryUrl();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$this->logger->debug('fetch openid-connect discovery document from ['.$url.']', [
'category' => get_class($this),
]);
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if (200 === $code) {
$discovery = json_decode($result, true);
$this->logger->debug('received openid-connect discovery document from ['.$url.']', [
'category' => get_class($this),
'discovery' => $discovery,
]);
if (true === $apc) {
apc_store($this->provider_url, $discovery);
}
return $discovery;
}
$this->logger->error('failed to receive openid-connect discovery document from ['.$url.'], request ended with status ['.$code.']', [
'category' => get_class($this),
]);
throw new OidcException\DiscoveryNotFound('failed to get openid-connect discovery document');
} | [
"public",
"function",
"getDiscoveryDocument",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"apc",
"=",
"extension_loaded",
"(",
"'apc'",
")",
"&&",
"apc_exists",
"(",
"$",
"this",
"->",
"provider_url",
")",
")",
"{",
"return",
"apc_get",
"(",
"$",
"this",
"->",
"provider_url",
")",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getDiscoveryUrl",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'fetch openid-connect discovery document from ['",
".",
"$",
"url",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"code",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"200",
"===",
"$",
"code",
")",
"{",
"$",
"discovery",
"=",
"json_decode",
"(",
"$",
"result",
",",
"true",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'received openid-connect discovery document from ['",
".",
"$",
"url",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"'discovery'",
"=>",
"$",
"discovery",
",",
"]",
")",
";",
"if",
"(",
"true",
"===",
"$",
"apc",
")",
"{",
"apc_store",
"(",
"$",
"this",
"->",
"provider_url",
",",
"$",
"discovery",
")",
";",
"}",
"return",
"$",
"discovery",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"'failed to receive openid-connect discovery document from ['",
".",
"$",
"url",
".",
"'], request ended with status ['",
".",
"$",
"code",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"throw",
"new",
"OidcException",
"\\",
"DiscoveryNotFound",
"(",
"'failed to get openid-connect discovery document'",
")",
";",
"}"
] | Get discovery document.
@return array | [
"Get",
"discovery",
"document",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Adapter/Oidc.php#L154-L190 |
30,008 | gyselroth/micro-auth | src/Adapter/Oidc.php | Oidc.verifyToken | protected function verifyToken(string $token): bool
{
if ($this->token_validation_url) {
$this->logger->debug('validate oauth2 token via rfc7662 token validation endpoint ['.$this->token_validation_url.']', [
'category' => get_class($this),
]);
$url = str_replace('{token}', $token, $this->token_validation_url);
} else {
$discovery = $this->getDiscoveryDocument();
if (!(isset($discovery['userinfo_endpoint']))) {
throw new OidcException\UserEndpointNotSet('userinfo_endpoint could not be determained');
}
$this->logger->debug('validate token via openid-connect userinfo_endpoint ['.$discovery['userinfo_endpoint'].']', [
'category' => get_class($this),
]);
$url = $discovery['userinfo_endpoint'].'?access_token='.$token;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = json_decode($result, true);
if (200 === $code) {
$attributes = json_decode($result, true);
$this->logger->debug('successfully verified oauth2 access token via authorization server', [
'category' => get_class($this),
]);
if (!isset($attributes[$this->identity_attribute])) {
throw new Exception\IdentityAttributeNotFound('identity attribute '.$this->identity_attribute.' not found in oauth2 response');
}
$this->identifier = $attributes[$this->identity_attribute];
if ($this->token_validation_url) {
$this->attributes = $attributes;
} else {
$this->access_token = $token;
}
return true;
}
$this->logger->error('failed verify oauth2 access token via authorization server, received status ['.$code.']', [
'category' => get_class($this),
]);
throw new OidcException\InvalidAccessToken('failed verify oauth2 access token via authorization server');
} | php | protected function verifyToken(string $token): bool
{
if ($this->token_validation_url) {
$this->logger->debug('validate oauth2 token via rfc7662 token validation endpoint ['.$this->token_validation_url.']', [
'category' => get_class($this),
]);
$url = str_replace('{token}', $token, $this->token_validation_url);
} else {
$discovery = $this->getDiscoveryDocument();
if (!(isset($discovery['userinfo_endpoint']))) {
throw new OidcException\UserEndpointNotSet('userinfo_endpoint could not be determained');
}
$this->logger->debug('validate token via openid-connect userinfo_endpoint ['.$discovery['userinfo_endpoint'].']', [
'category' => get_class($this),
]);
$url = $discovery['userinfo_endpoint'].'?access_token='.$token;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$response = json_decode($result, true);
if (200 === $code) {
$attributes = json_decode($result, true);
$this->logger->debug('successfully verified oauth2 access token via authorization server', [
'category' => get_class($this),
]);
if (!isset($attributes[$this->identity_attribute])) {
throw new Exception\IdentityAttributeNotFound('identity attribute '.$this->identity_attribute.' not found in oauth2 response');
}
$this->identifier = $attributes[$this->identity_attribute];
if ($this->token_validation_url) {
$this->attributes = $attributes;
} else {
$this->access_token = $token;
}
return true;
}
$this->logger->error('failed verify oauth2 access token via authorization server, received status ['.$code.']', [
'category' => get_class($this),
]);
throw new OidcException\InvalidAccessToken('failed verify oauth2 access token via authorization server');
} | [
"protected",
"function",
"verifyToken",
"(",
"string",
"$",
"token",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"token_validation_url",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'validate oauth2 token via rfc7662 token validation endpoint ['",
".",
"$",
"this",
"->",
"token_validation_url",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"$",
"url",
"=",
"str_replace",
"(",
"'{token}'",
",",
"$",
"token",
",",
"$",
"this",
"->",
"token_validation_url",
")",
";",
"}",
"else",
"{",
"$",
"discovery",
"=",
"$",
"this",
"->",
"getDiscoveryDocument",
"(",
")",
";",
"if",
"(",
"!",
"(",
"isset",
"(",
"$",
"discovery",
"[",
"'userinfo_endpoint'",
"]",
")",
")",
")",
"{",
"throw",
"new",
"OidcException",
"\\",
"UserEndpointNotSet",
"(",
"'userinfo_endpoint could not be determained'",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'validate token via openid-connect userinfo_endpoint ['",
".",
"$",
"discovery",
"[",
"'userinfo_endpoint'",
"]",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"$",
"url",
"=",
"$",
"discovery",
"[",
"'userinfo_endpoint'",
"]",
".",
"'?access_token='",
".",
"$",
"token",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"code",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"result",
",",
"true",
")",
";",
"if",
"(",
"200",
"===",
"$",
"code",
")",
"{",
"$",
"attributes",
"=",
"json_decode",
"(",
"$",
"result",
",",
"true",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'successfully verified oauth2 access token via authorization server'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"$",
"this",
"->",
"identity_attribute",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"IdentityAttributeNotFound",
"(",
"'identity attribute '",
".",
"$",
"this",
"->",
"identity_attribute",
".",
"' not found in oauth2 response'",
")",
";",
"}",
"$",
"this",
"->",
"identifier",
"=",
"$",
"attributes",
"[",
"$",
"this",
"->",
"identity_attribute",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"token_validation_url",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"$",
"attributes",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"access_token",
"=",
"$",
"token",
";",
"}",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"'failed verify oauth2 access token via authorization server, received status ['",
".",
"$",
"code",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"throw",
"new",
"OidcException",
"\\",
"InvalidAccessToken",
"(",
"'failed verify oauth2 access token via authorization server'",
")",
";",
"}"
] | Token verification.
@param string $token
@return bool | [
"Token",
"verification",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Adapter/Oidc.php#L243-L297 |
30,009 | hostnet/entity-plugin-lib | src/ReflectionGenerator.php | ReflectionGenerator.generate | public function generate(PackageClass $package_class)
{
$parent = $this->getParentClass($package_class);
$class_name = $package_class->getShortName();
$generated_namespace = $package_class->getGeneratedNamespaceName();
$methods = $this->getMethods($package_class);
$params = [
'class_name' => $class_name,
'namespace' => $generated_namespace,
'methods' => $methods,
'parent' => $parent ? $parent->getShortName() : null,
];
$interface = $this->environment->render('interface.php.twig', $params);
$path = $package_class->getGeneratedDirectory();
$this->filesystem->dumpFile($path . $class_name . 'Interface.php', $interface);
} | php | public function generate(PackageClass $package_class)
{
$parent = $this->getParentClass($package_class);
$class_name = $package_class->getShortName();
$generated_namespace = $package_class->getGeneratedNamespaceName();
$methods = $this->getMethods($package_class);
$params = [
'class_name' => $class_name,
'namespace' => $generated_namespace,
'methods' => $methods,
'parent' => $parent ? $parent->getShortName() : null,
];
$interface = $this->environment->render('interface.php.twig', $params);
$path = $package_class->getGeneratedDirectory();
$this->filesystem->dumpFile($path . $class_name . 'Interface.php', $interface);
} | [
"public",
"function",
"generate",
"(",
"PackageClass",
"$",
"package_class",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParentClass",
"(",
"$",
"package_class",
")",
";",
"$",
"class_name",
"=",
"$",
"package_class",
"->",
"getShortName",
"(",
")",
";",
"$",
"generated_namespace",
"=",
"$",
"package_class",
"->",
"getGeneratedNamespaceName",
"(",
")",
";",
"$",
"methods",
"=",
"$",
"this",
"->",
"getMethods",
"(",
"$",
"package_class",
")",
";",
"$",
"params",
"=",
"[",
"'class_name'",
"=>",
"$",
"class_name",
",",
"'namespace'",
"=>",
"$",
"generated_namespace",
",",
"'methods'",
"=>",
"$",
"methods",
",",
"'parent'",
"=>",
"$",
"parent",
"?",
"$",
"parent",
"->",
"getShortName",
"(",
")",
":",
"null",
",",
"]",
";",
"$",
"interface",
"=",
"$",
"this",
"->",
"environment",
"->",
"render",
"(",
"'interface.php.twig'",
",",
"$",
"params",
")",
";",
"$",
"path",
"=",
"$",
"package_class",
"->",
"getGeneratedDirectory",
"(",
")",
";",
"$",
"this",
"->",
"filesystem",
"->",
"dumpFile",
"(",
"$",
"path",
".",
"$",
"class_name",
".",
"'Interface.php'",
",",
"$",
"interface",
")",
";",
"}"
] | Generates the interface
@param PackageClass $package_class
@throws Error | [
"Generates",
"the",
"interface"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/ReflectionGenerator.php#L38-L55 |
30,010 | hostnet/entity-plugin-lib | src/ReflectionGenerator.php | ReflectionGenerator.getMethods | protected function getMethods(PackageClass $package_class)
{
try {
$class = new \ReflectionClass($package_class->getName());
} catch (\ReflectionException $e) {
return [];
}
$methods = $class->getMethods();
foreach ($methods as $key => $method) {
if ($method->name === '__construct') {
// The interface should not contain the constructor
unset($methods[$key]);
continue;
}
$methods[$key] = new ReflectionMethod($method);
}
return $methods;
} | php | protected function getMethods(PackageClass $package_class)
{
try {
$class = new \ReflectionClass($package_class->getName());
} catch (\ReflectionException $e) {
return [];
}
$methods = $class->getMethods();
foreach ($methods as $key => $method) {
if ($method->name === '__construct') {
// The interface should not contain the constructor
unset($methods[$key]);
continue;
}
$methods[$key] = new ReflectionMethod($method);
}
return $methods;
} | [
"protected",
"function",
"getMethods",
"(",
"PackageClass",
"$",
"package_class",
")",
"{",
"try",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"package_class",
"->",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"methods",
"=",
"$",
"class",
"->",
"getMethods",
"(",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"key",
"=>",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"->",
"name",
"===",
"'__construct'",
")",
"{",
"// The interface should not contain the constructor",
"unset",
"(",
"$",
"methods",
"[",
"$",
"key",
"]",
")",
";",
"continue",
";",
"}",
"$",
"methods",
"[",
"$",
"key",
"]",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"method",
")",
";",
"}",
"return",
"$",
"methods",
";",
"}"
] | Which methods do we have to generate?
@return \ReflectionMethod[] | [
"Which",
"methods",
"do",
"we",
"have",
"to",
"generate?"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/ReflectionGenerator.php#L62-L81 |
30,011 | hostnet/entity-plugin-lib | src/ReflectionGenerator.php | ReflectionGenerator.getParentClass | protected function getParentClass(PackageClass $package_class)
{
try {
$base_class = new \ReflectionClass($package_class->getName());
} catch (\ReflectionException $e) {
return null;
}
if (false === ($parent_reflection = $base_class->getParentClass())
|| dirname($parent_reflection->getFileName()) !== dirname($base_class->getFileName())
) {
return null;
}
return new PackageClass($parent_reflection->getName(), $parent_reflection->getFileName());
} | php | protected function getParentClass(PackageClass $package_class)
{
try {
$base_class = new \ReflectionClass($package_class->getName());
} catch (\ReflectionException $e) {
return null;
}
if (false === ($parent_reflection = $base_class->getParentClass())
|| dirname($parent_reflection->getFileName()) !== dirname($base_class->getFileName())
) {
return null;
}
return new PackageClass($parent_reflection->getName(), $parent_reflection->getFileName());
} | [
"protected",
"function",
"getParentClass",
"(",
"PackageClass",
"$",
"package_class",
")",
"{",
"try",
"{",
"$",
"base_class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"package_class",
"->",
"getName",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"false",
"===",
"(",
"$",
"parent_reflection",
"=",
"$",
"base_class",
"->",
"getParentClass",
"(",
")",
")",
"||",
"dirname",
"(",
"$",
"parent_reflection",
"->",
"getFileName",
"(",
")",
")",
"!==",
"dirname",
"(",
"$",
"base_class",
"->",
"getFileName",
"(",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"PackageClass",
"(",
"$",
"parent_reflection",
"->",
"getName",
"(",
")",
",",
"$",
"parent_reflection",
"->",
"getFileName",
"(",
")",
")",
";",
"}"
] | Get the Parent of the given base class, if any.
@param PackageClass $package_class the base for which the parent needs to be extracted.
@return NULL|\Hostnet\Component\EntityPlugin\PackageClass the parent class if any, otherwise null is returned. | [
"Get",
"the",
"Parent",
"of",
"the",
"given",
"base",
"class",
"if",
"any",
"."
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/ReflectionGenerator.php#L89-L103 |
30,012 | PackageFactory/atomic-fusion-proptypes | Classes/Error/ExceptionHandler/PropTypeExceptionHandler.php | PropTypeExceptionHandler.handleRenderingException | public function handleRenderingException($fusionPath, \Exception $exception)
{
if ($exception instanceof PropTypeException) {
return $this->handlePropTypeException($fusionPath, $exception, $exception->getReferenceCode());
} else {
parent::handleRenderingException($fusionPath, $exception);
}
} | php | public function handleRenderingException($fusionPath, \Exception $exception)
{
if ($exception instanceof PropTypeException) {
return $this->handlePropTypeException($fusionPath, $exception, $exception->getReferenceCode());
} else {
parent::handleRenderingException($fusionPath, $exception);
}
} | [
"public",
"function",
"handleRenderingException",
"(",
"$",
"fusionPath",
",",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"PropTypeException",
")",
"{",
"return",
"$",
"this",
"->",
"handlePropTypeException",
"(",
"$",
"fusionPath",
",",
"$",
"exception",
",",
"$",
"exception",
"->",
"getReferenceCode",
"(",
")",
")",
";",
"}",
"else",
"{",
"parent",
"::",
"handleRenderingException",
"(",
"$",
"fusionPath",
",",
"$",
"exception",
")",
";",
"}",
"}"
] | In all aspects other than handling of PropTypeException this behaves
exactly as the BubblingHandler which is the internal fusion exception handler
by default.
@param array $fusionPath
@param \Exception $exception
@return string
@throws \Neos\Flow\Configuration\Exception\InvalidConfigurationException
@throws \Neos\Flow\Mvc\Exception\StopActionException | [
"In",
"all",
"aspects",
"other",
"than",
"handling",
"of",
"PropTypeException",
"this",
"behaves",
"exactly",
"as",
"the",
"BubblingHandler",
"which",
"is",
"the",
"internal",
"fusion",
"exception",
"handler",
"by",
"default",
"."
] | cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c | https://github.com/PackageFactory/atomic-fusion-proptypes/blob/cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c/Classes/Error/ExceptionHandler/PropTypeExceptionHandler.php#L46-L53 |
30,013 | mmoreram/BaseBundle | BaseBundle.php | BaseBundle.registerCommands | public function registerCommands(Application $application)
{
foreach ($this->getCommands() as $command) {
$application->add($command);
}
} | php | public function registerCommands(Application $application)
{
foreach ($this->getCommands() as $command) {
$application->add($command);
}
} | [
"public",
"function",
"registerCommands",
"(",
"Application",
"$",
"application",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getCommands",
"(",
")",
"as",
"$",
"command",
")",
"{",
"$",
"application",
"->",
"add",
"(",
"$",
"command",
")",
";",
"}",
"}"
] | Register Commands.
@param Application $application | [
"Register",
"Commands",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/BaseBundle.php#L67-L72 |
30,014 | mirko-pagliai/cakephp-link-scanner | src/Command/LinkScannerCommand.php | LinkScannerCommand.execute | public function execute(Arguments $args, ConsoleIo $io)
{
try {
//Will trigger events provided by `LinkScannerCommandEventListener`
$this->LinkScanner->getEventManager()->on(new LinkScannerCommandEventListener($args, $io));
if ($args->getOption('follow-redirects')) {
$this->LinkScanner->setConfig('followRedirects', true);
}
if ($args->getOption('force')) {
$this->LinkScanner->setConfig('lockFile', false);
}
if ($args->hasOption('full-base-url')) {
$this->LinkScanner->setConfig('fullBaseUrl', $args->getOption('full-base-url'));
}
if ($args->hasOption('max-depth')) {
$this->LinkScanner->setConfig('maxDepth', $args->getOption('max-depth'));
}
if ($args->getOption('no-cache')) {
$this->LinkScanner->setConfig('cache', false);
}
if ($args->getOption('no-external-links')) {
$this->LinkScanner->setConfig('externalLinks', false);
}
if ($args->hasOption('timeout')) {
$this->LinkScanner->Client->setConfig('timeout', $args->getOption('timeout'));
}
$this->LinkScanner->scan();
if ($args->getOption('export-with-filename') || $args->getOption('export')) {
$this->LinkScanner->export($args->getOption('export-with-filename'));
}
} catch (Exception $e) {
$io->error($e->getMessage());
$this->abort();
}
return null;
} | php | public function execute(Arguments $args, ConsoleIo $io)
{
try {
//Will trigger events provided by `LinkScannerCommandEventListener`
$this->LinkScanner->getEventManager()->on(new LinkScannerCommandEventListener($args, $io));
if ($args->getOption('follow-redirects')) {
$this->LinkScanner->setConfig('followRedirects', true);
}
if ($args->getOption('force')) {
$this->LinkScanner->setConfig('lockFile', false);
}
if ($args->hasOption('full-base-url')) {
$this->LinkScanner->setConfig('fullBaseUrl', $args->getOption('full-base-url'));
}
if ($args->hasOption('max-depth')) {
$this->LinkScanner->setConfig('maxDepth', $args->getOption('max-depth'));
}
if ($args->getOption('no-cache')) {
$this->LinkScanner->setConfig('cache', false);
}
if ($args->getOption('no-external-links')) {
$this->LinkScanner->setConfig('externalLinks', false);
}
if ($args->hasOption('timeout')) {
$this->LinkScanner->Client->setConfig('timeout', $args->getOption('timeout'));
}
$this->LinkScanner->scan();
if ($args->getOption('export-with-filename') || $args->getOption('export')) {
$this->LinkScanner->export($args->getOption('export-with-filename'));
}
} catch (Exception $e) {
$io->error($e->getMessage());
$this->abort();
}
return null;
} | [
"public",
"function",
"execute",
"(",
"Arguments",
"$",
"args",
",",
"ConsoleIo",
"$",
"io",
")",
"{",
"try",
"{",
"//Will trigger events provided by `LinkScannerCommandEventListener`",
"$",
"this",
"->",
"LinkScanner",
"->",
"getEventManager",
"(",
")",
"->",
"on",
"(",
"new",
"LinkScannerCommandEventListener",
"(",
"$",
"args",
",",
"$",
"io",
")",
")",
";",
"if",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'follow-redirects'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"setConfig",
"(",
"'followRedirects'",
",",
"true",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'force'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"setConfig",
"(",
"'lockFile'",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"hasOption",
"(",
"'full-base-url'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"setConfig",
"(",
"'fullBaseUrl'",
",",
"$",
"args",
"->",
"getOption",
"(",
"'full-base-url'",
")",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"hasOption",
"(",
"'max-depth'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"setConfig",
"(",
"'maxDepth'",
",",
"$",
"args",
"->",
"getOption",
"(",
"'max-depth'",
")",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'no-cache'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"setConfig",
"(",
"'cache'",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'no-external-links'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"setConfig",
"(",
"'externalLinks'",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"args",
"->",
"hasOption",
"(",
"'timeout'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"Client",
"->",
"setConfig",
"(",
"'timeout'",
",",
"$",
"args",
"->",
"getOption",
"(",
"'timeout'",
")",
")",
";",
"}",
"$",
"this",
"->",
"LinkScanner",
"->",
"scan",
"(",
")",
";",
"if",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'export-with-filename'",
")",
"||",
"$",
"args",
"->",
"getOption",
"(",
"'export'",
")",
")",
"{",
"$",
"this",
"->",
"LinkScanner",
"->",
"export",
"(",
"$",
"args",
"->",
"getOption",
"(",
"'export-with-filename'",
")",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"io",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"abort",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Performs a complete scan
@param Arguments $args The command arguments
@param ConsoleIo $io The console io
@return null|int The exit code or null for success
@see LinkScannerCommandEventListener::implementedEvents()
@uses $LinkScanner | [
"Performs",
"a",
"complete",
"scan"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Command/LinkScannerCommand.php#L51-L90 |
30,015 | PackageFactory/atomic-fusion-proptypes | Classes/Validators/InstanceOfValidator.php | InstanceOfValidator.isValid | protected function isValid($value)
{
if (is_null($value)) {
return;
} elseif ($value) {
$context = [$value];
} else {
$context = [];
}
$q = new FlowQuery($context);
if ($q->is('[instanceof ' . $this->options['type'] . ']')) {
return;
}
$this->addError('The value is expected to satisfy the %s flowQuery condition.', 1515144113, [
$this->options['type']
]);
} | php | protected function isValid($value)
{
if (is_null($value)) {
return;
} elseif ($value) {
$context = [$value];
} else {
$context = [];
}
$q = new FlowQuery($context);
if ($q->is('[instanceof ' . $this->options['type'] . ']')) {
return;
}
$this->addError('The value is expected to satisfy the %s flowQuery condition.', 1515144113, [
$this->options['type']
]);
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"elseif",
"(",
"$",
"value",
")",
"{",
"$",
"context",
"=",
"[",
"$",
"value",
"]",
";",
"}",
"else",
"{",
"$",
"context",
"=",
"[",
"]",
";",
"}",
"$",
"q",
"=",
"new",
"FlowQuery",
"(",
"$",
"context",
")",
";",
"if",
"(",
"$",
"q",
"->",
"is",
"(",
"'[instanceof '",
".",
"$",
"this",
"->",
"options",
"[",
"'type'",
"]",
".",
"']'",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"addError",
"(",
"'The value is expected to satisfy the %s flowQuery condition.'",
",",
"1515144113",
",",
"[",
"$",
"this",
"->",
"options",
"[",
"'type'",
"]",
"]",
")",
";",
"}"
] | Checks if the given value is a valid via FlowQuery.
@param mixed $value The value that should be validated
@return void | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"via",
"FlowQuery",
"."
] | cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c | https://github.com/PackageFactory/atomic-fusion-proptypes/blob/cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c/Classes/Validators/InstanceOfValidator.php#L28-L47 |
30,016 | hiqdev/hiapi | src/console/QueueController.php | QueueController.requeue | private function requeue(string $queueName, AMQPMessage $msg, NotProcessableException $exception): void
{
$tries = 0;
$headers = $msg->get_properties()['application_headers'];
if ($headers instanceof AMQPTable) {
$tries = $headers->getNativeData()['x-number-of-tries'] ?? 0;
}
if ($exception->getMaxTries() !== null && $tries >= $exception->getMaxTries()) {
$this->logger->debug('No tries left for message. Marking it as an error', ['message' => $msg, 'exception' => $exception]);
$this->handleError($queueName, $msg, $exception);
return;
}
// Init delay exchange
$channel = $this->amqp->channel();
$delayExchange = "$queueName.delayed";
$channel->exchange_declare($delayExchange, 'x-delayed-message', false, true, true, false, false, new AMQPTable([
'x-delayed-type' => 'direct',
]));
$channel->queue_bind($queueName, $delayExchange);
// Send message
$delayDuration = 1000 * $exception->getSecondsBeforeRetry() * (int)pow($exception->getProgressionMultiplier(), $tries);
$delayMessage = new AMQPMessage($msg->getBody(), array_merge($msg->get_properties(), [
'application_headers' => new AMQPTable([
'x-delay' => $delayDuration,
'x-number-of-tries' => $tries + 1,
]),
]));
$channel->basic_publish($delayMessage, $delayExchange, '');
$this->logger->debug('Delayed message for ' . $delayDuration, ['message' => $msg, 'exception' => $exception]);
} | php | private function requeue(string $queueName, AMQPMessage $msg, NotProcessableException $exception): void
{
$tries = 0;
$headers = $msg->get_properties()['application_headers'];
if ($headers instanceof AMQPTable) {
$tries = $headers->getNativeData()['x-number-of-tries'] ?? 0;
}
if ($exception->getMaxTries() !== null && $tries >= $exception->getMaxTries()) {
$this->logger->debug('No tries left for message. Marking it as an error', ['message' => $msg, 'exception' => $exception]);
$this->handleError($queueName, $msg, $exception);
return;
}
// Init delay exchange
$channel = $this->amqp->channel();
$delayExchange = "$queueName.delayed";
$channel->exchange_declare($delayExchange, 'x-delayed-message', false, true, true, false, false, new AMQPTable([
'x-delayed-type' => 'direct',
]));
$channel->queue_bind($queueName, $delayExchange);
// Send message
$delayDuration = 1000 * $exception->getSecondsBeforeRetry() * (int)pow($exception->getProgressionMultiplier(), $tries);
$delayMessage = new AMQPMessage($msg->getBody(), array_merge($msg->get_properties(), [
'application_headers' => new AMQPTable([
'x-delay' => $delayDuration,
'x-number-of-tries' => $tries + 1,
]),
]));
$channel->basic_publish($delayMessage, $delayExchange, '');
$this->logger->debug('Delayed message for ' . $delayDuration, ['message' => $msg, 'exception' => $exception]);
} | [
"private",
"function",
"requeue",
"(",
"string",
"$",
"queueName",
",",
"AMQPMessage",
"$",
"msg",
",",
"NotProcessableException",
"$",
"exception",
")",
":",
"void",
"{",
"$",
"tries",
"=",
"0",
";",
"$",
"headers",
"=",
"$",
"msg",
"->",
"get_properties",
"(",
")",
"[",
"'application_headers'",
"]",
";",
"if",
"(",
"$",
"headers",
"instanceof",
"AMQPTable",
")",
"{",
"$",
"tries",
"=",
"$",
"headers",
"->",
"getNativeData",
"(",
")",
"[",
"'x-number-of-tries'",
"]",
"??",
"0",
";",
"}",
"if",
"(",
"$",
"exception",
"->",
"getMaxTries",
"(",
")",
"!==",
"null",
"&&",
"$",
"tries",
">=",
"$",
"exception",
"->",
"getMaxTries",
"(",
")",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'No tries left for message. Marking it as an error'",
",",
"[",
"'message'",
"=>",
"$",
"msg",
",",
"'exception'",
"=>",
"$",
"exception",
"]",
")",
";",
"$",
"this",
"->",
"handleError",
"(",
"$",
"queueName",
",",
"$",
"msg",
",",
"$",
"exception",
")",
";",
"return",
";",
"}",
"// Init delay exchange",
"$",
"channel",
"=",
"$",
"this",
"->",
"amqp",
"->",
"channel",
"(",
")",
";",
"$",
"delayExchange",
"=",
"\"$queueName.delayed\"",
";",
"$",
"channel",
"->",
"exchange_declare",
"(",
"$",
"delayExchange",
",",
"'x-delayed-message'",
",",
"false",
",",
"true",
",",
"true",
",",
"false",
",",
"false",
",",
"new",
"AMQPTable",
"(",
"[",
"'x-delayed-type'",
"=>",
"'direct'",
",",
"]",
")",
")",
";",
"$",
"channel",
"->",
"queue_bind",
"(",
"$",
"queueName",
",",
"$",
"delayExchange",
")",
";",
"// Send message",
"$",
"delayDuration",
"=",
"1000",
"*",
"$",
"exception",
"->",
"getSecondsBeforeRetry",
"(",
")",
"*",
"(",
"int",
")",
"pow",
"(",
"$",
"exception",
"->",
"getProgressionMultiplier",
"(",
")",
",",
"$",
"tries",
")",
";",
"$",
"delayMessage",
"=",
"new",
"AMQPMessage",
"(",
"$",
"msg",
"->",
"getBody",
"(",
")",
",",
"array_merge",
"(",
"$",
"msg",
"->",
"get_properties",
"(",
")",
",",
"[",
"'application_headers'",
"=>",
"new",
"AMQPTable",
"(",
"[",
"'x-delay'",
"=>",
"$",
"delayDuration",
",",
"'x-number-of-tries'",
"=>",
"$",
"tries",
"+",
"1",
",",
"]",
")",
",",
"]",
")",
")",
";",
"$",
"channel",
"->",
"basic_publish",
"(",
"$",
"delayMessage",
",",
"$",
"delayExchange",
",",
"''",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Delayed message for '",
".",
"$",
"delayDuration",
",",
"[",
"'message'",
"=>",
"$",
"msg",
",",
"'exception'",
"=>",
"$",
"exception",
"]",
")",
";",
"}"
] | Resends message to queue with a delay
@param string $queueName
@param AMQPMessage $msg
@param NotProcessableException $exception | [
"Resends",
"message",
"to",
"queue",
"with",
"a",
"delay"
] | 2b3b334b247f69068b1f21b19e8ea013b1bae947 | https://github.com/hiqdev/hiapi/blob/2b3b334b247f69068b1f21b19e8ea013b1bae947/src/console/QueueController.php#L139-L171 |
30,017 | rinvex/cortex-contacts | src/Http/Controllers/Managerarea/ContactsController.php | ContactsController.destroy | public function destroy(Contact $contact)
{
$contact->delete();
return intend([
'url' => route('managerarea.contacts.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/contacts::common.contact'), 'identifier' => $contact->full_name])],
]);
} | php | public function destroy(Contact $contact)
{
$contact->delete();
return intend([
'url' => route('managerarea.contacts.index'),
'with' => ['warning' => trans('cortex/foundation::messages.resource_deleted', ['resource' => trans('cortex/contacts::common.contact'), 'identifier' => $contact->full_name])],
]);
} | [
"public",
"function",
"destroy",
"(",
"Contact",
"$",
"contact",
")",
"{",
"$",
"contact",
"->",
"delete",
"(",
")",
";",
"return",
"intend",
"(",
"[",
"'url'",
"=>",
"route",
"(",
"'managerarea.contacts.index'",
")",
",",
"'with'",
"=>",
"[",
"'warning'",
"=>",
"trans",
"(",
"'cortex/foundation::messages.resource_deleted'",
",",
"[",
"'resource'",
"=>",
"trans",
"(",
"'cortex/contacts::common.contact'",
")",
",",
"'identifier'",
"=>",
"$",
"contact",
"->",
"full_name",
"]",
")",
"]",
",",
"]",
")",
";",
"}"
] | Destroy given contact.
@param \Cortex\Contacts\Models\Contact $contact
@throws \Exception
@return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse | [
"Destroy",
"given",
"contact",
"."
] | d27aef100c442bd560809be5a6653737434b2e62 | https://github.com/rinvex/cortex-contacts/blob/d27aef100c442bd560809be5a6653737434b2e62/src/Http/Controllers/Managerarea/ContactsController.php#L218-L226 |
30,018 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner._createLockFile | protected function _createLockFile()
{
is_true_or_fail(!$this->getConfig('lockFile') || !file_exists($this->lockFile), __d(
'link-scanner',
'Lock file `{0}` already exists, maybe a scan is already in progress. If not, remove it manually',
$this->lockFile
), RuntimeException::class);
return $this->getConfig('lockFile') ? new File($this->lockFile, true) !== false : true;
} | php | protected function _createLockFile()
{
is_true_or_fail(!$this->getConfig('lockFile') || !file_exists($this->lockFile), __d(
'link-scanner',
'Lock file `{0}` already exists, maybe a scan is already in progress. If not, remove it manually',
$this->lockFile
), RuntimeException::class);
return $this->getConfig('lockFile') ? new File($this->lockFile, true) !== false : true;
} | [
"protected",
"function",
"_createLockFile",
"(",
")",
"{",
"is_true_or_fail",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'lockFile'",
")",
"||",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"lockFile",
")",
",",
"__d",
"(",
"'link-scanner'",
",",
"'Lock file `{0}` already exists, maybe a scan is already in progress. If not, remove it manually'",
",",
"$",
"this",
"->",
"lockFile",
")",
",",
"RuntimeException",
"::",
"class",
")",
";",
"return",
"$",
"this",
"->",
"getConfig",
"(",
"'lockFile'",
")",
"?",
"new",
"File",
"(",
"$",
"this",
"->",
"lockFile",
",",
"true",
")",
"!==",
"false",
":",
"true",
";",
"}"
] | Internal method to create a lock file
@return bool
@throws RuntimeException
@uses $lockFile | [
"Internal",
"method",
"to",
"create",
"a",
"lock",
"file"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L142-L151 |
30,019 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner._getResponse | protected function _getResponse($url)
{
$this->alreadyScanned[] = $url;
$cacheKey = sprintf('response_%s', md5(serialize($url)));
$response = $this->getConfig('cache') ? Cache::read($cacheKey, 'LinkScanner') : null;
if ($response && is_array($response)) {
list($response, $body) = $response;
$stream = new Stream('php://memory', 'wb+');
$stream->write($body);
$stream->rewind();
$response = $response->withBody($stream);
}
if (!$response instanceof Response) {
try {
$response = $this->Client->get($url);
if ($this->getConfig('cache') && ($response->isOk() || $response->isRedirect())) {
Cache::write($cacheKey, [$response, (string)$response->getBody()], 'LinkScanner');
}
} catch (Exception $e) {
$response = (new Response)->withStatus(404);
}
}
return $response;
} | php | protected function _getResponse($url)
{
$this->alreadyScanned[] = $url;
$cacheKey = sprintf('response_%s', md5(serialize($url)));
$response = $this->getConfig('cache') ? Cache::read($cacheKey, 'LinkScanner') : null;
if ($response && is_array($response)) {
list($response, $body) = $response;
$stream = new Stream('php://memory', 'wb+');
$stream->write($body);
$stream->rewind();
$response = $response->withBody($stream);
}
if (!$response instanceof Response) {
try {
$response = $this->Client->get($url);
if ($this->getConfig('cache') && ($response->isOk() || $response->isRedirect())) {
Cache::write($cacheKey, [$response, (string)$response->getBody()], 'LinkScanner');
}
} catch (Exception $e) {
$response = (new Response)->withStatus(404);
}
}
return $response;
} | [
"protected",
"function",
"_getResponse",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"alreadyScanned",
"[",
"]",
"=",
"$",
"url",
";",
"$",
"cacheKey",
"=",
"sprintf",
"(",
"'response_%s'",
",",
"md5",
"(",
"serialize",
"(",
"$",
"url",
")",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'cache'",
")",
"?",
"Cache",
"::",
"read",
"(",
"$",
"cacheKey",
",",
"'LinkScanner'",
")",
":",
"null",
";",
"if",
"(",
"$",
"response",
"&&",
"is_array",
"(",
"$",
"response",
")",
")",
"{",
"list",
"(",
"$",
"response",
",",
"$",
"body",
")",
"=",
"$",
"response",
";",
"$",
"stream",
"=",
"new",
"Stream",
"(",
"'php://memory'",
",",
"'wb+'",
")",
";",
"$",
"stream",
"->",
"write",
"(",
"$",
"body",
")",
";",
"$",
"stream",
"->",
"rewind",
"(",
")",
";",
"$",
"response",
"=",
"$",
"response",
"->",
"withBody",
"(",
"$",
"stream",
")",
";",
"}",
"if",
"(",
"!",
"$",
"response",
"instanceof",
"Response",
")",
"{",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"Client",
"->",
"get",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'cache'",
")",
"&&",
"(",
"$",
"response",
"->",
"isOk",
"(",
")",
"||",
"$",
"response",
"->",
"isRedirect",
"(",
")",
")",
")",
"{",
"Cache",
"::",
"write",
"(",
"$",
"cacheKey",
",",
"[",
"$",
"response",
",",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
"]",
",",
"'LinkScanner'",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"response",
"=",
"(",
"new",
"Response",
")",
"->",
"withStatus",
"(",
"404",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] | Performs a single GET request and returns a `ScanResponse` instance.
The response will be cached, if that's ok and the cache is enabled.
@param string $url The url or path you want to request
@return Response
@uses $Client
@uses $alreadyScanned
@uses $fullBaseUrl | [
"Performs",
"a",
"single",
"GET",
"request",
"and",
"returns",
"a",
"ScanResponse",
"instance",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L163-L192 |
30,020 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner._recursiveScan | protected function _recursiveScan($url, $referer = null)
{
$response = $this->_singleScan($url, $referer);
if (!$response) {
return;
}
//Returns, if the maximum scanning depth has been reached
if ($this->getConfig('maxDepth') && ++$this->currentDepth >= $this->getConfig('maxDepth')) {
return;
}
//Returns, if the response is not ok
if (!$response->isOk()) {
$this->dispatchEvent('LinkScanner.responseNotOk', [$url]);
return;
}
//Continues scanning for the links found
foreach ((new BodyParser($response->getBody(), $url))->extractLinks() as $link) {
if (!$this->canBeScanned($link)) {
continue;
}
$this->dispatchEvent('LinkScanner.foundLinkToBeScanned', [$link]);
//Single scan for external links, recursive scan for internal links
call_user_func_array([$this, is_external_url($link, $this->hostname) ? '_singleScan' : __METHOD__], [$link, $url]);
}
} | php | protected function _recursiveScan($url, $referer = null)
{
$response = $this->_singleScan($url, $referer);
if (!$response) {
return;
}
//Returns, if the maximum scanning depth has been reached
if ($this->getConfig('maxDepth') && ++$this->currentDepth >= $this->getConfig('maxDepth')) {
return;
}
//Returns, if the response is not ok
if (!$response->isOk()) {
$this->dispatchEvent('LinkScanner.responseNotOk', [$url]);
return;
}
//Continues scanning for the links found
foreach ((new BodyParser($response->getBody(), $url))->extractLinks() as $link) {
if (!$this->canBeScanned($link)) {
continue;
}
$this->dispatchEvent('LinkScanner.foundLinkToBeScanned', [$link]);
//Single scan for external links, recursive scan for internal links
call_user_func_array([$this, is_external_url($link, $this->hostname) ? '_singleScan' : __METHOD__], [$link, $url]);
}
} | [
"protected",
"function",
"_recursiveScan",
"(",
"$",
"url",
",",
"$",
"referer",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"_singleScan",
"(",
"$",
"url",
",",
"$",
"referer",
")",
";",
"if",
"(",
"!",
"$",
"response",
")",
"{",
"return",
";",
"}",
"//Returns, if the maximum scanning depth has been reached",
"if",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'maxDepth'",
")",
"&&",
"++",
"$",
"this",
"->",
"currentDepth",
">=",
"$",
"this",
"->",
"getConfig",
"(",
"'maxDepth'",
")",
")",
"{",
"return",
";",
"}",
"//Returns, if the response is not ok",
"if",
"(",
"!",
"$",
"response",
"->",
"isOk",
"(",
")",
")",
"{",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.responseNotOk'",
",",
"[",
"$",
"url",
"]",
")",
";",
"return",
";",
"}",
"//Continues scanning for the links found",
"foreach",
"(",
"(",
"new",
"BodyParser",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"$",
"url",
")",
")",
"->",
"extractLinks",
"(",
")",
"as",
"$",
"link",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canBeScanned",
"(",
"$",
"link",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.foundLinkToBeScanned'",
",",
"[",
"$",
"link",
"]",
")",
";",
"//Single scan for external links, recursive scan for internal links",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"is_external_url",
"(",
"$",
"link",
",",
"$",
"this",
"->",
"hostname",
")",
"?",
"'_singleScan'",
":",
"__METHOD__",
"]",
",",
"[",
"$",
"link",
",",
"$",
"url",
"]",
")",
";",
"}",
"}"
] | Internal method to perform a recursive scan.
It recursively repeats the scan for all urls found that have not
already been scanned.
### Events
This method will trigger some events:
- `LinkScanner.foundLinkToBeScanned`: will be triggered when other links
to be scanned are found;
- `LinkScanner.responseNotOk`: will be triggered when a single url is
scanned and the response is not ok.
@param string|array $url Url to scan
@param string|null $referer Referer of this url
@return void
@uses _singleScan()
@uses canBeScanned()
@uses $alreadyScanned
@uses $currentDepth
@uses $hostname | [
"Internal",
"method",
"to",
"perform",
"a",
"recursive",
"scan",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L215-L245 |
30,021 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner._singleScan | protected function _singleScan($url, $referer = null)
{
$url = clean_url($url, true, true);
if (!$this->canBeScanned($url)) {
return null;
}
$this->dispatchEvent('LinkScanner.beforeScanUrl', [$url]);
$response = $this->_getResponse($url);
$this->dispatchEvent('LinkScanner.afterScanUrl', [$response]);
//Follows redirects
if ($response->isRedirect() && $this->getConfig('followRedirects')) {
$location = $response->getHeaderLine('location');
if (!$this->canBeScanned($location)) {
return null;
}
$this->dispatchEvent('LinkScanner.foundRedirect', [$location]);
return call_user_func([$this, __METHOD__], $location);
}
$this->ResultScan = $this->ResultScan->appendItem(new ScanEntity([
'code' => $response->getStatusCode(),
'external' => is_external_url($url, $this->hostname),
'location' => $response->getHeaderLine('Location'),
'type' => $response->getHeaderLine('content-type'),
] + compact('url', 'referer')));
return $response;
} | php | protected function _singleScan($url, $referer = null)
{
$url = clean_url($url, true, true);
if (!$this->canBeScanned($url)) {
return null;
}
$this->dispatchEvent('LinkScanner.beforeScanUrl', [$url]);
$response = $this->_getResponse($url);
$this->dispatchEvent('LinkScanner.afterScanUrl', [$response]);
//Follows redirects
if ($response->isRedirect() && $this->getConfig('followRedirects')) {
$location = $response->getHeaderLine('location');
if (!$this->canBeScanned($location)) {
return null;
}
$this->dispatchEvent('LinkScanner.foundRedirect', [$location]);
return call_user_func([$this, __METHOD__], $location);
}
$this->ResultScan = $this->ResultScan->appendItem(new ScanEntity([
'code' => $response->getStatusCode(),
'external' => is_external_url($url, $this->hostname),
'location' => $response->getHeaderLine('Location'),
'type' => $response->getHeaderLine('content-type'),
] + compact('url', 'referer')));
return $response;
} | [
"protected",
"function",
"_singleScan",
"(",
"$",
"url",
",",
"$",
"referer",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"clean_url",
"(",
"$",
"url",
",",
"true",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"canBeScanned",
"(",
"$",
"url",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.beforeScanUrl'",
",",
"[",
"$",
"url",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"_getResponse",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.afterScanUrl'",
",",
"[",
"$",
"response",
"]",
")",
";",
"//Follows redirects",
"if",
"(",
"$",
"response",
"->",
"isRedirect",
"(",
")",
"&&",
"$",
"this",
"->",
"getConfig",
"(",
"'followRedirects'",
")",
")",
"{",
"$",
"location",
"=",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'location'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"canBeScanned",
"(",
"$",
"location",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.foundRedirect'",
",",
"[",
"$",
"location",
"]",
")",
";",
"return",
"call_user_func",
"(",
"[",
"$",
"this",
",",
"__METHOD__",
"]",
",",
"$",
"location",
")",
";",
"}",
"$",
"this",
"->",
"ResultScan",
"=",
"$",
"this",
"->",
"ResultScan",
"->",
"appendItem",
"(",
"new",
"ScanEntity",
"(",
"[",
"'code'",
"=>",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"'external'",
"=>",
"is_external_url",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"hostname",
")",
",",
"'location'",
"=>",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'Location'",
")",
",",
"'type'",
"=>",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'content-type'",
")",
",",
"]",
"+",
"compact",
"(",
"'url'",
",",
"'referer'",
")",
")",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Internal method to perform a single scan.
### Events
This method will trigger some events:
- `LinkScanner.beforeScanUrl`: will be triggered before a single url is
scanned;
- `LinkScanner.afterScanUrl`: will be triggered after a single url is
scanned;
- `LinkScanner.foundRedirect`: will be triggered if a redirect is found.
@param string|array $url Url to scan
@param string|null $referer Referer of this url
@return ScanResponse|null
@uses _getResponse()
@uses canBeScanned()
@uses $ResultScan
@uses $hostname | [
"Internal",
"method",
"to",
"perform",
"a",
"single",
"scan",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L265-L296 |
30,022 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner.canBeScanned | protected function canBeScanned($url)
{
if (!is_url($url) || in_array($url, $this->alreadyScanned) ||
(!$this->getConfig('externalLinks') && is_external_url($url, $this->hostname))) {
return false;
}
foreach ((array)$this->getConfig('excludeLinks') as $pattern) {
if (preg_match($pattern, $url)) {
return false;
}
}
return true;
} | php | protected function canBeScanned($url)
{
if (!is_url($url) || in_array($url, $this->alreadyScanned) ||
(!$this->getConfig('externalLinks') && is_external_url($url, $this->hostname))) {
return false;
}
foreach ((array)$this->getConfig('excludeLinks') as $pattern) {
if (preg_match($pattern, $url)) {
return false;
}
}
return true;
} | [
"protected",
"function",
"canBeScanned",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"is_url",
"(",
"$",
"url",
")",
"||",
"in_array",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"alreadyScanned",
")",
"||",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'externalLinks'",
")",
"&&",
"is_external_url",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"hostname",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getConfig",
"(",
"'excludeLinks'",
")",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"url",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Checks if an url can be scanned.
Returns false if:
- the url has already been scanned;
- it's an external url and the external url scan has been disabled;
- the url matches the url patterns to be excluded.
@param string $url Url to check
@return bool
@uses $alreadyScanned
@uses $hostname | [
"Checks",
"if",
"an",
"url",
"can",
"be",
"scanned",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L310-L324 |
30,023 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner.serialize | public function serialize()
{
//Unsets the event class and event manager. For the `Client` instance,
// it takes only configuration and cookies
$properties = get_object_vars($this);
unset($properties['_eventClass'], $properties['_eventManager']);
$properties['Client'] = $this->Client->getConfig() + ['cookieJar' => $this->Client->cookies()];
return serialize($properties);
} | php | public function serialize()
{
//Unsets the event class and event manager. For the `Client` instance,
// it takes only configuration and cookies
$properties = get_object_vars($this);
unset($properties['_eventClass'], $properties['_eventManager']);
$properties['Client'] = $this->Client->getConfig() + ['cookieJar' => $this->Client->cookies()];
return serialize($properties);
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"//Unsets the event class and event manager. For the `Client` instance,",
"// it takes only configuration and cookies",
"$",
"properties",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"unset",
"(",
"$",
"properties",
"[",
"'_eventClass'",
"]",
",",
"$",
"properties",
"[",
"'_eventManager'",
"]",
")",
";",
"$",
"properties",
"[",
"'Client'",
"]",
"=",
"$",
"this",
"->",
"Client",
"->",
"getConfig",
"(",
")",
"+",
"[",
"'cookieJar'",
"=>",
"$",
"this",
"->",
"Client",
"->",
"cookies",
"(",
")",
"]",
";",
"return",
"serialize",
"(",
"$",
"properties",
")",
";",
"}"
] | Returns the string representation of the object
@return string
@uses $Client | [
"Returns",
"the",
"string",
"representation",
"of",
"the",
"object"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L331-L340 |
30,024 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner.unserialize | public function unserialize($serialized)
{
//Resets the event list and the Client instance
$properties = unserialize($serialized);
$this->getEventManager()->setEventList(new EventList);
$this->Client = new Client($properties['Client']);
unset($properties['Client']);
foreach ($properties as $name => $value) {
$this->$name = $value;
}
} | php | public function unserialize($serialized)
{
//Resets the event list and the Client instance
$properties = unserialize($serialized);
$this->getEventManager()->setEventList(new EventList);
$this->Client = new Client($properties['Client']);
unset($properties['Client']);
foreach ($properties as $name => $value) {
$this->$name = $value;
}
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"//Resets the event list and the Client instance",
"$",
"properties",
"=",
"unserialize",
"(",
"$",
"serialized",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"setEventList",
"(",
"new",
"EventList",
")",
";",
"$",
"this",
"->",
"Client",
"=",
"new",
"Client",
"(",
"$",
"properties",
"[",
"'Client'",
"]",
")",
";",
"unset",
"(",
"$",
"properties",
"[",
"'Client'",
"]",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"$",
"name",
"=",
"$",
"value",
";",
"}",
"}"
] | Called during unserialization of the object
@param string $serialized The string representation of the object
@return void
@uses $Client | [
"Called",
"during",
"unserialization",
"of",
"the",
"object"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L348-L359 |
30,025 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner.export | public function export($filename = null)
{
is_true_or_fail(!$this->ResultScan->isEmpty(), __d('link-scanner', 'There is no result to export. Perhaps the scan was not performed?'), RuntimeException::class);
$filename = $filename ?: sprintf('results_%s_%s', $this->hostname, $this->startTime);
$filename = Folder::isAbsolute($filename) ? $filename : Folder::slashTerm($this->getConfig('target')) . $filename;
(new File($filename, true))->write(serialize($this));
$this->dispatchEvent('LinkScanner.resultsExported', [$filename]);
return $filename;
} | php | public function export($filename = null)
{
is_true_or_fail(!$this->ResultScan->isEmpty(), __d('link-scanner', 'There is no result to export. Perhaps the scan was not performed?'), RuntimeException::class);
$filename = $filename ?: sprintf('results_%s_%s', $this->hostname, $this->startTime);
$filename = Folder::isAbsolute($filename) ? $filename : Folder::slashTerm($this->getConfig('target')) . $filename;
(new File($filename, true))->write(serialize($this));
$this->dispatchEvent('LinkScanner.resultsExported', [$filename]);
return $filename;
} | [
"public",
"function",
"export",
"(",
"$",
"filename",
"=",
"null",
")",
"{",
"is_true_or_fail",
"(",
"!",
"$",
"this",
"->",
"ResultScan",
"->",
"isEmpty",
"(",
")",
",",
"__d",
"(",
"'link-scanner'",
",",
"'There is no result to export. Perhaps the scan was not performed?'",
")",
",",
"RuntimeException",
"::",
"class",
")",
";",
"$",
"filename",
"=",
"$",
"filename",
"?",
":",
"sprintf",
"(",
"'results_%s_%s'",
",",
"$",
"this",
"->",
"hostname",
",",
"$",
"this",
"->",
"startTime",
")",
";",
"$",
"filename",
"=",
"Folder",
"::",
"isAbsolute",
"(",
"$",
"filename",
")",
"?",
"$",
"filename",
":",
"Folder",
"::",
"slashTerm",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'target'",
")",
")",
".",
"$",
"filename",
";",
"(",
"new",
"File",
"(",
"$",
"filename",
",",
"true",
")",
")",
"->",
"write",
"(",
"serialize",
"(",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.resultsExported'",
",",
"[",
"$",
"filename",
"]",
")",
";",
"return",
"$",
"filename",
";",
"}"
] | Exports scan results.
The filename will be generated automatically, or you can indicate a
relative or absolute path.
### Events
This method will trigger some events:
- `LinkScanner.resultsExported`: will be triggered when the results have
been exported.
@param string|null $filename Filename where to export
@return string
@see serialize()
@throws RuntimeException
@uses $ResultScan
@uses $hostname
@uses $startTime | [
"Exports",
"scan",
"results",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L378-L388 |
30,026 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner.import | public static function import($filename)
{
try {
$filename = Folder::isAbsolute($filename) ? $filename : Folder::slashTerm(self::getConfig('target')) . $filename;
$instance = unserialize(file_get_contents($filename));
} catch (Exception $e) {
$message = preg_replace('/^file_get_contents\([\/\w\d:\-\\\\]+\): /', null, $e->getMessage());
throw new RuntimeException(__d('link-scanner', 'Failed to import results from file `{0}` with message `{1}`', $filename, $message));
}
$instance->dispatchEvent('LinkScanner.resultsImported', [$filename]);
return $instance;
} | php | public static function import($filename)
{
try {
$filename = Folder::isAbsolute($filename) ? $filename : Folder::slashTerm(self::getConfig('target')) . $filename;
$instance = unserialize(file_get_contents($filename));
} catch (Exception $e) {
$message = preg_replace('/^file_get_contents\([\/\w\d:\-\\\\]+\): /', null, $e->getMessage());
throw new RuntimeException(__d('link-scanner', 'Failed to import results from file `{0}` with message `{1}`', $filename, $message));
}
$instance->dispatchEvent('LinkScanner.resultsImported', [$filename]);
return $instance;
} | [
"public",
"static",
"function",
"import",
"(",
"$",
"filename",
")",
"{",
"try",
"{",
"$",
"filename",
"=",
"Folder",
"::",
"isAbsolute",
"(",
"$",
"filename",
")",
"?",
"$",
"filename",
":",
"Folder",
"::",
"slashTerm",
"(",
"self",
"::",
"getConfig",
"(",
"'target'",
")",
")",
".",
"$",
"filename",
";",
"$",
"instance",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"filename",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"message",
"=",
"preg_replace",
"(",
"'/^file_get_contents\\([\\/\\w\\d:\\-\\\\\\\\]+\\): /'",
",",
"null",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Failed to import results from file `{0}` with message `{1}`'",
",",
"$",
"filename",
",",
"$",
"message",
")",
")",
";",
"}",
"$",
"instance",
"->",
"dispatchEvent",
"(",
"'LinkScanner.resultsImported'",
",",
"[",
"$",
"filename",
"]",
")",
";",
"return",
"$",
"instance",
";",
"}"
] | Imports scan results.
You can indicate a relative or absolute path.
### Events
This method will trigger some events:
- `LinkScanner.resultsImported`: will be triggered when the results have
been exported.
@param string $filename Filename from which to import
@return \LinkScanner\Utility\LinkScanner
@see unserialize()
@throws RuntimeException | [
"Imports",
"scan",
"results",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L403-L416 |
30,027 | mirko-pagliai/cakephp-link-scanner | src/Utility/LinkScanner.php | LinkScanner.scan | public function scan()
{
//Sets the full base url
$fullBaseUrl = $this->getConfig('fullBaseUrl', Configure::read('App.fullBaseUrl') ?: 'http://localhost');
is_true_or_fail(is_url($fullBaseUrl), __d('link-scanner', 'Invalid full base url `{0}`', $fullBaseUrl), InvalidArgumentException::class);
$this->hostname = get_hostname_from_url($fullBaseUrl);
$this->_createLockFile();
$this->startTime = time();
$maxNestingLevel = ini_set('xdebug.max_nesting_level', -1);
try {
$this->dispatchEvent('LinkScanner.scanStarted', [$this->startTime, $fullBaseUrl]);
$this->_recursiveScan($fullBaseUrl);
$this->endTime = time();
$this->dispatchEvent('LinkScanner.scanCompleted', [$this->startTime, $this->endTime, $this->ResultScan]);
} finally {
ini_set('xdebug.max_nesting_level', $maxNestingLevel);
@unlink($this->lockFile);
}
return $this;
} | php | public function scan()
{
//Sets the full base url
$fullBaseUrl = $this->getConfig('fullBaseUrl', Configure::read('App.fullBaseUrl') ?: 'http://localhost');
is_true_or_fail(is_url($fullBaseUrl), __d('link-scanner', 'Invalid full base url `{0}`', $fullBaseUrl), InvalidArgumentException::class);
$this->hostname = get_hostname_from_url($fullBaseUrl);
$this->_createLockFile();
$this->startTime = time();
$maxNestingLevel = ini_set('xdebug.max_nesting_level', -1);
try {
$this->dispatchEvent('LinkScanner.scanStarted', [$this->startTime, $fullBaseUrl]);
$this->_recursiveScan($fullBaseUrl);
$this->endTime = time();
$this->dispatchEvent('LinkScanner.scanCompleted', [$this->startTime, $this->endTime, $this->ResultScan]);
} finally {
ini_set('xdebug.max_nesting_level', $maxNestingLevel);
@unlink($this->lockFile);
}
return $this;
} | [
"public",
"function",
"scan",
"(",
")",
"{",
"//Sets the full base url",
"$",
"fullBaseUrl",
"=",
"$",
"this",
"->",
"getConfig",
"(",
"'fullBaseUrl'",
",",
"Configure",
"::",
"read",
"(",
"'App.fullBaseUrl'",
")",
"?",
":",
"'http://localhost'",
")",
";",
"is_true_or_fail",
"(",
"is_url",
"(",
"$",
"fullBaseUrl",
")",
",",
"__d",
"(",
"'link-scanner'",
",",
"'Invalid full base url `{0}`'",
",",
"$",
"fullBaseUrl",
")",
",",
"InvalidArgumentException",
"::",
"class",
")",
";",
"$",
"this",
"->",
"hostname",
"=",
"get_hostname_from_url",
"(",
"$",
"fullBaseUrl",
")",
";",
"$",
"this",
"->",
"_createLockFile",
"(",
")",
";",
"$",
"this",
"->",
"startTime",
"=",
"time",
"(",
")",
";",
"$",
"maxNestingLevel",
"=",
"ini_set",
"(",
"'xdebug.max_nesting_level'",
",",
"-",
"1",
")",
";",
"try",
"{",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.scanStarted'",
",",
"[",
"$",
"this",
"->",
"startTime",
",",
"$",
"fullBaseUrl",
"]",
")",
";",
"$",
"this",
"->",
"_recursiveScan",
"(",
"$",
"fullBaseUrl",
")",
";",
"$",
"this",
"->",
"endTime",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"dispatchEvent",
"(",
"'LinkScanner.scanCompleted'",
",",
"[",
"$",
"this",
"->",
"startTime",
",",
"$",
"this",
"->",
"endTime",
",",
"$",
"this",
"->",
"ResultScan",
"]",
")",
";",
"}",
"finally",
"{",
"ini_set",
"(",
"'xdebug.max_nesting_level'",
",",
"$",
"maxNestingLevel",
")",
";",
"@",
"unlink",
"(",
"$",
"this",
"->",
"lockFile",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Performs a complete scan.
### Events
This method will trigger some events:
- `LinkScanner.scanStarted`: will be triggered before the scan starts;
- `LinkScanner.scanCompleted`: will be triggered after the scan is
finished.
Other events will be triggered by `_recursiveScan()` and `_singleScan()`
methods.
@return $this
@throws InvalidArgumentException
@uses _createLockFile()
@uses _recursiveScan()
@uses $ResultScan
@uses $endTime
@uses $hostname
@uses $lockFile
@uses $startTime | [
"Performs",
"a",
"complete",
"scan",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Utility/LinkScanner.php#L439-L462 |
30,028 | hostnet/entity-plugin-lib | src/Installer.php | Installer.getGraph | private function getGraph()
{
if ($this->graph === null) {
$local_repository = $this->composer->getRepositoryManager()->getLocalRepository();
$packages = $local_repository->getPackages();
$packages[] = $this->composer->getPackage();
$supported_packages = $this->getSupportedPackages($packages);
$this->setUpAutoloading();
$this->graph = new EntityPackageBuilder($this, $supported_packages);
}
return $this->graph;
} | php | private function getGraph()
{
if ($this->graph === null) {
$local_repository = $this->composer->getRepositoryManager()->getLocalRepository();
$packages = $local_repository->getPackages();
$packages[] = $this->composer->getPackage();
$supported_packages = $this->getSupportedPackages($packages);
$this->setUpAutoloading();
$this->graph = new EntityPackageBuilder($this, $supported_packages);
}
return $this->graph;
} | [
"private",
"function",
"getGraph",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"graph",
"===",
"null",
")",
"{",
"$",
"local_repository",
"=",
"$",
"this",
"->",
"composer",
"->",
"getRepositoryManager",
"(",
")",
"->",
"getLocalRepository",
"(",
")",
";",
"$",
"packages",
"=",
"$",
"local_repository",
"->",
"getPackages",
"(",
")",
";",
"$",
"packages",
"[",
"]",
"=",
"$",
"this",
"->",
"composer",
"->",
"getPackage",
"(",
")",
";",
"$",
"supported_packages",
"=",
"$",
"this",
"->",
"getSupportedPackages",
"(",
"$",
"packages",
")",
";",
"$",
"this",
"->",
"setUpAutoloading",
"(",
")",
";",
"$",
"this",
"->",
"graph",
"=",
"new",
"EntityPackageBuilder",
"(",
"$",
"this",
",",
"$",
"supported_packages",
")",
";",
"}",
"return",
"$",
"this",
"->",
"graph",
";",
"}"
] | Calculate the dependency graph
@return \Hostnet\Component\EntityPlugin\EntityPackageBuilder | [
"Calculate",
"the",
"dependency",
"graph"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Installer.php#L84-L95 |
30,029 | hostnet/entity-plugin-lib | src/Installer.php | Installer.postAutoloadDump | public function postAutoloadDump()
{
$graph = $this->getGraph();
$this->io->write('<info>Pass 3/3: Performing individual generation</info>');
$this->generateConcreteIndividualCode($graph);
} | php | public function postAutoloadDump()
{
$graph = $this->getGraph();
$this->io->write('<info>Pass 3/3: Performing individual generation</info>');
$this->generateConcreteIndividualCode($graph);
} | [
"public",
"function",
"postAutoloadDump",
"(",
")",
"{",
"$",
"graph",
"=",
"$",
"this",
"->",
"getGraph",
"(",
")",
";",
"$",
"this",
"->",
"io",
"->",
"write",
"(",
"'<info>Pass 3/3: Performing individual generation</info>'",
")",
";",
"$",
"this",
"->",
"generateConcreteIndividualCode",
"(",
"$",
"graph",
")",
";",
"}"
] | Gets called on the POST_AUTOLOAD_DUMP event | [
"Gets",
"called",
"on",
"the",
"POST_AUTOLOAD_DUMP",
"event"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Installer.php#L113-L119 |
30,030 | hostnet/entity-plugin-lib | src/Installer.php | Installer.getSupportedPackages | private function getSupportedPackages(array $packages)
{
$supported_packages = [];
foreach ($packages as $package) {
/* @var $package \Composer\Package\PackageInterface */
if ($this->supportsPackage($package)) {
$supported_packages[] = $package;
}
}
return $supported_packages;
} | php | private function getSupportedPackages(array $packages)
{
$supported_packages = [];
foreach ($packages as $package) {
/* @var $package \Composer\Package\PackageInterface */
if ($this->supportsPackage($package)) {
$supported_packages[] = $package;
}
}
return $supported_packages;
} | [
"private",
"function",
"getSupportedPackages",
"(",
"array",
"$",
"packages",
")",
"{",
"$",
"supported_packages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"packages",
"as",
"$",
"package",
")",
"{",
"/* @var $package \\Composer\\Package\\PackageInterface */",
"if",
"(",
"$",
"this",
"->",
"supportsPackage",
"(",
"$",
"package",
")",
")",
"{",
"$",
"supported_packages",
"[",
"]",
"=",
"$",
"package",
";",
"}",
"}",
"return",
"$",
"supported_packages",
";",
"}"
] | Gives all packages that we need to install
@param RootPackageInterface[] $packages
@return \Composer\Package\PackageInterface[] | [
"Gives",
"all",
"packages",
"that",
"we",
"need",
"to",
"install"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Installer.php#L126-L136 |
30,031 | hostnet/entity-plugin-lib | src/Installer.php | Installer.setUpAutoloading | private function setUpAutoloading()
{
//Pre-required variable's
$package = $this->composer->getPackage();
$autoload_generator = $this->composer->getAutoloadGenerator();
$local_repository = $this->composer->getRepositoryManager()->getLocalRepository();
$installation_manager = $this->composer->getInstallationManager();
if (!$installation_manager) {
$installation_manager = new InstallationManager();
}
//API stolen from Composer see DumpAutoloadCommand.php
$package_map = $autoload_generator->buildPackageMap(
$installation_manager,
$package,
$local_repository->getCanonicalPackages()
);
$autoloads = $autoload_generator->parseAutoloads($package_map, $package);
//Create the classloader and register the classes.
$class_loader = $autoload_generator->createLoader($autoloads);
$class_loader->register();
} | php | private function setUpAutoloading()
{
//Pre-required variable's
$package = $this->composer->getPackage();
$autoload_generator = $this->composer->getAutoloadGenerator();
$local_repository = $this->composer->getRepositoryManager()->getLocalRepository();
$installation_manager = $this->composer->getInstallationManager();
if (!$installation_manager) {
$installation_manager = new InstallationManager();
}
//API stolen from Composer see DumpAutoloadCommand.php
$package_map = $autoload_generator->buildPackageMap(
$installation_manager,
$package,
$local_repository->getCanonicalPackages()
);
$autoloads = $autoload_generator->parseAutoloads($package_map, $package);
//Create the classloader and register the classes.
$class_loader = $autoload_generator->createLoader($autoloads);
$class_loader->register();
} | [
"private",
"function",
"setUpAutoloading",
"(",
")",
"{",
"//Pre-required variable's",
"$",
"package",
"=",
"$",
"this",
"->",
"composer",
"->",
"getPackage",
"(",
")",
";",
"$",
"autoload_generator",
"=",
"$",
"this",
"->",
"composer",
"->",
"getAutoloadGenerator",
"(",
")",
";",
"$",
"local_repository",
"=",
"$",
"this",
"->",
"composer",
"->",
"getRepositoryManager",
"(",
")",
"->",
"getLocalRepository",
"(",
")",
";",
"$",
"installation_manager",
"=",
"$",
"this",
"->",
"composer",
"->",
"getInstallationManager",
"(",
")",
";",
"if",
"(",
"!",
"$",
"installation_manager",
")",
"{",
"$",
"installation_manager",
"=",
"new",
"InstallationManager",
"(",
")",
";",
"}",
"//API stolen from Composer see DumpAutoloadCommand.php",
"$",
"package_map",
"=",
"$",
"autoload_generator",
"->",
"buildPackageMap",
"(",
"$",
"installation_manager",
",",
"$",
"package",
",",
"$",
"local_repository",
"->",
"getCanonicalPackages",
"(",
")",
")",
";",
"$",
"autoloads",
"=",
"$",
"autoload_generator",
"->",
"parseAutoloads",
"(",
"$",
"package_map",
",",
"$",
"package",
")",
";",
"//Create the classloader and register the classes.",
"$",
"class_loader",
"=",
"$",
"autoload_generator",
"->",
"createLoader",
"(",
"$",
"autoloads",
")",
";",
"$",
"class_loader",
"->",
"register",
"(",
")",
";",
"}"
] | Ensures all the packages are autoloaded, needed because classes are read using reflection. | [
"Ensures",
"all",
"the",
"packages",
"are",
"autoloaded",
"needed",
"because",
"classes",
"are",
"read",
"using",
"reflection",
"."
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Installer.php#L154-L176 |
30,032 | hostnet/entity-plugin-lib | src/Installer.php | Installer.generateEmptyCode | private function generateEmptyCode(EntityPackageBuilder $graph)
{
foreach ($graph->getEntityPackages() as $entity_package) {
/* @var $entity_package EntityPackage */
$this->writeIfVerbose(
' - Preparing package <info>' . $entity_package->getPackage()
->getName() . '</info>'
);
foreach ($entity_package->getEntityContent()->getClasses() as $entity) {
$this->writeIfVeryVerbose(
' - Generating empty interface for <info>' . $entity->getName() . '</info>'
);
$this->empty_generator->generate($entity);
}
}
} | php | private function generateEmptyCode(EntityPackageBuilder $graph)
{
foreach ($graph->getEntityPackages() as $entity_package) {
/* @var $entity_package EntityPackage */
$this->writeIfVerbose(
' - Preparing package <info>' . $entity_package->getPackage()
->getName() . '</info>'
);
foreach ($entity_package->getEntityContent()->getClasses() as $entity) {
$this->writeIfVeryVerbose(
' - Generating empty interface for <info>' . $entity->getName() . '</info>'
);
$this->empty_generator->generate($entity);
}
}
} | [
"private",
"function",
"generateEmptyCode",
"(",
"EntityPackageBuilder",
"$",
"graph",
")",
"{",
"foreach",
"(",
"$",
"graph",
"->",
"getEntityPackages",
"(",
")",
"as",
"$",
"entity_package",
")",
"{",
"/* @var $entity_package EntityPackage */",
"$",
"this",
"->",
"writeIfVerbose",
"(",
"' - Preparing package <info>'",
".",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'</info>'",
")",
";",
"foreach",
"(",
"$",
"entity_package",
"->",
"getEntityContent",
"(",
")",
"->",
"getClasses",
"(",
")",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"writeIfVeryVerbose",
"(",
"' - Generating empty interface for <info>'",
".",
"$",
"entity",
"->",
"getName",
"(",
")",
".",
"'</info>'",
")",
";",
"$",
"this",
"->",
"empty_generator",
"->",
"generate",
"(",
"$",
"entity",
")",
";",
"}",
"}",
"}"
] | Ensure all interfaces and traits exist
@see EmptyGenerator
@param EntityPackageBuilder $graph | [
"Ensure",
"all",
"interfaces",
"and",
"traits",
"exist"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Installer.php#L204-L219 |
30,033 | hostnet/entity-plugin-lib | src/Installer.php | Installer.generateConcreteIndividualCode | private function generateConcreteIndividualCode(EntityPackageBuilder $graph)
{
foreach ($graph->getEntityPackages() as $entity_package) {
/* @var $entity_package EntityPackage */
$this->writeIfVerbose(
' - Generating for package <info>' . $entity_package->getPackage()
->getName() . '</info>'
);
foreach ($entity_package->getEntityContent()->getClasses() as $entity) {
$this->writeIfVeryVerbose(
' - Generating interface for <info>' . $entity->getName() . '</info>'
);
$this->reflection_generator->generate($entity);
}
}
} | php | private function generateConcreteIndividualCode(EntityPackageBuilder $graph)
{
foreach ($graph->getEntityPackages() as $entity_package) {
/* @var $entity_package EntityPackage */
$this->writeIfVerbose(
' - Generating for package <info>' . $entity_package->getPackage()
->getName() . '</info>'
);
foreach ($entity_package->getEntityContent()->getClasses() as $entity) {
$this->writeIfVeryVerbose(
' - Generating interface for <info>' . $entity->getName() . '</info>'
);
$this->reflection_generator->generate($entity);
}
}
} | [
"private",
"function",
"generateConcreteIndividualCode",
"(",
"EntityPackageBuilder",
"$",
"graph",
")",
"{",
"foreach",
"(",
"$",
"graph",
"->",
"getEntityPackages",
"(",
")",
"as",
"$",
"entity_package",
")",
"{",
"/* @var $entity_package EntityPackage */",
"$",
"this",
"->",
"writeIfVerbose",
"(",
"' - Generating for package <info>'",
".",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'</info>'",
")",
";",
"foreach",
"(",
"$",
"entity_package",
"->",
"getEntityContent",
"(",
")",
"->",
"getClasses",
"(",
")",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"writeIfVeryVerbose",
"(",
"' - Generating interface for <info>'",
".",
"$",
"entity",
"->",
"getName",
"(",
")",
".",
"'</info>'",
")",
";",
"$",
"this",
"->",
"reflection_generator",
"->",
"generate",
"(",
"$",
"entity",
")",
";",
"}",
"}",
"}"
] | Ensure all interfaces and traits are filled with correct methods
@param EntityPackageBuilder $graph | [
"Ensure",
"all",
"interfaces",
"and",
"traits",
"are",
"filled",
"with",
"correct",
"methods"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Installer.php#L226-L241 |
30,034 | mirko-pagliai/cakephp-link-scanner | src/ResultScan.php | ResultScan.parseItems | protected function parseItems($items)
{
$items = $items instanceof Traversable ? $items->toArray() : $items;
return array_map(function ($item) {
return $item instanceof ScanEntity ? $item : new ScanEntity($item);
}, $items);
} | php | protected function parseItems($items)
{
$items = $items instanceof Traversable ? $items->toArray() : $items;
return array_map(function ($item) {
return $item instanceof ScanEntity ? $item : new ScanEntity($item);
}, $items);
} | [
"protected",
"function",
"parseItems",
"(",
"$",
"items",
")",
"{",
"$",
"items",
"=",
"$",
"items",
"instanceof",
"Traversable",
"?",
"$",
"items",
"->",
"toArray",
"(",
")",
":",
"$",
"items",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"instanceof",
"ScanEntity",
"?",
"$",
"item",
":",
"new",
"ScanEntity",
"(",
"$",
"item",
")",
";",
"}",
",",
"$",
"items",
")",
";",
"}"
] | Internal method to parse items.
Ensures that each item is a `ScanEntity` and has all the properties it needs
@param array|Traversable $items Array of items
@return array Parsed items | [
"Internal",
"method",
"to",
"parse",
"items",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/ResultScan.php#L31-L38 |
30,035 | mirko-pagliai/cakephp-link-scanner | src/ResultScan.php | ResultScan.append | public function append($items)
{
return new ResultScan(array_merge($this->buffered()->toArray(), $this->parseItems($items)));
} | php | public function append($items)
{
return new ResultScan(array_merge($this->buffered()->toArray(), $this->parseItems($items)));
} | [
"public",
"function",
"append",
"(",
"$",
"items",
")",
"{",
"return",
"new",
"ResultScan",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"buffered",
"(",
")",
"->",
"toArray",
"(",
")",
",",
"$",
"this",
"->",
"parseItems",
"(",
"$",
"items",
")",
")",
")",
";",
"}"
] | Appends items.
Returns a new `ResultScan` instance as the result of concatenating the
list of elements in this collection with the passed list of elements
@param array|Traversable $items Items
@return \LinkScanner\ResultScan
@uses parseItems() | [
"Appends",
"items",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/ResultScan.php#L59-L62 |
30,036 | mirko-pagliai/cakephp-link-scanner | src/ResultScan.php | ResultScan.prepend | public function prepend($items)
{
return new ResultScan(array_merge($this->parseItems($items), $this->buffered()->toArray()));
} | php | public function prepend($items)
{
return new ResultScan(array_merge($this->parseItems($items), $this->buffered()->toArray()));
} | [
"public",
"function",
"prepend",
"(",
"$",
"items",
")",
"{",
"return",
"new",
"ResultScan",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"parseItems",
"(",
"$",
"items",
")",
",",
"$",
"this",
"->",
"buffered",
"(",
")",
"->",
"toArray",
"(",
")",
")",
")",
";",
"}"
] | Prepends items.
Returns a new `ResultScan` instance as the result of concatenating the
passed list of elements with the list of elements in this collection
@param array|Traversable $items Items
@return \LinkScanner\ResultScan
@uses parseItems() | [
"Prepends",
"items",
"."
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/ResultScan.php#L73-L76 |
30,037 | mmoreram/BaseBundle | CompilerPass/MappingCompilerPass.php | MappingCompilerPass.addObjectManager | private function addObjectManager(
ContainerBuilder $container,
MappingBag $mappingBag
): string {
$reducedMappingBag = $mappingBag->getReducedMappingBag();
$definition = new Definition('Doctrine\Common\Persistence\ObjectManager');
$definition->setFactory([
new Reference('base.object_manager_provider'),
'getObjectManagerByEntityNamespace',
]);
$class = $this->resolveParameterName($container, $reducedMappingBag->getEntityClass());
$definition->setArguments([$class]);
$aliasName = ltrim(($mappingBag->getContainerPrefix().'.'.$mappingBag->getContainerObjectManagerName().'.'.$mappingBag->getEntityName()), '.');
$container->setDefinition(
$aliasName,
$definition
);
return $aliasName;
} | php | private function addObjectManager(
ContainerBuilder $container,
MappingBag $mappingBag
): string {
$reducedMappingBag = $mappingBag->getReducedMappingBag();
$definition = new Definition('Doctrine\Common\Persistence\ObjectManager');
$definition->setFactory([
new Reference('base.object_manager_provider'),
'getObjectManagerByEntityNamespace',
]);
$class = $this->resolveParameterName($container, $reducedMappingBag->getEntityClass());
$definition->setArguments([$class]);
$aliasName = ltrim(($mappingBag->getContainerPrefix().'.'.$mappingBag->getContainerObjectManagerName().'.'.$mappingBag->getEntityName()), '.');
$container->setDefinition(
$aliasName,
$definition
);
return $aliasName;
} | [
"private",
"function",
"addObjectManager",
"(",
"ContainerBuilder",
"$",
"container",
",",
"MappingBag",
"$",
"mappingBag",
")",
":",
"string",
"{",
"$",
"reducedMappingBag",
"=",
"$",
"mappingBag",
"->",
"getReducedMappingBag",
"(",
")",
";",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"'Doctrine\\Common\\Persistence\\ObjectManager'",
")",
";",
"$",
"definition",
"->",
"setFactory",
"(",
"[",
"new",
"Reference",
"(",
"'base.object_manager_provider'",
")",
",",
"'getObjectManagerByEntityNamespace'",
",",
"]",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"resolveParameterName",
"(",
"$",
"container",
",",
"$",
"reducedMappingBag",
"->",
"getEntityClass",
"(",
")",
")",
";",
"$",
"definition",
"->",
"setArguments",
"(",
"[",
"$",
"class",
"]",
")",
";",
"$",
"aliasName",
"=",
"ltrim",
"(",
"(",
"$",
"mappingBag",
"->",
"getContainerPrefix",
"(",
")",
".",
"'.'",
".",
"$",
"mappingBag",
"->",
"getContainerObjectManagerName",
"(",
")",
".",
"'.'",
".",
"$",
"mappingBag",
"->",
"getEntityName",
"(",
")",
")",
",",
"'.'",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"aliasName",
",",
"$",
"definition",
")",
";",
"return",
"$",
"aliasName",
";",
"}"
] | Add object manager alias and return the assigned name.
@param ContainerBuilder $container
@param MappingBag $mappingBag
@return string | [
"Add",
"object",
"manager",
"alias",
"and",
"return",
"the",
"assigned",
"name",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/CompilerPass/MappingCompilerPass.php#L113-L132 |
30,038 | mmoreram/BaseBundle | CompilerPass/MappingCompilerPass.php | MappingCompilerPass.addObjectDirector | private function addObjectDirector(
ContainerBuilder $container,
MappingBag $mappingBag,
string $objectManagerAliasName,
string $objectRepositoryAliasName
) {
$definition = new Definition('Mmoreram\BaseBundle\ORM\ObjectDirector');
$definition->setArguments([
new Reference($objectManagerAliasName),
new Reference($objectRepositoryAliasName),
]);
$definitionName = ltrim(($mappingBag->getContainerPrefix().'.object_director.'.$mappingBag->getEntityName()), '.');
$container->setDefinition(
$definitionName,
$definition
);
} | php | private function addObjectDirector(
ContainerBuilder $container,
MappingBag $mappingBag,
string $objectManagerAliasName,
string $objectRepositoryAliasName
) {
$definition = new Definition('Mmoreram\BaseBundle\ORM\ObjectDirector');
$definition->setArguments([
new Reference($objectManagerAliasName),
new Reference($objectRepositoryAliasName),
]);
$definitionName = ltrim(($mappingBag->getContainerPrefix().'.object_director.'.$mappingBag->getEntityName()), '.');
$container->setDefinition(
$definitionName,
$definition
);
} | [
"private",
"function",
"addObjectDirector",
"(",
"ContainerBuilder",
"$",
"container",
",",
"MappingBag",
"$",
"mappingBag",
",",
"string",
"$",
"objectManagerAliasName",
",",
"string",
"$",
"objectRepositoryAliasName",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"'Mmoreram\\BaseBundle\\ORM\\ObjectDirector'",
")",
";",
"$",
"definition",
"->",
"setArguments",
"(",
"[",
"new",
"Reference",
"(",
"$",
"objectManagerAliasName",
")",
",",
"new",
"Reference",
"(",
"$",
"objectRepositoryAliasName",
")",
",",
"]",
")",
";",
"$",
"definitionName",
"=",
"ltrim",
"(",
"(",
"$",
"mappingBag",
"->",
"getContainerPrefix",
"(",
")",
".",
"'.object_director.'",
".",
"$",
"mappingBag",
"->",
"getEntityName",
"(",
")",
")",
",",
"'.'",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"definitionName",
",",
"$",
"definition",
")",
";",
"}"
] | Add directors.
@param ContainerBuilder $container
@param MappingBag $mappingBag
@param string $objectManagerAliasName
@param string $objectRepositoryAliasName | [
"Add",
"directors",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/CompilerPass/MappingCompilerPass.php#L171-L187 |
30,039 | mmoreram/BaseBundle | CompilerPass/MappingCompilerPass.php | MappingCompilerPass.resolveParameterName | private function resolveParameterName(
ContainerBuilder $container,
$parameterName
) {
if (!is_string($parameterName)) {
return $parameterName;
}
return $container->hasParameter($parameterName)
? $container->getParameter($parameterName)
: $parameterName;
} | php | private function resolveParameterName(
ContainerBuilder $container,
$parameterName
) {
if (!is_string($parameterName)) {
return $parameterName;
}
return $container->hasParameter($parameterName)
? $container->getParameter($parameterName)
: $parameterName;
} | [
"private",
"function",
"resolveParameterName",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"parameterName",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"parameterName",
")",
")",
"{",
"return",
"$",
"parameterName",
";",
"}",
"return",
"$",
"container",
"->",
"hasParameter",
"(",
"$",
"parameterName",
")",
"?",
"$",
"container",
"->",
"getParameter",
"(",
"$",
"parameterName",
")",
":",
"$",
"parameterName",
";",
"}"
] | Return value of parameter name if exists
Return itself otherwise.
@param ContainerBuilder $container
@param mixed $parameterName
@return mixed | [
"Return",
"value",
"of",
"parameter",
"name",
"if",
"exists",
"Return",
"itself",
"otherwise",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/CompilerPass/MappingCompilerPass.php#L198-L209 |
30,040 | gyselroth/micro-auth | src/Adapter/Basic/Ldap.php | Ldap.plainAuth | public function plainAuth(string $username, string $password): bool
{
$resource = $this->ldap->getResource();
$esc_username = ldap_escape($username);
$filter = htmlspecialchars_decode(sprintf($this->account_filter, $esc_username));
$result = ldap_search($resource, $this->ldap->getBase(), $filter, ['dn', $this->identity_attribute]);
$entries = ldap_get_entries($resource, $result);
if (0 === $entries['count']) {
$this->logger->warning("user not found with ldap filter [{$filter}]", [
'category' => get_class($this),
]);
return false;
}
if ($entries['count'] > 1) {
$this->logger->warning("more than one user found with ldap filter [{$filter}]", [
'category' => get_class($this),
]);
return false;
}
$dn = $entries[0]['dn'];
$this->logger->info("found ldap user [{$dn}] with filter [{$filter}]", [
'category' => get_class($this),
]);
$result = ldap_bind($resource, $dn, $password);
$this->logger->info("bind ldap user [{$dn}]", [
'category' => get_class($this),
'result' => $result,
]);
if (false === $result) {
return false;
}
if (!isset($entries[0][$this->identity_attribute])) {
throw new Exception\IdentityAttributeNotFound('identity attribute not found');
}
$this->identifier = $entries[0][$this->identity_attribute][0];
$this->ldap_dn = $dn;
return true;
} | php | public function plainAuth(string $username, string $password): bool
{
$resource = $this->ldap->getResource();
$esc_username = ldap_escape($username);
$filter = htmlspecialchars_decode(sprintf($this->account_filter, $esc_username));
$result = ldap_search($resource, $this->ldap->getBase(), $filter, ['dn', $this->identity_attribute]);
$entries = ldap_get_entries($resource, $result);
if (0 === $entries['count']) {
$this->logger->warning("user not found with ldap filter [{$filter}]", [
'category' => get_class($this),
]);
return false;
}
if ($entries['count'] > 1) {
$this->logger->warning("more than one user found with ldap filter [{$filter}]", [
'category' => get_class($this),
]);
return false;
}
$dn = $entries[0]['dn'];
$this->logger->info("found ldap user [{$dn}] with filter [{$filter}]", [
'category' => get_class($this),
]);
$result = ldap_bind($resource, $dn, $password);
$this->logger->info("bind ldap user [{$dn}]", [
'category' => get_class($this),
'result' => $result,
]);
if (false === $result) {
return false;
}
if (!isset($entries[0][$this->identity_attribute])) {
throw new Exception\IdentityAttributeNotFound('identity attribute not found');
}
$this->identifier = $entries[0][$this->identity_attribute][0];
$this->ldap_dn = $dn;
return true;
} | [
"public",
"function",
"plainAuth",
"(",
"string",
"$",
"username",
",",
"string",
"$",
"password",
")",
":",
"bool",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"ldap",
"->",
"getResource",
"(",
")",
";",
"$",
"esc_username",
"=",
"ldap_escape",
"(",
"$",
"username",
")",
";",
"$",
"filter",
"=",
"htmlspecialchars_decode",
"(",
"sprintf",
"(",
"$",
"this",
"->",
"account_filter",
",",
"$",
"esc_username",
")",
")",
";",
"$",
"result",
"=",
"ldap_search",
"(",
"$",
"resource",
",",
"$",
"this",
"->",
"ldap",
"->",
"getBase",
"(",
")",
",",
"$",
"filter",
",",
"[",
"'dn'",
",",
"$",
"this",
"->",
"identity_attribute",
"]",
")",
";",
"$",
"entries",
"=",
"ldap_get_entries",
"(",
"$",
"resource",
",",
"$",
"result",
")",
";",
"if",
"(",
"0",
"===",
"$",
"entries",
"[",
"'count'",
"]",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"user not found with ldap filter [{$filter}]\"",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"entries",
"[",
"'count'",
"]",
">",
"1",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"\"more than one user found with ldap filter [{$filter}]\"",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"return",
"false",
";",
"}",
"$",
"dn",
"=",
"$",
"entries",
"[",
"0",
"]",
"[",
"'dn'",
"]",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"found ldap user [{$dn}] with filter [{$filter}]\"",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"$",
"result",
"=",
"ldap_bind",
"(",
"$",
"resource",
",",
"$",
"dn",
",",
"$",
"password",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"\"bind ldap user [{$dn}]\"",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"'result'",
"=>",
"$",
"result",
",",
"]",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"entries",
"[",
"0",
"]",
"[",
"$",
"this",
"->",
"identity_attribute",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"IdentityAttributeNotFound",
"(",
"'identity attribute not found'",
")",
";",
"}",
"$",
"this",
"->",
"identifier",
"=",
"$",
"entries",
"[",
"0",
"]",
"[",
"$",
"this",
"->",
"identity_attribute",
"]",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"ldap_dn",
"=",
"$",
"dn",
";",
"return",
"true",
";",
"}"
] | LDAP Auth.
@param string $username
@param string $password
@return bool | [
"LDAP",
"Auth",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Adapter/Basic/Ldap.php#L109-L156 |
30,041 | gyselroth/micro-auth | src/Auth.php | Auth.injectAdapter | public function injectAdapter(AdapterInterface $adapter, ?string $name = null): self
{
if (null === $name) {
$name = get_class($adapter);
}
$this->logger->debug('inject auth adapter ['.$name.'] of type ['.get_class($adapter).']', [
'category' => get_class($this),
]);
if ($this->hasAdapter($name)) {
throw new Exception\AdapterNotUnique('auth adapter '.$name.' is already registered');
}
$this->adapter[$name] = $adapter;
return $this;
} | php | public function injectAdapter(AdapterInterface $adapter, ?string $name = null): self
{
if (null === $name) {
$name = get_class($adapter);
}
$this->logger->debug('inject auth adapter ['.$name.'] of type ['.get_class($adapter).']', [
'category' => get_class($this),
]);
if ($this->hasAdapter($name)) {
throw new Exception\AdapterNotUnique('auth adapter '.$name.' is already registered');
}
$this->adapter[$name] = $adapter;
return $this;
} | [
"public",
"function",
"injectAdapter",
"(",
"AdapterInterface",
"$",
"adapter",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"self",
"{",
"if",
"(",
"null",
"===",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"get_class",
"(",
"$",
"adapter",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'inject auth adapter ['",
".",
"$",
"name",
".",
"'] of type ['",
".",
"get_class",
"(",
"$",
"adapter",
")",
".",
"']'",
",",
"[",
"'category'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasAdapter",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"AdapterNotUnique",
"(",
"'auth adapter '",
".",
"$",
"name",
".",
"' is already registered'",
")",
";",
"}",
"$",
"this",
"->",
"adapter",
"[",
"$",
"name",
"]",
"=",
"$",
"adapter",
";",
"return",
"$",
"this",
";",
"}"
] | Inject auth adapter.
@param AdapterInterface $adapter
@param string $name | [
"Inject",
"auth",
"adapter",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L113-L130 |
30,042 | gyselroth/micro-auth | src/Auth.php | Auth.getAdapter | public function getAdapter(string $name): AdapterInterface
{
if (!$this->hasAdapter($name)) {
throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered');
}
return $this->adapter[$name];
} | php | public function getAdapter(string $name): AdapterInterface
{
if (!$this->hasAdapter($name)) {
throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered');
}
return $this->adapter[$name];
} | [
"public",
"function",
"getAdapter",
"(",
"string",
"$",
"name",
")",
":",
"AdapterInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAdapter",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"AdapterNotFound",
"(",
"'auth adapter '",
".",
"$",
"name",
".",
"' is not registered'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"adapter",
"[",
"$",
"name",
"]",
";",
"}"
] | Get adapter.
@param string $name
@return AdapterInterface | [
"Get",
"adapter",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L139-L146 |
30,043 | gyselroth/micro-auth | src/Auth.php | Auth.getAdapters | public function getAdapters(array $adapters = []): array
{
if (empty($adapter)) {
return $this->adapter;
}
$list = [];
foreach ($adapter as $name) {
if (!$this->hasAdapter($name)) {
throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered');
}
$list[$name] = $this->adapter[$name];
}
return $list;
} | php | public function getAdapters(array $adapters = []): array
{
if (empty($adapter)) {
return $this->adapter;
}
$list = [];
foreach ($adapter as $name) {
if (!$this->hasAdapter($name)) {
throw new Exception\AdapterNotFound('auth adapter '.$name.' is not registered');
}
$list[$name] = $this->adapter[$name];
}
return $list;
} | [
"public",
"function",
"getAdapters",
"(",
"array",
"$",
"adapters",
"=",
"[",
"]",
")",
":",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"adapter",
")",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
";",
"}",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"adapter",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAdapter",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"AdapterNotFound",
"(",
"'auth adapter '",
".",
"$",
"name",
".",
"' is not registered'",
")",
";",
"}",
"$",
"list",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"adapter",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Get adapters.
@return AdapterInterface[] | [
"Get",
"adapters",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L153-L167 |
30,044 | gyselroth/micro-auth | src/Auth.php | Auth.createIdentity | public function createIdentity(AdapterInterface $adapter): IdentityInterface
{
$map = new $this->attribute_map_class($adapter->getAttributeMap(), $this->logger);
$this->identity = new $this->identity_class($adapter, $map, $this->logger);
return $this->identity;
} | php | public function createIdentity(AdapterInterface $adapter): IdentityInterface
{
$map = new $this->attribute_map_class($adapter->getAttributeMap(), $this->logger);
$this->identity = new $this->identity_class($adapter, $map, $this->logger);
return $this->identity;
} | [
"public",
"function",
"createIdentity",
"(",
"AdapterInterface",
"$",
"adapter",
")",
":",
"IdentityInterface",
"{",
"$",
"map",
"=",
"new",
"$",
"this",
"->",
"attribute_map_class",
"(",
"$",
"adapter",
"->",
"getAttributeMap",
"(",
")",
",",
"$",
"this",
"->",
"logger",
")",
";",
"$",
"this",
"->",
"identity",
"=",
"new",
"$",
"this",
"->",
"identity_class",
"(",
"$",
"adapter",
",",
"$",
"map",
",",
"$",
"this",
"->",
"logger",
")",
";",
"return",
"$",
"this",
"->",
"identity",
";",
"}"
] | Create identity.
@param AdapterInterface $adapter
@return IdentityInterface | [
"Create",
"identity",
"."
] | 9c08a6afc94f76635fb7d29f56fb8409e383677f | https://github.com/gyselroth/micro-auth/blob/9c08a6afc94f76635fb7d29f56fb8409e383677f/src/Auth.php#L242-L248 |
30,045 | mmoreram/BaseBundle | Kernel/BaseKernel.php | BaseKernel.configureContainer | protected function configureContainer(
ContainerBuilder $c,
LoaderInterface $loader
) {
$yamlContent = Yaml::dump($this->configuration);
$filePath = sys_get_temp_dir().'/base-test-'.rand(1, 9999999).'.yml';
file_put_contents($filePath, $yamlContent);
$loader->load($filePath);
unlink($filePath);
} | php | protected function configureContainer(
ContainerBuilder $c,
LoaderInterface $loader
) {
$yamlContent = Yaml::dump($this->configuration);
$filePath = sys_get_temp_dir().'/base-test-'.rand(1, 9999999).'.yml';
file_put_contents($filePath, $yamlContent);
$loader->load($filePath);
unlink($filePath);
} | [
"protected",
"function",
"configureContainer",
"(",
"ContainerBuilder",
"$",
"c",
",",
"LoaderInterface",
"$",
"loader",
")",
"{",
"$",
"yamlContent",
"=",
"Yaml",
"::",
"dump",
"(",
"$",
"this",
"->",
"configuration",
")",
";",
"$",
"filePath",
"=",
"sys_get_temp_dir",
"(",
")",
".",
"'/base-test-'",
".",
"rand",
"(",
"1",
",",
"9999999",
")",
".",
"'.yml'",
";",
"file_put_contents",
"(",
"$",
"filePath",
",",
"$",
"yamlContent",
")",
";",
"$",
"loader",
"->",
"load",
"(",
"$",
"filePath",
")",
";",
"unlink",
"(",
"$",
"filePath",
")",
";",
"}"
] | Configures the container.
You can register extensions:
$c->loadFromExtension('framework', array(
'secret' => '%secret%'
));
Or services:
$c->register('halloween', 'FooBundle\HalloweenProvider');
Or parameters:
$c->setParameter('halloween', 'lot of fun');
@param ContainerBuilder $c
@param LoaderInterface $loader | [
"Configures",
"the",
"container",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Kernel/BaseKernel.php#L130-L139 |
30,046 | mmoreram/BaseBundle | Kernel/BaseKernel.php | BaseKernel.configureRoutes | protected function configureRoutes(RouteCollectionBuilder $routes)
{
foreach ($this->routes as $route) {
is_array($route)
? $routes->add(
$route[0],
$route[1],
$route[2]
)
: $routes->import($route);
}
} | php | protected function configureRoutes(RouteCollectionBuilder $routes)
{
foreach ($this->routes as $route) {
is_array($route)
? $routes->add(
$route[0],
$route[1],
$route[2]
)
: $routes->import($route);
}
} | [
"protected",
"function",
"configureRoutes",
"(",
"RouteCollectionBuilder",
"$",
"routes",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"route",
")",
"{",
"is_array",
"(",
"$",
"route",
")",
"?",
"$",
"routes",
"->",
"add",
"(",
"$",
"route",
"[",
"0",
"]",
",",
"$",
"route",
"[",
"1",
"]",
",",
"$",
"route",
"[",
"2",
"]",
")",
":",
"$",
"routes",
"->",
"import",
"(",
"$",
"route",
")",
";",
"}",
"}"
] | Add or import routes into your application.
$routes->import('config/routing.yml');
$routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard');
@param RouteCollectionBuilder $routes | [
"Add",
"or",
"import",
"routes",
"into",
"your",
"application",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Kernel/BaseKernel.php#L149-L160 |
30,047 | mmoreram/BaseBundle | Kernel/BaseKernel.php | BaseKernel.sortArray | private function sortArray(&$element)
{
if (is_array($element)) {
array_walk($element, [$this, 'sortArray']);
array_key_exists(0, $element)
? sort($element)
: ksort($element);
}
} | php | private function sortArray(&$element)
{
if (is_array($element)) {
array_walk($element, [$this, 'sortArray']);
array_key_exists(0, $element)
? sort($element)
: ksort($element);
}
} | [
"private",
"function",
"sortArray",
"(",
"&",
"$",
"element",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"element",
")",
")",
"{",
"array_walk",
"(",
"$",
"element",
",",
"[",
"$",
"this",
",",
"'sortArray'",
"]",
")",
";",
"array_key_exists",
"(",
"0",
",",
"$",
"element",
")",
"?",
"sort",
"(",
"$",
"element",
")",
":",
"ksort",
"(",
"$",
"element",
")",
";",
"}",
"}"
] | Sort array's first level, taking in account if associative array or
sequential array.
@param mixed $element | [
"Sort",
"array",
"s",
"first",
"level",
"taking",
"in",
"account",
"if",
"associative",
"array",
"or",
"sequential",
"array",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Kernel/BaseKernel.php#L202-L210 |
30,048 | mmoreram/BaseBundle | SimpleBaseBundle.php | SimpleBaseBundle.getCompilerPasses | public function getCompilerPasses(): array
{
$mappingBagProvider = $this->getMappingBagProvider();
return $mappingBagProvider instanceof MappingBagProvider
? array_merge(
parent::getCompilerPasses(),
[new MappingCompilerPass($mappingBagProvider)]
)
: parent::getCompilerPasses();
} | php | public function getCompilerPasses(): array
{
$mappingBagProvider = $this->getMappingBagProvider();
return $mappingBagProvider instanceof MappingBagProvider
? array_merge(
parent::getCompilerPasses(),
[new MappingCompilerPass($mappingBagProvider)]
)
: parent::getCompilerPasses();
} | [
"public",
"function",
"getCompilerPasses",
"(",
")",
":",
"array",
"{",
"$",
"mappingBagProvider",
"=",
"$",
"this",
"->",
"getMappingBagProvider",
"(",
")",
";",
"return",
"$",
"mappingBagProvider",
"instanceof",
"MappingBagProvider",
"?",
"array_merge",
"(",
"parent",
"::",
"getCompilerPasses",
"(",
")",
",",
"[",
"new",
"MappingCompilerPass",
"(",
"$",
"mappingBagProvider",
")",
"]",
")",
":",
"parent",
"::",
"getCompilerPasses",
"(",
")",
";",
"}"
] | Return a CompilerPass instance array.
@return CompilerPassInterface[] | [
"Return",
"a",
"CompilerPass",
"instance",
"array",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/SimpleBaseBundle.php#L71-L81 |
30,049 | PackageFactory/atomic-fusion-proptypes | Classes/Validators/FloatValidator.php | FloatValidator.isValid | protected function isValid($value)
{
if (is_null($value) || is_float($value) || is_int($value)) {
return;
}
$this->addError('A valid float is expected.', 1514998717);
} | php | protected function isValid($value)
{
if (is_null($value) || is_float($value) || is_int($value)) {
return;
}
$this->addError('A valid float is expected.', 1514998717);
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"||",
"is_float",
"(",
"$",
"value",
")",
"||",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"addError",
"(",
"'A valid float is expected.'",
",",
"1514998717",
")",
";",
"}"
] | Checks if the given value is a valid float.
@param mixed $value The value that should be validated
@return void | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"a",
"valid",
"float",
"."
] | cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c | https://github.com/PackageFactory/atomic-fusion-proptypes/blob/cf872a5c82c2c7d05b0be850b90307e0c3b4ee4c/Classes/Validators/FloatValidator.php#L20-L26 |
30,050 | hostnet/entity-plugin-lib | src/Compound/CompoundGenerator.php | CompoundGenerator.generate | public function generate(EntityPackage $entity_package)
{
$classes = $this->content_provider->getPackageContent($entity_package)->getClasses();
foreach ($classes as $package_class) {
/* @var $package_class PackageClass */
$this->writeIfDebug(
' - Finding traits for <info>' . $package_class->getName() . '</info>.'
);
$traits = $this->recursivelyFindUseStatementsFor($entity_package, $package_class);
$this->generateTrait($package_class, array_unique($traits, SORT_REGULAR));
}
} | php | public function generate(EntityPackage $entity_package)
{
$classes = $this->content_provider->getPackageContent($entity_package)->getClasses();
foreach ($classes as $package_class) {
/* @var $package_class PackageClass */
$this->writeIfDebug(
' - Finding traits for <info>' . $package_class->getName() . '</info>.'
);
$traits = $this->recursivelyFindUseStatementsFor($entity_package, $package_class);
$this->generateTrait($package_class, array_unique($traits, SORT_REGULAR));
}
} | [
"public",
"function",
"generate",
"(",
"EntityPackage",
"$",
"entity_package",
")",
"{",
"$",
"classes",
"=",
"$",
"this",
"->",
"content_provider",
"->",
"getPackageContent",
"(",
"$",
"entity_package",
")",
"->",
"getClasses",
"(",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"package_class",
")",
"{",
"/* @var $package_class PackageClass */",
"$",
"this",
"->",
"writeIfDebug",
"(",
"' - Finding traits for <info>'",
".",
"$",
"package_class",
"->",
"getName",
"(",
")",
".",
"'</info>.'",
")",
";",
"$",
"traits",
"=",
"$",
"this",
"->",
"recursivelyFindUseStatementsFor",
"(",
"$",
"entity_package",
",",
"$",
"package_class",
")",
";",
"$",
"this",
"->",
"generateTrait",
"(",
"$",
"package_class",
",",
"array_unique",
"(",
"$",
"traits",
",",
"SORT_REGULAR",
")",
")",
";",
"}",
"}"
] | Ask the generator to generate all the trait of traits, and their matching combined interfaces
@return void | [
"Ask",
"the",
"generator",
"to",
"generate",
"all",
"the",
"trait",
"of",
"traits",
"and",
"their",
"matching",
"combined",
"interfaces"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Compound/CompoundGenerator.php#L52-L63 |
30,051 | hostnet/entity-plugin-lib | src/Compound/CompoundGenerator.php | CompoundGenerator.doesEntityExistInTree | private function doesEntityExistInTree(EntityPackage $entity_package, $requirement)
{
foreach ($entity_package->getFlattenedRequiredPackages() as $required_entity_package) {
if ($required_entity_package->getEntityContent()->hasClass($requirement)) {
return true;
}
}
return false;
} | php | private function doesEntityExistInTree(EntityPackage $entity_package, $requirement)
{
foreach ($entity_package->getFlattenedRequiredPackages() as $required_entity_package) {
if ($required_entity_package->getEntityContent()->hasClass($requirement)) {
return true;
}
}
return false;
} | [
"private",
"function",
"doesEntityExistInTree",
"(",
"EntityPackage",
"$",
"entity_package",
",",
"$",
"requirement",
")",
"{",
"foreach",
"(",
"$",
"entity_package",
"->",
"getFlattenedRequiredPackages",
"(",
")",
"as",
"$",
"required_entity_package",
")",
"{",
"if",
"(",
"$",
"required_entity_package",
"->",
"getEntityContent",
"(",
")",
"->",
"hasClass",
"(",
"$",
"requirement",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | In all other cases within this class, we use the PackageContentProvider to get the package
content. In this case we bypass it since we really want to know whether the entity exists.
@param EntityPackage $entity_package
@param string $requirement
@return boolean | [
"In",
"all",
"other",
"cases",
"within",
"this",
"class",
"we",
"use",
"the",
"PackageContentProvider",
"to",
"get",
"the",
"package",
"content",
".",
"In",
"this",
"case",
"we",
"bypass",
"it",
"since",
"we",
"really",
"want",
"to",
"know",
"whether",
"the",
"entity",
"exists",
"."
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Compound/CompoundGenerator.php#L72-L80 |
30,052 | hostnet/entity-plugin-lib | src/Compound/CompoundGenerator.php | CompoundGenerator.recursivelyFindUseStatementsFor | private function recursivelyFindUseStatementsFor(
EntityPackage $entity_package,
PackageClass $package_class,
array &$checked = []
) {
$result = [];
$entity_package_name = $entity_package->getPackage()->getName();
if (isset($checked[$entity_package_name])) {
return $result;
} else {
$checked[$entity_package_name] = true;
}
foreach ($entity_package->getDependentPackages() as $name => $dependent_package) {
/* @var $dependent_package EntityPackage */
$use_statements = $this->recursivelyFindUseStatementsFor($dependent_package, $package_class, $checked);
$result = array_merge($result, $use_statements);
}
$this->writeIfDebug(
' - Scanning for traits in <info>' . $entity_package->getPackage()->getName() . '</info>.'
);
$contents = $this->content_provider->getPackageContent($entity_package);
$traits = $contents->getOptionalTraits($package_class->getShortName());
foreach ($traits as $trait) {
/* @var $trait \Hostnet\Component\EntityPlugin\OptionalPackageTrait */
$requirement = $trait->getRequirement();
if ($this->doesEntityExistInTree($entity_package, $requirement)) {
$result[] = $trait;
$this->writeIfDebug(
' Injected <info>' . $trait->getName() . '</info> from <info>' .
$entity_package->getPackage()->getName() .
'</info>.'
);
} else {
$this->writeIfDebug(
' Not injected <warn>' . $trait->getName() . '</warn> from <info>' .
$entity_package->getPackage()->getName() . ' because ' . $requirement . ' is not found</info>.'
);
}
}
$package_class = $contents->getClassOrTrait($package_class->getShortName());
if ($package_class) {
$result[] = $package_class;
$this->writeIfDebug(
' Found <info>' . $package_class->getName() . '</info> in <info>'
. $entity_package->getPackage()->getName() . '</info>.'
);
}
return $result;
} | php | private function recursivelyFindUseStatementsFor(
EntityPackage $entity_package,
PackageClass $package_class,
array &$checked = []
) {
$result = [];
$entity_package_name = $entity_package->getPackage()->getName();
if (isset($checked[$entity_package_name])) {
return $result;
} else {
$checked[$entity_package_name] = true;
}
foreach ($entity_package->getDependentPackages() as $name => $dependent_package) {
/* @var $dependent_package EntityPackage */
$use_statements = $this->recursivelyFindUseStatementsFor($dependent_package, $package_class, $checked);
$result = array_merge($result, $use_statements);
}
$this->writeIfDebug(
' - Scanning for traits in <info>' . $entity_package->getPackage()->getName() . '</info>.'
);
$contents = $this->content_provider->getPackageContent($entity_package);
$traits = $contents->getOptionalTraits($package_class->getShortName());
foreach ($traits as $trait) {
/* @var $trait \Hostnet\Component\EntityPlugin\OptionalPackageTrait */
$requirement = $trait->getRequirement();
if ($this->doesEntityExistInTree($entity_package, $requirement)) {
$result[] = $trait;
$this->writeIfDebug(
' Injected <info>' . $trait->getName() . '</info> from <info>' .
$entity_package->getPackage()->getName() .
'</info>.'
);
} else {
$this->writeIfDebug(
' Not injected <warn>' . $trait->getName() . '</warn> from <info>' .
$entity_package->getPackage()->getName() . ' because ' . $requirement . ' is not found</info>.'
);
}
}
$package_class = $contents->getClassOrTrait($package_class->getShortName());
if ($package_class) {
$result[] = $package_class;
$this->writeIfDebug(
' Found <info>' . $package_class->getName() . '</info> in <info>'
. $entity_package->getPackage()->getName() . '</info>.'
);
}
return $result;
} | [
"private",
"function",
"recursivelyFindUseStatementsFor",
"(",
"EntityPackage",
"$",
"entity_package",
",",
"PackageClass",
"$",
"package_class",
",",
"array",
"&",
"$",
"checked",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"entity_package_name",
"=",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"checked",
"[",
"$",
"entity_package_name",
"]",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"$",
"checked",
"[",
"$",
"entity_package_name",
"]",
"=",
"true",
";",
"}",
"foreach",
"(",
"$",
"entity_package",
"->",
"getDependentPackages",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"dependent_package",
")",
"{",
"/* @var $dependent_package EntityPackage */",
"$",
"use_statements",
"=",
"$",
"this",
"->",
"recursivelyFindUseStatementsFor",
"(",
"$",
"dependent_package",
",",
"$",
"package_class",
",",
"$",
"checked",
")",
";",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"use_statements",
")",
";",
"}",
"$",
"this",
"->",
"writeIfDebug",
"(",
"' - Scanning for traits in <info>'",
".",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'</info>.'",
")",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"content_provider",
"->",
"getPackageContent",
"(",
"$",
"entity_package",
")",
";",
"$",
"traits",
"=",
"$",
"contents",
"->",
"getOptionalTraits",
"(",
"$",
"package_class",
"->",
"getShortName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"/* @var $trait \\Hostnet\\Component\\EntityPlugin\\OptionalPackageTrait */",
"$",
"requirement",
"=",
"$",
"trait",
"->",
"getRequirement",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"doesEntityExistInTree",
"(",
"$",
"entity_package",
",",
"$",
"requirement",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"trait",
";",
"$",
"this",
"->",
"writeIfDebug",
"(",
"' Injected <info>'",
".",
"$",
"trait",
"->",
"getName",
"(",
")",
".",
"'</info> from <info>'",
".",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'</info>.'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"writeIfDebug",
"(",
"' Not injected <warn>'",
".",
"$",
"trait",
"->",
"getName",
"(",
")",
".",
"'</warn> from <info>'",
".",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
".",
"' because '",
".",
"$",
"requirement",
".",
"' is not found</info>.'",
")",
";",
"}",
"}",
"$",
"package_class",
"=",
"$",
"contents",
"->",
"getClassOrTrait",
"(",
"$",
"package_class",
"->",
"getShortName",
"(",
")",
")",
";",
"if",
"(",
"$",
"package_class",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"package_class",
";",
"$",
"this",
"->",
"writeIfDebug",
"(",
"' Found <info>'",
".",
"$",
"package_class",
"->",
"getName",
"(",
")",
".",
"'</info> in <info>'",
".",
"$",
"entity_package",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
".",
"'</info>.'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Gives all the entities to be required in the compound interface
Also generates a unique alias for them
@param EntityPackage $entity_package
@param PackageClass $package_class
@param array $checked list of checked packages to prevent recursion errors
@return UseStatement[] | [
"Gives",
"all",
"the",
"entities",
"to",
"be",
"required",
"in",
"the",
"compound",
"interface",
"Also",
"generates",
"a",
"unique",
"alias",
"for",
"them"
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/Compound/CompoundGenerator.php#L91-L145 |
30,053 | mmoreram/BaseBundle | DependencyInjection/BaseExtension.php | BaseExtension.applyParametrizedValues | private function applyParametrizedValues(
array $config,
ContainerBuilder $container
) {
$parametrizationValues = $this->getParametrizationValues($config);
if (is_array($parametrizationValues)) {
$container
->getParameterBag()
->add($parametrizationValues);
}
} | php | private function applyParametrizedValues(
array $config,
ContainerBuilder $container
) {
$parametrizationValues = $this->getParametrizationValues($config);
if (is_array($parametrizationValues)) {
$container
->getParameterBag()
->add($parametrizationValues);
}
} | [
"private",
"function",
"applyParametrizedValues",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"parametrizationValues",
"=",
"$",
"this",
"->",
"getParametrizationValues",
"(",
"$",
"config",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"parametrizationValues",
")",
")",
"{",
"$",
"container",
"->",
"getParameterBag",
"(",
")",
"->",
"add",
"(",
"$",
"parametrizationValues",
")",
";",
"}",
"}"
] | Apply parametrized values.
@param array $config
@param ContainerBuilder $container | [
"Apply",
"parametrized",
"values",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseExtension.php#L264-L274 |
30,054 | mmoreram/BaseBundle | DependencyInjection/BaseExtension.php | BaseExtension.applyMappingParametrization | private function applyMappingParametrization(
array $config,
ContainerBuilder $container
) {
if (!$this->mappingBagProvider instanceof MappingBagProvider) {
return;
}
$mappingBagCollection = $this
->mappingBagProvider
->getMappingBagCollection();
$mappedParameters = [];
foreach ($mappingBagCollection->all() as $mappingBag) {
$entityName = $mappingBag->getEntityName();
$isOverwritable = $mappingBag->isOverwritable();
$mappedParameters = array_merge($mappedParameters, [
$mappingBag->getParamFormat('class') => $isOverwritable
? $config['mapping'][$entityName]['class']
: $mappingBag->getEntityNamespace(),
$mappingBag->getParamFormat('mapping_file') => $isOverwritable
? $config['mapping'][$entityName]['mapping_file']
: $mappingBag->getEntityMappingFilePath(),
$mappingBag->getParamFormat('manager') => $isOverwritable
? $config['mapping'][$entityName]['manager']
: $mappingBag->getManagerName(),
$mappingBag->getParamFormat('enabled') => $isOverwritable
? $config['mapping'][$entityName]['enabled']
: $mappingBag->getEntityIsEnabled(),
]);
}
$container
->getParameterBag()
->add($mappedParameters);
} | php | private function applyMappingParametrization(
array $config,
ContainerBuilder $container
) {
if (!$this->mappingBagProvider instanceof MappingBagProvider) {
return;
}
$mappingBagCollection = $this
->mappingBagProvider
->getMappingBagCollection();
$mappedParameters = [];
foreach ($mappingBagCollection->all() as $mappingBag) {
$entityName = $mappingBag->getEntityName();
$isOverwritable = $mappingBag->isOverwritable();
$mappedParameters = array_merge($mappedParameters, [
$mappingBag->getParamFormat('class') => $isOverwritable
? $config['mapping'][$entityName]['class']
: $mappingBag->getEntityNamespace(),
$mappingBag->getParamFormat('mapping_file') => $isOverwritable
? $config['mapping'][$entityName]['mapping_file']
: $mappingBag->getEntityMappingFilePath(),
$mappingBag->getParamFormat('manager') => $isOverwritable
? $config['mapping'][$entityName]['manager']
: $mappingBag->getManagerName(),
$mappingBag->getParamFormat('enabled') => $isOverwritable
? $config['mapping'][$entityName]['enabled']
: $mappingBag->getEntityIsEnabled(),
]);
}
$container
->getParameterBag()
->add($mappedParameters);
} | [
"private",
"function",
"applyMappingParametrization",
"(",
"array",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"mappingBagProvider",
"instanceof",
"MappingBagProvider",
")",
"{",
"return",
";",
"}",
"$",
"mappingBagCollection",
"=",
"$",
"this",
"->",
"mappingBagProvider",
"->",
"getMappingBagCollection",
"(",
")",
";",
"$",
"mappedParameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mappingBagCollection",
"->",
"all",
"(",
")",
"as",
"$",
"mappingBag",
")",
"{",
"$",
"entityName",
"=",
"$",
"mappingBag",
"->",
"getEntityName",
"(",
")",
";",
"$",
"isOverwritable",
"=",
"$",
"mappingBag",
"->",
"isOverwritable",
"(",
")",
";",
"$",
"mappedParameters",
"=",
"array_merge",
"(",
"$",
"mappedParameters",
",",
"[",
"$",
"mappingBag",
"->",
"getParamFormat",
"(",
"'class'",
")",
"=>",
"$",
"isOverwritable",
"?",
"$",
"config",
"[",
"'mapping'",
"]",
"[",
"$",
"entityName",
"]",
"[",
"'class'",
"]",
":",
"$",
"mappingBag",
"->",
"getEntityNamespace",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getParamFormat",
"(",
"'mapping_file'",
")",
"=>",
"$",
"isOverwritable",
"?",
"$",
"config",
"[",
"'mapping'",
"]",
"[",
"$",
"entityName",
"]",
"[",
"'mapping_file'",
"]",
":",
"$",
"mappingBag",
"->",
"getEntityMappingFilePath",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getParamFormat",
"(",
"'manager'",
")",
"=>",
"$",
"isOverwritable",
"?",
"$",
"config",
"[",
"'mapping'",
"]",
"[",
"$",
"entityName",
"]",
"[",
"'manager'",
"]",
":",
"$",
"mappingBag",
"->",
"getManagerName",
"(",
")",
",",
"$",
"mappingBag",
"->",
"getParamFormat",
"(",
"'enabled'",
")",
"=>",
"$",
"isOverwritable",
"?",
"$",
"config",
"[",
"'mapping'",
"]",
"[",
"$",
"entityName",
"]",
"[",
"'enabled'",
"]",
":",
"$",
"mappingBag",
"->",
"getEntityIsEnabled",
"(",
")",
",",
"]",
")",
";",
"}",
"$",
"container",
"->",
"getParameterBag",
"(",
")",
"->",
"add",
"(",
"$",
"mappedParameters",
")",
";",
"}"
] | Apply parametrization for Mapping data.
This method is only applied if the extension implements
EntitiesMappedExtension.
@param array $config
@param ContainerBuilder $container | [
"Apply",
"parametrization",
"for",
"Mapping",
"data",
".",
"This",
"method",
"is",
"only",
"applied",
"if",
"the",
"extension",
"implements",
"EntitiesMappedExtension",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseExtension.php#L284-L319 |
30,055 | mmoreram/BaseBundle | DependencyInjection/BaseExtension.php | BaseExtension.loadFiles | private function loadFiles(array $configFiles, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator($this->getConfigFilesLocation()));
foreach ($configFiles as $configFile) {
if (is_array($configFile)) {
if (isset($configFile[1]) && false === $configFile[1]) {
continue;
}
$configFile = $configFile[0];
}
$loader->load($configFile.'.yml');
}
} | php | private function loadFiles(array $configFiles, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator($this->getConfigFilesLocation()));
foreach ($configFiles as $configFile) {
if (is_array($configFile)) {
if (isset($configFile[1]) && false === $configFile[1]) {
continue;
}
$configFile = $configFile[0];
}
$loader->load($configFile.'.yml');
}
} | [
"private",
"function",
"loadFiles",
"(",
"array",
"$",
"configFiles",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"loader",
"=",
"new",
"YamlFileLoader",
"(",
"$",
"container",
",",
"new",
"FileLocator",
"(",
"$",
"this",
"->",
"getConfigFilesLocation",
"(",
")",
")",
")",
";",
"foreach",
"(",
"$",
"configFiles",
"as",
"$",
"configFile",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"configFile",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"configFile",
"[",
"1",
"]",
")",
"&&",
"false",
"===",
"$",
"configFile",
"[",
"1",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"configFile",
"=",
"$",
"configFile",
"[",
"0",
"]",
";",
"}",
"$",
"loader",
"->",
"load",
"(",
"$",
"configFile",
".",
"'.yml'",
")",
";",
"}",
"}"
] | Load multiple files.
@param array $configFiles Config files
@param ContainerBuilder $container Container | [
"Load",
"multiple",
"files",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseExtension.php#L327-L342 |
30,056 | mmoreram/BaseBundle | Mapping/MappingBagCollection.php | MappingBagCollection.create | public static function create(
array $entities,
string $bundleNamespace,
string $componentNamespace,
string $containerPrefix = '',
string $managerName = 'default',
string $containerObjectManagerName = 'object_manager',
string $containerObjectRepositoryName = 'object_repository',
bool $isOverwritable = false
): MappingBagCollection {
$mappingBagCollection = new self();
foreach ($entities as $entityName => $entityClass) {
$mappingBagCollection
->addMappingBag(new MappingBag(
$bundleNamespace,
$componentNamespace,
$entityName,
$entityClass,
'Resources/config/doctrine/'.$entityClass.'.orm.yml',
$managerName,
true,
$containerObjectManagerName,
$containerObjectRepositoryName,
$containerPrefix,
$isOverwritable
));
}
return $mappingBagCollection;
} | php | public static function create(
array $entities,
string $bundleNamespace,
string $componentNamespace,
string $containerPrefix = '',
string $managerName = 'default',
string $containerObjectManagerName = 'object_manager',
string $containerObjectRepositoryName = 'object_repository',
bool $isOverwritable = false
): MappingBagCollection {
$mappingBagCollection = new self();
foreach ($entities as $entityName => $entityClass) {
$mappingBagCollection
->addMappingBag(new MappingBag(
$bundleNamespace,
$componentNamespace,
$entityName,
$entityClass,
'Resources/config/doctrine/'.$entityClass.'.orm.yml',
$managerName,
true,
$containerObjectManagerName,
$containerObjectRepositoryName,
$containerPrefix,
$isOverwritable
));
}
return $mappingBagCollection;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"entities",
",",
"string",
"$",
"bundleNamespace",
",",
"string",
"$",
"componentNamespace",
",",
"string",
"$",
"containerPrefix",
"=",
"''",
",",
"string",
"$",
"managerName",
"=",
"'default'",
",",
"string",
"$",
"containerObjectManagerName",
"=",
"'object_manager'",
",",
"string",
"$",
"containerObjectRepositoryName",
"=",
"'object_repository'",
",",
"bool",
"$",
"isOverwritable",
"=",
"false",
")",
":",
"MappingBagCollection",
"{",
"$",
"mappingBagCollection",
"=",
"new",
"self",
"(",
")",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entityName",
"=>",
"$",
"entityClass",
")",
"{",
"$",
"mappingBagCollection",
"->",
"addMappingBag",
"(",
"new",
"MappingBag",
"(",
"$",
"bundleNamespace",
",",
"$",
"componentNamespace",
",",
"$",
"entityName",
",",
"$",
"entityClass",
",",
"'Resources/config/doctrine/'",
".",
"$",
"entityClass",
".",
"'.orm.yml'",
",",
"$",
"managerName",
",",
"true",
",",
"$",
"containerObjectManagerName",
",",
"$",
"containerObjectRepositoryName",
",",
"$",
"containerPrefix",
",",
"$",
"isOverwritable",
")",
")",
";",
"}",
"return",
"$",
"mappingBagCollection",
";",
"}"
] | Create by shortcut bloc.
@param array $entities
@param string $bundleNamespace
@param string $componentNamespace
@param string $containerPrefix
@param string $managerName
@param string $containerObjectManagerName
@param string $containerObjectRepositoryName
@param bool $isOverwritable
@return MappingBagCollection | [
"Create",
"by",
"shortcut",
"bloc",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/Mapping/MappingBagCollection.php#L64-L93 |
30,057 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.getObjectRepository | protected function getObjectRepository(string $entityNamespace): ? ObjectRepository
{
return $this
->get('base.object_repository_provider')
->getObjectRepositoryByEntityNamespace(
$this->locateEntity($entityNamespace)
);
} | php | protected function getObjectRepository(string $entityNamespace): ? ObjectRepository
{
return $this
->get('base.object_repository_provider')
->getObjectRepositoryByEntityNamespace(
$this->locateEntity($entityNamespace)
);
} | [
"protected",
"function",
"getObjectRepository",
"(",
"string",
"$",
"entityNamespace",
")",
":",
"?",
"ObjectRepository",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'base.object_repository_provider'",
")",
"->",
"getObjectRepositoryByEntityNamespace",
"(",
"$",
"this",
"->",
"locateEntity",
"(",
"$",
"entityNamespace",
")",
")",
";",
"}"
] | Get object repository given an entity namespace.
@param string $entityNamespace
@return ObjectRepository|null | [
"Get",
"object",
"repository",
"given",
"an",
"entity",
"namespace",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L77-L84 |
30,058 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.getObjectManager | protected function getObjectManager(string $entityNamespace): ? ObjectManager
{
return $this
->get('base.object_manager_provider')
->getObjectManagerByEntityNamespace(
$this->locateEntity($entityNamespace)
);
} | php | protected function getObjectManager(string $entityNamespace): ? ObjectManager
{
return $this
->get('base.object_manager_provider')
->getObjectManagerByEntityNamespace(
$this->locateEntity($entityNamespace)
);
} | [
"protected",
"function",
"getObjectManager",
"(",
"string",
"$",
"entityNamespace",
")",
":",
"?",
"ObjectManager",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'base.object_manager_provider'",
")",
"->",
"getObjectManagerByEntityNamespace",
"(",
"$",
"this",
"->",
"locateEntity",
"(",
"$",
"entityNamespace",
")",
")",
";",
"}"
] | Get object manager given an entity namespace.
@param string $entityNamespace
@return ObjectManager|null | [
"Get",
"object",
"manager",
"given",
"an",
"entity",
"namespace",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L93-L100 |
30,059 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.findOneBy | public function findOneBy(
string $entityNamespace,
array $criteria
) {
return $this
->getObjectRepository($this->locateEntity($entityNamespace))
->findOneBy($criteria);
} | php | public function findOneBy(
string $entityNamespace,
array $criteria
) {
return $this
->getObjectRepository($this->locateEntity($entityNamespace))
->findOneBy($criteria);
} | [
"public",
"function",
"findOneBy",
"(",
"string",
"$",
"entityNamespace",
",",
"array",
"$",
"criteria",
")",
"{",
"return",
"$",
"this",
"->",
"getObjectRepository",
"(",
"$",
"this",
"->",
"locateEntity",
"(",
"$",
"entityNamespace",
")",
")",
"->",
"findOneBy",
"(",
"$",
"criteria",
")",
";",
"}"
] | Get the entity instance with criteria.
@param string $entityNamespace
@param array $criteria
@return object | [
"Get",
"the",
"entity",
"instance",
"with",
"criteria",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L127-L134 |
30,060 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.findBy | public function findBy(
string $entityNamespace,
array $criteria
): array {
return $this
->getObjectRepository($this->locateEntity($entityNamespace))
->findBy($criteria);
} | php | public function findBy(
string $entityNamespace,
array $criteria
): array {
return $this
->getObjectRepository($this->locateEntity($entityNamespace))
->findBy($criteria);
} | [
"public",
"function",
"findBy",
"(",
"string",
"$",
"entityNamespace",
",",
"array",
"$",
"criteria",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"getObjectRepository",
"(",
"$",
"this",
"->",
"locateEntity",
"(",
"$",
"entityNamespace",
")",
")",
"->",
"findBy",
"(",
"$",
"criteria",
")",
";",
"}"
] | Get all entity instances.
@param string $entityNamespace
@param array $criteria
@return array | [
"Get",
"all",
"entity",
"instances",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L158-L165 |
30,061 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.clear | public function clear(string $entityNamespace)
{
$entityNamespace = $this->locateEntity($entityNamespace);
$this
->getObjectManager($entityNamespace)
->clear($entityNamespace);
} | php | public function clear(string $entityNamespace)
{
$entityNamespace = $this->locateEntity($entityNamespace);
$this
->getObjectManager($entityNamespace)
->clear($entityNamespace);
} | [
"public",
"function",
"clear",
"(",
"string",
"$",
"entityNamespace",
")",
"{",
"$",
"entityNamespace",
"=",
"$",
"this",
"->",
"locateEntity",
"(",
"$",
"entityNamespace",
")",
";",
"$",
"this",
"->",
"getObjectManager",
"(",
"$",
"entityNamespace",
")",
"->",
"clear",
"(",
"$",
"entityNamespace",
")",
";",
"}"
] | Clear the object manager tracking of an entity.
@param string $entityNamespace | [
"Clear",
"the",
"object",
"manager",
"tracking",
"of",
"an",
"entity",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L172-L178 |
30,062 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.save | protected function save($entities)
{
if (!is_array($entities)) {
$entities = [$entities];
}
foreach ($entities as $entity) {
$entityClass = get_class($entity);
$entityManager = $this
->get('base.object_manager_provider')
->getObjectManagerByEntityNamespace($entityClass);
$entityManager->persist($entity);
$entityManager->flush($entity);
}
} | php | protected function save($entities)
{
if (!is_array($entities)) {
$entities = [$entities];
}
foreach ($entities as $entity) {
$entityClass = get_class($entity);
$entityManager = $this
->get('base.object_manager_provider')
->getObjectManagerByEntityNamespace($entityClass);
$entityManager->persist($entity);
$entityManager->flush($entity);
}
} | [
"protected",
"function",
"save",
"(",
"$",
"entities",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"entities",
")",
")",
"{",
"$",
"entities",
"=",
"[",
"$",
"entities",
"]",
";",
"}",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"entityClass",
"=",
"get_class",
"(",
"$",
"entity",
")",
";",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'base.object_manager_provider'",
")",
"->",
"getObjectManagerByEntityNamespace",
"(",
"$",
"entityClass",
")",
";",
"$",
"entityManager",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"$",
"entityManager",
"->",
"flush",
"(",
"$",
"entity",
")",
";",
"}",
"}"
] | Save entity or array of entities.
@param mixed $entities | [
"Save",
"entity",
"or",
"array",
"of",
"entities",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L185-L199 |
30,063 | mmoreram/BaseBundle | DependencyInjection/BaseContainerAccessor.php | BaseContainerAccessor.locateEntity | private function locateEntity($entityAlias)
{
if (1 === preg_match('/^.*?\\.entity\\..*?\\.class$/', $entityAlias)) {
if (self::$container->hasParameter($entityAlias)) {
return $this->getParameter($entityAlias);
}
}
if (1 === preg_match('/^[^:]+:[^:]+$/', $entityAlias)) {
$possibleEntityAliasShortMapping = str_replace(':', '.entity.', $entityAlias.'.class');
if (self::$container->hasParameter($possibleEntityAliasShortMapping)) {
return $this->getParameter($possibleEntityAliasShortMapping);
}
}
return $entityAlias;
} | php | private function locateEntity($entityAlias)
{
if (1 === preg_match('/^.*?\\.entity\\..*?\\.class$/', $entityAlias)) {
if (self::$container->hasParameter($entityAlias)) {
return $this->getParameter($entityAlias);
}
}
if (1 === preg_match('/^[^:]+:[^:]+$/', $entityAlias)) {
$possibleEntityAliasShortMapping = str_replace(':', '.entity.', $entityAlias.'.class');
if (self::$container->hasParameter($possibleEntityAliasShortMapping)) {
return $this->getParameter($possibleEntityAliasShortMapping);
}
}
return $entityAlias;
} | [
"private",
"function",
"locateEntity",
"(",
"$",
"entityAlias",
")",
"{",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'/^.*?\\\\.entity\\\\..*?\\\\.class$/'",
",",
"$",
"entityAlias",
")",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"container",
"->",
"hasParameter",
"(",
"$",
"entityAlias",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getParameter",
"(",
"$",
"entityAlias",
")",
";",
"}",
"}",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'/^[^:]+:[^:]+$/'",
",",
"$",
"entityAlias",
")",
")",
"{",
"$",
"possibleEntityAliasShortMapping",
"=",
"str_replace",
"(",
"':'",
",",
"'.entity.'",
",",
"$",
"entityAlias",
".",
"'.class'",
")",
";",
"if",
"(",
"self",
"::",
"$",
"container",
"->",
"hasParameter",
"(",
"$",
"possibleEntityAliasShortMapping",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getParameter",
"(",
"$",
"possibleEntityAliasShortMapping",
")",
";",
"}",
"}",
"return",
"$",
"entityAlias",
";",
"}"
] | Get entity locator given a string.
Available formats:
MyBundle\Entity\Namespace\User - Namespace
MyBundle:User - Doctrine short alias
my_prefix:user - When using short DoctrineExtraMapping, prefix:name
my_prefix.entity.user.class - When using DoctrineExtraMapping class param
@param string $entityAlias
@return string | [
"Get",
"entity",
"locator",
"given",
"a",
"string",
"."
] | 5df60df71a659631cb95afd38c8884eda01d418b | https://github.com/mmoreram/BaseBundle/blob/5df60df71a659631cb95afd38c8884eda01d418b/DependencyInjection/BaseContainerAccessor.php#L215-L231 |
30,064 | hostnet/entity-plugin-lib | src/ReflectionParameter.php | ReflectionParameter.getPhpSafeDefaultValue | public function getPhpSafeDefaultValue()
{
$value = $this->getDefaultValue();
$is_string = $this->hasType() && $this->getType()->getName() === 'string';
if ($value === true) {
return 'true';
} elseif ($value === false) {
return 'false';
} elseif ($this->isDefaultValueConstant()) {
if (strpos($this->getDefaultValueConstantName(), 'self') === 0) {
return $this->getDefaultValueConstantName();
}
return '\\' . $this->getDefaultValueConstantName();
} elseif (is_array($value)) {
return '[]';
} elseif (null === $value || ($is_string && $value === 'null' && $this->allowsNull())) {
return 'null';
} elseif (is_numeric($value) && !$is_string) {
return (string) $value;
}
return var_export($value, true);
} | php | public function getPhpSafeDefaultValue()
{
$value = $this->getDefaultValue();
$is_string = $this->hasType() && $this->getType()->getName() === 'string';
if ($value === true) {
return 'true';
} elseif ($value === false) {
return 'false';
} elseif ($this->isDefaultValueConstant()) {
if (strpos($this->getDefaultValueConstantName(), 'self') === 0) {
return $this->getDefaultValueConstantName();
}
return '\\' . $this->getDefaultValueConstantName();
} elseif (is_array($value)) {
return '[]';
} elseif (null === $value || ($is_string && $value === 'null' && $this->allowsNull())) {
return 'null';
} elseif (is_numeric($value) && !$is_string) {
return (string) $value;
}
return var_export($value, true);
} | [
"public",
"function",
"getPhpSafeDefaultValue",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getDefaultValue",
"(",
")",
";",
"$",
"is_string",
"=",
"$",
"this",
"->",
"hasType",
"(",
")",
"&&",
"$",
"this",
"->",
"getType",
"(",
")",
"->",
"getName",
"(",
")",
"===",
"'string'",
";",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"return",
"'true'",
";",
"}",
"elseif",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"'false'",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isDefaultValueConstant",
"(",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"getDefaultValueConstantName",
"(",
")",
",",
"'self'",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"getDefaultValueConstantName",
"(",
")",
";",
"}",
"return",
"'\\\\'",
".",
"$",
"this",
"->",
"getDefaultValueConstantName",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'[]'",
";",
"}",
"elseif",
"(",
"null",
"===",
"$",
"value",
"||",
"(",
"$",
"is_string",
"&&",
"$",
"value",
"===",
"'null'",
"&&",
"$",
"this",
"->",
"allowsNull",
"(",
")",
")",
")",
"{",
"return",
"'null'",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"value",
")",
"&&",
"!",
"$",
"is_string",
")",
"{",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}",
"return",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"}"
] | Returns the default value in a manner which is safe to use in PHP code
as a default value.
@throws \ReflectionException If called on property without default value
@return string | [
"Returns",
"the",
"default",
"value",
"in",
"a",
"manner",
"which",
"is",
"safe",
"to",
"use",
"in",
"PHP",
"code",
"as",
"a",
"default",
"value",
"."
] | 49e2292ad64f9a679f3bf3d21880b024e16e5680 | https://github.com/hostnet/entity-plugin-lib/blob/49e2292ad64f9a679f3bf3d21880b024e16e5680/src/ReflectionParameter.php#L141-L163 |
30,065 | mirko-pagliai/cakephp-link-scanner | src/Event/LinkScannerCommandEventListener.php | LinkScannerCommandEventListener.afterScanUrl | public function afterScanUrl(Event $event, Response $response)
{
if (!$this->args->getOption('verbose')) {
return true;
}
$method = $response->isOk() ? 'success' : ($response->isRedirect() ? 'warning' : 'error');
$message = $response->isOk() ? __d('link-scanner', 'OK') : (string)$response->getStatusCode();
call_user_func([$this->io, $method], $message);
return true;
} | php | public function afterScanUrl(Event $event, Response $response)
{
if (!$this->args->getOption('verbose')) {
return true;
}
$method = $response->isOk() ? 'success' : ($response->isRedirect() ? 'warning' : 'error');
$message = $response->isOk() ? __d('link-scanner', 'OK') : (string)$response->getStatusCode();
call_user_func([$this->io, $method], $message);
return true;
} | [
"public",
"function",
"afterScanUrl",
"(",
"Event",
"$",
"event",
",",
"Response",
"$",
"response",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'verbose'",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"method",
"=",
"$",
"response",
"->",
"isOk",
"(",
")",
"?",
"'success'",
":",
"(",
"$",
"response",
"->",
"isRedirect",
"(",
")",
"?",
"'warning'",
":",
"'error'",
")",
";",
"$",
"message",
"=",
"$",
"response",
"->",
"isOk",
"(",
")",
"?",
"__d",
"(",
"'link-scanner'",
",",
"'OK'",
")",
":",
"(",
"string",
")",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"io",
",",
"$",
"method",
"]",
",",
"$",
"message",
")",
";",
"return",
"true",
";",
"}"
] | `LinkScanner.afterScanUrl` event
@param Event $event An `Event` instance
@param Response $response A `Response` instance
@return bool
@uses $args
@uses $io | [
"LinkScanner",
".",
"afterScanUrl",
"event"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L85-L96 |
30,066 | mirko-pagliai/cakephp-link-scanner | src/Event/LinkScannerCommandEventListener.php | LinkScannerCommandEventListener.beforeScanUrl | public function beforeScanUrl(Event $event, $url)
{
$this->io->verbose(__d('link-scanner', 'Checking {0} ...', $url), 0);
return true;
} | php | public function beforeScanUrl(Event $event, $url)
{
$this->io->verbose(__d('link-scanner', 'Checking {0} ...', $url), 0);
return true;
} | [
"public",
"function",
"beforeScanUrl",
"(",
"Event",
"$",
"event",
",",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"verbose",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Checking {0} ...'",
",",
"$",
"url",
")",
",",
"0",
")",
";",
"return",
"true",
";",
"}"
] | `LinkScanner.beforeScanUrl` event
@param Event $event An `Event` instance
@param string $url Url
@return bool
@uses $io | [
"LinkScanner",
".",
"beforeScanUrl",
"event"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L105-L110 |
30,067 | mirko-pagliai/cakephp-link-scanner | src/Event/LinkScannerCommandEventListener.php | LinkScannerCommandEventListener.foundLinkToBeScanned | public function foundLinkToBeScanned(Event $event, $link)
{
$this->io->verbose(__d('link-scanner', 'Link found: {0}', $link));
return true;
} | php | public function foundLinkToBeScanned(Event $event, $link)
{
$this->io->verbose(__d('link-scanner', 'Link found: {0}', $link));
return true;
} | [
"public",
"function",
"foundLinkToBeScanned",
"(",
"Event",
"$",
"event",
",",
"$",
"link",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"verbose",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Link found: {0}'",
",",
"$",
"link",
")",
")",
";",
"return",
"true",
";",
"}"
] | `LinkScanner.foundLinkToBeScanned` event
@param Event $event An `Event` instance
@param string $link Link
@return bool
@uses $io | [
"LinkScanner",
".",
"foundLinkToBeScanned",
"event"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L119-L124 |
30,068 | mirko-pagliai/cakephp-link-scanner | src/Event/LinkScannerCommandEventListener.php | LinkScannerCommandEventListener.resultsExported | public function resultsExported(Event $event, $filename)
{
$this->io->success(__d('link-scanner', 'Results have been exported to {0}', $filename));
return true;
} | php | public function resultsExported(Event $event, $filename)
{
$this->io->success(__d('link-scanner', 'Results have been exported to {0}', $filename));
return true;
} | [
"public",
"function",
"resultsExported",
"(",
"Event",
"$",
"event",
",",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"success",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Results have been exported to {0}'",
",",
"$",
"filename",
")",
")",
";",
"return",
"true",
";",
"}"
] | `LinkScanner.resultsExported` event
@param Event $event An `Event` instance
@param string $filename Filename
@return bool
@uses $io | [
"LinkScanner",
".",
"resultsExported",
"event"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L147-L152 |
30,069 | mirko-pagliai/cakephp-link-scanner | src/Event/LinkScannerCommandEventListener.php | LinkScannerCommandEventListener.scanCompleted | public function scanCompleted(Event $event, $startTime, $endTime, ResultScan $ResultScan)
{
if ($this->args->getOption('verbose')) {
$this->io->hr();
}
$endTime = new Time($endTime);
$elapsedTime = $endTime->diffForHumans(new Time($startTime), true);
$this->io->out(__d('link-scanner', 'Scan completed at {0}', $endTime->i18nFormat('yyyy-MM-dd HH:mm:ss')));
$this->io->out(__d('link-scanner', 'Elapsed time: {0}', $elapsedTime));
$this->io->out(__d('link-scanner', 'Total scanned links: {0}', $ResultScan->count()));
if ($this->args->getOption('verbose')) {
$this->io->hr();
}
return true;
} | php | public function scanCompleted(Event $event, $startTime, $endTime, ResultScan $ResultScan)
{
if ($this->args->getOption('verbose')) {
$this->io->hr();
}
$endTime = new Time($endTime);
$elapsedTime = $endTime->diffForHumans(new Time($startTime), true);
$this->io->out(__d('link-scanner', 'Scan completed at {0}', $endTime->i18nFormat('yyyy-MM-dd HH:mm:ss')));
$this->io->out(__d('link-scanner', 'Elapsed time: {0}', $elapsedTime));
$this->io->out(__d('link-scanner', 'Total scanned links: {0}', $ResultScan->count()));
if ($this->args->getOption('verbose')) {
$this->io->hr();
}
return true;
} | [
"public",
"function",
"scanCompleted",
"(",
"Event",
"$",
"event",
",",
"$",
"startTime",
",",
"$",
"endTime",
",",
"ResultScan",
"$",
"ResultScan",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'verbose'",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"hr",
"(",
")",
";",
"}",
"$",
"endTime",
"=",
"new",
"Time",
"(",
"$",
"endTime",
")",
";",
"$",
"elapsedTime",
"=",
"$",
"endTime",
"->",
"diffForHumans",
"(",
"new",
"Time",
"(",
"$",
"startTime",
")",
",",
"true",
")",
";",
"$",
"this",
"->",
"io",
"->",
"out",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Scan completed at {0}'",
",",
"$",
"endTime",
"->",
"i18nFormat",
"(",
"'yyyy-MM-dd HH:mm:ss'",
")",
")",
")",
";",
"$",
"this",
"->",
"io",
"->",
"out",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Elapsed time: {0}'",
",",
"$",
"elapsedTime",
")",
")",
";",
"$",
"this",
"->",
"io",
"->",
"out",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Total scanned links: {0}'",
",",
"$",
"ResultScan",
"->",
"count",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'verbose'",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"hr",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | `LinkScanner.scanCompleted` event
@param Event $event An `Event` instance
@param int $startTime Start time
@param int $endTime End time
@param ResultScan $ResultScan A `ResultScan` instance
@return bool
@uses $args
@uses $io | [
"LinkScanner",
".",
"scanCompleted",
"event"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L174-L192 |
30,070 | mirko-pagliai/cakephp-link-scanner | src/Event/LinkScannerCommandEventListener.php | LinkScannerCommandEventListener.scanStarted | public function scanStarted(Event $event, $startTime, $fullBaseUrl)
{
if ($this->args->getOption('verbose')) {
$this->io->hr();
}
$startTime = (new Time($startTime))->i18nFormat('yyyy-MM-dd HH:mm:ss');
$this->io->info(__d('link-scanner', 'Scan started for {0} at {1}', $fullBaseUrl, $startTime));
if (!$this->args->getOption('verbose')) {
return true;
}
$this->io->hr();
$cache = Cache::getConfig('LinkScanner');
if (!$this->args->getOption('no-cache') && Cache::enabled() && !empty($cache['duration'])) {
$this->io->success(__d('link-scanner', 'The cache is enabled and its duration is `{0}`', $cache['duration']));
} else {
$this->io->info(__d('link-scanner', 'The cache is disabled'));
}
if ($this->args->getOption('force')) {
$this->io->info(__d('link-scanner', 'Force mode is enabled'));
} else {
$this->io->info(__d('link-scanner', 'Force mode is not enabled'));
}
if ($event->getSubject()->getConfig('externalLinks')) {
$this->io->info(__d('link-scanner', 'Scanning of external links is enabled'));
} else {
$this->io->info(__d('link-scanner', 'Scanning of external links is not enabled'));
}
if ($event->getSubject()->getConfig('followRedirects')) {
$this->io->info(__d('link-scanner', 'Redirects will be followed'));
} else {
$this->io->info(__d('link-scanner', 'Redirects will not be followed'));
}
$maxDepth = $event->getSubject()->getConfig('maxDepth');
if (is_positive($maxDepth)) {
$this->io->info(__d('link-scanner', 'Maximum depth of the scan: {0}', $maxDepth));
}
$timeout = $event->getSubject()->Client->getConfig('timeout');
if (is_positive($timeout)) {
$this->io->info(__d('link-scanner', 'Timeout in seconds for GET requests: {0}', $timeout));
}
$this->io->hr();
return true;
} | php | public function scanStarted(Event $event, $startTime, $fullBaseUrl)
{
if ($this->args->getOption('verbose')) {
$this->io->hr();
}
$startTime = (new Time($startTime))->i18nFormat('yyyy-MM-dd HH:mm:ss');
$this->io->info(__d('link-scanner', 'Scan started for {0} at {1}', $fullBaseUrl, $startTime));
if (!$this->args->getOption('verbose')) {
return true;
}
$this->io->hr();
$cache = Cache::getConfig('LinkScanner');
if (!$this->args->getOption('no-cache') && Cache::enabled() && !empty($cache['duration'])) {
$this->io->success(__d('link-scanner', 'The cache is enabled and its duration is `{0}`', $cache['duration']));
} else {
$this->io->info(__d('link-scanner', 'The cache is disabled'));
}
if ($this->args->getOption('force')) {
$this->io->info(__d('link-scanner', 'Force mode is enabled'));
} else {
$this->io->info(__d('link-scanner', 'Force mode is not enabled'));
}
if ($event->getSubject()->getConfig('externalLinks')) {
$this->io->info(__d('link-scanner', 'Scanning of external links is enabled'));
} else {
$this->io->info(__d('link-scanner', 'Scanning of external links is not enabled'));
}
if ($event->getSubject()->getConfig('followRedirects')) {
$this->io->info(__d('link-scanner', 'Redirects will be followed'));
} else {
$this->io->info(__d('link-scanner', 'Redirects will not be followed'));
}
$maxDepth = $event->getSubject()->getConfig('maxDepth');
if (is_positive($maxDepth)) {
$this->io->info(__d('link-scanner', 'Maximum depth of the scan: {0}', $maxDepth));
}
$timeout = $event->getSubject()->Client->getConfig('timeout');
if (is_positive($timeout)) {
$this->io->info(__d('link-scanner', 'Timeout in seconds for GET requests: {0}', $timeout));
}
$this->io->hr();
return true;
} | [
"public",
"function",
"scanStarted",
"(",
"Event",
"$",
"event",
",",
"$",
"startTime",
",",
"$",
"fullBaseUrl",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'verbose'",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"hr",
"(",
")",
";",
"}",
"$",
"startTime",
"=",
"(",
"new",
"Time",
"(",
"$",
"startTime",
")",
")",
"->",
"i18nFormat",
"(",
"'yyyy-MM-dd HH:mm:ss'",
")",
";",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Scan started for {0} at {1}'",
",",
"$",
"fullBaseUrl",
",",
"$",
"startTime",
")",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'verbose'",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"io",
"->",
"hr",
"(",
")",
";",
"$",
"cache",
"=",
"Cache",
"::",
"getConfig",
"(",
"'LinkScanner'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'no-cache'",
")",
"&&",
"Cache",
"::",
"enabled",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"cache",
"[",
"'duration'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"success",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'The cache is enabled and its duration is `{0}`'",
",",
"$",
"cache",
"[",
"'duration'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'The cache is disabled'",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"args",
"->",
"getOption",
"(",
"'force'",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Force mode is enabled'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Force mode is not enabled'",
")",
")",
";",
"}",
"if",
"(",
"$",
"event",
"->",
"getSubject",
"(",
")",
"->",
"getConfig",
"(",
"'externalLinks'",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Scanning of external links is enabled'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Scanning of external links is not enabled'",
")",
")",
";",
"}",
"if",
"(",
"$",
"event",
"->",
"getSubject",
"(",
")",
"->",
"getConfig",
"(",
"'followRedirects'",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Redirects will be followed'",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Redirects will not be followed'",
")",
")",
";",
"}",
"$",
"maxDepth",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
"->",
"getConfig",
"(",
"'maxDepth'",
")",
";",
"if",
"(",
"is_positive",
"(",
"$",
"maxDepth",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Maximum depth of the scan: {0}'",
",",
"$",
"maxDepth",
")",
")",
";",
"}",
"$",
"timeout",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
"->",
"Client",
"->",
"getConfig",
"(",
"'timeout'",
")",
";",
"if",
"(",
"is_positive",
"(",
"$",
"timeout",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"info",
"(",
"__d",
"(",
"'link-scanner'",
",",
"'Timeout in seconds for GET requests: {0}'",
",",
"$",
"timeout",
")",
")",
";",
"}",
"$",
"this",
"->",
"io",
"->",
"hr",
"(",
")",
";",
"return",
"true",
";",
"}"
] | `LinkScanner.scanStarted` event
@param Event $event An `Event` instance
@param int $startTime Start time
@param string $fullBaseUrl Full base url
@return bool
@uses $args
@uses $io | [
"LinkScanner",
".",
"scanStarted",
"event"
] | 3889f0059f97d7ad7cc95572bd7cfb0384b0f636 | https://github.com/mirko-pagliai/cakephp-link-scanner/blob/3889f0059f97d7ad7cc95572bd7cfb0384b0f636/src/Event/LinkScannerCommandEventListener.php#L203-L256 |
30,071 | hiqdev/hiapi | src/event/ConfigurableEmitter.php | ConfigurableEmitter.setListeners | public function setListeners(array $listeners = [])
{
foreach ($listeners as $listener) {
if (!isset($listener['event']) || !isset($listener['listener'])) {
throw new InvalidConfigException('Both "event" and "listener" properties are required to attach a listener.');
}
if (is_string($listener['listener'])) {
$listener['listener'] = $this->listenerFromClassName($listener['listener']);
}
$this->addListener($listener['event'], $listener['listener'], $listener['priority'] ?? self::P_NORMAL);
}
return $this;
} | php | public function setListeners(array $listeners = [])
{
foreach ($listeners as $listener) {
if (!isset($listener['event']) || !isset($listener['listener'])) {
throw new InvalidConfigException('Both "event" and "listener" properties are required to attach a listener.');
}
if (is_string($listener['listener'])) {
$listener['listener'] = $this->listenerFromClassName($listener['listener']);
}
$this->addListener($listener['event'], $listener['listener'], $listener['priority'] ?? self::P_NORMAL);
}
return $this;
} | [
"public",
"function",
"setListeners",
"(",
"array",
"$",
"listeners",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"listeners",
"as",
"$",
"listener",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"listener",
"[",
"'event'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"listener",
"[",
"'listener'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
"(",
"'Both \"event\" and \"listener\" properties are required to attach a listener.'",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"listener",
"[",
"'listener'",
"]",
")",
")",
"{",
"$",
"listener",
"[",
"'listener'",
"]",
"=",
"$",
"this",
"->",
"listenerFromClassName",
"(",
"$",
"listener",
"[",
"'listener'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"addListener",
"(",
"$",
"listener",
"[",
"'event'",
"]",
",",
"$",
"listener",
"[",
"'listener'",
"]",
",",
"$",
"listener",
"[",
"'priority'",
"]",
"??",
"self",
"::",
"P_NORMAL",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Allows to set listeners with standard Yii configuration system
@param array[] $listeners
@return $this
@throws InvalidConfigException | [
"Allows",
"to",
"set",
"listeners",
"with",
"standard",
"Yii",
"configuration",
"system"
] | 2b3b334b247f69068b1f21b19e8ea013b1bae947 | https://github.com/hiqdev/hiapi/blob/2b3b334b247f69068b1f21b19e8ea013b1bae947/src/event/ConfigurableEmitter.php#L53-L68 |
30,072 | wikimedia/at-ease | src/Wikimedia/AtEase/AtEase.php | AtEase.suppressWarnings | public static function suppressWarnings( $end = false ) {
if ( $end ) {
if ( self::$suppressCount ) {
--self::$suppressCount;
if ( !self::$suppressCount ) {
error_reporting( self::$originalLevel );
}
}
} else {
if ( !self::$suppressCount ) {
self::$originalLevel =
error_reporting( E_ALL & ~(
E_WARNING |
E_NOTICE |
E_USER_WARNING |
E_USER_NOTICE |
E_DEPRECATED |
E_USER_DEPRECATED |
E_STRICT
) );
}
++self::$suppressCount;
}
} | php | public static function suppressWarnings( $end = false ) {
if ( $end ) {
if ( self::$suppressCount ) {
--self::$suppressCount;
if ( !self::$suppressCount ) {
error_reporting( self::$originalLevel );
}
}
} else {
if ( !self::$suppressCount ) {
self::$originalLevel =
error_reporting( E_ALL & ~(
E_WARNING |
E_NOTICE |
E_USER_WARNING |
E_USER_NOTICE |
E_DEPRECATED |
E_USER_DEPRECATED |
E_STRICT
) );
}
++self::$suppressCount;
}
} | [
"public",
"static",
"function",
"suppressWarnings",
"(",
"$",
"end",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"end",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"suppressCount",
")",
"{",
"--",
"self",
"::",
"$",
"suppressCount",
";",
"if",
"(",
"!",
"self",
"::",
"$",
"suppressCount",
")",
"{",
"error_reporting",
"(",
"self",
"::",
"$",
"originalLevel",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"suppressCount",
")",
"{",
"self",
"::",
"$",
"originalLevel",
"=",
"error_reporting",
"(",
"E_ALL",
"&",
"~",
"(",
"E_WARNING",
"|",
"E_NOTICE",
"|",
"E_USER_WARNING",
"|",
"E_USER_NOTICE",
"|",
"E_DEPRECATED",
"|",
"E_USER_DEPRECATED",
"|",
"E_STRICT",
")",
")",
";",
"}",
"++",
"self",
"::",
"$",
"suppressCount",
";",
"}",
"}"
] | Reference-counted warning suppression
@param bool $end Whether to restore warnings | [
"Reference",
"-",
"counted",
"warning",
"suppression"
] | 259a7e100daec82251f8385c1760c08813a81f7f | https://github.com/wikimedia/at-ease/blob/259a7e100daec82251f8385c1760c08813a81f7f/src/Wikimedia/AtEase/AtEase.php#L32-L55 |
30,073 | wikimedia/at-ease | src/Wikimedia/AtEase/AtEase.php | AtEase.quietCall | public static function quietCall( callable $callback /*, parameters... */ ) {
$args = array_slice( func_get_args(), 1 );
self::suppressWarnings();
$rv = call_user_func_array( $callback, $args );
self::restoreWarnings();
return $rv;
} | php | public static function quietCall( callable $callback /*, parameters... */ ) {
$args = array_slice( func_get_args(), 1 );
self::suppressWarnings();
$rv = call_user_func_array( $callback, $args );
self::restoreWarnings();
return $rv;
} | [
"public",
"static",
"function",
"quietCall",
"(",
"callable",
"$",
"callback",
"/*, parameters... */",
")",
"{",
"$",
"args",
"=",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"1",
")",
";",
"self",
"::",
"suppressWarnings",
"(",
")",
";",
"$",
"rv",
"=",
"call_user_func_array",
"(",
"$",
"callback",
",",
"$",
"args",
")",
";",
"self",
"::",
"restoreWarnings",
"(",
")",
";",
"return",
"$",
"rv",
";",
"}"
] | Call the callback given by the first parameter, suppressing any warnings.
@param callable $callback Function to call
@return mixed | [
"Call",
"the",
"callback",
"given",
"by",
"the",
"first",
"parameter",
"suppressing",
"any",
"warnings",
"."
] | 259a7e100daec82251f8385c1760c08813a81f7f | https://github.com/wikimedia/at-ease/blob/259a7e100daec82251f8385c1760c08813a81f7f/src/Wikimedia/AtEase/AtEase.php#L70-L76 |
30,074 | yiidoc/yii2-redactor | widgets/Redactor.php | Redactor.registerRegional | protected function registerRegional()
{
$this->clientOptions['lang'] = ArrayHelper::getValue($this->clientOptions, 'lang', Yii::$app->language);
$langAsset = 'lang/' . $this->clientOptions['lang'] . '.js';
if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $langAsset)) {
$this->assetBundle->js[] = $langAsset;
} else {
ArrayHelper::remove($this->clientOptions, 'lang');
}
} | php | protected function registerRegional()
{
$this->clientOptions['lang'] = ArrayHelper::getValue($this->clientOptions, 'lang', Yii::$app->language);
$langAsset = 'lang/' . $this->clientOptions['lang'] . '.js';
if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $langAsset)) {
$this->assetBundle->js[] = $langAsset;
} else {
ArrayHelper::remove($this->clientOptions, 'lang');
}
} | [
"protected",
"function",
"registerRegional",
"(",
")",
"{",
"$",
"this",
"->",
"clientOptions",
"[",
"'lang'",
"]",
"=",
"ArrayHelper",
"::",
"getValue",
"(",
"$",
"this",
"->",
"clientOptions",
",",
"'lang'",
",",
"Yii",
"::",
"$",
"app",
"->",
"language",
")",
";",
"$",
"langAsset",
"=",
"'lang/'",
".",
"$",
"this",
"->",
"clientOptions",
"[",
"'lang'",
"]",
".",
"'.js'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"sourcePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"langAsset",
")",
")",
"{",
"$",
"this",
"->",
"assetBundle",
"->",
"js",
"[",
"]",
"=",
"$",
"langAsset",
";",
"}",
"else",
"{",
"ArrayHelper",
"::",
"remove",
"(",
"$",
"this",
"->",
"clientOptions",
",",
"'lang'",
")",
";",
"}",
"}"
] | Register language for Redactor | [
"Register",
"language",
"for",
"Redactor"
] | 9848704a8bef370a0f09f3be0dd7a052d5ad3d32 | https://github.com/yiidoc/yii2-redactor/blob/9848704a8bef370a0f09f3be0dd7a052d5ad3d32/widgets/Redactor.php#L109-L119 |
30,075 | yiidoc/yii2-redactor | widgets/Redactor.php | Redactor.registerPlugins | protected function registerPlugins()
{
if (isset($this->clientOptions['plugins']) && count($this->clientOptions['plugins'])) {
foreach ($this->clientOptions['plugins'] as $plugin) {
$js = 'plugins/' . $plugin . '/' . $plugin . '.js';
if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $js)) {
$this->assetBundle->js[] = $js;
}
$css = 'plugins/' . $plugin . '/' . $plugin . '.css';
if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $css)) {
$this->assetBundle->css[] = $css;
}
}
}
} | php | protected function registerPlugins()
{
if (isset($this->clientOptions['plugins']) && count($this->clientOptions['plugins'])) {
foreach ($this->clientOptions['plugins'] as $plugin) {
$js = 'plugins/' . $plugin . '/' . $plugin . '.js';
if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $js)) {
$this->assetBundle->js[] = $js;
}
$css = 'plugins/' . $plugin . '/' . $plugin . '.css';
if (file_exists($this->sourcePath . DIRECTORY_SEPARATOR . $css)) {
$this->assetBundle->css[] = $css;
}
}
}
} | [
"protected",
"function",
"registerPlugins",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"clientOptions",
"[",
"'plugins'",
"]",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"clientOptions",
"[",
"'plugins'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"clientOptions",
"[",
"'plugins'",
"]",
"as",
"$",
"plugin",
")",
"{",
"$",
"js",
"=",
"'plugins/'",
".",
"$",
"plugin",
".",
"'/'",
".",
"$",
"plugin",
".",
"'.js'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"sourcePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"js",
")",
")",
"{",
"$",
"this",
"->",
"assetBundle",
"->",
"js",
"[",
"]",
"=",
"$",
"js",
";",
"}",
"$",
"css",
"=",
"'plugins/'",
".",
"$",
"plugin",
".",
"'/'",
".",
"$",
"plugin",
".",
"'.css'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"sourcePath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"css",
")",
")",
"{",
"$",
"this",
"->",
"assetBundle",
"->",
"css",
"[",
"]",
"=",
"$",
"css",
";",
"}",
"}",
"}",
"}"
] | Register plugins for Redactor | [
"Register",
"plugins",
"for",
"Redactor"
] | 9848704a8bef370a0f09f3be0dd7a052d5ad3d32 | https://github.com/yiidoc/yii2-redactor/blob/9848704a8bef370a0f09f3be0dd7a052d5ad3d32/widgets/Redactor.php#L124-L138 |
30,076 | marcelog/PAGI | doc/examples/quickstart/MyPAGIApplication.php | MyPAGIApplication.log | public function log($msg)
{
$agi = $this->getAgi();
$this->logger->debug($msg);
$agi->consoleLog($msg);
} | php | public function log($msg)
{
$agi = $this->getAgi();
$this->logger->debug($msg);
$agi->consoleLog($msg);
} | [
"public",
"function",
"log",
"(",
"$",
"msg",
")",
"{",
"$",
"agi",
"=",
"$",
"this",
"->",
"getAgi",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"$",
"msg",
")",
";",
"$",
"agi",
"->",
"consoleLog",
"(",
"$",
"msg",
")",
";",
"}"
] | Logs to asterisk console.
@param string $msg Message to log.
@return void | [
"Logs",
"to",
"asterisk",
"console",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/doc/examples/quickstart/MyPAGIApplication.php#L87-L92 |
30,077 | marcelog/PAGI | src/PAGI/CallSpool/CallFile.php | CallFile.getVariable | public function getVariable($key)
{
if (isset($this->variables[$key])) {
return $this->variables[$key];
}
return false;
} | php | public function getVariable($key)
{
if (isset($this->variables[$key])) {
return $this->variables[$key];
}
return false;
} | [
"public",
"function",
"getVariable",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"variables",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"variables",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"false",
";",
"}"
] | Returns the value for the given variable.
@param string $key Variable name.
@return string | [
"Returns",
"the",
"value",
"for",
"the",
"given",
"variable",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/CallSpool/CallFile.php#L93-L99 |
30,078 | marcelog/PAGI | src/PAGI/CallSpool/CallFile.php | CallFile.serialize | public function serialize()
{
$text = array();
foreach ($this->parameters as $k => $v) {
$text[] = $k . ': ' . $v;
}
foreach ($this->variables as $k => $v) {
$text[] = 'Set: ' . $k . '=' . $v;
}
return implode("\n", $text);
} | php | public function serialize()
{
$text = array();
foreach ($this->parameters as $k => $v) {
$text[] = $k . ': ' . $v;
}
foreach ($this->variables as $k => $v) {
$text[] = 'Set: ' . $k . '=' . $v;
}
return implode("\n", $text);
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"text",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"parameters",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"text",
"[",
"]",
"=",
"$",
"k",
".",
"': '",
".",
"$",
"v",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"variables",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"text",
"[",
"]",
"=",
"'Set: '",
".",
"$",
"k",
".",
"'='",
".",
"$",
"v",
";",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"text",
")",
";",
"}"
] | Returns the text describing this call file, ready to be spooled.
@return string | [
"Returns",
"the",
"text",
"describing",
"this",
"call",
"file",
"ready",
"to",
"be",
"spooled",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/CallSpool/CallFile.php#L409-L419 |
30,079 | marcelog/PAGI | src/PAGI/CallSpool/CallFile.php | CallFile.unserialize | public function unserialize($text)
{
$lines = explode("\n", $text);
foreach ($lines as $line) {
$data = explode(':', $line);
if (count($data) < 2) {
continue;
}
$key = trim($data[0]);
if (isset($data[1]) && (strlen($data[1]) > 0)) {
$value = trim($data[1]);
} else {
$value = '?';
}
if (strcasecmp($key, 'set') === 0) {
$data = explode('=', $value);
$key = trim($data[0]);
if (isset($data[1]) && (strlen($data[1]) > 0)) {
$value = trim($data[1]);
} else {
$value = '?';
}
$this->setVariable($key, $value);
} else {
$this->setParameter($key, $value);
}
}
} | php | public function unserialize($text)
{
$lines = explode("\n", $text);
foreach ($lines as $line) {
$data = explode(':', $line);
if (count($data) < 2) {
continue;
}
$key = trim($data[0]);
if (isset($data[1]) && (strlen($data[1]) > 0)) {
$value = trim($data[1]);
} else {
$value = '?';
}
if (strcasecmp($key, 'set') === 0) {
$data = explode('=', $value);
$key = trim($data[0]);
if (isset($data[1]) && (strlen($data[1]) > 0)) {
$value = trim($data[1]);
} else {
$value = '?';
}
$this->setVariable($key, $value);
} else {
$this->setParameter($key, $value);
}
}
} | [
"public",
"function",
"unserialize",
"(",
"$",
"text",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"text",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"data",
"=",
"explode",
"(",
"':'",
",",
"$",
"line",
")",
";",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"<",
"2",
")",
"{",
"continue",
";",
"}",
"$",
"key",
"=",
"trim",
"(",
"$",
"data",
"[",
"0",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"1",
"]",
")",
"&&",
"(",
"strlen",
"(",
"$",
"data",
"[",
"1",
"]",
")",
">",
"0",
")",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"data",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"'?'",
";",
"}",
"if",
"(",
"strcasecmp",
"(",
"$",
"key",
",",
"'set'",
")",
"===",
"0",
")",
"{",
"$",
"data",
"=",
"explode",
"(",
"'='",
",",
"$",
"value",
")",
";",
"$",
"key",
"=",
"trim",
"(",
"$",
"data",
"[",
"0",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"1",
"]",
")",
"&&",
"(",
"strlen",
"(",
"$",
"data",
"[",
"1",
"]",
")",
">",
"0",
")",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"data",
"[",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"'?'",
";",
"}",
"$",
"this",
"->",
"setVariable",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setParameter",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | Deconstructs a call file from the given text.
@param string $text A call file (intended to be pre-loaded, with
file_get_contents() or similar).
@return void | [
"Deconstructs",
"a",
"call",
"file",
"from",
"the",
"given",
"text",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/CallSpool/CallFile.php#L429-L456 |
30,080 | marcelog/PAGI | src/PAGI/Node/MockedNode.php | MockedNode.recordDoneSay | protected function recordDoneSay($what, $arguments = array())
{
$semiHash = serialize(array($what, $arguments));
if (isset($this->doneSay[$semiHash])) {
$this->doneSay[$semiHash]++;
} else {
$this->doneSay[$semiHash] = 1;
}
} | php | protected function recordDoneSay($what, $arguments = array())
{
$semiHash = serialize(array($what, $arguments));
if (isset($this->doneSay[$semiHash])) {
$this->doneSay[$semiHash]++;
} else {
$this->doneSay[$semiHash] = 1;
}
} | [
"protected",
"function",
"recordDoneSay",
"(",
"$",
"what",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"semiHash",
"=",
"serialize",
"(",
"array",
"(",
"$",
"what",
",",
"$",
"arguments",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"doneSay",
"[",
"$",
"semiHash",
"]",
")",
")",
"{",
"$",
"this",
"->",
"doneSay",
"[",
"$",
"semiHash",
"]",
"++",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"doneSay",
"[",
"$",
"semiHash",
"]",
"=",
"1",
";",
"}",
"}"
] | Records a played prompt message with its arguments.
@param string $what The pagi method name called.
@param string[] $arguments The arguments used, without the interrupt
digits.
@return void | [
"Records",
"a",
"played",
"prompt",
"message",
"with",
"its",
"arguments",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/MockedNode.php#L146-L154 |
30,081 | marcelog/PAGI | src/PAGI/Node/MockedNode.php | MockedNode.assertSay | protected function assertSay($what, $totalTimes, $arguments = array())
{
$semiHash = serialize(array($what, $arguments));
$this->expectedSay[$semiHash] = $totalTimes;
return $this;
} | php | protected function assertSay($what, $totalTimes, $arguments = array())
{
$semiHash = serialize(array($what, $arguments));
$this->expectedSay[$semiHash] = $totalTimes;
return $this;
} | [
"protected",
"function",
"assertSay",
"(",
"$",
"what",
",",
"$",
"totalTimes",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"semiHash",
"=",
"serialize",
"(",
"array",
"(",
"$",
"what",
",",
"$",
"arguments",
")",
")",
";",
"$",
"this",
"->",
"expectedSay",
"[",
"$",
"semiHash",
"]",
"=",
"$",
"totalTimes",
";",
"return",
"$",
"this",
";",
"}"
] | Generic method to expect prompt messages played.
@param string $what The pagi method name to expect.
@param integer $totalTimes Total times to expect this call
@param string[] $arguments The arguments to assert.
@return MockedNode | [
"Generic",
"method",
"to",
"expect",
"prompt",
"messages",
"played",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/MockedNode.php#L165-L170 |
30,082 | marcelog/PAGI | src/PAGI/Node/MockedNode.php | MockedNode.sayInterruptable | protected function sayInterruptable($what, array $arguments)
{
$client = $this->getClient();
$logger = $client->getLogger();
$args = "(" . implode(',', $arguments) . ")";
$argsCount = count($arguments);
$interruptDigits = $arguments[$argsCount - 1];
$this->recordDoneSay($what, array_slice($arguments, 0, $argsCount - 1));
if (empty($this->mockedInput)) {
$logger->debug("No more input available");
$client->onStreamFile(false);
} else {
if ($interruptDigits != Node::DTMF_NONE) {
$digit = array_shift($this->mockedInput);
if (strpos($interruptDigits, $digit) !== false) {
$logger->debug("Digit '$digit' will interrupt $what $args)");
$client->onStreamFile(true, $digit);
} else {
if ($digit != ' ') {
$logger->warning("Digit '$digit' will not interrupt $what $args)");
} else {
$logger->warning("Timeout input for $what $args");
}
$client->onStreamFile(false);
}
} else {
$logger->debug('None interruptable message');
$client->onStreamFile(false);
}
}
} | php | protected function sayInterruptable($what, array $arguments)
{
$client = $this->getClient();
$logger = $client->getLogger();
$args = "(" . implode(',', $arguments) . ")";
$argsCount = count($arguments);
$interruptDigits = $arguments[$argsCount - 1];
$this->recordDoneSay($what, array_slice($arguments, 0, $argsCount - 1));
if (empty($this->mockedInput)) {
$logger->debug("No more input available");
$client->onStreamFile(false);
} else {
if ($interruptDigits != Node::DTMF_NONE) {
$digit = array_shift($this->mockedInput);
if (strpos($interruptDigits, $digit) !== false) {
$logger->debug("Digit '$digit' will interrupt $what $args)");
$client->onStreamFile(true, $digit);
} else {
if ($digit != ' ') {
$logger->warning("Digit '$digit' will not interrupt $what $args)");
} else {
$logger->warning("Timeout input for $what $args");
}
$client->onStreamFile(false);
}
} else {
$logger->debug('None interruptable message');
$client->onStreamFile(false);
}
}
} | [
"protected",
"function",
"sayInterruptable",
"(",
"$",
"what",
",",
"array",
"$",
"arguments",
")",
"{",
"$",
"client",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
";",
"$",
"logger",
"=",
"$",
"client",
"->",
"getLogger",
"(",
")",
";",
"$",
"args",
"=",
"\"(\"",
".",
"implode",
"(",
"','",
",",
"$",
"arguments",
")",
".",
"\")\"",
";",
"$",
"argsCount",
"=",
"count",
"(",
"$",
"arguments",
")",
";",
"$",
"interruptDigits",
"=",
"$",
"arguments",
"[",
"$",
"argsCount",
"-",
"1",
"]",
";",
"$",
"this",
"->",
"recordDoneSay",
"(",
"$",
"what",
",",
"array_slice",
"(",
"$",
"arguments",
",",
"0",
",",
"$",
"argsCount",
"-",
"1",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"mockedInput",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"\"No more input available\"",
")",
";",
"$",
"client",
"->",
"onStreamFile",
"(",
"false",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"interruptDigits",
"!=",
"Node",
"::",
"DTMF_NONE",
")",
"{",
"$",
"digit",
"=",
"array_shift",
"(",
"$",
"this",
"->",
"mockedInput",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"interruptDigits",
",",
"$",
"digit",
")",
"!==",
"false",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"\"Digit '$digit' will interrupt $what $args)\"",
")",
";",
"$",
"client",
"->",
"onStreamFile",
"(",
"true",
",",
"$",
"digit",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"digit",
"!=",
"' '",
")",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Digit '$digit' will not interrupt $what $args)\"",
")",
";",
"}",
"else",
"{",
"$",
"logger",
"->",
"warning",
"(",
"\"Timeout input for $what $args\"",
")",
";",
"}",
"$",
"client",
"->",
"onStreamFile",
"(",
"false",
")",
";",
"}",
"}",
"else",
"{",
"$",
"logger",
"->",
"debug",
"(",
"'None interruptable message'",
")",
";",
"$",
"client",
"->",
"onStreamFile",
"(",
"false",
")",
";",
"}",
"}",
"}"
] | Used to mimic the user input per prompt message.
@param string $what
@param array $arguments
@return void | [
"Used",
"to",
"mimic",
"the",
"user",
"input",
"per",
"prompt",
"message",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/MockedNode.php#L261-L293 |
30,083 | marcelog/PAGI | src/PAGI/Logger/Asterisk/Impl/AsteriskLoggerImpl.php | AsteriskLoggerImpl.getLogger | public static function getLogger(IClient $agi)
{
if (self::$instance === false) {
$ret = new AsteriskLoggerImpl($agi);
self::$instance = $ret;
} else {
$ret = self::$instance;
}
return $ret;
} | php | public static function getLogger(IClient $agi)
{
if (self::$instance === false) {
$ret = new AsteriskLoggerImpl($agi);
self::$instance = $ret;
} else {
$ret = self::$instance;
}
return $ret;
} | [
"public",
"static",
"function",
"getLogger",
"(",
"IClient",
"$",
"agi",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"instance",
"===",
"false",
")",
"{",
"$",
"ret",
"=",
"new",
"AsteriskLoggerImpl",
"(",
"$",
"agi",
")",
";",
"self",
"::",
"$",
"instance",
"=",
"$",
"ret",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"self",
"::",
"$",
"instance",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Obtains an instance for this facade.
@param IClient $agi Client AGI to use.
@return void | [
"Obtains",
"an",
"instance",
"for",
"this",
"facade",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Logger/Asterisk/Impl/AsteriskLoggerImpl.php#L129-L138 |
30,084 | marcelog/PAGI | src/PAGI/Node/NodeActionCommand.php | NodeActionCommand.hangup | public function hangup($cause)
{
$this->action = self::NODE_ACTION_HANGUP;
$this->data['hangupCause'] = $cause;
return $this;
} | php | public function hangup($cause)
{
$this->action = self::NODE_ACTION_HANGUP;
$this->data['hangupCause'] = $cause;
return $this;
} | [
"public",
"function",
"hangup",
"(",
"$",
"cause",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"self",
"::",
"NODE_ACTION_HANGUP",
";",
"$",
"this",
"->",
"data",
"[",
"'hangupCause'",
"]",
"=",
"$",
"cause",
";",
"return",
"$",
"this",
";",
"}"
] | As an action, hangup the call with the given cause.
@param integer $cause
@return \PAGI\Node\NodeActionCommand | [
"As",
"an",
"action",
"hangup",
"the",
"call",
"with",
"the",
"given",
"cause",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeActionCommand.php#L155-L160 |
30,085 | marcelog/PAGI | src/PAGI/Node/NodeActionCommand.php | NodeActionCommand.execute | public function execute(\Closure $callback)
{
$this->action = self::NODE_ACTION_EXECUTE;
$this->data['callback'] = $callback;
return $this;
} | php | public function execute(\Closure $callback)
{
$this->action = self::NODE_ACTION_EXECUTE;
$this->data['callback'] = $callback;
return $this;
} | [
"public",
"function",
"execute",
"(",
"\\",
"Closure",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"self",
"::",
"NODE_ACTION_EXECUTE",
";",
"$",
"this",
"->",
"data",
"[",
"'callback'",
"]",
"=",
"$",
"callback",
";",
"return",
"$",
"this",
";",
"}"
] | As an action, execute the given callback.
@param \Closure $callback
@return \PAGI\Node\NodeActionCommand | [
"As",
"an",
"action",
"execute",
"the",
"given",
"callback",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/NodeActionCommand.php#L169-L174 |
30,086 | marcelog/PAGI | src/PAGI/Client/Impl/ClientImpl.php | ClientImpl.open | protected function open()
{
if (isset($this->options['stdin'])) {
$this->input = $this->options['stdin'];
} else {
$this->input = fopen('php://stdin', 'r');
}
if (isset($this->options['stdout'])) {
$this->output = $this->options['stdout'];
} else {
$this->output = fopen('php://stdout', 'w');
}
while (true) {
$line = $this->read($this->input);
if ($this->isEndOfEnvironmentVariables($line)) {
break;
}
$this->readEnvironmentVariable($line);
}
$this->logger->debug(print_r($this->variables, true));
} | php | protected function open()
{
if (isset($this->options['stdin'])) {
$this->input = $this->options['stdin'];
} else {
$this->input = fopen('php://stdin', 'r');
}
if (isset($this->options['stdout'])) {
$this->output = $this->options['stdout'];
} else {
$this->output = fopen('php://stdout', 'w');
}
while (true) {
$line = $this->read($this->input);
if ($this->isEndOfEnvironmentVariables($line)) {
break;
}
$this->readEnvironmentVariable($line);
}
$this->logger->debug(print_r($this->variables, true));
} | [
"protected",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'stdin'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"this",
"->",
"options",
"[",
"'stdin'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"input",
"=",
"fopen",
"(",
"'php://stdin'",
",",
"'r'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'stdout'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"$",
"this",
"->",
"options",
"[",
"'stdout'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"output",
"=",
"fopen",
"(",
"'php://stdout'",
",",
"'w'",
")",
";",
"}",
"while",
"(",
"true",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"this",
"->",
"input",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isEndOfEnvironmentVariables",
"(",
"$",
"line",
")",
")",
"{",
"break",
";",
"}",
"$",
"this",
"->",
"readEnvironmentVariable",
"(",
"$",
"line",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"print_r",
"(",
"$",
"this",
"->",
"variables",
",",
"true",
")",
")",
";",
"}"
] | Opens connection to agi. Will also read initial channel variables given
by asterisk when launching the agi.
@return void | [
"Opens",
"connection",
"to",
"agi",
".",
"Will",
"also",
"read",
"initial",
"channel",
"variables",
"given",
"by",
"asterisk",
"when",
"launching",
"the",
"agi",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L103-L123 |
30,087 | marcelog/PAGI | src/PAGI/Client/Impl/ClientImpl.php | ClientImpl.close | protected function close()
{
if ($this->input !== false) {
fclose($this->input);
}
if ($this->output !== false) {
fclose($this->output);
}
} | php | protected function close()
{
if ($this->input !== false) {
fclose($this->input);
}
if ($this->output !== false) {
fclose($this->output);
}
} | [
"protected",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"input",
"!==",
"false",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"input",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"output",
"!==",
"false",
")",
"{",
"fclose",
"(",
"$",
"this",
"->",
"output",
")",
";",
"}",
"}"
] | Closes the connection to agi.
@return void | [
"Closes",
"the",
"connection",
"to",
"agi",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L130-L138 |
30,088 | marcelog/PAGI | src/PAGI/Client/Impl/ClientImpl.php | ClientImpl.read | protected function read()
{
$line = fgets($this->input);
if ($line === false) {
throw new PAGIException('Could not read from AGI');
}
$line = substr($line, 0, -1);
$this->logger->debug('Read: ' . $line);
return $line;
} | php | protected function read()
{
$line = fgets($this->input);
if ($line === false) {
throw new PAGIException('Could not read from AGI');
}
$line = substr($line, 0, -1);
$this->logger->debug('Read: ' . $line);
return $line;
} | [
"protected",
"function",
"read",
"(",
")",
"{",
"$",
"line",
"=",
"fgets",
"(",
"$",
"this",
"->",
"input",
")",
";",
"if",
"(",
"$",
"line",
"===",
"false",
")",
"{",
"throw",
"new",
"PAGIException",
"(",
"'Could not read from AGI'",
")",
";",
"}",
"$",
"line",
"=",
"substr",
"(",
"$",
"line",
",",
"0",
",",
"-",
"1",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Read: '",
".",
"$",
"line",
")",
";",
"return",
"$",
"line",
";",
"}"
] | Reads input from asterisk.
@throws PAGIException
@return string | [
"Reads",
"input",
"from",
"asterisk",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L147-L156 |
30,089 | marcelog/PAGI | src/PAGI/Client/Impl/ClientImpl.php | ClientImpl.getInstance | public static function getInstance(array $options = array())
{
if (self::$instance === false) {
$ret = new ClientImpl($options);
self::$instance = $ret;
} else {
$ret = self::$instance;
}
return $ret;
} | php | public static function getInstance(array $options = array())
{
if (self::$instance === false) {
$ret = new ClientImpl($options);
self::$instance = $ret;
} else {
$ret = self::$instance;
}
return $ret;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"instance",
"===",
"false",
")",
"{",
"$",
"ret",
"=",
"new",
"ClientImpl",
"(",
"$",
"options",
")",
";",
"self",
"::",
"$",
"instance",
"=",
"$",
"ret",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"self",
"::",
"$",
"instance",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] | Returns a client instance for this call.
@param array $options Optional properties.
@return ClientImpl | [
"Returns",
"a",
"client",
"instance",
"for",
"this",
"call",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Client/Impl/ClientImpl.php#L165-L174 |
30,090 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.loadValidatorsFrom | public function loadValidatorsFrom(array $validatorsInformation)
{
foreach ($validatorsInformation as $name => $validatorInfo) {
$this->validateInputWith(
$name,
$validatorInfo['callback'],
$validatorInfo['soundOnError']
);
}
return $this;
} | php | public function loadValidatorsFrom(array $validatorsInformation)
{
foreach ($validatorsInformation as $name => $validatorInfo) {
$this->validateInputWith(
$name,
$validatorInfo['callback'],
$validatorInfo['soundOnError']
);
}
return $this;
} | [
"public",
"function",
"loadValidatorsFrom",
"(",
"array",
"$",
"validatorsInformation",
")",
"{",
"foreach",
"(",
"$",
"validatorsInformation",
"as",
"$",
"name",
"=>",
"$",
"validatorInfo",
")",
"{",
"$",
"this",
"->",
"validateInputWith",
"(",
"$",
"name",
",",
"$",
"validatorInfo",
"[",
"'callback'",
"]",
",",
"$",
"validatorInfo",
"[",
"'soundOnError'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Given an array of validator information structures, this will load
all validators into this node.
@param validatorInfo[] $validatorsInformation
@return Node | [
"Given",
"an",
"array",
"of",
"validator",
"information",
"structures",
"this",
"will",
"load",
"all",
"validators",
"into",
"this",
"node",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L467-L477 |
30,091 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.validateInputWith | public function validateInputWith($name, \Closure $validation, $soundOnError = null)
{
$this->inputValidations[$name] = self::createValidatorInfo(
$validation,
$soundOnError
);
return $this;
} | php | public function validateInputWith($name, \Closure $validation, $soundOnError = null)
{
$this->inputValidations[$name] = self::createValidatorInfo(
$validation,
$soundOnError
);
return $this;
} | [
"public",
"function",
"validateInputWith",
"(",
"$",
"name",
",",
"\\",
"Closure",
"$",
"validation",
",",
"$",
"soundOnError",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"inputValidations",
"[",
"$",
"name",
"]",
"=",
"self",
"::",
"createValidatorInfo",
"(",
"$",
"validation",
",",
"$",
"soundOnError",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Add an input validation to this node.
@param string $name A distrinctive name for this validator
@param \Closure $validation Callback to use for validation
@param string|null $soundOnError Optional sound to play on error
@return Node | [
"Add",
"an",
"input",
"validation",
"to",
"this",
"node",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L488-L495 |
30,092 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.validate | public function validate()
{
foreach ($this->inputValidations as $name => $data) {
$validator = $data['callback'];
$result = $validator($this);
if ($result === false) {
$this->logDebug("Validation FAILED: $name");
$onError = $data['soundOnError'];
if (is_array($onError)) {
foreach ($onError as $msg) {
$this->addPrePromptMessage($msg);
}
} elseif (is_string($onError)) {
$this->addPrePromptMessage($onError);
} else {
$this->logDebug("Ignoring validation sound: " . print_r($onError, true));
}
return false;
}
$this->logDebug("Validation OK: $name");
}
return true;
} | php | public function validate()
{
foreach ($this->inputValidations as $name => $data) {
$validator = $data['callback'];
$result = $validator($this);
if ($result === false) {
$this->logDebug("Validation FAILED: $name");
$onError = $data['soundOnError'];
if (is_array($onError)) {
foreach ($onError as $msg) {
$this->addPrePromptMessage($msg);
}
} elseif (is_string($onError)) {
$this->addPrePromptMessage($onError);
} else {
$this->logDebug("Ignoring validation sound: " . print_r($onError, true));
}
return false;
}
$this->logDebug("Validation OK: $name");
}
return true;
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"inputValidations",
"as",
"$",
"name",
"=>",
"$",
"data",
")",
"{",
"$",
"validator",
"=",
"$",
"data",
"[",
"'callback'",
"]",
";",
"$",
"result",
"=",
"$",
"validator",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"logDebug",
"(",
"\"Validation FAILED: $name\"",
")",
";",
"$",
"onError",
"=",
"$",
"data",
"[",
"'soundOnError'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"onError",
")",
")",
"{",
"foreach",
"(",
"$",
"onError",
"as",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"addPrePromptMessage",
"(",
"$",
"msg",
")",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"onError",
")",
")",
"{",
"$",
"this",
"->",
"addPrePromptMessage",
"(",
"$",
"onError",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"logDebug",
"(",
"\"Ignoring validation sound: \"",
".",
"print_r",
"(",
"$",
"onError",
",",
"true",
")",
")",
";",
"}",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"logDebug",
"(",
"\"Validation OK: $name\"",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Calls all validators in order. Will stop when any of them returns false.
@return boolean | [
"Calls",
"all",
"validators",
"in",
"order",
".",
"Will",
"stop",
"when",
"any",
"of",
"them",
"returns",
"false",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L502-L524 |
30,093 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.addClientMethodCall | protected function addClientMethodCall()
{
$args = func_get_args();
$name = array_shift($args);
$this->promptMessages[] = array($name => $args);
} | php | protected function addClientMethodCall()
{
$args = func_get_args();
$name = array_shift($args);
$this->promptMessages[] = array($name => $args);
} | [
"protected",
"function",
"addClientMethodCall",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"promptMessages",
"[",
"]",
"=",
"array",
"(",
"$",
"name",
"=>",
"$",
"args",
")",
";",
"}"
] | Internally used to execute prompt messages in the agi client.
@return void | [
"Internally",
"used",
"to",
"execute",
"prompt",
"messages",
"in",
"the",
"agi",
"client",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L542-L547 |
30,094 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.addPrePromptClientMethodCall | protected function addPrePromptClientMethodCall()
{
$args = func_get_args();
$name = array_shift($args);
$this->prePromptMessages[] = array($name => $args);
} | php | protected function addPrePromptClientMethodCall()
{
$args = func_get_args();
$name = array_shift($args);
$this->prePromptMessages[] = array($name => $args);
} | [
"protected",
"function",
"addPrePromptClientMethodCall",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"name",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"prePromptMessages",
"[",
"]",
"=",
"array",
"(",
"$",
"name",
"=>",
"$",
"args",
")",
";",
"}"
] | Internally used to execute pre prompt messages in the agi client.
@return void | [
"Internally",
"used",
"to",
"execute",
"pre",
"prompt",
"messages",
"in",
"the",
"agi",
"client",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L554-L559 |
30,095 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.evaluateInput | protected function evaluateInput($digit)
{
if ($this->inputIsCancel($digit)) {
return self::INPUT_CANCEL;
}
if ($this->inputIsEnd($digit)) {
return self::INPUT_END;
}
return self::INPUT_NORMAL;
} | php | protected function evaluateInput($digit)
{
if ($this->inputIsCancel($digit)) {
return self::INPUT_CANCEL;
}
if ($this->inputIsEnd($digit)) {
return self::INPUT_END;
}
return self::INPUT_NORMAL;
} | [
"protected",
"function",
"evaluateInput",
"(",
"$",
"digit",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inputIsCancel",
"(",
"$",
"digit",
")",
")",
"{",
"return",
"self",
"::",
"INPUT_CANCEL",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"inputIsEnd",
"(",
"$",
"digit",
")",
")",
"{",
"return",
"self",
"::",
"INPUT_END",
";",
"}",
"return",
"self",
"::",
"INPUT_NORMAL",
";",
"}"
] | Returns the kind of digit entered by the user, CANCEL, END, NORMAL.
@param string $digit A single character, one of the DTMF_* constants.
@return integer | [
"Returns",
"the",
"kind",
"of",
"digit",
"entered",
"by",
"the",
"user",
"CANCEL",
"END",
"NORMAL",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L837-L846 |
30,096 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.callClientMethod | protected function callClientMethod($name, array $arguments = array())
{
$this->logDebug("$name(" . implode(",", $arguments) . ")");
return call_user_func_array(array($this->client, $name), $arguments);
} | php | protected function callClientMethod($name, array $arguments = array())
{
$this->logDebug("$name(" . implode(",", $arguments) . ")");
return call_user_func_array(array($this->client, $name), $arguments);
} | [
"protected",
"function",
"callClientMethod",
"(",
"$",
"name",
",",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"logDebug",
"(",
"\"$name(\"",
".",
"implode",
"(",
"\",\"",
",",
"$",
"arguments",
")",
".",
"\")\"",
")",
";",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
"->",
"client",
",",
"$",
"name",
")",
",",
"$",
"arguments",
")",
";",
"}"
] | Call a specific method on a client.
@param string $name
@param string[] $arguments
@return IResult | [
"Call",
"a",
"specific",
"method",
"on",
"a",
"client",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L921-L925 |
30,097 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.callClientMethods | protected function callClientMethods($methods, $stopWhen = null)
{
$result = null;
foreach ($methods as $callInfo) {
foreach ($callInfo as $name => $arguments) {
$result = $this->callClientMethod($name, $arguments);
if ($stopWhen !== null) {
if ($stopWhen($result)) {
return $result;
}
}
}
}
return $result;
} | php | protected function callClientMethods($methods, $stopWhen = null)
{
$result = null;
foreach ($methods as $callInfo) {
foreach ($callInfo as $name => $arguments) {
$result = $this->callClientMethod($name, $arguments);
if ($stopWhen !== null) {
if ($stopWhen($result)) {
return $result;
}
}
}
}
return $result;
} | [
"protected",
"function",
"callClientMethods",
"(",
"$",
"methods",
",",
"$",
"stopWhen",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"null",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"callInfo",
")",
"{",
"foreach",
"(",
"$",
"callInfo",
"as",
"$",
"name",
"=>",
"$",
"arguments",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"callClientMethod",
"(",
"$",
"name",
",",
"$",
"arguments",
")",
";",
"if",
"(",
"$",
"stopWhen",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"stopWhen",
"(",
"$",
"result",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Calls methods in the PAGI client.
@param methodInfo[] $methods Methods to call, an array of arrays. The
second array has the method name as key and an array of arguments as
value.
@param \Closure $stopWhen If any, this callback is evaluated before
returning. Will return when false.
@return IResult | [
"Calls",
"methods",
"in",
"the",
"PAGI",
"client",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L938-L952 |
30,098 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.playPromptMessages | protected function playPromptMessages()
{
$interruptable = $this->promptsCanBeInterrupted;
$result = $this->callClientMethods(
$this->promptMessages,
function ($result) use ($interruptable) {
/* @var $result IReadResult */
return $interruptable && !$result->isTimeout();
}
);
return $result;
} | php | protected function playPromptMessages()
{
$interruptable = $this->promptsCanBeInterrupted;
$result = $this->callClientMethods(
$this->promptMessages,
function ($result) use ($interruptable) {
/* @var $result IReadResult */
return $interruptable && !$result->isTimeout();
}
);
return $result;
} | [
"protected",
"function",
"playPromptMessages",
"(",
")",
"{",
"$",
"interruptable",
"=",
"$",
"this",
"->",
"promptsCanBeInterrupted",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"callClientMethods",
"(",
"$",
"this",
"->",
"promptMessages",
",",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"$",
"interruptable",
")",
"{",
"/* @var $result IReadResult */",
"return",
"$",
"interruptable",
"&&",
"!",
"$",
"result",
"->",
"isTimeout",
"(",
")",
";",
"}",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Plays pre prompt messages, like error messages from validations.
@return IResult|null | [
"Plays",
"pre",
"prompt",
"messages",
"like",
"error",
"messages",
"from",
"validations",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L959-L970 |
30,099 | marcelog/PAGI | src/PAGI/Node/Node.php | Node.playPrePromptMessages | protected function playPrePromptMessages()
{
$interruptable = $this->prePromptMessagesInterruptable;
$result = $this->callClientMethods(
$this->prePromptMessages,
function ($result) use ($interruptable) {
/* @var $result IReadResult */
return $interruptable && !$result->isTimeout();
}
);
$this->clearPrePromptMessages();
return $result;
} | php | protected function playPrePromptMessages()
{
$interruptable = $this->prePromptMessagesInterruptable;
$result = $this->callClientMethods(
$this->prePromptMessages,
function ($result) use ($interruptable) {
/* @var $result IReadResult */
return $interruptable && !$result->isTimeout();
}
);
$this->clearPrePromptMessages();
return $result;
} | [
"protected",
"function",
"playPrePromptMessages",
"(",
")",
"{",
"$",
"interruptable",
"=",
"$",
"this",
"->",
"prePromptMessagesInterruptable",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"callClientMethods",
"(",
"$",
"this",
"->",
"prePromptMessages",
",",
"function",
"(",
"$",
"result",
")",
"use",
"(",
"$",
"interruptable",
")",
"{",
"/* @var $result IReadResult */",
"return",
"$",
"interruptable",
"&&",
"!",
"$",
"result",
"->",
"isTimeout",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"clearPrePromptMessages",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Internally used to play all pre prompt queued messages. Clears the
queue after it.
@return IResult | [
"Internally",
"used",
"to",
"play",
"all",
"pre",
"prompt",
"queued",
"messages",
".",
"Clears",
"the",
"queue",
"after",
"it",
"."
] | c72d50304716c60a8c016eaf2b0faf2fca72f46d | https://github.com/marcelog/PAGI/blob/c72d50304716c60a8c016eaf2b0faf2fca72f46d/src/PAGI/Node/Node.php#L988-L1000 |
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.