From 6e9d6d9dc739549daab04a18414810b307c96a6f Mon Sep 17 00:00:00 2001 From: thangnn Date: Wed, 28 Feb 2024 14:50:33 +0700 Subject: [PATCH] modified --- .../src/Model/Table/BlogCategoriesTable.php | 15 +++++---------- plugins/bc-blog/src/View/Helper/BlogHelper.php | 6 +----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php b/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php index 92898b2762..f60b4463f0 100755 --- a/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php +++ b/plugins/bc-blog/src/Model/Table/BlogCategoriesTable.php @@ -355,19 +355,14 @@ public function hasChild($id) * @param int $blogContentId * @param string $name * @param array $options - * @return array|null + * @return EntityInterface */ public function getByName($blogContentId, $name, $options = []) { - $options = array_merge([ - 'conditions' => [ - 'BlogCategory.blog_content_id' => $blogContentId, - 'BlogCategory.name' => urlencode($name), - ], - 'recursive' => -1 - ], $options); - $this->unbindModel(['hasMany' => ['BlogPost']]); - return $this->find('first', $options); + return $this->find()->where([ + 'BlogCategories.blog_content_id' => $blogContentId, + 'BlogCategories.name' => urlencode($name), + ])->first(); } /** diff --git a/plugins/bc-blog/src/View/Helper/BlogHelper.php b/plugins/bc-blog/src/View/Helper/BlogHelper.php index 48cb6ee90b..2d86e4c038 100755 --- a/plugins/bc-blog/src/View/Helper/BlogHelper.php +++ b/plugins/bc-blog/src/View/Helper/BlogHelper.php @@ -2031,12 +2031,8 @@ public function getCategoryByName($blogContentId, $categoryName = '', $options = $pass = $this->_View->getRequest()->getParam('pass'); $categoryName = $pass[count($pass) - 1]; } - $blogCategoriesModel = TableRegistry::getTableLocator()->get('BcBlog.BlogCategories'); - return $blogCategoriesModel->find()->where([ - 'BlogCategories.blog_content_id' => $blogContentId, - 'BlogCategories.name' => urlencode($categoryName), - ])->first(); + return $blogCategoriesModel->getByName($blogContentId, $categoryName, $options); } /**