_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
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 negative if ($isNeg) { $hi = ~$hi & (int)0xffffffff; $lo = ~$lo & (int)0xffffffff; if ($lo == (int)0xffffffff) { $hi++; $lo = 0; } else { $lo++; } } // Force 32bit words in excess of 2G to pe positive - we deal wigh sign // explicitly below if ($hi & (int)0x80000000) { $hi &= (int)0x7fffffff; $hi += 0x80000000; } if ($lo
php
{ "resource": "" }
q2401
DataStream.readBytes
train
public function readBytes($isCollectionElement = false) { if ($isCollectionElement) $this->readShort(); $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) {
php
{ "resource": "" }
q2403
DataStream.readList
train
public function readList($valueType) { $list = array(); $count = $this->readShort();
php
{ "resource": "" }
q2404
DataStream.readMap
train
public function readMap($keyType, $valueType) { $map = array(); $count = $this->readShort(); for ($i = 0; $i < $count;
php
{ "resource": "" }
q2405
DataStream.readFloat
train
public function readFloat($isCollectionElement = false) { if ($isCollectionElement) { $this->readShort(); }
php
{ "resource": "" }
q2406
DataStream.readDouble
train
public function readDouble($isCollectionElement = false) { if ($isCollectionElement) { $this->readShort(); }
php
{ "resource": "" }
q2407
DataStream.readInet
train
public function readInet($isCollectionElement = false) { if ($isCollectionElement) { $data = $this->read($this->readShort());
php
{ "resource": "" }
q2408
DataStream.readVarint
train
public function readVarint($isCollectionElement = false) { if($isCollectionElement) { $length = $this->readShort(); } else { $length = strlen($this->data); }
php
{ "resource": "" }
q2409
DataStream.readDecimal
train
public function readDecimal($isCollectionElement = false) { if ($isCollectionElement) { $this->readShort(); } $scale = $this->readInt(); $value = $this->readVarint($isCollectionElement);
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) { continue; } if ($field instanceof \atk4\data\Field_SQL_Expression) { continue;
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]); }
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'])) { foreach ($this->args['newField'] as $field => $option) { $result[] = 'add column '.$this->_render_one_field($field, $option); } } if (isset($this->args['alterField'])) {
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') { $type = 'boolean'; } if ($type == 'int') {
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'; break; case 'money': $type = 'decimal'; $len = '12,2'; break; case 'float': $type = 'decimal'; $len = '16,6'; break; case 'date': case 'datetime': $type = 'date'; break; case 'time': $type = 'varchar';
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; }
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'] =
php
{ "resource": "" }
q2417
Migration._render_one_field
train
protected function _render_one_field($field, $options) { $name = $options['name'] ?? $field;
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
php
{ "resource": "" }
q2419
ModuleConfig.getFinder
train
protected function getFinder(): PathFinderInterface { $result
php
{ "resource": "" }
q2420
ModuleConfig.createSchema
train
public function createSchema(array $config = []): SchemaInterface { $path = rtrim(Configure::read('ModuleConfig.schemaPath'), '/'); $file = $this->configType . '.json';
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, $validate]); $result = $cache->readFrom($cacheKey); if ($result !== false) { return $result; } // Real response $finder = $this->getFinder(); $result = $finder->find($this->module, $this->configFile, $validate); } catch (InvalidArgumentException $exception) {
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([$path]); $result = $cache->readFrom($cacheKey); if ($result !== false) { return $result; } // Real response $parser = $this->getParser(); $result = $parser->parse($path);
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(), $caller));
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 =
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();
php
{ "resource": "" }
q2426
WebhookService.readEvent
train
public function readEvent() { $rawRequestBody = $this->httpClient->getRawRequest(); $webhookEvent = !empty($rawRequestBody['webhook_event']) ? json_decode($rawRequestBody['webhook_event'], true)
php
{ "resource": "" }
q2427
CssAssetHandlerConnector.includeGeneratedCss
train
public function includeGeneratedCss() { $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath() . '.css'; $this->assetHandlerConnectorManager->createFileInTemporaryDirectory( $filePath, function () { /** @var MessageContainerDisplayCssAssetHandler $errorContainerDisplayCssAssetHandler */ $errorContainerDisplayCssAssetHandler = $this->assetHandlerConnectorManager ->getAssetHandlerFactory() ->getAssetHandler(MessageContainerDisplayCssAssetHandler::class); /** @var FieldsActivationCssAssetHandler $fieldsActivationCssAssetHandler */ $fieldsActivationCssAssetHandler = $this->assetHandlerConnectorManager ->getAssetHandlerFactory()
php
{ "resource": "" }
q2428
AssetHandlerConnectorManager.includeDefaultAssets
train
public function includeDefaultAssets() { if (false === $this->assetHandlerConnectorStates->defaultAssetsWereIncluded()) { $this->assetHandlerConnectorStates->markDefaultAssetsAsIncluded();
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 . '-' : ''; $identifier = substr( 'fz-' . $prefix . $formIdentifier,
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 = $this->writeTemporaryFile($absolutePath, $content);
php
{ "resource": "" }
q2431
ContextService.getContextHash
train
public function getContextHash() { return ($this->environmentService->isEnvironmentInFrontendMode()) ? 'fe-' . Core::get()->getPageController()->id
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 = $pageController->config['config']['language']; }
php
{ "resource": "" }
q2433
Select.addOptions
train
public function addOptions(array $options) { $existingOptions = $this->getOptions(); $newOptions = empty($existingOptions) ? $options
php
{ "resource": "" }
q2434
Parser.getDataFromPath
train
protected function getDataFromPath(string $path): string { $isPathRequired = $this->getConfig('pathRequired'); try { Utility::validatePath($path); } catch (InvalidArgumentException $e) {
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['allowEmptyData'] === false) { throw new JsonValidationException('Empty data is not allowed.'); } $this->warnings[] = "Skipping validation of empty data"; return; } // No need to validate with
php
{ "resource": "" }
q2436
Parser.readSchema
train
protected function readSchema(): \stdClass { $schema = $this->getEmptyResult(); try { $schema = $this->getSchema()->read(); } catch (InvalidArgumentException
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: * when the form was actually submitted by the user, or when the * argument `object` of the view helper is filled with a form instance. */ $this->formService->activateFormContext(); /* * If the form was submitted, applying custom behaviours on its fields. */ $this->formService->applyBehavioursOnSubmittedForm($this->controllerContext); /* * Adding the default class configured in TypoScript configuration to * the form HTML tag. */ $this->addDefaultClass(); /* * Handling data attributes that are added to the form HTML tag, * depending on several parameters. */ $this->handleDataAttributes(); /* *
php
{ "resource": "" }
q2439
FormViewHelper.addDefaultClass
train
protected function addDefaultClass() { $formDefaultClass = $this->formObject ->getConfiguration() ->getSettings() ->getDefaultClass(); $class = $this->tag->getAttribute('class'); if (false === empty($formDefaultClass)) {
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(); $formValidator = $this->getFormValidator($this->getFormObjectName()); $formResult = $formValidator->validateGhost($form); } else { $formResult = $this->formObject->getFormResult(); } $dataAttributes += $dataAttributesAssetHandler->getFieldsValuesDataAttributes($formResult); }
php
{ "resource": "" }
q2441
FormViewHelper.handleAssets
train
protected function handleAssets() { $assetHandlerConnectorManager = $this->getAssetHandlerConnectorManager(); // Default FormZ assets. $assetHandlerConnectorManager->includeDefaultAssets(); // JavaScript assets. $assetHandlerConnectorManager->getJavaScriptAssetHandlerConnector() ->generateAndIncludeFormzConfigurationJavaScript() ->generateAndIncludeJavaScript()
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/ConfigurationErrorBlock.html')); $layoutRootPath = StringService::get()->getExtensionRelativePath('Resources/Private/Layouts'); $view->setLayoutRootPaths([$layoutRootPath]); $view->assign('result', $result);
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($objectArgument); } if (false === $objectArgument instanceof FormInterface) {
php
{ "resource": "" }
q2444
FormViewHelper.getFormClassNameFromControllerAction
train
protected function getFormClassNameFromControllerAction() { return $this->controllerService->getFormClassNameFromControllerAction( $this->getControllerName(),
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>"; $root_node = null; // Parse using HTML5Lib if it's available. if (class_exists('HTML5Lib\\Parser')) { try { $doc = \HTML5Lib\Parser::parse($html); $root_node = $doc->documentElement->lastChild->lastChild; } catch (\Exception $e) { ; } } if ($root_node === null) { // HTML5Lib not available so we'll have to use DOMDocument // We'll only be able to parse HTML5 if it's valid XML $doc = new DOMDocument; $doc->formatOutput = false; $doc->preserveWhitespace = true; // loadHTML will fail with HTML5 tags (article, nav, etc) // so we need to suppress errors and if
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))) { $validatorReflection = new \ReflectionClass($validatorClassName); $validatorProperties = $validatorReflection->getDefaultProperties(); unset($validatorReflection); $validatorData = [ 'supportedOptions' => $validatorProperties['supportedOptions'], 'acceptsEmptyValues' => $validatorProperties['acceptsEmptyValues']
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 $dst/"); } // If there are no PHP files left in the
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(); if (false === $formResult->fieldIsDeactivated($field)) { $value = ObjectAccess::getProperty($formInstance, $fieldName); $value = (is_array($value))
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 === $formConfiguration->hasField($fieldName) && false === $formResult->fieldIsDeactivated($formConfiguration->getField($fieldName)) ) {
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(); if (false === $formResult->fieldIsDeactivated($field)
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))
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('<param', '<parameter', $content); $content = str_replace('</param', '</parameter', $content);
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_ACCESSOR : Method::TYPE_ACTION ); // Description $descriptions = $crawler->filterXPath('//comment'); if (count($descriptions) !== 1) { throw new \Exception('Only one comment expected'); } $descriptions->rewind(); $description = $this->getInner($descriptions->current()); $method->setDescription($description); // Parameters foreach ($crawler->filterXPath('//parameter') as $node) {
php
{ "resource": "" }
q2455
XmlLoader.getParameter
train
protected function getParameter(\DOMNode $node) { $name = $node->getAttribute('name'); $parameter = new Parameter($name);
php
{ "resource": "" }
q2456
XmlLoader.getInner
train
protected function getInner(\DOMNode $node) { $c14n = $node->C14N(); $begin = strpos($c14n, '>'); $end = strrpos($c14n, '<');
php
{ "resource": "" }
q2457
EncryptedFieldsBehavior.beforeSave
train
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject
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'); $table = $this->getTable(); $patch = []; foreach ($fields as $name => $field) { if (!$table->hasField($name)) { continue; } $value = $entity->get($name); if ($value === null || is_resource($value)) { continue; } $encrypted = Security::encrypt($value, $encryptionKey); if ($base64 === true) { $encrypted =
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)) {
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); if (empty($encoded) || $encoded === false) { return null; } if ($base64 === true) { $encoded = base64_decode($encoded, true); if ($encoded ===
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 = $this->getFields(); if (!isset($fields[$field])) { return false;
php
{ "resource": "" }
q2463
EncryptedFieldsBehavior.getFields
train
protected function getFields(): array { $fields = $this->getConfig('fields'); $defaults = [ 'decrypt' => false, ]; $result = []; foreach ($fields as $field =>
php
{ "resource": "" }
q2464
AbstractFormValidator.initializeValidator
train
private function initializeValidator($form) { if (false === $form instanceof FormInterface) { throw InvalidArgumentTypeException::validatingWrongFormType(get_class($form)); }
php
{ "resource": "" }
q2465
AbstractFormValidator.validate
train
final public function validate($form) { $this->initializeValidator($form); $formObject = $this->formValidatorExecutor->getFormObject(); $formObject->markFormAsSubmitted(); $formObject->setForm($form);
php
{ "resource": "" }
q2466
AbstractFormValidator.validateGhost
train
public function validateGhost($form, $initialize = true) { if ($initialize) { $this->initializeValidator($form);
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->callAfterFieldValidationMethod($field); }); $this->afterValidationProcess();
php
{ "resource": "" }
q2468
AbstractFormValidator.callAfterFieldValidationMethod
train
private function callAfterFieldValidationMethod(Field $field) { $functionName = lcfirst($field->getName() . 'Validated');
php
{ "resource": "" }
q2469
FieldsValidationJavaScriptAssetHandler.getJavaScriptCode
train
public function getJavaScriptCode() { $fieldsJavaScriptCode = []; $formConfiguration = $this->getFormObject()->getConfiguration(); foreach ($formConfiguration->getFields() as $field) { $fieldsJavaScriptCode[] = $this->processField($field);
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(AbstractValidator::class, class_parents($validatorClassName))) { $javaScriptCode[] = (string)$this->getInlineJavaScriptValidationCode($field, $validationName, $validationConfiguration); }
php
{ "resource": "" }
q2471
FieldsValidationJavaScriptAssetHandler.getInlineJavaScriptValidationCode
train
protected function getInlineJavaScriptValidationCode(Field $field, $validationName, Validation $validatorConfiguration) { $javaScriptValidationName = GeneralUtility::quoteJSvalue($validationName); $validatorName = addslashes($validatorConfiguration->getClassName()); $validatorConfigurationFinal = $this->getValidationConfiguration($field, $validationName, $validatorConfiguration); $validatorConfigurationFinal = $this->handleValidationConfiguration($validatorConfigurationFinal);
php
{ "resource": "" }
q2472
FieldsValidationJavaScriptAssetHandler.getValidationConfiguration
train
protected function getValidationConfiguration(Field $field, $validationName, Validation $validatorConfiguration) { $acceptsEmptyValues = ValidatorService::get()->validatorAcceptsEmptyValues($validatorConfiguration->getClassName()); /** @var FormzLocalizationJavaScriptAssetHandler $formzLocalizationJavaScriptAssetHandler */ $formzLocalizationJavaScriptAssetHandler = $this->assetHandlerFactory->getAssetHandler(FormzLocalizationJavaScriptAssetHandler::class); $messages = $formzLocalizationJavaScriptAssetHandler->getTranslationKeysForFieldValidation($field, $validationName);
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(!class_exists($className)) { throw new NotFoundException();
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]; if(!class_exists($className)) { throw new NotFoundException(); } if(!in_array($className, $this->builders)) { throw new NotDefinedException(); } $builderObject = new $className; $builderObject->setAdditionalOptions();
php
{ "resource": "" }
q2475
FormFactory.render
train
public function render() { $elements = []; foreach($this->builders as $builder) { $object = new $builder; $elements[] = [ 'element' => $object->initElement(),
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();
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; if ($provider instanceof DataProviderInterface) {
php
{ "resource": "" }
q2478
CacheService.getCacheInstance
train
public function getCacheInstance() { if (null === $this->cacheInstance) {
php
{ "resource": "" }
q2479
CacheService.getFormCacheIdentifier
train
public function getFormCacheIdentifier($formClassName, $formName) { $shortClassName = end(explode('\\', $formClassName));
php
{ "resource": "" }
q2480
CacheService.clearCacheCommand
train
public function clearCacheCommand($parameters) { if (in_array($parameters['cacheCmd'], ['all', 'system'])) { $files = $this->getFilesInPath(self::GENERATED_FILES_PATH . '*');
php
{ "resource": "" }
q2481
View.render
train
public static function render($file, $ex) : void { if (php_sapi_name() === 'cli') { exit(json_encode($ex)); }
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();
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'));
php
{ "resource": "" }
q2484
FormObjectConfiguration.getConfigurationObject
train
public function getConfigurationObject() { if (null === $this->configurationObject || $this->lastConfigurationHash !== $this->formObject->getHash() ) { $this->lastConfigurationHash = $this->formObject->getHash();
php
{ "resource": "" }
q2485
FormObjectConfiguration.getConfigurationValidationResult
train
public function getConfigurationValidationResult() { if (null === $this->configurationValidationResult || $this->lastConfigurationHash !== $this->formObject->getHash() ) { $configurationObject = $this->getConfigurationObject();
php
{ "resource": "" }
q2486
FormObjectConfiguration.refreshConfigurationValidationResult
train
protected function refreshConfigurationValidationResult(ConfigurationObjectInstance $configurationObject) { $result = new Result; $formzConfigurationValidationResult = $this->configurationFactory ->getFormzConfiguration() ->getValidationResult(); $result->merge($formzConfigurationValidationResult);
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'] : []; foreach ($this->formObject->getProperties() as $property) {
php
{ "resource": "" }
q2488
Sdk.getTool
train
public function getTool($name) { if (!isset($this->tools[$name])) {
php
{ "resource": "" }
q2489
InstanceService.reset
train
public function reset() { foreach (array_keys($this->objectInstances) as $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)) {
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::getProperty($classesConfiguration, $this->classNameSpace); if (false === $class->hasItem($this->className)) {
php
{ "resource": "" }
q2493
ClassViewHelper.getFormResultClass
train
protected function getFormResultClass() { $result = ''; $formObject = $this->formService->getFormObject(); if ($formObject->formWasSubmitted() && $formObject->hasFormResult() ) {
php
{ "resource": "" }
q2494
ConditionParserFactory.parse
train
public function parse(ActivationInterface $activation) { $hash = 'condition-tree-' . HashService::get()->getHash(serialize([ $activation->getExpression(), $activation->getConditions() ]));
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) ?: ''; $loader = [$this, 'loadRoutes']; $groupLoader = function () use ($slim, $children, $loader) { $loader($slim, $children);
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, $controller);
php
{ "resource": "" }
q2497
ErrorTrait.fail
train
protected function fail($message): void { if (is_string($message)) { $message = new RuntimeException($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) {
php
{ "resource": "" }
q2499
JsonToHtml.convert
train
private function convert(SirTrevorBlock $block) { foreach ($this->converters as $converter) {
php
{ "resource": "" }