function jsonSerialize() { $result = parent::jsonSerialize(); $result['owner'] = $this->owner->simplify('className,id,name,terms,avatar,singleUrl'); $result['agent'] = $this->agent->simplify('id,name,type,terms,avatar,singleUrl'); return $result; }
function jsonSerialize() { $json = ['id' => $this->id, 'project' => $this->project->simplify('id,name,singleUrl'), 'number' => $this->number, 'category' => $this->category, 'owner' => $this->owner->simplify('id,name,singleUrl'), 'agentRelations' => [], 'files' => [], 'singleUrl' => $this->singleUrl, 'editUrl' => $this->editUrl]; if ($this->project->publishedRegistrations || $this->project->canUser('@control')) { $json['status'] = $this->status; } if ($this->canUser('view') || $this->status === self::STATUS_APPROVED || $this->status === self::STATUS_WAITLIST) { $related_agents = $this->getRelatedAgents(); foreach (App::i()->getRegisteredRegistrationAgentRelations() as $def) { $json['agentRelations'][] = ['label' => $def->label, 'description' => $def->description, 'agent' => isset($related_agents[$def->agentRelationGroupName]) ? $related_agents[$def->agentRelationGroupName][0]->simplify('id,name,singleUrl') : null]; } foreach ($this->files as $group => $file) { if ($file instanceof File) { $json['files'][$group] = $file->simplify('id,url,name,deleteUrl'); } } } else { $json['owner'] = null; } return $json; }