portrino/px_ical

This package is abandoned and no longer maintained. No replacement package was suggested.

Provides classes to render ical via eluceo iCal lib (https://github.com/markuspoerschke/iCal)

Installs: 61

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 8

Forks: 0

Open Issues: 0

Type:typo3-cms-extension

0.2.1 2022-01-21 16:18 UTC

This package is auto-updated.

Last update: 2024-02-21 21:01:07 UTC


README

Build Status Maintainability Test Coverage Test Coverage Issue Count Latest Stable Version Total Downloads

Provides TYPO3 classes to render *.ics files via eluceo — iCal library.

Installation

composer require portrino/px_ical

Usage

Extbase view

You can prepend ?tx_par_pi1[format]=ical to your action controller request and extbase renders the corresponding view for you. By putting the ICalView class into the $viewFormatToObjectNameMap extbase is able to get the correct view class for your request. When you following the Domain Driven Design you have a domain model which is assigned to the view and get rendered by the different view classes.

By implementing the ICalEventInterface the ICalView class calls the __toICalEvent() method which have to be implemented by yourself. You have to return an Eluceo\iCal\Component\Event object here.

use Portrino\PxICal\Mvc\View\ICalView;
use TYPO3\CMS\Extbase\Mvc\View\JsonView;

class BookingController extends RestController
{
    /**
     * @var array
     */
    protected $viewFormatToObjectNameMap = [
        'json' => JsonView::class,
        'ical' => ICalView::class
    ];

    /**
     * Action Show
     *
     * @param \Foo\Bar\Domain\Model\Booking $booking
     *
     * @return void
     */
    public function showAction($booking)
    {
        /**
         * $booking should implement the ICalEventInterface
         */
        $this->view->assign('booking', $booking);
    }
    
}

...

class Booking extends AbstractEntity implements ICalEventInterface
{

    /**
     * @return Event
     */
    public function __toICalEvent()
    {
        $event = new Event();

        $event
            ->setUniqueId('foo_bar_' . (string)$this->getUid())
            ->setDtStart($this->getStart())
            ->setDtEnd($this->getEnd());

        ...

        return $event;
    }
}

If you do not have a domain model or the __toICalEvent() does not fit your needs, you can also assign the Eluceo\iCal\Component\Event object directly to the ICal view with the variable name vEvent

use Eluceo\iCal\Component\Event;

/**
 * Action Show
 *
 * @return void
 */
public function showAction()
{
    $vEvent = new Event();
    
    $vEvent
        ->setUniqueId('foo_bar_' . (string)$this->getUid())
        ->setDtStart($this->getStart())
        ->setDtEnd($this->getEnd());
        
    ...

    $this->view->assign('vEvent', $vEvent);
}

Service

This extensions provides a service class which creates an iCal file for you and put this file into: /typo3temp/px_ical folder. You just have to inject the class into your controller, ... and then you can call these methods to generates / remove the ical file.

Dependecy Injection:

/**
 * @var \Portrino\PxICal\Service\ICalFileServiceInterface
 * @inject
 */
protected $iCalFileService;

from domain object:

$file = $this->iCalFileService->createFromDomainObject($booking);

from event object:

$file = $this->iCalFileService->create($vEvent);

To remove created files you just have to call the inverse method which does the job for you:

by domain object:

$file = $this->iCalFileService->removeByDomainObject($booking);

by event object:

$file = $this->iCalFileService->remove($vEvent);

Authors

  • André Wuttig - Initial work, Unit Tests - aWuttig
  • Leopold Engst - Unit Tests - leen2104

See also the list of contributors who participated in this project.