Skip to content

Commit 586a153

Browse files
committed
New php library structure made easier
1 parent bca0e99 commit 586a153

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Bundle/Bundle.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,12 @@ public function build(ContainerBuilder $container)
7272
public function getContainerExtension()
7373
{
7474
if (null === $this->extension) {
75-
$basename = preg_replace('/Bundle$/', '', $this->getName());
76-
77-
$class = $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension';
75+
$class = $this->getContainerExtensionClass();
7876
if (class_exists($class)) {
7977
$extension = new $class();
8078

8179
// check naming convention
80+
$basename = preg_replace('/Bundle$/', '', $this->getName());
8281
$expectedAlias = Container::underscore($basename);
8382
if ($expectedAlias != $extension->getAlias()) {
8483
throw new \LogicException(sprintf(
@@ -197,4 +196,16 @@ public function registerCommands(Application $application)
197196
}
198197
}
199198
}
199+
200+
/**
201+
* Returns the bundle's container extension class.
202+
*
203+
* @return string
204+
*/
205+
protected function getContainerExtensionClass()
206+
{
207+
$basename = preg_replace('/Bundle$/', '', $this->getName());
208+
209+
return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension';
210+
}
200211
}

0 commit comments

Comments
 (0)