1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Statistics\Repository; 19 20use Fisharebest\Webtrees\Services\UserService; 21use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ContactRepositoryInterface; 22use Fisharebest\Webtrees\Tree; 23use Fisharebest\Webtrees\User; 24 25/** 26 * A repository providing methods for contact related statistics. 27 */ 28class ContactRepository implements ContactRepositoryInterface 29{ 30 /** 31 * @var Tree 32 */ 33 private $tree; 34 /** 35 * @var UserService 36 */ 37 private $user_service; 38 39 /** 40 * Constructor. 41 * 42 * @param Tree $tree 43 * @param UserService $user_service 44 */ 45 public function __construct(Tree $tree, UserService $user_service) 46 { 47 $this->tree = $tree; 48 $this->user_service = $user_service; 49 } 50 51 /** 52 * @inheritDoc 53 */ 54 public function contactWebmaster(): string 55 { 56 $user_id = (int) $this->tree->getPreference('WEBMASTER_USER_ID'); 57 $user = $this->user_service->find($user_id); 58 59 if ($user instanceof User) { 60 return $this->user_service->contactLink($user); 61 } 62 63 return ''; 64 } 65 66 /** 67 * @inheritDoc 68 */ 69 public function contactGedcom(): string 70 { 71 $user_id = (int) $this->tree->getPreference('CONTACT_USER_ID'); 72 $user = $this->user_service->find($user_id); 73 74 if ($user instanceof User) { 75 return $this->user_service->contactLink($user); 76 } 77 78 return ''; 79 } 80} 81