_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 33
8k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q3000
|
SitemapGenerator.addAll
|
train
|
public function addAll($objects)
{
if (is_a($objects, 'Closure')) {
return $this->closures[] = $objects;
}
|
php
|
{
"resource": ""
}
|
q3001
|
SitemapGenerator.addRaw
|
train
|
public function addRaw($data)
{
$this->validateData($data);
$data['location'] = trim($data['location'], '/');
|
php
|
{
"resource": ""
}
|
q3002
|
SitemapGenerator.contains
|
train
|
public function contains($url)
{
$url = trim($url, '/');
foreach ($this->entries as $entry) {
if ($entry['loc']
|
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
|
php
|
{
"resource": ""
}
|
q3004
|
SitemapGenerator.replaceAttributes
|
train
|
protected function replaceAttributes($data)
{
foreach ($data as $attribute => $value) {
|
php
|
{
"resource": ""
}
|
q3005
|
SitemapGenerator.replaceAttribute
|
train
|
protected function replaceAttribute($attribute)
{
if (array_key_exists($attribute, $this->replacements)) {
|
php
|
{
"resource": ""
}
|
q3006
|
SitemapGenerator.loadClosures
|
train
|
protected function loadClosures()
{
foreach ($this->closures as $closure) {
$instance = $closure();
|
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. '
|
php
|
{
"resource": ""
}
|
q3008
|
Tx_Oelib_ConfigCheck.checkForNonEmptyString
|
train
|
public function checkForNonEmptyString(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$value = $this->objectToCheck->getConfValueString($fieldName,
|
php
|
{
"resource": ""
}
|
q3009
|
Tx_Oelib_ConfigCheck.checkIfSingleInSetNotEmpty
|
train
|
protected function checkIfSingleInSetNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
array $allowedValues
) {
$this->checkForNonEmptyString(
|
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(
|
php
|
{
"resource": ""
}
|
q3011
|
Tx_Oelib_ConfigCheck.checkIfBoolean
|
train
|
protected function checkIfBoolean($fieldName, $canUseFlexforms, $sheet, $explanation)
{
$this->checkIfSingleInSetNotEmpty(
$fieldName,
|
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>, '
|
php
|
{
"resource": ""
}
|
q3013
|
Tx_Oelib_ConfigCheck.checkIfSingleInTableNotEmpty
|
train
|
public function checkIfSingleInTableNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$tableName
) {
$this->checkIfSingleInSetNotEmpty(
$fieldName,
|
php
|
{
"resource": ""
}
|
q3014
|
Tx_Oelib_ConfigCheck.checkIfSingleInTableOrEmpty
|
train
|
protected function checkIfSingleInTableOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$tableName
) {
$this->checkIfSingleInSetOrEmpty(
$fieldName,
|
php
|
{
"resource": ""
}
|
q3015
|
Tx_Oelib_ConfigCheck.checkIfMultiInTableOrEmpty
|
train
|
protected function checkIfMultiInTableOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$tableName
) {
$this->checkIfMultiInSetOrEmpty(
$fieldName,
|
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>'
|
php
|
{
"resource": ""
}
|
q3017
|
Tx_Oelib_ConfigCheck.checkRegExpNotEmpty
|
train
|
protected function checkRegExpNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation,
$regExp
) {
$this->checkForNonEmptyString(
|
php
|
{
"resource": ""
}
|
q3018
|
Tx_Oelib_ConfigCheck.checkIfFePagesNotEmpty
|
train
|
protected function checkIfFePagesNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkForNonEmptyString(
|
php
|
{
"resource": ""
}
|
q3019
|
Tx_Oelib_ConfigCheck.checkIfSingleFePageNotEmpty
|
train
|
protected function checkIfSingleFePageNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfPositiveInteger(
|
php
|
{
"resource": ""
}
|
q3020
|
Tx_Oelib_ConfigCheck.checkIfSingleFePageOrEmpty
|
train
|
protected function checkIfSingleFePageOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfInteger($fieldName, $canUseFlexforms,
|
php
|
{
"resource": ""
}
|
q3021
|
Tx_Oelib_ConfigCheck.checkIfSysFoldersNotEmpty
|
train
|
protected function checkIfSysFoldersNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkForNonEmptyString(
|
php
|
{
"resource": ""
}
|
q3022
|
Tx_Oelib_ConfigCheck.checkIfSingleSysFolderNotEmpty
|
train
|
protected function checkIfSingleSysFolderNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfPositiveInteger(
|
php
|
{
"resource": ""
}
|
q3023
|
Tx_Oelib_ConfigCheck.checkIfSingleSysFolderOrEmpty
|
train
|
protected function checkIfSingleSysFolderOrEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$explanation
) {
$this->checkIfInteger(
|
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 {
|
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>' .
|
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
);
|
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
|
php
|
{
"resource": ""
}
|
q3028
|
Tx_Oelib_ConfigCheck.checkIsValidEmailNotEmpty
|
train
|
public function checkIsValidEmailNotEmpty(
$fieldName,
$canUseFlexforms,
$sheet,
$allowInternalAddresses,
$explanation
) {
$this->checkForNonEmptyString(
|
php
|
{
"resource": ""
}
|
q3029
|
Tx_Oelib_TranslatorRegistry.setLanguageKeyFromConfiguration
|
train
|
private function setLanguageKeyFromConfiguration(\Tx_Oelib_Configuration $configuration)
{
if (!$configuration->hasString('language')) {
return;
}
|
php
|
{
"resource": ""
}
|
q3030
|
Tx_Oelib_TranslatorRegistry.initializeBackEnd
|
train
|
private function initializeBackEnd()
{
$backEndUser =
\Tx_Oelib_BackEndLogin
|
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) {
|
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 !== '') {
|
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
|
php
|
{
"resource": ""
}
|
q3034
|
Tracker.getCurrent
|
train
|
public function getCurrent()
{
if (is_null($this->current))
{
$siteView = $this->makeNewViewModel();
|
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(),
|
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(
|
php
|
{
"resource": ""
}
|
q3037
|
Tracker.isViewUnique
|
train
|
public function isViewUnique()
{
$hash = $this->getCurrentHash();
if (in_array($hash, $this->session->get('tracker.views', [])))
|
php
|
{
"resource": ""
}
|
q3038
|
Tracker.getCurrentHash
|
train
|
protected function getCurrentHash()
{
if ($this->currentHash === null)
{
$this->currentHash = md5(
$this->request->fullUrl() .
$this->request->method() .
|
php
|
{
"resource": ""
}
|
q3039
|
Tracker.saveCurrentModel
|
train
|
protected function saveCurrentModel()
{
$current = $this->getCurrent();
$current->setAttribute('app_time', $this->getCurrentRuntime());
|
php
|
{
"resource": ""
}
|
q3040
|
Tracker.saveTrackables
|
train
|
protected function saveTrackables($view, $success)
{
foreach ($this->trackables as $trackable)
{
|
php
|
{
"resource": ""
}
|
q3041
|
Tracker.flushOlderThanOrBetween
|
train
|
public function flushOlderThanOrBetween($until = null, $from = null)
{
|
php
|
{
"resource": ""
}
|
q3042
|
DataTablesMappingHelper.getComparator
|
train
|
public static function getComparator(DataTablesMappingInterface $mapping) {
if (null === $mapping->getParent()) {
return "LIKE";
}
switch ($mapping->getParent()->getType()) {
|
php
|
{
"resource": ""
}
|
q3043
|
DataTablesMappingHelper.getWhere
|
train
|
public static function getWhere(DataTablesMappingInterface $mapping) {
$where = [
static::getAlias($mapping),
static::getComparator($mapping),
|
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();
|
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);
|
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();
|
php
|
{
"resource": ""
}
|
q3047
|
DataTablesController.optionsAction
|
train
|
public function optionsAction($name) {
$dtProvider = $this->getDataTablesProvider($name);
$dtWrapper = $this->getDataTablesWrapper($dtProvider);
|
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());
|
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']))
{
|
php
|
{
"resource": ""
}
|
q3050
|
Autoload.instantiateClasses
|
train
|
public function instantiateClasses()
{
$data = $this->getData();
// Always load these
if (isset($data['always']))
{
$this->instantiateGroup($data['always']);
}
|
php
|
{
"resource": ""
}
|
q3051
|
Autoload.loadPsr4Group
|
train
|
private function loadPsr4Group($group)
{
if ( !isset($group['psr4']))
{
return;
|
php
|
{
"resource": ""
}
|
q3052
|
Autoload.instantiateGroup
|
train
|
private function instantiateGroup($group)
{
if ( !isset($group['instantiate']))
{
return;
|
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),
|
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
|
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');
|
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']),
|
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'
|
php
|
{
"resource": ""
}
|
q3058
|
PreUserController.indexAction
|
train
|
public function indexAction()
{
$em = $this->getDoctrine()->getEntityManager();
|
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.');
}
|
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) {
|
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:
|
php
|
{
"resource": ""
}
|
q3062
|
CloudStorage.transformContainers
|
train
|
protected function transformContainers(array $items)
{
if (!count($items)) {
return [];
}
$containers = [];
foreach ($items as $item) {
|
php
|
{
"resource": ""
}
|
q3063
|
KnowledgebaseServiceProvider.setupMigrations
|
train
|
protected function setupMigrations()
{
$migrations = realpath(__DIR__.'/../database/migrations');
$this->publishes([
|
php
|
{
"resource": ""
}
|
q3064
|
KnowledgebaseServiceProvider.setupSeeds
|
train
|
protected function setupSeeds()
{
$seeds = realpath(__DIR__.'/../database/seeds');
$this->publishes([
|
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;
}
|
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 = [
|
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;
|
php
|
{
"resource": ""
}
|
q3068
|
TwitterBase.createTweetEntities
|
train
|
protected function createTweetEntities($tweets)
{
$entities = [];
foreach ($tweets as $tweet)
{
$user = $this->twitterFactory->createUser($tweet['user']);
|
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();
|
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));
|
php
|
{
"resource": ""
}
|
q3071
|
LanguageKsh.commafy
|
train
|
public function commafy( $_ ) {
if ( !preg_match( '/^\d{1,4}$/', $_ ) ) {
return strrev( (string)preg_replace(
|
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.');
}
|
php
|
{
"resource": ""
}
|
q3073
|
GiroCheckout_SDK_Request.getResponseParam
|
train
|
public function getResponseParam($param) {
if (isset($this->response[$param]))
|
php
|
{
"resource": ""
}
|
q3074
|
GiroCheckout_SDK_Request.redirectCustomerToPaymentProvider
|
train
|
public function redirectCustomerToPaymentProvider() {
if (isset($this->response['redirect'])) {
header('location:' . $this->response['redirect']);
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) {
|
php
|
{
"resource": ""
}
|
q3076
|
ClassMetadataFactory.loadInterfaceMetadata
|
train
|
protected function loadInterfaceMetadata($metadata)
{
foreach( $metadata->getReflectionClass()->getInterfaces() as $interface ) {
|
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) {
|
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)
|
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])
|
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])
|
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']))
|
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);
}
|
php
|
{
"resource": ""
}
|
q3083
|
Assets.loadManifest
|
train
|
protected function loadManifest()
{
$manifestPath = Paths::assets('manifest.json');
if (file_exists($manifestPath))
{
|
php
|
{
"resource": ""
}
|
q3084
|
Container.objectData
|
train
|
protected function objectData($key, $default = null)
{
if (!$this->dataLoaded) {
|
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.
|
php
|
{
"resource": ""
}
|
q3086
|
Container.jsonSerialize
|
train
|
public function jsonSerialize()
{
return [
'name' => $this->name(),
'type' => $this->type(),
'files_count'
|
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]);
|
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) {
|
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
|
php
|
{
"resource": ""
}
|
q3090
|
Container.uploadFromString
|
train
|
public function uploadFromString($path, $contents, array $params = [], $verifyChecksum = true)
|
php
|
{
"resource": ""
}
|
q3091
|
Container.uploadFromStream
|
train
|
public function uploadFromStream($path, $resource, array $params = [])
{
return
|
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:
|
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()
|
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) {
|
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
|
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);
|
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 */
|
php
|
{
"resource": ""
}
|
q3098
|
Tx_Oelib_Model_FrontEndUser.setCountry
|
train
|
public function setCountry(\Tx_Oelib_Model_Country $country = null)
{
$countryCode = ($country !== null) ? $country->getIsoAlpha3Code() : '';
|
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) {
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.