productMetaData = $productMetadata; $this->scheduleFactory = $scheduleFactory; $this->dateTime = $datetime; $this->componentRegistrar = $componentRegistrar; $this->readFactory = $readFactory; } /** * @return string */ public function getCurrentServerUser() { if (function_exists('get_current_user')) { return get_current_user(); } // Try POSIX (Linux/Unix) if (function_exists('posix_geteuid') && function_exists('posix_getpwuid')) { $userInfo = posix_getpwuid(posix_geteuid()); if (!empty($userInfo['name'])) { return $userInfo['name']; } } // Try environment variables $user = getenv('USER') ?: getenv('USERNAME'); if (!empty($user)) { return $user; } // Fallback: unknown return 'unknown'; } /** * @return string */ public function getCurrentServerUserGroup() { if (function_exists('posix_getegid')) { $groupid = posix_getegid(); $groupinfo = posix_getgrgid($groupid); if (is_array($groupinfo)) { return $groupinfo['name']; } } return '-'; } /** * @return string */ public function getMagentoEdition() { return $this->productMetaData->getEdition() . ' ( ' . $this->productMetaData->getVersion() . ' )'; } /** * @param int $pageSize * @return \Magento\Cron\Model\ResourceModel\Schedule\Collection mixed */ public function getLatestCronJobs($pageSize) { $scheduleCollection = $this->scheduleFactory->create()->getCollection(); $scheduleCollection->setOrder('schedule_id', 'DESC') ->setPageSize($pageSize); return $scheduleCollection; } /** * @return string */ public function getServerTime() { return $this->dateTime->gmtDate(); } }