From 1280c5e80c8a1e4400920a0391415baeb684ec9b Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 15 May 2012 08:59:19 +0200 Subject: [PATCH] no generic edit page --- includes/ContentHandler.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index b3cf15ca22..95a86f8886 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -496,7 +496,9 @@ abstract class ContentHandler { } /** - * Return an EditPage object suitable for editing the given object + * Return an EditPage object suitable for editing the given object. + * This default implementation always fails with an MWException, because there is no + * generic edit page implementation suitable for all content models. * * @since WD.1 * @@ -504,10 +506,7 @@ abstract class ContentHandler { * @return EditPage */ public function createEditPage( Article $article ) { - $this->checkModelID( $article->getPage()->getContentModel() ); - - $editPage = new EditPage( $article ); - return $editPage; + throw new MWException( "ContentHandler class " . get_classs( $this ) . " does not provide an EditPage." ); } /** @@ -805,11 +804,33 @@ abstract class TextContentHandler extends ContentHandler { parent::__construct( $modelId, $formats ); } + /** + * Returns the content's text as-is. + * + * @param Content $content + * @param String|null $format + * @return mixed + */ public function serializeContent( Content $content, $format = null ) { $this->checkFormat( $format ); return $content->getNativeData(); } + /** + * Return an EditPage object for editing the given object + * + * @since WD.1 + * + * @param Article $article + * @return EditPage + */ + public function createEditPage( Article $article ) { + $this->checkModelID( $article->getPage()->getContentModel() ); + + $editPage = new EditPage( $article ); + return $editPage; + } + /** * attempts to merge differences between three versions. * Returns a new Content object for a clean merge and false for failure or a conflict. -- 2.20.1