, * term_source: list, * can_update: bool * } */ public function toArray(Request $request): array { return [ 'channel_id' => $this->resource['channel_id'], 'derived_from' => $this->ref($this->resource['derived_from']), 'wbw' => $this->ref($this->resource['wbw']), 'fallback' => array_map(fn (Channel $c) => $this->ref($c), $this->resource['fallback']), 'term_source' => array_map(fn (Channel $c) => $this->ref($c), $this->resource['term_source']), 'can_update' => $this->resource['can_update'], ]; } /** * @return array{id: string, name: string, type: string, lang: string, status: int}|null */ private function ref(?Channel $channel): ?array { return $channel === null ? null : [ 'id' => (string) $channel->uid, 'name' => (string) $channel->name, 'type' => (string) $channel->type, 'lang' => (string) $channel->lang, 'status' => (int) $channel->status, ]; } }