承接 heimrichhannot/contao-alert-reminder-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

heimrichhannot/contao-alert-reminder-bundle

Composer 安装命令:

composer require heimrichhannot/contao-alert-reminder-bundle

包简介

This utility bundle offers functionality to remind the backend users of existing alerts in the Contao CMS.

README 文档

README

This utility bundle offers functionality to remind the backend users of existing alerts in the Contao CMS.

Features

  • looks for existing (configurable) contao backend alerts (added via the hook getSystemMessages) and adds a backend message in order to remind the backend user of it

Use case

You might ask what's the use case of this functionality?

The original use case was in order to remind the backend users to add missing alt attributes to images (accessibility).

Without the functionality, the user might forget about it. Making the alt mandatory has also not been an option because of contao's simple file upload functionality which doesn't contain the field at all.

Hence the need for reminding the backend user of it.

Installation

  1. Run composer require heimrichhannot/contao-alert-reminder-bundle and update the database.

Technical instructions

Add new contao alerts to the context of this bundle

  1. Register a getSystemMessages hook as usual in contao:

    // config.php (or use yaml tags in contao 4.9+)
    $GLOBALS['TL_HOOKS']['getSystemMessages']['myBundle'] = [
        \Acme\MyBundle\EventListener\GetSystemMessagesListener::class, '__invoke'
    ];
    // GetSystemMessagesListener.php
    
    namespace Acme\MyBundle\EventListener;
    
    use Acme\AlertReminderBundle\Manager\AlertReminderManager;
    use Acme\RequestBundle\Component\HttpFoundation\Request;
    use Symfony\Contracts\Translation\TranslatorInterface;
    
    class GetSystemMessagesListener
    {
        /**
         * @var TranslatorInterface
         */
        private $translator;
        /**
         * @var Request
         */
        private $request;
        /**
         * @var AlertReminderManager
         */
        private $alertReminderManager;
    
        public function __construct(AlertReminderManager $alertReminderManager, TranslatorInterface $translator, Request $request)
        {
            $this->translator           = $translator;
            $this->request              = $request;
            $this->alertReminderManager = $alertReminderManager;
        }
    
        public function __invoke()
        {
            $message = '<p class="tl_error">My alert message</p>';
    
            return $this->alertReminderManager->prepareSystemMessage($message, 'some_alert_type_alias');
        }
    }
  2. In order to activate the reminding you have to add your alert type in your project's app/config/config.yml:

    huh_alert_reminder:
      alert_types:
        - { name: some_alert_type_alias }

Add your alerts to the alert queue backend module

This bundle introduces the AlertQueueModule. It's just a list of messages. You might use it to add the full list of alerts you want to the user to notice. In the context of reminding the user of missing alt-attributes this is the place to add shortcuts to the concrete media files.

You can add your messages by registering an event listener for the event AddAlertsToAlertReminderQueueEvent for example as follows:

public function __invoke(AddAlertsToAlertReminderQueueEvent $event)
{
    if ('alt_issues_existing' !== Input::get('type')) {
        return;
    }

    $messages = $event->getAlerts();

    $messages[] = [
        'class' => 'tl_error', // you can use Contao's tl_ classes
        'message' => 'My message'
    ];

    $event->setAlerts($messages);
}

统计信息

  • 总下载量: 1.5k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2020-08-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固