site->settings(); $result = $this->factory->create($settings)->check(); if (! $result['ok']) { \WP_CLI::error(Translator::text($result['message'])); return; } // wie im Backend: das ermittelte Kürzel merken, damit der nächste Aufruf nicht nachfragt if (($result['organization'] ?? '') !== '' && $result['organization'] !== $settings->organization) { $this->site->saveSettings($settings->withOrganization($result['organization'])); } \WP_CLI::success(Translator::text(Message::of('connection.ok_organization', [ 'organization' => $result['organization_name'] ?? ($result['organization'] ?? ''), ]))); } /** * Adds the addresses of this site to DomainWarn monitoring. * * ## EXAMPLES * * wp domainwarn sync */ public function sync(): void { $settings = $this->site->settings(); if (! $settings->complete()) { \WP_CLI::error(Translator::text(Message::of('connection.missing_config'))); } try { $result = (new DomainSync($this->factory->create($settings)))->run( $this->site->siteUrls(), $settings->customerName !== '' ? $settings->customerName : null, ); } catch (TransportException $e) { \WP_CLI::error(Translator::text(Message::of('connection.unreachable', ['detail' => $e->getMessage()]))); return; } foreach ($result['created'] as $name) { \WP_CLI::log(Translator::text(Message::of('sync.created', ['name' => $name]))); } foreach ($result['existing'] as $name) { \WP_CLI::log(Translator::text(Message::of('sync.existing', ['name' => $name]))); } foreach ($result['failed'] as $name => $detail) { \WP_CLI::warning(Translator::text(Message::of('sync.failed', ['name' => $name, 'detail' => $detail]))); } $text = Translator::text(Message::of('sync.summary', [ 'created' => count($result['created']), 'existing' => count($result['existing']), 'failed' => count($result['failed']), ])); $result['failed'] === [] ? \WP_CLI::success($text) : \WP_CLI::warning($text); } /** * Reports version, extensions and mail setup to DomainWarn, sends the heartbeat and refreshes the dashboard widget. * * ## EXAMPLES * * wp domainwarn report */ public function report(): void { try { // von Hand angestoßen: die Kennzahlen im Dashboard-Widget gleich mit erneuern, nicht erst zur vollen Stunde $lines = $this->report->run(true); } catch (TransportException $e) { \WP_CLI::error(Translator::text(Message::of('connection.unreachable', ['detail' => $e->getMessage()]))); return; } foreach ($lines as $line) { \WP_CLI::log(($line['host'] !== null ? $line['host'].': ' : '').Translator::text($line['message'])); } } }