diff --git a/includes/class-CategoryTemplated.php b/includes/class-CategoryTemplated.php index 74eda8e..2d49dae 100644 --- a/includes/class-CategoryTemplated.php +++ b/includes/class-CategoryTemplated.php @@ -1,140 +1,140 @@ . namespace itwikidelbot; /** * Handle a generic category associated to a template */ class CategoryTemplated extends Category { /** * Template name of this category * * @param $name */ private $name; /** * Arguments to be passed to the template * * @var array */ private $args; /** * Constructor * * @param $name Template name * @param $args Template arguments */ public function __construct( $name, $args ) { $this->name = $name; $this->args = $args; parent::__construct( $this->getTemplatedTitle() ); } /** * Get the name of the template * * @return string */ public function getTemplateName() { return $this->name; } /** * Get the name of the template for the page title * * @return string */ public function getTemplateTitleName() { return $this->getTemplateName() . '_TITLE'; } /** * Get the name of the template for the summary * * @return string */ public function getTemplateSummaryName() { return $this->getTemplateName() . '_SUMMARY'; } /** * Get the name of the template for the content */ public function getTemplateContentName() { return $this->getTemplateName() . '_CONTENT'; } /** * Get the template arguments * * @return array */ public function getTemplateArguments() { return $this->args; } /** * Get the edit summary for this category from its template * * @return string */ public function getTemplatedSummary() { return Template::get( $this->getTemplateSummaryName(), $this->getTemplateArguments() ); } /** * Get the page title from its template * * @return string */ public function getTemplatedTitle() { return Template::get( $this->getTemplateTitleName(), $this->getTemplateArguments() ); } /** * Get the page content for this category from its template * * @return string */ public function getTemplatedContent() { return Template::get( $this->getTemplateContentName(), $this->getTemplateArguments() ); } /** * Save this category from the content of its template * * @return mixed */ public function save() { return $this->saveByContentSummary( $this->getTemplatedContent(), $this->getTemplatedSummary() ); } /** * Save this category from the content of its template if it does not exist * - * @return bool|mixed + * @return self */ public function saveIfNotExists() { if( ! $this->exists() ) { - return $this->save(); + $this->save(); } - return false; + return $this; } }