_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q10600
ChartIterator.getScripts
train
public function getScripts() { $retVal = ''; while ( $this->scripts->valid() ) { $retVal .= "<script type='text/javascript'>\n{$this->scripts->get()}\n</script>\n"; $this->scripts->next(); } return $retVal; }
php
{ "resource": "" }
q10601
ChartIterator.getLibraries
train
public function getLibraries() { $config = \Altamira\Config::getInstance(); $libraryToPath = array( \Altamira\JsWriter\Flot::LIBRARY => $config['js.flotlib'], \Altamira\JsWriter\JqPlot::LIBRARY => $config['js.jqplotlib'] ); $libraryKe...
php
{ "resource": "" }
q10602
ChartIterator.renderCss
train
public function renderCss() { $config = \Altamira\Config::getInstance(); foreach ( $this->libraries as $library => $junk ) { switch( $library ) { case \Altamira\JsWriter\Flot::LIBRARY: break; case \Altamira\JsWriter\JqPlot::LIB...
php
{ "resource": "" }
q10603
InstallerController.getForm
train
protected function getForm($configPath) { $form = null; $melisConfig = $this->serviceLocator->get('MelisInstallerConfig'); $formConfig = $melisConfig->getItem($configPath); if ($formConfig) { $factory = new \Zend\Form\Factory(); $formElements = $this->getServ...
php
{ "resource": "" }
q10604
InstallerController.systemConfigurationChecker
train
protected function systemConfigurationChecker() { $response = []; $data = []; $errors = []; $dataExt = []; $dataVar = []; $checkDataExt = 0; $success = 0; $translator = $this->getServiceLocator()->get('translator'); $installHelper = $this->get...
php
{ "resource": "" }
q10605
InstallerController.vHostSetupChecker
train
protected function vHostSetupChecker() { $translator = $this->getServiceLocator()->get('translator'); $success = 0; $error = []; $platform = null; $module = null; if (!empty(getenv('MELIS_PLATFORM'))) { $platform = getenv('MELIS_PLATFORM'); } e...
php
{ "resource": "" }
q10606
InstallerController.checkDirectoryRights
train
protected function checkDirectoryRights() { $translator = $this->getServiceLocator()->get('translator'); $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $configDir = $installHelper->getDir('config'); $module = $this->getModuleSvc()->getAllModules(); $su...
php
{ "resource": "" }
q10607
InstallerController.getEnvironments
train
protected function getEnvironments() { $env = []; $container = new Container('melisinstaller'); if (isset($container['environments']) && isset($container['environments']['new'])) { $env = $container['environments']['new']; } return $env; }
php
{ "resource": "" }
q10608
InstallerController.getCurrentPlatform
train
protected function getCurrentPlatform() { $env = []; $container = new Container('melisinstaller'); if (isset($container['environments']) && isset($container['environments']['default_environment'])) { $env = $container['environments']['default_environment']; } re...
php
{ "resource": "" }
q10609
InstallerController.checkSysConfigAction
train
public function checkSysConfigAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->systemConfigurationChecker(); $success = $response['success']; $errors = $response['errors']; // add status...
php
{ "resource": "" }
q10610
InstallerController.checkVhostSetupAction
train
public function checkVhostSetupAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->vHostSetupChecker(); $success = $response['success']; $errors = $response['errors']; // add status to sess...
php
{ "resource": "" }
q10611
InstallerController.checkFileSystemRightsAction
train
public function checkFileSystemRightsAction() { $success = 0; $errors = []; if ($this->getRequest()->isXmlHttpRequest()) { $response = $this->checkDirectoryRights(); $success = $response['success']; $errors = $response['errors']; // add statu...
php
{ "resource": "" }
q10612
InstallerController.rollBackAction
train
public function rollBackAction() { $success = 0; $errors = []; $installHelper = $this->getServiceLocator()->get('InstallerHelper'); $container = new Container('melisinstaller'); if (!empty($container->getArrayCopy()) && in_array(array_keys($container['steps']), [$this->step...
php
{ "resource": "" }
q10613
InstallerController.hasMelisCmsModule
train
protected function hasMelisCmsModule() { $modulesSvc = $this->getServiceLocator()->get('MelisAssetManagerModulesService'); $modules = $modulesSvc->getAllModules(); $path = $modulesSvc->getModulePath('MelisCms'); $isExists = 0; if (file_exists($path)) { $isExists ...
php
{ "resource": "" }
q10614
TextListField.build
train
public function build(ConfigInterface $config, $width, ManialinkInterface $manialink, ManialinkFactory $manialinkFactory): Renderable { $input = $this ->uiFactory ->createInput($config->getPath(), '') ->setWidth($width * 0.66); $addButton = $this->uiFactory ...
php
{ "resource": "" }
q10615
TextListField.getElementLine
train
protected function getElementLine($config, $manialink, $element, $width, $manialinkFactory) { $label = $this->uiFactory ->createLabel($this->getElementName($element)) ->setX(2) ->setWidth($width * 0.66); $delButton = $this->uiFactory ->createButton('Re...
php
{ "resource": "" }
q10616
ActionButtons.renderActions
train
private function renderActions() { $this->beginButtonGroup(); foreach ($this->visibleActions as $action) { $label = ArrayHelper::getValue($action, $this->actionLabelProperty, ''); $url = ArrayHelper::getValue($action, $this->actionUrlProperty, null); $options = Ar...
php
{ "resource": "" }
q10617
ActionButtons.renderActionButton
train
private function renderActionButton() { $actionButtonOptions = $this->actionButtonOptions; Html::addCssClass($actionButtonOptions, $this->linkClasses); $this->beginButtonGroup(); echo Html::button($this->actionsButtonLabel . $this->caretHtml, $actionButtonOptions); echo Ht...
php
{ "resource": "" }
q10618
File.copy
train
public function copy(string $destination, $overwrite = false) : bool { $copied = false; if ($this->isFile()) { $exists = file_exists($destination); if (!$exists || ($exists && $overwrite)) { $copied = copy($this->realPath, $destination); } ...
php
{ "resource": "" }
q10619
File.delete
train
public function delete() : bool { $removed = null; if ($this->isDirectory()) { $removed = rmdir($this->realPath); } else { $removed = unlink($this->realPath); } return $removed; }
php
{ "resource": "" }
q10620
File.getSize
train
public function getSize() : int { $size = -1; if ($this->isFile()) { $size = filesize($this->realPath); } return $size; }
php
{ "resource": "" }
q10621
File.read
train
public function read() { $contents = false; if ($this->isFile() && $this->isReadable()) { $contents = file_get_contents($this->realPath); } return $contents; }
php
{ "resource": "" }
q10622
File.rename
train
public function rename(string $newName) : bool { $renamed = rename($this->realPath, $newName); if ($renamed) { $this->realPath = realpath($newName); } return $renamed; }
php
{ "resource": "" }
q10623
AutoLoad.autoLoad_XmlnukeFramework
train
protected function autoLoad_XmlnukeFramework($className) { foreach (AutoLoad::$_folders[AutoLoad::FRAMEWORK_XMLNUKE] as $prefix) { // PSR-0 Classes // convert namespace to full file path $class = PHPXMLNUKEDIR . $prefix . str_replace('\\', '/', $className); $class = ( file_exists("$class.php") ...
php
{ "resource": "" }
q10624
AutoLoad.autoLoad_UserProjects
train
protected function autoLoad_UserProjects($className) { $class = str_replace('\\', '/', ($className[0] == '\\' ? substr($className, 1) : $className)); foreach (AutoLoad::$_folders[AutoLoad::USER_PROJECTS] as $libName => $libDir) { $file = $libDir . '/' . $class; $file = ( file_exists("$file.php") ...
php
{ "resource": "" }
q10625
PaymentProcessor.createPayment
train
public function createPayment($gateway) { if (!GatewayInfo::isSupported($gateway)) { user_error(_t( "PaymentProcessor.INVALID_GATEWAY", "`{gateway}` is not supported.", null, array('gateway' => (string)$gateway) ), E_USE...
php
{ "resource": "" }
q10626
PaymentProcessor.createServiceFactory
train
public function createServiceFactory() { $factory = ServiceFactory::create(); $service = $factory->getService($this->payment, ServiceFactory::INTENT_PAYMENT); try { $serviceResponse = $service->initiate($this->getGatewayData()); } catch (Exception $ex) { // e...
php
{ "resource": "" }
q10627
SfdcResultHydrator.doHydrateList
train
public function doHydrateList(array $list, $parentKey = null) { $retVal = parent::doHydrateList($list, $parentKey); if('Id' === $parentKey) { if($retVal->count() > 0) { return $retVal->get(0); } return null; } r...
php
{ "resource": "" }
q10628
Collection.remove
train
public function remove($key, $remove = true) { if ($remove && $this->has($key, self::HAS_EXISTS)) { $key = $this->normalizeKey($key); unset($this->data[$key]); } return $this; }
php
{ "resource": "" }
q10629
Collection.removeEmpty
train
public function removeEmpty($considerEmpty = ['']) { foreach ($this->all() as $key => $value) { if (!is_scalar($value) && !is_null($value)) { continue; } foreach ($considerEmpty as $empty) { if ($value === $empty) { $thi...
php
{ "resource": "" }
q10630
Collection.sort
train
public function sort($sortBy = self::SORT_BY_KEYS_ASC, $sortFlags = SORT_REGULAR) { /** @noinspection SpellCheckingInspection */ $sortFunctions = [ self::SORT_BY_KEYS_ASC => 'ksort', self::SORT_BY_KEYS_DESC => 'krsort', self::SORT_BY_VALUES_ASC => 'asort', ...
php
{ "resource": "" }
q10631
XSLTheme.generateList
train
private function generateList($caption, $paragraph, $filelist, $xslUsed, $xsl) { $paragraph->addXmlnukeObject(new XmlnukeText($caption,true)); $listCollection = new XmlListCollection(XmlListType::UnorderedList ); $paragraph->addXmlnukeObject($listCollection); foreach($filelist as $file) { $xslnam...
php
{ "resource": "" }
q10632
PathTranslator.translate
train
function translate($path) { if(static::isWindowsOS()) { if(preg_match('%^([A-Z]):(.*)%', $path, $matches)) { // $path contains something like 'C:' at the start, // so it's an absolute path from the root. $drive = $matches[1]; ...
php
{ "resource": "" }
q10633
DebugExtension.definition
train
private function definition(ContainerBuilder $container, $class, $tag, array $arguments = []) { $definition = new Definition(strtr(__NAMESPACE__, ['ServiceContainer' => $class]), $arguments); return $container ->setDefinition($tag . '.' . self::id($class), $definition) ->add...
php
{ "resource": "" }
q10634
Container.invoke
train
public function invoke( $obj, string $method, array $params = [] ) { if (is_string($obj)) { //Attempt to retrieve object from //the container. $obj = $this->get($obj); } elseif (!is_object($obj)) { //Not a valid argument. ...
php
{ "resource": "" }
q10635
Container.build
train
private function build(string $name) { $instance = null; $map = $this->map[$name]; if (is_array($map)) { $params = $this->getParamsFromMap($map); $instance = new $name(...$params); } elseif ($map instanceof \Closure) { $instance = $map($this); ...
php
{ "resource": "" }
q10636
Collections.sort
train
public static function sort(ArrayList &$list, Comparator $comparator) { $array = $list->toArray(); usort($array, [$comparator, "compare"]); $list->replace($array); return $list; }
php
{ "resource": "" }
q10637
Config.getPluginPath
train
public function getPluginPath( $library ) { switch ( $library ) { case \Altamira\JsWriter\Flot::LIBRARY: return $this['js.flotpluginpath']; case \Altamira\JsWriter\JqPlot::LIBRARY: return $this['js.jqplotpluginpath']; } }
php
{ "resource": "" }
q10638
Dispatcher.reset
train
public function reset(Map $map) { $this->pluginManager->reset($map); $this->dataProviderManager->reset($this->pluginManager, $map); }
php
{ "resource": "" }
q10639
EventSynchronizer.prepareEntriesToDeliver
train
private function prepareEntriesToDeliver(array $entries) { $binaryAttributes = ['objectguid', 'objectsid']; foreach ($entries as $key => &$entry) { foreach ($binaryAttributes as $binaryAttribute) { if (array_key_exists($binaryAttribute, $entry)) { if ...
php
{ "resource": "" }
q10640
Consumer.consume
train
public function consume($url, Provider $provider = null, $format = self::FORMAT_DEFAULT) { if ($this->requestParameters instanceof RequestParameters) { $cacheKey = sha1($url . json_encode($this->requestParameters->toArray())); } else { $cacheKey = sha1($url); } ...
php
{ "resource": "" }
q10641
Consumer.buildOEmbedRequestUrl
train
protected function buildOEmbedRequestUrl($resource, $endPoint, $format = self::FORMAT_DEFAULT) { $parameters = [ 'url' => $resource, 'format' => $format, 'version' => self::VERSION ]; if ($this->getRequestParameters() !== null) { $parameters =...
php
{ "resource": "" }
q10642
Consumer.findProviderForUrl
train
protected function findProviderForUrl($url) { foreach ($this->providers as $provider) { if ($provider->match($url)) { return $provider; } } return null; }
php
{ "resource": "" }
q10643
Radio._checkSelected
train
protected function _checkSelected(array $options, $selectedVal) { if (!empty($selectedVal) && !Arr::key($selectedVal, $options)) { $selectedVal = self::KEY_NO_EXITS_VAL; $options = array_merge(array(self::KEY_NO_EXITS_VAL => $this->_translate('No exits')), $options); } ...
php
{ "resource": "" }
q10644
AdapterTrait.getNewSandBox
train
public function getNewSandBox(callable $action) { $errorHandler = $this->getOption('error_reporting'); if ($errorHandler !== null && !is_callable($errorHandler)) { $errorReporting = $errorHandler; $errorHandler = function ($number, $message, $file, $line) use ($errorReporting...
php
{ "resource": "" }
q10645
AdapterTrait.getSandboxCall
train
private function getSandboxCall(&$source, $method, $path, $input, callable $getSource, array $parameters) { return $this->getNewSandBox(function () use (&$source, $method, $path, $input, $getSource, $parameters) { $adapter = $this->getAdapter(); $cacheEnabled = ( $ada...
php
{ "resource": "" }
q10646
DirectAdmin.send
train
private function send(string $method, string $command, array $options = []): array { $result = $this->client->da_request($method, self::CMD_PREFIX . $command, $options); return $result; }
php
{ "resource": "" }
q10647
Select._checkNoSelected
train
protected function _checkNoSelected(array $options, array $selected, $isMultiply = false) { if ($isMultiply === 'multiple') { return array($options, $selected); } $_selected = array_pop($selected); if (!Arr::key($_selected, $options) && !empty($selected)) { ...
php
{ "resource": "" }
q10648
Select._createGroup
train
protected function _createGroup($key, array $gOptions, array $selected, array $options) { $label = (is_int($key)) ? sprintf($this->_translate('Select group %s'), $key) : $key; $output = array( '<optgroup label="' . $this->_translate($label) . '">' ); foreach ($gOptions a...
php
{ "resource": "" }
q10649
Select._getOptions
train
protected function _getOptions(array $options, array $selected = array(), $isMultiple = false) { $output = array(); list($options, $_selected) = $this->_checkNoSelected($options, $selected, $isMultiple); foreach ($options as $key => $data) { $label = $data; $value =...
php
{ "resource": "" }
q10650
Select._option
train
protected function _option($value, $selected = false, $class = '', $label = '') { if ($selected === true) { $selected = ' selected="selected"'; } $option = '<option value="' . $value . '" class="' . $class . '"' . $selected .'>' . $this->_translate($label) . ...
php
{ "resource": "" }
q10651
FileAdapter.cache
train
public function cache($path, $input, callable $rendered, &$success = null) { $cacheFolder = $this->getCacheDirectory(); $destination = $path; if (!$this->isCacheUpToDate($destination, $input)) { if (!is_writable($cacheFolder)) { throw new RuntimeException(sprintf...
php
{ "resource": "" }
q10652
FileAdapter.displayCached
train
public function displayCached($path, $input, callable $rendered, array $variables, &$success = null) { $__pug_parameters = $variables; $__pug_path = $this->cache($path, $input, $rendered, $success); call_user_func(function () use ($__pug_path, $__pug_parameters) { extract($__pug...
php
{ "resource": "" }
q10653
FileAdapter.cacheFileIfChanged
train
public function cacheFileIfChanged($path) { $outputFile = $path; if (!$this->isCacheUpToDate($outputFile)) { $compiler = $this->getRenderer()->getCompiler(); return $this->cacheFileContents( $outputFile, $compiler->compileFile($path), ...
php
{ "resource": "" }
q10654
FileAdapter.cacheDirectory
train
public function cacheDirectory($directory) { $success = 0; $errors = 0; $errorDetails = []; $renderer = $this->getRenderer(); $events = $renderer->getCompiler()->getEventListeners(); foreach ($renderer->scanDirectory($directory) as $inputFile) { $rendere...
php
{ "resource": "" }
q10655
FileAdapter.isCacheUpToDate
train
private function isCacheUpToDate(&$path, $input = null) { if (!$input) { $compiler = $this->getRenderer()->getCompiler(); $input = $compiler->resolve($path); $path = $this->getCachePath( ($this->getOption('keep_base_name') ? basename($path) : ''). ...
php
{ "resource": "" }
q10656
XmlnukePoll.getPollConfig
train
protected function getPollConfig() { $pollfile = new AnydatasetFilenameProcessor("_poll"); $anyconfig = new AnyDataset($pollfile->FullQualifiedNameAndPath()); $it = $anyconfig->getIterator(); if ($it->hasNext()) { $sr = $it->moveNext(); $this->_isdb = $sr->getField("dbname") != "-anydata-"; $this->...
php
{ "resource": "" }
q10657
XmlnukePoll.getAnyData
train
protected function getAnyData() { $filepoll = new AnydatasetFilenameProcessor("poll_list"); $this->_anyPoll = new AnyDataset($filepoll->FullQualifiedNameAndPath()); $fileanswer = new AnydatasetFilenameProcessor("poll_" . $this->_poll . "_" . $this->_lang); $this->_anyAnswer = new AnyDataset($fileanswer->FullQu...
php
{ "resource": "" }
q10658
ToursController.steps
train
public function steps() { Configure::write('debug', 0); if (!$this->request->is('ajax') || !$this->request->is('post') || !$this->RequestHandler->prefers('json')) { throw new BadRequestException(); } $data = $this->ConfigTheme->getStepsConfigTourApp(); $this->set(compact('data')); $this->set('_serial...
php
{ "resource": "" }
q10659
FirePHPHandler.write
train
protected function write(array $record) { if (!self::$sendHeaders) { return; } // WildFire-specific headers must be sent prior to any messages if (!self::$initialized) { self::$initialized = true; self::$sendHeaders = $this->headersAccepted(); ...
php
{ "resource": "" }
q10660
GuiHandler.displayManialinks
train
protected function displayManialinks() { $size = 0; foreach ($this->getManialinksToDisplay() as $mlData) { $currentSize = $size; $size += strlen($mlData['ml']); if ($currentSize != 0 && $size > $this->charLimit) { $this->executeMultiCall(); ...
php
{ "resource": "" }
q10661
GuiHandler.executeMultiCall
train
protected function executeMultiCall() { try { $this->factory->getConnection()->executeMulticall(); } catch (\Exception $e) { $this->logger->error("Couldn't deliver all manialinks : ".$e->getMessage(), ['exception' => $e]); $this->console->writeln('$F00ERROR - Coul...
php
{ "resource": "" }
q10662
GuiHandler.getManialinksToDisplay
train
protected function getManialinksToDisplay() { foreach ($this->displayQueu as $groupName => $manialinks) { foreach ($manialinks as $factoryId => $manialink) { $logins = $manialink->getUserGroup()->getLogins(); $this->displayeds[$groupName][$factoryId] = $manialink...
php
{ "resource": "" }
q10663
Button.render
train
public function render($name = '', $content = '', array $attrs = array(), $type = 'submit') { $attrs = array_merge(array('text' => null, 'name' => $name), $attrs); $attrs = $this->_getBtnClasses($attrs); $attrs['type'] = $type; if (Arr::key('icon', $attrs)) { $content =...
php
{ "resource": "" }
q10664
Search.CreatePage
train
public function CreatePage() { $myWords = $this->WordCollection(); $this->_titlePage = $myWords->Value("TITLE", $this->_context->get("SERVER_NAME") ); $this->_abstractPage = $myWords->Value("ABSTRACT", $this->_context->get("SERVER_NAME") ); $this->_document = new XmlnukeDocument($this->_titlePage, $th...
php
{ "resource": "" }
q10665
MapListDataProvider.updateMapList
train
protected function updateMapList() { $start = 0; do { try { $maps = $this->factory->getConnection()->getMapList(self::BATCH_SIZE, $start); } catch (IndexOutOfBoundException $e) { // This is normal error when we we are trying to find all maps a...
php
{ "resource": "" }
q10666
MapListDataProvider.onMapListModified
train
public function onMapListModified($curMapIndex, $nextMapIndex, $isListModified) { if ($isListModified) { $oldMaps = $this->mapStorage->getMaps(); $this->mapStorage->resetMapData(); $this->updateMapList(); // We will dispatch even only when list is modified. ...
php
{ "resource": "" }
q10667
PopulateTimeZonesTask.rebuildTitles
train
protected function rebuildTitles() { // Update the Title field in the dataobjects. This saves the time to build the title dynamically each time. foreach (TimeZoneData::get() as $tz) { $newTitle = $tz->prepareTitle(); if ($newTitle != $tz->Title) { $tz->Title =...
php
{ "resource": "" }
q10668
PopulateTimeZonesTask.message
train
protected function message($text) { if (Controller::curr() instanceof DatabaseAdmin) { DB::alteration_message($text, 'obsolete'); } else { Debug::message($text); } }
php
{ "resource": "" }
q10669
EventsController.ssecfg
train
public function ssecfg() { Configure::write('debug', 0); if (!$this->request->is('ajax') || !$this->request->is('post') || !$this->RequestHandler->prefers('json')) { throw new BadRequestException(); } $data = $this->ConfigTheme->getSseConfig(); $this->set(compact('data')); $this->set('_serialize', 'd...
php
{ "resource": "" }
q10670
EventsController.tasks
train
public function tasks() { $this->response->disableCache(); Configure::write('debug', 0); if (!$this->request->is('ajax') || !$this->request->is('post') || !$this->RequestHandler->prefers('json')) { throw new BadRequestException(); } $data = [ 'result' => false, 'tasks' => [] ]; $delete = (boo...
php
{ "resource": "" }
q10671
EventsController.queue
train
public function queue($type = null, $retry = 3000) { $this->response->disableCache(); Configure::write('debug', 0); if (!$this->request->is('sse')) { throw new BadRequestException(); } $type = (string)$type; $result = [ 'type' => '', 'progress' => 0, 'msg' => '', 'result' => null ]; $eve...
php
{ "resource": "" }
q10672
CheckInValidator.validate
train
public function validate($ticketCode = null) { if (filter_var($ticketCode, FILTER_VALIDATE_URL)) { $asURL = explode('/', parse_url($ticketCode, PHP_URL_PATH)); $ticketCode = end($asURL); } // Check if a code is given to the validator if (!isset($ticketCode)) ...
php
{ "resource": "" }
q10673
TypedArray.offsetSet
train
public function offsetSet($index, $newval) { if ($newval instanceof $this->type) { parent::offsetSet($index, $newval); return; } if ($this->allowedTypes[$this->type]($newval)) { parent::offsetSet($index, $newval); return; } ...
php
{ "resource": "" }
q10674
ImageListCommand.buildSearchParameter
train
protected function buildSearchParameter(array $searchFilters) { $search = []; foreach ($searchFilters as $filter) { $parts = explode(' ', trim($filter), 2); if (empty($parts) || 2 !== \count($parts)) { continue; } $search[$parts[0]] = ...
php
{ "resource": "" }
q10675
ImageListCommand.buildSortParameter
train
protected function buildSortParameter(array $sorts) { $sorting = []; foreach ($sorts as $sort) { $parts = explode(' ', trim($sort), 2); if (empty($parts)) { continue; } if (1 === \count($parts)) { $sorting[$parts[0]] =...
php
{ "resource": "" }
q10676
AgentCrud.getAll
train
public final function getAll(string $query, array $queryParams = null, string $fetchClass = null): array { return $this->query($query, $queryParams, null, $fetchClass)->getData(); }
php
{ "resource": "" }
q10677
Registry.hasLogger
train
public static function hasLogger($logger) { if ($logger instanceof Logger) { $index = array_search($logger, self::$loggers, true); return false !== $index; } else { return isset(self::$loggers[$logger]); } }
php
{ "resource": "" }
q10678
Registry.removeLogger
train
public static function removeLogger($logger) { if ($logger instanceof Logger) { if (false !== ($idx = array_search($logger, self::$loggers, true))) { unset(self::$loggers[$idx]); } } else { unset(self::$loggers[$logger]); } }
php
{ "resource": "" }
q10679
Registry.getInstance
train
public static function getInstance($name) { if (!isset(self::$loggers[$name])) { throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name)); } return self::$loggers[$name]; }
php
{ "resource": "" }
q10680
AbstractPipes.unblock
train
protected function unblock() { if (!$this->blocked) { return; } foreach ($this->pipes as $pipe) { stream_set_blocking($pipe, 0); } if (is_resource($this->input)) { stream_set_blocking($this->input, 0); } $this->blocked = f...
php
{ "resource": "" }
q10681
Discoverer.getEndpointForUrl
train
public function getEndpointForUrl($url) { $cacheKey = sha1($url . $this->preferredFormat . json_encode($this->supportedFormats)); if (!isset($this->cachedEndpoints[$url])) { $this->cachedEndpoints[$url] = $this->fetchEndpointForUrl($url); if (trim($this->cachedEndpoints[$url...
php
{ "resource": "" }
q10682
Discoverer.fetchEndpointForUrl
train
protected function fetchEndpointForUrl($url) { $endPoint = null; try { $content = $this->browser->getContent($url); } catch (Exception $exception) { throw new Exception( 'Unable to fetch the page body for "' . $url . '": ' . $exception->getMessage(), ...
php
{ "resource": "" }
q10683
FlashHandler.all
train
public function all() { return array_merge($this->messages[self::DURABLE], $this->messages[self::NOW]); }
php
{ "resource": "" }
q10684
FlashHandler.load
train
protected function load() { $this->reset(); $messages = $this->cookie->get($this->cookieKey); if ($messages) { $messages = json_decode($messages, true); if (!empty($messages[self::DURABLE])) { $this->messages[self::DURABLE] = $messages[self::DURABLE...
php
{ "resource": "" }
q10685
FlashHandler.reset
train
public function reset() { $this->messages = []; foreach (self::$when as $when) { $this->messages[$when] = []; } return $this; }
php
{ "resource": "" }
q10686
FlashHandler.save
train
protected function save() { $messages = []; foreach ([self::DURABLE, self::NEXT] as $when) { if (!empty($this->messages[$when])) { $messages[$when] = $this->messages[$when]; } } if ($messages) { $messages = json_encode($messages); ...
php
{ "resource": "" }
q10687
ProcessBuilder.setTimeout
train
public function setTimeout($timeout) { if (null === $timeout) { $this->timeout = null; return $this; } $timeout = (float) $timeout; if ($timeout < 0) { throw new InvalidArgumentException('The timeout value must be a valid positive integer or flo...
php
{ "resource": "" }
q10688
Poller.setupLogging
train
public function setupLogging(LoggerInterface $logger, array $incrementalAttributesToLog = ['dn']) { if (empty($incrementalAttributesToLog)) { throw new InvalidArgumentException('List of entry attributes to be logged during incremental sync cannot be empty'); } $this->logger ...
php
{ "resource": "" }
q10689
Poller.poll
train
public function poll($forceFullSync = false) { /** @var PollTaskRepository $pollTaskRepository */ $pollTaskRepository = $this->entityManager->getRepository(PollTask::class); $lastSuccessfulPollTask = $pollTaskRepository->findLastSuccessfulForPoller($this->getName()); $rootDseDns...
php
{ "resource": "" }
q10690
Poller.createCurrentPollTask
train
protected function createCurrentPollTask($invocationId, $highestCommitedUSN, $rootDseDnsHostName, $lastSuccessfulPollTask, $isFullSync) { $currentTask = new PollTask( $this->name, $invocationId, $highestCommitedUSN, $rootDseDnsHostName, $lastSucces...
php
{ "resource": "" }
q10691
Poller.isFullSyncRequired
train
private function isFullSyncRequired($forceFullSync, PollTask $lastSuccessfulSyncTask = null, $currentRootDseDnsHostName, $currentInvocationId) { if ($forceFullSync) { return true; } if (!$lastSuccessfulSyncTask) { return true; } if ($lastSuccessfulSy...
php
{ "resource": "" }
q10692
Poller.fullSync
train
private function fullSync(PollTask $currentTask, $highestCommitedUSN) { $entries = $this->fetcher->fullFetch($highestCommitedUSN); $this->synchronizer->fullSync($this->name, $currentTask->getId(), $entries); $this->logFullSync($entries); return count($entries); }
php
{ "resource": "" }
q10693
Poller.incrementalSync
train
private function incrementalSync(PollTask $currentTask, $usnChangedStartFrom, $highestCommitedUSN) { list($changed, $deleted) = $this->fetcher->incrementalFetch($usnChangedStartFrom, $highestCommitedUSN, $this->detectDeleted); $this->synchronizer->incrementalSync($this->name, $currentTask->getId(), ...
php
{ "resource": "" }
q10694
Poller.logFullSync
train
private function logFullSync($entries) { if ($this->logger) { $this->logger->info(sprintf("Full sync processed. Entries count: %d.", count($entries))); } }
php
{ "resource": "" }
q10695
Poller.logIncrementalSync
train
private function logIncrementalSync($changed, $deleted) { if ($this->logger) { $entriesLogReducer = function ($entry) { return array_intersect_key($entry, array_flip($this->incrementalAttributesToLog)); }; $changedToLog = array_map($entriesLogReducer,...
php
{ "resource": "" }
q10696
ArrayListTrait.filter
train
public function filter(\Closure $closure) { $newInstance = new self(); $newInstance->setArray(array_filter($this->array, $closure)); return $newInstance; }
php
{ "resource": "" }
q10697
ArrayListTrait.filterByKeys
train
public function filterByKeys(array $keys) { /** @noinspection PhpMethodParametersCountMismatchInspection */ $newInstance = new self(); $newInstance->setArray(array_filter($this->array, function ($key) use ($keys) { return array_search($key, $keys) !== false; }, ARRAY_FILT...
php
{ "resource": "" }
q10698
ArrayListTrait.map
train
public function map(\closure $mapFunction) { $newInstance = new self(); $newInstance->setArray(array_map($mapFunction, $this->array)); return $newInstance; }
php
{ "resource": "" }
q10699
ArrayListTrait.flatten
train
public function flatten() { $flattenedArray = []; array_walk_recursive($this->array, function ($item) use (&$flattenedArray) { $flattenedArray[] = $item; }); $newInstance = new self(); $newInstance->setArray($flattenedArray); return $newInstance; }
php
{ "resource": "" }