Hi Viper,
I looked through 'Part 2' quickly. Something that did catch my eye was
the part where you return the response from the front controller in your
bootstrap and set the content type header to be text/html. I assume
you've done this to set the UTF-8 encoding? What happens if you want to
return JSON, XML or file downloads from part of your application as a
response? The response object force ably overwrites any headers set to
text/html.
Based on the following thread, it seems setting the encoding in the
header isn't necessary as long as it's in the HTML.
http://www.nabble.com/Best-place-to-specify-encoding-tf4621717s16154.html#a13198947
As for the view perhaps you could use a plug-in like so:
class My_Plugin_SetEncoding extends Zend_Controller_Plugin_Abstract {
protected $_encoding;
public function __construct($encoding = 'utf-8')
{
$this->_encoding = $encoding;
}
public function preDispatch($request)
{
Zend_Controller_Action_HelperBroker::getHelper('ViewRenderer')->view->encoding
= $this->_encoding;
}
}
and then in your bootstrap
Zend_Layout::startMvc(
array <http://www.php.net/array>(
'layoutPath' => $siteRootDir . '/application/layouts',
'layout' => 'main'
)
);
Zend_Controller_Front::getInstance()
->throwExceptions(true)
->registerPlugin(new My_Plugin_SetEncoding('utf-8'))
->addModuleDirectory($siteRootDir . '/application/modules')
->dispatch();
Just a suggestion (I've not actually tried the code so I'm not sure if
it works, specifically ..._HelperBroker::getHelper part as the method
isn't defined as static?? Although the method does seem to be able to
operate as a static?? Can anyone explain?).
Luke
Viper X wrote:
Hi all there.
I'm writing simple web application to be used from me as "kick-start" when
starting new application, which needs user registration and authentication.
I think it can be interesting for someone to see my approach to the problem
and eventually to use some of my code for his own purpose :) So i decided to
put the code along with some descriptions to a blog series here:
http://zfsite.andreinikolov.com http://zfsite.andreinikolov.com
Now there is only the first part - setting up the MVC, later today I hope I
will manage to write the next part - putting the session management in the
database.
I'll appriciate any comments on it.