Skip to content

Commit

Permalink
Merge pull request #2840 from sonata-project/bundle-name-backport-2.3
Browse files Browse the repository at this point in the history
backport fix for bundle without vendor name to 2.3
  • Loading branch information
rande committed Mar 23, 2015
2 parents 3fbeb00 + 3b9c752 commit 03db550
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
11 changes: 5 additions & 6 deletions Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ 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\\\(Entity|Document|Model|PHPCR|CouchDocument|Phpcr|Doctrine\\\Orm|Doctrine\\\Phpcr|Doctrine\\\MongoDB|Doctrine\\\CouchDB)\\\(.*)@';
const CLASS_REGEX = '@(?:([A-Za-z0-9]*)\\\)?(Bundle\\\)?([A-Za-z0-9]+)Bundle\\\(Entity|Document|Model|PHPCR|CouchDocument|Phpcr|Doctrine\\\Orm|Doctrine\\\Phpcr|Doctrine\\\MongoDB|Doctrine\\\CouchDB)\\\(.*)@';

/**
* The class name managed by the admin class
Expand Down Expand Up @@ -957,8 +957,8 @@ public function getBaseRoutePattern()
);
} else {

$this->baseRoutePattern = sprintf('/%s/%s/%s',
$this->urlize($matches[1], '-'),
$this->baseRoutePattern = sprintf('/%s%s/%s',
empty($matches[1]) ? '' : $this->urlize($matches[1], '-').'/',
$this->urlize($matches[3], '-'),
$this->urlize($matches[5], '-')
);
Expand Down Expand Up @@ -990,9 +990,8 @@ public function getBaseRouteName()
$this->urlize($matches[5])
);
} else {

$this->baseRouteName = sprintf('admin_%s_%s_%s',
$this->urlize($matches[1]),
$this->baseRouteName = sprintf('admin_%s%s_%s',
empty($matches[1]) ? '' : $this->urlize($matches[1]).'_',
$this->urlize($matches[3]),
$this->urlize($matches[5])
);
Expand Down
14 changes: 11 additions & 3 deletions Tests/Admin/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,10 @@ public function provideGetBaseRoutePattern()
'Symfony\Cmf\Bundle\FooBundle\Doctrine\CouchDB\Menu',
'/cmf/foo/menu'
),
array(
'AppBundle\Entity\User',
'/app/user'
),
);
}

Expand All @@ -463,7 +467,7 @@ public function testGetBaseRoutePatternWithChildAdmin()
*/
public function testGetBaseRoutePatternWithUnreconizedClassname()
{
$admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
$admin = new PostAdmin('sonata.post.admin.post', 'News\Entity\Post', 'SonataNewsBundle:PostAdmin');
$admin->getBaseRoutePattern();
}

Expand Down Expand Up @@ -510,7 +514,7 @@ public function provideGetBaseRouteName()
'Symfony\Bundle\BarBarBundle\Doctrine\Phpcr\Menu\Item',
'admin_symfony_barbar_menu_item'
),
array(
array(
'Symfony\Cmf\Bundle\FooBundle\Doctrine\Orm\Menu',
'admin_cmf_foo_menu'
),
Expand All @@ -522,6 +526,10 @@ public function provideGetBaseRouteName()
'Symfony\Cmf\Bundle\FooBundle\Doctrine\CouchDB\Menu',
'admin_cmf_foo_menu'
),
array(
'AppBundle\Entity\User',
'admin_app_user'
),
);
}

Expand Down Expand Up @@ -570,7 +578,7 @@ public function testGetBaseRouteNameWithChildAdmin()
*/
public function testGetBaseRouteNameWithUnreconizedClassname()
{
$admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'SonataNewsBundle:PostAdmin');
$admin = new PostAdmin('sonata.post.admin.post', 'News\Entity\Post', 'SonataNewsBundle:PostAdmin');
$admin->getBaseRouteName();
}

Expand Down

0 comments on commit 03db550

Please sign in to comment.