Merge pull request #7642 from creative-commoners/pulls/4.0/fix-moduleloader-examples

DOCS Update getRelativeResourcePath (deprecated) to getResource()->getRelativePath() in upgrade examples
This commit is contained in:
Damian Mooyman 2017-11-27 15:27:23 +13:00 committed by GitHub
commit 7c3997344a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -410,13 +410,13 @@ Usage with custom logic:
+use SilverStripe\View\ThemeResourceLoader;
-$moduleFilePath = FRAMEWORK_DIR . '/MyFile.php';
+$moduleFilePath = ModuleLoader::getModule('silverstripe/framework')->getRelativeResourcePath('MyFile.php');
+$moduleFilePath = ModuleLoader::getModule('silverstripe/framework')->getResource('MyFile.php')->getRelativePath();
-$baseFilePath = BASE_PATH . '/composer.json';
+$baseFilePath = Director::baseFolder() . '/composer.json';
-$mysiteFilePath = 'mysite/css/styles.css';
+$mysiteFilePath = ModuleLoader::getModule('mysite')->getRelativeResourcePath('css/styles.css');
+$mysiteFilePath = ModuleLoader::getModule('mysite')->getResource('css/styles.css')->getRelativePath();
-$themesFilePath = SSViewer::get_theme_folder() . '/css/styles.css';
+$themesFilePath = ThemeResourceLoader::inst()->findThemedResource('css/styles.css');
@ -428,13 +428,15 @@ Usage with custom logic:
Usage for Page and ModelAdmin:
```php
class ListingPage extends \Page {
class ListingPage extends \Page
{
private static $icon = 'mycompany/silverstripe-mymodule: client/images/sitetree_icon.png';
}
```
```php
class MyCustomModelAdmin extends \SilverStripe\Admin\ModelAdmin {
class MyCustomModelAdmin extends \SilverStripe\Admin\ModelAdmin
{
private static $menu_icon = 'mycompany/silverstripe-mymodule: client/images/modeladmin_icon.png';
}
```