本文整理汇总了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;
}
示例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;
}