_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q11200
Ticket.getAvailableFrom
train
public function getAvailableFrom() { if ($this->AvailableFromDate) { return $this->dbObject('AvailableFromDate'); } elseif ($startDate = $this->getEventStartDate()) { $lastWeek = new Date(); $lastWeek->setValue(strtotime(self::config()->get('sale_start_threshold')...
php
{ "resource": "" }
q11201
Ticket.getAvailableTill
train
public function getAvailableTill() { if ($this->AvailableTillDate) { return $this->dbObject('AvailableTillDate'); } elseif ($startDate = $this->getEventStartDate()) { $till = strtotime(self::config()->get('sale_end_threshold'), strtotime($startDate->Nice())); $dat...
php
{ "resource": "" }
q11202
Ticket.validateDate
train
public function validateDate() { if ( ($from = $this->getAvailableFrom()) && ($till = $this->getAvailableTill()) && $from->InPast() && $till->InFuture() ) { return true; } return false; }
php
{ "resource": "" }
q11203
Ticket.getAvailable
train
public function getAvailable() { if (!$this->getAvailableFrom() && !$this->getAvailableTill()) { return false; } elseif ($this->validateDate() && $this->validateAvailability()) { return true; } return false; }
php
{ "resource": "" }
q11204
Ticket.getEventStartDate
train
private function getEventStartDate() { $currentDate = $this->Event()->getController()->CurrentDate(); if ($currentDate && $currentDate->exists()) { $date = $currentDate->obj('StartDate')->Format('Y-m-d'); $time = $currentDate->obj('StartTime')->Format('H:i:s'); $d...
php
{ "resource": "" }
q11205
RecordTableMap.doDelete
train
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(RecordTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria...
php
{ "resource": "" }
q11206
Factory.createForPlayer
train
public function createForPlayer($login) { if (!isset($this->groups[$login])) { $class = $this->class; /** @var Group $group */ $group = new $class(null, $this->dispatcher); $this->groups[$login] = $group; $group->addLogin($login); } ...
php
{ "resource": "" }
q11207
Factory.createForPlayers
train
public function createForPlayers($logins) { $class = $this->class; /** @var Group $group */ $group = new $class(null, $this->dispatcher); $this->groups[$group->getName()] = $group; foreach ($logins as $login) { $group->addLogin($login); } return ...
php
{ "resource": "" }
q11208
Factory.create
train
public function create($name) { $class = $this->class; /** @var Group $group */ $group = new $class($name, $this->dispatcher); $this->groups[$group->getName()] = $group; return $group; }
php
{ "resource": "" }
q11209
Factory.getGroup
train
public function getGroup($groupName) { return isset($this->groups[$groupName]) ? $this->groups[$groupName] : null; }
php
{ "resource": "" }
q11210
Factory.onExpansionGroupDestroy
train
public function onExpansionGroupDestroy(Group $group, $lastLogin) { if (isset($this->groups[$group->getName()])) { unset($this->groups[$group->getName()]); } }
php
{ "resource": "" }
q11211
HttpClientUtil.buildHttpClient
train
public static function buildHttpClient( $url = NULL, $username = NULL, $password = NULL, $contentType = self::CONTENT_JSON_API, $language = self::HEADER_LOCALE ) { $client = new Client($url); $client->setHead([ 'Accept: ' . $contentType, ...
php
{ "resource": "" }
q11212
Mapper.normalizeType
train
public static function normalizeType(string $type): string { switch ($type) { case self::DATA_TYPE_INT: case self::DATA_TYPE_BIGINT: case self::DATA_TYPE_TINYINT: case self::DATA_TYPE_SMALLINT: case self::DATA_TYPE_MEDIUMINT: case self:...
php
{ "resource": "" }
q11213
Game.addFromCsv
train
public function addFromCsv() { $files = array_diff(scandir($this->directory . '/in', SCANDIR_SORT_NONE), ['..', '.']); foreach ($files as $file) { if (0 !== strpos($file, 'game-add')) { continue; } $fileIn = $this->directory . '/in/' . $file; ...
php
{ "resource": "" }
q11214
Game.updateFromCsv
train
public function updateFromCsv() { $files = array_diff(scandir($this->directory . '/in', SCANDIR_SORT_NONE), ['..', '.']); foreach ($files as $file) { if (0 !== strpos($file, 'game-update')) { continue; } $fileIn = $this->directory . '/in/' . $fil...
php
{ "resource": "" }
q11215
Due.setEnvName
train
public static function setEnvName($arg_env_name) { if($arg_env_name == 'stage'){ self::$envName = 'stage'; self::$domain = self::$domainStage; }elseif($arg_env_name == 'prod'){ self::$envName = 'prod'; self::$domain = self::$domainProd; }else{ ...
php
{ "resource": "" }
q11216
Debugger.debug
train
public static function debug(array $strings, array $placeholders = []) { // Initialize messages storage. if (!isset($_SESSION[__TRAIT__])) { $_SESSION[__TRAIT__] = []; } // Mark debug message. array_unshift($strings, '<question>DEBUG:</question>'); $_SES...
php
{ "resource": "" }
q11217
Debugger.printMessages
train
public static function printMessages($clearQueue = true) { if (!empty($_SESSION[__TRAIT__])) { /** @var Message $message */ foreach ($_SESSION[__TRAIT__] as $message) { $message->output(); } } if ($clearQueue) { static::clearQu...
php
{ "resource": "" }
q11218
Mime.getTypeForExtension
train
public static function getTypeForExtension($extension) { static::ensureDataLoaded(); $extension = strtolower($extension); foreach (static::$mime_types as $mime_type => $extensions) { if (is_array($extensions)) { if (in_array($extension, $extensions, true)) { return $mime_type; } } else if ($ex...
php
{ "resource": "" }
q11219
Mime.getExtensionForType
train
public static function getExtensionForType($mime_type) { static::ensureDataLoaded(); if (!static::hasType($mime_type)) { return; } $extensions = static::$mime_types[$mime_type]; if (is_array($extensions)) { return $extensions[0]; } return $extensions; }
php
{ "resource": "" }
q11220
Mime.hasExtension
train
public static function hasExtension($extension) { static::ensureDataLoaded(); $extension = strtolower($extension); foreach (static::$mime_types as $extensions) { if (is_array($extensions)) { if (in_array($extension, $extensions, true)) { return true; } } else if ($extension === $extensions) { ...
php
{ "resource": "" }
q11221
Mime.guessType
train
public static function guessType($file_path, $reference_name = null, $default = 'application/octet-stream') { if (!$reference_name) { $reference_name = basename($file_path); } $extension = pathinfo($reference_name, PATHINFO_EXTENSION); if ($extension and $mime_type = static::getTypeForExtension($extension))...
php
{ "resource": "" }
q11222
Mime.guessExtension
train
public static function guessExtension($file_path, $reference_name = null, $default = 'bin') { if (!$reference_name) { $reference_name = basename($file_path); } if ($extension = pathinfo($reference_name, PATHINFO_EXTENSION) and static::hasExtension($extension)) { return strtolower($extension); } $mime_...
php
{ "resource": "" }
q11223
Mime.getMagicType
train
public static function getMagicType($file_path) { $file_info = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($file_info, $file_path); finfo_close($file_info); // Only return valid types, in order to maintain circular compatibility between methods. if (static::hasType($mime_type)) { return $mime_...
php
{ "resource": "" }
q11224
ScriptAdapter.parseParameters
train
protected function parseParameters($parameters) { if (isset($parameters[0])) { $params = json_decode($parameters[0], true); if ($params) { return $params; } } // If json couldn't be encoded return string as it was return $parameter...
php
{ "resource": "" }
q11225
UuidValueHolder.isDefault
train
public function isDefault() { if ($this->getAttribute()->hasOption(UuidAttribute::OPTION_DEFAULT_VALUE) && $this->getAttribute()->getOption(UuidAttribute::OPTION_DEFAULT_VALUE) !== 'auto_gen' ) { return $this->sameValueAs($this->getAttribute()->getDefaultValue()); } ...
php
{ "resource": "" }
q11226
TempDirectory.rmdir
train
private function rmdir($dir, $recursive) { $is_link = is_link($dir); if($is_link) { if(! unlink($dir)) throw new Exception("Error unlinking $dir"); } else if(! $recursive) { if(! rmdir($dir)) throw new Exception("Error removing temp dir: $dir"); } else { $dh = opendir($dir); if(! ...
php
{ "resource": "" }
q11227
HandleException.Setup
train
public function Setup($xmlModuleName, $customArgs) { parent::Setup($xmlModuleName, $customArgs); $this->_ErrorMessage = $customArgs; }
php
{ "resource": "" }
q11228
ManiaExchange.addMapToQueue
train
public function addMapToQueue($login, $id, $mxsite) { if (!$this->adminGroups->hasPermission($login, "maps.add")) { $this->chatNotification->sendMessage('expansion_mx.chat.nopermission', $login); return; } if ($this->downloadProgressing || count($this->addQueue) > ...
php
{ "resource": "" }
q11229
ConfigUiManager.getUiHandler
train
public function getUiHandler(ConfigInterface $config) { if ($config->isHidden()) { return null; } foreach ($this->uiHandlers as $ui) { if ($ui->isCompatible($config)) { return $ui; } } return null; }
php
{ "resource": "" }
q11230
WkPdfBuilder.render
train
public function render() { $process = $this->getProcess(); $process->run(); if (0 === $process->getExitCode()) { return file_get_contents($this->getOutput()); } throw new \RuntimeException( sprintf('Unable to render PDF. Command "%s" exited with "%s" ...
php
{ "resource": "" }
q11231
WkPdfBuilder.getProcess
train
public function getProcess() { $this->processBuilder->setArguments(array()); foreach ($this->options as $option => $value) { if (!$value) { continue; } if (!in_array($option, static::$nonPrefixedOptions)) { $option = sprintf('--%s...
php
{ "resource": "" }
q11232
XmlnukeDocument.addJavaScriptMethod
train
public function addJavaScriptMethod($jsObject, $jsMethod, $jsSource, $jsParameters = "") { $jsEventSource = "$(function() { \n" . " $('$jsObject').$jsMethod(function($jsParameters) { \n" . " $jsSource \n" . " }); \n" . "});\n\n"; $this->addJavaScriptSource($jsEventSource, false); }
php
{ "resource": "" }
q11233
XmlnukeDocument.addJavaScriptAttribute
train
public function addJavaScriptAttribute($jsObject, $jsAttrName, $attrParam) { if (!is_array($attrParam)) { $attrParam = array($attrParam); } $jsEventSource = "$(function() { \n" . " $('$jsObject').$jsAttrName({ \n"; $first = true; foreach ($attrParam as $key=>$value) { $jsEventSource...
php
{ "resource": "" }
q11234
XmlnukeDocument.CompactJs
train
protected function CompactJs( $sText ) { $sBuffer = ""; $i = 0; $iStop = strlen($sText); // Compact and Copy PHP Source Code. $sChar = ''; $sLast = ''; $sWanted = ''; $fEscape = false; for( $i = $i; $i < $iStop; $i++ ) { $sLast = $sChar; $sChar = su...
php
{ "resource": "" }
q11235
OperationListCommand.getPropertySettings
train
private function getPropertySettings($property) { $data = []; $settings = [ 'minimum' => 'min', 'maximum' => 'max', ]; foreach ($settings as $setting => $name) { if (isset($property[$setting])) { $data[] = $name.':'.$property[$setti...
php
{ "resource": "" }
q11236
PlayerTableMap.doDelete
train
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(PlayerTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria...
php
{ "resource": "" }
q11237
MigrateAttendeeFieldsTask.publishEvents
train
private function publishEvents() { /** @var CalendarEvent|TicketExtension $event */ foreach (CalendarEvent::get() as $event) { if ($event->Tickets()->exists()) { if ($event->doPublish()) { echo "[$event->ID] Published event \n"; $this->...
php
{ "resource": "" }
q11238
MigrateAttendeeFieldsTask.moveFieldData
train
private function moveFieldData(CalendarEvent $event) { if ($event->Attendees()->exists()) { /** @var Attendee $attendee */ foreach ($event->Attendees() as $attendee) { /** @var UserField $field */ foreach ($event->Fields() as $field) { ...
php
{ "resource": "" }
q11239
VisitorContainer.visitBefore
train
public function visitBefore(Node $node): void { parent::visitBefore($node); foreach ($this->visitors as $visitor) { $visitor->visitBefore($node); } }
php
{ "resource": "" }
q11240
VisitorContainer.visitAfter
train
public function visitAfter(Node $node): void { foreach ($this->visitors as $visitor) { $visitor->visitAfter($node); } parent::visitAfter($node); }
php
{ "resource": "" }
q11241
BenGorUserBundle.buildLoadableBundles
train
protected function buildLoadableBundles(ContainerBuilder $container) { $bundles = $container->getParameter('kernel.bundles'); foreach ($bundles as $bundle) { $reflectionClass = new \ReflectionClass($bundle); if ($reflectionClass->implementsInterface(LoadableBundle::class)) { ...
php
{ "resource": "" }
q11242
EloquentFiscalYear.byYearAndByOrganization
train
public function byYearAndByOrganization($year, $organiztionId) { return $this->FiscalYear->where('year', '=', $year)->where('organization_id', '=', $organiztionId)->get()->first(); }
php
{ "resource": "" }
q11243
EloquentFiscalYear.update
train
public function update(array $data, $FiscalYear = null) { if(empty($FiscalYear)) { $FiscalYear = $this->byId($data['id']); } foreach ($data as $key => $value) { $FiscalYear->$key = $value; } return $FiscalYear->save(); }
php
{ "resource": "" }
q11244
FileDiffer.isDiff
train
public function isDiff($first, $second) { if(! file_exists($first)) throw new NoSuchFileException($first); $second = $this->oFileNameResolver->resolve($first, $second); // If the second file doesn't exist, they're definitely different if(! file_exists($second)) return true; // If the file sizes are ...
php
{ "resource": "" }
q11245
MoveComponent.moveItem
train
public function moveItem($direct = null, $id = null, $delta = 1) { $isJson = $this->_controller->RequestHandler->prefers('json'); if ($isJson) { Configure::write('debug', 0); } $result = $this->_model->moveItem($direct, $id, $delta); if (!$isJson) { if (!$result) { $this->_controller->Flash->error(_...
php
{ "resource": "" }
q11246
MoveComponent.dropItem
train
public function dropItem() { Configure::write('debug', 0); if (!$this->_controller->request->is('ajax') || !$this->_controller->request->is('post') || !$this->_controller->RequestHandler->prefers('json')) { throw new BadRequestException(); } $id = $this->_controller->request->data('target'); $newParent...
php
{ "resource": "" }
q11247
RokkaApiHelper.organizationExists
train
public function organizationExists(User $client, $organizationName) { try { $org = $client->getOrganization($organizationName); return $org->getName() == $organizationName; } catch (ClientException $e) { if (404 === $e->getCode()) { return false; ...
php
{ "resource": "" }
q11248
RokkaApiHelper.stackExists
train
public function stackExists(Image $client, $stackName, $organizationName = '') { try { $stack = $client->getStack($stackName, $organizationName); return $stack->getName() == $stackName; } catch (ClientException $e) { if (404 === $e->getCode()) { r...
php
{ "resource": "" }
q11249
RokkaApiHelper.imageExists
train
public function imageExists(Image $client, $hash, $organizationName = '') { try { $sourceImage = $client->getSourceImage($hash, $organizationName); return $sourceImage instanceof SourceImage && $sourceImage->hash === $hash; } catch (ClientException $e) { if (404 ...
php
{ "resource": "" }
q11250
RokkaApiHelper.getSourceImageContents
train
public function getSourceImageContents(Image $client, $hash, $organizationName, $stackName = null, $format = 'jpg') { if (!$stackName) { return $client->getSourceImageContents($hash, $organizationName); } $uri = $client->getSourceImageUri($hash, $stackName, $format, null, $organi...
php
{ "resource": "" }
q11251
ChangeUserPasswordCommandBuilder.handlerArguments
train
protected function handlerArguments($user) { return [ $this->container->getDefinition( 'bengor.user.infrastructure.persistence.' . $user . '_repository' ), $this->container->getDefinition( 'bengor.user.infrastructure.security.symfony.' . $u...
php
{ "resource": "" }
q11252
ChangeUserPasswordCommandBuilder.byRequestRememberPasswordSpecification
train
private function byRequestRememberPasswordSpecification($user) { (new RequestRememberPasswordCommandBuilder($this->container, $this->persistence))->build($user); return [ 'command' => ByRequestRememberPasswordChangeUserPasswordCommand::class, 'handler' => ByRequestRememberPa...
php
{ "resource": "" }
q11253
HandlerTypeAdapter.syncData
train
public function syncData($controller_data) { if (is_object($controller_data)) { $handler_data = $this->legacy_handler->getData(); $refl_class = new \ReflectionClass(get_class($handler_data)); $filter = \ReflectionProperty::IS_PUBLIC | \ReflectionPrope...
php
{ "resource": "" }
q11254
AbstractConnection.getProcessCallback
train
protected function getProcessCallback() { return function ($state, $response) { list($command, $callback) = $this->commands->dequeue(); switch ($command->getId()) { case 'SUBSCRIBE': case 'PSUBSCRIBE': $wrapper = $this->getStreamin...
php
{ "resource": "" }
q11255
AbstractConnection.getStreamingWrapperCreator
train
protected function getStreamingWrapperCreator() { return function ($connection, $callback) { return function ($state, $response) use ($connection, $callback) { \call_user_func($callback, $response, $connection, null); }; }; }
php
{ "resource": "" }
q11256
AbstractConnection.createResource
train
protected function createResource(callable $callback) { $parameters = $this->parameters; $flags = STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT; if ($parameters->scheme === 'unix') { $uri = "unix://$parameters->path"; } else { $uri = "$parameters->schem...
php
{ "resource": "" }
q11257
ChatNotification.sendMessage
train
public function sendMessage($messageId, $to = null, $parameters = []) { $message = $messageId; if (is_string($to)) { $player = $this->playerStorage->getPlayerInfo($to); $message = $this->translations->getTranslation($messageId, $parameters, strtolower($player->getLanguage())...
php
{ "resource": "" }
q11258
MimeTypeFileInfoGuesser.guess
train
public static function guess(string $filename): ?string { if (! \is_file($filename)) { throw new FileNotFoundException($filename); } if (! \is_readable($filename)) { throw new AccessDeniedException($filename); } if (self::$magicFile !== null) { ...
php
{ "resource": "" }
q11259
CookieHandler.remove
train
public function remove($name) { $name = $this->getFullName($name); // Delete existing response cookie if (isset($this->responseCookies[$name])) { unset($this->responseCookies[$name]); } // Set response cookie if request cookie was set if (null !== $this-...
php
{ "resource": "" }
q11260
ArrayFilter.checkValue
train
protected function checkValue($value, $condition) { list($filterType, $valueToCheck) = $condition; switch ($filterType) { case self::FILTER_TYPE_EQ: return $valueToCheck == $value; case self::FILTER_TYPE_NEQ: return $valueToCheck != $value; ...
php
{ "resource": "" }
q11261
Countries.getCodeFromCountry
train
public function getCodeFromCountry($country) { $output = 'OTH'; if (array_key_exists($country, $this->countriesMapping)) { $output = $this->countriesMapping[$country]; } return $output; }
php
{ "resource": "" }
q11262
Countries.getCountryFromCode
train
public function getCountryFromCode($code) { $code = strtoupper($code); $output = "Other"; if (in_array($code, $this->countriesMapping)) { foreach ($this->countriesMapping as $country => $short) { if ($code == $short) { $output = $country; ...
php
{ "resource": "" }
q11263
Countries.getIsoAlpha2FromName
train
public function getIsoAlpha2FromName($name) { // First try and fetch from alpha3 code. try { return $this->iso->alpha3($this->getCodeFromCountry($name))['alpha2']; } catch (OutOfBoundsException $e) { // Nothing code continues. } // Couldn't getch alph...
php
{ "resource": "" }
q11264
AbstractDataProvider.dispatch
train
protected function dispatch($method, $params) { foreach ($this->plugins as $plugin) { $plugin->$method(...$params); } }
php
{ "resource": "" }
q11265
EloquentCostCenter.byOrganizationAndByKey
train
public function byOrganizationAndByKey($organizationId, $key) { return $this->CostCenter->where('organization_id', '=', $organizationId)->where('key', '=', $key)->get(); }
php
{ "resource": "" }
q11266
ReferenceRule.execute
train
protected function execute($value, EntityInterface $entity = null) { $success = true; $collection = null; if ($value instanceof EntityList) { $collection = $value; } elseif (null === $value) { $collection = new EntityList(); } elseif (is_array($value)...
php
{ "resource": "" }
q11267
Localization.addMap
train
public function addMap($locale, $map) { // Get sanitized locale $locale = Locale::sanitizeLocale($locale); $this->maps[$locale] = $map; return $this; }
php
{ "resource": "" }
q11268
Localization.addMaps
train
public function addMaps(array $maps) { foreach ($maps as $locale => $map) { $this->addMap($locale, $map); } return $this; }
php
{ "resource": "" }
q11269
Localization.findAvailableLocales
train
public function findAvailableLocales() { // Check for needed data $path = $this->getPath(); $domain = $this->getDomain(); if (!$path || !$domain) { throw new Exception("Values for 'path' and 'domain' must be set."); } // Build regular expressions for fi...
php
{ "resource": "" }
q11270
Localization.getDomain
train
public function getDomain($realDomain = false) { if ($realDomain) { return $this->getMap($this->getActive(), 'domain') ?: $this->domain; } return $this->domain; }
php
{ "resource": "" }
q11271
Localization.getMap
train
public function getMap($locale, $key = null) { // Get sanitized locale $locale = Locale::sanitizeLocale($locale); if ($key) { return isset($this->maps[$locale][$key]) ? $this->maps[$locale][$key] : null; } return isset($this->maps[$locale]) ? $this->maps[$locale...
php
{ "resource": "" }
q11272
PlayerChartRepository.getRankingForUpdate
train
public function getRankingForUpdate(Chart $chart) { $queryBuilder = $this->createQueryBuilder('pc'); $queryBuilder ->innerJoin('pc.player', 'p') ->addSelect('p') ->innerJoin('pc.status', 'status') ->addSelect('status') ->where('pc.chart = :...
php
{ "resource": "" }
q11273
PlayerChartRepository.getRanking
train
public function getRanking(Chart $chart, $player = null, $limit = null) { $queryBuilder = $this->getRankingBaseQuery($chart); $queryBuilder ->andWhere('status.boolRanking = 1'); if (null !== $limit && null !== $player) { $queryBuilder ->andWhere( ...
php
{ "resource": "" }
q11274
PlayerChartRepository.getDisableRanking
train
public function getDisableRanking(Chart $chart) { $queryBuilder = $this->getRankingBaseQuery($chart); $queryBuilder ->andWhere('status.boolRanking = 0'); return $queryBuilder->getQuery()->getResult(); }
php
{ "resource": "" }
q11275
OrderListingItem.dueLabel
train
static function dueLabel($date) { $days = \FlexiPeeHP\FakturaVydana::overdueDays($date); if ($days < 0) { $type = 'success'; $msg = sprintf(_(' %s days to due'), new \Ease\TWB\Badge(abs($days))); } else { $msg = sprintf(_(' %s days after d...
php
{ "resource": "" }
q11276
ActionScriptHelper._createFileVersion
train
protected function _createFileVersion($timestamp = null) { if (!is_int($timestamp)) { $timestamp = time(); } $result = dechex($timestamp); return $result; }
php
{ "resource": "" }
q11277
ActionScriptHelper._prepareFilePath
train
protected function _prepareFilePath($path = null) { if (empty($path)) { return false; } if (DIRECTORY_SEPARATOR !== '\\') { return $path; } $path = str_replace('\\', '/', $path); return $path; }
php
{ "resource": "" }
q11278
ActionScriptHelper._getIncludeFilePath
train
protected function _getIncludeFilePath($specificFullPath = null, $specificPath = null, $specificFileName = null) { if (empty($specificFullPath) || empty($specificPath) || empty($specificFileName)) { return false; } $oFile = new File($specificFullPath . $specificFileName); if (!$oFile->exists()) { retu...
php
{ "resource": "" }
q11279
ActionScriptHelper.css
train
public function css($options = [], $params = [], $includeOnlyParam = false, $useUserRolePrefix = false) { $css = $this->getFilesForAction('css', $params, $includeOnlyParam, $useUserRolePrefix); if (empty($css)) { return null; } return $this->Html->css($css, $options); }
php
{ "resource": "" }
q11280
NewOrganizationTrigger.run
train
public function run($id, $databaseConnectionName, &$userAppsRecommendations) { $this->Setting->changeDatabaseConnection($databaseConnectionName); $this->Setting->create(array('organization_id' => $id)); array_push($userAppsRecommendations, array('appName' => $this->Lang->get('decima-accounting::menu.initialAcco...
php
{ "resource": "" }
q11281
ExtBs3FormHelper.create
train
public function create($model = null, $options = []) { $form = parent::create($model, $options); if (!isset($options['url']) || ($options['url'] !== false)) { return $form; } // Ignore options `url` => false $result = mb_ereg_replace('action=\"[^\"]*\"', '', $form); return $result; }
php
{ "resource": "" }
q11282
ExtBs3FormHelper._initLabel
train
protected function _initLabel($options) { if (isset($options['label']) && is_array($options['label'])) { $options['label'] = [ 'text' => $options['label'] ]; } return parent::_initLabel($options); }
php
{ "resource": "" }
q11283
ExtBs3FormHelper.getLabelTextFromField
train
public function getLabelTextFromField($fieldName = null) { $text = ''; if (empty($fieldName)) { return $text; } if (strpos($fieldName, '.') !== false) { $fieldElements = explode('.', $fieldName); $text = array_pop($fieldElements); } else { $text = $fieldName; } if (substr($text, -3) === '_id'...
php
{ "resource": "" }
q11284
ExtBs3FormHelper._prepareExtraOptions
train
protected function _prepareExtraOptions(array &$options, $listExtraOptions = [], $optionPrefix = 'data-') { if (empty($options) || empty($listExtraOptions)) { return; } if (!is_array($listExtraOptions)) { $listExtraOptions = [$listExtraOptions]; } $extraOptions = array_intersect_key($options, array_fli...
php
{ "resource": "" }
q11285
ExtBs3FormHelper._inputMaskAlias
train
protected function _inputMaskAlias($fieldName, $options = [], $alias = '') { if (!is_array($options)) { $options = []; } $defaultOptions = [ 'label' => false, ]; $options += $defaultOptions; $options['data-inputmask-alias'] = $alias; return $this->text($fieldName, $options); }
php
{ "resource": "" }
q11286
ExtBs3FormHelper.spin
train
public function spin($fieldName, $options = []) { if (!is_array($options)) { $options = []; } $defaultOptions = $this->_getOptionsForElem('spin.defaultOpt'); $options = $defaultOptions + $options; $listExtraOptions = $this->_getOptionsForElem('spin.extraOpt'); $this->_prepareExtraOptions($options, $listE...
php
{ "resource": "" }
q11287
ExtBs3FormHelper.flag
train
public function flag($fieldName, $options = []) { if (!empty($fieldName)) { $this->setEntity($fieldName); } $this->unlockField($this->field()); if (!is_array($options)) { $options = []; } $defaultOptions = $this->_getOptionsForElem('flag.defaultOpt'); $options = $defaultOptions + $options; $divCl...
php
{ "resource": "" }
q11288
ExtBs3FormHelper.autocomplete
train
public function autocomplete($fieldName, $options = []) { if (!is_array($options)) { $options = []; } $defaultOptions = $this->_getOptionsForElem('autocomplete.defaultOpt'); $options = $defaultOptions + $options; $listExtraOptions = $this->_getOptionsForElem('autocomplete.extraOpt'); $this->_prepareExtra...
php
{ "resource": "" }
q11289
ExtBs3FormHelper.createUploadForm
train
public function createUploadForm($model = null, $options = []) { if (empty($options) || !is_array($options)) { $options = []; } $optionsDefault = $this->_getOptionsForElem('createUploadForm'); $options = $this->ViewExtension->getFormOptions($optionsDefault + $options); $result = $this->create($model, $opti...
php
{ "resource": "" }
q11290
ExtBs3FormHelper.upload
train
public function upload($url = null, $maxfilesize = 0, $acceptfiletypes = null, $redirecturl = null, $btnTitle = null, $btnClass = null) { if (empty($url)) { return null; } if (empty($btnTitle)) { $btnTitle = $this->ViewExtension->iconTag('fas fa-file-upload') . '&nbsp;' . $this->_getOptionsForElem('upload....
php
{ "resource": "" }
q11291
ExtBs3FormHelper.hiddenFields
train
public function hiddenFields($hiddenFields = null) { if (empty($hiddenFields)) { return null; } if (!is_array($hiddenFields)) { $hiddenFields = [$hiddenFields]; } $result = ''; $options = ['type' => 'hidden']; foreach ($hiddenFields as $hiddenField) { $result .= $this->input($hiddenField, $opti...
php
{ "resource": "" }
q11292
EloquentAccountType.create
train
public function create(array $data) { $AccountType = new AccountType(); $AccountType->setConnection($this->databaseConnectionName); $AccountType->fill($data)->save(); return $AccountType; }
php
{ "resource": "" }
q11293
EloquentAccountType.update
train
public function update(array $data, $AccountType = null) { if(empty($AccountType)) { $AccountType = $this->byId($data['id']); } foreach ($data as $key => $value) { $AccountType->$key = $value; } return $AccountType->save(); }
php
{ "resource": "" }
q11294
ProductShowListener.onProductShow
train
public function onProductShow(ResourceControllerEvent $event): void { $product = $event->getSubject(); if (!$product instanceof ProductInterface) { return; } $currentRequest = $this->requestStack->getCurrentRequest(); if ($currentRequest instanceof Request) { ...
php
{ "resource": "" }
q11295
Html.svgImg
train
public static function svgImg($src, $options = []) { $fallback = ArrayHelper::getValue($options, 'fallback', true); $fallbackExt = ArrayHelper::getValue($options, 'fallbackExt', 'png'); if ($fallback) { if (is_bool($fallback) && is_string($src)) { $fallback = rtr...
php
{ "resource": "" }
q11296
SocketService.run
train
public function run() { if(!$this->server) { try { // initialize socket server $this->server = new AppServer($this->config->socket->host, $this->config->socket->port); // create application with dependencies $app = new Sonar( ...
php
{ "resource": "" }
q11297
ErrorHandler.handleError
train
public static function handleError($code, $message, $file, $line) { $list = static::getSystemError($code); $name = $list[0]; $type = $list[1]; $message = "\"$message\" in $file:$line"; switch ($type) { case static::E_NOTICE: throw new NoticeError($messa...
php
{ "resource": "" }
q11298
ErrorHandler.handleShutdown
train
public static function handleShutdown($forceKill = false) { $err = error_get_last(); try { static::handleError($err['type'], $err['message'], $err['file'], $err['line']); } catch (\Error $ex) { echo call_user_func(static::$errHandler, $ex) . P...
php
{ "resource": "" }
q11299
LdapFetcher.getInvocationId
train
public function getInvocationId() { $dsServiceNode = $this->ldap->getNode($this->getRootDse()->getDsServiceName()); $invocationId = bin2hex($dsServiceNode->getAttribute('invocationId', 0)); return $invocationId; }
php
{ "resource": "" }