1
0
mirror of https://github.com/flarum/core.git synced 2025-07-23 01:31:40 +02:00
Files
php-flarum/src/Frontend/Compiler/Source/SourceCollector.php
Sami Mazouz f56fc11af9 [1.x] Theme Extender to Allow overriding LESS files (#3008)
This PR introduces the ability to just override a LESS file's contents through an extender.
This is mainly useful for theme development, as there are times in extensively customized themes where overriding the actual file makes a huge difference vs overriding CSS styles which can turn into a maintenance hell real fast.

Overriding styles is more tedious than overriding files. When you're designing an element, you would normally rather start from a blank canvas, than a styled element. With an already styled element you have to first override and undo the styles you do not wish to have, only then can you start shaping it, but even then you'd always end up constantly undoing default styles. This mostly applies for more advanced themes. (example: 851c55516d/less/forum/DiscussionList.less)
2021-09-10 13:45:18 -04:00

52 lines
915 B
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Frontend\Compiler\Source;
/**
* @internal
*/
class SourceCollector
{
/**
* @var SourceInterface[]
*/
protected $sources = [];
/**
* @param string $file
* @return $this
*/
public function addFile(string $file, string $extensionId = null)
{
$this->sources[] = new FileSource($file, $extensionId);
return $this;
}
/**
* @param callable $callback
* @return $this
*/
public function addString(callable $callback)
{
$this->sources[] = new StringSource($callback);
return $this;
}
/**
* @return SourceInterface[]
*/
public function getSources()
{
return $this->sources;
}
}