repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
acdh-oeaw/repo-php-util
src/acdhOeaw/util/MetadataCollection.php
MetadataCollection.filterResources
private function filterResources(string $namespace, int $singleOutNmsp): array { $result = array(); echo self::$debug ? "Filtering resources...\n" : ''; foreach ($this->resources() as $res) { echo self::$debug ? "\t" . $res->getUri() . "\n" : ''; $nonIdProps = array_diff($res->propertyUris(), array(RC::idProp())); $inNmsp = false; $ids = array(); foreach ($res->allResources(RC::idProp()) as $id) { $id = $id->getUri(); $ids[] = $id; $inNmsp = $inNmsp || strpos($id, $namespace) === 0; } if (count($ids) == 0) { echo self::$debug ? "\t\tskipping - no ids\n" : ''; } elseif ($this->fedora->isAcdhId($res->getUri())) { echo self::$debug ? "\t\tskipping - ACDH UUID\n" : ''; } elseif (count($nonIdProps) == 0 && $this->isIdElsewhere($res)) { echo self::$debug ? "\t\tskipping - single id assigned to another resource\n" : ''; } elseif (count($nonIdProps) == 0 && $singleOutNmsp !== MetadataCollection::CREATE && !$inNmsp) { echo self::$debug ? "\t\tskipping - onlyIds, outside namespace and mode == MetadataCollection::SKIP\n" : ''; } else { echo self::$debug ? "\t\tincluding\n" : ''; $result[] = $res; } } return $result; }
php
private function filterResources(string $namespace, int $singleOutNmsp): array { $result = array(); echo self::$debug ? "Filtering resources...\n" : ''; foreach ($this->resources() as $res) { echo self::$debug ? "\t" . $res->getUri() . "\n" : ''; $nonIdProps = array_diff($res->propertyUris(), array(RC::idProp())); $inNmsp = false; $ids = array(); foreach ($res->allResources(RC::idProp()) as $id) { $id = $id->getUri(); $ids[] = $id; $inNmsp = $inNmsp || strpos($id, $namespace) === 0; } if (count($ids) == 0) { echo self::$debug ? "\t\tskipping - no ids\n" : ''; } elseif ($this->fedora->isAcdhId($res->getUri())) { echo self::$debug ? "\t\tskipping - ACDH UUID\n" : ''; } elseif (count($nonIdProps) == 0 && $this->isIdElsewhere($res)) { echo self::$debug ? "\t\tskipping - single id assigned to another resource\n" : ''; } elseif (count($nonIdProps) == 0 && $singleOutNmsp !== MetadataCollection::CREATE && !$inNmsp) { echo self::$debug ? "\t\tskipping - onlyIds, outside namespace and mode == MetadataCollection::SKIP\n" : ''; } else { echo self::$debug ? "\t\tincluding\n" : ''; $result[] = $res; } } return $result; }
[ "private", "function", "filterResources", "(", "string", "$", "namespace", ",", "int", "$", "singleOutNmsp", ")", ":", "array", "{", "$", "result", "=", "array", "(", ")", ";", "echo", "self", "::", "$", "debug", "?", "\"Filtering resources...\\n\"", ":", ...
Returns set of resources to be imported skipping all other. @param string $namespace repository resources will be created for all resources in this namespace @param int $singleOutNmsp should repository resources be created representing URIs outside $namespace (MetadataCollection::SKIP or MetadataCollection::CREATE) @return array
[ "Returns", "set", "of", "resources", "to", "be", "imported", "skipping", "all", "other", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/MetadataCollection.php#L235-L266
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/MetadataCollection.php
MetadataCollection.promoteUrisToIds
private function promoteUrisToIds() { echo self::$debug ? "Promoting URIs to ids...\n" : ''; foreach ($this->resources() as $i) { if (!$i->isBNode()) { echo self::$debug ? "\t" . $i->getUri() . "\n" : ''; $i->addResource(RC::idProp(), $i->getUri()); } } }
php
private function promoteUrisToIds() { echo self::$debug ? "Promoting URIs to ids...\n" : ''; foreach ($this->resources() as $i) { if (!$i->isBNode()) { echo self::$debug ? "\t" . $i->getUri() . "\n" : ''; $i->addResource(RC::idProp(), $i->getUri()); } } }
[ "private", "function", "promoteUrisToIds", "(", ")", "{", "echo", "self", "::", "$", "debug", "?", "\"Promoting URIs to ids...\\n\"", ":", "''", ";", "foreach", "(", "$", "this", "->", "resources", "(", ")", "as", "$", "i", ")", "{", "if", "(", "!", "$...
Promotes subjects being fully qualified URLs to ids.
[ "Promotes", "subjects", "being", "fully", "qualified", "URLs", "to", "ids", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/MetadataCollection.php#L383-L391
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/MetadataCollection.php
MetadataCollection.sanitizeResource
private function sanitizeResource(Resource $res, string $namespace): Resource { $nonIdProps = array_diff($res->propertyUris(), array(RC::idProp())); if (count($nonIdProps) == 0) { // don't do anything when it's purely-id resource return $res; } $this->fedora->fixMetadataReferences($res); if ($this->containsWrongRefs($res, $namespace)) { echo $res->copy()->getGraph()->serialise('ntriples') . "\n"; throw new InvalidArgumentException('resource contains references to blank nodes'); } if (count($res->allLiterals(RC::titleProp())) == 0) { $res->addLiteral(RC::titleProp(), $res->getResource(RC::idProp())); } if ($res->isA('http://xmlns.com/foaf/0.1/Person') || $res->isA('http://xmlns.com/foaf/0.1/Agent')) { $res = self::makeAgent($res); } if ($this->resource !== null) { $res->addResource(RC::relProp(), $this->resource->getId()); } return $res; }
php
private function sanitizeResource(Resource $res, string $namespace): Resource { $nonIdProps = array_diff($res->propertyUris(), array(RC::idProp())); if (count($nonIdProps) == 0) { // don't do anything when it's purely-id resource return $res; } $this->fedora->fixMetadataReferences($res); if ($this->containsWrongRefs($res, $namespace)) { echo $res->copy()->getGraph()->serialise('ntriples') . "\n"; throw new InvalidArgumentException('resource contains references to blank nodes'); } if (count($res->allLiterals(RC::titleProp())) == 0) { $res->addLiteral(RC::titleProp(), $res->getResource(RC::idProp())); } if ($res->isA('http://xmlns.com/foaf/0.1/Person') || $res->isA('http://xmlns.com/foaf/0.1/Agent')) { $res = self::makeAgent($res); } if ($this->resource !== null) { $res->addResource(RC::relProp(), $this->resource->getId()); } return $res; }
[ "private", "function", "sanitizeResource", "(", "Resource", "$", "res", ",", "string", "$", "namespace", ")", ":", "Resource", "{", "$", "nonIdProps", "=", "array_diff", "(", "$", "res", "->", "propertyUris", "(", ")", ",", "array", "(", "RC", "::", "idP...
Cleans up resource metadata. @param Resource $res @param string $namespace @return Resource @throws InvalidArgumentException
[ "Cleans", "up", "resource", "metadata", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/MetadataCollection.php#L401-L428
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/MetadataCollection.php
MetadataCollection.removeLiteralIds
private function removeLiteralIds() { echo self::$debug ? "Removing literal ids...\n" : ""; foreach ($this->resources() as $i) { foreach ($i->allLiterals(RC::idProp()) as $j) { $i->delete(RC::idProp(), $j); if (self::$debug) { echo "\tremoved " . $j . " from " . $i->getUri() . "\n"; } } } }
php
private function removeLiteralIds() { echo self::$debug ? "Removing literal ids...\n" : ""; foreach ($this->resources() as $i) { foreach ($i->allLiterals(RC::idProp()) as $j) { $i->delete(RC::idProp(), $j); if (self::$debug) { echo "\tremoved " . $j . " from " . $i->getUri() . "\n"; } } } }
[ "private", "function", "removeLiteralIds", "(", ")", "{", "echo", "self", "::", "$", "debug", "?", "\"Removing literal ids...\\n\"", ":", "\"\"", ";", "foreach", "(", "$", "this", "->", "resources", "(", ")", "as", "$", "i", ")", "{", "foreach", "(", "$"...
Removes literal ids from the graph.
[ "Removes", "literal", "ids", "from", "the", "graph", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/MetadataCollection.php#L433-L444
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/acl/WebAcl.php
WebAcl.save
public function save() { foreach ($this->resRules as $i) { $i->save($this->res->getAclUrl()); } }
php
public function save() { foreach ($this->resRules as $i) { $i->save($this->res->getAclUrl()); } }
[ "public", "function", "save", "(", ")", "{", "foreach", "(", "$", "this", "->", "resRules", "as", "$", "i", ")", "{", "$", "i", "->", "save", "(", "$", "this", "->", "res", "->", "getAclUrl", "(", ")", ")", ";", "}", "}" ]
Manually triggers synchronization of all stored `WebAclRule` objects with the Fedora. @see setAutocommit()
[ "Manually", "triggers", "synchronization", "of", "all", "stored", "WebAclRule", "objects", "with", "the", "Fedora", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/acl/WebAcl.php#L203-L207
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/acl/WebAcl.php
WebAcl.revokeAll
public function revokeAll(int $mode = WebAclRule::READ): WebAcl { WebAclRule::checkMode($mode); if ($mode == WebAclRule::WRITE) { foreach ($this->resRules as $i) { $i->setMode(WebAclRule::READ); if (self::$autosave) { $i->save($this->res->getAclUrl()); } } } else { foreach ($this->resRules as $i) { $i->delete(true); } $this->resRules = array(); } return $this; }
php
public function revokeAll(int $mode = WebAclRule::READ): WebAcl { WebAclRule::checkMode($mode); if ($mode == WebAclRule::WRITE) { foreach ($this->resRules as $i) { $i->setMode(WebAclRule::READ); if (self::$autosave) { $i->save($this->res->getAclUrl()); } } } else { foreach ($this->resRules as $i) { $i->delete(true); } $this->resRules = array(); } return $this; }
[ "public", "function", "revokeAll", "(", "int", "$", "mode", "=", "WebAclRule", "::", "READ", ")", ":", "WebAcl", "{", "WebAclRule", "::", "checkMode", "(", "$", "mode", ")", ";", "if", "(", "$", "mode", "==", "WebAclRule", "::", "WRITE", ")", "{", "f...
Revokes privileges from all users, groups and classes for a given Fedora resource. Only rules directly targeting the given resource are removed. Rules inherited from Fedora parents sharing the same ACL are not affected. If `$mode` equals to `WebAclRule::WRITE` all privileges are limited to `WebAclRule::READ`. If `$mode` equals to `WebAclRule::READ` all privileges are revoked. @param int $mode WebAclRule::READ or WebAclRule::WRITE @return \acdhOeaw\fedora\acl\WebAcl
[ "Revokes", "privileges", "from", "all", "users", "groups", "and", "classes", "for", "a", "given", "Fedora", "resource", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/acl/WebAcl.php#L223-L241
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/acl/WebAcl.php
WebAcl.getRules
public function getRules(bool $inherited = true): array { $ret = array(); foreach ($this->resRules as $i) { $ret[] = $i->getData(); } if ($inherited) { foreach ($this->extRules as $i) { $ret[] = $i->getData(); } } return $ret; }
php
public function getRules(bool $inherited = true): array { $ret = array(); foreach ($this->resRules as $i) { $ret[] = $i->getData(); } if ($inherited) { foreach ($this->extRules as $i) { $ret[] = $i->getData(); } } return $ret; }
[ "public", "function", "getRules", "(", "bool", "$", "inherited", "=", "true", ")", ":", "array", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "resRules", "as", "$", "i", ")", "{", "$", "ret", "[", "]", "=", "...
Fetches an array of `WebAclRule` objects containing access rules for a corresponding Fedora resource. @param bool $inherited should rules inherited from parent (in Fedora terms) resources be taken into account? @return array
[ "Fetches", "an", "array", "of", "WebAclRule", "objects", "containing", "access", "rules", "for", "a", "corresponding", "Fedora", "resource", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/acl/WebAcl.php#L376-L387
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/acl/WebAcl.php
WebAcl.reload
public function reload(): WebAcl { $fedora = $this->res->getFedora(); $resUri = $this->res->getUri(true); $aclUri = $this->res->getAclUrl(); $this->resRules = []; $this->extRules = []; if ($aclUri) { $query = new SimpleQuery(self::QUERY, [$resUri, $aclUri]); $results = $fedora->runQuery($query); $rules = self::initRules($results, $fedora, $aclUri); foreach ($rules as $r) { if ($r->hasResource($resUri)) { $this->resRules[] = $r; } else { $this->extRules[] = $r; } } } return $this; }
php
public function reload(): WebAcl { $fedora = $this->res->getFedora(); $resUri = $this->res->getUri(true); $aclUri = $this->res->getAclUrl(); $this->resRules = []; $this->extRules = []; if ($aclUri) { $query = new SimpleQuery(self::QUERY, [$resUri, $aclUri]); $results = $fedora->runQuery($query); $rules = self::initRules($results, $fedora, $aclUri); foreach ($rules as $r) { if ($r->hasResource($resUri)) { $this->resRules[] = $r; } else { $this->extRules[] = $r; } } } return $this; }
[ "public", "function", "reload", "(", ")", ":", "WebAcl", "{", "$", "fedora", "=", "$", "this", "->", "res", "->", "getFedora", "(", ")", ";", "$", "resUri", "=", "$", "this", "->", "res", "->", "getUri", "(", "true", ")", ";", "$", "aclUri", "=",...
Reloads access rules by quering a triplestore. See class description for use cases.
[ "Reloads", "access", "rules", "by", "quering", "a", "triplestore", ".", "See", "class", "description", "for", "use", "cases", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/acl/WebAcl.php#L393-L413
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/acl/WebAcl.php
WebAcl.createAcl
public function createAcl(): WebAcl { $resMeta = $this->res->getMetadata(true); $acls = $resMeta->allResources(self::ACL_LINK_PROP); if (count($acls) > 1) { throw new RuntimeException('Resource has many ACLs'); } else if (count($acls) > 0) { return $this; } try { $location = RC::get('fedoraAclUri'); } catch (InvalidArgumentException $ex) { $location = '/'; } $aclMeta = (new Graph())->resource('.'); $aclMeta->addType(self::ACL_CLASS); $aclMeta->addLiteral(RC::titleProp(), 'ACL'); $id = preg_replace('|^[^:]+|', 'acl', $this->res->getUri(true)); $aclMeta->addResource(RC::idProp(), $id); // Link to ACL is applied after the transaction commit, so we need // a separate transaction not to affect the current one // As a side effect the resource for which an ACL is created has to // persistently exist in the repository already! $fedoraTmp = clone($this->res->getFedora()); $fedoraTmp->__clearCache(); $fedoraTmp->begin(); $aclRes = $fedoraTmp->createResource($aclMeta, '', $location, 'POST'); $resMeta->addResource(self::ACL_LINK_PROP, $aclRes->getUri(true)); try { $resTmp = $fedoraTmp->getResourceByUri($this->res->getUri()); $resTmp->setMetadata($resMeta); $resTmp->updateMetadata(); $fedoraTmp->commit(); } catch (NotFound $e) { $fedoraTmp->rollback(); } //sleep(1); //TODO $this->res->getMetadata(true); if ($this->res->getAclUrl() !== $aclRes->getUri(true)) { // second try for binary resources which are not handled properly by Fedora if ($this->res->getAclUrl(true) !== $aclRes->getUri(true)) { throw new RuntimeException('ACL creation failed'); } } foreach ($this->resRules as $h => $i) { $i->move($aclRes->getUri(true) . '/' . $h); } return $this; }
php
public function createAcl(): WebAcl { $resMeta = $this->res->getMetadata(true); $acls = $resMeta->allResources(self::ACL_LINK_PROP); if (count($acls) > 1) { throw new RuntimeException('Resource has many ACLs'); } else if (count($acls) > 0) { return $this; } try { $location = RC::get('fedoraAclUri'); } catch (InvalidArgumentException $ex) { $location = '/'; } $aclMeta = (new Graph())->resource('.'); $aclMeta->addType(self::ACL_CLASS); $aclMeta->addLiteral(RC::titleProp(), 'ACL'); $id = preg_replace('|^[^:]+|', 'acl', $this->res->getUri(true)); $aclMeta->addResource(RC::idProp(), $id); // Link to ACL is applied after the transaction commit, so we need // a separate transaction not to affect the current one // As a side effect the resource for which an ACL is created has to // persistently exist in the repository already! $fedoraTmp = clone($this->res->getFedora()); $fedoraTmp->__clearCache(); $fedoraTmp->begin(); $aclRes = $fedoraTmp->createResource($aclMeta, '', $location, 'POST'); $resMeta->addResource(self::ACL_LINK_PROP, $aclRes->getUri(true)); try { $resTmp = $fedoraTmp->getResourceByUri($this->res->getUri()); $resTmp->setMetadata($resMeta); $resTmp->updateMetadata(); $fedoraTmp->commit(); } catch (NotFound $e) { $fedoraTmp->rollback(); } //sleep(1); //TODO $this->res->getMetadata(true); if ($this->res->getAclUrl() !== $aclRes->getUri(true)) { // second try for binary resources which are not handled properly by Fedora if ($this->res->getAclUrl(true) !== $aclRes->getUri(true)) { throw new RuntimeException('ACL creation failed'); } } foreach ($this->resRules as $h => $i) { $i->move($aclRes->getUri(true) . '/' . $h); } return $this; }
[ "public", "function", "createAcl", "(", ")", ":", "WebAcl", "{", "$", "resMeta", "=", "$", "this", "->", "res", "->", "getMetadata", "(", "true", ")", ";", "$", "acls", "=", "$", "resMeta", "->", "allResources", "(", "self", "::", "ACL_LINK_PROP", ")",...
Creates an ACL attached directly to a given resource. All rules describing resource from ACL currently in effect are automatically moved to the newly created ACL. Resource has to permanently exist in the repository for operation to succeed (you can not create a resource's ACL within the same transaction a resource was created). If it is not a case, a `NotFound` exception is rised. If an ACL attached directly to the resource already exists, nothing happens. @throws \RuntimeException
[ "Creates", "an", "ACL", "attached", "directly", "to", "a", "given", "resource", ".", "All", "rules", "describing", "resource", "from", "ACL", "currently", "in", "effect", "are", "automatically", "moved", "to", "the", "newly", "created", "ACL", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/acl/WebAcl.php#L429-L482
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/acl/WebAcl.php
WebAcl.deleteAcl
public function deleteAcl(): WebAcl { $fedora = $this->res->getFedora(); $resMeta = $this->res->getMetadata(); $acls = $resMeta->allResources(self::ACL_LINK_PROP); if (count($acls) == 0) { throw new NotFound(); } foreach ($acls as $i) { $aclRes = $fedora->getResourceByUri($i); $aclMeta = $aclRes->getMetadata(); foreach ($aclMeta->allResources(self::ACL_CHILDREN_PROP) as $j) { $fedora->getResourceByUri($j->getUri())->delete(); } $aclRes->getMetadata(true); // notify children were deleted $aclRes->delete(true, false); } $resMeta->deleteResource(self::ACL_LINK_PROP); $this->res->setMetadata($resMeta); $this->res->updateMetadata(); $this->res->getAclUrl(true); $this->resRules = $this->extRules = []; return $this; }
php
public function deleteAcl(): WebAcl { $fedora = $this->res->getFedora(); $resMeta = $this->res->getMetadata(); $acls = $resMeta->allResources(self::ACL_LINK_PROP); if (count($acls) == 0) { throw new NotFound(); } foreach ($acls as $i) { $aclRes = $fedora->getResourceByUri($i); $aclMeta = $aclRes->getMetadata(); foreach ($aclMeta->allResources(self::ACL_CHILDREN_PROP) as $j) { $fedora->getResourceByUri($j->getUri())->delete(); } $aclRes->getMetadata(true); // notify children were deleted $aclRes->delete(true, false); } $resMeta->deleteResource(self::ACL_LINK_PROP); $this->res->setMetadata($resMeta); $this->res->updateMetadata(); $this->res->getAclUrl(true); $this->resRules = $this->extRules = []; return $this; }
[ "public", "function", "deleteAcl", "(", ")", ":", "WebAcl", "{", "$", "fedora", "=", "$", "this", "->", "res", "->", "getFedora", "(", ")", ";", "$", "resMeta", "=", "$", "this", "->", "res", "->", "getMetadata", "(", ")", ";", "$", "acls", "=", ...
Removes ACL directly attached to this resource. If there is no such ACL, error is thrown. @return \acdhOeaw\fedora\acl\WebAcl @throws NotFound
[ "Removes", "ACL", "directly", "attached", "to", "this", "resource", ".", "If", "there", "is", "no", "such", "ACL", "error", "is", "thrown", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/acl/WebAcl.php#L490-L514
train
locomotivemtl/charcoal-ui
src/Charcoal/Ui/Dashboard/DashboardTrait.php
DashboardTrait.setWidgetBuilder
protected function setWidgetBuilder($builder) { if (is_object($builder)) { $this->widgetBuilder = $builder; } else { throw new InvalidArgumentException( sprintf( 'Argument must be a widget builder, %s given', (is_object($builder) ? get_class($builder) : gettype($builder)) ) ); } return $this; }
php
protected function setWidgetBuilder($builder) { if (is_object($builder)) { $this->widgetBuilder = $builder; } else { throw new InvalidArgumentException( sprintf( 'Argument must be a widget builder, %s given', (is_object($builder) ? get_class($builder) : gettype($builder)) ) ); } return $this; }
[ "protected", "function", "setWidgetBuilder", "(", "$", "builder", ")", "{", "if", "(", "is_object", "(", "$", "builder", ")", ")", "{", "$", "this", "->", "widgetBuilder", "=", "$", "builder", ";", "}", "else", "{", "throw", "new", "InvalidArgumentExceptio...
Set a widget builder. @param object $builder The builder to create customized widget objects. @throws InvalidArgumentException If the argument is not a widget builder. @return DashboardInterface Chainable
[ "Set", "a", "widget", "builder", "." ]
0070f35d89ea24ae93720734d261c02a10e218b6
https://github.com/locomotivemtl/charcoal-ui/blob/0070f35d89ea24ae93720734d261c02a10e218b6/src/Charcoal/Ui/Dashboard/DashboardTrait.php#L59-L73
train
locomotivemtl/charcoal-ui
src/Charcoal/Ui/Dashboard/DashboardTrait.php
DashboardTrait.setWidgets
public function setWidgets(array $widgets) { $this->widgets = []; foreach ($widgets as $widgetIdent => $widget) { $this->addWidget($widgetIdent, $widget); } return $this; }
php
public function setWidgets(array $widgets) { $this->widgets = []; foreach ($widgets as $widgetIdent => $widget) { $this->addWidget($widgetIdent, $widget); } return $this; }
[ "public", "function", "setWidgets", "(", "array", "$", "widgets", ")", "{", "$", "this", "->", "widgets", "=", "[", "]", ";", "foreach", "(", "$", "widgets", "as", "$", "widgetIdent", "=>", "$", "widget", ")", "{", "$", "this", "->", "addWidget", "("...
Set the dashboard's widgets. @param array $widgets A collection of widgets. @return DashboardInterface Chainable
[ "Set", "the", "dashboard", "s", "widgets", "." ]
0070f35d89ea24ae93720734d261c02a10e218b6
https://github.com/locomotivemtl/charcoal-ui/blob/0070f35d89ea24ae93720734d261c02a10e218b6/src/Charcoal/Ui/Dashboard/DashboardTrait.php#L111-L120
train
locomotivemtl/charcoal-ui
src/Charcoal/Ui/Dashboard/DashboardTrait.php
DashboardTrait.addWidget
public function addWidget($widgetIdent, $widget) { if (!is_string($widgetIdent)) { throw new InvalidArgumentException( 'Widget identifier needs to be a string' ); } if ($widget instanceof UiItemInterface) { $this->widgets[$widgetIdent] = $widget; } elseif (is_array($widget)) { if (!isset($widget['ident'])) { $widget['ident'] = $widgetIdent; } $w = $this->widgetBuilder->build($widget); $this->widgets[$widgetIdent] = $w; } else { throw new InvalidArgumentException( 'Can not add widget: Invalid Widget.' ); } return $this; }
php
public function addWidget($widgetIdent, $widget) { if (!is_string($widgetIdent)) { throw new InvalidArgumentException( 'Widget identifier needs to be a string' ); } if ($widget instanceof UiItemInterface) { $this->widgets[$widgetIdent] = $widget; } elseif (is_array($widget)) { if (!isset($widget['ident'])) { $widget['ident'] = $widgetIdent; } $w = $this->widgetBuilder->build($widget); $this->widgets[$widgetIdent] = $w; } else { throw new InvalidArgumentException( 'Can not add widget: Invalid Widget.' ); } return $this; }
[ "public", "function", "addWidget", "(", "$", "widgetIdent", ",", "$", "widget", ")", "{", "if", "(", "!", "is_string", "(", "$", "widgetIdent", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Widget identifier needs to be a string'", ")", ";", ...
Add a widget to the dashboard. If a widget with the same $widgetIdent already exists, it will be overridden. @param string $widgetIdent The widget identifier. @param UiItemInterface|array $widget The widget object or structure. @throws InvalidArgumentException If the widget is invalid. @return DashboardInterface Chainable
[ "Add", "a", "widget", "to", "the", "dashboard", "." ]
0070f35d89ea24ae93720734d261c02a10e218b6
https://github.com/locomotivemtl/charcoal-ui/blob/0070f35d89ea24ae93720734d261c02a10e218b6/src/Charcoal/Ui/Dashboard/DashboardTrait.php#L132-L157
train
polyfony-inc/polyfony
Private/Polyfony/Keys.php
Keys.generate
public static function generate($mixed=null) { // create a sha1 signature of the array with a salt $hash = hash( Config::get('keys', 'algo'), json_encode(array($mixed, Config::get('keys', 'salt')), JSON_NUMERIC_CHECK) ); // get last 10 and first 10 chars together, convert to uppercase, return the key return(strtoupper(substr($hash, -10) . substr($hash, 0, 10))); }
php
public static function generate($mixed=null) { // create a sha1 signature of the array with a salt $hash = hash( Config::get('keys', 'algo'), json_encode(array($mixed, Config::get('keys', 'salt')), JSON_NUMERIC_CHECK) ); // get last 10 and first 10 chars together, convert to uppercase, return the key return(strtoupper(substr($hash, -10) . substr($hash, 0, 10))); }
[ "public", "static", "function", "generate", "(", "$", "mixed", "=", "null", ")", "{", "// create a sha1 signature of the array with a salt", "$", "hash", "=", "hash", "(", "Config", "::", "get", "(", "'keys'", ",", "'algo'", ")", ",", "json_encode", "(", "arra...
generate a key
[ "generate", "a", "key" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Keys.php#L8-L16
train
polyfony-inc/polyfony
Private/Polyfony/Keys.php
Keys.compare
public static function compare($key=null, $mixed=null) { // if no key is provided if(!$key || strlen($key) != 20) { // return false return(false); } // if keys do match return(self::generate($mixed) == $key ?: false); }
php
public static function compare($key=null, $mixed=null) { // if no key is provided if(!$key || strlen($key) != 20) { // return false return(false); } // if keys do match return(self::generate($mixed) == $key ?: false); }
[ "public", "static", "function", "compare", "(", "$", "key", "=", "null", ",", "$", "mixed", "=", "null", ")", "{", "// if no key is provided", "if", "(", "!", "$", "key", "||", "strlen", "(", "$", "key", ")", "!=", "20", ")", "{", "// return false", ...
compare a key with a new dynamically generated one
[ "compare", "a", "key", "with", "a", "new", "dynamically", "generated", "one" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Keys.php#L19-L27
train
secucard/secucard-connect-php-sdk
src/SecucardConnect/Product/Services/IdentRequestsService.php
IdentRequestsService.process
private function process(IdentRequest &$request) { if (isset($request->person)) { foreach ($request->person as $p) { $contact = $p->contact; if (!empty($contact) && !empty($contact->picture)) { $contact->pictureObject = $this->initMediaResource($contact->picture); } } } }
php
private function process(IdentRequest &$request) { if (isset($request->person)) { foreach ($request->person as $p) { $contact = $p->contact; if (!empty($contact) && !empty($contact->picture)) { $contact->pictureObject = $this->initMediaResource($contact->picture); } } } }
[ "private", "function", "process", "(", "IdentRequest", "&", "$", "request", ")", "{", "if", "(", "isset", "(", "$", "request", "->", "person", ")", ")", "{", "foreach", "(", "$", "request", "->", "person", "as", "$", "p", ")", "{", "$", "contact", ...
Handles proper contact picture initialization after retrieval of a ident request. @param IdentRequest $request
[ "Handles", "proper", "contact", "picture", "initialization", "after", "retrieval", "of", "a", "ident", "request", "." ]
d990686095e4e02d0924fc12b9bf60140fe8efab
https://github.com/secucard/secucard-connect-php-sdk/blob/d990686095e4e02d0924fc12b9bf60140fe8efab/src/SecucardConnect/Product/Services/IdentRequestsService.php#L42-L52
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/dissemination/Service.php
Service.addParameter
public function addParameter(string $name, string $defaultValue = '', string $rdfProperty = '_') { $id = $this->getId() . '/param/' . $name; $this->params[] = new Parameter( $this->fedora, $id, $this, $name, $defaultValue, $rdfProperty ); }
php
public function addParameter(string $name, string $defaultValue = '', string $rdfProperty = '_') { $id = $this->getId() . '/param/' . $name; $this->params[] = new Parameter( $this->fedora, $id, $this, $name, $defaultValue, $rdfProperty ); }
[ "public", "function", "addParameter", "(", "string", "$", "name", ",", "string", "$", "defaultValue", "=", "''", ",", "string", "$", "rdfProperty", "=", "'_'", ")", "{", "$", "id", "=", "$", "this", "->", "getId", "(", ")", ".", "'/param/'", ".", "$"...
Defines a dissemination service parameter. @param string $name parameter name @param string $defaultValue default parameter value @param string $rdfProperty RDF property holding parameter value in resources' metadata
[ "Defines", "a", "dissemination", "service", "parameter", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/dissemination/Service.php#L146-L152
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/dissemination/Service.php
Service.addMatch
public function addMatch(string $property, string $value, bool $required) { $id = $this->getid() . '/match/' . (count($this->matches) + 1); $this->matches[] = new Match($this->fedora, $id, $this, $property, $value, $required); }
php
public function addMatch(string $property, string $value, bool $required) { $id = $this->getid() . '/match/' . (count($this->matches) + 1); $this->matches[] = new Match($this->fedora, $id, $this, $property, $value, $required); }
[ "public", "function", "addMatch", "(", "string", "$", "property", ",", "string", "$", "value", ",", "bool", "$", "required", ")", "{", "$", "id", "=", "$", "this", "->", "getid", "(", ")", ".", "'/match/'", ".", "(", "count", "(", "$", "this", "->"...
Defines a matching rule for the dissemination service @param string $property RDF property to be checked in resource's metadata @param string $value expected RDF property value in resource's metadata @param bool $required is this match rule compulsory? @see \acdhOeaw\schema\dissemination\Match
[ "Defines", "a", "matching", "rule", "for", "the", "dissemination", "service" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/dissemination/Service.php#L161-L164
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/dissemination/Service.php
Service.getMetadata
public function getMetadata(): Resource { $meta = (new Graph())->resource('.'); $meta->addType(RC::get('fedoraServiceClass')); $meta->addResource(RC::idProp(), $this->getId()); $meta->addLiteral(RC::titleProp(), $this->getId()); $meta->addLiteral(RC::get('fedoraServiceLocProp'), $this->location); $retProp = RC::get('fedoraServiceRetFormatProp'); foreach ($this->format as $i) { $meta->addLiteral($retProp, $i); } $meta->addLiteral(RC::get('fedoraServiceRevProxyProp'), $this->revProxy); return $meta; }
php
public function getMetadata(): Resource { $meta = (new Graph())->resource('.'); $meta->addType(RC::get('fedoraServiceClass')); $meta->addResource(RC::idProp(), $this->getId()); $meta->addLiteral(RC::titleProp(), $this->getId()); $meta->addLiteral(RC::get('fedoraServiceLocProp'), $this->location); $retProp = RC::get('fedoraServiceRetFormatProp'); foreach ($this->format as $i) { $meta->addLiteral($retProp, $i); } $meta->addLiteral(RC::get('fedoraServiceRevProxyProp'), $this->revProxy); return $meta; }
[ "public", "function", "getMetadata", "(", ")", ":", "Resource", "{", "$", "meta", "=", "(", "new", "Graph", "(", ")", ")", "->", "resource", "(", "'.'", ")", ";", "$", "meta", "->", "addType", "(", "RC", "::", "get", "(", "'fedoraServiceClass'", ")",...
Returns metadata describing the dissemination service. @return Resource
[ "Returns", "metadata", "describing", "the", "dissemination", "service", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/dissemination/Service.php#L170-L189
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/dissemination/Service.php
Service.updateRms
public function updateRms(bool $create = true, bool $uploadBinary = true, string $path = '/'): FedoraResource { parent::updateRms($create, $uploadBinary, $path); $res = $this->getResource(false, false); $chPath = $res->getUri(true) . '/'; $children = []; foreach ($res->getChildren() as $i) { $children[$i->getUri(true)] = $i; } $validChildren = []; foreach ($this->params as $i) { $tmp = $i->updateRms($create, $uploadBinary, $chPath); $validChildren[] = $tmp->getUri(true); } foreach ($this->matches as $i) { $tmp = $i->updateRms($create, $uploadBinary, $chPath); $validChildren[] = $tmp->getUri(true); } $invalidChildren = array_diff(array_keys($children), $validChildren); foreach ($invalidChildren as $i) { $children[$i]->delete(true, true, false); } return $res; }
php
public function updateRms(bool $create = true, bool $uploadBinary = true, string $path = '/'): FedoraResource { parent::updateRms($create, $uploadBinary, $path); $res = $this->getResource(false, false); $chPath = $res->getUri(true) . '/'; $children = []; foreach ($res->getChildren() as $i) { $children[$i->getUri(true)] = $i; } $validChildren = []; foreach ($this->params as $i) { $tmp = $i->updateRms($create, $uploadBinary, $chPath); $validChildren[] = $tmp->getUri(true); } foreach ($this->matches as $i) { $tmp = $i->updateRms($create, $uploadBinary, $chPath); $validChildren[] = $tmp->getUri(true); } $invalidChildren = array_diff(array_keys($children), $validChildren); foreach ($invalidChildren as $i) { $children[$i]->delete(true, true, false); } return $res; }
[ "public", "function", "updateRms", "(", "bool", "$", "create", "=", "true", ",", "bool", "$", "uploadBinary", "=", "true", ",", "string", "$", "path", "=", "'/'", ")", ":", "FedoraResource", "{", "parent", "::", "updateRms", "(", "$", "create", ",", "$...
Updates the dissemination service definition in the repository. @param bool $create should repository resource be created if it does not exist? @param bool $uploadBinary should binary data of the real-world entity be uploaded uppon repository resource creation? @param string $path where to create a resource (if it does not exist). If it it ends with a "/", the resource will be created as a child of a given collection). All the parents in the Fedora resource tree have to exist (you can not create "/foo/bar" if "/foo" does not exist already). @return FedoraResource
[ "Updates", "the", "dissemination", "service", "definition", "in", "the", "repository", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/dissemination/Service.php#L203-L231
train
ventoviro/windwalker-core
src/Core/Logger/LoggerManager.php
LoggerManager.setLoggers
public function setLoggers(array $loggers) { foreach ($loggers as $channel => $logger) { $this->addLogger($channel, $logger); } return $this; }
php
public function setLoggers(array $loggers) { foreach ($loggers as $channel => $logger) { $this->addLogger($channel, $logger); } return $this; }
[ "public", "function", "setLoggers", "(", "array", "$", "loggers", ")", "{", "foreach", "(", "$", "loggers", "as", "$", "channel", "=>", "$", "logger", ")", "{", "$", "this", "->", "addLogger", "(", "$", "channel", ",", "$", "logger", ")", ";", "}", ...
Method to set property loggers @param LoggerInterface[] $loggers @return static Return self to support chaining.
[ "Method", "to", "set", "property", "loggers" ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Logger/LoggerManager.php#L519-L526
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/SparqlClient.php
SparqlClient.query
public function query(string $query, int $nTries = 1): Result { $headers = array('Content-Type' => 'application/x-www-form-urlencoded'); $body = 'query=' . rawurlencode($query); $request = new Request('POST', $this->url, $headers, $body); while ($nTries > 0) { $nTries--; try { $response = $this->client->send($request); $body = $response->getBody(); $result = new Result($body, 'application/sparql-results+json'); break; } catch (RequestException $ex) { if ($nTries <= 0) { throw $ex; } } } return $result; }
php
public function query(string $query, int $nTries = 1): Result { $headers = array('Content-Type' => 'application/x-www-form-urlencoded'); $body = 'query=' . rawurlencode($query); $request = new Request('POST', $this->url, $headers, $body); while ($nTries > 0) { $nTries--; try { $response = $this->client->send($request); $body = $response->getBody(); $result = new Result($body, 'application/sparql-results+json'); break; } catch (RequestException $ex) { if ($nTries <= 0) { throw $ex; } } } return $result; }
[ "public", "function", "query", "(", "string", "$", "query", ",", "int", "$", "nTries", "=", "1", ")", ":", "Result", "{", "$", "headers", "=", "array", "(", "'Content-Type'", "=>", "'application/x-www-form-urlencoded'", ")", ";", "$", "body", "=", "'query=...
Runs a given query. There is no support for UPDATE queries. @param string $query SPARQL query to be run @param int $nTries how many times request should be repeated in case of error before giving up @return \EasyRdf\Sparql\Result
[ "Runs", "a", "given", "query", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/SparqlClient.php#L91-L109
train
secucard/secucard-connect-php-sdk
src/SecucardConnect/Product/Common/Model/BaseCollection.php
BaseCollection.get
public function get($id) { foreach ($this->items as $item) { if ($item->id === $id) { return $item; } } return null; }
php
public function get($id) { foreach ($this->items as $item) { if ($item->id === $id) { return $item; } } return null; }
[ "public", "function", "get", "(", "$", "id", ")", "{", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "id", "===", "$", "id", ")", "{", "return", "$", "item", ";", "}", "}", "return", "n...
Get object in the collection by id @param string $id @return mixed|null
[ "Get", "object", "in", "the", "collection", "by", "id" ]
d990686095e4e02d0924fc12b9bf60140fe8efab
https://github.com/secucard/secucard-connect-php-sdk/blob/d990686095e4e02d0924fc12b9bf60140fe8efab/src/SecucardConnect/Product/Common/Model/BaseCollection.php#L64-L72
train
locomotivemtl/charcoal-ui
src/Charcoal/Ui/ConditionalizableTrait.php
ConditionalizableTrait.parseConditionalLogic
final protected function parseConditionalLogic($condition) { if ($condition === null) { return null; } if (is_bool($condition)) { return $condition; } $not = false; if (is_string($condition)) { $not = ($condition[0] === '!'); if ($not) { $condition = ltrim($condition, '!'); } } $result = $this->resolveConditionalLogic($condition); return (($not === true) ? !$result : $result); }
php
final protected function parseConditionalLogic($condition) { if ($condition === null) { return null; } if (is_bool($condition)) { return $condition; } $not = false; if (is_string($condition)) { $not = ($condition[0] === '!'); if ($not) { $condition = ltrim($condition, '!'); } } $result = $this->resolveConditionalLogic($condition); return (($not === true) ? !$result : $result); }
[ "final", "protected", "function", "parseConditionalLogic", "(", "$", "condition", ")", "{", "if", "(", "$", "condition", "===", "null", ")", "{", "return", "null", ";", "}", "if", "(", "is_bool", "(", "$", "condition", ")", ")", "{", "return", "$", "co...
Resolve the conditional logic. @param mixed $condition The condition. @return boolean|null
[ "Resolve", "the", "conditional", "logic", "." ]
0070f35d89ea24ae93720734d261c02a10e218b6
https://github.com/locomotivemtl/charcoal-ui/blob/0070f35d89ea24ae93720734d261c02a10e218b6/src/Charcoal/Ui/ConditionalizableTrait.php#L78-L99
train
jmikola/JmikolaWildcardEventDispatcherBundle
EventDispatcher/ContainerAwareEventDispatcher.php
ContainerAwareEventDispatcher.addListenerServicePattern
private function addListenerServicePattern($eventPattern, $callback, $priority = 0) { if (!is_array($callback) || 2 !== count($callback)) { throw new \InvalidArgumentException('Expected an array("service", "method") argument'); } $container = $this->container; $listenerProvider = function() use ($container, $callback) { return array($container->get($callback[0]), $callback[1]); }; $this->addListenerPattern(new LazyListenerPattern($eventPattern, $listenerProvider, $priority)); }
php
private function addListenerServicePattern($eventPattern, $callback, $priority = 0) { if (!is_array($callback) || 2 !== count($callback)) { throw new \InvalidArgumentException('Expected an array("service", "method") argument'); } $container = $this->container; $listenerProvider = function() use ($container, $callback) { return array($container->get($callback[0]), $callback[1]); }; $this->addListenerPattern(new LazyListenerPattern($eventPattern, $listenerProvider, $priority)); }
[ "private", "function", "addListenerServicePattern", "(", "$", "eventPattern", ",", "$", "callback", ",", "$", "priority", "=", "0", ")", "{", "if", "(", "!", "is_array", "(", "$", "callback", ")", "||", "2", "!==", "count", "(", "$", "callback", ")", "...
Adds a service as an event listener for all events matching the specified pattern. @param string $eventPattern @param callback $callback @param integer $priority @throw InvalidArgumentException if the callback is not a service/method tuple
[ "Adds", "a", "service", "as", "an", "event", "listener", "for", "all", "events", "matching", "the", "specified", "pattern", "." ]
b3295ce0eb4212f9bb0d6d0d0913cfa13d2e3884
https://github.com/jmikola/JmikolaWildcardEventDispatcherBundle/blob/b3295ce0eb4212f9bb0d6d0d0913cfa13d2e3884/EventDispatcher/ContainerAwareEventDispatcher.php#L48-L60
train
jmikola/JmikolaWildcardEventDispatcherBundle
EventDispatcher/ContainerAwareEventDispatcher.php
ContainerAwareEventDispatcher.addSubscriberService
public function addSubscriberService($serviceId, $class) { foreach ($class::getSubscribedEvents() as $eventName => $params) { if (is_string($params)) { $this->addListenerService($eventName, array($serviceId, $params), 0); } elseif (is_string($params[0])) { $this->addListenerService($eventName, array($serviceId, $params[0]), isset($params[1]) ? $params[1] : 0); } else { foreach ($params as $listener) { $this->addListenerService($eventName, array($serviceId, $listener[0]), isset($listener[1]) ? $listener[1] : 0); } } } }
php
public function addSubscriberService($serviceId, $class) { foreach ($class::getSubscribedEvents() as $eventName => $params) { if (is_string($params)) { $this->addListenerService($eventName, array($serviceId, $params), 0); } elseif (is_string($params[0])) { $this->addListenerService($eventName, array($serviceId, $params[0]), isset($params[1]) ? $params[1] : 0); } else { foreach ($params as $listener) { $this->addListenerService($eventName, array($serviceId, $listener[0]), isset($listener[1]) ? $listener[1] : 0); } } } }
[ "public", "function", "addSubscriberService", "(", "$", "serviceId", ",", "$", "class", ")", "{", "foreach", "(", "$", "class", "::", "getSubscribedEvents", "(", ")", "as", "$", "eventName", "=>", "$", "params", ")", "{", "if", "(", "is_string", "(", "$"...
Adds a service as an event subscriber for all events matching the specified pattern @param string $serviceId The service ID of the subscriber service @param string $class The service's class name (which must implement EventSubscriberInterface)
[ "Adds", "a", "service", "as", "an", "event", "subscriber", "for", "all", "events", "matching", "the", "specified", "pattern" ]
b3295ce0eb4212f9bb0d6d0d0913cfa13d2e3884
https://github.com/jmikola/JmikolaWildcardEventDispatcherBundle/blob/b3295ce0eb4212f9bb0d6d0d0913cfa13d2e3884/EventDispatcher/ContainerAwareEventDispatcher.php#L69-L82
train
crcms/microservice-framework
src/Console/Kernel.php
Kernel.commands
protected function commands() { $commands = $this->app['config']->get('mount.commands', []); if ($commands) { Artisan::starting(function ($artisan) use ($commands) { $artisan->resolveCommands($commands); }); } }
php
protected function commands() { $commands = $this->app['config']->get('mount.commands', []); if ($commands) { Artisan::starting(function ($artisan) use ($commands) { $artisan->resolveCommands($commands); }); } }
[ "protected", "function", "commands", "(", ")", "{", "$", "commands", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'mount.commands'", ",", "[", "]", ")", ";", "if", "(", "$", "commands", ")", "{", "Artisan", "::", "starting"...
Register the Closure based commands for the application. @return void
[ "Register", "the", "Closure", "based", "commands", "for", "the", "application", "." ]
7ad513562e333599642d5697ee45572d7d9e713d
https://github.com/crcms/microservice-framework/blob/7ad513562e333599642d5697ee45572d7d9e713d/src/Console/Kernel.php#L46-L54
train
polyfony-inc/polyfony
Private/Polyfony/Route.php
Route.setDestination
public function setDestination(string $merged_destination) :self { // explode the parameters list($this->bundle, $this->controller, $this->action) = explode('/', str_replace('@', '/',$merged_destination)); // if the action is an url parameter if(Route\Helper::isThisAParameterName($this->action)) { // we have an action triggered by an url parameter, remove special chars, and set the trigger $this->trigger = trim($this->action, '{}'); // action is not known yet $this->action = null; } // build route segments tp ease the job of the router later on $this->buildSegments(); // return the route return $this; }
php
public function setDestination(string $merged_destination) :self { // explode the parameters list($this->bundle, $this->controller, $this->action) = explode('/', str_replace('@', '/',$merged_destination)); // if the action is an url parameter if(Route\Helper::isThisAParameterName($this->action)) { // we have an action triggered by an url parameter, remove special chars, and set the trigger $this->trigger = trim($this->action, '{}'); // action is not known yet $this->action = null; } // build route segments tp ease the job of the router later on $this->buildSegments(); // return the route return $this; }
[ "public", "function", "setDestination", "(", "string", "$", "merged_destination", ")", ":", "self", "{", "// explode the parameters", "list", "(", "$", "this", "->", "bundle", ",", "$", "this", "->", "controller", ",", "$", "this", "->", "action", ")", "=", ...
shortcut for destination
[ "shortcut", "for", "destination" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Route.php#L74-L89
train
polyfony-inc/polyfony
Private/Polyfony/Response/CSV.php
CSV.buildAndGetDocument
public static function buildAndGetDocument($content) :array { // convert the array to a basic CSV string $content = is_array($content) ? self::convertArrayToString($content) : $content; // convert the content to the proper charset (if needs be) $content = mb_convert_encoding($content, self::destination_charset); // prefix it with the BOM characters $content = self::getBomCharacters() . $content; // return the formatted document return [ $content, self::destination_charset ]; }
php
public static function buildAndGetDocument($content) :array { // convert the array to a basic CSV string $content = is_array($content) ? self::convertArrayToString($content) : $content; // convert the content to the proper charset (if needs be) $content = mb_convert_encoding($content, self::destination_charset); // prefix it with the BOM characters $content = self::getBomCharacters() . $content; // return the formatted document return [ $content, self::destination_charset ]; }
[ "public", "static", "function", "buildAndGetDocument", "(", "$", "content", ")", ":", "array", "{", "// convert the array to a basic CSV string", "$", "content", "=", "is_array", "(", "$", "content", ")", "?", "self", "::", "convertArrayToString", "(", "$", "conte...
with preformatted csv will still work
[ "with", "preformatted", "csv", "will", "still", "work" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Response/CSV.php#L15-L27
train
ventoviro/windwalker-core
src/Core/Console/CoreConsole.php
CoreConsole.prepareExecute
protected function prepareExecute() { if (class_exists(ComposerInformation::class)) { $this->version = ComposerInformation::getInstalledVersion('windwalker/core'); } if ($this->getRootCommand()->getOption('n')) { IOFactory::getIO()->setInput(new NullInput()); } }
php
protected function prepareExecute() { if (class_exists(ComposerInformation::class)) { $this->version = ComposerInformation::getInstalledVersion('windwalker/core'); } if ($this->getRootCommand()->getOption('n')) { IOFactory::getIO()->setInput(new NullInput()); } }
[ "protected", "function", "prepareExecute", "(", ")", "{", "if", "(", "class_exists", "(", "ComposerInformation", "::", "class", ")", ")", "{", "$", "this", "->", "version", "=", "ComposerInformation", "::", "getInstalledVersion", "(", "'windwalker/core'", ")", "...
Prepare execute hook. @return void
[ "Prepare", "execute", "hook", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Console/CoreConsole.php#L226-L235
train
secucard/secucard-connect-php-sdk
src/SecucardConnect/Auth/PasswordCredentials.php
PasswordCredentials.addParameters
public function addParameters(&$params) { $params['grant_type'] = $this->getType(); $params['username'] = $this->username; $params['password'] = $this->password; }
php
public function addParameters(&$params) { $params['grant_type'] = $this->getType(); $params['username'] = $this->username; $params['password'] = $this->password; }
[ "public", "function", "addParameters", "(", "&", "$", "params", ")", "{", "$", "params", "[", "'grant_type'", "]", "=", "$", "this", "->", "getType", "(", ")", ";", "$", "params", "[", "'username'", "]", "=", "$", "this", "->", "username", ";", "$", ...
Function add parameters to params array @param array $params
[ "Function", "add", "parameters", "to", "params", "array" ]
d990686095e4e02d0924fc12b9bf60140fe8efab
https://github.com/secucard/secucard-connect-php-sdk/blob/d990686095e4e02d0924fc12b9bf60140fe8efab/src/SecucardConnect/Auth/PasswordCredentials.php#L36-L41
train
ventoviro/windwalker-core
src/Core/View/AbstractView.php
AbstractView.pipe
public function pipe($name, $handler = null) { if (is_callable($name)) { $handler = $name; $name = null; } return $handler($this->getRepository($name), $this); }
php
public function pipe($name, $handler = null) { if (is_callable($name)) { $handler = $name; $name = null; } return $handler($this->getRepository($name), $this); }
[ "public", "function", "pipe", "(", "$", "name", ",", "$", "handler", "=", "null", ")", "{", "if", "(", "is_callable", "(", "$", "name", ")", ")", "{", "$", "handler", "=", "$", "name", ";", "$", "name", "=", "null", ";", "}", "return", "$", "ha...
Pipe a callback to model and view then return value. @param string|callable $name The name alias of model, keep NULL as default model. Or just send a callable here as handler. @param callable $handler The callback handler. @return mixed
[ "Pipe", "a", "callback", "to", "model", "and", "view", "then", "return", "value", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/View/AbstractView.php#L663-L671
train
ventoviro/windwalker-core
src/Core/View/AbstractView.php
AbstractView.applyData
public function applyData($name, $handler = null) { if (is_callable($name)) { $handler = $name; $name = null; } $handler($this->getRepository($name), $this->getData()); return $this; }
php
public function applyData($name, $handler = null) { if (is_callable($name)) { $handler = $name; $name = null; } $handler($this->getRepository($name), $this->getData()); return $this; }
[ "public", "function", "applyData", "(", "$", "name", ",", "$", "handler", "=", "null", ")", "{", "if", "(", "is_callable", "(", "$", "name", ")", ")", "{", "$", "handler", "=", "$", "name", ";", "$", "name", "=", "null", ";", "}", "$", "handler",...
Apply a callback to model and view data. @param string|callable $name The name alias of model, keep NULL as default model. Or just send a callable here as handler. @param callable $handler The callback handler. @return $this
[ "Apply", "a", "callback", "to", "model", "and", "view", "data", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/View/AbstractView.php#L682-L692
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/redmine/Issue.php
Issue.fetchAll
static public function fetchAll(Fedora $fedora, bool $progressBar, array $filters = array()): array { $param = ['key=' . urlencode(RC::get('redmineApiKey')), 'limit' => 1000000]; foreach ($filters as $k => $v) { $param[] = urlencode($k) . '=' . urlencode($v); } $param = implode('&', $param); return self::redmineFetchLoop($fedora, $progressBar, 'issues', $param); }
php
static public function fetchAll(Fedora $fedora, bool $progressBar, array $filters = array()): array { $param = ['key=' . urlencode(RC::get('redmineApiKey')), 'limit' => 1000000]; foreach ($filters as $k => $v) { $param[] = urlencode($k) . '=' . urlencode($v); } $param = implode('&', $param); return self::redmineFetchLoop($fedora, $progressBar, 'issues', $param); }
[ "static", "public", "function", "fetchAll", "(", "Fedora", "$", "fedora", ",", "bool", "$", "progressBar", ",", "array", "$", "filters", "=", "array", "(", ")", ")", ":", "array", "{", "$", "param", "=", "[", "'key='", ".", "urlencode", "(", "RC", ":...
Returns array of all Issue objects which can be fetched from the Redmine. See the Redmine::fetchAll() description for details; @param \acdhOeaw\fedora\Fedora $fedora Fedora connection @param bool $progressBar should progress bar be displayed (makes sense only if the standard output is a console) @param array $filters filters to be passed to the Redmine's issue REST API in a form of an associative array, e.g. `array('tracker_id' => 5)` @return array @see Redmine::fetchAll()
[ "Returns", "array", "of", "all", "Issue", "objects", "which", "can", "be", "fetched", "from", "the", "Redmine", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/redmine/Issue.php#L57-L66
train
polyfony-inc/polyfony
Private/Polyfony/Record/Aware.php
Aware.save
public function save() :bool { // if an id already exists if($this->_['id']) { // we can update and return the number of affected rows (0 on error, 1 on success) return (bool) self::_update() ->set($this->__toArray(true, true)) ->where(['id'=>$this->_['id']]) ->execute(); } // this is a new record else { // try to insert it $inserted_object = self::create($this->__toArray(true, true)); // if insertion succeeded, return true if($inserted_object) { // clone ourselves with what the database returneds, a full fledged object $this->replicate($inserted_object); // return success return true; } // didnt insert else { // failure feedback return false; } } }
php
public function save() :bool { // if an id already exists if($this->_['id']) { // we can update and return the number of affected rows (0 on error, 1 on success) return (bool) self::_update() ->set($this->__toArray(true, true)) ->where(['id'=>$this->_['id']]) ->execute(); } // this is a new record else { // try to insert it $inserted_object = self::create($this->__toArray(true, true)); // if insertion succeeded, return true if($inserted_object) { // clone ourselves with what the database returneds, a full fledged object $this->replicate($inserted_object); // return success return true; } // didnt insert else { // failure feedback return false; } } }
[ "public", "function", "save", "(", ")", ":", "bool", "{", "// if an id already exists", "if", "(", "$", "this", "->", "_", "[", "'id'", "]", ")", "{", "// we can update and return the number of affected rows (0 on error, 1 on success)", "return", "(", "bool", ")", "...
update or create
[ "update", "or", "create" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Record/Aware.php#L155-L183
train
polyfony-inc/polyfony
Private/Polyfony/Record/Aware.php
Aware.create
public static function create(array $columns_and_values=[]) { return Database::query() ->insert($columns_and_values) ->into(self::tableName()) ->execute(); }
php
public static function create(array $columns_and_values=[]) { return Database::query() ->insert($columns_and_values) ->into(self::tableName()) ->execute(); }
[ "public", "static", "function", "create", "(", "array", "$", "columns_and_values", "=", "[", "]", ")", "{", "return", "Database", "::", "query", "(", ")", "->", "insert", "(", "$", "columns_and_values", ")", "->", "into", "(", "self", "::", "tableName", ...
shortcut to insert an element
[ "shortcut", "to", "insert", "an", "element" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Record/Aware.php#L205-L212
train
polyfony-inc/polyfony
Private/Polyfony/Record/Aware.php
Aware._select
public static function _select(array $select=[]) :Query { // returns a Query object, to execute, or to complement with some more parameters return Database::query() ->select($select) ->from(self::tableName()); }
php
public static function _select(array $select=[]) :Query { // returns a Query object, to execute, or to complement with some more parameters return Database::query() ->select($select) ->from(self::tableName()); }
[ "public", "static", "function", "_select", "(", "array", "$", "select", "=", "[", "]", ")", ":", "Query", "{", "// returns a Query object, to execute, or to complement with some more parameters", "return", "Database", "::", "query", "(", ")", "->", "select", "(", "$...
shortcut that bootstraps a select query
[ "shortcut", "that", "bootstraps", "a", "select", "query" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Record/Aware.php#L215-L222
train
polyfony-inc/polyfony
Private/Polyfony/Store/Memcache.php
Memcache.setup
public static function setup($server, $host, $port) { // Sanity check: Make sure we have received a valid switch ($server) { case 'Memcache' : self::$_memcache = new \Memcache(); break; case 'Memcached' : self::$_memcache = new \Memcached(); break; default : throw new \Exception("Unknown server {$server}."); } // Memcache instance created, add the server self::$_memcache->addServer($host, $port); }
php
public static function setup($server, $host, $port) { // Sanity check: Make sure we have received a valid switch ($server) { case 'Memcache' : self::$_memcache = new \Memcache(); break; case 'Memcached' : self::$_memcache = new \Memcached(); break; default : throw new \Exception("Unknown server {$server}."); } // Memcache instance created, add the server self::$_memcache->addServer($host, $port); }
[ "public", "static", "function", "setup", "(", "$", "server", ",", "$", "host", ",", "$", "port", ")", "{", "// Sanity check: Make sure we have received a valid", "switch", "(", "$", "server", ")", "{", "case", "'Memcache'", ":", "self", "::", "$", "_memcache",...
Setup Memcache for storing data. @access public @param string $server Whether we are using Memcache or Memcached. @param string $host The location of the Memcache server. @param string $port The port the Memcache server lives on. @throws \Exception If passed an incorrect server.
[ "Setup", "Memcache", "for", "storing", "data", "." ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Store/Memcache.php#L28-L38
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertContainsSelector
public function assertContainsSelector($selector, $output = '', $message = '') { $results = $this->executeDomQuery($output, $selector); $this->assertGreaterThan(0, count($results), $message); }
php
public function assertContainsSelector($selector, $output = '', $message = '') { $results = $this->executeDomQuery($output, $selector); $this->assertGreaterThan(0, count($results), $message); }
[ "public", "function", "assertContainsSelector", "(", "$", "selector", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "results", "=", "$", "this", "->", "executeDomQuery", "(", "$", "output", ",", "$", "selector", ")", ";"...
Assert that the given string contains an element matching the given selector. @since 1.0.0 @param string $selector A query selector for the element to find. @param string $output The output that should contain the $selector. @param string $message A message to display if the assertion fails.
[ "Assert", "that", "the", "given", "string", "contains", "an", "element", "matching", "the", "given", "selector", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L27-L32
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertNotContainsSelector
public function assertNotContainsSelector($selector, $output = '', $message = '') { $results = $this->executeDomQuery($output, $selector); $this->assertEquals(0, count($results), $message); }
php
public function assertNotContainsSelector($selector, $output = '', $message = '') { $results = $this->executeDomQuery($output, $selector); $this->assertEquals(0, count($results), $message); }
[ "public", "function", "assertNotContainsSelector", "(", "$", "selector", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "results", "=", "$", "this", "->", "executeDomQuery", "(", "$", "output", ",", "$", "selector", ")", ...
Assert that the given string does not contain an element matching the given selector. @since 1.0.0 @param string $selector A query selector for the element to find. @param string $output The output that should not contain the $selector. @param string $message A message to display if the assertion fails.
[ "Assert", "that", "the", "given", "string", "does", "not", "contain", "an", "element", "matching", "the", "given", "selector", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L43-L48
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertSelectorCount
public function assertSelectorCount($count, $selector, $output = '', $message = '') { $results = $this->executeDomQuery($output, $selector); $this->assertCount($count, $results, $message); }
php
public function assertSelectorCount($count, $selector, $output = '', $message = '') { $results = $this->executeDomQuery($output, $selector); $this->assertCount($count, $results, $message); }
[ "public", "function", "assertSelectorCount", "(", "$", "count", ",", "$", "selector", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "results", "=", "$", "this", "->", "executeDomQuery", "(", "$", "output", ",", "$", "s...
Assert the number of times an element matching the given selector is found. @since 1.0.0 @param int $count The number of matching elements expected. @param string $selector A query selector for the element to find. @param string $output The markup to run the assertion against. @param string $message A message to display if the assertion fails.
[ "Assert", "the", "number", "of", "times", "an", "element", "matching", "the", "given", "selector", "is", "found", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L60-L65
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertHasElementWithAttributes
public function assertHasElementWithAttributes($attributes = [], $output = '', $message = '') { $this->assertContainsSelector( '*' . $this->flattenAttributeArray($attributes), $output, $message ); }
php
public function assertHasElementWithAttributes($attributes = [], $output = '', $message = '') { $this->assertContainsSelector( '*' . $this->flattenAttributeArray($attributes), $output, $message ); }
[ "public", "function", "assertHasElementWithAttributes", "(", "$", "attributes", "=", "[", "]", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "assertContainsSelector", "(", "'*'", ".", "$", "this", "->", "flat...
Assert that an element with the given attributes exists in the given markup. @since 1.0.0 @param array $attributes An array of HTML attributes that should be found on the element. @param string $output The output that should contain an element with the provided $attributes. @param string $message A message to display if the assertion fails.
[ "Assert", "that", "an", "element", "with", "the", "given", "attributes", "exists", "in", "the", "given", "markup", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L77-L84
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertNotHasElementWithAttributes
public function assertNotHasElementWithAttributes($attributes = [], $output = '', $message = '') { $this->assertNotContainsSelector( '*' . $this->flattenAttributeArray($attributes), $output, $message ); }
php
public function assertNotHasElementWithAttributes($attributes = [], $output = '', $message = '') { $this->assertNotContainsSelector( '*' . $this->flattenAttributeArray($attributes), $output, $message ); }
[ "public", "function", "assertNotHasElementWithAttributes", "(", "$", "attributes", "=", "[", "]", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "assertNotContainsSelector", "(", "'*'", ".", "$", "this", "->", ...
Assert that an element with the given attributes does not exist in the given markup. @since 1.0.0 @param array $attributes An array of HTML attributes that should be found on the element. @param string $output The output that should not contain an element with the provided $attributes. @param string $message A message to display if the assertion fails.
[ "Assert", "that", "an", "element", "with", "the", "given", "attributes", "does", "not", "exist", "in", "the", "given", "markup", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L96-L103
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertElementContains
public function assertElementContains($contents, $selector = '', $output = '', $message = '') { $this->assertContains( $contents, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
php
public function assertElementContains($contents, $selector = '', $output = '', $message = '') { $this->assertContains( $contents, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
[ "public", "function", "assertElementContains", "(", "$", "contents", ",", "$", "selector", "=", "''", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "assertContains", "(", "$", "contents", ",", "$", "this", ...
Assert an element's contents contain the given string. @since 1.1.0 @param string $contents The string to look for within the DOM node's contents. @param string $selector A query selector for the element to find. @param string $output The output that should contain the $selector. @param string $message A message to display if the assertion fails.
[ "Assert", "an", "element", "s", "contents", "contain", "the", "given", "string", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L115-L122
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertElementNotContains
public function assertElementNotContains($contents, $selector = '', $output = '', $message = '') { $this->assertNotContains( $contents, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
php
public function assertElementNotContains($contents, $selector = '', $output = '', $message = '') { $this->assertNotContains( $contents, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
[ "public", "function", "assertElementNotContains", "(", "$", "contents", ",", "$", "selector", "=", "''", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "assertNotContains", "(", "$", "contents", ",", "$", "t...
Assert an element's contents do not contain the given string. @since 1.1.0 @param string $contents The string to look for within the DOM node's contents. @param string $selector A query selector for the element to find. @param string $output The output that should not contain the $selector. @param string $message A message to display if the assertion fails.
[ "Assert", "an", "element", "s", "contents", "do", "not", "contain", "the", "given", "string", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L134-L141
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertElementRegExp
public function assertElementRegExp($regexp, $selector = '', $output = '', $message = '') { $this->assertRegExp( $regexp, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
php
public function assertElementRegExp($regexp, $selector = '', $output = '', $message = '') { $this->assertRegExp( $regexp, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
[ "public", "function", "assertElementRegExp", "(", "$", "regexp", ",", "$", "selector", "=", "''", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "assertRegExp", "(", "$", "regexp", ",", "$", "this", "->", ...
Assert an element's contents contain the given regular expression pattern. @since 1.1.0 @param string $regexp The regular expression pattern to look for within the DOM node. @param string $selector A query selector for the element to find. @param string $output The output that should contain the $selector. @param string $message A message to display if the assertion fails.
[ "Assert", "an", "element", "s", "contents", "contain", "the", "given", "regular", "expression", "pattern", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L153-L160
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.assertElementNotRegExp
public function assertElementNotRegExp($regexp, $selector = '', $output = '', $message = '') { $this->assertNotRegExp( $regexp, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
php
public function assertElementNotRegExp($regexp, $selector = '', $output = '', $message = '') { $this->assertNotRegExp( $regexp, $this->getInnerHtmlOfMatchedElements($output, $selector), $message ); }
[ "public", "function", "assertElementNotRegExp", "(", "$", "regexp", ",", "$", "selector", "=", "''", ",", "$", "output", "=", "''", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "assertNotRegExp", "(", "$", "regexp", ",", "$", "this", ...
Assert an element's contents do not contain the given regular expression pattern. @since 1.1.0 @param string $regexp The regular expression pattern to look for within the DOM node. @param string $selector A query selector for the element to find. @param string $output The output that should not contain the $selector. @param string $message A message to display if the assertion fails.
[ "Assert", "an", "element", "s", "contents", "do", "not", "contain", "the", "given", "regular", "expression", "pattern", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L172-L179
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.flattenAttributeArray
protected function flattenAttributeArray(array $attributes) { if (empty($attributes)) { throw new RiskyTestError('Attributes array is empty.'); } array_walk($attributes, function (&$value, $key) { // Boolean attributes. if (null === $value) { $value = sprintf('[%s]', $key); } else { $value = sprintf('[%s="%s"]', $key, htmlspecialchars($value)); } }); return implode('', $attributes); }
php
protected function flattenAttributeArray(array $attributes) { if (empty($attributes)) { throw new RiskyTestError('Attributes array is empty.'); } array_walk($attributes, function (&$value, $key) { // Boolean attributes. if (null === $value) { $value = sprintf('[%s]', $key); } else { $value = sprintf('[%s="%s"]', $key, htmlspecialchars($value)); } }); return implode('', $attributes); }
[ "protected", "function", "flattenAttributeArray", "(", "array", "$", "attributes", ")", "{", "if", "(", "empty", "(", "$", "attributes", ")", ")", "{", "throw", "new", "RiskyTestError", "(", "'Attributes array is empty.'", ")", ";", "}", "array_walk", "(", "$"...
Given an array of HTML attributes, flatten them into a XPath attribute selector. @since 1.0.0 @throws RiskyTestError When the $attributes array is empty. @param array $attributes HTML attributes and their values. @return string A XPath attribute query selector.
[ "Given", "an", "array", "of", "HTML", "attributes", "flatten", "them", "into", "a", "XPath", "attribute", "selector", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L209-L225
train
stevegrunwell/phpunit-markup-assertions
src/MarkupAssertionsTrait.php
MarkupAssertionsTrait.getInnerHtmlOfMatchedElements
protected function getInnerHtmlOfMatchedElements($markup, $query) { $results = $this->executeDomQuery($markup, $query); $contents = []; // Loop through results and collect their innerHTML values. foreach ($results as $result) { $document = new DOMDocument; $document->appendChild($document->importNode($result->firstChild, true)); $contents[] = trim($document->saveHTML()); } return implode(PHP_EOL, $contents); }
php
protected function getInnerHtmlOfMatchedElements($markup, $query) { $results = $this->executeDomQuery($markup, $query); $contents = []; // Loop through results and collect their innerHTML values. foreach ($results as $result) { $document = new DOMDocument; $document->appendChild($document->importNode($result->firstChild, true)); $contents[] = trim($document->saveHTML()); } return implode(PHP_EOL, $contents); }
[ "protected", "function", "getInnerHtmlOfMatchedElements", "(", "$", "markup", ",", "$", "query", ")", "{", "$", "results", "=", "$", "this", "->", "executeDomQuery", "(", "$", "markup", ",", "$", "query", ")", ";", "$", "contents", "=", "[", "]", ";", ...
Given HTML markup and a DOM selector query, collect the innerHTML of the matched selectors. @since 1.1.0 @param string $markup The HTML for the DOMDocument. @param string $query The DOM selector query. @return string The concatenated innerHTML of any matched selectors.
[ "Given", "HTML", "markup", "and", "a", "DOM", "selector", "query", "collect", "the", "innerHTML", "of", "the", "matched", "selectors", "." ]
545ce29918d4d986e26961bf4d380c655583ece9
https://github.com/stevegrunwell/phpunit-markup-assertions/blob/545ce29918d4d986e26961bf4d380c655583ece9/src/MarkupAssertionsTrait.php#L237-L251
train
polyfony-inc/polyfony
Private/Polyfony/Thumbnail.php
Thumbnail.source
public function source($path, $override_chroot = false) { // if chroot is enabled, restrict the path to the chroot $this->Source = Filesystem::chroot($path, $override_chroot); // return self return($this); }
php
public function source($path, $override_chroot = false) { // if chroot is enabled, restrict the path to the chroot $this->Source = Filesystem::chroot($path, $override_chroot); // return self return($this); }
[ "public", "function", "source", "(", "$", "path", ",", "$", "override_chroot", "=", "false", ")", "{", "// if chroot is enabled, restrict the path to the chroot", "$", "this", "->", "Source", "=", "Filesystem", "::", "chroot", "(", "$", "path", ",", "$", "overri...
set the source image path
[ "set", "the", "source", "image", "path" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Thumbnail.php#L57-L62
train
polyfony-inc/polyfony
Private/Polyfony/Thumbnail.php
Thumbnail.type
public function type($mimetype) { // if the type is correct if(in_array($mimetype, $this->Allowed)) { // set the type $this->Output = $mimetype; } // return self return($this); }
php
public function type($mimetype) { // if the type is correct if(in_array($mimetype, $this->Allowed)) { // set the type $this->Output = $mimetype; } // return self return($this); }
[ "public", "function", "type", "(", "$", "mimetype", ")", "{", "// if the type is correct", "if", "(", "in_array", "(", "$", "mimetype", ",", "$", "this", "->", "Allowed", ")", ")", "{", "// set the type", "$", "this", "->", "Output", "=", "$", "mimetype", ...
set the output type
[ "set", "the", "output", "type" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Thumbnail.php#L73-L81
train
polyfony-inc/polyfony
Private/Polyfony/Thumbnail.php
Thumbnail.size
public function size($pixels) { // if the value is acceptable if(is_numeric($pixels) && $pixels >= 16 && $pixels <= 4096) { // set the limit $this->Maximum = intval($pixels); } // return self return($this); }
php
public function size($pixels) { // if the value is acceptable if(is_numeric($pixels) && $pixels >= 16 && $pixels <= 4096) { // set the limit $this->Maximum = intval($pixels); } // return self return($this); }
[ "public", "function", "size", "(", "$", "pixels", ")", "{", "// if the value is acceptable", "if", "(", "is_numeric", "(", "$", "pixels", ")", "&&", "$", "pixels", ">=", "16", "&&", "$", "pixels", "<=", "4096", ")", "{", "// set the limit", "$", "this", ...
set the size
[ "set", "the", "size" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Thumbnail.php#L84-L92
train
polyfony-inc/polyfony
Private/Polyfony/Thumbnail.php
Thumbnail.quality
public function quality($quality) { // if the value is acceptable if(is_numeric($quality) && $quality >= 10 && $quality <= 100) { // set the quality $this->Quality = intval($quality); } // return self return($this); }
php
public function quality($quality) { // if the value is acceptable if(is_numeric($quality) && $quality >= 10 && $quality <= 100) { // set the quality $this->Quality = intval($quality); } // return self return($this); }
[ "public", "function", "quality", "(", "$", "quality", ")", "{", "// if the value is acceptable", "if", "(", "is_numeric", "(", "$", "quality", ")", "&&", "$", "quality", ">=", "10", "&&", "$", "quality", "<=", "100", ")", "{", "// set the quality", "$", "t...
set the quality
[ "set", "the", "quality" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Thumbnail.php#L95-L103
train
ventoviro/windwalker-core
src/Core/Asset/AssetManager.php
AssetManager.exists
public function exists($uri, $strict = false) { if (static::isAbsoluteUrl($uri)) { return $uri; } $assetUri = $this->path; if (static::isAbsoluteUrl($assetUri)) { return rtrim($assetUri, '/') . '/' . ltrim($uri, '/'); } $root = $this->addSysPath($assetUri); $this->normalizeUri($uri, $assetFile, $assetMinFile); if (is_file($root . '/' . $uri)) { return $this->addBase($uri, 'path'); } if (!$strict) { if (is_file($root . '/' . $assetFile)) { return $this->addBase($assetFile, 'path'); } if (is_file($root . '/' . $assetMinFile)) { return $this->addBase($assetMinFile, 'path'); } } return false; }
php
public function exists($uri, $strict = false) { if (static::isAbsoluteUrl($uri)) { return $uri; } $assetUri = $this->path; if (static::isAbsoluteUrl($assetUri)) { return rtrim($assetUri, '/') . '/' . ltrim($uri, '/'); } $root = $this->addSysPath($assetUri); $this->normalizeUri($uri, $assetFile, $assetMinFile); if (is_file($root . '/' . $uri)) { return $this->addBase($uri, 'path'); } if (!$strict) { if (is_file($root . '/' . $assetFile)) { return $this->addBase($assetFile, 'path'); } if (is_file($root . '/' . $assetMinFile)) { return $this->addBase($assetMinFile, 'path'); } } return false; }
[ "public", "function", "exists", "(", "$", "uri", ",", "$", "strict", "=", "false", ")", "{", "if", "(", "static", "::", "isAbsoluteUrl", "(", "$", "uri", ")", ")", "{", "return", "$", "uri", ";", "}", "$", "assetUri", "=", "$", "this", "->", "pat...
Check asset uri exists in system and return actual path. @param string $uri The file uri to check. @param bool $strict Check .min file or un-min file exists again if input file not exists. @return bool|string @since 3.3
[ "Check", "asset", "uri", "exists", "in", "system", "and", "return", "actual", "path", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Asset/AssetManager.php#L269-L300
train
ventoviro/windwalker-core
src/Core/Asset/AssetManager.php
AssetManager.root
public function root($uri = null, $version = false) { if ($version === true) { $version = $this->getVersion(); } if ($version) { if (strpos($uri, '?') !== false) { $uri .= '&' . $version; } else { $uri .= '?' . $version; } } if ($uri !== null) { return $this->root . '/' . $uri; } return $this->root; }
php
public function root($uri = null, $version = false) { if ($version === true) { $version = $this->getVersion(); } if ($version) { if (strpos($uri, '?') !== false) { $uri .= '&' . $version; } else { $uri .= '?' . $version; } } if ($uri !== null) { return $this->root . '/' . $uri; } return $this->root; }
[ "public", "function", "root", "(", "$", "uri", "=", "null", ",", "$", "version", "=", "false", ")", "{", "if", "(", "$", "version", "===", "true", ")", "{", "$", "version", "=", "$", "this", "->", "getVersion", "(", ")", ";", "}", "if", "(", "$...
Method to get property Root @param string $uri @param bool $version @return string
[ "Method", "to", "get", "property", "Root" ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Asset/AssetManager.php#L1021-L1040
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/redmine/User.php
User.fetchAll
static public function fetchAll(Fedora $fedora, bool $progressBar): array { $param = 'limit=100000&key=' . urlencode(RC::get('redmineApiKey')); return self::redmineFetchLoop($fedora, $progressBar, 'users', $param); }
php
static public function fetchAll(Fedora $fedora, bool $progressBar): array { $param = 'limit=100000&key=' . urlencode(RC::get('redmineApiKey')); return self::redmineFetchLoop($fedora, $progressBar, 'users', $param); }
[ "static", "public", "function", "fetchAll", "(", "Fedora", "$", "fedora", ",", "bool", "$", "progressBar", ")", ":", "array", "{", "$", "param", "=", "'limit=100000&key='", ".", "urlencode", "(", "RC", "::", "get", "(", "'redmineApiKey'", ")", ")", ";", ...
Returns array of all User objects which can be fetched from the Redmine. See the Redmine::fetchAll() description for details; @param \acdhOeaw\fedora\Fedora $fedora Fedora connection @param bool $progressBar should progress bar be displayed (makes sense only if the standard output is a console) @return array @see Redmine::fetchAll()
[ "Returns", "array", "of", "all", "User", "objects", "which", "can", "be", "fetched", "from", "the", "Redmine", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/redmine/User.php#L56-L59
train
ventoviro/windwalker-core
src/Core/Ioc.php
Ioc.share
public function share($key, $callback, $name = null) { return static::factory($name)->share($key, $callback); }
php
public function share($key, $callback, $name = null) { return static::factory($name)->share($key, $callback); }
[ "public", "function", "share", "(", "$", "key", ",", "$", "callback", ",", "$", "name", "=", "null", ")", "{", "return", "static", "::", "factory", "(", "$", "name", ")", "->", "share", "(", "$", "key", ",", "$", "callback", ")", ";", "}" ]
Convenience method for creating shared keys. @param string $key Name of dataStore key to set. @param callable $callback Callable function to run when requesting the specified $key. @param string $name Container name. @return Container This object for chaining. @since 2.0
[ "Convenience", "method", "for", "creating", "shared", "keys", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Ioc.php#L401-L404
train
crcms/microservice-framework
src/Foundation/Exceptions/ExceptionHandler.php
ExceptionHandler.convertExceptionToServiceException
protected function convertExceptionToServiceException(Exception $e): ServiceException { $exception = get_class($e); $conversion = $this->container['config']->get('exception.conversion', []); if (isset($conversion[$exception])) { return new $conversion[$exception]($e->getMessage(), $e->getCode(), $e); } /*else if (in_array($exception, $conversion, true)) { return new ServiceException($e->getMessage(), 400, $e); }*/ else { $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 400; return new ServiceException($e->getMessage(), $statusCode, $e); } }
php
protected function convertExceptionToServiceException(Exception $e): ServiceException { $exception = get_class($e); $conversion = $this->container['config']->get('exception.conversion', []); if (isset($conversion[$exception])) { return new $conversion[$exception]($e->getMessage(), $e->getCode(), $e); } /*else if (in_array($exception, $conversion, true)) { return new ServiceException($e->getMessage(), 400, $e); }*/ else { $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 400; return new ServiceException($e->getMessage(), $statusCode, $e); } }
[ "protected", "function", "convertExceptionToServiceException", "(", "Exception", "$", "e", ")", ":", "ServiceException", "{", "$", "exception", "=", "get_class", "(", "$", "e", ")", ";", "$", "conversion", "=", "$", "this", "->", "container", "[", "'config'", ...
Convert other exception to service exception. @param Exception $e @return ServiceException
[ "Convert", "other", "exception", "to", "service", "exception", "." ]
7ad513562e333599642d5697ee45572d7d9e713d
https://github.com/crcms/microservice-framework/blob/7ad513562e333599642d5697ee45572d7d9e713d/src/Foundation/Exceptions/ExceptionHandler.php#L159-L173
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getUri
public function getUri(bool $standardized = false): string { if ($standardized) { return $this->fedora->standardizeUri($this->uri); } else { return $this->fedora->sanitizeUri($this->uri); } }
php
public function getUri(bool $standardized = false): string { if ($standardized) { return $this->fedora->standardizeUri($this->uri); } else { return $this->fedora->sanitizeUri($this->uri); } }
[ "public", "function", "getUri", "(", "bool", "$", "standardized", "=", "false", ")", ":", "string", "{", "if", "(", "$", "standardized", ")", "{", "return", "$", "this", "->", "fedora", "->", "standardizeUri", "(", "$", "this", "->", "uri", ")", ";", ...
Returns resource's Fedora URI @param bool $standardized should the Uri be standardized (in the form used in a triplestore) or current Fedora connection specific @return string
[ "Returns", "resource", "s", "Fedora", "URI" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L158-L164
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getId
public function getId(): string { $ids = $this->getIds(); if (count($ids) === 0) { throw new NoAcdhId(); } $acdhId = null; foreach ($ids as $id) { $inIdNmsp = strpos($id, RC::idNmsp()) === 0; $inVocabsNmsp = strpos($id, RC::vocabsNmsp()) === 0; if ($inIdNmsp || $inVocabsNmsp) { if ($acdhId !== null) { throw new ManyAcdhIds(); } $acdhId = $id; } } if ($acdhId === null) { throw new NoAcdhId(); } return $acdhId; }
php
public function getId(): string { $ids = $this->getIds(); if (count($ids) === 0) { throw new NoAcdhId(); } $acdhId = null; foreach ($ids as $id) { $inIdNmsp = strpos($id, RC::idNmsp()) === 0; $inVocabsNmsp = strpos($id, RC::vocabsNmsp()) === 0; if ($inIdNmsp || $inVocabsNmsp) { if ($acdhId !== null) { throw new ManyAcdhIds(); } $acdhId = $id; } } if ($acdhId === null) { throw new NoAcdhId(); } return $acdhId; }
[ "public", "function", "getId", "(", ")", ":", "string", "{", "$", "ids", "=", "$", "this", "->", "getIds", "(", ")", ";", "if", "(", "count", "(", "$", "ids", ")", "===", "0", ")", "{", "throw", "new", "NoAcdhId", "(", ")", ";", "}", "$", "ac...
Returns resource's ACDH UUID. If there is no or are many ACDH UUIDs, an error is thrown. @return string @throws RuntimeException @see getIds()
[ "Returns", "resource", "s", "ACDH", "UUID", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L175-L195
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getIds
public function getIds(): array { $this->loadMetadata(); $ids = array(); foreach ($this->metadata->allResources(RC::idProp()) as $i) { $ids[] = $i->getUri(); } return $ids; }
php
public function getIds(): array { $this->loadMetadata(); $ids = array(); foreach ($this->metadata->allResources(RC::idProp()) as $i) { $ids[] = $i->getUri(); } return $ids; }
[ "public", "function", "getIds", "(", ")", ":", "array", "{", "$", "this", "->", "loadMetadata", "(", ")", ";", "$", "ids", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "metadata", "->", "allResources", "(", "RC", "::", "idProp", ...
Returns an array of resource's IDs. If you want to get an ACDH ID, use the getId() method. @return array @see getId()
[ "Returns", "an", "array", "of", "resource", "s", "IDs", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L205-L212
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.delete
public function delete(bool $deep = false, bool $children = false, bool $references = false) { $this->uri = $this->fedora->sanitizeUri($this->getUri()); $fedoraChildren = $this->getMetadata()->allResources(self::CONTAINS_PROP); if (count($fedoraChildren) > 0) { throw new RuntimeException("A resource has Fedora children"); } $request = new Request('DELETE', $this->uri); $this->fedora->sendRequest($request); $this->fedora->getCache()->delete($this); if ($deep) { $request = new Request('DELETE', $this->uri . '/fcr:tombstone'); $this->fedora->sendRequest($request); } try { $this->getAcl()->deleteAcl(); } catch (NotFound $e) { } catch (Deleted $e) { } if ($children) { foreach ($this->getChildren() as $i) { $i->delete($deep, $children, $references); } } if ($references) { $id = $this->getId(); $query = new SimpleQuery('SELECT * WHERE {?res ?prop ?@}'); $query->setValues(array($id)); $results = $this->fedora->runQuery($query); foreach ($results as $i) { try { $res = $this->fedora->getResourceByUri($i->res); $meta = $res->getMetadata(); foreach ($meta->propertyUris() as $prop) { $meta->deleteResource($prop, $id); } $res->setMetadata($meta); $res->updateMetadata(self::OVERWRITE); } catch (Deleted $e) { } catch (NotFound $e) { } } } }
php
public function delete(bool $deep = false, bool $children = false, bool $references = false) { $this->uri = $this->fedora->sanitizeUri($this->getUri()); $fedoraChildren = $this->getMetadata()->allResources(self::CONTAINS_PROP); if (count($fedoraChildren) > 0) { throw new RuntimeException("A resource has Fedora children"); } $request = new Request('DELETE', $this->uri); $this->fedora->sendRequest($request); $this->fedora->getCache()->delete($this); if ($deep) { $request = new Request('DELETE', $this->uri . '/fcr:tombstone'); $this->fedora->sendRequest($request); } try { $this->getAcl()->deleteAcl(); } catch (NotFound $e) { } catch (Deleted $e) { } if ($children) { foreach ($this->getChildren() as $i) { $i->delete($deep, $children, $references); } } if ($references) { $id = $this->getId(); $query = new SimpleQuery('SELECT * WHERE {?res ?prop ?@}'); $query->setValues(array($id)); $results = $this->fedora->runQuery($query); foreach ($results as $i) { try { $res = $this->fedora->getResourceByUri($i->res); $meta = $res->getMetadata(); foreach ($meta->propertyUris() as $prop) { $meta->deleteResource($prop, $id); } $res->setMetadata($meta); $res->updateMetadata(self::OVERWRITE); } catch (Deleted $e) { } catch (NotFound $e) { } } } }
[ "public", "function", "delete", "(", "bool", "$", "deep", "=", "false", ",", "bool", "$", "children", "=", "false", ",", "bool", "$", "references", "=", "false", ")", "{", "$", "this", "->", "uri", "=", "$", "this", "->", "fedora", "->", "sanitizeUri...
Removes the resource from the Fedora. Please remember searching for children and references is done using a SPARQL query so any changes made since the beginning of the transaction won't be taken into account. @param bool $deep should tombstone resource will be deleted? @param bool $children should children be removed? @param bool $references should references to the resource be removed? (applies also for children when `$children == true`)
[ "Removes", "the", "resource", "from", "the", "Fedora", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L234-L284
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.move
public function move(string $destination): Response { $uri = $this->fedora->sanitizeUri($this->uri); $destination = $this->fedora->sanitizeUri($destination); $request = new Request('MOVE', $uri, ['Destination' => $destination]); $response = $this->fedora->sendRequest($request); $cache = $this->fedora->getCache(); $cache->deleteById($this->getId()); $cache->add($this); return $response; }
php
public function move(string $destination): Response { $uri = $this->fedora->sanitizeUri($this->uri); $destination = $this->fedora->sanitizeUri($destination); $request = new Request('MOVE', $uri, ['Destination' => $destination]); $response = $this->fedora->sendRequest($request); $cache = $this->fedora->getCache(); $cache->deleteById($this->getId()); $cache->add($this); return $response; }
[ "public", "function", "move", "(", "string", "$", "destination", ")", ":", "Response", "{", "$", "uri", "=", "$", "this", "->", "fedora", "->", "sanitizeUri", "(", "$", "this", "->", "uri", ")", ";", "$", "destination", "=", "$", "this", "->", "fedor...
Moves resource to another location. @param string $destination new location
[ "Moves", "resource", "to", "another", "location", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L291-L300
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getFixity
public function getFixity(): string { $uri = $this->fedora->sanitizeUri($this->uri); $request = new Request('GET', $uri . '/fcr:fixity'); $resp = $this->fedora->sendRequest($request); $graph = new Graph(); $graph->parse($resp->getBody()); $res = $graph->resource($uri); $fixityRes = $graph->resource($res->getResource('http://www.loc.gov/premis/rdf/v1#hasFixity')); $fixity = $fixityRes->getResource('http://www.loc.gov/premis/rdf/v1#hasMessageDigest'); return $fixity->getUri(); }
php
public function getFixity(): string { $uri = $this->fedora->sanitizeUri($this->uri); $request = new Request('GET', $uri . '/fcr:fixity'); $resp = $this->fedora->sendRequest($request); $graph = new Graph(); $graph->parse($resp->getBody()); $res = $graph->resource($uri); $fixityRes = $graph->resource($res->getResource('http://www.loc.gov/premis/rdf/v1#hasFixity')); $fixity = $fixityRes->getResource('http://www.loc.gov/premis/rdf/v1#hasMessageDigest'); return $fixity->getUri(); }
[ "public", "function", "getFixity", "(", ")", ":", "string", "{", "$", "uri", "=", "$", "this", "->", "fedora", "->", "sanitizeUri", "(", "$", "this", "->", "uri", ")", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "uri", ".", ...
Returns resource fixity. @throws Deleted @throws NotFound @throws RequestException
[ "Returns", "resource", "fixity", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L308-L319
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.setMetadata
public function setMetadata(Resource $metadata, bool $fixReferences = false) { $this->metadata = $metadata; $this->updated = false; $this->extractAclFromMetadata(); $this->fedora->getCache()->reload($this); if ($fixReferences) { $this->fedora->fixMetadataReferences($this->metadata); } }
php
public function setMetadata(Resource $metadata, bool $fixReferences = false) { $this->metadata = $metadata; $this->updated = false; $this->extractAclFromMetadata(); $this->fedora->getCache()->reload($this); if ($fixReferences) { $this->fedora->fixMetadataReferences($this->metadata); } }
[ "public", "function", "setMetadata", "(", "Resource", "$", "metadata", ",", "bool", "$", "fixReferences", "=", "false", ")", "{", "$", "this", "->", "metadata", "=", "$", "metadata", ";", "$", "this", "->", "updated", "=", "false", ";", "$", "this", "-...
Replaces resource metadata with a given RDF graph. New metadata are not automatically written back to the Fedora. Use the updateMetadata() method to write them back. @param EasyRdf\Resource $metadata @param bool $fixReferences Should reference to other repository resources be switched into corresponding UUIDs? @see updateMetadata()
[ "Replaces", "resource", "metadata", "with", "a", "given", "RDF", "graph", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L332-L343
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getMetadata
public function getMetadata(bool $force = false): Resource { $this->loadMetadata($force); return $this->metadata->copy(); }
php
public function getMetadata(bool $force = false): Resource { $this->loadMetadata($force); return $this->metadata->copy(); }
[ "public", "function", "getMetadata", "(", "bool", "$", "force", "=", "false", ")", ":", "Resource", "{", "$", "this", "->", "loadMetadata", "(", "$", "force", ")", ";", "return", "$", "this", "->", "metadata", "->", "copy", "(", ")", ";", "}" ]
Returns resource metadata. Fetches them from the Fedora if they were not fetched already. A deep copy of metadata is returned meaning adjusting the returned object does not automatically affect the resource metadata. Use the setMetadata() method to write back the changes you made. @param bool $force enforce fetch from Fedora (when you want to make sure metadata are in line with ones in the Fedora or e.g. reset them back to their current state in Fedora) @return \EasyRdf\Resource @see updateMetadata() @see setMetadata()
[ "Returns", "resource", "metadata", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L435-L438
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.loadMetadata
protected function loadMetadata(bool $force = false) { if (!$this->metadata || $force) { $meta = $this->getMetadataFromFedora(); if (count($meta->propertyUris()) === 0) { throw new RuntimeException('No resource metadata. Please check a value of the fedoraApiUrl configuration property.'); } $this->setMetadata($meta); } }
php
protected function loadMetadata(bool $force = false) { if (!$this->metadata || $force) { $meta = $this->getMetadataFromFedora(); if (count($meta->propertyUris()) === 0) { throw new RuntimeException('No resource metadata. Please check a value of the fedoraApiUrl configuration property.'); } $this->setMetadata($meta); } }
[ "protected", "function", "loadMetadata", "(", "bool", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "metadata", "||", "$", "force", ")", "{", "$", "meta", "=", "$", "this", "->", "getMetadataFromFedora", "(", ")", ";", "if"...
Loads current metadata from the Fedora. @param bool $force enforce fetch from Fedora (when you want to make sure metadata are in line with ones in the Fedora or e.g. reset them back to their current state in Fedora)
[ "Loads", "current", "metadata", "from", "the", "Fedora", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L447-L457
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getMetadataFromFedora
private function getMetadataFromFedora(): Resource { $uri = $this->fedora->sanitizeUri($this->uri); $request = new Request('GET', $uri . '/fcr:metadata', ['Accept' => 'application/n-triples']); $resp = $this->fedora->sendRequest($request); $format = ''; $headers = $resp->getHeaders(); if (isset($headers['Content-Type'])) { $format = explode(';', $headers['Content-Type'][0])[0]; } $this->extractAcl($resp); $graph = new Graph(); $graph->parse($resp->getBody(), $format); $meta = $graph->resource($uri); return $meta; }
php
private function getMetadataFromFedora(): Resource { $uri = $this->fedora->sanitizeUri($this->uri); $request = new Request('GET', $uri . '/fcr:metadata', ['Accept' => 'application/n-triples']); $resp = $this->fedora->sendRequest($request); $format = ''; $headers = $resp->getHeaders(); if (isset($headers['Content-Type'])) { $format = explode(';', $headers['Content-Type'][0])[0]; } $this->extractAcl($resp); $graph = new Graph(); $graph->parse($resp->getBody(), $format); $meta = $graph->resource($uri); return $meta; }
[ "private", "function", "getMetadataFromFedora", "(", ")", ":", "Resource", "{", "$", "uri", "=", "$", "this", "->", "fedora", "->", "sanitizeUri", "(", "$", "this", "->", "uri", ")", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", ...
Fetches metadata from Fedora. @return Resource @throws RequestException @throws Deleted
[ "Fetches", "metadata", "from", "Fedora", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L465-L482
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getContent
public function getContent(): Response { $uri = $this->fedora->sanitizeUri($this->uri); $request = new Request('GET', $uri); return $this->fedora->sendRequest($request); }
php
public function getContent(): Response { $uri = $this->fedora->sanitizeUri($this->uri); $request = new Request('GET', $uri); return $this->fedora->sendRequest($request); }
[ "public", "function", "getContent", "(", ")", ":", "Response", "{", "$", "uri", "=", "$", "this", "->", "fedora", "->", "sanitizeUri", "(", "$", "this", "->", "uri", ")", ";", "$", "request", "=", "new", "Request", "(", "'GET'", ",", "$", "uri", ")...
Returns resource's binary content. @return Response PSR-7 response containing resource's binary content
[ "Returns", "resource", "s", "binary", "content", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L488-L492
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.updateContent
public function updateContent($data, bool $convert = false) { if (empty($data)) { return; } $this->loadMetadata(); if ($this->isA('http://www.w3.org/ns/ldp#NonRDFSource')) { $request = new Request('PUT', $this->getUri()); $request = Fedora::attachData($request, $data); $this->fedora->sendRequest($request); } else if ($convert) { $aclRules = $this->getAcl()->getRules(false); $this->uri = $this->fedora->sanitizeUri($this->uri); $this->delete(true); $newRes = $this->fedora->createResource($this->metadata, $data, $this->uri, 'PUT'); $this->uri = $newRes->getUri(); // restore acl rules foreach ($aclRules as $rule) { $rule->save(); } } else { throw new RuntimeException('Resource is not a binary one. Turn on the $convert parameter if you are sure what you are doing.'); } $this->loadMetadata(true); }
php
public function updateContent($data, bool $convert = false) { if (empty($data)) { return; } $this->loadMetadata(); if ($this->isA('http://www.w3.org/ns/ldp#NonRDFSource')) { $request = new Request('PUT', $this->getUri()); $request = Fedora::attachData($request, $data); $this->fedora->sendRequest($request); } else if ($convert) { $aclRules = $this->getAcl()->getRules(false); $this->uri = $this->fedora->sanitizeUri($this->uri); $this->delete(true); $newRes = $this->fedora->createResource($this->metadata, $data, $this->uri, 'PUT'); $this->uri = $newRes->getUri(); // restore acl rules foreach ($aclRules as $rule) { $rule->save(); } } else { throw new RuntimeException('Resource is not a binary one. Turn on the $convert parameter if you are sure what you are doing.'); } $this->loadMetadata(true); }
[ "public", "function", "updateContent", "(", "$", "data", ",", "bool", "$", "convert", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", ";", "}", "$", "this", "->", "loadMetadata", "(", ")", ";", "if", "(", "$...
Updates resource binary content in the Fedora. If the resource is not a binary resource (in Fedora terms), it can be converted. This means the existing Fedora resource will be deleted and the new one will be created. This means the resource will change its Fedora URI but the id property indicated by the "fedoraIdProp" config option (see init()) will be preserved. This means until you are using the id property values (and not Fedora URIs) to denote resources in your metadata, your metadata consistency will be preserved. @param mixed $data resource data as a string, file name or an array: ['contentType' => 'foo', 'data' => 'bar', 'filename' => 'baz.txt'] @param bool $convert if metadata-only resource be automatically converted to a binary one @throws \DomainException @see init()
[ "Updates", "resource", "binary", "content", "in", "the", "Fedora", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L514-L537
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getFedoraChildren
public function getFedoraChildren(): array { $children = []; foreach ($this->getMetadata()->allResources(self::CONTAINS_PROP) as $i) { $children[] = $this->fedora->getResourceByUri($i->getUri()); } return $children; }
php
public function getFedoraChildren(): array { $children = []; foreach ($this->getMetadata()->allResources(self::CONTAINS_PROP) as $i) { $children[] = $this->fedora->getResourceByUri($i->getUri()); } return $children; }
[ "public", "function", "getFedoraChildren", "(", ")", ":", "array", "{", "$", "children", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getMetadata", "(", ")", "->", "allResources", "(", "self", "::", "CONTAINS_PROP", ")", "as", "$", "i", ")",...
Returns all resource's Fedora children. A Fedora child is a resource pointed by the ldp:contains triple. All Fedora children URIs are nested in the parent's URI path but the deepness of such nesting can vary (e.g. both http://a/b and http://a/b/c/d can be Fedora children of the http://a depenging on how they were created). Fedora's parent-child relation is automatically maintained by the Fedora and depends on the way Fedora resources are created. @return array
[ "Returns", "all", "resource", "s", "Fedora", "children", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L612-L618
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getChildrenByProperty
public function getChildrenByProperty(string $property, string $value = ''): array { $query = $this->getChildrenQuery(); if ($value != '') { $param = new HasValue($property, $value); } else { $param = new HasProperty($property); } $query->addParameter($param); return $this->fedora->getResourcesByQuery($query); }
php
public function getChildrenByProperty(string $property, string $value = ''): array { $query = $this->getChildrenQuery(); if ($value != '') { $param = new HasValue($property, $value); } else { $param = new HasProperty($property); } $query->addParameter($param); return $this->fedora->getResourcesByQuery($query); }
[ "public", "function", "getChildrenByProperty", "(", "string", "$", "property", ",", "string", "$", "value", "=", "''", ")", ":", "array", "{", "$", "query", "=", "$", "this", "->", "getChildrenQuery", "(", ")", ";", "if", "(", "$", "value", "!=", "''",...
Returns all resource's children having a given property or a given value of a given property. It is assumed that child-parent relations are denoted by: `child -> config::relProp -> id <- config::idProp <- parent` metadata properties scheme. @param string $property fully qualified URI of the property @param string $value property value (optional) @return array
[ "Returns", "all", "resource", "s", "children", "having", "a", "given", "property", "or", "a", "given", "value", "of", "a", "given", "property", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L645-L654
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getChildrenByPropertyRegEx
public function getChildrenByPropertyRegEx(string $property, string $regEx, string $flags = 'i'): array { $query = $this->getChildrenQuery(); $query->addParameter(new MatchesRegEx($property, $regEx, $flags)); return $this->fedora->getResourcesByQuery($query); }
php
public function getChildrenByPropertyRegEx(string $property, string $regEx, string $flags = 'i'): array { $query = $this->getChildrenQuery(); $query->addParameter(new MatchesRegEx($property, $regEx, $flags)); return $this->fedora->getResourcesByQuery($query); }
[ "public", "function", "getChildrenByPropertyRegEx", "(", "string", "$", "property", ",", "string", "$", "regEx", ",", "string", "$", "flags", "=", "'i'", ")", ":", "array", "{", "$", "query", "=", "$", "this", "->", "getChildrenQuery", "(", ")", ";", "$"...
Returns all resource's children with a given property matching a given regular expression It is assumed that child-parent relations are denoted by: `child -> config::relProp -> id <- config::idProp <- parent` metadata properties scheme. @param string $property fully qualified URI of the property @param string $regEx regular expression to match @param string $flags regular expression flags @return array
[ "Returns", "all", "resource", "s", "children", "with", "a", "given", "property", "matching", "a", "given", "regular", "expression" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L669-L674
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getAclUrl
public function getAclUrl(bool $refresh = false): string { if ($refresh || $this->aclUrl === null) { $request = new Request('HEAD', $this->fedora->sanitizeUri($this->uri)); $response = $this->fedora->sendRequest($request); $this->extractAcl($response); // Fedora 4.7.5 doesn't provide ACL link header for binary resources // if the ACL id directly attached to the resource (sic!). // As a fallback we can try to extract it from the metadata (which // is done automatically in the setMetadata() method being called // by the getMetadata(true) method). if ($this->aclUrl == '') { $this->getMetadata(true); } } return $this->aclUrl; }
php
public function getAclUrl(bool $refresh = false): string { if ($refresh || $this->aclUrl === null) { $request = new Request('HEAD', $this->fedora->sanitizeUri($this->uri)); $response = $this->fedora->sendRequest($request); $this->extractAcl($response); // Fedora 4.7.5 doesn't provide ACL link header for binary resources // if the ACL id directly attached to the resource (sic!). // As a fallback we can try to extract it from the metadata (which // is done automatically in the setMetadata() method being called // by the getMetadata(true) method). if ($this->aclUrl == '') { $this->getMetadata(true); } } return $this->aclUrl; }
[ "public", "function", "getAclUrl", "(", "bool", "$", "refresh", "=", "false", ")", ":", "string", "{", "if", "(", "$", "refresh", "||", "$", "this", "->", "aclUrl", "===", "null", ")", "{", "$", "request", "=", "new", "Request", "(", "'HEAD'", ",", ...
Returns URL of the resources' ACL collection @param bool $refresh should ACL URL be reread @return string
[ "Returns", "URL", "of", "the", "resources", "ACL", "collection" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L681-L697
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getAcl
public function getAcl(bool $refresh = true): WebAcl { if ($refresh || $this->acl === null) { $this->getAclUrl($refresh); $this->acl = new WebAcl($this); } return $this->acl; }
php
public function getAcl(bool $refresh = true): WebAcl { if ($refresh || $this->acl === null) { $this->getAclUrl($refresh); $this->acl = new WebAcl($this); } return $this->acl; }
[ "public", "function", "getAcl", "(", "bool", "$", "refresh", "=", "true", ")", ":", "WebAcl", "{", "if", "(", "$", "refresh", "||", "$", "this", "->", "acl", "===", "null", ")", "{", "$", "this", "->", "getAclUrl", "(", "$", "refresh", ")", ";", ...
Returns a WebAcl object for access rules manipulation. @param bool $refresh should the ACL collection and rules be refreshed or read from cache (there are many scenarios when reading requiring ACL data to be outdated so the default behaviour is to refresh) @return WebAcl
[ "Returns", "a", "WebAcl", "object", "for", "access", "rules", "manipulation", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L706-L712
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/FedoraResource.php
FedoraResource.getSparqlTriples
private function getSparqlTriples(Resource $metadata): string { $uri = $this->fedora->sanitizeUri($this->uri); $res = $metadata->copy(self::$skipProp, self::$skipPropRegExp, $uri); // make sure the ACL property is in current transaction $aclProp = $res->getResource(WebAcl::ACL_LINK_PROP); if ($aclProp) { $res->deleteResource(WebAcl::ACL_LINK_PROP); if ($aclProp->getUri() !== 'http://fedora.info/definitions/v4/repository#inaccessibleResource') { $res->addResource(WebAcl::ACL_LINK_PROP, $this->fedora->sanitizeUri($aclProp->getUri())); } } $rdf = $res->getGraph()->serialise('ntriples'); return $rdf; }
php
private function getSparqlTriples(Resource $metadata): string { $uri = $this->fedora->sanitizeUri($this->uri); $res = $metadata->copy(self::$skipProp, self::$skipPropRegExp, $uri); // make sure the ACL property is in current transaction $aclProp = $res->getResource(WebAcl::ACL_LINK_PROP); if ($aclProp) { $res->deleteResource(WebAcl::ACL_LINK_PROP); if ($aclProp->getUri() !== 'http://fedora.info/definitions/v4/repository#inaccessibleResource') { $res->addResource(WebAcl::ACL_LINK_PROP, $this->fedora->sanitizeUri($aclProp->getUri())); } } $rdf = $res->getGraph()->serialise('ntriples'); return $rdf; }
[ "private", "function", "getSparqlTriples", "(", "Resource", "$", "metadata", ")", ":", "string", "{", "$", "uri", "=", "$", "this", "->", "fedora", "->", "sanitizeUri", "(", "$", "this", "->", "uri", ")", ";", "$", "res", "=", "$", "metadata", "->", ...
Serializes metadata to a form suitable for Fedora's SPARQL-update query. This means the "ntriples" format with subject URIs compliant with current Fedora connection and excluding properties Fedora reserves for itself (and rises errors when they are provided from the outside). @param \EasyRdf\Resource $metadata metadata to serialize @return string @see $skipProp @see $skipPropRegExp
[ "Serializes", "metadata", "to", "a", "form", "suitable", "for", "Fedora", "s", "SPARQL", "-", "update", "query", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/FedoraResource.php#L824-L839
train
secucard/secucard-connect-php-sdk
src/SecucardConnect/Product/Loyalty/CardGroupsService.php
CardGroupsService.checkPasscodeEnabled
public function checkPasscodeEnabled($cardGroupId, $transactionType, $cardNumber) { return $this->execute($cardGroupId, "checkPasscodeEnabled", null, ["action" => $transactionType, "cardnumber" => $cardNumber]); }
php
public function checkPasscodeEnabled($cardGroupId, $transactionType, $cardNumber) { return $this->execute($cardGroupId, "checkPasscodeEnabled", null, ["action" => $transactionType, "cardnumber" => $cardNumber]); }
[ "public", "function", "checkPasscodeEnabled", "(", "$", "cardGroupId", ",", "$", "transactionType", ",", "$", "cardNumber", ")", "{", "return", "$", "this", "->", "execute", "(", "$", "cardGroupId", ",", "\"checkPasscodeEnabled\"", ",", "null", ",", "[", "\"ac...
Check if a passcode is enabled for this card @param string $cardGroupId CRG_XYZ @param string $transactionType FORM_TRANSACTION_XYZ @param string $cardNumber Number of the card @return bool|null @throws GuzzleException @throws ApiError @throws AuthError @throws ClientError
[ "Check", "if", "a", "passcode", "is", "enabled", "for", "this", "card" ]
d990686095e4e02d0924fc12b9bf60140fe8efab
https://github.com/secucard/secucard-connect-php-sdk/blob/d990686095e4e02d0924fc12b9bf60140fe8efab/src/SecucardConnect/Product/Loyalty/CardGroupsService.php#L29-L32
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/SchemaObject.php
SchemaObject.getResource
public function getResource(bool $create = true, bool $uploadBinary = true): FedoraResource { if ($this->res === null) { try { $this->findResource(false, false); } catch (NotFound $e) { $this->updateRms($create, $uploadBinary); } } return $this->res; }
php
public function getResource(bool $create = true, bool $uploadBinary = true): FedoraResource { if ($this->res === null) { try { $this->findResource(false, false); } catch (NotFound $e) { $this->updateRms($create, $uploadBinary); } } return $this->res; }
[ "public", "function", "getResource", "(", "bool", "$", "create", "=", "true", ",", "bool", "$", "uploadBinary", "=", "true", ")", ":", "FedoraResource", "{", "if", "(", "$", "this", "->", "res", "===", "null", ")", "{", "try", "{", "$", "this", "->",...
Returns repository resource representing given real-world entity. If it does not exist, it can be created. @param bool $create should repository resource be created if it does not exist? @param bool $uploadBinary should binary data of the real-world entity be uploaded uppon repository resource creation? @return FedoraResource
[ "Returns", "repository", "resource", "representing", "given", "real", "-", "world", "entity", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/SchemaObject.php#L129-L138
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/SchemaObject.php
SchemaObject.getIds
public function getIds(): array { $ids = array($this->id); $meta = $this->getMetadata(); foreach ($meta->allResources(RC::idProp()) as $id) { $ids[] = $id->getUri(); } $ids = array_unique($ids); return $ids; }
php
public function getIds(): array { $ids = array($this->id); $meta = $this->getMetadata(); foreach ($meta->allResources(RC::idProp()) as $id) { $ids[] = $id->getUri(); } $ids = array_unique($ids); return $ids; }
[ "public", "function", "getIds", "(", ")", ":", "array", "{", "$", "ids", "=", "array", "(", "$", "this", "->", "id", ")", ";", "$", "meta", "=", "$", "this", "->", "getMetadata", "(", ")", ";", "foreach", "(", "$", "meta", "->", "allResources", "...
Returns all known ids @return array list of all ids
[ "Returns", "all", "known", "ids" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/SchemaObject.php#L157-L165
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/SchemaObject.php
SchemaObject.updateRms
public function updateRms(bool $create = true, bool $uploadBinary = true, string $path = '/'): FedoraResource { $this->created = $this->findResource($create, $uploadBinary, $path); // if it has just been created it would be a waste of time to update it if (!$this->created) { $meta = $this->getMetadata(); if ($this->metadata) { $meta->merge($this->metadata, $this->metadataPreserve); } $this->fedora->fixMetadataReferences($meta); $meta = $this->mergeMetadata($this->res->getMetadata(), $meta); $this->res->setMetadata($meta); $this->res->updateMetadata(); $binaryContent = $this->getBinaryData(); if ($uploadBinary && $binaryContent !== '') { $this->res->updateContent($binaryContent, true); } } return $this->res; }
php
public function updateRms(bool $create = true, bool $uploadBinary = true, string $path = '/'): FedoraResource { $this->created = $this->findResource($create, $uploadBinary, $path); // if it has just been created it would be a waste of time to update it if (!$this->created) { $meta = $this->getMetadata(); if ($this->metadata) { $meta->merge($this->metadata, $this->metadataPreserve); } $this->fedora->fixMetadataReferences($meta); $meta = $this->mergeMetadata($this->res->getMetadata(), $meta); $this->res->setMetadata($meta); $this->res->updateMetadata(); $binaryContent = $this->getBinaryData(); if ($uploadBinary && $binaryContent !== '') { $this->res->updateContent($binaryContent, true); } } return $this->res; }
[ "public", "function", "updateRms", "(", "bool", "$", "create", "=", "true", ",", "bool", "$", "uploadBinary", "=", "true", ",", "string", "$", "path", "=", "'/'", ")", ":", "FedoraResource", "{", "$", "this", "->", "created", "=", "$", "this", "->", ...
Updates repository resource representing a real-world entity stored in this object. @param bool $create should repository resource be created if it does not exist? @param bool $uploadBinary should binary data of the real-world entity be uploaded uppon repository resource creation? @param string $path where to create a resource (if it does not exist). If it it ends with a "/", the resource will be created as a child of a given collection). All the parents in the Fedora resource tree have to exist (you can not create "/foo/bar" if "/foo" does not exist already). @return FedoraResource
[ "Updates", "repository", "resource", "representing", "a", "real", "-", "world", "entity", "stored", "in", "this", "object", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/SchemaObject.php#L181-L203
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/SchemaObject.php
SchemaObject.setMetadata
public function setMetadata(Resource $meta, array $preserve = array()) { $this->metadata = $meta; $this->metadataPreserve = $preserve; }
php
public function setMetadata(Resource $meta, array $preserve = array()) { $this->metadata = $meta; $this->metadataPreserve = $preserve; }
[ "public", "function", "setMetadata", "(", "Resource", "$", "meta", ",", "array", "$", "preserve", "=", "array", "(", ")", ")", "{", "$", "this", "->", "metadata", "=", "$", "meta", ";", "$", "this", "->", "metadataPreserve", "=", "$", "preserve", ";", ...
Sets an external metadata to be appended to automatically generated ones. If a given metatada property exists both in automatically generated and provided metadata, then the final result depends on the $preserve parameter: - if the property is listed in the $preserve array, both automatically generated and provided values will be kept - if not, only values from provided metadata will be kept and automatically generated ones will be skipped @param Resource $meta external metadata @param array $preserve list of metadata properties to be kept - see above
[ "Sets", "an", "external", "metadata", "to", "be", "appended", "to", "automatically", "generated", "ones", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/SchemaObject.php#L231-L234
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/SchemaObject.php
SchemaObject.findResource
protected function findResource(bool $create = true, bool $uploadBinary = true, string $path = ''): bool { $ids = $this->getIds(); echo self::$debug ? "searching for " . implode(', ', $ids) . "\n" : ""; $result = ''; try { $this->res = $this->fedora->getResourceByIds($ids); $result = 'found in cache'; } catch (NotFound $e) { if (!$create) { throw $e; } $meta = $this->getMetadata(); $this->fedora->fixMetadataReferences($meta); $binary = $uploadBinary ? $this->getBinaryData() : ''; $method = substr($path, -1) == '/' || $path === '' ? 'POST' : 'PUT'; $this->res = $this->fedora->createResource($meta, $binary, $path, $method); $result = 'not found - created'; } echo self::$debug ? "\t" . $result . " - " . $this->res->getUri(true) . "\n" : ""; return $result == 'not found - created'; }
php
protected function findResource(bool $create = true, bool $uploadBinary = true, string $path = ''): bool { $ids = $this->getIds(); echo self::$debug ? "searching for " . implode(', ', $ids) . "\n" : ""; $result = ''; try { $this->res = $this->fedora->getResourceByIds($ids); $result = 'found in cache'; } catch (NotFound $e) { if (!$create) { throw $e; } $meta = $this->getMetadata(); $this->fedora->fixMetadataReferences($meta); $binary = $uploadBinary ? $this->getBinaryData() : ''; $method = substr($path, -1) == '/' || $path === '' ? 'POST' : 'PUT'; $this->res = $this->fedora->createResource($meta, $binary, $path, $method); $result = 'not found - created'; } echo self::$debug ? "\t" . $result . " - " . $this->res->getUri(true) . "\n" : ""; return $result == 'not found - created'; }
[ "protected", "function", "findResource", "(", "bool", "$", "create", "=", "true", ",", "bool", "$", "uploadBinary", "=", "true", ",", "string", "$", "path", "=", "''", ")", ":", "bool", "{", "$", "ids", "=", "$", "this", "->", "getIds", "(", ")", "...
Tries to find a repository resource representing a given object. @param bool $create should repository resource be created if it was not found? @param bool $uploadBinary should binary data of the real-world entity be uploaded uppon repository resource creation? @param string $path where to create a resource (if it does not exist). If it it ends with a "/", the resource will be created as a child of a given collection). All the parents in the Fedora resource tree have to exist (you can not create "/foo/bar" if "/foo" does not exist already). @return boolean if a repository resource was found
[ "Tries", "to", "find", "a", "repository", "resource", "representing", "a", "given", "object", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/SchemaObject.php#L249-L273
train
acdh-oeaw/repo-php-util
src/acdhOeaw/schema/dissemination/Match.php
Match.getMetadata
public function getMetadata(): Resource { $meta = (new Graph())->resource('.'); $meta->addResource(RC::relProp(), $this->service->getResource()->getId()); $meta->addResource(RC::idProp(), $this->getId()); $meta->addLiteral(RC::titleProp(), 'A dissemination service matching rule'); $meta->addResource(RC::get('fedoraServiceMatchProp'), $this->property); $meta->addLiteral(RC::get('fedoraServiceMatchValue'), $this->value); $meta->addLiteral(RC::get('fedoraServiceMatchRequired'), $this->required); return $meta; }
php
public function getMetadata(): Resource { $meta = (new Graph())->resource('.'); $meta->addResource(RC::relProp(), $this->service->getResource()->getId()); $meta->addResource(RC::idProp(), $this->getId()); $meta->addLiteral(RC::titleProp(), 'A dissemination service matching rule'); $meta->addResource(RC::get('fedoraServiceMatchProp'), $this->property); $meta->addLiteral(RC::get('fedoraServiceMatchValue'), $this->value); $meta->addLiteral(RC::get('fedoraServiceMatchRequired'), $this->required); return $meta; }
[ "public", "function", "getMetadata", "(", ")", ":", "Resource", "{", "$", "meta", "=", "(", "new", "Graph", "(", ")", ")", "->", "resource", "(", "'.'", ")", ";", "$", "meta", "->", "addResource", "(", "RC", "::", "relProp", "(", ")", ",", "$", "...
Returns metadata describing the match @return Resource
[ "Returns", "metadata", "describing", "the", "match" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/schema/dissemination/Match.php#L119-L131
train
polyfony-inc/polyfony
Private/Polyfony/Record.php
Record.tget
public function tget(string $column, int $length=32) { // we get the raw value, truncate it, and escape it afterwards return strlen($this->get($column, true)) > $length ? Format::htmlSafe( Format::truncate( $this->get($column, true), $length ) ) : $this->get($column); }
php
public function tget(string $column, int $length=32) { // we get the raw value, truncate it, and escape it afterwards return strlen($this->get($column, true)) > $length ? Format::htmlSafe( Format::truncate( $this->get($column, true), $length ) ) : $this->get($column); }
[ "public", "function", "tget", "(", "string", "$", "column", ",", "int", "$", "length", "=", "32", ")", "{", "// we get the raw value, truncate it, and escape it afterwards", "return", "strlen", "(", "$", "this", "->", "get", "(", "$", "column", ",", "true", ")...
get a truncated field, that is safe to place in a HTML document
[ "get", "a", "truncated", "field", "that", "is", "safe", "to", "place", "in", "a", "HTML", "document" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Record.php#L8-L18
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.validateGraph
static public function validateGraph(Graph $graph, Fedora $fedora): array { $results = array(); foreach ($graph->resources() as $i) { $results = array_merge($results, self::validateResource($i, $fedora)); } return $results; }
php
static public function validateGraph(Graph $graph, Fedora $fedora): array { $results = array(); foreach ($graph->resources() as $i) { $results = array_merge($results, self::validateResource($i, $fedora)); } return $results; }
[ "static", "public", "function", "validateGraph", "(", "Graph", "$", "graph", ",", "Fedora", "$", "fedora", ")", ":", "array", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "graph", "->", "resources", "(", ")", "as", "$", "i",...
Checks a given RDF graph against ontology in a given Fedora repository. @param Graph $graph RDF graph to be checked @param Fedora $fedora repository connection object @return array list of errors
[ "Checks", "a", "given", "RDF", "graph", "against", "ontology", "in", "a", "given", "Fedora", "repository", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L71-L77
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.validateResource
static public function validateResource(Resource $res, Fedora $fedora): array { $results = array(); foreach ($res->propertyUris() as $prop) { if ($prop === self::RDFS_TYPE) { $tmp = self::checkClass($res, $fedora); } else { $tmp = self::checkProperty($prop, $res, $fedora); } $results = array_merge($results, $tmp); } return $results; }
php
static public function validateResource(Resource $res, Fedora $fedora): array { $results = array(); foreach ($res->propertyUris() as $prop) { if ($prop === self::RDFS_TYPE) { $tmp = self::checkClass($res, $fedora); } else { $tmp = self::checkProperty($prop, $res, $fedora); } $results = array_merge($results, $tmp); } return $results; }
[ "static", "public", "function", "validateResource", "(", "Resource", "$", "res", ",", "Fedora", "$", "fedora", ")", ":", "array", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "res", "->", "propertyUris", "(", ")", "as", "$", ...
Checks a given EasyRdf\Resource against ontology in a given repository. @param Resource $res @param Fedora $fedora repository connection object @return array list of errors
[ "Checks", "a", "given", "EasyRdf", "\\", "Resource", "against", "ontology", "in", "a", "given", "repository", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L85-L96
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.printResults
static public function printResults(array $results, string $format = 'text') { if ($format == 'tsv') { echo "subject\tmessage\tproperty\tvalue\n"; foreach ($results as $i) { echo $i . "\n"; } } else { $len = array(9, 9, 10, 7); foreach ($results as $i) { $len[0] = max($len[0], mb_strlen($i->resUri) + 2); $len[1] = max($len[1], mb_strlen($i->message) + 2); $len[2] = max($len[2], mb_strlen($i->property) + 2); $len[3] = max($len[3], mb_strlen($i->value) + 2); } $format = sprintf("%% %ds%% %ds%% %ds%% %ds\n", $len[0], $len[1], $len[2], $len[3]); printf($format, 'subject', 'message', 'property', 'value'); foreach ($results as $i) { printf($format, $i->resUri, $i->message, $i->property, $i->value); } } }
php
static public function printResults(array $results, string $format = 'text') { if ($format == 'tsv') { echo "subject\tmessage\tproperty\tvalue\n"; foreach ($results as $i) { echo $i . "\n"; } } else { $len = array(9, 9, 10, 7); foreach ($results as $i) { $len[0] = max($len[0], mb_strlen($i->resUri) + 2); $len[1] = max($len[1], mb_strlen($i->message) + 2); $len[2] = max($len[2], mb_strlen($i->property) + 2); $len[3] = max($len[3], mb_strlen($i->value) + 2); } $format = sprintf("%% %ds%% %ds%% %ds%% %ds\n", $len[0], $len[1], $len[2], $len[3]); printf($format, 'subject', 'message', 'property', 'value'); foreach ($results as $i) { printf($format, $i->resUri, $i->message, $i->property, $i->value); } } }
[ "static", "public", "function", "printResults", "(", "array", "$", "results", ",", "string", "$", "format", "=", "'text'", ")", "{", "if", "(", "$", "format", "==", "'tsv'", ")", "{", "echo", "\"subject\\tmessage\\tproperty\\tvalue\\n\"", ";", "foreach", "(", ...
Pretty prints a list of errors. @param array $results list of errors @param string $format print format: tsv or text
[ "Pretty", "prints", "a", "list", "of", "errors", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L113-L133
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.checkClass
static private function checkClass(Resource $res, Fedora $fedora): array { if (self::$classes === null) { self::loadClasses($fedora); } $ret = array(); foreach ($res->allResources(self::RDFS_TYPE) as $i) { $i = $i->getUri(); if (!isset(self::$classes[$i])) { $ret[] = new Error($res->getUri(), 'unknown class', $i); } } return $ret; }
php
static private function checkClass(Resource $res, Fedora $fedora): array { if (self::$classes === null) { self::loadClasses($fedora); } $ret = array(); foreach ($res->allResources(self::RDFS_TYPE) as $i) { $i = $i->getUri(); if (!isset(self::$classes[$i])) { $ret[] = new Error($res->getUri(), 'unknown class', $i); } } return $ret; }
[ "static", "private", "function", "checkClass", "(", "Resource", "$", "res", ",", "Fedora", "$", "fedora", ")", ":", "array", "{", "if", "(", "self", "::", "$", "classes", "===", "null", ")", "{", "self", "::", "loadClasses", "(", "$", "fedora", ")", ...
Checks if a resource is of known class @param Resource $res resource to be checked @param Fedora $fedora repository connection object @return array list of errors
[ "Checks", "if", "a", "resource", "is", "of", "known", "class" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L141-L153
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.checkProperty
static private function checkProperty(string $property, Resource $res, Fedora $fedora): array { $uri = $res->getUri(); $ret = array(); try { $propDef = self::getPropertyDef($property, $fedora); if (!self::checkRangeDomain($res, $propDef->getDomain())) { $ret[] = new Error($uri, 'wrong domain', '', $property); } list($matchType, $wrongType) = $propDef->fetchValues($res); foreach ($wrongType as $i) { $ret[] = new Error($uri, 'wrong value type (literal/uri)', (string) $i, $property); } foreach ($matchType as $i) { if (!self::checkRangeDomain($i, $propDef->getRange())) { $ret[] = new Error($uri, 'wrong range', $i->getUri(), $property); } } } catch (RuntimeException $e) { switch ($e->getCode()) { case 10: $ret[] = new Error($uri, 'unknown property', '', $property); break; case 11: $ret[] = new Error($uri, 'wrongly defined property', '', $property); break; case 12: $ret[] = new Error($uri, 'wrongly defined property', '', $property); break; default: throw $e; } } return $ret; }
php
static private function checkProperty(string $property, Resource $res, Fedora $fedora): array { $uri = $res->getUri(); $ret = array(); try { $propDef = self::getPropertyDef($property, $fedora); if (!self::checkRangeDomain($res, $propDef->getDomain())) { $ret[] = new Error($uri, 'wrong domain', '', $property); } list($matchType, $wrongType) = $propDef->fetchValues($res); foreach ($wrongType as $i) { $ret[] = new Error($uri, 'wrong value type (literal/uri)', (string) $i, $property); } foreach ($matchType as $i) { if (!self::checkRangeDomain($i, $propDef->getRange())) { $ret[] = new Error($uri, 'wrong range', $i->getUri(), $property); } } } catch (RuntimeException $e) { switch ($e->getCode()) { case 10: $ret[] = new Error($uri, 'unknown property', '', $property); break; case 11: $ret[] = new Error($uri, 'wrongly defined property', '', $property); break; case 12: $ret[] = new Error($uri, 'wrongly defined property', '', $property); break; default: throw $e; } } return $ret; }
[ "static", "private", "function", "checkProperty", "(", "string", "$", "property", ",", "Resource", "$", "res", ",", "Fedora", "$", "fedora", ")", ":", "array", "{", "$", "uri", "=", "$", "res", "->", "getUri", "(", ")", ";", "$", "ret", "=", "array",...
Checks if a given property is defined in the ontology and if all its values for a given resource match property definition provided by the ontology. @param string $property RDF property to be checked @param Resource $res resource containing given property values @param Fedora $fedora repository connection object @return array list of errors @throws RuntimeException
[ "Checks", "if", "a", "given", "property", "is", "defined", "in", "the", "ontology", "and", "if", "all", "its", "values", "for", "a", "given", "resource", "match", "property", "definition", "provided", "by", "the", "ontology", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L165-L201
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.getPropertyDef
static private function getPropertyDef(string $property, Fedora $fedora): OntologyProperty { if (!isset(self::$cache[$property])) { self::$cache[$property] = new OntologyProperty($property, $fedora); } return self::$cache[$property]; }
php
static private function getPropertyDef(string $property, Fedora $fedora): OntologyProperty { if (!isset(self::$cache[$property])) { self::$cache[$property] = new OntologyProperty($property, $fedora); } return self::$cache[$property]; }
[ "static", "private", "function", "getPropertyDef", "(", "string", "$", "property", ",", "Fedora", "$", "fedora", ")", ":", "OntologyProperty", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "cache", "[", "$", "property", "]", ")", ")", "{", "sel...
Fetches property definition from cache. Creates a deifinition if it does not exist. @param string $property RDF property URI @param Fedora $fedora repository connection object @return \acdhOeaw\util\metadataValidator\OntologyProperty
[ "Fetches", "property", "definition", "from", "cache", ".", "Creates", "a", "deifinition", "if", "it", "does", "not", "exist", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L210-L215
train
acdh-oeaw/repo-php-util
src/acdhOeaw/util/metadataValidator/MetadataValidator.php
MetadataValidator.loadClasses
static private function loadClasses(Fedora $fedora) { $ontologyLoc = RC::get('fedoraApiUrl') . '/' . RC::get('doorkeeperOntologyLocation') . '/'; $query = new SimpleQuery(" select ?fRes ?id ?parent where { ?fRes a <http://www.w3.org/2002/07/owl#Class> . ?fRes ?@ ?id . optional { ?fRes <http://www.w3.org/2000/01/rdf-schema#subClassOf> / (^?@ / <http://www.w3.org/2000/01/rdf-schema#subClassOf>)* ?parent . } filter regex(str(?fRes), ?#) } "); $query->setValues(array(RC::idProp(), RC::idProp(), $ontologyLoc)); $res = $fedora->runQuery($query); self::$classes = array(); foreach ($res as $i) { $id = $i->id->getUri(); if (!isset(self::$classes[$id])) { self::$classes[$id] = array($id); } if (isset($i->parent) && $i->parent) { self::$classes[$id][] = $i->parent->getUri(); } } }
php
static private function loadClasses(Fedora $fedora) { $ontologyLoc = RC::get('fedoraApiUrl') . '/' . RC::get('doorkeeperOntologyLocation') . '/'; $query = new SimpleQuery(" select ?fRes ?id ?parent where { ?fRes a <http://www.w3.org/2002/07/owl#Class> . ?fRes ?@ ?id . optional { ?fRes <http://www.w3.org/2000/01/rdf-schema#subClassOf> / (^?@ / <http://www.w3.org/2000/01/rdf-schema#subClassOf>)* ?parent . } filter regex(str(?fRes), ?#) } "); $query->setValues(array(RC::idProp(), RC::idProp(), $ontologyLoc)); $res = $fedora->runQuery($query); self::$classes = array(); foreach ($res as $i) { $id = $i->id->getUri(); if (!isset(self::$classes[$id])) { self::$classes[$id] = array($id); } if (isset($i->parent) && $i->parent) { self::$classes[$id][] = $i->parent->getUri(); } } }
[ "static", "private", "function", "loadClasses", "(", "Fedora", "$", "fedora", ")", "{", "$", "ontologyLoc", "=", "RC", "::", "get", "(", "'fedoraApiUrl'", ")", ".", "'/'", ".", "RC", "::", "get", "(", "'doorkeeperOntologyLocation'", ")", ".", "'/'", ";", ...
Loads classes defined in the ontology. @param Fedora $fedora repository connection object
[ "Loads", "classes", "defined", "in", "the", "ontology", "." ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/util/metadataValidator/MetadataValidator.php#L251-L276
train
polyfony-inc/polyfony
Private/Polyfony/Database.php
Database.describe
public static function describe(string $table) :array { // set the cachefile name $cache_name = ucfirst($table).'Nulls'; // check if it has been cached already if(Cache::has($cache_name)) { // get it from the cache return Cache::get($cache_name); } // else it is not available from the cache else { // the list of allowed null columns $allowed_nulls = []; // query the database foreach(self::query() ->query(str_replace('*table*', $table, self::$_config['nulls']['query'])) ->execute() as $column) { // populate the list $allowed_nulls[$column->get(self::$_config['nulls']['column_for_name'])] = self::$_config['nulls']['true'] == $column->get(self::$_config['nulls']['column_for_value']) ? true : false; } // save the results in the cache Cache::put($cache_name, $allowed_nulls); // and finaly return the results return $allowed_nulls; } }
php
public static function describe(string $table) :array { // set the cachefile name $cache_name = ucfirst($table).'Nulls'; // check if it has been cached already if(Cache::has($cache_name)) { // get it from the cache return Cache::get($cache_name); } // else it is not available from the cache else { // the list of allowed null columns $allowed_nulls = []; // query the database foreach(self::query() ->query(str_replace('*table*', $table, self::$_config['nulls']['query'])) ->execute() as $column) { // populate the list $allowed_nulls[$column->get(self::$_config['nulls']['column_for_name'])] = self::$_config['nulls']['true'] == $column->get(self::$_config['nulls']['column_for_value']) ? true : false; } // save the results in the cache Cache::put($cache_name, $allowed_nulls); // and finaly return the results return $allowed_nulls; } }
[ "public", "static", "function", "describe", "(", "string", "$", "table", ")", ":", "array", "{", "// set the cachefile name", "$", "cache_name", "=", "ucfirst", "(", "$", "table", ")", ".", "'Nulls'", ";", "// check if it has been cached already", "if", "(", "Ca...
get the description of a table
[ "get", "the", "description", "of", "a", "table" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Database.php#L181-L218
train
polyfony-inc/polyfony
Private/Polyfony/Controller.php
Controller.forward
final public function forward(string $controller, $action = null) :void { // get the current route as a base $route = Router::getCurrentRoute(); // and alter it $route->controller = $controller; $route->action = $action; // forward to the new route Router::forward($route); }
php
final public function forward(string $controller, $action = null) :void { // get the current route as a base $route = Router::getCurrentRoute(); // and alter it $route->controller = $controller; $route->action = $action; // forward to the new route Router::forward($route); }
[ "final", "public", "function", "forward", "(", "string", "$", "controller", ",", "$", "action", "=", "null", ")", ":", "void", "{", "// get the current route as a base", "$", "route", "=", "Router", "::", "getCurrentRoute", "(", ")", ";", "// and alter it", "$...
forward to another controller in the same bundle
[ "forward", "to", "another", "controller", "in", "the", "same", "bundle" ]
76dac2f4141c8f480370236295c07dfa52e5c589
https://github.com/polyfony-inc/polyfony/blob/76dac2f4141c8f480370236295c07dfa52e5c589/Private/Polyfony/Controller.php#L56-L68
train
ventoviro/windwalker-core
src/Core/Utilities/Classes/ArrayAccessTrait.php
ArrayAccessTrait.offsetGet
public function offsetGet($offset) { $field = $this->dataField; if (empty($this->{$field}[$offset])) { return null; } return $this->{$field}[$offset]; }
php
public function offsetGet($offset) { $field = $this->dataField; if (empty($this->{$field}[$offset])) { return null; } return $this->{$field}[$offset]; }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "$", "field", "=", "$", "this", "->", "dataField", ";", "if", "(", "empty", "(", "$", "this", "->", "{", "$", "field", "}", "[", "$", "offset", "]", ")", ")", "{", "return", "null",...
Get a value of property. @param mixed $offset Property key. @return mixed The value of this property.
[ "Get", "a", "value", "of", "property", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Utilities/Classes/ArrayAccessTrait.php#L46-L55
train
ventoviro/windwalker-core
src/Core/Utilities/Classes/ArrayAccessTrait.php
ArrayAccessTrait.offsetSet
public function offsetSet($offset, $value) { $field = $this->dataField; if ($offset !== null) { $this->{$field}[$offset] = $value; } else { array_push($this->{$field}, $value); } }
php
public function offsetSet($offset, $value) { $field = $this->dataField; if ($offset !== null) { $this->{$field}[$offset] = $value; } else { array_push($this->{$field}, $value); } }
[ "public", "function", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", "{", "$", "field", "=", "$", "this", "->", "dataField", ";", "if", "(", "$", "offset", "!==", "null", ")", "{", "$", "this", "->", "{", "$", "field", "}", "[", "$", ...
Set value to property @param mixed $offset Property key. @param mixed $value Property value to set. @return void
[ "Set", "value", "to", "property" ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Utilities/Classes/ArrayAccessTrait.php#L65-L74
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/metadataQuery/QueryParameter.php
QueryParameter.escapeUri
static public function escapeUri(string $uri): string { self::initSerializer(); return self::$serializer->serialiseValue(new Resource($uri)); }
php
static public function escapeUri(string $uri): string { self::initSerializer(); return self::$serializer->serialiseValue(new Resource($uri)); }
[ "static", "public", "function", "escapeUri", "(", "string", "$", "uri", ")", ":", "string", "{", "self", "::", "initSerializer", "(", ")", ";", "return", "self", "::", "$", "serializer", "->", "serialiseValue", "(", "new", "Resource", "(", "$", "uri", ")...
Escapes a given string as an URI @param string $uri @return string
[ "Escapes", "a", "given", "string", "as", "an", "URI" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/metadataQuery/QueryParameter.php#L68-L71
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/metadataQuery/QueryParameter.php
QueryParameter.escapeLiteral
static public function escapeLiteral(string $literal): string { self::initSerializer(); $value = self::$serializer->serialiseValue(new Literal($literal)); return $value; }
php
static public function escapeLiteral(string $literal): string { self::initSerializer(); $value = self::$serializer->serialiseValue(new Literal($literal)); return $value; }
[ "static", "public", "function", "escapeLiteral", "(", "string", "$", "literal", ")", ":", "string", "{", "self", "::", "initSerializer", "(", ")", ";", "$", "value", "=", "self", "::", "$", "serializer", "->", "serialiseValue", "(", "new", "Literal", "(", ...
Escapes a given string as a literal @param string $literal @return string
[ "Escapes", "a", "given", "string", "as", "a", "literal" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/metadataQuery/QueryParameter.php#L79-L83
train
hnhdigital-os/laravel-model-schema
src/Exceptions/ValidationException.php
ValidationException.getResponse
public function getResponse($route, $parameters, $config = []) { // Copy standard response. $response = self::$response; // Fill the response. array_set($response, 'is_error', true); array_set($response, 'message', $this->getMessage()); array_set($response, 'fields', array_keys($this->validator->errors()->messages())); array_set($response, 'feedback', $this->validator->errors()->all()); array_set($response, 'errors', $this->validator->errors()); if (array_has($config, 'feedback.html')) { array_set( $response, 'feedback', '<ul><li>'.implode('</li><li>', array_get($response, 'feedback')).'</li></ul>' ); } // JSON response required. if (request()->ajax() || request()->wantsJson()) { return response() ->json($response, 422); } // Redirect response, flash to session. session()->flash('is_error', true); session()->flash('message', array_get($response, 'message', '')); session()->flash('feedback', array_get($response, 'feedback', '')); session()->flash('fields', array_get($response, 'fields', [])); // Redirect to provided route. return redirect() ->route($route, $parameters) ->withErrors($this->getValidator()) ->withInput(); }
php
public function getResponse($route, $parameters, $config = []) { // Copy standard response. $response = self::$response; // Fill the response. array_set($response, 'is_error', true); array_set($response, 'message', $this->getMessage()); array_set($response, 'fields', array_keys($this->validator->errors()->messages())); array_set($response, 'feedback', $this->validator->errors()->all()); array_set($response, 'errors', $this->validator->errors()); if (array_has($config, 'feedback.html')) { array_set( $response, 'feedback', '<ul><li>'.implode('</li><li>', array_get($response, 'feedback')).'</li></ul>' ); } // JSON response required. if (request()->ajax() || request()->wantsJson()) { return response() ->json($response, 422); } // Redirect response, flash to session. session()->flash('is_error', true); session()->flash('message', array_get($response, 'message', '')); session()->flash('feedback', array_get($response, 'feedback', '')); session()->flash('fields', array_get($response, 'fields', [])); // Redirect to provided route. return redirect() ->route($route, $parameters) ->withErrors($this->getValidator()) ->withInput(); }
[ "public", "function", "getResponse", "(", "$", "route", ",", "$", "parameters", ",", "$", "config", "=", "[", "]", ")", "{", "// Copy standard response.", "$", "response", "=", "self", "::", "$", "response", ";", "// Fill the response.", "array_set", "(", "$...
Get a response to return. @return string|array
[ "Get", "a", "response", "to", "return", "." ]
ca0c51e9862aac43d19cf06fb8bb810d6bc7d41e
https://github.com/hnhdigital-os/laravel-model-schema/blob/ca0c51e9862aac43d19cf06fb8bb810d6bc7d41e/src/Exceptions/ValidationException.php#L56-L93
train
ventoviro/windwalker-core
src/Core/Application/WebApplication.php
WebApplication.dispatch
public function dispatch(Request $request, Response $response, $finalHandler = null) { /** @var AbstractPackage $package */ $package = $this->getPackage(); if (!$package) { throw new RouteNotFoundException('Can not find package to execute.', 404); } return $package->execute($request->getAttribute('_controller'), $request, $response); }
php
public function dispatch(Request $request, Response $response, $finalHandler = null) { /** @var AbstractPackage $package */ $package = $this->getPackage(); if (!$package) { throw new RouteNotFoundException('Can not find package to execute.', 404); } return $package->execute($request->getAttribute('_controller'), $request, $response); }
[ "public", "function", "dispatch", "(", "Request", "$", "request", ",", "Response", "$", "response", ",", "$", "finalHandler", "=", "null", ")", "{", "/** @var AbstractPackage $package */", "$", "package", "=", "$", "this", "->", "getPackage", "(", ")", ";", ...
Method as the Psr7 WebHttpServer handler. @param Request $request The Psr7 ServerRequest to get request params. @param Response $response The Psr7 Response interface to prepare respond data. @param callable $finalHandler The next handler to support middleware pattern. @return Response The returned response object. @throws \ReflectionException @throws \Windwalker\DI\Exception\DependencyResolutionException @since 3.0
[ "Method", "as", "the", "Psr7", "WebHttpServer", "handler", "." ]
0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074
https://github.com/ventoviro/windwalker-core/blob/0ed53059fc2d5d2d9b72f0e4aeef2fdf6aac0074/src/Core/Application/WebApplication.php#L230-L240
train
acdh-oeaw/repo-php-util
src/acdhOeaw/fedora/dissemination/Parameter.php
Parameter.registerTransformation
static public function registerTransformation(iTransformation $transformation) { self::$transformations[$transformation->getName()] = get_class($transformation); print_r(self::$transformations); }
php
static public function registerTransformation(iTransformation $transformation) { self::$transformations[$transformation->getName()] = get_class($transformation); print_r(self::$transformations); }
[ "static", "public", "function", "registerTransformation", "(", "iTransformation", "$", "transformation", ")", "{", "self", "::", "$", "transformations", "[", "$", "transformation", "->", "getName", "(", ")", "]", "=", "get_class", "(", "$", "transformation", ")"...
Registers a new transformation @param iTransformation $transformation transformation to be registered
[ "Registers", "a", "new", "transformation" ]
e22c7cd2613f3c8daf0deee879896d9cd7f61b41
https://github.com/acdh-oeaw/repo-php-util/blob/e22c7cd2613f3c8daf0deee879896d9cd7f61b41/src/acdhOeaw/fedora/dissemination/Parameter.php#L68-L72
train