1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core\Service;
13:
14: /**
15: * Xoops services manager contract boilerplate
16: *
17: * All service providers should extend this class, and implement the relevant
18: * contract interface
19: *
20: * @category Xoops\Core\Service\AbstractContract
21: * @package Xoops\Core
22: * @author Richard Griffith <richard@geekwright.com>
23: * @copyright 2013-2014 The XOOPS Project https://github.com/XOOPS/XoopsCore
24: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
25: * @version Release: 1.0
26: * @link http://xoops.org
27: * @since 2.6.0
28: */
29: abstract class AbstractContract
30: {
31: /** @var integer $priority - lowest value is highest priority */
32: protected $priority = Manager::PRIORITY_MEDIUM;
33:
34: /**
35: * setPriority - set the priority for this contract provider
36: *
37: * @param integer $priority - priority of this contract provider
38: *
39: * @return void
40: */
41: public function setPriority($priority)
42: {
43: $this->priority = (int) $priority;
44: }
45:
46: /**
47: * getPriority - get the priority for this contract provider
48: *
49: * @return integer - priority of this contract provider
50: */
51: public function getPriority()
52: {
53: return $this->priority;
54: }
55:
56: /**
57: * getMode - get the MODE for the contract. The MODE is set in the contract Interface, and
58: * permissible values defined in Manager
59: *
60: * @return integer - a MODE constant indicating how multiple services are handled
61: */
62: public function getMode()
63: {
64: $class = get_called_class();
65: return $class::MODE;
66: }
67:
68: /**
69: * getName - get a short name for this service provider. This should be unique within the
70: * scope of the named service, so using module dirname is suggested.
71: *
72: * @return string - a unique name for the service provider
73: */
74: abstract public function getName();
75:
76: /**
77: * getDescription - get human readable description of the service provider
78: *
79: * @return string
80: */
81: abstract public function getDescription();
82: }
83: