mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-24 20:06:09 +08:00
1.添加课程和章节事件监听
2.优化SEO类
This commit is contained in:
parent
0aa07da41b
commit
f04c23e90f
@ -7,7 +7,7 @@
|
||||
|
||||
namespace App\Http\Api;
|
||||
|
||||
use App\Services\Auth\Api as AppAuth;
|
||||
use App\Services\Auth\Api as ApiAuth;
|
||||
use Phalcon\DiInterface;
|
||||
use Phalcon\Mvc\ModuleDefinitionInterface;
|
||||
use Phalcon\Mvc\View;
|
||||
@ -29,7 +29,7 @@ class Module implements ModuleDefinitionInterface
|
||||
});
|
||||
|
||||
$dependencyInjector->setShared('auth', function () {
|
||||
return new AppAuth();
|
||||
return new ApiAuth();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,8 @@ class Connect extends Service
|
||||
$auth = $this->getAppAuth();
|
||||
|
||||
$auth->saveAuthInfo($user);
|
||||
|
||||
$this->eventsManager->fire('Account:afterRegister', $this, $user);
|
||||
}
|
||||
|
||||
public function bindUser(array $openUser)
|
||||
|
@ -103,6 +103,8 @@ class WeChatOfficialAccount extends Service
|
||||
$auth = $this->getAppAuth();
|
||||
|
||||
$auth->saveAuthInfo($user);
|
||||
|
||||
$this->eventsManager->fire('Account:afterRegister', $this, $user);
|
||||
}
|
||||
|
||||
protected function getAppAuth()
|
||||
|
@ -30,6 +30,11 @@ class Seo
|
||||
*/
|
||||
protected $titleSeparator = ' - ';
|
||||
|
||||
/**
|
||||
* @var string 关键字分隔符
|
||||
*/
|
||||
protected $keywordSeparator = ',';
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
@ -37,6 +42,10 @@ class Seo
|
||||
|
||||
public function setKeywords($keywords)
|
||||
{
|
||||
if (is_array($keywords)) {
|
||||
$keywords = implode($this->keywordSeparator, $keywords);
|
||||
}
|
||||
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
@ -84,4 +93,9 @@ class Seo
|
||||
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->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)
|
||||
|
@ -58,11 +58,15 @@ class ChapterLike extends LogicService
|
||||
|
||||
$this->incrChapterLikeCount($chapter);
|
||||
|
||||
$this->eventsManager->fire('Chapter:afterLike', $this, $chapter);
|
||||
|
||||
} else {
|
||||
|
||||
$action = 'undo';
|
||||
|
||||
$this->decrChapterLikeCount($chapter);
|
||||
|
||||
$this->eventsManager->fire('Chapter:afterUndoLike', $this, $chapter);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -57,12 +57,16 @@ class CourseFavorite extends LogicService
|
||||
$this->incrCourseFavoriteCount($course);
|
||||
$this->incrUserFavoriteCount($user);
|
||||
|
||||
$this->eventsManager->fire('Course:afterFavorite', $this, $course);
|
||||
|
||||
} else {
|
||||
|
||||
$action = 'undo';
|
||||
|
||||
$this->decrCourseFavoriteCount($course);
|
||||
$this->decrUserFavoriteCount($user);
|
||||
|
||||
$this->eventsManager->fire('Course:afterUndoFavorite', $this, $course);
|
||||
}
|
||||
|
||||
return [
|
||||
|
@ -27,7 +27,11 @@ class CourseInfo extends LogicService
|
||||
|
||||
$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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user