inNamespace( NS_GADGET_DEFINITION ); } /** * @return string */ protected function getContentClass() { return GadgetDefinitionContent::class; } public function makeEmptyContent() { $class = $this->getContentClass(); return new $class( FormatJson::encode( $this->getDefaultMetadata(), "\t" ) ); } public function getDefaultMetadata() { return [ 'settings' => [ 'rights' => [], 'default' => false, 'package' => false, 'hidden' => false, 'skins' => [], 'actions' => [], 'category' => '' ], 'module' => [ 'scripts' => [], 'styles' => [], 'datas' => [], 'peers' => [], 'dependencies' => [], 'messages' => [], 'type' => '', ], ]; } /** * @param Title $title The title of the page to supply the updates for. * @param string $role The role (slot) in which the content is being used. * @return DeferrableUpdate[] A list of DeferrableUpdate objects for putting information * about this content object somewhere. */ public function getDeletionUpdates( Title $title, $role ) { return array_merge( parent::getDeletionUpdates( $title, $role ), [ new GadgetDefinitionDeletionUpdate( $title ) ] ); } /** * @param Title $title The title of the page to supply the updates for. * @param Content $content The content to generate data updates for. * @param string $role The role (slot) in which the content is being used. * @param SlotRenderingProvider $slotOutput A provider that can be used to gain access to * a ParserOutput of $content by calling $slotOutput->getSlotParserOutput( $role, false ). * @return DeferrableUpdate[] A list of DeferrableUpdate objects for putting information * about this content object somewhere. */ public function getSecondaryDataUpdates( Title $title, Content $content, $role, SlotRenderingProvider $slotOutput ) { return array_merge( parent::getSecondaryDataUpdates( $title, $content, $role, $slotOutput ), [ new GadgetDefinitionSecondaryDataUpdate( $title ) ] ); } /** * @inheritDoc */ protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) { '@phan-var GadgetDefinitionContent $content'; parent::fillParserOutput( $content, $cpoParams, $output ); $assoc = $content->getAssocArray(); foreach ( [ 'scripts', 'styles', 'datas' ] as $type ) { foreach ( $assoc['module'][$type] as $page ) { $title = Title::makeTitleSafe( NS_GADGET, $page ); if ( $title ) { $output->addLink( $title ); } } } } }