. */ namespace SP\Services; use DI\Container; use Psr\Container\ContainerInterface; use SP\Config\Config; use SP\Core\Context\ContextInterface; use SP\Core\Context\SessionContext; use SP\Core\Context\StatelessContext; use SP\Core\Events\EventDispatcher; /** * Class Service * * @package SP\Services */ abstract class Service { const STATUS_INTERNAL_ERROR = 1000; /** * @var Config */ protected $config; /** * @var SessionContext|StatelessContext */ protected $context; /** * @var EventDispatcher */ protected $eventDispatcher; /** * @var ContainerInterface */ protected $dic; /** * Service constructor. * * @param Container $dic * @throws \DI\DependencyException * @throws \DI\NotFoundException */ public function __construct(Container $dic) { $this->dic = $dic; $this->config = $dic->get(Config::class); $this->context = $dic->get(ContextInterface::class); $this->eventDispatcher = $dic->get(EventDispatcher::class); if (method_exists($this, 'initialize')) { $this->initialize(); } } }