core-bundle/src/Resources/contao/library/Contao/Template.php
public static function generateStyleTag($href, $media=null, $mtime=false)
	{
		// Add the filemtime if not given and not an external file
		if ($mtime === null && !preg_match('@^https?://@', $href))
		{
			$container = System::getContainer();
			$rootDir = $container->getParameter('kernel.project_dir');

			if (file_exists($rootDir . '/' . $href))
			{
				$mtime = filemtime($rootDir . '/' . $href);
			}
			else
			{
				$webDir = StringUtil::stripRootDir($container->getParameter('contao.web_dir'));

				// Handle public bundle resources in web/
				if (file_exists($rootDir . '/' . $webDir . '/' . $href))
				{
					$mtime = filemtime($rootDir . '/' . $webDir . '/' . $href);
				}
			}
		}

		if ($mtime)
		{
			$href .= '?v=' . substr(md5($mtime), 0, 8);
		}

		return '<link rel="stylesheet" href="' . $href . '"' . (($media && $media != 'all') ? ' media="' . $media . '"' : '') . '>';
	}
public static function generateStyleTag($href, $media=null, $mtime=false)
	{
		// Add the filemtime if not given and not an external file
		if ($mtime === null && !preg_match('@^https?://@', $href))
		{
			$container = System::getContainer();
			$rootDir = $container->getParameter('kernel.project_dir');

			if (file_exists($rootDir . '/' . $href))
			{
				$mtime = filemtime($rootDir . '/' . $href);
			}
			else
			{
				$webDir = StringUtil::stripRootDir($container->getParameter('contao.web_dir'));

				// Handle public bundle resources in web/
				if (file_exists($rootDir . '/' . $webDir . '/' . $href))
				{
					$mtime = filemtime($rootDir . '/' . $webDir . '/' . $href);
				}
			}
		}

		if ($mtime)
		{
			$href .= '?v=' . substr(md5($mtime), 0, 8);
		}

		return '<link rel="stylesheet" href="' . $href . '"' . (($media && $media != 'all') ? ' media="' . $media . '"' : '') . '>';
	}
Generate the markup for a style sheet tag

@param string $href  The script path
@param string $media The media type string
@param mixed  $mtime The file mtime

@return string The markup string