Saves the keywords to the last searches in the database or session depending on the configuration.

@param string $keywords
@throws \UnexpectedValueException
427950
public function addToLastSearches($keywords)
    {
        $mode = $this->configuration->getSearchLastSearchesMode();
        switch ($mode) {
            case 'user':
                $this->storeKeywordsToSession($keywords);
                break;
            case 'global':
                $this->lastSearchesRepository->add($keywords, (int)$this->configuration->getSearchLastSearchesLimit());
                break;
            default:
                throw new \UnexpectedValueException(
                    'Unknown mode for plugin.tx_solr.search.lastSearches.mode, valid modes are "user" or "global".',
                    1342456570
                );
        }
    }
46779
public function setValue($value)
    {
        $matches = $this->parseKeywordText($value);
        if(isset($matches['keywords']))
        {
            if(isset($matches['keywords'][1]))
            {
                $this->database = $matches['keywords'][0];
                $this->table = $matches['keywords'][1];
            }
            else if(isset($matches['keywords'][0]))
            {
                $this->database = null;
                $this->table = $matches['keywords'][0];
            }
            $this->alias = $matches['alias'];
        }
    }
874209
public void addKeywords(String[] keywords) {
        for (String keyword : keywords) {
            if (taxonomy.concepts.containsKey(keyword)) {
                throw new IllegalArgumentException(String.format("Concept %s already exists.", keyword));
            }
        }

        for (String keyword : keywords) {
            taxonomy.concepts.put(keyword, this);
        }

        if (synset == null) {
            synset = new TreeSet<>();
        }

        for (String keyword : keywords) {
            synset.add(keyword);
        }
    }
785940
public function findByKeywords($keywords)
    {
        $qb = $this->createQueryBuilder();
        $qb->setQueryArray($this->transformConditionToMongoCondition($keywords));

        return $qb->getQuery()->execute();
    }
1212340
public function clear($log)
    {
        if ($log === 'change') {
            $this->changeRepository->clearLog();
        } elseif ($log === 'system') {
            $this->systemRepository->clearLog();
        } else {
            throw new \UnexpectedValueException("Invalid log type requested: $log");
        }

        $this->app['logger.system']->info(ucfirst($log) . ' log cleared.', ['event' => 'security']);
    }
1027976
public function setLocale(array $locales)
	{
		$localesSet = array();
				
		foreach($locales as $category => $catLocales) {
			if(in_array($category, $this->localeCategories) === false)
				throw new \UnexpectedValueException('Invalid category: ' . $category);
			
			if(($setCatLocale = setlocale($category, $catLocales)) !== false && in_array($category, array(LC_ALL, LC_MESSAGES)) === true) {
				putenv('LANG=' . $setCatLocale);
				putenv('LANGUAGE=' . $setCatLocale);
			}
			
			$localesSet[$category] = $setCatLocale;
		}

		return $localesSet;
	}
633943
protected function insertValues(array $values) : void
    {
        if (count($values) > 0) {
            foreach ($values as $k => $v) {
                $this->set((string)$k, $v);
            }
        }
    }
422491
public function set($fields = null)
    {
        if ($fields === null) {
            return $this->clause('set');
        }

        if (!in_array($this->action(), [self::ACTION_CREATE, self::ACTION_UPDATE])) {
            throw new \UnexpectedValueException(__('The action of this query needs to be either create update'));
        }

        $this->_parts['set'] = $fields;

        return $this;
    }
337297
public static function replacePhpReservedKeyword($keyword, $context = null)
    {
        if (PhpReservedKeyword::instance()->is($keyword)) {
            if ($context !== null) {
                $keywordKey = $keyword . '_' . $context;
                if (!array_key_exists($keywordKey, self::$replacedPhpReservedKeywords)) {
                    self::$replacedPhpReservedKeywords[$keywordKey] = 0;
                } else {
                    self::$replacedPhpReservedKeywords[$keywordKey]++;
                }
                return '_' . $keyword . (self::$replacedPhpReservedKeywords[$keywordKey] ? '_' . self::$replacedPhpReservedKeywords[$keywordKey] : '');
            } else {
                return '_' . $keyword;
            }
        } else {
            return $keyword;
        }
    }
897871
public function add($value)
    {
        if (!is_string($value)) {
            throw new UnexpectedTypeException($value, 'string', 'value');
        }
        if (empty($value)) {
            return;
        }

        if ($this->allowTokenize) {
            $this->values = array_merge($this->values, explode($this->delimiter, $value));
        } else {
            $this->values[] = $value;
        }
    }
464382
protected function saveConfig(IConfigSource $config)
    {
        $source = $config->getSource();

        array_walk_recursive(
            $source,
            function (&$value) {
                if ($value instanceof IConfigValue) {
                    $value->save();
                } elseif ($value instanceof IConfigSource) {
                    $this->saveConfig($value);
                } else {
                    throw new UnexpectedValueException($this->translate(
                        'Config source is corrupted.'
                    ));
                }
            }
        );
    }
1117785
protected function saveAllKeywordsToFiles($lastUpdate = null)
    {
        if ($lastUpdate === null) {
            $lastUpdate = time();
        }

        $this->saveKeywordsToFile($this->whitelist, $this->whitelistCacheFilePath, $lastUpdate);
        $this->saveKeywordsToFile($this->blacklist, $this->blacklistCacheFilePath, $lastUpdate);
    }
2118
public void setKeyword(String keyword) {
    if(keyword != null) {
      keyword = keyword.trim();
    }
    this.keyword = keyword;
  }
1348813
protected function applyRelatedFieldConfig(array $config)
    {
        if (!isset($config['relatedField']) || !is_string($config['relatedField'])) {
            throw new UnexpectedValueException($this->translate(
                'Relation field configuration should contain related field name and name should be a string.'
            ));
        }
        $this->relatedFieldName = $config['relatedField'];
    }
1357605
public boolean addKeywords(String keywords) {
        try {
            return add(new Meta(Element.KEYWORDS, keywords));
		} catch (DocumentException de) {
            throw new ExceptionConverter(de);
        }
    }
760910
public function dumpKeywords(array $keywords, $isShort)
    {
        if ($isShort) {
            return 1 < count($keywords) ? '(' . implode('|', $keywords) . ')' : $keywords[0];
        }

        return $keywords[0];
    }
316623
protected function storeKeywords($key, $minutes = null, array $keywords = [])
    {
        $keywords = empty($keywords) ? $this->keywords : $keywords;

        $this->determineKeywordsState($key, $keywords);

        $this->updateKeywordIndex($key);

        $this->updateInverseIndex($key, $minutes);
    }