<?php

namespace App\Services\Equipment\Link;


use App\Services\Equipment\EquipmentService;
use CodeIgniter\HTTP\IncomingRequest;

use App\Entities\Equipment\ServerEntity;

abstract class LinkService extends EquipmentService
{
    protected function __construct(?IncomingRequest $request = null)
    {
        parent::__construct($request);
        $this->addClassName('Link');
    }
    abstract protected function getPartService();
    final public function getPartEntities(ServerEntity $serverEntity): array
    {
        $entities = [];
        foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $entity) {
            $entities[] = $this->getPartService()->getEntity($entity->getPartInfoUID());
        }
        return $entities;
    }
}
