silverstripe-contentreview/src/Compatibility/ContentReviewCompatability.php

48 lines
1.2 KiB
PHP
Raw Normal View History

2015-11-02 00:27:42 +01:00
<?php
2015-09-23 00:32:23 +02:00
namespace SilverStripe\ContentReview\Compatibility;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Subsites\Model\Subsite;
2015-09-23 00:32:23 +02:00
/**
2015-11-02 00:27:42 +01:00
* This is a helper class which lets us do things with content review data without subsites
* messing our SQL queries up.
2015-11-02 00:27:42 +01:00
*
* Make sure any DataQuery instances you are building are BOTH created & executed between start()
2015-09-23 00:32:23 +02:00
* and done() because augmentDataQueryCreate and augmentSQL happens there.
*/
2015-11-02 00:27:42 +01:00
class ContentReviewCompatability
{
const SUBSITES = 0;
/**
* Returns the state of other modules before compatibility mode is started.
*
* @return array
*/
public static function start()
{
$compatibility = [
self::SUBSITES => null,
];
2015-11-02 00:27:42 +01:00
if (ClassInfo::exists(Subsite::class)) {
2015-11-02 00:27:42 +01:00
$compatibility[self::SUBSITES] = Subsite::$disable_subsite_filter;
Subsite::disable_subsite_filter(true);
}
return $compatibility;
}
/**
* @param array $compatibility
*/
public static function done(array $compatibility)
{
if (class_exists(Subsite::class)) {
2015-11-02 00:27:42 +01:00
Subsite::$disable_subsite_filter = $compatibility[self::SUBSITES];
}
}
}