2017-01-16 22:21:11 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace BusinessLogic\Category;
|
|
|
|
|
|
2017-01-28 22:35:42 -05:00
|
|
|
use BusinessLogic\Security\UserContext;
|
2017-01-16 22:21:11 -05:00
|
|
|
use DataAccess\CategoryGateway;
|
|
|
|
|
|
|
|
|
|
class CategoryRetriever {
|
2017-01-28 01:28:53 -05:00
|
|
|
/**
|
|
|
|
|
* @var CategoryGateway
|
|
|
|
|
*/
|
|
|
|
|
private $categoryGateway;
|
2017-01-16 22:21:11 -05:00
|
|
|
|
2017-01-28 01:28:53 -05:00
|
|
|
function __construct($categoryGateway) {
|
|
|
|
|
$this->categoryGateway = $categoryGateway;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-28 22:35:42 -05:00
|
|
|
/**
|
|
|
|
|
* @param $heskSettings array
|
|
|
|
|
* @param $userContext UserContext
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
function getAllCategories($heskSettings, $userContext) {
|
|
|
|
|
$categories = $this->categoryGateway->getAllCategories($heskSettings);
|
|
|
|
|
|
|
|
|
|
foreach ($categories as $category) {
|
|
|
|
|
$category->accessible = $userContext->admin ||
|
|
|
|
|
in_array($category->id, $userContext->categories);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $categories;
|
2017-01-16 22:21:11 -05:00
|
|
|
}
|
|
|
|
|
}
|