1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Tinyissue package. |
5
|
|
|
* |
6
|
|
|
* (c) Mohamed Alsharaf <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Tinyissue\Providers; |
13
|
|
|
|
14
|
|
|
use Illuminate\Bus\Dispatcher; |
15
|
|
|
use Illuminate\Support\Collection; |
16
|
|
|
use Illuminate\Support\ServiceProvider; |
17
|
|
|
use Illuminate\View\View; |
18
|
|
|
use Tinyissue\Extensions\Auth\LoggedUser; |
19
|
|
|
use Tinyissue\Form\ExportIssues; |
20
|
|
|
use Tinyissue\Model\Project; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* ComposerServiceProvider is the view service provider binding data to specific views. |
24
|
|
|
* |
25
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class ComposerServiceProvider extends ServiceProvider |
28
|
|
|
{ |
29
|
|
|
use LoggedUser; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Bootstrap any application services. |
33
|
|
|
* |
34
|
|
|
* @param \Illuminate\Bus\Dispatcher $dispatcher |
35
|
|
|
*/ |
36
|
|
|
public function boot(Dispatcher $dispatcher) |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
// Add export form to project sidebar |
39
|
|
|
// @todo review this |
40
|
|
|
\View::composer('layouts/sidebar/project', function (View $view) { |
41
|
|
|
$exportForm = new ExportIssues($this->app); |
|
|
|
|
42
|
|
|
$exportForm->setup(['project' => $view->project]); |
43
|
|
|
|
44
|
|
|
if ($view->project instanceof Project) { |
45
|
|
|
$this->loadProjectDefaultData($view->project, $view); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$view->with('exportForm', $exportForm); |
49
|
|
|
}); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Load any variables that are default to project side bar. |
54
|
|
|
* |
55
|
|
|
* @param Project $project |
56
|
|
|
* @param View $view |
57
|
|
|
*/ |
58
|
|
|
protected function loadProjectDefaultData(Project $project, View $view) |
59
|
|
|
{ |
60
|
|
|
if (!$view->offsetExists('closed_issues_count')) { |
61
|
|
|
$view->with('closed_issues_count', $project->countClosedIssues($this->getLoggedUser())); |
|
|
|
|
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
if (!$view->offsetExists('open_issues_count')) { |
65
|
|
|
$view->with('open_issues_count', $project->countOpenIssues($this->getLoggedUser())); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if (!$view->offsetExists('project_users') || !$view->project_users instanceof Collection) { |
69
|
|
|
$view->with('project_users', $project->getUsers()); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Register any application services. |
75
|
|
|
*/ |
76
|
|
|
public function register() |
77
|
|
|
{ |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.