Skip to content

Commit

Permalink
refactor: deprecate the scaffold.disable_sidebar config option
Browse files Browse the repository at this point in the history
We can now set `scaffold.sidebar_navigation` to false to disable the sidebar, and thus can remove that setting.
  • Loading branch information
josegonzalez committed Dec 6, 2016
1 parent b3e3db6 commit 2c14cbc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 38 deletions.
24 changes: 0 additions & 24 deletions docs/customizing-templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -215,30 +215,6 @@ title for any of the fields by using the ``scaffold.fields`` configuration
}
}
Disabling the Sidebar
---------------------

There are cases where you may wish to disable the sidebar. For instance, you
may be implementing crud-view for just a single table, or have all navigation
in your header. You can disable it using the ``scaffold.disable_sidebar``
configuration key:


.. code-block:: php
<?php
namespace App\Controller;
class ArticlesController extends AppController
{
public function beforeFilter()
{
parent::beforeFilter();
$action = $this->Crud->action();
$action->config('scaffold.disable_sidebar', false);
}
}
Overriding Template Parts
-------------------------

Expand Down
9 changes: 8 additions & 1 deletion src/Listener/Traits/SidebarNavigationTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ trait SidebarNavigationTrait
public function beforeRenderSidebarNavigation(Event $event)
{
$controller = $this->_controller();
$controller->set('sidebarNavigation', $this->_getSidebarNavigation());
$sidebarNavigation = $this->_getSidebarNavigation();
$controller->set('disableSidebar', ($sidebarNavigation === false) ? true : false);
$controller->set('sidebarNavigation', $sidebarNavigation);
}

/**
Expand All @@ -26,6 +28,11 @@ protected function _getSidebarNavigation()
{
$action = $this->_action();

// deprecated check
if ($action->config('scaffold.disable_sidebar')) {
return false;
}

return $action->config('scaffold.sidebar_navigation');
}
}
13 changes: 0 additions & 13 deletions src/Listener/ViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public function beforeRender(Event $event)
$controller->set('viewblocks', $this->_getViewBlocks());
$controller->set('formUrl', $this->_getFormUrl());
$controller->set('disableExtraButtons', $this->_getDisableExtraButtons());
$controller->set('disableSidebar', $this->_getDisableSidebar());
$controller->set('extraButtonsBlacklist', $this->_getExtraButtonsBlacklist());
$controller->set('enableDirtyCheck', $this->_getEnableDirtyCheck());
$controller->set('actionGroups', $this->_getActionGroups());
Expand Down Expand Up @@ -590,18 +589,6 @@ protected function _getDisableExtraButtons()
return $action->config('scaffold.disable_extra_buttons') ?: false;
}

/**
* Disable sidebar.
*
* @return bool
*/
protected function _getDisableSidebar()
{
$action = $this->_action();

return $action->config('scaffold.disable_sidebar') ?: false;
}

/**
* Get extra buttons blacklist
*
Expand Down

0 comments on commit 2c14cbc

Please sign in to comment.