| | |
| | | <?php |
| | | namespace JVBase\integrations; |
| | | |
| | | use JVBase\inc\managers\ErrorHelper; |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\Errors; |
| | | use JVBase\managers\IconsManager; |
| | |
| | | } |
| | | |
| | | trait _Base { |
| | | use ErrorHelper; |
| | | /** |
| | | * @var string Unique identifier for this service (ex: square, facebook) |
| | | */ |
| | |
| | | */ |
| | | public function isSetUp(): bool |
| | | { |
| | | return !empty($this->loadCredentials()); |
| | | $tmp = null; |
| | | if ($this->userID) { |
| | | $tmp = $this->userID; |
| | | $this->switchUser(); |
| | | } |
| | | $isSetUp = !empty($this->loadCredentials()??[]); |
| | | if ($tmp) { |
| | | $this->switchUser($tmp); |
| | | } |
| | | return $isSetUp; |
| | | } |
| | | |
| | | public function loadCredentials():array |
| | |
| | | |
| | | protected function logError(string $method, string $message, array $context = []):void |
| | | { |
| | | |
| | | $context['service'] = $this->service_name; |
| | | Errors::getInstance()->log('['.self::class.']'.$method, $message, $context); |
| | | Errors::log($message, array_merge( |
| | | [ |
| | | 'service' => $this->service_name, |
| | | 'method' => $method, |
| | | 'class' => static::class, |
| | | ], |
| | | $context |
| | | )); |
| | | } |
| | | |
| | | protected function getReturnURL():string |
| | |
| | | { |
| | | if (is_admin()) { |
| | | $icons = IconsManager::for('admin'); |
| | | return $icons->getRawSvg($icon); |
| | | return $icons->getRawSvg($icon)??''; |
| | | } |
| | | return jvbDashIcon($icon); |
| | | } |