_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q2300
Install.checkPermission
train
protected function checkPermission(OutputInterface $output) { $output->writeln(array( "Checking some permissions" )); /** @var Translator $translator */ $translator = $this->getContainer()->get('thelia.translator'); $permissions = new CheckPermission(false, $tra...
php
{ "resource": "" }
q2301
Install.createConfigFile
train
protected function createConfigFile($connectionInfo) { $fs = new Filesystem(); $sampleConfigFile = THELIA_CONF_DIR . "database.yml.sample"; $configFile = THELIA_CONF_DIR . "database.yml"; $fs->copy($sampleConfigFile, $configFile, true); $configContent = file_get_contents($...
php
{ "resource": "" }
q2302
Install.tryConnection
train
protected function tryConnection($connectionInfo, OutputInterface $output) { if (\is_null($connectionInfo["dbName"])) { return false; } $dsn = "mysql:host=%s;port=%s"; try { $connection = new \PDO( sprintf($dsn, $connectionInfo["host"], $conn...
php
{ "resource": "" }
q2303
Version.setVersion
train
public function setVersion() { $wp_filesystem = self::getWpFilesystem(); // Get installed composer package data. $installedFile = wp_normalize_path( realpath( __DIR__ . '/../../../../' ) ) . '/composer/installed.json'; if ( 'direct' === get_filesystem_method() ) { $file = $wp_filesystem->get_contents( $in...
php
{ "resource": "" }
q2304
ClassFactory.create
train
public static function create(string $configType, ClassType $classType, array $options = []) { $classType = (string)$classType; $classMapVersion = empty($options['classMapVersion']) ? Configure::read('ModuleConfig.classMapVersion') : (string)$options['classMapVersion']; $classMap = empty($o...
php
{ "resource": "" }
q2305
ClassFactory.getInstance
train
public static function getInstance(string $class, array $params = []) { if (!class_exists($class)) { throw new InvalidArgumentException("Class [$class] does not exist"); } if (empty($params)) { return new $class; } $reflection = new ReflectionClass($...
php
{ "resource": "" }
q2306
JavaScriptAssetHandlerConnector.includeLanguageJavaScriptFiles
train
public function includeLanguageJavaScriptFiles() { $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath('locale-' . ContextService::get()->getLanguageKey()) . '.js'; $this->assetHandlerConnectorManager->createFileInTemporaryDirectory( $filePath, functio...
php
{ "resource": "" }
q2307
JavaScriptAssetHandlerConnector.generateAndIncludeFormzConfigurationJavaScript
train
public function generateAndIncludeFormzConfigurationJavaScript() { $formzConfigurationJavaScriptAssetHandler = $this->getFormzConfigurationJavaScriptAssetHandler(); $fileName = $formzConfigurationJavaScriptAssetHandler->getJavaScriptFileName(); $this->assetHandlerConnectorManager->createFil...
php
{ "resource": "" }
q2308
JavaScriptAssetHandlerConnector.generateAndIncludeJavaScript
train
public function generateAndIncludeJavaScript() { $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath() . '.js'; $this->assetHandlerConnectorManager->createFileInTemporaryDirectory( $filePath, function () { return // ...
php
{ "resource": "" }
q2309
JavaScriptAssetHandlerConnector.generateAndIncludeInlineJavaScript
train
public function generateAndIncludeInlineJavaScript() { $formName = $this->assetHandlerFactory->getFormObject()->getName(); $javaScriptCode = $this->getFormRequestDataJavaScriptAssetHandler() ->getFormRequestDataJavaScriptCode(); if (ExtensionService::get()->isInDebugMode()) { ...
php
{ "resource": "" }
q2310
JavaScriptAssetHandlerConnector.includeJavaScriptValidationAndConditionFiles
train
public function includeJavaScriptValidationAndConditionFiles() { $javaScriptValidationFiles = $this->getJavaScriptFiles(); $assetHandlerConnectorStates = $this->assetHandlerConnectorManager ->getAssetHandlerConnectorStates(); foreach ($javaScriptValidationFiles as $file) { ...
php
{ "resource": "" }
q2311
JavaScriptAssetHandlerConnector.getJavaScriptFiles
train
protected function getJavaScriptFiles() { $formObject = $this->assetHandlerFactory->getFormObject(); $javaScriptFiles = $this->getFieldsValidationJavaScriptAssetHandler() ->getJavaScriptValidationFiles(); $conditionProcessor = $this->getConditionProcessor($formObject); ...
php
{ "resource": "" }
q2312
JavaScriptAssetHandlerConnector.includeJsFile
train
protected function includeJsFile($path) { $pageRenderer = $this->assetHandlerConnectorManager->getPageRenderer(); if ($this->environmentService->isEnvironmentInFrontendMode()) { $pageRenderer->addJsFooterFile($path); } else { $pageRenderer->addJsFile($path); ...
php
{ "resource": "" }
q2313
Utility.validatePath
train
public static function validatePath(string $path = null): void { if (empty($path)) { throw new InvalidArgumentException("Cannot validate empty path"); } if (!file_exists($path)) { throw new InvalidArgumentException("Path does not exist [$path]"); } if...
php
{ "resource": "" }
q2314
Utility.getControllers
train
public static function getControllers(bool $includePlugins = true): array { // get application controllers $result = static::getDirControllers(APP . 'Controller' . DS); if ($includePlugins === false) { return $result; } $plugins = Plugin::loaded(); if (!...
php
{ "resource": "" }
q2315
Utility.getApiVersions
train
public static function getApiVersions(string $path = ''): array { $apis = []; $apiPath = (!empty($path)) ? $path : App::path('Controller/Api')[0]; $dir = new Folder(); // get folders in Controller/Api directory $tree = $dir->tree($apiPath, false, 'dir'); foreach ($t...
php
{ "resource": "" }
q2316
Utility.getDirControllers
train
public static function getDirControllers(string $path, string $plugin = null, bool $fqcn = true): array { $result = []; try { static::validatePath($path); $dir = new DirectoryIterator($path); } catch (InvalidArgumentException $e) { return $result; ...
php
{ "resource": "" }
q2317
Utility.getModels
train
public static function getModels(string $connectionManager = 'default', bool $excludePhinxlog = true): array { $result = []; $tables = ConnectionManager::get($connectionManager)->getSchemaCollection()->listTables(); if (empty($tables)) { return $result; } foreac...
php
{ "resource": "" }
q2318
Utility.getModelColumns
train
public static function getModelColumns(string $model = '', string $connectionManager = 'default'): array { $result = $columns = []; if (empty($model)) { return $result; } // making sure that model is in table naming conventions. $model = Inflector::tableize($mod...
php
{ "resource": "" }
q2319
Utility.getColors
train
public static function getColors(array $config = [], bool $pretty = true): array { $result = []; $config = empty($config) ? Configure::read('Colors') : $config; if (!$pretty) { return $config; } if (!$config) { return $result; } for...
php
{ "resource": "" }
q2320
Utility.sortApiVersions
train
protected static function sortApiVersions(array $versions = []): array { usort($versions, function ($first, $second) { $firstVersion = (float)$first['number']; $secondVersion = (float)$second['number']; if ($firstVersion == $secondVersion) { return 0; ...
php
{ "resource": "" }
q2321
Core.undefined_function
train
public static function undefined_function( $function_name ) { if ( \function_exists( $function_name ) ) { return new \Twig_Function( $function_name, function () use ( $function_name ) { ob_start(); $return = \call_user_func_array( $function_name, \func_get_args() ); $echo = ob_get_clean(...
php
{ "resource": "" }
q2322
ConfigurationFactory.getFormzConfiguration
train
public function getFormzConfiguration() { $cacheIdentifier = $this->getCacheIdentifier(); if (false === array_key_exists($cacheIdentifier, $this->instances)) { $this->instances[$cacheIdentifier] = $this->getFormzConfigurationFromCache($cacheIdentifier); } return $this->...
php
{ "resource": "" }
q2323
ConfigurationFactory.getFormzConfigurationFromCache
train
protected function getFormzConfigurationFromCache($cacheIdentifier) { $cacheInstance = CacheService::get()->getCacheInstance(); if ($cacheInstance->has($cacheIdentifier)) { $instance = $cacheInstance->get($cacheIdentifier); } else { $instance = $this->buildFormzConfi...
php
{ "resource": "" }
q2324
FormzException.getNewExceptionInstance
train
final protected static function getNewExceptionInstance($message, $code, array $arguments = []) { $exceptionClassName = get_called_class(); return new $exceptionClassName( vsprintf($message, $arguments), $code ); }
php
{ "resource": "" }
q2325
LoggingContentHandler.shouldLog
train
private function shouldLog($event) { $level = isset($this->configuration[$event]) ? $this->configuration[$event] : ''; $level = strtolower($level); if (!$level) { return ''; } if (!isset(self::$levels[$level])) { return ''; } return ...
php
{ "resource": "" }
q2326
SlotContextEntry.addSlot
train
public function addSlot($name, Closure $closure, array $arguments) { $this->closures[$name] = $closure; $this->arguments[$name] = $arguments; }
php
{ "resource": "" }
q2327
SlotContextEntry.addTemplateVariables
train
public function addTemplateVariables($slotName, array $arguments) { $templateVariableContainer = $this->renderingContext->getTemplateVariableContainer(); $savedArguments = []; ArrayUtility::mergeRecursiveWithOverrule( $arguments, $this->getSlotArguments($slotName) ...
php
{ "resource": "" }
q2328
SlotContextEntry.restoreTemplateVariables
train
public function restoreTemplateVariables($slotName) { $templateVariableContainer = $this->renderingContext->getTemplateVariableContainer(); $mergedArguments = (isset($this->injectedVariables[$slotName])) ? $this->injectedVariables[$slotName] : []; $savedArguments = (isset($this->savedVariabl...
php
{ "resource": "" }
q2329
Polyglot.stripLanguage
train
public function stripLanguage($path, $language = null) { $strip = '/' . ( isset($language) ? $language : $this->getLanguage() ); if ( strlen($strip) > 1 && strpos($path, $strip) === 0 ) { $path = substr($path, strlen($strip)); } return $path; }
php
{ "resource": "" }
q2330
Polyglot.prependLanguage
train
public function prependLanguage($path, $language = null) { $prepend = ( isset($language) ? $language : $this->getLanguage() ); if ( strlen($prepend) > 1 ) { return $prepend . (strpos($path, '/') === 0 ? $path : '/' . $path); } return $path; }
php
{ "resource": "" }
q2331
Polyglot.replaceLanguage
train
public function replaceLanguage($path, $language, $replacement = null) { $path = $this->stripLanguage($path, $language); $path = $this->prependLanguage($path, $replacement); return $path; }
php
{ "resource": "" }
q2332
Polyglot.getFromHeader
train
protected function getFromHeader(ServerRequestInterface $request) { $accept = $request->getHeaderLine('Accept-Language'); if ( empty($accept) || empty($this->languages) ) { return; } $language = (new Negotiator())->getBest($accept, $this->languages); if ( $lang...
php
{ "resource": "" }
q2333
Polyglot.getFromPath
train
protected function getFromPath(ServerRequestInterface $request) { $uri = $request->getUri(); $regex = '~^\/?' . $this->getRegEx() . '\b~'; $path = rtrim( $uri->getPath(), '/\\' ) . '/'; if ( preg_match($regex, $path, $matches) ) { if (isset($matches['language'])) { ...
php
{ "resource": "" }
q2334
Polyglot.getFromQuery
train
protected function getFromQuery(ServerRequestInterface $request) { $params = array_intersect_key($request->getQueryParams(), array_flip($this->getQueryKeys())); $regex = '~^\/?' . $this->getRegEx() . '\b~'; foreach ($params as $key => $value) { if ( preg_match($regex, $value, $...
php
{ "resource": "" }
q2335
Polyglot.setSupportedLanguages
train
public function setSupportedLanguages(array $languages) { $this->languages = $languages; $this->fallbackLanguage = reset($languages); return $this; }
php
{ "resource": "" }
q2336
Polyglot.setFallbackLanguage
train
public function setFallbackLanguage($language) { if ( $this->isSupported($language) ) { $this->fallbackLanguage = $language; } else { throw new RuntimeException('Variable must be one of the supported languages.'); } return $this; }
php
{ "resource": "" }
q2337
Polyglot.getUserLanguage
train
public function getUserLanguage(ServerRequestInterface $request = null) { if ( $this->saveInSession && isset($_SESSION['language']) && $this->isSupported($_SESSION['language']) ) { return $_SESSION['language']; } if ( empty($language) ...
php
{ "resource": "" }
q2338
Polyglot.setCallbacks
train
public function setCallbacks(array $callables) { $this->callbacks = []; foreach ($callables as $callable) { if (is_callable($callable)) { $this->addCallback($callable); } } return $this; }
php
{ "resource": "" }
q2339
Polyglot.setQueryKeys
train
public function setQueryKeys(array $keys) { $this->queryKeys = []; foreach ($keys as $key) { if (is_string($key)) { $this->addQueryKey($key); } } return $this; }
php
{ "resource": "" }
q2340
Polyglot.sanitizeLanguage
train
public function sanitizeLanguage($language) { if ( 0 === count($this->languages) ) { throw new RuntimeException('Polyglot features no supported languages.'); } if ( ! $this->isSupported($language) ) { $language = $this->getFallbackLanguage(); } retur...
php
{ "resource": "" }
q2341
Polyglot.isLanguageRequiredInUri
train
public function isLanguageRequiredInUri($state = null) { if (isset($state)) { $this->languageRequiredInUri = (bool) $state; } return $this->languageRequiredInUri; }
php
{ "resource": "" }
q2342
Polyglot.isLanguageIncludedInRoutes
train
public function isLanguageIncludedInRoutes($state = null) { if (isset($state)) { $this->languageIncludedInRoutes = (bool) $state; } return $this->languageIncludedInRoutes; }
php
{ "resource": "" }
q2343
Schema.applyCallback
train
protected function applyCallback(stdClass $schema): stdClass { if (is_callable($this->callback)) { $result = call_user_func_array($this->callback, [Convert::objectToArray($schema)]); if (is_null($result)) { throw new InvalidArgumentException('Callback returned `null`...
php
{ "resource": "" }
q2344
FormValidatorExecutor.checkFieldsActivation
train
public function checkFieldsActivation() { foreach ($this->getFormObject()->getConfiguration()->getFields() as $field) { if (false === $this->result->fieldIsDeactivated($field)) { $this->checkFieldActivation($field); } } return $this; }
php
{ "resource": "" }
q2345
CacheManager.addCache
train
public function addCache(CacheInterface $cache) { $this->cacheMap[$cache->getName()] = $cache; $this->cacheNames[] = $cache->getName(); }
php
{ "resource": "" }
q2346
Database.query
train
public function query($cql, array $values = [], $consistency = ConsistencyEnum::CONSISTENCY_QUORUM) { if ($this->batchQuery && in_array(substr($cql, 0, 6), ['INSERT', 'UPDATE', 'DELETE'])) { $this->appendQueryToStack($cql, $values); return true; } if (empty($values)) { $response = $this->connection->send...
php
{ "resource": "" }
q2347
FormzConfigurationJavaScriptAssetHandler.getFormzConfiguration
train
protected function getFormzConfiguration() { $rootConfigurationArray = $this->getFormObject() ->getConfiguration() ->getRootConfiguration() ->toArray(); $cleanFormzConfigurationArray = [ 'view' => $rootConfigurationArray['view'] ]; re...
php
{ "resource": "" }
q2348
ContainerBuilder.setDefaultConfiguration
train
private function setDefaultConfiguration(): void { $this->parameterBag->set('app.devmode', false); $this->parameterBag->set('container.dumper.inline_class_loader', true); $this->config->addPass($this->parameterBag); }
php
{ "resource": "" }
q2349
BrowserDumper.dump
train
public function dump() { $methods = $this->specification->getMethods(); $result = '<?php /* * This file is part of PHP Selenium Library. * (c) Alexandre Salomé <alexandre.salome@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed w...
php
{ "resource": "" }
q2350
BrowserDumper.dumpMethod
train
protected function dumpMethod(Method $method) { $builder = new MethodBuilder(); $documentation = $method->getDescription()."\n\n"; $signature = array(); foreach ($method->getParameters() as $parameter) { $builder->addParameter($parameter->getName()); $docume...
php
{ "resource": "" }
q2351
TbbcCacheExtension.createCache
train
private function createCache(array $config, ContainerBuilder $container) { $type = $config['type']; if (array_key_exists($type, $this->cacheFactories)) { $id = sprintf('tbbc_cache.%s_cache', $config['name']); $this->cacheFactories[$type]->create($container, $id, $config); ...
php
{ "resource": "" }
q2352
TbbcCacheExtension.createCacheFactories
train
private function createCacheFactories() { if (null !== $this->cacheFactories) { return $this->cacheFactories; } // load bundled cache factories $tempContainer = new ContainerBuilder(); $loader = new Loader\XmlFileLoader($tempContainer, new FileLocator(__DIR__.'/....
php
{ "resource": "" }
q2353
MessageService.sanitizeValidatorResult
train
public function sanitizeValidatorResult(Result $result, $validationName) { $newResult = new Result; $this->sanitizeValidatorResultMessages('error', $result->getFlattenedErrors(), $newResult, $validationName); $this->sanitizeValidatorResultMessages('warning', $result->getFlattenedWarnings(),...
php
{ "resource": "" }
q2354
MessageService.filterMessages
train
public function filterMessages(array $messages, array $supportedMessages, $canCreateNewMessages = false) { // Adding the keys `value` and `extension` to the messages, only if it is missing. $addValueToArray = function (array &$a) { foreach ($a as $k => $v) { if (false ===...
php
{ "resource": "" }
q2355
Decorator.render
train
public function render(ElementInterface $formElement, $value = '', $attributes = array()) { $this->checkDependencies(); $config = $this->di->get('config'); if (empty($this->templateName) && !empty($config->forms->templates->default_name)) { $this->templateName = $config->forms-...
php
{ "resource": "" }
q2356
Decorator.checkDependencies
train
private function checkDependencies() { if (!($this->di instanceof DiInterface)) { throw new DiNotSetException(); } if (!$this->di->has('view')) { throw new ViewNotSetException(); } if (!$this->di->has('assets')) { throw new InvalidAssetsM...
php
{ "resource": "" }
q2357
BasePathFinder.getFilePath
train
protected function getFilePath(string $path): string { if (empty($path)) { $path = $this->fileName; } return $path; }
php
{ "resource": "" }
q2358
BasePathFinder.getDistributionFilePath
train
protected function getDistributionFilePath(string $path): string { $postfix = self::DIST_FILENAME_POSTFIX; if (empty($path)) { $path = $this->fileName; } // Check if this is the distribution file path $pathinfo = pathinfo($path); $postfixIndex = strlen($...
php
{ "resource": "" }
q2359
BasePathFinder.validatePath
train
protected function validatePath(string $path): void { if (empty($path)) { $this->fail(new InvalidArgumentException("Path is not specified")); } if (!is_string($path)) { $this->fail(new InvalidArgumentException("Path is not a string")); } }
php
{ "resource": "" }
q2360
BasePathFinder.addFileExtension
train
protected function addFileExtension(string $path): string { $extension = pathinfo($path, PATHINFO_EXTENSION); if (empty($extension)) { $path .= $this->extension; } return $path; }
php
{ "resource": "" }
q2361
FormRequestDataJavaScriptAssetHandler.getSubmittedFormValues
train
protected function getSubmittedFormValues() { $result = []; $formName = $this->getFormObject()->getName(); $originalRequest = $this->getControllerContext() ->getRequest() ->getOriginalRequest(); if (null !== $originalRequest && $originalRequest->h...
php
{ "resource": "" }
q2362
EncryptedCookiesMiddleware.encryptAndRenderCookies
train
private function encryptAndRenderCookies($resCookies) { $renderable = []; foreach ($resCookies as $cookie) { if (is_string($cookie)) { $cookie = SetCookie::fromSetCookieString($cookie); } if ($cookie instanceof SetCookie) { $val =...
php
{ "resource": "" }
q2363
TwigExtension.formatTimepoint
train
public function formatTimepoint($time, $format) { if ($time instanceof TimePoint) { return $time->format($format, $this->displayTimezone); } if ($time instanceof DateTime) { $formatted = clone $time; $formatted->setTimezone(new DateTimeZone($this->display...
php
{ "resource": "" }
q2364
AjaxValidationController.processRequest
train
public function processRequest(RequestInterface $request, ResponseInterface $response) { $this->result = new AjaxResult; try { $this->processRequestParent($request, $response); } catch (Exception $exception) { if (false === $this->protectedRequestMode) { ...
php
{ "resource": "" }
q2365
AjaxValidationController.initializeActionMethodValidators
train
protected function initializeActionMethodValidators() { $this->initializeActionMethodValidatorsParent(); $request = $this->getRequest(); if (false === $request->hasArgument('name')) { throw MissingArgumentException::ajaxControllerNameArgumentNotSet(); } if (fal...
php
{ "resource": "" }
q2366
AjaxValidationController.runAction
train
public function runAction($name, $className, $fieldName, $validatorName) { $this->formName = $name; $this->formClassName = $className; $this->fieldName = $fieldName; $this->validatorName = $validatorName; $this->form = $this->getForm(); $this->formObject = $this->get...
php
{ "resource": "" }
q2367
ListParser.normalize
train
protected function normalize(array $data, string $prefix = null): array { if ($prefix) { $prefix .= '.'; } $result = []; foreach ($data as $item) { $value = [ 'label' => (string)$item['label'], 'inactive' => (bool)$item['inacti...
php
{ "resource": "" }
q2368
ListParser.filter
train
protected function filter(array $data): array { $result = []; foreach ($data as $key => $value) { if ($value['inactive']) { continue; } $result[$key] = $value; if (isset($value['children'])) { $result[$key]['children'] ...
php
{ "resource": "" }
q2369
ListParser.flatten
train
protected function flatten(array $data): array { $result = []; foreach ($data as $key => $value) { $item = [ 'label' => $value['label'], 'inactive' => $value['inactive'] ]; $result[$key] = $item; if (isset($value['chil...
php
{ "resource": "" }
q2370
Cache.setOptions
train
protected function setOptions(array $options = []): void { $this->options = $options; $this->configName = empty($options['cacheConfig']) ? static::DEFAULT_CONFIG : (string)$options['cacheConfig']; $this->skipCache = empty($this->options['cacheSkip']) ? false : (bool)$this->options['cacheSkip...
php
{ "resource": "" }
q2371
Cache.getKey
train
public function getKey(array $params): string { // Push current options to the list of // params to ensure unique cache key for // each set of options. $params[] = $this->options; $params = json_encode($params); $params = $params ?: microtime(); $params = md5...
php
{ "resource": "" }
q2372
Cache.readFrom
train
public function readFrom(string $key) { $result = false; if ($this->skipCache()) { $this->warnings[] = 'Skipping read from cache'; return $result; } $cachedData = CakeCache::read($key, $this->getConfig()); if (!$this->isValidCache($cachedData)) { ...
php
{ "resource": "" }
q2373
BooleanNode.getLogicalResult
train
protected function getLogicalResult(callable $logicalAndFunction, callable $logicalOrFunction) { switch ($this->operator) { case ConditionParser::LOGICAL_AND: $result = call_user_func($logicalAndFunction); break; case ConditionParser::LOGICAL_OR: ...
php
{ "resource": "" }
q2374
BooleanNode.processLogicalOrPhp
train
protected function processLogicalOrPhp(PhpConditionDataObject $dataObject) { return $this->leftNode->getPhpResult($dataObject) || $this->rightNode->getPhpResult($dataObject); }
php
{ "resource": "" }
q2375
UtilityPage.requireDefaultRecords
train
public function requireDefaultRecords() { parent::requireDefaultRecords(); // Skip creation of default records if (!self::config()->create_default_pages) { return; } // Ensure that an assets path exists before we do any error page creation if (!file_exists(ASSETS_PATH)) { mkdir(ASSETS_PATH); } ...
php
{ "resource": "" }
q2376
UtilityPage.get_top_level_templates
train
public static function get_top_level_templates() { $ss_templates_array = array(); $current_theme_path = THEMES_PATH.'/'.Config::inst()->get('SSViewer', 'theme'); //theme directories to search $search_dir_array = array( MAINTENANCE_MODE_PATH.'/templates', $current_theme_path.'/templates' ); foreach...
php
{ "resource": "" }
q2377
FormObjectFactory.getInstanceFromClassName
train
public function getInstanceFromClassName($className, $name) { if (false === class_exists($className)) { throw ClassNotFoundException::wrongFormClassName($className); } if (false === in_array(FormInterface::class, class_implements($className))) { throw InvalidArgument...
php
{ "resource": "" }
q2378
FormObjectFactory.createInstance
train
protected function createInstance($className, $name) { $formConfiguration = $this->typoScriptService->getFormConfiguration($className); /** @var FormObject $instance */ $instance = Core::instantiate(FormObject::class, $className, $name, $formConfiguration); $this->insertObjectPrope...
php
{ "resource": "" }
q2379
FormObjectFactory.insertObjectProperties
train
protected function insertObjectProperties(FormObject $instance) { $className = $instance->getClassName(); /** @var ReflectionService $reflectionService */ $reflectionService = GeneralUtility::makeInstance(ReflectionService::class); $reflectionProperties = $reflectionService->getClas...
php
{ "resource": "" }
q2380
TaxonomyTrait.addTerm
train
public function addTerm($term_id) { $term = ($term_id instanceof Term) ? $term_id : Term::findOrFail($term_id); $term_relation = [ 'term_id' => $term->id, 'vocabulary_id' => $term->vocabulary_id, ]; return $this->related()->save(new TermRelation($term_relation)); }
php
{ "resource": "" }
q2381
TaxonomyTrait.hasTerm
train
public function hasTerm($term_id) { $term = ($term_id instanceof Term) ? $term_id : Term::findOrFail($term_id); $term_relation = [ 'term_id' => $term->id, 'vocabulary_id' => $term->vocabulary_id, ]; return ($this->related()->where('term_id', $term_id)->count()) ? TRUE : FALSE; }
php
{ "resource": "" }
q2382
TaxonomyTrait.getTermsByVocabularyName
train
public function getTermsByVocabularyName($name) { $vocabulary = \Taxonomy::getVocabularyByName($name); return $this->related()->where('vocabulary_id', $vocabulary->id)->get(); }
php
{ "resource": "" }
q2383
TaxonomyTrait.getTermsByVocabularyNameAsArray
train
public function getTermsByVocabularyNameAsArray($name) { $vocabulary = \Taxonomy::getVocabularyByName($name); $term_relations = $this->related()->where('vocabulary_id', $vocabulary->id)->get(); $data = []; foreach ($term_relations as $term_relation) { $data[$term_relation->term->id] = $term_rela...
php
{ "resource": "" }
q2384
TaxonomyTrait.removeTerm
train
public function removeTerm($term_id) { $term_id = ($term_id instanceof Term) ? $term_id->id : $term_id; return $this->related()->where('term_id', $term_id)->delete(); }
php
{ "resource": "" }
q2385
FormViewHelperService.applyBehavioursOnSubmittedForm
train
public function applyBehavioursOnSubmittedForm(ControllerContext $controllerContext) { if ($this->formObject->formWasSubmitted()) { $request = $controllerContext->getRequest()->getOriginalRequest(); $formName = $this->formObject->getName(); if ($request &...
php
{ "resource": "" }
q2386
ConditionProcessor.getActivationConditionTreeForField
train
public function getActivationConditionTreeForField(Field $field) { $key = $field->getName(); if (false === array_key_exists($key, $this->fieldsTrees)) { $this->fieldsTrees[$key] = $this->getConditionTree($field->getActivation()); } $this->fieldsTrees[$key]->injectDepend...
php
{ "resource": "" }
q2387
ConditionProcessor.getActivationConditionTreeForValidation
train
public function getActivationConditionTreeForValidation(Validation $validation) { $key = $validation->getParentField()->getName() . '->' . $validation->getName(); if (false === array_key_exists($key, $this->validationsTrees)) { $this->validationsTrees[$key] = $this->getConditionTree($va...
php
{ "resource": "" }
q2388
ConditionProcessor.calculateAllTrees
train
public function calculateAllTrees() { $fields = $this->formObject->getConfiguration()->getFields(); foreach ($fields as $field) { $this->getActivationConditionTreeForField($field); foreach ($field->getValidation() as $validation) { $this->getActivationCondit...
php
{ "resource": "" }
q2389
Handlers.exceptionHandler
train
public function exceptionHandler($e) : void { $this->setError( (int) $e->getCode(), (string) $e->getMessage(), (string) $e->getFile(), (int) $e->getLine(), (string) get_class($e), $e->getTrace() ); View::render('500.php...
php
{ "resource": "" }
q2390
Handlers.fatalHandler
train
public function fatalHandler() : void { $errors = error_get_last(); if (is_array($errors)) { $this->setError( (int) $errors['type'], (string) $errors['message'], (string) $errors['file'], (int) $errors['line'], ...
php
{ "resource": "" }
q2391
MigratorConsole.migrateModels
train
public function migrateModels($models) { // run inside callback $this->set(function ($c) use ($models) { $c->notice('Preparing to migrate models'); $p = $c->app->db; foreach ($models as $model) { if (!is_object($model)) { $mode...
php
{ "resource": "" }
q2392
ExtensionService.getExtensionConfiguration
train
public function getExtensionConfiguration($configurationName) { $result = null; $extensionConfiguration = $this->getFullExtensionConfiguration(); if (null === $configurationName) { $result = $extensionConfiguration; } elseif (ArrayUtility::isValidPath($extensionConfigura...
php
{ "resource": "" }
q2393
CookieHandler.expireCookie
train
public function expireCookie(ResponseInterface $response, $name) { $cookie = SetCookie::createExpired($name) ->withMaxAge($this->configuration['maxAge']) ->withPath($this->configuration['path']) ->withDomain($this->configuration['domain']) ->withSecure($this->...
php
{ "resource": "" }
q2394
AbstractValidator.addError
train
protected function addError($key, $code, array $arguments = [], $title = '') { $message = $this->addMessage(Error::class, $key, $code, $arguments, $title); $this->result->addError($message); }
php
{ "resource": "" }
q2395
AbstractValidator.addWarning
train
protected function addWarning($key, $code, array $arguments = [], $title = '') { $message = $this->addMessage(Warning::class, $key, $code, $arguments, $title); $this->result->addWarning($message); }
php
{ "resource": "" }
q2396
AbstractValidator.addNotice
train
protected function addNotice($key, $code, array $arguments = [], $title = '') { $message = $this->addMessage(Notice::class, $key, $code, $arguments, $title); $this->result->addNotice($message); }
php
{ "resource": "" }
q2397
FormObject.addProperty
train
public function addProperty($name) { if (false === $this->hasProperty($name)) { $this->properties[] = $name; $this->hashService->resetHash(); } return $this; }
php
{ "resource": "" }
q2398
DataStream.read
train
protected function read($length) { if ($this->length < $length) { throw new \Exception('Reading while at end of stream'); } $output = substr($this->data, 0, $length); $this->data = substr($this->data, $length); $this->length -= $length; return $output; }
php
{ "resource": "" }
q2399
DataStream.readInt
train
public function readInt($isCollectionElement = false) { if ($isCollectionElement) { $length = $this->readShort(); return unpack('l', strrev($this->read($length)))[1]; } return unpack('l', strrev($this->read(4)))[1]; }
php
{ "resource": "" }