Returns an 'error' response.

@param Settings $settings
@param Entry $entry
@return Response|null
553203
private function _returnError(Settings $settings, Entry $entry)
    {
        if ($this->hasEventHandlers(self::EVENT_AFTER_ERROR)) {
            $this->trigger(self::EVENT_AFTER_ERROR, new SaveEvent([
                'entry' => $entry
            ]));
        }

        if (Craft::$app->getRequest()->getAcceptsJson()) {
            return $this->asJson([
                'success' => false,
                'errors' => $entry->getErrors(),
            ]);
        }

        Craft::$app->getSession()->setError(Craft::t('guest-entries', 'Couldn’t save entry.'));

        // Send the entry back to the template
        Craft::$app->getUrlManager()->setRouteParams([
            'variables' => [$settings->entryVariable => $entry]
        ]);

        return null;
    }
1017179
public function getSettingsSave($section, $name, $value)
    {
        $uri = 'settings.save';
        $uriData = [
            'section' => $section,
            'name' => $name,
            'value' => $value
        ];

        try {
            $response = $this->_request(
                [
                    'uri' => $uri,
                    'type' => 'get',
                    'data' => $uriData
                ]
            );
        } catch (\Exception $e) {
            throw new InvalidException($e->getMessage());
        }

        return $response->getBody()->getContents();
    }
1141115
public function get_hyphenator( Settings $settings ) {
		$lang       = $settings['hyphenLanguage'];
		$exceptions = (array) $settings['hyphenationCustomExceptions'];
		$hyphenator = $this->cache->get_hyphenator( $lang );

		if ( null === $hyphenator ) {
			$hyphenator = new Hyphenator( $lang, $exceptions );
			$this->cache->set_hyphenator( $lang, $hyphenator );
		} else {
			$hyphenator->set_language( $lang ); // just for insurance.
			$hyphenator->set_custom_exceptions( $exceptions );
		}

		return $hyphenator;
	}
562684
private function _populateEntryModel(Section $section, SectionSettings $sectionSettings, Request $request): Entry
    {
        // Create and populate the entry
        $entry = new Entry([
            'sectionId' => $section->id,
            'authorId' => Db::idByUid('{{%elements}}', $sectionSettings->authorUid),
            'siteId' => $request->getBodyParam('siteId'),
            'typeId' => $request->getBodyParam('typeId') ?? $section->getEntryTypes()[0]->id,
            'title' => $request->getBodyParam('title'),
            'slug' => $request->getBodyParam('slug'),
            'enabled' => (bool)$sectionSettings->enabledByDefault,
            'enabledForSite' => (bool)$request->getBodyParam('enabledForSite', true),
            'newParentId' => $request->getBodyParam('parentId'),
        ]);

        if (($postDate = $request->getBodyParam('postDate')) !== null) {
            $entry->postDate = DateTimeHelper::toDateTime($postDate) ?: null;
        }

        if (($expiryDate = $request->getBodyParam('expiryDate')) !== null) {
            $entry->expiryDate = DateTimeHelper::toDateTime($expiryDate) ?: null;
        }

        $fieldsLocation = $request->getParam('fieldsLocation', 'fields');
        $entry->setFieldValuesFromRequest($fieldsLocation);

        return $entry;
    }
91458
private static function force_enable_settings(restore_controller $controller, array $settings) {
        $plan = $controller->get_plan();
        foreach ($settings as $config => $settingname) {
            $value = true;
            if ($plan->setting_exists($settingname)) {
                $setting = $plan->get_setting($settingname);
                // We do not allow this setting to be locked for a duplicate function.
                if ($setting->get_status() !== base_setting::NOT_LOCKED) {
                    $setting->set_status(base_setting::NOT_LOCKED);
                }
                $setting->set_value($value);
                $setting->set_status(base_setting::LOCKED_BY_CONFIG);
            } else {
                $controller->log('Unknown setting: ' . $settingname, BACKUP::LOG_DEBUG);
            }
        }
    }
443588
public function getJavascript(&$javascripts, Settings $settings)
    {
        if ($this->linktype == LinkConstants::LINK_JAVASCRIPT) {
            $javascripts[$this->getIdType() . $settings->getPrefix() . $this->getId()] = $this->javascript;
        }
    }
735321
protected static function validateSettings($settings)
    {
        if (!isset($settings['consumerKey']) || !isset($settings['consumerSecret'])) {
            return false;
        }
        $settings['token'] = isset($settings['token']) ? $settings['token'] : null;
        $settings['tokenSecret'] = isset($settings['tokenSecret']) ? $settings['tokenSecret'] : null;

        return $settings;
    }
714006
public function youTryToGetSettingWithinSection($setting, $section)
    {
        $this->responseValue = $this->settingService->section($section)->get($setting, 'null');
    }
543790
protected static function _validateConfig(array $entries)
    {
        $base = self::$_requires;
        foreach ($entries as $var=>$val) {
            if (in_array($var, $base)) {
                unset($base[array_search($var, $base)]);
            }
        }
        return (count($base)===0);
    }
65923
public function deserialize($data, Entry $entry, array $options = [])
    {
        $this->sipe('title', 'setTitle', $data, $entry);
        $this->sipe('status', 'setStatus', $data, $entry);

        if (isset($data['user']['id'])) {
            $user = $this->userRepo->findOneBy(['uuid' => $data['user']['id']]);

            if (!empty($user)) {
                $entry->setUser($user);
            }
        }
        /* TODO: checks rights */
        $this->deserializeCategories($entry, $data['categories']);
        $this->deserializeKeywords($entry, $data['keywords']);

        if (isset($data['clacoForm']['id'])) {
            $clacoForm = $this->clacoFormRepo->findOneBy(['uuid' => $data['clacoForm']['id']]);

            if (!empty($clacoForm)) {
                $entry->setClacoForm($clacoForm);

                // Initializes status
                if (empty($entry->getStatus())) {
                    $status = $clacoForm->isModerated() ? Entry::PENDING : Entry::PUBLISHED;
                    $entry->setStatus($status);
                }

                // Sets values for fields
                $fields = $this->fieldRepo->findBy(['clacoForm' => $clacoForm]);

                foreach ($fields as $field) {
                    $uuid = $field->getUuid();

                    if (isset($data['values'][$uuid])) {
                        $fieldValue = $this->fieldValueRepo->findOneBy(['entry' => $entry, 'field' => $field]);

                        if (empty($fieldValue)) {
                            $fieldValue = new FieldValue();
                            $fieldValue->setEntry($entry);
                            $fieldValue->setField($field);

                            $fielFacetValue = new FieldFacetValue();
                            $fielFacetValue->setUser($entry->getUser());
                            $fielFacetValue->setFieldFacet($field->getFieldFacet());
                            $fielFacetValue->setValue($data['values'][$uuid]);
                            $fieldValue->setFieldFacetValue($fielFacetValue);

                            $this->om->persist($fielFacetValue);
                        } else {
                            $fieldValue->setValue($data['values'][$uuid]);
                        }
                        $this->om->persist($fieldValue);

                        $fieldsCategories = $this->fieldChoiceCategoryRepo->findBy(['field' => $field]);

                        foreach ($fieldsCategories as $fieldCategory) {
                            switch ($field->getType()) {
                                case FieldFacet::NUMBER_TYPE:
                                    $isCategoryValue = floatval($data['values'][$uuid]) === floatval($fieldCategory->getValue());
                                    break;
                                default:
                                    $isCategoryValue = $data['values'][$uuid] === $fieldCategory->getValue();
                            }
                            if ($isCategoryValue) {
                                $entry->addCategory($fieldCategory->getCategory());
                            }
                        }
                    }
                }
            }
        }
        $currentDate = new \DateTime();

        if (empty($entry->getCreationDate())) {
            $entry->setCreationDate($currentDate);
            $this->clacoFormManager->notifyCategoriesManagers($entry, [], $entry->getCategories());
        } else {
            $entry->setEditionDate($currentDate);
            $this->clacoFormManager->notifyCategoriesManagers($entry, $entry->getCategories(), $entry->getCategories());
        }

        return $entry;
    }
580496
protected function writeToLog($entry) {
		if ($entry[0] >= $this->logLevel) {
			trigger_error("** ".$this->getFormattedCaller()." ** {$entry[1]} **",$this->loggerTypes[$entry[0]]->getPhpErrorCode());
		}
	}
922330
public static function type_set_before($var, array $settings)
	{
		$var    = is_array($var) ? implode(',', $var) : strval($var);
		$values = array_filter(explode(',', trim($var)));

		if ($settings['data_type'] == 'enum' and count($values) > 1)
		{
			throw new InvalidContentType('Enum cannot have more than 1 value.');
		}

		foreach ($values as $val)
		{
			if ( ! in_array($val, $settings['options']))
			{
				throw new InvalidContentType('Invalid value given for '.ucfirst($settings['data_type']).
					', value "'.$var.'" not in available options: "'.implode(', ', $settings['options']).'".');
			}
		}

		return $var;
	}
535088
private function _loadSettingsFromArray($settings)
    {
        if (isset($settings['sp'])) {
            $this->_sp = $settings['sp'];
        }
        if (isset($settings['idp'])) {
            $this->_idp = $settings['idp'];
        }

        $errors = $this->checkSettings($settings);
        if (empty($errors)) {
            $this->_errors = array();

            if (isset($settings['strict'])) {
                $this->_strict = $settings['strict'];
            }
            if (isset($settings['debug'])) {
                $this->_debug = $settings['debug'];
            }

            if (isset($settings['baseurl'])) {
                $this->_baseurl = $settings['baseurl'];
            }

            if (isset($settings['compress'])) {
                $this->_compress = $settings['compress'];
            }

            if (isset($settings['security'])) {
                $this->_security = $settings['security'];
            }

            if (isset($settings['contactPerson'])) {
                $this->_contacts = $settings['contactPerson'];
            }

            if (isset($settings['organization'])) {
                $this->_organization = $settings['organization'];
            }

            $this->_addDefaultValues();
            return true;
        } else {
            $this->_errors = $errors;
            return false;
        }
    }
1337544
public static function parse($line, $output, $settings)
	{
		$bits     = explode(' ', $line, count(static::$fields));
		$index    = 0;
		$i_used   = 0;
		$style    = null;
		$exceeded = false;

		// First loop through and see if any of our thresholds are exceeded
		if (is_array($settings['threshold']))
		{
			foreach (static::$fields as $field => $show)
			{
				if (isset($settings['threshold'][$field]))
				{
					$operator = $settings['threshold'][$field]['operator'];
					$value    = $settings['threshold'][$field]['value'];
					switch ($operator)
					{
						case '=':
							$statement = (trim($bits[$index]) == $value);
							break;

						case '<':
							$statement = (trim($bits[$index]) < $value);
							break;

						case '>':
						default:
							$statement = (trim($bits[$index]) > $value);
							break;
					}

					if ($statement)
					{
						$exceeded[] = $field;
					}
				}

				$index++;
			}
		}

		// Reset index
		$index = 0;

		// Loop through and do actual output
		foreach (static::$fields as $field => $show)
		{
			if ($show)
			{
				if ($exceeded)
				{
					$style = array('color'=>'red');

					if (in_array($field, $exceeded))
					{
						$style = 'error';
					}
				}

				if ($i_used != 0)
				{
					$output->addString(' ');
				}

				$value = trim($bits[$index]);

				// See if we need to change date format
				if (isset(static::$dateFormat))
				{
					$d = \DateTime::createFromFormat(static::$dateFormat, $value);
					if ($d && $d->format(static::$dateFormat) == $value)
					{
						$value = $d->format($settings['dateFormat']);
					}
				}

				if (method_exists(get_called_class(), 'parse' . ucfirst($field)))
				{
					$method = 'parse' . ucfirst($field);
					$value  = static::$method($value);
				}

				$output->addString($value, $style);

				// Increment used count
				$i_used++;
			}

			// Increment total count
			$index++;
		}

		$output->addSpacer();

		// See if the total time exceeds the given threshold
		if ($exceeded && !$settings['noBeep'])
		{
			$output->beep();
		}
	}
1310838
public function isAllowed($entry)
    {
        foreach ($this->entries as $elmt) {
            if ($elmt->check($entry)) {
                return $this->matchingResponse;
            }
        }

        return null;
    }
156575
public static function logEntry($entry)
  {
    $parts = explode("|", $entry, 5);
    $array = array();

    if(count($parts) != 5)
    {
      $array["timestamp"] = 0;
      $array["level"]     = TeamSpeak3::LOGLEVEL_ERROR;
      $array["channel"]   = "ParamParser";
      $array["server_id"] = "";
      $array["msg"]       = Str::factory("convert error (" . trim($entry) . ")");
      $array["msg_plain"] = $entry;
      $array["malformed"] = TRUE;
    }
    else
    {
      $array["timestamp"] = strtotime(trim($parts[0]));
      $array["level"]     = self::logLevel(trim($parts[1]));
      $array["channel"]   = trim($parts[2]);
      $array["server_id"] = trim($parts[3]);
      $array["msg"]       = Str::factory(trim($parts[4]));
      $array["msg_plain"] = $entry;
      $array["malformed"] = FALSE;
    }

    return $array;
  }
340709
public function get_document($entry, $options = array()) {
        global $DB;

        $keywords = array();
        if ($aliases = $DB->get_records('glossary_alias', array('entryid' => $entry->id))) {
            foreach ($aliases as $alias) {
                $keywords[] = $alias->alias;
            }
        }

        try {
            $cm = $this->get_cm('glossary', $entry->glossaryid, $entry->course);
            $context = \context_module::instance($cm->id);
        } catch (\dml_missing_record_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving mod_glossary ' . $entry->id . ' document, not all required data is available: ' .
                $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        } catch (\dml_exception $ex) {
            // Notify it as we run here as admin, we should see everything.
            debugging('Error retrieving mod_glossary' . $entry->id . ' document: ' . $ex->getMessage(), DEBUG_DEVELOPER);
            return false;
        }

        // Prepare associative array with data from DB.
        $doc = \core_search\document_factory::instance($entry->id, $this->componentname, $this->areaname);
        $doc->set('title', content_to_text($entry->concept, false));
        $doc->set('content', content_to_text($entry->definition, $entry->definitionformat));
        $doc->set('contextid', $context->id);
        $doc->set('courseid', $entry->course);
        $doc->set('userid', $entry->userid);
        $doc->set('owneruserid', \core_search\manager::NO_OWNER_ID);
        $doc->set('modified', $entry->timemodified);

        // Check if this document should be considered new.
        if (isset($options['lastindexedtime']) && ($options['lastindexedtime'] < $entry->timecreated)) {
            // If the document was created after the last index time, it must be new.
            $doc->set_is_new(true);
        }

        // Adding keywords as extra info.
        if ($keywords) {
            // No need to pass through content_to_text here as this is just a list of keywords.
            $doc->set('description1', implode(' ' , $keywords));
        }

        return $doc;
    }