lithium\core\Libraries::_filter()

protected static method

Filters a list of library search results by the given set of options.

Parameters

  • array $libs

    List of found libraries.

  • array $config

    The configuration of the library currently being searched within.

  • array $options

    The options used to filter/format $libs.

Returns

array

Returns a copy of $libs, filtered and transformed based on the configuration provided in $options.

Source

	protected static function _filter($libs, array $config, array $options = []) {
		if (is_callable($options['format'])) {
			foreach ($libs as $i => $file) {
				$libs[$i] = $options['format']($file, $config);
			}
			$libs = $options['name'] ? preg_grep("/{$options['name']}$/", $libs) : $libs;
		}
		if ($exclude = $options['exclude']) {
			if (is_string($exclude)) {
				$libs = preg_grep($exclude, $libs, PREG_GREP_INVERT);
			} elseif (is_callable($exclude)) {
				$libs = array_values(array_filter($libs, $exclude));
			}
		}
		if ($filter = $options['filter']) {
			if (is_string($filter)) {
				$libs = preg_grep($filter, $libs) ;
			} elseif (is_callable($filter)) {
				$libs = array_filter(array_map($filter, $libs));
			}
		}
		return $libs;
	}