Returns filters.
@param string $extension Extension name. Eg: css
@return self
761957
public function getFilters($extension = null)
    {
        if ($extension === null) {
            return $this->filters;
        }
        elseif (isset($this->filters[$extension])) {
            return $this->filters[$extension];
        }
        else {
            return null;
        }
    }
943974
public function setAllowedExtensions($extensions)
    {
        if (is_string($extensions)) {
            $extensions = explode(',', $extensions);
        }

        $this->allowedExtensions = array_map('trim', $extensions);

        return $this;
    }
239535
protected function getParser($extension)
    {
        foreach ($this->supportedParsers as $parser) {
            if (in_array($extension, $parser::getSupportedExtensions())) {
                return new $parser();
            }
        }

        // If none exist, then throw an exception
        throw new UnsupportedFormatException('Unsupported configuration format');
    }
784993
public function getFileHandler($extension)
    {
        if (array_key_exists($extension, $this->fileHandler)) {
            //@todo check for interface
            //@todo use factory here
            return GeneralUtility::makeInstance($this->fileHandler[$extension]);
        } else {
            return;
        }
    }
446474
public function resetAliases($extension = null)
    {
        if ($extension === null) {
            $this->aliases = [];
        }
        else {
            $this->aliases[$extension] = [];
        }

        return $this;
    }
1240240
public function getBundles($extension = null)
    {
        if ($extension === null) {
            return $this->bundles;
        }
        elseif (isset($this->bundles[$extension])) {
            return $this->bundles[$extension];
        }
        else {
            return null;
        }
    }
921225
public function replaceExtension($extension)
    {
        $atoms = $this->nameAtoms();
        if (array('', '') === $atoms) {
            if (null === $extension) {
                return $this;
            }

            return $this->replaceName(
                static::EXTENSION_SEPARATOR . $extension
            );
        }

        $numAtoms = count($atoms);

        if ($numAtoms > 1) {
            if (null === $extension) {
                $replacement = array();
            } else {
                $replacement = array($extension);
            }

            array_splice($atoms, -1, $numAtoms, $replacement);
        } elseif (null !== $extension) {
            $atoms[] = $extension;
        }

        return $this->replaceName(implode(self::EXTENSION_SEPARATOR, $atoms));
    }
619675
public function extension($extension = null)
    {
        if (is_null($extension)) {
            if (!empty($this->extension)) {
                return $this->extension;
            }
            if (isset($this->attributes['extension'])) {
                return $this->attributes['extension'];
            }
        }
        $this->extension = $this->checkExtension($extension);

        return $this;
    }
1015007
public static function clean_file_extensions($extensions) {

        debugging('The method workshop::clean_file_extensions() is deprecated.
            Please use the methods provided by the \core_form\filetypes_util class.', DEBUG_DEVELOPER);

        $extensions = self::normalize_file_extensions($extensions);

        foreach ($extensions as $i => $extension) {
            $extensions[$i] = ltrim($extension, '.');
        }

        return implode(', ', $extensions);
    }
94991
public function setTypeFromExtension($extension)
    {
        if ( ! $this->checkExtension($extension) ) {
            throw new InvalidFileExtensionException("Invalid File Extension [{$extension}].");
        }

        $this->setSelectedType($extension);

        return $this;
    }
324121
public function setExtension($extension)
    {
        if (! Str::startsWith($extension, '.')) {
            $extension = ".$extension";
        }

        $this->extension = $extension;

        return $this;
    }
771471
protected function loadExtension($extension)
	{
		if (isset($this->classMap[$extension]))
		{
			return;
		}
		foreach ($this->supportedTypes as $imageType => $extensions)
		{
			if (in_array($extension, $extensions, true))
			{
				$this->loadType($imageType);
			}
		}
	}
203660
public static function getTypeForExtension($extension) {
		static::ensureDataLoaded();

		$extension = strtolower($extension);
		foreach (static::$mime_types as $mime_type => $extensions) {
			if (is_array($extensions)) {
				if (in_array($extension, $extensions, true)) {
					return $mime_type;
				}
			} else if ($extension === $extensions) {
				return $mime_type;
			}
		}
	}
1148475
public static function hasExtension($extension) {
		static::ensureDataLoaded();

		$extension = strtolower($extension);
		foreach (static::$mime_types as $extensions) {
			if (is_array($extensions)) {
				if (in_array($extension, $extensions, true)) {
					return true;
				}
			} else if ($extension === $extensions) {
				return true;
			}
		}

		return false;
	}
533932
public static function purifyExtension($extension)
    {
        $extension = (string)$extension;
        $extension = trim($extension);
        $extension = ltrim($extension, '.');

        return $extension;
    }
676625
public function cacheExtension($extension = null)
    {
        if (empty($extension)) {
            return $this->cache_extension;
        }

        $this->cache_extension = $extension;

        return $this;
    }
715961
public function findAllWithExtension($extensions)
	{
		$found = [];

		if (!is_array($extensions))
		{
			$extensions = [$extensions];
		}

		foreach ($this->getFlatListOfFiles() as $file)
		{
			$ext = $file->getExtension();
			if (in_array($ext, $extensions))
			{
				$found[] = $file;
			}
		}

		return $found;
	}