On Jan 20, 10:15 pm, Bernhard Schussek <[email protected]> wrote:
> I know I'm repeating myself, but having an explicit inheritance tree
> now _and_ encouraging unique bundle names, why don't we include the
> full namespace when referring to resources in bundles?
>
> Including the vendor name in the bundle name to make it unique is kinda weird.

I agree with Bernhard, including the vendor name is like creating a
new namespacing system for identification when PHP already has one.
The only reason I can see to do that is for keeping references
shorter, which is definitely a good reason though.

Here's a different idea, haven't decided if its good or bad yet.
Instead of registerBundles returning a standard index array, it could
return an associative array:


     public function registerBundles()
     {
         return array(
             'SymfonyFrameworkBundle'=>new Symfony\Bundle
\FrameworkBundle\FrameworkBundle(),
             // ...
             'SensioBlogBundle'=>new Sensio\Bundle\BlogBundle
\BlogBundle(),
             'FooBarBlogBundle'=>new FooBar\Bundle\FooBlogBundle
\FooBlogBundle(),
         );
     }

And the key can include the vendor name (or whatever uniqueness
convention you like). Its purpose would be to map the bundle to some
more concise name to use that will be unique within the project. In
the real world it might be difficult to ensure everyone follows
convention of VendorMyNameBundle; this would allow two bundles with
the same class name to exist. The getParent() could then return the
fully qualified class name and leave no ambiguity.

Another possible advantage is if you are developing then need to
override a bundle to put more functionality in to it. All the
references to the bundle e.g.

    defaults: { _controller: HelloBundle:Hello:index, _format: xml }

    return $this->render('HelloBundle:Hello:index.twig.html');


Could remain unchanged, you would just alter your bundle configuration
like so:

    public function registerBundles()
     {
         return array(
             // ...
             'HelloBundle'=>new MyCompany\Bundle\HelloBundle
\HelloBundle(),
         );
     }

to

    public function registerBundles()
     {
         return array(
             // ...
             'BaseHelloBundle'=>new MyCompany\Bundle\HelloBundle
\HelloBundle(),
             'HelloBundle'=>new MyCompany\Bundle\HelloBundleExtended
\HelloBundle(),
         );
     }


Disadvantages:
 - People could accidentally put 2 keys with the same name and it
would go undetected. A possible solution is instead of returning an
associative array, calling a series of $this-
>registerBundle('MyBundle', new MyCompany\MyBundle())
 - It's harder to explain to use
ProjectConfiguredBundleIndexName:Lorem:ipsum than
BundleName:Lorem:ipsum - people could potentially index their bundles
in strange or misleading ways

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.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