diff --git a/README.md b/README.md index 47b0a93..cdea5ee 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Requirements -* SilverStripe 3.0 +* SilverStripe 4.0 ## Documentation diff --git a/_config.php b/_config.php index a4abe2d..b3d9bbc 100644 --- a/_config.php +++ b/_config.php @@ -1,2 +1 @@ "Image", - "ShoppingAdditionalImage" => "Image", - "GoogleProductCategory" => "GoogleProductCategory" + "ShoppingPrimaryImage" => Image::class, + "ShoppingAdditionalImage" => Image::class, + "GoogleProductCategory" => GoogleProductCategory::class ]; /** @@ -172,9 +173,7 @@ public function addCMSFieldsToTabset($tabset) 'GoogleProductCategoryID', $this->owner->fieldLabel("GoogleProductCategory"), '', - null, - null, - 'GoogleProductCategory', + GoogleProductCategory::class, 'Title' ), UploadField::create("ShoppingPrimaryImage") @@ -202,8 +201,6 @@ public function hasCMSSettingsFields() */ public function updateSettingsFields(FieldList $fields) { - var_dump("i'm here!"); - exit; if($this->owner->hasCMSSettingsFields()) { $tabset = $fields->findOrMakeTab('Root.Settings'); @@ -221,8 +218,6 @@ public function updateSettingsFields(FieldList $fields) */ public function updateCMSFields(FieldList $fields) { - var_dump("i'm here!"); - exit; if (!$this->owner->hasCMSSettingsFields()) { $tabset = $fields->findOrMakeTab('Root.Settings'); diff --git a/src/GoogleShoppingFeed.php b/src/GoogleShoppingFeed.php index 842eea6..c547826 100644 --- a/src/GoogleShoppingFeed.php +++ b/src/GoogleShoppingFeed.php @@ -2,6 +2,7 @@ namespace ilateral\SilverStripe\GoogleShoppingFeed; +use Product; use SilverStripe\ORM\DataList; use SilverStripe\ORM\ArrayList; use SilverStripe\Core\Config\Config; @@ -66,7 +67,7 @@ class GoogleShoppingFeed public static function register_dataobject($className) { if (!self::is_registered($className)) { - $className::add_extension('GoogleShoppingFeedExtension'); + $className::add_extension(Extension::class); self::$dataobjects[] = $className; } @@ -130,20 +131,20 @@ public static function clear_registered_dataobjects() * * @return ArrayList */ - public static function get_items() + public static function getItems() { $output = new ArrayList(); - $search_filter = Config::inst()->get('GoogleShoppingFeed', 'use_show_in_search'); - $disabled_filter = Config::inst()->get('GoogleShoppingFeed', 'use_disabled'); + $search_filter = Config::inst()->get(__CLASS__, 'use_show_in_search'); + $disabled_filter = Config::inst()->get(__CLASS__, 'use_disabled'); $filter = array(); // todo migrate to extension hook or DI point for other modules to foreach (self::$dataobjects as $class) { - if ($class == "SiteTree") { + if ($class == SiteTree::class) { $search_filter = ($search_filter) ? "\"ShowInSearch\" = 1" : ""; $instances = Versioned::get_by_stage('SiteTree', 'Live', $search_filter); - } elseif ($class == "Product") { + } elseif ($class == Product::class) { $instances = $class::get(); if ($disabled_filter) { @@ -164,6 +165,20 @@ public static function get_items() return $output; } + + /** + * Static interface to instance level ->getItems() for backward compatibility. + * + * @param string + * @param int + * + * @return ArrayList + * @deprecated Please create an instance and call ->getSitemaps() instead. + */ + public static function get_items() + { + return static::inst()->getItems(); + } /** * Returns the string frequency of edits for a particular dataobject class. @@ -191,6 +206,6 @@ public static function get_frequency_for_class($class) */ public static function enabled() { - return (Config::inst()->get('GoogleShoppingFeed', 'enabled', Config::INHERITED)); + return (Config::inst()->get(self::class, 'enabled')); } } diff --git a/src/model/GoogleProductCategory.php b/src/Model/GoogleProductCategory.php similarity index 92% rename from src/model/GoogleProductCategory.php rename to src/Model/GoogleProductCategory.php index 88a7134..508368f 100644 --- a/src/model/GoogleProductCategory.php +++ b/src/Model/GoogleProductCategory.php @@ -1,6 +1,6 @@ assertEquals(3, $items->count()); }