src/Biz/User/Service/Impl/BatchNotificationServiceImpl.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\User\Service\Impl;

use Biz\BaseService;
use AppBundle\Common\ArrayToolkit;
use Biz\Common\CommonException;
use Biz\Notification\NotificationException;
use Biz\User\Service\BatchNotificationService;

class BatchNotificationServiceImpl extends BaseService implements BatchNotificationService
{
    public function createBatchNotification($fields)
    {
        if (!ArrayToolkit::requireds($fields, array('title', 'content'))) {
            $this->createNewException(CommonException::ERROR_PARAMETER_MISSING());
        }

        $mode = empty($fields['mode']) ? '' : $fields['mode'];
        unset($fields['mode']);

        $user = $this->getCurrentUser();
        $fields['fromId'] = $user['id'];

        $fields['title'] = $this->purifyHtml($fields['title']);
        $fields['targetId'] = empty($fields['targetId']) ? 0 : $fields['targetId'];
        $fields['type'] = empty($fields['type']) ? 'text' : $fields['type'];
        $fields['published'] = empty($fields['published']) ? 0 : $fields['published'];
        $fields['targetType'] = empty($fields['targetType']) ? 'global' : $fields['targetType'];
        $fields['createdTime'] = empty($fields['createdTime']) ? time() : $fields['createdTime'];
        $fields['sendedTime'] = 0;
        $notification = $this->getBatchNotificationDao()->create($fields);

        if (!empty($mode) && $mode == 'publish') {
            $this->publishBatchNotification($notification['id']);
        }

        return $notification;
    }

    public function publishBatchNotification($id)
    {
        $batchNotification = $this->getBatchNotificationDao()->get($id);
        if (empty($batchNotification)) {
            $this->createNewException(NotificationException::BATCH_NOTIFICATION_NOT_FOUND());
        }
        if ($batchNotification['published'] == 1) {
            $this->createNewException(NotificationException::PUBLISHED_BATCH_NOTIFICATION());
        }
        $batchNotification['published'] = 1;
        $batchNotification['sendedTime'] = time();
        $batchNotification = $this->getBatchNotificationDao()->update($id, $batchNotification);

        $this->dispatchEvent('batch_notification.publish', $batchNotification);

        return true;
    }

    public function getBatchNotification($id)
    {

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。