_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 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 & (int)0x80000000) {
$lo &= (int)0x7fffffff;
$lo += 0x80000000;
}
$value = $hi * 4294967296 + $lo;
if ($isNeg) {
$value = 0 - $value;
}
} else {
if ($arr[2] & 0x80000000) {
$arr[2] = $arr[2] & 0xffffffff;
}
if ($arr[1] & 0x80000000) {
$arr[1] = $arr[1] & 0xffffffff;
$arr[1] = $arr[1] ^ 0xffffffff;
$arr[2] = $arr[2] ^ 0xffffffff;
$value = 0 - $arr[1]*4294967296 - $arr[2] - 1;
} else {
$value = $arr[1]*4294967296 + $arr[2];
}
}
return $value;
} | 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_LEFT);
}
return $uuid;
} | 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) {
continue;
}
if ($field instanceof \atk4\data\Field_SQL_Expression) {
continue;
}
if ($field->short_name == $m->id_field) {
$this->id($field->actual ?: $field->short_name);
continue;
}
$this->field($field->actual ?: $field->short_name, ['type' => $field->type]); // todo add more options here
}
return $m;
} | 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'])) {
foreach ($this->args['newField'] as $field => $option) {
$result[] = 'add column '.$this->_render_one_field($field, $option);
}
}
if (isset($this->args['alterField'])) {
foreach ($this->args['alterField'] as $field => $option) {
$result[] = 'change column '.$this->_escape($field).' '.$this->_render_one_field($field, $option);
}
}
return implode(', ', $result);
} | 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') {
$type = 'integer';
}
if ($type == 'decimal') {
$type = 'float';
}
if ($type == 'longtext' || $type == 'longblob') {
$type = 'text';
}
return $type;
} | 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';
$len = '8';
break;
case 'text':
$type = 'longtext';
break;
case 'array':
case 'object':
$type = 'longtext';
break;
default:
$type = 'varchar';
$len = '255';
break;
}
$len = $options['len'] ?? $len;
return $len !== null ? $type.'('.$len.')' : $type;
} | 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 = $this->getModelFieldType($row['type']);
$this->field($row['name'], ['type'=>$type]);
}
return $has_fields;
} | 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 Exception([
ucfirst($what).' alias should be unique',
'alias' => $alias,
]);
}
$this->args[$what][$alias] = $value;
}
} | 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, $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) {
$this->mergeMessages($exception, __FUNCTION__);
}
// Get finder errors and warnings, if any
$this->mergeMessages($finder, __FUNCTION__);
$this->mergeMessages($cache, __FUNCTION__);
// Re-throw finder exception
if ($exception) {
throw $exception;
}
if ($cache && $cacheKey) {
$cache->writeTo($cacheKey, $result);
}
return $result;
} | 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);
} catch (InvalidArgumentException $exception) {
$this->mergeMessages($exception, __FUNCTION__);
}
$this->mergeMessages($parser, __FUNCTION__);
$this->mergeMessages($cache, __FUNCTION__);
// Re-throw parser exception
if ($exception) {
throw $exception;
}
if ($cache && $cacheKey) {
$cache->writeTo($cacheKey, $result, ['path' => $path]);
}
return $result;
} | 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));
return;
}
if ($source instanceof ErrorAwareInterface) {
$this->errors = array_merge($this->errors, $this->formatMessages($source->getErrors(), $caller));
$this->warnings = array_merge($this->warnings, $this->formatMessages($source->getWarnings(), $caller));
return;
}
$this->errors[] = "Cannot merge messages from [" . get_class($source) . "]";
} | 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(), $moduleName, null, $options))->parseToArray();
if (empty($config['table']) || empty($config['table']['type'])) {
return false;
}
return true;
} | 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);
return empty($diff);
} | 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) : false;
} | 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()
->getAssetHandler(FieldsActivationCssAssetHandler::class);
$css = $errorContainerDisplayCssAssetHandler->getErrorContainerDisplayCss() . LF;
$css .= $fieldsActivationCssAssetHandler->getFieldsActivationCss();
return $css;
}
);
$this->assetHandlerConnectorManager
->getPageRenderer()
->addCssFile(StringService::get()->getResourceRelativePath($filePath));
return $this;
} | php | {
"resource": ""
} |
q2428 | AssetHandlerConnectorManager.includeDefaultAssets | train | public function includeDefaultAssets()
{
if (false === $this->assetHandlerConnectorStates->defaultAssetsWereIncluded()) {
$this->assetHandlerConnectorStates->markDefaultAssetsAsIncluded();
$this->getJavaScriptAssetHandlerConnector()->includeDefaultJavaScriptFiles();
$this->getCssAssetHandlerConnector()->includeDefaultCssFiles();
}
return $this;
} | 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,
0,
22
);
$identifier .= '-' . md5($formObject->getHash() . $formObject->getName());
return CacheService::GENERATED_FILES_PATH . $identifier;
} | 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);
if (null !== $result) {
throw FileCreationFailedException::fileCreationFailed($absolutePath, $result);
}
}
return $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 = $pageController->config['config']['language'];
}
} else {
$backendUser = Core::get()->getBackendUser();
if (strlen($backendUser->uc['lang']) > 0) {
$languageKey = $backendUser->uc['lang'];
}
}
return $languageKey;
} | 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->warnings[] = $e->getMessage();
return (string)json_encode($this->getEmptyResult());
}
return (string)file_get_contents($path);
} | 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 empty schema (empty() does not work on objects)
$schemaArray = Convert::objectToArray($schema);
if (empty($schemaArray)) {
if ($config['allowEmptySchema'] === false) {
throw new JsonValidationException('Empty schema is not allowed.');
}
$this->warnings[] = "Skipping validation with empty schema";
return;
}
$this->runValidator($data, $schema);
} | 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->schema->getSchemaPath()}` cannot be read", 0, $e);
}
return $schema;
} | 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) {
$this->errors[] = sprintf('[%s]: %s', $error['pointer'], $error['message']);
}
throw new JsonValidationException('Failed to validate json data against the schema.');
}
} | 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();
/*
* Including JavaScript and CSS assets in the page renderer.
*/
$this->handleAssets();
$this->timeTracker->logTime('pre-render');
/*
* Getting the result of the original Fluid `FormViewHelper` rendering.
*/
$result = $this->getParentRenderResult($arguments);
/*
* Language files need to be included at the end, because they depend on
* what was used by previous assets.
*/
$this->getAssetHandlerConnectorManager()
->getJavaScriptAssetHandlerConnector()
->includeLanguageJavaScriptFiles();
return $result;
} | 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($class) ? $class . ' ' : '') . $formDefaultClass;
$this->tag->addAttribute('class', $class);
}
} | 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);
}
if (true === $this->formObject->formWasSubmitted()) {
$dataAttributes += [DataAttributesAssetHandler::getFieldSubmissionDone() => '1'];
$dataAttributes += $dataAttributesAssetHandler->getFieldsValidDataAttributes();
$dataAttributes += $dataAttributesAssetHandler->getFieldsMessagesDataAttributes();
}
$this->tag->addAttributes($dataAttributes);
} | php | {
"resource": ""
} |
q2441 | FormViewHelper.handleAssets | train | protected function handleAssets()
{
$assetHandlerConnectorManager = $this->getAssetHandlerConnectorManager();
// Default FormZ assets.
$assetHandlerConnectorManager->includeDefaultAssets();
// JavaScript assets.
$assetHandlerConnectorManager->getJavaScriptAssetHandlerConnector()
->generateAndIncludeFormzConfigurationJavaScript()
->generateAndIncludeJavaScript()
->generateAndIncludeInlineJavaScript()
->includeJavaScriptValidationAndConditionFiles();
// CSS assets.
$assetHandlerConnectorManager->getCssAssetHandlerConnector()
->includeGeneratedCss();
} | 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);
$templatePath = GeneralUtility::getFileAbsFileName('EXT:' . ExtensionService::get()->getExtensionKey() . '/Resources/Public/StyleSheets/Form.ErrorBlock.css');
$this->pageRenderer->addCssFile(StringService::get()->getResourceRelativePath($templatePath));
return $view->render();
} | 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) {
throw InvalidOptionValueException::formViewHelperWrongFormValueObjectType($objectArgument);
}
$formClassName = $this->getFormClassName();
if (false === $objectArgument instanceof $formClassName) {
throw InvalidOptionValueException::formViewHelperWrongFormValueClassName($formClassName, $objectArgument);
}
return $objectArgument;
} | 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>";
$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 it fails to parse we
// retry with the XML parser instead
$prev_use_errors = libxml_use_internal_errors(true);
if ($doc->loadHTML($html)) {
$root_node = $doc->documentElement->lastChild->lastChild;
}
else if ($doc->loadXML($html)) {
$root_node = $doc->documentElement;
}
else {
libxml_use_internal_errors($prev_use_errors);
throw new InvalidHtmlException;
}
libxml_use_internal_errors($prev_use_errors);
}
list($text, $_, $opts) = static::_truncate_node($doc, $root_node, $length, $opts);
$text = ht_substr(ht_substr($text, 0, -6), 5);
return $text;
} | 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']
];
if (in_array(FormzAbstractValidator::class, class_parents($validatorClassName))) {
$validatorData['formzValidator'] = true;
$validatorData['supportedMessages'] = $validatorProperties['supportedMessages'];
$validatorData['supportsAllMessages'] = $validatorProperties['supportsAllMessages'];
}
$this->validatorsData[$validatorClassName] = $validatorData;
}
}
return $this->validatorsData[$validatorClassName];
} | 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 package dir, remove the directory
if (count(glob("$dir/*.php")) === 0)
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
{
shell_exec("rd /S /Q $dir");
}
else
{
shell_exec("rm -Rf $dir");
}
}
} | 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))
? implode(' ', $value)
: $value;
if (false === empty($value)) {
$result[self::getFieldDataValueKey($fieldName)] = $value;
}
}
}
return $result;
} | 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))
) {
$result += $this->getFieldErrorMessages($fieldName, $fieldResult);
$result += $this->getFieldWarningMessages($fieldName, $fieldResult);
$result += $this->getFieldNoticeMessages($fieldName, $fieldResult);
}
}
return $result;
} | 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)
&& false === $formResult->forProperty($fieldName)->hasErrors()
) {
$result[self::getFieldDataValidKey($fieldName)] = '1';
}
}
return $result;
} | 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),
$stringService->sanitizeString($validationName),
$stringService->sanitizeString($messageKey)
]
);
} | 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('<param', '<parameter', $content);
$content = str_replace('</param', '</parameter', $content);
$crawler = new Crawler();
$crawler->addContent($content, 'xml');
foreach ($crawler->filterXPath('//function') as $node) {
$method = $this->getMethod($node);
$this->specification->addMethod($method);
}
} | 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) {
$method->addParameter($this->getParameter($node));
}
// Return
$returnNodes = $crawler->filterXPath('//return');
if (count($returnNodes) > 1) {
throw new \Exception("Should not be more than one return node");
} elseif (count($returnNodes) == 1) {
$returnNodes->rewind();
list($type, $description) = $this->getReturn($returnNodes->current());
$method->setReturnType($type);
$method->setReturnDescription($description);
}
return $method;
} | 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');
$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 = base64_encode($encrypted);
}
$patch[$name] = $encrypted;
}
if (!empty($patch)) {
$accessible = array_fill_keys(array_keys($patch), true);
$entity = $table->patchEntity($entity, $patch, [
'accessibleFields' => $accessible,
]);
}
return $entity;
} | 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.');
}
}
return $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) {
$entity->set([$field => $value], ['guard' => false]);
$entity->setDirty($field, false);
}
}
return $entity;
} | 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 === false) {
return null;
}
}
$decrypted = Security::decrypt($encoded, $encryptionKey);
if ($decrypted === false) {
throw new RuntimeException("Unable to decypher `{$field}`. Check your enryption key.");
}
return $decrypted;
} | 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;
}
$decrypt = $fields[$field]['decrypt'];
if (is_callable($decrypt)) {
$decrypt = $decrypt($entity, $field);
}
return $decrypt;
} | 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;
$values = [];
}
$values = array_merge($defaults, $values);
$result[$field] = $values;
}
return $result;
} | 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 = $this->getFormValidatorExecutor($form);
} | 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($this->result);
return $this->result;
} | 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->callAfterFieldValidationMethod($field);
});
$this->afterValidationProcess();
if ($this->result->hasErrors()) {
// Storing the form for possible third party further usage.
FormService::addFormWithErrors($form);
}
} | 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 = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());
$fieldsJavaScriptCode = implode(CRLF, $fieldsJavaScriptCode);
return <<<JS
(function() {
Fz.Form.get(
$formName,
function(form) {
var field = null;
$fieldsJavaScriptCode
}
);
})();
JS;
} | 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);
}
}
$javaScriptCode = implode(CRLF, $javaScriptCode);
$javaScriptFieldName = GeneralUtility::quoteJSvalue($fieldName);
return <<<JS
/***************************
* Field: "$fieldName"
****************************/
field = form.getFieldByName($javaScriptFieldName);
if (null !== field) {
$javaScriptCode
}
JS;
} | 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);
return <<<JS
/*
* Validation rule "$validationName"
*/
field.addValidation($javaScriptValidationName, '$validatorName', $validatorConfigurationFinal);
JS;
} | 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);
return ArrayService::get()->arrayToJavaScriptJson([
'options' => $validatorConfiguration->getOptions(),
'messages' => $messages,
'settings' => $validatorConfiguration->toArray(),
'acceptsEmptyValues' => $acceptsEmptyValues
]);
} | 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();
}
if(!in_array($className, $this->builders)) {
throw new NotDefinedException();
}
$method = new \ReflectionMethod($className, self::BUILDER_METHOD);
return $method->invokeArgs(new $className, array($settings));
} | 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();
return $builderObject->getAdditionalOptions();
$setMethod = new \ReflectionMethod($className, self::INIT_ELEMENT_METHOD);
$getMethod = new \ReflectionMethod($className, self::ADDITIONAL_OPTIONS_METHOD);
$setMethod->invokeArgs($builderObject, array($settings));
return $getMethod->invokeArgs($builderObject, array($settings));
} | 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()
];
}
return $elements;
} | 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())) {
throw new NotFoundException;
}
return (new $classname)->getData();
} | 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) {
$dataProviderClasses[$classname] = $provider->getName();
}
}
$input
->addOptions($dataProviderClasses)
->setLabel('Data provider');
$this->add($input);
} | 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('\Devfactory\Taxonomy\Controllers\TaxonomyController@getIndex'))->with('success', 'Updated');
} | 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->getConfigurationObjectFromCache();
}
return $this->configurationObject;
} | php | {
"resource": ""
} |
q2485 | FormObjectConfiguration.getConfigurationValidationResult | train | public function getConfigurationValidationResult()
{
if (null === $this->configurationValidationResult
|| $this->lastConfigurationHash !== $this->formObject->getHash()
) {
$configurationObject = $this->getConfigurationObject();
$this->configurationValidationResult = $this->refreshConfigurationValidationResult($configurationObject);
}
return $this->configurationValidationResult;
} | php | {
"resource": ""
} |
q2486 | FormObjectConfiguration.refreshConfigurationValidationResult | train | protected function refreshConfigurationValidationResult(ConfigurationObjectInstance $configurationObject)
{
$result = new Result;
$formzConfigurationValidationResult = $this->configurationFactory
->getFormzConfiguration()
->getValidationResult();
$result->merge($formzConfigurationValidationResult);
$result->forProperty('forms.' . $this->formObject->getClassName())
->merge($configurationObject->getValidationResult());
return $result;
} | 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) {
$sanitizedFieldsConfiguration[$property] = (isset($fieldsConfiguration[$property]))
? $fieldsConfiguration[$property]
: [];
}
$configuration['fields'] = $sanitizedFieldsConfiguration;
return $configuration;
} | 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($this->arguments['name'], 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();
}
if (null === $this->fieldName) {
throw EntryNotFoundException::classViewHelperFieldNotFound($this->arguments['name']);
}
} | 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)) {
throw UnregisteredConfigurationException::cssClassNameNotFound($this->arguments['name'], $this->classNameSpace, $this->className);
}
$this->classValue = $class->getItem($this->className);
} | 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);
$result = $this->getPropertyResultClass($fieldResult);
}
return $result;
} | 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)) {
$this->trees[$hash] = $this->getConditionTree($hash, $activation);
}
return $this->trees[$hash];
} | 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);
};
$group = $slim->group($prefix, $groupLoader);
while ($mw = array_pop($middlewares)) {
$group->add($mw);
}
} else {
$this->loadRoute($slim, $name, $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, $controller);
$route->setName($name);
while ($middleware = array_pop($stack)) {
$route->add($middleware);
}
return $route;
} | 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']));
}
return $html;
} | 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": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.