jsvrcek/ics-bundle

此包为JsvrcekICS iCal库提供依赖注入包装器

安装数:102,425

依赖者: 0

建议者: 0

安全性: 0

星标: 11

关注者: 3

分支: 3

开放问题: 5

类型:symfony-bundle

1.1 2022-11-28 17:54 UTC

This package is auto-updated.

Last update: 2024-08-28 21:28:38 UTC


README

提供对Jsvrcek\ICS库的依赖注入的Symfony Bundle,用于创建iCal .ics文件。

安装

composer req jsvrcek/ics-bundle

使用方法

    namespace App\Services;
    private Formatter $formatter;
    private CalendarExport $calendarExport;

    class MyService
    {

    public function __construct(Formatter $formatter, CalendarExport $calendarExport) {

        $this->formatter = $formatter;
        $this->calendarExport = $calendarExport;
    }
// or inject them into the controller
        public function calendarAction(Formatter $formatter, CalendarExport $calendarExport)
        {
        $eventOne = new CalendarEvent();
        $eventOne->setStart(new \DateTime())
            ->setSummary('Family reunion')
            ->setUid('event-uid');

        //add an Attendee
        $attendee = new Attendee($this->formatter); // or $formatter
        $attendee->setValue('moe@example.com')
            ->setName('Moe Smith');
        $eventOne->addAttendee($attendee);

            
            $response = new Response($calendarExport->getStream());
            $response->headers->set('Content-Type', 'text/calendar');
            
            return $response;
        }
    }