isMacOs() public static method

Returns true if operating system is based on apple MacOS.
public static isMacOs ( ) : boolean
return boolean
コード例 #1
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws RuntimeException
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $opener = '';
     if (OperatingSystem::isMacOs()) {
         $opener = 'open';
     } elseif (OperatingSystem::isWindows()) {
         $opener = 'start';
     } else {
         // Linux
         if (exec('which xde-open')) {
             $opener = 'xdg-open';
         } elseif (exec('which gnome-open')) {
             $opener = 'gnome-open';
         } elseif (exec('which kde-open')) {
             $opener = 'kde-open';
         }
     }
     if (empty($opener)) {
         throw new RuntimeException('No opener command like xde-open, gnome-open, kde-open was found.');
     }
     $this->detectMagento($output);
     if ($this->initMagento($output)) {
         $store = $this->getHelperSet()->get('parameter')->askStore($input, $output, 'store', true);
         if ($store->getId() == Store::DEFAULT_STORE_ID) {
             $url = $this->getBackendStoreUrl($store);
         } else {
             $url = $this->getFrontendStoreUrl($store);
         }
         $output->writeln('Opening URL <comment>' . $url . '</comment> in browser');
         Exec::run(escapeshellcmd($opener . ' ' . $url));
     }
 }
コード例 #2
0
 /**
  * @param OutputInterface $output
  * @return string
  */
 private function resolveOpenerCommand(OutputInterface $output)
 {
     $opener = '';
     if (OperatingSystem::isMacOs()) {
         $opener = 'open';
     } elseif (OperatingSystem::isWindows()) {
         $opener = 'start';
     } else {
         // Linux
         if (exec('which xdg-open')) {
             $opener = 'xdg-open';
         } elseif (exec('which gnome-open')) {
             $opener = 'gnome-open';
         } elseif (exec('which kde-open')) {
             $opener = 'kde-open';
         }
     }
     if (empty($opener)) {
         throw new RuntimeException('No opener command like xdg-open, gnome-open, kde-open was found.');
     }
     if (OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity()) {
         $message = sprintf('open command is "%s"', $opener);
         $output->writeln('<debug>' . $message . '</debug>');
     }
     return $opener;
 }
コード例 #3
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws RuntimeException
  * @return int|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $opener = '';
     if (OperatingSystem::isMacOs()) {
         $opener = 'open';
     } elseif (OperatingSystem::isWindows()) {
         $opener = 'start';
     } else {
         // Linux
         if (exec('which xde-open')) {
             $opener = 'xdg-open';
         } elseif (exec('which gnome-open')) {
             $opener = 'gnome-open';
         } elseif (exec('which kde-open')) {
             $opener = 'kde-open';
         }
     }
     if (empty($opener)) {
         throw new RuntimeException('No opener command like xde-open, gnome-open, kde-open was found.');
     }
     $this->detectMagento($output);
     if ($this->initMagento($output)) {
         $store = $this->getHelperSet()->get('parameter')->askStore($input, $output, 'store', true);
         if ($store->getId() == \Mage_Core_Model_App::ADMIN_STORE_ID) {
             $adminFrontName = (string) \Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
             $url = rtrim($store->getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_WEB), '/') . '/' . $adminFrontName;
         } else {
             $url = $store->getBaseUrl(\Mage_Core_Model_Store::URL_TYPE_LINK) . '?___store=' . $store->getCode();
         }
         $output->writeln('Opening URL <comment>' . $url . '</comment> in browser');
         Exec::run(escapeshellcmd($opener . ' ' . $url));
     }
 }
コード例 #4
0
ファイル: EventSubscriber.php プロジェクト: lslab/n98-magerun
 /**
  * Display a warning if a running n98-magerun as root user
  *
  * @param ConsoleEvent $event
  * @return void
  */
 public function checkRunningAsRootUser(ConsoleEvent $event)
 {
     $output = $event->getOutput();
     if ($output instanceof ConsoleOutput) {
         $errorOutput = $output->getErrorOutput();
         if (OperatingSystem::isLinux() || OperatingSystem::isMacOs()) {
             if (function_exists('posix_getuid')) {
                 if (posix_getuid() === 0) {
                     $errorOutput->writeln('');
                     $errorOutput->writeln(self::WARNING_ROOT_USER);
                     $errorOutput->writeln('');
                 }
             }
         }
     }
 }
コード例 #5
0
 /**
  * Display a warning if a running n98-magerun as root user
  *
  * @param ConsoleEvent $event
  * @return void
  */
 public function checkRunningAsRootUser(Event $event)
 {
     if ($this->_isSkipRootCheck()) {
         return;
     }
     $config = $event->getApplication()->getConfig();
     if (!$config['application']['check-root-user']) {
         return;
     }
     $output = $event->getOutput();
     if (OperatingSystem::isLinux() || OperatingSystem::isMacOs()) {
         if (function_exists('posix_getuid')) {
             if (posix_getuid() === 0) {
                 $output->writeln('');
                 $output->writeln(self::WARNING_ROOT_USER);
                 $output->writeln('');
             }
         }
     }
 }