<?php
class objectiveZen extends objective
{
    /**
     * 追加团队目标。
     * Append child objective.
     *
     * @param  array $objectiveList
     * @access public
     * @return array
     */
    protected function appendChildObjective($objectiveList): array
    {
        $childObjectiveList = array();
        foreach($objectiveList as $objective)
        {
            $objective->parent = 0;
            $objective->team   = '';
            $objective->BV     = '';
            $objective->AV     = '';
            $objective->key    = $objective->id;

            if($objective->links)
            {
                $childObjectives = $this->objective->getList($objective->pi, $objective->links);
                foreach($childObjectives as $childObjective)
                {
                    $childObjective->parent = $objective->id;
                    $childObjective->key    = $objective->id . '_' . $childObjective->id;
                }
                $childObjectiveList = array_merge($childObjectiveList, $childObjectives);
            }
        }
        return array_merge($objectiveList, $childObjectiveList);
    }
}
