_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q243700 | DC_Table.move | validation | public function move()
{
// Proceed only if all mandatory variables are set
if ($this->intId && Input::get('sid') && (!$GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['root'] || !\in_array($this->intId, $this->root)))
{
$objRow = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=? OR id=?")
->limit(2)
->execute($this->intId, Input::get('sid'));
$row = $objRow->fetchAllAssoc();
if ($row[0]['pid'] == $row[1]['pid'])
{
$this->Database->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->execute($row[0]['sorting'], $row[1]['id']);
$this->Database->prepare("UPDATE " . $this->strTable . " SET sorting=? WHERE id=?")
->execute($row[1]['sorting'], $row[0]['id']);
// Invalidate cache tags
$this->invalidateCacheTags($this);
}
}
$this->redirect($this->getReferer());
} | php | {
"resource": ""
} |
q243701 | DC_Table.paginationMenu | validation | protected function paginationMenu()
{
/** @var AttributeBagInterface $objSessionBag */
$objSessionBag = System::getContainer()->get('session')->getBag('contao_backend');
$session = $objSessionBag->all();
$filter = ($GLOBALS['TL_DCA'][$this->strTable]['list']['sorting']['mode'] == 4) ? $this->strTable.'_'.CURRENT_ID : $this->strTable;
list($offset, $limit) = explode(',', $this->limit);
// Set the limit filter based on the page number
if (isset($_GET['lp']))
{
$lp = (int) Input::get('lp') - 1;
if ($lp >= 0 && $lp < ceil($this->total / $limit))
{
$session['filter'][$filter]['limit'] = ($lp * $limit) . ',' . $limit;
$objSessionBag->replace($session);
}
$this->redirect(preg_replace('/&(amp;)?lp=[^&]+/i', '', Environment::get('request')));
}
if ($limit) // see #6923
{
Input::setGet('lp', $offset / $limit + 1);
}
$objPagination = new Pagination($this->total, $limit, 7, 'lp', new BackendTemplate('be_pagination'), true);
return $objPagination->generate();
} | php | {
"resource": ""
} |
q243702 | Configuration.canonicalize | validation | private function canonicalize(string $value): string
{
$resolved = [];
$chunks = preg_split('#([\\\\/]+)#', $value, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
for ($i = 0, $c = \count($chunks); $i < $c; ++$i) {
if ('.' === $chunks[$i]) {
++$i;
continue;
}
// Reduce multiple slashes to one
if ('/' === $chunks[$i][0]) {
$resolved[] = '/';
continue;
}
// Reduce multiple backslashes to one
if ('\\' === $chunks[$i][0]) {
$resolved[] = '\\';
continue;
}
if ('..' === $chunks[$i]) {
++$i;
array_pop($resolved);
array_pop($resolved);
continue;
}
$resolved[] = $chunks[$i];
}
return rtrim(implode('', $resolved), '\/');
} | php | {
"resource": ""
} |
q243703 | DropZone.generateMarkup | validation | public function generateMarkup()
{
// Maximum file size in MB
$intMaxSize = round(static::getMaxUploadSize() / 1024 / 1024);
// String of accepted file extensions
$strAccepted = implode(',', array_map(function ($a) { return '.' . $a; }, StringUtil::trimsplit(',', strtolower(Config::get('uploadTypes')))));
// Add the scripts
$GLOBALS['TL_CSS'][] = 'assets/dropzone/css/dropzone.min.css';
$GLOBALS['TL_JAVASCRIPT'][] = 'assets/dropzone/js/dropzone.min.js';
// Generate the markup
$return = '
<input type="hidden" name="action" value="fileupload">
<div class="fallback">
<input type="file" name="' . $this->strName . '[]" class="tl_upload_field" onfocus="Backend.getScrollOffset()" multiple>
</div>
<div class="dropzone">
<div class="dz-default dz-message">
<span>' . $GLOBALS['TL_LANG']['tl_files']['dropzone'] . '</span>
</div>
<span class="dropzone-previews"></span>
</div>
<script>
Dropzone.autoDiscover = false;
window.addEvent("domready", function() {
new Dropzone("#tl_files", {
paramName: "' . $this->strName . '",
maxFilesize: ' . $intMaxSize . ',
acceptedFiles: "' . $strAccepted . '",
timeout: 0,
previewsContainer: ".dropzone-previews",
clickable: ".dropzone",
dictFileTooBig: ' . json_encode($GLOBALS['TL_LANG']['tl_files']['dropzoneFileTooBig']) . ',
dictInvalidFileType: ' . json_encode($GLOBALS['TL_LANG']['tl_files']['dropzoneInvalidType']) . '
}).on("addedfile", function() {
$$(".dz-message").setStyle("display", "none");
}).on("success", function(file, message) {
if (!message) return;
var container = $("tl_message");
if (!container) {
container = new Element("div", {
"id": "tl_message",
"class": "tl_message"
}).inject($("tl_buttons"), "before");
}
container.appendHTML(message);
});
$$("div.tl_formbody_submit").setStyle("display", "none");
});
</script>';
if (isset($GLOBALS['TL_LANG']['tl_files']['fileupload'][1]))
{
$return .= '
<p class="tl_help tl_tip">' . sprintf($GLOBALS['TL_LANG']['tl_files']['fileupload'][1], System::getReadableSize(static::getMaxUploadSize()), Config::get('gdMaxImgWidth') . 'x' . Config::get('gdMaxImgHeight')) . '</p>';
}
return $return;
} | php | {
"resource": ""
} |
q243704 | NewsletterModel.findSentByPid | validation | public static function findSentByPid($intPid, array $arrOptions=array())
{
$t = static::$strTable;
$arrColumns = array("$t.pid=?");
if (!static::isPreviewMode($arrOptions))
{
$arrColumns[] = "$t.sent=1";
}
if (!isset($arrOptions['order']))
{
$arrOptions['order'] = "$t.date DESC";
}
return static::findBy($arrColumns, $intPid, $arrOptions);
} | php | {
"resource": ""
} |
q243705 | NewsletterModel.findSentByPids | validation | public static function findSentByPids($arrPids, array $arrOptions=array())
{
if (empty($arrPids) || !\is_array($arrPids))
{
return null;
}
$t = static::$strTable;
$arrColumns = array("$t.pid IN(" . implode(',', array_map('\intval', $arrPids)) . ")");
if (!static::isPreviewMode($arrOptions))
{
$arrColumns[] = "$t.sent=1";
}
if (!isset($arrOptions['order']))
{
$arrOptions['order'] = "$t.date DESC";
}
return static::findBy($arrColumns, null, $arrOptions);
} | php | {
"resource": ""
} |
q243706 | tl_faq.checkPermission | validation | public function checkPermission()
{
$bundles = Contao\System::getContainer()->getParameter('kernel.bundles');
// HOOK: comments extension required
if (!isset($bundles['ContaoCommentsBundle']))
{
$key = array_search('allowComments', $GLOBALS['TL_DCA']['tl_faq']['list']['sorting']['headerFields']);
unset($GLOBALS['TL_DCA']['tl_faq']['list']['sorting']['headerFields'][$key]);
}
} | php | {
"resource": ""
} |
q243707 | BackendMain.welcomeScreen | validation | protected function welcomeScreen()
{
System::loadLanguageFile('explain');
$objTemplate = new BackendTemplate('be_welcome');
$objTemplate->messages = Message::generateUnwrapped() . Backend::getSystemMessages();
$objTemplate->loginMsg = $GLOBALS['TL_LANG']['MSC']['firstLogin'];
// Add the login message
if ($this->User->lastLogin > 0)
{
$formatter = new DateTimeFormatter(System::getContainer()->get('translator'));
$diff = $formatter->formatDiff(new \DateTime(date('Y-m-d H:i:s', $this->User->lastLogin)), new \DateTime());
$objTemplate->loginMsg = sprintf(
$GLOBALS['TL_LANG']['MSC']['lastLogin'][1],
'<time title="' . Date::parse(Config::get('datimFormat'), $this->User->lastLogin) . '">' . $diff . '</time>'
);
}
// Add the versions overview
Versions::addToTemplate($objTemplate);
$objTemplate->showDifferences = StringUtil::specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['showDifferences']));
$objTemplate->recordOfTable = StringUtil::specialchars(str_replace("'", "\\'", $GLOBALS['TL_LANG']['MSC']['recordOfTable']));
$objTemplate->systemMessages = $GLOBALS['TL_LANG']['MSC']['systemMessages'];
$objTemplate->shortcuts = $GLOBALS['TL_LANG']['MSC']['shortcuts'][0];
$objTemplate->shortcutsLink = $GLOBALS['TL_LANG']['MSC']['shortcuts'][1];
$objTemplate->editElement = StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['editElement']);
return $objTemplate->parse();
} | php | {
"resource": ""
} |
q243708 | BackendMain.setImpersonatedLogout | validation | private function setImpersonatedLogout()
{
$token = System::getContainer()->get('security.token_storage')->getToken();
if (!$token instanceof TokenInterface)
{
return;
}
$impersonatorUser = null;
foreach ($token->getRoles() as $role)
{
if ($role instanceof SwitchUserRole)
{
$impersonatorUser = $role->getSource()->getUsername();
break;
}
}
if (!$impersonatorUser)
{
return;
}
$request = System::getContainer()->get('request_stack')->getCurrentRequest();
if ($request === null)
{
throw new \RuntimeException('The request stack did not contain a request');
}
$firewallMap = System::getContainer()->get('security.firewall.map');
// Generate the "exit impersonation" path from the current request
if (($firewallConfig = $firewallMap->getFirewallConfig($request)) === null || ($switchUserConfig = $firewallConfig->getSwitchUser()) === null)
{
return;
}
// Take the use back to the "users" module
$arrParams = array('do' => 'user', urlencode($switchUserConfig['parameter']) => SwitchUserListener::EXIT_VALUE);
$this->Template->logout = sprintf($GLOBALS['TL_LANG']['MSC']['switchBT'], $impersonatorUser);
$this->Template->logoutLink = System::getContainer()->get('router')->generate('contao_backend', $arrParams);
} | php | {
"resource": ""
} |
q243709 | ValidCharacters.getOptions | validation | public function getOptions(): array
{
$options = [];
foreach (self::DEFAULT_OPTIONS as $option => $label) {
$options[$option] = $this->translator->trans('MSC.validCharacters.'.$label, [], 'contao_default');
}
$event = new SlugValidCharactersEvent($options);
$this->eventDispatcher->dispatch(ContaoCoreEvents::SLUG_VALID_CHARACTERS, $event);
return $event->getOptions();
} | php | {
"resource": ""
} |
q243710 | NativeDocumentMapper.mapContentBlock | validation | public function mapContentBlock(Content $content)
{
$contentInfo = $content->versionInfo->contentInfo;
$locations = $this->locationHandler->loadLocationsByContent($contentInfo->id);
$blockFields = $this->getBlockFields($content);
$contentFields = $this->getContentFields($content);
$documents = [];
$locationFieldsMap = [];
foreach ($locations as $location) {
$locationFieldsMap[$location->id] = $this->getLocationFields($location);
}
foreach (array_keys($content->versionInfo->names) as $languageCode) {
$blockTranslationFields = $this->getBlockTranslationFields(
$content,
$languageCode
);
$translationLocationDocuments = array();
foreach ($locations as $location) {
$translationLocationDocuments[] = new Document(
array(
'id' => $this->generateLocationDocumentId($location->id, $languageCode),
'fields' => array_merge(
$blockFields,
$locationFieldsMap[$location->id],
$blockTranslationFields
),
)
);
}
$isMainTranslation = ($contentInfo->mainLanguageCode === $languageCode);
$alwaysAvailable = ($isMainTranslation && $contentInfo->alwaysAvailable);
$contentTranslationFields = $this->getContentTranslationFields(
$content,
$languageCode
);
$documents[] = new Document(
array(
'id' => $this->generateContentDocumentId(
$contentInfo->id,
$languageCode
),
'languageCode' => $languageCode,
'alwaysAvailable' => $alwaysAvailable,
'isMainTranslation' => $isMainTranslation,
'fields' => array_merge(
$blockFields,
$contentFields,
$blockTranslationFields,
$contentTranslationFields
),
'documents' => $translationLocationDocuments,
)
);
}
return $documents;
} | php | {
"resource": ""
} |
q243711 | IndexingDepthProvider.getMaxDepthForContent | validation | public function getMaxDepthForContent(ContentType $contentType): int
{
if (isset($this->contentTypeMap[$contentType->identifier])) {
return $this->contentTypeMap[$contentType->identifier];
}
return $this->defaultIndexingDepth;
} | php | {
"resource": ""
} |
q243712 | Handler.findContent | validation | public function findContent(Query $query, array $languageFilter = array())
{
$query = clone $query;
$query->filter = $query->filter ?: new Criterion\MatchAll();
$query->query = $query->query ?: new Criterion\MatchAll();
$this->coreFilter->apply(
$query,
$languageFilter,
DocumentMapper::DOCUMENT_TYPE_IDENTIFIER_CONTENT
);
return $this->resultExtractor->extract(
$this->gateway->findContent($query, $languageFilter),
$query->facetBuilders
);
} | php | {
"resource": ""
} |
q243713 | Handler.findSingle | validation | public function findSingle(Criterion $filter, array $languageFilter = array())
{
$query = new Query();
$query->filter = $filter;
$query->query = new Criterion\MatchAll();
$query->offset = 0;
$query->limit = 1;
$this->coreFilter->apply(
$query,
$languageFilter,
DocumentMapper::DOCUMENT_TYPE_IDENTIFIER_CONTENT
);
$result = $this->resultExtractor->extract(
$this->gateway->findContent($query, $languageFilter)
);
if (!$result->totalCount) {
throw new NotFoundException('Content', 'findSingle() found no content for given $filter');
} elseif ($result->totalCount > 1) {
throw new InvalidArgumentException('totalCount', 'findSingle() found more then one item for given $filter');
}
$first = reset($result->searchHits);
return $first->valueObject;
} | php | {
"resource": ""
} |
q243714 | Handler.indexContent | validation | public function indexContent(Content $content)
{
$this->gateway->bulkIndexDocuments(array($this->mapper->mapContentBlock($content)));
} | php | {
"resource": ""
} |
q243715 | Handler.bulkIndexContent | validation | public function bulkIndexContent(array $contentObjects)
{
$documents = array();
foreach ($contentObjects as $content) {
try {
$documents[] = $this->mapper->mapContentBlock($content);
} catch (NotFoundException $ex) {
// ignore content objects without assigned state id
}
}
if (!empty($documents)) {
$this->gateway->bulkIndexDocuments($documents);
}
} | php | {
"resource": ""
} |
q243716 | Handler.deleteContent | validation | public function deleteContent($contentId, $versionId = null)
{
$idPrefix = $this->mapper->generateContentDocumentId($contentId);
$this->gateway->deleteByQuery("_root_:{$idPrefix}*");
} | php | {
"resource": ""
} |
q243717 | SolrCreateIndexCommand.logWarning | validation | private function logWarning(OutputInterface $output, ProgressBar $progress, $message)
{
$progress->clear();
$this->logger->warning($message);
$progress->display();
} | php | {
"resource": ""
} |
q243718 | Stream.request | validation | public function request($method, Endpoint $endpoint, $path, Message $message = null)
{
$message = $message ?: new Message();
// We'll try to reach backend several times before throwing exception.
$i = 0;
do {
++$i;
if ($responseMessage = $this->requestStream($method, $endpoint, $path, $message)) {
return $responseMessage;
}
usleep($this->retryWaitMs * 1000);
} while ($i < $this->connectionRetry);
if ($this->logger instanceof LoggerInterface) {
$this->logger->error(
sprintf('Connection to %s failed, attempted %d times', $endpoint->getURL(), $this->connectionRetry)
);
}
throw new ConnectionException($endpoint->getURL(), $path, $method);
} | php | {
"resource": ""
} |
q243719 | Stream.getRequestHeaders | validation | protected function getRequestHeaders(Message $message, Endpoint $endpoint)
{
// Use message headers as default
$headers = $message->headers;
// Set headers from $endpoint
if ($endpoint->user !== null) {
$headers['Authorization'] = 'Basic ' . base64_encode("{$endpoint->user}:{$endpoint->pass}");
}
// Render headers
$requestHeaders = '';
foreach ($headers as $name => $value) {
if (is_numeric($name)) {
throw new \RuntimeException("Invalid HTTP header name $name");
}
$requestHeaders .= "$name: $value\r\n";
}
return $requestHeaders;
} | php | {
"resource": ""
} |
q243720 | MapLocation.getSearchFields | validation | protected function getSearchFields(
Criterion $criterion,
$fieldDefinitionIdentifier,
$fieldTypeIdentifier = null,
$name = null
) {
return $this->fieldNameResolver->getFieldTypes(
$criterion,
$fieldDefinitionIdentifier,
$fieldTypeIdentifier,
$name
);
} | php | {
"resource": ""
} |
q243721 | Field.mapSearchFieldValue | validation | protected function mapSearchFieldValue($value, FieldType $searchFieldType = null)
{
if (null === $searchFieldType) {
return $value;
}
$searchField = new SearchField('field', $value, $searchFieldType);
$value = (array)$this->fieldValueMapper->map($searchField);
return current($value);
} | php | {
"resource": ""
} |
q243722 | Native.internalFind | validation | protected function internalFind(array $parameters, array $languageSettings = array())
{
$searchTargets = $this->getSearchTargets($languageSettings);
if (!empty($searchTargets)) {
$parameters['shards'] = $searchTargets;
}
return $this->search($parameters);
} | php | {
"resource": ""
} |
q243723 | Native.generateQueryString | validation | protected function generateQueryString(array $parameters)
{
$removedArrayCharacters = preg_replace(
'/%5B[0-9]+%5D=/',
'=',
http_build_query($parameters)
);
$removedDuplicatedEscapingForUrlPath = str_replace('%5C%5C%2F', '%5C%2F', $removedArrayCharacters);
return $removedDuplicatedEscapingForUrlPath;
} | php | {
"resource": ""
} |
q243724 | Native.getSearchTargets | validation | protected function getSearchTargets($languageSettings)
{
if ($this->endpointResolver instanceof SingleEndpointResolver && !$this->endpointResolver->hasMultipleEndpoints()) {
return '';
}
$shards = array();
$endpoints = $this->endpointResolver->getSearchTargets($languageSettings);
if (!empty($endpoints)) {
foreach ($endpoints as $endpoint) {
$shards[] = $this->endpointRegistry->getEndpoint($endpoint)->getIdentifier();
}
}
return implode(',', $shards);
} | php | {
"resource": ""
} |
q243725 | Native.getAllSearchTargets | validation | protected function getAllSearchTargets()
{
if ($this->endpointResolver instanceof SingleEndpointResolver && !$this->endpointResolver->hasMultipleEndpoints()) {
return '';
}
$shards = [];
$searchTargets = $this->endpointResolver->getEndpoints();
if (!empty($searchTargets)) {
foreach ($searchTargets as $endpointName) {
$shards[] = $this->endpointRegistry->getEndpoint($endpointName)->getIdentifier();
}
}
return implode(',', $shards);
} | php | {
"resource": ""
} |
q243726 | Native.bulkIndexDocuments | validation | public function bulkIndexDocuments(array $documents)
{
$documentMap = array();
$mainTranslationsEndpoint = $this->endpointResolver->getMainLanguagesEndpoint();
$mainTranslationsDocuments = array();
foreach ($documents as $translationDocuments) {
foreach ($translationDocuments as $document) {
$documentMap[$document->languageCode][] = $document;
if ($mainTranslationsEndpoint !== null && $document->isMainTranslation) {
$mainTranslationsDocuments[] = $this->getMainTranslationDocument($document);
}
}
}
foreach ($documentMap as $languageCode => $translationDocuments) {
$this->doBulkIndexDocuments(
$this->endpointRegistry->getEndpoint(
$this->endpointResolver->getIndexingTarget($languageCode)
),
$translationDocuments
);
}
if (!empty($mainTranslationsDocuments)) {
$this->doBulkIndexDocuments(
$this->endpointRegistry->getEndpoint($mainTranslationsEndpoint),
$mainTranslationsDocuments
);
}
} | php | {
"resource": ""
} |
q243727 | Native.commit | validation | public function commit($flush = false)
{
$payload = $flush ?
'<commit/>' :
'<commit softCommit="true"/>';
foreach ($this->endpointResolver->getEndpoints() as $endpointName) {
$result = $this->client->request(
'POST',
$this->endpointRegistry->getEndpoint($endpointName),
'/update',
new Message(
array(
'Content-Type' => 'text/xml',
),
$payload
)
);
if ($result->headers['status'] !== 200) {
throw new RuntimeException(
'Wrong HTTP status received from Solr: ' .
$result->headers['status'] . var_export($result, true)
);
}
}
} | php | {
"resource": ""
} |
q243728 | Native.search | validation | protected function search(array $parameters)
{
$queryString = $this->generateQueryString($parameters);
$response = $this->client->request(
'POST',
$this->endpointRegistry->getEndpoint(
$this->endpointResolver->getEntryEndpoint()
),
'/select',
new Message(
[
'Content-Type' => 'application/x-www-form-urlencoded',
],
$queryString
)
);
// @todo: Error handling?
$result = json_decode($response->body);
if (!isset($result->response)) {
throw new RuntimeException(
'->response not set: ' . var_export(array($result, $parameters), true)
);
}
return $result;
} | php | {
"resource": ""
} |
q243729 | Field.getSortFieldName | validation | protected function getSortFieldName(
SortClause $sortClause,
$contentTypeIdentifier,
$fieldDefinitionIdentifier
) {
return $this->fieldNameResolver->getSortFieldName(
$sortClause,
$contentTypeIdentifier,
$fieldDefinitionIdentifier
);
} | php | {
"resource": ""
} |
q243730 | NativeEndpointResolver.hasMultipleEndpoints | validation | public function hasMultipleEndpoints()
{
if ($this->hasMultiple !== null) {
return $this->hasMultiple;
}
$endpointSet = array_flip($this->endpointMap);
if (isset($this->defaultEndpoint)) {
$endpointSet[$this->defaultEndpoint] = true;
}
if (isset($this->mainLanguagesEndpoint)) {
$endpointSet[$this->mainLanguagesEndpoint] = true;
}
return $this->hasMultiple = count($endpointSet) > 1;
} | php | {
"resource": ""
} |
q243731 | EzSystemsEzPlatformSolrSearchEngineExtension.processConnectionConfiguration | validation | protected function processConnectionConfiguration(ContainerBuilder $container, array $config)
{
$alias = $this->getAlias();
if (isset($config['default_connection'])) {
$container->setParameter(
"{$alias}.default_connection",
$config['default_connection']
);
} elseif (!empty($config['connections'])) {
reset($config['connections']);
$container->setParameter(
"{$alias}.default_connection",
key($config['connections'])
);
}
foreach ($config['connections'] as $name => $params) {
$this->configureSearchServices($container, $name, $params);
$this->configureBoostMap($container, $name, $params);
$this->configureIndexingDepth($container, $name, $params);
$container->setParameter("$alias.connection.$name", $params);
}
foreach ($config['endpoints'] as $name => $params) {
$this->defineEndpoint($container, $name, $params);
}
// Search engine itself, for given connection name
$searchEngineDef = $container->findDefinition(self::ENGINE_ID);
$searchEngineDef->setFactory([new Reference('ezpublish.solr.engine_factory'), 'buildEngine']);
// Factory for BoostFactorProvider uses mapping configured for the connection in use
$boostFactorProviderDef = $container->findDefinition(self::BOOST_FACTOR_PROVIDER_ID);
$boostFactorProviderDef->setFactory([new Reference('ezpublish.solr.boost_factor_provider_factory'), 'buildService']);
} | php | {
"resource": ""
} |
q243732 | EzSystemsEzPlatformSolrSearchEngineExtension.configureSearchServices | validation | private function configureSearchServices(ContainerBuilder $container, $connectionName, $connectionParams)
{
$alias = $this->getAlias();
// Endpoint resolver
$endpointResolverDefinition = new DefinitionDecorator(self::ENDPOINT_RESOLVER_ID);
$endpointResolverDefinition->replaceArgument(0, $connectionParams['entry_endpoints']);
$endpointResolverDefinition->replaceArgument(1, $connectionParams['mapping']['translations']);
$endpointResolverDefinition->replaceArgument(2, $connectionParams['mapping']['default']);
$endpointResolverDefinition->replaceArgument(3, $connectionParams['mapping']['main_translations']);
$endpointResolverId = "$alias.connection.$connectionName.endpoint_resolver_id";
$container->setDefinition($endpointResolverId, $endpointResolverDefinition);
// Core filter
$coreFilterDefinition = new DefinitionDecorator(self::CORE_FILTER_ID);
$coreFilterDefinition->replaceArgument(0, new Reference($endpointResolverId));
$coreFilterId = "$alias.connection.$connectionName.core_filter_id";
$container->setDefinition($coreFilterId, $coreFilterDefinition);
// Gateway
$gatewayDefinition = new DefinitionDecorator(self::GATEWAY_ID);
$gatewayDefinition->replaceArgument(1, new Reference($endpointResolverId));
$gatewayId = "$alias.connection.$connectionName.gateway_id";
$container->setDefinition($gatewayId, $gatewayDefinition);
} | php | {
"resource": ""
} |
q243733 | EzSystemsEzPlatformSolrSearchEngineExtension.defineEndpoint | validation | protected function defineEndpoint(ContainerBuilder $container, $alias, $params)
{
$definition = new Definition(self::ENDPOINT_CLASS, array($params));
$definition->addTag(self::ENDPOINT_TAG, array('alias' => $alias));
$container->setDefinition(
sprintf($this->getAlias() . '.endpoints.%s', $alias),
$definition
);
} | php | {
"resource": ""
} |
q243734 | CriterionVisitor.getRange | validation | protected function getRange($operator, $start, $end)
{
$startBrace = '[';
$startValue = '*';
$endValue = '*';
$endBrace = ']';
$start = '"' . $this->escapeQuote($this->toString($start), true) . '"';
$end = '"' . $this->escapeQuote($this->toString($end), true) . '"';
switch ($operator) {
case Operator::GT:
$startBrace = '{';
$endBrace = '}';
// Intentionally omitted break
case Operator::GTE:
$startValue = $start;
break;
case Operator::LT:
$startBrace = '{';
$endBrace = '}';
// Intentionally omitted break
case Operator::LTE:
$endValue = $end;
break;
case Operator::BETWEEN:
$startValue = $start;
$endValue = $end;
break;
default:
throw new \RuntimeException("Unknown operator: $operator");
}
return "$startBrace$startValue TO $endValue$endBrace";
} | php | {
"resource": ""
} |
q243735 | CriterionVisitor.escapeExpressions | validation | protected function escapeExpressions($string, $allowWildcard = false)
{
if ($allowWildcard) {
$reservedCharacters = preg_quote('+-&|!(){}[]^"~?:\\ ');
} else {
$reservedCharacters = preg_quote('+-&|!(){}[]^"~*?:\\ ');
}
return preg_replace_callback(
'/([' . $reservedCharacters . '])/',
function ($matches) {
return '\\' . $matches[0];
},
$string
);
} | php | {
"resource": ""
} |
q243736 | Configuration.addEndpointsSection | validation | protected function addEndpointsSection(ArrayNodeDefinition $node)
{
$node->children()
->arrayNode('endpoints')
->info('Solr Search Engine endpoint configuration')
->useAttributeAsKey('endpoint_name')
->performNoDeepMerging()
->prototype('array')
->children()
// To support Symfony 3 env() variables we don't parse the dsn setting here but in Endpoint ctor
->scalarNode('dsn')
->defaultNull()
->end()
->scalarNode('scheme')
->defaultValue($this->defaultEndpointValues['scheme'])
->end()
->scalarNode('host')
->defaultValue($this->defaultEndpointValues['host'])
->end()
->scalarNode('port')
->defaultValue($this->defaultEndpointValues['port'])
->end()
->scalarNode('user')
->defaultValue($this->defaultEndpointValues['user'])
->end()
->scalarNode('pass')
->defaultValue($this->defaultEndpointValues['pass'])
->end()
->scalarNode('path')
->defaultValue($this->defaultEndpointValues['path'])
->end()
->scalarNode('core')
->isRequired()
->end()
->end()
->end()
->end()
->end();
} | php | {
"resource": ""
} |
q243737 | ContentDocumentFulltextFields.getIndexFieldName | validation | private function getIndexFieldName(int $depth): string
{
if ($depth === 0) {
return self::$fieldName;
}
return sprintf(self::$relatedContentFieldName, $depth);
} | php | {
"resource": ""
} |
q243738 | NativeCoreFilter.getCoreCriterion | validation | private function getCoreCriterion(array $languageCodes, $useAlwaysAvailable)
{
// Handle languages if given
if (!empty($languageCodes)) {
// Get condition for prioritized languages fallback
$filter = $this->getLanguageFilter($languageCodes);
// Handle always available fallback if used
if ($useAlwaysAvailable) {
// Combine conditions with OR
$filter = new LogicalOr(
array(
$filter,
$this->getAlwaysAvailableFilter($languageCodes),
)
);
}
// Return languages condition
return $filter;
}
// Otherwise search only main languages
return new CustomField(self::FIELD_IS_MAIN_LANGUAGE, Operator::EQ, true);
} | php | {
"resource": ""
} |
q243739 | NativeCoreFilter.getLanguageFilter | validation | private function getLanguageFilter(array $languageCodes)
{
$languageFilters = array();
foreach ($languageCodes as $languageCode) {
// Include language
$condition = new CustomField(self::FIELD_LANGUAGE, Operator::EQ, $languageCode);
// Get list of excluded languages
$excluded = $this->getExcludedLanguageCodes($languageCodes, $languageCode);
// Combine if list is not empty
if (!empty($excluded)) {
$condition = new LogicalAnd(
array(
$condition,
new LogicalNot(
new CustomField(self::FIELD_LANGUAGES, Operator::IN, $excluded)
),
)
);
}
$languageFilters[] = $condition;
}
// Combine language fallback conditions with OR
if (count($languageFilters) > 1) {
$languageFilters = array(new LogicalOr($languageFilters));
}
// Exclude main languages index if used
if ($this->hasMainLanguagesEndpoint) {
$languageFilters[] = new LogicalNot(
new CustomField(self::FIELD_IS_MAIN_LANGUAGES_INDEX, Operator::EQ, true)
);
}
// Combine conditions
if (count($languageFilters) > 1) {
return new LogicalAnd($languageFilters);
}
return reset($languageFilters);
} | php | {
"resource": ""
} |
q243740 | NativeCoreFilter.getAlwaysAvailableFilter | validation | private function getAlwaysAvailableFilter(array $languageCodes)
{
$conditions = array(
// Include always available main language translations
new CustomField(
self::FIELD_IS_ALWAYS_AVAILABLE,
Operator::EQ,
true
),
// Exclude all given languages
new LogicalNot(
new CustomField(self::FIELD_LANGUAGES, Operator::IN, $languageCodes)
),
);
// Include only from main languages index if used
if ($this->hasMainLanguagesEndpoint) {
$conditions[] = new CustomField(
self::FIELD_IS_MAIN_LANGUAGES_INDEX,
Operator::EQ,
true
);
}
// Combine conditions
return new LogicalAnd($conditions);
} | php | {
"resource": ""
} |
q243741 | BlockDocumentsContentFields.getIndexFieldType | validation | private function getIndexFieldType(
ContentType $contentType,
FieldDefinition $fieldDefinition,
FieldType $fieldType
) {
if (!$fieldType instanceof FieldType\TextField) {
return $fieldType;
}
$fieldType = clone $fieldType;
$fieldType->boost = $this->boostFactorProvider->getContentFieldBoostFactor(
$contentType,
$fieldDefinition
);
return $fieldType;
} | php | {
"resource": ""
} |
q243742 | NativeQueryConverter.getFacetParams | validation | private function getFacetParams(array $facetBuilders)
{
$facetSets = array_map(
function ($facetBuilder) {
return $this->facetBuilderVisitor->visitBuilder($facetBuilder, spl_object_hash($facetBuilder));
},
$facetBuilders
);
$facetParams = array();
// In case when facet sets contain same keys, merge them in an array
foreach ($facetSets as $facetSet) {
foreach ($facetSet as $key => $value) {
if (isset($facetParams[$key])) {
if (!is_array($facetParams[$key])) {
$facetParams[$key] = array($facetParams[$key]);
}
$facetParams[$key][] = $value;
} else {
$facetParams[$key] = $value;
}
}
}
return $facetParams;
} | php | {
"resource": ""
} |
q243743 | FacetBuilderVisitor.mapData | validation | protected function mapData(array $data)
{
$values = array();
reset($data);
while ($key = current($data)) {
$values[$key] = next($data);
next($data);
}
return $values;
} | php | {
"resource": ""
} |
q243744 | WsdlAnalyser.loadMessagesAndVersions | validation | public static function loadMessagesAndVersions($wsdls)
{
$msgAndVer = [];
foreach ($wsdls as $wsdl) {
$wsdlIdentifier = self::makeWsdlIdentifier($wsdl);
self::$wsdlIds[$wsdlIdentifier] = $wsdl;
self::loadWsdlXpath($wsdl, $wsdlIdentifier);
$operations = self::$wsdlDomXpath[$wsdlIdentifier]->query(self::XPATH_ALL_OPERATIONS);
if ($operations->length === 0) {
//No operations found - are there any external WSDLs being imported?
$imports = self::$wsdlDomXpath[$wsdlIdentifier]->query(self::XPATH_IMPORTS);
$operations = [];
foreach ($imports as $import) {
if (!empty($import->value)) {
$tmpMsg = self::getMessagesAndVersionsFromImportedWsdl(
$import->value,
$wsdl,
$wsdlIdentifier
);
foreach ($tmpMsg as $msgName => $msgInfo) {
$msgAndVer[$msgName] = $msgInfo;
}
}
}
}
$msgAndVer = array_merge(
$msgAndVer,
self::loopOperationsWithQuery(
$operations,
self::XPATH_VERSION_FOR_OPERATION,
$wsdlIdentifier,
self::$wsdlDomXpath[$wsdlIdentifier]
)
);
}
return $msgAndVer;
} | php | {
"resource": ""
} |
q243745 | WsdlAnalyser.getMessagesAndVersionsFromImportedWsdl | validation | protected static function getMessagesAndVersionsFromImportedWsdl($import, $wsdlPath, $wsdlIdentifier)
{
$msgAndVer = [];
$domXpath = null;
$importPath = realpath(dirname($wsdlPath)).DIRECTORY_SEPARATOR.$import;
$wsdlContent = file_get_contents($importPath);
if ($wsdlContent !== false) {
$domDoc = new \DOMDocument('1.0', 'UTF-8');
$ok = $domDoc->loadXML($wsdlContent);
if ($ok === true) {
$domXpath = new \DOMXPath($domDoc);
$domXpath->registerNamespace(
'wsdl',
'http://schemas.xmlsoap.org/wsdl/'
);
$domXpath->registerNamespace(
'soap',
'http://schemas.xmlsoap.org/wsdl/soap/'
);
}
} else {
throw new InvalidWsdlFileException('WSDL '.$importPath.' import could not be loaded');
}
if ($domXpath instanceof \DOMXPath) {
$nodeList = $domXpath->query(self::XPATH_ALL_OPERATIONS);
$msgAndVer = array_merge(
$msgAndVer,
self::loopOperationsWithQuery(
$nodeList,
self::XPATH_ALT_VERSION_FOR_OPERATION,
$wsdlIdentifier,
$domXpath
)
);
}
return $msgAndVer;
} | php | {
"resource": ""
} |
q243746 | WsdlAnalyser.loadWsdlXpath | validation | public static function loadWsdlXpath($wsdlFilePath, $wsdlId)
{
if (!isset(self::$wsdlDomXpath[$wsdlId]) || is_null(self::$wsdlDomXpath[$wsdlId])) {
$wsdlContent = file_get_contents($wsdlFilePath);
if ($wsdlContent !== false) {
self::$wsdlDomDoc[$wsdlId] = new \DOMDocument('1.0', 'UTF-8');
self::$wsdlDomDoc[$wsdlId]->loadXML($wsdlContent);
self::$wsdlDomXpath[$wsdlId] = new \DOMXPath(self::$wsdlDomDoc[$wsdlId]);
self::$wsdlDomXpath[$wsdlId]->registerNamespace(
'wsdl',
'http://schemas.xmlsoap.org/wsdl/'
);
self::$wsdlDomXpath[$wsdlId]->registerNamespace(
'soap',
'http://schemas.xmlsoap.org/wsdl/soap/'
);
} else {
throw new InvalidWsdlFileException('WSDL '.$wsdlFilePath.' could not be loaded');
}
}
} | php | {
"resource": ""
} |
q243747 | WsdlAnalyser.exaluateXpathQueryOnWsdl | validation | public static function exaluateXpathQueryOnWsdl($wsdlId, $wsdlFilePath, $xpath)
{
WsdlAnalyser::loadWsdlXpath($wsdlFilePath, $wsdlId);
return self::$wsdlDomXpath[$wsdlId]->evaluate($xpath);
} | php | {
"resource": ""
} |
q243748 | WsdlAnalyser.loopOperationsWithQuery | validation | protected static function loopOperationsWithQuery($operations, $query, $wsdlIdentifier, $domXpath)
{
$msgAndVer = [];
foreach ($operations as $operation) {
if (!empty($operation->value)) {
$fullVersion = $domXpath->evaluate(
sprintf($query, $operation->value)
);
if (!empty($fullVersion)) {
$extractedVersion = self::extractMessageVersion($fullVersion);
$msgAndVer[$operation->value] = [
'version' => $extractedVersion,
'wsdl' => $wsdlIdentifier
];
}
}
}
return $msgAndVer;
} | php | {
"resource": ""
} |
q243749 | Base.createRequest | validation | public function createRequest($messageName, RequestOptionsInterface $params)
{
$this->checkMessageIsInWsdl($messageName);
$builder = $this->findBuilderForMessage($messageName);
if ($builder instanceof ConvertInterface) {
return $builder->convert($params, $this->getActiveVersionFor($messageName));
} else {
throw new \RuntimeException('No builder found for message '.$messageName);
}
} | php | {
"resource": ""
} |
q243750 | Base.findBuilderForMessage | validation | protected function findBuilderForMessage($messageName)
{
$builder = null;
if (array_key_exists($messageName, $this->messageBuilders) &&
$this->messageBuilders[$messageName] instanceof ConvertInterface
) {
$builder = $this->messageBuilders[$messageName];
} else {
$section = substr($messageName, 0, strpos($messageName, '_'));
$message = substr($messageName, strpos($messageName, '_') + 1);
$builderClass = __NAMESPACE__.'\\Converter\\'.$section.'\\'.$message."Conv";
if (class_exists($builderClass)) {
/** @var ConvertInterface $builder */
$builder = new $builderClass();
$builder->setParams($this->params);
$this->messageBuilders[$messageName] = $builder;
}
}
return $builder;
} | php | {
"resource": ""
} |
q243751 | HandlerValidateFOP.analyze | validation | public function analyze(SendResult $response)
{
$analyzeResponse = new Result($response);
$domXpath = $this->makeDomXpath($response->responseXml);
//General error level in the transmissionError location:
$errorCodeNodeList = $domXpath->query(self::Q_G_ERR);
if ($errorCodeNodeList->length > 0) {
$errorCatNode = $domXpath->query(self::Q_G_CAT)->item(0);
$analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));
$code = $errorCodeNodeList->item(0)->nodeValue;
$errorTextNodeList = $domXpath->query(self::Q_G_MSG);
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'general');
}
//Deficient FOP level errors:
$errorCodeNodeList = $domXpath->query(self::Q_D_ERR);
if ($errorCodeNodeList->length > 0) {
$errorCatNode = $domXpath->query(self::Q_D_CAT)->item(0);
$analyzeResponse->setStatus($this->makeStatusForPotentiallyNonExistent($errorCatNode));
$code = $errorCodeNodeList->item(0)->nodeValue;
$errorTextNodeList = $domXpath->query(self::Q_D_MSG);
$message = $this->makeMessageFromMessagesNodeList($errorTextNodeList);
$analyzeResponse->messages[] = new Result\NotOk($code, trim($message), 'deficient_fop');
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243752 | HandlerValidateFOP.makeStatusForPotentiallyNonExistent | validation | protected function makeStatusForPotentiallyNonExistent($errorCatNode)
{
if ($errorCatNode instanceof \DOMNode) {
$status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
} else {
$status = Result::STATUS_ERROR;
}
return $status;
} | php | {
"resource": ""
} |
q243753 | Result.setStatus | validation | public function setStatus($newStatus)
{
if ($this->isWorseStatus($newStatus, $this->status)) {
$this->status = $newStatus;
}
} | php | {
"resource": ""
} |
q243754 | Result.isWorseStatus | validation | protected function isWorseStatus($newStatus, $currentStatus)
{
$levels = [
self::STATUS_UNKNOWN => -1,
self::STATUS_OK => 0,
self::STATUS_INFO => 2,
self::STATUS_WARN => 5,
self::STATUS_ERROR => 10,
self::STATUS_FATAL => 20,
];
return ($currentStatus === null || $levels[$newStatus] > $levels[$currentStatus]);
} | php | {
"resource": ""
} |
q243755 | Client.setConsumerId | validation | public function setConsumerId($id)
{
$this->sessionHandler->setTransactionFlowLink(true);
$this->sessionHandler->setConsumerId($id);
} | php | {
"resource": ""
} |
q243756 | Client.pnrRetrieve | validation | public function pnrRetrieve(RequestOptions\PnrRetrieveOptions $options, $messageOptions = [])
{
$msgName = 'PNR_Retrieve';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243757 | Client.pnrCreatePnr | validation | public function pnrCreatePnr(RequestOptions\PnrCreatePnrOptions $options, $messageOptions = [])
{
$msgName = 'PNR_AddMultiElements';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243758 | Client.pnrAddMultiElements | validation | public function pnrAddMultiElements(RequestOptions\PnrAddMultiElementsOptions $options, $messageOptions = [])
{
$msgName = 'PNR_AddMultiElements';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243759 | Client.pnrRetrieveAndDisplay | validation | public function pnrRetrieveAndDisplay(RequestOptions\PnrRetrieveAndDisplayOptions $options, $messageOptions = [])
{
$msgName = 'PNR_RetrieveAndDisplay';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243760 | Client.queueList | validation | public function queueList(RequestOptions\QueueListOptions $options, $messageOptions = [])
{
$msgName = 'Queue_List';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243761 | Client.queuePlacePnr | validation | public function queuePlacePnr(RequestOptions\QueuePlacePnrOptions $options, $messageOptions = [])
{
$msgName = 'Queue_PlacePNR';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243762 | Client.pnrIgnore | validation | public function pnrIgnore(RequestOptions\PnrIgnoreOptions $options, $messageOptions = [])
{
$msgName = 'PNR_Ignore';
return $this->callMessage($msgName, $options, $messageOptions);
} | php | {
"resource": ""
} |
q243763 | Client.callMessage | validation | protected function callMessage($messageName, $options, $messageOptions, $endSession = false)
{
$messageOptions = $this->makeMessageOptions($messageOptions, $endSession);
$this->lastMessage = $messageName;
$sendResult = $this->sessionHandler->sendMessage(
$messageName,
$this->requestCreator->createRequest(
$messageName,
$options
),
$messageOptions
);
$response = $this->responseHandler->analyzeResponse(
$sendResult,
$messageName
);
if ($messageOptions['returnXml'] === false) {
$response->responseXml = null;
}
return $response;
} | php | {
"resource": ""
} |
q243764 | Client.makeMessageOptions | validation | protected function makeMessageOptions(array $incoming, $endSession = false)
{
$options = [
'endSession' => $endSession,
'returnXml' => $this->returnResultXml
];
if (array_key_exists('endSession', $incoming)) {
$options['endSession'] = $incoming['endSession'];
}
if (array_key_exists('returnXml', $incoming)) {
$options['returnXml'] = $incoming['returnXml'];
}
return $options;
} | php | {
"resource": ""
} |
q243765 | SecurityAuthenticateOptions.loadFromAuthParams | validation | protected function loadFromAuthParams(AuthParams $authParams)
{
$this->officeId = $authParams->officeId;
$this->dutyCode = $authParams->dutyCode;
$this->organizationId = $authParams->organizationId;
$this->originatorTypeCode = $authParams->originatorTypeCode;
$this->userId = $authParams->userId;
$this->passwordLength = $authParams->passwordLength;
$this->passwordData = $authParams->passwordData;
} | php | {
"resource": ""
} |
q243766 | SoapHeader4.getConsumerId | validation | public function getConsumerId($generate = false)
{
if (is_null($this->consumerId) && $generate) {
$this->consumerId = $this->generateGuid();
}
return $this->consumerId;
} | php | {
"resource": ""
} |
q243767 | SoapHeader4.prepareForNextMessage | validation | protected function prepareForNextMessage($messageName, $messageOptions)
{
if ($this->isAuthenticated === true && is_int($this->sessionData['sequenceNumber'])) {
$this->sessionData['sequenceNumber']++;
}
$headers = $this->createSoapHeaders($this->sessionData, $this->params, $messageName, $messageOptions);
$this->getSoapClient($messageName)->__setSoapHeaders(null);
$this->getSoapClient($messageName)->__setSoapHeaders($headers);
} | php | {
"resource": ""
} |
q243768 | SoapHeader4.getEndpointFromWsdl | validation | protected function getEndpointFromWsdl($wsdlFilePath, $messageName)
{
$wsdlId = $this->getWsdlIdFor($messageName);
return WsdlAnalyser::exaluateXpathQueryOnWsdl(
$wsdlId,
$wsdlFilePath,
self::XPATH_ENDPOINT
);
} | php | {
"resource": ""
} |
q243769 | SoapHeader4.getActionFromWsdl | validation | protected function getActionFromWsdl($wsdlFilePath, $messageName)
{
$wsdlId = $this->getWsdlIdFor($messageName);
return WsdlAnalyser::exaluateXpathQueryOnWsdl(
$wsdlId,
$wsdlFilePath,
sprintf(self::XPATH_OPERATION_ACTION, $messageName)
);
} | php | {
"resource": ""
} |
q243770 | SoapHeader4.generateGuid | validation | protected function generateGuid()
{
mt_srand((double) microtime() * 10000);
$charId = strtoupper(md5(uniqid(rand(), true)));
$hyphen = chr(45); // "-"
$uuid = substr($charId, 0, 8) . $hyphen
. substr($charId, 8, 4) . $hyphen
. substr($charId, 12, 4) . $hyphen
. substr($charId, 16, 4) . $hyphen
. substr($charId, 20, 12);
return $uuid;
} | php | {
"resource": ""
} |
q243771 | SoapHeader4.makeSoapClientOptions | validation | protected function makeSoapClientOptions()
{
$options = $this->soapClientOptions;
$options['classmap'] = array_merge(Classmap::$soapheader4map, Classmap::$map);
if (!empty($this->params->soapClientOptions)) {
$options = array_merge($options, $this->params->soapClientOptions);
}
return $options;
} | php | {
"resource": ""
} |
q243772 | SoapHeader4.getStatefulStatusCode | validation | private function getStatefulStatusCode($messageName, array $messageOptions)
{
// on security-auth this is always 'Start'
if ('Security_Authenticate' === $messageName) {
return self::TRANSACTION_STATUS_CODE_START;
}
// if endSession is set this will be (the) 'End'
if (isset($messageOptions['endSession']) && $messageOptions['endSession'] === true) {
return self::TRANSACTION_STATUS_CODE_END;
}
// on everything else we assume in-series
return self::TRANSACTION_STATUS_CODE_INSERIES;
} | php | {
"resource": ""
} |
q243773 | SegmentGroup.loadOptionalSegmentInformation | validation | protected function loadOptionalSegmentInformation($options)
{
if (!empty($options->operatingCompany)) {
$this->segmentInformation->companyDetails->operatingCompany = $options->operatingCompany;
}
if ($options->arrivalDate instanceof \DateTime) {
$this->segmentInformation->flightDate->setArrivalDate($options->arrivalDate);
}
if (!empty($options->groupNumber)) {
$this->segmentInformation->flightTypeDetails = new FlightTypeDetails($options->groupNumber);
}
$this->loadAdditionalSegmentDetails($options->airplaneCode, $options->nrOfStops);
} | php | {
"resource": ""
} |
q243774 | SegmentGroup.loadInventory | validation | protected function loadInventory($inventory)
{
if (is_array($inventory) && count($inventory) > 0) {
$this->inventory = new Inventory();
foreach ($inventory as $bookingClass => $availabilityAmount) {
$this->inventory->bookingClassDetails[] = new BookingClassDetails(
$bookingClass,
$availabilityAmount
);
}
}
} | php | {
"resource": ""
} |
q243775 | Base.setSessionData | validation | public function setSessionData(array $sessionData)
{
if (isset($sessionData['sessionId'], $sessionData['sequenceNumber'], $sessionData['securityToken'])) {
$this->sessionData['sessionId'] = $sessionData['sessionId'];
$this->sessionData['sequenceNumber'] = $sessionData['sequenceNumber'];
$this->sessionData['securityToken'] = $sessionData['securityToken'];
$this->isAuthenticated = true;
} else {
$this->isAuthenticated = false;
}
return $this->isAuthenticated;
} | php | {
"resource": ""
} |
q243776 | Base.getMessagesAndVersions | validation | public function getMessagesAndVersions()
{
if (empty($this->messagesAndVersions)) {
$this->messagesAndVersions = WsdlAnalyser::loadMessagesAndVersions($this->params->wsdl);
}
return $this->messagesAndVersions;
} | php | {
"resource": ""
} |
q243777 | Base.getWsdlIdFor | validation | protected function getWsdlIdFor($messageName)
{
$msgAndVer = $this->getMessagesAndVersions();
if (isset($msgAndVer[$messageName]) && isset($msgAndVer[$messageName]['wsdl'])) {
return $msgAndVer[$messageName]['wsdl'];
}
return null;
} | php | {
"resource": ""
} |
q243778 | Base.getSoapClient | validation | protected function getSoapClient($msgName)
{
$wsdlId = $this->getWsdlIdFor($msgName);
if (!empty($msgName)) {
if (!isset($this->soapClients[$wsdlId]) || !($this->soapClients[$wsdlId] instanceof \SoapClient)) {
$this->soapClients[$wsdlId] = $this->initSoapClient($wsdlId);
}
return $this->soapClients[$wsdlId];
} else {
return null;
}
} | php | {
"resource": ""
} |
q243779 | Base.initSoapClient | validation | protected function initSoapClient($wsdlId)
{
$wsdlPath = WsdlAnalyser::$wsdlIds[$wsdlId];
$client = new Client\SoapClient(
$wsdlPath,
$this->makeSoapClientOptions(),
$this->params->logger
);
return $client;
} | php | {
"resource": ""
} |
q243780 | Base.executeMethodOnSoapClientForMsg | validation | protected function executeMethodOnSoapClientForMsg($msgName, $method)
{
$result = null;
$soapClient = $this->getSoapClient($msgName);
if ($soapClient instanceof \SoapClient) {
$result = $soapClient->$method();
}
return $result;
} | php | {
"resource": ""
} |
q243781 | DataElementsIndiv.makeSegmentNameForRequestElement | validation | protected function makeSegmentNameForRequestElement($elementType, $element)
{
$elementName = '';
$sourceArray = [
'Contact' => ElementManagementData::SEGNAME_CONTACT_ELEMENT,
'FormOfPayment' => ElementManagementData::SEGNAME_FORM_OF_PAYMENT,
'MiscellaneousRemark' => ElementManagementData::SEGNAME_GENERAL_REMARK,
'ReceivedFrom' => ElementManagementData::SEGNAME_RECEIVE_FROM,
'ServiceRequest' => ElementManagementData::SEGNAME_SPECIAL_SERVICE_REQUEST,
'Ticketing' => ElementManagementData::SEGNAME_TICKETING_ELEMENT,
'AccountingInfo' => ElementManagementData::SEGNAME_ACCOUNTING_INFORMATION,
'Address' => null, // Special case - the type is a parameter.
'FrequentFlyer' => ElementManagementData::SEGNAME_SPECIAL_SERVICE_REQUEST,
'OtherServiceInfo' => ElementManagementData::SEGNAME_OTHER_SERVICE_INFORMATION,
'ManualCommission' => ElementManagementData::SEGNAME_COMMISSION,
'SeatRequest' => ElementManagementData::SEGNAME_SEAT_REQUEST,
'TourCode' => ElementManagementData::SEGNAME_TOUR_CODE,
'ManualIssuedTicket' => ElementManagementData::SEGNAME_MANUAL_DOCUMENT_REGISTRATION_WITH_ET_NUMBER
];
if (array_key_exists($elementType, $sourceArray)) {
$elementName = $sourceArray[$elementType];
if ($elementType === 'Address') {
/** @var Element\Address $element */
$elementName = $element->type;
}
}
return $elementName;
} | php | {
"resource": ""
} |
q243782 | StandardResponseHandler.analyzeWithErrCodeCategoryMsgQuery | validation | protected function analyzeWithErrCodeCategoryMsgQuery(SendResult $response, $qErr, $qCat, $qMsg, $errLevel = null)
{
$analyzeResponse = new Result($response);
$domXpath = $this->makeDomXpath($response->responseXml);
$errorCodeNodeList = $domXpath->query($qErr);
if ($errorCodeNodeList->length > 0) {
$analyzeResponse->status = Result::STATUS_ERROR;
$errorCatNode = $domXpath->query($qCat)->item(0);
if ($errorCatNode instanceof \DOMNode) {
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
}
$analyzeResponse->messages[] = new Result\NotOk(
$errorCodeNodeList->item(0)->nodeValue,
$this->makeMessageFromMessagesNodeList(
$domXpath->query($qMsg)
),
$errLevel
);
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243783 | StandardResponseHandler.analyzeWithErrorCodeMsgQueryLevel | validation | protected function analyzeWithErrorCodeMsgQueryLevel(SendResult $response, $qErr, $qMsg, $qLvl, $lvlToText)
{
$analyzeResponse = new Result($response);
$domXpath = $this->makeDomXpath($response->responseXml);
$errorCodeNodeList = $domXpath->query($qErr);
if ($errorCodeNodeList->length > 0) {
$analyzeResponse->status = Result::STATUS_ERROR;
$lvlNodeList = $domXpath->query($qLvl);
$level = null;
if ($lvlNodeList->length > 0) {
if (array_key_exists($lvlNodeList->item(0)->nodeValue, $lvlToText)) {
$level = $lvlToText[$lvlNodeList->item(0)->nodeValue];
}
}
$analyzeResponse->messages[] = new Result\NotOk(
$errorCodeNodeList->item(0)->nodeValue,
$this->makeMessageFromMessagesNodeList(
$domXpath->query($qMsg)
),
$level
);
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243784 | StandardResponseHandler.analyzeWithErrCodeAndMsgQueryFixedCat | validation | public function analyzeWithErrCodeAndMsgQueryFixedCat(SendResult $response, $qErr, $qMsg, $category)
{
$analyzeResponse = new Result($response);
$domXpath = $this->makeDomXpath($response->responseXml);
$errorCodeNodeList = $domXpath->query($qErr);
$errorMsgNodeList = $domXpath->query($qMsg);
if ($errorCodeNodeList->length > 0 || $errorMsgNodeList->length > 0) {
$analyzeResponse->status = $category;
$errorCode = ($errorCodeNodeList->length > 0) ? $errorCodeNodeList->item(0)->nodeValue : null;
$analyzeResponse->messages[] = new Result\NotOk(
$errorCode,
$this->makeMessageFromMessagesNodeList($errorMsgNodeList)
);
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243785 | StandardResponseHandler.analyzeWithErrCodeCategoryMsgNodeName | validation | protected function analyzeWithErrCodeCategoryMsgNodeName(SendResult $response, $nodeErr, $nodeCat, $nodeMsg)
{
$analyzeResponse = new Result($response);
$domDoc = $this->loadDomDocument($response->responseXml);
$errorCodeNode = $domDoc->getElementsByTagName($nodeErr)->item(0);
if (!is_null($errorCodeNode)) {
$errorCatNode = $domDoc->getElementsByTagName($nodeCat)->item(0);
if ($errorCatNode instanceof \DOMNode) {
$analyzeResponse->status = $this->makeStatusFromErrorQualifier($errorCatNode->nodeValue);
} else {
$analyzeResponse->status = Result::STATUS_ERROR;
}
$errorCode = $errorCodeNode->nodeValue;
$errorTextNodeList = $domDoc->getElementsByTagName($nodeMsg);
$analyzeResponse->messages[] = new Result\NotOk(
$errorCode,
$this->makeMessageFromMessagesNodeList($errorTextNodeList)
);
}
return $analyzeResponse;
} | php | {
"resource": ""
} |
q243786 | StandardResponseHandler.makeDomXpath | validation | protected function makeDomXpath($response)
{
$domDoc = $this->loadDomDocument($response);
$domXpath = new \DOMXPath($domDoc);
$domXpath->registerNamespace(
self::XMLNS_PREFIX,
$domDoc->documentElement->lookupNamespaceUri(null)
);
return $domXpath;
} | php | {
"resource": ""
} |
q243787 | StandardResponseHandler.makeStatusFromErrorQualifier | validation | protected function makeStatusFromErrorQualifier($qualifier, $defaultStatus = Result::STATUS_ERROR)
{
$statusQualMapping = [
'INF' => Result::STATUS_INFO,
'WEC' => Result::STATUS_WARN,
'WZZ' => Result::STATUS_WARN, //Mutually defined warning
'WA' => Result::STATUS_WARN, //Info line Warning - PNR_AddMultiElements
'W' => Result::STATUS_WARN,
'EC' => Result::STATUS_ERROR,
'ERR' => Result::STATUS_ERROR, //DocRefund_UpdateRefund
'ERC' => Result::STATUS_ERROR, //DocRefund_UpdateRefund
'X' => Result::STATUS_ERROR,
'001' => Result::STATUS_ERROR, //Air_MultiAvailability
'O' => Result::STATUS_OK,
'STA' => Result::STATUS_OK,
'ZZZ' => Result::STATUS_UNKNOWN
];
if (array_key_exists($qualifier, $statusQualMapping)) {
$status = $statusQualMapping[$qualifier];
} elseif (is_null($qualifier)) {
$status = $defaultStatus;
} else {
$status = Result::STATUS_UNKNOWN;
}
return $status;
} | php | {
"resource": ""
} |
q243788 | Base.analyzeResponse | validation | public function analyzeResponse($sendResult, $messageName)
{
if (!empty($sendResult->exception)) {
return $this->makeResultForException($sendResult);
}
$handler = $this->findHandlerForMessage($messageName);
if ($handler instanceof MessageResponseHandler) {
return $handler->analyze($sendResult);
} else {
return new Result($sendResult, Result::STATUS_UNKNOWN);
}
} | php | {
"resource": ""
} |
q243789 | Base.findHandlerForMessage | validation | private function findHandlerForMessage($messageName)
{
$handler = null;
if (array_key_exists($messageName, $this->responseHandlers) &&
$this->responseHandlers[$messageName] instanceof MessageResponseHandler
) {
$handler = $this->responseHandlers[$messageName];
} else {
$section = substr($messageName, 0, strpos($messageName, '_'));
$message = substr($messageName, strpos($messageName, '_') + 1);
$handlerClass = __NAMESPACE__.'\\'.$section.'\\Handler'.$message;
if (class_exists($handlerClass)) {
/** @var MessageResponseHandler $handler */
$handler = new $handlerClass();
$this->responseHandlers[$messageName] = $handler;
}
}
return $handler;
} | php | {
"resource": ""
} |
q243790 | Base.loadClientParams | validation | protected function loadClientParams(Params $params, $receivedFromIdentifier, $version)
{
if ($params->authParams instanceof Params\AuthParams) {
$this->authParams = $params->authParams;
if (isset($params->sessionHandlerParams) &&
$params->sessionHandlerParams instanceof Params\SessionHandlerParams
) {
$params->sessionHandlerParams->authParams = $this->authParams;
}
} elseif (isset($params->sessionHandlerParams) &&
$params->sessionHandlerParams->authParams instanceof Params\AuthParams
) {
//@deprecated - Provide backwards compatibility with old authparams structure.
//Github Issue 40 - retrieve AuthParams from sessionhandlerparams if not generally available
$this->authParams = $params->sessionHandlerParams->authParams;
}
$this->sessionHandler = $this->loadSessionHandler(
$params->sessionHandler,
$params->sessionHandlerParams
);
$this->requestCreator = $this->loadRequestCreator(
$params->requestCreator,
$params->requestCreatorParams,
$receivedFromIdentifier."-".$version,
$this->sessionHandler->getOriginatorOffice(),
$this->sessionHandler->getMessagesAndVersions()
);
$this->responseHandler = $this->loadResponseHandler(
$params->responseHandler
);
$this->returnResultXml = $params->returnXml;
} | php | {
"resource": ""
} |
q243791 | Base.loadSessionHandler | validation | protected function loadSessionHandler($sessionHandler, $params)
{
if ($sessionHandler instanceof HandlerInterface) {
$newSessionHandler = $sessionHandler;
} else {
$newSessionHandler = HandlerFactory::createHandler($params);
}
return $newSessionHandler;
} | php | {
"resource": ""
} |
q243792 | Base.loadRequestCreator | validation | protected function loadRequestCreator($requestCreator, $params, $libIdentifier, $originatorOffice, $mesVer)
{
if ($requestCreator instanceof RequestCreatorInterface) {
$newRequestCreator = $requestCreator;
} else {
$params->originatorOfficeId = $originatorOffice;
$params->messagesAndVersions = $mesVer;
$newRequestCreator = RequestCreatorFactory::createRequestCreator(
$params,
$libIdentifier
);
}
return $newRequestCreator;
} | php | {
"resource": ""
} |
q243793 | MsgBodyExtractor.getStringBetween | validation | private function getStringBetween($string, $start, $end)
{
$startPos = strpos($string, $start) + strlen($start);
$endPos = strlen($string) - strpos($string, $end);
return substr($string, $startPos, -$endPos);
} | php | {
"resource": ""
} |
q243794 | PricePNRWithBookingClass13.loadPricingOptionsFromRequestOptions | validation | public static function loadPricingOptionsFromRequestOptions($options)
{
$priceOptions = [];
$priceOptions = self::mergeOptions(
$priceOptions,
self::makePricingOptionForValidatingCarrier($options->validatingCarrier)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::makePricingOptionForCurrencyOverride($options->currencyOverride)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::makePricingOptionFareBasisOverride($options->pricingsFareBasis)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::makePricingOptionFareFamilyOverride($options->fareFamily)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadCorpNegoFare($options->corporateNegoFare)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadCorpUniFares($options->corporateUniFares, $options->awardPricing)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadObFees($options->obFees, $options->obFeeRefs)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadPaxDiscount($options->paxDiscountCodes, $options->paxDiscountCodeRefs)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadPointOverrides(
$options->pointOfSaleOverride,
$options->pointOfTicketingOverride
)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadPricingLogic($options->pricingLogic)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadTicketType($options->ticketType)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadTaxes($options->taxes)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadExemptTaxes($options->exemptTaxes)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadPastDate($options->pastDatePricing)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadFormOfPayment($options->formOfPayment)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::loadReferences($options->references)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::makeOverrideOptions($options->overrideOptions, $priceOptions)
);
$priceOptions = self::mergeOptions(
$priceOptions,
self::makeOverrideOptionsWithCriteria($options->overrideOptionsWithCriteria, $priceOptions)
);
// All options processed, no options found:
if (empty($priceOptions)) {
$priceOptions[] = new PricingOptionGroup(PricingOptionKey::OPTION_NO_OPTION);
}
return $priceOptions;
} | php | {
"resource": ""
} |
q243795 | PricePNRWithBookingClass13.makePricingOptionFareFamilyOverride | validation | protected static function makePricingOptionFareFamilyOverride($fareFamily)
{
$opt = [];
if ($fareFamily !== null) {
$po = new PricingOptionGroup(PricingOptionKey::OPTION_FARE_FAMILY);
$po->optionDetail = new OptionDetail([['FF' => $fareFamily]]);
$opt[] = $po;
}
return $opt;
} | php | {
"resource": ""
} |
q243796 | PricePNRWithBookingClass13.loadCorpNegoFare | validation | protected static function loadCorpNegoFare($corporateNegoFare)
{
$opt = [];
if ($corporateNegoFare !== null) {
$po = new PricingOptionGroup(PricingOptionKey::OPTION_CORPORATE_NEGOTIATED_FARES);
$po->optionDetail = new OptionDetail($corporateNegoFare);
$opt[] = $po;
}
return $opt;
} | php | {
"resource": ""
} |
q243797 | PricePNRWithBookingClass13.loadObFees | validation | protected static function loadObFees($obFees, $obFeeRefs)
{
$opt = [];
if (!empty($obFees)) {
$po = new PricingOptionGroup(PricingOptionKey::OPTION_OB_FEES);
$po->penDisInformation = new PenDisInformation(
PenDisInformation::QUAL_OB_FEES,
$obFees
);
if (!empty($obFeeRefs)) {
$po->paxSegTstReference = new PaxSegTstReference($obFeeRefs);
}
$opt[] = $po;
}
return $opt;
} | php | {
"resource": ""
} |
q243798 | MopDescription.loadMopDetails | validation | protected function loadMopDetails(MopInfo $options)
{
$this->mopDetails = new MopDetails();
if ($this->checkAnyNotEmpty($options->fopCode, $options->fopStatus)) {
$this->mopDetails->fopPNRDetails = new FopPNRDetails(
$options->fopCode,
$options->fopStatus
);
}
if (!empty($options->freeFlowText)) {
$this->mopDetails->oldFopFreeflow = new OldFopFreeflow(
$options->freeFlowText,
$options->freeFlowEncoding
);
}
if (!empty($options->supplementaryData)) {
$this->mopDetails->pnrSupplementaryData[] = new PnrSupplementaryData(
DataAndSwitchMap::TYPE_DATA_INFORMATION,
$options->supplementaryData
);
}
if (!empty($options->supplementarySwitches)) {
$this->mopDetails->pnrSupplementaryData[] = new PnrSupplementaryData(
DataAndSwitchMap::TYPE_SWITCH_INFORMATION,
$options->supplementarySwitches
);
}
} | php | {
"resource": ""
} |
q243799 | MopDescription.loadPaymentModule | validation | protected function loadPaymentModule(MopInfo $options)
{
if ($this->checkAnyNotEmpty(
$options->fopType,
$options->payMerchant,
$options->payments,
$options->installmentsInfo,
$options->mopPaymentType,
$options->creditCardInfo,
$options->fraudScreening,
$options->payIds,
$options->paySupData
)) {
if ($this instanceof MopDescription14) {
$this->paymentModule = new PaymentModule14($options->fopType);
} else {
$this->paymentModule = new PaymentModule($options->fopType);
}
$this->paymentModule->loadPaymentData($options);
$this->loadMopInformation($options);
$this->loadPaymentSupplementaryData($options);
}
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.