From a4058ae2b14cd3857f39741740d22fbf43fea23d Mon Sep 17 00:00:00 2001 From: Tam Date: Fri, 2 Aug 2019 15:08:15 +0100 Subject: [PATCH] Fix CP edit url not linking to the admin --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/elements/Notice.php | 21 +++++++++++---------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ec8f51..c37288c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.2 - 2019-08-02 +### Fixed +- Fix CP edit url not linking to the admin + ## 1.0.1 - 2019-04-24 ### Fixed - Fixed project config not syncing field layout diff --git a/composer.json b/composer.json index ab512af..e21575d 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "ether/cart-notices", "description": "Automatically show notices based off cart details", - "version": "1.0.1", + "version": "1.0.2", "type": "craft-plugin", "license": "proprietary", "minimum-stability": "dev", diff --git a/src/elements/Notice.php b/src/elements/Notice.php index 84da267..e6d199f 100644 --- a/src/elements/Notice.php +++ b/src/elements/Notice.php @@ -8,6 +8,7 @@ namespace ether\cartnotices\elements; +use Craft; use craft\base\Element; use craft\commerce\elements\Product; use craft\elements\actions\Restore; @@ -136,9 +137,9 @@ public static function find (): ElementQueryInterface public function getEditorHtml (): string { - $html = \Craft::$app->getView()->renderTemplateMacro('_includes/forms', 'textField', [ + $html = Craft::$app->getView()->renderTemplateMacro('_includes/forms', 'textField', [ [ - 'label' => \Craft::t('app', 'Title'), + 'label' => Craft::t('app', 'Title'), 'siteId' => $this->siteId, 'id' => 'title', 'name' => 'title', @@ -159,13 +160,13 @@ public function getEditorHtml (): string public function getFieldLayout () { - return \Craft::$app->getFields()->getLayoutByType(Notice::class); + return Craft::$app->getFields()->getLayoutByType(Notice::class); } public function getCpEditUrl () { - $url = '/cart-notices/' . $this->id . '/'; - $url .= \Craft::$app->getSites()->getSiteById($this->siteId)->handle; + $url = 'cart-notices/' . $this->id . '/'; + $url .= Craft::$app->getSites()->getSiteById($this->siteId)->handle; return UrlHelper::cpUrl($url); } @@ -180,7 +181,7 @@ protected static function defineActions (string $source = null): array protected static function defineTableAttributes (): array { return [ - 'title' => \Craft::t('app', 'Title'), + 'title' => Craft::t('app', 'Title'), 'type' => CartNotices::t('Type'), 'target' => CartNotices::t('Target'), 'threshold' => CartNotices::t('Threshold'), @@ -191,8 +192,8 @@ protected static function defineTableAttributes (): array 'maxQty' => CartNotices::t('Max Qty'), 'products' => CartNotices::t('Products'), 'categories' => CartNotices::t('Categories'), - 'dateCreated' => \Craft::t('app', 'Date Created'), - 'dateUpdated' => \Craft::t('app', 'Date Updated'), + 'dateCreated' => Craft::t('app', 'Date Created'), + 'dateUpdated' => Craft::t('app', 'Date Updated'), ]; } @@ -326,7 +327,7 @@ public function setEagerLoadedElements (string $handle, array $elements) */ public function afterSave (bool $isNew) { - $db = \Craft::$app->getDb(); + $db = Craft::$app->getDb(); $transaction = $db->beginTransaction(); @@ -402,7 +403,7 @@ public function afterSave (bool $isNew) */ private function _saveRelations ($target, $ids) { - $db = \Craft::$app->getDb(); + $db = Craft::$app->getDb(); $table = '{{%cart-notices_notice_' . $target . '}}'; $db->createCommand()