Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Symfony 7 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@
}
},
"require": {
"php": ">=5.6",
"jsvrcek/ics": "^0.4"
"php": ">=7.4",
"symfony/config": "~5.4|~6.0|~7.0",
"symfony/dependency-injection": "~5.4|~6.0|~7.0",
"symfony/http-foundation": "~5.4|~6.0|~7.0",
"symfony/http-kernel": "~5.4|~6.0|~7.0",
"symfony/mime": "~5.4|~6.0|~7.0",
"jsvrcek/ics": ">=0.4"
},
"require-dev": {
"phpunit/phpunit": "~5",
"swiftmailer/swiftmailer": "@stable",
"symfony/symfony": "~2.7 | ~3.0"
"phpunit/phpunit": "~9"
},
"config": {
"bin-dir": "bin"
Expand Down
36 changes: 7 additions & 29 deletions src/Component/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,15 @@
*/
class Calendar extends vCalendar
{
/**
* String $filename
*/
private $filename = 'calendar.ics';
private string $filename = 'calendar.ics';

/**
* Calendar contentType
* @return String calendar contentType
*/
public function getContentType(){
public function getContentType(): string
{
return 'text/calendar';
}

/**
* Export
* @param Boolean $doImmediateOutput = false
* @return String .ics formatted text
*/
public function export($doImmediateOutput = false){
public function export(bool $doImmediateOutput = false): string
{
//setup exporter
$calendarExport = new CalendarExport(new CalendarStream, new Formatter());
$calendarExport->addCalendar($this);
Expand All @@ -46,27 +36,15 @@ public function export($doImmediateOutput = false){
return $calendarExport->getStream();
}

/**
* Set filename
*
* @param String $filename
* @return Calendar
*/
public function setFilename($filename)
public function setFilename(string $filename): Calendar
{
$this->filename = $filename;

return $this;
}

/**
* Get filename
*
* @return String
*/
public function getFilename()
public function getFilename(): string
{
return $this->filename;
}

}
12 changes: 2 additions & 10 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,10 @@
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('welp_ical');
if (\method_exists($treeBuilder, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$rootNode = $treeBuilder->root('stof_doctrine_extensions');
}
$rootNode = $treeBuilder->getRootNode();

// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
Expand Down
9 changes: 2 additions & 7 deletions src/DependencyInjection/WelpIcalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
*/
class WelpIcalExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
Expand All @@ -32,10 +29,8 @@ public function load(array $configs, ContainerBuilder $container)

/**
* Get alias
*
* @return string
*/
public function getAlias()
public function getAlias(): string
{
return 'welp_ical';
}
Expand Down
110 changes: 29 additions & 81 deletions src/Factory/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
namespace Welp\IcalBundle\Factory;

use Welp\IcalBundle\Component\Calendar;

use Jsvrcek\ICS\Model\CalendarEvent;
use Jsvrcek\ICS\Model\CalendarAlarm;
use Jsvrcek\ICS\Model\CalendarFreeBusy;
use Jsvrcek\ICS\Model\CalendarTodo;

use Jsvrcek\ICS\Model\Relationship\Attendee;
use Jsvrcek\ICS\Model\Relationship\Organizer;

use Jsvrcek\ICS\Model\Description\Geo;
use Jsvrcek\ICS\Model\Description\Location;

use Jsvrcek\ICS\Model\Recurrence\RecurrenceRule;

use Jsvrcek\ICS\Utility\Formatter;
use Jsvrcek\ICS\CalendarStream;
use Jsvrcek\ICS\CalendarExport;

/**
* Calendar Factory
*
Expand All @@ -28,30 +22,22 @@
*/
class Factory
{
/**
* @var string
*/
protected $timezone;
protected ?\DateTimeZone $timezone = null;

/**
* @var string
*/
protected $prodid;
protected ?string $prodid = null;

/**
* Create new calendar
*
* @return Calendar
*/
public function createCalendar()
public function createCalendar(): Calendar
{
$calendar = new Calendar();

if (!is_null($this->timezone)) {
if ($this->timezone !== null) {
$calendar->setTimezone($this->timezone);
}

if (!is_null($this->prodid)) {
if ($this->prodid !== null) {
$calendar->setProdId($this->prodid);
}

Expand All @@ -60,128 +46,90 @@ public function createCalendar()

/**
* Create new CalendarEvent
*
* @return CalendarEvent
*/
public function createCalendarEvent()
public function createCalendarEvent(): CalendarEvent
{
$calendarEvent = new CalendarEvent();

return $calendarEvent;
return new CalendarEvent();
}

/**
* Create new CalendarAlarm
*
* @return CalendarAlarm
*/
public function createCalendarAlarm()
public function createCalendarAlarm(): CalendarAlarm
{
$calendarAlarm = new CalendarAlarm();

return $calendarAlarm;
return new CalendarAlarm();
}

/**
* Create new CalendarFreeBusy
*
* @return CalendarFreeBusy
*/
public function createCalendarFreeBusy()
public function createCalendarFreeBusy(): CalendarFreeBusy
{
$calendarFreeBusy = new CalendarFreeBusy();

return $calendarFreeBusy;
return new CalendarFreeBusy();
}

/**
* Create new CalendarTodo
*
* @return CalendarTodo
*/
public function createCalendarTodo()
public function createCalendarTodo(): CalendarTodo
{
$calendarTodo = new CalendarTodo();

return $calendarTodo;
return new CalendarTodo();
}

/**
* Create new Attendee
*
* @return Attendee
*/
public function createAttendee()
public function createAttendee(): Attendee
{
$attendee = new Attendee(new Formatter());

return $attendee;
return new Attendee(new Formatter());
}

/**
* Create new Organizer
*
* @return Organizer
*/
public function createOrganizer()
public function createOrganizer(): Organizer
{
$organizer = new Organizer(new Formatter());

return $organizer;
return new Organizer(new Formatter());
}

/**
* Create new Geo
*
* @return Geo
*/
public function createGeo()
public function createGeo(): Geo
{
$geo = new Geo();

return $geo;
return new Geo();
}

/**
* Create new Location
*
* @return Location
*/
public function createLocation()
public function createLocation(): Location
{
$location = new Location();

return $location;
return new Location();
}

/**
* Create new RecurrenceRule
*
* @return RecurrenceRule
*/
public function createRecurrenceRule()
public function createRecurrenceRule(): RecurrenceRule
{
$recurrenceRule = new RecurrenceRule(new Formatter());

return $recurrenceRule;
return new RecurrenceRule(new Formatter());
}

/**
* Set default timezone for calendars
*
* @param string $timezone
*/
public function setTimezone($timezone)
public function setTimezone(?string $timezone)
{
$this->timezone = new \DateTimeZone($timezone);
if ($timezone !== null) {
$this->timezone = new \DateTimeZone($timezone);
}
}

/**
* Set default prodid for calendars
*
* @param string $prodid
*/
public function setProdid($prodid)
public function setProdid(?string $prodid)
{
$this->prodid = $prodid;
}
Expand Down
12 changes: 2 additions & 10 deletions src/Mailer/CalendarAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@

namespace Welp\IcalBundle\Mailer;

use Symfony\Component\Mime\Part\DataPart;
use Welp\IcalBundle\Component\Calendar;

use Jsvrcek\ICS\Utility\Formatter;
use Jsvrcek\ICS\CalendarStream;
use Jsvrcek\ICS\CalendarExport;

/**
* Calendar attachment for Swift mailer messages
*
* @package Welp\IcalBundle\Mailer
* @author Titouan BENOIT <titouan@welp.today>
*/
class CalendarAttachment extends \Swift_Attachment
class CalendarAttachment extends DataPart
{
/**
* Calendar attachment constructor
*
* @param Calendar $calendar
*/
public function __construct(Calendar $calendar)
{
$data = $calendar->export();
Expand Down
Loading