_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q2400
DataStream.readBigInt
train
function readBigInt($isCollectionElement = false) { if ($isCollectionElement) { $length = $this->readShort(); } else { $length = 8; } $data = $this->read($length); $arr = unpack('N2', $data); if (PHP_INT_SIZE == 4) { $hi = $arr[1]; $lo = $arr[2]; $isNeg = $hi < 0; // Check for a nega...
php
{ "resource": "" }
q2401
DataStream.readBytes
train
public function readBytes($isCollectionElement = false) { if ($isCollectionElement) $this->readShort(); $length = $this->readInt(); if ($length == -1) return null; return $this->read($length); }
php
{ "resource": "" }
q2402
DataStream.readUuid
train
public function readUuid($isCollectionElement = false) { if ($isCollectionElement) $this->readShort(); $uuid = ''; $data = $this->read(16); for ($i = 0; $i < 16; ++$i) { if ($i == 4 || $i == 6 || $i == 8 || $i == 10) { $uuid .= '-'; } $uuid .= str_pad(dechex(ord($data{$i})), 2, '0', STR_PAD_LEF...
php
{ "resource": "" }
q2403
DataStream.readList
train
public function readList($valueType) { $list = array(); $count = $this->readShort(); for ($i = 0; $i < $count; ++$i) { $list[] = $this->readByType($valueType, true); } return $list; }
php
{ "resource": "" }
q2404
DataStream.readMap
train
public function readMap($keyType, $valueType) { $map = array(); $count = $this->readShort(); for ($i = 0; $i < $count; ++$i) { $map[$this->readByType($keyType, true)] = $this->readByType($valueType, true); } return $map; }
php
{ "resource": "" }
q2405
DataStream.readFloat
train
public function readFloat($isCollectionElement = false) { if ($isCollectionElement) { $this->readShort(); } return unpack('f', strrev($this->read(4)))[1]; }
php
{ "resource": "" }
q2406
DataStream.readDouble
train
public function readDouble($isCollectionElement = false) { if ($isCollectionElement) { $this->readShort(); } return unpack('d', strrev($this->read(8)))[1]; }
php
{ "resource": "" }
q2407
DataStream.readInet
train
public function readInet($isCollectionElement = false) { if ($isCollectionElement) { $data = $this->read($this->readShort()); } else { $data = $this->data; } return inet_ntop($data); }
php
{ "resource": "" }
q2408
DataStream.readVarint
train
public function readVarint($isCollectionElement = false) { if($isCollectionElement) { $length = $this->readShort(); } else { $length = strlen($this->data); } $hex = unpack('H*', $this->read($length)); return $this->bchexdec($hex[1]); }
php
{ "resource": "" }
q2409
DataStream.readDecimal
train
public function readDecimal($isCollectionElement = false) { if ($isCollectionElement) { $this->readShort(); } $scale = $this->readInt(); $value = $this->readVarint($isCollectionElement); $len = strlen($value); return substr($value, 0, $len - $scale) . '.' . substr($value, $len - $scale); }
php
{ "resource": "" }
q2410
Migration.setModel
train
public function setModel(\atk4\data\Model $m) { $this->table($m->table); foreach ($m->elements as $field) { // ignore not persisted model fields if (!$field instanceof \atk4\data\Field) { continue; } if ($field->never_persist) { ...
php
{ "resource": "" }
q2411
Migration.mode
train
public function mode($mode) { if (!isset($this->templates[$mode])) { throw new Exception(['Structure builder does not have this mode', 'mode' => $mode]); } $this->mode = $mode; $this->template = $this->templates[$mode]; return $this; }
php
{ "resource": "" }
q2412
Migration._render_statements
train
public function _render_statements() { $result = []; if (isset($this->args['dropField'])) { foreach ($this->args['dropField'] as $field => $junk) { $result[] = 'drop column '.$this->_escape($field); } } if (isset($this->args['newField'])) { ...
php
{ "resource": "" }
q2413
Migration.getModelFieldType
train
public function getModelFieldType($type) { $type = preg_replace('/\(.*/', '', strtolower($type)); // remove parenthesis if (substr($type, 0, 7) == 'varchar' || substr($type, 0, 4) == 'char' || substr($type, 0, 4) == 'enum') { $type = null; } if ($type == 'tinyint') { ...
php
{ "resource": "" }
q2414
Migration.getSQLFieldType
train
public function getSQLFieldType($type, $options = []) { $type = strtolower($type); $len = null; switch ($type) { case 'boolean': $type = 'tinyint'; $len = 1; break; case 'integer': $type = 'int'; ...
php
{ "resource": "" }
q2415
Migration.importTable
train
public function importTable($table) { $this->table($table); $has_fields = false; foreach ($this->describeTable($table) as $row) { $has_fields = true; if ($row['pk']) { $this->id($row['name']); continue; } $type ...
php
{ "resource": "" }
q2416
Migration.id
train
public function id($name = null) { if (!$name) { $name = 'id'; } $val = $this->connection->expr($this->primary_key_expr); $this->args['field'] = [$name => $val] + (isset($this->args['field']) ? $this->args['field'] : []); return $this; }
php
{ "resource": "" }
q2417
Migration._render_one_field
train
protected function _render_one_field($field, $options) { $name = $options['name'] ?? $field; $type = $this->getSQLFieldType($options['type'] ?? null, $options); return $this->_escape($name).' '.$type; }
php
{ "resource": "" }
q2418
Migration._set_args
train
protected function _set_args($what, $alias, $value) { // save value in args if ($alias === null) { $this->args[$what][] = $value; } else { // don't allow multiple values with same alias if (isset($this->args[$what][$alias])) { throw new Ex...
php
{ "resource": "" }
q2419
ModuleConfig.getFinder
train
protected function getFinder(): PathFinderInterface { $result = ClassFactory::createFinder($this->configType, $this->options); return $result; }
php
{ "resource": "" }
q2420
ModuleConfig.createSchema
train
public function createSchema(array $config = []): SchemaInterface { $path = rtrim(Configure::read('ModuleConfig.schemaPath'), '/'); $file = $this->configType . '.json'; $schemaPath = implode(DIRECTORY_SEPARATOR, [$path, $file]); return new Schema($schemaPath, null, $config); }
php
{ "resource": "" }
q2421
ModuleConfig.find
train
public function find(bool $validate = true) { $cache = $finder = $exception = $cacheKey = $result = null; try { // Cached response $cache = new Cache(__FUNCTION__, $this->options); $cacheKey = $cache->getKey([$this->module, $this->configType, $this->configFile, $v...
php
{ "resource": "" }
q2422
ModuleConfig.parse
train
public function parse() { $result = new stdClass(); $cache = $parser = $exception = $cacheKey = $path = null; try { $path = $this->find(false); // Cached response $cache = new PathCache(__FUNCTION__, $this->options); $cacheKey = $cache->getKey(...
php
{ "resource": "" }
q2423
ModuleConfig.mergeMessages
train
protected function mergeMessages($source = null, string $caller = 'ModuleConfig'): void { $source = is_object($source) ? $source : new stdClass(); if ($source instanceof InvalidArgumentException) { $this->errors = array_merge($this->errors, $this->formatMessages($source->getMessage(), $...
php
{ "resource": "" }
q2424
ModuleConfig.exists
train
public static function exists(string $moduleName, array $options = []) : bool { $config = (new ModuleConfig(ConfigType::MIGRATION(), $moduleName, null, $options))->parseToArray(); if (empty($config)) { return false; } $config = (new ModuleConfig(ConfigType::MODULE(), $mo...
php
{ "resource": "" }
q2425
ModuleConfig.hasMigrationFields
train
public static function hasMigrationFields(string $moduleName, array $fields, array $options = []): bool { $config = (new ModuleConfig(ConfigType::MIGRATION(), $moduleName, null, $options))->parseToArray(); $fieldKeys = array_flip($fields); $diff = array_diff_key($fieldKeys, $config); ...
php
{ "resource": "" }
q2426
WebhookService.readEvent
train
public function readEvent() { $rawRequestBody = $this->httpClient->getRawRequest(); $webhookEvent = !empty($rawRequestBody['webhook_event']) ? json_decode($rawRequestBody['webhook_event'], true) : false; return $webhookEvent ? $this->dataFactory->create($webhookEvent)...
php
{ "resource": "" }
q2427
CssAssetHandlerConnector.includeGeneratedCss
train
public function includeGeneratedCss() { $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath() . '.css'; $this->assetHandlerConnectorManager->createFileInTemporaryDirectory( $filePath, function () { /** @var MessageContainerDisplayCssAss...
php
{ "resource": "" }
q2428
AssetHandlerConnectorManager.includeDefaultAssets
train
public function includeDefaultAssets() { if (false === $this->assetHandlerConnectorStates->defaultAssetsWereIncluded()) { $this->assetHandlerConnectorStates->markDefaultAssetsAsIncluded(); $this->getJavaScriptAssetHandlerConnector()->includeDefaultJavaScriptFiles(); $thi...
php
{ "resource": "" }
q2429
AssetHandlerConnectorManager.getFormzGeneratedFilePath
train
public function getFormzGeneratedFilePath($prefix = '') { $formObject = $this->assetHandlerFactory->getFormObject(); $formIdentifier = CacheService::get()->getFormCacheIdentifier($formObject->getClassName(), $formObject->getName()); $prefix = (false === empty($prefix)) ? $prefix ...
php
{ "resource": "" }
q2430
AssetHandlerConnectorManager.createFileInTemporaryDirectory
train
public function createFileInTemporaryDirectory($relativePath, callable $callback) { $result = false; $absolutePath = GeneralUtility::getFileAbsFileName($relativePath); if (false === $this->fileExists($absolutePath)) { $content = call_user_func($callback); $result = ...
php
{ "resource": "" }
q2431
ContextService.getContextHash
train
public function getContextHash() { return ($this->environmentService->isEnvironmentInFrontendMode()) ? 'fe-' . Core::get()->getPageController()->id : 'be-' . StringService::get()->sanitizeString(GeneralUtility::_GET('M')); }
php
{ "resource": "" }
q2432
ContextService.getLanguageKey
train
public function getLanguageKey() { $languageKey = 'unknown'; if ($this->environmentService->isEnvironmentInFrontendMode()) { $pageController = Core::get()->getPageController(); if (isset($pageController->config['config']['language'])) { $languageKey = $pageC...
php
{ "resource": "" }
q2433
Select.addOptions
train
public function addOptions(array $options) { $existingOptions = $this->getOptions(); $newOptions = empty($existingOptions) ? $options : array_merge((array)$existingOptions, $options); $this->setOptions($newOptions); return $this; }
php
{ "resource": "" }
q2434
Parser.getDataFromPath
train
protected function getDataFromPath(string $path): string { $isPathRequired = $this->getConfig('pathRequired'); try { Utility::validatePath($path); } catch (InvalidArgumentException $e) { if ($isPathRequired) { throw $e; } $this...
php
{ "resource": "" }
q2435
Parser.validate
train
protected function validate(stdClass $data): void { $config = $this->getConfig(); $schema = $this->readSchema(); // No need to validate empty data (empty() does not work on objects) $dataArray = Convert::objectToArray($data); if (empty($dataArray)) { if ($config[...
php
{ "resource": "" }
q2436
Parser.readSchema
train
protected function readSchema(): \stdClass { $schema = $this->getEmptyResult(); try { $schema = $this->getSchema()->read(); } catch (InvalidArgumentException $e) { $this->errors[] = $e->getMessage(); throw new JsonValidationException("Schema file `{$this...
php
{ "resource": "" }
q2437
Parser.runValidator
train
protected function runValidator(stdClass $data, stdClass $schema): void { $config = $this->getConfig(); $validator = new Validator; $validator->validate($data, $schema, $config['validationMode']); if (!$validator->isValid()) { foreach ($validator->getErrors() as $error)...
php
{ "resource": "" }
q2438
FormViewHelper.renderForm
train
final protected function renderForm(array $arguments) { /* * We begin by setting up the form service: request results and form * instance are inserted in the service, and are used afterwards. * * There are only two ways to be sure the values injected are correct: ...
php
{ "resource": "" }
q2439
FormViewHelper.addDefaultClass
train
protected function addDefaultClass() { $formDefaultClass = $this->formObject ->getConfiguration() ->getSettings() ->getDefaultClass(); $class = $this->tag->getAttribute('class'); if (false === empty($formDefaultClass)) { $class = (!empty($cla...
php
{ "resource": "" }
q2440
FormViewHelper.handleDataAttributes
train
protected function handleDataAttributes() { $dataAttributes = []; $dataAttributesAssetHandler = $this->getDataAttributesAssetHandler(); if ($this->formObject->hasForm()) { if (false === $this->formObject->hasFormResult()) { $form = $this->formObject->getForm(); ...
php
{ "resource": "" }
q2441
FormViewHelper.handleAssets
train
protected function handleAssets() { $assetHandlerConnectorManager = $this->getAssetHandlerConnectorManager(); // Default FormZ assets. $assetHandlerConnectorManager->includeDefaultAssets(); // JavaScript assets. $assetHandlerConnectorManager->getJavaScriptAssetHandlerConnec...
php
{ "resource": "" }
q2442
FormViewHelper.getErrorText
train
protected function getErrorText(Result $result) { /** @var $view StandaloneView */ $view = Core::instantiate(StandaloneView::class); $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName('EXT:' . ExtensionService::get()->getExtensionKey() . '/Resources/Private/Templates/Error/...
php
{ "resource": "" }
q2443
FormViewHelper.getFormObjectArgument
train
protected function getFormObjectArgument() { $objectArgument = $this->arguments['object']; if (null === $objectArgument) { return null; } if (false === is_object($objectArgument)) { throw InvalidOptionValueException::formViewHelperWrongFormValueType($objectA...
php
{ "resource": "" }
q2444
FormViewHelper.getFormClassNameFromControllerAction
train
protected function getFormClassNameFromControllerAction() { return $this->controllerService->getFormClassNameFromControllerAction( $this->getControllerName(), $this->getControllerActionName(), $this->getFormObjectName() ); }
php
{ "resource": "" }
q2445
Truncator.truncate
train
public static function truncate($html, $length, $opts=array()) { if (is_string($opts)) $opts = array('ellipsis' => $opts); $opts = array_merge(static::$default_options, $opts); // wrap the html in case it consists of adjacent nodes like <p>foo</p><p>bar</p> $html = "<div>".static::utf8_for_xml($html)."</div>"; ...
php
{ "resource": "" }
q2446
ValidatorService.getValidatorData
train
protected function getValidatorData($validatorClassName) { if (false === isset($this->validatorsData[$validatorClassName])) { $this->validatorsData[$validatorClassName] = []; if (in_array(AbstractValidator::class, class_parents($validatorClassName))) { $validatorRefl...
php
{ "resource": "" }
q2447
CodeigniterInstaller.moveCoreFiles
train
protected function moveCoreFiles($downloadPath, $wildcard = '*.php') { $dir = realpath($downloadPath); $dst = dirname($dir); // Move the files up one level if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { shell_exec("move /Y $dir/$wildcard $dst/"); } else { shell_exec("mv -f $dir/$wildcard $d...
php
{ "resource": "" }
q2448
DataAttributesAssetHandler.getFieldsValuesDataAttributes
train
public function getFieldsValuesDataAttributes(FormResult $formResult) { $result = []; $formObject = $this->getFormObject(); $formInstance = $formObject->getForm(); foreach ($formObject->getConfiguration()->getFields() as $field) { $fieldName = $field->getName(); ...
php
{ "resource": "" }
q2449
DataAttributesAssetHandler.getFieldsMessagesDataAttributes
train
public function getFieldsMessagesDataAttributes() { $result = []; $formConfiguration = $this->getFormObject()->getConfiguration(); $formResult = $this->getFormObject()->getFormResult(); foreach ($formResult->getSubResults() as $fieldName => $fieldResult) { if (true === $...
php
{ "resource": "" }
q2450
DataAttributesAssetHandler.getFieldsValidDataAttributes
train
public function getFieldsValidDataAttributes() { $result = []; $formConfiguration = $this->getFormObject()->getConfiguration(); $formResult = $this->getFormObject()->getFormResult(); foreach ($formConfiguration->getFields() as $field) { $fieldName = $field->getName(); ...
php
{ "resource": "" }
q2451
DataAttributesAssetHandler.getFieldDataValidationMessageKey
train
public static function getFieldDataValidationMessageKey($fieldName, $type, $validationName, $messageKey) { $stringService = StringService::get(); return vsprintf( 'fz-%s-%s-%s-%s', [ $type, $stringService->sanitizeString($fieldName), ...
php
{ "resource": "" }
q2452
HTTPProblem.title
train
public function title() { if (in_array($this->type(), [null, 'about:blank'], true)) { return $this->determineStatusPhrase($this->status()); } return $this->title; }
php
{ "resource": "" }
q2453
XmlLoader.load
train
public function load($file) { if (!file_exists($file)) { throw new \RuntimeException(sprintf('The file "%s" does not exists', $file)); } $content = file_get_contents($file); // HACK: DOMNode seems to bug when a node is named "param" $content = str_replace('<para...
php
{ "resource": "" }
q2454
XmlLoader.getMethod
train
public function getMethod(\DOMNode $node) { $crawler = new Crawler($node); $name = $crawler->attr('name'); // Initialize $method = new Method($name); // Type $method->setType( preg_match('/(^(get|is)|ToString$)/', $name) ? Method::TYPE_AC...
php
{ "resource": "" }
q2455
XmlLoader.getParameter
train
protected function getParameter(\DOMNode $node) { $name = $node->getAttribute('name'); $parameter = new Parameter($name); $parameter->setDescription($this->getInner($node)); return $parameter; }
php
{ "resource": "" }
q2456
XmlLoader.getInner
train
protected function getInner(\DOMNode $node) { $c14n = $node->C14N(); $begin = strpos($c14n, '>'); $end = strrpos($c14n, '<'); $content = substr($c14n, $begin + 1, $end - $begin - 1); return $content; }
php
{ "resource": "" }
q2457
EncryptedFieldsBehavior.beforeSave
train
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options): void { $entity = $this->encryptEntity($entity); }
php
{ "resource": "" }
q2458
EncryptedFieldsBehavior.encryptEntity
train
public function encryptEntity(EntityInterface $entity): EntityInterface { if (!$this->isEncryptable($entity)) { return $entity; } $fields = $this->getFields(); $encryptionKey = $this->getConfig('encryptionKey'); $base64 = $this->getConfig('base64'); $tabl...
php
{ "resource": "" }
q2459
EncryptedFieldsBehavior.isEncryptable
train
public function isEncryptable(EntityInterface $entity): bool { $enabled = $this->getConfig('enabled'); if (is_callable($enabled)) { $enabled = $enabled($entity); if (!is_bool($enabled)) { throw new RuntimeException('Condition callable must return a boolean.');...
php
{ "resource": "" }
q2460
EncryptedFieldsBehavior.decryptEntity
train
public function decryptEntity(EntityInterface $entity, array $fields): EntityInterface { if (!$this->isEncryptable($entity)) { return $entity; } foreach ($fields as $field) { $value = $this->decryptEntityField($entity, $field); if ($value !== null) { ...
php
{ "resource": "" }
q2461
EncryptedFieldsBehavior.decryptEntityField
train
public function decryptEntityField(EntityInterface $entity, string $field) { if (!$this->canDecryptField($entity, $field)) { return null; } $encryptionKey = $this->getConfig('encryptionKey'); $base64 = $this->getConfig('base64'); $encoded = $entity->get($field); ...
php
{ "resource": "" }
q2462
EncryptedFieldsBehavior.canDecryptField
train
protected function canDecryptField(EntityInterface $entity, string $field): bool { if (!$this->getTable()->hasField($field)) { return false; } $decryptAll = $this->getConfig('decryptAll'); if ($decryptAll === true) { return true; } $fields = $...
php
{ "resource": "" }
q2463
EncryptedFieldsBehavior.getFields
train
protected function getFields(): array { $fields = $this->getConfig('fields'); $defaults = [ 'decrypt' => false, ]; $result = []; foreach ($fields as $field => $values) { if (is_numeric($field)) { $field = $values; $value...
php
{ "resource": "" }
q2464
AbstractFormValidator.initializeValidator
train
private function initializeValidator($form) { if (false === $form instanceof FormInterface) { throw InvalidArgumentTypeException::validatingWrongFormType(get_class($form)); } $this->form = $form; $this->result = new FormResult; $this->formValidatorExecutor = $thi...
php
{ "resource": "" }
q2465
AbstractFormValidator.validate
train
final public function validate($form) { $this->initializeValidator($form); $formObject = $this->formValidatorExecutor->getFormObject(); $formObject->markFormAsSubmitted(); $formObject->setForm($form); $this->validateGhost($form, false); $formObject->setFormResult($...
php
{ "resource": "" }
q2466
AbstractFormValidator.validateGhost
train
public function validateGhost($form, $initialize = true) { if ($initialize) { $this->initializeValidator($form); } $this->isValid($form); return $this->result; }
php
{ "resource": "" }
q2467
AbstractFormValidator.isValid
train
final public function isValid($form) { $this->formValidatorExecutor->applyBehaviours(); $this->formValidatorExecutor->checkFieldsActivation(); $this->beforeValidationProcess(); $this->formValidatorExecutor->validateFields(function (Field $field) { $this->callAfterFieldV...
php
{ "resource": "" }
q2468
AbstractFormValidator.callAfterFieldValidationMethod
train
private function callAfterFieldValidationMethod(Field $field) { $functionName = lcfirst($field->getName() . 'Validated'); if (method_exists($this, $functionName)) { call_user_func([$this, $functionName]); } }
php
{ "resource": "" }
q2469
FieldsValidationJavaScriptAssetHandler.getJavaScriptCode
train
public function getJavaScriptCode() { $fieldsJavaScriptCode = []; $formConfiguration = $this->getFormObject()->getConfiguration(); foreach ($formConfiguration->getFields() as $field) { $fieldsJavaScriptCode[] = $this->processField($field); } $formName = GeneralU...
php
{ "resource": "" }
q2470
FieldsValidationJavaScriptAssetHandler.processField
train
protected function processField($field) { $javaScriptCode = []; $fieldName = $field->getName(); foreach ($field->getValidation() as $validationName => $validationConfiguration) { $validatorClassName = $validationConfiguration->getClassName(); if (in_array(AbstractVa...
php
{ "resource": "" }
q2471
FieldsValidationJavaScriptAssetHandler.getInlineJavaScriptValidationCode
train
protected function getInlineJavaScriptValidationCode(Field $field, $validationName, Validation $validatorConfiguration) { $javaScriptValidationName = GeneralUtility::quoteJSvalue($validationName); $validatorName = addslashes($validatorConfiguration->getClassName()); $validatorConfigurationFi...
php
{ "resource": "" }
q2472
FieldsValidationJavaScriptAssetHandler.getValidationConfiguration
train
protected function getValidationConfiguration(Field $field, $validationName, Validation $validatorConfiguration) { $acceptsEmptyValues = ValidatorService::get()->validatorAcceptsEmptyValues($validatorConfiguration->getClassName()); /** @var FormzLocalizationJavaScriptAssetHandler $formzLocalization...
php
{ "resource": "" }
q2473
FormFactory.callBuilderMethod
train
private function callBuilderMethod($item) { $settings = new InputSettingsForm; if (!$settings->isValid($item)) { throw new InvalidInputSettingsException; } $settings->bind($item, new \stdClass); $className = $item[InputSettingsForm::TYPE_PARAM]; if(!clas...
php
{ "resource": "" }
q2474
FormFactory.callAdditionalOptionsMethod
train
private function callAdditionalOptionsMethod($item) { $settings = new InputSettingsForm; if (!$settings->isValid($item)) { throw new InvalidInputSettingsException; } $settings->bind($item, new \stdClass); $className = $item[InputSettingsForm::TYPE_PARAM]; ...
php
{ "resource": "" }
q2475
FormFactory.render
train
public function render() { $elements = []; foreach($this->builders as $builder) { $object = new $builder; $elements[] = [ 'element' => $object->initElement(), 'options' => $object->getAdditionalOptions() ]; } re...
php
{ "resource": "" }
q2476
InputSettings.getDataFromProvider
train
public function getDataFromProvider() { $select = $this->get(self::DATA_PARAM); if(is_null($select->getValue())) { return array(); } $classname = $select->getValue(); if (!class_exists($classname) || !array_key_exists($classname, $select->getOptions())) { ...
php
{ "resource": "" }
q2477
InputSettings.addDataProviderInput
train
public function addDataProviderInput() { $input = (new Select(self::DATA_PARAM)) ->setOptions(array(null => '---')); $dataProviderClasses = array(); foreach ($this->di->get('config')->formFactory->dataProviders as $classname) { $provider = new $classname; ...
php
{ "resource": "" }
q2478
CacheService.getCacheInstance
train
public function getCacheInstance() { if (null === $this->cacheInstance) { $this->cacheInstance = $this->cacheManager->getCache(self::CACHE_IDENTIFIER); } return $this->cacheInstance; }
php
{ "resource": "" }
q2479
CacheService.getFormCacheIdentifier
train
public function getFormCacheIdentifier($formClassName, $formName) { $shortClassName = end(explode('\\', $formClassName)); return StringService::get()->sanitizeString($shortClassName . '-' . $formName); }
php
{ "resource": "" }
q2480
CacheService.clearCacheCommand
train
public function clearCacheCommand($parameters) { if (in_array($parameters['cacheCmd'], ['all', 'system'])) { $files = $this->getFilesInPath(self::GENERATED_FILES_PATH . '*'); foreach ($files as $file) { $this->clearFile($file); } } }
php
{ "resource": "" }
q2481
View.render
train
public static function render($file, $ex) : void { if (php_sapi_name() === 'cli') { exit(json_encode($ex)); } http_response_code(500); require ouch_views($file); exit(1); //stop execution on first error }
php
{ "resource": "" }
q2482
TaxonomyController.deleteDestroy
train
public function deleteDestroy($id) { $vocabulary = $this->vocabulary->find($id); $terms = $vocabulary->terms->lists('id')->toArray(); TermRelation::whereIn('term_id',$terms)->delete(); Term::destroy($terms); $this->vocabulary->destroy($id); return response()->json(['OK']); }
php
{ "resource": "" }
q2483
TaxonomyController.putUpdate
train
public function putUpdate(Request $request, $id) { $this->validate($request, isset($this->vocabulary->rules_create) ? $this->vocabulary->rules_create : $this->vocabulary->rules); $vocabulary = $this->vocabulary->findOrFail($id); $vocabulary->update(Input::only('name')); return Redirect::to(action('\De...
php
{ "resource": "" }
q2484
FormObjectConfiguration.getConfigurationObject
train
public function getConfigurationObject() { if (null === $this->configurationObject || $this->lastConfigurationHash !== $this->formObject->getHash() ) { $this->lastConfigurationHash = $this->formObject->getHash(); $this->configurationObject = $this->getConfiguratio...
php
{ "resource": "" }
q2485
FormObjectConfiguration.getConfigurationValidationResult
train
public function getConfigurationValidationResult() { if (null === $this->configurationValidationResult || $this->lastConfigurationHash !== $this->formObject->getHash() ) { $configurationObject = $this->getConfigurationObject(); $this->configurationValidationResult...
php
{ "resource": "" }
q2486
FormObjectConfiguration.refreshConfigurationValidationResult
train
protected function refreshConfigurationValidationResult(ConfigurationObjectInstance $configurationObject) { $result = new Result; $formzConfigurationValidationResult = $this->configurationFactory ->getFormzConfiguration() ->getValidationResult(); $result->merge($form...
php
{ "resource": "" }
q2487
FormObjectConfiguration.sanitizeConfiguration
train
protected function sanitizeConfiguration(array $configuration) { // Removing configuration of fields which do not exist for this form. $sanitizedFieldsConfiguration = []; $fieldsConfiguration = (isset($configuration['fields'])) ? $configuration['fields'] : []; ...
php
{ "resource": "" }
q2488
Sdk.getTool
train
public function getTool($name) { if (!isset($this->tools[$name])) { $this->tools[$name] = $this->createTool($name); } return $this->tools[$name]; }
php
{ "resource": "" }
q2489
InstanceService.reset
train
public function reset() { foreach (array_keys($this->objectInstances) as $className) { if ($className !== self::class) { unset($this->objectInstances[$className]); } } }
php
{ "resource": "" }
q2490
ClassViewHelper.initializeClassNames
train
protected function initializeClassNames() { list($this->classNameSpace, $this->className) = GeneralUtility::trimExplode('.', $this->arguments['name']); if (false === in_array($this->classNameSpace, self::$acceptedClassesNameSpace)) { throw InvalidEntryException::invalidCssClassNamespace...
php
{ "resource": "" }
q2491
ClassViewHelper.initializeFieldName
train
protected function initializeFieldName() { $this->fieldName = $this->arguments['field']; if (empty($this->fieldName) && $this->fieldService->fieldContextExists() ) { $this->fieldName = $this->fieldService ->getCurrentField() ->getName(...
php
{ "resource": "" }
q2492
ClassViewHelper.initializeClassValue
train
protected function initializeClassValue() { $classesConfiguration = $this->formService ->getFormObject() ->getConfiguration() ->getRootConfiguration() ->getView() ->getClasses(); /** @var ViewClass $class */ $class = ObjectAccess::...
php
{ "resource": "" }
q2493
ClassViewHelper.getFormResultClass
train
protected function getFormResultClass() { $result = ''; $formObject = $this->formService->getFormObject(); if ($formObject->formWasSubmitted() && $formObject->hasFormResult() ) { $fieldResult = $formObject->getFormResult()->forProperty($this->fieldName); ...
php
{ "resource": "" }
q2494
ConditionParserFactory.parse
train
public function parse(ActivationInterface $activation) { $hash = 'condition-tree-' . HashService::get()->getHash(serialize([ $activation->getExpression(), $activation->getConditions() ])); if (false === array_key_exists($hash, $this->trees)) {...
php
{ "resource": "" }
q2495
RouteLoader.loadRoutes
train
public function loadRoutes(App $slim, array $routes) { foreach ($routes as $name => $details) { if ($children = $this->nullable('routes', $details)) { $middlewares = $this->nullable('stack', $details) ?: []; $prefix = $this->nullable('route', $details) ?: ''; ...
php
{ "resource": "" }
q2496
RouteLoader.loadRoute
train
private function loadRoute(App $slim, $name, array $details) { $methods = $this->methods($details); $pattern = $this->nullable('route', $details); $stack = $this->nullable('stack', $details) ?: []; $controller = array_pop($stack); $route = $slim->map($methods, $pattern, $co...
php
{ "resource": "" }
q2497
ErrorTrait.fail
train
protected function fail($message): void { if (is_string($message)) { $message = new RuntimeException($message); } $this->errors[] = $message->getMessage(); throw $message; }
php
{ "resource": "" }
q2498
JsonToHtml.toHtml
train
public function toHtml($json) { // convert the json to an associative array $input = json_decode($json, true); $html = ''; // loop trough the data blocks foreach ($input['data'] as $block) { $html .= $this->convert(new SirTrevorBlock($block['type'], $block['data'...
php
{ "resource": "" }
q2499
JsonToHtml.convert
train
private function convert(SirTrevorBlock $block) { foreach ($this->converters as $converter) { if ($converter->matches($block->getType())) { return $converter->toHtml($block->getData()); } } }
php
{ "resource": "" }