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
iherwig/wcmf
src/wcmf/lib/model/output/ImageOutputStrategy.php
ImageOutputStrategy.drawDirectLine
protected function drawDirectLine($start, $end) { ImageLine($this->img, $start->x, $start->y, $end->x, $end->y, $this->lineColor); }
php
protected function drawDirectLine($start, $end) { ImageLine($this->img, $start->x, $start->y, $end->x, $end->y, $this->lineColor); }
[ "protected", "function", "drawDirectLine", "(", "$", "start", ",", "$", "end", ")", "{", "ImageLine", "(", "$", "this", "->", "img", ",", "$", "start", "->", "x", ",", "$", "start", "->", "y", ",", "$", "end", "->", "x", ",", "$", "end", "->", ...
Draw direct line. @param $start The start point (Position). @param $end The end point (Position).
[ "Draw", "direct", "line", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/output/ImageOutputStrategy.php#L211-L218
train
iherwig/wcmf
src/wcmf/lib/model/output/ImageOutputStrategy.php
ImageOutputStrategy.drawRoutedLine
protected function drawRoutedLine($start, $end) { if ($this->map["type"] == MAPTYPE_HORIZONTAL) { ImageLine($this->img, $start->x, $start->y, $start->x, $start->y-($start->y-$end->y)/2, $this->lineColor); ImageLine($this->img, $start->x, $start->y-($start->y-$end->y)/2, $end->x, $start->y-($start->y-$end->y)/2, $this->lineColor); ImageLine($this->img, $end->x, $start->y-($start->y-$end->y)/2, $end->x, $end->y, $this->lineColor); } else { ImageLine($this->img, $start->x, $start->y, $start->x+($end->x-$start->x)/2, $start->y, $this->lineColor); ImageLine($this->img, $start->x+($end->x-$start->x)/2, $start->y, $start->x+($end->x-$start->x)/2, $end->y, $this->lineColor); ImageLine($this->img, $start->x+($end->x-$start->x)/2, $end->y, $end->x, $end->y, $this->lineColor); } }
php
protected function drawRoutedLine($start, $end) { if ($this->map["type"] == MAPTYPE_HORIZONTAL) { ImageLine($this->img, $start->x, $start->y, $start->x, $start->y-($start->y-$end->y)/2, $this->lineColor); ImageLine($this->img, $start->x, $start->y-($start->y-$end->y)/2, $end->x, $start->y-($start->y-$end->y)/2, $this->lineColor); ImageLine($this->img, $end->x, $start->y-($start->y-$end->y)/2, $end->x, $end->y, $this->lineColor); } else { ImageLine($this->img, $start->x, $start->y, $start->x+($end->x-$start->x)/2, $start->y, $this->lineColor); ImageLine($this->img, $start->x+($end->x-$start->x)/2, $start->y, $start->x+($end->x-$start->x)/2, $end->y, $this->lineColor); ImageLine($this->img, $start->x+($end->x-$start->x)/2, $end->y, $end->x, $end->y, $this->lineColor); } }
[ "protected", "function", "drawRoutedLine", "(", "$", "start", ",", "$", "end", ")", "{", "if", "(", "$", "this", "->", "map", "[", "\"type\"", "]", "==", "MAPTYPE_HORIZONTAL", ")", "{", "ImageLine", "(", "$", "this", "->", "img", ",", "$", "start", "...
Draw routed line. @param $start The start point (Position). @param $end The end point (Position).
[ "Draw", "routed", "line", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/output/ImageOutputStrategy.php#L225-L266
train
iherwig/wcmf
src/wcmf/lib/model/output/ImageOutputStrategy.php
ImageOutputStrategy.calculateEndPoints
private function calculateEndPoints($poid, $oid) { // from child... if ($this->map["type"] == MAPTYPE_HORIZONTAL) { // connect from mid top... $x1 = $this->map[$oid]->x * $this->scale['x'] + ($this->labelDim['right'] - $this->labelDim['left'])/2 + $this->border; $y1 = $this->map[$oid]->y * $this->scale['y'] + $this->border - 1; } else { // connect from mid left... $x1 = $this->map[$oid]->x * $this->scale['x'] + $this->border - 1; $y1 = $this->map[$oid]->y * $this->scale['y'] + ($this->labelDim['bottom'] - $this->labelDim['top'])/2 + $this->border; } // ...to parent if ($this->map["type"] == MAPTYPE_HORIZONTAL) { // ...to mid bottom $x2 = $this->map[$poid]->x * $this->scale['x'] + ($this->labelDim['right'] - $this->labelDim['left'])/2 + $this->border; $y2 = $this->map[$poid]->y * $this->scale['y'] + ($this->labelDim['bottom'] - $this->labelDim['top']) + $this->border + 1; } else { // ...to mid right $x2 = $this->map[$poid]->x * $this->scale['x'] + $this->labelDim['right'] - $this->labelDim['left'] + $this->border + 1; $y2 = $this->map[$poid]->y * $this->scale['y'] + ($this->labelDim['bottom'] - $this->labelDim['top'])/2 + $this->border; } return [new Position($x1, $y1, 0), new Position($x2, $y2, 0)]; }
php
private function calculateEndPoints($poid, $oid) { // from child... if ($this->map["type"] == MAPTYPE_HORIZONTAL) { // connect from mid top... $x1 = $this->map[$oid]->x * $this->scale['x'] + ($this->labelDim['right'] - $this->labelDim['left'])/2 + $this->border; $y1 = $this->map[$oid]->y * $this->scale['y'] + $this->border - 1; } else { // connect from mid left... $x1 = $this->map[$oid]->x * $this->scale['x'] + $this->border - 1; $y1 = $this->map[$oid]->y * $this->scale['y'] + ($this->labelDim['bottom'] - $this->labelDim['top'])/2 + $this->border; } // ...to parent if ($this->map["type"] == MAPTYPE_HORIZONTAL) { // ...to mid bottom $x2 = $this->map[$poid]->x * $this->scale['x'] + ($this->labelDim['right'] - $this->labelDim['left'])/2 + $this->border; $y2 = $this->map[$poid]->y * $this->scale['y'] + ($this->labelDim['bottom'] - $this->labelDim['top']) + $this->border + 1; } else { // ...to mid right $x2 = $this->map[$poid]->x * $this->scale['x'] + $this->labelDim['right'] - $this->labelDim['left'] + $this->border + 1; $y2 = $this->map[$poid]->y * $this->scale['y'] + ($this->labelDim['bottom'] - $this->labelDim['top'])/2 + $this->border; } return [new Position($x1, $y1, 0), new Position($x2, $y2, 0)]; }
[ "private", "function", "calculateEndPoints", "(", "$", "poid", ",", "$", "oid", ")", "{", "// from child...", "if", "(", "$", "this", "->", "map", "[", "\"type\"", "]", "==", "MAPTYPE_HORIZONTAL", ")", "{", "// connect from mid top...", "$", "x1", "=", "$", ...
Calculate line end points. @param $poid The parent object's object id. @param $oid The object's object id. @return Array containing start and end position
[ "Calculate", "line", "end", "points", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/output/ImageOutputStrategy.php#L274-L298
train
iherwig/wcmf
src/wcmf/lib/core/ClassLoader.php
ClassLoader.load
public function load($className) { // search under baseDir assuming that namespaces match directories $filename = $this->baseDir.str_replace("\\", "/", $className).'.php'; if (file_exists($filename)) { include($filename); } }
php
public function load($className) { // search under baseDir assuming that namespaces match directories $filename = $this->baseDir.str_replace("\\", "/", $className).'.php'; if (file_exists($filename)) { include($filename); } }
[ "public", "function", "load", "(", "$", "className", ")", "{", "// search under baseDir assuming that namespaces match directories", "$", "filename", "=", "$", "this", "->", "baseDir", ".", "str_replace", "(", "\"\\\\\"", ",", "\"/\"", ",", "$", "className", ")", ...
Load the given class definition @param $className The class name
[ "Load", "the", "given", "class", "definition" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/core/ClassLoader.php#L40-L46
train
iherwig/wcmf
src/wcmf/lib/presentation/Application.php
Application.initialize
public function initialize($defaultController='', $defaultContext='', $defaultAction='login') { $config = ObjectFactory::getInstance('configuration'); $this->debug = $config->getBooleanValue('debug', 'Application'); // configure php if ($config->hasSection('phpconfig')) { $phpSettings = $config->getSection('phpconfig'); foreach ($phpSettings as $option => $value) { ini_set($option, $value); } } // create the Request and Response instances $this->request = ObjectFactory::getInstance('request'); $this->response = ObjectFactory::getInstance('response'); $this->request->setResponse($this->response); $this->request->initialize($defaultController, $defaultContext, $defaultAction); // initialize session $session = ObjectFactory::getInstance('session'); // load user configuration $principalFactory = ObjectFactory::getInstance('principalFactory'); $authUser = $principalFactory->getUser($session->getAuthUser(), true); if ($authUser && strlen($authUser->getConfig()) > 0) { $config->addConfiguration($authUser->getConfig(), true); } // load event listeners $listeners = $config->getValue('listeners', 'application'); foreach ($listeners as $key) { ObjectFactory::getInstance($key); } // set timezone date_default_timezone_set($config->getValue('timezone', 'application')); // return the request return $this->request; }
php
public function initialize($defaultController='', $defaultContext='', $defaultAction='login') { $config = ObjectFactory::getInstance('configuration'); $this->debug = $config->getBooleanValue('debug', 'Application'); // configure php if ($config->hasSection('phpconfig')) { $phpSettings = $config->getSection('phpconfig'); foreach ($phpSettings as $option => $value) { ini_set($option, $value); } } // create the Request and Response instances $this->request = ObjectFactory::getInstance('request'); $this->response = ObjectFactory::getInstance('response'); $this->request->setResponse($this->response); $this->request->initialize($defaultController, $defaultContext, $defaultAction); // initialize session $session = ObjectFactory::getInstance('session'); // load user configuration $principalFactory = ObjectFactory::getInstance('principalFactory'); $authUser = $principalFactory->getUser($session->getAuthUser(), true); if ($authUser && strlen($authUser->getConfig()) > 0) { $config->addConfiguration($authUser->getConfig(), true); } // load event listeners $listeners = $config->getValue('listeners', 'application'); foreach ($listeners as $key) { ObjectFactory::getInstance($key); } // set timezone date_default_timezone_set($config->getValue('timezone', 'application')); // return the request return $this->request; }
[ "public", "function", "initialize", "(", "$", "defaultController", "=", "''", ",", "$", "defaultContext", "=", "''", ",", "$", "defaultAction", "=", "'login'", ")", "{", "$", "config", "=", "ObjectFactory", "::", "getInstance", "(", "'configuration'", ")", "...
Initialize the request. @param $defaultController The controller to call if none is given in request parameters (optional, default: '') @param $defaultContext The context to set if none is given in request parameters (optional, default: '') @param $defaultAction The action to perform if none is given in request parameters (optional, default: 'login') @return Request instance representing the current HTTP request
[ "Initialize", "the", "request", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Application.php#L71-L111
train
iherwig/wcmf
src/wcmf/lib/presentation/Application.php
Application.run
public function run(Request $request) { // process the requested action ObjectFactory::getInstance('actionMapper')->processAction($request, $this->response); return $this->response; }
php
public function run(Request $request) { // process the requested action ObjectFactory::getInstance('actionMapper')->processAction($request, $this->response); return $this->response; }
[ "public", "function", "run", "(", "Request", "$", "request", ")", "{", "// process the requested action", "ObjectFactory", "::", "getInstance", "(", "'actionMapper'", ")", "->", "processAction", "(", "$", "request", ",", "$", "this", "->", "response", ")", ";", ...
Run the application with the given request @param $request @return Response instance
[ "Run", "the", "application", "with", "the", "given", "request" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Application.php#L118-L122
train
iherwig/wcmf
src/wcmf/lib/presentation/Application.php
Application.handleException
public function handleException(\Exception $exception) { // get error level $logFunction = 'error'; if ($exception instanceof ApplicationException) { $logFunction = $exception->getError()->getLevel() == ApplicationError::LEVEL_WARNING ? 'warn' : 'error'; } self::$logger->$logFunction($exception); try { if (ObjectFactory::getInstance('configuration') != null) { // rollback current transaction $persistenceFacade = ObjectFactory::getInstance('persistenceFacade'); $persistenceFacade->getTransaction()->rollback(); // redirect to failure action if ($this->request) { $error = ApplicationError::fromException($exception); $this->request->addError($error); $this->response->addError($error); $this->request->setAction('failure'); $this->response->setAction('failure'); $this->response->setStatus($error->getStatusCode()); ObjectFactory::getInstance('actionMapper')->processAction($this->request, $this->response); return; } } throw $exception; } catch (\Exception $ex) { self::$logger->error($ex->getMessage()."\n".$ex->getTraceAsString()); } }
php
public function handleException(\Exception $exception) { // get error level $logFunction = 'error'; if ($exception instanceof ApplicationException) { $logFunction = $exception->getError()->getLevel() == ApplicationError::LEVEL_WARNING ? 'warn' : 'error'; } self::$logger->$logFunction($exception); try { if (ObjectFactory::getInstance('configuration') != null) { // rollback current transaction $persistenceFacade = ObjectFactory::getInstance('persistenceFacade'); $persistenceFacade->getTransaction()->rollback(); // redirect to failure action if ($this->request) { $error = ApplicationError::fromException($exception); $this->request->addError($error); $this->response->addError($error); $this->request->setAction('failure'); $this->response->setAction('failure'); $this->response->setStatus($error->getStatusCode()); ObjectFactory::getInstance('actionMapper')->processAction($this->request, $this->response); return; } } throw $exception; } catch (\Exception $ex) { self::$logger->error($ex->getMessage()."\n".$ex->getTraceAsString()); } }
[ "public", "function", "handleException", "(", "\\", "Exception", "$", "exception", ")", "{", "// get error level", "$", "logFunction", "=", "'error'", ";", "if", "(", "$", "exception", "instanceof", "ApplicationException", ")", "{", "$", "logFunction", "=", "$",...
Default exception handling method. Rolls back the transaction and executes 'failure' action. @param $exception The Exception instance
[ "Default", "exception", "handling", "method", ".", "Rolls", "back", "the", "transaction", "and", "executes", "failure", "action", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Application.php#L129-L161
train
iherwig/wcmf
src/wcmf/lib/presentation/Application.php
Application.outputHandler
public function outputHandler($buffer) { // log last error, if it's level is enabled $error = error_get_last(); if ($error !== null && (in_array($error['type'], [E_ERROR, E_PARSE, E_COMPILE_ERROR]))) { $errorStr = $error['file']."::".$error['line'].": ".$error['type'].": ".$error['message']; self::$logger->error($errorStr); // suppress error message in browser if (!$this->debug) { header('HTTP/1.1 500 Internal Server Error'); $buffer = ''; } else { $buffer = "<pre>\n".$errorStr."\n</pre>"; } } return trim($buffer); }
php
public function outputHandler($buffer) { // log last error, if it's level is enabled $error = error_get_last(); if ($error !== null && (in_array($error['type'], [E_ERROR, E_PARSE, E_COMPILE_ERROR]))) { $errorStr = $error['file']."::".$error['line'].": ".$error['type'].": ".$error['message']; self::$logger->error($errorStr); // suppress error message in browser if (!$this->debug) { header('HTTP/1.1 500 Internal Server Error'); $buffer = ''; } else { $buffer = "<pre>\n".$errorStr."\n</pre>"; } } return trim($buffer); }
[ "public", "function", "outputHandler", "(", "$", "buffer", ")", "{", "// log last error, if it's level is enabled", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "!==", "null", "&&", "(", "in_array", "(", "$", "error", "[", "'t...
This method is run as ob_start callback @note must be public @param $buffer The content to be returned to the client @return String
[ "This", "method", "is", "run", "as", "ob_start", "callback" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Application.php#L169-L185
train
skie/plum_search
src/Controller/Component/FilterComponent.php
FilterComponent.parameters
public function parameters($reset = false) { if ($reset || is_null($this->_searchParameters)) { $this->_searchParameters = new ParameterRegistry($this->_controller, []); $parameters = (array)$this->config('parameters'); foreach ($parameters as $parameter) { if (!empty($parameter['name'])) { $this->addParam($parameter['name'], $parameter); } } } return $this->_searchParameters; }
php
public function parameters($reset = false) { if ($reset || is_null($this->_searchParameters)) { $this->_searchParameters = new ParameterRegistry($this->_controller, []); $parameters = (array)$this->config('parameters'); foreach ($parameters as $parameter) { if (!empty($parameter['name'])) { $this->addParam($parameter['name'], $parameter); } } } return $this->_searchParameters; }
[ "public", "function", "parameters", "(", "$", "reset", "=", "false", ")", "{", "if", "(", "$", "reset", "||", "is_null", "(", "$", "this", "->", "_searchParameters", ")", ")", "{", "$", "this", "->", "_searchParameters", "=", "new", "ParameterRegistry", ...
Returns parameters registry instance @param bool $reset Reset flag. @return \PlumSearch\FormParameter\ParameterRegistry
[ "Returns", "parameters", "registry", "instance" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Controller/Component/FilterComponent.php#L71-L84
train
skie/plum_search
src/Controller/Component/FilterComponent.php
FilterComponent.prg
public function prg($table, $options = []) { $this->config($options); $formName = $this->_initParam('formName', $this->config('formName')); $action = $this->_initParam('action', $this->controller()->request->params['action']); $this->parameters()->config([ 'formName' => $formName, ]); if ($this->_controller->request->is(['post', 'put'])) { $this->_redirect($action); } elseif ($this->_controller->request->is('get')) { $this->_setViewData($formName); return $table->find('filters', $this->values()); } return $table; }
php
public function prg($table, $options = []) { $this->config($options); $formName = $this->_initParam('formName', $this->config('formName')); $action = $this->_initParam('action', $this->controller()->request->params['action']); $this->parameters()->config([ 'formName' => $formName, ]); if ($this->_controller->request->is(['post', 'put'])) { $this->_redirect($action); } elseif ($this->_controller->request->is('get')) { $this->_setViewData($formName); return $table->find('filters', $this->values()); } return $table; }
[ "public", "function", "prg", "(", "$", "table", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "config", "(", "$", "options", ")", ";", "$", "formName", "=", "$", "this", "->", "_initParam", "(", "'formName'", ",", "$", "this", ...
Implements Post Redirect Get flow method. For POST requests builds redirection url and perform redirect to get action. For GET requests add filters finder to passed into the method query and returns it. @param Table $table Table instance. @param array $options Search parameters. @return mixed
[ "Implements", "Post", "Redirect", "Get", "flow", "method", ".", "For", "POST", "requests", "builds", "redirection", "url", "and", "perform", "redirect", "to", "get", "action", ".", "For", "GET", "requests", "add", "filters", "finder", "to", "passed", "into", ...
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Controller/Component/FilterComponent.php#L138-L157
train
skie/plum_search
src/Controller/Component/FilterComponent.php
FilterComponent._redirect
protected function _redirect($action) { $params = $this->controller()->request->params['pass']; $searchParams = array_diff_key( array_merge( $this->controller()->request->query, $this->values() ), array_flip( (array)$this->config('prohibitedParams') ) ); if ($this->config('filterEmptyParams')) { $searchParams = array_filter($searchParams); } $params['?'] = $searchParams; $params = array_merge($params, $searchParams); $params['action'] = $action; $this->controller()->redirect($params); $this->controller()->response->send(); $this->controller()->response->stop(); }
php
protected function _redirect($action) { $params = $this->controller()->request->params['pass']; $searchParams = array_diff_key( array_merge( $this->controller()->request->query, $this->values() ), array_flip( (array)$this->config('prohibitedParams') ) ); if ($this->config('filterEmptyParams')) { $searchParams = array_filter($searchParams); } $params['?'] = $searchParams; $params = array_merge($params, $searchParams); $params['action'] = $action; $this->controller()->redirect($params); $this->controller()->response->send(); $this->controller()->response->stop(); }
[ "protected", "function", "_redirect", "(", "$", "action", ")", "{", "$", "params", "=", "$", "this", "->", "controller", "(", ")", "->", "request", "->", "params", "[", "'pass'", "]", ";", "$", "searchParams", "=", "array_diff_key", "(", "array_merge", "...
Redirect action method @param string $action Action name. @return void
[ "Redirect", "action", "method" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Controller/Component/FilterComponent.php#L202-L225
train
skie/plum_search
src/Controller/Component/FilterComponent.php
FilterComponent._setViewData
protected function _setViewData($formName) { $this->controller()->request->data($formName, $this->parameters()->viewValues()); $this->controller()->set('searchParameters', $this->parameters()); }
php
protected function _setViewData($formName) { $this->controller()->request->data($formName, $this->parameters()->viewValues()); $this->controller()->set('searchParameters', $this->parameters()); }
[ "protected", "function", "_setViewData", "(", "$", "formName", ")", "{", "$", "this", "->", "controller", "(", ")", "->", "request", "->", "data", "(", "$", "formName", ",", "$", "this", "->", "parameters", "(", ")", "->", "viewValues", "(", ")", ")", ...
Set up view data @param string $formName Form name. @return void
[ "Set", "up", "view", "data" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Controller/Component/FilterComponent.php#L233-L237
train
skie/plum_search
src/Model/Behavior/FilterableBehavior.php
FilterableBehavior.filters
public function filters($reset = false) { if ($reset || is_null($this->_searchFilters)) { $this->_searchFilters = new FilterRegistry($this->_table); } return $this->_searchFilters; }
php
public function filters($reset = false) { if ($reset || is_null($this->_searchFilters)) { $this->_searchFilters = new FilterRegistry($this->_table); } return $this->_searchFilters; }
[ "public", "function", "filters", "(", "$", "reset", "=", "false", ")", "{", "if", "(", "$", "reset", "||", "is_null", "(", "$", "this", "->", "_searchFilters", ")", ")", "{", "$", "this", "->", "_searchFilters", "=", "new", "FilterRegistry", "(", "$", ...
Returns filter registry instance @param bool $reset Reset flag. @return \PlumSearch\Model\FilterRegistry
[ "Returns", "filter", "registry", "instance" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Model/Behavior/FilterableBehavior.php#L77-L84
train
skie/plum_search
src/Model/Behavior/FilterableBehavior.php
FilterableBehavior.findFilter
public function findFilter(Query $query, array $options) { foreach ($this->filters()->collection() as $name => $filter) { $filter->apply($query, $options); } return $query; }
php
public function findFilter(Query $query, array $options) { foreach ($this->filters()->collection() as $name => $filter) { $filter->apply($query, $options); } return $query; }
[ "public", "function", "findFilter", "(", "Query", "$", "query", ",", "array", "$", "options", ")", "{", "foreach", "(", "$", "this", "->", "filters", "(", ")", "->", "collection", "(", ")", "as", "$", "name", "=>", "$", "filter", ")", "{", "$", "fi...
Results for this finder will be query filtered by search parameters @param \Cake\ORM\Query $query Query. @param array $options Array of options as described above. @return \Cake\ORM\Query
[ "Results", "for", "this", "finder", "will", "be", "query", "filtered", "by", "search", "parameters" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Model/Behavior/FilterableBehavior.php#L141-L148
train
vufind-org/vufindharvest
src/RecordWriterStrategy/RecordWriterStrategyFactory.php
RecordWriterStrategyFactory.getStrategy
public function getStrategy($basePath, $settings = []) { if (isset($settings['combineRecords']) && $settings['combineRecords']) { $combineTag = $settings['combineRecordsTag'] ?? null; return new CombinedRecordWriterStrategy($basePath, $combineTag); } return new IndividualRecordWriterStrategy($basePath); }
php
public function getStrategy($basePath, $settings = []) { if (isset($settings['combineRecords']) && $settings['combineRecords']) { $combineTag = $settings['combineRecordsTag'] ?? null; return new CombinedRecordWriterStrategy($basePath, $combineTag); } return new IndividualRecordWriterStrategy($basePath); }
[ "public", "function", "getStrategy", "(", "$", "basePath", ",", "$", "settings", "=", "[", "]", ")", "{", "if", "(", "isset", "(", "$", "settings", "[", "'combineRecords'", "]", ")", "&&", "$", "settings", "[", "'combineRecords'", "]", ")", "{", "$", ...
Build writer strategy object. @param string $basePath Base path for harvest @param array $settings Configuration settings @return RecordWriterStrategyInterface
[ "Build", "writer", "strategy", "object", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/RecordWriterStrategy/RecordWriterStrategyFactory.php#L49-L56
train
skie/plum_search
src/Model/FilterRegistry.php
FilterRegistry._create
protected function _create($class, $alias, $config) { if (empty($config['name'])) { $config['name'] = $alias; } $instance = new $class($this, $config); return $instance; }
php
protected function _create($class, $alias, $config) { if (empty($config['name'])) { $config['name'] = $alias; } $instance = new $class($this, $config); return $instance; }
[ "protected", "function", "_create", "(", "$", "class", ",", "$", "alias", ",", "$", "config", ")", "{", "if", "(", "empty", "(", "$", "config", "[", "'name'", "]", ")", ")", "{", "$", "config", "[", "'name'", "]", "=", "$", "alias", ";", "}", "...
Create the filter instance. Part of the template method for Cake\Core\ObjectRegistry::load() Enabled filters will be registered with the event manager. @param string $class The class name to create. @param string $alias The alias of the filter. @param array $config An array of config to use for the filter. @return \PlumSearch\Model\Filter\AbstractFilter The constructed filter class.
[ "Create", "the", "filter", "instance", "." ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/Model/FilterRegistry.php#L92-L100
train
iherwig/wcmf
src/wcmf/application/controller/TreeController.php
TreeController.getChildren
protected function getChildren($oid) { $permissionManager = $this->getPermissionManager(); $persistenceFacade = $this->getPersistenceFacade(); // check read permission on type $type = $oid->getType(); if (!$permissionManager->authorize($type, '', PersistenceAction::READ)) { return []; } $objectsTmp = []; if ($this->isRootTypeNode($oid)) { // load instances of type $objectsTmp = $persistenceFacade->loadObjects($type, BuildDepth::SINGLE); } else { // load children of node if ($permissionManager->authorize($oid, '', PersistenceAction::READ)) { $node = $persistenceFacade->load($oid, 1); if ($node) { $objectsTmp = $node->getChildren(); } } } // check read permission on instances $objects = []; foreach ($objectsTmp as $object) { if ($permissionManager->authorize($object->getOID(), '', PersistenceAction::READ)) { $objects[] = $object; } } return $objects; }
php
protected function getChildren($oid) { $permissionManager = $this->getPermissionManager(); $persistenceFacade = $this->getPersistenceFacade(); // check read permission on type $type = $oid->getType(); if (!$permissionManager->authorize($type, '', PersistenceAction::READ)) { return []; } $objectsTmp = []; if ($this->isRootTypeNode($oid)) { // load instances of type $objectsTmp = $persistenceFacade->loadObjects($type, BuildDepth::SINGLE); } else { // load children of node if ($permissionManager->authorize($oid, '', PersistenceAction::READ)) { $node = $persistenceFacade->load($oid, 1); if ($node) { $objectsTmp = $node->getChildren(); } } } // check read permission on instances $objects = []; foreach ($objectsTmp as $object) { if ($permissionManager->authorize($object->getOID(), '', PersistenceAction::READ)) { $objects[] = $object; } } return $objects; }
[ "protected", "function", "getChildren", "(", "$", "oid", ")", "{", "$", "permissionManager", "=", "$", "this", "->", "getPermissionManager", "(", ")", ";", "$", "persistenceFacade", "=", "$", "this", "->", "getPersistenceFacade", "(", ")", ";", "// check read ...
Get the children for a given oid. @param $oid The object id @return Array of Node instances.
[ "Get", "the", "children", "for", "a", "given", "oid", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/TreeController.php#L88-L122
train
iherwig/wcmf
src/wcmf/application/controller/TreeController.php
TreeController.getViewNode
protected function getViewNode(Node $node, $displayText='') { if (strlen($displayText) == 0) { $displayText = trim($this->getDisplayText($node)); } if (strlen($displayText) == 0) { $displayText = '-'; } $oid = $node->getOID(); $isFolder = $oid->containsDummyIds(); $hasChildren = $this->isRootTypeNode($oid) || sizeof($node->getNumChildren()) > 0; return [ 'oid' => $node->getOID()->__toString(), 'displayText' => $displayText, 'isFolder' => $isFolder, 'hasChildren' => $hasChildren ]; }
php
protected function getViewNode(Node $node, $displayText='') { if (strlen($displayText) == 0) { $displayText = trim($this->getDisplayText($node)); } if (strlen($displayText) == 0) { $displayText = '-'; } $oid = $node->getOID(); $isFolder = $oid->containsDummyIds(); $hasChildren = $this->isRootTypeNode($oid) || sizeof($node->getNumChildren()) > 0; return [ 'oid' => $node->getOID()->__toString(), 'displayText' => $displayText, 'isFolder' => $isFolder, 'hasChildren' => $hasChildren ]; }
[ "protected", "function", "getViewNode", "(", "Node", "$", "node", ",", "$", "displayText", "=", "''", ")", "{", "if", "(", "strlen", "(", "$", "displayText", ")", "==", "0", ")", "{", "$", "displayText", "=", "trim", "(", "$", "this", "->", "getDispl...
Get the view of a Node @param $node The Node to create the view for @param $displayText The text to display (will be taken from TreeController::getDisplayText() if not specified) (default: '') @return An associative array whose keys correspond to Ext.tree.TreeNode config parameters
[ "Get", "the", "view", "of", "a", "Node" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/TreeController.php#L139-L155
train
iherwig/wcmf
src/wcmf/application/controller/TreeController.php
TreeController.getDisplayText
protected function getDisplayText(Node $node) { if ($this->isRootTypeNode($node->getOID())) { $mapper = $node->getMapper(); return $mapper->getTypeDisplayName($this->getMessage()); } else { return strip_tags(preg_replace("/[\r\n']/", " ", NodeUtil::getDisplayValue($node))); } }
php
protected function getDisplayText(Node $node) { if ($this->isRootTypeNode($node->getOID())) { $mapper = $node->getMapper(); return $mapper->getTypeDisplayName($this->getMessage()); } else { return strip_tags(preg_replace("/[\r\n']/", " ", NodeUtil::getDisplayValue($node))); } }
[ "protected", "function", "getDisplayText", "(", "Node", "$", "node", ")", "{", "if", "(", "$", "this", "->", "isRootTypeNode", "(", "$", "node", "->", "getOID", "(", ")", ")", ")", "{", "$", "mapper", "=", "$", "node", "->", "getMapper", "(", ")", ...
Get the display text for a Node @param $node Node to display @return The display text.
[ "Get", "the", "display", "text", "for", "a", "Node" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/TreeController.php#L171-L179
train
iherwig/wcmf
src/wcmf/application/controller/TreeController.php
TreeController.getRootTypes
protected function getRootTypes() { $types = null; $config = $this->getConfiguration(); // get root types from configuration // try request value first $request = $this->getRequest(); $rootTypeVar = $request->getValue('rootTypes'); if ($config->hasValue($rootTypeVar, 'application')) { $types = $config->getValue($rootTypeVar, 'application'); if (!is_array($types)) { $types = null; } } if ($types == null) { // fall back to root types $types = $config->hasValue('rootTypes', 'application'); } // filter types by read permission $permissionManager = $this->getPermissionManager(); $persistenceFacade = $this->getPersistenceFacade(); $nodes = []; foreach($types as $type) { if ($permissionManager->authorize($type, '', PersistenceAction::READ)) { $node = $persistenceFacade->create($type, BuildDepth::SINGLE); $nodes[] = $node; } } return $nodes; }
php
protected function getRootTypes() { $types = null; $config = $this->getConfiguration(); // get root types from configuration // try request value first $request = $this->getRequest(); $rootTypeVar = $request->getValue('rootTypes'); if ($config->hasValue($rootTypeVar, 'application')) { $types = $config->getValue($rootTypeVar, 'application'); if (!is_array($types)) { $types = null; } } if ($types == null) { // fall back to root types $types = $config->hasValue('rootTypes', 'application'); } // filter types by read permission $permissionManager = $this->getPermissionManager(); $persistenceFacade = $this->getPersistenceFacade(); $nodes = []; foreach($types as $type) { if ($permissionManager->authorize($type, '', PersistenceAction::READ)) { $node = $persistenceFacade->create($type, BuildDepth::SINGLE); $nodes[] = $node; } } return $nodes; }
[ "protected", "function", "getRootTypes", "(", ")", "{", "$", "types", "=", "null", ";", "$", "config", "=", "$", "this", "->", "getConfiguration", "(", ")", ";", "// get root types from configuration", "// try request value first", "$", "request", "=", "$", "thi...
Get all root types @return Array of Node instances
[ "Get", "all", "root", "types" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/TreeController.php#L185-L215
train
iherwig/wcmf
src/wcmf/application/controller/TreeController.php
TreeController.isRootTypeNode
protected function isRootTypeNode(ObjectId $oid) { if ($oid->containsDummyIds()) { $type = $oid->getType(); $rootTypes = $this->getRootTypes(); foreach ($rootTypes as $rootType) { if ($rootType->getType() == $type) { return true; } } } return false; }
php
protected function isRootTypeNode(ObjectId $oid) { if ($oid->containsDummyIds()) { $type = $oid->getType(); $rootTypes = $this->getRootTypes(); foreach ($rootTypes as $rootType) { if ($rootType->getType() == $type) { return true; } } } return false; }
[ "protected", "function", "isRootTypeNode", "(", "ObjectId", "$", "oid", ")", "{", "if", "(", "$", "oid", "->", "containsDummyIds", "(", ")", ")", "{", "$", "type", "=", "$", "oid", "->", "getType", "(", ")", ";", "$", "rootTypes", "=", "$", "this", ...
Check if the given oid belongs to a root type node @param $oid The object id @return Boolean
[ "Check", "if", "the", "given", "oid", "belongs", "to", "a", "root", "type", "node" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/TreeController.php#L222-L233
train
iherwig/wcmf
src/wcmf/lib/security/principal/impl/AbstractUser.php
AbstractUser.ensureHashedPassword
protected function ensureHashedPassword() { // the password is expected to be stored in the 'password' value $password = $this->getValue('password'); if (strlen($password) > 0 && !PasswordService::isHashed($password)) { $this->setValue('password', PasswordService::hash($password)); } }
php
protected function ensureHashedPassword() { // the password is expected to be stored in the 'password' value $password = $this->getValue('password'); if (strlen($password) > 0 && !PasswordService::isHashed($password)) { $this->setValue('password', PasswordService::hash($password)); } }
[ "protected", "function", "ensureHashedPassword", "(", ")", "{", "// the password is expected to be stored in the 'password' value", "$", "password", "=", "$", "this", "->", "getValue", "(", "'password'", ")", ";", "if", "(", "strlen", "(", "$", "password", ")", ">",...
Hash password property if not done already.
[ "Hash", "password", "property", "if", "not", "done", "already", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/principal/impl/AbstractUser.php#L160-L166
train
iherwig/wcmf
src/wcmf/lib/security/principal/impl/AbstractUser.php
AbstractUser.setRoleConfig
protected function setRoleConfig() { if (strlen($this->getConfig()) == 0) { // check added nodes for Role instances foreach ($this->getAddedNodes() as $relationName => $nodes) { foreach ($nodes as $node) { if ($node instanceof Role) { $roleName = $node->getName(); $roleConfigs = self::getRoleConfigs(); if (isset($roleConfigs[$roleName])) { $this->setConfig($roleConfigs[$roleName]); break; } } } } } }
php
protected function setRoleConfig() { if (strlen($this->getConfig()) == 0) { // check added nodes for Role instances foreach ($this->getAddedNodes() as $relationName => $nodes) { foreach ($nodes as $node) { if ($node instanceof Role) { $roleName = $node->getName(); $roleConfigs = self::getRoleConfigs(); if (isset($roleConfigs[$roleName])) { $this->setConfig($roleConfigs[$roleName]); break; } } } } } }
[ "protected", "function", "setRoleConfig", "(", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "getConfig", "(", ")", ")", "==", "0", ")", "{", "// check added nodes for Role instances", "foreach", "(", "$", "this", "->", "getAddedNodes", "(", ")", ...
Set the configuration of the currently associated role, if no configuration is set already.
[ "Set", "the", "configuration", "of", "the", "currently", "associated", "role", "if", "no", "configuration", "is", "set", "already", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/principal/impl/AbstractUser.php#L172-L188
train
iherwig/wcmf
src/wcmf/lib/security/principal/impl/AbstractUser.php
AbstractUser.getRoleConfigs
protected static function getRoleConfigs() { if (self::$roleConfig == null) { // load role config if existing $config = ObjectFactory::getInstance('configuration'); if (($roleConfig = $config->getSection('roleconfig')) !== false) { self::$roleConfig = $roleConfig; } } return self::$roleConfig; }
php
protected static function getRoleConfigs() { if (self::$roleConfig == null) { // load role config if existing $config = ObjectFactory::getInstance('configuration'); if (($roleConfig = $config->getSection('roleconfig')) !== false) { self::$roleConfig = $roleConfig; } } return self::$roleConfig; }
[ "protected", "static", "function", "getRoleConfigs", "(", ")", "{", "if", "(", "self", "::", "$", "roleConfig", "==", "null", ")", "{", "// load role config if existing", "$", "config", "=", "ObjectFactory", "::", "getInstance", "(", "'configuration'", ")", ";",...
Get the role configurations from the application configuration @return Array with role names as keys and config file names as values
[ "Get", "the", "role", "configurations", "from", "the", "application", "configuration" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/principal/impl/AbstractUser.php#L236-L245
train
iherwig/wcmf
src/wcmf/lib/security/principal/impl/AbstractUser.php
AbstractUser.getAuthUser
protected function getAuthUser() { $principalFactory = ObjectFactory::getInstance('principalFactory'); $session = ObjectFactory::getInstance('session'); return $principalFactory->getUser($session->getAuthUser()); }
php
protected function getAuthUser() { $principalFactory = ObjectFactory::getInstance('principalFactory'); $session = ObjectFactory::getInstance('session'); return $principalFactory->getUser($session->getAuthUser()); }
[ "protected", "function", "getAuthUser", "(", ")", "{", "$", "principalFactory", "=", "ObjectFactory", "::", "getInstance", "(", "'principalFactory'", ")", ";", "$", "session", "=", "ObjectFactory", "::", "getInstance", "(", "'session'", ")", ";", "return", "$", ...
Get the currently authenticated user @return User
[ "Get", "the", "currently", "authenticated", "user" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/security/principal/impl/AbstractUser.php#L251-L255
train
iherwig/wcmf
src/wcmf/lib/persistence/impl/AbstractMapper.php
AbstractMapper.authorizationFailedError
protected function authorizationFailedError($resource, $action) { // when reading only log the error to avoid errors on the display $msg = ObjectFactory::getInstance('message')-> getText("Authorization failed for action '%0%' on '%1%'.", [$action, $resource]); if ($action == PersistenceAction::READ) { self::$logger->error($msg."\n".ErrorHandler::getStackTrace()); } else { throw new AuthorizationException($msg); } }
php
protected function authorizationFailedError($resource, $action) { // when reading only log the error to avoid errors on the display $msg = ObjectFactory::getInstance('message')-> getText("Authorization failed for action '%0%' on '%1%'.", [$action, $resource]); if ($action == PersistenceAction::READ) { self::$logger->error($msg."\n".ErrorHandler::getStackTrace()); } else { throw new AuthorizationException($msg); } }
[ "protected", "function", "authorizationFailedError", "(", "$", "resource", ",", "$", "action", ")", "{", "// when reading only log the error to avoid errors on the display", "$", "msg", "=", "ObjectFactory", "::", "getInstance", "(", "'message'", ")", "->", "getText", "...
Handle an authorization error. @param $resource @param $action @throws AuthorizationException
[ "Handle", "an", "authorization", "error", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/AbstractMapper.php#L403-L413
train
iherwig/wcmf
src/wcmf/lib/persistence/impl/AbstractMapper.php
AbstractMapper.initRelations
private function initRelations() { if ($this->relations == null) { $this->relations = []; $this->relations['byrole'] = []; $this->relations['bytype'] = []; $relations = $this->getRelations(); foreach ($relations as $relation) { $this->relations['byrole'][$relation->getOtherRole()] = $relation; $otherType = $relation->getOtherType(); if (!isset($this->relations['bytype'][$otherType])) { $this->relations['bytype'][$otherType] = []; } $this->relations['bytype'][$otherType][] = $relation; $this->relations['bytype'][$this->persistenceFacade->getSimpleType($otherType)][] = $relation; } } }
php
private function initRelations() { if ($this->relations == null) { $this->relations = []; $this->relations['byrole'] = []; $this->relations['bytype'] = []; $relations = $this->getRelations(); foreach ($relations as $relation) { $this->relations['byrole'][$relation->getOtherRole()] = $relation; $otherType = $relation->getOtherType(); if (!isset($this->relations['bytype'][$otherType])) { $this->relations['bytype'][$otherType] = []; } $this->relations['bytype'][$otherType][] = $relation; $this->relations['bytype'][$this->persistenceFacade->getSimpleType($otherType)][] = $relation; } } }
[ "private", "function", "initRelations", "(", ")", "{", "if", "(", "$", "this", "->", "relations", "==", "null", ")", "{", "$", "this", "->", "relations", "=", "[", "]", ";", "$", "this", "->", "relations", "[", "'byrole'", "]", "=", "[", "]", ";", ...
Initialize relations.
[ "Initialize", "relations", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/AbstractMapper.php#L418-L435
train
Aerendir/PHPValueObjects
src/CurrencyExchangeRate/CurrencyExchangeRate.php
CurrencyExchangeRate.setExchangeRate
protected function setExchangeRate(float $exchangeRate): void { if ( ! is_float($exchangeRate)) { throw new \InvalidArgumentException(sprintf('ExchangeRate has to be a float. %s given.', gettype($exchangeRate))); } $this->exchangeRate = $exchangeRate; }
php
protected function setExchangeRate(float $exchangeRate): void { if ( ! is_float($exchangeRate)) { throw new \InvalidArgumentException(sprintf('ExchangeRate has to be a float. %s given.', gettype($exchangeRate))); } $this->exchangeRate = $exchangeRate; }
[ "protected", "function", "setExchangeRate", "(", "float", "$", "exchangeRate", ")", ":", "void", "{", "if", "(", "!", "is_float", "(", "$", "exchangeRate", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'ExchangeRate has...
Set the conversion rate of the currency. @param float $exchangeRate
[ "Set", "the", "conversion", "rate", "of", "the", "currency", "." ]
5ef646e593e411bf1b678755ff552a00a245d4c9
https://github.com/Aerendir/PHPValueObjects/blob/5ef646e593e411bf1b678755ff552a00a245d4c9/src/CurrencyExchangeRate/CurrencyExchangeRate.php#L95-L102
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQueryUnionQueryProvider.php
ObjectQueryUnionQueryProvider.getLastQueryStrings
public function getLastQueryStrings() { $result = []; foreach ($this->queries as $query) { $result[] = $query->getLastQueryString(); } return $result; }
php
public function getLastQueryStrings() { $result = []; foreach ($this->queries as $query) { $result[] = $query->getLastQueryString(); } return $result; }
[ "public", "function", "getLastQueryStrings", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "queries", "as", "$", "query", ")", "{", "$", "result", "[", "]", "=", "$", "query", "->", "getLastQueryString", "(", ")...
Get the last query strings @return Array of string
[ "Get", "the", "last", "query", "strings" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQueryUnionQueryProvider.php#L62-L68
train
iherwig/wcmf
src/wcmf/lib/model/NodeIterator.php
NodeIterator.addToQueue
protected function addToQueue($nodeList) { for ($i=sizeof($nodeList)-1; $i>=0; $i--) { if ($nodeList[$i] instanceof Node) { $this->nodeList[] = $nodeList[$i]; } } }
php
protected function addToQueue($nodeList) { for ($i=sizeof($nodeList)-1; $i>=0; $i--) { if ($nodeList[$i] instanceof Node) { $this->nodeList[] = $nodeList[$i]; } } }
[ "protected", "function", "addToQueue", "(", "$", "nodeList", ")", "{", "for", "(", "$", "i", "=", "sizeof", "(", "$", "nodeList", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "if", "(", "$", "nodeList", "[", "$", "i...
Add nodes to the processing queue. @param $nodeList An array of nodes.
[ "Add", "nodes", "to", "the", "processing", "queue", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeIterator.php#L144-L150
train
GW2Treasures/gw2api
src/V2/Endpoint/Guild/RestrictedGuildHandler.php
RestrictedGuildHandler.onError
public function onError(ResponseInterface $response, RequestInterface $request) { $json = $this->getResponseAsJson( $response ); if( !is_null( $json ) && isset( $json->text )) { if( $json->text === 'access restricted to guild leaders' ) { throw new GuildLeaderRequiredException( $json->text, $response ); } elseif( $json->text === 'membership required' ) { throw new MembershipRequiredException( $json->text, $response ); } } }
php
public function onError(ResponseInterface $response, RequestInterface $request) { $json = $this->getResponseAsJson( $response ); if( !is_null( $json ) && isset( $json->text )) { if( $json->text === 'access restricted to guild leaders' ) { throw new GuildLeaderRequiredException( $json->text, $response ); } elseif( $json->text === 'membership required' ) { throw new MembershipRequiredException( $json->text, $response ); } } }
[ "public", "function", "onError", "(", "ResponseInterface", "$", "response", ",", "RequestInterface", "$", "request", ")", "{", "$", "json", "=", "$", "this", "->", "getResponseAsJson", "(", "$", "response", ")", ";", "if", "(", "!", "is_null", "(", "$", ...
Handle errors by the api. @param ResponseInterface $response @param RequestInterface $request @throws GuildLeaderRequiredException @throws MembershipRequiredException
[ "Handle", "errors", "by", "the", "api", "." ]
c8795af0c1d0a434b9e530f779d5a95786db2176
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Endpoint/Guild/RestrictedGuildHandler.php#L28-L37
train
iherwig/wcmf
src/wcmf/lib/io/FileUtil.php
FileUtil.getMimeType
public static function getMimeType($file) { $defaultType = 'application/octet-stream'; if (class_exists('\FileInfo')) { // use extension $fileInfo = new finfo(FILEINFO_MIME); $fileType = $fileInfo->file(file_get_contents($file)); } else { // try detect image mime type $imageInfo = @getimagesize($file); $fileType = isset($imageInfo['mime']) ? $imageInfo['mime'] : ''; } return (is_string($fileType) && !empty($fileType)) ? $fileType : $defaultType; }
php
public static function getMimeType($file) { $defaultType = 'application/octet-stream'; if (class_exists('\FileInfo')) { // use extension $fileInfo = new finfo(FILEINFO_MIME); $fileType = $fileInfo->file(file_get_contents($file)); } else { // try detect image mime type $imageInfo = @getimagesize($file); $fileType = isset($imageInfo['mime']) ? $imageInfo['mime'] : ''; } return (is_string($fileType) && !empty($fileType)) ? $fileType : $defaultType; }
[ "public", "static", "function", "getMimeType", "(", "$", "file", ")", "{", "$", "defaultType", "=", "'application/octet-stream'", ";", "if", "(", "class_exists", "(", "'\\FileInfo'", ")", ")", "{", "// use extension", "$", "fileInfo", "=", "new", "finfo", "(",...
Get the mime type of the given file @param $file The file @return String
[ "Get", "the", "mime", "type", "of", "the", "given", "file" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/io/FileUtil.php#L66-L79
train
iherwig/wcmf
src/wcmf/lib/io/FileUtil.php
FileUtil.copyRecDir
public static function copyRecDir($source, $dest) { if (!is_dir($dest)) { self::mkdirRec($dest); } $dir = opendir($source); while ($file = readdir($dir)) { if ($file == "." || $file == "..") { continue; } self::copyRec("$source/$file", "$dest/$file"); } closedir($dir); }
php
public static function copyRecDir($source, $dest) { if (!is_dir($dest)) { self::mkdirRec($dest); } $dir = opendir($source); while ($file = readdir($dir)) { if ($file == "." || $file == "..") { continue; } self::copyRec("$source/$file", "$dest/$file"); } closedir($dir); }
[ "public", "static", "function", "copyRecDir", "(", "$", "source", ",", "$", "dest", ")", "{", "if", "(", "!", "is_dir", "(", "$", "dest", ")", ")", "{", "self", "::", "mkdirRec", "(", "$", "dest", ")", ";", "}", "$", "dir", "=", "opendir", "(", ...
Recursive copy for directories. @param $source The name of the source directory @param $dest The name of the destination directory
[ "Recursive", "copy", "for", "directories", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/io/FileUtil.php#L196-L208
train
iherwig/wcmf
src/wcmf/lib/io/FileUtil.php
FileUtil.fixFilename
public static function fixFilename($file) { if (file_exists($file)) { return $file; } else { $file = iconv('utf-8', 'cp1252', $file); if (file_exists($file)) { return $file; } } return null; }
php
public static function fixFilename($file) { if (file_exists($file)) { return $file; } else { $file = iconv('utf-8', 'cp1252', $file); if (file_exists($file)) { return $file; } } return null; }
[ "public", "static", "function", "fixFilename", "(", "$", "file", ")", "{", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "return", "$", "file", ";", "}", "else", "{", "$", "file", "=", "iconv", "(", "'utf-8'", ",", "'cp1252'", ",", "$"...
Fix the name of an existing file to be used with php file functions @param $file @return String or null, if the file does not exist
[ "Fix", "the", "name", "of", "an", "existing", "file", "to", "be", "used", "with", "php", "file", "functions" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/io/FileUtil.php#L286-L297
train
iherwig/wcmf
src/wcmf/lib/io/FileUtil.php
FileUtil.urlencodeFilename
public static function urlencodeFilename($file) { $parts = explode('/', $file); $result = []; foreach ($parts as $part) { $result[] = rawurlencode($part); } return join('/', $result); }
php
public static function urlencodeFilename($file) { $parts = explode('/', $file); $result = []; foreach ($parts as $part) { $result[] = rawurlencode($part); } return join('/', $result); }
[ "public", "static", "function", "urlencodeFilename", "(", "$", "file", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "file", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "...
Url encode a file path @param $file @return String
[ "Url", "encode", "a", "file", "path" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/io/FileUtil.php#L304-L311
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.getObjectTemplate
public function getObjectTemplate($type, $alias=null, $combineOperator=Criteria::OPERATOR_AND) { $template = null; // use the typeNode, the first time a node template of the query type is requested $persistenceFacade = ObjectFactory::getInstance('persistenceFacade'); $fqType = $persistenceFacade->getFullyQualifiedType($type); if ($fqType == $this->typeNode->getType() && !$this->isTypeNodeInQuery) { $template = $this->typeNode; $this->isTypeNodeInQuery = true; // the typeNode is contained already in the rootNodes array } else { // don't use PersistenceFacade::create, because template instances must be transient $mapper = self::getMapper($fqType); $template = $mapper->create($fqType, BuildDepth::SINGLE); $this->rootNodes[] = $template; } $template->setProperty(self::PROPERTY_COMBINE_OPERATOR, $combineOperator); if ($alias != null) { $template->setProperty(self::PROPERTY_TABLE_NAME, $alias); } $initialOid = $template->getOID()->__toString(); $template->setProperty(self::PROPERTY_INITIAL_OID, $initialOid); $this->observedObjects[$initialOid] = $template; return $template; }
php
public function getObjectTemplate($type, $alias=null, $combineOperator=Criteria::OPERATOR_AND) { $template = null; // use the typeNode, the first time a node template of the query type is requested $persistenceFacade = ObjectFactory::getInstance('persistenceFacade'); $fqType = $persistenceFacade->getFullyQualifiedType($type); if ($fqType == $this->typeNode->getType() && !$this->isTypeNodeInQuery) { $template = $this->typeNode; $this->isTypeNodeInQuery = true; // the typeNode is contained already in the rootNodes array } else { // don't use PersistenceFacade::create, because template instances must be transient $mapper = self::getMapper($fqType); $template = $mapper->create($fqType, BuildDepth::SINGLE); $this->rootNodes[] = $template; } $template->setProperty(self::PROPERTY_COMBINE_OPERATOR, $combineOperator); if ($alias != null) { $template->setProperty(self::PROPERTY_TABLE_NAME, $alias); } $initialOid = $template->getOID()->__toString(); $template->setProperty(self::PROPERTY_INITIAL_OID, $initialOid); $this->observedObjects[$initialOid] = $template; return $template; }
[ "public", "function", "getObjectTemplate", "(", "$", "type", ",", "$", "alias", "=", "null", ",", "$", "combineOperator", "=", "Criteria", "::", "OPERATOR_AND", ")", "{", "$", "template", "=", "null", ";", "// use the typeNode, the first time a node template of the ...
Get an object template for a given type. @param $type The type to query for @param $alias An alias name to be used in the query. if null, use the default name (default: _null_) @param $combineOperator One of the Criteria::OPERATOR constants that precedes the conditions described in the template (default: _Criteria::OPERATOR_AND_) @return Node
[ "Get", "an", "object", "template", "for", "a", "given", "type", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L169-L194
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.registerObjectTemplate
public function registerObjectTemplate(Node $template, $alias=null, $combineOperator=Criteria::OPERATOR_AND) { if ($template != null) { $initialOid = $template->getOID(); $initialOidStr = $initialOid->__toString(); $template->setProperty(self::PROPERTY_INITIAL_OID, $initialOidStr); $this->observedObjects[$initialOidStr] = $template; // call the setters for all attributes in order to register them in the query $includePKs = !ObjectId::isDummyId($initialOid->getFirstId()); $template->copyValues($template, $includePKs); $template->setProperty(self::PROPERTY_COMBINE_OPERATOR, $combineOperator); if ($alias != null) { $template->setProperty(self::PROPERTY_TABLE_NAME, $alias); } // replace the typeNode, the first time a node template of the query type is registered if ($template->getType() == $this->typeNode->getType() && !$this->isTypeNodeInQuery) { $newRootNodes = [$template]; foreach($this->rootNodes as $node) { if ($node != $this->typeNode) { $newRootNodes[] = $node; } } $this->rootNodes = $newRootNodes; $this->isTypeNodeInQuery = true; } else { $this->rootNodes[] = $template; } } }
php
public function registerObjectTemplate(Node $template, $alias=null, $combineOperator=Criteria::OPERATOR_AND) { if ($template != null) { $initialOid = $template->getOID(); $initialOidStr = $initialOid->__toString(); $template->setProperty(self::PROPERTY_INITIAL_OID, $initialOidStr); $this->observedObjects[$initialOidStr] = $template; // call the setters for all attributes in order to register them in the query $includePKs = !ObjectId::isDummyId($initialOid->getFirstId()); $template->copyValues($template, $includePKs); $template->setProperty(self::PROPERTY_COMBINE_OPERATOR, $combineOperator); if ($alias != null) { $template->setProperty(self::PROPERTY_TABLE_NAME, $alias); } // replace the typeNode, the first time a node template of the query type is registered if ($template->getType() == $this->typeNode->getType() && !$this->isTypeNodeInQuery) { $newRootNodes = [$template]; foreach($this->rootNodes as $node) { if ($node != $this->typeNode) { $newRootNodes[] = $node; } } $this->rootNodes = $newRootNodes; $this->isTypeNodeInQuery = true; } else { $this->rootNodes[] = $template; } } }
[ "public", "function", "registerObjectTemplate", "(", "Node", "$", "template", ",", "$", "alias", "=", "null", ",", "$", "combineOperator", "=", "Criteria", "::", "OPERATOR_AND", ")", "{", "if", "(", "$", "template", "!=", "null", ")", "{", "$", "initialOid...
Register an object template at the query. @param $template Node instance to register as template @param $alias An alias name to be used in the query. if null, use the default name (default: _null_) @param $combineOperator One of the Criteria::OPERATOR constants that precedes the conditions described in the template (default: Criteria::OPERATOR_AND)
[ "Register", "an", "object", "template", "at", "the", "query", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L203-L234
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.makeGroup
public function makeGroup($templates, $combineOperator=Criteria::OPERATOR_AND) { $this->groups[] = ['tpls' => $templates, self::PROPERTY_COMBINE_OPERATOR => $combineOperator]; // store grouped nodes in an extra array to separate them from the others for ($i=0; $i<sizeof($templates); $i++) { if ($templates[$i] != null) { $this->groupedOIDs[] = $templates[$i]->getOID(); } else { throw new IllegalArgumentException("Null value found in group"); } } }
php
public function makeGroup($templates, $combineOperator=Criteria::OPERATOR_AND) { $this->groups[] = ['tpls' => $templates, self::PROPERTY_COMBINE_OPERATOR => $combineOperator]; // store grouped nodes in an extra array to separate them from the others for ($i=0; $i<sizeof($templates); $i++) { if ($templates[$i] != null) { $this->groupedOIDs[] = $templates[$i]->getOID(); } else { throw new IllegalArgumentException("Null value found in group"); } } }
[ "public", "function", "makeGroup", "(", "$", "templates", ",", "$", "combineOperator", "=", "Criteria", "::", "OPERATOR_AND", ")", "{", "$", "this", "->", "groups", "[", "]", "=", "[", "'tpls'", "=>", "$", "templates", ",", "self", "::", "PROPERTY_COMBINE_...
Group different templates together to realize brackets in the query. @note Grouped templates will be ignored, when iterating over the object tree and appended at the end. @param $templates An array of references to the templates contained in the group @param $combineOperator One of the Criteria::OPERATOR constants that precedes the group (default: _Criteria::OPERATOR_AND_)
[ "Group", "different", "templates", "together", "to", "realize", "brackets", "in", "the", "query", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L242-L253
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.getQueryCondition
public function getQueryCondition() { $query = $this->getQueryString(); $tmp = preg_split("/ WHERE /i", $query); if (sizeof($tmp) > 1) { $tmp = preg_split("/ ORDER /i", $tmp[1]); return $tmp[0]; } return ''; }
php
public function getQueryCondition() { $query = $this->getQueryString(); $tmp = preg_split("/ WHERE /i", $query); if (sizeof($tmp) > 1) { $tmp = preg_split("/ ORDER /i", $tmp[1]); return $tmp[0]; } return ''; }
[ "public", "function", "getQueryCondition", "(", ")", "{", "$", "query", "=", "$", "this", "->", "getQueryString", "(", ")", ";", "$", "tmp", "=", "preg_split", "(", "\"/ WHERE /i\"", ",", "$", "query", ")", ";", "if", "(", "sizeof", "(", "$", "tmp", ...
Get the condition part of the query. This is especially useful to build a StringQuery from the query objects. @return String
[ "Get", "the", "condition", "part", "of", "the", "query", ".", "This", "is", "especially", "useful", "to", "build", "a", "StringQuery", "from", "the", "query", "objects", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L260-L268
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.getParameters
protected function getParameters($criteria, array $parameters) { $result = []; // flatten conditions $criteriaFlat = []; foreach ($criteria as $key => $curCriteria) { foreach ($curCriteria as $criterion) { if ($criterion instanceof Criteria) { $mapper = self::getMapper($criterion->getType()); $valueName = $criterion->getAttribute(); $attributeDesc = $mapper->getAttribute($valueName); if ($attributeDesc) { $criteriaFlat[] = $criterion; } } } } // get parameters in order $criteriaValuePosition = []; foreach ($parameters as $placeholder => $index) { $value = $criteriaFlat[$index]->getValue(); if (is_array($value)) { // criteria has array value // initialize position counting for this criteria (defined by index) if (!isset($criteriaValuePosition[$index])) { $criteriaValuePosition[$index] = 0; } // set the value from the array $result[$placeholder] = $value[$criteriaValuePosition[$index]]; $criteriaValuePosition[$index]++; } else { // criteria has single value $result[$placeholder] = $value; } } return $result; }
php
protected function getParameters($criteria, array $parameters) { $result = []; // flatten conditions $criteriaFlat = []; foreach ($criteria as $key => $curCriteria) { foreach ($curCriteria as $criterion) { if ($criterion instanceof Criteria) { $mapper = self::getMapper($criterion->getType()); $valueName = $criterion->getAttribute(); $attributeDesc = $mapper->getAttribute($valueName); if ($attributeDesc) { $criteriaFlat[] = $criterion; } } } } // get parameters in order $criteriaValuePosition = []; foreach ($parameters as $placeholder => $index) { $value = $criteriaFlat[$index]->getValue(); if (is_array($value)) { // criteria has array value // initialize position counting for this criteria (defined by index) if (!isset($criteriaValuePosition[$index])) { $criteriaValuePosition[$index] = 0; } // set the value from the array $result[$placeholder] = $value[$criteriaValuePosition[$index]]; $criteriaValuePosition[$index]++; } else { // criteria has single value $result[$placeholder] = $value; } } return $result; }
[ "protected", "function", "getParameters", "(", "$", "criteria", ",", "array", "$", "parameters", ")", "{", "$", "result", "=", "[", "]", ";", "// flatten conditions", "$", "criteriaFlat", "=", "[", "]", ";", "foreach", "(", "$", "criteria", "as", "$", "k...
Get an array of parameter values for the given criteria @param $criteria An array of Criteria instances that define conditions on the object's attributes (maybe null) @param $parameters Array defining the parameter order @return Array
[ "Get", "an", "array", "of", "parameter", "values", "for", "the", "given", "criteria" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L561-L597
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.processTableName
protected function processTableName(Node $tpl) { $mapper = self::getMapper($tpl->getType()); $mapperTableName = $mapper->getRealTableName(); $tableName = $tpl->getProperty(self::PROPERTY_TABLE_NAME); if ($tableName == null) { $tableName = $mapperTableName; // if the template is the child of another node of the same type, // we must use a table alias $parents = $tpl->getParentsEx(null, null, $tpl->getType()); foreach ($parents as $curParent) { $curParentTableName = $curParent->getProperty(self::PROPERTY_TABLE_NAME); if ($curParentTableName == $tableName) { $tableName .= '_'.($this->aliasCounter++); } } // set the table name for later reference $tpl->setProperty(self::PROPERTY_TABLE_NAME, $tableName); } return ['name' => $mapperTableName, 'alias' => $tableName]; }
php
protected function processTableName(Node $tpl) { $mapper = self::getMapper($tpl->getType()); $mapperTableName = $mapper->getRealTableName(); $tableName = $tpl->getProperty(self::PROPERTY_TABLE_NAME); if ($tableName == null) { $tableName = $mapperTableName; // if the template is the child of another node of the same type, // we must use a table alias $parents = $tpl->getParentsEx(null, null, $tpl->getType()); foreach ($parents as $curParent) { $curParentTableName = $curParent->getProperty(self::PROPERTY_TABLE_NAME); if ($curParentTableName == $tableName) { $tableName .= '_'.($this->aliasCounter++); } } // set the table name for later reference $tpl->setProperty(self::PROPERTY_TABLE_NAME, $tableName); } return ['name' => $mapperTableName, 'alias' => $tableName]; }
[ "protected", "function", "processTableName", "(", "Node", "$", "tpl", ")", "{", "$", "mapper", "=", "self", "::", "getMapper", "(", "$", "tpl", "->", "getType", "(", ")", ")", ";", "$", "mapperTableName", "=", "$", "mapper", "->", "getRealTableName", "("...
Get the table name for the template and calculate an alias if necessary. @param $tpl The object template @return Associative array with keys 'name', 'alias'
[ "Get", "the", "table", "name", "for", "the", "template", "and", "calculate", "an", "alias", "if", "necessary", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L629-L651
train
iherwig/wcmf
src/wcmf/lib/model/ObjectQuery.php
ObjectQuery.valueChanged
public function valueChanged(ValueChangeEvent $event) { $object = $event->getObject(); $name = $event->getValueName(); $initialOid = $object->getProperty(self::PROPERTY_INITIAL_OID); if (isset($this->observedObjects[$initialOid])) { $newValue = $event->getNewValue(); // make a criteria from newValue and make sure that all properties are set if (!($newValue instanceof Criteria)) { // LIKE fallback, if the value is not a Criteria instance $mapper = self::getMapper($object->getType()); $pkNames = $mapper->getPkNames(); if (!in_array($name, $pkNames)) { // use like condition on any attribute, if it's a string // other value changes will be ignored! if (is_string($newValue)) { $newValue = new Criteria($object->getType(), $name, 'LIKE', '%'.$newValue.'%'); } } else { // don't search for pk names with LIKE $newValue = new Criteria($object->getType(), $name, '=', $newValue); } } else { // make sure that type and name are set even if the Criteria is constructed // via Criteria::forValue() $newValue->setType($object->getType()); $newValue->setAttribute($name); } $oid = $object->getOID()->__toString(); // store change in internal array to have it when constructing the query if (!isset($this->conditions[$oid])) { $this->conditions[$oid] = []; } $this->conditions[$oid][$name] = $newValue; } }
php
public function valueChanged(ValueChangeEvent $event) { $object = $event->getObject(); $name = $event->getValueName(); $initialOid = $object->getProperty(self::PROPERTY_INITIAL_OID); if (isset($this->observedObjects[$initialOid])) { $newValue = $event->getNewValue(); // make a criteria from newValue and make sure that all properties are set if (!($newValue instanceof Criteria)) { // LIKE fallback, if the value is not a Criteria instance $mapper = self::getMapper($object->getType()); $pkNames = $mapper->getPkNames(); if (!in_array($name, $pkNames)) { // use like condition on any attribute, if it's a string // other value changes will be ignored! if (is_string($newValue)) { $newValue = new Criteria($object->getType(), $name, 'LIKE', '%'.$newValue.'%'); } } else { // don't search for pk names with LIKE $newValue = new Criteria($object->getType(), $name, '=', $newValue); } } else { // make sure that type and name are set even if the Criteria is constructed // via Criteria::forValue() $newValue->setType($object->getType()); $newValue->setAttribute($name); } $oid = $object->getOID()->__toString(); // store change in internal array to have it when constructing the query if (!isset($this->conditions[$oid])) { $this->conditions[$oid] = []; } $this->conditions[$oid][$name] = $newValue; } }
[ "public", "function", "valueChanged", "(", "ValueChangeEvent", "$", "event", ")", "{", "$", "object", "=", "$", "event", "->", "getObject", "(", ")", ";", "$", "name", "=", "$", "event", "->", "getValueName", "(", ")", ";", "$", "initialOid", "=", "$",...
Listen to ValueChangeEvents @param $event ValueChangeEvent instance
[ "Listen", "to", "ValueChangeEvents" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/ObjectQuery.php#L657-L694
train
skie/plum_search
src/FormParameter/ParameterRegistry.php
ParameterRegistry._resolveClassName
protected function _resolveClassName($class) { $result = App::className($class, 'FormParameter', 'Parameter'); if ($result || strpos($class, '.') !== false) { return $result; } return App::className('PlumSearch.' . $class, 'FormParameter', 'Parameter'); }
php
protected function _resolveClassName($class) { $result = App::className($class, 'FormParameter', 'Parameter'); if ($result || strpos($class, '.') !== false) { return $result; } return App::className('PlumSearch.' . $class, 'FormParameter', 'Parameter'); }
[ "protected", "function", "_resolveClassName", "(", "$", "class", ")", "{", "$", "result", "=", "App", "::", "className", "(", "$", "class", ",", "'FormParameter'", ",", "'Parameter'", ")", ";", "if", "(", "$", "result", "||", "strpos", "(", "$", "class",...
Resolve a param class name. Part of the template method for Cake\Core\ObjectRegistry::load() @param string $class Partial class name to resolve. @return string|false Either the correct class name or false.
[ "Resolve", "a", "param", "class", "name", "." ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/FormParameter/ParameterRegistry.php#L62-L70
train
skie/plum_search
src/FormParameter/ParameterRegistry.php
ParameterRegistry.collection
public function collection($collectionMethod = null) { $collection = collection($this->_loaded); if (is_callable($collectionMethod)) { return $collectionMethod($collection); } return $collection; }
php
public function collection($collectionMethod = null) { $collection = collection($this->_loaded); if (is_callable($collectionMethod)) { return $collectionMethod($collection); } return $collection; }
[ "public", "function", "collection", "(", "$", "collectionMethod", "=", "null", ")", "{", "$", "collection", "=", "collection", "(", "$", "this", "->", "_loaded", ")", ";", "if", "(", "is_callable", "(", "$", "collectionMethod", ")", ")", "{", "return", "...
Return collection of loaded parameters @return \Cake\Collection\Collection
[ "Return", "collection", "of", "loaded", "parameters" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/FormParameter/ParameterRegistry.php#L115-L123
train
skie/plum_search
src/FormParameter/ParameterRegistry.php
ParameterRegistry.data
public function data($name = null) { if ($this->_Controller->request->is('get')) { if (empty($name)) { return $this->_Controller->request->query; } else { return $this->_Controller->request->query($name); } } elseif ($this->_Controller->request->is(['post', 'put'])) { if (empty($name)) { return $this->_Controller->request->data[$this->formName]; } else { return $this->_Controller->request->data($this->fieldName($name)); } } return null; }
php
public function data($name = null) { if ($this->_Controller->request->is('get')) { if (empty($name)) { return $this->_Controller->request->query; } else { return $this->_Controller->request->query($name); } } elseif ($this->_Controller->request->is(['post', 'put'])) { if (empty($name)) { return $this->_Controller->request->data[$this->formName]; } else { return $this->_Controller->request->data($this->fieldName($name)); } } return null; }
[ "public", "function", "data", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "this", "->", "_Controller", "->", "request", "->", "is", "(", "'get'", ")", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "$", "t...
Returns parameter value based by it's name @param string $name Parameter name. @return mixed
[ "Returns", "parameter", "value", "based", "by", "it", "s", "name" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/FormParameter/ParameterRegistry.php#L131-L148
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.readInRelation
public function readInRelation() { $request = $this->getRequest(); // rewrite query if querying for a relation $relationName = $request->getValue('relation'); // set the query $sourceOid = ObjectId::parse($request->getValue('sourceOid')); $persistenceFacade = $this->getPersistenceFacade(); $sourceNode = $persistenceFacade->load($sourceOid); if ($sourceNode) { $relationQuery = NodeUtil::getRelationQueryCondition($sourceNode, $relationName); $query = ($request->hasValue('query') ? $request->getValue('query').'&' : '').$relationQuery; $request->setValue('query', $query); // set the class name $mapper = $sourceNode->getMapper(); $relation = $mapper->getRelation($relationName); $otherType = $relation->getOtherType(); $request->setValue('className', $otherType); // set default order if (!$request->hasValue('sortFieldName')) { $otherMapper = $persistenceFacade->getMapper($otherType); $sortkeyDef = $otherMapper->getSortkey($relation->getThisRole()); if ($sortkeyDef != null) { $request->setValue('sortFieldName', $sortkeyDef['sortFieldName']); $request->setValue('sortDirection', $sortkeyDef['sortDirection']); } } } // delegate to ListController $subResponse = $this->executeSubAction('list'); $this->handleSubResponse($subResponse); }
php
public function readInRelation() { $request = $this->getRequest(); // rewrite query if querying for a relation $relationName = $request->getValue('relation'); // set the query $sourceOid = ObjectId::parse($request->getValue('sourceOid')); $persistenceFacade = $this->getPersistenceFacade(); $sourceNode = $persistenceFacade->load($sourceOid); if ($sourceNode) { $relationQuery = NodeUtil::getRelationQueryCondition($sourceNode, $relationName); $query = ($request->hasValue('query') ? $request->getValue('query').'&' : '').$relationQuery; $request->setValue('query', $query); // set the class name $mapper = $sourceNode->getMapper(); $relation = $mapper->getRelation($relationName); $otherType = $relation->getOtherType(); $request->setValue('className', $otherType); // set default order if (!$request->hasValue('sortFieldName')) { $otherMapper = $persistenceFacade->getMapper($otherType); $sortkeyDef = $otherMapper->getSortkey($relation->getThisRole()); if ($sortkeyDef != null) { $request->setValue('sortFieldName', $sortkeyDef['sortFieldName']); $request->setValue('sortDirection', $sortkeyDef['sortDirection']); } } } // delegate to ListController $subResponse = $this->executeSubAction('list'); $this->handleSubResponse($subResponse); }
[ "public", "function", "readInRelation", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "// rewrite query if querying for a relation", "$", "relationName", "=", "$", "request", "->", "getValue", "(", "'relation'", ")", ";", ...
Read objects that are related to another object | Parameter | Description |------------------|------------------------- | _in_ `language` | The language of the returned objects | _in_ `sourceId` | Id of the object to which the returned objects are related (determines the object id together with _className_) | _in_ `className` | The type of the object defined by _sourceId_ | _in_ `relation` | Name of the relation to the object defined by _sourceId_ (determines the type of the returned objects) | _in_ `sortBy` | <em>?sortBy=+foo</em> for sorting the list by foo ascending or | _in_ `sort` | <em>?sort(+foo)</em> for sorting the list by foo ascending | _in_ `limit` | <em>?limit(10,25)</em> for loading 10 objects starting from position 25 | _in_ `query` | A query condition encoded in RQL to be used with StringQuery::setRQLConditionString() | _out_ | List of objects
[ "Read", "objects", "that", "are", "related", "to", "another", "object" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L190-L225
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.create
public function create() { $this->requireTransaction(); // delegate to SaveController $subResponse = $this->executeSubAction('create'); // return object only $oidStr = $subResponse->hasValue('oid') ? $subResponse->getValue('oid')->__toString() : null; $this->handleSubResponse($subResponse, $oidStr); // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } }
php
public function create() { $this->requireTransaction(); // delegate to SaveController $subResponse = $this->executeSubAction('create'); // return object only $oidStr = $subResponse->hasValue('oid') ? $subResponse->getValue('oid')->__toString() : null; $this->handleSubResponse($subResponse, $oidStr); // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } }
[ "public", "function", "create", "(", ")", "{", "$", "this", "->", "requireTransaction", "(", ")", ";", "// delegate to SaveController", "$", "subResponse", "=", "$", "this", "->", "executeSubAction", "(", "'create'", ")", ";", "// return object only", "$", "oidS...
Create an object of a given type | Parameter | Description |------------------|------------------------- | _in_ `language` | The language of the object | _in_ `className` | Type of object to create | _out_ | Created object data The object data is contained in POST content.
[ "Create", "an", "object", "of", "a", "given", "type" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L238-L251
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.createInRelation
public function createInRelation() { $this->requireTransaction(); $request = $this->getRequest(); // create new object $oidStr = null; $sourceOid = ObjectId::parse($request->getValue('sourceOid')); $relatedType = $this->getRelatedType($sourceOid, $request->getValue('relation')); $request->setValue('className', $relatedType); $subResponse = $this->executeSubAction('create'); if (!$subResponse->hasErrors()) { $createStatus = $subResponse->getStatus(); $targetOid = $subResponse->getValue('oid'); $targetOidStr = $targetOid->__toString(); // add new object to relation $request->setValue('targetOid', $targetOidStr); $request->setValue('role', $request->getValue('relation')); $subResponse = $this->executeSubAction('associate'); if (!$subResponse->hasErrors()) { // add related object to subresponse similar to default update action $persistenceFacade = $this->getPersistenceFacade(); $targetObj = $persistenceFacade->load($targetOid); $subResponse->setValue('oid', $targetOid); $subResponse->setValue($targetOidStr, $targetObj); $subResponse->setStatus($createStatus); // in case of success, return object only $oidStr = $subResponse->hasValue('oid') ? $subResponse->getValue('oid')->__toString() : ''; } } // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse, $oidStr); }
php
public function createInRelation() { $this->requireTransaction(); $request = $this->getRequest(); // create new object $oidStr = null; $sourceOid = ObjectId::parse($request->getValue('sourceOid')); $relatedType = $this->getRelatedType($sourceOid, $request->getValue('relation')); $request->setValue('className', $relatedType); $subResponse = $this->executeSubAction('create'); if (!$subResponse->hasErrors()) { $createStatus = $subResponse->getStatus(); $targetOid = $subResponse->getValue('oid'); $targetOidStr = $targetOid->__toString(); // add new object to relation $request->setValue('targetOid', $targetOidStr); $request->setValue('role', $request->getValue('relation')); $subResponse = $this->executeSubAction('associate'); if (!$subResponse->hasErrors()) { // add related object to subresponse similar to default update action $persistenceFacade = $this->getPersistenceFacade(); $targetObj = $persistenceFacade->load($targetOid); $subResponse->setValue('oid', $targetOid); $subResponse->setValue($targetOidStr, $targetObj); $subResponse->setStatus($createStatus); // in case of success, return object only $oidStr = $subResponse->hasValue('oid') ? $subResponse->getValue('oid')->__toString() : ''; } } // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse, $oidStr); }
[ "public", "function", "createInRelation", "(", ")", "{", "$", "this", "->", "requireTransaction", "(", ")", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "// create new object", "$", "oidStr", "=", "null", ";", "$", "sourceOid",...
Create an object of a given type in the given relation | Parameter | Description |------------------|------------------------- | _in_ `language` | The language of the object | _in_ `className` | Type of object to create | _in_ `sourceId` | Id of the object to which the created objects are added (determines the object id together with _className_) | _in_ `relation` | Name of the relation to the object defined by _sourceId_ (determines the type of the created/added object) | _out_ | Created object data The object data is contained in POST content. If an existing object should be added, an `oid` parameter in the object data is sufficient.
[ "Create", "an", "object", "of", "a", "given", "type", "in", "the", "given", "relation" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L267-L304
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.update
public function update() { $this->requireTransaction(); $request = $this->getRequest(); $oidStr = $this->getFirstRequestOid(); $isOrderRequest = $request->hasValue('referenceOid'); if ($isOrderRequest) { // change order in all objects of the same type $request->setValue('insertOid', $this->getFirstRequestOid()); // delegate to SortController $subResponse = $this->executeSubAction('moveBefore'); // add sorted object to subresponse similar to default update action if (!$subResponse->hasErrors()) { $oid = ObjectId::parse($oidStr); $persistenceFacade = $this->getPersistenceFacade(); $object = $persistenceFacade->load($oid); $subResponse->setValue('oid', $oid); $subResponse->setValue($oidStr, $object); } } else { // delegate to SaveController $subResponse = $this->executeSubAction('update'); } // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse, $oidStr); }
php
public function update() { $this->requireTransaction(); $request = $this->getRequest(); $oidStr = $this->getFirstRequestOid(); $isOrderRequest = $request->hasValue('referenceOid'); if ($isOrderRequest) { // change order in all objects of the same type $request->setValue('insertOid', $this->getFirstRequestOid()); // delegate to SortController $subResponse = $this->executeSubAction('moveBefore'); // add sorted object to subresponse similar to default update action if (!$subResponse->hasErrors()) { $oid = ObjectId::parse($oidStr); $persistenceFacade = $this->getPersistenceFacade(); $object = $persistenceFacade->load($oid); $subResponse->setValue('oid', $oid); $subResponse->setValue($oidStr, $object); } } else { // delegate to SaveController $subResponse = $this->executeSubAction('update'); } // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse, $oidStr); }
[ "public", "function", "update", "(", ")", "{", "$", "this", "->", "requireTransaction", "(", ")", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "oidStr", "=", "$", "this", "->", "getFirstRequestOid", "(", ")", ";", "$...
Update an object or change the order | Parameter | Description |------------------|------------------------- | _in_ `language` | The language of the object | _in_ `className` | Type of object to update | _in_ `id` | Id of object to update | _out_ | Updated object data The object data is contained in POST content.
[ "Update", "an", "object", "or", "change", "the", "order" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L318-L350
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.updateInRelation
public function updateInRelation() { $this->requireTransaction(); $request = $this->getRequest(); $isOrderRequest = $request->hasValue('referenceOid'); $request->setValue('role', $request->getValue('relation')); if ($isOrderRequest) { // change order in a relation $request->setValue('containerOid', $request->getValue('sourceOid')); $request->setValue('insertOid', $request->getValue('targetOid')); // delegate to SortController $subResponse = $this->executeSubAction('insertBefore'); } else { // update existing object // delegate to SaveController // NOTE: we need to update first, otherwise the update action might override // the foreign keys changes from the associate action $subResponse = $this->executeSubAction('update'); if (!$subResponse->hasErrors()) { // and add object to relation // delegate to AssociateController $subResponse = $this->executeSubAction('associate'); } } // add related object to subresponse similar to default update action if (!$subResponse->hasErrors()) { $targetOidStr = $request->getValue('targetOid'); $targetOid = ObjectId::parse($targetOidStr); $persistenceFacade = $this->getPersistenceFacade(); $targetObj = $persistenceFacade->load($targetOid); $subResponse->setValue('oid', $targetOid); $subResponse->setValue($targetOidStr, $targetObj); } // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse, $targetOidStr); }
php
public function updateInRelation() { $this->requireTransaction(); $request = $this->getRequest(); $isOrderRequest = $request->hasValue('referenceOid'); $request->setValue('role', $request->getValue('relation')); if ($isOrderRequest) { // change order in a relation $request->setValue('containerOid', $request->getValue('sourceOid')); $request->setValue('insertOid', $request->getValue('targetOid')); // delegate to SortController $subResponse = $this->executeSubAction('insertBefore'); } else { // update existing object // delegate to SaveController // NOTE: we need to update first, otherwise the update action might override // the foreign keys changes from the associate action $subResponse = $this->executeSubAction('update'); if (!$subResponse->hasErrors()) { // and add object to relation // delegate to AssociateController $subResponse = $this->executeSubAction('associate'); } } // add related object to subresponse similar to default update action if (!$subResponse->hasErrors()) { $targetOidStr = $request->getValue('targetOid'); $targetOid = ObjectId::parse($targetOidStr); $persistenceFacade = $this->getPersistenceFacade(); $targetObj = $persistenceFacade->load($targetOid); $subResponse->setValue('oid', $targetOid); $subResponse->setValue($targetOidStr, $targetObj); } // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse, $targetOidStr); }
[ "public", "function", "updateInRelation", "(", ")", "{", "$", "this", "->", "requireTransaction", "(", ")", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "isOrderRequest", "=", "$", "request", "->", "hasValue", "(", "'ref...
Update an object in a relation or change the order | Parameter | Description |------------------|------------------------- | _in_ `language` | The language of the object | _in_ `className` | Type of object to update | _in_ `id` | Id of object to update | _in_ `relation` | Relation name if an existing object should be added to a relation (determines the type of the added object) | _in_ `sourceId` | Id of the object to which the added object is related (determines the object id together with _className_) | _in_ `targetId` | Id of the object to be added to the relation (determines the object id together with _relation_) | _out_ | Updated object data The object data is contained in POST content.
[ "Update", "an", "object", "in", "a", "relation", "or", "change", "the", "order" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L367-L409
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.deleteInRelation
public function deleteInRelation() { $this->requireTransaction(); $request = $this->getRequest(); // remove existing object from relation $request->setValue('role', $request->getValue('relation')); // delegate to AssociateController $subResponse = $this->executeSubAction('disassociate'); // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse); }
php
public function deleteInRelation() { $this->requireTransaction(); $request = $this->getRequest(); // remove existing object from relation $request->setValue('role', $request->getValue('relation')); // delegate to AssociateController $subResponse = $this->executeSubAction('disassociate'); // prevent commit if ($subResponse->hasErrors()) { $this->endTransaction(false); } $this->handleSubResponse($subResponse); }
[ "public", "function", "deleteInRelation", "(", ")", "{", "$", "this", "->", "requireTransaction", "(", ")", ";", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "// remove existing object from relation", "$", "request", "->", "setValue", "...
Remove an object from a relation | Parameter | Description |------------------|------------------------- | _in_ `language` | The language of the object | _in_ `className` | Type of object to delete | _in_ `id` | Id of object to delete | _in_ `relation` | Name of the relation to the object defined by _sourceId_ (determines the type of the deleted object) | _in_ `sourceId` | Id of the object to which the deleted object is related (determines the object id together with _className_) | _in_ `targetId` | Id of the object to be deleted from the relation (determines the object id together with _relation_)
[ "Remove", "an", "object", "from", "a", "relation" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L444-L459
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.handleSubResponse
protected function handleSubResponse(Response $subResponse, $oidStr=null) { $response = $this->getResponse(); if (!$subResponse->hasErrors()) { $response->clearValues(); $response->setHeaders($subResponse->getHeaders()); $response->setStatus($subResponse->getStatus()); if ($subResponse->hasValue('object')) { $object = $subResponse->getValue('object'); if ($object != null) { $response->setValue($object->getOID()->__toString(), $object); } } if ($subResponse->hasValue('list')) { $objects = $subResponse->getValue('list'); $response->setValues($objects); } if ($oidStr != null && $subResponse->hasValue($oidStr)) { $object = $subResponse->getValue($oidStr); $response->setValue($oidStr, $object); if ($subResponse->getStatus() == 201) { $this->setLocationHeaderFromOid($oidStr); } } return true; } // in case of error, return default response $response->setErrors($subResponse->getErrors()); $response->setStatus(400); return false; }
php
protected function handleSubResponse(Response $subResponse, $oidStr=null) { $response = $this->getResponse(); if (!$subResponse->hasErrors()) { $response->clearValues(); $response->setHeaders($subResponse->getHeaders()); $response->setStatus($subResponse->getStatus()); if ($subResponse->hasValue('object')) { $object = $subResponse->getValue('object'); if ($object != null) { $response->setValue($object->getOID()->__toString(), $object); } } if ($subResponse->hasValue('list')) { $objects = $subResponse->getValue('list'); $response->setValues($objects); } if ($oidStr != null && $subResponse->hasValue($oidStr)) { $object = $subResponse->getValue($oidStr); $response->setValue($oidStr, $object); if ($subResponse->getStatus() == 201) { $this->setLocationHeaderFromOid($oidStr); } } return true; } // in case of error, return default response $response->setErrors($subResponse->getErrors()); $response->setStatus(400); return false; }
[ "protected", "function", "handleSubResponse", "(", "Response", "$", "subResponse", ",", "$", "oidStr", "=", "null", ")", "{", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "if", "(", "!", "$", "subResponse", "->", "hasErrors", "(...
Create the actual response from the response resulting from delegating to another controller @param $subResponse The response returned from the other controller @param $oidStr Serialized object id of the object to return (optional) @return Boolean whether an error occured or not
[ "Create", "the", "actual", "response", "from", "the", "response", "resulting", "from", "delegating", "to", "another", "controller" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L468-L498
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.setLocationHeaderFromOid
protected function setLocationHeaderFromOid($oidStr) { $oid = ObjectId::parse($oidStr); if ($oid) { $response = $this->getResponse(); $response->setHeader('Location', $oidStr); } }
php
protected function setLocationHeaderFromOid($oidStr) { $oid = ObjectId::parse($oidStr); if ($oid) { $response = $this->getResponse(); $response->setHeader('Location', $oidStr); } }
[ "protected", "function", "setLocationHeaderFromOid", "(", "$", "oidStr", ")", "{", "$", "oid", "=", "ObjectId", "::", "parse", "(", "$", "oidStr", ")", ";", "if", "(", "$", "oid", ")", "{", "$", "response", "=", "$", "this", "->", "getResponse", "(", ...
Set the location response header according to the given object id @param $oidStr The serialized object id
[ "Set", "the", "location", "response", "header", "according", "to", "the", "given", "object", "id" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L528-L534
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.getFirstRequestOid
protected function getFirstRequestOid() { $request = $this->getRequest(); foreach ($request->getValues() as $key => $value) { if (ObjectId::isValid($key)) { return $key; } } return ''; }
php
protected function getFirstRequestOid() { $request = $this->getRequest(); foreach ($request->getValues() as $key => $value) { if (ObjectId::isValid($key)) { return $key; } } return ''; }
[ "protected", "function", "getFirstRequestOid", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "foreach", "(", "$", "request", "->", "getValues", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(",...
Get the first oid from the request @return String
[ "Get", "the", "first", "oid", "from", "the", "request" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L540-L548
train
iherwig/wcmf
src/wcmf/application/controller/RESTController.php
RESTController.getRelatedType
protected function getRelatedType(ObjectId $sourceOid, $role) { $persistenceFacade = $this->getPersistenceFacade(); $sourceMapper = $persistenceFacade->getMapper($sourceOid->getType()); $relation = $sourceMapper->getRelation($role); return $relation->getOtherType(); }
php
protected function getRelatedType(ObjectId $sourceOid, $role) { $persistenceFacade = $this->getPersistenceFacade(); $sourceMapper = $persistenceFacade->getMapper($sourceOid->getType()); $relation = $sourceMapper->getRelation($role); return $relation->getOtherType(); }
[ "protected", "function", "getRelatedType", "(", "ObjectId", "$", "sourceOid", ",", "$", "role", ")", "{", "$", "persistenceFacade", "=", "$", "this", "->", "getPersistenceFacade", "(", ")", ";", "$", "sourceMapper", "=", "$", "persistenceFacade", "->", "getMap...
Get the type that is used in the given role related to the given source object. @param $sourceOid ObjectId of the source object @param $role The role name @return String
[ "Get", "the", "type", "that", "is", "used", "in", "the", "given", "role", "related", "to", "the", "given", "source", "object", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/RESTController.php#L557-L562
train
heyday/silverstripe-versioneddataobjects
code/VersionedReadingMode.php
VersionedReadingMode.restoreOriginalReadingMode
public static function restoreOriginalReadingMode() { if ( isset(self::$originalReadingMode) && in_array(self::$originalReadingMode, array('Stage', 'Live')) ) { Versioned::reading_stage(self::$originalReadingMode); } }
php
public static function restoreOriginalReadingMode() { if ( isset(self::$originalReadingMode) && in_array(self::$originalReadingMode, array('Stage', 'Live')) ) { Versioned::reading_stage(self::$originalReadingMode); } }
[ "public", "static", "function", "restoreOriginalReadingMode", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "originalReadingMode", ")", "&&", "in_array", "(", "self", "::", "$", "originalReadingMode", ",", "array", "(", "'Stage'", ",", "'Live'", ...
Restore the reading mode to what's been set originally in the CMS
[ "Restore", "the", "reading", "mode", "to", "what", "s", "been", "set", "originally", "in", "the", "CMS" ]
30a07d976abd17baba9d9194ca176c82d72323ac
https://github.com/heyday/silverstripe-versioneddataobjects/blob/30a07d976abd17baba9d9194ca176c82d72323ac/code/VersionedReadingMode.php#L39-L47
train
iherwig/wcmf
src/wcmf/lib/model/output/DotOutputStrategy.php
DotOutputStrategy.isWritten
private function isWritten($node) { $oidStr = $node->getOID()->__toString(); return (isset($this->writtenNodes[$oidStr])); }
php
private function isWritten($node) { $oidStr = $node->getOID()->__toString(); return (isset($this->writtenNodes[$oidStr])); }
[ "private", "function", "isWritten", "(", "$", "node", ")", "{", "$", "oidStr", "=", "$", "node", "->", "getOID", "(", ")", "->", "__toString", "(", ")", ";", "return", "(", "isset", "(", "$", "this", "->", "writtenNodes", "[", "$", "oidStr", "]", "...
Check if a node is written. @param $node The node to check @return Boolean
[ "Check", "if", "a", "node", "is", "written", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/output/DotOutputStrategy.php#L130-L133
train
iherwig/wcmf
src/wcmf/lib/model/output/DotOutputStrategy.php
DotOutputStrategy.getIndex
private function getIndex($node) { $oidStr = $node->getOID()->__toString(); if (!isset($this->nodeIndexMap[$oidStr])) { $this->nodeIndexMap[$oidStr] = $this->getNextIndex(); } return $this->nodeIndexMap[$oidStr]; }
php
private function getIndex($node) { $oidStr = $node->getOID()->__toString(); if (!isset($this->nodeIndexMap[$oidStr])) { $this->nodeIndexMap[$oidStr] = $this->getNextIndex(); } return $this->nodeIndexMap[$oidStr]; }
[ "private", "function", "getIndex", "(", "$", "node", ")", "{", "$", "oidStr", "=", "$", "node", "->", "getOID", "(", ")", "->", "__toString", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "nodeIndexMap", "[", "$", "oidStr", "]", ...
Get the node index. @param $node The node to get the index of @return Number
[ "Get", "the", "node", "index", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/output/DotOutputStrategy.php#L140-L146
train
iherwig/wcmf
src/wcmf/lib/model/NodeSortkeyComparator.php
NodeSortkeyComparator.compare
public function compare(Node $a, Node $b) { $valA = $this->getSortkeyValue($a); $valB = $this->getSortkeyValue($b); if ($valA == $valB) { return 0; } return ($valA > $valB) ? 1 : -1; }
php
public function compare(Node $a, Node $b) { $valA = $this->getSortkeyValue($a); $valB = $this->getSortkeyValue($b); if ($valA == $valB) { return 0; } return ($valA > $valB) ? 1 : -1; }
[ "public", "function", "compare", "(", "Node", "$", "a", ",", "Node", "$", "b", ")", "{", "$", "valA", "=", "$", "this", "->", "getSortkeyValue", "(", "$", "a", ")", ";", "$", "valB", "=", "$", "this", "->", "getSortkeyValue", "(", "$", "b", ")", ...
Compare function for sorting Nodes in the given relation @param $a First Node instance @param $b First Node instance @return -1, 0 or 1 whether a is less, equal or greater than b in respect of the criteria
[ "Compare", "function", "for", "sorting", "Nodes", "in", "the", "given", "relation" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeSortkeyComparator.php#L63-L68
train
iherwig/wcmf
src/wcmf/lib/model/NodeSortkeyComparator.php
NodeSortkeyComparator.getSortkeyValue
protected function getSortkeyValue(Node $node) { // if no role is defined for a or b, the sortkey is // determined from the type of the reference node $defaultRole = $this->referenceNode->getType(); $referenceMapper = $this->referenceNode->getMapper(); $mapper = $node->getMapper(); if ($referenceMapper && $mapper) { $referenceRole = $defaultRole; // get the sortkey of the node for the relation to the reference node, // if a role is defined $oidStr = $node->getOID()->__toString(); if (isset($this->oidRoleMap[$oidStr])) { $nodeRole = $this->oidRoleMap[$oidStr]; $relationDesc = $referenceMapper->getRelation($nodeRole); $referenceRole = $relationDesc->getThisRole(); } $sortkeyDef = $mapper->getSortkey($referenceRole); return $node->getValue($sortkeyDef['sortFieldName']); } return 0; }
php
protected function getSortkeyValue(Node $node) { // if no role is defined for a or b, the sortkey is // determined from the type of the reference node $defaultRole = $this->referenceNode->getType(); $referenceMapper = $this->referenceNode->getMapper(); $mapper = $node->getMapper(); if ($referenceMapper && $mapper) { $referenceRole = $defaultRole; // get the sortkey of the node for the relation to the reference node, // if a role is defined $oidStr = $node->getOID()->__toString(); if (isset($this->oidRoleMap[$oidStr])) { $nodeRole = $this->oidRoleMap[$oidStr]; $relationDesc = $referenceMapper->getRelation($nodeRole); $referenceRole = $relationDesc->getThisRole(); } $sortkeyDef = $mapper->getSortkey($referenceRole); return $node->getValue($sortkeyDef['sortFieldName']); } return 0; }
[ "protected", "function", "getSortkeyValue", "(", "Node", "$", "node", ")", "{", "// if no role is defined for a or b, the sortkey is", "// determined from the type of the reference node", "$", "defaultRole", "=", "$", "this", "->", "referenceNode", "->", "getType", "(", ")"...
Get the sortkey value of a node in the given relation @param $node Node @return Number
[ "Get", "the", "sortkey", "value", "of", "a", "node", "in", "the", "given", "relation" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/NodeSortkeyComparator.php#L75-L97
train
GW2Treasures/gw2api
src/V2/Pagination/PaginationHandler.php
PaginationHandler.onError
public function onError( ResponseInterface $response, RequestInterface $request ) { $json = $this->getResponseAsJson( $response ); if( !is_null( $json ) && isset( $json->text )) { if( strpos( $json->text, 'page out of range.' ) === 0 ) { throw new PageOutOfRangeException( $json->text, $response ); } } }
php
public function onError( ResponseInterface $response, RequestInterface $request ) { $json = $this->getResponseAsJson( $response ); if( !is_null( $json ) && isset( $json->text )) { if( strpos( $json->text, 'page out of range.' ) === 0 ) { throw new PageOutOfRangeException( $json->text, $response ); } } }
[ "public", "function", "onError", "(", "ResponseInterface", "$", "response", ",", "RequestInterface", "$", "request", ")", "{", "$", "json", "=", "$", "this", "->", "getResponseAsJson", "(", "$", "response", ")", ";", "if", "(", "!", "is_null", "(", "$", ...
Handle PageOutOfRangeExceptions. @param ResponseInterface $response @param RequestInterface $request @throws PageOutOfRangeException
[ "Handle", "PageOutOfRangeExceptions", "." ]
c8795af0c1d0a434b9e530f779d5a95786db2176
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Pagination/PaginationHandler.php#L26-L33
train
GW2Treasures/gw2api
src/GW2Api.php
GW2Api.extractCacertFile
protected function extractCacertFile() { if( $this->isIncludedAsPhar() ) { $cacertFilePath = $this->getCacertFilePath(); if( !file_exists( $cacertFilePath )) { copy( __DIR__ . '/cacert.pem', $cacertFilePath ); } } }
php
protected function extractCacertFile() { if( $this->isIncludedAsPhar() ) { $cacertFilePath = $this->getCacertFilePath(); if( !file_exists( $cacertFilePath )) { copy( __DIR__ . '/cacert.pem', $cacertFilePath ); } } }
[ "protected", "function", "extractCacertFile", "(", ")", "{", "if", "(", "$", "this", "->", "isIncludedAsPhar", "(", ")", ")", "{", "$", "cacertFilePath", "=", "$", "this", "->", "getCacertFilePath", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$",...
Copies the phar cacert from the phar into the temp directory.
[ "Copies", "the", "phar", "cacert", "from", "the", "phar", "into", "the", "temp", "directory", "." ]
c8795af0c1d0a434b9e530f779d5a95786db2176
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/GW2Api.php#L114-L122
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.isCached
public function isCached() { $cache = ObjectFactory::getInstance('staticCache'); return $this->id == self::NO_CACHE ? false : $cache->exists(self::getCacheSection($this->type), self::getCacheId($this->id)); }
php
public function isCached() { $cache = ObjectFactory::getInstance('staticCache'); return $this->id == self::NO_CACHE ? false : $cache->exists(self::getCacheSection($this->type), self::getCacheId($this->id)); }
[ "public", "function", "isCached", "(", ")", "{", "$", "cache", "=", "ObjectFactory", "::", "getInstance", "(", "'staticCache'", ")", ";", "return", "$", "this", "->", "id", "==", "self", "::", "NO_CACHE", "?", "false", ":", "$", "cache", "->", "exists", ...
Check if the statement is cached already @return Boolean
[ "Check", "if", "the", "statement", "is", "cached", "already" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L106-L110
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.setParameters
public function setParameters($parameters) { $this->parameters = $parameters; // store version with colons stripped $this->parametersStripped = array_combine(array_map(function($name) { return preg_replace('/^:/', '', $name); }, array_keys($this->parameters)), $this->parameters); }
php
public function setParameters($parameters) { $this->parameters = $parameters; // store version with colons stripped $this->parametersStripped = array_combine(array_map(function($name) { return preg_replace('/^:/', '', $name); }, array_keys($this->parameters)), $this->parameters); }
[ "public", "function", "setParameters", "(", "$", "parameters", ")", "{", "$", "this", "->", "parameters", "=", "$", "parameters", ";", "// store version with colons stripped", "$", "this", "->", "parametersStripped", "=", "array_combine", "(", "array_map", "(", "f...
Set the parameter values to replace the placeholders with when doing the select @param $parameters Associative array with placeholders as keys
[ "Set", "the", "parameter", "values", "to", "replace", "the", "placeholders", "with", "when", "doing", "the", "select" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L137-L143
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.getRowCount
public function getRowCount() { $mapper = ObjectFactory::getInstance('persistenceFacade')->getMapper($this->type); if ($this->table) { $table = !is_array($this->table) ? $this-> table : key($this->table); // use pk columns for counting $countColumns = array_map(function($valueName) use ($mapper, $table) { return $mapper->quoteIdentifier($table).'.'.$mapper->quoteIdentifier($mapper->getAttribute($valueName)->getColumn()); }, $mapper->getPkNames()); } else { // fallback if table is not defined: take first column $adapter = $this->getAdapter(); $columns = $this->processSelect($adapter->getPlatform()); $countColumns = [$columns[$this->quantifier ? 1 : 0][0][0]]; } $countStatement = clone $this; $countStatement->reset(Select::COLUMNS); $countStatement->reset(Select::LIMIT); $countStatement->reset(Select::OFFSET); $countStatement->reset(Select::ORDER); $countStatement->reset(Select::GROUP); // remove all join columns to prevent errors because of missing group by for non aggregated columns (42000 - 1140) $joins = $countStatement->joins->getJoins(); $countStatement->reset(Select::JOINS); foreach ($joins as $key => $join) { // re add join without cols $countStatement->join($join["name"], $join["on"], [], $join["type"]); } // create aggregation column $countStatement->columns(['nRows' => new \Zend\Db\Sql\Expression('COUNT('.$this->quantifier.' '.join(', ', $countColumns).')')]); $countStatement->id = $this->id != self::NO_CACHE ? $this->id.'-count' : self::NO_CACHE; try { $result = $countStatement->query(); $row = $result->fetch(); return $row['nRows']; } catch (\Exception $ex) { self::$logger->error("The query: ".$countStatement->__toString()."\ncaused the following exception:\n".$ex->getMessage()); throw new PersistenceException("Error in persistent operation. See log file for details."); } }
php
public function getRowCount() { $mapper = ObjectFactory::getInstance('persistenceFacade')->getMapper($this->type); if ($this->table) { $table = !is_array($this->table) ? $this-> table : key($this->table); // use pk columns for counting $countColumns = array_map(function($valueName) use ($mapper, $table) { return $mapper->quoteIdentifier($table).'.'.$mapper->quoteIdentifier($mapper->getAttribute($valueName)->getColumn()); }, $mapper->getPkNames()); } else { // fallback if table is not defined: take first column $adapter = $this->getAdapter(); $columns = $this->processSelect($adapter->getPlatform()); $countColumns = [$columns[$this->quantifier ? 1 : 0][0][0]]; } $countStatement = clone $this; $countStatement->reset(Select::COLUMNS); $countStatement->reset(Select::LIMIT); $countStatement->reset(Select::OFFSET); $countStatement->reset(Select::ORDER); $countStatement->reset(Select::GROUP); // remove all join columns to prevent errors because of missing group by for non aggregated columns (42000 - 1140) $joins = $countStatement->joins->getJoins(); $countStatement->reset(Select::JOINS); foreach ($joins as $key => $join) { // re add join without cols $countStatement->join($join["name"], $join["on"], [], $join["type"]); } // create aggregation column $countStatement->columns(['nRows' => new \Zend\Db\Sql\Expression('COUNT('.$this->quantifier.' '.join(', ', $countColumns).')')]); $countStatement->id = $this->id != self::NO_CACHE ? $this->id.'-count' : self::NO_CACHE; try { $result = $countStatement->query(); $row = $result->fetch(); return $row['nRows']; } catch (\Exception $ex) { self::$logger->error("The query: ".$countStatement->__toString()."\ncaused the following exception:\n".$ex->getMessage()); throw new PersistenceException("Error in persistent operation. See log file for details."); } }
[ "public", "function", "getRowCount", "(", ")", "{", "$", "mapper", "=", "ObjectFactory", "::", "getInstance", "(", "'persistenceFacade'", ")", "->", "getMapper", "(", "$", "this", "->", "type", ")", ";", "if", "(", "$", "this", "->", "table", ")", "{", ...
Execute a count query and return the row count @return Integer
[ "Execute", "a", "count", "query", "and", "return", "the", "row", "count" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L158-L201
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.save
public function save() { if ($this->id != self::NO_CACHE) { $cache = ObjectFactory::getInstance('staticCache'); $cache->put(self::getCacheSection($this->type), self::getCacheId($this->id), $this); } }
php
public function save() { if ($this->id != self::NO_CACHE) { $cache = ObjectFactory::getInstance('staticCache'); $cache->put(self::getCacheSection($this->type), self::getCacheId($this->id), $this); } }
[ "public", "function", "save", "(", ")", "{", "if", "(", "$", "this", "->", "id", "!=", "self", "::", "NO_CACHE", ")", "{", "$", "cache", "=", "ObjectFactory", "::", "getInstance", "(", "'staticCache'", ")", ";", "$", "cache", "->", "put", "(", "self"...
Put the statement into the cache
[ "Put", "the", "statement", "into", "the", "cache" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L206-L211
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.addColumns
public function addColumns(array $columns, $joinName=null) { if ($joinName === null) { // add normal column $this->columns = $this->columns + $columns; } else { // add column to join $joins = []; foreach ($this->joins->getJoins() as $join) { if ($join['name'] == $joinName || in_array($joinName, array_keys($join['name']))) { $join['columns'] += $columns; } $joins[] = $join; } $this->joins->reset(); foreach ($joins as $join) { parent::join($join['name'], $join['on'], $join['columns'], $join['type']); } } }
php
public function addColumns(array $columns, $joinName=null) { if ($joinName === null) { // add normal column $this->columns = $this->columns + $columns; } else { // add column to join $joins = []; foreach ($this->joins->getJoins() as $join) { if ($join['name'] == $joinName || in_array($joinName, array_keys($join['name']))) { $join['columns'] += $columns; } $joins[] = $join; } $this->joins->reset(); foreach ($joins as $join) { parent::join($join['name'], $join['on'], $join['columns'], $join['type']); } } }
[ "public", "function", "addColumns", "(", "array", "$", "columns", ",", "$", "joinName", "=", "null", ")", "{", "if", "(", "$", "joinName", "===", "null", ")", "{", "// add normal column", "$", "this", "->", "columns", "=", "$", "this", "->", "columns", ...
Add columns to the statement @param $columns Array of columns (@see Select::columns()) @param $joinName The name of the join to which the columns belong
[ "Add", "columns", "to", "the", "statement" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L231-L250
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.getAliasNames
public function getAliasNames($table) { $names = []; if (is_array($this->table) && current($this->table) == $table) { $names[] = key($this->table); } foreach ($this->joins->getJoins() as $join) { $joinName = $join['name']; if (is_array($joinName) && current($joinName) == $table) { $names[] = key($joinName); } } return $names; }
php
public function getAliasNames($table) { $names = []; if (is_array($this->table) && current($this->table) == $table) { $names[] = key($this->table); } foreach ($this->joins->getJoins() as $join) { $joinName = $join['name']; if (is_array($joinName) && current($joinName) == $table) { $names[] = key($joinName); } } return $names; }
[ "public", "function", "getAliasNames", "(", "$", "table", ")", "{", "$", "names", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "this", "->", "table", ")", "&&", "current", "(", "$", "this", "->", "table", ")", "==", "$", "table", ")", "{"...
Get the alias names for a table name @param $tables @return Array
[ "Get", "the", "alias", "names", "for", "a", "table", "name" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L257-L269
train
iherwig/wcmf
src/wcmf/lib/model/mapper/SelectStatement.php
SelectStatement.getSql
public function getSql() { $cacheKey = self::getCacheId($this->id); if (!isset($this->cachedSql[$cacheKey])) { $sql = trim((new Sql($this->getAdapter()))->buildSqlString($this)); $this->cachedSql[$cacheKey] = $sql; } return $this->cachedSql[$cacheKey]; }
php
public function getSql() { $cacheKey = self::getCacheId($this->id); if (!isset($this->cachedSql[$cacheKey])) { $sql = trim((new Sql($this->getAdapter()))->buildSqlString($this)); $this->cachedSql[$cacheKey] = $sql; } return $this->cachedSql[$cacheKey]; }
[ "public", "function", "getSql", "(", ")", "{", "$", "cacheKey", "=", "self", "::", "getCacheId", "(", "$", "this", "->", "id", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "cachedSql", "[", "$", "cacheKey", "]", ")", ")", "{", "$", ...
Get the sql string for this statement @return String
[ "Get", "the", "sql", "string", "for", "this", "statement" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/model/mapper/SelectStatement.php#L275-L282
train
iherwig/wcmf
src/wcmf/application/controller/BatchDisplayController.php
BatchDisplayController.loadNode
protected function loadNode(ObjectId $oid) { // check if we already loaded the node if ($this->isRegistered($oid)) { return; } $persistenceFacade = $this->getPersistenceFacade(); // restore the request values from session $language = $this->getRequestValue('language'); $translateValues = StringUtil::getBoolean($this->getRequestValue('translateValues')); // load the node $node = $persistenceFacade->load($oid); if ($node == null) { throw new PersistenceException("Can't load node '".$oid."'"); } // translate all nodes to the requested language if requested if ($this->isLocalizedRequest()) { $localization = $this->getLocalization(); $node = $localization->loadTranslation($node, $language, true, true); } // translate values if requested if ($translateValues) { $nodes = [$node]; if ($this->isLocalizedRequest()) { NodeUtil::translateValues($nodes, $language); } else { NodeUtil::translateValues($nodes); } } // assign it to the response $this->addNodeToResponse($node); $this->register($oid); $logger = $this->getLogger(); if ($logger->isInfoEnabled()) { $logger->info("Loaded: ".$node->getOID()); } if ($logger->isDebugEnabled()) { $logger->debug($node->toString()); } }
php
protected function loadNode(ObjectId $oid) { // check if we already loaded the node if ($this->isRegistered($oid)) { return; } $persistenceFacade = $this->getPersistenceFacade(); // restore the request values from session $language = $this->getRequestValue('language'); $translateValues = StringUtil::getBoolean($this->getRequestValue('translateValues')); // load the node $node = $persistenceFacade->load($oid); if ($node == null) { throw new PersistenceException("Can't load node '".$oid."'"); } // translate all nodes to the requested language if requested if ($this->isLocalizedRequest()) { $localization = $this->getLocalization(); $node = $localization->loadTranslation($node, $language, true, true); } // translate values if requested if ($translateValues) { $nodes = [$node]; if ($this->isLocalizedRequest()) { NodeUtil::translateValues($nodes, $language); } else { NodeUtil::translateValues($nodes); } } // assign it to the response $this->addNodeToResponse($node); $this->register($oid); $logger = $this->getLogger(); if ($logger->isInfoEnabled()) { $logger->info("Loaded: ".$node->getOID()); } if ($logger->isDebugEnabled()) { $logger->debug($node->toString()); } }
[ "protected", "function", "loadNode", "(", "ObjectId", "$", "oid", ")", "{", "// check if we already loaded the node", "if", "(", "$", "this", "->", "isRegistered", "(", "$", "oid", ")", ")", "{", "return", ";", "}", "$", "persistenceFacade", "=", "$", "this"...
Load the node with the given object id and assign it to the response. @param $oid The object id of the node to copy
[ "Load", "the", "node", "with", "the", "given", "object", "id", "and", "assign", "it", "to", "the", "response", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchDisplayController.php#L208-L254
train
iherwig/wcmf
src/wcmf/application/controller/BatchDisplayController.php
BatchDisplayController.register
protected function register(ObjectId $oid) { $registry = $this->getLocalSessionValue(self::REGISTRY_VAR); $registry[] = $oid->__toString(); $this->setLocalSessionValue(self::REGISTRY_VAR, $registry); }
php
protected function register(ObjectId $oid) { $registry = $this->getLocalSessionValue(self::REGISTRY_VAR); $registry[] = $oid->__toString(); $this->setLocalSessionValue(self::REGISTRY_VAR, $registry); }
[ "protected", "function", "register", "(", "ObjectId", "$", "oid", ")", "{", "$", "registry", "=", "$", "this", "->", "getLocalSessionValue", "(", "self", "::", "REGISTRY_VAR", ")", ";", "$", "registry", "[", "]", "=", "$", "oid", "->", "__toString", "(",...
Register an object id in the registry @param $oid The object id to register
[ "Register", "an", "object", "id", "in", "the", "registry" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchDisplayController.php#L260-L264
train
iherwig/wcmf
src/wcmf/application/controller/BatchDisplayController.php
BatchDisplayController.isRegistered
protected function isRegistered(ObjectId $oid) { $registry = $this->getLocalSessionValue(self::REGISTRY_VAR); return in_array($oid->__toString(), $registry); }
php
protected function isRegistered(ObjectId $oid) { $registry = $this->getLocalSessionValue(self::REGISTRY_VAR); return in_array($oid->__toString(), $registry); }
[ "protected", "function", "isRegistered", "(", "ObjectId", "$", "oid", ")", "{", "$", "registry", "=", "$", "this", "->", "getLocalSessionValue", "(", "self", "::", "REGISTRY_VAR", ")", ";", "return", "in_array", "(", "$", "oid", "->", "__toString", "(", ")...
Check if an object id is registered in the registry @param $oid The object id to check @return Boolean whether the object id is registered or not
[ "Check", "if", "an", "object", "id", "is", "registered", "in", "the", "registry" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchDisplayController.php#L271-L274
train
iherwig/wcmf
src/wcmf/application/controller/BatchDisplayController.php
BatchDisplayController.addNodeToResponse
protected function addNodeToResponse(Node $node) { $response = $this->getResponse(); if (!$response->hasValue('list')) { $objects = []; $response->setValue('list', $objects); } $objects = $response->getValue('list'); $objects[] = $node; $response->setValue('list', $objects); }
php
protected function addNodeToResponse(Node $node) { $response = $this->getResponse(); if (!$response->hasValue('list')) { $objects = []; $response->setValue('list', $objects); } $objects = $response->getValue('list'); $objects[] = $node; $response->setValue('list', $objects); }
[ "protected", "function", "addNodeToResponse", "(", "Node", "$", "node", ")", "{", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "if", "(", "!", "$", "response", "->", "hasValue", "(", "'list'", ")", ")", "{", "$", "objects", ...
Add a given node to the list variable of the response @param $node The Node instance to add
[ "Add", "a", "given", "node", "to", "the", "list", "variable", "of", "the", "response" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchDisplayController.php#L280-L290
train
GW2Treasures/gw2api
src/V2/Schema/SchemaHandler.php
SchemaHandler.onRequest
public function onRequest( RequestInterface $request ) { $schema = $this->getEndpoint()->getSchema(); return $request->withHeader( 'X-Schema-Version', $schema ); }
php
public function onRequest( RequestInterface $request ) { $schema = $this->getEndpoint()->getSchema(); return $request->withHeader( 'X-Schema-Version', $schema ); }
[ "public", "function", "onRequest", "(", "RequestInterface", "$", "request", ")", "{", "$", "schema", "=", "$", "this", "->", "getEndpoint", "(", ")", "->", "getSchema", "(", ")", ";", "return", "$", "request", "->", "withHeader", "(", "'X-Schema-Version'", ...
Add the schema version header. @param RequestInterface $request @return MessageInterface|RequestInterface
[ "Add", "the", "schema", "version", "header", "." ]
c8795af0c1d0a434b9e530f779d5a95786db2176
https://github.com/GW2Treasures/gw2api/blob/c8795af0c1d0a434b9e530f779d5a95786db2176/src/V2/Schema/SchemaHandler.php#L22-L26
train
iherwig/wcmf
src/wcmf/application/controller/MediaController.php
MediaController.onFileMoved
protected function onFileMoved($cmd, $result, $args, $elfinder) { $addedFiles = $result['added']; $removedFiles = $result['removed']; for ($i=0, $count=sizeof($removedFiles); $i<$count; $i++) { $source = $removedFiles[$i]['realpath']; $target = $elfinder->realpath($addedFiles[$i]['hash']); } $logger = $this->getLogger(); $logger->debug($cmd." file: ".$source." -> ".$target); }
php
protected function onFileMoved($cmd, $result, $args, $elfinder) { $addedFiles = $result['added']; $removedFiles = $result['removed']; for ($i=0, $count=sizeof($removedFiles); $i<$count; $i++) { $source = $removedFiles[$i]['realpath']; $target = $elfinder->realpath($addedFiles[$i]['hash']); } $logger = $this->getLogger(); $logger->debug($cmd." file: ".$source." -> ".$target); }
[ "protected", "function", "onFileMoved", "(", "$", "cmd", ",", "$", "result", ",", "$", "args", ",", "$", "elfinder", ")", "{", "$", "addedFiles", "=", "$", "result", "[", "'added'", "]", ";", "$", "removedFiles", "=", "$", "result", "[", "'removed'", ...
Called when file is moved @param $cmd elFinder command name @param $result Command result as array @param $args Command arguments from client @param $elfinder elFinder instance
[ "Called", "when", "file", "is", "moved" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/MediaController.php#L156-L165
train
iherwig/wcmf
src/wcmf/lib/i18n/impl/FileMessage.php
FileMessage.getTranslations
private function getTranslations($lang) { if (!isset($this->translations[$lang])) { $messageFile = $this->localeDir."/messages_".$lang.".php"; if (file_exists($messageFile)) { require_once($messageFile); // store for later reference $this->translations[$lang] = ${"messages_$lang"}; } else { $this->translations[$lang] = []; } } return $this->translations[$lang]; }
php
private function getTranslations($lang) { if (!isset($this->translations[$lang])) { $messageFile = $this->localeDir."/messages_".$lang.".php"; if (file_exists($messageFile)) { require_once($messageFile); // store for later reference $this->translations[$lang] = ${"messages_$lang"}; } else { $this->translations[$lang] = []; } } return $this->translations[$lang]; }
[ "private", "function", "getTranslations", "(", "$", "lang", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "translations", "[", "$", "lang", "]", ")", ")", "{", "$", "messageFile", "=", "$", "this", "->", "localeDir", ".", "\"/messages_\"",...
Get all translations for a language. @param $lang The language (optional, default: '') @return The translations as associative array
[ "Get", "all", "translations", "for", "a", "language", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/i18n/impl/FileMessage.php#L97-L110
train
vufind-org/vufindharvest
src/OaiPmh/HarvesterFactory.php
HarvesterFactory.configureClient
protected function configureClient(Client $client, array $settings) { $configuredClient = $client ?: new Client(); // Set authentication, if necessary: if (!empty($settings['httpUser']) && !empty($settings['httpPass'])) { $configuredClient->setAuth($settings['httpUser'], $settings['httpPass']); } // Set up assorted client options from $settings array: $configuredClient->setOptions($this->getClientOptions($settings)); return $configuredClient; }
php
protected function configureClient(Client $client, array $settings) { $configuredClient = $client ?: new Client(); // Set authentication, if necessary: if (!empty($settings['httpUser']) && !empty($settings['httpPass'])) { $configuredClient->setAuth($settings['httpUser'], $settings['httpPass']); } // Set up assorted client options from $settings array: $configuredClient->setOptions($this->getClientOptions($settings)); return $configuredClient; }
[ "protected", "function", "configureClient", "(", "Client", "$", "client", ",", "array", "$", "settings", ")", "{", "$", "configuredClient", "=", "$", "client", "?", ":", "new", "Client", "(", ")", ";", "// Set authentication, if necessary:", "if", "(", "!", ...
Configure the HTTP client @param Client $client HTTP client @param array $settings Settings @return Client @throws Exception
[ "Configure", "the", "HTTP", "client" ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterFactory.php#L103-L116
train
vufind-org/vufindharvest
src/OaiPmh/HarvesterFactory.php
HarvesterFactory.getBasePath
protected function getBasePath($harvestRoot, $target) { // Build the full harvest path: $basePath = rtrim($harvestRoot, '/') . '/' . rtrim($target, '/') . '/'; // Create the directory if it does not already exist: if (!is_dir($basePath)) { if (!mkdir($basePath)) { throw new \Exception("Problem creating directory {$basePath}."); } } return $basePath; }
php
protected function getBasePath($harvestRoot, $target) { // Build the full harvest path: $basePath = rtrim($harvestRoot, '/') . '/' . rtrim($target, '/') . '/'; // Create the directory if it does not already exist: if (!is_dir($basePath)) { if (!mkdir($basePath)) { throw new \Exception("Problem creating directory {$basePath}."); } } return $basePath; }
[ "protected", "function", "getBasePath", "(", "$", "harvestRoot", ",", "$", "target", ")", "{", "// Build the full harvest path:", "$", "basePath", "=", "rtrim", "(", "$", "harvestRoot", ",", "'/'", ")", ".", "'/'", ".", "rtrim", "(", "$", "target", ",", "'...
Set up directory structure for harvesting. @param string $harvestRoot Root directory containing harvested data. @param string $target The OAI-PMH target directory to create inside $harvestRoot. @return string
[ "Set", "up", "directory", "structure", "for", "harvesting", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterFactory.php#L127-L140
train
vufind-org/vufindharvest
src/OaiPmh/HarvesterFactory.php
HarvesterFactory.getCommunicator
protected function getCommunicator(Client $client, array $settings, ResponseProcessorInterface $processor, $target ) { if (empty($settings['url'])) { throw new \Exception("Missing base URL for {$target}."); } $comm = new Communicator($settings['url'], $client, $processor); // We only want the communicator to output messages if we are in verbose // mode; communicator messages are considered verbose output. if (isset($settings['verbose']) && $settings['verbose'] && $writer = $this->getConsoleWriter($settings) ) { $comm->setOutputWriter($writer); } return $comm; }
php
protected function getCommunicator(Client $client, array $settings, ResponseProcessorInterface $processor, $target ) { if (empty($settings['url'])) { throw new \Exception("Missing base URL for {$target}."); } $comm = new Communicator($settings['url'], $client, $processor); // We only want the communicator to output messages if we are in verbose // mode; communicator messages are considered verbose output. if (isset($settings['verbose']) && $settings['verbose'] && $writer = $this->getConsoleWriter($settings) ) { $comm->setOutputWriter($writer); } return $comm; }
[ "protected", "function", "getCommunicator", "(", "Client", "$", "client", ",", "array", "$", "settings", ",", "ResponseProcessorInterface", "$", "processor", ",", "$", "target", ")", "{", "if", "(", "empty", "(", "$", "settings", "[", "'url'", "]", ")", ")...
Get the communicator. @param Client $client HTTP client @param array $settings Additional settings @param ResponseProcessorInterface $processor Response processor @param string $target Target being configured (used for error messages) @return Communicator
[ "Get", "the", "communicator", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterFactory.php#L153-L168
train
vufind-org/vufindharvest
src/OaiPmh/HarvesterFactory.php
HarvesterFactory.getFormatter
protected function getFormatter(Communicator $communicator, array $settings) { // Build the formatter: $formatter = new RecordXmlFormatter($settings); // Load set names if we're going to need them: if ($formatter->needsSetNames()) { $loader = $this->getSetLoader($communicator, $settings); if ($writer = $this->getConsoleWriter($settings)) { $loader->setOutputWriter($writer); } $formatter->setSetNames($loader->getNames()); } return $formatter; }
php
protected function getFormatter(Communicator $communicator, array $settings) { // Build the formatter: $formatter = new RecordXmlFormatter($settings); // Load set names if we're going to need them: if ($formatter->needsSetNames()) { $loader = $this->getSetLoader($communicator, $settings); if ($writer = $this->getConsoleWriter($settings)) { $loader->setOutputWriter($writer); } $formatter->setSetNames($loader->getNames()); } return $formatter; }
[ "protected", "function", "getFormatter", "(", "Communicator", "$", "communicator", ",", "array", "$", "settings", ")", "{", "// Build the formatter:", "$", "formatter", "=", "new", "RecordXmlFormatter", "(", "$", "settings", ")", ";", "// Load set names if we're going...
Get the record XML formatter. @param Communicator $communicator Communicator @param array $settings Additional settings @return RecordXmlFormatter
[ "Get", "the", "record", "XML", "formatter", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterFactory.php#L178-L193
train
vufind-org/vufindharvest
src/OaiPmh/HarvesterFactory.php
HarvesterFactory.getWriter
protected function getWriter(RecordWriterStrategyInterface $strategy, RecordXmlFormatter $formatter, array $settings ) { return new RecordWriter($strategy, $formatter, $settings); }
php
protected function getWriter(RecordWriterStrategyInterface $strategy, RecordXmlFormatter $formatter, array $settings ) { return new RecordWriter($strategy, $formatter, $settings); }
[ "protected", "function", "getWriter", "(", "RecordWriterStrategyInterface", "$", "strategy", ",", "RecordXmlFormatter", "$", "formatter", ",", "array", "$", "settings", ")", "{", "return", "new", "RecordWriter", "(", "$", "strategy", ",", "$", "formatter", ",", ...
Build the writer support object. @param RecordWriterStrategyInterface $strategy Writing strategy @param RecordXmlFormatter $formatter XML record formatter @param array $settings Configuration settings @return RecordWriter
[ "Build", "the", "writer", "support", "object", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterFactory.php#L256-L260
train
vufind-org/vufindharvest
src/OaiPmh/HarvesterFactory.php
HarvesterFactory.getHarvester
public function getHarvester($target, $harvestRoot, Client $client = null, array $settings = [] ) { $basePath = $this->getBasePath($harvestRoot, $target); $responseProcessor = $this->getResponseProcessor($basePath, $settings); $communicator = $this->getCommunicator( $this->configureClient($client, $settings), $settings, $responseProcessor, $target ); $formatter = $this->getFormatter($communicator, $settings); $strategy = $this->getWriterStrategyFactory() ->getStrategy($basePath, $settings); $writer = $this->getWriter($strategy, $formatter, $settings); $stateManager = $this->getStateManager($basePath); $harvester = new Harvester($communicator, $writer, $stateManager, $settings); if ($writer = $this->getConsoleWriter($settings)) { $harvester->setOutputWriter($writer); } return $harvester; }
php
public function getHarvester($target, $harvestRoot, Client $client = null, array $settings = [] ) { $basePath = $this->getBasePath($harvestRoot, $target); $responseProcessor = $this->getResponseProcessor($basePath, $settings); $communicator = $this->getCommunicator( $this->configureClient($client, $settings), $settings, $responseProcessor, $target ); $formatter = $this->getFormatter($communicator, $settings); $strategy = $this->getWriterStrategyFactory() ->getStrategy($basePath, $settings); $writer = $this->getWriter($strategy, $formatter, $settings); $stateManager = $this->getStateManager($basePath); $harvester = new Harvester($communicator, $writer, $stateManager, $settings); if ($writer = $this->getConsoleWriter($settings)) { $harvester->setOutputWriter($writer); } return $harvester; }
[ "public", "function", "getHarvester", "(", "$", "target", ",", "$", "harvestRoot", ",", "Client", "$", "client", "=", "null", ",", "array", "$", "settings", "=", "[", "]", ")", "{", "$", "basePath", "=", "$", "this", "->", "getBasePath", "(", "$", "h...
Get the harvester @param string $target Name of source being harvested (used as directory name for storing harvested data inside $harvestRoot) @param string $harvestRoot Root directory containing harvested data. @param Client $client HTTP client @param array $settings Additional settings @return Harvester @throws \Exception
[ "Get", "the", "harvester" ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/HarvesterFactory.php#L285-L304
train
iherwig/wcmf
src/wcmf/application/controller/BatchController.php
BatchController.addWorkPackage
protected function addWorkPackage($name, $size, array $oids, $callback, $args=null) { $request = $this->getRequest(); $response = $this->getResponse(); if (strlen($callback) == 0) { throw new ApplicationException($request, $response, ApplicationError::getGeneral("Wrong work package description '".$name."': No callback given.")); } $workPackages = $this->getLocalSessionValue(self::PACKAGES_VAR); $counter = 1; $total = sizeof($oids); while(sizeof($oids) > 0) { $items = []; for($i=0; $i<$size && sizeof($oids)>0; $i++) { $nextItem = array_shift($oids); $items[] = sprintf('%s', $nextItem); } // define status text $start = $counter; $end = ($counter+sizeof($items)-1); $stepsText = $counter; if ($start != $end) { $stepsText .= '-'.($counter+sizeof($items)-1); } $statusText = ""; if ($total > 1) { $statusText = $stepsText.'/'.$total; } $curWorkPackage = [ 'name' => $name.' '.$statusText, 'oids' => $items, 'callback' => $callback, 'args' => $args ]; $workPackages[] = $curWorkPackage; $counter += $size; } $this->workPackages = $workPackages; // update session $this->setLocalSessionValue(self::PACKAGES_VAR, $workPackages); $this->setLocalSessionValue(self::NUM_STEPS_VAR, sizeof($workPackages)); }
php
protected function addWorkPackage($name, $size, array $oids, $callback, $args=null) { $request = $this->getRequest(); $response = $this->getResponse(); if (strlen($callback) == 0) { throw new ApplicationException($request, $response, ApplicationError::getGeneral("Wrong work package description '".$name."': No callback given.")); } $workPackages = $this->getLocalSessionValue(self::PACKAGES_VAR); $counter = 1; $total = sizeof($oids); while(sizeof($oids) > 0) { $items = []; for($i=0; $i<$size && sizeof($oids)>0; $i++) { $nextItem = array_shift($oids); $items[] = sprintf('%s', $nextItem); } // define status text $start = $counter; $end = ($counter+sizeof($items)-1); $stepsText = $counter; if ($start != $end) { $stepsText .= '-'.($counter+sizeof($items)-1); } $statusText = ""; if ($total > 1) { $statusText = $stepsText.'/'.$total; } $curWorkPackage = [ 'name' => $name.' '.$statusText, 'oids' => $items, 'callback' => $callback, 'args' => $args ]; $workPackages[] = $curWorkPackage; $counter += $size; } $this->workPackages = $workPackages; // update session $this->setLocalSessionValue(self::PACKAGES_VAR, $workPackages); $this->setLocalSessionValue(self::NUM_STEPS_VAR, sizeof($workPackages)); }
[ "protected", "function", "addWorkPackage", "(", "$", "name", ",", "$", "size", ",", "array", "$", "oids", ",", "$", "callback", ",", "$", "args", "=", "null", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "resp...
Add a work package to session. This package will be divided into sub packages of given size. @param $name Display name of the package (will be supplemented by startNumber-endNumber, e.g. '1-7', '8-14', ...) @param $size Size of one sub package. This defines how many of the oids will be passed to the callback in one call (e.g. '7' means pass 7 oids per call) @param $oids An array of object ids (or other application specific package identifiers) that will be distributed into sub packages of given size @param $callback The name of method to call for this package type. The callback method must accept the following parameters: 1. array parameter (the object ids to process in the current call) 2. optionally array parameter (the additional arguments) @param $args Associative array of additional callback arguments (application specific) (default: _null_)
[ "Add", "a", "work", "package", "to", "session", ".", "This", "package", "will", "be", "divided", "into", "sub", "packages", "of", "given", "size", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchController.php#L209-L253
train
iherwig/wcmf
src/wcmf/application/controller/BatchController.php
BatchController.getRequestValue
protected function getRequestValue($name) { $requestValues = $this->getLocalSessionValue(self::REQUEST_VAR); return isset($requestValues[$name]) ? $requestValues[$name] : null; }
php
protected function getRequestValue($name) { $requestValues = $this->getLocalSessionValue(self::REQUEST_VAR); return isset($requestValues[$name]) ? $requestValues[$name] : null; }
[ "protected", "function", "getRequestValue", "(", "$", "name", ")", "{", "$", "requestValues", "=", "$", "this", "->", "getLocalSessionValue", "(", "self", "::", "REQUEST_VAR", ")", ";", "return", "isset", "(", "$", "requestValues", "[", "$", "name", "]", "...
Get a value from the initial request. @param $name The name of the value @return Mixed
[ "Get", "a", "value", "from", "the", "initial", "request", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchController.php#L284-L287
train
iherwig/wcmf
src/wcmf/application/controller/BatchController.php
BatchController.getDisplayText
protected function getDisplayText($step) { $numPackages = sizeof($this->workPackages); return ($step>=0 && $step<$numPackages) ? $this->workPackages[$step]['name']." ..." : ($step>=$numPackages ? "Done" : ""); }
php
protected function getDisplayText($step) { $numPackages = sizeof($this->workPackages); return ($step>=0 && $step<$numPackages) ? $this->workPackages[$step]['name']." ..." : ($step>=$numPackages ? "Done" : ""); }
[ "protected", "function", "getDisplayText", "(", "$", "step", ")", "{", "$", "numPackages", "=", "sizeof", "(", "$", "this", "->", "workPackages", ")", ";", "return", "(", "$", "step", ">=", "0", "&&", "$", "step", "<", "$", "numPackages", ")", "?", "...
Get the text to display for the current step. @param $step The step number
[ "Get", "the", "text", "to", "display", "for", "the", "current", "step", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/application/controller/BatchController.php#L301-L305
train
iherwig/wcmf
src/wcmf/lib/presentation/Controller.php
Controller.executeSubAction
protected function executeSubAction($action) { $curRequest = $this->getRequest(); $subRequest = ObjectFactory::getNewInstance('request'); $subRequest->setSender(get_class($this)); $subRequest->setContext($curRequest->getContext()); $subRequest->setAction($action); $subRequest->setHeaders($curRequest->getHeaders()); $subRequest->setValues($curRequest->getValues()); $subRequest->setFormat('null'); $subRequest->setResponseFormat('null'); $subResponse = ObjectFactory::getNewInstance('response'); $this->actionMapper->processAction($subRequest, $subResponse); return $subResponse; }
php
protected function executeSubAction($action) { $curRequest = $this->getRequest(); $subRequest = ObjectFactory::getNewInstance('request'); $subRequest->setSender(get_class($this)); $subRequest->setContext($curRequest->getContext()); $subRequest->setAction($action); $subRequest->setHeaders($curRequest->getHeaders()); $subRequest->setValues($curRequest->getValues()); $subRequest->setFormat('null'); $subRequest->setResponseFormat('null'); $subResponse = ObjectFactory::getNewInstance('response'); $this->actionMapper->processAction($subRequest, $subResponse); return $subResponse; }
[ "protected", "function", "executeSubAction", "(", "$", "action", ")", "{", "$", "curRequest", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "subRequest", "=", "ObjectFactory", "::", "getNewInstance", "(", "'request'", ")", ";", "$", "subRequest",...
Delegate the current request to another action. The context is the same as the current context and the source controller will be set to this. The request and response format will be NullFormat which means that all request values should be passed in the application internal format and all response values will have that format. Execution will return to the calling controller instance afterwards. @param $action The name of the action to execute @return Response instance
[ "Delegate", "the", "current", "request", "to", "another", "action", ".", "The", "context", "is", "the", "same", "as", "the", "current", "context", "and", "the", "source", "controller", "will", "be", "set", "to", "this", ".", "The", "request", "and", "respo...
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Controller.php#L211-L224
train
iherwig/wcmf
src/wcmf/lib/presentation/Controller.php
Controller.endTransaction
protected function endTransaction($commit) { $tx = $this->getPersistenceFacade()->getTransaction(); if ($this->startedTransaction && $tx->isActive()) { if ($commit) { $tx->commit(); } else { $tx->rollback(); } } $this->startedTransaction = false; }
php
protected function endTransaction($commit) { $tx = $this->getPersistenceFacade()->getTransaction(); if ($this->startedTransaction && $tx->isActive()) { if ($commit) { $tx->commit(); } else { $tx->rollback(); } } $this->startedTransaction = false; }
[ "protected", "function", "endTransaction", "(", "$", "commit", ")", "{", "$", "tx", "=", "$", "this", "->", "getPersistenceFacade", "(", ")", "->", "getTransaction", "(", ")", ";", "if", "(", "$", "this", "->", "startedTransaction", "&&", "$", "tx", "->"...
End the transaction. Only if this controller instance started the transaction, it will be committed or rolled back. Otherwise the call will be ignored. @param $commit Boolean whether the transaction should be committed
[ "End", "the", "transaction", ".", "Only", "if", "this", "controller", "instance", "started", "the", "transaction", "it", "will", "be", "committed", "or", "rolled", "back", ".", "Otherwise", "the", "call", "will", "be", "ignored", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Controller.php#L347-L358
train
iherwig/wcmf
src/wcmf/lib/presentation/Controller.php
Controller.getLocalSessionValue
protected function getLocalSessionValue($key, $default=null) { $sessionVarname = get_class($this); $localValues = $this->session->get($sessionVarname, null); return array_key_exists($key, $localValues) ? $localValues[$key] : $default; }
php
protected function getLocalSessionValue($key, $default=null) { $sessionVarname = get_class($this); $localValues = $this->session->get($sessionVarname, null); return array_key_exists($key, $localValues) ? $localValues[$key] : $default; }
[ "protected", "function", "getLocalSessionValue", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "sessionVarname", "=", "get_class", "(", "$", "this", ")", ";", "$", "localValues", "=", "$", "this", "->", "session", "->", "get", "(", ...
Set the value of a local session variable. @param $key The key (name) of the session vaiable. @param $default The default value if the key is not defined (optional, default: _null_) @return The session var or null if it doesn't exist.
[ "Set", "the", "value", "of", "a", "local", "session", "variable", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Controller.php#L435-L439
train
iherwig/wcmf
src/wcmf/lib/presentation/Controller.php
Controller.setLocalSessionValue
protected function setLocalSessionValue($key, $value) { $sessionVarname = get_class($this); $localValues = $this->session->get($sessionVarname, null); if ($localValues == null) { $localValues = []; } $localValues[$key] = $value; $this->session->set($sessionVarname, $localValues); }
php
protected function setLocalSessionValue($key, $value) { $sessionVarname = get_class($this); $localValues = $this->session->get($sessionVarname, null); if ($localValues == null) { $localValues = []; } $localValues[$key] = $value; $this->session->set($sessionVarname, $localValues); }
[ "protected", "function", "setLocalSessionValue", "(", "$", "key", ",", "$", "value", ")", "{", "$", "sessionVarname", "=", "get_class", "(", "$", "this", ")", ";", "$", "localValues", "=", "$", "this", "->", "session", "->", "get", "(", "$", "sessionVarn...
Get the value of a local session variable. @param $key The key (name) of the session vaiable. @param $value The value of the session variable.
[ "Get", "the", "value", "of", "a", "local", "session", "variable", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/presentation/Controller.php#L446-L454
train
iherwig/wcmf
src/wcmf/lib/config/ActionKey.php
ActionKey.createKey
public static function createKey($resource, $context, $action) { return $resource.self::$actionDelimiter.$context.self::$actionDelimiter.$action; }
php
public static function createKey($resource, $context, $action) { return $resource.self::$actionDelimiter.$context.self::$actionDelimiter.$action; }
[ "public", "static", "function", "createKey", "(", "$", "resource", ",", "$", "context", ",", "$", "action", ")", "{", "return", "$", "resource", ".", "self", "::", "$", "actionDelimiter", ".", "$", "context", ".", "self", "::", "$", "actionDelimiter", "....
Create an action key from the given values @param $resource The resource @param $context The context @param $action The action @return String
[ "Create", "an", "action", "key", "from", "the", "given", "values" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/config/ActionKey.php#L33-L35
train
iherwig/wcmf
src/wcmf/lib/config/ActionKey.php
ActionKey.parseKey
public static function parseKey($actionKey) { list($resource, $context, $action) = explode(self::$actionDelimiter, $actionKey); return ['resource' => $resource, 'context' => $context, 'action' => $action]; }
php
public static function parseKey($actionKey) { list($resource, $context, $action) = explode(self::$actionDelimiter, $actionKey); return ['resource' => $resource, 'context' => $context, 'action' => $action]; }
[ "public", "static", "function", "parseKey", "(", "$", "actionKey", ")", "{", "list", "(", "$", "resource", ",", "$", "context", ",", "$", "action", ")", "=", "explode", "(", "self", "::", "$", "actionDelimiter", ",", "$", "actionKey", ")", ";", "return...
Parse an action @param $actionKey The action key @return Associative array with keys 'resouce', 'context', 'action'
[ "Parse", "an", "action" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/config/ActionKey.php#L42-L45
train
iherwig/wcmf
src/wcmf/lib/config/ActionKey.php
ActionKey.getBestMatch
public static function getBestMatch(ActionKeyProvider $actionKeyProvider, $resource, $context, $action) { $hasResource = strlen($resource) > 0; $hasContext = strlen($context) > 0; $hasAction = strlen($action) > 0; // check resource?context?action if ($hasResource && $hasContext && $hasAction) { $key = self::createKey($resource, $context, $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check resource??action if ($hasResource && $hasAction) { $key = self::createKey($resource, '', $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check resource?context? if ($hasResource && $hasContext) { $key = self::createKey($resource, $context, ''); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ?context?action if ($hasContext && $hasAction) { $key = self::createKey('', $context, $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ??action if ($hasAction) { $key = self::createKey('', '', $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check resource?? if ($hasResource) { $key = self::createKey($resource, '', ''); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ?context? if ($hasContext) { $key = self::createKey('', $context, ''); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ?? $key = self::createKey('', '', ''); if ($actionKeyProvider->containsKey($key)) { return $key; } // no key found for requested key return ''; }
php
public static function getBestMatch(ActionKeyProvider $actionKeyProvider, $resource, $context, $action) { $hasResource = strlen($resource) > 0; $hasContext = strlen($context) > 0; $hasAction = strlen($action) > 0; // check resource?context?action if ($hasResource && $hasContext && $hasAction) { $key = self::createKey($resource, $context, $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check resource??action if ($hasResource && $hasAction) { $key = self::createKey($resource, '', $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check resource?context? if ($hasResource && $hasContext) { $key = self::createKey($resource, $context, ''); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ?context?action if ($hasContext && $hasAction) { $key = self::createKey('', $context, $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ??action if ($hasAction) { $key = self::createKey('', '', $action); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check resource?? if ($hasResource) { $key = self::createKey($resource, '', ''); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ?context? if ($hasContext) { $key = self::createKey('', $context, ''); if ($actionKeyProvider->containsKey($key)) { return $key; } } // check ?? $key = self::createKey('', '', ''); if ($actionKeyProvider->containsKey($key)) { return $key; } // no key found for requested key return ''; }
[ "public", "static", "function", "getBestMatch", "(", "ActionKeyProvider", "$", "actionKeyProvider", ",", "$", "resource", ",", "$", "context", ",", "$", "action", ")", "{", "$", "hasResource", "=", "strlen", "(", "$", "resource", ")", ">", "0", ";", "$", ...
Get an action key that matches a given combination of resource, context, action best. @param $actionKeyProvider ActionKeyProvider instance used to search action keys @param $resource The given resource @param $context The given context @param $action The given action @return The best matching key or an empty string if nothing matches.
[ "Get", "an", "action", "key", "that", "matches", "a", "given", "combination", "of", "resource", "context", "action", "best", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/config/ActionKey.php#L55-L124
train
vufind-org/vufindharvest
src/OaiPmh/RecordWriter.php
RecordWriter.write
public function write($records) { // Array for tracking successfully harvested IDs: $harvestedIds = []; // Date of most recent record encountered: $endDate = 0; $this->strategy->beginWrite(); // Loop through the records: foreach ($records as $record) { // Die if the record is missing its header: if (empty($record->header)) { throw new \Exception('Unexpected missing record header.'); } // Get the ID of the current record: $id = $this->extractID($record); // Save the current record, either as a deleted or as a regular file: $attribs = $record->header->attributes(); if (strtolower($attribs['status']) == 'deleted') { $this->strategy->addDeletedRecord($id); } else { $recordXML = $this->recordFormatter->format($id, $record); $this->strategy->addRecord($id, $recordXML); $harvestedIds[] = $id; } // If the current record's date is newer than the previous end date, // remember it for future reference: $date = $this->normalizeDate($record->header->datestamp); if ($date && $date > $endDate) { $endDate = $date; } } $this->strategy->endWrite(); $this->writeHarvestedIdsLog($harvestedIds); return $endDate; }
php
public function write($records) { // Array for tracking successfully harvested IDs: $harvestedIds = []; // Date of most recent record encountered: $endDate = 0; $this->strategy->beginWrite(); // Loop through the records: foreach ($records as $record) { // Die if the record is missing its header: if (empty($record->header)) { throw new \Exception('Unexpected missing record header.'); } // Get the ID of the current record: $id = $this->extractID($record); // Save the current record, either as a deleted or as a regular file: $attribs = $record->header->attributes(); if (strtolower($attribs['status']) == 'deleted') { $this->strategy->addDeletedRecord($id); } else { $recordXML = $this->recordFormatter->format($id, $record); $this->strategy->addRecord($id, $recordXML); $harvestedIds[] = $id; } // If the current record's date is newer than the previous end date, // remember it for future reference: $date = $this->normalizeDate($record->header->datestamp); if ($date && $date > $endDate) { $endDate = $date; } } $this->strategy->endWrite(); $this->writeHarvestedIdsLog($harvestedIds); return $endDate; }
[ "public", "function", "write", "(", "$", "records", ")", "{", "// Array for tracking successfully harvested IDs:", "$", "harvestedIds", "=", "[", "]", ";", "// Date of most recent record encountered:", "$", "endDate", "=", "0", ";", "$", "this", "->", "strategy", "-...
Save harvested records to disk and return the end date. @param object $records SimpleXML records. @return int
[ "Save", "harvested", "records", "to", "disk", "and", "return", "the", "end", "date", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/RecordWriter.php#L189-L232
train
iherwig/wcmf
src/wcmf/lib/persistence/impl/DefaultPersistenceFacade.php
DefaultPersistenceFacade.setMappers
public function setMappers($mappers) { $this->mappers = $mappers; foreach ($mappers as $fqName => $mapper) { // register simple type names $name = $this->calculateSimpleType($fqName); if (!isset($this->mappers[$name])) { $this->mappers[$name] = $mapper; if (!isset($this->simpleToFqNames[$name])) { $this->simpleToFqNames[$name] = $fqName; } else { // if the simple type name already exists, we remove // it in order to prevent collisions with the new type unset($this->simpleToFqNames[$name]); } } // set logging strategy $mapper->setLogStrategy($this->logStrategy); } }
php
public function setMappers($mappers) { $this->mappers = $mappers; foreach ($mappers as $fqName => $mapper) { // register simple type names $name = $this->calculateSimpleType($fqName); if (!isset($this->mappers[$name])) { $this->mappers[$name] = $mapper; if (!isset($this->simpleToFqNames[$name])) { $this->simpleToFqNames[$name] = $fqName; } else { // if the simple type name already exists, we remove // it in order to prevent collisions with the new type unset($this->simpleToFqNames[$name]); } } // set logging strategy $mapper->setLogStrategy($this->logStrategy); } }
[ "public", "function", "setMappers", "(", "$", "mappers", ")", "{", "$", "this", "->", "mappers", "=", "$", "mappers", ";", "foreach", "(", "$", "mappers", "as", "$", "fqName", "=>", "$", "mapper", ")", "{", "// register simple type names", "$", "name", "...
Set the PersistentMapper instances. @param $mappers Associative array with the fully qualified mapped class names as keys and the mapper instances as values
[ "Set", "the", "PersistentMapper", "instances", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistenceFacade.php#L71-L90
train
iherwig/wcmf
src/wcmf/lib/persistence/impl/DefaultPersistenceFacade.php
DefaultPersistenceFacade.checkArrayParameter
private function checkArrayParameter($param, $paramName, $className=null) { if ($param == null) { return; } if (!is_array($param)) { throw new IllegalArgumentException("The parameter '".$paramName. "' is expected to be null or an array"); } if ($className != null) { foreach ($param as $instance) { if (!($instance instanceof $className)) { throw new IllegalArgumentException("The parameter '".$paramName. "' is expected to contain only instances of '".$className."'"); } } } }
php
private function checkArrayParameter($param, $paramName, $className=null) { if ($param == null) { return; } if (!is_array($param)) { throw new IllegalArgumentException("The parameter '".$paramName. "' is expected to be null or an array"); } if ($className != null) { foreach ($param as $instance) { if (!($instance instanceof $className)) { throw new IllegalArgumentException("The parameter '".$paramName. "' is expected to contain only instances of '".$className."'"); } } } }
[ "private", "function", "checkArrayParameter", "(", "$", "param", ",", "$", "paramName", ",", "$", "className", "=", "null", ")", "{", "if", "(", "$", "param", "==", "null", ")", "{", "return", ";", "}", "if", "(", "!", "is_array", "(", "$", "param", ...
Check if the given value is either null or an array and throw an exception if not @param $param The parameter @param $paramName The name of the parameter (used in the exception text) @param $className Class name to match if, instances of a specific type are expected (optional)
[ "Check", "if", "the", "given", "value", "is", "either", "null", "or", "an", "array", "and", "throw", "an", "exception", "if", "not" ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistenceFacade.php#L277-L293
train
iherwig/wcmf
src/wcmf/lib/persistence/impl/DefaultPersistenceFacade.php
DefaultPersistenceFacade.calculateSimpleType
protected function calculateSimpleType($type) { $pos = strrpos($type, '.'); if ($pos !== false) { return substr($type, $pos+1); } return $type; }
php
protected function calculateSimpleType($type) { $pos = strrpos($type, '.'); if ($pos !== false) { return substr($type, $pos+1); } return $type; }
[ "protected", "function", "calculateSimpleType", "(", "$", "type", ")", "{", "$", "pos", "=", "strrpos", "(", "$", "type", ",", "'.'", ")", ";", "if", "(", "$", "pos", "!==", "false", ")", "{", "return", "substr", "(", "$", "type", ",", "$", "pos", ...
Calculate the simple type name for a given fully qualified type name. @param $type Type name with namespace @return Simple type name (without namespace)
[ "Calculate", "the", "simple", "type", "name", "for", "a", "given", "fully", "qualified", "type", "name", "." ]
2542b8d4139464d39a9a8ce8a954dfecf700c41b
https://github.com/iherwig/wcmf/blob/2542b8d4139464d39a9a8ce8a954dfecf700c41b/src/wcmf/lib/persistence/impl/DefaultPersistenceFacade.php#L318-L324
train
skie/plum_search
src/FormParameter/AutocompleteParameter.php
AutocompleteParameter.initializeInnerParameters
public function initializeInnerParameters() { $paramName = $this->config('name'); $this->_dependentParameters[$paramName] = new HiddenParameter($this->_registry, [ 'name' => $paramName ]); }
php
public function initializeInnerParameters() { $paramName = $this->config('name'); $this->_dependentParameters[$paramName] = new HiddenParameter($this->_registry, [ 'name' => $paramName ]); }
[ "public", "function", "initializeInnerParameters", "(", ")", "{", "$", "paramName", "=", "$", "this", "->", "config", "(", "'name'", ")", ";", "$", "this", "->", "_dependentParameters", "[", "$", "paramName", "]", "=", "new", "HiddenParameter", "(", "$", "...
initialize inner parameters @return void
[ "initialize", "inner", "parameters" ]
24d981e240bff7c15731981d6f9b3056abdaf80e
https://github.com/skie/plum_search/blob/24d981e240bff7c15731981d6f9b3056abdaf80e/src/FormParameter/AutocompleteParameter.php#L74-L80
train
vufind-org/vufindharvest
src/OaiPmh/SetLoader.php
SetLoader.getNames
public function getNames() { $this->write("Loading set list... "); // On the first pass through the following loop, we want to get the // first page of sets without using a resumption token: $params = []; $setNames = []; // Grab set information until we have it all (at which point we will // break out of this otherwise-infinite loop): do { // Process current page of results: $response = $this->sendRequest('ListSets', $params); if (isset($response->ListSets->set)) { foreach ($response->ListSets->set as $current) { $spec = (string)$current->setSpec; $name = (string)$current->setName; if (!empty($spec)) { $setNames[$spec] = $name; } } } // Is there a resumption token? If so, continue looping; if not, // we're done! $params['resumptionToken'] = !empty($response->ListSets->resumptionToken) ? (string)$response->ListSets->resumptionToken : ''; } while (!empty($params['resumptionToken'])); $this->writeLine("found " . count($setNames)); return $setNames; }
php
public function getNames() { $this->write("Loading set list... "); // On the first pass through the following loop, we want to get the // first page of sets without using a resumption token: $params = []; $setNames = []; // Grab set information until we have it all (at which point we will // break out of this otherwise-infinite loop): do { // Process current page of results: $response = $this->sendRequest('ListSets', $params); if (isset($response->ListSets->set)) { foreach ($response->ListSets->set as $current) { $spec = (string)$current->setSpec; $name = (string)$current->setName; if (!empty($spec)) { $setNames[$spec] = $name; } } } // Is there a resumption token? If so, continue looping; if not, // we're done! $params['resumptionToken'] = !empty($response->ListSets->resumptionToken) ? (string)$response->ListSets->resumptionToken : ''; } while (!empty($params['resumptionToken'])); $this->writeLine("found " . count($setNames)); return $setNames; }
[ "public", "function", "getNames", "(", ")", "{", "$", "this", "->", "write", "(", "\"Loading set list... \"", ")", ";", "// On the first pass through the following loop, we want to get the", "// first page of sets without using a resumption token:", "$", "params", "=", "[", "...
Load set list from the server. @return array
[ "Load", "set", "list", "from", "the", "server", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/SetLoader.php#L90-L123
train
vufind-org/vufindharvest
src/OaiPmh/RecordXmlFormatter.php
RecordXmlFormatter.fixNamespaces
protected function fixNamespaces($xml, $ns, $attr = '') { foreach ($ns as $key => $val) { if (!empty($key) && strstr($xml, $key . ':') && !strstr($xml, 'xmlns:' . $key) && !strstr($attr, 'xmlns:' . $key) ) { $attr .= ' xmlns:' . $key . '="' . $val . '"'; } } if (!empty($attr)) { $xml = preg_replace('/>/', ' ' . $attr . '>', $xml, 1); } return $xml; }
php
protected function fixNamespaces($xml, $ns, $attr = '') { foreach ($ns as $key => $val) { if (!empty($key) && strstr($xml, $key . ':') && !strstr($xml, 'xmlns:' . $key) && !strstr($attr, 'xmlns:' . $key) ) { $attr .= ' xmlns:' . $key . '="' . $val . '"'; } } if (!empty($attr)) { $xml = preg_replace('/>/', ' ' . $attr . '>', $xml, 1); } return $xml; }
[ "protected", "function", "fixNamespaces", "(", "$", "xml", ",", "$", "ns", ",", "$", "attr", "=", "''", ")", "{", "foreach", "(", "$", "ns", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "empty", "(", "$", "key", ")", "&&", "s...
Fix namespaces in the top tag of the XML document to compensate for bugs in the SimpleXML library. @param string $xml XML document to clean up @param array $ns Namespaces to check @param string $attr Attributes extracted from the <metadata> tag @return string
[ "Fix", "namespaces", "in", "the", "top", "tag", "of", "the", "XML", "document", "to", "compensate", "for", "bugs", "in", "the", "SimpleXML", "library", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/RecordXmlFormatter.php#L132-L146
train
vufind-org/vufindharvest
src/OaiPmh/RecordXmlFormatter.php
RecordXmlFormatter.getHeaderSetAdditions
protected function getHeaderSetAdditions($setSpec) { $insert = ''; foreach ($setSpec as $current) { $set = (string)$current; if ($this->injectSetSpec) { $insert .= $this->createTag($this->injectSetSpec, $set); } if ($this->injectSetName) { $name = $this->setNames[$set] ?? $set; $insert .= $this->createTag($this->injectSetName, $name); } } return $insert; }
php
protected function getHeaderSetAdditions($setSpec) { $insert = ''; foreach ($setSpec as $current) { $set = (string)$current; if ($this->injectSetSpec) { $insert .= $this->createTag($this->injectSetSpec, $set); } if ($this->injectSetName) { $name = $this->setNames[$set] ?? $set; $insert .= $this->createTag($this->injectSetName, $name); } } return $insert; }
[ "protected", "function", "getHeaderSetAdditions", "(", "$", "setSpec", ")", "{", "$", "insert", "=", "''", ";", "foreach", "(", "$", "setSpec", "as", "$", "current", ")", "{", "$", "set", "=", "(", "string", ")", "$", "current", ";", "if", "(", "$", ...
Format setSpec header element as XML tags for inclusion in final record. @param object $setSpec Header setSpec element (in SimpleXML format). @return string
[ "Format", "setSpec", "header", "element", "as", "XML", "tags", "for", "inclusion", "in", "final", "record", "." ]
43a42d1e2292fbba8974a26ace3d522551a1a88f
https://github.com/vufind-org/vufindharvest/blob/43a42d1e2292fbba8974a26ace3d522551a1a88f/src/OaiPmh/RecordXmlFormatter.php#L180-L194
train