mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-25 04:07:17 +08:00
1.添加课程和章节事件监听
2.优化SEO类
This commit is contained in:
parent
0aa07da41b
commit
f04c23e90f
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Api;
|
namespace App\Http\Api;
|
||||||
|
|
||||||
use App\Services\Auth\Api as AppAuth;
|
use App\Services\Auth\Api as ApiAuth;
|
||||||
use Phalcon\DiInterface;
|
use Phalcon\DiInterface;
|
||||||
use Phalcon\Mvc\ModuleDefinitionInterface;
|
use Phalcon\Mvc\ModuleDefinitionInterface;
|
||||||
use Phalcon\Mvc\View;
|
use Phalcon\Mvc\View;
|
||||||
@ -29,7 +29,7 @@ class Module implements ModuleDefinitionInterface
|
|||||||
});
|
});
|
||||||
|
|
||||||
$dependencyInjector->setShared('auth', function () {
|
$dependencyInjector->setShared('auth', function () {
|
||||||
return new AppAuth();
|
return new ApiAuth();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,8 @@ class Connect extends Service
|
|||||||
$auth = $this->getAppAuth();
|
$auth = $this->getAppAuth();
|
||||||
|
|
||||||
$auth->saveAuthInfo($user);
|
$auth->saveAuthInfo($user);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Account:afterRegister', $this, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bindUser(array $openUser)
|
public function bindUser(array $openUser)
|
||||||
|
@ -103,6 +103,8 @@ class WeChatOfficialAccount extends Service
|
|||||||
$auth = $this->getAppAuth();
|
$auth = $this->getAppAuth();
|
||||||
|
|
||||||
$auth->saveAuthInfo($user);
|
$auth->saveAuthInfo($user);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Account:afterRegister', $this, $user);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getAppAuth()
|
protected function getAppAuth()
|
||||||
|
@ -30,6 +30,11 @@ class Seo
|
|||||||
*/
|
*/
|
||||||
protected $titleSeparator = ' - ';
|
protected $titleSeparator = ' - ';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string 关键字分隔符
|
||||||
|
*/
|
||||||
|
protected $keywordSeparator = ',';
|
||||||
|
|
||||||
public function setTitle($title)
|
public function setTitle($title)
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
@ -37,6 +42,10 @@ class Seo
|
|||||||
|
|
||||||
public function setKeywords($keywords)
|
public function setKeywords($keywords)
|
||||||
{
|
{
|
||||||
|
if (is_array($keywords)) {
|
||||||
|
$keywords = implode($this->keywordSeparator, $keywords);
|
||||||
|
}
|
||||||
|
|
||||||
$this->keywords = $keywords;
|
$this->keywords = $keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,4 +93,9 @@ class Seo
|
|||||||
return $this->titleSeparator;
|
return $this->titleSeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getKeywordSeparator()
|
||||||
|
{
|
||||||
|
return $this->keywordSeparator;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
51
app/Listeners/Chapter.php
Normal file
51
app/Listeners/Chapter.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||||
|
* @license https://opensource.org/licenses/GPL-2.0
|
||||||
|
* @link https://www.koogua.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Models\Chapter as ChapterModel;
|
||||||
|
use Phalcon\Events\Event as PhEvent;
|
||||||
|
|
||||||
|
class Chapter extends Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
public function afterCreate(PhEvent $event, $source, ChapterModel $chapter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterUpdate(PhEvent $event, $source, ChapterModel $chapter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterDelete(PhEvent $event, $source, ChapterModel $chapter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterRestore(PhEvent $event, $source, ChapterModel $chapter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterView(PhEvent $event, $source, ChapterModel $chapter)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterLike(PhEvent $event, $source, ChapterModel $chapter): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterUndoLike(PhEvent $event, $source, ChapterModel $chapter): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
51
app/Listeners/Course.php
Normal file
51
app/Listeners/Course.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
||||||
|
* @license https://opensource.org/licenses/GPL-2.0
|
||||||
|
* @link https://www.koogua.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Listeners;
|
||||||
|
|
||||||
|
use App\Models\Course as CourseModel;
|
||||||
|
use Phalcon\Events\Event as PhEvent;
|
||||||
|
|
||||||
|
class Course extends Listener
|
||||||
|
{
|
||||||
|
|
||||||
|
public function afterCreate(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterUpdate(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterDelete(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterRestore(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterView(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterFavorite(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function afterUndoFavorite(PhEvent $event, $source, CourseModel $course): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -53,7 +53,11 @@ class ChapterInfo extends LogicService
|
|||||||
$this->setChapterUser($chapter, $user);
|
$this->setChapterUser($chapter, $user);
|
||||||
$this->handleChapterUser($chapter, $user);
|
$this->handleChapterUser($chapter, $user);
|
||||||
|
|
||||||
return $this->handleChapter($chapter, $user);
|
$result = $this->handleChapter($chapter, $user);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Chapter:afterView', $this, $chapter);
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleChapter(ChapterModel $chapter, UserModel $user)
|
protected function handleChapter(ChapterModel $chapter, UserModel $user)
|
||||||
|
@ -58,11 +58,15 @@ class ChapterLike extends LogicService
|
|||||||
|
|
||||||
$this->incrChapterLikeCount($chapter);
|
$this->incrChapterLikeCount($chapter);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Chapter:afterLike', $this, $chapter);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$action = 'undo';
|
$action = 'undo';
|
||||||
|
|
||||||
$this->decrChapterLikeCount($chapter);
|
$this->decrChapterLikeCount($chapter);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Chapter:afterUndoLike', $this, $chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -57,12 +57,16 @@ class CourseFavorite extends LogicService
|
|||||||
$this->incrCourseFavoriteCount($course);
|
$this->incrCourseFavoriteCount($course);
|
||||||
$this->incrUserFavoriteCount($user);
|
$this->incrUserFavoriteCount($user);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Course:afterFavorite', $this, $course);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$action = 'undo';
|
$action = 'undo';
|
||||||
|
|
||||||
$this->decrCourseFavoriteCount($course);
|
$this->decrCourseFavoriteCount($course);
|
||||||
$this->decrUserFavoriteCount($user);
|
$this->decrUserFavoriteCount($user);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Course:afterUndoFavorite', $this, $course);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -27,7 +27,11 @@ class CourseInfo extends LogicService
|
|||||||
|
|
||||||
$this->setCourseUser($course, $user);
|
$this->setCourseUser($course, $user);
|
||||||
|
|
||||||
return $this->handleCourse($course, $user);
|
$result = $this->handleCourse($course, $user);
|
||||||
|
|
||||||
|
$this->eventsManager->fire('Course:afterView', $this, $course);
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleCourse(CourseModel $course, UserModel $user)
|
protected function handleCourse(CourseModel $course, UserModel $user)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user