. */ namespace SP\Services\UserGroup; use SP\Core\Exceptions\SPException; use SP\Core\Traits\InjectableTrait; use SP\DataModel\ItemSearchData; use SP\Repositories\UserGroup\UserGroupRepository; use SP\Services\ServiceItemTrait; /** * Class UserGroupService * * @package SP\Services\UserGroup */ class UserGroupService { use InjectableTrait; use ServiceItemTrait; /** * @var UserGroupRepository */ protected $userGroupRepository; /** * UserGroup constructor. * * @throws \SP\Core\Dic\ContainerException */ public function __construct() { $this->injectDependencies(); } /** * @param UserGroupRepository $userGroupRepository */ public function inject(UserGroupRepository $userGroupRepository) { $this->userGroupRepository = $userGroupRepository; } /** * @param ItemSearchData $itemSearchData * @return \SP\DataModel\ClientData[] */ public function search(ItemSearchData $itemSearchData) { return $this->userGroupRepository->search($itemSearchData); } /** * @param $id * @return mixed */ public function getById($id) { return $this->userGroupRepository->getById($id); } /** * @param $id * @return $this * @throws SPException */ public function delete($id) { if ($this->userGroupRepository->delete($id) === 0) { throw new SPException(__u('Grupo no encontrado'), SPException::INFO); } return $this; } /** * @param $itemData * @return mixed * @throws SPException */ public function create($itemData) { return $this->userGroupRepository->create($itemData); } /** * @param $itemData * @return mixed * @throws SPException * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException */ public function update($itemData) { return $this->userGroupRepository->update($itemData); } /** * Get all items from the service's repository * * @return array */ public function getAllBasic() { return $this->userGroupRepository->getAll(); } }