AbstractService.php 4.35 KB
Newer Older
llaffont's avatar
llaffont committed
1 2 3 4
<?php
/**
 * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
 *
Laurent's avatar
Laurent committed
5
 * BOKEH is free software; you can redistribute it and/or modify
llaffont's avatar
llaffont committed
6 7 8 9 10 11
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation.
 *
 * There are special exceptions to the terms and conditions of the AGPL as it
 * is applied to this software (see README file).
 *
Laurent's avatar
Laurent committed
12
 * BOKEH is distributed in the hope that it will be useful,
llaffont's avatar
llaffont committed
13 14 15 16 17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
Laurent's avatar
Laurent committed
18
 * along with BOKEH; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
llaffont's avatar
llaffont committed
20 21 22
 */

abstract class Class_WebService_SIGB_AbstractService {
23
  use Trait_Translator;
24

25 26 27 28 29 30 31
  const
    COMMUNICATION_OK = 'ok',
    COMMUNICATION_ERROR = 'error',
    COMMUNICATION_NOT_IMPLEMENTED = 'na';



32 33
  protected static $_logger;
  protected $_notice_cache;
llaffont's avatar
llaffont committed
34

35 36 37 38 39 40
  /**
   * @return Class_WebService_SIGB_AbstractService
   */
  public static function newInstance() {
    return new static();
  }
41

llaffont's avatar
llaffont committed
42

43 44 45
  public static function setLogger($logger) {
    static::$_logger = $logger;
  }
46 47


48 49 50 51 52
  public static function log() {
    if (!static::$_logger)
      return;
    static::$_logger->log();
  }
53 54


55 56 57 58 59
  public static function logError($url, $message) {
    if (!static::$_logger)
      return;
    static::$_logger->logError($url, $message);
  }
60 61


62
  public function getReservationsOf($emprunteur) {
63
    return [];
64
  }
llaffont's avatar
llaffont committed
65 66


67
  public function getEmpruntsOf($emprunteur) {
68
    return [];
69
  }
llaffont's avatar
llaffont committed
70 71


72 73 74
  public function getPopupUrlForUserInformations($user) {
    return null;
  }
llaffont's avatar
llaffont committed
75 76


77 78 79 80 81
  public function getNoticeCache() {
    if (!isset($this->_notice_cache))
      $this->_notice_cache = new Class_WebService_SIGB_NoticeCache($this);
    return $this->_notice_cache;
  }
llaffont's avatar
llaffont committed
82 83


84 85 86
  public function cacheNotice($notice) {
    $this->getNoticeCache()->cacheNotice($notice);
  }
llaffont's avatar
llaffont committed
87 88


89 90 91
  public function getExemplaire($notice_id, $code_barre){
    return $this->getNoticeCache()->getExemplaire($notice_id, $code_barre);
  }
llaffont's avatar
llaffont committed
92 93


94
  public function saveEmprunteur($emprunteur) {}
llaffont's avatar
llaffont committed
95 96


97 98 99
  public function isConnected() {
    return true;
  }
llaffont's avatar
llaffont committed
100 101


102 103 104
  public function providesPickupLocations() {
    return false;
  }
105 106


Ghislain Loas's avatar
Ghislain Loas committed
107 108 109 110 111
  public function providesChangePasswordService() {
    return false;
  }


112 113 114
  public function pickupLocationsFor($user, $item) {
    return [];
  }
115 116


117 118 119
  public function providesSuggestions() {
    return false;
  }
120 121


122 123 124
  public function suggestionsOf($user) {
    return [];
  }
125 126


127 128 129
  public function newBuySuggestForm() {
    return new ZendAfi_Form_SuggestionAchat();
  }
130 131


132 133 134
  public function suggest($suggestion) {
    return $this->_error($this->_('Suggestions non prises en charge par ce connecteur'));
  }
135 136


efalcy's avatar
efalcy committed
137 138
  public function loansHistory($borrower) {
    return new Class_WebService_SIGB_LoansHistory($borrower);
139 140 141
  }


142
  public function providesLoansHistory() {
143
    return false;
144 145 146
  }


147 148 149
  protected function _success() {
    return ['statut' => true, 'erreur' => ''];
  }
llaffont's avatar
llaffont committed
150 151


152 153 154
  protected function _error($message) {
    return ['statut' => false, 'erreur' => $message];
  }
155

156

157 158 159
  public function isPergame() {
    return false;
  }
160 161


162 163 164
  public function test() {
    return $this->_('Ce service n\'est pas testable');
  }
165 166


167 168 169 170 171
  public function testCommunicationStatus() {
    return static::COMMUNICATION_NOT_IMPLEMENTED;
  }


Patrick Barroca's avatar
Patrick Barroca committed
172 173 174 175 176
  public function getServiceName() {
    return preg_replace('/.*_(.*)_Service/', '$1', get_class($this));
  }


lbrun's avatar
lbrun committed
177
  public function canConsult($field) {
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
    return false;
  }


  public function hasOnSiteConsultation() {
    return false;
  }


  public function getAvailableItems() {
    return [];
  }


  public function placeConsultationRequest() {
    return [];
  }


  public function cancelConsultationRequest() {
    return [];
  }


  public function getConsultationRequests() {
    return [];
  }
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219


  abstract public function getServerRoot();

  abstract public function getEmprunteur($user);

  abstract public function getUserAnnexe($user);

  abstract public function reserverExemplaire($user, $exemplaire, $code_annexe);

  abstract public function supprimerReservation($user, $reservation_id);

  abstract public function prolongerPret($user, $pret_id);

  abstract public function getNotice($id);
220
}