Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Sharing data between plugins
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tom Boutell  
View profile  
 More options Jun 8, 11:20 am
From: Tom Boutell <t...@punkave.com>
Date: Mon, 8 Jun 2009 11:20:52 -0400
Local: Mon, Jun 8 2009 11:20 am
Subject: Re: Sharing data between plugins
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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile  
 More options Jun 8, 11:43 am
From: Jonathan Wage <jonw...@gmail.com>
Date: Mon, 8 Jun 2009 10:43:08 -0500
Local: Mon, Jun 8 2009 11:43 am
Subject: Re: [symfony-devs] Re: Sharing data between plugins

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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Boutell  
View profile  
 More options Jun 8, 11:51 am
From: Tom Boutell <t...@punkave.com>
Date: Mon, 8 Jun 2009 11:51:43 -0400
Local: Mon, Jun 8 2009 11:51 am
Subject: Re: [symfony-devs] Re: Sharing data between plugins
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

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

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google