Issues

ZF-7764: Allow easy configuration of classResources

Issue Type: Patch Created: 2009-09-02T14:00:34.000+0000 Last Updated: 2012-11-20T21:37:22.000+0000 Status: Open Fix version(s): Reporter: Michiel Thalen (chielsen) Assignee: None Tags: - Zend_Application

Related issues: - ZF-7742

Attachments: - add_resourcemethod_config.patch

Description

I have created a patch that allows to configure classResources same as plugins.

Options can be set via the resources configuration, where classResource also can be disabled. Like:

<pre class="highlight">
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initCache()
    {
        $file = $this->getOption('defaultcachedir'). 'pluginLoaderCache.php';
        if (file_exists($file)) {
            include_once $file;
        }
        if ($this->getOption('plugin')) {
            Zend_Loader_PluginLoader::setIncludeFileCache($file);
        }
    }

    protected function _initSession() {
        $session = new Zend_Session_Namespace( $this->getOption('name') );
        Zend_Registry::set( 'session', $session );
        
        if (!isset($session->initialized)) {
            Zend_Session::regenerateId();
            $session->initialized = true;
        }
    }
}

With this config:

<pre class="highlight"> 
<?xml version="1.0"?>
/bootstrap.phpBootstrap00/default/controllers<a href="http://zf.dev">http://zf.dev</a>PDO_MYSQLlocalhostrootpasswzftrue/../data/cache/1Naam

Where _initCache will not be called.

Comments

Posted by Markus (rockaut) on 2009-09-02T23:51:13.000+0000

I like it :D

Only thing i dont get: Cache and Session are available Resource Plugins, why not only use this?

But the Disable feature is nice, would like to see this for Res-Plug-Ins too.

Posted by Michiel Thalen (chielsen) on 2009-09-03T03:43:12.000+0000

Well cache isn't available AFAIK and the session resource doesn't do what this does. BUT, this is only an example about how it would work. Resourceplugins you can disable already by just removing them from the resource config.

Posted by Michiel Thalen (chielsen) on 2009-11-26T13:57:50.000+0000

updated it

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-11-27T05:18:12.000+0000

I would personally like to see some benchmarks about this. Though the feature is nice, it's not essential imho, and it has the potential of slowing down every app based on zend_app.

Posted by Michiel Thalen (chielsen) on 2009-11-27T06:45:41.000+0000

I did 2 runs of 10k, results are the patch hardly makes a difference (only a bit faster). See the attached results and files i ran the test with.

Notice that there is no checking if the options actually exists (so results in a notice error) in the 'old' implementation. An extra check would only make it slower.

Also, since you are saving the config into a local variable, more calls to the getOptions or a bigger config file will make it slower.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts