<?php
 namespace App\Core\EmailHosting; use App\Core\Product\AbstractProduct; abstract class AbstractEmailHosting extends AbstractProduct implements EmailHostingInterface { protected function ok(string $message = '', array $data = []): array { return ['status' => 'success', 'message' => $message, 'data' => $data]; } protected function fail(string $message, array $data = []): array { return ['status' => 'error', 'message' => $message, 'data' => $data]; } public function requiresServer(): bool { return false; } public function getClientActions(): array { $actions = parent::getClientActions(); $actions['mailboxes'] = ['label' => 'Posta Kutuları', 'icon' => 'fas fa-inbox', 'class' => 'btn-outline-primary', 'enabled' => true]; $actions['aliases'] = ['label' => 'Takma Adlar', 'icon' => 'fas fa-tags', 'class' => 'btn-outline-primary', 'enabled' => true]; $actions['forwarders'] = ['label' => 'Yönlendirmeler', 'icon' => 'fas fa-share', 'class' => 'btn-outline-primary', 'enabled' => true]; $actions['spam'] = ['label' => 'Spam Kuralları', 'icon' => 'fas fa-shield-halved', 'class' => 'btn-outline-primary', 'enabled' => true]; return $actions; } public function handleClientAction(string $action, array $params): array { $op = $params['op'] ?? 'list'; return match ($action) { 'mailboxes' => match ($op) { 'list' => $this->listMailboxes($params), 'create' => $this->createMailbox($params), 'delete' => $this->deleteMailbox($params), 'password' => $this->setMailboxPassword($params), 'quota' => $this->setMailboxQuota($params), default => $this->fail('Bilinmeyen işlem: ' . $op), }, 'aliases' => match ($op) { 'list' => $this->listAliases($params), 'create' => $this->createAlias($params), 'delete' => $this->deleteAlias($params), default => $this->fail('Bilinmeyen işlem: ' . $op), }, 'forwarders' => match ($op) { 'list' => $this->listForwarders($params), 'create' => $this->createForwarder($params), 'delete' => $this->deleteForwarder($params), default => $this->fail('Bilinmeyen işlem: ' . $op), }, 'spam' => match ($op) { 'list' => $this->listSpamRules($params), 'create' => $this->addSpamRule($params), 'delete' => $this->removeSpamRule($params), default => $this->fail('Bilinmeyen işlem: ' . $op), }, default => parent::handleClientAction($action, $params), }; } public function listMailboxes(array $params): array { return $this->ok('', ['mailboxes' => []]); } public function createMailbox(array $params): array { return $this->fail('Desteklenmiyor'); } public function deleteMailbox(array $params): array { return $this->fail('Desteklenmiyor'); } public function setMailboxPassword(array $params): array { return $this->fail('Desteklenmiyor'); } public function setMailboxQuota(array $params): array { return $this->fail('Desteklenmiyor'); } public function listAliases(array $params): array { return $this->ok('', ['aliases' => []]); } public function createAlias(array $params): array { return $this->fail('Desteklenmiyor'); } public function deleteAlias(array $params): array { return $this->fail('Desteklenmiyor'); } public function listForwarders(array $params): array { return $this->ok('', ['forwarders' => []]); } public function createForwarder(array $params): array { return $this->fail('Desteklenmiyor'); } public function deleteForwarder(array $params): array { return $this->fail('Desteklenmiyor'); } public function listSpamRules(array $params): array { return $this->ok('', ['blocklist' => [], 'whitelist' => []]); } public function addSpamRule(array $params): array { return $this->fail('Desteklenmiyor'); } public function removeSpamRule(array $params): array { return $this->fail('Desteklenmiyor'); } } 