当前位置: 首页>>代码示例>>PHP>>正文


PHP FOFPlatform::instance方法代码示例

本文整理汇总了PHP中FOFPlatform::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP FOFPlatform::instance方法的具体用法?PHP FOFPlatform::instance怎么用?PHP FOFPlatform::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FOFPlatform的用法示例。


在下文中一共展示了FOFPlatform::instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstance

 /**
  * Find and return the most relevant platform object
  *
  * @return  FOFPlatformInterface
  */
 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         // Where to look for platform integrations
         $paths = array(__DIR__ . '/../integration');
         if (is_array(self::$paths)) {
             $paths = array_merge($paths, self::$paths);
         }
         // Get a list of folders inside this directory
         $integrations = array();
         foreach ($paths as $path) {
             if (!is_dir($path)) {
                 continue;
             }
             $di = new DirectoryIterator($path);
             $temp = array();
             foreach ($di as $fileSpec) {
                 if (!$fileSpec->isDir()) {
                     continue;
                 }
                 $fileName = $fileSpec->getFilename();
                 if (substr($fileName, 0, 1) == '.') {
                     continue;
                 }
                 $platformFilename = $path . '/' . $fileName . '/platform.php';
                 if (!file_exists($platformFilename)) {
                     continue;
                 }
                 $temp[] = array('classname' => 'FOFIntegration' . ucfirst($fileName) . 'Platform', 'fullpath' => $path . '/' . $fileName . '/platform.php');
             }
             $integrations = array_merge($integrations, $temp);
         }
         // Loop all paths
         foreach ($integrations as $integration) {
             // Get the class name for this platform class
             $class_name = $integration['classname'];
             // Load the file if the class doesn't exist
             if (!class_exists($class_name, false)) {
                 @(include_once $integration['fullpath']);
             }
             // If the class still doesn't exist this file didn't
             // actually contain a platform class; skip it
             if (!class_exists($class_name, false)) {
                 continue;
             }
             // If it doesn't implement FOFPlatformInterface, skip it
             if (!class_implements($class_name, 'FOFPlatformInterface')) {
                 continue;
             }
             // Get an object of this platform
             $o = new $class_name();
             // If it's not enabled, skip it
             if (!$o->isEnabled()) {
                 continue;
             }
             if (is_object(self::$instance)) {
                 // Replace self::$instance if this object has a
                 // lower order number
                 $current_order = self::$instance->getOrdering();
                 $new_order = $o->getOrdering();
                 if ($new_order < $current_order) {
                     self::$instance = null;
                     self::$instance = $o;
                 }
             } else {
                 // There is no self::$instance already, so use the
                 // object we just created.
                 self::$instance = $o;
             }
         }
     }
     return self::$instance;
 }
开发者ID:naka211,项目名称:studiekorrektur,代码行数:78,代码来源:platform.php

示例2: getInstance

 /**
  * Find and return the most relevant platform object
  *
  * @return  FOFPlatformInterface
  */
 public static function getInstance()
 {
     if (!is_object(self::$instance)) {
         // Get the paths to look into
         $paths = array(__DIR__);
         if (is_array(self::$paths)) {
             $paths = array_merge(array(__DIR__), self::$paths);
         }
         $paths = array_unique($paths);
         // Loop all paths
         JLoader::import('joomla.filesystem.folder');
         foreach ($paths as $path) {
             // Get the .php files containing platform classes
             $files = JFolder::files($path, '[a-z0-9]\\.php$', false, true, array('interface.php', 'platform.php'));
             if (!empty($files)) {
                 foreach ($files as $file) {
                     // Get the class name for this platform class
                     $base_name = basename($file, '.php');
                     $class_name = 'FOFPlatform' . ucfirst($base_name);
                     // Load the file if the class doesn't exist
                     if (!class_exists($class_name)) {
                         @(include_once $file);
                     }
                     // If the class still doesn't exist this file didn't
                     // actually contain a platform class; skip it
                     if (!class_exists($class_name)) {
                         continue;
                     }
                     // If it doesn't implement FOFPlatformInterface, skip it
                     if (!class_implements($class_name, 'FOFPlatformInterface')) {
                         continue;
                     }
                     // Get an object of this platform
                     $o = new $class_name();
                     // If it's not enabled, skip it
                     if (!$o->isEnabled()) {
                         continue;
                     }
                     if (is_object(self::$instance)) {
                         // Replace self::$instance if this object has a
                         // lower order number
                         $current_order = self::$instance->getOrdering();
                         $new_order = $o->getOrdering();
                         if ($new_order < $current_order) {
                             self::$instance = null;
                             self::$instance = $o;
                         }
                     } else {
                         // There is no self::$instance already, so use the
                         // object we just created.
                         self::$instance = $o;
                     }
                 }
             }
         }
     }
     return self::$instance;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:63,代码来源:platform.php


注:本文中的FOFPlatform::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。