|
@@ -50,6 +50,8 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
const CONTEXT_MENU = 'menu';
|
|
|
const CONTEXT_DASHBOARD = 'dashboard';
|
|
|
|
|
|
+ const CLASS_REGEX = '@([A-Za-z0-9]*)\\\(Bundle\\\)?([A-Za-z0-9]+)Bundle\\\([A-Za-z0-9].*)\\\([A-Za-z0-9]*)$@';
|
|
|
+
|
|
|
/**
|
|
|
* The class name managed by the admin class
|
|
|
*
|
|
@@ -845,7 +847,7 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
public function getBaseRoutePattern()
|
|
|
{
|
|
|
if (!$this->baseRoutePattern) {
|
|
|
- preg_match('@([A-Za-z0-9]*)\\\([A-Za-z0-9]*)Bundle\\\(Entity|Document|Model|PHPCR)\\\(.*)@', $this->getClass(), $matches);
|
|
|
+ preg_match(self::CLASS_REGEX, $this->getClass(), $matches);
|
|
|
|
|
|
if (!$matches) {
|
|
|
throw new \RuntimeException(sprintf('Please define a default `baseRoutePattern` value for the admin class `%s`', get_class($this)));
|
|
@@ -854,14 +856,14 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
if ($this->isChild()) { // the admin class is a child, prefix it with the parent route name
|
|
|
$this->baseRoutePattern = sprintf('%s/{id}/%s',
|
|
|
$this->getParent()->getBaseRoutePattern(),
|
|
|
- $this->urlize($matches[4], '-')
|
|
|
+ $this->urlize($matches[5], '-')
|
|
|
);
|
|
|
} else {
|
|
|
|
|
|
$this->baseRoutePattern = sprintf('/%s/%s/%s',
|
|
|
$this->urlize($matches[1], '-'),
|
|
|
- $this->urlize($matches[2], '-'),
|
|
|
- $this->urlize($matches[4], '-')
|
|
|
+ $this->urlize($matches[3], '-'),
|
|
|
+ $this->urlize($matches[5], '-')
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@@ -879,23 +881,23 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
|
|
|
public function getBaseRouteName()
|
|
|
{
|
|
|
if (!$this->baseRouteName) {
|
|
|
- preg_match('@([A-Za-z0-9]*)\\\([A-Za-z0-9]*)Bundle\\\(Entity|Document|Model|PHPCR)\\\(.*)@', $this->getClass(), $matches);
|
|
|
+ preg_match(self::CLASS_REGEX, $this->getClass(), $matches);
|
|
|
|
|
|
if (!$matches) {
|
|
|
- throw new \RuntimeException(sprintf('Please define a default `baseRouteName` value for the admin class `%s`', get_class($this)));
|
|
|
+ throw new \RuntimeException(sprintf('Cannot automatically determine base route name, please define a default `baseRouteName` value for the admin class `%s`', get_class($this)));
|
|
|
}
|
|
|
|
|
|
if ($this->isChild()) { // the admin class is a child, prefix it with the parent route name
|
|
|
$this->baseRouteName = sprintf('%s_%s',
|
|
|
$this->getParent()->getBaseRouteName(),
|
|
|
- $this->urlize($matches[4])
|
|
|
+ $this->urlize($matches[5])
|
|
|
);
|
|
|
} else {
|
|
|
|
|
|
$this->baseRouteName = sprintf('admin_%s_%s_%s',
|
|
|
$this->urlize($matches[1]),
|
|
|
- $this->urlize($matches[2]),
|
|
|
- $this->urlize($matches[4])
|
|
|
+ $this->urlize($matches[3]),
|
|
|
+ $this->urlize($matches[5])
|
|
|
);
|
|
|
}
|
|
|
}
|