Skip to content

Commit

Permalink
New register contact sidebar event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Oct 4, 2017
1 parent 373ed1b commit 26cd8f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
<?php

namespace Modules\Contact\Sidebar;
namespace Modules\Contact\Events\Handlers;

use Maatwebsite\Sidebar\Group;
use Maatwebsite\Sidebar\Item;
use Maatwebsite\Sidebar\Menu;
use Modules\User\Contracts\Authentication;
use Modules\Core\Sidebar\AbstractAdminSidebar;

class SidebarExtender implements \Maatwebsite\Sidebar\SidebarExtender
class RegisterContactSidebar extends AbstractAdminSidebar
{
/**
* @var Authentication
*/
protected $auth;

/**
* @param Authentication $auth
*
* @internal param Guard $guard
*/
public function __construct(Authentication $auth)
{
$this->auth = $auth;
}

/**
* Method used to define your sidebar menu groups and items
* @param Menu $menu
*
* @return Menu
*/
public function extendWith(Menu $menu)
{
$menu->group(trans('core::sidebar.content'), function (Group $group) {
$group->item('Contact requests', function (Item $item) {
$item->icon('fa fa-envelope-o');
$item->weight(0);
$item->weight(config('asgard.contact.config.sidebar-position', 15));
$item->route('admin.contact.contactrequest.index');
$item->authorize(
$this->auth->hasAccess('contact.contactrequests.index')
Expand Down
10 changes: 9 additions & 1 deletion Providers/ContactServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\ServiceProvider;
use Modules\Contact\Entities\ContactRequest;
use Modules\Contact\Events\Handlers\RegisterContactSidebar;
use Modules\Contact\Repositories\Cache\CacheContactRequestDecorator;
use Modules\Contact\Repositories\ContactRequestRepository;
use Modules\Contact\Repositories\Eloquent\EloquentContactRequestRepository;
use Modules\Core\Events\BuildingSidebar;
use Modules\Core\Traits\CanGetSidebarClassForModule;
use Modules\Core\Traits\CanPublishConfiguration;

class ContactServiceProvider extends ServiceProvider
{
use CanPublishConfiguration;
use CanPublishConfiguration, CanGetSidebarClassForModule;
/**
* Indicates if loading of the provider is deferred.
*
Expand All @@ -29,6 +32,11 @@ public function register()
{
$this->registerBindings();
$this->registerFactories();

$this->app['events']->listen(
BuildingSidebar::class,
$this->getSidebarClassForModule('contact', RegisterContactSidebar::class)
);
}

public function boot()
Expand Down
9 changes: 9 additions & 0 deletions changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
url: https://github.com/AsgardCms/Block
versions:
"3.0.0":
added:
- AsgardCMS v3 support
- Read the sidebar position from configuration file, default to 15
- New <code>RegisterContactSidebar</code> class
changed:
- Removed usages of <code>URL::route()</code> in favor of <code>route()</code>

0 comments on commit 26cd8f3

Please sign in to comment.