public function setUp() { parent::setUp(); // Set backend $adapter = new AssetAdapter(ASSETS_PATH . '/DBFileTest'); $filesystem = new Filesystem($adapter); $filesystem->addPlugin(new FlysystemUrlPlugin()); $backend = new AssetStoreTest_SpyStore(); $backend->setFilesystem($filesystem); Injector::inst()->registerService($backend, 'AssetStore'); // Disable legacy Config::inst()->remove(get_class(new FlysystemAssetStore()), 'legacy_filenames'); // Update base url Config::inst()->update('Director', 'alternate_base_url', '/mysite/'); }
/** * Set this store as the new asset backend * * @param string $basedir Basedir to store assets, which will be placed beneath 'assets' folder */ public static function activate($basedir) { // Assign this as the new store $adapter = new AssetAdapter(ASSETS_PATH . '/' . $basedir); $filesystem = new Filesystem($adapter); $filesystem->addPlugin(new FlysystemUrlPlugin()); $backend = new AssetStoreTest_SpyStore(); $backend->setFilesystem($filesystem); Injector::inst()->registerService($backend, 'AssetStore'); // Disable legacy and set defaults Config::inst()->remove(get_class(new FlysystemAssetStore()), 'legacy_filenames'); Config::inst()->update('Director', 'alternate_base_url', '/'); DBFile::config()->force_resample = false; File::config()->force_resample = false; self::reset(); self::$basedir = $basedir; // Ensure basedir exists SS_Filesystem::makeFolder(self::base_path()); }