| | |
| | | use JVBase\rest\routes\AdminRoutes; |
| | | use JVBase\rest\routes\IntegrationsRoutes; |
| | | use JVBase\base\SchemaHelper; |
| | | use UserRoutes; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | } |
| | | |
| | | |
| | | public function __construct() |
| | | private function __construct() |
| | | { |
| | | $this->customBlocks = new CustomBlocks(); |
| | | $this->managers = [ |
| | |
| | | 'queue' => new QueueRoutes(), |
| | | 'settings' => new SettingsRoutes(), |
| | | 'upload' => new UploadRoutes(), |
| | | 'forms' => new FormRoutes() |
| | | 'forms' => new FormRoutes(), |
| | | 'user' => new UserRoutes() |
| | | ]; |
| | | |
| | | if (Site::has('magicLink')) { |
| | | if (Site::has('magic_link')) { |
| | | // $this->routes['magicLink'] = new MagicLinkRoutes(); |
| | | $this->managers['magicLink'] = new MagicLinkManager(); |
| | | } |
| | |
| | | protected function setupIntegrations(): void |
| | | { |
| | | foreach(array_keys(Site::getIntegrations()) as $integration) { |
| | | $this->integrations[$integration] = new $this->serviceMap[$integration](); |
| | | $this->integrations[$integration] = $this->serviceMap[$integration]::getInstance(); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public function connect(string $service, ?int $userID = null): mixed |
| | | { |
| | | if ($userID) { |
| | | if (!$this->userCanConnect($service, $userID)) { |
| | | return null; |
| | | } |
| | | |
| | | if (!array_key_exists($service, $this->integrations)) { |
| | | return null; |
| | | } |
| | | return new $this->serviceMap[$service]($userID); |
| | | } |
| | | return (array_key_exists($service, $this->integrations)) ? $this->integrations[$service] : null; |
| | | // if ($userID) { |
| | | // if (!$this->userCanConnect($service, $userID)) { |
| | | // return null; |
| | | // } |
| | | // |
| | | // if (!array_key_exists($service, $this->integrations)) { |
| | | // return null; |
| | | // } |
| | | // |
| | | // return $this->serviceMap[$service]::getInstance($userID); |
| | | // } |
| | | return is_null($userID) ? |
| | | $this->integrations[$service]??null : |
| | | (array_key_exists($service, $this->integrations) ? $this->serviceMap[$service]::getInstance($userID) : null); |
| | | } |
| | | |
| | | public function userCanConnect(string $service, int $userID): bool |
| | |
| | | ?> |
| | | <section class="main-actions"> |
| | | <div class="buttons col"> |
| | | <?= implode($buttons); ?> |
| | | <?= implode('', $buttons); ?> |
| | | </div> |
| | | <div class="actions"> |
| | | <?= implode($contents); ?> |
| | | <?= implode('', $contents); ?> |
| | | </div> |
| | | </section> |
| | | <?php |