| | |
| | | <?php |
| | | namespace JVBase\registrar\helpers; |
| | | |
| | | use JVBase\integrations\ServiceMap; |
| | | use JVBase\registrar\config\Integration; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\base\Site; |
| | |
| | | } |
| | | |
| | | class AddIntegrationFields { |
| | | use ServiceMap; |
| | | protected string $service_name; |
| | | private Registrar $registrar; |
| | | protected Integration $config; |
| | |
| | | |
| | | public function getIntegrationFields():array |
| | | { |
| | | if (!$this->getService($this->service_name)) { |
| | | error_log('Attempted to connect to unsupported service: '.$this->service_name); |
| | | return []; |
| | | } |
| | | $fields = [ |
| | | 'share_to_'.$this->service_name => [ |
| | | 'type' => 'true_false', |
| | |
| | | 'default' => 1, |
| | | ]; |
| | | } |
| | | $additional = JVB()->connect($this->service_name)->getAdditionalFields($this->config->getContentType()); |
| | | |
| | | $additional = $this->getService($this->service_name)->getAdditionalFields($this->config->getContentType()); |
| | | if (!empty($additional)) { |
| | | $additional = array_combine( |
| | | array_map(fn($k) => str_starts_with($k, '_'.$this->service_name) ? $k : "_{$this->service_name}_{$k}", array_keys($additional)), |