contao/docs

Wrong class name (?)

Closed this issue · 2 comments

In https://docs.contao.org/dev/getting-started/extension/#service-configuration we have

namespace SomeVendor\ContaoExampleBundle\DependencyInjection;
// ...
class ContaoExampleExtension extends Extension

Shouldn't that be

class SomeVendorContaoExampleExtension extends Extension

This naming would conform to the linked Symfony example where it reads

namespace Acme\HelloBundle\DependencyInjection;
// ...
class AcmeHelloExtension extends Extension

It depends on the name of the bundle class, see https://symfony.com/doc/current/bundles/extension.html#creating-an-extension-class

The name is equal to the bundle name with the Bundle suffix replaced by Extension (e.g. the Extension class of the AcmeBundle would be called AcmeExtension and the one for AcmeHelloBundle would be called AcmeHelloExtension).

So in the example of the docs, the bundle class would be

// src/ContaoExampleBundle.php
namespace SomeVendor\ContaoExampleBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class ContaoExampleBundle extends Bundle
{
}

SomeVendorContaoExampleExtension would only be correct if your bundle was called SomeVendorContaoExampleBundle.

OK, I see. Thank you!