Ahhhh!

I didn't realize that events could be subscribed to before they were
declared somewhere.

Yes, I see how this makes sense. Plugins that provide buttons can
subscribe to events at pluginConfiguration time, even if those plugins
load before pkContextCMSPlugin does. Very nice. Thanks.

-Tom

On Mon, Jun 8, 2009 at 11:43 AM, Jonathan Wage<[email protected]> wrote:
> Why not use events? The code which renders these buttons are powered by some
> "button" class that gives you an interface to build these buttons then
> render them? or you build an array? Either way, right before you render this
> object/array simply pass it to an event that your plugins can subscribe to
> and manipulate the data before being rendered.
>
> Jonathan H. Wage (+1 415 992 5468)
> Open Source Software Developer & Evangelist
> sensiolabs.com | jwage.com | doctrine-project.org | symfony-project.org
>
>
> On Mon, Jun 8, 2009 at 10:20 AM, Tom Boutell <[email protected]> wrote:
>>
>> FYI, I resolved the issue by looping over the plugins in the project
>> and looking to see if they have a
>> pluginnamePluginPkContextCMSExtension class. If they do, I ask that
>> class for a list of global buttons.
>>
>> This seems reasonable in practice because I only look for these when a
>> user is logged in with editing privileges, and it would be unusual for
>> a single Symfony project to use, let's say, 50 plugins. And it's
>> pretty elegant from an OOP perspective. But I'd be interested in the
>> thoughts of others on whether there's another way to do it with the
>> same elegance and better performance.
>>
>> Keeping this stuff in a pkContextCMS-specific class for each plugin
>> seems cleaner than adding CMS-specific methods to the
>> pluginConfiguration class, which I also considered.
>>
>> My getExtensionClasses() method follows.
>>
>> (I also upgraded my global buttons to be a proper class and so on, and
>> I check the extension classes to see whether they actually have a
>> getGlobalButtons method before interrogating them.)
>>
>> -Tom
>>
>>  static public function getExtensionClasses()
>>  {
>>    $classes = array();
>>    $plugins = sfContext::getInstance()->getConfiguration()->getPlugins();
>>    foreach ($plugins as $plugin)
>>    {
>>      $class = $plugin . "PkContextCMSExtension";
>>      if (class_exists($class, true))
>>      {
>>        $classes[] = $class;
>>      }
>>    }
>>    if (class_exists("ProjectPkContextCMSExtension"))
>>    {
>>      $classes[] = "ProjectPKContextCMSExtension";
>>    }
>>    return $classes;
>>  }
>>
>>
>>
>> --
>> Tom Boutell
>> P'unk Avenue
>> 215 755 1330
>> punkave.com
>> window.punkave.com
>>
>>
>
>
> >
>



-- 
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to