Merge pull request #6748 from robbieaverill/bugfix/config-api-in-fulltextsearchable

FIX Update config API reference in FulltextSearchable and use namespaced imports for class names
This commit is contained in:
Damian Mooyman 2017-03-29 10:51:05 +13:00 committed by GitHub
commit c2fbb68408

View File

@ -2,6 +2,8 @@
namespace SilverStripe\ORM\Search;
use SilverStripe\Assets\File;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\Config\Config;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\ORM\Connect\MySQLSchemaManager;
@ -51,12 +53,11 @@ class FulltextSearchable extends DataExtension
* listed here. Default: {@link SiteTree} and {@link File}.
* @throws Exception
*/
public static function enable(
$searchableClasses = array('SilverStripe\\CMS\\Model\\SiteTree', 'SilverStripe\\Assets\\File')
) {
public static function enable($searchableClasses = [SiteTree::class, File::class])
{
$defaultColumns = array(
'SilverStripe\\CMS\\Model\\SiteTree' => '"Title","MenuTitle","Content","MetaDescription"',
'SilverStripe\\Assets\\File' => '"Name","Title"'
SiteTree::class => '"Title","MenuTitle","Content","MetaDescription"',
File::class => '"Name","Title"'
);
if (!is_array($searchableClasses)) {
@ -68,7 +69,7 @@ class FulltextSearchable extends DataExtension
}
if (isset($defaultColumns[$class])) {
Config::inst()->update(
Config::modify()->set(
$class,
'create_table_options',
array(MySQLSchemaManager::ID => 'ENGINE=MyISAM')