_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30700 | ResponseRecordStorage.unfinishedResponses | train | protected function unfinishedResponses()
{
$now = TimeSupport::now();
$unfinishedReps = [];
foreach ($this->reps as $pid=>$response)
{
if ($now >= $response->timeout)
{
$unfinishedReps[] = $response;
$response->timeout = $now +... | php | {
"resource": ""
} |
q30701 | ResponseRecordStorage.expireResponses | train | protected function expireResponses()
{
$now = TimeSupport::now();
$expiredReps = [];
foreach ($this->handledReps as $pid=>$response)
{
if ($now >= $response->timeout)
{
$expiredReps[] = $pid;
}
}
foreach ($expiredR... | php | {
"resource": ""
} |
q30702 | ThemeChanger.change | train | public function change(ThemeInterface $previousTheme, ThemeInterface $theme, $path, array $templatesMap)
{
$this->saveThemeStructure($previousTheme, $path);
$this->changeTemplate($theme, $templatesMap);
} | php | {
"resource": ""
} |
q30703 | ThemeChanger.saveThemeStructure | train | protected function saveThemeStructure(ThemeInterface $theme, $themeStructureFile)
{
$templates = array();
foreach ($this->languagesRepository->activeLanguages() as $language) {
foreach ($this->pagesRepository->activePages() as $page) {
$key = $language->getId() . '-' . $p... | php | {
"resource": ""
} |
q30704 | HiddenWidget.render | train | public function render(array $data, ContextInterface $context)
{
$data = optionsParser($data, [
'name' => '',
'val' => null,
'type' => 'text',
'escape' => true,
'templateVars' => [],
]);
$data->add('value', $data->consume('val'));
... | php | {
"resource": ""
} |
q30705 | AppConnect.initialize | train | public function initialize() : void
{
$connection = config('database.default');
Accessor::$appRoot = config('app.dir');
UpstartConfig::$database = config("database.connections.{$connection}");
if (!DB::start()) {
$this->exception('Could not establish a database connection.');
}
... | php | {
"resource": ""
} |
q30706 | KikDriver.convertQuestion | train | private function convertQuestion(Question $question)
{
$buttons = $question->getButtons();
if ($buttons) {
return [
[
'type' => 'suggested',
'responses' => Collection::make($buttons)->transform(function ($button) {
... | php | {
"resource": ""
} |
q30707 | GeotSession.get | train | public function get( $key ) {
$key = sanitize_key( $key );
return isset( $_SESSION[ $key ] ) ? json_decode( $_SESSION[ $key ] ) : false;
} | php | {
"resource": ""
} |
q30708 | GeotSession.set | train | public function set( $key, $value ) {
$key = sanitize_key( $key );
$_SESSION[ $key ] = wp_json_encode( $value );
return $_SESSION[ $key ];
} | php | {
"resource": ""
} |
q30709 | GeotSession.should_start_session | train | public function should_start_session() {
$start_session = true;
if ( ! empty( $_SERVER['REQUEST_URI'] ) ) {
$blacklist = $this->get_blacklist();
$uri = ltrim( $_SERVER['REQUEST_URI'], '/' );
$uri = untrailingslashit( $uri );
if ( in_array( $uri, $blacklist ) ) {
$start_session = false;
... | php | {
"resource": ""
} |
q30710 | GeotSession.get_blacklist | train | public function get_blacklist() {
$blacklist = apply_filters( 'geot/sessions/session_start_uri_blacklist', array(
'feed',
'feed/rss',
'feed/rss2',
'feed/rdf',
'feed/atom',
'comments/feed',
) );
// Look to see if WordPress is in a sub folder or this is a network site that uses sub folders
$fold... | php | {
"resource": ""
} |
q30711 | LRUCache.set | train | public function set(string $key, $value): void
{
if (isset($this->data[$key])) {
unset($this->data[$key]);
} else {
if ($this->size >= $this->maxSize) {
\reset($this->data);
unset($this->data[\key($this->data)]);
} else {
... | php | {
"resource": ""
} |
q30712 | LRUCache.remove | train | public function remove(string $key): void
{
if (isset($this->data[$key])) {
unset($this->data[$key]);
$this->size--;
}
} | php | {
"resource": ""
} |
q30713 | App.commit | train | private static function commit()
{
$transaction = env('SIMPLES_TRANSACTION_CLASS', '\\Simples\\Persistence\\Transaction');
if (!class_exists($transaction)) {
return;
}
if (!method_exists($transaction, 'commit')) {
throw new ErrorException("The transaction com... | php | {
"resource": ""
} |
q30714 | App.request | train | public static function request()
{
$container = Container::instance();
if (!$container->has('request')) {
$request = new Request(Kernel::options('strict'));
$container->register('request', $request->fromServer());
}
return $container->get('request');
} | php | {
"resource": ""
} |
q30715 | App.response | train | public static function response()
{
$container = Container::instance();
if (!$container->has('response')) {
$container->register('response', new Response());
}
return $container->get('response');
} | php | {
"resource": ""
} |
q30716 | Configuration.getConfigTreeBuilder | train | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root($this->alias);
$rootNode
->validate()
->ifTrue(function($v) {
return !empty($v['enabled']) && empty($v['pools']);
})
... | php | {
"resource": ""
} |
q30717 | Handler.create | train | public function create($handlerType, $level)
{
if (false === array_key_exists('handler', $this->_config)) {
throw new MonologCreator\Exception(
'no handler configuration found'
);
}
if (false === array_key_exists($handlerType, $this->_config['handler'... | php | {
"resource": ""
} |
q30718 | Game.allowBonus | train | public function allowBonus($game, $user)
{
if (! $game->getPlayBonus() || $game->getPlayBonus() == 'none') {
return false;
} elseif ($game->getPlayBonus() == 'one') {
if ($this->getEntryMapper()->findOneBy(array(
'game' => $game,
'user' => $use... | php | {
"resource": ""
} |
q30719 | Game.addAnotherChance | train | public function addAnotherChance($game, $user, $winner = 0)
{
if ($this->allowBonus($game, $user)) {
$this->addAnotherEntry($game, $user, $winner);
return true;
}
return false;
} | php | {
"resource": ""
} |
q30720 | Game.playAgain | train | public function playAgain($game, $user, $winner = 0)
{
if ($this->allowBonus($game, $user)) {
$entry = $this->addAnotherEntry($game, $user, $winner);
$entry->setActive(1);
$entry = $this->getEntryMapper()->update($entry);
if ($entry->getActive() == 1) {
... | php | {
"resource": ""
} |
q30721 | ErrorReport.errorHandling | train | private function errorHandling(?bool $isConsole = false)
{
$this->internalErrors();
$whoopsRun = new WhoopsRun;
$development = new PrettyPageHandler;
$errors = new Error;
$production = new CallbackHandler($this->uiRegister());
$cliErrors = new CallbackHandler($this->cliReg... | php | {
"resource": ""
} |
q30722 | ErrorReport.uiRegister | train | public function uiRegister() : Closure
{
return function($exception, $inspector, $run) {
$appHandler = new \App\Exceptions\Handler();
if ($exception instanceof Exception) {
return $appHandler->render(
$this->getRequest() ?? new Request(array_merge($_POST, $_FILES)),
$excep... | php | {
"resource": ""
} |
q30723 | ErrorReport.cliRegister | train | public function cliRegister() : Closure
{
return function($exception, $inspector, $run) {
Output::error($exception);
die($exception . PHP_EOL);
exit;
};
} | php | {
"resource": ""
} |
q30724 | BorderManager.buildBorder | train | public static function buildBorder($string, Border $border)
{
switch ($border->getType()) {
case Border::TYPE_UNDERLINE:
$result = self::buildUnderline($string, $border);
break;
case Border::TYPE_FRAME:
$result = self::buildFrame($strin... | php | {
"resource": ""
} |
q30725 | BorderManager.buildUnderline | train | private static function buildUnderline($string, Border $border)
{
$stringLength = Util::getVisibleStringLength($string);
$underline = Util::buildPatternLine($border->getLineCharacter(), $stringLength);
$result = $string . PHP_EOL . $underline . PHP_EOL;
return $result;
} | php | {
"resource": ""
} |
q30726 | BorderManager.buildFrame | train | private static function buildFrame($string, Border $border)
{
$stringLength = Util::getVisibleStringLength($string);
$line = Util::buildPatternLine($border->getLineCharacter(), $stringLength + 2);
$firstLine = $border->getCrossCharacter() . $line . $border->getCrossCharacter();
$ma... | php | {
"resource": ""
} |
q30727 | BorderManager.__underlineBorder | train | private static function __underlineBorder($string)
{
$border = new Border(Border::TYPE_UNDERLINE);
$borderedElement = new BorderedElement($string, $border);
return $borderedElement->render();
} | php | {
"resource": ""
} |
q30728 | BorderManager.__doubleUnderlineBorder | train | private static function __doubleUnderlineBorder($string)
{
$border = new Border(Border::TYPE_UNDERLINE, '=');
$borderedElement = new BorderedElement($string, $border);
return $borderedElement->render();
} | php | {
"resource": ""
} |
q30729 | BorderManager.__border | train | private static function __border($string)
{
$border = new Border(Border::TYPE_FRAME);
$borderedElement = new BorderedElement($string, $border);
return $borderedElement->render();
} | php | {
"resource": ""
} |
q30730 | BorderManager.__doubleBorder | train | private static function __doubleBorder($string)
{
$border = new Border(Border::TYPE_FRAME, '=', '#', '*');
$borderedElement = new BorderedElement($string, $border);
return $borderedElement->render();
} | php | {
"resource": ""
} |
q30731 | Response.failure | train | public static function failure($code, $err = 'Unknown', $uri = '', $method = '', $extra = '') {
// syslog(LOG_WARNING, print_r($extra, TRUE));
switch ($code) {
case '403':
throw new \HPCloud\Transport\ForbiddenException($err);
case '401':
throw new \HPCloud\Transport\UnauthorizedEx... | php | {
"resource": ""
} |
q30732 | Response.content | train | public function content() {
$out = '';
// XXX: The addition of the Content-Length check is a workaround
// for an issue with using PHP Stream Wrappers to communicate with
// Identity Service. Apparently, the remote does not provide
// an EOF marker, and PHP is too dumb to truncate at Content-Length... | php | {
"resource": ""
} |
q30733 | Response.header | train | public function header($name, $default = NULL) {
if (isset($this->headers[$name])) {
return $this->headers[$name];
}
return $default;
} | php | {
"resource": ""
} |
q30734 | Response.parseHeaders | train | protected function parseHeaders($headerArray) {
$ret = array_shift($headerArray);
$responseLine = preg_split('/\s/', $ret);
$count = count($headerArray);
$this->protocol = $responseLine[0];
$this->code = (int) $responseLine[1];
$this->message = $responseLine[2];
// A CONTINUE response mean... | php | {
"resource": ""
} |
q30735 | Config.getInfo | train | public function getInfo($name)
{
$keys = explode('.', $name);
if (is_array($keys)) {
$file = array_shift($keys);
$key = implode('.', $keys);
} else {
$file = $name;
$key = null;
}
return ['file' => $file, 'key' => $key];
} | php | {
"resource": ""
} |
q30736 | BlocksAdderMenuItem.addElement | train | public function addElement($blockType, array $element)
{
$this->blockType = $blockType;
$this->label = $element["description"];
$this->filter = $element["filter"];
$this->type = 'element';
} | php | {
"resource": ""
} |
q30737 | CURLTransport.execCurl | train | protected function execCurl($handle) {
if (empty($this->multi)) {
$multi = curl_multi_init();
$this->multi = $multi;
// fwrite(STDOUT, "Creating MULTI handle.\n");
}
else {
// fwrite(STDOUT, "Reusing MULTI handle.\n");
$multi = $this->multi;
}
curl_multi_add_handle($mul... | php | {
"resource": ""
} |
q30738 | CURLTransport.fetchHeaders | train | protected function fetchHeaders($file) {
$buffer = array();
while ($header = fgets($file)) {
$header = trim($header);
if ($header == 'HTTP/1.1 100 Continue') {
// Obey the command.
continue;
}
if (!empty($header)) {
$buffer[] = $header;
}
}
return $b... | php | {
"resource": ""
} |
q30739 | CURLTransport.determineMethod | train | protected function determineMethod($curl, $method) {
$method = strtoupper($method);
switch ($method) {
case 'GET':
curl_setopt($curl, CURLOPT_HTTPGET, TRUE);
break;
case 'HEAD':
curl_setopt($curl, CURLOPT_NOBODY, TRUE);
break;
// Put is problematic: Some PUT r... | php | {
"resource": ""
} |
q30740 | FileStream.getFileName | train | protected function getFileName()
{
$fileName = parent::getFileName();
if ($this->maxCount !== false) {
$fileName = strtr($fileName, [$this->countPlaceHolder => $this->currentFileCount]);
}
return $fileName;
} | php | {
"resource": ""
} |
q30741 | RouterFactory.build | train | public function build(array $config)
{
$router = new Router();
foreach ($config as $name => $route) {
if ($route instanceof RouteInterface) {
$router->register($name, $route);
continue;
}
$route = $this->applyDefaults($route);
... | php | {
"resource": ""
} |
q30742 | eZFlowPoolItem.definition | train | public static function definition()
{
return array( 'fields' => array( 'block_id' => array( 'name' => 'BlockID',
'datatype' => 'string',
'default' => '',
... | php | {
"resource": ""
} |
q30743 | eZFlowPoolItem.fetchListByContentObjectId | train | static function fetchListByContentObjectId( $objectId )
{
$conds = array( 'object_id' => $objectId );
$objectList = eZPersistentObject::fetchObjectList( self::definition(), null, $conds );
return $objectList;
} | php | {
"resource": ""
} |
q30744 | LanguageManager.add | train | protected function add(array $values)
{
$values =
$this->dispatchBeforeOperationEvent(
'\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\BeforeLanguageAddingEvent',
LanguageEvents::BEFORE_ADD_LANGUAGE,
... | php | {
"resource": ""
} |
q30745 | LanguageManager.edit | train | protected function edit(array $values)
{
$values =
$this->dispatchBeforeOperationEvent(
'\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Language\BeforeLanguageEditingEvent',
LanguageEvents::BEFORE_EDIT_LANGUAGE,
$values,
... | php | {
"resource": ""
} |
q30746 | LanguageManager.resetMain | train | protected function resetMain()
{
try {
$language = $this->languageRepository->mainLanguage();
if (null !== $language) {
$result = $this->languageRepository
->setRepositoryObject($language)
->save(array('MainLangu... | php | {
"resource": ""
} |
q30747 | Parser.decode | train | public static function decode($value, $assoc = false)
{
$data = json_decode((string) $value, $assoc);
switch (json_last_error()) {
case JSON_ERROR_NONE:
return $data;
break;
case JSON_ERROR_DEPTH:
throw new \RuntimeException('... | php | {
"resource": ""
} |
q30748 | Trace.normalize | train | final public function normalize(): void
{
foreach ($this->props['items'] as &$item) {
$item = array_replace($this->defaultItem, $item);
}
unset($item);
} | php | {
"resource": ""
} |
q30749 | Trace.truncateByLimit | train | final public function truncateByLimit(int $limit): bool
{
if (count($this->props['items']) <= $limit) {
return false;
}
$this->props['items'] = array_slice($this->props['items'], 0, $limit);
return true;
} | php | {
"resource": ""
} |
q30750 | Trace.trimFilename | train | public function trimFilename(string $prefix): bool
{
$affected = false;
$len = strlen($prefix);
foreach ($this->props['items'] as &$item) {
if ((!empty($item['file'])) && (strpos($item['file'], $prefix) === 0)) {
$item['file'] = substr($item['file'], $len);
... | php | {
"resource": ""
} |
q30751 | Trace.truncate | train | public function truncate(array $options): bool
{
$options = array_replace($this->defaultOptions, $options);
$nItems = [];
foreach (array_reverse($this->props['items']) as $item) {
$f = $this->filterItem($item, $options);
if ($f) {
if ($f !== self::FILT... | php | {
"resource": ""
} |
q30752 | Trace.filterItem | train | protected function filterItem(array $item, array $options)
{
if ($options['filter']) {
$f = call_user_func($options['filter'], $item);
if ($f) {
return $f;
}
}
if (!empty($item['class'])) {
$result = $this->filterByClass($item, ... | php | {
"resource": ""
} |
q30753 | XenforoPassword.hashRaw | train | private function hashRaw($password, $salt, $function = '', $storedHash = null) {
if ($function == '') {
$function = $this->hashFunction;
}
if($function !== 'crypt') {
$calcHash = hash($function, hash($function, $password).$salt);
} else if(!is_null($storedHash)){... | php | {
"resource": ""
} |
q30754 | IncludeParser.prefixParentKeys | train | protected function prefixParentKeys($key, array $parent): string
{
return !empty($parent) ?
$this->flattenKeys($parent).".$key" : $key;
} | php | {
"resource": ""
} |
q30755 | Security.tokenize | train | public function tokenize(array $credentials)
{
if (empty($credentials)) {
throw new AuthenticationException('Unable to create token, no or empty credentials');
}
foreach ($this->providers as $provider) {
if (!$provider->supportsCredentials($credentials)) {
... | php | {
"resource": ""
} |
q30756 | Security.authenticate | train | public function authenticate(RequestInterface $request)
{
$token = $this->token();
if (!$token && !$this->findMatchingArea($request)) {
return $this;
}
if (!$token) {
throw new AuthenticationException('Unable to authenticate, token is missing');
}
... | php | {
"resource": ""
} |
q30757 | Security.authorize | train | public function authorize(RequestInterface $request)
{
if (!$area = $this->findMatchingArea($request)) {
return $this;
}
if (!$this->user) {
throw new AuthorizationException(sprintf('Access denied to area "%s". No authenticated user', $area->pattern()));
}
... | php | {
"resource": ""
} |
q30758 | Security.findMatchingArea | train | protected function findMatchingArea(RequestInterface $request)
{
foreach ($this->areas as $area) {
if (!$area->match($request)) {
continue;
}
return $area;
}
return null;
} | php | {
"resource": ""
} |
q30759 | ViewComponent.loadView | train | private function loadView(bool $try = false) : void
{
// configure view component
Accessor::$viewsExtension = config('view.extension');
Accessor::$viewsEngine = config('view.engine');
Accessor::$viewsCache = config('app.dir') . config('view.compiled');
Accessor::$viewsDirectory = config('ap... | php | {
"resource": ""
} |
q30760 | Validate.check | train | public static function check(Plugin $plugin, ReflectionClass $info) : bool
{
/**
* Check if plugin meets the minimum requirements
*/
if (
array_key_exists('PACKAGE', $info->getConstants()) &&
array_key_exists('VERSION', $info->getConstants()) &&
(
array_key_exists('AUTHORS'... | php | {
"resource": ""
} |
q30761 | Validate.isCompatable | train | private static function isCompatable(Plugin $plugin) : bool
{
$frameworkVersion = substr(self::getVersion(), 0, strrpos(self::getVersion(), '*'));
$pluginVersions = explode('|', $plugin::FRAMEWORK);
foreach($pluginVersions as $version) {
$version = substr($version, 0, strrpos($version, '*'));
... | php | {
"resource": ""
} |
q30762 | aContainerCapped.setServices | train | function setServices(iContainer $container)
{
/** @var Container $container */
$this->sc = $container;
$container->nest($this, uniqid()); // for now nested name are not valuable.
} | php | {
"resource": ""
} |
q30763 | CustomerDetailsForm.getDeliveryFields | train | public function getDeliveryFields()
{
$contact = $this->getContact();
$fields = FieldList::create(
CompositeField::create(
CompositeField::create(
TextField::create(
'DeliveryCompany',
_t('SilverCommerce... | php | {
"resource": ""
} |
q30764 | CustomerDetailsForm.getDeliveryDropdownFields | train | public function getDeliveryDropdownFields()
{
$contact = $this->getContact();
return FieldList::create(
CompositeField::create(
DropdownField::create(
'ShippingAddress',
_t(
'SilverCommerce\Checkout.Delivery... | php | {
"resource": ""
} |
q30765 | UploadedFile.move | train | public function move($path, $file = null, $overwrite = false)
{
if (!$this->isValid()) {
throw new UploadedFileException('Upload was not successful - '.$this->getErrorMessage());
}
$target = $this->getTarget($path, $file);
if (!$overwrite && is_file($target)) {
... | php | {
"resource": ""
} |
q30766 | UploadedFile.getTarget | train | protected function getTarget($path, $file = null)
{
if ($file === null) {
$nArr = explode('.', $this->raw['name']);
$file = md5(microtime(true) . implode('.', $nArr)) . '.' . array_pop($nArr);
}
return rtrim($path, '\\/') . '/' . $file;
} | php | {
"resource": ""
} |
q30767 | UploadedFile.getErrorMessage | train | public function getErrorMessage()
{
switch ($this->raw['error']) {
case UPLOAD_ERR_OK:
return null;
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
case UPLOAD_ERR_FORM_SIZE:
... | php | {
"resource": ""
} |
q30768 | InDepthArgumentsResolver.matchType | train | private static function matchType(\ReflectionParameter $parameter, $value) : bool
{
if ($class = $parameter->getClass()) {
return \is_object($value) && $class->isInstance($value);
}
if ($parameter->isArray()) {
return \is_array($value);
}
if ($parame... | php | {
"resource": ""
} |
q30769 | InDepthArgumentsResolver.compareParameters | train | private static function compareParameters(\ReflectionParameter $a, \ReflectionParameter $b) : int
{
if (0 !== $result = self::compareParameterClasses($a, $b)) {
return $result;
}
if ($a->isArray() ^ $b->isArray()) {
return $b->isArray() << 1 - 1;
}
i... | php | {
"resource": ""
} |
q30770 | InDepthArgumentsResolver.compareParameterClasses | train | private static function compareParameterClasses(\ReflectionParameter $a, \ReflectionParameter $b) : int
{
$a = $a->getClass();
$b = $b->getClass();
if ($a && $b) {
return $a->isSubclassOf($b->name) ? -1 : (int) $b->isSubclassOf($a->name);
}
return (int) !$a - (i... | php | {
"resource": ""
} |
q30771 | eZPageZone.toXML | train | public function toXML( DOMDocument $dom )
{
$zoneNode = $dom->createElement( 'zone' );
foreach ( $this->attributes as $attrName => $attrValue )
{
switch ( $attrName )
{
case 'id':
$zoneNode->setAttribute( 'id', 'id_' . $attrValue );... | php | {
"resource": ""
} |
q30772 | eZPageZone.createFromXML | train | public static function createFromXML( DOMElement $node )
{
$newObj = new eZPageZone();
if ( $node->hasAttributes() )
{
foreach ( $node->attributes as $attr )
{
if ( $attr->name == 'id' )
{
$value = explode( '_', $at... | php | {
"resource": ""
} |
q30773 | eZPageZone.sortBlocks | train | public function sortBlocks( array $sortArray )
{
$sortedBlocks = array();
foreach( $sortArray as $sortItem )
{
$blocksToBeRemoved = array();
foreach( $this->attributes['blocks'] as $block )
{
if ( $block->attribute('id') === $... | php | {
"resource": ""
} |
q30774 | eZPageZone.moveBlockUp | train | public function moveBlockUp( $currentIndex )
{
$array =& $this->attributes['blocks'];
$newIndex = $currentIndex - 1;
if ( $newIndex < 0 || $newIndex >= count( $array ) )
return false;
$tmpItem = $array[$newIndex];
$array[$newIndex] =& $array[$currentIndex];
... | php | {
"resource": ""
} |
q30775 | eZPageZone.removeProcessed | train | public function removeProcessed()
{
if ( $this->hasAttribute( 'action' ) )
{
unset( $this->attributes['action'] );
}
if ( $this->getBlockCount() > 0 )
{
foreach ( $this->attributes['blocks'] as $index => $block )
{
if ( $bl... | php | {
"resource": ""
} |
q30776 | EntityRead.exeRead | train | protected static function exeRead(string $entity, $data = null)
{
if (!is_array($data) && !is_numeric($data))
return null;
if (is_array($data)) {
$read = new TableCrud($entity);
$read->loadArray($data);
if ($read->exist())
$data = (int... | php | {
"resource": ""
} |
q30777 | DrupalBootstrap._beforeSuite | train | public function _beforeSuite($settings = []) {
if ($this->config['check_logs'] && \Drupal::moduleHandler()->moduleExists('dblog')) {
// Clear log entries from the database log.
\Drupal::database()->truncate('watchdog')->execute();
}
} | php | {
"resource": ""
} |
q30778 | DrupalBootstrap._afterSuite | train | public function _afterSuite() {
if (isset($this->users)) {
$users = User::loadMultiple($this->users);
/** @var \Drupal\user\Entity\User $user */
foreach ($users as $user) {
$user->delete();
}
}
if ($this->config['check_logs']) {
if (\Drupal::moduleHandler()->moduleExi... | php | {
"resource": ""
} |
q30779 | DrupalBootstrap.getConfig | train | public function getConfig($key) {
if (isset($this->config[$key])) {
return $this->config[$key];
}
return FALSE;
} | php | {
"resource": ""
} |
q30780 | DrupalBootstrap.createUserWithRoles | train | public function createUserWithRoles(array $roles = ['authenticated'], $password = FALSE) {
$faker = Faker::create();
/** @var \Drupal\user\Entity\User $user */
$user = User::create([
'name' => $faker->userName,
'mail' => $faker->email,
'roles' => $roles,
'pass' => $password ? $passwo... | php | {
"resource": ""
} |
q30781 | DrupalBootstrap.deleteUser | train | public function deleteUser($username) {
$users = \Drupal::entityQuery('user')
->condition("name", $username)
->execute();
/** @var \Drupal\user\Entity\User $users */
$users = User::loadMultiple($users);
foreach ($users as $user) {
$user->delete();
}
} | php | {
"resource": ""
} |
q30782 | SublimeSearch.getColumn | train | public function getColumn($columnKey)
{
$columns = $this->searchable();
if (array_key_exists($columnKey, $columns)) {
return $columns[$columnKey];
}
foreach ($columns as $column) {
if ($column === $columnKey || ends_with($column, ".{$columnKey}")) {
... | php | {
"resource": ""
} |
q30783 | SublimeSearch.search | train | public function search($searchStr)
{
$conditions = [];
$parsedStr = $this->parseSearchStr($searchStr);
foreach ($this->searchable() as $column) {
$conditions[] = $column.' like "'.$parsedStr.'"';
}
$method = $this->searchOperator.'Raw';
$query = $this-... | php | {
"resource": ""
} |
q30784 | SublimeSearch.applySort | train | protected function applySort($query, $searchStr)
{
if (empty($searchStr) || count($sortColumns = $this->sortColumns()) == 0) {
return $query;
}
$sortColumns = array_map(function ($column) {
return DB::raw("IFNULL(({$column}), '')");
}, $sortColumns);
... | php | {
"resource": ""
} |
q30785 | Request.redirect | train | public function redirect ($to)
{
if (is_array($to)) {
$to = join('/', $to);
}
$uri = $this->base_uri;
if ('http://' != substr($to, 0, 7) &&
'https://' != substr($to, 0, 8)) {
if ($to[0] != '/' && $uri[strlen($uri) - 1] != '/') {
$to = '/' . $to;
}
$to = join('', [$this->base_uri, $to]);
... | php | {
"resource": ""
} |
q30786 | VerifySignature.handle | train | public function handle(Request $request, Closure $next, $requestKey = 'default')
{
if (!array_key_exists($requestKey, $this->configurations->get('signed-requests'))) {
throw new InvalidConfigurationException();
}
$signed = new Verifier($request);
$key = sprintf(
... | php | {
"resource": ""
} |
q30787 | MysqlExtra.getExtrasDDLWithDelimiter | train | public function getExtrasDDLWithDelimiter()
{
$ddls = $this->getExtrasDDL();
$start = "DELIMITER {$this->delimiter}";
$end = 'DELIMITER ;';
$newDdls = [];
foreach ($ddls as $idx => $ddl) {
$newDdls[] = $start;
if (!preg_match('/;$/', $ddl)) {
... | php | {
"resource": ""
} |
q30788 | QueuedBulkDeleteJob.getTitle | train | public function getTitle()
{
$title = ($this->Title) ? $this->Title : sprintf('Delete %s %s', count($this->ids), $this->dataClass);
if ($this->User) {
return $title .= sprintf(' (Initiated by %s)', $this->User->getTitle());
}
return $title;
} | php | {
"resource": ""
} |
q30789 | QueuedBulkDeleteJob.process | train | public function process()
{
$remainingChildren = $this->remainingChildren;
// if there's no more, we're done!
if (!count($remainingChildren)) {
$this->isComplete = true;
$this->handleCompletion();
return;
}
$class = $this->dataClass;
... | php | {
"resource": ""
} |
q30790 | QueuedBulkDeleteJob.handleCompletion | train | public function handleCompletion()
{
$member = $this->User;
if ($member && $member->exists()) {
$email = new Email();
$email->setTo($member->Email);
$email->setSubject('A deletion task requested by you has completed.');
$message = sprintf('<p>Hi, %s<... | php | {
"resource": ""
} |
q30791 | Entry.checkBonusEntry | train | public function checkBonusEntry($game, $user)
{
$query = $this->em->createQuery(
'SELECT COUNT(e.id) FROM PlaygroundGame\Entity\Entry e
WHERE e.user = :user AND e.game = :game AND (e.bonus = 0 OR e.bonus IS NULL)'
);
$query->setParameter('user', $user);
$que... | php | {
"resource": ""
} |
q30792 | BreadcrumbsHelper.add | train | public function add($title, $url = null, array $options = [])
{
$options = optionsParser($options)->append('class', 'breadcrumb-item');
return parent::add($title, $url, $options->toArray());
} | php | {
"resource": ""
} |
q30793 | BreadcrumbsHelper.render | train | public function render(array $attributes = [], array $separator = [])
{
if (empty($this->crumbs)) {
return parent::render($attributes, $separator);
}
//Removes the url for the last crumb
end($this->crumbs);
$last = key($this->crumbs);
$this->crumbs[$last]... | php | {
"resource": ""
} |
q30794 | Markdown.doHardBreaks | train | protected function doHardBreaks($text) {
if ($this->single_linebreak == true) {
$expression = '/ {2,}\n|\n{1}/';
} else {
$expression = '/ {2,}\n/';
}
return preg_replace_callback($expression,
array(&$this, '_doHardBreaks_callback'), $text);
} | php | {
"resource": ""
} |
q30795 | Service.initializeObject | train | public function initializeObject()
{
if ($this->browserRequestEngine instanceof DependencyProxy) {
$this->browserRequestEngine->_activateDependency();
}
$this->browser->setRequestEngine($this->browserRequestEngine);
} | php | {
"resource": ""
} |
q30796 | Service.isCommentSpam | train | public function isCommentSpam($permaLink, $content, $type, $author = '', $authorEmailAddress = '', $authorUri = '')
{
if ($this->settings['apiKey'] === '' || $this->settings['apiKey'] === null) {
$this->systemLogger->log('Could not check comment for spam because no Akismet API key was provided i... | php | {
"resource": ""
} |
q30797 | Service.submitSpam | train | public function submitSpam($permaLink, $content, $type, $author = '', $authorEmailAddress = '', $authorUri = '')
{
if ($this->settings['apiKey'] === '') {
$this->systemLogger->log('Could not submit new spam sample to Akismet because no API key was provided in the settings.', LOG_WARNING);
... | php | {
"resource": ""
} |
q30798 | StringsExtension.left | train | public function left($text, $length)
{
if (!$this->isValidLength($text, $length)) return $text;
return \substr($text, 0, $length);
} | php | {
"resource": ""
} |
q30799 | StringsExtension.right | train | public function right($text, $length)
{
if (!$this->isValidLength($text, $length)) return $text;
$textLength = strlen($text);
return \substr($text, $textLength - $length, $textLength);
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.