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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
26,600
|
iherwig/wcmf
|
src/wcmf/lib/security/impl/StaticPermissionManager.php
|
StaticPermissionManager.getConfigurationInstance
|
protected function getConfigurationInstance() {
// get config file to modify
$configFiles = $this->configuration->getConfigurations();
if (sizeof($configFiles) == 0) {
return false;
}
// create a writable configuration and modify the permission
$mainConfig = $configFiles[0];
$config = new InifileConfiguration(dirname($mainConfig).'/');
$config->addConfiguration(basename($mainConfig));
return [
'instance' => $config,
'file' => $mainConfig
];
}
|
php
|
protected function getConfigurationInstance() {
// get config file to modify
$configFiles = $this->configuration->getConfigurations();
if (sizeof($configFiles) == 0) {
return false;
}
// create a writable configuration and modify the permission
$mainConfig = $configFiles[0];
$config = new InifileConfiguration(dirname($mainConfig).'/');
$config->addConfiguration(basename($mainConfig));
return [
'instance' => $config,
'file' => $mainConfig
];
}
|
[
"protected",
"function",
"getConfigurationInstance",
"(",
")",
"{",
"// get config file to modify",
"$",
"configFiles",
"=",
"$",
"this",
"->",
"configuration",
"->",
"getConfigurations",
"(",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"configFiles",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"// create a writable configuration and modify the permission",
"$",
"mainConfig",
"=",
"$",
"configFiles",
"[",
"0",
"]",
";",
"$",
"config",
"=",
"new",
"InifileConfiguration",
"(",
"dirname",
"(",
"$",
"mainConfig",
")",
".",
"'/'",
")",
";",
"$",
"config",
"->",
"addConfiguration",
"(",
"basename",
"(",
"$",
"mainConfig",
")",
")",
";",
"return",
"[",
"'instance'",
"=>",
"$",
"config",
",",
"'file'",
"=>",
"$",
"mainConfig",
"]",
";",
"}"
] |
Get the configuration instance and file that is used to store the permissions.
@return Associative array with keys 'instance' and 'file'.
|
[
"Get",
"the",
"configuration",
"instance",
"and",
"file",
"that",
"is",
"used",
"to",
"store",
"the",
"permissions",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/impl/StaticPermissionManager.php#L157-L172
|
26,601
|
iherwig/wcmf
|
src/wcmf/lib/config/impl/PersistenceActionKeyProvider.php
|
PersistenceActionKeyProvider.getAllKeyValues
|
protected function getAllKeyValues() {
$keys = [];
// add temporary permission to allow to read entitys
$this->isLoadingKeys = true;
$permissionManager = ObjectFactory::getInstance('permissionManager');
$tmpPerm = $permissionManager->addTempPermission($this->entityType, '', PersistenceAction::READ);
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$objects = $persistenceFacade->loadObjects($this->entityType, BuildDepth::SINGLE);
$permissionManager->removeTempPermission($tmpPerm);
$this->isLoadingKeys = false;
foreach ($objects as $object) {
$key = ActionKey::createKey(
$object->getValue($this->valueMap['resource']),
$object->getValue($this->valueMap['context']),
$object->getValue($this->valueMap['action'])
);
$keys[$key] = $object->getValue($this->valueMap['value']);
}
return $keys;
}
|
php
|
protected function getAllKeyValues() {
$keys = [];
// add temporary permission to allow to read entitys
$this->isLoadingKeys = true;
$permissionManager = ObjectFactory::getInstance('permissionManager');
$tmpPerm = $permissionManager->addTempPermission($this->entityType, '', PersistenceAction::READ);
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$objects = $persistenceFacade->loadObjects($this->entityType, BuildDepth::SINGLE);
$permissionManager->removeTempPermission($tmpPerm);
$this->isLoadingKeys = false;
foreach ($objects as $object) {
$key = ActionKey::createKey(
$object->getValue($this->valueMap['resource']),
$object->getValue($this->valueMap['context']),
$object->getValue($this->valueMap['action'])
);
$keys[$key] = $object->getValue($this->valueMap['value']);
}
return $keys;
}
|
[
"protected",
"function",
"getAllKeyValues",
"(",
")",
"{",
"$",
"keys",
"=",
"[",
"]",
";",
"// add temporary permission to allow to read entitys",
"$",
"this",
"->",
"isLoadingKeys",
"=",
"true",
";",
"$",
"permissionManager",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'permissionManager'",
")",
";",
"$",
"tmpPerm",
"=",
"$",
"permissionManager",
"->",
"addTempPermission",
"(",
"$",
"this",
"->",
"entityType",
",",
"''",
",",
"PersistenceAction",
"::",
"READ",
")",
";",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"$",
"objects",
"=",
"$",
"persistenceFacade",
"->",
"loadObjects",
"(",
"$",
"this",
"->",
"entityType",
",",
"BuildDepth",
"::",
"SINGLE",
")",
";",
"$",
"permissionManager",
"->",
"removeTempPermission",
"(",
"$",
"tmpPerm",
")",
";",
"$",
"this",
"->",
"isLoadingKeys",
"=",
"false",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"key",
"=",
"ActionKey",
"::",
"createKey",
"(",
"$",
"object",
"->",
"getValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'resource'",
"]",
")",
",",
"$",
"object",
"->",
"getValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'context'",
"]",
")",
",",
"$",
"object",
"->",
"getValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'action'",
"]",
")",
")",
";",
"$",
"keys",
"[",
"$",
"key",
"]",
"=",
"$",
"object",
"->",
"getValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'value'",
"]",
")",
";",
"}",
"return",
"$",
"keys",
";",
"}"
] |
Get all key values from the storage
@return Associative array with action keys as keys
|
[
"Get",
"all",
"key",
"values",
"from",
"the",
"storage"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/config/impl/PersistenceActionKeyProvider.php#L112-L131
|
26,602
|
iherwig/wcmf
|
src/wcmf/lib/config/impl/PersistenceActionKeyProvider.php
|
PersistenceActionKeyProvider.getSingleKeyValue
|
protected function getSingleKeyValue($actionKey) {
$query = new ObjectQuery($this->entityType, __CLASS__.__METHOD__);
$tpl = $query->getObjectTemplate($this->entityType);
$actionKeyParams = ActionKey::parseKey($actionKey);
$tpl->setValue($this->valueMap['resource'], Criteria::asValue('=', $actionKeyParams['resource']));
$tpl->setValue($this->valueMap['context'], Criteria::asValue('=', $actionKeyParams['context']));
$tpl->setValue($this->valueMap['action'], Criteria::asValue('=', $actionKeyParams['action']));
$keys = $query->execute(BuildDepth::SINGLE);
if (sizeof($keys) > 0) {
return $keys[0]->getValue($this->valueMap['value']);
}
return null;
}
|
php
|
protected function getSingleKeyValue($actionKey) {
$query = new ObjectQuery($this->entityType, __CLASS__.__METHOD__);
$tpl = $query->getObjectTemplate($this->entityType);
$actionKeyParams = ActionKey::parseKey($actionKey);
$tpl->setValue($this->valueMap['resource'], Criteria::asValue('=', $actionKeyParams['resource']));
$tpl->setValue($this->valueMap['context'], Criteria::asValue('=', $actionKeyParams['context']));
$tpl->setValue($this->valueMap['action'], Criteria::asValue('=', $actionKeyParams['action']));
$keys = $query->execute(BuildDepth::SINGLE);
if (sizeof($keys) > 0) {
return $keys[0]->getValue($this->valueMap['value']);
}
return null;
}
|
[
"protected",
"function",
"getSingleKeyValue",
"(",
"$",
"actionKey",
")",
"{",
"$",
"query",
"=",
"new",
"ObjectQuery",
"(",
"$",
"this",
"->",
"entityType",
",",
"__CLASS__",
".",
"__METHOD__",
")",
";",
"$",
"tpl",
"=",
"$",
"query",
"->",
"getObjectTemplate",
"(",
"$",
"this",
"->",
"entityType",
")",
";",
"$",
"actionKeyParams",
"=",
"ActionKey",
"::",
"parseKey",
"(",
"$",
"actionKey",
")",
";",
"$",
"tpl",
"->",
"setValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'resource'",
"]",
",",
"Criteria",
"::",
"asValue",
"(",
"'='",
",",
"$",
"actionKeyParams",
"[",
"'resource'",
"]",
")",
")",
";",
"$",
"tpl",
"->",
"setValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'context'",
"]",
",",
"Criteria",
"::",
"asValue",
"(",
"'='",
",",
"$",
"actionKeyParams",
"[",
"'context'",
"]",
")",
")",
";",
"$",
"tpl",
"->",
"setValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'action'",
"]",
",",
"Criteria",
"::",
"asValue",
"(",
"'='",
",",
"$",
"actionKeyParams",
"[",
"'action'",
"]",
")",
")",
";",
"$",
"keys",
"=",
"$",
"query",
"->",
"execute",
"(",
"BuildDepth",
"::",
"SINGLE",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"keys",
")",
">",
"0",
")",
"{",
"return",
"$",
"keys",
"[",
"0",
"]",
"->",
"getValue",
"(",
"$",
"this",
"->",
"valueMap",
"[",
"'value'",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get a single key value from the storage
@param $actionKey The action key
@return String
|
[
"Get",
"a",
"single",
"key",
"value",
"from",
"the",
"storage"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/config/impl/PersistenceActionKeyProvider.php#L138-L150
|
26,603
|
iherwig/wcmf
|
src/wcmf/lib/config/impl/PersistenceActionKeyProvider.php
|
PersistenceActionKeyProvider.keyChanged
|
public function keyChanged(PersistenceEvent $event) {
$object = $event->getObject();
if ($object->getType() == $this->entityType) {
$cache = ObjectFactory::getInstance('dynamicCache');
$cache->clear($this->getId());
}
}
|
php
|
public function keyChanged(PersistenceEvent $event) {
$object = $event->getObject();
if ($object->getType() == $this->entityType) {
$cache = ObjectFactory::getInstance('dynamicCache');
$cache->clear($this->getId());
}
}
|
[
"public",
"function",
"keyChanged",
"(",
"PersistenceEvent",
"$",
"event",
")",
"{",
"$",
"object",
"=",
"$",
"event",
"->",
"getObject",
"(",
")",
";",
"if",
"(",
"$",
"object",
"->",
"getType",
"(",
")",
"==",
"$",
"this",
"->",
"entityType",
")",
"{",
"$",
"cache",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'dynamicCache'",
")",
";",
"$",
"cache",
"->",
"clear",
"(",
"$",
"this",
"->",
"getId",
"(",
")",
")",
";",
"}",
"}"
] |
Listen to PersistentEvent
@param $event PersistentEvent instance
|
[
"Listen",
"to",
"PersistentEvent"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/config/impl/PersistenceActionKeyProvider.php#L156-L162
|
26,604
|
iherwig/wcmf
|
src/wcmf/lib/service/impl/HTTPClient.php
|
HTTPClient.doLogin
|
protected function doLogin() {
if ($this->user) {
$request = ObjectFactory::getNewInstance('request');
$request->setAction('login');
$request->setValues([
'login' => $this->user['login'],
'password' => $this->user['password']
]);
$response = $this->doRemoteCall($request, true);
if ($response->getValue('success')) {
$this->sessionId = $response->getValue('sid');
return true;
}
}
else {
throw new \RuntimeException("Remote user required for remote call.");
}
}
|
php
|
protected function doLogin() {
if ($this->user) {
$request = ObjectFactory::getNewInstance('request');
$request->setAction('login');
$request->setValues([
'login' => $this->user['login'],
'password' => $this->user['password']
]);
$response = $this->doRemoteCall($request, true);
if ($response->getValue('success')) {
$this->sessionId = $response->getValue('sid');
return true;
}
}
else {
throw new \RuntimeException("Remote user required for remote call.");
}
}
|
[
"protected",
"function",
"doLogin",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"user",
")",
"{",
"$",
"request",
"=",
"ObjectFactory",
"::",
"getNewInstance",
"(",
"'request'",
")",
";",
"$",
"request",
"->",
"setAction",
"(",
"'login'",
")",
";",
"$",
"request",
"->",
"setValues",
"(",
"[",
"'login'",
"=>",
"$",
"this",
"->",
"user",
"[",
"'login'",
"]",
",",
"'password'",
"=>",
"$",
"this",
"->",
"user",
"[",
"'password'",
"]",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"doRemoteCall",
"(",
"$",
"request",
",",
"true",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getValue",
"(",
"'success'",
")",
")",
"{",
"$",
"this",
"->",
"sessionId",
"=",
"$",
"response",
"->",
"getValue",
"(",
"'sid'",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Remote user required for remote call.\"",
")",
";",
"}",
"}"
] |
Do the login request. If the request is successful,
the session id will be set.
@return True on success
|
[
"Do",
"the",
"login",
"request",
".",
"If",
"the",
"request",
"is",
"successful",
"the",
"session",
"id",
"will",
"be",
"set",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/impl/HTTPClient.php#L130-L147
|
26,605
|
iherwig/wcmf
|
src/wcmf/application/controller/CopyController.php
|
CopyController.copyNode
|
protected function copyNode(ObjectId $oid) {
$logger = $this->getLogger();
if ($logger->isDebugEnabled()) {
$logger->debug("Copying node ".$oid);
}
$persistenceFacade = $this->getPersistenceFacade();
// load the original node
$node = $persistenceFacade->load($oid);
if ($node == null) {
throw new PersistenceException("Can't load node '".$oid."'");
}
// check if we already have a copy of the node
$nodeCopy = $this->getCopy($node->getOID());
if ($nodeCopy == null) {
// if not, create it
$nodeCopy = $persistenceFacade->create($node->getType());
$node->copyValues($nodeCopy, false);
}
// save copy
$this->registerCopy($node, $nodeCopy);
if ($logger->isInfoEnabled()) {
$logger->info("Copied: ".$node->getOID()." to ".$nodeCopy->getOID());
}
if ($logger->isDebugEnabled()) {
$logger->debug($nodeCopy->__toString());
}
// create the connections to already copied relatives
// this must be done after saving the node in order to have a correct oid
$mapper = $node->getMapper();
$relations = $mapper->getRelations();
foreach ($relations as $relation) {
if ($relation->getOtherNavigability()) {
$otherRole = $relation->getOtherRole();
$relativeValue = $node->getValue($otherRole);
$relatives = $relation->isMultiValued() ? $relativeValue :
($relativeValue != null ? [$relativeValue] : []);
foreach ($relatives as $relative) {
$copiedRelative = $this->getCopy($relative->getOID());
if ($copiedRelative != null) {
$nodeCopy->addNode($copiedRelative, $otherRole);
if ($logger->isDebugEnabled()) {
$logger->debug("Added ".$copiedRelative->getOID()." to ".$nodeCopy->getOID());
$logger->debug($copiedRelative->__toString());
}
}
}
}
}
return $nodeCopy;
}
|
php
|
protected function copyNode(ObjectId $oid) {
$logger = $this->getLogger();
if ($logger->isDebugEnabled()) {
$logger->debug("Copying node ".$oid);
}
$persistenceFacade = $this->getPersistenceFacade();
// load the original node
$node = $persistenceFacade->load($oid);
if ($node == null) {
throw new PersistenceException("Can't load node '".$oid."'");
}
// check if we already have a copy of the node
$nodeCopy = $this->getCopy($node->getOID());
if ($nodeCopy == null) {
// if not, create it
$nodeCopy = $persistenceFacade->create($node->getType());
$node->copyValues($nodeCopy, false);
}
// save copy
$this->registerCopy($node, $nodeCopy);
if ($logger->isInfoEnabled()) {
$logger->info("Copied: ".$node->getOID()." to ".$nodeCopy->getOID());
}
if ($logger->isDebugEnabled()) {
$logger->debug($nodeCopy->__toString());
}
// create the connections to already copied relatives
// this must be done after saving the node in order to have a correct oid
$mapper = $node->getMapper();
$relations = $mapper->getRelations();
foreach ($relations as $relation) {
if ($relation->getOtherNavigability()) {
$otherRole = $relation->getOtherRole();
$relativeValue = $node->getValue($otherRole);
$relatives = $relation->isMultiValued() ? $relativeValue :
($relativeValue != null ? [$relativeValue] : []);
foreach ($relatives as $relative) {
$copiedRelative = $this->getCopy($relative->getOID());
if ($copiedRelative != null) {
$nodeCopy->addNode($copiedRelative, $otherRole);
if ($logger->isDebugEnabled()) {
$logger->debug("Added ".$copiedRelative->getOID()." to ".$nodeCopy->getOID());
$logger->debug($copiedRelative->__toString());
}
}
}
}
}
return $nodeCopy;
}
|
[
"protected",
"function",
"copyNode",
"(",
"ObjectId",
"$",
"oid",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"if",
"(",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"\"Copying node \"",
".",
"$",
"oid",
")",
";",
"}",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"// load the original node",
"$",
"node",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"$",
"oid",
")",
";",
"if",
"(",
"$",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"\"Can't load node '\"",
".",
"$",
"oid",
".",
"\"'\"",
")",
";",
"}",
"// check if we already have a copy of the node",
"$",
"nodeCopy",
"=",
"$",
"this",
"->",
"getCopy",
"(",
"$",
"node",
"->",
"getOID",
"(",
")",
")",
";",
"if",
"(",
"$",
"nodeCopy",
"==",
"null",
")",
"{",
"// if not, create it",
"$",
"nodeCopy",
"=",
"$",
"persistenceFacade",
"->",
"create",
"(",
"$",
"node",
"->",
"getType",
"(",
")",
")",
";",
"$",
"node",
"->",
"copyValues",
"(",
"$",
"nodeCopy",
",",
"false",
")",
";",
"}",
"// save copy",
"$",
"this",
"->",
"registerCopy",
"(",
"$",
"node",
",",
"$",
"nodeCopy",
")",
";",
"if",
"(",
"$",
"logger",
"->",
"isInfoEnabled",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"info",
"(",
"\"Copied: \"",
".",
"$",
"node",
"->",
"getOID",
"(",
")",
".",
"\" to \"",
".",
"$",
"nodeCopy",
"->",
"getOID",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"$",
"nodeCopy",
"->",
"__toString",
"(",
")",
")",
";",
"}",
"// create the connections to already copied relatives",
"// this must be done after saving the node in order to have a correct oid",
"$",
"mapper",
"=",
"$",
"node",
"->",
"getMapper",
"(",
")",
";",
"$",
"relations",
"=",
"$",
"mapper",
"->",
"getRelations",
"(",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"relation",
")",
"{",
"if",
"(",
"$",
"relation",
"->",
"getOtherNavigability",
"(",
")",
")",
"{",
"$",
"otherRole",
"=",
"$",
"relation",
"->",
"getOtherRole",
"(",
")",
";",
"$",
"relativeValue",
"=",
"$",
"node",
"->",
"getValue",
"(",
"$",
"otherRole",
")",
";",
"$",
"relatives",
"=",
"$",
"relation",
"->",
"isMultiValued",
"(",
")",
"?",
"$",
"relativeValue",
":",
"(",
"$",
"relativeValue",
"!=",
"null",
"?",
"[",
"$",
"relativeValue",
"]",
":",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"relatives",
"as",
"$",
"relative",
")",
"{",
"$",
"copiedRelative",
"=",
"$",
"this",
"->",
"getCopy",
"(",
"$",
"relative",
"->",
"getOID",
"(",
")",
")",
";",
"if",
"(",
"$",
"copiedRelative",
"!=",
"null",
")",
"{",
"$",
"nodeCopy",
"->",
"addNode",
"(",
"$",
"copiedRelative",
",",
"$",
"otherRole",
")",
";",
"if",
"(",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"\"Added \"",
".",
"$",
"copiedRelative",
"->",
"getOID",
"(",
")",
".",
"\" to \"",
".",
"$",
"nodeCopy",
"->",
"getOID",
"(",
")",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"$",
"copiedRelative",
"->",
"__toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"nodeCopy",
";",
"}"
] |
Create a copy of the node with the given object id. The returned
node is already persisted.
@param $oid The object id of the node to copy
@return The copied Node or null
|
[
"Create",
"a",
"copy",
"of",
"the",
"node",
"with",
"the",
"given",
"object",
"id",
".",
"The",
"returned",
"node",
"is",
"already",
"persisted",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/CopyController.php#L355-L409
|
26,606
|
iherwig/wcmf
|
src/wcmf/application/controller/CopyController.php
|
CopyController.getTargetNode
|
protected function getTargetNode(ObjectId $targetOID) {
if ($this->targetNode == null) {
// load parent node
$persistenceFacade = $this->getPersistenceFacade();
$targetNode = $persistenceFacade->load($targetOID);
$this->targetNode = $targetNode;
}
return $this->targetNode;
}
|
php
|
protected function getTargetNode(ObjectId $targetOID) {
if ($this->targetNode == null) {
// load parent node
$persistenceFacade = $this->getPersistenceFacade();
$targetNode = $persistenceFacade->load($targetOID);
$this->targetNode = $targetNode;
}
return $this->targetNode;
}
|
[
"protected",
"function",
"getTargetNode",
"(",
"ObjectId",
"$",
"targetOID",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"targetNode",
"==",
"null",
")",
"{",
"// load parent node",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"$",
"targetNode",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"$",
"targetOID",
")",
";",
"$",
"this",
"->",
"targetNode",
"=",
"$",
"targetNode",
";",
"}",
"return",
"$",
"this",
"->",
"targetNode",
";",
"}"
] |
Get the target node from the request parameter targetoid
@param $targetOID The object id of the target node
@return Node instance
|
[
"Get",
"the",
"target",
"node",
"from",
"the",
"request",
"parameter",
"targetoid"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/CopyController.php#L427-L435
|
26,607
|
iherwig/wcmf
|
src/wcmf/application/controller/CopyController.php
|
CopyController.registerCopy
|
protected function registerCopy(PersistentObject $origNode, PersistentObject $copyNode) {
// store oid in the registry
$registry = $this->getLocalSessionValue(self::OBJECT_MAP_VAR);
$registry[$origNode->getOID()->__toString()] = $copyNode->getOID()->__toString();
$this->setLocalSessionValue(self::OBJECT_MAP_VAR, $registry);
}
|
php
|
protected function registerCopy(PersistentObject $origNode, PersistentObject $copyNode) {
// store oid in the registry
$registry = $this->getLocalSessionValue(self::OBJECT_MAP_VAR);
$registry[$origNode->getOID()->__toString()] = $copyNode->getOID()->__toString();
$this->setLocalSessionValue(self::OBJECT_MAP_VAR, $registry);
}
|
[
"protected",
"function",
"registerCopy",
"(",
"PersistentObject",
"$",
"origNode",
",",
"PersistentObject",
"$",
"copyNode",
")",
"{",
"// store oid in the registry",
"$",
"registry",
"=",
"$",
"this",
"->",
"getLocalSessionValue",
"(",
"self",
"::",
"OBJECT_MAP_VAR",
")",
";",
"$",
"registry",
"[",
"$",
"origNode",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
"]",
"=",
"$",
"copyNode",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
";",
"$",
"this",
"->",
"setLocalSessionValue",
"(",
"self",
"::",
"OBJECT_MAP_VAR",
",",
"$",
"registry",
")",
";",
"}"
] |
Register a copied node in the session for later reference
@param $origNode The original Node instance
@param $copyNode The copied Node instance
|
[
"Register",
"a",
"copied",
"node",
"in",
"the",
"session",
"for",
"later",
"reference"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/CopyController.php#L442-L447
|
26,608
|
iherwig/wcmf
|
src/wcmf/application/controller/CopyController.php
|
CopyController.updateCopyOIDs
|
protected function updateCopyOIDs(array $oidMap) {
$registry = $this->getLocalSessionValue(self::OBJECT_MAP_VAR);
// registry maybe deleted already if it's the last step
if ($registry) {
$flippedRegistry = array_flip($registry);
foreach ($oidMap as $oldOid => $newOid) {
if (isset($flippedRegistry[$oldOid])) {
$key = $flippedRegistry[$oldOid];
unset($flippedRegistry[$oldOid]);
$flippedRegistry[$newOid] = $key;
}
}
$registry = array_flip($flippedRegistry);
$this->setLocalSessionValue(self::OBJECT_MAP_VAR, $registry);
}
}
|
php
|
protected function updateCopyOIDs(array $oidMap) {
$registry = $this->getLocalSessionValue(self::OBJECT_MAP_VAR);
// registry maybe deleted already if it's the last step
if ($registry) {
$flippedRegistry = array_flip($registry);
foreach ($oidMap as $oldOid => $newOid) {
if (isset($flippedRegistry[$oldOid])) {
$key = $flippedRegistry[$oldOid];
unset($flippedRegistry[$oldOid]);
$flippedRegistry[$newOid] = $key;
}
}
$registry = array_flip($flippedRegistry);
$this->setLocalSessionValue(self::OBJECT_MAP_VAR, $registry);
}
}
|
[
"protected",
"function",
"updateCopyOIDs",
"(",
"array",
"$",
"oidMap",
")",
"{",
"$",
"registry",
"=",
"$",
"this",
"->",
"getLocalSessionValue",
"(",
"self",
"::",
"OBJECT_MAP_VAR",
")",
";",
"// registry maybe deleted already if it's the last step",
"if",
"(",
"$",
"registry",
")",
"{",
"$",
"flippedRegistry",
"=",
"array_flip",
"(",
"$",
"registry",
")",
";",
"foreach",
"(",
"$",
"oidMap",
"as",
"$",
"oldOid",
"=>",
"$",
"newOid",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"flippedRegistry",
"[",
"$",
"oldOid",
"]",
")",
")",
"{",
"$",
"key",
"=",
"$",
"flippedRegistry",
"[",
"$",
"oldOid",
"]",
";",
"unset",
"(",
"$",
"flippedRegistry",
"[",
"$",
"oldOid",
"]",
")",
";",
"$",
"flippedRegistry",
"[",
"$",
"newOid",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"$",
"registry",
"=",
"array_flip",
"(",
"$",
"flippedRegistry",
")",
";",
"$",
"this",
"->",
"setLocalSessionValue",
"(",
"self",
"::",
"OBJECT_MAP_VAR",
",",
"$",
"registry",
")",
";",
"}",
"}"
] |
Update the copied object ids in the registry
@param $oidMap Map of changed object ids (key: old value, value: new value)
|
[
"Update",
"the",
"copied",
"object",
"ids",
"in",
"the",
"registry"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/CopyController.php#L453-L468
|
26,609
|
iherwig/wcmf
|
src/wcmf/application/controller/CopyController.php
|
CopyController.getCopyOID
|
protected function getCopyOID(ObjectId $origOID) {
$registry = $this->getLocalSessionValue(self::OBJECT_MAP_VAR);
// check if the oid exists in the registry
$oidStr = $origOID->__toString();
if (!isset($registry[$oidStr])) {
$logger = $this->getLogger();
if ($logger->isDebugEnabled()) {
$logger->debug("Copy of ".$oidStr." not found.");
}
return null;
}
$copyOID = ObjectId::parse($registry[$oidStr]);
return $copyOID;
}
|
php
|
protected function getCopyOID(ObjectId $origOID) {
$registry = $this->getLocalSessionValue(self::OBJECT_MAP_VAR);
// check if the oid exists in the registry
$oidStr = $origOID->__toString();
if (!isset($registry[$oidStr])) {
$logger = $this->getLogger();
if ($logger->isDebugEnabled()) {
$logger->debug("Copy of ".$oidStr." not found.");
}
return null;
}
$copyOID = ObjectId::parse($registry[$oidStr]);
return $copyOID;
}
|
[
"protected",
"function",
"getCopyOID",
"(",
"ObjectId",
"$",
"origOID",
")",
"{",
"$",
"registry",
"=",
"$",
"this",
"->",
"getLocalSessionValue",
"(",
"self",
"::",
"OBJECT_MAP_VAR",
")",
";",
"// check if the oid exists in the registry",
"$",
"oidStr",
"=",
"$",
"origOID",
"->",
"__toString",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"registry",
"[",
"$",
"oidStr",
"]",
")",
")",
"{",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"if",
"(",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"$",
"logger",
"->",
"debug",
"(",
"\"Copy of \"",
".",
"$",
"oidStr",
".",
"\" not found.\"",
")",
";",
"}",
"return",
"null",
";",
"}",
"$",
"copyOID",
"=",
"ObjectId",
"::",
"parse",
"(",
"$",
"registry",
"[",
"$",
"oidStr",
"]",
")",
";",
"return",
"$",
"copyOID",
";",
"}"
] |
Get the object id of the copied node for a node id
@param $origOID The object id of the original node
@return ObjectId or null, if it does not exist already
|
[
"Get",
"the",
"object",
"id",
"of",
"the",
"copied",
"node",
"for",
"a",
"node",
"id"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/CopyController.php#L475-L490
|
26,610
|
iherwig/wcmf
|
src/wcmf/application/controller/CopyController.php
|
CopyController.getCopy
|
protected function getCopy(ObjectId $origOID) {
$copyOID = $this->getCopyOID($origOID);
if ($copyOID != null) {
$persistenceFacade = $this->getPersistenceFacade();
$nodeCopy = $persistenceFacade->load($copyOID);
return $nodeCopy;
}
else {
return null;
}
}
|
php
|
protected function getCopy(ObjectId $origOID) {
$copyOID = $this->getCopyOID($origOID);
if ($copyOID != null) {
$persistenceFacade = $this->getPersistenceFacade();
$nodeCopy = $persistenceFacade->load($copyOID);
return $nodeCopy;
}
else {
return null;
}
}
|
[
"protected",
"function",
"getCopy",
"(",
"ObjectId",
"$",
"origOID",
")",
"{",
"$",
"copyOID",
"=",
"$",
"this",
"->",
"getCopyOID",
"(",
"$",
"origOID",
")",
";",
"if",
"(",
"$",
"copyOID",
"!=",
"null",
")",
"{",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"$",
"nodeCopy",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"$",
"copyOID",
")",
";",
"return",
"$",
"nodeCopy",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the copied node for a node id
@param $origOID The object id of the original node
@return Copied Node or null, if it does not exist already
|
[
"Get",
"the",
"copied",
"node",
"for",
"a",
"node",
"id"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/CopyController.php#L497-L507
|
26,611
|
iherwig/wcmf
|
src/wcmf/lib/search/impl/LuceneSearch.php
|
LuceneSearch.setIndexPath
|
public function setIndexPath($indexPath) {
$fileUtil = new FileUtil();
$this->indexPath = $fileUtil->realpath(WCMF_BASE.$indexPath).'/';
$fileUtil->mkdirRec($this->indexPath);
if (!is_writeable($this->indexPath)) {
throw new ConfigurationException("Index path '".$indexPath."' is not writeable.");
}
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Lucene index location: ".$this->indexPath);
}
}
|
php
|
public function setIndexPath($indexPath) {
$fileUtil = new FileUtil();
$this->indexPath = $fileUtil->realpath(WCMF_BASE.$indexPath).'/';
$fileUtil->mkdirRec($this->indexPath);
if (!is_writeable($this->indexPath)) {
throw new ConfigurationException("Index path '".$indexPath."' is not writeable.");
}
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Lucene index location: ".$this->indexPath);
}
}
|
[
"public",
"function",
"setIndexPath",
"(",
"$",
"indexPath",
")",
"{",
"$",
"fileUtil",
"=",
"new",
"FileUtil",
"(",
")",
";",
"$",
"this",
"->",
"indexPath",
"=",
"$",
"fileUtil",
"->",
"realpath",
"(",
"WCMF_BASE",
".",
"$",
"indexPath",
")",
".",
"'/'",
";",
"$",
"fileUtil",
"->",
"mkdirRec",
"(",
"$",
"this",
"->",
"indexPath",
")",
";",
"if",
"(",
"!",
"is_writeable",
"(",
"$",
"this",
"->",
"indexPath",
")",
")",
"{",
"throw",
"new",
"ConfigurationException",
"(",
"\"Index path '\"",
".",
"$",
"indexPath",
".",
"\"' is not writeable.\"",
")",
";",
"}",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Lucene index location: \"",
".",
"$",
"this",
"->",
"indexPath",
")",
";",
"}",
"}"
] |
Set the path to the search index.
@param $indexPath Directory relative to main
|
[
"Set",
"the",
"path",
"to",
"the",
"search",
"index",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/search/impl/LuceneSearch.php#L88-L98
|
26,612
|
iherwig/wcmf
|
src/wcmf/lib/search/impl/LuceneSearch.php
|
LuceneSearch.afterCommit
|
public function afterCommit(TransactionEvent $event) {
if ($this->liveUpdate && $event->getPhase() == TransactionEvent::AFTER_COMMIT) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
// add inserted/updated objects
foreach (array_merge(array_values($event->getInsertedOids()), $event->getUpdatedOids()) as $oid) {
$object = $persistenceFacade->load(ObjectId::parse($oid));
if ($object) {
$this->addToIndex($object);
}
else {
self::$logger->warn("Could not index object with oid ".$oid." because it does not exist");
}
}
// remove deleted objects
foreach ($event->getDeletedOids() as $oid) {
$this->deleteFromIndex(ObjectId::parse($oid));
}
}
}
|
php
|
public function afterCommit(TransactionEvent $event) {
if ($this->liveUpdate && $event->getPhase() == TransactionEvent::AFTER_COMMIT) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
// add inserted/updated objects
foreach (array_merge(array_values($event->getInsertedOids()), $event->getUpdatedOids()) as $oid) {
$object = $persistenceFacade->load(ObjectId::parse($oid));
if ($object) {
$this->addToIndex($object);
}
else {
self::$logger->warn("Could not index object with oid ".$oid." because it does not exist");
}
}
// remove deleted objects
foreach ($event->getDeletedOids() as $oid) {
$this->deleteFromIndex(ObjectId::parse($oid));
}
}
}
|
[
"public",
"function",
"afterCommit",
"(",
"TransactionEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"liveUpdate",
"&&",
"$",
"event",
"->",
"getPhase",
"(",
")",
"==",
"TransactionEvent",
"::",
"AFTER_COMMIT",
")",
"{",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"// add inserted/updated objects",
"foreach",
"(",
"array_merge",
"(",
"array_values",
"(",
"$",
"event",
"->",
"getInsertedOids",
"(",
")",
")",
",",
"$",
"event",
"->",
"getUpdatedOids",
"(",
")",
")",
"as",
"$",
"oid",
")",
"{",
"$",
"object",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"ObjectId",
"::",
"parse",
"(",
"$",
"oid",
")",
")",
";",
"if",
"(",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"addToIndex",
"(",
"$",
"object",
")",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"logger",
"->",
"warn",
"(",
"\"Could not index object with oid \"",
".",
"$",
"oid",
".",
"\" because it does not exist\"",
")",
";",
"}",
"}",
"// remove deleted objects",
"foreach",
"(",
"$",
"event",
"->",
"getDeletedOids",
"(",
")",
"as",
"$",
"oid",
")",
"{",
"$",
"this",
"->",
"deleteFromIndex",
"(",
"ObjectId",
"::",
"parse",
"(",
"$",
"oid",
")",
")",
";",
"}",
"}",
"}"
] |
Listen to TransactionEvents
@param $event TransactionEvent instance
|
[
"Listen",
"to",
"TransactionEvents"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/search/impl/LuceneSearch.php#L310-L328
|
26,613
|
iherwig/wcmf
|
src/wcmf/lib/search/impl/LuceneSearch.php
|
LuceneSearch.getIndex
|
private function getIndex($create = true) {
if (!$this->index || $create) {
$indexPath = $this->getIndexPath();
$analyzer = new LuceneUtf8Analyzer();
// add stop words filter
$stopWords = $this->getStopWords();
$stopWordsFilter = new StopWords($stopWords);
$analyzer->addFilter($stopWordsFilter);
Analyzer::setDefault($analyzer);
Wildcard::setMinPrefixLength(0);
QueryParser::setDefaultEncoding('UTF-8');
QueryParser::setDefaultOperator(QueryParser::B_AND);
try {
$this->index = Lucene::open($indexPath);
//$this->index->setMaxMergeDocs(5);
//$this->index->setMergeFactor(5);
}
catch (\Exception $ex) {
$this->index = $this->resetIndex();
}
}
return $this->index;
}
|
php
|
private function getIndex($create = true) {
if (!$this->index || $create) {
$indexPath = $this->getIndexPath();
$analyzer = new LuceneUtf8Analyzer();
// add stop words filter
$stopWords = $this->getStopWords();
$stopWordsFilter = new StopWords($stopWords);
$analyzer->addFilter($stopWordsFilter);
Analyzer::setDefault($analyzer);
Wildcard::setMinPrefixLength(0);
QueryParser::setDefaultEncoding('UTF-8');
QueryParser::setDefaultOperator(QueryParser::B_AND);
try {
$this->index = Lucene::open($indexPath);
//$this->index->setMaxMergeDocs(5);
//$this->index->setMergeFactor(5);
}
catch (\Exception $ex) {
$this->index = $this->resetIndex();
}
}
return $this->index;
}
|
[
"private",
"function",
"getIndex",
"(",
"$",
"create",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"index",
"||",
"$",
"create",
")",
"{",
"$",
"indexPath",
"=",
"$",
"this",
"->",
"getIndexPath",
"(",
")",
";",
"$",
"analyzer",
"=",
"new",
"LuceneUtf8Analyzer",
"(",
")",
";",
"// add stop words filter",
"$",
"stopWords",
"=",
"$",
"this",
"->",
"getStopWords",
"(",
")",
";",
"$",
"stopWordsFilter",
"=",
"new",
"StopWords",
"(",
"$",
"stopWords",
")",
";",
"$",
"analyzer",
"->",
"addFilter",
"(",
"$",
"stopWordsFilter",
")",
";",
"Analyzer",
"::",
"setDefault",
"(",
"$",
"analyzer",
")",
";",
"Wildcard",
"::",
"setMinPrefixLength",
"(",
"0",
")",
";",
"QueryParser",
"::",
"setDefaultEncoding",
"(",
"'UTF-8'",
")",
";",
"QueryParser",
"::",
"setDefaultOperator",
"(",
"QueryParser",
"::",
"B_AND",
")",
";",
"try",
"{",
"$",
"this",
"->",
"index",
"=",
"Lucene",
"::",
"open",
"(",
"$",
"indexPath",
")",
";",
"//$this->index->setMaxMergeDocs(5);",
"//$this->index->setMergeFactor(5);",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"index",
"=",
"$",
"this",
"->",
"resetIndex",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"index",
";",
"}"
] |
Get the search index.
@param $create Boolean whether to create the index, if it does not exist (default: _true_)
@return An instance of ZendSearch/SearchIndexInterface or null
|
[
"Get",
"the",
"search",
"index",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/search/impl/LuceneSearch.php#L335-L361
|
26,614
|
GW2Treasures/gw2api
|
src/V2/Endpoint/Continent/RegionEndpoint.php
|
RegionEndpoint.mapsOf
|
public function mapsOf( $region ) {
return new MapEndpoint( $this->api, $this->continent, $this->floor, $region );
}
|
php
|
public function mapsOf( $region ) {
return new MapEndpoint( $this->api, $this->continent, $this->floor, $region );
}
|
[
"public",
"function",
"mapsOf",
"(",
"$",
"region",
")",
"{",
"return",
"new",
"MapEndpoint",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"continent",
",",
"$",
"this",
"->",
"floor",
",",
"$",
"region",
")",
";",
"}"
] |
Get the regions maps.
@param int $region
@return MapEndpoint
|
[
"Get",
"the",
"regions",
"maps",
"."
] |
c8795af0c1d0a434b9e530f779d5a95786db2176
|
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Endpoint/Continent/RegionEndpoint.php#L47-L49
|
26,615
|
iherwig/wcmf
|
src/wcmf/lib/presentation/link/LinkProcessor.php
|
LinkProcessor.processLinks
|
public static function processLinks($node, $base, LinkProcessorStrategy $strategy,
$recursive=true) {
if (!$node) {
return;
}
$invalidURLs = [];
$logger = LogManager::getLogger(__CLASS__);
// iterate over all node values
$iter = new NodeValueIterator($node, $recursive);
for($iter->rewind(); $iter->valid(); $iter->next()) {
$currentNode = $iter->currentNode();
$valueName = $iter->key();
$value = $currentNode->getValue($valueName);
$oldValue = $value;
// find links in texts
$urls = array_fill_keys(StringUtil::getUrls($value), 'embedded');
// find direct attribute urls
if (preg_match('/^[a-zA-Z]+:\/\//', $value) || InternalLink::isLink($value)) {
$urls[$value] = 'direct';
}
// process urls
foreach ($urls as $url => $type) {
// translate relative urls
if (!InternalLink::isLink($url) && !preg_match('/^#|^{|^$|^[a-zA-Z]+:\/\/|^javascript:|^mailto:/', $url) &&
@file_exists($url) === false) {
// translate relative links
$urlConv = URIUtil::translate($url, $base);
$value = self::replaceUrl($value, $url, $urlConv['absolute'], $type);
$url = $urlConv['absolute'];
}
// check url
$urlOK = self::checkUrl($url, $strategy);
if ($urlOK) {
$urlConv = null;
if (InternalLink::isLink($url)) {
// convert internal urls
$urlConv = self::convertInternalLink($url, $strategy);
}
elseif (preg_match('/^#/', $url)) {
// convert hash links
$urlConv = $strategy->getObjectUrl($node).$url;
}
if ($urlConv !== null) {
$value = self::replaceUrl($value, $url, $urlConv, $type);
}
}
else {
// invalid url
$logger->error("Invalid URL found: ".$url);
$oidStr = $currentNode->getOID()->__toString();
if (!isset($invalidURLs[$oidStr])) {
$invalidURLs[] = [];
}
$invalidURLs[$oidStr][] = $url;
$value = self::replaceUrl($value, $url, '#', $type);
}
}
if ($oldValue != $value) {
$currentNode->setValue($valueName, $value, true);
}
}
return $invalidURLs;
}
|
php
|
public static function processLinks($node, $base, LinkProcessorStrategy $strategy,
$recursive=true) {
if (!$node) {
return;
}
$invalidURLs = [];
$logger = LogManager::getLogger(__CLASS__);
// iterate over all node values
$iter = new NodeValueIterator($node, $recursive);
for($iter->rewind(); $iter->valid(); $iter->next()) {
$currentNode = $iter->currentNode();
$valueName = $iter->key();
$value = $currentNode->getValue($valueName);
$oldValue = $value;
// find links in texts
$urls = array_fill_keys(StringUtil::getUrls($value), 'embedded');
// find direct attribute urls
if (preg_match('/^[a-zA-Z]+:\/\//', $value) || InternalLink::isLink($value)) {
$urls[$value] = 'direct';
}
// process urls
foreach ($urls as $url => $type) {
// translate relative urls
if (!InternalLink::isLink($url) && !preg_match('/^#|^{|^$|^[a-zA-Z]+:\/\/|^javascript:|^mailto:/', $url) &&
@file_exists($url) === false) {
// translate relative links
$urlConv = URIUtil::translate($url, $base);
$value = self::replaceUrl($value, $url, $urlConv['absolute'], $type);
$url = $urlConv['absolute'];
}
// check url
$urlOK = self::checkUrl($url, $strategy);
if ($urlOK) {
$urlConv = null;
if (InternalLink::isLink($url)) {
// convert internal urls
$urlConv = self::convertInternalLink($url, $strategy);
}
elseif (preg_match('/^#/', $url)) {
// convert hash links
$urlConv = $strategy->getObjectUrl($node).$url;
}
if ($urlConv !== null) {
$value = self::replaceUrl($value, $url, $urlConv, $type);
}
}
else {
// invalid url
$logger->error("Invalid URL found: ".$url);
$oidStr = $currentNode->getOID()->__toString();
if (!isset($invalidURLs[$oidStr])) {
$invalidURLs[] = [];
}
$invalidURLs[$oidStr][] = $url;
$value = self::replaceUrl($value, $url, '#', $type);
}
}
if ($oldValue != $value) {
$currentNode->setValue($valueName, $value, true);
}
}
return $invalidURLs;
}
|
[
"public",
"static",
"function",
"processLinks",
"(",
"$",
"node",
",",
"$",
"base",
",",
"LinkProcessorStrategy",
"$",
"strategy",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"return",
";",
"}",
"$",
"invalidURLs",
"=",
"[",
"]",
";",
"$",
"logger",
"=",
"LogManager",
"::",
"getLogger",
"(",
"__CLASS__",
")",
";",
"// iterate over all node values",
"$",
"iter",
"=",
"new",
"NodeValueIterator",
"(",
"$",
"node",
",",
"$",
"recursive",
")",
";",
"for",
"(",
"$",
"iter",
"->",
"rewind",
"(",
")",
";",
"$",
"iter",
"->",
"valid",
"(",
")",
";",
"$",
"iter",
"->",
"next",
"(",
")",
")",
"{",
"$",
"currentNode",
"=",
"$",
"iter",
"->",
"currentNode",
"(",
")",
";",
"$",
"valueName",
"=",
"$",
"iter",
"->",
"key",
"(",
")",
";",
"$",
"value",
"=",
"$",
"currentNode",
"->",
"getValue",
"(",
"$",
"valueName",
")",
";",
"$",
"oldValue",
"=",
"$",
"value",
";",
"// find links in texts",
"$",
"urls",
"=",
"array_fill_keys",
"(",
"StringUtil",
"::",
"getUrls",
"(",
"$",
"value",
")",
",",
"'embedded'",
")",
";",
"// find direct attribute urls",
"if",
"(",
"preg_match",
"(",
"'/^[a-zA-Z]+:\\/\\//'",
",",
"$",
"value",
")",
"||",
"InternalLink",
"::",
"isLink",
"(",
"$",
"value",
")",
")",
"{",
"$",
"urls",
"[",
"$",
"value",
"]",
"=",
"'direct'",
";",
"}",
"// process urls",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"url",
"=>",
"$",
"type",
")",
"{",
"// translate relative urls",
"if",
"(",
"!",
"InternalLink",
"::",
"isLink",
"(",
"$",
"url",
")",
"&&",
"!",
"preg_match",
"(",
"'/^#|^{|^$|^[a-zA-Z]+:\\/\\/|^javascript:|^mailto:/'",
",",
"$",
"url",
")",
"&&",
"@",
"file_exists",
"(",
"$",
"url",
")",
"===",
"false",
")",
"{",
"// translate relative links",
"$",
"urlConv",
"=",
"URIUtil",
"::",
"translate",
"(",
"$",
"url",
",",
"$",
"base",
")",
";",
"$",
"value",
"=",
"self",
"::",
"replaceUrl",
"(",
"$",
"value",
",",
"$",
"url",
",",
"$",
"urlConv",
"[",
"'absolute'",
"]",
",",
"$",
"type",
")",
";",
"$",
"url",
"=",
"$",
"urlConv",
"[",
"'absolute'",
"]",
";",
"}",
"// check url",
"$",
"urlOK",
"=",
"self",
"::",
"checkUrl",
"(",
"$",
"url",
",",
"$",
"strategy",
")",
";",
"if",
"(",
"$",
"urlOK",
")",
"{",
"$",
"urlConv",
"=",
"null",
";",
"if",
"(",
"InternalLink",
"::",
"isLink",
"(",
"$",
"url",
")",
")",
"{",
"// convert internal urls",
"$",
"urlConv",
"=",
"self",
"::",
"convertInternalLink",
"(",
"$",
"url",
",",
"$",
"strategy",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^#/'",
",",
"$",
"url",
")",
")",
"{",
"// convert hash links",
"$",
"urlConv",
"=",
"$",
"strategy",
"->",
"getObjectUrl",
"(",
"$",
"node",
")",
".",
"$",
"url",
";",
"}",
"if",
"(",
"$",
"urlConv",
"!==",
"null",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"replaceUrl",
"(",
"$",
"value",
",",
"$",
"url",
",",
"$",
"urlConv",
",",
"$",
"type",
")",
";",
"}",
"}",
"else",
"{",
"// invalid url",
"$",
"logger",
"->",
"error",
"(",
"\"Invalid URL found: \"",
".",
"$",
"url",
")",
";",
"$",
"oidStr",
"=",
"$",
"currentNode",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"invalidURLs",
"[",
"$",
"oidStr",
"]",
")",
")",
"{",
"$",
"invalidURLs",
"[",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"invalidURLs",
"[",
"$",
"oidStr",
"]",
"[",
"]",
"=",
"$",
"url",
";",
"$",
"value",
"=",
"self",
"::",
"replaceUrl",
"(",
"$",
"value",
",",
"$",
"url",
",",
"'#'",
",",
"$",
"type",
")",
";",
"}",
"}",
"if",
"(",
"$",
"oldValue",
"!=",
"$",
"value",
")",
"{",
"$",
"currentNode",
"->",
"setValue",
"(",
"$",
"valueName",
",",
"$",
"value",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"invalidURLs",
";",
"}"
] |
Check and convert links in the given node.
@param $node Node instance
@param $base The base url of relative links as seen from the executing script
@param $strategy The strategy used to check and create urls
@param recursive Boolean whether to process child nodes to (default: true)
@return Array of invalid urls
|
[
"Check",
"and",
"convert",
"links",
"in",
"the",
"given",
"node",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/link/LinkProcessor.php#L39-L106
|
26,616
|
iherwig/wcmf
|
src/wcmf/lib/presentation/link/LinkProcessor.php
|
LinkProcessor.replaceUrl
|
protected static function replaceUrl($value, $url, $urlConv, $type) {
if ($type == 'embedded') {
$value = str_replace('"'.$url.'"', '"'.$urlConv.'"', $value);
}
else {
$value = str_replace($url, $urlConv, $value);
}
return $value;
}
|
php
|
protected static function replaceUrl($value, $url, $urlConv, $type) {
if ($type == 'embedded') {
$value = str_replace('"'.$url.'"', '"'.$urlConv.'"', $value);
}
else {
$value = str_replace($url, $urlConv, $value);
}
return $value;
}
|
[
"protected",
"static",
"function",
"replaceUrl",
"(",
"$",
"value",
",",
"$",
"url",
",",
"$",
"urlConv",
",",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'embedded'",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"'\"'",
".",
"$",
"url",
".",
"'\"'",
",",
"'\"'",
".",
"$",
"urlConv",
".",
"'\"'",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"url",
",",
"$",
"urlConv",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Replace the url in the given value
@param $value
@param $url
@param $urlConv
@param $type embedded or direct
@return String
|
[
"Replace",
"the",
"url",
"in",
"the",
"given",
"value"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/link/LinkProcessor.php#L116-L124
|
26,617
|
iherwig/wcmf
|
src/wcmf/lib/presentation/link/LinkProcessor.php
|
LinkProcessor.convertInternalLink
|
protected static function convertInternalLink($url, LinkProcessorStrategy $strategy) {
$urlConv = $url;
if (InternalLink::isLink($url)) {
$oid = InternalLink::getReferencedOID($url);
if ($oid != null) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$object = $persistenceFacade->load($oid);
$urlConv = $strategy->getObjectUrl($object);
}
else {
$urlConv = '#';
}
$anchorOID = InternalLink::getAnchorOID($url);
if ($anchorOID != null) {
if (strrpos($urlConv) !== 0) {
$urlConv .= '#';
}
$urlConv .= $anchorOID;
}
else {
$anchorName = InternalLink::getAnchorName($url);
if ($anchorName != null) {
if (strrpos($urlConv) !== 0) {
$urlConv .= '#';
}
$urlConv .= $anchorName;
}
}
}
return $urlConv;
}
|
php
|
protected static function convertInternalLink($url, LinkProcessorStrategy $strategy) {
$urlConv = $url;
if (InternalLink::isLink($url)) {
$oid = InternalLink::getReferencedOID($url);
if ($oid != null) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$object = $persistenceFacade->load($oid);
$urlConv = $strategy->getObjectUrl($object);
}
else {
$urlConv = '#';
}
$anchorOID = InternalLink::getAnchorOID($url);
if ($anchorOID != null) {
if (strrpos($urlConv) !== 0) {
$urlConv .= '#';
}
$urlConv .= $anchorOID;
}
else {
$anchorName = InternalLink::getAnchorName($url);
if ($anchorName != null) {
if (strrpos($urlConv) !== 0) {
$urlConv .= '#';
}
$urlConv .= $anchorName;
}
}
}
return $urlConv;
}
|
[
"protected",
"static",
"function",
"convertInternalLink",
"(",
"$",
"url",
",",
"LinkProcessorStrategy",
"$",
"strategy",
")",
"{",
"$",
"urlConv",
"=",
"$",
"url",
";",
"if",
"(",
"InternalLink",
"::",
"isLink",
"(",
"$",
"url",
")",
")",
"{",
"$",
"oid",
"=",
"InternalLink",
"::",
"getReferencedOID",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"oid",
"!=",
"null",
")",
"{",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"$",
"object",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"$",
"oid",
")",
";",
"$",
"urlConv",
"=",
"$",
"strategy",
"->",
"getObjectUrl",
"(",
"$",
"object",
")",
";",
"}",
"else",
"{",
"$",
"urlConv",
"=",
"'#'",
";",
"}",
"$",
"anchorOID",
"=",
"InternalLink",
"::",
"getAnchorOID",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"anchorOID",
"!=",
"null",
")",
"{",
"if",
"(",
"strrpos",
"(",
"$",
"urlConv",
")",
"!==",
"0",
")",
"{",
"$",
"urlConv",
".=",
"'#'",
";",
"}",
"$",
"urlConv",
".=",
"$",
"anchorOID",
";",
"}",
"else",
"{",
"$",
"anchorName",
"=",
"InternalLink",
"::",
"getAnchorName",
"(",
"$",
"url",
")",
";",
"if",
"(",
"$",
"anchorName",
"!=",
"null",
")",
"{",
"if",
"(",
"strrpos",
"(",
"$",
"urlConv",
")",
"!==",
"0",
")",
"{",
"$",
"urlConv",
".=",
"'#'",
";",
"}",
"$",
"urlConv",
".=",
"$",
"anchorName",
";",
"}",
"}",
"}",
"return",
"$",
"urlConv",
";",
"}"
] |
Convert an internal link.
@param $url The url to convert
@param $strategy The strategy used to check and create urls
@return The converted url
|
[
"Convert",
"an",
"internal",
"link",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/link/LinkProcessor.php#L171-L201
|
26,618
|
iherwig/wcmf
|
src/wcmf/lib/service/SoapClient.php
|
SoapClient.call
|
public function call($method, $params=[]) {
$header = $this->generateWSSecurityHeader($this->user, $this->password);
$response = $this->__soapCall($method, sizeof($params) > 0 ? [$params] : [], null, $header);
// in document/literal style the "return" parameter holds the result
return property_exists($response, 'return') ? $response->return : $response;
}
|
php
|
public function call($method, $params=[]) {
$header = $this->generateWSSecurityHeader($this->user, $this->password);
$response = $this->__soapCall($method, sizeof($params) > 0 ? [$params] : [], null, $header);
// in document/literal style the "return" parameter holds the result
return property_exists($response, 'return') ? $response->return : $response;
}
|
[
"public",
"function",
"call",
"(",
"$",
"method",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"generateWSSecurityHeader",
"(",
"$",
"this",
"->",
"user",
",",
"$",
"this",
"->",
"password",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"__soapCall",
"(",
"$",
"method",
",",
"sizeof",
"(",
"$",
"params",
")",
">",
"0",
"?",
"[",
"$",
"params",
"]",
":",
"[",
"]",
",",
"null",
",",
"$",
"header",
")",
";",
"// in document/literal style the \"return\" parameter holds the result",
"return",
"property_exists",
"(",
"$",
"response",
",",
"'return'",
")",
"?",
"$",
"response",
"->",
"return",
":",
"$",
"response",
";",
"}"
] |
Call the given soap method
@param $method
@param $params (optional, default: empty array)
|
[
"Call",
"the",
"given",
"soap",
"method"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/SoapClient.php#L50-L55
|
26,619
|
iherwig/wcmf
|
src/wcmf/lib/service/SoapClient.php
|
SoapClient.__doRequest
|
public function __doRequest($request, $location, $action, $version, $oneway=0){
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Request:");
self::$logger->debug($request);
}
$response = trim(parent::__doRequest($request, $location, $action, $version, $oneway));
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Response:");
self::$logger->debug($response);
self::$logger->debug($this->getDebugInfos());
}
$parsedResponse = preg_replace('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $response);
// fix missing last e> caused by php's built-in webserver
if (preg_match('/^<\?xml/', $parsedResponse) && !preg_match('/e>$/', $parsedResponse)) {
$parsedResponse .= 'e>';
}
return $parsedResponse;
}
|
php
|
public function __doRequest($request, $location, $action, $version, $oneway=0){
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Request:");
self::$logger->debug($request);
}
$response = trim(parent::__doRequest($request, $location, $action, $version, $oneway));
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Response:");
self::$logger->debug($response);
self::$logger->debug($this->getDebugInfos());
}
$parsedResponse = preg_replace('/^(\x00\x00\xFE\xFF|\xFF\xFE\x00\x00|\xFE\xFF|\xFF\xFE|\xEF\xBB\xBF)/', "", $response);
// fix missing last e> caused by php's built-in webserver
if (preg_match('/^<\?xml/', $parsedResponse) && !preg_match('/e>$/', $parsedResponse)) {
$parsedResponse .= 'e>';
}
return $parsedResponse;
}
|
[
"public",
"function",
"__doRequest",
"(",
"$",
"request",
",",
"$",
"location",
",",
"$",
"action",
",",
"$",
"version",
",",
"$",
"oneway",
"=",
"0",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Request:\"",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"request",
")",
";",
"}",
"$",
"response",
"=",
"trim",
"(",
"parent",
"::",
"__doRequest",
"(",
"$",
"request",
",",
"$",
"location",
",",
"$",
"action",
",",
"$",
"version",
",",
"$",
"oneway",
")",
")",
";",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Response:\"",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"response",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"this",
"->",
"getDebugInfos",
"(",
")",
")",
";",
"}",
"$",
"parsedResponse",
"=",
"preg_replace",
"(",
"'/^(\\x00\\x00\\xFE\\xFF|\\xFF\\xFE\\x00\\x00|\\xFE\\xFF|\\xFF\\xFE|\\xEF\\xBB\\xBF)/'",
",",
"\"\"",
",",
"$",
"response",
")",
";",
"// fix missing last e> caused by php's built-in webserver",
"if",
"(",
"preg_match",
"(",
"'/^<\\?xml/'",
",",
"$",
"parsedResponse",
")",
"&&",
"!",
"preg_match",
"(",
"'/e>$/'",
",",
"$",
"parsedResponse",
")",
")",
"{",
"$",
"parsedResponse",
".=",
"'e>'",
";",
"}",
"return",
"$",
"parsedResponse",
";",
"}"
] |
Overridden in order to strip bom characters
@see SoapClient::__doRequest
|
[
"Overridden",
"in",
"order",
"to",
"strip",
"bom",
"characters"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/SoapClient.php#L61-L78
|
26,620
|
iherwig/wcmf
|
src/wcmf/lib/service/SoapClient.php
|
SoapClient.generateWSSecurityHeader
|
private function generateWSSecurityHeader($user, $password) {
$nonce = sha1(mt_rand());
$xml = '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="'.self::OASIS.'/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>'.$user.'</wsse:Username>
<wsse:Password Type="'.self::OASIS.'/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$password.'</wsse:Password>
<wsse:Nonce EncodingType="'.self::OASIS.'/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'.$nonce.'</wsse:Nonce>
</wsse:UsernameToken>
</wsse:Security>';
return new \SoapHeader(self::OASIS.'/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', new \SoapVar($xml, XSD_ANYXML), true);
}
|
php
|
private function generateWSSecurityHeader($user, $password) {
$nonce = sha1(mt_rand());
$xml = '<wsse:Security SOAP-ENV:mustUnderstand="1" xmlns:wsse="'.self::OASIS.'/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>'.$user.'</wsse:Username>
<wsse:Password Type="'.self::OASIS.'/oasis-200401-wss-username-token-profile-1.0#PasswordText">'.$password.'</wsse:Password>
<wsse:Nonce EncodingType="'.self::OASIS.'/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'.$nonce.'</wsse:Nonce>
</wsse:UsernameToken>
</wsse:Security>';
return new \SoapHeader(self::OASIS.'/oasis-200401-wss-wssecurity-secext-1.0.xsd', 'Security', new \SoapVar($xml, XSD_ANYXML), true);
}
|
[
"private",
"function",
"generateWSSecurityHeader",
"(",
"$",
"user",
",",
"$",
"password",
")",
"{",
"$",
"nonce",
"=",
"sha1",
"(",
"mt_rand",
"(",
")",
")",
";",
"$",
"xml",
"=",
"'<wsse:Security SOAP-ENV:mustUnderstand=\"1\" xmlns:wsse=\"'",
".",
"self",
"::",
"OASIS",
".",
"'/oasis-200401-wss-wssecurity-secext-1.0.xsd\">\n <wsse:UsernameToken>\n <wsse:Username>'",
".",
"$",
"user",
".",
"'</wsse:Username>\n <wsse:Password Type=\"'",
".",
"self",
"::",
"OASIS",
".",
"'/oasis-200401-wss-username-token-profile-1.0#PasswordText\">'",
".",
"$",
"password",
".",
"'</wsse:Password>\n <wsse:Nonce EncodingType=\"'",
".",
"self",
"::",
"OASIS",
".",
"'/oasis-200401-wss-soap-message-security-1.0#Base64Binary\">'",
".",
"$",
"nonce",
".",
"'</wsse:Nonce>\n </wsse:UsernameToken>\n </wsse:Security>'",
";",
"return",
"new",
"\\",
"SoapHeader",
"(",
"self",
"::",
"OASIS",
".",
"'/oasis-200401-wss-wssecurity-secext-1.0.xsd'",
",",
"'Security'",
",",
"new",
"\\",
"SoapVar",
"(",
"$",
"xml",
",",
"XSD_ANYXML",
")",
",",
"true",
")",
";",
"}"
] |
Create the WS-Security authentication header for the given credentials
@param $user
@param $password
@return SoapHeader
|
[
"Create",
"the",
"WS",
"-",
"Security",
"authentication",
"header",
"for",
"the",
"given",
"credentials"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/SoapClient.php#L86-L96
|
26,621
|
iherwig/wcmf
|
src/wcmf/lib/service/SoapClient.php
|
SoapClient.getDebugInfos
|
public function getDebugInfos() {
$requestHeaders = $this->__getLastRequestHeaders();
$request = $this->__getLastRequest();
$responseHeaders = $this->__getLastResponseHeaders();
$response = $this->__getLastResponse();
$msg = '';
$msg .= "Request Headers:\n" . $requestHeaders . "\n";
$msg .= "Request:\n" . $request . "\n";
$msg .= "Response Headers:\n" . $responseHeaders . "\n";
$msg .= "Response:\n" . $response . "\n";
return $msg;
}
|
php
|
public function getDebugInfos() {
$requestHeaders = $this->__getLastRequestHeaders();
$request = $this->__getLastRequest();
$responseHeaders = $this->__getLastResponseHeaders();
$response = $this->__getLastResponse();
$msg = '';
$msg .= "Request Headers:\n" . $requestHeaders . "\n";
$msg .= "Request:\n" . $request . "\n";
$msg .= "Response Headers:\n" . $responseHeaders . "\n";
$msg .= "Response:\n" . $response . "\n";
return $msg;
}
|
[
"public",
"function",
"getDebugInfos",
"(",
")",
"{",
"$",
"requestHeaders",
"=",
"$",
"this",
"->",
"__getLastRequestHeaders",
"(",
")",
";",
"$",
"request",
"=",
"$",
"this",
"->",
"__getLastRequest",
"(",
")",
";",
"$",
"responseHeaders",
"=",
"$",
"this",
"->",
"__getLastResponseHeaders",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"__getLastResponse",
"(",
")",
";",
"$",
"msg",
"=",
"''",
";",
"$",
"msg",
".=",
"\"Request Headers:\\n\"",
".",
"$",
"requestHeaders",
".",
"\"\\n\"",
";",
"$",
"msg",
".=",
"\"Request:\\n\"",
".",
"$",
"request",
".",
"\"\\n\"",
";",
"$",
"msg",
".=",
"\"Response Headers:\\n\"",
".",
"$",
"responseHeaders",
".",
"\"\\n\"",
";",
"$",
"msg",
".=",
"\"Response:\\n\"",
".",
"$",
"response",
".",
"\"\\n\"",
";",
"return",
"$",
"msg",
";",
"}"
] |
Get informations about the last request. Available
if constructor options contain 'trace' => 1
@return String
|
[
"Get",
"informations",
"about",
"the",
"last",
"request",
".",
"Available",
"if",
"constructor",
"options",
"contain",
"trace",
"=",
">",
"1"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/SoapClient.php#L103-L116
|
26,622
|
heyday/silverstripe-versioneddataobjects
|
code/VersionedDataObjectDetailsForm.php
|
VersionedDataObjectDetailsForm_ItemRequest.doSaveAndQuit
|
public function doSaveAndQuit($data, $form)
{
$this->save($data, $form);
$controller = $this->getToplevelController();
$controller->getResponse()->addHeader("X-Pjax", "Content");
$controller->redirect($this->getBackLink());
}
|
php
|
public function doSaveAndQuit($data, $form)
{
$this->save($data, $form);
$controller = $this->getToplevelController();
$controller->getResponse()->addHeader("X-Pjax", "Content");
$controller->redirect($this->getBackLink());
}
|
[
"public",
"function",
"doSaveAndQuit",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"$",
"this",
"->",
"save",
"(",
"$",
"data",
",",
"$",
"form",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"getToplevelController",
"(",
")",
";",
"$",
"controller",
"->",
"getResponse",
"(",
")",
"->",
"addHeader",
"(",
"\"X-Pjax\"",
",",
"\"Content\"",
")",
";",
"$",
"controller",
"->",
"redirect",
"(",
"$",
"this",
"->",
"getBackLink",
"(",
")",
")",
";",
"}"
] |
Override the doSaveAnQuit action from better buttons so that it uses the versioned way fo saving things.
@param $data
@param $form
|
[
"Override",
"the",
"doSaveAnQuit",
"action",
"from",
"better",
"buttons",
"so",
"that",
"it",
"uses",
"the",
"versioned",
"way",
"fo",
"saving",
"things",
"."
] |
30a07d976abd17baba9d9194ca176c82d72323ac
|
https://github.com/heyday/silverstripe-versioneddataobjects/blob/30a07d976abd17baba9d9194ca176c82d72323ac/code/VersionedDataObjectDetailsForm.php#L275-L281
|
26,623
|
silverstripe/silverstripe-dynamodb
|
code/Model/DynamoDbSession.php
|
DynamoDbSession.get
|
public static function get()
{
// Use DynamoDB for distributed session storage if it's configured
$awsDynamoDBSessionTable = Environment::getEnv('AWS_DYNAMODB_SESSION_TABLE');
if (!empty($awsDynamoDBSessionTable)) {
$awsRegionName = Environment::getEnv('AWS_REGION_NAME');
$awsDynamoDBEndpoint = Environment::getEnv('AWS_DYNAMODB_ENDPOINT');
$awsAccessKey = Environment::getEnv('AWS_ACCESS_KEY');
$awsSecretKey = Environment::getEnv('AWS_SECRET_KEY');
$dynamoOptions = array('region' => $awsRegionName);
// This endpoint can be set for locally testing DynamoDB.
// see http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
if (!empty($awsDynamoDBEndpoint)) {
$dynamoOptions['endpoint'] = $awsDynamoDBEndpoint;
}
if (!empty($awsAccessKey) && !empty($awsSecretKey)) {
$dynamoOptions['credentials']['key'] = $awsAccessKey;
$dynamoOptions['credentials']['secret'] = $awsSecretKey;
} else {
// cache credentials when IAM fetches the credentials from EC2 metadata service
// this will use doctrine/cache (included via composer) to do the actual caching into APCu
// http://docs.aws.amazon.com/aws-sdk-php/guide/latest/performance.html#cache-instance-profile-credentials
$dynamoOptions['credentials'] = new DoctrineCacheAdapter(new ApcuCache());
}
return new static($dynamoOptions, $awsDynamoDBSessionTable);
}
return null;
}
|
php
|
public static function get()
{
// Use DynamoDB for distributed session storage if it's configured
$awsDynamoDBSessionTable = Environment::getEnv('AWS_DYNAMODB_SESSION_TABLE');
if (!empty($awsDynamoDBSessionTable)) {
$awsRegionName = Environment::getEnv('AWS_REGION_NAME');
$awsDynamoDBEndpoint = Environment::getEnv('AWS_DYNAMODB_ENDPOINT');
$awsAccessKey = Environment::getEnv('AWS_ACCESS_KEY');
$awsSecretKey = Environment::getEnv('AWS_SECRET_KEY');
$dynamoOptions = array('region' => $awsRegionName);
// This endpoint can be set for locally testing DynamoDB.
// see http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
if (!empty($awsDynamoDBEndpoint)) {
$dynamoOptions['endpoint'] = $awsDynamoDBEndpoint;
}
if (!empty($awsAccessKey) && !empty($awsSecretKey)) {
$dynamoOptions['credentials']['key'] = $awsAccessKey;
$dynamoOptions['credentials']['secret'] = $awsSecretKey;
} else {
// cache credentials when IAM fetches the credentials from EC2 metadata service
// this will use doctrine/cache (included via composer) to do the actual caching into APCu
// http://docs.aws.amazon.com/aws-sdk-php/guide/latest/performance.html#cache-instance-profile-credentials
$dynamoOptions['credentials'] = new DoctrineCacheAdapter(new ApcuCache());
}
return new static($dynamoOptions, $awsDynamoDBSessionTable);
}
return null;
}
|
[
"public",
"static",
"function",
"get",
"(",
")",
"{",
"// Use DynamoDB for distributed session storage if it's configured",
"$",
"awsDynamoDBSessionTable",
"=",
"Environment",
"::",
"getEnv",
"(",
"'AWS_DYNAMODB_SESSION_TABLE'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"awsDynamoDBSessionTable",
")",
")",
"{",
"$",
"awsRegionName",
"=",
"Environment",
"::",
"getEnv",
"(",
"'AWS_REGION_NAME'",
")",
";",
"$",
"awsDynamoDBEndpoint",
"=",
"Environment",
"::",
"getEnv",
"(",
"'AWS_DYNAMODB_ENDPOINT'",
")",
";",
"$",
"awsAccessKey",
"=",
"Environment",
"::",
"getEnv",
"(",
"'AWS_ACCESS_KEY'",
")",
";",
"$",
"awsSecretKey",
"=",
"Environment",
"::",
"getEnv",
"(",
"'AWS_SECRET_KEY'",
")",
";",
"$",
"dynamoOptions",
"=",
"array",
"(",
"'region'",
"=>",
"$",
"awsRegionName",
")",
";",
"// This endpoint can be set for locally testing DynamoDB.",
"// see http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html",
"if",
"(",
"!",
"empty",
"(",
"$",
"awsDynamoDBEndpoint",
")",
")",
"{",
"$",
"dynamoOptions",
"[",
"'endpoint'",
"]",
"=",
"$",
"awsDynamoDBEndpoint",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"awsAccessKey",
")",
"&&",
"!",
"empty",
"(",
"$",
"awsSecretKey",
")",
")",
"{",
"$",
"dynamoOptions",
"[",
"'credentials'",
"]",
"[",
"'key'",
"]",
"=",
"$",
"awsAccessKey",
";",
"$",
"dynamoOptions",
"[",
"'credentials'",
"]",
"[",
"'secret'",
"]",
"=",
"$",
"awsSecretKey",
";",
"}",
"else",
"{",
"// cache credentials when IAM fetches the credentials from EC2 metadata service",
"// this will use doctrine/cache (included via composer) to do the actual caching into APCu",
"// http://docs.aws.amazon.com/aws-sdk-php/guide/latest/performance.html#cache-instance-profile-credentials",
"$",
"dynamoOptions",
"[",
"'credentials'",
"]",
"=",
"new",
"DoctrineCacheAdapter",
"(",
"new",
"ApcuCache",
"(",
")",
")",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"dynamoOptions",
",",
"$",
"awsDynamoDBSessionTable",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get an instance of DynamoDbSession configured from the environment if available.
@return null|DynamoDbSession
|
[
"Get",
"an",
"instance",
"of",
"DynamoDbSession",
"configured",
"from",
"the",
"environment",
"if",
"available",
"."
] |
785c69771b37636515f6a3b0015d04eab1585ca8
|
https://github.com/silverstripe/silverstripe-dynamodb/blob/785c69771b37636515f6a3b0015d04eab1585ca8/code/Model/DynamoDbSession.php#L45-L77
|
26,624
|
skie/plum_search
|
src/Model/Filter/AbstractFilter.php
|
AbstractFilter.apply
|
public function apply(Query $query, array $data)
{
if ($this->_applicable($data)) {
$field = $this->config('field');
if (is_string($field) && (strpos($field, '.') === false)) {
$field = $query->repository()->alias() . '.' . $field;
}
return $this->_buildQuery($query, $field, $this->_value($data), $data);
}
return $query;
}
|
php
|
public function apply(Query $query, array $data)
{
if ($this->_applicable($data)) {
$field = $this->config('field');
if (is_string($field) && (strpos($field, '.') === false)) {
$field = $query->repository()->alias() . '.' . $field;
}
return $this->_buildQuery($query, $field, $this->_value($data), $data);
}
return $query;
}
|
[
"public",
"function",
"apply",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_applicable",
"(",
"$",
"data",
")",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"config",
"(",
"'field'",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
"&&",
"(",
"strpos",
"(",
"$",
"field",
",",
"'.'",
")",
"===",
"false",
")",
")",
"{",
"$",
"field",
"=",
"$",
"query",
"->",
"repository",
"(",
")",
"->",
"alias",
"(",
")",
".",
"'.'",
".",
"$",
"field",
";",
"}",
"return",
"$",
"this",
"->",
"_buildQuery",
"(",
"$",
"query",
",",
"$",
"field",
",",
"$",
"this",
"->",
"_value",
"(",
"$",
"data",
")",
",",
"$",
"data",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Apply filter to query based on filter data
@param \Cake\ORM\Query $query Query.
@param array $data Filters values.
@return \Cake\ORM\Query
|
[
"Apply",
"filter",
"to",
"query",
"based",
"on",
"filter",
"data"
] |
24d981e240bff7c15731981d6f9b3056abdaf80e
|
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Model/Filter/AbstractFilter.php#L63-L75
|
26,625
|
skie/plum_search
|
src/Model/Filter/AbstractFilter.php
|
AbstractFilter._applicable
|
protected function _applicable($data)
{
$field = $this->config('name');
return $field && (!empty($data[$field]) || $this->_defaultDefined() || isset($data[$field]) && (string)$data[$field] !== '');
}
|
php
|
protected function _applicable($data)
{
$field = $this->config('name');
return $field && (!empty($data[$field]) || $this->_defaultDefined() || isset($data[$field]) && (string)$data[$field] !== '');
}
|
[
"protected",
"function",
"_applicable",
"(",
"$",
"data",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"config",
"(",
"'name'",
")",
";",
"return",
"$",
"field",
"&&",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
"||",
"$",
"this",
"->",
"_defaultDefined",
"(",
")",
"||",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
"&&",
"(",
"string",
")",
"$",
"data",
"[",
"$",
"field",
"]",
"!==",
"''",
")",
";",
"}"
] |
Check if filter applicable to query based on filter data
@param array $data Array of options as described above.
@return bool
|
[
"Check",
"if",
"filter",
"applicable",
"to",
"query",
"based",
"on",
"filter",
"data"
] |
24d981e240bff7c15731981d6f9b3056abdaf80e
|
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Model/Filter/AbstractFilter.php#L83-L88
|
26,626
|
skie/plum_search
|
src/Model/Filter/AbstractFilter.php
|
AbstractFilter._value
|
protected function _value($data)
{
$field = $this->config('name');
$value = $data[$field];
if (empty($value) && $this->_defaultDefined()) {
$value = $this->config('default');
}
return $value;
}
|
php
|
protected function _value($data)
{
$field = $this->config('name');
$value = $data[$field];
if (empty($value) && $this->_defaultDefined()) {
$value = $this->config('default');
}
return $value;
}
|
[
"protected",
"function",
"_value",
"(",
"$",
"data",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"config",
"(",
"'name'",
")",
";",
"$",
"value",
"=",
"$",
"data",
"[",
"$",
"field",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
"&&",
"$",
"this",
"->",
"_defaultDefined",
"(",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"config",
"(",
"'default'",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Evaluate value of filter parameter
@param array $data Array of options as described above.
@return mixed
|
[
"Evaluate",
"value",
"of",
"filter",
"parameter"
] |
24d981e240bff7c15731981d6f9b3056abdaf80e
|
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Model/Filter/AbstractFilter.php#L119-L128
|
26,627
|
vufind-org/vufindharvest
|
src/OaiPmh/Communicator.php
|
Communicator.sendRequest
|
protected function sendRequest($verb, $params)
{
// Set up the request:
$this->client->resetParameters(false, false); // keep cookies/auth
$this->client->setUri($this->baseUrl);
// Load request parameters:
$query = $this->client->getRequest()->getQuery();
$query->set('verb', $verb);
foreach ($params as $key => $value) {
$query->set($key, $value);
}
// Perform request:
return $this->client->setMethod('GET')->send();
}
|
php
|
protected function sendRequest($verb, $params)
{
// Set up the request:
$this->client->resetParameters(false, false); // keep cookies/auth
$this->client->setUri($this->baseUrl);
// Load request parameters:
$query = $this->client->getRequest()->getQuery();
$query->set('verb', $verb);
foreach ($params as $key => $value) {
$query->set($key, $value);
}
// Perform request:
return $this->client->setMethod('GET')->send();
}
|
[
"protected",
"function",
"sendRequest",
"(",
"$",
"verb",
",",
"$",
"params",
")",
"{",
"// Set up the request:",
"$",
"this",
"->",
"client",
"->",
"resetParameters",
"(",
"false",
",",
"false",
")",
";",
"// keep cookies/auth",
"$",
"this",
"->",
"client",
"->",
"setUri",
"(",
"$",
"this",
"->",
"baseUrl",
")",
";",
"// Load request parameters:",
"$",
"query",
"=",
"$",
"this",
"->",
"client",
"->",
"getRequest",
"(",
")",
"->",
"getQuery",
"(",
")",
";",
"$",
"query",
"->",
"set",
"(",
"'verb'",
",",
"$",
"verb",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"// Perform request:",
"return",
"$",
"this",
"->",
"client",
"->",
"setMethod",
"(",
"'GET'",
")",
"->",
"send",
"(",
")",
";",
"}"
] |
Perform a single OAI-PMH request.
@param string $verb OAI-PMH verb to execute.
@param array $params GET parameters for ListRecords method.
@return string
|
[
"Perform",
"a",
"single",
"OAI",
"-",
"PMH",
"request",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/Communicator.php#L92-L107
|
26,628
|
vufind-org/vufindharvest
|
src/OaiPmh/Communicator.php
|
Communicator.getOaiResponse
|
protected function getOaiResponse($verb, $params)
{
// Debug:
$this->write(
"Sending request: verb = {$verb}, params = " . print_r($params, true)
);
// Set up retry loop:
do {
$result = $this->sendRequest($verb, $params);
if ($result->getStatusCode() == 503) {
$delayHeader = $result->getHeaders()->get('Retry-After');
$delay = is_object($delayHeader)
? $delayHeader->getDeltaSeconds() : 0;
if ($delay > 0) {
$this->writeLine(
"Received 503 response; waiting {$delay} seconds..."
);
sleep($delay);
}
} elseif (!$result->isSuccess()) {
throw new \Exception('HTTP Error ' . $result->getStatusCode());
}
} while ($result->getStatusCode() == 503);
// If we got this far, there was no error -- send back response.
return $result->getBody();
}
|
php
|
protected function getOaiResponse($verb, $params)
{
// Debug:
$this->write(
"Sending request: verb = {$verb}, params = " . print_r($params, true)
);
// Set up retry loop:
do {
$result = $this->sendRequest($verb, $params);
if ($result->getStatusCode() == 503) {
$delayHeader = $result->getHeaders()->get('Retry-After');
$delay = is_object($delayHeader)
? $delayHeader->getDeltaSeconds() : 0;
if ($delay > 0) {
$this->writeLine(
"Received 503 response; waiting {$delay} seconds..."
);
sleep($delay);
}
} elseif (!$result->isSuccess()) {
throw new \Exception('HTTP Error ' . $result->getStatusCode());
}
} while ($result->getStatusCode() == 503);
// If we got this far, there was no error -- send back response.
return $result->getBody();
}
|
[
"protected",
"function",
"getOaiResponse",
"(",
"$",
"verb",
",",
"$",
"params",
")",
"{",
"// Debug:",
"$",
"this",
"->",
"write",
"(",
"\"Sending request: verb = {$verb}, params = \"",
".",
"print_r",
"(",
"$",
"params",
",",
"true",
")",
")",
";",
"// Set up retry loop:",
"do",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"verb",
",",
"$",
"params",
")",
";",
"if",
"(",
"$",
"result",
"->",
"getStatusCode",
"(",
")",
"==",
"503",
")",
"{",
"$",
"delayHeader",
"=",
"$",
"result",
"->",
"getHeaders",
"(",
")",
"->",
"get",
"(",
"'Retry-After'",
")",
";",
"$",
"delay",
"=",
"is_object",
"(",
"$",
"delayHeader",
")",
"?",
"$",
"delayHeader",
"->",
"getDeltaSeconds",
"(",
")",
":",
"0",
";",
"if",
"(",
"$",
"delay",
">",
"0",
")",
"{",
"$",
"this",
"->",
"writeLine",
"(",
"\"Received 503 response; waiting {$delay} seconds...\"",
")",
";",
"sleep",
"(",
"$",
"delay",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"result",
"->",
"isSuccess",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'HTTP Error '",
".",
"$",
"result",
"->",
"getStatusCode",
"(",
")",
")",
";",
"}",
"}",
"while",
"(",
"$",
"result",
"->",
"getStatusCode",
"(",
")",
"==",
"503",
")",
";",
"// If we got this far, there was no error -- send back response.",
"return",
"$",
"result",
"->",
"getBody",
"(",
")",
";",
"}"
] |
Make an OAI-PMH request. Throw an exception if there is an error; return
an XML string on success.
@param string $verb OAI-PMH verb to execute.
@param array $params GET parameters for ListRecords method.
@return string
|
[
"Make",
"an",
"OAI",
"-",
"PMH",
"request",
".",
"Throw",
"an",
"exception",
"if",
"there",
"is",
"an",
"error",
";",
"return",
"an",
"XML",
"string",
"on",
"success",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/Communicator.php#L118-L145
|
26,629
|
vufind-org/vufindharvest
|
src/OaiPmh/Communicator.php
|
Communicator.request
|
public function request($verb, $params = [])
{
$xml = $this->getOaiResponse($verb, $params);
return $this->responseProcessor
? $this->responseProcessor->process($xml) : $xml;
}
|
php
|
public function request($verb, $params = [])
{
$xml = $this->getOaiResponse($verb, $params);
return $this->responseProcessor
? $this->responseProcessor->process($xml) : $xml;
}
|
[
"public",
"function",
"request",
"(",
"$",
"verb",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"xml",
"=",
"$",
"this",
"->",
"getOaiResponse",
"(",
"$",
"verb",
",",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"responseProcessor",
"?",
"$",
"this",
"->",
"responseProcessor",
"->",
"process",
"(",
"$",
"xml",
")",
":",
"$",
"xml",
";",
"}"
] |
Make an OAI-PMH request. Throw an exception if there is an error; return
the processed response on success.
@param string $verb OAI-PMH verb to execute.
@param array $params GET parameters for ListRecords method.
@return mixed
|
[
"Make",
"an",
"OAI",
"-",
"PMH",
"request",
".",
"Throw",
"an",
"exception",
"if",
"there",
"is",
"an",
"error",
";",
"return",
"the",
"processed",
"response",
"on",
"success",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/Communicator.php#L156-L161
|
26,630
|
GW2Treasures/gw2api
|
src/V2/ApiResponse.php
|
ApiResponse.json
|
public function json( array $config = [] ) {
$options = isset($config['big_int_strings']) ? JSON_BIGINT_AS_STRING : 0;
return json_decode($this->response->getBody(), false, 512, $options);
}
|
php
|
public function json( array $config = [] ) {
$options = isset($config['big_int_strings']) ? JSON_BIGINT_AS_STRING : 0;
return json_decode($this->response->getBody(), false, 512, $options);
}
|
[
"public",
"function",
"json",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"isset",
"(",
"$",
"config",
"[",
"'big_int_strings'",
"]",
")",
"?",
"JSON_BIGINT_AS_STRING",
":",
"0",
";",
"return",
"json_decode",
"(",
"$",
"this",
"->",
"response",
"->",
"getBody",
"(",
")",
",",
"false",
",",
"512",
",",
"$",
"options",
")",
";",
"}"
] |
Get the response as json object.
@param array $config
@return mixed
|
[
"Get",
"the",
"response",
"as",
"json",
"object",
"."
] |
c8795af0c1d0a434b9e530f779d5a95786db2176
|
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/ApiResponse.php#L30-L33
|
26,631
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.setConnectionParams
|
public function setConnectionParams($params) {
$this->connectionParams = $params;
if (isset($this->connectionParams['dbPrefix'])) {
$this->dbPrefix = $this->connectionParams['dbPrefix'];
}
}
|
php
|
public function setConnectionParams($params) {
$this->connectionParams = $params;
if (isset($this->connectionParams['dbPrefix'])) {
$this->dbPrefix = $this->connectionParams['dbPrefix'];
}
}
|
[
"public",
"function",
"setConnectionParams",
"(",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"connectionParams",
"=",
"$",
"params",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"connectionParams",
"[",
"'dbPrefix'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"dbPrefix",
"=",
"$",
"this",
"->",
"connectionParams",
"[",
"'dbPrefix'",
"]",
";",
"}",
"}"
] |
Set the connection parameters.
@param $params Initialization data given in an associative array with the following keys:
dbType, dbHostName, dbUserName, dbPassword, dbName
if dbPrefix is given it will be appended to every table string, which is
useful if different applications operate on the same database
|
[
"Set",
"the",
"connection",
"parameters",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L132-L137
|
26,632
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.getMapper
|
protected static function getMapper($type, $strict=true) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$mapper = $persistenceFacade->getMapper($type);
if ($strict && !($mapper instanceof RDBMapper)) {
throw new PersistenceException('Only PersistenceMappers of type RDBMapper are supported.');
}
return $mapper;
}
|
php
|
protected static function getMapper($type, $strict=true) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$mapper = $persistenceFacade->getMapper($type);
if ($strict && !($mapper instanceof RDBMapper)) {
throw new PersistenceException('Only PersistenceMappers of type RDBMapper are supported.');
}
return $mapper;
}
|
[
"protected",
"static",
"function",
"getMapper",
"(",
"$",
"type",
",",
"$",
"strict",
"=",
"true",
")",
"{",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"$",
"mapper",
"=",
"$",
"persistenceFacade",
"->",
"getMapper",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"strict",
"&&",
"!",
"(",
"$",
"mapper",
"instanceof",
"RDBMapper",
")",
")",
"{",
"throw",
"new",
"PersistenceException",
"(",
"'Only PersistenceMappers of type RDBMapper are supported.'",
")",
";",
"}",
"return",
"$",
"mapper",
";",
"}"
] |
Get the mapper for a Node and optionally check if it is a supported one.
@param $type The type of Node to get the mapper for
@param $strict Boolean indicating if the mapper must be an instance of RDBMapper (default true)
@return RDBMapper instance
|
[
"Get",
"the",
"mapper",
"for",
"a",
"Node",
"and",
"optionally",
"check",
"if",
"it",
"is",
"a",
"supported",
"one",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L174-L181
|
26,633
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.getSequenceMapper
|
protected function getSequenceMapper() {
if (self::$sequenceMapper == null) {
self::$sequenceMapper = self::getMapper(self::SEQUENCE_CLASS);
}
return self::$sequenceMapper;
}
|
php
|
protected function getSequenceMapper() {
if (self::$sequenceMapper == null) {
self::$sequenceMapper = self::getMapper(self::SEQUENCE_CLASS);
}
return self::$sequenceMapper;
}
|
[
"protected",
"function",
"getSequenceMapper",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"sequenceMapper",
"==",
"null",
")",
"{",
"self",
"::",
"$",
"sequenceMapper",
"=",
"self",
"::",
"getMapper",
"(",
"self",
"::",
"SEQUENCE_CLASS",
")",
";",
"}",
"return",
"self",
"::",
"$",
"sequenceMapper",
";",
"}"
] |
Get the sequence mapper
@return PersistenceMapper
|
[
"Get",
"the",
"sequence",
"mapper"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L266-L271
|
26,634
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.getNextId
|
protected function getNextId() {
try {
$sequenceMapper = $this->getSequenceMapper();
$sequenceTable = $sequenceMapper->getRealTableName();
$sequenceConn = $sequenceMapper->getConnection();
$tableName = strtolower($this->getRealTableName());
// run id sequence in it's own transaction, if supported
if (!$this->isFileDB) {
$sequenceConn->beginTransaction();
}
if ($this->idSelectStmt == null) {
$this->idSelectStmt = $sequenceConn->prepare("SELECT ".$this->quoteIdentifier("id").
" FROM ".$this->quoteIdentifier($sequenceTable)." WHERE ".
$this->quoteIdentifier("table")."=".$this->quoteValue($tableName));
}
if ($this->idInsertStmt == null) {
$this->idInsertStmt = $sequenceConn->prepare("INSERT INTO ".
$this->quoteIdentifier($sequenceTable)." (".$this->quoteIdentifier("id").
", ".$this->quoteIdentifier("table").") VALUES (1, ".
$this->quoteValue($tableName).")");
}
if ($this->idUpdateStmt == null) {
$this->idUpdateStmt = $sequenceConn->prepare("UPDATE ".$this->quoteIdentifier($sequenceTable).
" SET ".$this->quoteIdentifier("id")."=(".$this->quoteIdentifier("id")."+1) WHERE ".
$this->quoteIdentifier("table")."=".$this->quoteValue($tableName));
}
$this->idSelectStmt->execute();
$rows = $this->idSelectStmt->fetchAll(PDO::FETCH_ASSOC);
if (sizeof($rows) == 0) {
$this->idInsertStmt->execute();
$this->idInsertStmt->closeCursor();
$rows = [['id' => 1]];
}
$id = $rows[0]['id'];
$this->idUpdateStmt->execute();
$this->idUpdateStmt->closeCursor();
$this->idSelectStmt->closeCursor();
if (!$this->isFileDB) {
$sequenceConn->commit();
}
return $id;
}
catch (\Exception $ex) {
self::$logger->error("The next id query caused the following exception:\n".$ex->getMessage());
throw new PersistenceException("Error in persistent operation. See log file for details.");
}
}
|
php
|
protected function getNextId() {
try {
$sequenceMapper = $this->getSequenceMapper();
$sequenceTable = $sequenceMapper->getRealTableName();
$sequenceConn = $sequenceMapper->getConnection();
$tableName = strtolower($this->getRealTableName());
// run id sequence in it's own transaction, if supported
if (!$this->isFileDB) {
$sequenceConn->beginTransaction();
}
if ($this->idSelectStmt == null) {
$this->idSelectStmt = $sequenceConn->prepare("SELECT ".$this->quoteIdentifier("id").
" FROM ".$this->quoteIdentifier($sequenceTable)." WHERE ".
$this->quoteIdentifier("table")."=".$this->quoteValue($tableName));
}
if ($this->idInsertStmt == null) {
$this->idInsertStmt = $sequenceConn->prepare("INSERT INTO ".
$this->quoteIdentifier($sequenceTable)." (".$this->quoteIdentifier("id").
", ".$this->quoteIdentifier("table").") VALUES (1, ".
$this->quoteValue($tableName).")");
}
if ($this->idUpdateStmt == null) {
$this->idUpdateStmt = $sequenceConn->prepare("UPDATE ".$this->quoteIdentifier($sequenceTable).
" SET ".$this->quoteIdentifier("id")."=(".$this->quoteIdentifier("id")."+1) WHERE ".
$this->quoteIdentifier("table")."=".$this->quoteValue($tableName));
}
$this->idSelectStmt->execute();
$rows = $this->idSelectStmt->fetchAll(PDO::FETCH_ASSOC);
if (sizeof($rows) == 0) {
$this->idInsertStmt->execute();
$this->idInsertStmt->closeCursor();
$rows = [['id' => 1]];
}
$id = $rows[0]['id'];
$this->idUpdateStmt->execute();
$this->idUpdateStmt->closeCursor();
$this->idSelectStmt->closeCursor();
if (!$this->isFileDB) {
$sequenceConn->commit();
}
return $id;
}
catch (\Exception $ex) {
self::$logger->error("The next id query caused the following exception:\n".$ex->getMessage());
throw new PersistenceException("Error in persistent operation. See log file for details.");
}
}
|
[
"protected",
"function",
"getNextId",
"(",
")",
"{",
"try",
"{",
"$",
"sequenceMapper",
"=",
"$",
"this",
"->",
"getSequenceMapper",
"(",
")",
";",
"$",
"sequenceTable",
"=",
"$",
"sequenceMapper",
"->",
"getRealTableName",
"(",
")",
";",
"$",
"sequenceConn",
"=",
"$",
"sequenceMapper",
"->",
"getConnection",
"(",
")",
";",
"$",
"tableName",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"getRealTableName",
"(",
")",
")",
";",
"// run id sequence in it's own transaction, if supported",
"if",
"(",
"!",
"$",
"this",
"->",
"isFileDB",
")",
"{",
"$",
"sequenceConn",
"->",
"beginTransaction",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"idSelectStmt",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"idSelectStmt",
"=",
"$",
"sequenceConn",
"->",
"prepare",
"(",
"\"SELECT \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"id\"",
")",
".",
"\" FROM \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"sequenceTable",
")",
".",
"\" WHERE \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"table\"",
")",
".",
"\"=\"",
".",
"$",
"this",
"->",
"quoteValue",
"(",
"$",
"tableName",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"idInsertStmt",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"idInsertStmt",
"=",
"$",
"sequenceConn",
"->",
"prepare",
"(",
"\"INSERT INTO \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"sequenceTable",
")",
".",
"\" (\"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"id\"",
")",
".",
"\", \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"table\"",
")",
".",
"\") VALUES (1, \"",
".",
"$",
"this",
"->",
"quoteValue",
"(",
"$",
"tableName",
")",
".",
"\")\"",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"idUpdateStmt",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"idUpdateStmt",
"=",
"$",
"sequenceConn",
"->",
"prepare",
"(",
"\"UPDATE \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"sequenceTable",
")",
".",
"\" SET \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"id\"",
")",
".",
"\"=(\"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"id\"",
")",
".",
"\"+1) WHERE \"",
".",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"\"table\"",
")",
".",
"\"=\"",
".",
"$",
"this",
"->",
"quoteValue",
"(",
"$",
"tableName",
")",
")",
";",
"}",
"$",
"this",
"->",
"idSelectStmt",
"->",
"execute",
"(",
")",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"idSelectStmt",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"rows",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"idInsertStmt",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"idInsertStmt",
"->",
"closeCursor",
"(",
")",
";",
"$",
"rows",
"=",
"[",
"[",
"'id'",
"=>",
"1",
"]",
"]",
";",
"}",
"$",
"id",
"=",
"$",
"rows",
"[",
"0",
"]",
"[",
"'id'",
"]",
";",
"$",
"this",
"->",
"idUpdateStmt",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"idUpdateStmt",
"->",
"closeCursor",
"(",
")",
";",
"$",
"this",
"->",
"idSelectStmt",
"->",
"closeCursor",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isFileDB",
")",
"{",
"$",
"sequenceConn",
"->",
"commit",
"(",
")",
";",
"}",
"return",
"$",
"id",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"\"The next id query caused the following exception:\\n\"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"new",
"PersistenceException",
"(",
"\"Error in persistent operation. See log file for details.\"",
")",
";",
"}",
"}"
] |
Get a new id for inserting into the database
@return An id value.
|
[
"Get",
"a",
"new",
"id",
"for",
"inserting",
"into",
"the",
"database"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L277-L324
|
26,635
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.executeSql
|
public function executeSql($sql, $parameters=[]) {
if ($this->adapter == null) {
$this->connect();
}
try {
$stmt = $this->adapter->createStatement($sql, $parameters);
$results = $stmt->execute();
if ($results->isQueryResult()) {
return $results->getResource()->fetchAll();
}
else {
return $results->getAffectedRows();
}
}
catch (\Exception $ex) {
self::$logger->error("The query: ".$sql."\ncaused the following exception:\n".$ex->getMessage());
throw new PersistenceException("Error in persistent operation. See log file for details.");
}
}
|
php
|
public function executeSql($sql, $parameters=[]) {
if ($this->adapter == null) {
$this->connect();
}
try {
$stmt = $this->adapter->createStatement($sql, $parameters);
$results = $stmt->execute();
if ($results->isQueryResult()) {
return $results->getResource()->fetchAll();
}
else {
return $results->getAffectedRows();
}
}
catch (\Exception $ex) {
self::$logger->error("The query: ".$sql."\ncaused the following exception:\n".$ex->getMessage());
throw new PersistenceException("Error in persistent operation. See log file for details.");
}
}
|
[
"public",
"function",
"executeSql",
"(",
"$",
"sql",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"adapter",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"try",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"adapter",
"->",
"createStatement",
"(",
"$",
"sql",
",",
"$",
"parameters",
")",
";",
"$",
"results",
"=",
"$",
"stmt",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"results",
"->",
"isQueryResult",
"(",
")",
")",
"{",
"return",
"$",
"results",
"->",
"getResource",
"(",
")",
"->",
"fetchAll",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"results",
"->",
"getAffectedRows",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"error",
"(",
"\"The query: \"",
".",
"$",
"sql",
".",
"\"\\ncaused the following exception:\\n\"",
".",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"throw",
"new",
"PersistenceException",
"(",
"\"Error in persistent operation. See log file for details.\"",
")",
";",
"}",
"}"
] |
Execute a query on the connection.
@param $sql The SQL statement as string
@param $parameters An associative array of parameter name/values pairs to replace the placeholders with (optional, default: empty array)
@return If the query is a select, an array of associative arrays containing the selected data,
the number of affected rows else
|
[
"Execute",
"a",
"query",
"on",
"the",
"connection",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L370-L388
|
26,636
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.initRelations
|
private function initRelations() {
if ($this->relations == null) {
$this->relations = [];
$this->relations['all'] = array_values($this->getRelationDescriptions());
$this->relations['parent'] = [];
$this->relations['child'] = [];
$this->relations['undefined'] = [];
$this->relations['nm'] = [];
foreach ($this->relations['all'] as $relation) {
$hierarchyType = $relation->getHierarchyType();
$hierarchyKey = $hierarchyType == 'parent' || $hierarchyType == 'child' ?
$hierarchyType : 'undefined';
$this->relations[$hierarchyKey][] = $relation;
// also store relations to many to many objects, because
// they would be invisible otherwise
if ($relation instanceof RDBManyToManyRelationDescription) {
$nmRelation = $relation->getThisEndRelation();
$this->relations['nm'][$nmRelation->getOtherRole()] = $nmRelation;
}
}
}
}
|
php
|
private function initRelations() {
if ($this->relations == null) {
$this->relations = [];
$this->relations['all'] = array_values($this->getRelationDescriptions());
$this->relations['parent'] = [];
$this->relations['child'] = [];
$this->relations['undefined'] = [];
$this->relations['nm'] = [];
foreach ($this->relations['all'] as $relation) {
$hierarchyType = $relation->getHierarchyType();
$hierarchyKey = $hierarchyType == 'parent' || $hierarchyType == 'child' ?
$hierarchyType : 'undefined';
$this->relations[$hierarchyKey][] = $relation;
// also store relations to many to many objects, because
// they would be invisible otherwise
if ($relation instanceof RDBManyToManyRelationDescription) {
$nmRelation = $relation->getThisEndRelation();
$this->relations['nm'][$nmRelation->getOtherRole()] = $nmRelation;
}
}
}
}
|
[
"private",
"function",
"initRelations",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relations",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"relations",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"relations",
"[",
"'all'",
"]",
"=",
"array_values",
"(",
"$",
"this",
"->",
"getRelationDescriptions",
"(",
")",
")",
";",
"$",
"this",
"->",
"relations",
"[",
"'parent'",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"relations",
"[",
"'child'",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"relations",
"[",
"'undefined'",
"]",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"relations",
"[",
"'nm'",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"relations",
"[",
"'all'",
"]",
"as",
"$",
"relation",
")",
"{",
"$",
"hierarchyType",
"=",
"$",
"relation",
"->",
"getHierarchyType",
"(",
")",
";",
"$",
"hierarchyKey",
"=",
"$",
"hierarchyType",
"==",
"'parent'",
"||",
"$",
"hierarchyType",
"==",
"'child'",
"?",
"$",
"hierarchyType",
":",
"'undefined'",
";",
"$",
"this",
"->",
"relations",
"[",
"$",
"hierarchyKey",
"]",
"[",
"]",
"=",
"$",
"relation",
";",
"// also store relations to many to many objects, because",
"// they would be invisible otherwise",
"if",
"(",
"$",
"relation",
"instanceof",
"RDBManyToManyRelationDescription",
")",
"{",
"$",
"nmRelation",
"=",
"$",
"relation",
"->",
"getThisEndRelation",
"(",
")",
";",
"$",
"this",
"->",
"relations",
"[",
"'nm'",
"]",
"[",
"$",
"nmRelation",
"->",
"getOtherRole",
"(",
")",
"]",
"=",
"$",
"nmRelation",
";",
"}",
"}",
"}",
"}"
] |
Get the relation descriptions defined in the subclass and add them to internal arrays.
|
[
"Get",
"the",
"relation",
"descriptions",
"defined",
"in",
"the",
"subclass",
"and",
"add",
"them",
"to",
"internal",
"arrays",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L512-L535
|
26,637
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.loadObjectsFromQueryParts
|
protected function loadObjectsFromQueryParts($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) {
if ($buildDepth < 0 && !in_array($buildDepth, [BuildDepth::INFINITE, BuildDepth::SINGLE])) {
throw new IllegalArgumentException("Build depth not supported: $buildDepth");
}
// create query
$selectStmt = $this->getSelectSQL($criteria, null, null, $orderby, $pagingInfo);
$objects = $this->loadObjectsFromSQL($selectStmt, $buildDepth, $pagingInfo);
return $objects;
}
|
php
|
protected function loadObjectsFromQueryParts($type, $buildDepth=BuildDepth::SINGLE, $criteria=null, $orderby=null, PagingInfo $pagingInfo=null) {
if ($buildDepth < 0 && !in_array($buildDepth, [BuildDepth::INFINITE, BuildDepth::SINGLE])) {
throw new IllegalArgumentException("Build depth not supported: $buildDepth");
}
// create query
$selectStmt = $this->getSelectSQL($criteria, null, null, $orderby, $pagingInfo);
$objects = $this->loadObjectsFromSQL($selectStmt, $buildDepth, $pagingInfo);
return $objects;
}
|
[
"protected",
"function",
"loadObjectsFromQueryParts",
"(",
"$",
"type",
",",
"$",
"buildDepth",
"=",
"BuildDepth",
"::",
"SINGLE",
",",
"$",
"criteria",
"=",
"null",
",",
"$",
"orderby",
"=",
"null",
",",
"PagingInfo",
"$",
"pagingInfo",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"buildDepth",
"<",
"0",
"&&",
"!",
"in_array",
"(",
"$",
"buildDepth",
",",
"[",
"BuildDepth",
"::",
"INFINITE",
",",
"BuildDepth",
"::",
"SINGLE",
"]",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Build depth not supported: $buildDepth\"",
")",
";",
"}",
"// create query",
"$",
"selectStmt",
"=",
"$",
"this",
"->",
"getSelectSQL",
"(",
"$",
"criteria",
",",
"null",
",",
"null",
",",
"$",
"orderby",
",",
"$",
"pagingInfo",
")",
";",
"$",
"objects",
"=",
"$",
"this",
"->",
"loadObjectsFromSQL",
"(",
"$",
"selectStmt",
",",
"$",
"buildDepth",
",",
"$",
"pagingInfo",
")",
";",
"return",
"$",
"objects",
";",
"}"
] |
Load objects defined by several query parts.
@param $type The type of the object
@param $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
(except BuildDepth::REQUIRED, BuildDepth::PROXIES_ONLY) (default: BuildDepth::SINGLE)
@param $criteria An array of Criteria instances that define conditions on the type's attributes (optional, default: _null_)
@param $orderby An array holding names of attributes to order by, maybe appended with 'ASC', 'DESC' (optional, default: _null_)
@param $pagingInfo A reference PagingInfo instance (optional, default: _null_)
@return Array of PersistentObject instances
|
[
"Load",
"objects",
"defined",
"by",
"several",
"query",
"parts",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L885-L895
|
26,638
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.createObjectFromData
|
protected function createObjectFromData(array $data) {
// determine if we are loading or creating
$createFromLoadedData = (sizeof($data) > 0) ? true : false;
// initialize data and oid
$oid = null;
$initialData = $data;
if ($createFromLoadedData) {
$oid = $this->constructOID($initialData);
// cleanup data
foreach($initialData as $name => $value) {
if ($this->hasAttribute($name) || strpos($name, self::INTERNAL_VALUE_PREFIX) === 0) {
$value = $this->convertValueFromStorage($name, $value);
$initialData[$name] = $value;
}
else {
unset($initialData[$name]);
}
}
}
// construct object
$object = $this->createObject($oid, $initialData);
return $object;
}
|
php
|
protected function createObjectFromData(array $data) {
// determine if we are loading or creating
$createFromLoadedData = (sizeof($data) > 0) ? true : false;
// initialize data and oid
$oid = null;
$initialData = $data;
if ($createFromLoadedData) {
$oid = $this->constructOID($initialData);
// cleanup data
foreach($initialData as $name => $value) {
if ($this->hasAttribute($name) || strpos($name, self::INTERNAL_VALUE_PREFIX) === 0) {
$value = $this->convertValueFromStorage($name, $value);
$initialData[$name] = $value;
}
else {
unset($initialData[$name]);
}
}
}
// construct object
$object = $this->createObject($oid, $initialData);
return $object;
}
|
[
"protected",
"function",
"createObjectFromData",
"(",
"array",
"$",
"data",
")",
"{",
"// determine if we are loading or creating",
"$",
"createFromLoadedData",
"=",
"(",
"sizeof",
"(",
"$",
"data",
")",
">",
"0",
")",
"?",
"true",
":",
"false",
";",
"// initialize data and oid",
"$",
"oid",
"=",
"null",
";",
"$",
"initialData",
"=",
"$",
"data",
";",
"if",
"(",
"$",
"createFromLoadedData",
")",
"{",
"$",
"oid",
"=",
"$",
"this",
"->",
"constructOID",
"(",
"$",
"initialData",
")",
";",
"// cleanup data",
"foreach",
"(",
"$",
"initialData",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"name",
")",
"||",
"strpos",
"(",
"$",
"name",
",",
"self",
"::",
"INTERNAL_VALUE_PREFIX",
")",
"===",
"0",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"convertValueFromStorage",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"initialData",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"initialData",
"[",
"$",
"name",
"]",
")",
";",
"}",
"}",
"}",
"// construct object",
"$",
"object",
"=",
"$",
"this",
"->",
"createObject",
"(",
"$",
"oid",
",",
"$",
"initialData",
")",
";",
"return",
"$",
"object",
";",
"}"
] |
Create an object of the mapper's type with the given attributes from the given data
@param $data An associative array with the attribute names as keys and the attribute values as values
@return PersistentObject
|
[
"Create",
"an",
"object",
"of",
"the",
"mapper",
"s",
"type",
"with",
"the",
"given",
"attributes",
"from",
"the",
"given",
"data"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L950-L974
|
26,639
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.convertValueFromStorage
|
protected function convertValueFromStorage($valueName, $value) {
// filter values according to type
if ($this->hasAttribute($valueName)) {
$type = $this->getAttribute($valueName)->getType();
// integer
if (strpos(strtolower($type), 'int') === 0) {
$value = (strlen($value) == 0) ? null : intval($value);
}
}
return $value;
}
|
php
|
protected function convertValueFromStorage($valueName, $value) {
// filter values according to type
if ($this->hasAttribute($valueName)) {
$type = $this->getAttribute($valueName)->getType();
// integer
if (strpos(strtolower($type), 'int') === 0) {
$value = (strlen($value) == 0) ? null : intval($value);
}
}
return $value;
}
|
[
"protected",
"function",
"convertValueFromStorage",
"(",
"$",
"valueName",
",",
"$",
"value",
")",
"{",
"// filter values according to type",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"valueName",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"valueName",
")",
"->",
"getType",
"(",
")",
";",
"// integer",
"if",
"(",
"strpos",
"(",
"strtolower",
"(",
"$",
"type",
")",
",",
"'int'",
")",
"===",
"0",
")",
"{",
"$",
"value",
"=",
"(",
"strlen",
"(",
"$",
"value",
")",
"==",
"0",
")",
"?",
"null",
":",
"intval",
"(",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] |
Convert value after retrieval from storage
@param $valueName
@param $value
@return Mixed
|
[
"Convert",
"value",
"after",
"retrieval",
"from",
"storage"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L982-L992
|
26,640
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.addRelatedObjects
|
protected function addRelatedObjects(array $objects, $buildDepth=BuildDepth::SINGLE) {
// recalculate build depth for the next generation
$newBuildDepth = $buildDepth;
if ($buildDepth != BuildDepth::SINGLE && $buildDepth != BuildDepth::INFINITE && $buildDepth > 0) {
$newBuildDepth = $buildDepth-1;
}
$loadNextGeneration = (($buildDepth != BuildDepth::SINGLE) && ($buildDepth > 0 || $buildDepth == BuildDepth::INFINITE));
// get dependend objects of this object
$relationDescs = $this->getRelations();
foreach($relationDescs as $relationDesc) {
$role = $relationDesc->getOtherRole();
$relationId = $role.$relationDesc->getThisRole();
// if the build depth is not satisfied already and the relation is not
// currently loading, we load the complete objects and add them
if ($loadNextGeneration && !isset($this->loadingRelations[$relationId])) {
$this->loadingRelations[$relationId] = true;
$relatives = $this->loadRelation($objects, $role, $newBuildDepth);
// set the values
foreach ($objects as $object) {
$oidStr = $object->getOID()->__toString();
$object->setValue($role, isset($relatives[$oidStr]) ? $relatives[$oidStr] : null, true, false);
}
unset($this->loadingRelations[$relationId]);
}
// otherwise set the value to not initialized.
// the Node will initialize it with the proxies for the relation objects
// on first access
else {
foreach ($objects as $object) {
if ($object instanceof Node) {
$object->addRelation($role);
}
}
}
}
}
|
php
|
protected function addRelatedObjects(array $objects, $buildDepth=BuildDepth::SINGLE) {
// recalculate build depth for the next generation
$newBuildDepth = $buildDepth;
if ($buildDepth != BuildDepth::SINGLE && $buildDepth != BuildDepth::INFINITE && $buildDepth > 0) {
$newBuildDepth = $buildDepth-1;
}
$loadNextGeneration = (($buildDepth != BuildDepth::SINGLE) && ($buildDepth > 0 || $buildDepth == BuildDepth::INFINITE));
// get dependend objects of this object
$relationDescs = $this->getRelations();
foreach($relationDescs as $relationDesc) {
$role = $relationDesc->getOtherRole();
$relationId = $role.$relationDesc->getThisRole();
// if the build depth is not satisfied already and the relation is not
// currently loading, we load the complete objects and add them
if ($loadNextGeneration && !isset($this->loadingRelations[$relationId])) {
$this->loadingRelations[$relationId] = true;
$relatives = $this->loadRelation($objects, $role, $newBuildDepth);
// set the values
foreach ($objects as $object) {
$oidStr = $object->getOID()->__toString();
$object->setValue($role, isset($relatives[$oidStr]) ? $relatives[$oidStr] : null, true, false);
}
unset($this->loadingRelations[$relationId]);
}
// otherwise set the value to not initialized.
// the Node will initialize it with the proxies for the relation objects
// on first access
else {
foreach ($objects as $object) {
if ($object instanceof Node) {
$object->addRelation($role);
}
}
}
}
}
|
[
"protected",
"function",
"addRelatedObjects",
"(",
"array",
"$",
"objects",
",",
"$",
"buildDepth",
"=",
"BuildDepth",
"::",
"SINGLE",
")",
"{",
"// recalculate build depth for the next generation",
"$",
"newBuildDepth",
"=",
"$",
"buildDepth",
";",
"if",
"(",
"$",
"buildDepth",
"!=",
"BuildDepth",
"::",
"SINGLE",
"&&",
"$",
"buildDepth",
"!=",
"BuildDepth",
"::",
"INFINITE",
"&&",
"$",
"buildDepth",
">",
"0",
")",
"{",
"$",
"newBuildDepth",
"=",
"$",
"buildDepth",
"-",
"1",
";",
"}",
"$",
"loadNextGeneration",
"=",
"(",
"(",
"$",
"buildDepth",
"!=",
"BuildDepth",
"::",
"SINGLE",
")",
"&&",
"(",
"$",
"buildDepth",
">",
"0",
"||",
"$",
"buildDepth",
"==",
"BuildDepth",
"::",
"INFINITE",
")",
")",
";",
"// get dependend objects of this object",
"$",
"relationDescs",
"=",
"$",
"this",
"->",
"getRelations",
"(",
")",
";",
"foreach",
"(",
"$",
"relationDescs",
"as",
"$",
"relationDesc",
")",
"{",
"$",
"role",
"=",
"$",
"relationDesc",
"->",
"getOtherRole",
"(",
")",
";",
"$",
"relationId",
"=",
"$",
"role",
".",
"$",
"relationDesc",
"->",
"getThisRole",
"(",
")",
";",
"// if the build depth is not satisfied already and the relation is not",
"// currently loading, we load the complete objects and add them",
"if",
"(",
"$",
"loadNextGeneration",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"loadingRelations",
"[",
"$",
"relationId",
"]",
")",
")",
"{",
"$",
"this",
"->",
"loadingRelations",
"[",
"$",
"relationId",
"]",
"=",
"true",
";",
"$",
"relatives",
"=",
"$",
"this",
"->",
"loadRelation",
"(",
"$",
"objects",
",",
"$",
"role",
",",
"$",
"newBuildDepth",
")",
";",
"// set the values",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"oidStr",
"=",
"$",
"object",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
";",
"$",
"object",
"->",
"setValue",
"(",
"$",
"role",
",",
"isset",
"(",
"$",
"relatives",
"[",
"$",
"oidStr",
"]",
")",
"?",
"$",
"relatives",
"[",
"$",
"oidStr",
"]",
":",
"null",
",",
"true",
",",
"false",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"loadingRelations",
"[",
"$",
"relationId",
"]",
")",
";",
"}",
"// otherwise set the value to not initialized.",
"// the Node will initialize it with the proxies for the relation objects",
"// on first access",
"else",
"{",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"Node",
")",
"{",
"$",
"object",
"->",
"addRelation",
"(",
"$",
"role",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Append the child data to a list of object. If the buildDepth does not determine to load a
child generation, only the oids of the children will be loaded.
@param $objects Array of PersistentObject instances to append the children to
@param $buildDepth @see PersistenceFacade::loadObjects()
|
[
"Append",
"the",
"child",
"data",
"to",
"a",
"list",
"of",
"object",
".",
"If",
"the",
"buildDepth",
"does",
"not",
"determine",
"to",
"load",
"a",
"child",
"generation",
"only",
"the",
"oids",
"of",
"the",
"children",
"will",
"be",
"loaded",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L1000-L1037
|
26,641
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.handleDbEvent
|
public function handleDbEvent($e) {
$statement = $e->getParam('statement', null);
if ($statement != null) {
$this->statements[] = [$statement->getSql(), $statement->getParameterContainer()->getNamedArray()];
}
}
|
php
|
public function handleDbEvent($e) {
$statement = $e->getParam('statement', null);
if ($statement != null) {
$this->statements[] = [$statement->getSql(), $statement->getParameterContainer()->getNamedArray()];
}
}
|
[
"public",
"function",
"handleDbEvent",
"(",
"$",
"e",
")",
"{",
"$",
"statement",
"=",
"$",
"e",
"->",
"getParam",
"(",
"'statement'",
",",
"null",
")",
";",
"if",
"(",
"$",
"statement",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"statements",
"[",
"]",
"=",
"[",
"$",
"statement",
"->",
"getSql",
"(",
")",
",",
"$",
"statement",
"->",
"getParameterContainer",
"(",
")",
"->",
"getNamedArray",
"(",
")",
"]",
";",
"}",
"}"
] |
Handle an event triggered from the zend db layer
@param $e
|
[
"Handle",
"an",
"event",
"triggered",
"from",
"the",
"zend",
"db",
"layer"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L1099-L1104
|
26,642
|
iherwig/wcmf
|
src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php
|
AbstractRDBMapper.isInTransaction
|
protected function isInTransaction() {
return isset(self::$inTransaction[$this->connId]) && self::$inTransaction[$this->connId] === true;
}
|
php
|
protected function isInTransaction() {
return isset(self::$inTransaction[$this->connId]) && self::$inTransaction[$this->connId] === true;
}
|
[
"protected",
"function",
"isInTransaction",
"(",
")",
"{",
"return",
"isset",
"(",
"self",
"::",
"$",
"inTransaction",
"[",
"$",
"this",
"->",
"connId",
"]",
")",
"&&",
"self",
"::",
"$",
"inTransaction",
"[",
"$",
"this",
"->",
"connId",
"]",
"===",
"true",
";",
"}"
] |
Check if the connection is currently in a transaction
@return Boolean
|
[
"Check",
"if",
"the",
"connection",
"is",
"currently",
"in",
"a",
"transaction"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/impl/AbstractRDBMapper.php#L1176-L1178
|
26,643
|
vufind-org/vufindharvest
|
src/OaiPmh/HarvesterConsoleRunner.php
|
HarvesterConsoleRunner.getHelp
|
public function getHelp()
{
$msg = $this->opts->getUsageMessage();
// Amend the auto-generated help message:
$options = "[ options ] [ target ]\n"
. "Where [ target ] is the name of a section of the configuration\n"
. "specified by the ini option, or a directory to harvest into if\n"
. "no .ini file is used. If [ target ] is omitted, all .ini sections\n"
. "will be processed. [ options ] may be selected from those below,\n"
. "and will override .ini settings where applicable.";
$this->write(str_replace('[ options ]', $options, $msg));
}
|
php
|
public function getHelp()
{
$msg = $this->opts->getUsageMessage();
// Amend the auto-generated help message:
$options = "[ options ] [ target ]\n"
. "Where [ target ] is the name of a section of the configuration\n"
. "specified by the ini option, or a directory to harvest into if\n"
. "no .ini file is used. If [ target ] is omitted, all .ini sections\n"
. "will be processed. [ options ] may be selected from those below,\n"
. "and will override .ini settings where applicable.";
$this->write(str_replace('[ options ]', $options, $msg));
}
|
[
"public",
"function",
"getHelp",
"(",
")",
"{",
"$",
"msg",
"=",
"$",
"this",
"->",
"opts",
"->",
"getUsageMessage",
"(",
")",
";",
"// Amend the auto-generated help message:",
"$",
"options",
"=",
"\"[ options ] [ target ]\\n\"",
".",
"\"Where [ target ] is the name of a section of the configuration\\n\"",
".",
"\"specified by the ini option, or a directory to harvest into if\\n\"",
".",
"\"no .ini file is used. If [ target ] is omitted, all .ini sections\\n\"",
".",
"\"will be processed. [ options ] may be selected from those below,\\n\"",
".",
"\"and will override .ini settings where applicable.\"",
";",
"$",
"this",
"->",
"write",
"(",
"str_replace",
"(",
"'[ options ]'",
",",
"$",
"options",
",",
"$",
"msg",
")",
")",
";",
"}"
] |
Render help message.
@return void
|
[
"Render",
"help",
"message",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterConsoleRunner.php#L194-L205
|
26,644
|
vufind-org/vufindharvest
|
src/OaiPmh/HarvesterConsoleRunner.php
|
HarvesterConsoleRunner.run
|
public function run()
{
// Support help message:
if ($this->opts->getOption('h')) {
$this->getHelp();
return true;
}
if (!$allSettings = $this->getSettings()) {
return false;
}
// Loop through all the settings and perform harvests:
$processed = $skipped = 0;
foreach ($allSettings as $target => $baseSettings) {
$settings = $this->updateSettingsWithConsoleOptions($baseSettings);
if (empty($target) || empty($settings)) {
$skipped++;
continue;
}
$this->writeLine("Processing {$target}...");
try {
$this->harvestSingleRepository($target, $settings);
} catch (\Exception $e) {
$this->writeLine($e->getMessage());
return false;
}
$processed++;
}
// All done.
if ($processed == 0 && $skipped > 0) {
$this->writeLine(
'No valid settings found; '
. 'please set url and metadataPrefix at minimum.'
);
return false;
}
$this->writeLine(
"Completed without errors -- {$processed} source(s) processed."
);
return true;
}
|
php
|
public function run()
{
// Support help message:
if ($this->opts->getOption('h')) {
$this->getHelp();
return true;
}
if (!$allSettings = $this->getSettings()) {
return false;
}
// Loop through all the settings and perform harvests:
$processed = $skipped = 0;
foreach ($allSettings as $target => $baseSettings) {
$settings = $this->updateSettingsWithConsoleOptions($baseSettings);
if (empty($target) || empty($settings)) {
$skipped++;
continue;
}
$this->writeLine("Processing {$target}...");
try {
$this->harvestSingleRepository($target, $settings);
} catch (\Exception $e) {
$this->writeLine($e->getMessage());
return false;
}
$processed++;
}
// All done.
if ($processed == 0 && $skipped > 0) {
$this->writeLine(
'No valid settings found; '
. 'please set url and metadataPrefix at minimum.'
);
return false;
}
$this->writeLine(
"Completed without errors -- {$processed} source(s) processed."
);
return true;
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"// Support help message:",
"if",
"(",
"$",
"this",
"->",
"opts",
"->",
"getOption",
"(",
"'h'",
")",
")",
"{",
"$",
"this",
"->",
"getHelp",
"(",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"allSettings",
"=",
"$",
"this",
"->",
"getSettings",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Loop through all the settings and perform harvests:",
"$",
"processed",
"=",
"$",
"skipped",
"=",
"0",
";",
"foreach",
"(",
"$",
"allSettings",
"as",
"$",
"target",
"=>",
"$",
"baseSettings",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"updateSettingsWithConsoleOptions",
"(",
"$",
"baseSettings",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"target",
")",
"||",
"empty",
"(",
"$",
"settings",
")",
")",
"{",
"$",
"skipped",
"++",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"writeLine",
"(",
"\"Processing {$target}...\"",
")",
";",
"try",
"{",
"$",
"this",
"->",
"harvestSingleRepository",
"(",
"$",
"target",
",",
"$",
"settings",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"writeLine",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"processed",
"++",
";",
"}",
"// All done.",
"if",
"(",
"$",
"processed",
"==",
"0",
"&&",
"$",
"skipped",
">",
"0",
")",
"{",
"$",
"this",
"->",
"writeLine",
"(",
"'No valid settings found; '",
".",
"'please set url and metadataPrefix at minimum.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"writeLine",
"(",
"\"Completed without errors -- {$processed} source(s) processed.\"",
")",
";",
"return",
"true",
";",
"}"
] |
Run the task and return true on success.
@return bool
|
[
"Run",
"the",
"task",
"and",
"return",
"true",
"on",
"success",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterConsoleRunner.php#L212-L254
|
26,645
|
vufind-org/vufindharvest
|
src/OaiPmh/HarvesterConsoleRunner.php
|
HarvesterConsoleRunner.getSettings
|
protected function getSettings()
{
$ini = $this->opts->getOption('ini');
$argv = $this->opts->getRemainingArgs();
$section = $argv[0] ?? false;
if (!$ini && !$section) {
$this->writeLine(
'Please specify an .ini file with the --ini flag'
. ' or a target directory with the first parameter.'
);
return false;
}
return $ini
? $this->getSettingsFromIni($ini, $section)
: [$section => []];
}
|
php
|
protected function getSettings()
{
$ini = $this->opts->getOption('ini');
$argv = $this->opts->getRemainingArgs();
$section = $argv[0] ?? false;
if (!$ini && !$section) {
$this->writeLine(
'Please specify an .ini file with the --ini flag'
. ' or a target directory with the first parameter.'
);
return false;
}
return $ini
? $this->getSettingsFromIni($ini, $section)
: [$section => []];
}
|
[
"protected",
"function",
"getSettings",
"(",
")",
"{",
"$",
"ini",
"=",
"$",
"this",
"->",
"opts",
"->",
"getOption",
"(",
"'ini'",
")",
";",
"$",
"argv",
"=",
"$",
"this",
"->",
"opts",
"->",
"getRemainingArgs",
"(",
")",
";",
"$",
"section",
"=",
"$",
"argv",
"[",
"0",
"]",
"??",
"false",
";",
"if",
"(",
"!",
"$",
"ini",
"&&",
"!",
"$",
"section",
")",
"{",
"$",
"this",
"->",
"writeLine",
"(",
"'Please specify an .ini file with the --ini flag'",
".",
"' or a target directory with the first parameter.'",
")",
";",
"return",
"false",
";",
"}",
"return",
"$",
"ini",
"?",
"$",
"this",
"->",
"getSettingsFromIni",
"(",
"$",
"ini",
",",
"$",
"section",
")",
":",
"[",
"$",
"section",
"=>",
"[",
"]",
"]",
";",
"}"
] |
Load the harvest settings. Return false on error.
@return array|bool
|
[
"Load",
"the",
"harvest",
"settings",
".",
"Return",
"false",
"on",
"error",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterConsoleRunner.php#L306-L321
|
26,646
|
vufind-org/vufindharvest
|
src/OaiPmh/HarvesterConsoleRunner.php
|
HarvesterConsoleRunner.harvestSingleRepository
|
protected function harvestSingleRepository($target, $settings)
{
$settings['from'] = $this->opts->getOption('from');
$settings['until'] = $this->opts->getOption('until');
$settings['silent'] = false;
$harvest = $this->factory->getHarvester(
$target,
$this->getHarvestRoot(),
$this->getHttpClient(),
$settings
);
$harvest->launch();
}
|
php
|
protected function harvestSingleRepository($target, $settings)
{
$settings['from'] = $this->opts->getOption('from');
$settings['until'] = $this->opts->getOption('until');
$settings['silent'] = false;
$harvest = $this->factory->getHarvester(
$target,
$this->getHarvestRoot(),
$this->getHttpClient(),
$settings
);
$harvest->launch();
}
|
[
"protected",
"function",
"harvestSingleRepository",
"(",
"$",
"target",
",",
"$",
"settings",
")",
"{",
"$",
"settings",
"[",
"'from'",
"]",
"=",
"$",
"this",
"->",
"opts",
"->",
"getOption",
"(",
"'from'",
")",
";",
"$",
"settings",
"[",
"'until'",
"]",
"=",
"$",
"this",
"->",
"opts",
"->",
"getOption",
"(",
"'until'",
")",
";",
"$",
"settings",
"[",
"'silent'",
"]",
"=",
"false",
";",
"$",
"harvest",
"=",
"$",
"this",
"->",
"factory",
"->",
"getHarvester",
"(",
"$",
"target",
",",
"$",
"this",
"->",
"getHarvestRoot",
"(",
")",
",",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
",",
"$",
"settings",
")",
";",
"$",
"harvest",
"->",
"launch",
"(",
")",
";",
"}"
] |
Harvest a single repository.
@param string $target Name of repo (used for target directory)
@param array $settings Settings for the harvester.
@return void
@throws \Exception
|
[
"Harvest",
"a",
"single",
"repository",
"."
] |
43a42d1e2292fbba8974a26ace3d522551a1a88f
|
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterConsoleRunner.php#L332-L344
|
26,647
|
iherwig/wcmf
|
src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php
|
DefaultLockHandler.storeLock
|
protected function storeLock(Lock $lock) {
if ($lock->getType() == Lock::TYPE_PESSIMISTIC) {
// pessimistic locks must be stored in the database in order
// to be seen by other users
$lockObj = $this->persistenceFacade->create($this->lockType, BuildDepth::REQUIRED);
$lockObj->setValue('objectid', $lock->getObjectId());
$lockObj->setValue('login', $lock->getLogin());
$lockObj->setValue('created', $lock->getCreated());
// save lock immediatly
$lockObj->getMapper()->save($lockObj);
}
// store the lock in the session for faster retrieval
$this->addSessionLock($lock);
}
|
php
|
protected function storeLock(Lock $lock) {
if ($lock->getType() == Lock::TYPE_PESSIMISTIC) {
// pessimistic locks must be stored in the database in order
// to be seen by other users
$lockObj = $this->persistenceFacade->create($this->lockType, BuildDepth::REQUIRED);
$lockObj->setValue('objectid', $lock->getObjectId());
$lockObj->setValue('login', $lock->getLogin());
$lockObj->setValue('created', $lock->getCreated());
// save lock immediatly
$lockObj->getMapper()->save($lockObj);
}
// store the lock in the session for faster retrieval
$this->addSessionLock($lock);
}
|
[
"protected",
"function",
"storeLock",
"(",
"Lock",
"$",
"lock",
")",
"{",
"if",
"(",
"$",
"lock",
"->",
"getType",
"(",
")",
"==",
"Lock",
"::",
"TYPE_PESSIMISTIC",
")",
"{",
"// pessimistic locks must be stored in the database in order",
"// to be seen by other users",
"$",
"lockObj",
"=",
"$",
"this",
"->",
"persistenceFacade",
"->",
"create",
"(",
"$",
"this",
"->",
"lockType",
",",
"BuildDepth",
"::",
"REQUIRED",
")",
";",
"$",
"lockObj",
"->",
"setValue",
"(",
"'objectid'",
",",
"$",
"lock",
"->",
"getObjectId",
"(",
")",
")",
";",
"$",
"lockObj",
"->",
"setValue",
"(",
"'login'",
",",
"$",
"lock",
"->",
"getLogin",
"(",
")",
")",
";",
"$",
"lockObj",
"->",
"setValue",
"(",
"'created'",
",",
"$",
"lock",
"->",
"getCreated",
"(",
")",
")",
";",
"// save lock immediatly",
"$",
"lockObj",
"->",
"getMapper",
"(",
")",
"->",
"save",
"(",
"$",
"lockObj",
")",
";",
"}",
"// store the lock in the session for faster retrieval",
"$",
"this",
"->",
"addSessionLock",
"(",
"$",
"lock",
")",
";",
"}"
] |
Store the given Lock instance for later retrieval
@param $lock Lock instance
|
[
"Store",
"the",
"given",
"Lock",
"instance",
"for",
"later",
"retrieval"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php#L209-L222
|
26,648
|
iherwig/wcmf
|
src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php
|
DefaultLockHandler.getSessionLocks
|
protected function getSessionLocks() {
if ($this->session->exist(self::SESSION_VARNAME)) {
return $this->session->get(self::SESSION_VARNAME);
}
return [];
}
|
php
|
protected function getSessionLocks() {
if ($this->session->exist(self::SESSION_VARNAME)) {
return $this->session->get(self::SESSION_VARNAME);
}
return [];
}
|
[
"protected",
"function",
"getSessionLocks",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"session",
"->",
"exist",
"(",
"self",
"::",
"SESSION_VARNAME",
")",
")",
"{",
"return",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"self",
"::",
"SESSION_VARNAME",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Get the Lock instances stored in the session
@return Associative array with the serialized ObjectId instances
as keys and the Lock instances as values
|
[
"Get",
"the",
"Lock",
"instances",
"stored",
"in",
"the",
"session"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php#L237-L242
|
26,649
|
iherwig/wcmf
|
src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php
|
DefaultLockHandler.addSessionLock
|
protected function addSessionLock(Lock $lock) {
$locks = $this->getSessionLocks();
$locks[$lock->getObjectId()->__toString()] = $lock;
$this->session->set(self::SESSION_VARNAME, $locks);
}
|
php
|
protected function addSessionLock(Lock $lock) {
$locks = $this->getSessionLocks();
$locks[$lock->getObjectId()->__toString()] = $lock;
$this->session->set(self::SESSION_VARNAME, $locks);
}
|
[
"protected",
"function",
"addSessionLock",
"(",
"Lock",
"$",
"lock",
")",
"{",
"$",
"locks",
"=",
"$",
"this",
"->",
"getSessionLocks",
"(",
")",
";",
"$",
"locks",
"[",
"$",
"lock",
"->",
"getObjectId",
"(",
")",
"->",
"__toString",
"(",
")",
"]",
"=",
"$",
"lock",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"self",
"::",
"SESSION_VARNAME",
",",
"$",
"locks",
")",
";",
"}"
] |
Add a given Lock instance to the session
@param $lock Lock instance
|
[
"Add",
"a",
"given",
"Lock",
"instance",
"to",
"the",
"session"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php#L248-L252
|
26,650
|
iherwig/wcmf
|
src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php
|
DefaultLockHandler.removeSessionLock
|
protected function removeSessionLock(ObjectId $oid, $type) {
$locks = $this->getSessionLocks();
if (isset($locks[$oid->__toString()])) {
$lock = $locks[$oid->__toString()];
if ($type == null || $type != null && $lock->getType() == $type) {
unset($locks[$oid->__toString()]);
$this->session->set(self::SESSION_VARNAME, $locks);
}
}
}
|
php
|
protected function removeSessionLock(ObjectId $oid, $type) {
$locks = $this->getSessionLocks();
if (isset($locks[$oid->__toString()])) {
$lock = $locks[$oid->__toString()];
if ($type == null || $type != null && $lock->getType() == $type) {
unset($locks[$oid->__toString()]);
$this->session->set(self::SESSION_VARNAME, $locks);
}
}
}
|
[
"protected",
"function",
"removeSessionLock",
"(",
"ObjectId",
"$",
"oid",
",",
"$",
"type",
")",
"{",
"$",
"locks",
"=",
"$",
"this",
"->",
"getSessionLocks",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"locks",
"[",
"$",
"oid",
"->",
"__toString",
"(",
")",
"]",
")",
")",
"{",
"$",
"lock",
"=",
"$",
"locks",
"[",
"$",
"oid",
"->",
"__toString",
"(",
")",
"]",
";",
"if",
"(",
"$",
"type",
"==",
"null",
"||",
"$",
"type",
"!=",
"null",
"&&",
"$",
"lock",
"->",
"getType",
"(",
")",
"==",
"$",
"type",
")",
"{",
"unset",
"(",
"$",
"locks",
"[",
"$",
"oid",
"->",
"__toString",
"(",
")",
"]",
")",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"self",
"::",
"SESSION_VARNAME",
",",
"$",
"locks",
")",
";",
"}",
"}",
"}"
] |
Remove a given Lock instance from the session
@param $oid The locked oid
@param $type One of the Lock::Type constants or null for all types (default: _null_)
|
[
"Remove",
"a",
"given",
"Lock",
"instance",
"from",
"the",
"session"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/concurrency/impl/DefaultLockHandler.php#L259-L268
|
26,651
|
iherwig/wcmf
|
src/wcmf/lib/presentation/format/impl/AbstractFormat.php
|
AbstractFormat.getNode
|
protected function getNode(ObjectId $oid) {
$oidStr = $oid->__toString();
if (!isset($this->deserializedNodes[$oidStr])) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$type = $oid->getType();
if ($persistenceFacade->isKnownType($type)) {
// don't create all values by default (-> don't use PersistenceFacade::create() directly, just for determining the class)
$class = get_class($persistenceFacade->create($type, BuildDepth::SINGLE));
$node = new $class;
}
else {
$node = new Node($type);
}
$node->setOID($oid);
$this->deserializedNodes[$oidStr] = $node;
}
return $this->deserializedNodes[$oidStr];
}
|
php
|
protected function getNode(ObjectId $oid) {
$oidStr = $oid->__toString();
if (!isset($this->deserializedNodes[$oidStr])) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$type = $oid->getType();
if ($persistenceFacade->isKnownType($type)) {
// don't create all values by default (-> don't use PersistenceFacade::create() directly, just for determining the class)
$class = get_class($persistenceFacade->create($type, BuildDepth::SINGLE));
$node = new $class;
}
else {
$node = new Node($type);
}
$node->setOID($oid);
$this->deserializedNodes[$oidStr] = $node;
}
return $this->deserializedNodes[$oidStr];
}
|
[
"protected",
"function",
"getNode",
"(",
"ObjectId",
"$",
"oid",
")",
"{",
"$",
"oidStr",
"=",
"$",
"oid",
"->",
"__toString",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"deserializedNodes",
"[",
"$",
"oidStr",
"]",
")",
")",
"{",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"$",
"type",
"=",
"$",
"oid",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"$",
"persistenceFacade",
"->",
"isKnownType",
"(",
"$",
"type",
")",
")",
"{",
"// don't create all values by default (-> don't use PersistenceFacade::create() directly, just for determining the class)",
"$",
"class",
"=",
"get_class",
"(",
"$",
"persistenceFacade",
"->",
"create",
"(",
"$",
"type",
",",
"BuildDepth",
"::",
"SINGLE",
")",
")",
";",
"$",
"node",
"=",
"new",
"$",
"class",
";",
"}",
"else",
"{",
"$",
"node",
"=",
"new",
"Node",
"(",
"$",
"type",
")",
";",
"}",
"$",
"node",
"->",
"setOID",
"(",
"$",
"oid",
")",
";",
"$",
"this",
"->",
"deserializedNodes",
"[",
"$",
"oidStr",
"]",
"=",
"$",
"node",
";",
"}",
"return",
"$",
"this",
"->",
"deserializedNodes",
"[",
"$",
"oidStr",
"]",
";",
"}"
] |
Get a node with the given oid to deserialize values from form fields into it.
The method ensures that there is only one instance per oid.
@param $oid The oid
@return Node
|
[
"Get",
"a",
"node",
"with",
"the",
"given",
"oid",
"to",
"deserialize",
"values",
"from",
"form",
"fields",
"into",
"it",
".",
"The",
"method",
"ensures",
"that",
"there",
"is",
"only",
"one",
"instance",
"per",
"oid",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/format/impl/AbstractFormat.php#L121-L138
|
26,652
|
iherwig/wcmf
|
src/wcmf/lib/core/impl/MonologFileLogger.php
|
MonologFileLogger.prepareMessage
|
private function prepareMessage($message) {
return is_string($message) ? $message :
(is_object($message) && method_exists($message, '__toString') ? $message->__toString() :
StringUtil::getDump($message));
}
|
php
|
private function prepareMessage($message) {
return is_string($message) ? $message :
(is_object($message) && method_exists($message, '__toString') ? $message->__toString() :
StringUtil::getDump($message));
}
|
[
"private",
"function",
"prepareMessage",
"(",
"$",
"message",
")",
"{",
"return",
"is_string",
"(",
"$",
"message",
")",
"?",
"$",
"message",
":",
"(",
"is_object",
"(",
"$",
"message",
")",
"&&",
"method_exists",
"(",
"$",
"message",
",",
"'__toString'",
")",
"?",
"$",
"message",
"->",
"__toString",
"(",
")",
":",
"StringUtil",
"::",
"getDump",
"(",
"$",
"message",
")",
")",
";",
"}"
] |
Prepare a message to be used with the internal logger
@param $message
@return String
|
[
"Prepare",
"a",
"message",
"to",
"be",
"used",
"with",
"the",
"internal",
"logger"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/impl/MonologFileLogger.php#L191-L195
|
26,653
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.filter
|
public static function filter(array $nodeList, ObjectId $oid=null, $type=null, $values=null,
$properties=null, $useRegExp=true) {
$returnArray = [];
for ($i=0, $count=sizeof($nodeList); $i<$count; $i++) {
$curNode = $nodeList[$i];
if ($curNode instanceof PersistentObject) {
$match = true;
// check oid
if ($oid != null && $curNode->getOID() != $oid) {
$match = false;
}
// check type
if ($type != null) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$fqType = $persistenceFacade->getFullyQualifiedType($type);
if ($fqType != null && $curNode->getType() != $fqType) {
$match = false;
}
}
// check values
if ($values != null && is_array($values)) {
foreach($values as $key => $value) {
$nodeValue = $curNode->getValue($key);
if ($useRegExp && !preg_match("/".$value."/m", $nodeValue) ||
!$useRegExp && $value != $nodeValue) {
$match = false;
break;
}
}
}
// check properties
if ($properties != null && is_array($properties)) {
foreach($properties as $key => $value) {
$nodeProperty = $curNode->getProperty($key);
if ($useRegExp && !preg_match("/".$value."/m", $nodeProperty) ||
!$useRegExp && $value != $nodeProperty) {
$match = false;
break;
}
}
}
if ($match) {
$returnArray[] = $curNode;
}
}
else {
self::$logger->warn(StringUtil::getDump($curNode)." found, where a PersistentObject was expected.\n".ErrorHandler::getStackTrace(),
__CLASS__);
}
}
return $returnArray;
}
|
php
|
public static function filter(array $nodeList, ObjectId $oid=null, $type=null, $values=null,
$properties=null, $useRegExp=true) {
$returnArray = [];
for ($i=0, $count=sizeof($nodeList); $i<$count; $i++) {
$curNode = $nodeList[$i];
if ($curNode instanceof PersistentObject) {
$match = true;
// check oid
if ($oid != null && $curNode->getOID() != $oid) {
$match = false;
}
// check type
if ($type != null) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$fqType = $persistenceFacade->getFullyQualifiedType($type);
if ($fqType != null && $curNode->getType() != $fqType) {
$match = false;
}
}
// check values
if ($values != null && is_array($values)) {
foreach($values as $key => $value) {
$nodeValue = $curNode->getValue($key);
if ($useRegExp && !preg_match("/".$value."/m", $nodeValue) ||
!$useRegExp && $value != $nodeValue) {
$match = false;
break;
}
}
}
// check properties
if ($properties != null && is_array($properties)) {
foreach($properties as $key => $value) {
$nodeProperty = $curNode->getProperty($key);
if ($useRegExp && !preg_match("/".$value."/m", $nodeProperty) ||
!$useRegExp && $value != $nodeProperty) {
$match = false;
break;
}
}
}
if ($match) {
$returnArray[] = $curNode;
}
}
else {
self::$logger->warn(StringUtil::getDump($curNode)." found, where a PersistentObject was expected.\n".ErrorHandler::getStackTrace(),
__CLASS__);
}
}
return $returnArray;
}
|
[
"public",
"static",
"function",
"filter",
"(",
"array",
"$",
"nodeList",
",",
"ObjectId",
"$",
"oid",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"useRegExp",
"=",
"true",
")",
"{",
"$",
"returnArray",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"sizeof",
"(",
"$",
"nodeList",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"curNode",
"=",
"$",
"nodeList",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"curNode",
"instanceof",
"PersistentObject",
")",
"{",
"$",
"match",
"=",
"true",
";",
"// check oid",
"if",
"(",
"$",
"oid",
"!=",
"null",
"&&",
"$",
"curNode",
"->",
"getOID",
"(",
")",
"!=",
"$",
"oid",
")",
"{",
"$",
"match",
"=",
"false",
";",
"}",
"// check type",
"if",
"(",
"$",
"type",
"!=",
"null",
")",
"{",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"$",
"fqType",
"=",
"$",
"persistenceFacade",
"->",
"getFullyQualifiedType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"$",
"fqType",
"!=",
"null",
"&&",
"$",
"curNode",
"->",
"getType",
"(",
")",
"!=",
"$",
"fqType",
")",
"{",
"$",
"match",
"=",
"false",
";",
"}",
"}",
"// check values",
"if",
"(",
"$",
"values",
"!=",
"null",
"&&",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"nodeValue",
"=",
"$",
"curNode",
"->",
"getValue",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"useRegExp",
"&&",
"!",
"preg_match",
"(",
"\"/\"",
".",
"$",
"value",
".",
"\"/m\"",
",",
"$",
"nodeValue",
")",
"||",
"!",
"$",
"useRegExp",
"&&",
"$",
"value",
"!=",
"$",
"nodeValue",
")",
"{",
"$",
"match",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"// check properties",
"if",
"(",
"$",
"properties",
"!=",
"null",
"&&",
"is_array",
"(",
"$",
"properties",
")",
")",
"{",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"nodeProperty",
"=",
"$",
"curNode",
"->",
"getProperty",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"useRegExp",
"&&",
"!",
"preg_match",
"(",
"\"/\"",
".",
"$",
"value",
".",
"\"/m\"",
",",
"$",
"nodeProperty",
")",
"||",
"!",
"$",
"useRegExp",
"&&",
"$",
"value",
"!=",
"$",
"nodeProperty",
")",
"{",
"$",
"match",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"returnArray",
"[",
"]",
"=",
"$",
"curNode",
";",
"}",
"}",
"else",
"{",
"self",
"::",
"$",
"logger",
"->",
"warn",
"(",
"StringUtil",
"::",
"getDump",
"(",
"$",
"curNode",
")",
".",
"\" found, where a PersistentObject was expected.\\n\"",
".",
"ErrorHandler",
"::",
"getStackTrace",
"(",
")",
",",
"__CLASS__",
")",
";",
"}",
"}",
"return",
"$",
"returnArray",
";",
"}"
] |
Get Nodes that match given conditions from a list.
@param $nodeList An array of nodes to filter or a single Node.
@param $oid The object id that the Nodes should match (optional, default: _null_)
@param $type The type that the Nodes should match (either fully qualified or simple, if not ambiguous)
(optional, default: _null_)
@param $values An associative array holding key value pairs that the Node values should match
(values are interpreted as regular expression, optional, default: _null_)
@param $properties An associative array holding key value pairs that the Node properties should match
(values are interpreted as regular expression, optional, default: _null_)
@param $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: _true_)
@return An Array holding references to the Nodes that matched.
|
[
"Get",
"Nodes",
"that",
"match",
"given",
"conditions",
"from",
"a",
"list",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L185-L237
|
26,654
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getRelationNames
|
public function getRelationNames() {
$result = [];
$relations = $this->getRelations();
foreach ($relations as $curRelation) {
$result[] = $curRelation->getOtherRole();
}
return $result;
}
|
php
|
public function getRelationNames() {
$result = [];
$relations = $this->getRelations();
foreach ($relations as $curRelation) {
$result[] = $curRelation->getOtherRole();
}
return $result;
}
|
[
"public",
"function",
"getRelationNames",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"relations",
"=",
"$",
"this",
"->",
"getRelations",
"(",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"curRelation",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"curRelation",
"->",
"getOtherRole",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the names of all relations.
@return An array of relation names.
|
[
"Get",
"the",
"names",
"of",
"all",
"relations",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L305-L312
|
26,655
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.addNode
|
public function addNode(PersistentObject $other, $role=null, $forceSet=false, $trackChange=true, $updateOtherSide=true) {
$mapper = $this->getMapper();
// set role if missing
if ($role == null) {
$otherType = $other->getType();
$relations = $mapper->getRelationsByType($otherType);
$role = (sizeof($relations) > 0) ? $relations[0]->getOtherRole() : $otherType;
}
// get the relation description
$relDesc = $mapper->getRelation($role);
$value = $other;
$oldValue = parent::getValue($role);
$addedNodes = []; // this array contains the other node or nothing
if (!$relDesc || $relDesc->isMultiValued()) {
// check multiplicity if multivalued
$maxMultiplicity = $relDesc->getOtherMaxMultiplicity();
if ($relDesc->isMultiValued() && !($maxMultiplicity == 'unbounded') &&
sizeof(oldValue) >= $maxMultiplicity) {
throw new IllegalArgumentException("Maximum number of related objects exceeded: ".$role." (".(sizeof(oldValue)+1)." > ".$maxMultiplicity.")");
}
// make sure that the value is an array if multivalued
$mergeResult = self::mergeObjectLists($oldValue, [$value]);
$value = $mergeResult['result'];
$addedNodes = $mergeResult['added'];
}
elseif ($oldValue == null && $value != null ||
$oldValue->getOID()->__toString() != $value->getOID()->__toString()) {
$addedNodes[] = $value;
}
$result1 = sizeof($addedNodes) > 0 && parent::setValue($role, $value, $forceSet, $trackChange);
// remember the addition
if (sizeof($addedNodes) > 0) {
if (!isset($this->addedNodes[$role])) {
$this->addedNodes[$role] = [];
}
$this->addedNodes[$role][] = $other;
}
// propagate add action to the other object
$result2 = true;
if ($updateOtherSide) {
$thisRole = $relDesc ? $relDesc->getThisRole() : null;
$result2 = $other->addNode($this, $thisRole, $forceSet, $trackChange, false);
}
return ($result1 & $result2);
}
|
php
|
public function addNode(PersistentObject $other, $role=null, $forceSet=false, $trackChange=true, $updateOtherSide=true) {
$mapper = $this->getMapper();
// set role if missing
if ($role == null) {
$otherType = $other->getType();
$relations = $mapper->getRelationsByType($otherType);
$role = (sizeof($relations) > 0) ? $relations[0]->getOtherRole() : $otherType;
}
// get the relation description
$relDesc = $mapper->getRelation($role);
$value = $other;
$oldValue = parent::getValue($role);
$addedNodes = []; // this array contains the other node or nothing
if (!$relDesc || $relDesc->isMultiValued()) {
// check multiplicity if multivalued
$maxMultiplicity = $relDesc->getOtherMaxMultiplicity();
if ($relDesc->isMultiValued() && !($maxMultiplicity == 'unbounded') &&
sizeof(oldValue) >= $maxMultiplicity) {
throw new IllegalArgumentException("Maximum number of related objects exceeded: ".$role." (".(sizeof(oldValue)+1)." > ".$maxMultiplicity.")");
}
// make sure that the value is an array if multivalued
$mergeResult = self::mergeObjectLists($oldValue, [$value]);
$value = $mergeResult['result'];
$addedNodes = $mergeResult['added'];
}
elseif ($oldValue == null && $value != null ||
$oldValue->getOID()->__toString() != $value->getOID()->__toString()) {
$addedNodes[] = $value;
}
$result1 = sizeof($addedNodes) > 0 && parent::setValue($role, $value, $forceSet, $trackChange);
// remember the addition
if (sizeof($addedNodes) > 0) {
if (!isset($this->addedNodes[$role])) {
$this->addedNodes[$role] = [];
}
$this->addedNodes[$role][] = $other;
}
// propagate add action to the other object
$result2 = true;
if ($updateOtherSide) {
$thisRole = $relDesc ? $relDesc->getThisRole() : null;
$result2 = $other->addNode($this, $thisRole, $forceSet, $trackChange, false);
}
return ($result1 & $result2);
}
|
[
"public",
"function",
"addNode",
"(",
"PersistentObject",
"$",
"other",
",",
"$",
"role",
"=",
"null",
",",
"$",
"forceSet",
"=",
"false",
",",
"$",
"trackChange",
"=",
"true",
",",
"$",
"updateOtherSide",
"=",
"true",
")",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"// set role if missing",
"if",
"(",
"$",
"role",
"==",
"null",
")",
"{",
"$",
"otherType",
"=",
"$",
"other",
"->",
"getType",
"(",
")",
";",
"$",
"relations",
"=",
"$",
"mapper",
"->",
"getRelationsByType",
"(",
"$",
"otherType",
")",
";",
"$",
"role",
"=",
"(",
"sizeof",
"(",
"$",
"relations",
")",
">",
"0",
")",
"?",
"$",
"relations",
"[",
"0",
"]",
"->",
"getOtherRole",
"(",
")",
":",
"$",
"otherType",
";",
"}",
"// get the relation description",
"$",
"relDesc",
"=",
"$",
"mapper",
"->",
"getRelation",
"(",
"$",
"role",
")",
";",
"$",
"value",
"=",
"$",
"other",
";",
"$",
"oldValue",
"=",
"parent",
"::",
"getValue",
"(",
"$",
"role",
")",
";",
"$",
"addedNodes",
"=",
"[",
"]",
";",
"// this array contains the other node or nothing",
"if",
"(",
"!",
"$",
"relDesc",
"||",
"$",
"relDesc",
"->",
"isMultiValued",
"(",
")",
")",
"{",
"// check multiplicity if multivalued",
"$",
"maxMultiplicity",
"=",
"$",
"relDesc",
"->",
"getOtherMaxMultiplicity",
"(",
")",
";",
"if",
"(",
"$",
"relDesc",
"->",
"isMultiValued",
"(",
")",
"&&",
"!",
"(",
"$",
"maxMultiplicity",
"==",
"'unbounded'",
")",
"&&",
"sizeof",
"(",
"oldValue",
")",
">=",
"$",
"maxMultiplicity",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Maximum number of related objects exceeded: \"",
".",
"$",
"role",
".",
"\" (\"",
".",
"(",
"sizeof",
"(",
"oldValue",
")",
"+",
"1",
")",
".",
"\" > \"",
".",
"$",
"maxMultiplicity",
".",
"\")\"",
")",
";",
"}",
"// make sure that the value is an array if multivalued",
"$",
"mergeResult",
"=",
"self",
"::",
"mergeObjectLists",
"(",
"$",
"oldValue",
",",
"[",
"$",
"value",
"]",
")",
";",
"$",
"value",
"=",
"$",
"mergeResult",
"[",
"'result'",
"]",
";",
"$",
"addedNodes",
"=",
"$",
"mergeResult",
"[",
"'added'",
"]",
";",
"}",
"elseif",
"(",
"$",
"oldValue",
"==",
"null",
"&&",
"$",
"value",
"!=",
"null",
"||",
"$",
"oldValue",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
"!=",
"$",
"value",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
")",
"{",
"$",
"addedNodes",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"result1",
"=",
"sizeof",
"(",
"$",
"addedNodes",
")",
">",
"0",
"&&",
"parent",
"::",
"setValue",
"(",
"$",
"role",
",",
"$",
"value",
",",
"$",
"forceSet",
",",
"$",
"trackChange",
")",
";",
"// remember the addition",
"if",
"(",
"sizeof",
"(",
"$",
"addedNodes",
")",
">",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"addedNodes",
"[",
"$",
"role",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addedNodes",
"[",
"$",
"role",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"addedNodes",
"[",
"$",
"role",
"]",
"[",
"]",
"=",
"$",
"other",
";",
"}",
"// propagate add action to the other object",
"$",
"result2",
"=",
"true",
";",
"if",
"(",
"$",
"updateOtherSide",
")",
"{",
"$",
"thisRole",
"=",
"$",
"relDesc",
"?",
"$",
"relDesc",
"->",
"getThisRole",
"(",
")",
":",
"null",
";",
"$",
"result2",
"=",
"$",
"other",
"->",
"addNode",
"(",
"$",
"this",
",",
"$",
"thisRole",
",",
"$",
"forceSet",
",",
"$",
"trackChange",
",",
"false",
")",
";",
"}",
"return",
"(",
"$",
"result1",
"&",
"$",
"result2",
")",
";",
"}"
] |
Add a Node to the given relation. Delegates to setValue internally.
@param $other PersistentObject
@param $role The role of the Node in the created relation. If null, the role will be
the Node's simple type (without namespace) (default: _null_)
@param $forceSet @see PersistentObject::setValue()
@param $trackChange @see PersistentObject::setValue()
@param $updateOtherSide Boolean whether to update also the other side of the relation (default: _true_)
@return Boolean whether the operation succeeds or not
|
[
"Add",
"a",
"Node",
"to",
"the",
"given",
"relation",
".",
"Delegates",
"to",
"setValue",
"internally",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L324-L373
|
26,656
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.deleteNode
|
public function deleteNode(PersistentObject $other, $role=null, $updateOtherSide=true) {
$mapper = $this->getMapper();
// set role if missing
if ($role == null) {
$otherType = $other->getType();
$relations = $mapper->getRelationsByType($otherType);
$role = (sizeof($relations) > 0) ? $relations[0]->getOtherRole() : $otherType;
}
$nodes = $this->getValue($role);
if (empty($nodes)) {
// nothing to delete
return;
}
// get the relation description
$relDesc = $mapper->getRelation($role);
$oid = $other->getOID();
if (is_array($nodes)) {
// multi valued relation
for($i=0, $count=sizeof($nodes); $i<$count; $i++) {
if ($nodes[$i]->getOID() == $oid) {
// remove child
array_splice($nodes, $i, 1);
break;
}
}
}
else {
// single valued relation
if ($nodes->getOID() == $oid) {
// remove child
$nodes = null;
}
}
parent::setValue($role, $nodes);
// remember the deletion
if (!isset($this->deletedNodes[$role])) {
$this->deletedNodes[$role] = [];
}
$this->deletedNodes[$role][] = $other->getOID();
$this->setState(PersistentOBject::STATE_DIRTY);
// propagate add action to the other object
if ($updateOtherSide) {
$thisRole = $relDesc ? $relDesc->getThisRole() : null;
$other->deleteNode($this, $thisRole, false);
}
}
|
php
|
public function deleteNode(PersistentObject $other, $role=null, $updateOtherSide=true) {
$mapper = $this->getMapper();
// set role if missing
if ($role == null) {
$otherType = $other->getType();
$relations = $mapper->getRelationsByType($otherType);
$role = (sizeof($relations) > 0) ? $relations[0]->getOtherRole() : $otherType;
}
$nodes = $this->getValue($role);
if (empty($nodes)) {
// nothing to delete
return;
}
// get the relation description
$relDesc = $mapper->getRelation($role);
$oid = $other->getOID();
if (is_array($nodes)) {
// multi valued relation
for($i=0, $count=sizeof($nodes); $i<$count; $i++) {
if ($nodes[$i]->getOID() == $oid) {
// remove child
array_splice($nodes, $i, 1);
break;
}
}
}
else {
// single valued relation
if ($nodes->getOID() == $oid) {
// remove child
$nodes = null;
}
}
parent::setValue($role, $nodes);
// remember the deletion
if (!isset($this->deletedNodes[$role])) {
$this->deletedNodes[$role] = [];
}
$this->deletedNodes[$role][] = $other->getOID();
$this->setState(PersistentOBject::STATE_DIRTY);
// propagate add action to the other object
if ($updateOtherSide) {
$thisRole = $relDesc ? $relDesc->getThisRole() : null;
$other->deleteNode($this, $thisRole, false);
}
}
|
[
"public",
"function",
"deleteNode",
"(",
"PersistentObject",
"$",
"other",
",",
"$",
"role",
"=",
"null",
",",
"$",
"updateOtherSide",
"=",
"true",
")",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"// set role if missing",
"if",
"(",
"$",
"role",
"==",
"null",
")",
"{",
"$",
"otherType",
"=",
"$",
"other",
"->",
"getType",
"(",
")",
";",
"$",
"relations",
"=",
"$",
"mapper",
"->",
"getRelationsByType",
"(",
"$",
"otherType",
")",
";",
"$",
"role",
"=",
"(",
"sizeof",
"(",
"$",
"relations",
")",
">",
"0",
")",
"?",
"$",
"relations",
"[",
"0",
"]",
"->",
"getOtherRole",
"(",
")",
":",
"$",
"otherType",
";",
"}",
"$",
"nodes",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"role",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"nodes",
")",
")",
"{",
"// nothing to delete",
"return",
";",
"}",
"// get the relation description",
"$",
"relDesc",
"=",
"$",
"mapper",
"->",
"getRelation",
"(",
"$",
"role",
")",
";",
"$",
"oid",
"=",
"$",
"other",
"->",
"getOID",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"nodes",
")",
")",
"{",
"// multi valued relation",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"sizeof",
"(",
"$",
"nodes",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"nodes",
"[",
"$",
"i",
"]",
"->",
"getOID",
"(",
")",
"==",
"$",
"oid",
")",
"{",
"// remove child",
"array_splice",
"(",
"$",
"nodes",
",",
"$",
"i",
",",
"1",
")",
";",
"break",
";",
"}",
"}",
"}",
"else",
"{",
"// single valued relation",
"if",
"(",
"$",
"nodes",
"->",
"getOID",
"(",
")",
"==",
"$",
"oid",
")",
"{",
"// remove child",
"$",
"nodes",
"=",
"null",
";",
"}",
"}",
"parent",
"::",
"setValue",
"(",
"$",
"role",
",",
"$",
"nodes",
")",
";",
"// remember the deletion",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"deletedNodes",
"[",
"$",
"role",
"]",
")",
")",
"{",
"$",
"this",
"->",
"deletedNodes",
"[",
"$",
"role",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"deletedNodes",
"[",
"$",
"role",
"]",
"[",
"]",
"=",
"$",
"other",
"->",
"getOID",
"(",
")",
";",
"$",
"this",
"->",
"setState",
"(",
"PersistentOBject",
"::",
"STATE_DIRTY",
")",
";",
"// propagate add action to the other object",
"if",
"(",
"$",
"updateOtherSide",
")",
"{",
"$",
"thisRole",
"=",
"$",
"relDesc",
"?",
"$",
"relDesc",
"->",
"getThisRole",
"(",
")",
":",
"null",
";",
"$",
"other",
"->",
"deleteNode",
"(",
"$",
"this",
",",
"$",
"thisRole",
",",
"false",
")",
";",
"}",
"}"
] |
Delete a Node from the given relation.
@param $other The Node to delete.
@param $role The role of the Node. If null, the role is the Node's type (without namespace) (default: _null_)
@param $updateOtherSide Boolean whether to update also the other side of the relation (default: _true_)
|
[
"Delete",
"a",
"Node",
"from",
"the",
"given",
"relation",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L391-L443
|
26,657
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.setNodeOrder
|
public function setNodeOrder(array $orderedList, array $movedList=null, $role=null) {
$this->orderedNodes = [
'ordered' => $orderedList,
'moved' => $movedList,
'role' => $role
];
$this->setState(PersistentOBject::STATE_DIRTY);
}
|
php
|
public function setNodeOrder(array $orderedList, array $movedList=null, $role=null) {
$this->orderedNodes = [
'ordered' => $orderedList,
'moved' => $movedList,
'role' => $role
];
$this->setState(PersistentOBject::STATE_DIRTY);
}
|
[
"public",
"function",
"setNodeOrder",
"(",
"array",
"$",
"orderedList",
",",
"array",
"$",
"movedList",
"=",
"null",
",",
"$",
"role",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"orderedNodes",
"=",
"[",
"'ordered'",
"=>",
"$",
"orderedList",
",",
"'moved'",
"=>",
"$",
"movedList",
",",
"'role'",
"=>",
"$",
"role",
"]",
";",
"$",
"this",
"->",
"setState",
"(",
"PersistentOBject",
"::",
"STATE_DIRTY",
")",
";",
"}"
] |
Define the order of related Node instances. The mapper is responsible for
persisting the order of the given Node instances in relation to this Node.
@note Note instances, that are not explicitly sortable by a sortkey
(@see PersistenceMapper::getDefaultOrder()) will be ignored. If a given
Node instance is not related to this Node yet, an exception will be thrown.
Any not persisted definition of a previous call will be overwritten
@param $orderedList Array of ordered Node instances
@param $movedList Array of repositioned Node instances (optional, improves performance)
@param $role Role name of the Node instances (optional)
|
[
"Define",
"the",
"order",
"of",
"related",
"Node",
"instances",
".",
"The",
"mapper",
"is",
"responsible",
"for",
"persisting",
"the",
"order",
"of",
"the",
"given",
"Node",
"instances",
"in",
"relation",
"to",
"this",
"Node",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L466-L473
|
26,658
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.loadChildren
|
public function loadChildren($role=null, $buildDepth=BuildDepth::SINGLE) {
if ($role != null) {
$this->loadRelations([$role], $buildDepth);
}
else {
$this->loadRelations(array_keys($this->getPossibleChildren()), $buildDepth);
}
}
|
php
|
public function loadChildren($role=null, $buildDepth=BuildDepth::SINGLE) {
if ($role != null) {
$this->loadRelations([$role], $buildDepth);
}
else {
$this->loadRelations(array_keys($this->getPossibleChildren()), $buildDepth);
}
}
|
[
"public",
"function",
"loadChildren",
"(",
"$",
"role",
"=",
"null",
",",
"$",
"buildDepth",
"=",
"BuildDepth",
"::",
"SINGLE",
")",
"{",
"if",
"(",
"$",
"role",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"loadRelations",
"(",
"[",
"$",
"role",
"]",
",",
"$",
"buildDepth",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"loadRelations",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"getPossibleChildren",
"(",
")",
")",
",",
"$",
"buildDepth",
")",
";",
"}",
"}"
] |
Load the children of a given role and add them. If all children should be
loaded, set the role parameter to null.
@param $role The role of children to load (maybe null, to load all children) (default: _null_)
@param $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
(default: _BuildDepth::SINGLE_)
|
[
"Load",
"the",
"children",
"of",
"a",
"given",
"role",
"and",
"add",
"them",
".",
"If",
"all",
"children",
"should",
"be",
"loaded",
"set",
"the",
"role",
"parameter",
"to",
"null",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L491-L498
|
26,659
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getFirstChild
|
public function getFirstChild($role=null, $type=null, $values=null, $properties=null, $useRegExp=true) {
$children = $this->getChildrenEx(null, $role, $type, $values, $properties, $useRegExp);
if (sizeof($children) > 0) {
return $children[0];
}
else {
return null;
}
}
|
php
|
public function getFirstChild($role=null, $type=null, $values=null, $properties=null, $useRegExp=true) {
$children = $this->getChildrenEx(null, $role, $type, $values, $properties, $useRegExp);
if (sizeof($children) > 0) {
return $children[0];
}
else {
return null;
}
}
|
[
"public",
"function",
"getFirstChild",
"(",
"$",
"role",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"useRegExp",
"=",
"true",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"getChildrenEx",
"(",
"null",
",",
"$",
"role",
",",
"$",
"type",
",",
"$",
"values",
",",
"$",
"properties",
",",
"$",
"useRegExp",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"children",
")",
">",
"0",
")",
"{",
"return",
"$",
"children",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the first child that matches given conditions.
@param $role The role that the child should match (optional, default: _null_).
@param $type The type that the child should match (either fully qualified or simple, if not ambiguous)
(optional, default: _null_).
@param $values An associative array holding key value pairs that the child values should match (optional, default: _null_).
@param $properties An associative array holding key value pairs that the child properties should match (optional, default: _null_).
@param $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: _true_)
@return Node instance or null.
|
[
"Get",
"the",
"first",
"child",
"that",
"matches",
"given",
"conditions",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L519-L527
|
26,660
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getChildrenEx
|
public function getChildrenEx(ObjectId $oid=null, $role=null, $type=null, $values=null,
$properties=null, $useRegExp=true) {
if ($role != null) {
// nodes of a given role are requested
// make sure it is a child role
$childRoles = $this->getPossibleChildren();
if (!isset($childRoles[$role])) {
throw new IllegalArgumentException("No child role defined with name: ".$role);
}
// we are only looking for nodes that are in memory already
$nodes = parent::getValue($role);
if (!is_array($nodes)) {
$nodes = [$nodes];
}
// sort out proxies
$children = [];
foreach($nodes as $curNode) {
if ($curNode instanceof PersistentObject) {
$children[] = $curNode;
}
}
return self::filter($children, $oid, $type, $values, $properties, $useRegExp);
}
else {
return self::filter($this->getChildren(), $oid, $type, $values, $properties, $useRegExp);
}
}
|
php
|
public function getChildrenEx(ObjectId $oid=null, $role=null, $type=null, $values=null,
$properties=null, $useRegExp=true) {
if ($role != null) {
// nodes of a given role are requested
// make sure it is a child role
$childRoles = $this->getPossibleChildren();
if (!isset($childRoles[$role])) {
throw new IllegalArgumentException("No child role defined with name: ".$role);
}
// we are only looking for nodes that are in memory already
$nodes = parent::getValue($role);
if (!is_array($nodes)) {
$nodes = [$nodes];
}
// sort out proxies
$children = [];
foreach($nodes as $curNode) {
if ($curNode instanceof PersistentObject) {
$children[] = $curNode;
}
}
return self::filter($children, $oid, $type, $values, $properties, $useRegExp);
}
else {
return self::filter($this->getChildren(), $oid, $type, $values, $properties, $useRegExp);
}
}
|
[
"public",
"function",
"getChildrenEx",
"(",
"ObjectId",
"$",
"oid",
"=",
"null",
",",
"$",
"role",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"useRegExp",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"role",
"!=",
"null",
")",
"{",
"// nodes of a given role are requested",
"// make sure it is a child role",
"$",
"childRoles",
"=",
"$",
"this",
"->",
"getPossibleChildren",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"childRoles",
"[",
"$",
"role",
"]",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No child role defined with name: \"",
".",
"$",
"role",
")",
";",
"}",
"// we are only looking for nodes that are in memory already",
"$",
"nodes",
"=",
"parent",
"::",
"getValue",
"(",
"$",
"role",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"nodes",
")",
")",
"{",
"$",
"nodes",
"=",
"[",
"$",
"nodes",
"]",
";",
"}",
"// sort out proxies",
"$",
"children",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"curNode",
")",
"{",
"if",
"(",
"$",
"curNode",
"instanceof",
"PersistentObject",
")",
"{",
"$",
"children",
"[",
"]",
"=",
"$",
"curNode",
";",
"}",
"}",
"return",
"self",
"::",
"filter",
"(",
"$",
"children",
",",
"$",
"oid",
",",
"$",
"type",
",",
"$",
"values",
",",
"$",
"properties",
",",
"$",
"useRegExp",
")",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"filter",
"(",
"$",
"this",
"->",
"getChildren",
"(",
")",
",",
"$",
"oid",
",",
"$",
"type",
",",
"$",
"values",
",",
"$",
"properties",
",",
"$",
"useRegExp",
")",
";",
"}",
"}"
] |
Get the children that match given conditions.
@note This method will only return objects that are already loaded, to get all objects in
the given relation (including proxies), use the Node::getValue() method and filter the returned
list afterwards.
@param $oid The object id that the children should match (optional, default: _null_).
@param $role The role that the children should match (optional, default: _null_).
@param $type The type that the children should match (either fully qualified or simple, if not ambiguous)
(optional, default: _null_).
@param $values An associative array holding key value pairs that the children values should match (optional, default: _null_).
@param $properties An associative array holding key value pairs that the children properties should match (optional, default: _null_).
@param $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: _true_)
@return Array containing children Nodes that matched (proxies not included).
|
[
"Get",
"the",
"children",
"that",
"match",
"given",
"conditions",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L552-L578
|
26,661
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.loadParents
|
public function loadParents($role=null, $buildDepth=BuildDepth::SINGLE) {
if ($role != null) {
$this->loadRelations([$role], $buildDepth);
}
else {
$this->loadRelations(array_keys($this->getPossibleParents()), $buildDepth);
}
}
|
php
|
public function loadParents($role=null, $buildDepth=BuildDepth::SINGLE) {
if ($role != null) {
$this->loadRelations([$role], $buildDepth);
}
else {
$this->loadRelations(array_keys($this->getPossibleParents()), $buildDepth);
}
}
|
[
"public",
"function",
"loadParents",
"(",
"$",
"role",
"=",
"null",
",",
"$",
"buildDepth",
"=",
"BuildDepth",
"::",
"SINGLE",
")",
"{",
"if",
"(",
"$",
"role",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"loadRelations",
"(",
"[",
"$",
"role",
"]",
",",
"$",
"buildDepth",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"loadRelations",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"getPossibleParents",
"(",
")",
")",
",",
"$",
"buildDepth",
")",
";",
"}",
"}"
] |
Load the parents of a given role and add them. If all parents should be
loaded, set the role parameter to null.
@param $role The role of parents to load (maybe null, to load all parents) (default: _null_)
@param $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
(default: _BuildDepth::SINGLE_)
|
[
"Load",
"the",
"parents",
"of",
"a",
"given",
"role",
"and",
"add",
"them",
".",
"If",
"all",
"parents",
"should",
"be",
"loaded",
"set",
"the",
"role",
"parameter",
"to",
"null",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L600-L607
|
26,662
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getFirstParent
|
public function getFirstParent($role=null, $type=null, $values=null, $properties=null, $useRegExp=true) {
$parents = $this->getParentsEx(null, $role, $type, $values, $properties, $useRegExp);
if (sizeof($parents) > 0) {
return $parents[0];
}
else {
return null;
}
}
|
php
|
public function getFirstParent($role=null, $type=null, $values=null, $properties=null, $useRegExp=true) {
$parents = $this->getParentsEx(null, $role, $type, $values, $properties, $useRegExp);
if (sizeof($parents) > 0) {
return $parents[0];
}
else {
return null;
}
}
|
[
"public",
"function",
"getFirstParent",
"(",
"$",
"role",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"useRegExp",
"=",
"true",
")",
"{",
"$",
"parents",
"=",
"$",
"this",
"->",
"getParentsEx",
"(",
"null",
",",
"$",
"role",
",",
"$",
"type",
",",
"$",
"values",
",",
"$",
"properties",
",",
"$",
"useRegExp",
")",
";",
"if",
"(",
"sizeof",
"(",
"$",
"parents",
")",
">",
"0",
")",
"{",
"return",
"$",
"parents",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Get the first parent that matches given conditions.
@param $role The role that the parent should match (optional, default: _null_).
@param $type The type that the parent should match (either fully qualified or simple, if not ambiguous)
(optional, default: _null_).
@param $values An associative array holding key value pairs that the parent values should match (optional, default: _null_).
@param $properties An associative array holding key value pairs that the parent properties should match (optional, default: _null_).
@param $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: _true_)
@return Node instance or null.
|
[
"Get",
"the",
"first",
"parent",
"that",
"matches",
"given",
"conditions",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L643-L652
|
26,663
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getParentsEx
|
public function getParentsEx(ObjectId $oid=null, $role=null, $type=null, $values=null,
$properties=null, $useRegExp=true) {
if ($role != null) {
// nodes of a given role are requested
// make sure it is a parent role
$parentRoles = $this->getPossibleParents();
if (!isset($parentRoles[$role])) {
throw new IllegalArgumentException("No parent role defined with name: ".$role);
}
// we are only looking for nodes that are in memory already
$nodes = parent::getValue($role);
if (!is_array($nodes)) {
$nodes = [$nodes];
}
// sort out proxies
$parents = [];
foreach($nodes as $curNode) {
if ($curNode instanceof PersistentObject) {
$parents[] = $curNode;
}
}
return self::filter($parents, $oid, $type, $values, $properties, $useRegExp);
}
else {
return self::filter($this->getParents(), $oid, $type, $values, $properties, $useRegExp);
}
}
|
php
|
public function getParentsEx(ObjectId $oid=null, $role=null, $type=null, $values=null,
$properties=null, $useRegExp=true) {
if ($role != null) {
// nodes of a given role are requested
// make sure it is a parent role
$parentRoles = $this->getPossibleParents();
if (!isset($parentRoles[$role])) {
throw new IllegalArgumentException("No parent role defined with name: ".$role);
}
// we are only looking for nodes that are in memory already
$nodes = parent::getValue($role);
if (!is_array($nodes)) {
$nodes = [$nodes];
}
// sort out proxies
$parents = [];
foreach($nodes as $curNode) {
if ($curNode instanceof PersistentObject) {
$parents[] = $curNode;
}
}
return self::filter($parents, $oid, $type, $values, $properties, $useRegExp);
}
else {
return self::filter($this->getParents(), $oid, $type, $values, $properties, $useRegExp);
}
}
|
[
"public",
"function",
"getParentsEx",
"(",
"ObjectId",
"$",
"oid",
"=",
"null",
",",
"$",
"role",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"values",
"=",
"null",
",",
"$",
"properties",
"=",
"null",
",",
"$",
"useRegExp",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"role",
"!=",
"null",
")",
"{",
"// nodes of a given role are requested",
"// make sure it is a parent role",
"$",
"parentRoles",
"=",
"$",
"this",
"->",
"getPossibleParents",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parentRoles",
"[",
"$",
"role",
"]",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No parent role defined with name: \"",
".",
"$",
"role",
")",
";",
"}",
"// we are only looking for nodes that are in memory already",
"$",
"nodes",
"=",
"parent",
"::",
"getValue",
"(",
"$",
"role",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"nodes",
")",
")",
"{",
"$",
"nodes",
"=",
"[",
"$",
"nodes",
"]",
";",
"}",
"// sort out proxies",
"$",
"parents",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"curNode",
")",
"{",
"if",
"(",
"$",
"curNode",
"instanceof",
"PersistentObject",
")",
"{",
"$",
"parents",
"[",
"]",
"=",
"$",
"curNode",
";",
"}",
"}",
"return",
"self",
"::",
"filter",
"(",
"$",
"parents",
",",
"$",
"oid",
",",
"$",
"type",
",",
"$",
"values",
",",
"$",
"properties",
",",
"$",
"useRegExp",
")",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"filter",
"(",
"$",
"this",
"->",
"getParents",
"(",
")",
",",
"$",
"oid",
",",
"$",
"type",
",",
"$",
"values",
",",
"$",
"properties",
",",
"$",
"useRegExp",
")",
";",
"}",
"}"
] |
Get the parents that match given conditions.
@note This method will only return objects that are already loaded, to get all objects in
the given relation (including proxies), use the Node::getValue() method and filter the returned
list afterwards.
@param $oid The object id that the parent should match (optional, default: _null_).
@param $role The role that the parents should match (optional, default: _null_).
@param $type The type that the parents should match (either fully qualified or simple, if not ambiguous)
(optional, default: _null_).
@param $values An associative array holding key value pairs that the parent values should match (optional, default: _null_).
@param $properties An associative array holding key value pairs that the parent properties should match (optional, default: _null_).
@param $useRegExp Boolean whether to interpret the given values/properties as regular expressions or not (default: _true_)
@return Array containing parent Nodes that matched (proxies not included).
|
[
"Get",
"the",
"parents",
"that",
"match",
"given",
"conditions",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L677-L703
|
26,664
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getNodeRelation
|
public function getNodeRelation($object) {
$relations = $this->getRelations();
foreach ($relations as $curRelation) {
$curRelatives = parent::getValue($curRelation->getOtherRole());
if ($curRelatives instanceof Node && $curRelatives->getOID() == $object->getOID()) {
return $curRelation;
}
elseif (is_array($curRelatives)) {
foreach ($curRelatives as $curRelative) {
if ($curRelative->getOID() == $object->getOID()) {
return $curRelation;
}
}
}
}
return null;
}
|
php
|
public function getNodeRelation($object) {
$relations = $this->getRelations();
foreach ($relations as $curRelation) {
$curRelatives = parent::getValue($curRelation->getOtherRole());
if ($curRelatives instanceof Node && $curRelatives->getOID() == $object->getOID()) {
return $curRelation;
}
elseif (is_array($curRelatives)) {
foreach ($curRelatives as $curRelative) {
if ($curRelative->getOID() == $object->getOID()) {
return $curRelation;
}
}
}
}
return null;
}
|
[
"public",
"function",
"getNodeRelation",
"(",
"$",
"object",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"getRelations",
"(",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"curRelation",
")",
"{",
"$",
"curRelatives",
"=",
"parent",
"::",
"getValue",
"(",
"$",
"curRelation",
"->",
"getOtherRole",
"(",
")",
")",
";",
"if",
"(",
"$",
"curRelatives",
"instanceof",
"Node",
"&&",
"$",
"curRelatives",
"->",
"getOID",
"(",
")",
"==",
"$",
"object",
"->",
"getOID",
"(",
")",
")",
"{",
"return",
"$",
"curRelation",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"curRelatives",
")",
")",
"{",
"foreach",
"(",
"$",
"curRelatives",
"as",
"$",
"curRelative",
")",
"{",
"if",
"(",
"$",
"curRelative",
"->",
"getOID",
"(",
")",
"==",
"$",
"object",
"->",
"getOID",
"(",
")",
")",
"{",
"return",
"$",
"curRelation",
";",
"}",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Get the relation description for a given node.
@param $object PersistentObject instance to look for
@return RelationDescription instance or null, if the Node is not related
|
[
"Get",
"the",
"relation",
"description",
"for",
"a",
"given",
"node",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L723-L739
|
26,665
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.loadRelations
|
protected function loadRelations(array $roles, $buildDepth=BuildDepth::SINGLE) {
$oldState = $this->getState();
foreach ($roles as $curRole) {
if (isset($this->relationStates[$curRole]) &&
$this->relationStates[$curRole] != self::RELATION_STATE_LOADED) {
$relatives = [];
// resolve proxies if the relation is already initialized
if ($this->relationStates[$curRole] == self::RELATION_STATE_INITIALIZED) {
$proxies = $this->getValue($curRole);
if (is_array($proxies)) {
foreach ($proxies as $curRelative) {
if ($curRelative instanceof PersistentObjectProxy) {
// resolve proxies
$curRelative->resolve($buildDepth);
$relatives[] = $curRelative->getRealSubject();
}
else {
$relatives[] = $curRelative;
}
}
}
}
// otherwise load the objects directly
else {
$mapper = $this->getMapper();
$allRelatives = $mapper->loadRelation([$this], $curRole, $buildDepth);
$oidStr = $this->getOID()->__toString();
$relatives = isset($allRelatives[$oidStr]) ? $allRelatives[$oidStr] : null;
$relDesc = $mapper->getRelation($curRole);
if (!$relDesc->isMultiValued()) {
$relatives = $relatives != null ? $relatives[0] : null;
}
}
$this->setValueInternal($curRole, $relatives);
$this->relationStates[$curRole] = self::RELATION_STATE_LOADED;
}
}
$this->setState($oldState);
}
|
php
|
protected function loadRelations(array $roles, $buildDepth=BuildDepth::SINGLE) {
$oldState = $this->getState();
foreach ($roles as $curRole) {
if (isset($this->relationStates[$curRole]) &&
$this->relationStates[$curRole] != self::RELATION_STATE_LOADED) {
$relatives = [];
// resolve proxies if the relation is already initialized
if ($this->relationStates[$curRole] == self::RELATION_STATE_INITIALIZED) {
$proxies = $this->getValue($curRole);
if (is_array($proxies)) {
foreach ($proxies as $curRelative) {
if ($curRelative instanceof PersistentObjectProxy) {
// resolve proxies
$curRelative->resolve($buildDepth);
$relatives[] = $curRelative->getRealSubject();
}
else {
$relatives[] = $curRelative;
}
}
}
}
// otherwise load the objects directly
else {
$mapper = $this->getMapper();
$allRelatives = $mapper->loadRelation([$this], $curRole, $buildDepth);
$oidStr = $this->getOID()->__toString();
$relatives = isset($allRelatives[$oidStr]) ? $allRelatives[$oidStr] : null;
$relDesc = $mapper->getRelation($curRole);
if (!$relDesc->isMultiValued()) {
$relatives = $relatives != null ? $relatives[0] : null;
}
}
$this->setValueInternal($curRole, $relatives);
$this->relationStates[$curRole] = self::RELATION_STATE_LOADED;
}
}
$this->setState($oldState);
}
|
[
"protected",
"function",
"loadRelations",
"(",
"array",
"$",
"roles",
",",
"$",
"buildDepth",
"=",
"BuildDepth",
"::",
"SINGLE",
")",
"{",
"$",
"oldState",
"=",
"$",
"this",
"->",
"getState",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"curRole",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"relationStates",
"[",
"$",
"curRole",
"]",
")",
"&&",
"$",
"this",
"->",
"relationStates",
"[",
"$",
"curRole",
"]",
"!=",
"self",
"::",
"RELATION_STATE_LOADED",
")",
"{",
"$",
"relatives",
"=",
"[",
"]",
";",
"// resolve proxies if the relation is already initialized",
"if",
"(",
"$",
"this",
"->",
"relationStates",
"[",
"$",
"curRole",
"]",
"==",
"self",
"::",
"RELATION_STATE_INITIALIZED",
")",
"{",
"$",
"proxies",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"curRole",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"proxies",
")",
")",
"{",
"foreach",
"(",
"$",
"proxies",
"as",
"$",
"curRelative",
")",
"{",
"if",
"(",
"$",
"curRelative",
"instanceof",
"PersistentObjectProxy",
")",
"{",
"// resolve proxies",
"$",
"curRelative",
"->",
"resolve",
"(",
"$",
"buildDepth",
")",
";",
"$",
"relatives",
"[",
"]",
"=",
"$",
"curRelative",
"->",
"getRealSubject",
"(",
")",
";",
"}",
"else",
"{",
"$",
"relatives",
"[",
"]",
"=",
"$",
"curRelative",
";",
"}",
"}",
"}",
"}",
"// otherwise load the objects directly",
"else",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"getMapper",
"(",
")",
";",
"$",
"allRelatives",
"=",
"$",
"mapper",
"->",
"loadRelation",
"(",
"[",
"$",
"this",
"]",
",",
"$",
"curRole",
",",
"$",
"buildDepth",
")",
";",
"$",
"oidStr",
"=",
"$",
"this",
"->",
"getOID",
"(",
")",
"->",
"__toString",
"(",
")",
";",
"$",
"relatives",
"=",
"isset",
"(",
"$",
"allRelatives",
"[",
"$",
"oidStr",
"]",
")",
"?",
"$",
"allRelatives",
"[",
"$",
"oidStr",
"]",
":",
"null",
";",
"$",
"relDesc",
"=",
"$",
"mapper",
"->",
"getRelation",
"(",
"$",
"curRole",
")",
";",
"if",
"(",
"!",
"$",
"relDesc",
"->",
"isMultiValued",
"(",
")",
")",
"{",
"$",
"relatives",
"=",
"$",
"relatives",
"!=",
"null",
"?",
"$",
"relatives",
"[",
"0",
"]",
":",
"null",
";",
"}",
"}",
"$",
"this",
"->",
"setValueInternal",
"(",
"$",
"curRole",
",",
"$",
"relatives",
")",
";",
"$",
"this",
"->",
"relationStates",
"[",
"$",
"curRole",
"]",
"=",
"self",
"::",
"RELATION_STATE_LOADED",
";",
"}",
"}",
"$",
"this",
"->",
"setState",
"(",
"$",
"oldState",
")",
";",
"}"
] |
Load all objects in the given set of relations
@param $roles An array of relation (=role) names
@param $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
(default: _BuildDepth::SINGLE_)
|
[
"Load",
"all",
"objects",
"in",
"the",
"given",
"set",
"of",
"relations"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L747-L786
|
26,666
|
iherwig/wcmf
|
src/wcmf/lib/model/Node.php
|
Node.getRelatives
|
public function getRelatives($hierarchyType, $memOnly=true) {
$relatives = [];
$relations = $this->getRelations($hierarchyType);
foreach ($relations as $curRelation) {
$curRelatives = null;
if ($memOnly) {
$curRelatives = parent::getValue($curRelation->getOtherRole());
}
else {
$curRelatives = $this->getValue($curRelation->getOtherRole());
}
if (!$curRelatives) {
continue;
}
if (!is_array($curRelatives)) {
$curRelatives = [$curRelatives];
}
foreach ($curRelatives as $curRelative) {
if ($curRelative instanceof PersistentObjectProxy && $memOnly) {
// ignore proxies
continue;
}
else {
$relatives[] = $curRelative;
}
}
}
return $relatives;
}
|
php
|
public function getRelatives($hierarchyType, $memOnly=true) {
$relatives = [];
$relations = $this->getRelations($hierarchyType);
foreach ($relations as $curRelation) {
$curRelatives = null;
if ($memOnly) {
$curRelatives = parent::getValue($curRelation->getOtherRole());
}
else {
$curRelatives = $this->getValue($curRelation->getOtherRole());
}
if (!$curRelatives) {
continue;
}
if (!is_array($curRelatives)) {
$curRelatives = [$curRelatives];
}
foreach ($curRelatives as $curRelative) {
if ($curRelative instanceof PersistentObjectProxy && $memOnly) {
// ignore proxies
continue;
}
else {
$relatives[] = $curRelative;
}
}
}
return $relatives;
}
|
[
"public",
"function",
"getRelatives",
"(",
"$",
"hierarchyType",
",",
"$",
"memOnly",
"=",
"true",
")",
"{",
"$",
"relatives",
"=",
"[",
"]",
";",
"$",
"relations",
"=",
"$",
"this",
"->",
"getRelations",
"(",
"$",
"hierarchyType",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"curRelation",
")",
"{",
"$",
"curRelatives",
"=",
"null",
";",
"if",
"(",
"$",
"memOnly",
")",
"{",
"$",
"curRelatives",
"=",
"parent",
"::",
"getValue",
"(",
"$",
"curRelation",
"->",
"getOtherRole",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"curRelatives",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"curRelation",
"->",
"getOtherRole",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"curRelatives",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"curRelatives",
")",
")",
"{",
"$",
"curRelatives",
"=",
"[",
"$",
"curRelatives",
"]",
";",
"}",
"foreach",
"(",
"$",
"curRelatives",
"as",
"$",
"curRelative",
")",
"{",
"if",
"(",
"$",
"curRelative",
"instanceof",
"PersistentObjectProxy",
"&&",
"$",
"memOnly",
")",
"{",
"// ignore proxies",
"continue",
";",
"}",
"else",
"{",
"$",
"relatives",
"[",
"]",
"=",
"$",
"curRelative",
";",
"}",
"}",
"}",
"return",
"$",
"relatives",
";",
"}"
] |
Get the relatives of a given hierarchyType.
@param $hierarchyType @see PersistenceMapper::getRelations
@param $memOnly Boolean whether to only get the relatives in memory or all relatives (including proxies) (default: _true_).
@return An array containing the relatives.
|
[
"Get",
"the",
"relatives",
"of",
"a",
"given",
"hierarchyType",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/Node.php#L803-L831
|
26,667
|
iherwig/wcmf
|
src/wcmf/lib/core/impl/ClientSideSession.php
|
ClientSideSession.createToken
|
protected function createToken($login) {
$jwt = (new Builder())
->setIssuer($this->getTokenIssuer())
->setIssuedAt(time())
->setExpiration(time()+3600)
->set(self::AUTH_USER_NAME, $login)
->sign($this->getTokenSigner(), $this->key)
->getToken();
return $jwt->__toString();
}
|
php
|
protected function createToken($login) {
$jwt = (new Builder())
->setIssuer($this->getTokenIssuer())
->setIssuedAt(time())
->setExpiration(time()+3600)
->set(self::AUTH_USER_NAME, $login)
->sign($this->getTokenSigner(), $this->key)
->getToken();
return $jwt->__toString();
}
|
[
"protected",
"function",
"createToken",
"(",
"$",
"login",
")",
"{",
"$",
"jwt",
"=",
"(",
"new",
"Builder",
"(",
")",
")",
"->",
"setIssuer",
"(",
"$",
"this",
"->",
"getTokenIssuer",
"(",
")",
")",
"->",
"setIssuedAt",
"(",
"time",
"(",
")",
")",
"->",
"setExpiration",
"(",
"time",
"(",
")",
"+",
"3600",
")",
"->",
"set",
"(",
"self",
"::",
"AUTH_USER_NAME",
",",
"$",
"login",
")",
"->",
"sign",
"(",
"$",
"this",
"->",
"getTokenSigner",
"(",
")",
",",
"$",
"this",
"->",
"key",
")",
"->",
"getToken",
"(",
")",
";",
"return",
"$",
"jwt",
"->",
"__toString",
"(",
")",
";",
"}"
] |
Create the token for the given login
@param $login
@return String
|
[
"Create",
"the",
"token",
"for",
"the",
"given",
"login"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/impl/ClientSideSession.php#L177-L186
|
26,668
|
iherwig/wcmf
|
src/wcmf/lib/core/impl/ClientSideSession.php
|
ClientSideSession.getTokenData
|
protected function getTokenData() {
$result = null;
$request = ObjectFactory::getInstance('request');
$token = $request->hasHeader(self::TOKEN_HEADER) ?
trim(str_replace(self::AUTH_TYPE, '', $request->getHeader(self::TOKEN_HEADER))) : $this->token;
if ($token !== null) {
$jwt = (new Parser())->parse((string)$token);
// validate
$data = new ValidationData();
$data->setIssuer($this->getTokenIssuer());
if ($jwt->validate($data) && $jwt->verify($this->getTokenSigner(), $this->key)) {
$result = $jwt->getClaims();
}
}
return $result;
}
|
php
|
protected function getTokenData() {
$result = null;
$request = ObjectFactory::getInstance('request');
$token = $request->hasHeader(self::TOKEN_HEADER) ?
trim(str_replace(self::AUTH_TYPE, '', $request->getHeader(self::TOKEN_HEADER))) : $this->token;
if ($token !== null) {
$jwt = (new Parser())->parse((string)$token);
// validate
$data = new ValidationData();
$data->setIssuer($this->getTokenIssuer());
if ($jwt->validate($data) && $jwt->verify($this->getTokenSigner(), $this->key)) {
$result = $jwt->getClaims();
}
}
return $result;
}
|
[
"protected",
"function",
"getTokenData",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"request",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'request'",
")",
";",
"$",
"token",
"=",
"$",
"request",
"->",
"hasHeader",
"(",
"self",
"::",
"TOKEN_HEADER",
")",
"?",
"trim",
"(",
"str_replace",
"(",
"self",
"::",
"AUTH_TYPE",
",",
"''",
",",
"$",
"request",
"->",
"getHeader",
"(",
"self",
"::",
"TOKEN_HEADER",
")",
")",
")",
":",
"$",
"this",
"->",
"token",
";",
"if",
"(",
"$",
"token",
"!==",
"null",
")",
"{",
"$",
"jwt",
"=",
"(",
"new",
"Parser",
"(",
")",
")",
"->",
"parse",
"(",
"(",
"string",
")",
"$",
"token",
")",
";",
"// validate",
"$",
"data",
"=",
"new",
"ValidationData",
"(",
")",
";",
"$",
"data",
"->",
"setIssuer",
"(",
"$",
"this",
"->",
"getTokenIssuer",
"(",
")",
")",
";",
"if",
"(",
"$",
"jwt",
"->",
"validate",
"(",
"$",
"data",
")",
"&&",
"$",
"jwt",
"->",
"verify",
"(",
"$",
"this",
"->",
"getTokenSigner",
"(",
")",
",",
"$",
"this",
"->",
"key",
")",
")",
"{",
"$",
"result",
"=",
"$",
"jwt",
"->",
"getClaims",
"(",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the claims stored in the JWT
@return Associative array
|
[
"Get",
"the",
"claims",
"stored",
"in",
"the",
"JWT"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/impl/ClientSideSession.php#L208-L225
|
26,669
|
iherwig/wcmf
|
src/wcmf/lib/service/SoapServer.php
|
SoapServer.getResponseHeaders
|
public function getResponseHeaders() {
$headerStrings = headers_list();
header_remove();
$headers = [];
foreach ($headerStrings as $header) {
list($name, $value) = explode(':', $header, 2);
$headers[trim($name)] = trim($value);
}
return $headers;
}
|
php
|
public function getResponseHeaders() {
$headerStrings = headers_list();
header_remove();
$headers = [];
foreach ($headerStrings as $header) {
list($name, $value) = explode(':', $header, 2);
$headers[trim($name)] = trim($value);
}
return $headers;
}
|
[
"public",
"function",
"getResponseHeaders",
"(",
")",
"{",
"$",
"headerStrings",
"=",
"headers_list",
"(",
")",
";",
"header_remove",
"(",
")",
";",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"headerStrings",
"as",
"$",
"header",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"header",
",",
"2",
")",
";",
"$",
"headers",
"[",
"trim",
"(",
"$",
"name",
")",
"]",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Get the response headers after a call to the service method
@return Array
|
[
"Get",
"the",
"response",
"headers",
"after",
"a",
"call",
"to",
"the",
"service",
"method"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/SoapServer.php#L120-L129
|
26,670
|
iherwig/wcmf
|
src/wcmf/lib/service/SoapServer.php
|
SoapServer.doCall
|
public function doCall($action, $params) {
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("SoapServer action: ".$action);
self::$logger->debug($params);
}
$authHeader = $this->requestHeader['Security']['UsernameToken'];
$request = ObjectFactory::getInstance('request');
$request->setAction('actionSet');
$request->setFormat('soap');
$request->setResponseFormat('null');
$request->setValues([
'data' => [
'action1' => [
'action' => 'login',
'params' => [
'user' => $authHeader['Username'],
'password' => $authHeader['Password']['!']
]
],
'action2' => [
'action' => $action,
'params' => $params
],
'action3' => [
'action' => 'logout'
]
]
]);
// run the application
$actionResponse = ObjectFactory::getInstance('response');
try {
$response = $this->application->run($request);
if ($response->hasErrors()) {
$errors = $response->getErrors();
$this->handleException(new ApplicationException($request, $response, $errors[0]));
}
else {
$responseData = $response->getValue('data');
$data = $responseData['action2'];
$actionResponse->setSender($data['controller']);
$actionResponse->setContext($data['context']);
$actionResponse->setAction($data['action']);
$actionResponse->setFormat('soap');
$actionResponse->setValues($data);
$formatter = ObjectFactory::getInstance('formatter');
$formatter->serialize($actionResponse);
if (self::$logger->isDebugEnabled()) {
self::$logger->debug($actionResponse->__toString());
}
}
}
catch (\Exception $ex) {
$this->handleException($ex);
}
return $actionResponse;
}
|
php
|
public function doCall($action, $params) {
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("SoapServer action: ".$action);
self::$logger->debug($params);
}
$authHeader = $this->requestHeader['Security']['UsernameToken'];
$request = ObjectFactory::getInstance('request');
$request->setAction('actionSet');
$request->setFormat('soap');
$request->setResponseFormat('null');
$request->setValues([
'data' => [
'action1' => [
'action' => 'login',
'params' => [
'user' => $authHeader['Username'],
'password' => $authHeader['Password']['!']
]
],
'action2' => [
'action' => $action,
'params' => $params
],
'action3' => [
'action' => 'logout'
]
]
]);
// run the application
$actionResponse = ObjectFactory::getInstance('response');
try {
$response = $this->application->run($request);
if ($response->hasErrors()) {
$errors = $response->getErrors();
$this->handleException(new ApplicationException($request, $response, $errors[0]));
}
else {
$responseData = $response->getValue('data');
$data = $responseData['action2'];
$actionResponse->setSender($data['controller']);
$actionResponse->setContext($data['context']);
$actionResponse->setAction($data['action']);
$actionResponse->setFormat('soap');
$actionResponse->setValues($data);
$formatter = ObjectFactory::getInstance('formatter');
$formatter->serialize($actionResponse);
if (self::$logger->isDebugEnabled()) {
self::$logger->debug($actionResponse->__toString());
}
}
}
catch (\Exception $ex) {
$this->handleException($ex);
}
return $actionResponse;
}
|
[
"public",
"function",
"doCall",
"(",
"$",
"action",
",",
"$",
"params",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"SoapServer action: \"",
".",
"$",
"action",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"params",
")",
";",
"}",
"$",
"authHeader",
"=",
"$",
"this",
"->",
"requestHeader",
"[",
"'Security'",
"]",
"[",
"'UsernameToken'",
"]",
";",
"$",
"request",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'request'",
")",
";",
"$",
"request",
"->",
"setAction",
"(",
"'actionSet'",
")",
";",
"$",
"request",
"->",
"setFormat",
"(",
"'soap'",
")",
";",
"$",
"request",
"->",
"setResponseFormat",
"(",
"'null'",
")",
";",
"$",
"request",
"->",
"setValues",
"(",
"[",
"'data'",
"=>",
"[",
"'action1'",
"=>",
"[",
"'action'",
"=>",
"'login'",
",",
"'params'",
"=>",
"[",
"'user'",
"=>",
"$",
"authHeader",
"[",
"'Username'",
"]",
",",
"'password'",
"=>",
"$",
"authHeader",
"[",
"'Password'",
"]",
"[",
"'!'",
"]",
"]",
"]",
",",
"'action2'",
"=>",
"[",
"'action'",
"=>",
"$",
"action",
",",
"'params'",
"=>",
"$",
"params",
"]",
",",
"'action3'",
"=>",
"[",
"'action'",
"=>",
"'logout'",
"]",
"]",
"]",
")",
";",
"// run the application",
"$",
"actionResponse",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'response'",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"application",
"->",
"run",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"response",
"->",
"hasErrors",
"(",
")",
")",
"{",
"$",
"errors",
"=",
"$",
"response",
"->",
"getErrors",
"(",
")",
";",
"$",
"this",
"->",
"handleException",
"(",
"new",
"ApplicationException",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"errors",
"[",
"0",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"responseData",
"=",
"$",
"response",
"->",
"getValue",
"(",
"'data'",
")",
";",
"$",
"data",
"=",
"$",
"responseData",
"[",
"'action2'",
"]",
";",
"$",
"actionResponse",
"->",
"setSender",
"(",
"$",
"data",
"[",
"'controller'",
"]",
")",
";",
"$",
"actionResponse",
"->",
"setContext",
"(",
"$",
"data",
"[",
"'context'",
"]",
")",
";",
"$",
"actionResponse",
"->",
"setAction",
"(",
"$",
"data",
"[",
"'action'",
"]",
")",
";",
"$",
"actionResponse",
"->",
"setFormat",
"(",
"'soap'",
")",
";",
"$",
"actionResponse",
"->",
"setValues",
"(",
"$",
"data",
")",
";",
"$",
"formatter",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'formatter'",
")",
";",
"$",
"formatter",
"->",
"serialize",
"(",
"$",
"actionResponse",
")",
";",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"actionResponse",
"->",
"__toString",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"handleException",
"(",
"$",
"ex",
")",
";",
"}",
"return",
"$",
"actionResponse",
";",
"}"
] |
Process a soap call
@param $action The action
@param $params The action parameters
@return The Response instance from the executed Controller
|
[
"Process",
"a",
"soap",
"call"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/service/SoapServer.php#L154-L211
|
26,671
|
iherwig/wcmf
|
src/wcmf/application/controller/SearchIndexController.php
|
SearchIndexController.collect
|
protected function collect($types) {
$persistenceFacade = $this->getPersistenceFacade();
$nodesPerCall = $this->getRequestValue('nodesPerCall');
foreach ($types as $type) {
$oids = $persistenceFacade->getOIDs($type);
$oidLists = array_chunk($oids, self::OPTIMIZE_FREQ);
for ($i=0, $count=sizeof($oidLists); $i<$count; $i++) {
$this->addWorkPackage($this->getMessage()->getText('Indexing %0% %1% objects, starting from %2%., ', [sizeof($oids), $type, ($i*self::OPTIMIZE_FREQ+1)]),
$nodesPerCall, $oidLists[$i], 'index');
$this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
1, [0], 'optimize');
}
}
}
|
php
|
protected function collect($types) {
$persistenceFacade = $this->getPersistenceFacade();
$nodesPerCall = $this->getRequestValue('nodesPerCall');
foreach ($types as $type) {
$oids = $persistenceFacade->getOIDs($type);
$oidLists = array_chunk($oids, self::OPTIMIZE_FREQ);
for ($i=0, $count=sizeof($oidLists); $i<$count; $i++) {
$this->addWorkPackage($this->getMessage()->getText('Indexing %0% %1% objects, starting from %2%., ', [sizeof($oids), $type, ($i*self::OPTIMIZE_FREQ+1)]),
$nodesPerCall, $oidLists[$i], 'index');
$this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
1, [0], 'optimize');
}
}
}
|
[
"protected",
"function",
"collect",
"(",
"$",
"types",
")",
"{",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"$",
"nodesPerCall",
"=",
"$",
"this",
"->",
"getRequestValue",
"(",
"'nodesPerCall'",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"oids",
"=",
"$",
"persistenceFacade",
"->",
"getOIDs",
"(",
"$",
"type",
")",
";",
"$",
"oidLists",
"=",
"array_chunk",
"(",
"$",
"oids",
",",
"self",
"::",
"OPTIMIZE_FREQ",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"count",
"=",
"sizeof",
"(",
"$",
"oidLists",
")",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
"->",
"getText",
"(",
"'Indexing %0% %1% objects, starting from %2%., '",
",",
"[",
"sizeof",
"(",
"$",
"oids",
")",
",",
"$",
"type",
",",
"(",
"$",
"i",
"*",
"self",
"::",
"OPTIMIZE_FREQ",
"+",
"1",
")",
"]",
")",
",",
"$",
"nodesPerCall",
",",
"$",
"oidLists",
"[",
"$",
"i",
"]",
",",
"'index'",
")",
";",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
"->",
"getText",
"(",
"'Optimizing index'",
")",
",",
"1",
",",
"[",
"0",
"]",
",",
"'optimize'",
")",
";",
"}",
"}",
"}"
] |
Collect all oids of the given types
@param $types The types to process
@note This is a callback method called on a matching work package @see BatchController::addWorkPackage()
|
[
"Collect",
"all",
"oids",
"of",
"the",
"given",
"types"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/SearchIndexController.php#L129-L142
|
26,672
|
iherwig/wcmf
|
src/wcmf/application/controller/SearchIndexController.php
|
SearchIndexController.index
|
protected function index($oids) {
$persistenceFacade = $this->getPersistenceFacade();
foreach($oids as $oid) {
if (ObjectId::isValid($oid)) {
$obj = $persistenceFacade->load($oid);
if ($obj) {
$this->search->addToIndex($obj);
}
}
}
$this->search->commitIndex(false);
if ($this->getStepNumber() == $this->getNumberOfSteps()) {
$this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
1, [0], 'optimize');
}
}
|
php
|
protected function index($oids) {
$persistenceFacade = $this->getPersistenceFacade();
foreach($oids as $oid) {
if (ObjectId::isValid($oid)) {
$obj = $persistenceFacade->load($oid);
if ($obj) {
$this->search->addToIndex($obj);
}
}
}
$this->search->commitIndex(false);
if ($this->getStepNumber() == $this->getNumberOfSteps()) {
$this->addWorkPackage($this->getMessage()->getText('Optimizing index'),
1, [0], 'optimize');
}
}
|
[
"protected",
"function",
"index",
"(",
"$",
"oids",
")",
"{",
"$",
"persistenceFacade",
"=",
"$",
"this",
"->",
"getPersistenceFacade",
"(",
")",
";",
"foreach",
"(",
"$",
"oids",
"as",
"$",
"oid",
")",
"{",
"if",
"(",
"ObjectId",
"::",
"isValid",
"(",
"$",
"oid",
")",
")",
"{",
"$",
"obj",
"=",
"$",
"persistenceFacade",
"->",
"load",
"(",
"$",
"oid",
")",
";",
"if",
"(",
"$",
"obj",
")",
"{",
"$",
"this",
"->",
"search",
"->",
"addToIndex",
"(",
"$",
"obj",
")",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"search",
"->",
"commitIndex",
"(",
"false",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getStepNumber",
"(",
")",
"==",
"$",
"this",
"->",
"getNumberOfSteps",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addWorkPackage",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
"->",
"getText",
"(",
"'Optimizing index'",
")",
",",
"1",
",",
"[",
"0",
"]",
",",
"'optimize'",
")",
";",
"}",
"}"
] |
Create the lucene index from the given objects
@param $oids The oids to process
@note This is a callback method called on a matching work package @see BatchController::addWorkPackage()
|
[
"Create",
"the",
"lucene",
"index",
"from",
"the",
"given",
"objects"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/SearchIndexController.php#L149-L165
|
26,673
|
iherwig/wcmf
|
src/wcmf/lib/core/ErrorHandler.php
|
ErrorHandler.getStackTrace
|
public static function getStackTrace() {
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = ob_get_contents();
ob_end_clean();
// remove first item from backtrace as it's this function which is redundant.
$trace = preg_replace('/^#0\s+'.__FUNCTION__."[^\n]*\n/", '', $trace, 1);
return $trace;
}
|
php
|
public static function getStackTrace() {
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = ob_get_contents();
ob_end_clean();
// remove first item from backtrace as it's this function which is redundant.
$trace = preg_replace('/^#0\s+'.__FUNCTION__."[^\n]*\n/", '', $trace, 1);
return $trace;
}
|
[
"public",
"static",
"function",
"getStackTrace",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"debug_print_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
")",
";",
"$",
"trace",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"// remove first item from backtrace as it's this function which is redundant.",
"$",
"trace",
"=",
"preg_replace",
"(",
"'/^#0\\s+'",
".",
"__FUNCTION__",
".",
"\"[^\\n]*\\n/\"",
",",
"''",
",",
"$",
"trace",
",",
"1",
")",
";",
"return",
"$",
"trace",
";",
"}"
] |
Get the stack trace
@return The stack trace as string
|
[
"Get",
"the",
"stack",
"trace"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/ErrorHandler.php#L45-L55
|
26,674
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.getConnections
|
public static function getConnections($type, $otherRole, $otherType, $hierarchyType='all') {
$paths = [];
self::getConnectionsImpl($type, $otherRole, $otherType, $hierarchyType, $paths);
$minLength = -1;
$shortestPaths = [];
foreach ($paths as $curPath) {
$curLength = $curPath->getPathLength();
if ($minLength == -1 || $minLength > $curLength) {
$minLength = $curLength;
$shortestPaths = [$curPath];
}
elseif ($curLength == $minLength) {
$shortestPaths[] = $curPath;
}
}
return $shortestPaths;
}
|
php
|
public static function getConnections($type, $otherRole, $otherType, $hierarchyType='all') {
$paths = [];
self::getConnectionsImpl($type, $otherRole, $otherType, $hierarchyType, $paths);
$minLength = -1;
$shortestPaths = [];
foreach ($paths as $curPath) {
$curLength = $curPath->getPathLength();
if ($minLength == -1 || $minLength > $curLength) {
$minLength = $curLength;
$shortestPaths = [$curPath];
}
elseif ($curLength == $minLength) {
$shortestPaths[] = $curPath;
}
}
return $shortestPaths;
}
|
[
"public",
"static",
"function",
"getConnections",
"(",
"$",
"type",
",",
"$",
"otherRole",
",",
"$",
"otherType",
",",
"$",
"hierarchyType",
"=",
"'all'",
")",
"{",
"$",
"paths",
"=",
"[",
"]",
";",
"self",
"::",
"getConnectionsImpl",
"(",
"$",
"type",
",",
"$",
"otherRole",
",",
"$",
"otherType",
",",
"$",
"hierarchyType",
",",
"$",
"paths",
")",
";",
"$",
"minLength",
"=",
"-",
"1",
";",
"$",
"shortestPaths",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"curPath",
")",
"{",
"$",
"curLength",
"=",
"$",
"curPath",
"->",
"getPathLength",
"(",
")",
";",
"if",
"(",
"$",
"minLength",
"==",
"-",
"1",
"||",
"$",
"minLength",
">",
"$",
"curLength",
")",
"{",
"$",
"minLength",
"=",
"$",
"curLength",
";",
"$",
"shortestPaths",
"=",
"[",
"$",
"curPath",
"]",
";",
"}",
"elseif",
"(",
"$",
"curLength",
"==",
"$",
"minLength",
")",
"{",
"$",
"shortestPaths",
"[",
"]",
"=",
"$",
"curPath",
";",
"}",
"}",
"return",
"$",
"shortestPaths",
";",
"}"
] |
Get the shortest paths that connect a type to another type.
@param $type The type to start from
@param $otherRole The role of the type at the other end (maybe null, if only type shoudl match)
@param $otherType The type at the other end (maybe null, if only role shoudl match)
@param $hierarchyType The hierarchy type that the other type has in relation to this type
'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
@return An array of PathDescription instances
|
[
"Get",
"the",
"shortest",
"paths",
"that",
"connect",
"a",
"type",
"to",
"another",
"type",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L39-L55
|
26,675
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.getConnectionsImpl
|
protected static function getConnectionsImpl($type, $otherRole, $otherType,
$hierarchyType, array &$result=[], array $currentPath=[]) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$mapper = $persistenceFacade->getMapper($type);
// check relations
$relationDescs = $mapper->getRelations($hierarchyType);
foreach ($relationDescs as $relationDesc) {
// loop detection
$loopDetected = false;
foreach ($currentPath as $pathPart) {
if ($relationDesc->isSameRelation($pathPart)) {
$loopDetected = true;
break;
}
}
if ($loopDetected) {
// continue with next relation
continue;
}
$pathFound = null;
$nextType = $relationDesc->getOtherType();
$nextRole = $relationDesc->getOtherRole();
$otherTypeFq = $otherType != null ? $persistenceFacade->getFullyQualifiedType($otherType) : null;
if (($otherRole != null && $nextRole == $otherRole) || ($otherType != null && $nextType == $otherTypeFq)) {
// other end found -> terminate
$pathFound = $currentPath;
$pathFound[] = $relationDesc;
}
else {
// nothing found -> proceed with next generation
$nextCurrentPath = $currentPath;
$nextCurrentPath[] = $relationDesc;
self::getConnectionsImpl($nextType, $otherRole, $otherType, $hierarchyType, $result, $nextCurrentPath);
}
// if a path is found, add it to the result
if ($pathFound) {
$result[] = new PathDescription($pathFound);
}
}
}
|
php
|
protected static function getConnectionsImpl($type, $otherRole, $otherType,
$hierarchyType, array &$result=[], array $currentPath=[]) {
$persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
$mapper = $persistenceFacade->getMapper($type);
// check relations
$relationDescs = $mapper->getRelations($hierarchyType);
foreach ($relationDescs as $relationDesc) {
// loop detection
$loopDetected = false;
foreach ($currentPath as $pathPart) {
if ($relationDesc->isSameRelation($pathPart)) {
$loopDetected = true;
break;
}
}
if ($loopDetected) {
// continue with next relation
continue;
}
$pathFound = null;
$nextType = $relationDesc->getOtherType();
$nextRole = $relationDesc->getOtherRole();
$otherTypeFq = $otherType != null ? $persistenceFacade->getFullyQualifiedType($otherType) : null;
if (($otherRole != null && $nextRole == $otherRole) || ($otherType != null && $nextType == $otherTypeFq)) {
// other end found -> terminate
$pathFound = $currentPath;
$pathFound[] = $relationDesc;
}
else {
// nothing found -> proceed with next generation
$nextCurrentPath = $currentPath;
$nextCurrentPath[] = $relationDesc;
self::getConnectionsImpl($nextType, $otherRole, $otherType, $hierarchyType, $result, $nextCurrentPath);
}
// if a path is found, add it to the result
if ($pathFound) {
$result[] = new PathDescription($pathFound);
}
}
}
|
[
"protected",
"static",
"function",
"getConnectionsImpl",
"(",
"$",
"type",
",",
"$",
"otherRole",
",",
"$",
"otherType",
",",
"$",
"hierarchyType",
",",
"array",
"&",
"$",
"result",
"=",
"[",
"]",
",",
"array",
"$",
"currentPath",
"=",
"[",
"]",
")",
"{",
"$",
"persistenceFacade",
"=",
"ObjectFactory",
"::",
"getInstance",
"(",
"'persistenceFacade'",
")",
";",
"$",
"mapper",
"=",
"$",
"persistenceFacade",
"->",
"getMapper",
"(",
"$",
"type",
")",
";",
"// check relations",
"$",
"relationDescs",
"=",
"$",
"mapper",
"->",
"getRelations",
"(",
"$",
"hierarchyType",
")",
";",
"foreach",
"(",
"$",
"relationDescs",
"as",
"$",
"relationDesc",
")",
"{",
"// loop detection",
"$",
"loopDetected",
"=",
"false",
";",
"foreach",
"(",
"$",
"currentPath",
"as",
"$",
"pathPart",
")",
"{",
"if",
"(",
"$",
"relationDesc",
"->",
"isSameRelation",
"(",
"$",
"pathPart",
")",
")",
"{",
"$",
"loopDetected",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"loopDetected",
")",
"{",
"// continue with next relation",
"continue",
";",
"}",
"$",
"pathFound",
"=",
"null",
";",
"$",
"nextType",
"=",
"$",
"relationDesc",
"->",
"getOtherType",
"(",
")",
";",
"$",
"nextRole",
"=",
"$",
"relationDesc",
"->",
"getOtherRole",
"(",
")",
";",
"$",
"otherTypeFq",
"=",
"$",
"otherType",
"!=",
"null",
"?",
"$",
"persistenceFacade",
"->",
"getFullyQualifiedType",
"(",
"$",
"otherType",
")",
":",
"null",
";",
"if",
"(",
"(",
"$",
"otherRole",
"!=",
"null",
"&&",
"$",
"nextRole",
"==",
"$",
"otherRole",
")",
"||",
"(",
"$",
"otherType",
"!=",
"null",
"&&",
"$",
"nextType",
"==",
"$",
"otherTypeFq",
")",
")",
"{",
"// other end found -> terminate",
"$",
"pathFound",
"=",
"$",
"currentPath",
";",
"$",
"pathFound",
"[",
"]",
"=",
"$",
"relationDesc",
";",
"}",
"else",
"{",
"// nothing found -> proceed with next generation",
"$",
"nextCurrentPath",
"=",
"$",
"currentPath",
";",
"$",
"nextCurrentPath",
"[",
"]",
"=",
"$",
"relationDesc",
";",
"self",
"::",
"getConnectionsImpl",
"(",
"$",
"nextType",
",",
"$",
"otherRole",
",",
"$",
"otherType",
",",
"$",
"hierarchyType",
",",
"$",
"result",
",",
"$",
"nextCurrentPath",
")",
";",
"}",
"// if a path is found, add it to the result",
"if",
"(",
"$",
"pathFound",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"new",
"PathDescription",
"(",
"$",
"pathFound",
")",
";",
"}",
"}",
"}"
] |
Get the relations that connect a type to another type.
@param $type The type to start from
@param $otherRole The role of the type at the other end (maybe null, if only type shoudl match)
@param $otherType The type at the other end (maybe null, if only role shoudl match)
@param $hierarchyType The hierarchy type that the other type has in relation to this type
'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
@param $result Array of PathDescriptions after execution
@param $currentPath Internal use only
|
[
"Get",
"the",
"relations",
"that",
"connect",
"a",
"type",
"to",
"another",
"type",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L67-L109
|
26,676
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.getRelationQueryCondition
|
public static function getRelationQueryCondition($node, $otherRole) {
$mapper = $node->getMapper();
$relationDescription = $mapper->getRelation($otherRole);
$otherType = $relationDescription->getOtherType();
$query = new ObjectQuery($otherType, __CLASS__.__METHOD__.$node->getType().$otherRole);
// add the primary keys of the node
// using the role name as alias (avoids ambiguous paths)
$nodeTpl = $query->getObjectTemplate($node->getType(), $relationDescription->getThisRole());
$oid = $node->getOID();
$ids = $oid->getId();
$i = 0;
foreach ($mapper->getPkNames() as $pkName) {
$nodeTpl->setValue($pkName, Criteria::asValue("=", $ids[$i++]));
}
// add the other type in the given relation
$otherTpl = $query->getObjectTemplate($otherType);
$nodeTpl->addNode($otherTpl, $otherRole);
$condition = $query->getQueryCondition();
// prevent selecting all objects, if the condition is empty
if (strlen($condition) == 0) {
$condition = 0;
}
return $condition;
}
|
php
|
public static function getRelationQueryCondition($node, $otherRole) {
$mapper = $node->getMapper();
$relationDescription = $mapper->getRelation($otherRole);
$otherType = $relationDescription->getOtherType();
$query = new ObjectQuery($otherType, __CLASS__.__METHOD__.$node->getType().$otherRole);
// add the primary keys of the node
// using the role name as alias (avoids ambiguous paths)
$nodeTpl = $query->getObjectTemplate($node->getType(), $relationDescription->getThisRole());
$oid = $node->getOID();
$ids = $oid->getId();
$i = 0;
foreach ($mapper->getPkNames() as $pkName) {
$nodeTpl->setValue($pkName, Criteria::asValue("=", $ids[$i++]));
}
// add the other type in the given relation
$otherTpl = $query->getObjectTemplate($otherType);
$nodeTpl->addNode($otherTpl, $otherRole);
$condition = $query->getQueryCondition();
// prevent selecting all objects, if the condition is empty
if (strlen($condition) == 0) {
$condition = 0;
}
return $condition;
}
|
[
"public",
"static",
"function",
"getRelationQueryCondition",
"(",
"$",
"node",
",",
"$",
"otherRole",
")",
"{",
"$",
"mapper",
"=",
"$",
"node",
"->",
"getMapper",
"(",
")",
";",
"$",
"relationDescription",
"=",
"$",
"mapper",
"->",
"getRelation",
"(",
"$",
"otherRole",
")",
";",
"$",
"otherType",
"=",
"$",
"relationDescription",
"->",
"getOtherType",
"(",
")",
";",
"$",
"query",
"=",
"new",
"ObjectQuery",
"(",
"$",
"otherType",
",",
"__CLASS__",
".",
"__METHOD__",
".",
"$",
"node",
"->",
"getType",
"(",
")",
".",
"$",
"otherRole",
")",
";",
"// add the primary keys of the node",
"// using the role name as alias (avoids ambiguous paths)",
"$",
"nodeTpl",
"=",
"$",
"query",
"->",
"getObjectTemplate",
"(",
"$",
"node",
"->",
"getType",
"(",
")",
",",
"$",
"relationDescription",
"->",
"getThisRole",
"(",
")",
")",
";",
"$",
"oid",
"=",
"$",
"node",
"->",
"getOID",
"(",
")",
";",
"$",
"ids",
"=",
"$",
"oid",
"->",
"getId",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"mapper",
"->",
"getPkNames",
"(",
")",
"as",
"$",
"pkName",
")",
"{",
"$",
"nodeTpl",
"->",
"setValue",
"(",
"$",
"pkName",
",",
"Criteria",
"::",
"asValue",
"(",
"\"=\"",
",",
"$",
"ids",
"[",
"$",
"i",
"++",
"]",
")",
")",
";",
"}",
"// add the other type in the given relation",
"$",
"otherTpl",
"=",
"$",
"query",
"->",
"getObjectTemplate",
"(",
"$",
"otherType",
")",
";",
"$",
"nodeTpl",
"->",
"addNode",
"(",
"$",
"otherTpl",
",",
"$",
"otherRole",
")",
";",
"$",
"condition",
"=",
"$",
"query",
"->",
"getQueryCondition",
"(",
")",
";",
"// prevent selecting all objects, if the condition is empty",
"if",
"(",
"strlen",
"(",
"$",
"condition",
")",
"==",
"0",
")",
"{",
"$",
"condition",
"=",
"0",
";",
"}",
"return",
"$",
"condition",
";",
"}"
] |
Get the query condition used to select all related Nodes of a given role.
@param $node The Node to select the relatives for
@param $otherRole The role of the other nodes
@return The condition string to be used with StringQuery.
|
[
"Get",
"the",
"query",
"condition",
"used",
"to",
"select",
"all",
"related",
"Nodes",
"of",
"a",
"given",
"role",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L117-L141
|
26,677
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.makeNodeUrlsRelative
|
public static function makeNodeUrlsRelative(Node $node, $baseUrl, $recursive=true) {
// use NodeValueIterator to iterate over all Node values
// and call the global convert function on each
$iter = new NodeValueIterator($node, $recursive);
for($iter->rewind(); $iter->valid(); $iter->next()) {
self::makeValueUrlsRelative($iter->currentNode(), $iter->key(), $baseUrl);
}
}
|
php
|
public static function makeNodeUrlsRelative(Node $node, $baseUrl, $recursive=true) {
// use NodeValueIterator to iterate over all Node values
// and call the global convert function on each
$iter = new NodeValueIterator($node, $recursive);
for($iter->rewind(); $iter->valid(); $iter->next()) {
self::makeValueUrlsRelative($iter->currentNode(), $iter->key(), $baseUrl);
}
}
|
[
"public",
"static",
"function",
"makeNodeUrlsRelative",
"(",
"Node",
"$",
"node",
",",
"$",
"baseUrl",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"// use NodeValueIterator to iterate over all Node values",
"// and call the global convert function on each",
"$",
"iter",
"=",
"new",
"NodeValueIterator",
"(",
"$",
"node",
",",
"$",
"recursive",
")",
";",
"for",
"(",
"$",
"iter",
"->",
"rewind",
"(",
")",
";",
"$",
"iter",
"->",
"valid",
"(",
")",
";",
"$",
"iter",
"->",
"next",
"(",
")",
")",
"{",
"self",
"::",
"makeValueUrlsRelative",
"(",
"$",
"iter",
"->",
"currentNode",
"(",
")",
",",
"$",
"iter",
"->",
"key",
"(",
")",
",",
"$",
"baseUrl",
")",
";",
"}",
"}"
] |
Make all urls matching a given base url in a Node relative.
@param $node Node instance that holds the value
@param $baseUrl The baseUrl to which matching urls will be made relative
@param $recursive Boolean whether to recurse into child Nodes or not (default: true)
|
[
"Make",
"all",
"urls",
"matching",
"a",
"given",
"base",
"url",
"in",
"a",
"Node",
"relative",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L202-L209
|
26,678
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.makeValueUrlsRelative
|
private static function makeValueUrlsRelative(PersistentObject $object, $valueName, $baseUrl) {
$value = $object->getValue($valueName);
// find urls in texts
$urls = StringUtil::getUrls($value);
// find direct attribute urls
if (strpos($value, 'http://') === 0 || strpos($value, 'https://') === 0) {
$urls[] = $value;
}
// process urls
foreach ($urls as $url) {
// convert absolute urls matching baseUrl
$urlConv = $url;
if (strpos($url, $baseUrl) === 0) {
$urlConv = str_replace($baseUrl, '', $url);
}
// replace url
$value = str_replace($url, $urlConv, $value);
}
$object->setValue($valueName, $value);
}
|
php
|
private static function makeValueUrlsRelative(PersistentObject $object, $valueName, $baseUrl) {
$value = $object->getValue($valueName);
// find urls in texts
$urls = StringUtil::getUrls($value);
// find direct attribute urls
if (strpos($value, 'http://') === 0 || strpos($value, 'https://') === 0) {
$urls[] = $value;
}
// process urls
foreach ($urls as $url) {
// convert absolute urls matching baseUrl
$urlConv = $url;
if (strpos($url, $baseUrl) === 0) {
$urlConv = str_replace($baseUrl, '', $url);
}
// replace url
$value = str_replace($url, $urlConv, $value);
}
$object->setValue($valueName, $value);
}
|
[
"private",
"static",
"function",
"makeValueUrlsRelative",
"(",
"PersistentObject",
"$",
"object",
",",
"$",
"valueName",
",",
"$",
"baseUrl",
")",
"{",
"$",
"value",
"=",
"$",
"object",
"->",
"getValue",
"(",
"$",
"valueName",
")",
";",
"// find urls in texts",
"$",
"urls",
"=",
"StringUtil",
"::",
"getUrls",
"(",
"$",
"value",
")",
";",
"// find direct attribute urls",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'http://'",
")",
"===",
"0",
"||",
"strpos",
"(",
"$",
"value",
",",
"'https://'",
")",
"===",
"0",
")",
"{",
"$",
"urls",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"// process urls",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"url",
")",
"{",
"// convert absolute urls matching baseUrl",
"$",
"urlConv",
"=",
"$",
"url",
";",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"$",
"baseUrl",
")",
"===",
"0",
")",
"{",
"$",
"urlConv",
"=",
"str_replace",
"(",
"$",
"baseUrl",
",",
"''",
",",
"$",
"url",
")",
";",
"}",
"// replace url",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"url",
",",
"$",
"urlConv",
",",
"$",
"value",
")",
";",
"}",
"$",
"object",
"->",
"setValue",
"(",
"$",
"valueName",
",",
"$",
"value",
")",
";",
"}"
] |
Make the urls matching a given base url in a PersistentObject value relative.
@param $node Node instance that holds the value
@param $valueName The name of the value
@param $baseUrl The baseUrl to which matching urls will be made relative
|
[
"Make",
"the",
"urls",
"matching",
"a",
"given",
"base",
"url",
"in",
"a",
"PersistentObject",
"value",
"relative",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L217-L237
|
26,679
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.translateValues
|
public static function translateValues(&$nodes, $language=null, $itemDelim=", ") {
// translate the node values
for($i=0; $i<sizeof($nodes); $i++) {
$iter = new NodeValueIterator($nodes[$i], false);
for($iter->rewind(); $iter->valid(); $iter->next()) {
self::translateValue($iter->currentNode(), $iter->key(), $language, $itemDelim);
}
}
}
|
php
|
public static function translateValues(&$nodes, $language=null, $itemDelim=", ") {
// translate the node values
for($i=0; $i<sizeof($nodes); $i++) {
$iter = new NodeValueIterator($nodes[$i], false);
for($iter->rewind(); $iter->valid(); $iter->next()) {
self::translateValue($iter->currentNode(), $iter->key(), $language, $itemDelim);
}
}
}
|
[
"public",
"static",
"function",
"translateValues",
"(",
"&",
"$",
"nodes",
",",
"$",
"language",
"=",
"null",
",",
"$",
"itemDelim",
"=",
"\", \"",
")",
"{",
"// translate the node values",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"nodes",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"iter",
"=",
"new",
"NodeValueIterator",
"(",
"$",
"nodes",
"[",
"$",
"i",
"]",
",",
"false",
")",
";",
"for",
"(",
"$",
"iter",
"->",
"rewind",
"(",
")",
";",
"$",
"iter",
"->",
"valid",
"(",
")",
";",
"$",
"iter",
"->",
"next",
"(",
")",
")",
"{",
"self",
"::",
"translateValue",
"(",
"$",
"iter",
"->",
"currentNode",
"(",
")",
",",
"$",
"iter",
"->",
"key",
"(",
")",
",",
"$",
"language",
",",
"$",
"itemDelim",
")",
";",
"}",
"}",
"}"
] |
Translate all list values in a list of Nodes.
@note Translation in this case refers to mapping list values from the key to the value
and should not be confused with localization, although values maybe localized using the
language parameter.
@param $nodes A reference to the array of Node instances
@param $language The language code, if the translated values should be localized.
Optional, default is Localizat$objectgetDefaultLanguage()
@param $itemDelim Delimiter string for array values (optional, default: ", ")
|
[
"Translate",
"all",
"list",
"values",
"in",
"a",
"list",
"of",
"Nodes",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L249-L257
|
26,680
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.translateValue
|
public static function translateValue(PersistentObject $object, $valueName, $language, $itemDelim=", ") {
$value = $object->getValue($valueName);
// translate list values
$value = ValueListProvider::translateValue($value, $object->getValueProperty($valueName, 'input_type'), $language, $itemDelim);
// force set (the rendered value may not be satisfy validation rules)
$object->setValue($valueName, $value, true);
}
|
php
|
public static function translateValue(PersistentObject $object, $valueName, $language, $itemDelim=", ") {
$value = $object->getValue($valueName);
// translate list values
$value = ValueListProvider::translateValue($value, $object->getValueProperty($valueName, 'input_type'), $language, $itemDelim);
// force set (the rendered value may not be satisfy validation rules)
$object->setValue($valueName, $value, true);
}
|
[
"public",
"static",
"function",
"translateValue",
"(",
"PersistentObject",
"$",
"object",
",",
"$",
"valueName",
",",
"$",
"language",
",",
"$",
"itemDelim",
"=",
"\", \"",
")",
"{",
"$",
"value",
"=",
"$",
"object",
"->",
"getValue",
"(",
"$",
"valueName",
")",
";",
"// translate list values",
"$",
"value",
"=",
"ValueListProvider",
"::",
"translateValue",
"(",
"$",
"value",
",",
"$",
"object",
"->",
"getValueProperty",
"(",
"$",
"valueName",
",",
"'input_type'",
")",
",",
"$",
"language",
",",
"$",
"itemDelim",
")",
";",
"// force set (the rendered value may not be satisfy validation rules)",
"$",
"object",
"->",
"setValue",
"(",
"$",
"valueName",
",",
"$",
"value",
",",
"true",
")",
";",
"}"
] |
Translate a PersistentObject list value.
@param $object The object whose value to translate
@param $valueName The name of the value to translate
@param $language The language to use
@param $itemDelim Delimiter string for array values (optional, default: ", ")
|
[
"Translate",
"a",
"PersistentObject",
"list",
"value",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L266-L272
|
26,681
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.removeNonDisplayValues
|
public static function removeNonDisplayValues(Node $node) {
$displayValues = $node->getProperty('displayValues');
$valueNames = $node->getValueNames();
foreach($valueNames as $name) {
if (!in_array($name, $displayValues)) {
$node->removeValue($name);
}
}
}
|
php
|
public static function removeNonDisplayValues(Node $node) {
$displayValues = $node->getProperty('displayValues');
$valueNames = $node->getValueNames();
foreach($valueNames as $name) {
if (!in_array($name, $displayValues)) {
$node->removeValue($name);
}
}
}
|
[
"public",
"static",
"function",
"removeNonDisplayValues",
"(",
"Node",
"$",
"node",
")",
"{",
"$",
"displayValues",
"=",
"$",
"node",
"->",
"getProperty",
"(",
"'displayValues'",
")",
";",
"$",
"valueNames",
"=",
"$",
"node",
"->",
"getValueNames",
"(",
")",
";",
"foreach",
"(",
"$",
"valueNames",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"displayValues",
")",
")",
"{",
"$",
"node",
"->",
"removeValue",
"(",
"$",
"name",
")",
";",
"}",
"}",
"}"
] |
Remove all values from a Node that are not a display value.
@param $node The Node instance
|
[
"Remove",
"all",
"values",
"from",
"a",
"Node",
"that",
"are",
"not",
"a",
"display",
"value",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L278-L286
|
26,682
|
iherwig/wcmf
|
src/wcmf/lib/model/NodeUtil.php
|
NodeUtil.removeNonPkValues
|
public static function removeNonPkValues(Node $node) {
$mapper = $node->getMapper();
$pkValues = $mapper->getPkNames();
$valueNames = $node->getValueNames();
foreach($valueNames as $name) {
if (!in_array($name, $pkValues)) {
$node->removeValue($name);
}
}
}
|
php
|
public static function removeNonPkValues(Node $node) {
$mapper = $node->getMapper();
$pkValues = $mapper->getPkNames();
$valueNames = $node->getValueNames();
foreach($valueNames as $name) {
if (!in_array($name, $pkValues)) {
$node->removeValue($name);
}
}
}
|
[
"public",
"static",
"function",
"removeNonPkValues",
"(",
"Node",
"$",
"node",
")",
"{",
"$",
"mapper",
"=",
"$",
"node",
"->",
"getMapper",
"(",
")",
";",
"$",
"pkValues",
"=",
"$",
"mapper",
"->",
"getPkNames",
"(",
")",
";",
"$",
"valueNames",
"=",
"$",
"node",
"->",
"getValueNames",
"(",
")",
";",
"foreach",
"(",
"$",
"valueNames",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"pkValues",
")",
")",
"{",
"$",
"node",
"->",
"removeValue",
"(",
"$",
"name",
")",
";",
"}",
"}",
"}"
] |
Remove all values from a Node that are not a primary key value.
@param $node The Node instance
|
[
"Remove",
"all",
"values",
"from",
"a",
"Node",
"that",
"are",
"not",
"a",
"primary",
"key",
"value",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeUtil.php#L292-L301
|
26,683
|
iherwig/wcmf
|
src/wcmf/lib/presentation/impl/DefaultRequest.php
|
DefaultRequest.getBestRoute
|
protected function getBestRoute($routes) {
// order matching routes by number of parameters
$method = $this->getMethod();
usort($routes, function($a, $b) use ($method) {
$numParamsA = $a['numPathParameters'];
$numParamsB = $b['numPathParameters'];
if ($numParamsA == $numParamsB) {
$numPatternsA = $a['numPathPatterns'];
$numPatternsB = $b['numPathPatterns'];
if ($numPatternsA == $numPatternsB) {
$hasMethodA = in_array($method, $a['methods']);
$hasMethodB = in_array($method, $b['methods']);
return ($hasMethodA && !$hasMethodB) ? -1 :
((!$hasMethodA && $hasMethodB) ? 1 : 0);
}
// more patterns is more specific
return ($numPatternsA < $numPatternsB) ? 1 : -1;
}
// less parameters is more specific
return ($numParamsA > $numParamsB) ? 1 : -1;
});
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Ordered routes:");
self::$logger->debug($routes);
}
// return most specific route
return array_shift($routes);
}
|
php
|
protected function getBestRoute($routes) {
// order matching routes by number of parameters
$method = $this->getMethod();
usort($routes, function($a, $b) use ($method) {
$numParamsA = $a['numPathParameters'];
$numParamsB = $b['numPathParameters'];
if ($numParamsA == $numParamsB) {
$numPatternsA = $a['numPathPatterns'];
$numPatternsB = $b['numPathPatterns'];
if ($numPatternsA == $numPatternsB) {
$hasMethodA = in_array($method, $a['methods']);
$hasMethodB = in_array($method, $b['methods']);
return ($hasMethodA && !$hasMethodB) ? -1 :
((!$hasMethodA && $hasMethodB) ? 1 : 0);
}
// more patterns is more specific
return ($numPatternsA < $numPatternsB) ? 1 : -1;
}
// less parameters is more specific
return ($numParamsA > $numParamsB) ? 1 : -1;
});
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Ordered routes:");
self::$logger->debug($routes);
}
// return most specific route
return array_shift($routes);
}
|
[
"protected",
"function",
"getBestRoute",
"(",
"$",
"routes",
")",
"{",
"// order matching routes by number of parameters",
"$",
"method",
"=",
"$",
"this",
"->",
"getMethod",
"(",
")",
";",
"usort",
"(",
"$",
"routes",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"method",
")",
"{",
"$",
"numParamsA",
"=",
"$",
"a",
"[",
"'numPathParameters'",
"]",
";",
"$",
"numParamsB",
"=",
"$",
"b",
"[",
"'numPathParameters'",
"]",
";",
"if",
"(",
"$",
"numParamsA",
"==",
"$",
"numParamsB",
")",
"{",
"$",
"numPatternsA",
"=",
"$",
"a",
"[",
"'numPathPatterns'",
"]",
";",
"$",
"numPatternsB",
"=",
"$",
"b",
"[",
"'numPathPatterns'",
"]",
";",
"if",
"(",
"$",
"numPatternsA",
"==",
"$",
"numPatternsB",
")",
"{",
"$",
"hasMethodA",
"=",
"in_array",
"(",
"$",
"method",
",",
"$",
"a",
"[",
"'methods'",
"]",
")",
";",
"$",
"hasMethodB",
"=",
"in_array",
"(",
"$",
"method",
",",
"$",
"b",
"[",
"'methods'",
"]",
")",
";",
"return",
"(",
"$",
"hasMethodA",
"&&",
"!",
"$",
"hasMethodB",
")",
"?",
"-",
"1",
":",
"(",
"(",
"!",
"$",
"hasMethodA",
"&&",
"$",
"hasMethodB",
")",
"?",
"1",
":",
"0",
")",
";",
"}",
"// more patterns is more specific",
"return",
"(",
"$",
"numPatternsA",
"<",
"$",
"numPatternsB",
")",
"?",
"1",
":",
"-",
"1",
";",
"}",
"// less parameters is more specific",
"return",
"(",
"$",
"numParamsA",
">",
"$",
"numParamsB",
")",
"?",
"1",
":",
"-",
"1",
";",
"}",
")",
";",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Ordered routes:\"",
")",
";",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"routes",
")",
";",
"}",
"// return most specific route",
"return",
"array_shift",
"(",
"$",
"routes",
")",
";",
"}"
] |
Get the best matching route from the given list of routes
@param $routes Array of route definitions as returned by getMatchingRoutes()
@return Array with keys 'numPathParameters', 'parameters', 'methods'
|
[
"Get",
"the",
"best",
"matching",
"route",
"from",
"the",
"given",
"list",
"of",
"routes"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/impl/DefaultRequest.php#L333-L361
|
26,684
|
iherwig/wcmf
|
src/wcmf/lib/util/DOMUtils.php
|
DOMUtils.processHtml
|
public static function processHtml($content, callable $processor) {
$doc = new \DOMDocument();
$doc->loadHTML('<html>'.trim(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')).'</html>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$processor($doc);
return trim(str_replace(['<html>', '</html>'], '', $doc->saveHTML()));
}
|
php
|
public static function processHtml($content, callable $processor) {
$doc = new \DOMDocument();
$doc->loadHTML('<html>'.trim(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')).'</html>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$processor($doc);
return trim(str_replace(['<html>', '</html>'], '', $doc->saveHTML()));
}
|
[
"public",
"static",
"function",
"processHtml",
"(",
"$",
"content",
",",
"callable",
"$",
"processor",
")",
"{",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"$",
"doc",
"->",
"loadHTML",
"(",
"'<html>'",
".",
"trim",
"(",
"mb_convert_encoding",
"(",
"$",
"content",
",",
"'HTML-ENTITIES'",
",",
"'UTF-8'",
")",
")",
".",
"'</html>'",
",",
"LIBXML_HTML_NOIMPLIED",
"|",
"LIBXML_HTML_NODEFDTD",
")",
";",
"$",
"processor",
"(",
"$",
"doc",
")",
";",
"return",
"trim",
"(",
"str_replace",
"(",
"[",
"'<html>'",
",",
"'</html>'",
"]",
",",
"''",
",",
"$",
"doc",
"->",
"saveHTML",
"(",
")",
")",
")",
";",
"}"
] |
Process the given html fragment using the given function
@param $content Html string
@param $processor Function that accepts a DOMDocument as only parameter
@return String
|
[
"Process",
"the",
"given",
"html",
"fragment",
"using",
"the",
"given",
"function"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/util/DOMUtils.php#L25-L30
|
26,685
|
iherwig/wcmf
|
src/wcmf/lib/util/DOMUtils.php
|
DOMUtils.getChildNodesOfName
|
public static function getChildNodesOfName(\DOMElement $element, $elementName) {
$result = [];
foreach ($element->childNodes as $child) {
if ($child->nodeName == $elementName) {
$result[] = $child;
}
}
return $result;
}
|
php
|
public static function getChildNodesOfName(\DOMElement $element, $elementName) {
$result = [];
foreach ($element->childNodes as $child) {
if ($child->nodeName == $elementName) {
$result[] = $child;
}
}
return $result;
}
|
[
"public",
"static",
"function",
"getChildNodesOfName",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"$",
"elementName",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"element",
"->",
"childNodes",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"->",
"nodeName",
"==",
"$",
"elementName",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"child",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get the child nodes of a given element name
@param \DOMElement $element
@param $elementName
@return \DOMNodeList[]
|
[
"Get",
"the",
"child",
"nodes",
"of",
"a",
"given",
"element",
"name"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/util/DOMUtils.php#L38-L46
|
26,686
|
iherwig/wcmf
|
src/wcmf/lib/util/DOMUtils.php
|
DOMUtils.getNextSiblingOfType
|
public static function getNextSiblingOfType(\DOMElement $element, $elementType) {
$nextSibling = $element->nextSibling;
while ($nextSibling && $nextSibling->nodeType != $elementType) {
$nextSibling = $nextSibling->nextSibling;
}
return $nextSibling;
}
|
php
|
public static function getNextSiblingOfType(\DOMElement $element, $elementType) {
$nextSibling = $element->nextSibling;
while ($nextSibling && $nextSibling->nodeType != $elementType) {
$nextSibling = $nextSibling->nextSibling;
}
return $nextSibling;
}
|
[
"public",
"static",
"function",
"getNextSiblingOfType",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"$",
"elementType",
")",
"{",
"$",
"nextSibling",
"=",
"$",
"element",
"->",
"nextSibling",
";",
"while",
"(",
"$",
"nextSibling",
"&&",
"$",
"nextSibling",
"->",
"nodeType",
"!=",
"$",
"elementType",
")",
"{",
"$",
"nextSibling",
"=",
"$",
"nextSibling",
"->",
"nextSibling",
";",
"}",
"return",
"$",
"nextSibling",
";",
"}"
] |
Get the next sibling of the given element type
@param $element Reference element
@param $elementType Element type (e.g. XML_ELEMENT_NODE)
@return \DomElement
|
[
"Get",
"the",
"next",
"sibling",
"of",
"the",
"given",
"element",
"type"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/util/DOMUtils.php#L54-L60
|
26,687
|
iherwig/wcmf
|
src/wcmf/lib/util/DOMUtils.php
|
DOMUtils.getInnerHtml
|
public static function getInnerHtml(\DOMElement $element) {
$innerHTML= '';
$children = $element->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveXML( $child );
}
return $innerHTML;
}
|
php
|
public static function getInnerHtml(\DOMElement $element) {
$innerHTML= '';
$children = $element->childNodes;
foreach ($children as $child) {
$innerHTML .= $child->ownerDocument->saveXML( $child );
}
return $innerHTML;
}
|
[
"public",
"static",
"function",
"getInnerHtml",
"(",
"\\",
"DOMElement",
"$",
"element",
")",
"{",
"$",
"innerHTML",
"=",
"''",
";",
"$",
"children",
"=",
"$",
"element",
"->",
"childNodes",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"innerHTML",
".=",
"$",
"child",
"->",
"ownerDocument",
"->",
"saveXML",
"(",
"$",
"child",
")",
";",
"}",
"return",
"$",
"innerHTML",
";",
"}"
] |
Get the inner html string of an element
@param \DOMElement $element
@return String
|
[
"Get",
"the",
"inner",
"html",
"string",
"of",
"an",
"element"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/util/DOMUtils.php#L67-L74
|
26,688
|
iherwig/wcmf
|
src/wcmf/lib/util/DOMUtils.php
|
DOMUtils.setInnerHtml
|
public static function setInnerHtml(\DOMElement $element, $html) {
$fragment = $element->ownerDocument->createDocumentFragment();
$fragment->appendXML($html);
$element->appendChild($fragment);
}
|
php
|
public static function setInnerHtml(\DOMElement $element, $html) {
$fragment = $element->ownerDocument->createDocumentFragment();
$fragment->appendXML($html);
$element->appendChild($fragment);
}
|
[
"public",
"static",
"function",
"setInnerHtml",
"(",
"\\",
"DOMElement",
"$",
"element",
",",
"$",
"html",
")",
"{",
"$",
"fragment",
"=",
"$",
"element",
"->",
"ownerDocument",
"->",
"createDocumentFragment",
"(",
")",
";",
"$",
"fragment",
"->",
"appendXML",
"(",
"$",
"html",
")",
";",
"$",
"element",
"->",
"appendChild",
"(",
"$",
"fragment",
")",
";",
"}"
] |
Set the inner html string of an element
@param \DOMElement $element
@param $html
|
[
"Set",
"the",
"inner",
"html",
"string",
"of",
"an",
"element"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/util/DOMUtils.php#L81-L85
|
26,689
|
iherwig/wcmf
|
src/wcmf/lib/util/DOMUtils.php
|
DOMUtils.removeEmptyLines
|
public static function removeEmptyLines($html) {
// merge multiple linebreaks to one
$html = preg_replace("/(<br>\s*)+/", "<br>", $html);
// remove linebreaks at the beginning of a paragraph
$html = preg_replace("/<p>(\s|<br>)*/", "<p>", $html);
// remove linebreaks at the end of a paragraph
$html = preg_replace("/(\s|<br>)*<\/p>/", "</p>", $html);
// remove empty paragraphs
$html = preg_replace("/<p><\/p>/", "", $html);
return $html;
}
|
php
|
public static function removeEmptyLines($html) {
// merge multiple linebreaks to one
$html = preg_replace("/(<br>\s*)+/", "<br>", $html);
// remove linebreaks at the beginning of a paragraph
$html = preg_replace("/<p>(\s|<br>)*/", "<p>", $html);
// remove linebreaks at the end of a paragraph
$html = preg_replace("/(\s|<br>)*<\/p>/", "</p>", $html);
// remove empty paragraphs
$html = preg_replace("/<p><\/p>/", "", $html);
return $html;
}
|
[
"public",
"static",
"function",
"removeEmptyLines",
"(",
"$",
"html",
")",
"{",
"// merge multiple linebreaks to one",
"$",
"html",
"=",
"preg_replace",
"(",
"\"/(<br>\\s*)+/\"",
",",
"\"<br>\"",
",",
"$",
"html",
")",
";",
"// remove linebreaks at the beginning of a paragraph",
"$",
"html",
"=",
"preg_replace",
"(",
"\"/<p>(\\s|<br>)*/\"",
",",
"\"<p>\"",
",",
"$",
"html",
")",
";",
"// remove linebreaks at the end of a paragraph",
"$",
"html",
"=",
"preg_replace",
"(",
"\"/(\\s|<br>)*<\\/p>/\"",
",",
"\"</p>\"",
",",
"$",
"html",
")",
";",
"// remove empty paragraphs",
"$",
"html",
"=",
"preg_replace",
"(",
"\"/<p><\\/p>/\"",
",",
"\"\"",
",",
"$",
"html",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Remove double linebreaks and empty paragraphs
@param $content
@return String
|
[
"Remove",
"double",
"linebreaks",
"and",
"empty",
"paragraphs"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/util/DOMUtils.php#L93-L103
|
26,690
|
iherwig/wcmf
|
src/wcmf/lib/core/impl/DefaultFactory.php
|
DefaultFactory.resolveValue
|
protected function resolveValue($value) {
// special treatments, if value is a string
if (is_string($value)) {
// replace variables denoted by a leading $
if (strpos($value, '$') === 0) {
$value = $this->getInstance(preg_replace('/^\$/', '', $value));
}
else {
// convert booleans
$lower = strtolower($value);
if ($lower === 'true') {
$value = true;
}
if ($lower === 'false') {
$value = false;
}
}
}
// special treatments, if value is an array
if (is_array($value)) {
$result = [];
$containsInstance = false;
// check for variables
foreach ($value as $val) {
if (is_string($val) && strpos($val, '$') === 0) {
$result[] = $this->getInstance(preg_replace('/^\$/', '', $val));
$containsInstance = true;
}
else {
$result[] = $val;
}
}
// only replace value, if the array containes an variable
if ($containsInstance) {
$value = $result;
}
}
return $value;
}
|
php
|
protected function resolveValue($value) {
// special treatments, if value is a string
if (is_string($value)) {
// replace variables denoted by a leading $
if (strpos($value, '$') === 0) {
$value = $this->getInstance(preg_replace('/^\$/', '', $value));
}
else {
// convert booleans
$lower = strtolower($value);
if ($lower === 'true') {
$value = true;
}
if ($lower === 'false') {
$value = false;
}
}
}
// special treatments, if value is an array
if (is_array($value)) {
$result = [];
$containsInstance = false;
// check for variables
foreach ($value as $val) {
if (is_string($val) && strpos($val, '$') === 0) {
$result[] = $this->getInstance(preg_replace('/^\$/', '', $val));
$containsInstance = true;
}
else {
$result[] = $val;
}
}
// only replace value, if the array containes an variable
if ($containsInstance) {
$value = $result;
}
}
return $value;
}
|
[
"protected",
"function",
"resolveValue",
"(",
"$",
"value",
")",
"{",
"// special treatments, if value is a string",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"// replace variables denoted by a leading $",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'$'",
")",
"===",
"0",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"preg_replace",
"(",
"'/^\\$/'",
",",
"''",
",",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"// convert booleans",
"$",
"lower",
"=",
"strtolower",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"lower",
"===",
"'true'",
")",
"{",
"$",
"value",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"lower",
"===",
"'false'",
")",
"{",
"$",
"value",
"=",
"false",
";",
"}",
"}",
"}",
"// special treatments, if value is an array",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"containsInstance",
"=",
"false",
";",
"// check for variables",
"foreach",
"(",
"$",
"value",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"val",
")",
"&&",
"strpos",
"(",
"$",
"val",
",",
"'$'",
")",
"===",
"0",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"preg_replace",
"(",
"'/^\\$/'",
",",
"''",
",",
"$",
"val",
")",
")",
";",
"$",
"containsInstance",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"// only replace value, if the array containes an variable",
"if",
"(",
"$",
"containsInstance",
")",
"{",
"$",
"value",
"=",
"$",
"result",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] |
Resolve a configuration value into a parameter
@param $value
@return Mixed
|
[
"Resolve",
"a",
"configuration",
"value",
"into",
"a",
"parameter"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/impl/DefaultFactory.php#L331-L369
|
26,691
|
iherwig/wcmf
|
src/wcmf/lib/core/impl/DefaultFactory.php
|
DefaultFactory.getInterface
|
protected function getInterface($name) {
if (isset($this->requiredInterfaces[$name])) {
return $this->requiredInterfaces[$name];
}
return null;
}
|
php
|
protected function getInterface($name) {
if (isset($this->requiredInterfaces[$name])) {
return $this->requiredInterfaces[$name];
}
return null;
}
|
[
"protected",
"function",
"getInterface",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"requiredInterfaces",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"requiredInterfaces",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Get the interface that is required to be implemented by the given instance
@param $name The name of the instance
@return Interface or null, if undefined
|
[
"Get",
"the",
"interface",
"that",
"is",
"required",
"to",
"be",
"implemented",
"by",
"the",
"given",
"instance"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/impl/DefaultFactory.php#L376-L381
|
26,692
|
iherwig/wcmf
|
src/wcmf/lib/security/impl/AbstractPermissionManager.php
|
AbstractPermissionManager.serializePermissions
|
protected function serializePermissions($permissions) {
$result = $permissions['default'] === true ? PermissionManager::PERMISSION_MODIFIER_ALLOW.'* ' :
PermissionManager::PERMISSION_MODIFIER_DENY.'* ';
if (isset($permissions['allow'])) {
foreach ($permissions['allow'] as $role) {
$result .= PermissionManager::PERMISSION_MODIFIER_ALLOW.$role.' ';
}
}
if (isset($permissions['deny'])) {
foreach ($permissions['deny'] as $role) {
$result .= PermissionManager::PERMISSION_MODIFIER_DENY.$role.' ';
}
}
return trim($result);
}
|
php
|
protected function serializePermissions($permissions) {
$result = $permissions['default'] === true ? PermissionManager::PERMISSION_MODIFIER_ALLOW.'* ' :
PermissionManager::PERMISSION_MODIFIER_DENY.'* ';
if (isset($permissions['allow'])) {
foreach ($permissions['allow'] as $role) {
$result .= PermissionManager::PERMISSION_MODIFIER_ALLOW.$role.' ';
}
}
if (isset($permissions['deny'])) {
foreach ($permissions['deny'] as $role) {
$result .= PermissionManager::PERMISSION_MODIFIER_DENY.$role.' ';
}
}
return trim($result);
}
|
[
"protected",
"function",
"serializePermissions",
"(",
"$",
"permissions",
")",
"{",
"$",
"result",
"=",
"$",
"permissions",
"[",
"'default'",
"]",
"===",
"true",
"?",
"PermissionManager",
"::",
"PERMISSION_MODIFIER_ALLOW",
".",
"'* '",
":",
"PermissionManager",
"::",
"PERMISSION_MODIFIER_DENY",
".",
"'* '",
";",
"if",
"(",
"isset",
"(",
"$",
"permissions",
"[",
"'allow'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"permissions",
"[",
"'allow'",
"]",
"as",
"$",
"role",
")",
"{",
"$",
"result",
".=",
"PermissionManager",
"::",
"PERMISSION_MODIFIER_ALLOW",
".",
"$",
"role",
".",
"' '",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"permissions",
"[",
"'deny'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"permissions",
"[",
"'deny'",
"]",
"as",
"$",
"role",
")",
"{",
"$",
"result",
".=",
"PermissionManager",
"::",
"PERMISSION_MODIFIER_DENY",
".",
"$",
"role",
".",
"' '",
";",
"}",
"}",
"return",
"trim",
"(",
"$",
"result",
")",
";",
"}"
] |
Convert an associative permissions array with keys 'default', 'allow', 'deny'
into a string.
@param $permissions Associative array with keys 'default', 'allow', 'deny',
where 'allow', 'deny' are arrays itself holding roles and 'default' is a
boolean value derived from the wildcard policy (+* or -*).
@return A role string (+*, +administrators, -guest, entries without '+' or '-'
prefix default to allow rules).
|
[
"Convert",
"an",
"associative",
"permissions",
"array",
"with",
"keys",
"default",
"allow",
"deny",
"into",
"a",
"string",
"."
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/impl/AbstractPermissionManager.php#L349-L363
|
26,693
|
iherwig/wcmf
|
src/wcmf/lib/security/impl/AbstractPermissionManager.php
|
AbstractPermissionManager.matchRoles
|
protected function matchRoles($resource, $permissions, $login) {
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Matching roles for ".$login);
}
$user = $this->principalFactory->getUser($login, true);
if ($user != null) {
foreach (['allow' => true, 'deny' => false] as $key => $result) {
if (isset($permissions[$key])) {
foreach ($permissions[$key] as $role) {
if ($this->matchRole($user, $role, $resource)) {
if (self::$logger->isDebugEnabled()) {
self::$logger->debug($key." because of role ".$role);
}
return $result;
}
}
}
}
}
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Check default ".$permissions['default']);
}
return (isset($permissions['default']) ? $permissions['default'] : false);
}
|
php
|
protected function matchRoles($resource, $permissions, $login) {
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Matching roles for ".$login);
}
$user = $this->principalFactory->getUser($login, true);
if ($user != null) {
foreach (['allow' => true, 'deny' => false] as $key => $result) {
if (isset($permissions[$key])) {
foreach ($permissions[$key] as $role) {
if ($this->matchRole($user, $role, $resource)) {
if (self::$logger->isDebugEnabled()) {
self::$logger->debug($key." because of role ".$role);
}
return $result;
}
}
}
}
}
if (self::$logger->isDebugEnabled()) {
self::$logger->debug("Check default ".$permissions['default']);
}
return (isset($permissions['default']) ? $permissions['default'] : false);
}
|
[
"protected",
"function",
"matchRoles",
"(",
"$",
"resource",
",",
"$",
"permissions",
",",
"$",
"login",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Matching roles for \"",
".",
"$",
"login",
")",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"principalFactory",
"->",
"getUser",
"(",
"$",
"login",
",",
"true",
")",
";",
"if",
"(",
"$",
"user",
"!=",
"null",
")",
"{",
"foreach",
"(",
"[",
"'allow'",
"=>",
"true",
",",
"'deny'",
"=>",
"false",
"]",
"as",
"$",
"key",
"=>",
"$",
"result",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"permissions",
"[",
"$",
"key",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"permissions",
"[",
"$",
"key",
"]",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matchRole",
"(",
"$",
"user",
",",
"$",
"role",
",",
"$",
"resource",
")",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"$",
"key",
".",
"\" because of role \"",
".",
"$",
"role",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"}",
"}",
"}",
"}",
"if",
"(",
"self",
"::",
"$",
"logger",
"->",
"isDebugEnabled",
"(",
")",
")",
"{",
"self",
"::",
"$",
"logger",
"->",
"debug",
"(",
"\"Check default \"",
".",
"$",
"permissions",
"[",
"'default'",
"]",
")",
";",
"}",
"return",
"(",
"isset",
"(",
"$",
"permissions",
"[",
"'default'",
"]",
")",
"?",
"$",
"permissions",
"[",
"'default'",
"]",
":",
"false",
")",
";",
"}"
] |
Matches the roles of the user and the roles in the given permissions
@param $resource The resource string to authorize.
@param $permissions An array containing permissions as an associative array
with the keys 'default', 'allow', 'deny', where 'allow', 'deny' are arrays
itself holding roles and 'default' is a boolean value derived from the
wildcard policy (+* or -*). 'allow' overwrites 'deny' overwrites 'default'
@param $login the login of the user to match the roles for
@return Boolean whether the user is authorized according to the permissions
|
[
"Matches",
"the",
"roles",
"of",
"the",
"user",
"and",
"the",
"roles",
"in",
"the",
"given",
"permissions"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/impl/AbstractPermissionManager.php#L375-L398
|
26,694
|
iherwig/wcmf
|
src/wcmf/lib/security/impl/AbstractPermissionManager.php
|
AbstractPermissionManager.matchRole
|
protected function matchRole(User $user, $role, $resource) {
$isDynamicRole = isset($this->dynamicRoles[$role]);
return (($isDynamicRole && $this->dynamicRoles[$role]->match($user, $resource) === true)
|| (!$isDynamicRole && $user->hasRole($role)));
}
|
php
|
protected function matchRole(User $user, $role, $resource) {
$isDynamicRole = isset($this->dynamicRoles[$role]);
return (($isDynamicRole && $this->dynamicRoles[$role]->match($user, $resource) === true)
|| (!$isDynamicRole && $user->hasRole($role)));
}
|
[
"protected",
"function",
"matchRole",
"(",
"User",
"$",
"user",
",",
"$",
"role",
",",
"$",
"resource",
")",
"{",
"$",
"isDynamicRole",
"=",
"isset",
"(",
"$",
"this",
"->",
"dynamicRoles",
"[",
"$",
"role",
"]",
")",
";",
"return",
"(",
"(",
"$",
"isDynamicRole",
"&&",
"$",
"this",
"->",
"dynamicRoles",
"[",
"$",
"role",
"]",
"->",
"match",
"(",
"$",
"user",
",",
"$",
"resource",
")",
"===",
"true",
")",
"||",
"(",
"!",
"$",
"isDynamicRole",
"&&",
"$",
"user",
"->",
"hasRole",
"(",
"$",
"role",
")",
")",
")",
";",
"}"
] |
Check if a user matches the role for a resource
@param $user The user instance.
@param $role The role name.
@param $resource The resource string to authorize.
@return Boolean
|
[
"Check",
"if",
"a",
"user",
"matches",
"the",
"role",
"for",
"a",
"resource"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/impl/AbstractPermissionManager.php#L407-L411
|
26,695
|
GW2Treasures/gw2api
|
src/V2/Endpoint/Continent/MapEndpoint.php
|
MapEndpoint.poisOf
|
public function poisOf( $map ) {
return new PoiEndpoint( $this->api, $this->continent, $this->floor, $this->region, $map );
}
|
php
|
public function poisOf( $map ) {
return new PoiEndpoint( $this->api, $this->continent, $this->floor, $this->region, $map );
}
|
[
"public",
"function",
"poisOf",
"(",
"$",
"map",
")",
"{",
"return",
"new",
"PoiEndpoint",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"continent",
",",
"$",
"this",
"->",
"floor",
",",
"$",
"this",
"->",
"region",
",",
"$",
"map",
")",
";",
"}"
] |
Get the maps points of interest.
@param int $map
@return PoiEndpoint
|
[
"Get",
"the",
"maps",
"points",
"of",
"interest",
"."
] |
c8795af0c1d0a434b9e530f779d5a95786db2176
|
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Endpoint/Continent/MapEndpoint.php#L52-L54
|
26,696
|
GW2Treasures/gw2api
|
src/V2/Endpoint/Continent/MapEndpoint.php
|
MapEndpoint.tasksOf
|
public function tasksOf( $map ) {
return new TaskEndpoint( $this->api, $this->continent, $this->floor, $this->region, $map );
}
|
php
|
public function tasksOf( $map ) {
return new TaskEndpoint( $this->api, $this->continent, $this->floor, $this->region, $map );
}
|
[
"public",
"function",
"tasksOf",
"(",
"$",
"map",
")",
"{",
"return",
"new",
"TaskEndpoint",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"continent",
",",
"$",
"this",
"->",
"floor",
",",
"$",
"this",
"->",
"region",
",",
"$",
"map",
")",
";",
"}"
] |
Get the maps tasks.
@param int $map
@return TaskEndpoint
|
[
"Get",
"the",
"maps",
"tasks",
"."
] |
c8795af0c1d0a434b9e530f779d5a95786db2176
|
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Endpoint/Continent/MapEndpoint.php#L63-L65
|
26,697
|
GW2Treasures/gw2api
|
src/V2/Endpoint/Continent/MapEndpoint.php
|
MapEndpoint.sectorsOf
|
public function sectorsOf( $map ) {
return new SectorEndpoint( $this->api, $this->continent, $this->floor, $this->region, $map );
}
|
php
|
public function sectorsOf( $map ) {
return new SectorEndpoint( $this->api, $this->continent, $this->floor, $this->region, $map );
}
|
[
"public",
"function",
"sectorsOf",
"(",
"$",
"map",
")",
"{",
"return",
"new",
"SectorEndpoint",
"(",
"$",
"this",
"->",
"api",
",",
"$",
"this",
"->",
"continent",
",",
"$",
"this",
"->",
"floor",
",",
"$",
"this",
"->",
"region",
",",
"$",
"map",
")",
";",
"}"
] |
Get the maps sectors.
@param int $map
@return SectorEndpoint
|
[
"Get",
"the",
"maps",
"sectors",
"."
] |
c8795af0c1d0a434b9e530f779d5a95786db2176
|
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Endpoint/Continent/MapEndpoint.php#L74-L76
|
26,698
|
iherwig/wcmf
|
src/wcmf/lib/pdf/PDF.php
|
PDF.numberOfLines
|
public function numberOfLines($width, $text) {
$nbLines = 0;
$lines = preg_split('/\n/', $text);
foreach ($lines as $line) {
$nbLines += $this->NbLines($width, $line);
}
return $nbLines;
}
|
php
|
public function numberOfLines($width, $text) {
$nbLines = 0;
$lines = preg_split('/\n/', $text);
foreach ($lines as $line) {
$nbLines += $this->NbLines($width, $line);
}
return $nbLines;
}
|
[
"public",
"function",
"numberOfLines",
"(",
"$",
"width",
",",
"$",
"text",
")",
"{",
"$",
"nbLines",
"=",
"0",
";",
"$",
"lines",
"=",
"preg_split",
"(",
"'/\\n/'",
",",
"$",
"text",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"nbLines",
"+=",
"$",
"this",
"->",
"NbLines",
"(",
"$",
"width",
",",
"$",
"line",
")",
";",
"}",
"return",
"$",
"nbLines",
";",
"}"
] |
Computes the number of lines a MultiCell of width w will take
instead of NbLines it correctly handles linebreaks
@param $width The width
@param $text The text
|
[
"Computes",
"the",
"number",
"of",
"lines",
"a",
"MultiCell",
"of",
"width",
"w",
"will",
"take",
"instead",
"of",
"NbLines",
"it",
"correctly",
"handles",
"linebreaks"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/pdf/PDF.php#L96-L103
|
26,699
|
iherwig/wcmf
|
src/wcmf/lib/pdf/PDF.php
|
PDF.CheckPageBreak
|
public function CheckPageBreak($h) {
if($this->GetY()+$h>$this->PageBreakTrigger) {
$this->AddPage($this->CurOrientation);
return true;
}
return false;
}
|
php
|
public function CheckPageBreak($h) {
if($this->GetY()+$h>$this->PageBreakTrigger) {
$this->AddPage($this->CurOrientation);
return true;
}
return false;
}
|
[
"public",
"function",
"CheckPageBreak",
"(",
"$",
"h",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"GetY",
"(",
")",
"+",
"$",
"h",
">",
"$",
"this",
"->",
"PageBreakTrigger",
")",
"{",
"$",
"this",
"->",
"AddPage",
"(",
"$",
"this",
"->",
"CurOrientation",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
If the height h would cause an overflow, add a new page immediately
@param $h The height
@return Boolean whether a new page was inserted or not
|
[
"If",
"the",
"height",
"h",
"would",
"cause",
"an",
"overflow",
"add",
"a",
"new",
"page",
"immediately"
] |
2542b8d4139464d39a9a8ce8a954dfecf700c41b
|
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/pdf/PDF.php#L115-L121
|
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.