Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mrclay opened this issue Sep 3, 2015 · 2 comments
Closed

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

mrclay opened this issue Sep 3, 2015 · 2 comments

Comments

@mrclay
Copy link
Owner

mrclay commented Sep 3, 2015

Originally reported on Google Code with ID 65

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.

Reported by 1stvamp on 2008-10-29 09:39:28


- _Attachment: [Minify.patch](https://storage.googleapis.com/google-code-attachments/minify/issue-65/comment-0/Minify.patch)_
@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

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

Reported by mrclay.org on 2008-10-29 14:43:45

  • Status changed: WontFix

@mrclay
Copy link
Owner Author

mrclay commented Sep 3, 2015

I labelled this incorrectly, sorry for the noise.

Reported by mrclay.org on 2008-11-27 15:49:05

  • Status changed: Invalid

@mrclay mrclay closed this as completed Sep 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant