Serializes a ScheduledTask entity for the JSON api.

@param ScheduledTask $scheduledTask - the task to serialize

@return array - the serialized representation of the task
551911
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,
        ];
    }
722922
private Task taskToBeRescheduled(Task task) {
        Task taskToBeRetried = task.copy();
        taskToBeRetried.setTaskId(IDGenerator.generate());
        taskToBeRetried.setRetriedTaskId(task.getTaskId());
        taskToBeRetried.setStatus(SCHEDULED);
        taskToBeRetried.setRetryCount(task.getRetryCount() + 1);
        taskToBeRetried.setRetried(false);
        taskToBeRetried.setPollCount(0);
        taskToBeRetried.setCallbackAfterSeconds(0);
        task.setRetried(true);
        return taskToBeRetried;
    }
801903
public function serialize(PaymentsRequestInterface $request)
    {
        $result = array();
        foreach (self::$propertyMap as $property => $name) {
            $value = $request->{$property};
            if (!empty($value)) {
                if ($value instanceof \DateTime) {
                    if ($value->getTimestamp() > 1) {
                        $result[$name] = $value->format(DATE_ATOM);
                    }
                } else {
                    $result[$name] = $value;
                }
            }
        }
        return $result;
    }
114127
def serialized_task(self, task: Task) -> Tuple[str, str]:
        
        return f"{task.hash}.json", task.json
489045
public function saveAdditionalFields(
        array $submittedData,
        AbstractTask $task
    ) {
        /** @var $task ReIndexTask */
        if (!$this->isTaskInstanceofReIndexTask($task)) {
            return;
        }

        $task->setRootPageId($submittedData['site']);

        $indexingConfigurations = [];
        if (!empty($submittedData['indexingConfigurations'])) {
            $indexingConfigurations = $submittedData['indexingConfigurations'];
        }
        $task->setIndexingConfigurationsToReIndex($indexingConfigurations);
    }
941479
private function scheduleTask(TaskInterface $task, array $workload)
    {
        return $this->taskScheduler->createTask($task->getHandlerClass(), $workload)
            ->executeAt($task->getSchedule())
            ->schedule();
    }
1333359
public static function scheduled_task_from_record($record) {
        $classname = self::get_canonical_class_name($record->classname);
        if (!class_exists($classname)) {
            debugging("Failed to load task: " . $classname, DEBUG_DEVELOPER);
            return false;
        }
        /** @var \core\task\scheduled_task $task */
        $task = new $classname;
        if (isset($record->lastruntime)) {
            $task->set_last_run_time($record->lastruntime);
        }
        if (isset($record->nextruntime)) {
            $task->set_next_run_time($record->nextruntime);
        }
        if (isset($record->customised)) {
            $task->set_customised($record->customised);
        }
        if (isset($record->component)) {
            $task->set_component($record->component);
        }
        $task->set_blocking(!empty($record->blocking));
        if (isset($record->minute)) {
            $task->set_minute($record->minute);
        }
        if (isset($record->hour)) {
            $task->set_hour($record->hour);
        }
        if (isset($record->day)) {
            $task->set_day($record->day);
        }
        if (isset($record->month)) {
            $task->set_month($record->month);
        }
        if (isset($record->dayofweek)) {
            $task->set_day_of_week($record->dayofweek);
        }
        if (isset($record->faildelay)) {
            $task->set_fail_delay($record->faildelay);
        }
        if (isset($record->disabled)) {
            $task->set_disabled($record->disabled);
        }

        return $task;
    }
1331687
protected function schedule(Schedule $schedule)
    {
        parent::schedule($schedule);

        // Activate scheduled posts
        $schedule->call(function() {
            $content = Content::where('status_scheduled', '<=', Carbon::now())->get();

            foreach ($content as $item) {
                $item->status = 1;
                $item->status_scheduled = null;
                $item->save();
            }
        })->everyMinute();
    }
1077014
public static function get_scheduled_task($classname) {
        global $DB;

        $classname = self::get_canonical_class_name($classname);
        // We are just reading - so no locks required.
        $record = $DB->get_record('task_scheduled', array('classname'=>$classname), '*', IGNORE_MISSING);
        if (!$record) {
            return false;
        }
        return self::scheduled_task_from_record($record);
    }
96298
public function serialize()
    {
        $request = $this->requestStack->getCurrentRequest();

        $logo = $this->fileUtilities->getOneBy([
            'url' => $this->config->getParameter('logo'),
        ]);

        return [
            'maintenance' => MaintenanceHandler::isMaintenanceEnabled(),
            'logo' => $logo ? [
                'url' => $logo->getUrl(),
                'colorized' => 'image/svg+xml' === $logo->getMimeType(),
            ] : null,
            'logo_redirect_home' => $this->config->getParameter('logo_redirect_home'),
            'name' => $this->config->getParameter('name'),
            'secondaryName' => $this->config->getParameter('secondary_name'),
            'description' => null, // the one for the current locale
            'version' => $this->versionManager->getDistributionVersion(),
            'environment' => $this->env,
            'links' => $this->serializeLinks(),
            'asset' => $this->assets->getUrl(''),
            'server' => [
                'protocol' => $request->isSecure() || $this->config->getParameter('ssl_enabled') ? 'https' : 'http',
                'host' => $this->config->getParameter('domain_name') ? $this->config->getParameter('domain_name') : $request->getHost(),
                'path' => $request->getBasePath(),
            ],
            'theme' => $this->serializeTheme(),
            'locale' => $this->serializeLocale(),
            'openGraph' => [
                'enabled' => $this->config->getParameter('enable_opengraph'),
            ],
            'resources' => [
                'types' => array_map(function (ResourceType $resourceType) {
                    return $this->resourceTypeSerializer->serialize($resourceType);
                }, $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll()),
                'softDelete' => $this->config->getParameter('resource.soft_delete'),
            ],
            'plugins' => $this->pluginManager->getEnabled(true),
            'javascripts' => $this->config->getParameter('javascripts'),
        ];
    }
169797
public function getTaskList()
    {
        $propertyList = $this->_getEntityList('Tasks');
        $result = [];

        foreach ($propertyList as $properties) {
            $result[] = Task::createFromOptions($properties);
        }

        return $result;
    }
1038717
public function serialize(Resource $resource)
    {
        return [
            'id' => $resource->getUuid(),
            'name' => $resource->getName(),
            'resourceType' => $this->resourceTypeSerializer->serialize($resource->getResourceType()),
            'maxTimeReservation' => $resource->getMaxTimeReservation(),
            'description' => $resource->getDescription(),
            'localization' => $resource->getLocalisation(),
            'quantity' => $resource->getQuantity(),
            'color' => $resource->getColor(),
            'organizations' => $this->getOrganizations($resource),
            'resourceRights' => $this->getResourceRights($resource),
        ];
    }
296421
public function runEvent(Request $request)
    {
        $scheduling = new Scheduling();

        try {
            $output = $scheduling->runTask($request->get('id'));

            return [
                'status'    => true,
                'message'   => 'success',
                'data'      => $output,
            ];
        } catch (\Exception $e) {
            return [
                'status'    => false,
                'message'   => 'failed',
                'data'      => $e->getMessage(),
            ];
        }
    }
32739
function jsonSerialize()
    {
        return [
            'success' => $this->success,
            'message' => $this->message,
            'error'   => $this->getError(),
            'data'    => SerializerBuilder::create()->build()->serialize(
                $this->data,
                'json',
                SerializationContext::create()->setGroups($this->groups)
            ),
        ];
    }
567463
public function serialize(ResourceEvaluation $resourceEvaluation)
    {
        $serialized = [
            'id' => $resourceEvaluation->getId(),
            'date' => $resourceEvaluation->getDate() ? $resourceEvaluation->getDate()->format('Y-m-d H:i') : null,
            'status' => $resourceEvaluation->getStatus(),
            'duration' => $resourceEvaluation->getDuration(),
            'score' => $resourceEvaluation->getScore(),
            'scoreMin' => $resourceEvaluation->getScoreMin(),
            'scoreMax' => $resourceEvaluation->getScoreMax(),
            'customScore' => $resourceEvaluation->getCustomScore(),
            'progression' => $resourceEvaluation->getProgression(),
            'comment' => $resourceEvaluation->getComment(),
            'data' => $resourceEvaluation->getData(),
            'resourceUserEvaluation' => $this->resourceUserEvaluationSerializer->serialize($resourceEvaluation->getResourceUserEvaluation()),
        ];

        return $serialized;
    }
503683
public function jsonSerialize() {
        return array('count' => $this->totalAmount, 
            'countOfPages' => $this->numberOfPages(), 
            'limit' => $this->amountPerPage,
            'page' => $this->currentPage, 
            'previousPage' => $this->previousPage(), 
            'nextPage' => $this->nextPage());
    }
1149527
public function jsonSerialize()
    {
        $result = array();
        foreach (get_object_vars($this) as $k => $v) {
            // $v is not checked for null like other jsonSerialize functions, all values should be defined here

            // Two special cases occur because they require sublevels in their JSON
            // encoding to be considered valid.
            if ($k == "months") {
                $result[$k] = array("month" => $this->months);
            }
            else if ($k == "weekDays") {
                $result[$k] = array("day" => $this->weekDays);
            }
            else {
                $result[$k] = $v;
            }
        }
        return array($this->name() => $result);
    }