mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-06 17:41:01 +00:00
Move source files directly under src/ directory
This commit is contained in:
parent
804261bc26
commit
a37b385c23
190 changed files with 19 additions and 21 deletions
53
src/Event/Subscriber/GenerateCustomCSSSubscriber.php
Normal file
53
src/Event/Subscriber/GenerateCustomCSSSubscriber.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\Event\Subscriber;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use ScssPhp\ScssPhp\Compiler;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Wallabag\CoreBundle\Event\ConfigUpdatedEvent;
|
||||
|
||||
class GenerateCustomCSSSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $em;
|
||||
private $compiler;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, Compiler $compiler)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->compiler = $compiler;
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
ConfigUpdatedEvent::NAME => 'onConfigUpdated',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate custom CSS.
|
||||
*/
|
||||
public function onConfigUpdated(ConfigUpdatedEvent $event)
|
||||
{
|
||||
$config = $event->getConfig();
|
||||
|
||||
$css = $this->compiler->compileString(
|
||||
'h1 { font-family: "' . $config->getFont() . '";}
|
||||
#article {
|
||||
max-width: ' . $config->getMaxWidth() . 'em;
|
||||
font-family: "' . $config->getFont() . '";
|
||||
}
|
||||
#article article {
|
||||
font-size: ' . $config->getFontsize() . 'em;
|
||||
line-height: ' . $config->getLineHeight() . 'em;
|
||||
}
|
||||
;
|
||||
')->getCss();
|
||||
|
||||
$config->setCustomCSS($css);
|
||||
|
||||
$this->em->persist($config);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue