<?php
 namespace Moto\Twig\Extension; use Moto; class LiveChatExtension extends AbstractExtension { protected $_name = 'motoLiveChat'; protected static $_settings; public function getGlobals() { return array( 'LiveChat' => $this ); } protected static function _loadSettings() { if (static::$_settings) { return; } static::$_settings = Moto\Website\Settings::get('integration_live_chat'); } protected static function _getSettings($name = null, $default = null) { return Moto\Util::getValue(static::$_settings, $name, $default); } protected function _onInitRuntime() { parent::_onInitRuntime(); static::_loadSettings(); } public function getProviderName() { return static::_getSettings('provider', 'none'); } public function isEnabled() { return ($this->getProviderName() !== 'none'); } public function isAllowOnPage($page = null) { if (!$this->isEnabled()) { return false; } if (!($page instanceof Moto\Website\ContentPage)) { return false; } return true; } public function exportFrontendSettings() { $settings = [ 'provider' => $this->getProviderName(), 'options' => static::_getSettings('providers.' . $this->getProviderName()), ]; return $this->_returnTemplate(json_encode((object) $settings)); } } 