public function serialize(ScheduledTask $scheduledTask)
    {
        return [
            'id' => $scheduledTask->getId(),
            'type' => $scheduledTask->getType(),
            'name' => $scheduledTask->getName(),
            'scheduledDate' => $scheduledTask->getScheduledDate()->format('Y-m-d\TH:i:s'),
            'data' => $scheduledTask->getData(),
            'meta' => [
                'lastExecution' => $scheduledTask->getExecutionDate() ? $scheduledTask->getExecutionDate()->format('Y-m-d\TH:i:s') : null,
            ],
            'users' => array_map(function (User $user) {
                return $this->userSerializer->serialize($user);
            }, $scheduledTask->getUsers()),
            'workspace' => $scheduledTask->getWorkspace() ? $this->workspaceSerializer->serialize($scheduledTask->getWorkspace(), ['minimal']) : null,
            'group' => $scheduledTask->getGroup() ? [ // todo : use GroupSerializer when available
                'id' => $scheduledTask->getGroup()->getId(),
                'name' => $scheduledTask->getGroup()->getName(),
            ] : null,
        ];
    }
public function serialize(ScheduledTask $scheduledTask)
    {
        return [
            'id' => $scheduledTask->getId(),
            'type' => $scheduledTask->getType(),
            'name' => $scheduledTask->getName(),
            'scheduledDate' => $scheduledTask->getScheduledDate()->format('Y-m-d\TH:i:s'),
            'data' => $scheduledTask->getData(),
            'meta' => [
                'lastExecution' => $scheduledTask->getExecutionDate() ? $scheduledTask->getExecutionDate()->format('Y-m-d\TH:i:s') : null,
            ],
            'users' => array_map(function (User $user) {
                return $this->userSerializer->serialize($user);
            }, $scheduledTask->getUsers()),
            'workspace' => $scheduledTask->getWorkspace() ? $this->workspaceSerializer->serialize($scheduledTask->getWorkspace(), ['minimal']) : null,
            'group' => $scheduledTask->getGroup() ? [ // todo : use GroupSerializer when available
                'id' => $scheduledTask->getGroup()->getId(),
                'name' => $scheduledTask->getGroup()->getName(),
            ] : null,
        ];
    }
public function serialize ( ScheduledTask $ scheduledTask ) { return [ 'id' => $ scheduledTask -> getId ( ) , 'type' => $ scheduledTask -> getType ( ) , 'name' => $ scheduledTask -> getName ( ) , 'scheduledDate' => $ scheduledTask -> getScheduledDate ( ) -> format ( 'Y-m-d\TH:i:s' ) , 'data' => $ scheduledTask -> getData ( ) , 'meta' => [ 'lastExecution' => $ scheduledTask -> getExecutionDate ( ) ? $ scheduledTask -> getExecutionDate ( ) -> format ( 'Y-m-d\TH:i:s' ) : null , ] , 'users' => array_map ( function ( User $ user ) { return $ this -> userSerializer -> serialize ( $ user ) ; } , $ scheduledTask -> getUsers ( ) ) , 'workspace' => $ scheduledTask -> getWorkspace ( ) ? $ this -> workspaceSerializer -> serialize ( $ scheduledTask -> getWorkspace ( ) , [ 'minimal' ] ) : null , 'group' => $ scheduledTask -> getGroup ( ) ? [ // todo : use GroupSerializer when available 'id' => $ scheduledTask -> getGroup ( ) -> getId ( ) , 'name' => $ scheduledTask -> getGroup ( ) -> getName ( ) , ] : null , ] ; }
Serializes a ScheduledTask entity for the JSON api.

@param ScheduledTask $scheduledTask - the task to serialize

@return array - the serialized representation of the task
Serializes a ScheduledTask entity for the JSON api .