2015-11-02 00:27:42 +01:00
|
|
|
<?php
|
2015-09-23 00:32:23 +02:00
|
|
|
|
2017-09-06 05:49:23 +02:00
|
|
|
namespace SilverStripe\ContentReview\Compatibility;
|
|
|
|
|
|
|
|
use SilverStripe\Core\ClassInfo;
|
|
|
|
use SilverStripe\Subsites\Model\Subsite;
|
2018-01-08 04:47:31 +01:00
|
|
|
|
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
|
2018-01-08 21:30:20 +01:00
|
|
|
* 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()
|
|
|
|
{
|
2018-01-08 04:47:31 +01:00
|
|
|
$compatibility = [
|
2018-01-08 21:30:20 +01:00
|
|
|
self::SUBSITES => null,
|
2018-01-08 04:47:31 +01:00
|
|
|
];
|
2015-11-02 00:27:42 +01:00
|
|
|
|
2017-09-06 05:49:23 +02: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)
|
|
|
|
{
|
2017-09-06 05:49:23 +02:00
|
|
|
if (class_exists(Subsite::class)) {
|
2015-11-02 00:27:42 +01:00
|
|
|
Subsite::$disable_subsite_filter = $compatibility[self::SUBSITES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|