repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
oat-sa/tao-core
actions/form/class.ResetUserPassword.php
tao_actions_form_ResetUserPassword.initElements
public function initElements() { $tokenElement = tao_helpers_form_FormFactory::getElement('token', 'Hidden'); $this->form->addElement($tokenElement); $pass1Element = tao_helpers_form_FormFactory::getElement('newpassword', 'Hiddenbox'); $pass1Element->setDescription(__('New password')); $pass1Element->addValidators(PasswordConstraintsService::singleton()->getValidators()); $pass1Element->setBreakOnFirstError(false); $this->form->addElement($pass1Element); $pass2Element = tao_helpers_form_FormFactory::getElement('newpassword2', 'Hiddenbox'); $pass2Element->setDescription(__('Repeat new password')); $pass2Element->addValidators(array( tao_helpers_form_FormFactory::getValidator('Password', array('password2_ref' => $pass1Element)), )); $this->form->addElement($pass2Element); }
php
public function initElements() { $tokenElement = tao_helpers_form_FormFactory::getElement('token', 'Hidden'); $this->form->addElement($tokenElement); $pass1Element = tao_helpers_form_FormFactory::getElement('newpassword', 'Hiddenbox'); $pass1Element->setDescription(__('New password')); $pass1Element->addValidators(PasswordConstraintsService::singleton()->getValidators()); $pass1Element->setBreakOnFirstError(false); $this->form->addElement($pass1Element); $pass2Element = tao_helpers_form_FormFactory::getElement('newpassword2', 'Hiddenbox'); $pass2Element->setDescription(__('Repeat new password')); $pass2Element->addValidators(array( tao_helpers_form_FormFactory::getValidator('Password', array('password2_ref' => $pass1Element)), )); $this->form->addElement($pass2Element); }
[ "public", "function", "initElements", "(", ")", "{", "$", "tokenElement", "=", "tao_helpers_form_FormFactory", "::", "getElement", "(", "'token'", ",", "'Hidden'", ")", ";", "$", "this", "->", "form", "->", "addElement", "(", "$", "tokenElement", ")", ";", "...
Initialiaze password reset form elements @access public @author Aleh Hutnikau <hutnikau@1pt.com> @return mixed
[ "Initialiaze", "password", "reset", "form", "elements" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.ResetUserPassword.php#L57-L74
oat-sa/tao-core
models/classes/messaging/MessagingService.php
MessagingService.getTransport
protected function getTransport() { if (is_null($this->transport)) { $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $transport = $tao->getConfig(self::CONFIG_KEY); if (!is_object($transport) || !$transport instanceof Transport) { return false; } $this->transport = $transport; } return $this->transport; }
php
protected function getTransport() { if (is_null($this->transport)) { $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $transport = $tao->getConfig(self::CONFIG_KEY); if (!is_object($transport) || !$transport instanceof Transport) { return false; } $this->transport = $transport; } return $this->transport; }
[ "protected", "function", "getTransport", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "transport", ")", ")", "{", "$", "tao", "=", "\\", "common_ext_ExtensionsManager", "::", "singleton", "(", ")", "->", "getExtensionById", "(", "'tao'", ")...
Get the current transport implementation @return Transport
[ "Get", "the", "current", "transport", "implementation" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/messaging/MessagingService.php#L42-L53
oat-sa/tao-core
models/classes/messaging/MessagingService.php
MessagingService.setTransport
public function setTransport(Transport $transporter) { $this->transport = $transporter; $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $tao->setConfig(self::CONFIG_KEY, $this->transport); }
php
public function setTransport(Transport $transporter) { $this->transport = $transporter; $tao = \common_ext_ExtensionsManager::singleton()->getExtensionById('tao'); $tao->setConfig(self::CONFIG_KEY, $this->transport); }
[ "public", "function", "setTransport", "(", "Transport", "$", "transporter", ")", "{", "$", "this", "->", "transport", "=", "$", "transporter", ";", "$", "tao", "=", "\\", "common_ext_ExtensionsManager", "::", "singleton", "(", ")", "->", "getExtensionById", "(...
Set the transport implementation to use @param Transport $transporter
[ "Set", "the", "transport", "implementation", "to", "use" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/messaging/MessagingService.php#L60-L65
oat-sa/tao-core
models/classes/messaging/MessagingService.php
MessagingService.send
public function send(Message $message) { $transport = $this->getTransport(); if ($transport == false) { throw new \common_exception_InconsistentData('Transport strategy not correctly set for '.__CLASS__); } return $this->getTransport()->send($message); }
php
public function send(Message $message) { $transport = $this->getTransport(); if ($transport == false) { throw new \common_exception_InconsistentData('Transport strategy not correctly set for '.__CLASS__); } return $this->getTransport()->send($message); }
[ "public", "function", "send", "(", "Message", "$", "message", ")", "{", "$", "transport", "=", "$", "this", "->", "getTransport", "(", ")", ";", "if", "(", "$", "transport", "==", "false", ")", "{", "throw", "new", "\\", "common_exception_InconsistentData"...
Send a message (destination is part of the message) @param Message $message @return boolean
[ "Send", "a", "message", "(", "destination", "is", "part", "of", "the", "message", ")" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/messaging/MessagingService.php#L73-L80
oat-sa/tao-core
models/classes/http/HttpRequestHelperTrait.php
HttpRequestHelperTrait.getHeaders
protected function getHeaders() { $headers = []; foreach ($this->getPsrRequest()->getHeaders() as $name => $values) { $headers[strtolower($name)] = (count($values) == 1) ? reset($values) : $values; } return $headers; }
php
protected function getHeaders() { $headers = []; foreach ($this->getPsrRequest()->getHeaders() as $name => $values) { $headers[strtolower($name)] = (count($values) == 1) ? reset($values) : $values; } return $headers; }
[ "protected", "function", "getHeaders", "(", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getPsrRequest", "(", ")", "->", "getHeaders", "(", ")", "as", "$", "name", "=>", "$", "values", ")", "{", "$", "headers", ...
Retrieves all message header values. The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header. // Represent the headers as a string foreach ($message->getHeaders() as $name => $values) { echo $name . ": " . implode(", ", $values); } // Emit headers iteratively: foreach ($message->getHeaders() as $name => $values) { foreach ($values as $value) { header(sprintf('%s: %s', $name, $value), false); } } While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified. @return string[][] Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header.
[ "Retrieves", "all", "message", "header", "values", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/http/HttpRequestHelperTrait.php#L64-L71
oat-sa/tao-core
models/classes/http/HttpRequestHelperTrait.php
HttpRequestHelperTrait.getHeader
protected function getHeader($name, $default = null) { if ($this->hasHeader($name)) { return $this->getPsrRequest()->getHeader($name); } else { return $default; } }
php
protected function getHeader($name, $default = null) { if ($this->hasHeader($name)) { return $this->getPsrRequest()->getHeader($name); } else { return $default; } }
[ "protected", "function", "getHeader", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasHeader", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "getPsrRequest", "(", ")", "->", "getHeader",...
Retrieves a message header value by the given case-insensitive name. This method returns an array of all the header values of the given case-insensitive header name. If the header does not appear in the message, this method MUST return an empty array. @param string $name Case-insensitive header field name. @param mixed $default Default value to return if the header does not exist. @return string[] An array of string values as provided for the given header. If the header does not appear in the message, this method MUST return an empty array.
[ "Retrieves", "a", "message", "header", "value", "by", "the", "given", "case", "-", "insensitive", "name", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/http/HttpRequestHelperTrait.php#L101-L108
oat-sa/tao-core
models/classes/http/HttpRequestHelperTrait.php
HttpRequestHelperTrait.isXmlHttpRequest
protected function isXmlHttpRequest() { $serverParams = $this->getPsrRequest()->getServerParams(); if(isset($serverParams['HTTP_X_REQUESTED_WITH'])){ if(strtolower($serverParams['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ return true; } } return false; }
php
protected function isXmlHttpRequest() { $serverParams = $this->getPsrRequest()->getServerParams(); if(isset($serverParams['HTTP_X_REQUESTED_WITH'])){ if(strtolower($serverParams['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ return true; } } return false; }
[ "protected", "function", "isXmlHttpRequest", "(", ")", "{", "$", "serverParams", "=", "$", "this", "->", "getPsrRequest", "(", ")", "->", "getServerParams", "(", ")", ";", "if", "(", "isset", "(", "$", "serverParams", "[", "'HTTP_X_REQUESTED_WITH'", "]", ")"...
Check if the current request is using AJAX @return bool
[ "Check", "if", "the", "current", "request", "is", "using", "AJAX" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/http/HttpRequestHelperTrait.php#L352-L361
oat-sa/tao-core
helpers/grid/Cell/class.ResourceLabelAdapter.php
tao_helpers_grid_Cell_ResourceLabelAdapter.getValue
public function getValue($rowId, $columnId, $data = null) { $returnValue = null; if(!empty($data) && is_string($data) && common_Utils::isUri($data)){ $data = new core_kernel_classes_Resource($data); } if($data instanceof core_kernel_classes_Resource){ $returnValue = $data->getLabel(); }else{ $returnValue = $data;//return the data, unaltered } return $returnValue; }
php
public function getValue($rowId, $columnId, $data = null) { $returnValue = null; if(!empty($data) && is_string($data) && common_Utils::isUri($data)){ $data = new core_kernel_classes_Resource($data); } if($data instanceof core_kernel_classes_Resource){ $returnValue = $data->getLabel(); }else{ $returnValue = $data;//return the data, unaltered } return $returnValue; }
[ "public", "function", "getValue", "(", "$", "rowId", ",", "$", "columnId", ",", "$", "data", "=", "null", ")", "{", "$", "returnValue", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "data", ")", "&&", "is_string", "(", "$", "data", ")", "&...
Short description of method getValue @access public @author Somsack Sipasseuth, <somsack.sipasseuth@tudor.lu> @param string rowId @param string columnId @param string data @return mixed
[ "Short", "description", "of", "method", "getValue" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/grid/Cell/class.ResourceLabelAdapter.php#L50-L66
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.initFormProperties
public function initFormProperties(array $properties) { /** @var core_kernel_classes_Property $property */ foreach ($properties as $property) { $property->feed(); $widget = $this->getWidgetProperty($property); if (is_null($widget) || $widget instanceof core_kernel_classes_Literal) { continue; } $propertyData = [ 'uri' => $property->getUri(), 'label' => $property->getLabel(), 'widget' => $widget->getUri(), ]; // Validators $validators = $this->getPropertyValidators($property); if (!empty($validators)) { $propertyData['validators'] = $validators; } // Range values /** @var core_kernel_classes_Class $range */ $range = $property->getRange(); if (!is_null($range) && $range->getUri() != 'http://www.w3.org/2000/01/rdf-schema#Literal') { $propertyData['range'] = $range->getUri(); $this->ranges[$range->getUri()] = $this->getRangeData($range); } // Existing values if ( $this->doesExist() && !is_null($value = $this->getFieldValue($property, isset($propertyData['range']) ? $propertyData['range'] : null)) ) { $propertyData['value'] = $value; } // Field position in the form $guiPropertyOrder = $property->getOnePropertyValue($this->getProperty(TaoOntology::PROPERTY_GUI_ORDER)); if (!is_null($guiPropertyOrder)) { $position = intval((string)$guiPropertyOrder); $propertyData['position'] = $position; $i = 0; while ( $i < count($this->formProperties) && (isset($this->formProperties[$i]['position']) && $position >= $this->formProperties[$i]['position']) ) { $i++; } array_splice($this->formProperties, $i, 0, array($propertyData)); } else { $this->formProperties[] = $propertyData; } } }
php
public function initFormProperties(array $properties) { /** @var core_kernel_classes_Property $property */ foreach ($properties as $property) { $property->feed(); $widget = $this->getWidgetProperty($property); if (is_null($widget) || $widget instanceof core_kernel_classes_Literal) { continue; } $propertyData = [ 'uri' => $property->getUri(), 'label' => $property->getLabel(), 'widget' => $widget->getUri(), ]; // Validators $validators = $this->getPropertyValidators($property); if (!empty($validators)) { $propertyData['validators'] = $validators; } // Range values /** @var core_kernel_classes_Class $range */ $range = $property->getRange(); if (!is_null($range) && $range->getUri() != 'http://www.w3.org/2000/01/rdf-schema#Literal') { $propertyData['range'] = $range->getUri(); $this->ranges[$range->getUri()] = $this->getRangeData($range); } // Existing values if ( $this->doesExist() && !is_null($value = $this->getFieldValue($property, isset($propertyData['range']) ? $propertyData['range'] : null)) ) { $propertyData['value'] = $value; } // Field position in the form $guiPropertyOrder = $property->getOnePropertyValue($this->getProperty(TaoOntology::PROPERTY_GUI_ORDER)); if (!is_null($guiPropertyOrder)) { $position = intval((string)$guiPropertyOrder); $propertyData['position'] = $position; $i = 0; while ( $i < count($this->formProperties) && (isset($this->formProperties[$i]['position']) && $position >= $this->formProperties[$i]['position']) ) { $i++; } array_splice($this->formProperties, $i, 0, array($propertyData)); } else { $this->formProperties[] = $propertyData; } } }
[ "public", "function", "initFormProperties", "(", "array", "$", "properties", ")", "{", "/** @var core_kernel_classes_Property $property */", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "property", "->", "feed", "(", ")", ";", "$", "w...
Initialize form properties. - Only if resource property has a widget property - Fetch property validator - If necessary fetch property ranges - In case of edition, retrieve property values - Sort properties with GUI order property @param array $properties
[ "Initialize", "form", "properties", ".", "-", "Only", "if", "resource", "property", "has", "a", "widget", "property", "-", "Fetch", "property", "validator", "-", "If", "necessary", "fetch", "property", "ranges", "-", "In", "case", "of", "edition", "retrieve", ...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L95-L154
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.bind
public function bind(array $parameters = []) { foreach ($this->formProperties as $key => $property) { if (isset($parameters[$property['uri']])) { $value = $parameters[$property['uri']]; } else { $value = ''; } $this->formProperties[$key]['formValue'] = $value; } return $this; }
php
public function bind(array $parameters = []) { foreach ($this->formProperties as $key => $property) { if (isset($parameters[$property['uri']])) { $value = $parameters[$property['uri']]; } else { $value = ''; } $this->formProperties[$key]['formValue'] = $value; } return $this; }
[ "public", "function", "bind", "(", "array", "$", "parameters", "=", "[", "]", ")", "{", "foreach", "(", "$", "this", "->", "formProperties", "as", "$", "key", "=>", "$", "property", ")", "{", "if", "(", "isset", "(", "$", "parameters", "[", "$", "p...
Populate the form properties with given $parameters. @param array $parameters @return $this
[ "Populate", "the", "form", "properties", "with", "given", "$parameters", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L175-L186
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.validate
public function validate() { $report = common_report_Report::createInfo(); foreach ($this->formProperties as $property) { try { $value = $property['formValue']; if (isset($property['validators'])) { foreach ($property['validators'] as $validatorName) { $validatorClass = 'tao_helpers_form_validators_' . $validatorName; if (!class_exists($validatorClass)) { throw new common_Exception('Validator is not correctly set (unknown)'); } /** @var ValidatorInterface $validator */ $validator = new $validatorClass(); if (!$validator->evaluate($value)) { throw new common_exception_ValidationFailed( $property['uri'], $validator->getMessage() ); } } } if (isset($property['range'])) { if (!isset($this->ranges[$property['range']])) { throw new common_Exception($property['label'] . ' : Range is unknown'); } $rangeValidated = false; foreach ($this->ranges[$property['range']] as $rangeData) { if (is_array($value)) { foreach ($value as $k => $v) { if ($rangeData['uri'] == $v) { unset($value[$k]); } } if (empty($value)) { $rangeValidated = true; break; } } else { if ($rangeData['uri'] == $value) { $rangeValidated = true; break; } } } if (!$rangeValidated) { throw new common_exception_ValidationFailed( $property['uri'], 'Range "' . $value . '" for field "' . $property['label'] . '" is not recognized.' ); } } } catch (common_exception_ValidationFailed $e) { $subReport = common_report_Report::createFailure($e->getMessage()); $subReport->setData($property['uri']); $report->add($subReport); } } return $report; }
php
public function validate() { $report = common_report_Report::createInfo(); foreach ($this->formProperties as $property) { try { $value = $property['formValue']; if (isset($property['validators'])) { foreach ($property['validators'] as $validatorName) { $validatorClass = 'tao_helpers_form_validators_' . $validatorName; if (!class_exists($validatorClass)) { throw new common_Exception('Validator is not correctly set (unknown)'); } /** @var ValidatorInterface $validator */ $validator = new $validatorClass(); if (!$validator->evaluate($value)) { throw new common_exception_ValidationFailed( $property['uri'], $validator->getMessage() ); } } } if (isset($property['range'])) { if (!isset($this->ranges[$property['range']])) { throw new common_Exception($property['label'] . ' : Range is unknown'); } $rangeValidated = false; foreach ($this->ranges[$property['range']] as $rangeData) { if (is_array($value)) { foreach ($value as $k => $v) { if ($rangeData['uri'] == $v) { unset($value[$k]); } } if (empty($value)) { $rangeValidated = true; break; } } else { if ($rangeData['uri'] == $value) { $rangeValidated = true; break; } } } if (!$rangeValidated) { throw new common_exception_ValidationFailed( $property['uri'], 'Range "' . $value . '" for field "' . $property['label'] . '" is not recognized.' ); } } } catch (common_exception_ValidationFailed $e) { $subReport = common_report_Report::createFailure($e->getMessage()); $subReport->setData($property['uri']); $report->add($subReport); } } return $report; }
[ "public", "function", "validate", "(", ")", "{", "$", "report", "=", "common_report_Report", "::", "createInfo", "(", ")", ";", "foreach", "(", "$", "this", "->", "formProperties", "as", "$", "property", ")", "{", "try", "{", "$", "value", "=", "$", "p...
Validate the form against the property validators. In case of range, check if value belong to associated ranges list Return failure report if one or more field is invalid @return common_report_Report @throws common_Exception In case of runtime error
[ "Validate", "the", "form", "against", "the", "property", "validators", ".", "In", "case", "of", "range", "check", "if", "value", "belong", "to", "associated", "ranges", "list", "Return", "failure", "report", "if", "one", "or", "more", "field", "is", "invalid...
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L196-L261
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.save
public function save() { $values = $this->prepareValuesToSave(); if ($this->isNew()) { if (!$resource = $this->class->createInstanceWithProperties($values)) { throw new common_Exception(__('Unable to save resource.')); } $this->resource = $resource; } else { $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($this->resource); $binder->bind($values); } return $this->resource; }
php
public function save() { $values = $this->prepareValuesToSave(); if ($this->isNew()) { if (!$resource = $this->class->createInstanceWithProperties($values)) { throw new common_Exception(__('Unable to save resource.')); } $this->resource = $resource; } else { $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($this->resource); $binder->bind($values); } return $this->resource; }
[ "public", "function", "save", "(", ")", "{", "$", "values", "=", "$", "this", "->", "prepareValuesToSave", "(", ")", ";", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "if", "(", "!", "$", "resource", "=", "$", "this", "->", "class",...
Save the form resource. If $resource is set, use GenerisFormDataBinder to update resource with form properties If only $class is set, create a new resource under it @return core_kernel_classes_Resource|null @throws common_Exception
[ "Save", "the", "form", "resource", ".", "If", "$resource", "is", "set", "use", "GenerisFormDataBinder", "to", "update", "resource", "with", "form", "properties", "If", "only", "$class", "is", "set", "create", "a", "new", "resource", "under", "it" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L271-L286
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.getPropertyValidators
protected function getPropertyValidators(core_kernel_classes_Property $property) { $validators = []; /** @var ValidatorInterface $validator */ foreach (ValidationRuleRegistry::getRegistry()->getValidators($property) as $validator) { $validators[] = $validator->getName(); } return $validators; }
php
protected function getPropertyValidators(core_kernel_classes_Property $property) { $validators = []; /** @var ValidatorInterface $validator */ foreach (ValidationRuleRegistry::getRegistry()->getValidators($property) as $validator) { $validators[] = $validator->getName(); } return $validators; }
[ "protected", "function", "getPropertyValidators", "(", "core_kernel_classes_Property", "$", "property", ")", "{", "$", "validators", "=", "[", "]", ";", "/** @var ValidatorInterface $validator */", "foreach", "(", "ValidationRuleRegistry", "::", "getRegistry", "(", ")", ...
Get property validators @param core_kernel_classes_Property $property @return array
[ "Get", "property", "validators" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L328-L336
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.getRangeData
protected function getRangeData(core_kernel_classes_Class $range) { if (is_null($range) || $range instanceof core_kernel_classes_Literal) { return []; } $options = array(); /** @var core_kernel_classes_Resource $rangeInstance */ foreach ($range->getInstances(true) as $rangeInstance) { $options[] = [ 'uri' => $rangeInstance->getUri(), 'label' => $rangeInstance->getLabel(), ]; } if (!empty($options)) { ksort($options); return $options; } return []; }
php
protected function getRangeData(core_kernel_classes_Class $range) { if (is_null($range) || $range instanceof core_kernel_classes_Literal) { return []; } $options = array(); /** @var core_kernel_classes_Resource $rangeInstance */ foreach ($range->getInstances(true) as $rangeInstance) { $options[] = [ 'uri' => $rangeInstance->getUri(), 'label' => $rangeInstance->getLabel(), ]; } if (!empty($options)) { ksort($options); return $options; } return []; }
[ "protected", "function", "getRangeData", "(", "core_kernel_classes_Class", "$", "range", ")", "{", "if", "(", "is_null", "(", "$", "range", ")", "||", "$", "range", "instanceof", "core_kernel_classes_Literal", ")", "{", "return", "[", "]", ";", "}", "$", "op...
Get the list of resource associated to the given $range @param core_kernel_classes_Class $range @return array
[ "Get", "the", "list", "of", "resource", "associated", "to", "the", "given", "$range" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L344-L366
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.getFieldValue
protected function getFieldValue(core_kernel_classes_Property $property, $range = null) { $propertyValues = []; /** @var core_kernel_classes_Resource $resource */ $values = $this->resource->getPropertyValuesCollection($property); foreach ($values->getIterator() as $value) { if (is_null($value)) { continue; } if ($value instanceof core_kernel_classes_Resource) { if (!is_null($range)) { $propertyValues[] = $value->getUri(); } else { $propertyValues[] = $value->getLabel(); } } elseif ($value instanceof core_kernel_classes_Literal) { $propertyValues[] = (string)$value; } } if (!empty($propertyValues)) { if (count($propertyValues) == 1) { return $propertyValues[0]; } else { return $propertyValues; } } return null; }
php
protected function getFieldValue(core_kernel_classes_Property $property, $range = null) { $propertyValues = []; /** @var core_kernel_classes_Resource $resource */ $values = $this->resource->getPropertyValuesCollection($property); foreach ($values->getIterator() as $value) { if (is_null($value)) { continue; } if ($value instanceof core_kernel_classes_Resource) { if (!is_null($range)) { $propertyValues[] = $value->getUri(); } else { $propertyValues[] = $value->getLabel(); } } elseif ($value instanceof core_kernel_classes_Literal) { $propertyValues[] = (string)$value; } } if (!empty($propertyValues)) { if (count($propertyValues) == 1) { return $propertyValues[0]; } else { return $propertyValues; } } return null; }
[ "protected", "function", "getFieldValue", "(", "core_kernel_classes_Property", "$", "property", ",", "$", "range", "=", "null", ")", "{", "$", "propertyValues", "=", "[", "]", ";", "/** @var core_kernel_classes_Resource $resource */", "$", "values", "=", "$", "this"...
Get the value of the given property. If $range is not null, return the value $uri @param core_kernel_classes_Property $property @param null $range @return array|mixed|null
[ "Get", "the", "value", "of", "the", "given", "property", ".", "If", "$range", "is", "not", "null", "return", "the", "value", "$uri" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L376-L409
oat-sa/tao-core
actions/form/class.RestForm.php
tao_actions_form_RestForm.prepareValuesToSave
protected function prepareValuesToSave() { $values = []; foreach ($this->formProperties as $property) { $values[$property['uri']] = $property['formValue']; } return $values; }
php
protected function prepareValuesToSave() { $values = []; foreach ($this->formProperties as $property) { $values[$property['uri']] = $property['formValue']; } return $values; }
[ "protected", "function", "prepareValuesToSave", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "formProperties", "as", "$", "property", ")", "{", "$", "values", "[", "$", "property", "[", "'uri'", "]", "]", "=", ...
Format the form properties to save them @return array
[ "Format", "the", "form", "properties", "to", "save", "them" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/actions/form/class.RestForm.php#L437-L444
oat-sa/tao-core
helpers/form/elements/xhtml/class.Calendar.php
tao_helpers_form_elements_xhtml_Calendar.render
public function render() { $returnValue = $this->renderLabel(); $uniqueId = uniqid('calendar_'); $elementId = tao_helpers_Display::TextCleaner($this->getDescription()) . '_' . $uniqueId; if (! isset($this->attributes['size'])) { $this->attributes['size'] = 20; } $returnValue .= "<div class='form-elt-container'><input class='datepicker-input' type='text' name='{$this->name}' id='$elementId' "; $returnValue .= $this->renderAttributes(); if (! empty($this->value)) { $timeStamp = is_numeric($this->getRawValue()) ? $this->getRawValue() : $this->getEvaluatedValue(); $returnValue .= ' value="' . _dh(tao_helpers_Date::displayeDate($timeStamp, tao_helpers_Date::FORMAT_DATEPICKER)) . '"'; } $returnValue .= ' /></div>'; return (string) $returnValue; }
php
public function render() { $returnValue = $this->renderLabel(); $uniqueId = uniqid('calendar_'); $elementId = tao_helpers_Display::TextCleaner($this->getDescription()) . '_' . $uniqueId; if (! isset($this->attributes['size'])) { $this->attributes['size'] = 20; } $returnValue .= "<div class='form-elt-container'><input class='datepicker-input' type='text' name='{$this->name}' id='$elementId' "; $returnValue .= $this->renderAttributes(); if (! empty($this->value)) { $timeStamp = is_numeric($this->getRawValue()) ? $this->getRawValue() : $this->getEvaluatedValue(); $returnValue .= ' value="' . _dh(tao_helpers_Date::displayeDate($timeStamp, tao_helpers_Date::FORMAT_DATEPICKER)) . '"'; } $returnValue .= ' /></div>'; return (string) $returnValue; }
[ "public", "function", "render", "(", ")", "{", "$", "returnValue", "=", "$", "this", "->", "renderLabel", "(", ")", ";", "$", "uniqueId", "=", "uniqid", "(", "'calendar_'", ")", ";", "$", "elementId", "=", "tao_helpers_Display", "::", "TextCleaner", "(", ...
Rendering of the XHTML implementation of the Calendar Widget. @author Bertrand Chevrier, <bertrand@taotesting.com> @return The XHTML stream of the Calendar Widget.
[ "Rendering", "of", "the", "XHTML", "implementation", "of", "the", "Calendar", "Widget", "." ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/helpers/form/elements/xhtml/class.Calendar.php#L39-L60
oat-sa/tao-core
models/classes/cliArgument/argument/implementation/Group.php
Group.load
public function load(Action $action) { if (! is_null($this->argument)) { $this->argument->load($action); } }
php
public function load(Action $action) { if (! is_null($this->argument)) { $this->argument->load($action); } }
[ "public", "function", "load", "(", "Action", "$", "action", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "argument", ")", ")", "{", "$", "this", "->", "argument", "->", "load", "(", "$", "action", ")", ";", "}", "}" ]
Load the action with only one applicable argument, the first matched into isApplicable() method @param Action $action
[ "Load", "the", "action", "with", "only", "one", "applicable", "argument", "the", "first", "matched", "into", "isApplicable", "()", "method" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/cliArgument/argument/implementation/Group.php#L37-L42
oat-sa/tao-core
models/classes/cliArgument/argument/implementation/Group.php
Group.isApplicable
public function isApplicable(array $params) { foreach ($this->getArguments() as $argument) { if ($argument->isApplicable($params)) { $this->argument = $argument; return true; } } return false; }
php
public function isApplicable(array $params) { foreach ($this->getArguments() as $argument) { if ($argument->isApplicable($params)) { $this->argument = $argument; return true; } } return false; }
[ "public", "function", "isApplicable", "(", "array", "$", "params", ")", "{", "foreach", "(", "$", "this", "->", "getArguments", "(", ")", "as", "$", "argument", ")", "{", "if", "(", "$", "argument", "->", "isApplicable", "(", "$", "params", ")", ")", ...
Check if provided params fit into one of option arguments Only first applicable is taken under consideration @param array $params @return bool
[ "Check", "if", "provided", "params", "fit", "into", "one", "of", "option", "arguments", "Only", "first", "applicable", "is", "taken", "under", "consideration" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/cliArgument/argument/implementation/Group.php#L51-L60
oat-sa/tao-core
models/classes/security/SignatureGenerator.php
SignatureGenerator.generate
public function generate(...$dataToSign) { $salt = $this->getOption(self::OPTION_SALT); if (empty($salt)) { throw new InconsistencyConfigException(sprintf('Option %s is not defined', self::OPTION_SALT)); } $dataToCheck = json_encode($dataToSign); return hash('sha256', $salt . $dataToCheck . $salt); }
php
public function generate(...$dataToSign) { $salt = $this->getOption(self::OPTION_SALT); if (empty($salt)) { throw new InconsistencyConfigException(sprintf('Option %s is not defined', self::OPTION_SALT)); } $dataToCheck = json_encode($dataToSign); return hash('sha256', $salt . $dataToCheck . $salt); }
[ "public", "function", "generate", "(", "...", "$", "dataToSign", ")", "{", "$", "salt", "=", "$", "this", "->", "getOption", "(", "self", "::", "OPTION_SALT", ")", ";", "if", "(", "empty", "(", "$", "salt", ")", ")", "{", "throw", "new", "Inconsisten...
@param string[] $dataToSign @return string @throws InconsistencyConfigException
[ "@param", "string", "[]", "$dataToSign" ]
train
https://github.com/oat-sa/tao-core/blob/067ef1ddc1a273a6f59be1cc6d07ada7c6033cd0/models/classes/security/SignatureGenerator.php#L21-L32
sonata-project/sonata-doctrine-extensions
src/Adapter/PHPCR/DoctrinePHPCRAdapter.php
DoctrinePHPCRAdapter.getUrlsafeIdentifier
public function getUrlsafeIdentifier($document) { $id = $this->getNormalizedIdentifier($document); if (null !== $id) { return substr($id, 1); } }
php
public function getUrlsafeIdentifier($document) { $id = $this->getNormalizedIdentifier($document); if (null !== $id) { return substr($id, 1); } }
[ "public", "function", "getUrlsafeIdentifier", "(", "$", "document", ")", "{", "$", "id", "=", "$", "this", "->", "getNormalizedIdentifier", "(", "$", "document", ")", ";", "if", "(", "null", "!==", "$", "id", ")", "{", "return", "substr", "(", "$", "id...
Currently only the leading slash is removed. TODO: do we also have to encode certain characters like spaces or does that happen automatically? {@inheritdoc}
[ "Currently", "only", "the", "leading", "slash", "is", "removed", "." ]
train
https://github.com/sonata-project/sonata-doctrine-extensions/blob/aab1ede164095afcb1f40253c5d97258b930a433/src/Adapter/PHPCR/DoctrinePHPCRAdapter.php#L67-L74
sonata-project/sonata-doctrine-extensions
src/Model/BaseManager.php
BaseManager.getObjectManager
public function getObjectManager() { $manager = $this->registry->getManagerForClass($this->class); if (!$manager) { throw new \RuntimeException(sprintf( 'Unable to find the mapping information for the class %s.' .' Please check the `auto_mapping` option' .' (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview)' .' or add the bundle to the `mappings` section in the doctrine configuration.', $this->class )); } return $manager; }
php
public function getObjectManager() { $manager = $this->registry->getManagerForClass($this->class); if (!$manager) { throw new \RuntimeException(sprintf( 'Unable to find the mapping information for the class %s.' .' Please check the `auto_mapping` option' .' (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview)' .' or add the bundle to the `mappings` section in the doctrine configuration.', $this->class )); } return $manager; }
[ "public", "function", "getObjectManager", "(", ")", "{", "$", "manager", "=", "$", "this", "->", "registry", "->", "getManagerForClass", "(", "$", "this", "->", "class", ")", ";", "if", "(", "!", "$", "manager", ")", "{", "throw", "new", "\\", "Runtime...
@throws \RuntimeException @return ObjectManager
[ "@throws", "\\", "RuntimeException" ]
train
https://github.com/sonata-project/sonata-doctrine-extensions/blob/aab1ede164095afcb1f40253c5d97258b930a433/src/Model/BaseManager.php#L50-L65
sonata-project/sonata-doctrine-extensions
src/Mapper/ORM/DoctrineORMMapper.php
DoctrineORMMapper.addDiscriminator
public function addDiscriminator(string $class, string $key, string $discriminatorClass): void { if (!isset($this->discriminators[$class])) { $this->discriminators[$class] = []; } if (!isset($this->discriminators[$class][$key])) { $this->discriminators[$class][$key] = $discriminatorClass; } }
php
public function addDiscriminator(string $class, string $key, string $discriminatorClass): void { if (!isset($this->discriminators[$class])) { $this->discriminators[$class] = []; } if (!isset($this->discriminators[$class][$key])) { $this->discriminators[$class][$key] = $discriminatorClass; } }
[ "public", "function", "addDiscriminator", "(", "string", "$", "class", ",", "string", "$", "key", ",", "string", "$", "discriminatorClass", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "discriminators", "[", "$", "class", "]", ...
Add a discriminator to a class. @param string $key Key is the database value and values are the classes @param string $discriminatorClass The mapped class
[ "Add", "a", "discriminator", "to", "a", "class", "." ]
train
https://github.com/sonata-project/sonata-doctrine-extensions/blob/aab1ede164095afcb1f40253c5d97258b930a433/src/Mapper/ORM/DoctrineORMMapper.php#L84-L93
spatie/phpunit-snapshot-assertions
src/Filesystem.php
Filesystem.getNamesWithDifferentExtension
public function getNamesWithDifferentExtension(string $fileName) { if (! file_exists($this->basePath)) { return []; } $extension = pathinfo($fileName, PATHINFO_EXTENSION); $baseName = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1); $allNames = scandir($this->basePath); $namesWithDifferentExtension = array_filter($allNames, function ($existingName) use ($baseName, $extension) { $existingExtension = pathinfo($existingName, PATHINFO_EXTENSION); $existingBaseName = substr($existingName, 0, strlen($existingName) - strlen($existingExtension) - 1); return $existingBaseName === $baseName && $existingExtension !== $extension; }); return array_values($namesWithDifferentExtension); }
php
public function getNamesWithDifferentExtension(string $fileName) { if (! file_exists($this->basePath)) { return []; } $extension = pathinfo($fileName, PATHINFO_EXTENSION); $baseName = substr($fileName, 0, strlen($fileName) - strlen($extension) - 1); $allNames = scandir($this->basePath); $namesWithDifferentExtension = array_filter($allNames, function ($existingName) use ($baseName, $extension) { $existingExtension = pathinfo($existingName, PATHINFO_EXTENSION); $existingBaseName = substr($existingName, 0, strlen($existingName) - strlen($existingExtension) - 1); return $existingBaseName === $baseName && $existingExtension !== $extension; }); return array_values($namesWithDifferentExtension); }
[ "public", "function", "getNamesWithDifferentExtension", "(", "string", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "basePath", ")", ")", "{", "return", "[", "]", ";", "}", "$", "extension", "=", "pathinfo", "(", "$",...
Get all file names in this directory that have the same name as $fileName, but have a different file extension. @param string $fileName @return array
[ "Get", "all", "file", "names", "in", "this", "directory", "that", "have", "the", "same", "name", "as", "$fileName", "but", "have", "a", "different", "file", "extension", "." ]
train
https://github.com/spatie/phpunit-snapshot-assertions/blob/4fcadbedfff1427c44d4b237ea05e2e4a3cb935a/src/Filesystem.php#L38-L59
PHP-DI/Invoker
src/Invoker.php
Invoker.call
public function call($callable, array $parameters = array()) { if ($this->callableResolver) { $callable = $this->callableResolver->resolve($callable); } if (! is_callable($callable)) { throw new NotCallableException(sprintf( '%s is not a callable', is_object($callable) ? 'Instance of ' . get_class($callable) : var_export($callable, true) )); } $callableReflection = CallableReflection::create($callable); $args = $this->parameterResolver->getParameters($callableReflection, $parameters, array()); // Sort by array key because call_user_func_array ignores numeric keys ksort($args); // Check all parameters are resolved $diff = array_diff_key($callableReflection->getParameters(), $args); if (! empty($diff)) { /** @var \ReflectionParameter $parameter */ $parameter = reset($diff); throw new NotEnoughParametersException(sprintf( 'Unable to invoke the callable because no value was given for parameter %d ($%s)', $parameter->getPosition() + 1, $parameter->name )); } return call_user_func_array($callable, $args); }
php
public function call($callable, array $parameters = array()) { if ($this->callableResolver) { $callable = $this->callableResolver->resolve($callable); } if (! is_callable($callable)) { throw new NotCallableException(sprintf( '%s is not a callable', is_object($callable) ? 'Instance of ' . get_class($callable) : var_export($callable, true) )); } $callableReflection = CallableReflection::create($callable); $args = $this->parameterResolver->getParameters($callableReflection, $parameters, array()); // Sort by array key because call_user_func_array ignores numeric keys ksort($args); // Check all parameters are resolved $diff = array_diff_key($callableReflection->getParameters(), $args); if (! empty($diff)) { /** @var \ReflectionParameter $parameter */ $parameter = reset($diff); throw new NotEnoughParametersException(sprintf( 'Unable to invoke the callable because no value was given for parameter %d ($%s)', $parameter->getPosition() + 1, $parameter->name )); } return call_user_func_array($callable, $args); }
[ "public", "function", "call", "(", "$", "callable", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "callableResolver", ")", "{", "$", "callable", "=", "$", "this", "->", "callableResolver", "->", "resol...
{@inheritdoc}
[ "{" ]
train
https://github.com/PHP-DI/Invoker/blob/a812493e87bb4ed413584e4a98208f54c43475ec/src/Invoker.php#L50-L83
PHP-DI/Invoker
src/CallableResolver.php
CallableResolver.resolve
public function resolve($callable) { if (is_string($callable) && strpos($callable, '::') !== false) { $callable = explode('::', $callable, 2); } $callable = $this->resolveFromContainer($callable); if (! is_callable($callable)) { throw NotCallableException::fromInvalidCallable($callable, true); } return $callable; }
php
public function resolve($callable) { if (is_string($callable) && strpos($callable, '::') !== false) { $callable = explode('::', $callable, 2); } $callable = $this->resolveFromContainer($callable); if (! is_callable($callable)) { throw NotCallableException::fromInvalidCallable($callable, true); } return $callable; }
[ "public", "function", "resolve", "(", "$", "callable", ")", "{", "if", "(", "is_string", "(", "$", "callable", ")", "&&", "strpos", "(", "$", "callable", ",", "'::'", ")", "!==", "false", ")", "{", "$", "callable", "=", "explode", "(", "'::'", ",", ...
Resolve the given callable into a real PHP callable. @param callable|string|array $callable @return callable Real PHP callable. @throws NotCallableException
[ "Resolve", "the", "given", "callable", "into", "a", "real", "PHP", "callable", "." ]
train
https://github.com/PHP-DI/Invoker/blob/a812493e87bb4ed413584e4a98208f54c43475ec/src/CallableResolver.php#L35-L48
PHP-DI/Invoker
src/Reflection/CallableReflection.php
CallableReflection.create
public static function create($callable) { // Closure if ($callable instanceof \Closure) { return new \ReflectionFunction($callable); } // Array callable if (is_array($callable)) { list($class, $method) = $callable; if (! method_exists($class, $method)) { throw NotCallableException::fromInvalidCallable($callable); } return new \ReflectionMethod($class, $method); } // Callable object (i.e. implementing __invoke()) if (is_object($callable) && method_exists($callable, '__invoke')) { return new \ReflectionMethod($callable, '__invoke'); } // Callable class (i.e. implementing __invoke()) if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) { return new \ReflectionMethod($callable, '__invoke'); } // Standard function if (is_string($callable) && function_exists($callable)) { return new \ReflectionFunction($callable); } throw new NotCallableException(sprintf( '%s is not a callable', is_string($callable) ? $callable : 'Instance of ' . get_class($callable) )); }
php
public static function create($callable) { // Closure if ($callable instanceof \Closure) { return new \ReflectionFunction($callable); } // Array callable if (is_array($callable)) { list($class, $method) = $callable; if (! method_exists($class, $method)) { throw NotCallableException::fromInvalidCallable($callable); } return new \ReflectionMethod($class, $method); } // Callable object (i.e. implementing __invoke()) if (is_object($callable) && method_exists($callable, '__invoke')) { return new \ReflectionMethod($callable, '__invoke'); } // Callable class (i.e. implementing __invoke()) if (is_string($callable) && class_exists($callable) && method_exists($callable, '__invoke')) { return new \ReflectionMethod($callable, '__invoke'); } // Standard function if (is_string($callable) && function_exists($callable)) { return new \ReflectionFunction($callable); } throw new NotCallableException(sprintf( '%s is not a callable', is_string($callable) ? $callable : 'Instance of ' . get_class($callable) )); }
[ "public", "static", "function", "create", "(", "$", "callable", ")", "{", "// Closure", "if", "(", "$", "callable", "instanceof", "\\", "Closure", ")", "{", "return", "new", "\\", "ReflectionFunction", "(", "$", "callable", ")", ";", "}", "// Array callable"...
@param callable $callable @return \ReflectionFunctionAbstract @throws NotCallableException TODO Use the `callable` type-hint once support for PHP 5.4 and up.
[ "@param", "callable", "$callable" ]
train
https://github.com/PHP-DI/Invoker/blob/a812493e87bb4ed413584e4a98208f54c43475ec/src/Reflection/CallableReflection.php#L23-L60
prooph/service-bus
src/Plugin/Router/RegexRouter.php
RegexRouter.to
public function to($handler): RegexRouter { if (! \is_string($handler) && ! \is_object($handler) && ! \is_callable($handler)) { throw new Exception\InvalidArgumentException(\sprintf( 'Invalid handler provided. Expected type is string, object or callable but type of %s given.', \gettype($handler) )); } if (null === $this->tmpPattern) { throw new Exception\RuntimeException(\sprintf( 'Cannot map handler %s to a pattern. Please use method route before calling method to', \is_object($handler) ? \get_class($handler) : (\is_string($handler) ? $handler : \gettype($handler)) )); } $this->patternMap[] = [$this->tmpPattern => $handler]; $this->tmpPattern = null; return $this; }
php
public function to($handler): RegexRouter { if (! \is_string($handler) && ! \is_object($handler) && ! \is_callable($handler)) { throw new Exception\InvalidArgumentException(\sprintf( 'Invalid handler provided. Expected type is string, object or callable but type of %s given.', \gettype($handler) )); } if (null === $this->tmpPattern) { throw new Exception\RuntimeException(\sprintf( 'Cannot map handler %s to a pattern. Please use method route before calling method to', \is_object($handler) ? \get_class($handler) : (\is_string($handler) ? $handler : \gettype($handler)) )); } $this->patternMap[] = [$this->tmpPattern => $handler]; $this->tmpPattern = null; return $this; }
[ "public", "function", "to", "(", "$", "handler", ")", ":", "RegexRouter", "{", "if", "(", "!", "\\", "is_string", "(", "$", "handler", ")", "&&", "!", "\\", "is_object", "(", "$", "handler", ")", "&&", "!", "\\", "is_callable", "(", "$", "handler", ...
@param string|object|callable $handler @throws Exception\RuntimeException @throws Exception\InvalidArgumentException
[ "@param", "string|object|callable", "$handler" ]
train
https://github.com/prooph/service-bus/blob/8253c291fe41354be3faea15173e2f2bce1d69b9/src/Plugin/Router/RegexRouter.php#L87-L110
prooph/service-bus
src/CommandBus.php
CommandBus.dispatch
public function dispatch($command): void { $this->commandQueue[] = $command; if (! $this->isDispatching) { $this->isDispatching = true; $actionEventEmitter = $this->events; try { while ($command = \array_shift($this->commandQueue)) { $actionEvent = $actionEventEmitter->getNewActionEvent( self::EVENT_DISPATCH, $this, [ self::EVENT_PARAM_MESSAGE => $command, ] ); try { $actionEventEmitter->dispatch($actionEvent); if (! $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLED)) { throw new RuntimeException(\sprintf('Command %s was not handled', $this->getMessageName($command))); } } catch (\Throwable $exception) { $actionEvent->setParam(self::EVENT_PARAM_EXCEPTION, $exception); } finally { $actionEvent->stopPropagation(false); $this->triggerFinalize($actionEvent); } } $this->isDispatching = false; } catch (\Throwable $e) { $this->isDispatching = false; throw CommandDispatchException::wrap($e, $this->commandQueue); } } }
php
public function dispatch($command): void { $this->commandQueue[] = $command; if (! $this->isDispatching) { $this->isDispatching = true; $actionEventEmitter = $this->events; try { while ($command = \array_shift($this->commandQueue)) { $actionEvent = $actionEventEmitter->getNewActionEvent( self::EVENT_DISPATCH, $this, [ self::EVENT_PARAM_MESSAGE => $command, ] ); try { $actionEventEmitter->dispatch($actionEvent); if (! $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLED)) { throw new RuntimeException(\sprintf('Command %s was not handled', $this->getMessageName($command))); } } catch (\Throwable $exception) { $actionEvent->setParam(self::EVENT_PARAM_EXCEPTION, $exception); } finally { $actionEvent->stopPropagation(false); $this->triggerFinalize($actionEvent); } } $this->isDispatching = false; } catch (\Throwable $e) { $this->isDispatching = false; throw CommandDispatchException::wrap($e, $this->commandQueue); } } }
[ "public", "function", "dispatch", "(", "$", "command", ")", ":", "void", "{", "$", "this", "->", "commandQueue", "[", "]", "=", "$", "command", ";", "if", "(", "!", "$", "this", "->", "isDispatching", ")", "{", "$", "this", "->", "isDispatching", "="...
@param mixed $command @throws CommandDispatchException
[ "@param", "mixed", "$command" ]
train
https://github.com/prooph/service-bus/blob/8253c291fe41354be3faea15173e2f2bce1d69b9/src/CommandBus.php#L74-L112
prooph/service-bus
src/Plugin/Router/SingleHandlerRouter.php
SingleHandlerRouter.to
public function to($messageHandler): SingleHandlerRouter { if (! \is_string($messageHandler) && ! \is_object($messageHandler) && ! \is_callable($messageHandler)) { throw new Exception\InvalidArgumentException(\sprintf( 'Invalid message handler provided. Expected type is string, object or callable but type of %s given.', \gettype($messageHandler) )); } if (null === $this->tmpMessageName) { throw new Exception\RuntimeException(\sprintf( 'Cannot map handler %s to a message. Please use method route before calling method to', \is_object($messageHandler) ? \get_class($messageHandler) : (\is_string($messageHandler) ? $messageHandler : \gettype($messageHandler)) )); } $this->messageMap[$this->tmpMessageName] = $messageHandler; $this->tmpMessageName = null; return $this; }
php
public function to($messageHandler): SingleHandlerRouter { if (! \is_string($messageHandler) && ! \is_object($messageHandler) && ! \is_callable($messageHandler)) { throw new Exception\InvalidArgumentException(\sprintf( 'Invalid message handler provided. Expected type is string, object or callable but type of %s given.', \gettype($messageHandler) )); } if (null === $this->tmpMessageName) { throw new Exception\RuntimeException(\sprintf( 'Cannot map handler %s to a message. Please use method route before calling method to', \is_object($messageHandler) ? \get_class($messageHandler) : (\is_string($messageHandler) ? $messageHandler : \gettype($messageHandler)) )); } $this->messageMap[$this->tmpMessageName] = $messageHandler; $this->tmpMessageName = null; return $this; }
[ "public", "function", "to", "(", "$", "messageHandler", ")", ":", "SingleHandlerRouter", "{", "if", "(", "!", "\\", "is_string", "(", "$", "messageHandler", ")", "&&", "!", "\\", "is_object", "(", "$", "messageHandler", ")", "&&", "!", "\\", "is_callable",...
@param string|object|callable $messageHandler @return SingleHandlerRouter @throws Exception\RuntimeException @throws Exception\InvalidArgumentException
[ "@param", "string|object|callable", "$messageHandler" ]
train
https://github.com/prooph/service-bus/blob/8253c291fe41354be3faea15173e2f2bce1d69b9/src/Plugin/Router/SingleHandlerRouter.php#L78-L101
prooph/service-bus
src/QueryBus.php
QueryBus.dispatch
public function dispatch($query): PromiseInterface { $deferred = new Deferred(); $actionEventEmitter = $this->events; $actionEvent = $actionEventEmitter->getNewActionEvent( self::EVENT_DISPATCH, $this, [ self::EVENT_PARAM_MESSAGE => $query, self::EVENT_PARAM_DEFERRED => $deferred, self::EVENT_PARAM_PROMISE => $deferred->promise(), ] ); try { $actionEventEmitter->dispatch($actionEvent); if (! $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLED)) { throw new RuntimeException(\sprintf('Query %s was not handled', $this->getMessageName($query))); } } catch (\Throwable $exception) { $actionEvent->setParam(self::EVENT_PARAM_EXCEPTION, $exception); } finally { $actionEvent->stopPropagation(false); $this->triggerFinalize($actionEvent); } return $actionEvent->getParam(self::EVENT_PARAM_PROMISE); }
php
public function dispatch($query): PromiseInterface { $deferred = new Deferred(); $actionEventEmitter = $this->events; $actionEvent = $actionEventEmitter->getNewActionEvent( self::EVENT_DISPATCH, $this, [ self::EVENT_PARAM_MESSAGE => $query, self::EVENT_PARAM_DEFERRED => $deferred, self::EVENT_PARAM_PROMISE => $deferred->promise(), ] ); try { $actionEventEmitter->dispatch($actionEvent); if (! $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLED)) { throw new RuntimeException(\sprintf('Query %s was not handled', $this->getMessageName($query))); } } catch (\Throwable $exception) { $actionEvent->setParam(self::EVENT_PARAM_EXCEPTION, $exception); } finally { $actionEvent->stopPropagation(false); $this->triggerFinalize($actionEvent); } return $actionEvent->getParam(self::EVENT_PARAM_PROMISE); }
[ "public", "function", "dispatch", "(", "$", "query", ")", ":", "PromiseInterface", "{", "$", "deferred", "=", "new", "Deferred", "(", ")", ";", "$", "actionEventEmitter", "=", "$", "this", "->", "events", ";", "$", "actionEvent", "=", "$", "actionEventEmit...
@param mixed $query @throws RuntimeException
[ "@param", "mixed", "$query" ]
train
https://github.com/prooph/service-bus/blob/8253c291fe41354be3faea15173e2f2bce1d69b9/src/QueryBus.php#L84-L114
prooph/service-bus
src/Plugin/Router/EventRouter.php
EventRouter.to
public function to($eventListener): EventRouter { if (! \is_string($eventListener) && ! \is_object($eventListener) && ! \is_callable($eventListener)) { throw new Exception\InvalidArgumentException(\sprintf( 'Invalid event listener provided. Expected type is string, object or callable but type of %s given.', \gettype($eventListener) )); } if (null === $this->tmpEventName) { throw new Exception\RuntimeException(\sprintf( 'Cannot map listener %s to an event. Please use method route before calling method to', \is_object($eventListener) ? \get_class($eventListener) : (\is_string($eventListener) ? $eventListener : \gettype($eventListener)) )); } $this->eventMap[$this->tmpEventName][] = $eventListener; return $this; }
php
public function to($eventListener): EventRouter { if (! \is_string($eventListener) && ! \is_object($eventListener) && ! \is_callable($eventListener)) { throw new Exception\InvalidArgumentException(\sprintf( 'Invalid event listener provided. Expected type is string, object or callable but type of %s given.', \gettype($eventListener) )); } if (null === $this->tmpEventName) { throw new Exception\RuntimeException(\sprintf( 'Cannot map listener %s to an event. Please use method route before calling method to', \is_object($eventListener) ? \get_class($eventListener) : (\is_string($eventListener) ? $eventListener : \gettype($eventListener)) )); } $this->eventMap[$this->tmpEventName][] = $eventListener; return $this; }
[ "public", "function", "to", "(", "$", "eventListener", ")", ":", "EventRouter", "{", "if", "(", "!", "\\", "is_string", "(", "$", "eventListener", ")", "&&", "!", "\\", "is_object", "(", "$", "eventListener", ")", "&&", "!", "\\", "is_callable", "(", "...
@param string|object|callable $eventListener @return EventRouter @throws Exception\RuntimeException @throws Exception\InvalidArgumentException
[ "@param", "string|object|callable", "$eventListener" ]
train
https://github.com/prooph/service-bus/blob/8253c291fe41354be3faea15173e2f2bce1d69b9/src/Plugin/Router/EventRouter.php#L91-L112
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/PersistenceManagerFactory.php
PersistenceManagerFactory.visit
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the stackable for the entity manager names $entityManagerNames = new StackableStorage(); // initialize the default settings for the persistence units $persistenceManagerSettings = new PersistenceManagerSettings(); $persistenceManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray()); // initialize the persistence manager instance $persistenceManager = new PersistenceManager(); $persistenceManager->injectApplication($application); $persistenceManager->injectEntityManagerNames($entityManagerNames); $persistenceManager->injectManagerSettings($persistenceManagerSettings); // create the naming context and add it the manager $contextFactory = $managerConfiguration->getContextFactory(); $contextFactory::visit($persistenceManager); // attach the instance $application->addManager($persistenceManager, $managerConfiguration); }
php
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the stackable for the entity manager names $entityManagerNames = new StackableStorage(); // initialize the default settings for the persistence units $persistenceManagerSettings = new PersistenceManagerSettings(); $persistenceManagerSettings->mergeWithParams($managerConfiguration->getParamsAsArray()); // initialize the persistence manager instance $persistenceManager = new PersistenceManager(); $persistenceManager->injectApplication($application); $persistenceManager->injectEntityManagerNames($entityManagerNames); $persistenceManager->injectManagerSettings($persistenceManagerSettings); // create the naming context and add it the manager $contextFactory = $managerConfiguration->getContextFactory(); $contextFactory::visit($persistenceManager); // attach the instance $application->addManager($persistenceManager, $managerConfiguration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ManagerNodeInterface", "$", "managerConfiguration", ")", "{", "// initialize the stackable for the entity manager names", "$", "entityManagerNames", "=", "new", "StackableStorage", ...
The main method that creates new instances in a separate context. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration @return void
[ "The", "main", "method", "that", "creates", "new", "instances", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/PersistenceManagerFactory.php#L50-L72
appserver-io/appserver
src/AppserverIo/Appserver/Core/Commands/CommandFactory.php
CommandFactory.factory
public static function factory($name, array $constructorArgs = array()) { $reflectionClass = new \ReflectionClass(sprintf('AppserverIo\Appserver\Core\Commands\%sCommand', ucfirst($name))); return $reflectionClass->newInstanceArgs($constructorArgs); }
php
public static function factory($name, array $constructorArgs = array()) { $reflectionClass = new \ReflectionClass(sprintf('AppserverIo\Appserver\Core\Commands\%sCommand', ucfirst($name))); return $reflectionClass->newInstanceArgs($constructorArgs); }
[ "public", "static", "function", "factory", "(", "$", "name", ",", "array", "$", "constructorArgs", "=", "array", "(", ")", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "sprintf", "(", "'AppserverIo\\Appserver\\Core\\Commands\\%sComma...
Creates and returns a new command instance of the command with the passed name. @param string $name ass name of the command to create the instance for @param array $constructorArgs The arguments passed to the constructor @return \AppserverIo\Appserver\Core\Commands\CommandInterface The command instance
[ "Creates", "and", "returns", "a", "new", "command", "instance", "of", "the", "command", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Commands/CommandFactory.php#L43-L47
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/SystemPropertiesNodeTrait.php
SystemPropertiesNodeTrait.setSystemProperty
public function setSystemProperty($name, $type, $value) { // initialize the system property to set $sytemPropertyToSet = new SystemPropertyNode($name, $type, new NodeValue($value)); // query whether a system property with this name has already been set foreach ($this->systemProperties as $key => $systemProperty) { if ($systemProperty->getName() === $systemProperty->getName()) { // override the system property $this->systemProperties[$key] = $sytemPropertyToSet; return; } } // append the system property $this->systemProperties[] = $sytemPropertyToSet; }
php
public function setSystemProperty($name, $type, $value) { // initialize the system property to set $sytemPropertyToSet = new SystemPropertyNode($name, $type, new NodeValue($value)); // query whether a system property with this name has already been set foreach ($this->systemProperties as $key => $systemProperty) { if ($systemProperty->getName() === $systemProperty->getName()) { // override the system property $this->systemProperties[$key] = $sytemPropertyToSet; return; } } // append the system property $this->systemProperties[] = $sytemPropertyToSet; }
[ "public", "function", "setSystemProperty", "(", "$", "name", ",", "$", "type", ",", "$", "value", ")", "{", "// initialize the system property to set", "$", "sytemPropertyToSet", "=", "new", "SystemPropertyNode", "(", "$", "name", ",", "$", "type", ",", "new", ...
Sets the system property with the passed name, type and value. @param string $name The system property name @param string $type The system property type @param mixed $value The system property value @return void
[ "Sets", "the", "system", "property", "with", "the", "passed", "name", "type", "and", "value", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/SystemPropertiesNodeTrait.php#L78-L95
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/SystemPropertiesNodeTrait.php
SystemPropertiesNodeTrait.getSystemProperty
public function getSystemProperty($name) { $systemProperties = $this->getSystemPropertiesAsArray(); if (array_key_exists($name, $systemProperties)) { return $systemProperties[$name]; } }
php
public function getSystemProperty($name) { $systemProperties = $this->getSystemPropertiesAsArray(); if (array_key_exists($name, $systemProperties)) { return $systemProperties[$name]; } }
[ "public", "function", "getSystemProperty", "(", "$", "name", ")", "{", "$", "systemProperties", "=", "$", "this", "->", "getSystemPropertiesAsArray", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "systemProperties", ")", ")", "{",...
Returns the system property with the passed name casted to the specified type. @param string $name The name of the system property to be returned @return mixed The requested system property casted to the specified type
[ "Returns", "the", "system", "property", "with", "the", "passed", "name", "casted", "to", "the", "specified", "type", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/SystemPropertiesNodeTrait.php#L105-L111
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/SystemPropertiesNodeTrait.php
SystemPropertiesNodeTrait.getSystemPropertiesAsArray
public function getSystemPropertiesAsArray() { $systemProperties = array(); if (is_array($this->getSystemProperties())) { foreach ($this->getSystemProperties() as $systemProperty) { $systemProperties[$systemProperty->getName()] = $systemProperty->castToType(); } } return $systemProperties; }
php
public function getSystemPropertiesAsArray() { $systemProperties = array(); if (is_array($this->getSystemProperties())) { foreach ($this->getSystemProperties() as $systemProperty) { $systemProperties[$systemProperty->getName()] = $systemProperty->castToType(); } } return $systemProperties; }
[ "public", "function", "getSystemPropertiesAsArray", "(", ")", "{", "$", "systemProperties", "=", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "getSystemProperties", "(", ")", ")", ")", "{", "foreach", "(", "$", "this", "->", "ge...
Returns the system properties casted to the defined type as associative array. @return array The array with the casted system properties
[ "Returns", "the", "system", "properties", "casted", "to", "the", "defined", "type", "as", "associative", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/SystemPropertiesNodeTrait.php#L119-L128
appserver-io/appserver
src/AppserverIo/Appserver/Provisioning/Steps/AbstractDatabaseStep.php
AbstractDatabaseStep.getEntityManager
public function getEntityManager() { // check if we have a valid datasource node if ($this->getDatasourceNode() == null) { return; } // prepare the path to the entities $absolutePaths = array(); if ($relativePaths = $this->getStepNode()->getParam(AbstractDatabaseStep::PARAM_PATH_TO_ENTITIES)) { foreach (explode(PATH_SEPARATOR, $relativePaths) as $relativePath) { $absolutePaths[] = $this->getWebappPath() . DIRECTORY_SEPARATOR . $relativePath; } } // load the database connection parameters $connectionParameters = $this->getConnectionParameters(); // initialize and load the entity manager and the schema tool $metadataConfiguration = Setup::createAnnotationMetadataConfiguration($absolutePaths, true, null, null, false); return EntityManager::create($connectionParameters, $metadataConfiguration); }
php
public function getEntityManager() { // check if we have a valid datasource node if ($this->getDatasourceNode() == null) { return; } // prepare the path to the entities $absolutePaths = array(); if ($relativePaths = $this->getStepNode()->getParam(AbstractDatabaseStep::PARAM_PATH_TO_ENTITIES)) { foreach (explode(PATH_SEPARATOR, $relativePaths) as $relativePath) { $absolutePaths[] = $this->getWebappPath() . DIRECTORY_SEPARATOR . $relativePath; } } // load the database connection parameters $connectionParameters = $this->getConnectionParameters(); // initialize and load the entity manager and the schema tool $metadataConfiguration = Setup::createAnnotationMetadataConfiguration($absolutePaths, true, null, null, false); return EntityManager::create($connectionParameters, $metadataConfiguration); }
[ "public", "function", "getEntityManager", "(", ")", "{", "// check if we have a valid datasource node", "if", "(", "$", "this", "->", "getDatasourceNode", "(", ")", "==", "null", ")", "{", "return", ";", "}", "// prepare the path to the entities", "$", "absolutePaths"...
Initializes and returns the Doctrine EntityManager instance. @return \Doctrine\ORM\EntityManager The Doctrine EntityManager instancer
[ "Initializes", "and", "returns", "the", "Doctrine", "EntityManager", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Provisioning/Steps/AbstractDatabaseStep.php#L104-L126
appserver-io/appserver
src/AppserverIo/Appserver/Provisioning/Steps/AbstractDatabaseStep.php
AbstractDatabaseStep.getConnectionParameters
public function getConnectionParameters() { // load the datasource node $datasourceNode = $this->getDatasourceNode(); // initialize the database node $databaseNode = $datasourceNode->getDatabase(); // initialize the connection parameters $connectionParameters = array( AbstractDatabaseStep::CONNECTION_PARAM_DRIVER => $databaseNode->getDriver()->getNodeValue()->__toString(), AbstractDatabaseStep::CONNECTION_PARAM_USER => $databaseNode->getUser()->getNodeValue()->__toString(), AbstractDatabaseStep::CONNECTION_PARAM_PASSWORD => $databaseNode->getPassword()->getNodeValue()->__toString() ); // initialize the path to the database when we use sqlite for example if ($databaseNode->getPath()) { if ($path = $databaseNode->getPath()->getNodeValue()->__toString()) { $connectionParameters[AbstractDatabaseStep::CONNECTION_PARAM_PATH] = $this->getWebappPath() . DIRECTORY_SEPARATOR . $path; } } // add database name if using another PDO driver than sqlite if ($databaseNode->getDatabaseName()) { $databaseName = $databaseNode->getDatabaseName()->getNodeValue()->__toString(); $connectionParameters[AbstractDatabaseStep::CONNECTION_PARAM_DATABASENAME] = $databaseName; } // add database host if using another PDO driver than sqlite if ($databaseNode->getDatabaseHost()) { $databaseHost = $databaseNode->getDatabaseHost()->getNodeValue()->__toString(); $connectionParameters[AbstractDatabaseStep::CONNECTION_PARAM_HOST] = $databaseHost; } // set the connection parameters return $connectionParameters; }
php
public function getConnectionParameters() { // load the datasource node $datasourceNode = $this->getDatasourceNode(); // initialize the database node $databaseNode = $datasourceNode->getDatabase(); // initialize the connection parameters $connectionParameters = array( AbstractDatabaseStep::CONNECTION_PARAM_DRIVER => $databaseNode->getDriver()->getNodeValue()->__toString(), AbstractDatabaseStep::CONNECTION_PARAM_USER => $databaseNode->getUser()->getNodeValue()->__toString(), AbstractDatabaseStep::CONNECTION_PARAM_PASSWORD => $databaseNode->getPassword()->getNodeValue()->__toString() ); // initialize the path to the database when we use sqlite for example if ($databaseNode->getPath()) { if ($path = $databaseNode->getPath()->getNodeValue()->__toString()) { $connectionParameters[AbstractDatabaseStep::CONNECTION_PARAM_PATH] = $this->getWebappPath() . DIRECTORY_SEPARATOR . $path; } } // add database name if using another PDO driver than sqlite if ($databaseNode->getDatabaseName()) { $databaseName = $databaseNode->getDatabaseName()->getNodeValue()->__toString(); $connectionParameters[AbstractDatabaseStep::CONNECTION_PARAM_DATABASENAME] = $databaseName; } // add database host if using another PDO driver than sqlite if ($databaseNode->getDatabaseHost()) { $databaseHost = $databaseNode->getDatabaseHost()->getNodeValue()->__toString(); $connectionParameters[AbstractDatabaseStep::CONNECTION_PARAM_HOST] = $databaseHost; } // set the connection parameters return $connectionParameters; }
[ "public", "function", "getConnectionParameters", "(", ")", "{", "// load the datasource node", "$", "datasourceNode", "=", "$", "this", "->", "getDatasourceNode", "(", ")", ";", "// initialize the database node", "$", "databaseNode", "=", "$", "datasourceNode", "->", ...
Initializes an returns an array with the database connection parameters necessary to connect to the database using Doctrine. @return array An array with the connection parameters
[ "Initializes", "an", "returns", "an", "array", "with", "the", "database", "connection", "parameters", "necessary", "to", "connect", "to", "the", "database", "using", "Doctrine", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Provisioning/Steps/AbstractDatabaseStep.php#L134-L171
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/StandardSessionManagerFactory.php
StandardSessionManagerFactory.visit
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the sessions and the session settings $sessionHandlers = new HashMap(); $sessionSettings = new DefaultSessionSettings(); $sessionMarshaller = new StandardSessionMarshaller(); // add the configured session handlers /** @var \AppserverIo\Appserver\Core\Api\Node\SessionHandlerNode $sessionHandlerNode */ foreach ($managerConfiguration->getSessionHandlers() as $sessionHandlerNode) { if ($factory = $sessionHandlerNode->getFactory()) { $sessionHandlers->add( $sessionHandlerNode->getName(), $factory::create($sessionHandlerNode, $sessionSettings, $sessionMarshaller) ); } } // we need a garbage collector $garbageCollector = new StandardGarbageCollector(); $garbageCollector->injectApplication($application); $garbageCollector->injectSessionSettings($sessionSettings); $garbageCollector->start(); // and finally we need the session manager instance $sessionManager = new StandardSessionManager(); $sessionManager->injectApplication($application); $sessionManager->injectSessionSettings($sessionSettings); $sessionManager->injectSessionHandlers($sessionHandlers); $sessionManager->injectGarbageCollector($garbageCollector); $sessionManager->injectSessionMarshaller($sessionMarshaller); $sessionManager->injectManagerConfiguration($managerConfiguration); // attach the instance $application->addManager($sessionManager, $managerConfiguration); }
php
public static function visit(ApplicationInterface $application, ManagerNodeInterface $managerConfiguration) { // initialize the sessions and the session settings $sessionHandlers = new HashMap(); $sessionSettings = new DefaultSessionSettings(); $sessionMarshaller = new StandardSessionMarshaller(); // add the configured session handlers /** @var \AppserverIo\Appserver\Core\Api\Node\SessionHandlerNode $sessionHandlerNode */ foreach ($managerConfiguration->getSessionHandlers() as $sessionHandlerNode) { if ($factory = $sessionHandlerNode->getFactory()) { $sessionHandlers->add( $sessionHandlerNode->getName(), $factory::create($sessionHandlerNode, $sessionSettings, $sessionMarshaller) ); } } // we need a garbage collector $garbageCollector = new StandardGarbageCollector(); $garbageCollector->injectApplication($application); $garbageCollector->injectSessionSettings($sessionSettings); $garbageCollector->start(); // and finally we need the session manager instance $sessionManager = new StandardSessionManager(); $sessionManager->injectApplication($application); $sessionManager->injectSessionSettings($sessionSettings); $sessionManager->injectSessionHandlers($sessionHandlers); $sessionManager->injectGarbageCollector($garbageCollector); $sessionManager->injectSessionMarshaller($sessionMarshaller); $sessionManager->injectManagerConfiguration($managerConfiguration); // attach the instance $application->addManager($sessionManager, $managerConfiguration); }
[ "public", "static", "function", "visit", "(", "ApplicationInterface", "$", "application", ",", "ManagerNodeInterface", "$", "managerConfiguration", ")", "{", "// initialize the sessions and the session settings", "$", "sessionHandlers", "=", "new", "HashMap", "(", ")", ";...
The main method that creates new instances in a separate context. @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance to register the class loader with @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerConfiguration The manager configuration @return void
[ "The", "main", "method", "that", "creates", "new", "instances", "in", "a", "separate", "context", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/StandardSessionManagerFactory.php#L48-L84
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/CalendarBasedTimeout.php
CalendarBasedTimeout.factoryFromScheduleExpression
public static function factoryFromScheduleExpression(ScheduleExpression $scheduleExpression) { // prepare the CRON expression $cronExpression = sprintf( '%s %s %s %s %s %s %s', $scheduleExpression->getSecond(), $scheduleExpression->getMinute(), $scheduleExpression->getHour(), $scheduleExpression->getDayOfMonth(), $scheduleExpression->getMonth(), $scheduleExpression->getDayOfWeek(), $scheduleExpression->getYear() ); // return the point in time at which the next timer expiration is scheduled to occur return new CalendarBasedTimeout($cronExpression, $scheduleExpression, new FieldFactory()); }
php
public static function factoryFromScheduleExpression(ScheduleExpression $scheduleExpression) { // prepare the CRON expression $cronExpression = sprintf( '%s %s %s %s %s %s %s', $scheduleExpression->getSecond(), $scheduleExpression->getMinute(), $scheduleExpression->getHour(), $scheduleExpression->getDayOfMonth(), $scheduleExpression->getMonth(), $scheduleExpression->getDayOfWeek(), $scheduleExpression->getYear() ); // return the point in time at which the next timer expiration is scheduled to occur return new CalendarBasedTimeout($cronExpression, $scheduleExpression, new FieldFactory()); }
[ "public", "static", "function", "factoryFromScheduleExpression", "(", "ScheduleExpression", "$", "scheduleExpression", ")", "{", "// prepare the CRON expression", "$", "cronExpression", "=", "sprintf", "(", "'%s %s %s %s %s %s %s'", ",", "$", "scheduleExpression", "->", "ge...
Additional factory method that creates a new instance from the passed schedule expression. @param \AppserverIo\Psr\EnterpriseBeans\ScheduleExpression $scheduleExpression The schedule expression with the data to create the instance with @return \AppserverIo\Appserver\PersistenceContainer\CalendarBasedTimeout The instance
[ "Additional", "factory", "method", "that", "creates", "a", "new", "instance", "from", "the", "passed", "schedule", "expression", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/CalendarBasedTimeout.php#L69-L86
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/DependencyInjection/DeploymentDescriptorParser.php
DeploymentDescriptorParser.mapAuthenticator
public function mapAuthenticator($shortname) { // query whether or not we've manager configuration found /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerNode */ if ($managerNode = $this->getAuthenticationContext()->getManagerConfiguration()) { // initialize the authenticator configurations found in the manager configuration /** @var \AppserverIo\Appserver\Core\Api\Node\AuthenticatorNodeInterface $authenticatorNode */ foreach ($managerNode->getAuthenticators() as $authenticatorNode) { // query whether or not the shortname matches if (strcasecmp($authenticatorNode->getName(), $shortname) === 0) { return $authenticatorNode->getType(); } } } // throw an exception if the can't find an matching authenticator class name throw new AuthenticationException(sprintf('Can\t find authenticator configuration for %s', $shortname)); }
php
public function mapAuthenticator($shortname) { // query whether or not we've manager configuration found /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $managerNode */ if ($managerNode = $this->getAuthenticationContext()->getManagerConfiguration()) { // initialize the authenticator configurations found in the manager configuration /** @var \AppserverIo\Appserver\Core\Api\Node\AuthenticatorNodeInterface $authenticatorNode */ foreach ($managerNode->getAuthenticators() as $authenticatorNode) { // query whether or not the shortname matches if (strcasecmp($authenticatorNode->getName(), $shortname) === 0) { return $authenticatorNode->getType(); } } } // throw an exception if the can't find an matching authenticator class name throw new AuthenticationException(sprintf('Can\t find authenticator configuration for %s', $shortname)); }
[ "public", "function", "mapAuthenticator", "(", "$", "shortname", ")", "{", "// query whether or not we've manager configuration found", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ManagerNodeInterface $managerNode */", "if", "(", "$", "managerNode", "=", "$", "this", "->",...
Returns the authenticator class name for the passed shortname. @param string $shortname The shortname of the requested authenticator class name @return string The requested authenticator class name @throws \AppserverIo\Http\Authentication\AuthenticationException Is thrown if no mapping for the requested authenticator is not available
[ "Returns", "the", "authenticator", "class", "name", "for", "the", "passed", "shortname", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/DependencyInjection/DeploymentDescriptorParser.php#L89-L107
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/DependencyInjection/DeploymentDescriptorParser.php
DeploymentDescriptorParser.parse
public function parse() { // load the web application base directory $webappPath = $this->getAuthenticationContext()->getWebappPath(); // prepare the deployment descriptor $deploymentDescriptor = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF' . DIRECTORY_SEPARATOR . 'web.xml'; // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { return; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // prepare and initialize the configuration node $webAppNode = new WebAppNode(); $webAppNode->initFromFile($deploymentDescriptor); // query whether or not we've a login configuration /** @var \AppserverIo\Appserver\Core\Api\Node\LoginConfigNode $loginConfig */ if ($loginConfig = $webAppNode->getLoginConfig()) { // create the authentication method instance $reflectionClass = new ReflectionClass($this->mapAuthenticator($loginConfig->getAuthMethod()->__toString())); $authenticator = $reflectionClass->newInstanceArgs(array($loginConfig, $this->getAuthenticationContext(), new Boolean(true))); // add the authentication method itself $this->getAuthenticationContext()->addAuthenticator($authenticator); // initialize the security roles, that are part of the new security subsystem /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityRoleNode $securityRoleNode */ foreach ($webAppNode->getSecurityRoles() as $securityRoleNode) { // do something here } // initialize the security roles, that are part of the new security subsystem /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityConstraintNode $securityContstraintNode */ foreach ($webAppNode->getSecurityConstraints() as $securityContstraintNode) { // prepare the array with the authentication constraint role names $roleNames = array(); if ($authConstraint = $securityContstraintNode->getAuthConstraint()) { $roleNames = $authConstraint->getRoleNamesAsArray(); } /** @var \AppserverIo\Appserver\Core\Api\Node\WebResourceCollectionNode $webResourceCollectionNode */ foreach ($securityContstraintNode->getWebResourceCollections() as $webResourceCollectionNode) { // prepare the arrays for the HTTP methods and the method omissions $httpMethods = $webResourceCollectionNode->getHttpMethodsAsArray(); $httpMethodOmissions = $webResourceCollectionNode->getHttpMethodOmissionsAsArray(); /** @var \AppserverIo\Appserver\Core\Api\Node\UrlPatternNode $urlPatternNode */ foreach ($webResourceCollectionNode->getUrlPatterns() as $urlPatternNode) { // prepare the URL pattern to authenticator mapping with the necessary data $mapping = new Mapping( $urlPatternNode->__toString(), $authenticator->getSerial(), $roleNames, $httpMethods, $httpMethodOmissions ); // add the URL pattern to authenticator mapping $this->getAuthenticationContext()->addMapping($mapping); } } } } }
php
public function parse() { // load the web application base directory $webappPath = $this->getAuthenticationContext()->getWebappPath(); // prepare the deployment descriptor $deploymentDescriptor = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF' . DIRECTORY_SEPARATOR . 'web.xml'; // query whether we found epb.xml deployment descriptor file if (file_exists($deploymentDescriptor) === false) { return; } // validate the passed configuration file /** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->getApplication()->newService('AppserverIo\Appserver\Core\Api\ConfigurationService'); $configurationService->validateFile($deploymentDescriptor, null, true); // prepare and initialize the configuration node $webAppNode = new WebAppNode(); $webAppNode->initFromFile($deploymentDescriptor); // query whether or not we've a login configuration /** @var \AppserverIo\Appserver\Core\Api\Node\LoginConfigNode $loginConfig */ if ($loginConfig = $webAppNode->getLoginConfig()) { // create the authentication method instance $reflectionClass = new ReflectionClass($this->mapAuthenticator($loginConfig->getAuthMethod()->__toString())); $authenticator = $reflectionClass->newInstanceArgs(array($loginConfig, $this->getAuthenticationContext(), new Boolean(true))); // add the authentication method itself $this->getAuthenticationContext()->addAuthenticator($authenticator); // initialize the security roles, that are part of the new security subsystem /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityRoleNode $securityRoleNode */ foreach ($webAppNode->getSecurityRoles() as $securityRoleNode) { // do something here } // initialize the security roles, that are part of the new security subsystem /** @var \AppserverIo\Appserver\Core\Api\Node\SecurityConstraintNode $securityContstraintNode */ foreach ($webAppNode->getSecurityConstraints() as $securityContstraintNode) { // prepare the array with the authentication constraint role names $roleNames = array(); if ($authConstraint = $securityContstraintNode->getAuthConstraint()) { $roleNames = $authConstraint->getRoleNamesAsArray(); } /** @var \AppserverIo\Appserver\Core\Api\Node\WebResourceCollectionNode $webResourceCollectionNode */ foreach ($securityContstraintNode->getWebResourceCollections() as $webResourceCollectionNode) { // prepare the arrays for the HTTP methods and the method omissions $httpMethods = $webResourceCollectionNode->getHttpMethodsAsArray(); $httpMethodOmissions = $webResourceCollectionNode->getHttpMethodOmissionsAsArray(); /** @var \AppserverIo\Appserver\Core\Api\Node\UrlPatternNode $urlPatternNode */ foreach ($webResourceCollectionNode->getUrlPatterns() as $urlPatternNode) { // prepare the URL pattern to authenticator mapping with the necessary data $mapping = new Mapping( $urlPatternNode->__toString(), $authenticator->getSerial(), $roleNames, $httpMethods, $httpMethodOmissions ); // add the URL pattern to authenticator mapping $this->getAuthenticationContext()->addMapping($mapping); } } } } }
[ "public", "function", "parse", "(", ")", "{", "// load the web application base directory", "$", "webappPath", "=", "$", "this", "->", "getAuthenticationContext", "(", ")", "->", "getWebappPath", "(", ")", ";", "// prepare the deployment descriptor", "$", "deploymentDes...
Parses the servlet context's deployment descriptor file for servlets that has to be registered in the object manager. @return void
[ "Parses", "the", "servlet", "context", "s", "deployment", "descriptor", "file", "for", "servlets", "that", "has", "to", "be", "registered", "in", "the", "object", "manager", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/DependencyInjection/DeploymentDescriptorParser.php#L115-L183
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/RecursiveNormalizer.php
RecursiveNormalizer.normalize
public function normalize(ConfigurationInterface $configuration) { // normalize the configuration node without children $node = parent::normalize($configuration); // now we add recursive normalization foreach ($configuration->getChildren() as $child) { $node->{$configuration->getNodeName()}->children[] = $this->normalize($child); } // return the normalized node instance return $node; }
php
public function normalize(ConfigurationInterface $configuration) { // normalize the configuration node without children $node = parent::normalize($configuration); // now we add recursive normalization foreach ($configuration->getChildren() as $child) { $node->{$configuration->getNodeName()}->children[] = $this->normalize($child); } // return the normalized node instance return $node; }
[ "public", "function", "normalize", "(", "ConfigurationInterface", "$", "configuration", ")", "{", "// normalize the configuration node without children", "$", "node", "=", "parent", "::", "normalize", "(", "$", "configuration", ")", ";", "// now we add recursive normalizati...
Normalizes the passed configuration node recursive and returns a \stdClass representation of it. @param \AppserverIo\Configuration\Interfaces\ConfigurationInterface $configuration The configuration node to normalize recursive @return \stdClass The normalized configuration node
[ "Normalizes", "the", "passed", "configuration", "node", "recursive", "and", "returns", "a", "\\", "stdClass", "representation", "of", "it", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/RecursiveNormalizer.php#L45-L58
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/SimpleGroup.php
SimpleGroup.addMember
public function addMember(PrincipalInterface $pricipal) { // query whether or not the passed prinicpal is already a member $isMember = $this->members->exists($pricipal->getName()); // if the principal is not a member, add it if ($isMember === false) { $this->members->add($pricipal->getName(), $pricipal); } // return if the principal has successfully been added return $isMember === false; }
php
public function addMember(PrincipalInterface $pricipal) { // query whether or not the passed prinicpal is already a member $isMember = $this->members->exists($pricipal->getName()); // if the principal is not a member, add it if ($isMember === false) { $this->members->add($pricipal->getName(), $pricipal); } // return if the principal has successfully been added return $isMember === false; }
[ "public", "function", "addMember", "(", "PrincipalInterface", "$", "pricipal", ")", "{", "// query whether or not the passed prinicpal is already a member", "$", "isMember", "=", "$", "this", "->", "members", "->", "exists", "(", "$", "pricipal", "->", "getName", "(",...
Adds the passed principal to the group. @param \AppserverIo\Psr\Security\PrincipalInterface $pricipal The principal to add @return boolean TRUE if the member was successfully added, FALSE if the principal was already a member
[ "Adds", "the", "passed", "principal", "to", "the", "group", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/SimpleGroup.php#L70-L83
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/SimpleGroup.php
SimpleGroup.removeMember
public function removeMember(PrincipalInterface $principal) { // query whether or not the passed principal is a member of this group if ($this->members->exists($principal->getName())) { // remove the princial and return TRUE $this->members->remove($principal->getName()); return true; } // return FALSE, if not return false; }
php
public function removeMember(PrincipalInterface $principal) { // query whether or not the passed principal is a member of this group if ($this->members->exists($principal->getName())) { // remove the princial and return TRUE $this->members->remove($principal->getName()); return true; } // return FALSE, if not return false; }
[ "public", "function", "removeMember", "(", "PrincipalInterface", "$", "principal", ")", "{", "// query whether or not the passed principal is a member of this group", "if", "(", "$", "this", "->", "members", "->", "exists", "(", "$", "principal", "->", "getName", "(", ...
Removes the passed principal from the group. @param \AppserverIo\Psr\Security\PrincipalInterface $principal The principal to remove @return boolean TRUE if the member was successfully removed, FALSE if the principal was not a member
[ "Removes", "the", "passed", "principal", "from", "the", "group", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/SimpleGroup.php#L92-L104
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/SimpleGroup.php
SimpleGroup.isMember
public function isMember(PrincipalInterface $principal) { // first see if there is a key with the member name $isMember = $this->members->exists($principal->getName()); if ($isMember === false) { // check the AnybodyPrincipal & NobodyPrincipal special cases $isMember = ($principal instanceof AnybodyPrincipal); if ($isMember === false) { if ($principal instanceof NobodyPrincipal) { return false; } } } if ($isMember === false) { // check any groups for membership foreach ($this->members as $group) { if ($group instanceof GroupInterface) { $isMember = $group->isMember($principal); } } } return $isMember; }
php
public function isMember(PrincipalInterface $principal) { // first see if there is a key with the member name $isMember = $this->members->exists($principal->getName()); if ($isMember === false) { // check the AnybodyPrincipal & NobodyPrincipal special cases $isMember = ($principal instanceof AnybodyPrincipal); if ($isMember === false) { if ($principal instanceof NobodyPrincipal) { return false; } } } if ($isMember === false) { // check any groups for membership foreach ($this->members as $group) { if ($group instanceof GroupInterface) { $isMember = $group->isMember($principal); } } } return $isMember; }
[ "public", "function", "isMember", "(", "PrincipalInterface", "$", "principal", ")", "{", "// first see if there is a key with the member name", "$", "isMember", "=", "$", "this", "->", "members", "->", "exists", "(", "$", "principal", "->", "getName", "(", ")", ")...
Returns TRUE if the passed principal is a member of the group. This method does a recursive search, so if a principal belongs to a group which is a member of this group, true is returned. A special check is made to see if the member is an instance of AnybodyPrincipal or NobodyPrincipal since these classes do not hash to meaningful values. @param \AppserverIo\Psr\Security\PrincipalInterface $principal The principal to query membership for @return boolean TRUE if the principal is a member of this group, FALSE otherwise
[ "Returns", "TRUE", "if", "the", "passed", "principal", "is", "a", "member", "of", "the", "group", ".", "This", "method", "does", "a", "recursive", "search", "so", "if", "a", "principal", "belongs", "to", "a", "group", "which", "is", "a", "member", "of", ...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/SimpleGroup.php#L119-L145
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Utils/Util.php
Util.createPasswordHash
public static function createPasswordHash($hashAlgorithm, $hashEncoding, $hashCharset, String $name, String $password, $callback) { $newPassword = clone $password; return $newPassword->md5(); }
php
public static function createPasswordHash($hashAlgorithm, $hashEncoding, $hashCharset, String $name, String $password, $callback) { $newPassword = clone $password; return $newPassword->md5(); }
[ "public", "static", "function", "createPasswordHash", "(", "$", "hashAlgorithm", ",", "$", "hashEncoding", ",", "$", "hashCharset", ",", "String", "$", "name", ",", "String", "$", "password", ",", "$", "callback", ")", "{", "$", "newPassword", "=", "clone", ...
Creates and returns a hashed version of the passed password. @param string $hashAlgorithm The hash algorithm to use @param string $hashEncoding The hash encoding to use @param string $hashCharset The hash charset to use @param \AppserverIo\Lang\String $name The login name @param \AppserverIo\Lang\String $password The password credential @param mixed $callback The callback providing some additional hashing functionality @return \AppserverIo\Lang\String The hashed password
[ "Creates", "and", "returns", "a", "hashed", "version", "of", "the", "passed", "password", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Utils/Util.php#L73-L77
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Utils/Util.php
Util.getRoleSets
public static function getRoleSets(String $username, String $lookupName, String $rolesQuery, LoginModuleInterface $aslm) { try { // initialize the map for the groups $setsMap = new HashMap(); // load the application context $application = RequestHandler::getApplicationContext(); /** @var \AppserverIo\Appserver\Core\Api\Node\DatabaseNode $databaseNode */ $databaseNode = $application->getNamingDirectory()->search($lookupName)->getDatabase(); // prepare the connection parameters and create the DBAL connection $connection = DriverManager::getConnection(ConnectionUtil::get($application)->fromDatabaseNode($databaseNode)); // try to load the principal's roles from the database $statement = $connection->prepare($rolesQuery); $statement->bindParam(1, $username); $statement->execute(); // query whether or not we've a password found or not $row = $statement->fetch(\PDO::FETCH_NUM); // query whether or not we've found at least one role if ($row == false) { // try load the unauthenticated identity if ($aslm->getUnauthenticatedIdentity() == null) { throw new FailedLoginException('No matching username found in Roles'); } // we're running with an unauthenticatedIdentity so create an empty roles set and return return array(new SimpleGroup(Util::DEFAULT_GROUP_NAME)); } do { // load the found name and initialize the group name with a default value $name = $row[0]; $groupName = Util::DEFAULT_GROUP_NAME; // query whether or not we've to initialize a default group if (isset($row[1])) { $groupName = $row[1]; } // query whether or not the group already exists in the set if ($setsMap->exists($groupName) === false) { $group = new SimpleGroup(new String($groupName)); $setsMap->add($groupName, $group); } else { $group = $setsMap->get($groupName); } try { // add the user to the group $group->addMember($aslm->createIdentity(new String($name))); // log a message $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->debug(sprintf('Assign user to role: %s', $name)); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error(sprintf('Failed to create principal: %s', $name)); } // load one group after another } while ($row = $statement->fetch(\PDO::FETCH_OBJ)); } catch (NamingException $ne) { throw new LoginException($ne->__toString()); } catch (\PDOException $pdoe) { throw new LoginException($pdoe->__toString()); } // close the prepared statement if ($statement != null) { try { $statement->closeCursor(); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } } // close the DBAL connection if ($connection != null) { try { $connection->close(); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } } // return the prepared groups return $setsMap->toArray(); }
php
public static function getRoleSets(String $username, String $lookupName, String $rolesQuery, LoginModuleInterface $aslm) { try { // initialize the map for the groups $setsMap = new HashMap(); // load the application context $application = RequestHandler::getApplicationContext(); /** @var \AppserverIo\Appserver\Core\Api\Node\DatabaseNode $databaseNode */ $databaseNode = $application->getNamingDirectory()->search($lookupName)->getDatabase(); // prepare the connection parameters and create the DBAL connection $connection = DriverManager::getConnection(ConnectionUtil::get($application)->fromDatabaseNode($databaseNode)); // try to load the principal's roles from the database $statement = $connection->prepare($rolesQuery); $statement->bindParam(1, $username); $statement->execute(); // query whether or not we've a password found or not $row = $statement->fetch(\PDO::FETCH_NUM); // query whether or not we've found at least one role if ($row == false) { // try load the unauthenticated identity if ($aslm->getUnauthenticatedIdentity() == null) { throw new FailedLoginException('No matching username found in Roles'); } // we're running with an unauthenticatedIdentity so create an empty roles set and return return array(new SimpleGroup(Util::DEFAULT_GROUP_NAME)); } do { // load the found name and initialize the group name with a default value $name = $row[0]; $groupName = Util::DEFAULT_GROUP_NAME; // query whether or not we've to initialize a default group if (isset($row[1])) { $groupName = $row[1]; } // query whether or not the group already exists in the set if ($setsMap->exists($groupName) === false) { $group = new SimpleGroup(new String($groupName)); $setsMap->add($groupName, $group); } else { $group = $setsMap->get($groupName); } try { // add the user to the group $group->addMember($aslm->createIdentity(new String($name))); // log a message $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->debug(sprintf('Assign user to role: %s', $name)); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error(sprintf('Failed to create principal: %s', $name)); } // load one group after another } while ($row = $statement->fetch(\PDO::FETCH_OBJ)); } catch (NamingException $ne) { throw new LoginException($ne->__toString()); } catch (\PDOException $pdoe) { throw new LoginException($pdoe->__toString()); } // close the prepared statement if ($statement != null) { try { $statement->closeCursor(); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } } // close the DBAL connection if ($connection != null) { try { $connection->close(); } catch (\Exception $e) { $application ->getNamingDirectory() ->search(NamingDirectoryKeys::SYSTEM_LOGGER) ->error($e->__toString()); } } // return the prepared groups return $setsMap->toArray(); }
[ "public", "static", "function", "getRoleSets", "(", "String", "$", "username", ",", "String", "$", "lookupName", ",", "String", "$", "rolesQuery", ",", "LoginModuleInterface", "$", "aslm", ")", "{", "try", "{", "// initialize the map for the groups", "$", "setsMap...
Execute the rolesQuery against the dsJndiName to obtain the roles for the authenticated user. @param \AppserverIo\Lang\String $username The username to load the roles for @param \AppserverIo\Lang\String $lookupName The lookup name for the datasource @param \AppserverIo\Lang\String $rolesQuery The query to load the roles @param \AppserverIo\Psr\Security\Auth\Spi\LoginModuleInterface $aslm The login module to add the roles to @return array An array of groups containing the sets of roles @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if an error during login occured
[ "Execute", "the", "rolesQuery", "against", "the", "dsJndiName", "to", "obtain", "the", "roles", "for", "the", "authenticated", "user", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Utils/Util.php#L90-L193
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.init
public function init() { // reset the servlet request $httpRequest = $this->getHttpRequest(); // initialize the parts foreach ($httpRequest->getParts() as $part) { $this->addPart(Part::fromHttpRequest($part)); } // set the body content if we can find one if ($httpRequest->getHeader(HttpProtocol::HEADER_CONTENT_LENGTH) > 0) { $this->setBodyStream($httpRequest->getBodyContent()); } // copy server variables to members $this->setServerName($this->getServerVar(ServerVars::SERVER_NAME)); $this->setQueryString($this->getServerVar(ServerVars::QUERY_STRING)); $this->setRequestUri($this->getServerVar(ServerVars::X_REQUEST_URI)); $this->setDocumentRoot($this->getServerVar(ServerVars::DOCUMENT_ROOT)); $this->setRequestUrl($this->getServerVar(ServerVars::HTTP_HOST) . $this->getServerVar(ServerVars::X_REQUEST_URI)); }
php
public function init() { // reset the servlet request $httpRequest = $this->getHttpRequest(); // initialize the parts foreach ($httpRequest->getParts() as $part) { $this->addPart(Part::fromHttpRequest($part)); } // set the body content if we can find one if ($httpRequest->getHeader(HttpProtocol::HEADER_CONTENT_LENGTH) > 0) { $this->setBodyStream($httpRequest->getBodyContent()); } // copy server variables to members $this->setServerName($this->getServerVar(ServerVars::SERVER_NAME)); $this->setQueryString($this->getServerVar(ServerVars::QUERY_STRING)); $this->setRequestUri($this->getServerVar(ServerVars::X_REQUEST_URI)); $this->setDocumentRoot($this->getServerVar(ServerVars::DOCUMENT_ROOT)); $this->setRequestUrl($this->getServerVar(ServerVars::HTTP_HOST) . $this->getServerVar(ServerVars::X_REQUEST_URI)); }
[ "public", "function", "init", "(", ")", "{", "// reset the servlet request", "$", "httpRequest", "=", "$", "this", "->", "getHttpRequest", "(", ")", ";", "// initialize the parts", "foreach", "(", "$", "httpRequest", "->", "getParts", "(", ")", "as", "$", "par...
Initializes the servlet request with the data from the injected HTTP request instance. @return void
[ "Initializes", "the", "servlet", "request", "with", "the", "data", "from", "the", "injected", "HTTP", "request", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L310-L332
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.prepare
public function prepare() { // prepare the context path $contextPath = str_replace($this->getContext()->getAppBase(), '', $this->getContext()->getWebappPath()); // set the context path $this->setContextPath($contextPath); // Fixed #735 - Endless Loop for URLs without servlet name // Load the request URI and query string from the server vars, because we have to // take care about changes from other modules like directory or rewrite module! $uri = $this->getRequestUri(); $queryString = $this->getQueryString(); // get uri without querystring $uriWithoutQueryString = str_replace('?' . $queryString, '', $uri); // initialize the path information and the directory to start with list ($dirname, $basename, $extension) = array_values(pathinfo($uriWithoutQueryString)); // make the registered handlers local $handlers = $this->getHandlers(); // descent the directory structure down to find the (almost virtual) servlet file do { // bingo we found a (again: almost virtual) servlet file if (isset($handlers[".$extension"])) { // prepare the servlet path (we've to take care, because the // pathinfo() function converts / to \ on Windows OS if ($dirname === DIRECTORY_SEPARATOR) { $servletPath = '/' . $basename; } else { $servletPath = $dirname . '/' . $basename; } // we set the basename, because this is the servlet path $this->setServletPath($servletPath); // we set the path info, what is the request URI with stripped dir- and basename $this->setPathInfo(str_replace($servletPath, '', $uriWithoutQueryString)); // we've found what we were looking for, so break here break; } // break if we finally can't find a servlet to handle the request if ($dirname === '/') { throw new ServletException( sprintf('Can\'t find a handler for URI %s, either ', $uri) ); } // descend down the directory tree list ($dirname, $basename, $extension) = array_values(pathinfo($dirname)); } while ($dirname !== false); // stop until we reached the root of the URI // prepare and set the servlet path $this->setServletPath(str_replace($contextPath, '', $this->getServletPath())); // prepare the base modifier which allows our apps to provide a base URL $webappsDir = str_replace($this->getContext()->getBaseDirectory(), '', $this->getContext()->getAppBase()); $relativeRequestPath = strstr($this->getDocumentRoot(), $webappsDir); $proposedBaseModifier = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($webappsDir, '', $relativeRequestPath)); // prepare the base modifier if (strpos($proposedBaseModifier, $contextPath) === 0) { $this->setBaseModifier(''); } else { $this->setBaseModifier($contextPath); } }
php
public function prepare() { // prepare the context path $contextPath = str_replace($this->getContext()->getAppBase(), '', $this->getContext()->getWebappPath()); // set the context path $this->setContextPath($contextPath); // Fixed #735 - Endless Loop for URLs without servlet name // Load the request URI and query string from the server vars, because we have to // take care about changes from other modules like directory or rewrite module! $uri = $this->getRequestUri(); $queryString = $this->getQueryString(); // get uri without querystring $uriWithoutQueryString = str_replace('?' . $queryString, '', $uri); // initialize the path information and the directory to start with list ($dirname, $basename, $extension) = array_values(pathinfo($uriWithoutQueryString)); // make the registered handlers local $handlers = $this->getHandlers(); // descent the directory structure down to find the (almost virtual) servlet file do { // bingo we found a (again: almost virtual) servlet file if (isset($handlers[".$extension"])) { // prepare the servlet path (we've to take care, because the // pathinfo() function converts / to \ on Windows OS if ($dirname === DIRECTORY_SEPARATOR) { $servletPath = '/' . $basename; } else { $servletPath = $dirname . '/' . $basename; } // we set the basename, because this is the servlet path $this->setServletPath($servletPath); // we set the path info, what is the request URI with stripped dir- and basename $this->setPathInfo(str_replace($servletPath, '', $uriWithoutQueryString)); // we've found what we were looking for, so break here break; } // break if we finally can't find a servlet to handle the request if ($dirname === '/') { throw new ServletException( sprintf('Can\'t find a handler for URI %s, either ', $uri) ); } // descend down the directory tree list ($dirname, $basename, $extension) = array_values(pathinfo($dirname)); } while ($dirname !== false); // stop until we reached the root of the URI // prepare and set the servlet path $this->setServletPath(str_replace($contextPath, '', $this->getServletPath())); // prepare the base modifier which allows our apps to provide a base URL $webappsDir = str_replace($this->getContext()->getBaseDirectory(), '', $this->getContext()->getAppBase()); $relativeRequestPath = strstr($this->getDocumentRoot(), $webappsDir); $proposedBaseModifier = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($webappsDir, '', $relativeRequestPath)); // prepare the base modifier if (strpos($proposedBaseModifier, $contextPath) === 0) { $this->setBaseModifier(''); } else { $this->setBaseModifier($contextPath); } }
[ "public", "function", "prepare", "(", ")", "{", "// prepare the context path", "$", "contextPath", "=", "str_replace", "(", "$", "this", "->", "getContext", "(", ")", "->", "getAppBase", "(", ")", ",", "''", ",", "$", "this", "->", "getContext", "(", ")", ...
Prepares the request instance. @return void @throws \AppserverIo\Psr\Servlet\ServletException Is thrown if the request can't be prepared, because no file handle exists
[ "Prepares", "the", "request", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L340-L412
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.getParameter
public function getParameter($name, $filter = FILTER_SANITIZE_STRING) { $parameterMap = $this->getParameterMap(); if (isset($parameterMap[$name])) { return filter_var($parameterMap[$name], $filter); } }
php
public function getParameter($name, $filter = FILTER_SANITIZE_STRING) { $parameterMap = $this->getParameterMap(); if (isset($parameterMap[$name])) { return filter_var($parameterMap[$name], $filter); } }
[ "public", "function", "getParameter", "(", "$", "name", ",", "$", "filter", "=", "FILTER_SANITIZE_STRING", ")", "{", "$", "parameterMap", "=", "$", "this", "->", "getParameterMap", "(", ")", ";", "if", "(", "isset", "(", "$", "parameterMap", "[", "$", "n...
Returns the parameter with the passed name if available or null if the parameter not exists. @param string $name The name of the parameter to return @param integer $filter The filter to use @return string|null
[ "Returns", "the", "parameter", "with", "the", "passed", "name", "if", "available", "or", "null", "if", "the", "parameter", "not", "exists", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L778-L784
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.addPart
public function addPart(PartInterface $part, $name = null) { if ($name == null) { $name = $part->getName(); } $this->parts[$name] = $part; }
php
public function addPart(PartInterface $part, $name = null) { if ($name == null) { $name = $part->getName(); } $this->parts[$name] = $part; }
[ "public", "function", "addPart", "(", "PartInterface", "$", "part", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "==", "null", ")", "{", "$", "name", "=", "$", "part", "->", "getName", "(", ")", ";", "}", "$", "this", "->", ...
Adds a part to the parts collection. @param \AppserverIo\Appserver\ServletEngine\Http\Part $part A form part object @param string $name A manually defined name @return void
[ "Adds", "a", "part", "to", "the", "parts", "collection", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L818-L824
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.getProposedSessionId
public function getProposedSessionId() { // if no session has already been load, initialize the session manager /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */ $manager = $this->getContext()->search(SessionManagerInterface::IDENTIFIER); // if no session manager was found, we don't support sessions if ($manager == null) { return; } // if we can't find a requested session name, we try to load the default session cookie if ($this->getRequestedSessionName() == null) { $this->setRequestedSessionName($manager->getSessionSettings()->getSessionName()); } // load the requested session ID and name $sessionName = $this->getRequestedSessionName(); $id = $this->getRequestedSessionId(); // try to load session ID from session cookie of request/response $cookieFound = null; if ($id == null && $this->getResponse()->hasCookie($sessionName)) { $cookieFound = $this->getResponse()->getCookie($sessionName); } elseif ($id == null && $this->hasCookie($sessionName)) { $cookieFound = $this->getCookie($sessionName); } // check if we can find a cookie if (is_array($cookieFound)) { // iterate over the cookies and try to find one that is not expired foreach ($cookieFound as $cookie) { if ($cookie instanceof CookieInterface && $cookie->isExpired() === false) { $this->setRequestedSessionId($id = $cookie->getValue()); } } // if we found a single cookie instance } elseif ($cookieFound instanceof CookieInterface && $cookieFound->isExpired() === false) { $this->setRequestedSessionId($id = $cookieFound->getValue()); } // return the requested session return $id; }
php
public function getProposedSessionId() { // if no session has already been load, initialize the session manager /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */ $manager = $this->getContext()->search(SessionManagerInterface::IDENTIFIER); // if no session manager was found, we don't support sessions if ($manager == null) { return; } // if we can't find a requested session name, we try to load the default session cookie if ($this->getRequestedSessionName() == null) { $this->setRequestedSessionName($manager->getSessionSettings()->getSessionName()); } // load the requested session ID and name $sessionName = $this->getRequestedSessionName(); $id = $this->getRequestedSessionId(); // try to load session ID from session cookie of request/response $cookieFound = null; if ($id == null && $this->getResponse()->hasCookie($sessionName)) { $cookieFound = $this->getResponse()->getCookie($sessionName); } elseif ($id == null && $this->hasCookie($sessionName)) { $cookieFound = $this->getCookie($sessionName); } // check if we can find a cookie if (is_array($cookieFound)) { // iterate over the cookies and try to find one that is not expired foreach ($cookieFound as $cookie) { if ($cookie instanceof CookieInterface && $cookie->isExpired() === false) { $this->setRequestedSessionId($id = $cookie->getValue()); } } // if we found a single cookie instance } elseif ($cookieFound instanceof CookieInterface && $cookieFound->isExpired() === false) { $this->setRequestedSessionId($id = $cookieFound->getValue()); } // return the requested session return $id; }
[ "public", "function", "getProposedSessionId", "(", ")", "{", "// if no session has already been load, initialize the session manager", "/** @var \\AppserverIo\\Appserver\\ServletEngine\\SessionManagerInterface $manager */", "$", "manager", "=", "$", "this", "->", "getContext", "(", "...
Return the session identifier proposed by the actual configuration and request state. @return string The session identifier proposed for this request
[ "Return", "the", "session", "identifier", "proposed", "by", "the", "actual", "configuration", "and", "request", "state", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L875-L920
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.getSession
public function getSession($create = false) { // load the proposed session-ID and name $id = $this->getProposedSessionId(); $sessionName = $this->getRequestedSessionName(); // if no session has already been load, initialize the session manager /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */ $manager = $this->getSessionManager(); // if no session manager was found, we don't support sessions if ($manager == null) { return; } // find or create a new session (if flag has been set) $session = $manager->find($id); // if we can't find a session or session has been expired and we want to create a new one if ($session == null && $create === true) { // check if a session ID has been specified if ($id == null) { // if not, generate a unique one $id = SessionUtils::generateRandomString(); } // create a new session and register ID in request $session = $manager->create($id, $sessionName); } // if we can't find a session and we should NOT create one, return nothing if ($create === false && $session == null) { return; } // if we can't find a session although we SHOULD create one, we throw an exception if ($create === true && $session == null) { throw new \Exception('Can\'t create a new session!'); } // initialize the session wrapper $wrapper = new SessionWrapper(); $wrapper->injectSession($session); $wrapper->injectRequest($this); // set the session ID in the execution environment Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $id); // return the found session return $wrapper; }
php
public function getSession($create = false) { // load the proposed session-ID and name $id = $this->getProposedSessionId(); $sessionName = $this->getRequestedSessionName(); // if no session has already been load, initialize the session manager /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */ $manager = $this->getSessionManager(); // if no session manager was found, we don't support sessions if ($manager == null) { return; } // find or create a new session (if flag has been set) $session = $manager->find($id); // if we can't find a session or session has been expired and we want to create a new one if ($session == null && $create === true) { // check if a session ID has been specified if ($id == null) { // if not, generate a unique one $id = SessionUtils::generateRandomString(); } // create a new session and register ID in request $session = $manager->create($id, $sessionName); } // if we can't find a session and we should NOT create one, return nothing if ($create === false && $session == null) { return; } // if we can't find a session although we SHOULD create one, we throw an exception if ($create === true && $session == null) { throw new \Exception('Can\'t create a new session!'); } // initialize the session wrapper $wrapper = new SessionWrapper(); $wrapper->injectSession($session); $wrapper->injectRequest($this); // set the session ID in the execution environment Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $id); // return the found session return $wrapper; }
[ "public", "function", "getSession", "(", "$", "create", "=", "false", ")", "{", "// load the proposed session-ID and name", "$", "id", "=", "$", "this", "->", "getProposedSessionId", "(", ")", ";", "$", "sessionName", "=", "$", "this", "->", "getRequestedSession...
Returns the session for this request. @param boolean $create TRUE to create a new session, else FALSE @return null|\AppserverIo\Psr\Servlet\Http\HttpSessionInterface The session instance @throws \Exception
[ "Returns", "the", "session", "for", "this", "request", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L931-L982
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.isUserInRole
public function isUserInRole(String $role) { // query whether or not we've an user principal if ($principal = $this->getUserPrincipal()) { return $principal->getRoles()->contains($role); } // user is not in passed role return false; }
php
public function isUserInRole(String $role) { // query whether or not we've an user principal if ($principal = $this->getUserPrincipal()) { return $principal->getRoles()->contains($role); } // user is not in passed role return false; }
[ "public", "function", "isUserInRole", "(", "String", "$", "role", ")", "{", "// query whether or not we've an user principal", "if", "(", "$", "principal", "=", "$", "this", "->", "getUserPrincipal", "(", ")", ")", "{", "return", "$", "principal", "->", "getRole...
Return_s a boolean indicating whether the authenticated user is included in the specified logical "role". @param \AppserverIo\Lang\String $role The role we want to test for @return boolean TRUE if the user has the passed role, else FALSE
[ "Return_s", "a", "boolean", "indicating", "whether", "the", "authenticated", "user", "is", "included", "in", "the", "specified", "logical", "role", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L1361-L1371
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.authenticate
public function authenticate(HttpServletResponseInterface $servletResponse) { // load the authentication manager and try to authenticate this request /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */ if ($authenticationManager = $this->getAuthenticationManager()) { return $authenticationManager->handleRequest($this, $servletResponse); } // also return TRUE if we can't find an authentication manager return true; }
php
public function authenticate(HttpServletResponseInterface $servletResponse) { // load the authentication manager and try to authenticate this request /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */ if ($authenticationManager = $this->getAuthenticationManager()) { return $authenticationManager->handleRequest($this, $servletResponse); } // also return TRUE if we can't find an authentication manager return true; }
[ "public", "function", "authenticate", "(", "HttpServletResponseInterface", "$", "servletResponse", ")", "{", "// load the authentication manager and try to authenticate this request", "/** @var \\AppserverIo\\Psr\\Auth\\AuthenticationManagerInterface $authenticationManager */", "if", "(", ...
Use the container login mechanism configured for the servlet context to authenticate the user making this request. This method may modify and commit the passed servlet response. @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The servlet response @return boolean TRUE when non-null values were or have been established as the values returned by getRemoteUser, else FALSE
[ "Use", "the", "container", "login", "mechanism", "configured", "for", "the", "servlet", "context", "to", "authenticate", "the", "user", "making", "this", "request", ".", "This", "method", "may", "modify", "and", "commit", "the", "passed", "servlet", "response", ...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L1381-L1392
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.login
public function login(String $username, String $password) { // query whether or not we're already authenticated or not if ($this->getAuthType() != null || $this->getRemoteUser() != null || $this->getUserPrincipal() != null) { throw new ServletException('Already authenticated'); } // load the authentication manager and try to authenticate this request /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */ if ($authenticationManager = $this->getAuthenticationManager()) { // try to load the authentication managers default authenticator if (($authenticator = $authenticationManager->getAuthenticator()) == null) { throw new ServletException('Can\'t find default authenticator'); } // authenticate the passed username/password combination $authenticator->login($username, $password, $this); } }
php
public function login(String $username, String $password) { // query whether or not we're already authenticated or not if ($this->getAuthType() != null || $this->getRemoteUser() != null || $this->getUserPrincipal() != null) { throw new ServletException('Already authenticated'); } // load the authentication manager and try to authenticate this request /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */ if ($authenticationManager = $this->getAuthenticationManager()) { // try to load the authentication managers default authenticator if (($authenticator = $authenticationManager->getAuthenticator()) == null) { throw new ServletException('Can\'t find default authenticator'); } // authenticate the passed username/password combination $authenticator->login($username, $password, $this); } }
[ "public", "function", "login", "(", "String", "$", "username", ",", "String", "$", "password", ")", "{", "// query whether or not we're already authenticated or not", "if", "(", "$", "this", "->", "getAuthType", "(", ")", "!=", "null", "||", "$", "this", "->", ...
Validate the provided username and password in the password validation realm used by the web container login mechanism configured for the ServletContext. @param \AppserverIo\Lang\String $username The username to login @param \AppserverIo\Lang\String $password The password used to authenticate the user @return void @throws \AppserverIo\Psr\Servlet\ServletException Is thrown if no default authenticator can be found
[ "Validate", "the", "provided", "username", "and", "password", "in", "the", "password", "validation", "realm", "used", "by", "the", "web", "container", "login", "mechanism", "configured", "for", "the", "ServletContext", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L1404-L1423
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Http/Request.php
Request.logout
public function logout() { // load the authentication manager and try to authenticate this request /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */ if ($authenticationManager = $this->getAuthenticationManager()) { // try to load the authentication managers default authenticator if (($authenticator = $authenticationManager->getAuthenticator()) == null) { throw new ServletException('Can\'t find default authenticator'); } // logout the actual user $authenticator->logout($this); } }
php
public function logout() { // load the authentication manager and try to authenticate this request /** @var \AppserverIo\Psr\Auth\AuthenticationManagerInterface $authenticationManager */ if ($authenticationManager = $this->getAuthenticationManager()) { // try to load the authentication managers default authenticator if (($authenticator = $authenticationManager->getAuthenticator()) == null) { throw new ServletException('Can\'t find default authenticator'); } // logout the actual user $authenticator->logout($this); } }
[ "public", "function", "logout", "(", ")", "{", "// load the authentication manager and try to authenticate this request", "/** @var \\AppserverIo\\Psr\\Auth\\AuthenticationManagerInterface $authenticationManager */", "if", "(", "$", "authenticationManager", "=", "$", "this", "->", "g...
Establish null as the value returned when getUserPrincipal, getRemoteUser, and getAuthType is called on the request. @return void @throws \AppserverIo\Psr\Servlet\ServletException Is thrown if no default authenticator can be found
[ "Establish", "null", "as", "the", "value", "returned", "when", "getUserPrincipal", "getRemoteUser", "and", "getAuthType", "is", "called", "on", "the", "request", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Http/Request.php#L1432-L1446
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php
StatefulSessionBeanMap.add
public function add($key, $object, $lifetime = 0) { // check if a key has been passed if (is_null($key)) { throw new NullPointerException('Passed key is null'); } // check if lifetime is of type integer if (is_integer($lifetime) === false) { throw new InvalidLifetimeException(sprintf('Passed lifetime must be an integer, but is %s instead', $lifetime)); } // check if a primitive datatype is passed if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) { // add the item and lifetime to the array $this->items[$key] = $object; // add a lifetime if passed lifetime > 0 if ($lifetime > 0) { $this->lifetime[$key] = time() + $lifetime; } // and return return; } // check if an object is passed if (is_object($key)) { if ($key instanceof String) { $newKey = $key->stringValue(); } elseif ($key instanceof Float) { $newKey = $key->floatValue(); } elseif ($key instanceof Integer) { $newKey = $key->intValue(); } elseif ($key instanceof Boolean) { $newKey = $key->booleanValue(); } elseif (method_exists($key, '__toString')) { $newKey = $key->__toString(); } else { throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); } // add the item and lifetime to the array $this->items[$newKey] = $object; // add a lifetime if passed lifetime > 0 if ($lifetime > 0) { $this->lifetime[$newKey] = time() + $lifetime; } // and return return; } throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); }
php
public function add($key, $object, $lifetime = 0) { // check if a key has been passed if (is_null($key)) { throw new NullPointerException('Passed key is null'); } // check if lifetime is of type integer if (is_integer($lifetime) === false) { throw new InvalidLifetimeException(sprintf('Passed lifetime must be an integer, but is %s instead', $lifetime)); } // check if a primitive datatype is passed if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) { // add the item and lifetime to the array $this->items[$key] = $object; // add a lifetime if passed lifetime > 0 if ($lifetime > 0) { $this->lifetime[$key] = time() + $lifetime; } // and return return; } // check if an object is passed if (is_object($key)) { if ($key instanceof String) { $newKey = $key->stringValue(); } elseif ($key instanceof Float) { $newKey = $key->floatValue(); } elseif ($key instanceof Integer) { $newKey = $key->intValue(); } elseif ($key instanceof Boolean) { $newKey = $key->booleanValue(); } elseif (method_exists($key, '__toString')) { $newKey = $key->__toString(); } else { throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); } // add the item and lifetime to the array $this->items[$newKey] = $object; // add a lifetime if passed lifetime > 0 if ($lifetime > 0) { $this->lifetime[$newKey] = time() + $lifetime; } // and return return; } throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); }
[ "public", "function", "add", "(", "$", "key", ",", "$", "object", ",", "$", "lifetime", "=", "0", ")", "{", "// check if a key has been passed", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "throw", "new", "NullPointerException", "(", "'Passed key...
This method adds the passed object with the passed key to the instance. @param mixed $key The key to add the passed value under @param mixed $object The object to add to the instance @param integer $lifetime The items lifetime @return null @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an primitive datatype @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is null or not a flat datatype like Integer, String, Double or Boolean
[ "This", "method", "adds", "the", "passed", "object", "with", "the", "passed", "key", "to", "the", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php#L69-L115
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php
StatefulSessionBeanMap.get
public function get($key) { // check if a key has been passed if (is_null($key)) { throw new NullPointerException('Passed key is null'); } // check if a primitive datatype is passed if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) { // return the value for the passed key, if it exists if (array_key_exists($key, $this->items) && !$this->isTimedOut($key)) { // item is available and NOT timed out return $this->items[$key]; } elseif (array_key_exists($key, $this->items) && $this->isTimedOut($key)) { // item is available, but timed out return; } else { // item is generally not available throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $key)); } } // check if an object is passed if (is_object($key)) { if ($key instanceof String) { $newKey = $key->stringValue(); } elseif ($key instanceof Float) { $newKey = $key->floatValue(); } elseif ($key instanceof Integer) { $newKey = $key->intValue(); } elseif ($key instanceof Boolean) { $newKey = $key->booleanValue(); } elseif (method_exists($key, '__toString')) { $newKey = $key->__toString(); } else { throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); } // return the value for the passed key, if it exists if (array_key_exists($newKey, $this->items) && !$this->isTimedOut($newKey)) { // item is available and NOT timed out return $this->items[$newKey]; } elseif (array_key_exists($newKey, $this->items) && $this->isTimedOut($newKey)) { // item is available, but timed out return; } else { // item is generally not available throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $newKey)); } } throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); }
php
public function get($key) { // check if a key has been passed if (is_null($key)) { throw new NullPointerException('Passed key is null'); } // check if a primitive datatype is passed if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) { // return the value for the passed key, if it exists if (array_key_exists($key, $this->items) && !$this->isTimedOut($key)) { // item is available and NOT timed out return $this->items[$key]; } elseif (array_key_exists($key, $this->items) && $this->isTimedOut($key)) { // item is available, but timed out return; } else { // item is generally not available throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $key)); } } // check if an object is passed if (is_object($key)) { if ($key instanceof String) { $newKey = $key->stringValue(); } elseif ($key instanceof Float) { $newKey = $key->floatValue(); } elseif ($key instanceof Integer) { $newKey = $key->intValue(); } elseif ($key instanceof Boolean) { $newKey = $key->booleanValue(); } elseif (method_exists($key, '__toString')) { $newKey = $key->__toString(); } else { throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); } // return the value for the passed key, if it exists if (array_key_exists($newKey, $this->items) && !$this->isTimedOut($newKey)) { // item is available and NOT timed out return $this->items[$newKey]; } elseif (array_key_exists($newKey, $this->items) && $this->isTimedOut($newKey)) { // item is available, but timed out return; } else { // item is generally not available throw new IndexOutOfBoundsException(sprintf('Index %s out of bounds', $newKey)); } } throw new InvalidKeyException('Passed key has to be a primitive datatype or has to implement the __toString() method'); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "// check if a key has been passed", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "throw", "new", "NullPointerException", "(", "'Passed key is null'", ")", ";", "}", "// check if a primitive datatype...
This method returns the element with the passed key from the Collection. @param mixed $key Holds the key of the element to return @return mixed The requested element @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an integer @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key OR value are NULL @throws \AppserverIo\Collections\IndexOutOfBoundsException Is thrown if no element with the passed key exists in the Collection @see \AppserverIo\Collections\CollectionInterface::get($key)
[ "This", "method", "returns", "the", "element", "with", "the", "passed", "key", "from", "the", "Collection", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php#L129-L177
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php
StatefulSessionBeanMap.remove
public function remove($key, callable $beforeRemove = null) { // check if a key has been passed if (is_null($key)) { throw new NullPointerException('Passed key is null'); } // check if a primitive datatype is passed if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) { if (array_key_exists($key, $this->items)) { // invoke the callback before if (is_callable($beforeRemove)) { call_user_func($beforeRemove, $this->items[$key]); } // remove the item unset($this->items[$key]); // remove the lifetime if set if (isset($this->lifetime[$key])) { unset($this->lifetime[$key]); } return; } else { throw new IndexOutOfBoundsException('Index ' . $key . ' out of bounds'); } } // check if an object is passed if (is_object($key)) { if ($key instanceof String) { $newKey = $key->stringValue(); } elseif ($key instanceof Float) { $newKey = $key->floatValue(); } elseif ($key instanceof Integer) { $newKey = $key->intValue(); } elseif ($key instanceof Boolean) { $newKey = $key->booleanValue(); } elseif (method_exists($key, '__toString')) { $newKey = $key->__toString(); } else { throw new InvalidKeyException('Passed key has to be a primitive datatype or ' . 'has to implement the __toString() method'); } if (array_key_exists($newKey, $this->items)) { // invoke the callback before if (is_callable($beforeRemove)) { call_user_func($beforeRemove, $this->items[$newKey]); } // remove the item unset($this->items[$newKey]); // remove the lifetime if set if (isset($this->lifetime[$newKey])) { unset($this->lifetime[$newKey]); } return; } else { throw new IndexOutOfBoundsException('Index ' . $newKey . ' out of bounds'); } } throw new InvalidKeyException('Passed key has to be a primitive datatype or ' . 'has to implement the __toString() method'); }
php
public function remove($key, callable $beforeRemove = null) { // check if a key has been passed if (is_null($key)) { throw new NullPointerException('Passed key is null'); } // check if a primitive datatype is passed if (is_integer($key) || is_string($key) || is_double($key) || is_bool($key)) { if (array_key_exists($key, $this->items)) { // invoke the callback before if (is_callable($beforeRemove)) { call_user_func($beforeRemove, $this->items[$key]); } // remove the item unset($this->items[$key]); // remove the lifetime if set if (isset($this->lifetime[$key])) { unset($this->lifetime[$key]); } return; } else { throw new IndexOutOfBoundsException('Index ' . $key . ' out of bounds'); } } // check if an object is passed if (is_object($key)) { if ($key instanceof String) { $newKey = $key->stringValue(); } elseif ($key instanceof Float) { $newKey = $key->floatValue(); } elseif ($key instanceof Integer) { $newKey = $key->intValue(); } elseif ($key instanceof Boolean) { $newKey = $key->booleanValue(); } elseif (method_exists($key, '__toString')) { $newKey = $key->__toString(); } else { throw new InvalidKeyException('Passed key has to be a primitive datatype or ' . 'has to implement the __toString() method'); } if (array_key_exists($newKey, $this->items)) { // invoke the callback before if (is_callable($beforeRemove)) { call_user_func($beforeRemove, $this->items[$newKey]); } // remove the item unset($this->items[$newKey]); // remove the lifetime if set if (isset($this->lifetime[$newKey])) { unset($this->lifetime[$newKey]); } return; } else { throw new IndexOutOfBoundsException('Index ' . $newKey . ' out of bounds'); } } throw new InvalidKeyException('Passed key has to be a primitive datatype or ' . 'has to implement the __toString() method'); }
[ "public", "function", "remove", "(", "$", "key", ",", "callable", "$", "beforeRemove", "=", "null", ")", "{", "// check if a key has been passed", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "throw", "new", "NullPointerException", "(", "'Passed key i...
This method removes the element with the passed key, that has to be an integer, from the IndexedCollection. @param mixed $key Holds the key of the element to remove @param callable $beforeRemove Is called before the item will be removed @return void @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an integer @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is NULL @throws \AppserverIo\Collections\IndexOutOfBoundsException Is thrown if no element with the passed key exists in the Collection
[ "This", "method", "removes", "the", "element", "with", "the", "passed", "key", "that", "has", "to", "be", "an", "integer", "from", "the", "IndexedCollection", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php#L192-L248
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php
StatefulSessionBeanMap.isTimedOut
public function isTimedOut($key) { // if the item is available and has timed out, return TRUE if (array_key_exists($key, $this->lifetime) && $this->lifetime[$key] < time()) { return true; } // else return FALSE return false; }
php
public function isTimedOut($key) { // if the item is available and has timed out, return TRUE if (array_key_exists($key, $this->lifetime) && $this->lifetime[$key] < time()) { return true; } // else return FALSE return false; }
[ "public", "function", "isTimedOut", "(", "$", "key", ")", "{", "// if the item is available and has timed out, return TRUE", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "lifetime", ")", "&&", "$", "this", "->", "lifetime", "[", "$", ...
Returns TRUE if an lifetime value for the passed key is available and the item has timed out. @param mixed $key The key of the item the lifetime check is requested @return boolean TRUE if the item has timed out, else FALSE
[ "Returns", "TRUE", "if", "an", "lifetime", "value", "for", "the", "passed", "key", "is", "available", "and", "the", "item", "has", "timed", "out", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/StatefulSessionBeanMap.php#L258-L266
appserver-io/appserver
src/AppserverIo/Appserver/Core/GeneratorThread.php
GeneratorThread.run
public function run() { // register a shutdown function register_shutdown_function(array($this, 'shutdown')); // register the default autoloader require SERVER_AUTOLOADER; try { // iterate over all structures and generate them foreach ($this->structures as $structure) { $this->generator->create($structure); } } catch (\Exception $e) { $this->log(LogLevel::ERROR, $e->__toString()); } }
php
public function run() { // register a shutdown function register_shutdown_function(array($this, 'shutdown')); // register the default autoloader require SERVER_AUTOLOADER; try { // iterate over all structures and generate them foreach ($this->structures as $structure) { $this->generator->create($structure); } } catch (\Exception $e) { $this->log(LogLevel::ERROR, $e->__toString()); } }
[ "public", "function", "run", "(", ")", "{", "// register a shutdown function", "register_shutdown_function", "(", "array", "(", "$", "this", ",", "'shutdown'", ")", ")", ";", "// register the default autoloader", "require", "SERVER_AUTOLOADER", ";", "try", "{", "// it...
Run method @return void
[ "Run", "method" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GeneratorThread.php#L75-L93
appserver-io/appserver
src/AppserverIo/Appserver/Core/GeneratorThread.php
GeneratorThread.shutdown
public function shutdown() { // check if there was a fatal error caused shutdown if ($lastError = error_get_last()) { // initialize error type and message $type = 0; $message = ''; // extract the last error values extract($lastError); // query whether we've a fatal/user error if ($type === E_ERROR || $type === E_USER_ERROR) { $this->log(LogLevel::ERROR, $message); } } }
php
public function shutdown() { // check if there was a fatal error caused shutdown if ($lastError = error_get_last()) { // initialize error type and message $type = 0; $message = ''; // extract the last error values extract($lastError); // query whether we've a fatal/user error if ($type === E_ERROR || $type === E_USER_ERROR) { $this->log(LogLevel::ERROR, $message); } } }
[ "public", "function", "shutdown", "(", ")", "{", "// check if there was a fatal error caused shutdown", "if", "(", "$", "lastError", "=", "error_get_last", "(", ")", ")", "{", "// initialize error type and message", "$", "type", "=", "0", ";", "$", "message", "=", ...
The shutdown method implementation. @return void
[ "The", "shutdown", "method", "implementation", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GeneratorThread.php#L100-L115
appserver-io/appserver
src/AppserverIo/Appserver/Core/GeneratorThread.php
GeneratorThread.log
public function log($level, $message, array $context = array()) { error_log(sprintf($this->getDefaultLogFormat(), date('Y-m-d H:i:s'), gethostname(), $level, $message, json_encode($context))); }
php
public function log($level, $message, array $context = array()) { error_log(sprintf($this->getDefaultLogFormat(), date('Y-m-d H:i:s'), gethostname(), $level, $message, json_encode($context))); }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "error_log", "(", "sprintf", "(", "$", "this", "->", "getDefaultLogFormat", "(", ")", ",", "date", "(", "'Y-m-d H:i:s'"...
This is a very basic method to log some stuff by using the error_log() method of PHP. @param mixed $level The log level to use @param string $message The message we want to log @param array $context The context we of the message @return void
[ "This", "is", "a", "very", "basic", "method", "to", "log", "some", "stuff", "by", "using", "the", "error_log", "()", "method", "of", "PHP", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/GeneratorThread.php#L136-L139
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/NamingDirectoryLoginModule.php
NamingDirectoryLoginModule.initialize
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // load the parameters from the map $this->userPathPrefix = $params->get(ParamKeys::USER_PATH_PREFIX); $this->rolesPathPrefix = $params->get(ParamKeys::ROLES_PATH_PREFIX); }
php
public function initialize(Subject $subject, CallbackHandlerInterface $callbackHandler, MapInterface $sharedState, MapInterface $params) { // call the parent method parent::initialize($subject, $callbackHandler, $sharedState, $params); // load the parameters from the map $this->userPathPrefix = $params->get(ParamKeys::USER_PATH_PREFIX); $this->rolesPathPrefix = $params->get(ParamKeys::ROLES_PATH_PREFIX); }
[ "public", "function", "initialize", "(", "Subject", "$", "subject", ",", "CallbackHandlerInterface", "$", "callbackHandler", ",", "MapInterface", "$", "sharedState", ",", "MapInterface", "$", "params", ")", "{", "// call the parent method", "parent", "::", "initialize...
Initialize the login module. This stores the subject, callbackHandler and sharedState and options for the login session. Subclasses should override if they need to process their own options. A call to parent::initialize() must be made in the case of an override. The following parameters can by default be passed from the configuration. rolesPathPrefix: The naming directory prefix used to load the user's roles userPathPrefix: The naming directory prefix used to load the user @param \AppserverIo\Psr\Security\Auth\Subject $subject The Subject to update after a successful login @param \AppserverIo\Psr\Security\Auth\Callback\CallbackHandlerInterface $callbackHandler The callback handler that will be used to obtain the user identity and credentials @param \AppserverIo\Collections\MapInterface $sharedState A map shared between all configured login module instances @param \AppserverIo\Collections\MapInterface $params The parameters passed to the login module @return void
[ "Initialize", "the", "login", "module", ".", "This", "stores", "the", "subject", "callbackHandler", "and", "sharedState", "and", "options", "for", "the", "login", "session", ".", "Subclasses", "should", "override", "if", "they", "need", "to", "process", "their",...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/NamingDirectoryLoginModule.php#L75-L84
appserver-io/appserver
src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/NamingDirectoryLoginModule.php
NamingDirectoryLoginModule.getUsersPassword
protected function getUsersPassword() { try { // load the application context $application = RequestHandler::getApplicationContext(); // load and return the user's password or throw an exception return new String($application->search(sprintf('%s/%s', $this->userPathPrefix, $this->getUsername()))); } catch (\Exception $e) { throw new LoginException('No matching username found in naming directory'); } }
php
protected function getUsersPassword() { try { // load the application context $application = RequestHandler::getApplicationContext(); // load and return the user's password or throw an exception return new String($application->search(sprintf('%s/%s', $this->userPathPrefix, $this->getUsername()))); } catch (\Exception $e) { throw new LoginException('No matching username found in naming directory'); } }
[ "protected", "function", "getUsersPassword", "(", ")", "{", "try", "{", "// load the application context", "$", "application", "=", "RequestHandler", "::", "getApplicationContext", "(", ")", ";", "// load and return the user's password or throw an exception", "return", "new",...
Returns the password for the user from the naming directory. @return \AppserverIo\Lang\String The user's password @throws \AppserverIo\Psr\Security\Auth\Login\LoginException Is thrown if password can't be loaded
[ "Returns", "the", "password", "for", "the", "user", "from", "the", "naming", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/ServletEngine/Security/Auth/Spi/NamingDirectoryLoginModule.php#L92-L105
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.registerReferences
public function registerReferences(DescriptorInterface $descriptor) { // register the EPB references foreach ($descriptor->getEpbReferences() as $epbReference) { $this->registerEpbReference($epbReference); } // register the resource references foreach ($descriptor->getResReferences() as $resReference) { $this->registerResReference($resReference); } // register the bean references foreach ($descriptor->getBeanReferences() as $beanReference) { $this->registerBeanReference($beanReference); } // register the persistence unit references foreach ($descriptor->getPersistenceUnitReferences() as $persistenceUnitReference) { $this->registerPersistenceUnitReference($persistenceUnitReference); } }
php
public function registerReferences(DescriptorInterface $descriptor) { // register the EPB references foreach ($descriptor->getEpbReferences() as $epbReference) { $this->registerEpbReference($epbReference); } // register the resource references foreach ($descriptor->getResReferences() as $resReference) { $this->registerResReference($resReference); } // register the bean references foreach ($descriptor->getBeanReferences() as $beanReference) { $this->registerBeanReference($beanReference); } // register the persistence unit references foreach ($descriptor->getPersistenceUnitReferences() as $persistenceUnitReference) { $this->registerPersistenceUnitReference($persistenceUnitReference); } }
[ "public", "function", "registerReferences", "(", "DescriptorInterface", "$", "descriptor", ")", "{", "// register the EPB references", "foreach", "(", "$", "descriptor", "->", "getEpbReferences", "(", ")", "as", "$", "epbReference", ")", "{", "$", "this", "->", "...
Register's the references of the passed descriptor. @param \AppserverIo\Psr\Deployment\DescriptorInterface $descriptor The descriptor to register the references for @return void
[ "Register", "s", "the", "references", "of", "the", "passed", "descriptor", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L54-L76
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.registerEpbReference
public function registerEpbReference(EpbReferenceDescriptorInterface $epbReference) { try { // load the application instance and reference name $application = $this->getApplication(); $name = $epbReference->getRefName(); // initialize the bean's URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $name); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Enterprise bean reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // this has to be refactored, because it'll be quite faster to inject either // the remote/local proxy instance as injection a callback that creates the // proxy on-the-fly! // query whether or not we've a lookup name specified if ($lookup = $epbReference->getLookup()) { // create a reference to a bean in the global directory $application->getNamingDirectory()->bind($uri, array(&$this, 'lookup'), array($lookup)); // try to load the bean name, if no lookup name has been specified } elseif ($beanName = $epbReference->getBeanName()) { // query whether we've a local business interface if ($epbReference->getBeanInterface() === sprintf('%sLocal', $beanName)) { // bind the local business interface of the bean to the appliations naming directory $application->getNamingDirectory() ->bind( $uri, array(&$this, 'lookupProxy'), array(sprintf('%s/local', $beanName)) ); // query whether we've a remote business interface } elseif ($epbReference->getBeanInterface() === (sprintf('%sRemote', $beanName))) { // bind the remote business interface of the bean to the applications naming directory $application->getNamingDirectory() ->bind( $uri, array(&$this, 'lookupProxy'), array(sprintf('%s/remote', $beanName)) ); // at least, we need a business interface } else { // log a critical message that we can't bind the reference $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind bean reference %s to naming directory', $uri) ); } } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind enterprise bean reference %s to naming directory, because of missing lookup/bean name', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
php
public function registerEpbReference(EpbReferenceDescriptorInterface $epbReference) { try { // load the application instance and reference name $application = $this->getApplication(); $name = $epbReference->getRefName(); // initialize the bean's URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $name); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Enterprise bean reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // this has to be refactored, because it'll be quite faster to inject either // the remote/local proxy instance as injection a callback that creates the // proxy on-the-fly! // query whether or not we've a lookup name specified if ($lookup = $epbReference->getLookup()) { // create a reference to a bean in the global directory $application->getNamingDirectory()->bind($uri, array(&$this, 'lookup'), array($lookup)); // try to load the bean name, if no lookup name has been specified } elseif ($beanName = $epbReference->getBeanName()) { // query whether we've a local business interface if ($epbReference->getBeanInterface() === sprintf('%sLocal', $beanName)) { // bind the local business interface of the bean to the appliations naming directory $application->getNamingDirectory() ->bind( $uri, array(&$this, 'lookupProxy'), array(sprintf('%s/local', $beanName)) ); // query whether we've a remote business interface } elseif ($epbReference->getBeanInterface() === (sprintf('%sRemote', $beanName))) { // bind the remote business interface of the bean to the applications naming directory $application->getNamingDirectory() ->bind( $uri, array(&$this, 'lookupProxy'), array(sprintf('%s/remote', $beanName)) ); // at least, we need a business interface } else { // log a critical message that we can't bind the reference $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind bean reference %s to naming directory', $uri) ); } } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind enterprise bean reference %s to naming directory, because of missing lookup/bean name', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
[ "public", "function", "registerEpbReference", "(", "EpbReferenceDescriptorInterface", "$", "epbReference", ")", "{", "try", "{", "// load the application instance and reference name", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "$", "nam...
Registers the passed EPB reference in the applications directory. @param \AppserverIo\Psr\EnterpriseBeans\Description\EpbReferenceDescriptorInterface $epbReference The EPB reference to register @return void
[ "Registers", "the", "passed", "EPB", "reference", "in", "the", "applications", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L85-L156
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.registerResReference
public function registerResReference(ResReferenceDescriptorInterface $resReference) { try { // load the application instance and reference name $application = $this->getApplication(); // initialize the resource URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $resReference->getRefName()); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Resource reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // catch the NamingException if the ref name is not bound yet } catch (NamingException $e) { // log a message that we've to register the resource reference now $application->getInitialContext()->getSystemLogger()->debug( sprintf('Resource reference %s has not been bound to naming directory', $uri) ); } try { // try to use the lookup to bind the reference to if ($lookup = $resReference->getLookup()) { // create a reference to a resource in the global directory $application->getNamingDirectory()->bindReference($uri, $lookup); // try to bind the reference by the specified type } elseif ($type = $resReference->getType()) { // bind a reference to the resource shortname $application->getNamingDirectory() ->bindReference( $uri, sprintf('php:global/%s/%s', $application->getUniqueName(), $type) ); // log a critical message that we can't bind the reference } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind resource reference %s to naming directory, because of missing source bean/lookup name', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
php
public function registerResReference(ResReferenceDescriptorInterface $resReference) { try { // load the application instance and reference name $application = $this->getApplication(); // initialize the resource URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $resReference->getRefName()); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Resource reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // catch the NamingException if the ref name is not bound yet } catch (NamingException $e) { // log a message that we've to register the resource reference now $application->getInitialContext()->getSystemLogger()->debug( sprintf('Resource reference %s has not been bound to naming directory', $uri) ); } try { // try to use the lookup to bind the reference to if ($lookup = $resReference->getLookup()) { // create a reference to a resource in the global directory $application->getNamingDirectory()->bindReference($uri, $lookup); // try to bind the reference by the specified type } elseif ($type = $resReference->getType()) { // bind a reference to the resource shortname $application->getNamingDirectory() ->bindReference( $uri, sprintf('php:global/%s/%s', $application->getUniqueName(), $type) ); // log a critical message that we can't bind the reference } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind resource reference %s to naming directory, because of missing source bean/lookup name', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
[ "public", "function", "registerResReference", "(", "ResReferenceDescriptorInterface", "$", "resReference", ")", "{", "try", "{", "// load the application instance and reference name", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "// initial...
Registers the passed resource reference in the applications directory. @param \AppserverIo\Psr\EnterpriseBeans\Description\ResReferenceDescriptorInterface $resReference The resource reference to register @return void
[ "Registers", "the", "passed", "resource", "reference", "in", "the", "applications", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L165-L219
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.registerBeanReference
public function registerBeanReference(BeanReferenceDescriptorInterface $beanReference) { try { // load the application instance and reference name $application = $this->getApplication(); // initialize the class URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $beanReference->getRefName()); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Bean reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // catch the NamingException if the ref name is not bound yet } catch (NamingException $e) { // log a message that we've to register the bean reference now $application->getInitialContext()->getSystemLogger()->debug( sprintf('Bean reference %s has not been bound to naming directory', $uri) ); } try { // try to bind the bean by the specified bean name if ($beanName = $beanReference->getBeanName()) { // bind a reference to the class type $application->getNamingDirectory() ->bind( $uri, array(&$this, 'lookupBean'), array($beanName) ); // log a critical message that we can't bind the reference } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind bean reference %s to naming directory, because of missing source bean name', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
php
public function registerBeanReference(BeanReferenceDescriptorInterface $beanReference) { try { // load the application instance and reference name $application = $this->getApplication(); // initialize the class URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $beanReference->getRefName()); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Bean reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // catch the NamingException if the ref name is not bound yet } catch (NamingException $e) { // log a message that we've to register the bean reference now $application->getInitialContext()->getSystemLogger()->debug( sprintf('Bean reference %s has not been bound to naming directory', $uri) ); } try { // try to bind the bean by the specified bean name if ($beanName = $beanReference->getBeanName()) { // bind a reference to the class type $application->getNamingDirectory() ->bind( $uri, array(&$this, 'lookupBean'), array($beanName) ); // log a critical message that we can't bind the reference } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind bean reference %s to naming directory, because of missing source bean name', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
[ "public", "function", "registerBeanReference", "(", "BeanReferenceDescriptorInterface", "$", "beanReference", ")", "{", "try", "{", "// load the application instance and reference name", "$", "application", "=", "$", "this", "->", "getApplication", "(", ")", ";", "// init...
Registers the passed bean reference in the applications directory. @param \AppserverIo\Psr\EnterpriseBeans\Description\BeanReferenceDescriptorInterface $beanReference The bean reference to register @return void
[ "Registers", "the", "passed", "bean", "reference", "in", "the", "applications", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L228-L278
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.registerPersistenceUnitReference
public function registerPersistenceUnitReference(PersistenceUnitReferenceDescriptorInterface $persistenceUnitReference) { try { // load the application instance and reference name $application = $this->getApplication(); // initialize the persistence unit URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $persistenceUnitReference->getRefName()); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Persistence unit reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // catch the NamingException if the ref name is not bound yet } catch (NamingException $e) { // log a message that we've to register the resource reference now $application->getInitialContext()->getSystemLogger()->debug( sprintf('Persistence unit reference %s has not been bound to naming directory', $uri) ); } try { // try to use the unit name to bind the reference to if ($unitName = $persistenceUnitReference->getUnitName()) { // load the persistenc manager to bind the callback to $persistenceManager = $application->search(PersistenceContextInterface::IDENTIFIER); // create a reference to a persistence unit in the global directory $application->getNamingDirectory() ->bind( $uri, array(&$persistenceManager, 'lookupProxy'), array($unitName) ); // log a critical message that we can't bind the reference } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind persistence unit Reference %s to naming directory, because of missing unit name definition', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
php
public function registerPersistenceUnitReference(PersistenceUnitReferenceDescriptorInterface $persistenceUnitReference) { try { // load the application instance and reference name $application = $this->getApplication(); // initialize the persistence unit URI $uri = sprintf('php:global/%s/%s', $application->getUniqueName(), $persistenceUnitReference->getRefName()); // query whether the reference has already been bound to the application if ($application->getNamingDirectory()->isBound($uri)) { // log a message that the reference has already been bound $application->getInitialContext()->getSystemLogger()->debug( sprintf('Persistence unit reference %s has already been bound to naming directory', $uri) ); // return immediately return; } // catch the NamingException if the ref name is not bound yet } catch (NamingException $e) { // log a message that we've to register the resource reference now $application->getInitialContext()->getSystemLogger()->debug( sprintf('Persistence unit reference %s has not been bound to naming directory', $uri) ); } try { // try to use the unit name to bind the reference to if ($unitName = $persistenceUnitReference->getUnitName()) { // load the persistenc manager to bind the callback to $persistenceManager = $application->search(PersistenceContextInterface::IDENTIFIER); // create a reference to a persistence unit in the global directory $application->getNamingDirectory() ->bind( $uri, array(&$persistenceManager, 'lookupProxy'), array($unitName) ); // log a critical message that we can't bind the reference } else { $application->getInitialContext()->getSystemLogger()->critical( sprintf('Can\'t bind persistence unit Reference %s to naming directory, because of missing unit name definition', $uri) ); } // catch all other exceptions } catch (\Exception $e) { $application->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
[ "public", "function", "registerPersistenceUnitReference", "(", "PersistenceUnitReferenceDescriptorInterface", "$", "persistenceUnitReference", ")", "{", "try", "{", "// load the application instance and reference name", "$", "application", "=", "$", "this", "->", "getApplication"...
Registers the passed persistence unit reference in the applications directory. @param \AppserverIo\Psr\EnterpriseBeans\Description\PersistenceUnitReferenceDescriptorInterface $persistenceUnitReference The persistence unit reference to register @return void
[ "Registers", "the", "passed", "persistence", "unit", "reference", "in", "the", "applications", "directory", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L287-L339
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.lookupProxy
public function lookupProxy($lookupName) { // load the initial context instance $initialContext = $this->getInitialContext(); // query whether a request context is available if ($servletRequest = RequestHandler::getRequestContext()) { // inject the servlet request to handle SFSBs correctly $initialContext->injectServletRequest($servletRequest); } // return the proxy instance return $initialContext->lookup($lookupName); }
php
public function lookupProxy($lookupName) { // load the initial context instance $initialContext = $this->getInitialContext(); // query whether a request context is available if ($servletRequest = RequestHandler::getRequestContext()) { // inject the servlet request to handle SFSBs correctly $initialContext->injectServletRequest($servletRequest); } // return the proxy instance return $initialContext->lookup($lookupName); }
[ "public", "function", "lookupProxy", "(", "$", "lookupName", ")", "{", "// load the initial context instance", "$", "initialContext", "=", "$", "this", "->", "getInitialContext", "(", ")", ";", "// query whether a request context is available", "if", "(", "$", "servletR...
This returns a proxy to the requested session bean. If the proxy has already been instanciated for the actual request, the existing instance will be returned. @param string $lookupName The lookup name for the requested session bean @return \AppserverIo\RemoteMethodInvocation\RemoteObjectInterface The proxy instance
[ "This", "returns", "a", "proxy", "to", "the", "requested", "session", "bean", ".", "If", "the", "proxy", "has", "already", "been", "instanciated", "for", "the", "actual", "request", "the", "existing", "instance", "will", "be", "returned", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L361-L375
appserver-io/appserver
src/AppserverIo/Appserver/Core/AbstractEpbManager.php
AbstractEpbManager.lookupLocalProxy
public function lookupLocalProxy($lookupName) { // extract the session bean name from the lookup name $beanName = str_replace('/local', '', $lookupName); // load the application $application = $this->getApplication(); // load bean and object manager $beanManager = $application->search(BeanContextInterface::IDENTIFIER); $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER); // load the requested session bean $sessionBean = $application->search($beanName); // load the bean descriptor $sessionBeanDescriptor = $objectManager->getObjectDescriptors()->get(get_class($sessionBean)); // initialize the local proxy instance return new LocalProxy( $beanManager, $sessionBeanDescriptor, $sessionBean ); }
php
public function lookupLocalProxy($lookupName) { // extract the session bean name from the lookup name $beanName = str_replace('/local', '', $lookupName); // load the application $application = $this->getApplication(); // load bean and object manager $beanManager = $application->search(BeanContextInterface::IDENTIFIER); $objectManager = $application->search(ObjectManagerInterface::IDENTIFIER); // load the requested session bean $sessionBean = $application->search($beanName); // load the bean descriptor $sessionBeanDescriptor = $objectManager->getObjectDescriptors()->get(get_class($sessionBean)); // initialize the local proxy instance return new LocalProxy( $beanManager, $sessionBeanDescriptor, $sessionBean ); }
[ "public", "function", "lookupLocalProxy", "(", "$", "lookupName", ")", "{", "// extract the session bean name from the lookup name", "$", "beanName", "=", "str_replace", "(", "'/local'", ",", "''", ",", "$", "lookupName", ")", ";", "// load the application", "$", "app...
This returns a local proxy to the requested session bean. @param string $lookupName The lookup name for the requested session bean @return \AppserverIo\RemoteMethodInvocation\RemoteObjectInterface The proxy instance
[ "This", "returns", "a", "local", "proxy", "to", "the", "requested", "session", "bean", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/AbstractEpbManager.php#L384-L409
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/CacheFactories/MemcacheCacheFactory.php
MemcacheCacheFactory.get
public static function get(array $configuration = array()) { if (extension_loaded('memcache')) { $memcache = new \Memcache(); $memcache->connect($configuration[CacheKeys::HOST]); $cache = new MemcacheCache(); $cache->setMemcache($memcache); return $cache; } }
php
public static function get(array $configuration = array()) { if (extension_loaded('memcache')) { $memcache = new \Memcache(); $memcache->connect($configuration[CacheKeys::HOST]); $cache = new MemcacheCache(); $cache->setMemcache($memcache); return $cache; } }
[ "public", "static", "function", "get", "(", "array", "$", "configuration", "=", "array", "(", ")", ")", "{", "if", "(", "extension_loaded", "(", "'memcache'", ")", ")", "{", "$", "memcache", "=", "new", "\\", "Memcache", "(", ")", ";", "$", "memcache",...
Return's the new cache instance. @param array $configuration The cache configuration @return \Doctrine\Common\Cache\CacheProvider The cache instance
[ "Return", "s", "the", "new", "cache", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/CacheFactories/MemcacheCacheFactory.php#L45-L54
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/AnnotationRegistries/FileAnnotationRegistry.php
FileAnnotationRegistry.register
public function register(AnnotationRegistryConfigurationInterface $annotationRegistry) { if (is_file($filename = $annotationRegistry->getFile())) { AnnotationRegistry::registerFile($filename); } else { throw new \InvalidArgumentException(sprintf('Annotation Registry can\'t register file "%s" containing Doctrine Annotations', $filename)); } }
php
public function register(AnnotationRegistryConfigurationInterface $annotationRegistry) { if (is_file($filename = $annotationRegistry->getFile())) { AnnotationRegistry::registerFile($filename); } else { throw new \InvalidArgumentException(sprintf('Annotation Registry can\'t register file "%s" containing Doctrine Annotations', $filename)); } }
[ "public", "function", "register", "(", "AnnotationRegistryConfigurationInterface", "$", "annotationRegistry", ")", "{", "if", "(", "is_file", "(", "$", "filename", "=", "$", "annotationRegistry", "->", "getFile", "(", ")", ")", ")", "{", "AnnotationRegistry", "::"...
Register's the annotation driver for the passed configuration. @param \AppserverIo\Description\Configuration\AnnotationRegistryConfigurationInterface $annotationRegistry The configuration node @return void @throws \InvalidArgumentException Is thrown, if the file with the annotations that have to be registerd is not available
[ "Register", "s", "the", "annotation", "driver", "for", "the", "passed", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Doctrine/V2/AnnotationRegistries/FileAnnotationRegistry.php#L47-L54
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Tasks/StartupBeanTask.php
StartupBeanTask.bootstrap
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // make the application available and register the class loaders $application = $this->application; $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application); // create s simulated request/session ID whereas session equals request ID Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId); // try to load the profile logger if (isset($this->loggers[$profileLoggerKey = \AppserverIo\Logger\LoggerUtils::PROFILE])) { $this->profileLogger = $this->loggers[$profileLoggerKey]; $this->profileLogger->appendThreadContext('timer-service-executor'); } }
php
public function bootstrap() { // setup autoloader require SERVER_AUTOLOADER; // make the application available and register the class loaders $application = $this->application; $application->registerClassLoaders(); // register the applications annotation registries $application->registerAnnotationRegistries(); // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application); // create s simulated request/session ID whereas session equals request ID Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId); // try to load the profile logger if (isset($this->loggers[$profileLoggerKey = \AppserverIo\Logger\LoggerUtils::PROFILE])) { $this->profileLogger = $this->loggers[$profileLoggerKey]; $this->profileLogger->appendThreadContext('timer-service-executor'); } }
[ "public", "function", "bootstrap", "(", ")", "{", "// setup autoloader", "require", "SERVER_AUTOLOADER", ";", "// make the application available and register the class loaders", "$", "application", "=", "$", "this", "->", "application", ";", "$", "application", "->", "reg...
This method will be invoked before the while() loop starts and can be used to implement some bootstrap functionality. @return void
[ "This", "method", "will", "be", "invoked", "before", "the", "while", "()", "loop", "starts", "and", "can", "be", "used", "to", "implement", "some", "bootstrap", "functionality", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Tasks/StartupBeanTask.php#L70-L95
appserver-io/appserver
src/AppserverIo/Appserver/PersistenceContainer/Tasks/StartupBeanTask.php
StartupBeanTask.execute
public function execute() { // make the descriptor and the application instance locally available $descriptor = $this->descriptor; $application = $this->application; // if we found a singleton session bean with a startup callback if ($descriptor instanceof SingletonSessionBeanDescriptorInterface && $descriptor->isInitOnStartup()) { $application->search($descriptor->getName()); } }
php
public function execute() { // make the descriptor and the application instance locally available $descriptor = $this->descriptor; $application = $this->application; // if we found a singleton session bean with a startup callback if ($descriptor instanceof SingletonSessionBeanDescriptorInterface && $descriptor->isInitOnStartup()) { $application->search($descriptor->getName()); } }
[ "public", "function", "execute", "(", ")", "{", "// make the descriptor and the application instance locally available", "$", "descriptor", "=", "$", "this", "->", "descriptor", ";", "$", "application", "=", "$", "this", "->", "application", ";", "// if we found a singl...
This method is the threads main method that'll be invoked once and has to provide the threads business logic. @return void @see \AppserverIo\Appserver\Core\AbstractExecutorThread::execute()
[ "This", "method", "is", "the", "threads", "main", "method", "that", "ll", "be", "invoked", "once", "and", "has", "to", "provide", "the", "threads", "business", "logic", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/PersistenceContainer/Tasks/StartupBeanTask.php#L104-L115
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/ContextsNodeTrait.php
ContextsNodeTrait.getContext
public function getContext($name) { /** @var \AppserverIo\Appserver\Core\Api\Node\ContextNode $context */ foreach ($this->getContexts() as $context) { if ($context->getName() === $name) { return $context; } } }
php
public function getContext($name) { /** @var \AppserverIo\Appserver\Core\Api\Node\ContextNode $context */ foreach ($this->getContexts() as $context) { if ($context->getName() === $name) { return $context; } } }
[ "public", "function", "getContext", "(", "$", "name", ")", "{", "/** @var \\AppserverIo\\Appserver\\Core\\Api\\Node\\ContextNode $context */", "foreach", "(", "$", "this", "->", "getContexts", "(", ")", "as", "$", "context", ")", "{", "if", "(", "$", "context", "-...
Returns the context with the passed name. @param string $name The name of the requested context @return \AppserverIo\Appserver\Core\Api\Node\ContextNode|null The requested context node
[ "Returns", "the", "context", "with", "the", "passed", "name", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/ContextsNodeTrait.php#L65-L73
appserver-io/appserver
src/AppserverIo/Appserver/Core/Scanner/CronScanner.php
CronScanner.main
public function main() { // log the configured deployment directory $this->getSystemLogger()->info('Now start CRON scanner'); // load the validated and merged CRON jobs /** \AppserverIo\Appserver\Core\Api\Node\CronNodeInterface $cronNode */ $cronNodes = $this->newService('AppserverIo\Appserver\Core\Api\ScannerService')->findAll(); // execute all the registered CRON jobs while (true) { // initialize an instance with the current date/time $currentTime = new \DateTime(); // execute each of the jobs found in the configuration file /** @var \AppserverIo\Appserver\Core\Api\Node\CronNodeInterface $cronNode */ foreach ($cronNodes as $cronNode) { // execute each of the jobs found in the configuration file /** @var \AppserverIo\Appserver\Core\Api\Node\JobNodeInterface $jobNode */ foreach ($cronNode->getJobs() as $jobNode) { // load the scheduled expression from the job definition $schedule = $jobNode->getSchedule()->getNodeValue()->__toString(); // query whether the job has to be scheduled or not if (CronExpression::factory($schedule)->isDue($currentTime)) { $this->getCronJob($jobNode); } } } // sleep for the configured interval sleep($this->getInterval()); } }
php
public function main() { // log the configured deployment directory $this->getSystemLogger()->info('Now start CRON scanner'); // load the validated and merged CRON jobs /** \AppserverIo\Appserver\Core\Api\Node\CronNodeInterface $cronNode */ $cronNodes = $this->newService('AppserverIo\Appserver\Core\Api\ScannerService')->findAll(); // execute all the registered CRON jobs while (true) { // initialize an instance with the current date/time $currentTime = new \DateTime(); // execute each of the jobs found in the configuration file /** @var \AppserverIo\Appserver\Core\Api\Node\CronNodeInterface $cronNode */ foreach ($cronNodes as $cronNode) { // execute each of the jobs found in the configuration file /** @var \AppserverIo\Appserver\Core\Api\Node\JobNodeInterface $jobNode */ foreach ($cronNode->getJobs() as $jobNode) { // load the scheduled expression from the job definition $schedule = $jobNode->getSchedule()->getNodeValue()->__toString(); // query whether the job has to be scheduled or not if (CronExpression::factory($schedule)->isDue($currentTime)) { $this->getCronJob($jobNode); } } } // sleep for the configured interval sleep($this->getInterval()); } }
[ "public", "function", "main", "(", ")", "{", "// log the configured deployment directory", "$", "this", "->", "getSystemLogger", "(", ")", "->", "info", "(", "'Now start CRON scanner'", ")", ";", "// load the validated and merged CRON jobs", "/** \\AppserverIo\\Appserver\\Cor...
Start's the CRON scanner and executes the jobs configured in the systems etc/appserver/conf.d/cron.xml and in the applications META-INF/cron.xml files. @return void @see \AppserverIo\Appserver\Core\AbstractThread::main()
[ "Start", "s", "the", "CRON", "scanner", "and", "executes", "the", "jobs", "configured", "in", "the", "systems", "etc", "/", "appserver", "/", "conf", ".", "d", "/", "cron", ".", "xml", "and", "in", "the", "applications", "META", "-", "INF", "/", "cron"...
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Scanner/CronScanner.php#L96-L128
appserver-io/appserver
src/AppserverIo/Appserver/Core/Api/Node/HeadersNodeTrait.php
HeadersNodeTrait.getHeadersAsArray
public function getHeadersAsArray() { $headers = array(); foreach ($this->getHeaders() as $headerNode) { $header = array( 'type' => $headerNode->getType(), 'name' => $headerNode->getName(), 'value' => $headerNode->getValue(), 'uri' => $headerNode->getUri(), 'override' => $headerNode->getOverride(), 'append' => $headerNode->getAppend() ); $headers[$headerNode->getType()][] = $header; } return $headers; }
php
public function getHeadersAsArray() { $headers = array(); foreach ($this->getHeaders() as $headerNode) { $header = array( 'type' => $headerNode->getType(), 'name' => $headerNode->getName(), 'value' => $headerNode->getValue(), 'uri' => $headerNode->getUri(), 'override' => $headerNode->getOverride(), 'append' => $headerNode->getAppend() ); $headers[$headerNode->getType()][] = $header; } return $headers; }
[ "public", "function", "getHeadersAsArray", "(", ")", "{", "$", "headers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getHeaders", "(", ")", "as", "$", "headerNode", ")", "{", "$", "header", "=", "array", "(", "'type'", "=>", "$"...
Returns the headers as an associative array. @return array The array with the headers
[ "Returns", "the", "headers", "as", "an", "associative", "array", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Core/Api/Node/HeadersNodeTrait.php#L60-L75
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.getBaseDirectory
public function getBaseDirectory($directoryToAppend = null) { $baseDirectory = $this->getNamingDirectory()->search('php:env/baseDirectory'); if ($directoryToAppend != null) { $baseDirectory .= $directoryToAppend; } return $baseDirectory; }
php
public function getBaseDirectory($directoryToAppend = null) { $baseDirectory = $this->getNamingDirectory()->search('php:env/baseDirectory'); if ($directoryToAppend != null) { $baseDirectory .= $directoryToAppend; } return $baseDirectory; }
[ "public", "function", "getBaseDirectory", "(", "$", "directoryToAppend", "=", "null", ")", "{", "$", "baseDirectory", "=", "$", "this", "->", "getNamingDirectory", "(", ")", "->", "search", "(", "'php:env/baseDirectory'", ")", ";", "if", "(", "$", "directoryTo...
Returns the absolute path to the servers document root directory @param string $directoryToAppend The directory to append to the base directory @return string The base directory with appended dir if given
[ "Returns", "the", "absolute", "path", "to", "the", "servers", "document", "root", "directory" ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L294-L301
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.getSystemProperties
public function getSystemProperties() { // load the configuration service $service = $this->newService(ConfigurationService::class); // load the system properties $systemProperties = $service->getSystemProperties($this->getContainer()->getContainerNode()); // append the application specific properties $systemProperties->add(SystemPropertyKeys::WEBAPP, $webappPath = $this->getWebappPath()); $systemProperties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); $systemProperties->add(SystemPropertyKeys::WEBAPP_DATA, $this->getDataDir()); $systemProperties->add(SystemPropertyKeys::WEBAPP_CACHE, $this->getCacheDir()); $systemProperties->add(SystemPropertyKeys::WEBAPP_SESSION, $this->getSessionDir()); // return the system properties return $systemProperties; }
php
public function getSystemProperties() { // load the configuration service $service = $this->newService(ConfigurationService::class); // load the system properties $systemProperties = $service->getSystemProperties($this->getContainer()->getContainerNode()); // append the application specific properties $systemProperties->add(SystemPropertyKeys::WEBAPP, $webappPath = $this->getWebappPath()); $systemProperties->add(SystemPropertyKeys::WEBAPP_NAME, basename($webappPath)); $systemProperties->add(SystemPropertyKeys::WEBAPP_DATA, $this->getDataDir()); $systemProperties->add(SystemPropertyKeys::WEBAPP_CACHE, $this->getCacheDir()); $systemProperties->add(SystemPropertyKeys::WEBAPP_SESSION, $this->getSessionDir()); // return the system properties return $systemProperties; }
[ "public", "function", "getSystemProperties", "(", ")", "{", "// load the configuration service", "$", "service", "=", "$", "this", "->", "newService", "(", "ConfigurationService", "::", "class", ")", ";", "// load the system properties", "$", "systemProperties", "=", ...
Return's the system properties enriched with the application specific properties like webapp.dir etc. @return \AppserverIo\Properties\PropertiesInterface The sytem properties
[ "Return", "s", "the", "system", "properties", "enriched", "with", "the", "application", "specific", "properties", "like", "webapp", ".", "dir", "etc", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L408-L426
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.getLogger
public function getLogger($name = LoggerUtils::SYSTEM_LOGGER) { if (isset($this->loggers[$name])) { return $this->loggers[$name]; } return null; }
php
public function getLogger($name = LoggerUtils::SYSTEM_LOGGER) { if (isset($this->loggers[$name])) { return $this->loggers[$name]; } return null; }
[ "public", "function", "getLogger", "(", "$", "name", "=", "LoggerUtils", "::", "SYSTEM_LOGGER", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "loggers", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "loggers", "[", "$", ...
Return the requested logger instance, by default the application's system logger. @param string $name The name of the requested logger @return \Psr\Log\LoggerInterface|null The logger instance
[ "Return", "the", "requested", "logger", "instance", "by", "default", "the", "application", "s", "system", "logger", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L573-L579
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.addClassLoader
public function addClassLoader(ClassLoaderInterface $classLoader, ClassLoaderNodeInterface $configuration) { // bind the class loader callback to the naming directory => the application itself $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getClassLoader'), array($configuration->getName())); // add the class loader instance to the application $this->classLoaders[$configuration->getName()] = $classLoader; }
php
public function addClassLoader(ClassLoaderInterface $classLoader, ClassLoaderNodeInterface $configuration) { // bind the class loader callback to the naming directory => the application itself $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getClassLoader'), array($configuration->getName())); // add the class loader instance to the application $this->classLoaders[$configuration->getName()] = $classLoader; }
[ "public", "function", "addClassLoader", "(", "ClassLoaderInterface", "$", "classLoader", ",", "ClassLoaderNodeInterface", "$", "configuration", ")", "{", "// bind the class loader callback to the naming directory => the application itself", "$", "this", "->", "getNamingDirectory", ...
Injects an additional class loader. @param \AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface $classLoader A class loader to put on the class loader stack @param \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNodeInterface $configuration The class loader's configuration @return void
[ "Injects", "an", "additional", "class", "loader", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L589-L597
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.addManager
public function addManager(ManagerInterface $manager, ManagerNodeInterface $configuration) { // bind the manager callback to the naming directory => the application itself $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getManager'), array($configuration->getName())); // add the manager instance to the application $this->managers[$configuration->getName()] = $manager; }
php
public function addManager(ManagerInterface $manager, ManagerNodeInterface $configuration) { // bind the manager callback to the naming directory => the application itself $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getManager'), array($configuration->getName())); // add the manager instance to the application $this->managers[$configuration->getName()] = $manager; }
[ "public", "function", "addManager", "(", "ManagerInterface", "$", "manager", ",", "ManagerNodeInterface", "$", "configuration", ")", "{", "// bind the manager callback to the naming directory => the application itself", "$", "this", "->", "getNamingDirectory", "(", ")", "->",...
Injects manager instance and the configuration. @param \AppserverIo\Psr\Application\ManagerInterface $manager A manager instance @param \AppserverIo\Appserver\Core\Api\Node\ManagerNodeInterface $configuration The managers configuration @return void
[ "Injects", "manager", "instance", "and", "the", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L607-L615
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.addProvisioner
public function addProvisioner(ProvisionerInterface $provisioner, ProvisionerConfigurationInterface $configuration) { // bind the provisioner callback to the naming directory => the application itself $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getProvisioner'), array($configuration->getName())); // add the provisioner instance to the application $this->provisioners[$configuration->getName()] = $provisioner; }
php
public function addProvisioner(ProvisionerInterface $provisioner, ProvisionerConfigurationInterface $configuration) { // bind the provisioner callback to the naming directory => the application itself $this->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getProvisioner'), array($configuration->getName())); // add the provisioner instance to the application $this->provisioners[$configuration->getName()] = $provisioner; }
[ "public", "function", "addProvisioner", "(", "ProvisionerInterface", "$", "provisioner", ",", "ProvisionerConfigurationInterface", "$", "configuration", ")", "{", "// bind the provisioner callback to the naming directory => the application itself", "$", "this", "->", "getNamingDire...
Injects the provisioner instance and the configuration. @param \AppserverIo\Psr\Application\ProvisionerInterface $provisioner A provisioner instance @param \AppserverIo\Provisioning\Configuration\ProvisionerConfigurationInterface $configuration The provisioner configuration @return void
[ "Injects", "the", "provisioner", "instance", "and", "the", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L625-L633
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.addLogger
public function addLogger(LoggerInterface $logger, LoggerNodeInterface $configuration) { // bind the logger callback to the naming directory => the application itself $this->getNamingDirectory()->bind($name = sprintf('php:global/log/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getLogger'), array($configuration->getName())); // alos bind a reference from the application to the logger scope (to make DI more comfortable) $this->getNamingDirectory()->bindReference(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), $name); // add the logger instance to the application $this->loggers[$configuration->getName()] = $logger; }
php
public function addLogger(LoggerInterface $logger, LoggerNodeInterface $configuration) { // bind the logger callback to the naming directory => the application itself $this->getNamingDirectory()->bind($name = sprintf('php:global/log/%s/%s', $this->getUniqueName(), $configuration->getName()), array(&$this, 'getLogger'), array($configuration->getName())); // alos bind a reference from the application to the logger scope (to make DI more comfortable) $this->getNamingDirectory()->bindReference(sprintf('php:global/%s/%s', $this->getUniqueName(), $configuration->getName()), $name); // add the logger instance to the application $this->loggers[$configuration->getName()] = $logger; }
[ "public", "function", "addLogger", "(", "LoggerInterface", "$", "logger", ",", "LoggerNodeInterface", "$", "configuration", ")", "{", "// bind the logger callback to the naming directory => the application itself", "$", "this", "->", "getNamingDirectory", "(", ")", "->", "b...
Injects the logger instance and the configuration. @param \Psr\Log\LoggerInterface $logger A provisioner instance @param \AppserverIo\Appserver\Core\Api\Node\LoggerNodeInterface $configuration The provisioner configuration @return void
[ "Injects", "the", "logger", "instance", "and", "the", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L643-L654
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.prepare
public function prepare(ContainerInterface $container, ContextNode $contextNode) { // set the application configuration $this->contextNode = $contextNode; // load the unique application name + the naming directory $uniqueName = $this->getUniqueName(); $namingDirectory = $this->getNamingDirectory(); // create subdirectories for the application and the logger $namingDirectory->createSubdirectory(sprintf('php:global/%s', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/log/%s', $uniqueName)); // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to $namingDirectory->createSubdirectory(sprintf('php:env/%s', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env/persistence', $uniqueName)); // bind the directory containing the applications $namingDirectory->bind(sprintf('php:env/%s/appBase', $uniqueName), $container->getAppBase()); // prepare the application specific directories $webappPath = sprintf('%s/%s', $this->getAppBase(), $this->getName()); $tmpDirectory = sprintf('%s/%s', $container->getTmpDir(), $this->getName()); $dataDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::DATA), '/')); $cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::CACHE), '/')); $sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::SESSION), '/')); // prepare the application specific environment variables $namingDirectory->bind(sprintf('php:env/%s/webappPath', $uniqueName), $webappPath); $namingDirectory->bind(sprintf('php:env/%s/tmpDirectory', $uniqueName), $tmpDirectory); $namingDirectory->bind(sprintf('php:env/%s/dataDirectory', $uniqueName), $dataDirectory); $namingDirectory->bind(sprintf('php:env/%s/cacheDirectory', $uniqueName), $cacheDirectory); $namingDirectory->bind(sprintf('php:env/%s/sessionDirectory', $uniqueName), $sessionDirectory); // bind the interface as reference to the application $namingDirectory->bind($uri = sprintf('php:global/%s/%s', $uniqueName, ApplicationInterface::IDENTIFIER), $this); // also bind an alias to the application /** @deprecated Also bind an alias to the application to ensure backwards compatibility */ $namingDirectory->bindReference(sprintf('php:global/%s/Application', $uniqueName), $uri); }
php
public function prepare(ContainerInterface $container, ContextNode $contextNode) { // set the application configuration $this->contextNode = $contextNode; // load the unique application name + the naming directory $uniqueName = $this->getUniqueName(); $namingDirectory = $this->getNamingDirectory(); // create subdirectories for the application and the logger $namingDirectory->createSubdirectory(sprintf('php:global/%s', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/log/%s', $uniqueName)); // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to $namingDirectory->createSubdirectory(sprintf('php:env/%s', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env/persistence', $uniqueName)); // bind the directory containing the applications $namingDirectory->bind(sprintf('php:env/%s/appBase', $uniqueName), $container->getAppBase()); // prepare the application specific directories $webappPath = sprintf('%s/%s', $this->getAppBase(), $this->getName()); $tmpDirectory = sprintf('%s/%s', $container->getTmpDir(), $this->getName()); $dataDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::DATA), '/')); $cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::CACHE), '/')); $sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::SESSION), '/')); // prepare the application specific environment variables $namingDirectory->bind(sprintf('php:env/%s/webappPath', $uniqueName), $webappPath); $namingDirectory->bind(sprintf('php:env/%s/tmpDirectory', $uniqueName), $tmpDirectory); $namingDirectory->bind(sprintf('php:env/%s/dataDirectory', $uniqueName), $dataDirectory); $namingDirectory->bind(sprintf('php:env/%s/cacheDirectory', $uniqueName), $cacheDirectory); $namingDirectory->bind(sprintf('php:env/%s/sessionDirectory', $uniqueName), $sessionDirectory); // bind the interface as reference to the application $namingDirectory->bind($uri = sprintf('php:global/%s/%s', $uniqueName, ApplicationInterface::IDENTIFIER), $this); // also bind an alias to the application /** @deprecated Also bind an alias to the application to ensure backwards compatibility */ $namingDirectory->bindReference(sprintf('php:global/%s/Application', $uniqueName), $uri); }
[ "public", "function", "prepare", "(", "ContainerInterface", "$", "container", ",", "ContextNode", "$", "contextNode", ")", "{", "// set the application configuration", "$", "this", "->", "contextNode", "=", "$", "contextNode", ";", "// load the unique application name + t...
Prepares the application with the specific data found in the passed context node. @param \AppserverIo\Psr\ApplicationServer\ContainerInterface $container The container instance bind the application to @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $contextNode The application configuration @return void
[ "Prepares", "the", "application", "with", "the", "specific", "data", "found", "in", "the", "passed", "context", "node", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L665-L707
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.getEnvironmentAwareGlobPattern
public function getEnvironmentAwareGlobPattern($fileGlob, $flags = 0, $fileExtension = 'xml') { return AppEnvironmentHelper::getEnvironmentAwareGlobPattern($this->getWebappPath(), $fileGlob, $flags, $fileExtension); }
php
public function getEnvironmentAwareGlobPattern($fileGlob, $flags = 0, $fileExtension = 'xml') { return AppEnvironmentHelper::getEnvironmentAwareGlobPattern($this->getWebappPath(), $fileGlob, $flags, $fileExtension); }
[ "public", "function", "getEnvironmentAwareGlobPattern", "(", "$", "fileGlob", ",", "$", "flags", "=", "0", ",", "$", "fileExtension", "=", "'xml'", ")", "{", "return", "AppEnvironmentHelper", "::", "getEnvironmentAwareGlobPattern", "(", "$", "this", "->", "getWeba...
Will take a segmented path to a file (which might contain glob type wildcards) and return it fixed to the currently active environment modifier, e. g. ```php AppEnvironmentHelper::getEnvironmentAwareFilePath('webapps/example', 'META-INF/*-ds') => 'webapps/example/META-INF/*-ds.dev.xml' ``` @param string $fileGlob The intermediate path (or glob pattern) from app base path to file extension @param integer $flags The flags passed to the glob function @param string $fileExtension The extension of the file, will default to 'xml' @return string @see \AppserverIo\Appserver\Core\Utilities\AppEnvironmentHelper::getEnvironmentAwareGlobPattern()
[ "Will", "take", "a", "segmented", "path", "to", "a", "file", "(", "which", "might", "contain", "glob", "type", "wildcards", ")", "and", "return", "it", "fixed", "to", "the", "currently", "active", "environment", "modifier", "e", ".", "g", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L724-L727
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.unload
public function unload() { // load the unique application name + the naming directory $uniqueName = $this->getUniqueName(); $namingDirectory = $this->getNamingDirectory(); // unbind the environment references of the application $namingDirectory->unbind(sprintf('php:env/%s/webappPath', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/tmpDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/dataDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/cacheDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/sessionDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s', $uniqueName)); // unbind the global references of the application $namingDirectory->unbind(sprintf('php:global/%s/env/ApplicationInterface', $uniqueName)); $namingDirectory->unbind(sprintf('php:global/%s/env/persistence', $uniqueName)); $namingDirectory->unbind(sprintf('php:global/%s/env', $uniqueName)); $namingDirectory->unbind(sprintf('php:global/%s', $uniqueName)); }
php
public function unload() { // load the unique application name + the naming directory $uniqueName = $this->getUniqueName(); $namingDirectory = $this->getNamingDirectory(); // unbind the environment references of the application $namingDirectory->unbind(sprintf('php:env/%s/webappPath', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/tmpDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/dataDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/cacheDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s/sessionDirectory', $uniqueName)); $namingDirectory->unbind(sprintf('php:env/%s', $uniqueName)); // unbind the global references of the application $namingDirectory->unbind(sprintf('php:global/%s/env/ApplicationInterface', $uniqueName)); $namingDirectory->unbind(sprintf('php:global/%s/env/persistence', $uniqueName)); $namingDirectory->unbind(sprintf('php:global/%s/env', $uniqueName)); $namingDirectory->unbind(sprintf('php:global/%s', $uniqueName)); }
[ "public", "function", "unload", "(", ")", "{", "// load the unique application name + the naming directory", "$", "uniqueName", "=", "$", "this", "->", "getUniqueName", "(", ")", ";", "$", "namingDirectory", "=", "$", "this", "->", "getNamingDirectory", "(", ")", ...
Cleanup the naming directory from the application entries. @return void
[ "Cleanup", "the", "naming", "directory", "from", "the", "application", "entries", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L734-L754
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.isConnected
public function isConnected() { return $this->synchronized(function ($self) { return $self->applicationState->equals(ApplicationStateKeys::get(ApplicationStateKeys::INITIALIZATION_SUCCESSFUL)); }, $this); }
php
public function isConnected() { return $this->synchronized(function ($self) { return $self->applicationState->equals(ApplicationStateKeys::get(ApplicationStateKeys::INITIALIZATION_SUCCESSFUL)); }, $this); }
[ "public", "function", "isConnected", "(", ")", "{", "return", "$", "this", "->", "synchronized", "(", "function", "(", "$", "self", ")", "{", "return", "$", "self", "->", "applicationState", "->", "equals", "(", "ApplicationStateKeys", "::", "get", "(", "A...
TRUE if the application has been connected, else FALSE. @return boolean Returns TRUE if the application has been connected, else FALSE
[ "TRUE", "if", "the", "application", "has", "been", "connected", "else", "FALSE", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L774-L779
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.registerClassLoaders
public function registerClassLoaders() { // initialize the registered managers /** @var \AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface $classLoader */ foreach ($this->getClassLoaders() as $classLoader) { // log the class loader we want to initialize $this->getInitialContext()->getSystemLogger()->debug( sprintf('Now register classloader %s for application %s', get_class($classLoader), $this->getName()) ); // register the class loader instance $classLoader->register(true, true); // log the class loader we've successfully registered $this->getInitialContext()->getSystemLogger()->debug( sprintf('Successfully registered classloader %s for application %s', get_class($classLoader), $this->getName()) ); } }
php
public function registerClassLoaders() { // initialize the registered managers /** @var \AppserverIo\Appserver\Core\Interfaces\ClassLoaderInterface $classLoader */ foreach ($this->getClassLoaders() as $classLoader) { // log the class loader we want to initialize $this->getInitialContext()->getSystemLogger()->debug( sprintf('Now register classloader %s for application %s', get_class($classLoader), $this->getName()) ); // register the class loader instance $classLoader->register(true, true); // log the class loader we've successfully registered $this->getInitialContext()->getSystemLogger()->debug( sprintf('Successfully registered classloader %s for application %s', get_class($classLoader), $this->getName()) ); } }
[ "public", "function", "registerClassLoaders", "(", ")", "{", "// initialize the registered managers", "/** @var \\AppserverIo\\Appserver\\Core\\Interfaces\\ClassLoaderInterface $classLoader */", "foreach", "(", "$", "this", "->", "getClassLoaders", "(", ")", "as", "$", "classLoad...
Registers all class loaders injected to the applications in the opposite order as they have been injected. @return void
[ "Registers", "all", "class", "loaders", "injected", "to", "the", "applications", "in", "the", "opposite", "order", "as", "they", "have", "been", "injected", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L787-L806
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.registerAnnotationRegistries
public function registerAnnotationRegistries() { // reset the annotation registry AnnotationRegistry::reset(); // register additional annotation libraries foreach ($this->getContextNode()->getAnnotationRegistries() as $annotationRegistry) { // register the annotations specified by the annotation registery $annotationRegistryType = $annotationRegistry->getType(); $registry = new $annotationRegistryType(); $registry->register($annotationRegistry); } }
php
public function registerAnnotationRegistries() { // reset the annotation registry AnnotationRegistry::reset(); // register additional annotation libraries foreach ($this->getContextNode()->getAnnotationRegistries() as $annotationRegistry) { // register the annotations specified by the annotation registery $annotationRegistryType = $annotationRegistry->getType(); $registry = new $annotationRegistryType(); $registry->register($annotationRegistry); } }
[ "public", "function", "registerAnnotationRegistries", "(", ")", "{", "// reset the annotation registry", "AnnotationRegistry", "::", "reset", "(", ")", ";", "// register additional annotation libraries", "foreach", "(", "$", "this", "->", "getContextNode", "(", ")", "->",...
Registers additional annotation registries defined in the configuration. @return void
[ "Registers", "additional", "annotation", "registries", "defined", "in", "the", "configuration", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L813-L826
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.registerEnvironment
public function registerEnvironment() { // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $this); // create s simulated request/session ID whereas session equals request ID Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId); }
php
public function registerEnvironment() { // add the application instance to the environment Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $this); // create s simulated request/session ID whereas session equals request ID Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString()); Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId); }
[ "public", "function", "registerEnvironment", "(", ")", "{", "// add the application instance to the environment", "Environment", "::", "singleton", "(", ")", "->", "setAttribute", "(", "EnvironmentKeys", "::", "APPLICATION", ",", "$", "this", ")", ";", "// create s simu...
Registers the the application in the environment. @return void
[ "Registers", "the", "the", "application", "in", "the", "environment", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L833-L842
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.provision
public function provision() { // invoke the provisioners and provision the application /** @var \AppserverIo\Psr\Application\ProvisionerInterface $provisioner */ foreach ($this->getProvisioners() as $provisioner) { // log the manager we want to initialize \debug(sprintf('Now invoking provisioner %s for application %s', get_class($provisioner), $this->getName())); // execute the provisioning steps $provisioner->provision($this); // log the manager we've successfully registered \debug(sprintf('Successfully invoked provisioner %s for application %s', get_class($provisioner), $this->getName())); } }
php
public function provision() { // invoke the provisioners and provision the application /** @var \AppserverIo\Psr\Application\ProvisionerInterface $provisioner */ foreach ($this->getProvisioners() as $provisioner) { // log the manager we want to initialize \debug(sprintf('Now invoking provisioner %s for application %s', get_class($provisioner), $this->getName())); // execute the provisioning steps $provisioner->provision($this); // log the manager we've successfully registered \debug(sprintf('Successfully invoked provisioner %s for application %s', get_class($provisioner), $this->getName())); } }
[ "public", "function", "provision", "(", ")", "{", "// invoke the provisioners and provision the application", "/** @var \\AppserverIo\\Psr\\Application\\ProvisionerInterface $provisioner */", "foreach", "(", "$", "this", "->", "getProvisioners", "(", ")", "as", "$", "provisioner"...
Provisions the initialized application. @return void
[ "Provisions", "the", "initialized", "application", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L849-L864
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.initializeManagers
public function initializeManagers() { // initialize the registered managers /** @var \AppserverIo\Psr\Application\ManagerInterface $manager */ foreach ($this->getManagers() as $manager) { // log the manager we want to initialize \debug(sprintf('Now register manager %s for application %s', get_class($manager), $this->getName())); // initialize the manager instance $manager->initialize($this); // log the manager we've successfully registered \debug(sprintf('Now registered manager %s for application %s', get_class($manager), $this->getName())); } }
php
public function initializeManagers() { // initialize the registered managers /** @var \AppserverIo\Psr\Application\ManagerInterface $manager */ foreach ($this->getManagers() as $manager) { // log the manager we want to initialize \debug(sprintf('Now register manager %s for application %s', get_class($manager), $this->getName())); // initialize the manager instance $manager->initialize($this); // log the manager we've successfully registered \debug(sprintf('Now registered manager %s for application %s', get_class($manager), $this->getName())); } }
[ "public", "function", "initializeManagers", "(", ")", "{", "// initialize the registered managers", "/** @var \\AppserverIo\\Psr\\Application\\ManagerInterface $manager */", "foreach", "(", "$", "this", "->", "getManagers", "(", ")", "as", "$", "manager", ")", "{", "// log ...
Registers all managers in the application. @return void
[ "Registers", "all", "managers", "in", "the", "application", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L871-L886
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.postStartupManagers
public function postStartupManagers() { // initialize the registered managers /** @var \AppserverIo\Psr\Application\ManagerInterface $manager */ foreach ($this->getManagers() as $manager) { // log the manager we want to invoke the postStartup() lifecycle callback \debug(sprintf('Now invoke the postStartup() lifecycle callback of manager %s for application %s', get_class($manager), $this->getName())); // invoke the manager's postStartup() lifecycle callback $manager->postStartup($this); // log the manager we've successfully invoked the postStartup() lifecycle callback \debug(sprintf('Successfully invoked the postStartup() lifecycle callback of manager %s for application %s', get_class($manager), $this->getName())); } }
php
public function postStartupManagers() { // initialize the registered managers /** @var \AppserverIo\Psr\Application\ManagerInterface $manager */ foreach ($this->getManagers() as $manager) { // log the manager we want to invoke the postStartup() lifecycle callback \debug(sprintf('Now invoke the postStartup() lifecycle callback of manager %s for application %s', get_class($manager), $this->getName())); // invoke the manager's postStartup() lifecycle callback $manager->postStartup($this); // log the manager we've successfully invoked the postStartup() lifecycle callback \debug(sprintf('Successfully invoked the postStartup() lifecycle callback of manager %s for application %s', get_class($manager), $this->getName())); } }
[ "public", "function", "postStartupManagers", "(", ")", "{", "// initialize the registered managers", "/** @var \\AppserverIo\\Psr\\Application\\ManagerInterface $manager */", "foreach", "(", "$", "this", "->", "getManagers", "(", ")", "as", "$", "manager", ")", "{", "// log...
Invokes the postStartup() method lifecycle callback of the registered managers. @return void
[ "Invokes", "the", "postStartup", "()", "method", "lifecycle", "callback", "of", "the", "registered", "managers", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L893-L908
appserver-io/appserver
src/AppserverIo/Appserver/Application/Application.php
Application.stop
public function stop() { // start application shutdown $this->synchronized(function ($self) { $self->applicationState = ApplicationStateKeys::get(ApplicationStateKeys::HALT); }, $this); do { // log a message that we'll wait till application has been shutdown \info(sprintf('Wait for application %s to be shutdown', $this->getName())); // query whether application state key is SHUTDOWN or not $waitForShutdown = $this->synchronized(function ($self) { return $self->applicationState->notEquals(ApplicationStateKeys::get(ApplicationStateKeys::SHUTDOWN)); }, $this); // wait one second more sleep(1); } while ($waitForShutdown); }
php
public function stop() { // start application shutdown $this->synchronized(function ($self) { $self->applicationState = ApplicationStateKeys::get(ApplicationStateKeys::HALT); }, $this); do { // log a message that we'll wait till application has been shutdown \info(sprintf('Wait for application %s to be shutdown', $this->getName())); // query whether application state key is SHUTDOWN or not $waitForShutdown = $this->synchronized(function ($self) { return $self->applicationState->notEquals(ApplicationStateKeys::get(ApplicationStateKeys::SHUTDOWN)); }, $this); // wait one second more sleep(1); } while ($waitForShutdown); }
[ "public", "function", "stop", "(", ")", "{", "// start application shutdown", "$", "this", "->", "synchronized", "(", "function", "(", "$", "self", ")", "{", "$", "self", "->", "applicationState", "=", "ApplicationStateKeys", "::", "get", "(", "ApplicationStateK...
Stops the application instance. @return void
[ "Stops", "the", "application", "instance", "." ]
train
https://github.com/appserver-io/appserver/blob/2a5be730158b1fe2e60586665d5656d46c82ba73/src/AppserverIo/Appserver/Application/Application.php#L915-L936