_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3 values | text stringlengths 83 13k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q3000 | SitemapGenerator.addAll | train | public function addAll($objects)
{
if (is_a($objects, 'Closure')) {
return $this->closures[] = $objects;
}
foreach ($objects as $object) {
$this->add($object);
}
} | php | {
"resource": ""
} |
q3001 | SitemapGenerator.addRaw | train | public function addRaw($data)
{
$this->validateData($data);
$data['location'] = trim($data['location'], '/');
$this->entries[] = $this->replaceAttributes($data);
} | php | {
"resource": ""
} |
q3002 | SitemapGenerator.contains | train | public function contains($url)
{
$url = trim($url, '/');
foreach ($this->entries as $entry) {
if ($entry['loc'] == $url) {
return TRUE;
}
}
return FALSE;
} | php | {
"resource": ""
} |
q3003 | SitemapGenerator.generateIndex | train | public function generateIndex()
{
$this->loadClosures();
$xml = new XMLWriter();
$xml->openMemory();
$xml->writeRaw('<?xml version="1.0" encoding="UTF-8"?>');
$xml->writeRaw('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
foreach ($this->entries as $data) {
$xml->startElement('sitemap');
foreach ($data as $attribute => $value) {
$xml->writeElement($attribute, $value);
}
$xml->endElement();
}
$xml->writeRaw('</sitemapindex>');
return $xml->outputMemory();
} | php | {
"resource": ""
} |
q3004 | SitemapGenerator.replaceAttributes | train | protected function replaceAttributes($data)
{
foreach ($data as $attribute => $value) {
$replacement = $this->replaceAttribute($attribute);
unset($data[$attribute]);
$data[$replacement] = $value;
}
return $data;
} | php | {
"resource": ""
} |
q3005 | SitemapGenerator.replaceAttribute | train | protected function replaceAttribute($attribute)
{
if (array_key_exists($attribute, $this->replacements)) {
return $this->replacements[$attribute];
}
return $attribute;
} | php | {
"resource": ""
} |
q3006 | SitemapGenerator.loadClosures | train | protected function loadClosures()
{
foreach ($this->closures as $closure) {
$instance = $closure();
if (is_array($instance) || $instance instanceof Traversable) {
$this->addAll($instance);
} else {
$this->add($instance);
}
}
} | php | {
"resource": ""
} |
q3007 | Tx_Oelib_ConfigCheck.checkTemplateFile | train | protected function checkTemplateFile($canUseFlexforms = false)
{
if (TYPO3_MODE === 'BE') {
return;
}
$this->checkForNonEmptyString(
'templateFile',
$canUseFlexforms,
's_template_special',
'This value specifies the HTML template which is essential when ' .
'creating any output from this extension.'
);
if (($this->getFrontEndController() !== null)
&& $this->objectToCheck->hasConfValueString('templateFile', 's_template_special')
) {
$rawFileName = $this->objectToCheck->getConfValueString(
'templateFile',
's_template_special',
true
);
if (!is_file($this->getFrontEndController()->tmpl->getFileName($rawFileName))) {
$message = 'The specified HTML template file <strong>'
. htmlspecialchars($rawFileName)
. '</strong> cannot be read. '
. 'The HTML template file is essential when creating any '
. 'output from this extension. '
. 'Please either create the file <strong>' . $rawFileName
. '</strong> or select an existing file using the TS setup '
. 'variable <strong>' . $this->getTSSetupPath()
. 'templateFile</strong>';
if ($canUseFlexforms) {
$message .= ' or via FlexForms';
}
$message .= '.';
$this->setErrorMessage($message);
}
}
} | php | {
"resource": ""
} |
q3008 | Tx_Oelib_ConfigCheck.checkForNonEmptyString | train | public function checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$value = $this->objectToCheck->getConfValueString($fieldName, $sheet);
$this->checkForNonEmptyStringValue(
$value,
$fieldName,
$canUseFlexforms,
$explanation
);
} | php | {
"resource": ""
} |
q3009 | Tx_Oelib_ConfigCheck.checkIfSingleInSetNotEmpty | train | protected function checkIfSingleInSetNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
array $allowedValues
) {
$this->checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIfSingleInSetOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$allowedValues
);
} | php | {
"resource": ""
} |
q3010 | Tx_Oelib_ConfigCheck.checkIfSingleInSetOrEmpty | train | protected function checkIfSingleInSetOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
array $allowedValues
) {
if ($this->objectToCheck->hasConfValueString($fieldName, $sheet)) {
$value = $this->objectToCheck->getConfValueString($fieldName, $sheet);
$this->checkIfSingleInSetOrEmptyValue(
$value,
$fieldName,
$canUseFlexforms,
$explanation,
$allowedValues
);
}
} | php | {
"resource": ""
} |
q3011 | Tx_Oelib_ConfigCheck.checkIfBoolean | train | protected function checkIfBoolean($fieldName, $canUseFlexforms, $sheet, $explanation)
{
$this->checkIfSingleInSetNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
['0', '1']
);
} | php | {
"resource": ""
} |
q3012 | Tx_Oelib_ConfigCheck.checkIfMultiInSetOrEmpty | train | protected function checkIfMultiInSetOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
array $allowedValues
) {
if ($this->objectToCheck->hasConfValueString($fieldName, $sheet)) {
$allValues = GeneralUtility::trimExplode(
',',
$this->objectToCheck->getConfValueString($fieldName, $sheet),
true
);
$overviewOfValues = '(' . implode(', ', $allowedValues) . ')';
foreach ($allValues as $currentValue) {
if (!in_array($currentValue, $allowedValues, true)) {
$message = 'The TS setup variable <strong>'
. $this->getTSSetupPath() . $fieldName
. '</strong> contains the value <strong>'
. htmlspecialchars($currentValue) . '</strong>, '
. 'but only the following values are allowed: '
. '<br /><strong>' . $overviewOfValues . '</strong><br />'
. $explanation;
$this->setErrorMessageAndRequestCorrection(
$fieldName,
$canUseFlexforms,
$message
);
}
}
}
} | php | {
"resource": ""
} |
q3013 | Tx_Oelib_ConfigCheck.checkIfSingleInTableNotEmpty | train | public function checkIfSingleInTableNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$tableName
) {
$this->checkIfSingleInSetNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$this->getDbColumnNames($tableName)
);
} | php | {
"resource": ""
} |
q3014 | Tx_Oelib_ConfigCheck.checkIfSingleInTableOrEmpty | train | protected function checkIfSingleInTableOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$tableName
) {
$this->checkIfSingleInSetOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$this->getDbColumnNames($tableName)
);
} | php | {
"resource": ""
} |
q3015 | Tx_Oelib_ConfigCheck.checkIfMultiInTableOrEmpty | train | protected function checkIfMultiInTableOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$tableName
) {
$this->checkIfMultiInSetOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$this->getDbColumnNames($tableName)
);
} | php | {
"resource": ""
} |
q3016 | Tx_Oelib_ConfigCheck.checkRegExp | train | protected function checkRegExp(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$regExp
) {
$value = $this->objectToCheck->getConfValueString($fieldName, $sheet);
if (!preg_match($regExp, $value)) {
$message = 'The TS setup variable <strong>' . $this->getTSSetupPath()
. $fieldName . '</strong> contains the value <strong>'
. htmlspecialchars($value) . '</strong> which isn\'t valid. '
. $explanation;
$this->setErrorMessageAndRequestCorrection(
$fieldName,
$canUseFlexforms,
$message
);
}
} | php | {
"resource": ""
} |
q3017 | Tx_Oelib_ConfigCheck.checkRegExpNotEmpty | train | protected function checkRegExpNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$regExp
) {
$this->checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkRegExp(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$regExp
);
} | php | {
"resource": ""
} |
q3018 | Tx_Oelib_ConfigCheck.checkIfFePagesNotEmpty | train | protected function checkIfFePagesNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIfFePagesOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
} | php | {
"resource": ""
} |
q3019 | Tx_Oelib_ConfigCheck.checkIfSingleFePageNotEmpty | train | protected function checkIfSingleFePageNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfPositiveInteger(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIfFePagesOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
} | php | {
"resource": ""
} |
q3020 | Tx_Oelib_ConfigCheck.checkIfSingleFePageOrEmpty | train | protected function checkIfSingleFePageOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfInteger($fieldName, $canUseFlexforms, $sheet, $explanation);
$this->checkIfFePagesOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
} | php | {
"resource": ""
} |
q3021 | Tx_Oelib_ConfigCheck.checkIfSysFoldersNotEmpty | train | protected function checkIfSysFoldersNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIfSysFoldersOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
} | php | {
"resource": ""
} |
q3022 | Tx_Oelib_ConfigCheck.checkIfSingleSysFolderNotEmpty | train | protected function checkIfSingleSysFolderNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfPositiveInteger(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIfSysFoldersOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
} | php | {
"resource": ""
} |
q3023 | Tx_Oelib_ConfigCheck.checkIfSingleSysFolderOrEmpty | train | protected function checkIfSingleSysFolderOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfInteger(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIfSysFoldersOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
} | php | {
"resource": ""
} |
q3024 | Tx_Oelib_ConfigCheck.checkIfSysFoldersOrEmpty | train | protected function checkIfSysFoldersOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$pids = $this->objectToCheck->getConfValueString($fieldName, $sheet);
// Uses the plural if the configuration value is empty or contains a
// comma.
if (($pids === '') || (strrpos($pids, ',') !== false)) {
$message = 'All the selected pages need to be system folders so '
. 'that data records are tidily separated from front-end '
. 'content. ' . $explanation;
} else {
$message = 'The selected page needs to be a system folder so that '
. 'data records are tidily separated from front-end content. '
. $explanation;
}
$this->checkPageTypeOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$message,
'=254'
);
} | php | {
"resource": ""
} |
q3025 | Tx_Oelib_ConfigCheck.checkPageTypeOrEmpty | train | protected function checkPageTypeOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$typeCondition
) {
$this->checkIfPidListOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
if ($this->objectToCheck->hasConfValueString($fieldName, $sheet)) {
$pids = $this->objectToCheck->getConfValueString($fieldName, $sheet);
$offendingPids = \Tx_Oelib_Db::selectColumnForMultiple(
'uid',
'pages',
'uid IN (' . $pids . ') AND NOT (doktype' . $typeCondition . ')' .
\Tx_Oelib_Db::enableFields('pages')
);
$dbResultCount = count($offendingPids);
if ($dbResultCount > 0) {
$pageIdPlural = ($dbResultCount > 1) ? 's' : '';
$bePlural = ($dbResultCount > 1) ? 'are' : 'is';
$message = 'The TS setup variable <strong>' .
$this->getTSSetupPath() . $fieldName .
'</strong> contains the page ID' . $pageIdPlural .
' <strong>' . implode(',', $offendingPids) . '</strong> ' .
'which ' . $bePlural . ' of an incorrect page type. ' .
$explanation . '<br />';
$this->setErrorMessageAndRequestCorrection(
$fieldName,
$canUseFlexforms,
$message
);
}
}
} | php | {
"resource": ""
} |
q3026 | Tx_Oelib_ConfigCheck.checkListViewIfSingleInSetNotEmpty | train | protected function checkListViewIfSingleInSetNotEmpty(
$fieldName,
$explanation,
array $allowedValues
) {
$fieldSubPath = 'listView.' . $fieldName;
$value = $this->objectToCheck->getListViewConfValueString($fieldName);
$this->checkForNonEmptyStringValue(
$value,
$fieldSubPath,
false,
$explanation
);
$this->checkIfSingleInSetOrEmptyValue(
$value,
$fieldSubPath,
false,
$explanation,
$allowedValues
);
} | php | {
"resource": ""
} |
q3027 | Tx_Oelib_ConfigCheck.checkIsValidEmailOrEmpty | train | public function checkIsValidEmailOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$unused,
$explanation
) {
$value = $this->objectToCheck->getConfValueString($fieldName, $sheet);
if ($value === '') {
return;
}
if (!GeneralUtility::validEmail($value)) {
$message = 'The e-mail address in <strong>' . $this->getTSSetupPath()
. $fieldName . '</strong> is set to <strong>' . $value . '</strong> '
. 'which is not valid. E-mails might not be received as long as '
. 'this address is invalid.<br />';
$this->setErrorMessageAndRequestCorrection(
$fieldName,
$canUseFlexforms,
$message . $explanation
);
}
} | php | {
"resource": ""
} |
q3028 | Tx_Oelib_ConfigCheck.checkIsValidEmailNotEmpty | train | public function checkIsValidEmailNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$allowInternalAddresses,
$explanation
) {
$this->checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
);
$this->checkIsValidEmailOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$allowInternalAddresses,
$explanation
);
} | php | {
"resource": ""
} |
q3029 | Tx_Oelib_TranslatorRegistry.setLanguageKeyFromConfiguration | train | private function setLanguageKeyFromConfiguration(\Tx_Oelib_Configuration $configuration)
{
if (!$configuration->hasString('language')) {
return;
}
$this->languageKey = $configuration->getAsString('language');
if ($configuration->hasString('language_alt')) {
$this->alternativeLanguageKey = $configuration->getAsString('language_alt');
}
} | php | {
"resource": ""
} |
q3030 | Tx_Oelib_TranslatorRegistry.initializeBackEnd | train | private function initializeBackEnd()
{
$backEndUser =
\Tx_Oelib_BackEndLoginManager::getInstance()->getLoggedInUser(\Tx_Oelib_Mapper_BackEndUser::class);
$this->languageKey = $backEndUser->getLanguage();
} | php | {
"resource": ""
} |
q3031 | Tx_Oelib_TranslatorRegistry.getByExtensionName | train | private function getByExtensionName($extensionName)
{
if ($extensionName === '') {
throw new \InvalidArgumentException('The parameter $extensionName must not be empty.', 1331489578);
}
if (!ExtensionManagementUtility::isLoaded($extensionName)) {
throw new \BadMethodCallException(
'The extension with the name "' . $extensionName . '" is not loaded.',
1331489598
);
}
if (!isset($this->translators[$extensionName])) {
$localizedLabels = $this->getLocalizedLabelsFromFile($extensionName);
// Overrides the localized labels with labels from TypoScript only
// in the front end.
if (($this->getFrontEndController() !== null)
&& isset($localizedLabels[$this->languageKey])
&& is_array($localizedLabels[$this->languageKey])
) {
$labelsFromTyposcript = $this->getLocalizedLabelsFromTypoScript($extensionName);
foreach ($labelsFromTyposcript as $labelKey => $labelFromTyposcript) {
$localizedLabels[$this->languageKey][$labelKey][0]['target'] = $labelFromTyposcript;
}
}
/** @var \Tx_Oelib_Translator $translator */
$translator = GeneralUtility::makeInstance(
\Tx_Oelib_Translator::class,
$this->languageKey,
$this->alternativeLanguageKey,
$localizedLabels
);
$this->translators[$extensionName] = $translator;
}
return $this->translators[$extensionName];
} | php | {
"resource": ""
} |
q3032 | Tx_Oelib_TranslatorRegistry.getLocalizedLabelsFromFile | train | private function getLocalizedLabelsFromFile($extensionKey)
{
if ($extensionKey === '') {
throw new \InvalidArgumentException('$extensionKey must not be empty.', 1331489618);
}
/** @var LocalizationFactory $languageFactory */
$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
$languageFile = 'EXT:' . $extensionKey . '/' . self::LANGUAGE_FILE_PATH;
$localizedLabels = $languageFactory->getParsedData($languageFile, $this->languageKey, 'utf-8', 0);
if ($this->alternativeLanguageKey !== '') {
$alternativeLabels = $languageFactory->getParsedData($languageFile, $this->languageKey, 'utf-8', 0);
$localizedLabels = array_merge(
$alternativeLabels,
is_array($localizedLabels) ? $localizedLabels : []
);
}
return $localizedLabels;
} | php | {
"resource": ""
} |
q3033 | Tx_Oelib_TranslatorRegistry.getLocalizedLabelsFromTypoScript | train | private function getLocalizedLabelsFromTypoScript($extensionName)
{
if ($extensionName === '') {
throw new \InvalidArgumentException('The parameter $extensionName must not be empty.', 1331489630);
}
$result = [];
$namespace = 'plugin.tx_' . $extensionName . '._LOCAL_LANG.' . $this->languageKey;
$configuration = \Tx_Oelib_ConfigurationRegistry::get($namespace);
foreach ($configuration->getArrayKeys() as $key) {
$result[$key] = $configuration->getAsString($key);
}
return $result;
} | php | {
"resource": ""
} |
q3034 | Tracker.getCurrent | train | public function getCurrent()
{
if (is_null($this->current))
{
$siteView = $this->makeNewViewModel();
$this->current = $siteView;
}
return $this->current;
} | php | {
"resource": ""
} |
q3035 | Tracker.collectVisitData | train | protected function collectVisitData()
{
$request = $this->request;
$user = $request->user();
$userId = $user ? $user->getKey() : null;
return [
'user_id' => $userId,
'http_referer' => $request->server('HTTP_REFERER'),
'url' => $request->fullUrl(),
'request_method' => $request->method(),
'request_path' => $request->getPathInfo(),
'http_user_agent' => $request->server('HTTP_USER_AGENT'),
'http_accept_language' => $request->server('HTTP_ACCEPT_LANGUAGE'),
'locale' => $this->app->getLocale(),
'request_time' => $request->server('REQUEST_TIME')
];
} | php | {
"resource": ""
} |
q3036 | Tracker.saveCurrent | train | public function saveCurrent()
{
if ($this->saveEnabled() && $this->isViewValid() && $this->isViewUnique())
{
$success = $this->saveCurrentModel();
// Keep on only if the model save has succeeded
if ($success)
{
$this->storeCurrentHash();
$this->saveTrackables(
$this->getCurrent(),
$success
);
}
return $success;
}
return false;
} | php | {
"resource": ""
} |
q3037 | Tracker.isViewUnique | train | public function isViewUnique()
{
$hash = $this->getCurrentHash();
if (in_array($hash, $this->session->get('tracker.views', [])))
{
return false;
}
return true;
} | php | {
"resource": ""
} |
q3038 | Tracker.getCurrentHash | train | protected function getCurrentHash()
{
if ($this->currentHash === null)
{
$this->currentHash = md5(
$this->request->fullUrl() .
$this->request->method() .
$this->request->getClientIp()
);
}
return $this->currentHash;
} | php | {
"resource": ""
} |
q3039 | Tracker.saveCurrentModel | train | protected function saveCurrentModel()
{
$current = $this->getCurrent();
$current->setAttribute('app_time', $this->getCurrentRuntime());
$current->setAttribute('memory', memory_get_peak_usage(true));
return $current->save();
} | php | {
"resource": ""
} |
q3040 | Tracker.saveTrackables | train | protected function saveTrackables($view, $success)
{
foreach ($this->trackables as $trackable)
{
$trackable->attachTrackerView($view);
}
return $success;
} | php | {
"resource": ""
} |
q3041 | Tracker.flushOlderThanOrBetween | train | public function flushOlderThanOrBetween($until = null, $from = null)
{
$modelName = $this->getViewModelName();
return $modelName::olderThanOrBetween($until, $from)->delete();
} | php | {
"resource": ""
} |
q3042 | DataTablesMappingHelper.getComparator | train | public static function getComparator(DataTablesMappingInterface $mapping) {
if (null === $mapping->getParent()) {
return "LIKE";
}
switch ($mapping->getParent()->getType()) {
case DataTablesColumnInterface::DATATABLES_TYPE_DATE:
case DataTablesColumnInterface::DATATABLES_TYPE_HTML_NUM:
case DataTablesColumnInterface::DATATABLES_TYPE_NUM:
case DataTablesColumnInterface::DATATABLES_TYPE_NUM_FMT:
return "=";
}
return "LIKE";
} | php | {
"resource": ""
} |
q3043 | DataTablesMappingHelper.getWhere | train | public static function getWhere(DataTablesMappingInterface $mapping) {
$where = [
static::getAlias($mapping),
static::getComparator($mapping),
static::getParam($mapping),
];
return implode(" ", $where);
} | php | {
"resource": ""
} |
q3044 | DataTablesController.deleteAction | train | public function deleteAction(Request $request, $name, $id) {
$dtProvider = $this->getDataTablesProvider($name);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_DELETE, [$entity]);
$em = $this->getDoctrine()->getManager();
$em->remove($entity);
$em->flush();
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_DELETE, [$entity]);
$output = $this->prepareActionResponse(200, "DataTablesController.deleteAction.success");
} catch (Exception $ex) {
$output = $this->handleDataTablesException($ex, "DataTablesController.deleteAction");
}
return $this->buildDataTablesResponse($request, $name, $output);
} | php | {
"resource": ""
} |
q3045 | DataTablesController.editAction | train | public function editAction(Request $request, $name, $id, $data, $value) {
$dtProvider = $this->getDataTablesProvider($name);
$dtEditor = $this->getDataTablesEditor($dtProvider);
$dtColumn = $this->getDataTablesColumn($dtProvider, $data);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
if (true === $request->isMethod(HTTPInterface::HTTP_METHOD_POST)) {
$value = $request->request->get("value");
}
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_EDIT, [$entity]);
$dtEditor->editColumn($dtColumn, $entity, $value);
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_POST_EDIT, [$entity]);
$output = $this->prepareActionResponse(200, "DataTablesController.editAction.success");
} catch (Exception $ex) {
$output = $this->handleDataTablesException($ex, "DataTablesController.editAction");
}
return new JsonResponse($output);
} | php | {
"resource": ""
} |
q3046 | DataTablesController.exportAction | train | public function exportAction(Request $request, $name) {
$windows = DataTablesExportHelper::isWindows($request);
$dtProvider = $this->getDataTablesProvider($name);
$dtExporter = $this->getDataTablesCSVExporter($dtProvider);
$repository = $this->getDataTablesRepository($dtProvider);
$filename = (new DateTime())->format("Y.m.d-H.i.s") . "-" . $dtProvider->getName() . ".csv";
$charset = true === $windows ? "iso-8859-1" : "utf-8";
$response = new StreamedResponse();
$response->headers->set("Content-Disposition", "attachment; filename=\"" . $filename . "\"");
$response->headers->set("Content-Type", "text/csv; charset=" . $charset);
$response->setCallback(function() use ($dtProvider, $repository, $dtExporter, $windows) {
$this->exportDataTablesCallback($dtProvider, $repository, $dtExporter, $windows);
});
$response->setStatusCode(200);
return $response;
} | php | {
"resource": ""
} |
q3047 | DataTablesController.optionsAction | train | public function optionsAction($name) {
$dtProvider = $this->getDataTablesProvider($name);
$dtWrapper = $this->getDataTablesWrapper($dtProvider);
$dtOptions = DataTablesWrapperHelper::getOptions($dtWrapper);
return new JsonResponse($dtOptions);
} | php | {
"resource": ""
} |
q3048 | DataTablesController.showAction | train | public function showAction($name, $id) {
$dtProvider = $this->getDataTablesProvider($name);
try {
$entity = $this->getDataTablesEntityById($dtProvider, $id);
$this->dispatchDataTablesEvent(DataTablesEvents::DATATABLES_PRE_SHOW, [$entity]);
} catch (EntityNotFoundException $ex) {
$this->getLogger()->debug($ex->getMessage());
$entity = [];
}
$serializer = $this->getDataTablesSerializer();
return new Response($serializer->serialize($entity, "json"), 200, ["Content-type" => "application/json"]);
} | php | {
"resource": ""
} |
q3049 | Autoload.loadPsr4 | train | public function loadPsr4()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->loadPsr4Group($data['always']);
}
// These only in admin
if (is_admin() && isset($data['admin']))
{
$this->loadPsr4Group($data['admin']);
}
// These only in frontend
if ( !is_admin() && isset($data['frontend']))
{
$this->loadPsr4Group($data['frontend']);
}
} | php | {
"resource": ""
} |
q3050 | Autoload.instantiateClasses | train | public function instantiateClasses()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->instantiateGroup($data['always']);
}
// These only in admin
if (is_admin() && isset($data['admin']))
{
$this->instantiateGroup($data['admin']);
}
// These only in frontend
if ( !is_admin() && isset($data['frontend']))
{
$this->instantiateGroup($data['frontend']);
}
} | php | {
"resource": ""
} |
q3051 | Autoload.loadPsr4Group | train | private function loadPsr4Group($group)
{
if ( !isset($group['psr4']))
{
return;
}
foreach ($group['psr4'] as $prefix => $paths)
{
$this->objectRegistry->addPsr4($prefix, $paths);
}
} | php | {
"resource": ""
} |
q3052 | Autoload.instantiateGroup | train | private function instantiateGroup($group)
{
if ( !isset($group['instantiate']))
{
return;
}
foreach ($group['instantiate'] as $nickname => $className)
{
$this->objectRegistry->register($nickname, new $className());
}
} | php | {
"resource": ""
} |
q3053 | User.createUser | train | private function createUser(array $user)
{
$this->fields = [
'id' => $this->getValue('id', $user),
'name' => $this->getValue('name', $user),
'username' => $this->getValue('username', $user),
'description' => $this->getValue('description', $user),
'location' => $this->getValue('location', $user),
'url' => $this->getValue('url', $user),
'followers_count' => $this->getValue('followers_count', $user),
'friends_count' => $this->getValue('friends_count', $user),
'favourites_count' => $this->getValue('favourites_count', $user),
'listed_count' => $this->getValue('listed_count', $user),
'created_at' => $this->getValue('created_at', $user)
];
} | php | {
"resource": ""
} |
q3054 | Customizer.configureKirki | train | public function configureKirki()
{
// These cannot be setup above directly, do it now
self::$OPTIONS_DEFAULTS['logo_image'] = Urls::assets('images/admin/customizer.png');
self::$OPTIONS_DEFAULTS['url_path'] = Urls::baobabFramework('vendor/aristath/kirki/');
// Todo pull description from somewhere where it is already defined
self::$OPTIONS_DEFAULTS['description'] = Strings::translate('This is the theme description');
$data = $this->getData();
return array_merge(self::$OPTIONS_DEFAULTS, $data['options']);
} | php | {
"resource": ""
} |
q3055 | Customizer.registerControls | train | public function registerControls($controls)
{
$data = $this->getData();
$customControls = $data['controls'];
foreach ($customControls as &$c) {
$c['label'] = $this->translateValueIfKeyExists($c, 'label');
$c['description'] = $this->translateValueIfKeyExists($c, 'description');
$c['default'] = $this->translateValueIfKeyExists($c, 'default');
$c['help'] = $this->translateValueIfKeyExists($c, 'help');
if (isset($c['choices'])) {
foreach ($c['choices'] as $id => $label) {
if (isset($label)) {
$c['choices'][$id] = Strings::translate($label);
}
}
}
}
return array_merge($controls, $customControls);
} | php | {
"resource": ""
} |
q3056 | Customizer.createPanels | train | public function createPanels($wp_customize)
{
$data = $this->getData();
// Move all default sections to the default panel
$defaultPanel = $data['options']['default_panel'];
$wp_customize->add_panel($defaultPanel['id'], array(
'priority' => 10,
'title' => Strings::translate($defaultPanel['title']),
'description' => ''
));
$existingSections = $wp_customize->sections();
/** @var \WP_Customize_Section $section */
foreach ($existingSections as $sectionId => $section) {
if (empty($section->panel)) {
$section->panel = $defaultPanel['id'];
}
}
// Define additional panels and sections
$panels = $data['panels'];
$panelPriority = 1000;
foreach ($panels as $panelProps) {
if (isset($panelProps['title'])) {
$panelId = 'panel-' . $panelPriority;
$wp_customize->add_panel($panelId, array(
'priority' => $panelPriority,
'title' => Strings::translate($panelProps['title']),
'description' => Strings::translate($panelProps['description'])
));
} else {
$panelId = $defaultPanel['id'];
}
$sectionPriority = 10;
foreach ($panelProps['sections'] as $sectionId => $sectionProps) {
$wp_customize->add_section($sectionId, array(
'panel' => $panelId,
'priority' => $sectionPriority,
'title' => Strings::translate($sectionProps['title']),
'description' => Strings::translate($sectionProps['description'])
));
$sectionPriority += 10;
}
$panelPriority += 10;
}
return $wp_customize;
} | php | {
"resource": ""
} |
q3057 | Twitter.getTweetsFromUser | train | public function getTweetsFromUser($username, $count = 10, $cacheMinutes = 30, $returnEntities = true)
{
$count = $this->getVerifiedCount($count, 1, 200);
$endpoint = '/statuses/user_timeline.json';
$url = $this->urlHelper->joinSlugs([$this->baseUrl, $this->apiVersion, $endpoint]);
$data = [
'screen_name' => $username,
'count' => $count
];
$headers = [
'Authorization' => 'Bearer ' . $this->requestAppAccessToken()
];
$response = $this->courier->get($url, $data, $headers, $cacheMinutes);
if ($returnEntities)
{
$tweets = $response->toArray();
$response = $this->createTweetEntities($tweets);
}
return $response;
} | php | {
"resource": ""
} |
q3058 | PreUserController.indexAction | train | public function indexAction()
{
$em = $this->getDoctrine()->getEntityManager();
$entities = $em->getRepository('DMSLauncherBundle:PreUser')->findAll();
return array('entities' => $entities);
} | php | {
"resource": ""
} |
q3059 | PreUserController.showAction | train | public function showAction($id)
{
$em = $this->getDoctrine()->getEntityManager();
$entity = $em->getRepository('DMSLauncherBundle:PreUser')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find PreUser entity.');
}
return array(
'entity' => $entity,
'referralCount' => $em->getRepository('DMSLauncherBundle:PreUser')->getReferralsCount($entity->getToken()),
);
} | php | {
"resource": ""
} |
q3060 | CloudStorage.containers | train | public function containers($limit = 10000, $marker = '')
{
$response = $this->api->request('GET', '/', [
'query' => [
'limit' => intval($limit),
'marker' => $marker,
],
]);
if ($response->getStatusCode() !== 200) {
throw new ApiRequestFailedException('Unable to list containers.', $response->getStatusCode());
}
$containers = json_decode($response->getBody(), true);
return new Collection($this->transformContainers($containers));
} | php | {
"resource": ""
} |
q3061 | CloudStorage.createContainer | train | public function createContainer($name, $type = 'public')
{
if (!in_array($type, ['public', 'private', 'gallery'])) {
throw new InvalidArgumentException('Unknown type "'.$type.'" provided.');
}
$response = $this->api->request('PUT', '/'.trim($name, '/'), [
'headers' => [
'X-Container-Meta-Type' => $type,
],
]);
switch ($response->getStatusCode()) {
case 201:
return $this->getContainer(trim($name, '/'));
case 202:
throw new ApiRequestFailedException('Container "'.$name.'" already exists.');
default:
throw new ApiRequestFailedException('Unable to create container "'.$name.'".', $response->getStatusCode());
}
} | php | {
"resource": ""
} |
q3062 | CloudStorage.transformContainers | train | protected function transformContainers(array $items)
{
if (!count($items)) {
return [];
}
$containers = [];
foreach ($items as $item) {
$container = new Container($this->api, $this->uploader, $item['name'], $item);
$containers[$container->name()] = $container;
}
return $containers;
} | php | {
"resource": ""
} |
q3063 | KnowledgebaseServiceProvider.setupMigrations | train | protected function setupMigrations()
{
$migrations = realpath(__DIR__.'/../database/migrations');
$this->publishes([
$migrations => $this->app->databasePath() . '/migrations',
]);
} | php | {
"resource": ""
} |
q3064 | KnowledgebaseServiceProvider.setupSeeds | train | protected function setupSeeds()
{
$seeds = realpath(__DIR__.'/../database/seeds');
$this->publishes([
$seeds => $this->app->databasePath() . '/seeds',
]);
} | php | {
"resource": ""
} |
q3065 | Tx_Oelib_MailerFactory.getMailer | train | public function getMailer()
{
if ($this->isTestMode) {
$className = \Tx_Oelib_EmailCollector::class;
} else {
$className = \Tx_Oelib_RealMailer::class;
}
if (!is_object($this->mailer) || (get_class($this->mailer) !== $className)) {
$this->mailer = GeneralUtility::makeInstance($className);
}
return $this->mailer;
} | php | {
"resource": ""
} |
q3066 | TwitterBase.requestAppAccessToken | train | protected function requestAppAccessToken()
{
$credentials = $this->authHelper->generateAppCredentials($this->apiKey, $this->apiSecret);
$endpoint = '/oauth2/token';
$url = $this->urlHelper->joinSlugs([$this->baseUrl, $endpoint]);
$data = ['grant_type' => 'client_credentials'];
$headers = [
'Authorization' => 'Basic ' . $credentials,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
];
$response = $this->courier->post($url, $data, $headers)->toArray();
return $response['access_token'];
} | php | {
"resource": ""
} |
q3067 | TwitterBase.getVerifiedCount | train | protected function getVerifiedCount($count, $min = 1, $max = 100)
{
settype($count, "integer");
settype($min, "integer");
settype($max, "integer");
// If $min is greater than $max,
// use the smallest of the two ($max)
if ($min > $max) $min = $max;
if ($count < $min)
{
$count = $min;
}
elseif ($count > $max)
{
$count = $max;
}
return $count;
} | php | {
"resource": ""
} |
q3068 | TwitterBase.createTweetEntities | train | protected function createTweetEntities($tweets)
{
$entities = [];
foreach ($tweets as $tweet)
{
$user = $this->twitterFactory->createUser($tweet['user']);
$entities[] = $this->twitterFactory->createTweet($tweet, $user);
}
return $entities;
} | php | {
"resource": ""
} |
q3069 | Laravel4.registerConfigurator | train | private function registerConfigurator()
{
$this->app->bind('CodeZero\Twitter\Twitter', function($app)
{
$config = $app['config']->has("twitter")
? $app['config']->get("twitter")
: $app['config']->get("twitter::config");
$configurator = new \CodeZero\Configurator\DefaultConfigurator();
$courier = $app->make('CodeZero\Twitter\TwitterCourier');
$authHelper = new \CodeZero\Twitter\AuthHelper();
$urlHelper = new \CodeZero\Utilities\UrlHelper();
$twitterFactory = new \CodeZero\Twitter\TwitterFactory();
return new \CodeZero\Twitter\Twitter($config, $configurator, $courier, $authHelper, $urlHelper, $twitterFactory);
});
} | php | {
"resource": ""
} |
q3070 | DefaultController.registerAction | train | public function registerAction()
{
$entity = new PreUser();
$request = $this->getRequest();
$form = $this->createForm(new RegistrationForm(), $entity);
$form->bindRequest($request);
if ($form->isValid()) {
$entity->setRegisteredOn(new \DateTime('now'));
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
//Generate Token based on ID assigned
$entity->setToken(base_convert($entity->getId() + 100000000, 10, 32));
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('launcher_done', array('token' => $entity->getToken())));
}
return array(
'entity' => $entity,
'form' => $form->createView()
);
} | php | {
"resource": ""
} |
q3071 | LanguageKsh.commafy | train | public function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
return strrev( (string)preg_replace( '/(\d{3})(?=\d)(?!\d*\.)/', '$1,', strrev( $_ ) ) );
} else {
return $_;
}
} | php | {
"resource": ""
} |
q3072 | GiroCheckout_SDK_Request.addParam | train | public function addParam($param, $value) {
if (!$this->requestMethod->hasParam($param)) {
throw new GiroCheckout_SDK_Exception_helper('Failure: param "' . $param . '" not valid or misspelled. Please check API Params List.');
}
if ($value instanceof GiroCheckout_SDK_Request_Cart) {
$this->params[$param] = $value->getAllItems();
}
else {
$this->params[$param] = $value;
}
return $this;
} | php | {
"resource": ""
} |
q3073 | GiroCheckout_SDK_Request.getResponseParam | train | public function getResponseParam($param) {
if (isset($this->response[$param])) {
return $this->response[$param];
}
return null;
} | php | {
"resource": ""
} |
q3074 | GiroCheckout_SDK_Request.redirectCustomerToPaymentProvider | train | public function redirectCustomerToPaymentProvider() {
if (isset($this->response['redirect'])) {
header('location:' . $this->response['redirect']);
exit;
}
elseif (isset($this->response['url'])) {
header('location:' . $this->response['url']);
exit;
}
} | php | {
"resource": ""
} |
q3075 | MobileDetectExtension.getAvailableDevices | train | public function getAvailableDevices()
{
$availableDevices = array();
$rules = array_change_key_case($this->detector->getRules());
foreach ($rules as $device => $rule) {
$availableDevices[$device] = static::fromCamelCase($device);
}
return $availableDevices;
} | php | {
"resource": ""
} |
q3076 | ClassMetadataFactory.loadInterfaceMetadata | train | protected function loadInterfaceMetadata($metadata)
{
foreach( $metadata->getReflectionClass()->getInterfaces() as $interface ) {
$metadata->mergeRules($this->getClassMetadata($interface->getName()));
}
} | php | {
"resource": ""
} |
q3077 | GiroCheckout_SDK_AbstractApi.hasParam | train | public function hasParam($paramName) {
if (isset($this->paramFields[$paramName])) {
return true;
}
elseif ('sourceId' === $paramName) {
return true;
} //default field due to support issues
elseif ('userAgent' === $paramName) {
return true;
} //default field due to support issues
elseif ('orderId' === $paramName) {
return true;
} //default field due to support issues
elseif ('customerId' === $paramName) {
return true;
} //default field due to support issues
return false;
} | php | {
"resource": ""
} |
q3078 | GiroCheckout_SDK_AbstractApi.getSubmitParams | train | public function getSubmitParams($params) {
$submitParams = array();
foreach ($this->paramFields as $k => $mandatory) {
if (isset($params[$k]) && strlen($params[$k]) > 0) {
$submitParams[$k] = $params[$k];
}
elseif ((!isset($params[$k]) || strlen($params[$k]) == 0) && $mandatory) {
throw new \Exception('mandatory field ' . $k . ' is unset or empty');
}
}
return $submitParams;
} | php | {
"resource": ""
} |
q3079 | GiroCheckout_SDK_AbstractApi.checkResponse | train | public function checkResponse($response) {
if (!is_array($response)) {
return FALSE;
}
$responseParams = array();
foreach ($this->responseFields as $k => $mandatory) {
if (isset($response[$k])) {
$responseParams[$k] = $response[$k];
}
elseif (!isset($response[$k]) && $mandatory) {
throw new \Exception('expected response field ' . $k . ' is missing');
}
}
return $responseParams;
} | php | {
"resource": ""
} |
q3080 | GiroCheckout_SDK_AbstractApi.checkNotification | train | public function checkNotification($notify) {
if (!is_array($notify)) {
return FALSE;
}
$notifyParams = array();
foreach ($this->notifyFields as $k => $mandatory) {
if (isset($notify[$k])) {
$notifyParams[$k] = $notify[$k];
}
elseif (!isset($notify[$k]) && $mandatory) {
throw new \Exception('expected notification field ' . $k . ' is missing');
}
}
return $notifyParams;
} | php | {
"resource": ""
} |
q3081 | Assets.registerAssets | train | public function registerAssets()
{
$data = $this->getData();
// Read the assets manifest file if it exists
$manifest = $this->loadManifest();
if (isset($data['styles']))
{
foreach ($data['styles'] as $handle => $props)
{
$this->handleStyleAction('register', $handle, $props, $manifest);
}
}
if (isset($data['scripts']))
{
foreach ($data['scripts'] as $handle => $props)
{
$this->handleScriptAction('register', $handle, $props, $manifest);
}
}
} | php | {
"resource": ""
} |
q3082 | Assets.enqueueAssets | train | public function enqueueAssets()
{
$data = $this->getData();
if (isset($data['editor']))
{
// Tell the TinyMCE editor to use a custom stylesheet
add_editor_style($data['editor']);
}
if (isset($data['styles']))
{
foreach ($data['styles'] as $handle => $props)
{
$this->handleStyleAction('enqueue', $handle, $props);
}
}
if (isset($data['scripts']))
{
foreach ($data['scripts'] as $handle => $props)
{
$this->handleScriptAction('enqueue', $handle, $props);
}
}
} | php | {
"resource": ""
} |
q3083 | Assets.loadManifest | train | protected function loadManifest()
{
$manifestPath = Paths::assets('manifest.json');
if (file_exists($manifestPath))
{
return json_decode(file_get_contents($manifestPath), true);
}
return null;
} | php | {
"resource": ""
} |
q3084 | Container.objectData | train | protected function objectData($key, $default = null)
{
if (!$this->dataLoaded) {
$this->loadContainerData();
}
return isset($this->data[$key]) ? $this->data[$key] : $default;
} | php | {
"resource": ""
} |
q3085 | Container.loadContainerData | train | protected function loadContainerData()
{
// CloudStorage::containers and CloudStorage::getContainer methods did not
// produce any requests to Selectel API, since it may be unnecessary if
// user only wants to upload/manage files or delete container via API.
// If user really wants some container info, we will load
// it here on demand. This speeds up application a bit.
$response = $this->api->request('HEAD', $this->absolutePath());
if ($response->getStatusCode() !== 204) {
throw new ApiRequestFailedException('Container "'.$this->name().'" was not found.');
}
$this->dataLoaded = true;
// We will extract some headers from response
// and assign them as container data. Also
// we'll try to find any container Meta.
$this->data = [
'type' => $response->getHeaderLine('X-Container-Meta-Type'),
'count' => intval($response->getHeaderLine('X-Container-Object-Count')),
'bytes' => intval($response->getHeaderLine('X-Container-Bytes-Used')),
'rx_bytes' => intval($response->getHeaderLine('X-Received-Bytes')),
'tx_bytes' => intval($response->getHeaderLine('X-Transfered-Bytes')),
'meta' => $this->extractMetaData($response),
];
} | php | {
"resource": ""
} |
q3086 | Container.jsonSerialize | train | public function jsonSerialize()
{
return [
'name' => $this->name(),
'type' => $this->type(),
'files_count' => $this->filesCount(),
'size' => $this->size(),
'uploaded_bytes' => $this->uploadedBytes(),
'downloaded_bytes' => $this->downloadedBytes(),
];
} | php | {
"resource": ""
} |
q3087 | Container.setType | train | public function setType($type)
{
if ($this->type() === $type) {
return $type;
}
// Catch any API Request Exceptions here
// so we can replace exception message
// with more informative one.
try {
$this->setMeta(['Type' => $type]);
} catch (ApiRequestFailedException $e) {
throw new ApiRequestFailedException('Unable to set container type to "'.$type.'".', $e->getCode());
}
return $this->data['type'] = $type;
} | php | {
"resource": ""
} |
q3088 | Container.createDir | train | public function createDir($name)
{
$response = $this->api->request('PUT', $this->absolutePath($name), [
'headers' => [
'Content-Type' => 'application/directory',
],
]);
if ($response->getStatusCode() !== 201) {
throw new ApiRequestFailedException('Unable to create directory "'.$name.'".', $response->getStatusCode());
}
return $response->getHeaderLine('ETag');
} | php | {
"resource": ""
} |
q3089 | Container.deleteDir | train | public function deleteDir($name)
{
$response = $this->api->request('DELETE', $this->absolutePath($name));
if ($response->getStatusCode() !== 204) {
throw new ApiRequestFailedException('Unable to delete directory "'.$name.'".', $response->getStatusCode());
}
return true;
} | php | {
"resource": ""
} |
q3090 | Container.uploadFromString | train | public function uploadFromString($path, $contents, array $params = [], $verifyChecksum = true)
{
return $this->uploader->upload($this->api, $this->absolutePath($path), $contents, $params, $verifyChecksum);
} | php | {
"resource": ""
} |
q3091 | Container.uploadFromStream | train | public function uploadFromStream($path, $resource, array $params = [])
{
return $this->uploader->upload($this->api, $this->absolutePath($path), $resource, $params, false);
} | php | {
"resource": ""
} |
q3092 | Container.delete | train | public function delete()
{
$response = $this->api->request('DELETE', $this->absolutePath());
switch ($response->getStatusCode()) {
case 204:
// Container removed.
return;
case 404:
throw new ApiRequestFailedException('Container "'.$this->name().'" was not found.');
case 409:
throw new ApiRequestFailedException('Container must be empty.');
}
} | php | {
"resource": ""
} |
q3093 | Tx_Oelib_Model_FrontEndUser.getName | train | public function getName()
{
if ($this->hasString('name')) {
$result = $this->getAsString('name');
} elseif ($this->hasFirstName() || $this->hasLastName()) {
$result = trim($this->getFirstName() . ' ' . $this->getLastName());
} else {
$result = $this->getUserName();
}
return $result;
} | php | {
"resource": ""
} |
q3094 | Tx_Oelib_Model_FrontEndUser.hasGroupMembership | train | public function hasGroupMembership($uidList)
{
if ($uidList === '') {
throw new \InvalidArgumentException('$uidList must not be empty.', 1331488635);
}
$isMember = false;
foreach (GeneralUtility::trimExplode(',', $uidList, true) as $uid) {
if ($this->getUserGroups()->hasUid($uid)) {
$isMember = true;
break;
}
}
return $isMember;
} | php | {
"resource": ""
} |
q3095 | Tx_Oelib_Model_FrontEndUser.setGender | train | public function setGender($genderKey)
{
$validGenderKeys = [self::GENDER_MALE, self::GENDER_FEMALE, self::GENDER_UNKNOWN];
if (!in_array($genderKey, $validGenderKeys, true)) {
throw new \InvalidArgumentException(
'$genderKey must be one of the predefined constants, but actually is: ' . $genderKey,
1393329321
);
}
$this->setAsInteger('gender', $genderKey);
} | php | {
"resource": ""
} |
q3096 | Tx_Oelib_Model_FrontEndUser.getAge | train | public function getAge()
{
if (!$this->hasDateOfBirth()) {
return 0;
}
$currentTimestamp = $GLOBALS['EXEC_TIME'];
$birthTimestamp = $this->getDateOfBirth();
$currentYear = (int)strftime('%Y', $currentTimestamp);
$currentMonth = (int)strftime('%m', $currentTimestamp);
$currentDay = (int)strftime('%d', $currentTimestamp);
$birthYear = (int)strftime('%Y', $birthTimestamp);
$birthMonth = (int)strftime('%m', $birthTimestamp);
$birthDay = (int)strftime('%d', $birthTimestamp);
$age = $currentYear - $birthYear;
if ($currentMonth < $birthMonth) {
$age--;
} elseif ($currentMonth === $birthMonth) {
if ($currentDay < $birthDay) {
$age--;
}
}
return $age;
} | php | {
"resource": ""
} |
q3097 | Tx_Oelib_Model_FrontEndUser.getCountry | train | public function getCountry()
{
$countryCode = $this->getAsString('static_info_country');
if ($countryCode === '') {
return null;
}
try {
/** @var \Tx_Oelib_Mapper_Country $countryMapper */
$countryMapper = \Tx_Oelib_MapperRegistry::get(\Tx_Oelib_Mapper_Country::class);
/** @var \Tx_Oelib_Model_Country $country */
$country = $countryMapper->findByIsoAlpha3Code($countryCode);
} catch (\Tx_Oelib_Exception_NotFound $exception) {
$country = null;
}
return $country;
} | php | {
"resource": ""
} |
q3098 | Tx_Oelib_Model_FrontEndUser.setCountry | train | public function setCountry(\Tx_Oelib_Model_Country $country = null)
{
$countryCode = ($country !== null) ? $country->getIsoAlpha3Code() : '';
$this->setAsString('static_info_country', $countryCode);
} | php | {
"resource": ""
} |
q3099 | IntervalTree.search | train | public function search($interval)
{
if (is_null($this->top_node)) {
return array();
}
$result = $this->find_intervals($interval);
$result = array_values($result);
usort($result, function (RangeInterface $a, RangeInterface $b) {
$x = $a->getStart();
$y = $b->getStart();
$comparedValue = $this->compare($x, $y);
if ($comparedValue == 0) {
$x = $a->getEnd();
$y = $b->getEnd();
$comparedValue = $this->compare($x, $y);
}
return $comparedValue;
});
return $result;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.