Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[solved] 3.1.12 Please explain code-line


Go to End


3 Posts   976 Views

Avatar
timo

Community Member, 47 Posts

17 May 2015 at 6:26pm

Edited: 18/05/2015 3:58pm

in cms/code/model/ErrorPage.php at line ~ 170 :

$this->extend('getDefaultRecords', $data);

what does it exactly?
Thanks.timo

whole function:

protected function getDefaultRecords() {
		$data = array(
			array(
				'ErrorCode' => 404,
				'Title' => _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found'),
				'Content' => _t(
					'ErrorPage.DEFAULTERRORPAGECONTENT', 
					'<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p>'
					. '<p>Please check the spelling of the URL you were trying to access and try again.</p>'
				)
			),
			array(
				'ErrorCode' => 500,
				'Title' => _t('ErrorPage.DEFAULTSERVERERRORPAGETITLE', 'Server error'),
				'Content' => _t(
					'ErrorPage.DEFAULTSERVERERRORPAGECONTENT', 
					'<p>Sorry, there was a problem with handling your request.</p>'
				)
			)
		);

		$this->extend('getDefaultRecords', $data); // ?????

		return $data;
	}

Avatar
Nightjar

Community Member, 28 Posts

19 May 2015 at 8:34pm

It is a hook point.
It enables Decorators/Extensions to run if they're using that hook.
You can learn more here: http://beta.docs.silverstripe.org/en/developer_guides/extending/extensions/#modifying-existing-methods

Avatar
timo

Community Member, 47 Posts

19 May 2015 at 9:30pm

Nightjar!
Clear answer!
thanks.timo.