Jeff-Lewis / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Extending Minify to load a controller from a different location #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For an internal implementation of Minify integrated with our own MVC
framework, we needed to load a custom controller for use with our views,
and using the naming convention for our framework for the controller class
Minify would fail, attempting instead to load Minify_Controller_etcetc.
The fix for this was of course to override serve() in our Minify extended
class (which we had already created as a wrapper as a matter of good
practice), but copying and pasting the entirety of serve(), which does
quite a few things and has changed between releases of Minify, seems the
wrong way to do this to override one simple little autoload method.

As a proposed patch (attached) I've moved the controller loading to a
separate static method in Minify and call this from within serve(),
allowing anyone that wishes to do so to just override this loadController()
method.

Not sure if this is solving an edge-case here, but it feels like a better
way to do this overall.

Original issue reported on code.google.com by 1stv...@gmail.com on 29 Oct 2008 at 9:39

Attachments:

GoogleCodeExporter commented 9 years ago
You do not need to extend Minify to do this. Simply create a controller object 
(load 
it however you want) and pass it as the first parameter to serve(). It's 
easiest, 
but not required, to make your controller a subclass of Minify_Controller_Base.

{{{
$myController = MyFramework::factory('MinifyController');
Minify::serve($myController, $options);
}}}

serve() only uses its loader if you pass a string. I'm sorry this isn't well-
documented yet; here's the phpdoc line that specifies this:
http://code.google.com/p/minify/source/browse/tags/release_2.1.0/min/lib/
Minify.php#135

Original comment by mrclay....@gmail.com on 29 Oct 2008 at 2:43

GoogleCodeExporter commented 9 years ago
I labelled this incorrectly, sorry for the noise.

Original comment by mrclay....@gmail.com on 27 Nov 2008 at 3:49