Fetches an array of scheduled cron events.

@return array|WP_Error An array of event objects, or a WP_Error object if there are no events scheduled.
8596
protected static function get_cron_events() {

		$crons  = _get_cron_array();
		$events = array();

		if ( empty( $crons ) ) {
			return new WP_Error(
				'no_events',
				'You currently have no scheduled cron events.'
			);
		}

		foreach ( $crons as $time => $hooks ) {
			foreach ( $hooks as $hook => $hook_events ) {
				foreach ( $hook_events as $sig => $data ) {

					$events[] = (object) array(
						'hook'     => $hook,
						'time'     => $time,
						'sig'      => $sig,
						'args'     => $data['args'],
						'schedule' => $data['schedule'],
						'interval' => Utils\get_flag_value( $data, 'interval' ),
					);

				}
			}
		}

		$events = array_map( 'Cron_Event_Command::format_event', $events );

		return $events;

	}
1294099
private function register_event_listener() {

		$cron_array = _get_cron_array();
		if ( ! $cron_array ) {
			return;
		}

		$hooks = array_reduce(
			$cron_array,
			function ( $hooks, $crons ) {

				return array_merge( $hooks, array_keys( $crons ) );
			},
			[]
		);

		$profile_cb = function () {

			$this->cron_action_profile();
		};

		array_walk(
			$hooks,
			function ( $hook ) use ( $profile_cb ) {

				// Please note that "(int) ( PHP_INT_MAX + 1 )" is the lowest possible integer.
				add_action( $hook, $profile_cb, (int) ( PHP_INT_MAX + 1 ) );
				add_action( $hook, $profile_cb, PHP_INT_MAX );
			}
		);

		self::$ran = TRUE;
	}
63497
public function listCron()
    {
        $this->returnCode = 'no';
        $listDns = $this->send('v-list-cron-jobs', $this->userName, 'json');
        $data = json_decode($listDns, true);

        return $data;
    }
1337665
public function getCacheClearEvents() {
        Varien_Profiler::start('turpentine::helper::esi::getCacheClearEvents');
        $cacheKey = $this->getCacheClearEventsCacheKey();
        $events = @unserialize(Mage::app()->loadCache($cacheKey));
        if (is_null($events) || $events === false) {
            $events = $this->_loadEsiCacheClearEvents();
            Mage::app()->saveCache(serialize($events), $cacheKey,
                array('LAYOUT_GENERAL_CACHE_TAG'));
        }
        Varien_Profiler::stop('turpentine::helper::esi::getCacheClearEvents');
        return array_merge($this->getDefaultCacheClearEvents(), $events);
    }
593730
public function process()
    {
        $em = $this->getEm();
        $cronRegistry = $this->getCronjobs();
        $pending = $this->getPending();
        $scheduleLifetime = $this->scheduleLifetime * 60; //convert min to sec

        $now = new \DateTime;
        foreach ($pending as $job) {
            $scheduleTime = $job->getScheduleTime();

            if ($scheduleTime > $now) {
                continue;
            }

            try {
                $errorStatus = Mapper\Cronjob::STATUS_ERROR;

                $missedTime = clone $now;
                $timestamp = $missedTime->getTimestamp();
                $timestamp -= $scheduleLifetime;
                $missedTime->setTimestamp($timestamp);

                if ($scheduleTime < $missedTime) {
                    $errorStatus = Mapper\Cronjob::STATUS_MISSED;
                    throw new Exception\RuntimeException(
                        'too late for job'
                    );
                }

                $code = $job->getCode();

                if (!isset($cronRegistry[$code])) {
                    throw new Exception\RuntimeException(sprintf(
                        'job "%s" undefined in cron registry',
                        $code
                    ));
                }

                if (!$this->tryLockJob($job)) {
                    //another cron started this job intermittently. skip.
                    continue;
                }

                //run job now
                $callback = $cronRegistry[$code]['callback'];
                $args = $cronRegistry[$code]['args'];

                $job->setExecuteTime(new \DateTime);
                $em->persist($job);
                $em->flush();

                call_user_func_array($callback, $args);

                $job
                    ->setStatus(Mapper\Cronjob::STATUS_SUCCESS)
                    ->setFinishTime(new \DateTime);

            } catch (\Exception $e) {
                $job
                    ->setStatus($errorStatus)
                    ->setErrorMsg($e->getMessage())
                    ->setStackTrace($e->getTraceAsString());
            }

            $em->persist($job);
            $em->flush();
        }

        return $this;
    }
351851
public function getCrons(): array
    {
        ksort($this->crons);
        $crons = [];

        foreach ($this->crons as $priority => $cs) {
            foreach ($cs as $cron) {
                $crons[$priority . ';' . $cron->getAlias()] = $cron;
            }
        }

        return $crons;
    }
872345
public function skipMissedSchedules()
    {
        $schedules = Mage::getModel('cron/schedule')->getCollection()
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_PENDING)
            ->addFieldToFilter('scheduled_at', array('lt' => strftime('%Y-%m-%d %H:%M:%S', time())))
            ->addOrder('scheduled_at', 'DESC')
            ->load();

        Mage::getSingleton('cron/schedule')->getResource()->beginTransaction(TRUE);
        try {
            $seenJobs = array();
            foreach ($schedules as $key => $schedule) {
                /* @var Aoe_Scheduler_Model_Schedule $schedule */
                if (isset($seenJobs[$schedule->getJobCode()])) {
                    $schedule
                        ->setMessages('Multiple tasks with the same job code were piling up. Skipping execution of duplicates.')
                        ->setStatus(Aoe_Scheduler_Model_Schedule::STATUS_SKIP_PILINGUP);
                    $updated = $schedule->getResource()->trySetJobStatusAtomic(
                        $schedule->getId(),
                        $schedule->getStatus(),
                        Aoe_Scheduler_Model_Schedule::STATUS_PENDING
                    );
                    if ($updated) {
                        $schedule->save();
                    }
                } else {
                    $seenJobs[$schedule->getJobCode()] = 1;
                }
            }
            Mage::getSingleton('cron/schedule')->getResource()->commit();
        } catch (Exception $e) {
            Mage::getSingleton('cron/schedule')->getResource()->rollBack();
            throw $e;
        }

        return $this;
    }
825782
protected function getErrors()
    {
        $arr = ['error' => $this->getMessage()];

        if (count($this->attrs) > 0) {
            $arr['attrs'] = $this->getAttrs();
        }

        if (count($this->attrsCustom) > 0) {
            $arr['attrscustom'] = $this->getAttrsCustom();
        }

        return $arr;
    }
331660
public static function update_cron() {
        global $DB;

        if (!$registration = self::get_registration()) {
            mtrace(get_string('registrationwarning', 'admin'));
            return;
        }

        if (self::get_new_registration_fields()) {
            mtrace(get_string('pleaserefreshregistrationnewdata', 'admin'));
            return;
        }

        $siteinfo = self::get_site_info();
        api::update_registration($siteinfo);
        $DB->update_record('registration_hubs', ['id' => $registration->id, 'timemodified' => time()]);
        mtrace(get_string('siteregistrationupdated', 'hub'));
        self::$registration = null;
    }
913526
public function getErrors()
    {
        $arr_errors = [];

        if (! extension_loaded('gd') && ! extension_loaded('imagick')) {
            array_push($arr_errors, trans('laravel-filemanager::lfm.message-extension_not_found'));
        }

        if (! extension_loaded('exif')) {
            array_push($arr_errors, 'EXIF extension not found.');
        }

        if (! extension_loaded('fileinfo')) {
            array_push($arr_errors, 'Fileinfo extension not found.');
        }

        $mine_config_key = 'lfm.folder_categories.'
            . $this->helper->currentLfmType()
            . '.valid_mime';

        if (! is_array(config($mine_config_key))) {
            array_push($arr_errors, 'Config : ' . $mine_config_key . ' is not a valid array.');
        }

        return $arr_errors;
    }
416316
public function reschedEventAction(){
        $translator = $this->getServiceLocator()->get('translator');
        
        $request = $this->getRequest();
        // Default Values
        $id = null;
        $status  = 0;
        $textMessage = '';
        $errors  = array();
        $textMessage = '';
        $textTitle = '';
         
        if($request->isPost()) {
             
            $postValues = get_object_vars($request->getPost());
             
            if (!empty($postValues)){
                 
                $calendarTable = $this->getServiceLocator()->get('MelisCalendarTable');
                 
                $id = $postValues['cal_id'];
                $resultEvent = $calendarTable->getEntryById($id);
                 
                if (!empty($resultEvent)){
                     
                    $event = $resultEvent->current();
                     
                    if (!empty($event)){
                         
                        $calendarService = $this->getServiceLocator()->get('MelisCalendarService');
                        $responseData = $calendarService->reschedCalendarEvent($postValues);
                        
                        if (!empty($responseData)){
                            $textMessage = 'tr_melistoolcalendar_save_event_success';
                            $status = 1;
                        }
                    }
                }
            }
        }
         
        $response = array(
            'success' => $status,
            'textTitle' => 'tr_melistoolcalendar_save_event_title',
            'textMessage' => $textMessage,
            'errors' => $errors,
        );
        
        if ($status){
            $this->getEventManager()->trigger('meliscalendar_save_event_end', $this, array_merge($response, array('typeCode' => 'CALENDAR_EVENT_DRAG', 'itemId' => $id)));
        }
         
        return new JsonModel($response);
    }
895818
public function getCallbackEvents(): array
    {
        $events = [];
        foreach ($this->getHydratedEntries() as $hydratedEntry) {
            /** @var \Kerox\Messenger\Model\Callback\Entry $hydratedEntry */
            $events = array_merge($events, $hydratedEntry->getEvents());
        }

        return $events;
    }
878849
public function allEvents(): array
    {
        $events = $this->iterableEvents();

        if ($this->endEvent && $this->responseEvent !== $this->endEvent) {
            $events[] = $this->endEvent;
        }

        if ($this->responseEvent) {
            array_unshift($events, $this->responseEvent);
        }

        array_unshift($events, $this->calledEvent);

        return $events;
    }
874112
public function get_columns() {
		return array(
			'hour'      => sprintf( esc_html__( 'Wk. %s', 'wp-event-calendar' ), date_i18n( 'W', $this->today ) ),
			'sunday'    => date_i18n( 'D, M. j', $this->week_start ),
			'monday'    => date_i18n( 'D, M. j', $this->week_start + ( DAY_IN_SECONDS * 1 ) ),
			'tuesday'   => date_i18n( 'D, M. j', $this->week_start + ( DAY_IN_SECONDS * 2 ) ),
			'wednesday' => date_i18n( 'D, M. j', $this->week_start + ( DAY_IN_SECONDS * 3 ) ),
			'thursday'  => date_i18n( 'D, M. j', $this->week_start + ( DAY_IN_SECONDS * 4 ) ),
			'friday'    => date_i18n( 'D, M. j', $this->week_start + ( DAY_IN_SECONDS * 5 ) ),
			'saturday'  => date_i18n( 'D, M. j', $this->week_end )
		);
	}
1282272
public function retrieveCalendarEvents(){
        
        $select = $this->tableGateway->getSql()->select();
        // preparing columns for calendar ui
        // as defined column name for calendar ui
        $select->columns(
            array(
                new \Zend\Db\Sql\Expression('cal_id AS id'),
                new \Zend\Db\Sql\Expression('CONCAT(cal_id," : ",cal_event_title) AS title'),
                new \Zend\Db\Sql\Expression('cal_date_start AS start'),
                new \Zend\Db\Sql\Expression('cal_date_end AS end'),
            ));
        $dataCalendar = $this->tableGateway->selectWith($select);
        
        return $dataCalendar;
    }
105131
public static function fetch() {
        global $SESSION;

        if (!isset($SESSION) || !isset($SESSION->notifications)) {
            return [];
        }

        $notifications = $SESSION->notifications;
        unset($SESSION->notifications);

        $renderables = [];
        foreach ($notifications as $notification) {
            $renderable = new \core\output\notification($notification->message, $notification->type);
            $renderables[] = $renderable;
        }

        return $renderables;
    }
986041
public function getErrors()
    {
        if (empty( $this->_errors )) {
            $errorList = Array();

            foreach ($this->__get(self::$ERROR) as $error) {
                $errorCode       = $error[self::$ERROR_ERROR_CODE];
                $message         = $error[self::$ERROR_MESSAGE];
                $consumerMessage = $error[self::$ERROR_CONSUMER_MESSAGE];
                $paySysMessage   = $error[self::$ERROR_PAY_SYS_MESSAGE];

                $errorObject = new WirecardCEE_QMore_Error($errorCode, $message);
                $errorObject->setPaySysMessage($paySysMessage);
                $errorObject->setConsumerMessage($consumerMessage);

                array_push($errorList, $errorObject);
            }

            $this->_errors = $errorList;
        }

        return $this->_errors;
    }