drenso/ical-bundle

此包已被弃用且不再维护。作者建议使用bomo/ical-bundle包。

为Symfony 2创建ics URL或文件

1.1.0 2016-04-26 15:24 UTC

This package is not auto-updated.

Last update: 2017-02-06 13:55:07 UTC


README

DrensoIcalBundle

此包基于BOMO(https://github.com/BorisMorel/IcalBundle)的工作。

更新 06-02-2017

由于我们假设BOMO的包已被弃用,因此设置了此包。然而,我们提出的Pull Request最终被合并,因此此包不再需要。请不要使用此包,而应使用BOMOIcalBundle。

此包用于创建ics文件或url,以用事件填充共享日历。

概述

<?php
public function getIcs()
{
    $provider = $this->get('drenso_ical.ics_provider');

    $tz = $provider->createTimezone();
    $tz
        ->setTzid('Europe/Paris')
        ->setProperty('X-LIC-LOCATION', $tz->getTzid())
        ;

    $cal = $provider->createCalendar($tz);

    $cal
        ->setName('My cal1')
        ->setDescription('Foo')
        ;

    $datetime = new \Datetime('now');
    $event = $cal->newEvent();
    $event
        ->setStartDate($datetime)
        ->setEndDate($datetime->modify('+5 hours'))
        ->setName('Event 1')
        ->setDescription('Desc for event')
        ->setAttendee('foo@bar.me')
        ->setAttendee('John Doe')
        ;

    $alarm = $event->newAlarm();
    $alarm
        ->setAction('display')
        ->setDescription($event->getProperty('description'))
        ->setTrigger('-PT2H') //See Dateinterval string format
        ;

    // All Day event
    $event = $cal->newEvent();
    $event
        ->isAllDayEvent()
        ->setStartDate($datetime)
        ->setEndDate($datetime->modify('+10 days'))
        ->setName('All day event')
        ->setDescription('All day visualisation')
        ;

    $calStr = $cal->returnCalendar();

    return new Response(
        $calStr,
        200,
        array(
            'Content-Type' => 'text/calendar; charset=utf-8',
            'Content-Disposition' => 'attachment; filename="calendar.ics"',
        )
    );
}

版本

  • 2013/10/01 : 第一个版本
  • 2013/10/02 : 修复问题#2
  • 2013/10/07 : 修复问题#1
  • 2016/03/21 : 在Drenso的所有权下为Symfony 3.0发布新版本

实际状态

此包处于稳定状态;

安装

在您的composer.json中添加DrensoIcalBundle

{
    "require": {
        "drenso/ical-bundle": "~1.0"
    }
}

现在,运行以下步骤告诉composer下载包

$ php composer.phar update drenso/ical-bundle

AppKernel.php

$bundles = array(
    ...
    new Drenso\IcalBundle\DrensoIcalBundle(),
);

用户指南

所有对象都可以由提供者管理。但是,对象需要附加。

附加到日历的事件

附加到事件上的闹钟

为了简化使用,对象是创建子功能的代理方法。

$alarm = $event->newAlarm();
$alarm
    ->set[...]
    [...]
    ;

与以下严格相同

$alarm = $provider->createAlarm();
$alarm
    ->set[...]
    [...]
    ;
$event->attachAlarm($alarm);

对象引用

提供者

Timezone function createTimezone();
Calendar function createCalendar();
Event function createEvent();
Alarm function createAlarm();

时区

Timezone function __construct(array $config=null);
string function getTzid();
this function setTzid($tz);
this function setProperty($name, $value);
vtimezone function getTimezone();

日历

Calendar function __construct(array $config);
this function setName($name);
this function setDescription($desc);
Event function newEvent(); //Directly attached to this Calendar
this function attachEvent(Event $event)
string function returnCalendar();
vcalendar function getCalendar();

事件

Event function __construct(mixed $param);
this function setStartDate(Datetime $date);
this function setEndDate(Datetime $date);
this function isAllDayEvent();
this function setName($name);
this function setLocation($loc);
this function setDescription($desc);
this function setComment($comment);
this function setAttendee($attendee);
this function setOrganizer($org);
Alarm function newAlarm(); //Directly attached to this Event
this function attachAlarm(Alarm $alarm);
mixed function getProperty($prop);
vevent function getEvent();

闹钟

Alarm function __construct(mixed $param);
this function setAction($action); //Currently, only 'display' action is setted.
this function setDescription($desc);
this function setTrigger($trigger);
valarm function getAlarm();

配置示例

目前,此包不需要任何配置部分。