_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q3100
NGSIAPIv2.post
train
public function post($url, $requestBody = null) { $posturl = $this->url . $url; return $this->restRequest($posturl, 'POST', $requestBody); }
php
{ "resource": "" }
q3101
SitemapRun.run
train
public function run() { $this->generator->addRaw( array( 'location' => 'example.com', 'last_modified' => '2013-01-28', 'change_frequency' => 'weekly', 'priority' => '0.65' ) ); $this->generator->addRaw( array( 'location' => 'example.com/test', 'last_modified' => '2013-12-28', 'change_frequency' => 'weekly', 'priority' => '0.95' ) ); $this->generator->addRaw( array( 'location' => 'example.com/test/2', 'last_modified' => '2013-12-25', 'change_frequency' => 'weekly', 'priority' => '0.99' ) ); return $this->generator->generate(); }
php
{ "resource": "" }
q3102
SystemEmailFromBuilder.canBuild
train
public function canBuild() { $configuration = $this->getEmailConfiguration(); $emailAddress = (string)$configuration['defaultMailFromAddress']; return \filter_var($emailAddress, FILTER_VALIDATE_EMAIL) !== false; }
php
{ "resource": "" }
q3103
CachedAssociationCount.getCachedRelationCount
train
protected function getCachedRelationCount($propertyName) { if (array_key_exists($propertyName, $this->cachedRelationCountsCount)) { return $this->cachedRelationCountsCount[$propertyName]; } $this->cachedRelationCountsCount[$propertyName] = $this->getUncachedRelationCount($propertyName); return $this->cachedRelationCountsCount[$propertyName]; }
php
{ "resource": "" }
q3104
CachedAssociationCount.getUncachedRelationCount
train
protected function getUncachedRelationCount($propertyName) { if ($this->$propertyName instanceof LazyObjectStorage) { $reflectionClass = new \ReflectionClass(LazyObjectStorage::class); $reflectionProperty = $reflectionClass->getProperty('fieldValue'); $reflectionProperty->setAccessible(true); $count = (int)$reflectionProperty->getValue($this->$propertyName); } else { $count = $this->$propertyName->count(); } return $count; }
php
{ "resource": "" }
q3105
Tx_Oelib_PageFinder.getPageUid
train
public function getPageUid() { switch ($this->getCurrentSource()) { case self::SOURCE_MANUAL: $result = $this->storedPageUid; break; case self::SOURCE_FRONT_END: $result = (int)$this->getFrontEndController()->id; break; case self::SOURCE_BACK_END: $result = (int)GeneralUtility::_GP('id'); break; default: $result = 0; } return $result; }
php
{ "resource": "" }
q3106
Tx_Oelib_PageFinder.getCurrentSource
train
public function getCurrentSource() { if ($this->manualPageUidSource !== self::SOURCE_AUTO) { $result = $this->manualPageUidSource; } elseif ($this->hasManualPageUid()) { $result = self::SOURCE_MANUAL; } elseif ($this->hasFrontEnd()) { $result = self::SOURCE_FRONT_END; } elseif ($this->hasBackEnd()) { $result = self::SOURCE_BACK_END; } else { $result = self::NO_SOURCE_FOUND; } return $result; }
php
{ "resource": "" }
q3107
Views.pickView
train
public static function pickView($stack) { $viewRoot = trailingslashit(Paths::views()); foreach ($stack as $id) { $innerPath = str_replace('.', '/', $id); $innerPath .= '.blade.php'; if (file_exists($viewRoot . $innerPath)) return $id; } return null; }
php
{ "resource": "" }
q3108
Posts.mainPageTitle
train
public static function mainPageTitle() { if (is_home()) { if (get_option('page_for_posts', true)) { return get_the_title(get_option('page_for_posts', true)); } else { return __('Latest Posts', 'baobab'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { return apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { return apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { return sprintf(__('Daily Archives: %s', 'baobab'), get_the_date()); } elseif (is_month()) { return sprintf(__('Monthly Archives: %s', 'baobab'), get_the_date('F Y')); } elseif (is_year()) { return sprintf(__('Yearly Archives: %s', 'baobab'), get_the_date('Y')); } elseif (is_author()) { $author = get_queried_object(); return sprintf(__('Author Archives: %s', 'baobab'), apply_filters('the_author', is_object($author) ? $author->display_name : null)); } else { return single_cat_title('', false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'baobab'), get_search_query()); } elseif (is_404()) { return __('Not Found', 'baobab'); } else { return get_the_title(); } }
php
{ "resource": "" }
q3109
DefaultDataTablesRepository.buildDataTablesCountExported
train
protected function buildDataTablesCountExported(DataTablesProviderInterface $dtProvider) { $prefix = $dtProvider->getPrefix(); $qb = $this->createQueryBuilder($prefix) ->select("COUNT(" . $prefix . ")"); return $qb; }
php
{ "resource": "" }
q3110
DefaultDataTablesRepository.buildDataTablesCountFiltered
train
protected function buildDataTablesCountFiltered(DataTablesWrapperInterface $dtWrapper) { $prefix = $dtWrapper->getMapping()->getPrefix(); $qb = $this->createQueryBuilder($prefix) ->select("COUNT(" . $prefix . ")"); DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper); return $qb; }
php
{ "resource": "" }
q3111
DefaultDataTablesRepository.buildDataTablesCountTotal
train
protected function buildDataTablesCountTotal(DataTablesWrapperInterface $dtWrapper) { $prefix = $dtWrapper->getMapping()->getPrefix(); $qb = $this->createQueryBuilder($prefix) ->select("COUNT(" . $prefix . ")"); return $qb; }
php
{ "resource": "" }
q3112
DefaultDataTablesRepository.buildDataTablesFindAll
train
protected function buildDataTablesFindAll(DataTablesWrapperInterface $dtWrapper) { $prefix = $dtWrapper->getMapping()->getPrefix(); $qb = $this->createQueryBuilder($prefix) ->setFirstResult($dtWrapper->getRequest()->getStart()); if (0 < $dtWrapper->getRequest()->getLength()) { $qb->setMaxResults($dtWrapper->getRequest()->getLength()); } DataTablesRepositoryHelper::appendWhere($qb, $dtWrapper); DataTablesRepositoryHelper::appendOrder($qb, $dtWrapper); return $qb; }
php
{ "resource": "" }
q3113
DataTablesExportHelper.isWindows
train
public static function isWindows(Request $request) { if (false === $request->headers->has("user-agent")) { return false; } $dd = new DeviceDetector($request->headers->get("user-agent")); $dd->parse(); $os = $dd->getOs("name"); return 1 === preg_match("/Windows/", $os); }
php
{ "resource": "" }
q3114
Ajax.generateNonceField
train
public function generateNonceField($action) { $nonceName = $this->namespace . '_' . $action; return wp_nonce_field(md5($nonceName), $nonceName, true, false); }
php
{ "resource": "" }
q3115
CacheControlService.getCacheTagsAndLifetime
train
protected function getCacheTagsAndLifetime() { $lifetime = null; $tags = array(); $entriesMetadata = $this->contentCacheFrontend->getAllMetadata(); foreach ($entriesMetadata as $identifier => $metadata) { $entryTags = isset($metadata['tags']) ? $metadata['tags'] : array(); $entryLifetime = isset($metadata['lifetime']) ? $metadata['lifetime'] : null; if ($entryLifetime !== null) { if ($lifetime === null) { $lifetime = $entryLifetime; } else { $lifetime = min($lifetime, $entryLifetime); } } $tags = array_unique(array_merge($tags, $entryTags)); } return array($tags, $lifetime); }
php
{ "resource": "" }
q3116
VarnishBanService.banAll
train
public function banAll($domains = null, $contentType = null) { $this->cacheInvalidator->invalidateRegex('.*', $contentType, $domains); $this->logger->log(sprintf('Cleared all Varnish cache%s%s', $domains ? ' for domains "' . (is_array($domains) ? implode(', ', $domains) : $domains) . '"' : '', $contentType ? ' with content type "' . $contentType . '"' : '')); $this->execute(); }
php
{ "resource": "" }
q3117
VarnishBanService.banByTags
train
public function banByTags(array $tags, $domains = null) { if (count($this->settings['ignoredCacheTags']) > 0) { $tags = array_diff($tags, $this->settings['ignoredCacheTags']); } /** * Sanitize tags * @see \Neos\Fusion\Core\Cache\ContentCache */ foreach ($tags as $key => $tag) { $tags[$key] = strtr($tag, '.:', '_-'); } // Set specific domain before invalidating tags if ($domains) { $this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, is_array($domains) ? '^(' . implode('|', $domains) . ')$' : $domains); } $this->tagHandler->invalidateTags($tags); // Unset specific domain after invalidating tags if ($domains) { $this->varnishProxyClient->setDefaultBanHeader(ProxyClient\Varnish::HTTP_HEADER_HOST, ProxyClient\Varnish::REGEX_MATCH_ALL); } $this->logger->log(sprintf('Cleared Varnish cache for tags "%s"%s', implode(',', $tags), $domains ? ' for domains "' . (is_array($domains) ? implode(', ', $domains) : $domains) . '"' : '')); $this->execute(); }
php
{ "resource": "" }
q3118
Router.addFallthroughRoute
train
protected function addFallthroughRoute($controller, $uri) { $missing = $this->any($uri.'/{_missing}', $controller.'@missingMethod'); $missing->where('_missing', '(.*)'); }
php
{ "resource": "" }
q3119
Tx_Oelib_Db.select
train
public static function select( $fields, $tableNames, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '' ) { if ($tableNames === '') { throw new \InvalidArgumentException('The table names must not be empty.', 1331488261); } if ($fields === '') { throw new \InvalidArgumentException('$fields must not be empty.', 1331488270); } self::enableQueryLogging(); $dbResult = self::getDatabaseConnection()->exec_SELECTquery( $fields, $tableNames, $whereClause, $groupBy, $orderBy, $limit ); if (!$dbResult) { throw new \Tx_Oelib_Exception_Database(); } return $dbResult; }
php
{ "resource": "" }
q3120
Tx_Oelib_Db.selectSingle
train
public static function selectSingle( $fields, $tableNames, $whereClause = '', $groupBy = '', $orderBy = '', $offset = 0 ) { $result = self::selectMultiple( $fields, $tableNames, $whereClause, $groupBy, $orderBy, $offset . ',' . 1 ); if (empty($result)) { throw new \Tx_Oelib_Exception_EmptyQueryResult(); } return $result[0]; }
php
{ "resource": "" }
q3121
Tx_Oelib_Db.selectMultiple
train
public static function selectMultiple( $fieldNames, $tableNames, $whereClause = '', $groupBy = '', $orderBy = '', $limit = '' ) { $result = []; $dbResult = self::select( $fieldNames, $tableNames, $whereClause, $groupBy, $orderBy, $limit ); $databaseConnection = self::getDatabaseConnection(); while ($recordData = $databaseConnection->sql_fetch_assoc($dbResult)) { $result[] = $recordData; } $databaseConnection->sql_free_result($dbResult); return $result; }
php
{ "resource": "" }
q3122
MetaGenerator.generate
train
public function generate() { $this->loadWebmasterTags(); $title = $this->getTitle(); $description = $this->getDescription(); $keywords = $this->getKeywords(); $metatags = $this->metatags; $html = array(); $html[] = "<title>$title</title>"; $html[] = sprintf('<meta name="description" itemprop="description" content="%s" />%s', $description, PHP_EOL); if (!empty($keywords)) { $html[] = sprintf('<meta name="keywords" content="%s" />%s', $keywords, PHP_EOL); } foreach ($metatags as $key => $value): $name = $value[0]; $content = $value[1]; $html[] = sprintf('<meta %s="%s" content="%s" />%s', $name, $key, $content, PHP_EOL); endforeach; return implode(PHP_EOL, $html); }
php
{ "resource": "" }
q3123
MetaGenerator.fromObject
train
public function fromObject(MetaAware $object) { $data = $object->getMetaData(); if (array_key_exists('title', $data)) { $this->setTitle($data['title']); } if (array_key_exists('description', $data)) { $this->setDescription($data['description']); } if (array_key_exists('keywords', $data)) { $this->setKeywords($data['keywords']); } }
php
{ "resource": "" }
q3124
MetaGenerator.setTitle
train
public function setTitle($title) { $title = strip_tags($title); $this->title_session = $title; $this->title = $title . $this->getDefault('separator') . $this->getDefault('title'); }
php
{ "resource": "" }
q3125
MetaGenerator.setDescription
train
public function setDescription($description) { $description = strip_tags($description); if (mb_strlen($description) > 160) { $description = mb_substr($description, 0, 160); } $this->description = $description; }
php
{ "resource": "" }
q3126
MetaGenerator.getKeywords
train
public function getKeywords() { $keywords = $this->keywords ? : $this->getDefault('keywords'); return (is_array($keywords)) ? implode(', ', $keywords) : $keywords; }
php
{ "resource": "" }
q3127
MetaGenerator.loadWebmasterTags
train
public function loadWebmasterTags() { foreach ($this->webmaster as $name => $value): if (!empty($value)): $meta = array_get(self::$webmasterTags, $name, $name); $this->addMeta($meta, $value); endif; endforeach; }
php
{ "resource": "" }
q3128
Cruncher.getLastVisited
train
public function getLastVisited($locale = null, $query = null) { $query = $this->determineLocaleAndQuery($locale, $query); $lastVisited = $query->orderBy('created_at', 'desc')->first(); return $lastVisited ? $lastVisited->created_at : null; }
php
{ "resource": "" }
q3129
Cruncher.getTotalVisitCount
train
public function getTotalVisitCount($locale = null, $query = null) { $query = $this->determineLocaleAndQuery($locale, $query); return $query->count(); }
php
{ "resource": "" }
q3130
Cruncher.getTodayCount
train
public function getTodayCount($locale = null, $query = null) { $query = $this->determineLocaleAndQuery($locale, $query); return $query->where('created_at', '>=', Carbon::today())->count(); }
php
{ "resource": "" }
q3131
Cruncher.getCountInBetween
train
public function getCountInBetween(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null) { if (is_null($until)) { $until = Carbon::now(); } if ( ! is_null($cacheKey)) { $count = $this->getCachedCountBetween($from, $until, $locale, $cacheKey); if ( ! is_null($count)) { return $count; } } $query = $this->determineLocaleAndQuery($locale, $query); $count = $query->whereBetween('created_at', [$from, $until])->count(); $this->cacheCountBetween($count, $from, $until, $locale, $cacheKey); return $count; }
php
{ "resource": "" }
q3132
Cruncher.getCachedCountBetween
train
protected function getCachedCountBetween(Carbon $from, Carbon $until, $locale, $cacheKey) { $key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey); return $this->cache->get($key); }
php
{ "resource": "" }
q3133
Cruncher.cacheCountBetween
train
protected function cacheCountBetween($count, Carbon $from, Carbon $until, $locale, $cacheKey) { // Cache only if cacheKey is present if ($cacheKey && ($until->timestamp < Carbon::now()->timestamp)) { $key = $this->makeBetweenCacheKey($from, $until, $locale, $cacheKey); $this->cache->put($key, $count, 525600); } }
php
{ "resource": "" }
q3134
Cruncher.makeBetweenCacheKey
train
protected function makeBetweenCacheKey(Carbon $from, Carbon $until, $locale, $cacheKey) { $key = 'tracker.between.' . $cacheKey . '.'; $key .= (is_null($locale) ? '' : $locale . '.'); return $key . $from->timestamp . '-' . $until->timestamp; }
php
{ "resource": "" }
q3135
Cruncher.getRelativeYearCount
train
public function getRelativeYearCount($end = null, $locale = null, $query = null, $cacheKey = null) { if (is_null($end)) { $end = Carbon::today(); } return $this->getCountInBetween($end->copy()->subYear()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey); }
php
{ "resource": "" }
q3136
Cruncher.getRelativeMonthCount
train
public function getRelativeMonthCount($end = null, $locale = null, $query = null, $cacheKey = null) { if (is_null($end)) { $end = Carbon::today(); } return $this->getCountInBetween($end->copy()->subMonth()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey); }
php
{ "resource": "" }
q3137
Cruncher.getRelativeWeekCount
train
public function getRelativeWeekCount($end = null, $locale = null, $query = null, $cacheKey = null) { if (is_null($end)) { $end = Carbon::today(); } return $this->getCountInBetween($end->copy()->subWeek()->addDay()->startOfDay(), $end->endOfDay(), $locale, $query, $cacheKey); }
php
{ "resource": "" }
q3138
Cruncher.getRelativeDayCount
train
public function getRelativeDayCount($end = null, $locale = null, $query = null, $cacheKey = null) { if (is_null($end)) { $end = Carbon::today(); } return $this->getCountInBetween($end, $end->copy()->endOfDay(), $locale, $query, $cacheKey); }
php
{ "resource": "" }
q3139
Cruncher.getCountForDay
train
public function getCountForDay(Carbon $day = null, $locale = null, $query = null, $cacheKey = null) { if (is_null($day)) { $day = Carbon::now(); } return $this->getCountInBetween($day->startOfDay(), $day->copy()->endOfDay(), $locale, $query, $cacheKey); }
php
{ "resource": "" }
q3140
Cruncher.getCountPerMonth
train
public function getCountPerMonth(Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null) { return $this->getCountPer('Month', $from, $until, $locale, $query, $cacheKey); }
php
{ "resource": "" }
q3141
Cruncher.getCountPer
train
protected function getCountPer($span, Carbon $from, Carbon $until = null, $locale = null, $query = null, $cacheKey = null) { $query = $this->determineLocaleAndQuery($locale, $query); $statistics = []; $labels = []; if (is_null($until)) { $until = Carbon::now(); } $until->{'startOf' . $span}(); while ($until->gt($from)) { $start = $until->copy(); $end = $until->copy()->{'endOf' . $span}(); $labels[] = $until->copy(); $statistics[] = $this->getCountInBetween($start, $end, $locale, clone $query, $cacheKey); $until->{'sub' . $span}(); } return [ array_reverse($statistics), array_reverse($labels) ]; }
php
{ "resource": "" }
q3142
Cruncher.determineLocaleAndQuery
train
protected function determineLocaleAndQuery($locale, $query) { if (is_null($query)) { $modelName = $this->getViewModelName(); $query = with(new $modelName)->newQuery(); } if ($locale) { $query->where('locale', $locale); } return $query; }
php
{ "resource": "" }
q3143
MetaData.extractMetaData
train
protected function extractMetaData(ResponseInterface $response) { $headers = $this->findMetaHeaders($response); if (!count($headers)) { return []; } $metaData = []; foreach ($headers as $header) { $metaData[$header] = $response->getHeaderLine($header); } return $metaData; }
php
{ "resource": "" }
q3144
MetaData.findMetaHeaders
train
protected function findMetaHeaders(ResponseInterface $response) { $headerNames = array_keys($response->getHeaders()); $metaType = $this->objectMetaType(); return array_filter($headerNames, function ($header) use ($metaType) { return strpos($header, 'X-'.$metaType.'-Meta') !== false; }); }
php
{ "resource": "" }
q3145
MetaData.hasMeta
train
public function hasMeta($name) { $meta = $this->objectData('meta', []); return isset($meta[$this->sanitizeMetaName($name)]); }
php
{ "resource": "" }
q3146
MetaData.getMeta
train
public function getMeta($name) { if (!$this->hasMeta($name)) { throw new InvalidArgumentException('Meta data with name "'.$name.'" does not exists.'); } $meta = $this->objectData('meta', []); return $meta[$this->sanitizeMetaName($name)]; }
php
{ "resource": "" }
q3147
MetaData.setMeta
train
public function setMeta(array $meta) { $headers = []; $metaType = $this->objectMetaType(); // We will replace any 'X-{Object}-Meta-' prefixes in meta name // and prepend final header names with same prefix so API will // receive sanitized headers and won't produce any errors. foreach ($meta as $name => $value) { $key = str_replace('X-'.$metaType.'-Meta-', '', $name); $headers['X-'.$metaType.'-Meta-'.$key] = $value; } $response = $this->apiClient()->request('POST', $this->absolutePath(), ['headers' => $headers]); if ($response->getStatusCode() !== 202) { throw new ApiRequestFailedException('Unable to update container meta data.', $response->getStatusCode()); } return true; }
php
{ "resource": "" }
q3148
SubscriptionEntity.getContext
train
public function getContext($options = []) { $url = $this->getBaseURI(); if (count($options) > 0) { $prefix = ($this->_type) ? "&" : "?"; $url .= $prefix . urldecode(http_build_query($options)); } return $this->_orion->get($url); }
php
{ "resource": "" }
q3149
SubscriptionEntity.update
train
public function update($subscription){ if(!isset($this->_id) || null == $this->_id){ throw new \Exception("You must especify an Id to perform subscription updates"); } if($subscription instanceof SubscriptionFactory){ $context = new ContextFactory((array) $subscription->get()); }elseif(is_array($subscription) || is_object($subscription)){ $context = new ContextFactory((array)$subscription); } return $this->_orion->patch($this->getBaseURI(), $context); }
php
{ "resource": "" }
q3150
Uuid.create
train
public static function create() { // use COM helper if available if (function_exists('com_create_guid')) { return com_create_guid(); } // generate UUID mt_srand((double) microtime() * 10000); // optional for php 4.2.0 and up. $charid = strtoupper(md5(uniqid(rand(), true))); $uuid = join('-', array( substr($charid, 0, 8), substr($charid, 8, 4), substr($charid, 12, 4), substr($charid, 16, 4), substr($charid, 20, 12), )); return $uuid; }
php
{ "resource": "" }
q3151
DataTablesWrapperHelper.getLanguageURL
train
public static function getLanguageURL($language) { // Initialize the directory. $dir = ObjectHelper::getDirectory(JQueryDataTablesBundle::class); $dir .= "/Resources/public/datatables-i18n/%language%.json"; // Initialize the URI. $uri = "/bundles/jquerydatatables/datatables-i18n/%language%.json"; // Initialize the URL. $url = StringHelper::replace($uri, ["%language%"], [$language]); // Initialize and check the filename. $file = StringHelper::replace($dir, ["%language%"], [$language]); if (false === file_exists($file)) { throw new FileNotFoundException(null, 500, null, $url); } return $url; }
php
{ "resource": "" }
q3152
DataTablesWrapperHelper.getOptions
train
public static function getOptions(DataTablesWrapperInterface $dtWrapper) { $output = []; if (null !== $dtWrapper->getOptions()) { $output = $dtWrapper->getOptions()->getOptions(); } $output["ajax"] = []; $output["ajax"]["type"] = $dtWrapper->getMethod(); $output["ajax"]["url"] = $dtWrapper->getUrl(); $output["columns"] = []; $output["order"] = $dtWrapper->getOrder(); $output["processing"] = $dtWrapper->getProcessing(); $output["serverSide"] = $dtWrapper->getServerSide(); foreach ($dtWrapper->getColumns() as $current) { $output["columns"][] = DataTablesNormalizer::normalizeColumn($current); } return $output; }
php
{ "resource": "" }
q3153
File.fileData
train
protected function fileData($key, $default = null) { $this->guardDeletedFile(); return isset($this->data[$key]) ? $this->data[$key] : $default; }
php
{ "resource": "" }
q3154
File.absolutePath
train
protected function absolutePath($path = '') { if (!$path) { $path = $this->path(); } return '/'.$this->container().($path ? '/'.ltrim($path, '/') : ''); }
php
{ "resource": "" }
q3155
File.read
train
public function read() { $response = $this->api->request('GET', $this->absolutePath()); return (string) $response->getBody(); }
php
{ "resource": "" }
q3156
File.readStream
train
public function readStream($psr7Stream = false) { $response = $this->api->request('GET', $this->absolutePath()); if ($psr7Stream) { return $response->getBody(); } return StreamWrapper::getResource($response->getBody()); }
php
{ "resource": "" }
q3157
File.rename
train
public function rename($name) { $this->guardDeletedFile(); // If there is any slash character in new name, Selectel // will create new virtual directory and copy file to // this new one. Such behaviour may be unexpected. if (count(explode('/', $name)) > 1) { throw new InvalidArgumentException('File name can not contain "/" character.'); } $destination = $this->directory().'/'.$name; $response = $this->api->request('PUT', $this->absolutePath($destination), [ 'headers' => [ 'X-Copy-From' => $this->absolutePath(), 'Content-Length' => 0, ], ]); if ($response->getStatusCode() !== 201) { throw new ApiRequestFailedException( 'Unable to rename file from "'.$this->name().'" to "'.$name.'" (path: "'.$this->directory().'").', $response->getStatusCode() ); } // Since Selectel Storage does not provide such method as "rename", // we need to delete original file after copying. Also, "deleted" // flag needs to be reverted because file was actually renamed. $this->delete(); $this->deleted = false; return $this->data['name'] = $destination; }
php
{ "resource": "" }
q3158
File.copy
train
public function copy($destination, $destinationContainer = null) { $this->guardDeletedFile(); if (is_null($destinationContainer)) { $destinationContainer = $this->container(); } $fullDestination = '/'.$destinationContainer.'/'.ltrim($destination, '/'); $response = $this->api->request('COPY', $this->absolutePath(), [ 'headers' => [ 'Destination' => $fullDestination, ], ]); if ($response->getStatusCode() !== 201) { throw new ApiRequestFailedException( 'Unable to copy file from "'.$this->path().'" to "'.$destination.'".', $response->getStatusCode() ); } return $fullDestination; }
php
{ "resource": "" }
q3159
File.delete
train
public function delete() { $this->guardDeletedFile(); $response = $this->api->request('DELETE', $this->absolutePath()); if ($response->getStatusCode() !== 204) { throw new ApiRequestFailedException('Unable to delete file "'.$this->path().'".', $response->getStatusCode()); } // Set deleted flag to true, so any other calls to // this File will result in throwing exception. $this->deleted = true; return true; }
php
{ "resource": "" }
q3160
File.jsonSerialize
train
public function jsonSerialize() { return [ 'name' => $this->name(), 'path' => $this->path(), 'directory' => $this->directory(), 'container' => $this->container(), 'size' => $this->size(), 'content_type' => $this->contentType(), 'last_modified' => $this->lastModifiedAt(), 'etag' => $this->etag(), ]; }
php
{ "resource": "" }
q3161
GiroCheckout_SDK_Notify.getResponseParam
train
public function getResponseParam($param) { if (isset($this->notifyParams[$param])) { return $this->notifyParams[$param]; } return NULL; }
php
{ "resource": "" }
q3162
GiroCheckout_SDK_Notify.parseNotification
train
public function parseNotification($params) { $Config = GiroCheckout_SDK_Config::getInstance(); if ($Config->getConfig('DEBUG_MODE')) { GiroCheckout_SDK_Debug_helper::getInstance()->logNotificationInput($params); } if (!is_array($params) || empty($params)) { throw new GiroCheckout_SDK_Exception_helper('no data given'); } try { $this->notifyParams = $this->requestMethod->checkNotification($params); if ($Config->getConfig('DEBUG_MODE')) { GiroCheckout_SDK_Debug_helper::getInstance()->logNotificationParams($this->notifyParams); } if (!$this->checkHash()) { throw new GiroCheckout_SDK_Exception_helper('hash mismatch'); } } catch (\Exception $e) { throw new GiroCheckout_SDK_Exception_helper('Failure: ' . $e->getMessage() . "\n"); } return TRUE; }
php
{ "resource": "" }
q3163
GiroCheckout_SDK_Notify.checkHash
train
public function checkHash() { $string = ''; $hashFieldName = $this->requestMethod->getNotifyHashName(); foreach ($this->notifyParams as $k => $v) { if ($k !== $hashFieldName) { $string .= $v; } } if ($this->notifyParams[$hashFieldName] === hash_hmac('md5', $string, $this->secret)) { return TRUE; } return FALSE; }
php
{ "resource": "" }
q3164
GiroCheckout_SDK_Notify.avsSuccessful
train
public function avsSuccessful() { if ($this->requestMethod->getAVSSuccessfulCode() != NULL) { return $this->requestMethod->getAVSSuccessfulCode() == $this->notifyParams['gcResultAVS']; } return FALSE; }
php
{ "resource": "" }
q3165
GiroCheckout_SDK_Notify.sendOkStatus
train
public function sendOkStatus() { $Config = GiroCheckout_SDK_Config::getInstance(); if ($Config->getConfig('DEBUG_MODE')) { GiroCheckout_SDK_Debug_helper::getInstance()->logNotificationOutput('sendOkStatus'); } header('HTTP/1.1 200 OK'); }
php
{ "resource": "" }
q3166
GiroCheckout_SDK_Notify.sendBadRequestStatus
train
public function sendBadRequestStatus() { $Config = GiroCheckout_SDK_Config::getInstance(); if ($Config->getConfig('DEBUG_MODE')) { GiroCheckout_SDK_Debug_helper::getInstance()->logNotificationOutput('sendBadRequestStatus'); } header('HTTP/1.1 400 Bad Request'); }
php
{ "resource": "" }
q3167
GiroCheckout_SDK_Notify.sendServiceUnavailableStatus
train
public function sendServiceUnavailableStatus() { $Config = GiroCheckout_SDK_Config::getInstance(); if ($Config->getConfig('DEBUG_MODE')) { GiroCheckout_SDK_Debug_helper::getInstance()->logNotificationOutput('sendServiceUnavailableStatus'); } header('HTTP/1.1 503 Service Unavailable'); }
php
{ "resource": "" }
q3168
GiroCheckout_SDK_Notify.sendOtherStatus
train
public function sendOtherStatus() { $Config = GiroCheckout_SDK_Config::getInstance(); if ($Config->getConfig('DEBUG_MODE')) { GiroCheckout_SDK_Debug_helper::getInstance()->logNotificationOutput('sendOtherStatus'); } header('HTTP/1.1 404 Not Found'); }
php
{ "resource": "" }
q3169
GiroCheckout_SDK_Notify.getNotifyResponseStringJson
train
public function getNotifyResponseStringJson() { $response['Result'] = $this->notifyResponse['Result']; $response['ErrorMessage'] = $this->notifyResponse['ErrorMessage']; $response['OrderId'] = $this->notifyResponse['OrderId']; $response['CustomerId'] = $this->notifyResponse['CustomerId']; $response['MailSent'] = $this->notifyResponse['MailSent']; $response['Timestamp'] = time(); return json_encode($this->notifyResponse); }
php
{ "resource": "" }
q3170
Tx_Oelib_FrontEndLoginManager.getLoggedInUser
train
public function getLoggedInUser($mapperName = \Tx_Oelib_Mapper_FrontEndUser::class) { if ($mapperName === '') { throw new \InvalidArgumentException('$mapperName must not be empty.', 1331488730); } if (!$this->isLoggedIn()) { return null; } if ($this->loggedInUser !== null) { $user = $this->loggedInUser; } else { /** @var \Tx_Oelib_Mapper_FrontEndUser $mapper */ $mapper = \Tx_Oelib_MapperRegistry::get($mapperName); /** @var \Tx_Oelib_Model_FrontEndUser $user */ $user = $mapper->find($this->getFrontEndController()->fe_user->user['uid']); } return $user; }
php
{ "resource": "" }
q3171
AbstractInitializer.getSettingOrThrow
train
public function getSettingOrThrow($key) { if ( !isset($this->data[$key])) { throw new UnknownSettingException($this->id, $key); } return $this->data[$key]; }
php
{ "resource": "" }
q3172
AbstractInitializer.getSetting
train
public function getSetting($key, $defaultValue) { if ( !isset($this->data[$key])) { return $defaultValue; } return $this->data[$key]; }
php
{ "resource": "" }
q3173
Tx_Oelib_TemplateHelper.init
train
public function init($configuration = null) { if ($this->isInitialized) { return; } // Calls the base class's constructor manually as this isn't done automatically. parent::__construct(); $this->initializeConfiguration($configuration); $this->ensureContentObject(); if ($this->extKey !== '') { $this->pi_setPiVarDefaults(); $this->pi_loadLL(); $this->initializeConfigurationCheck(); } $this->isInitialized = true; }
php
{ "resource": "" }
q3174
Tx_Oelib_TemplateHelper.getConfValue
train
private function getConfValue( $fieldName, $sheet = 'sDEF', $isFileName = false, $ignoreFlexform = false ) { $flexformsValue = ''; if (!$ignoreFlexform) { $flexformsValue = $this->pi_getFFvalue( $this->cObj->data['pi_flexform'], $fieldName, $sheet ); } if ($isFileName && $flexformsValue !== null && $flexformsValue !== '') { $flexformsValue = $this->addPathToFileName($flexformsValue); } $confValue = isset($this->conf[$fieldName]) ? $this->conf[$fieldName] : ''; return $flexformsValue ?: $confValue; }
php
{ "resource": "" }
q3175
Tx_Oelib_TemplateHelper.addPathToFileName
train
private function addPathToFileName($fileName, $path = '') { if (empty($path)) { $path = 'uploads/tx_' . $this->extKey . '/'; } return $path . $fileName; }
php
{ "resource": "" }
q3176
Tx_Oelib_TemplateHelper.getConfValueString
train
public function getConfValueString( $fieldName, $sheet = 'sDEF', $isFileName = false, $ignoreFlexform = false ) { return trim( $this->getConfValue( $fieldName, $sheet, $isFileName, $ignoreFlexform ) ); }
php
{ "resource": "" }
q3177
Tx_Oelib_TemplateHelper.hasConfValueString
train
public function hasConfValueString( $fieldName, $sheet = 'sDEF', $ignoreFlexform = false ) { return $this->getConfValueString( $fieldName, $sheet, false, $ignoreFlexform ) !== ''; }
php
{ "resource": "" }
q3178
Tx_Oelib_TemplateHelper.setCachedConfigurationValue
train
public static function setCachedConfigurationValue($key, $value) { $pageUid = \Tx_Oelib_PageFinder::getInstance()->getPageUid(); if (!isset(self::$cachedConfigurations[$pageUid])) { self::$cachedConfigurations[$pageUid] = []; } self::$cachedConfigurations[$pageUid][$key] = $value; }
php
{ "resource": "" }
q3179
Tx_Oelib_TemplateHelper.setLabels
train
public function setLabels() { $template = $this->getTemplate(); try { $labels = $template->getLabelMarkerNames(); } catch (Exception $exception) { $labels = []; } foreach ($labels as $label) { $template->setMarker($label, $this->translate($label)); } }
php
{ "resource": "" }
q3180
Tx_Oelib_TemplateHelper.ensureIntegerArrayValues
train
protected function ensureIntegerArrayValues(array $keys) { if (empty($keys)) { return; } foreach ($keys as $key) { if (!isset($this->piVars[$key]) || !is_array($this->piVars[$key]) ) { continue; } foreach ($this->piVars[$key] as $innerKey => $value) { $integerValue = (int)$value; if ($integerValue === 0) { unset($this->piVars[$key][$innerKey]); } else { $this->piVars[$key][$innerKey] = $integerValue; } } } }
php
{ "resource": "" }
q3181
Tx_Oelib_TemplateHelper.getListViewConfigurationValue
train
private function getListViewConfigurationValue($fieldName) { if (empty($fieldName)) { throw new \InvalidArgumentException('$fieldName must not be empty.', 1331489528); } if (!isset($this->conf['listView.']) || !isset($this->conf['listView.'][$fieldName]) ) { return ''; } return $this->conf['listView.'][$fieldName]; }
php
{ "resource": "" }
q3182
GiroCheckout_SDK_Hash_helper.getHMACMD5Hash
train
public static function getHMACMD5Hash($password, $data) { $dataString = implode('', $data); return self::getHMACMD5HashString($password, $dataString); }
php
{ "resource": "" }
q3183
GiroCheckout_SDK_Hash_helper.getHMACMD5HashString
train
public static function getHMACMD5HashString($password, $data) { if (function_exists('hash_hmac')) { return hash_hmac('MD5', $data, $password); } else { return self::hmacFallbackMD5($data, $password); } }
php
{ "resource": "" }
q3184
ContentCacheFlusherService.generateCacheTags
train
protected function generateCacheTags($node) { $this->tagsToFlush[ContentCache::TAG_EVERYTHING] = 'which were tagged with "Everything".'; if (empty($this->workspacesToFlush[$node->getWorkspace()->getName()])) { $this->resolveWorkspaceChain($node->getWorkspace()); } if (!array_key_exists($node->getWorkspace()->getName(), $this->workspacesToFlush)) { return; } $nodeIdentifier = $node->getIdentifier(); foreach ($this->workspacesToFlush[$node->getWorkspace()->getName()] as $workspaceName => $workspaceHash) { $this->generateCacheTagsForNodeIdentifier($workspaceHash .'_'. $nodeIdentifier); $this->generateCacheTagsForNodeType($node->getNodeType()->getName(), $nodeIdentifier, $workspaceHash); $nodeInWorkspace = $node; while ($nodeInWorkspace->getDepth() > 1) { $nodeInWorkspace = $nodeInWorkspace->getParent(); // Workaround for issue #56566 in Neos.ContentRepository if ($nodeInWorkspace === null) { break; } $tagName = 'DescendantOf_' . $workspaceHash . '_' . $nodeInWorkspace->getIdentifier(); $this->tagsToFlush[$tagName] = sprintf('which were tagged with "%s" because node "%s" has changed.', $tagName, $node->getPath()); } } if ($node instanceof NodeInterface && $node->getContext() instanceof ContentContext) { /** @var Site $site */ $site = $node->getContext()->getCurrentSite(); if ($site->hasActiveDomains()) { $domains = $site->getActiveDomains()->map(function (Domain $domain) { return $domain->getHostname(); })->toArray(); $this->domainsToFlush = array_unique(array_merge($this->domainsToFlush, $domains)); } } }
php
{ "resource": "" }
q3185
Tx_Oelib_Template.getMarker
train
public function getMarker($markerName) { $unifiedMarkerName = $this->createMarkerName($markerName); if (!isset($this->markers[$unifiedMarkerName])) { return ''; } return $this->markers[$unifiedMarkerName]; }
php
{ "resource": "" }
q3186
Tx_Oelib_Template.isSubpartVisible
train
public function isSubpartVisible($subpartName) { if ($subpartName === '') { return false; } return isset($this->subparts[$subpartName]) && !isset($this->subpartsToHide[$subpartName]); }
php
{ "resource": "" }
q3187
Tx_Oelib_Template.replaceSubparts
train
protected function replaceSubparts($templateCode) { $template = $this; return preg_replace_callback( self::SUBPART_PATTERN, function (array $matches) use ($template) { return $template->getSubpart($matches[1]); }, $templateCode ); }
php
{ "resource": "" }
q3188
Trackable.attachTrackerView
train
public function attachTrackerView($view) { if ( ! $this->trackerViews->contains($view->getKey())) { return $this->trackerViews()->attach($view); } }
php
{ "resource": "" }
q3189
Terms.implodeSlugs
train
public static function implodeSlugs($glue, $terms) { if ($terms==null || empty($terms) || is_wp_error($terms)) return ''; $tokens = array(); foreach ($terms as $t) { $tokens[] = $t->slug; } return implode($glue, $tokens); }
php
{ "resource": "" }
q3190
Terms.implodeNames
train
public static function implodeNames($glue, $terms) { if ($terms==null || empty($terms) || is_wp_error($terms)) return ''; $tokens = array(); foreach ($terms as $t) { $tokens[] = $t->name; } return implode($glue, $tokens); }
php
{ "resource": "" }
q3191
Tx_Oelib_ConfigurationProxy.get
train
protected function get($key) { $this->loadConfigurationLazily(); if ($this->hasConfigurationValue($key)) { $result = $this->configuration[$key]; } else { $result = ''; } return $result; }
php
{ "resource": "" }
q3192
VarnishCommandController.clearCommand
train
public function clearCommand($domain = null, $contentType = null) { $this->varnishBanService->banAll($domain, $contentType); }
php
{ "resource": "" }
q3193
DataTablesFactory.copyParameterBag
train
protected static function copyParameterBag(ParameterBag $src, ParameterBag $dst) { foreach ($src->keys() as $current) { if (true === in_array($current, DataTablesEnumerator::enumParameters())) { continue; } $dst->set($current, $src->get($current)); } }
php
{ "resource": "" }
q3194
DataTablesFactory.isValidRawColumn
train
protected static function isValidRawColumn(array $rawColumn) { if (false === array_key_exists(DataTablesColumnInterface::DATATABLES_PARAMETER_DATA, $rawColumn)) { return false; } if (false === array_key_exists(DataTablesColumnInterface::DATATABLES_PARAMETER_NAME, $rawColumn)) { return false; } return true; }
php
{ "resource": "" }
q3195
DataTablesFactory.isValidRawOrder
train
protected static function isValidRawOrder(array $rawOrder) { if (false === array_key_exists(DataTablesOrderInterface::DATATABLES_PARAMETER_COLUMN, $rawOrder)) { return false; } if (false === array_key_exists(DataTablesOrderInterface::DATATABLES_PARAMETER_DIR, $rawOrder)) { return false; } return true; }
php
{ "resource": "" }
q3196
DataTablesFactory.isValidRawSearch
train
protected static function isValidRawSearch(array $rawSearch) { if (false === array_key_exists(DataTablesSearchInterface::DATATABLES_PARAMETER_REGEX, $rawSearch)) { return false; } if (false === array_key_exists(DataTablesSearchInterface::DATATABLES_PARAMETER_VALUE, $rawSearch)) { return false; } return true; }
php
{ "resource": "" }
q3197
DataTablesFactory.newColumn
train
public static function newColumn($data, $name, $cellType = DataTablesColumnInterface::DATATABLES_CELL_TYPE_TD) { $dtColumn = new DataTablesColumn(); $dtColumn->getMapping()->setColumn($data); $dtColumn->setCellType($cellType); $dtColumn->setData($data); $dtColumn->setName($name); $dtColumn->setTitle($name); return $dtColumn; }
php
{ "resource": "" }
q3198
DataTablesFactory.newWrapper
train
public static function newWrapper($url, DataTablesProviderInterface $provider, UserInterface $user = null) { $dtWrapper = new DataTablesWrapper(); $dtWrapper->getMapping()->setPrefix($provider->getPrefix()); $dtWrapper->setMethod($provider->getMethod()); $dtWrapper->setProvider($provider); $dtWrapper->setUser($user); $dtWrapper->setUrl($url); return $dtWrapper; }
php
{ "resource": "" }
q3199
DataTablesFactory.parseColumn
train
protected static function parseColumn(array $rawColumn, DataTablesWrapperInterface $wrapper) { if (false === static::isValidRawColumn($rawColumn)) { return null; } $dtColumn = $wrapper->getColumn($rawColumn[DataTablesColumnInterface::DATATABLES_PARAMETER_DATA]); if (null === $dtColumn) { return null; } if ($dtColumn->getName() !== $rawColumn[DataTablesColumnInterface::DATATABLES_PARAMETER_NAME]) { return null; } if (false === $dtColumn->getSearchable()) { $dtColumn->setSearch(static::parseSearch([])); // Set a default search. return $dtColumn; } $dtColumn->setSearch(static::parseSearch($rawColumn[DataTablesColumnInterface::DATATABLES_PARAMETER_SEARCH])); return $dtColumn; }
php
{ "resource": "" }