Permalink
Browse files

huuuge refactoring. Decoupled sfLESS to many small pieces

  • Loading branch information...
1 parent 6b0cc03 commit ebf202c0d14fe25be4439175661c790e69a328c5 @everzet committed Jul 5, 2010
@@ -29,7 +29,7 @@ public function initialize()
// Register listener to routing.load_configuration event
$this->dispatcher->connect(
'context.load_factories',
- array('sfLESS', 'findAndCompile')
+ array('sfLESSListeners', 'findAndCompile')
);
// If app_sf_less_plugin_toolbar in app.yml is set to true (by default)
@@ -0,0 +1,121 @@
+<?php
+
+/*
+ * This file is part of the sfLESSPlugin.
+ * (c) 2010 Konstantin Kudryashov <ever.zet@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfLESSConfig is configuration manager.
+ *
+ * @package sfLESSPlugin
+ * @subpackage lib
+ * @author Konstantin Kudryashov <ever.zet@gmail.com>
+ * @version 1.0.0
+ */
+class sfLESSConfig
+{
+ /**
+ * Do we need to check dates before compile
+ *
+ * @var boolean
+ */
+ protected $checkDates;
+
+ /**
+ * Do we need compression for CSS files
+ *
+ * @var boolean
+ */
+ protected $useCompression;
+
+ /**
+ * Creates config instance
+ *
+ * @param boolean $checkDates whether we check dates before compile
+ * @param boolean $useCompression whether we compress result styles
+ */
+ public function __construct($checkDates = true, $useCompression = false)
+ {
+ $this->checkDates = $checkDates;
+ $this->useCompression = $useCompression;
+ }
+
+ /**
+ * Do we need to check dates before compile
+ *
+ * @return boolean
+ */
+ public function isCheckDates()
+ {
+ return $this->checkDates;
+ }
+
+ /**
+ * Set need of check dates before compile
+ *
+ * @param boolean $checkDates Do we need to check dates before compile
+ */
+ public function setIsCheckDates($checkDates)
+ {
+ $this->checkDates = $checkDates;
+ }
+
+ /**
+ * Do we need compression for CSS files
+ *
+ * @return boolean
+ */
+ public function isUseCompression()
+ {
+ return $this->useCompression;
+ }
+
+ /**
+ * Set need of compression for CSS files
+ *
+ * @param boolean $useCompression Do we need compression for CSS files
+ */
+ public function setIsUseCompression($useCompression)
+ {
+ $this->useCompression = $useCompression;
+ }
+
+ /**
+ * Returns paths to CSS files
+ *
+ * @return string a path to CSS files directory
+ */
+ public function getCssPaths()
+ {
+ return 'web/css/';
+ }
+
+ /**
+ * Returns paths to LESS files
+ *
+ * @return string a path to LESS files directories
+ */
+ public function getLessPaths()
+ {
+ return 'web/less/';
+ }
+
+ /**
+ * Returns debug info of the current state
+ *
+ * @return array state
+ */
+ public function getDebugInfo()
+ {
+ return array(
+ 'dates' => var_export($this->isCheckDates(), true),
+ 'compress' => var_export($this->isUseCompression(), true),
+ 'less' => $this->getLessPaths(),
+ 'css' => $this->getCssPaths()
+ );
+ }
+}
@@ -0,0 +1,52 @@
+<?php
+
+/*
+ * This file is part of the sfLESSPlugin.
+ * (c) 2010 Konstantin Kudryashov <ever.zet@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfLESS is helper class to provide LESS compiling in symfony projects.
+ *
+ * @package sfLESSPlugin
+ * @subpackage lib
+ * @author Konstantin Kudryashov <ever.zet@gmail.com>
+ * @version 1.0.0
+ */
+class sfLESSConfig extends LESSConfig
+{
+ /**
+ * @see LESSConfig
+ */
+ public function isCheckDates()
+ {
+ return sfConfig::get('app_sf_less_plugin_check_dates', parent::isCheckDates());
+ }
+
+ /**
+ * @see LESSConfig
+ */
+ public function isUseCompression()
+ {
+ return sfConfig::get('app_sf_less_plugin_use_compression', parent::isUseCompression());
+ }
+
+ /**
+ * @see LESSConfig
+ */
+ public function getCssPaths()
+ {
+ return sfLESSUtils::getSepFixedPath(sfConfig::get('sf_web_dir')) . '/css/';
+ }
+
+ /**
+ * @see LESSConfig
+ */
+ public function getLessPaths()
+ {
+ return sfLESSUtils::getSepFixedPath(sfConfig::get('sf_web_dir')) . '/less/';
+ }
+}
@@ -14,6 +14,7 @@
* @package sfLESSPlugin
* @subpackage helper
* @author Victor Berchet <victor@suumit.com>
+ * @author Konstantin Kudryashov <ever.zet@gmail.com>
* @version 1.0.0
*/
use_helper('Asset');
@@ -32,7 +33,9 @@ function get_less_stylesheets()
$response = sfContext::getInstance()->getResponse();
sfConfig::set('symfony.asset.stylesheets_included', true);
- sfLESS::findAndFixContentLinks($response, sfConfig::get('app_sf_less_plugin_use_js', false));
+ sfLESSListeners::findAndFixContentLinks(
+ $response, sfConfig::get('app_sf_less_plugin_use_js', false)
+ );
$html = '';
foreach ($response->getStylesheets() as $file => $options)
Oops, something went wrong.

0 comments on commit ebf202c

Please sign in to comment.