|
@@ -2782,37 +2782,43 @@ EOT;
|
|
|
{
|
|
|
$list = array();
|
|
|
|
|
|
- if (in_array($action, array('tree', 'show', 'edit', 'delete', 'list', 'batch'))) {
|
|
|
+ if (in_array($action, array('tree', 'show', 'edit', 'delete', 'list', 'batch')) && $this->hasAccess('create')) {
|
|
|
$list['create'] = array(
|
|
|
'template' => 'SonataAdminBundle:Button:create_button.html.twig',
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- if (in_array($action, array('show', 'delete', 'acl', 'history')) && $object) {
|
|
|
+ if (in_array($action, array('show', 'delete', 'acl', 'history')) && $this->canAccessObject('edit', $object)) {
|
|
|
$list['edit'] = array(
|
|
|
'template' => 'SonataAdminBundle:Button:edit_button.html.twig',
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- if (in_array($action, array('show', 'edit', 'acl')) && $object) {
|
|
|
+ if (in_array($action, array('show', 'edit', 'acl')) && $this->canAccessObject('history', $object)) {
|
|
|
$list['history'] = array(
|
|
|
'template' => 'SonataAdminBundle:Button:history_button.html.twig',
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- if (in_array($action, array('edit', 'history')) && $object) {
|
|
|
+ if (in_array($action, array('edit', 'history'))
|
|
|
+ && $this->isAclEnabled()
|
|
|
+ && $this->canAccessObject('acl', $object)
|
|
|
+ ) {
|
|
|
$list['acl'] = array(
|
|
|
'template' => 'SonataAdminBundle:Button:acl_button.html.twig',
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- if (in_array($action, array('edit', 'history', 'acl')) && $object) {
|
|
|
+ if (in_array($action, array('edit', 'history', 'acl'))
|
|
|
+ && $this->canAccessObject('show', $object)
|
|
|
+ && count($this->getShow()) > 0
|
|
|
+ ) {
|
|
|
$list['show'] = array(
|
|
|
'template' => 'SonataAdminBundle:Button:show_button.html.twig',
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- if (in_array($action, array('show', 'edit', 'delete', 'acl', 'batch'))) {
|
|
|
+ if (in_array($action, array('show', 'edit', 'delete', 'acl', 'batch')) && $this->hasAccess('list')) {
|
|
|
$list['list'] = array(
|
|
|
'template' => 'SonataAdminBundle:Button:list_button.html.twig',
|
|
|
);
|
|
@@ -3197,4 +3203,17 @@ EOT;
|
|
|
$extension->configureRoutes($this, $this->routes);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Check object existence and access, without throw Exception.
|
|
|
+ *
|
|
|
+ * @param string $action
|
|
|
+ * @param object $object
|
|
|
+ *
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ private function canAccessObject($action, $object)
|
|
|
+ {
|
|
|
+ return $object && $this->id($object) && $this->hasAccess($action, $object);
|
|
|
+ }
|
|
|
}
|