Skip to content

Commit

Permalink
Add siteconfig method to model classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlewis-everley committed Nov 10, 2016
1 parent 92b1bb4 commit fa2fd86
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions code/model/CatalogueCategory.php
Expand Up @@ -80,6 +80,21 @@ public function isDisabled()
return $this->Disabled;
}

/**
* Stub method to get the site config, unless the current class can provide an alternate.
*
* @return SiteConfig
*/
public function getSiteConfig() {

if($this->hasMethod('alternateSiteConfig')) {
$altConfig = $this->alternateSiteConfig();
if($altConfig) return $altConfig;
}

return SiteConfig::current_site_config();
}

/**
* Return the link for this {@link SimpleProduct} object, with the
* {@link Director::baseURL()} included.
Expand Down
15 changes: 15 additions & 0 deletions code/model/CatalogueProduct.php
Expand Up @@ -233,6 +233,21 @@ public function getTaxString()

return $return;
}

/**
* Stub method to get the site config, unless the current class can provide an alternate.
*
* @return SiteConfig
*/
public function getSiteConfig() {

if($this->hasMethod('alternateSiteConfig')) {
$altConfig = $this->alternateSiteConfig();
if($altConfig) return $altConfig;
}

return SiteConfig::current_site_config();
}


/**
Expand Down

0 comments on commit fa2fd86

Please sign in to comment.