Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Francis Besset committed Feb 20, 2011
1 parent 0ebea43 commit 100ee81
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 213 deletions.
104 changes: 0 additions & 104 deletions Templating/Helper/BaseJavascriptsHelper.php

This file was deleted.

104 changes: 0 additions & 104 deletions Templating/Helper/BaseStylesheetsHelper.php

This file was deleted.

43 changes: 40 additions & 3 deletions Templating/Helper/JavascriptsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

namespace Bundle\PackingMinifyBundle\Templating\Helper;

use Symfony\Component\Templating\Helper\Helper;
use Bundle\PackingMinifyBundle\Templating\Minifier\Minifier;
use Bundle\PackingMinifyBundle\Templating\Resource\FileResource;

class JavascriptsHelper extends BaseJavascriptsHelper
/**
* @author Fabien Potencier <[email protected]>
* @author Francis Besset <http://www.github.com/francisbesset/>
*/
class JavascriptsHelper extends Helper
{
protected $javascripts = array();
protected $assetHelper;
protected $minifier;
protected $options;
protected $resources = array();
Expand All @@ -20,7 +27,7 @@ class JavascriptsHelper extends BaseJavascriptsHelper
*/
public function __construct(AssetsHelper $assetHelper, Minifier $minifier, array $options = array())
{
parent::__construct($assetHelper);
$this->assetHelper = $assetHelper;

$this->options = array(
'cache_dir' => null,
Expand Down Expand Up @@ -51,6 +58,16 @@ public function add($javascript, $attributes = array())
$this->javascripts[$javascript] = $attributes;
}

/**
* Returns all JavaScript files.
*
* @return array An array of JavaScript files to include
*/
public function get()
{
return $this->javascripts;
}

/**
* Returns HTML representation of the links to stylesheets.
*
Expand Down Expand Up @@ -118,7 +135,27 @@ public function setCache($cache)
}
}

public function getHtml($path, array $attributes = array())
/**
* Returns a string representation of this helper as HTML.
*
* @return string The HTML representation of the JavaScripts
*/
public function __toString()
{
return $this->render();
}

/**
* Returns the canonical name of this helper.
*
* @return string The canonical name
*/
public function getName()
{
return 'javascripts';
}

protected function getHtml($path, array $attributes = array())
{
$atts = '';
foreach ($attributes as $key => $value) {
Expand Down
41 changes: 39 additions & 2 deletions Templating/Helper/StylesheetsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

namespace Bundle\PackingMinifyBundle\Templating\Helper;

use Symfony\Component\Templating\Helper\Helper;
use Bundle\PackingMinifyBundle\Templating\Minifier\MinifierInterface;
use Bundle\PackingMinifyBundle\Templating\Resource\FileResource;

class StylesheetsHelper extends BaseStylesheetsHelper
/**
* @author Fabien Potencier <[email protected]>
* @author Francis Besset <http://www.github.com/francisbesset/>
*/
class StylesheetsHelper extends Helper
{
protected $stylesheets = array();
protected $assetHelper;
protected $minifier;
protected $options;
protected $resources = array();
Expand All @@ -20,7 +27,7 @@ class StylesheetsHelper extends BaseStylesheetsHelper
*/
public function __construct(AssetsHelper $assetHelper, MinifierInterface $minifier, array $options = array())
{
parent::__construct($assetHelper);
$this->assetHelper = $assetHelper;

$this->options = array(
'cache_dir' => null,
Expand Down Expand Up @@ -51,6 +58,16 @@ public function add($stylesheet, $attributes = array())
$this->stylesheets[$stylesheet] = $attributes;
}

/**
* Returns all stylesheet files.
*
* @return array An array of stylesheet files to include
*/
public function get()
{
return $this->stylesheets;
}

/**
* Returns HTML representation of the links to stylesheets.
*
Expand Down Expand Up @@ -118,6 +135,26 @@ public function setCache($cache)
}
}

/**
* Returns the canonical name of this helper.
*
* @return string The canonical name
*/
public function getName()
{
return 'stylesheets';
}

/**
* Returns a string representation of this helper as HTML.
*
* @return string The HTML representation of the stylesheets
*/
public function __toString()
{
return $this->render();
}

protected function getHtml($path, array $attributes = array())
{
$atts = '';
Expand Down

0 comments on commit 100ee81

Please sign in to comment.