Skip to content

Commit

Permalink
Modernize code and fix timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
tattali committed May 1, 2024
1 parent fe2b18b commit 044a84f
Show file tree
Hide file tree
Showing 30 changed files with 404 additions and 512 deletions.
33 changes: 8 additions & 25 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ root = true
[*]
# Change these settings to your own preference
indent_style = space
indent_size = 4
indent_size = 2

# We recommend you to keep these unchanged
end_of_line = lf
Expand All @@ -16,49 +16,32 @@ trim_trailing_whitespace = true
insert_final_newline = true

[*.json]
indent_style = space
indent_size = 2
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[*.php]
indent_style = space
indent_size = 4

[*.xml]
indent_style = space
indent_size = 4

[phpunit.xml]
indent_size = 2

[*.yaml]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[.gitmodules]
indent_style = tab

[.php_cs]
indent_style = space
indent_size = 4

[.php_cs.xml.dist]
indent_style = space
indent_size = 2

[.travis.yml]
indent_style = space
indent_size = 2

[composer.json]
indent_style = space
indent_size = 4
indent_style = tab

[phpunit.xml.dist]
indent_style = space
[Makefile]
indent_size = 4
indent_style = tab
25 changes: 5 additions & 20 deletions .github/workflows/code_checks.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Code_Checks

on: ["push", "pull_request"]
on: [push, pull_request]

jobs:
tests:
Expand All @@ -9,25 +9,10 @@ jobs:
fail-fast: false
matrix:
php: ['8.2']
stability: [ prefer-stable ]
minimum-stability: [ stable ]
symfony-version: ['6.4.*']
stability: [prefer-stable]
minimum-stability: [stable]
symfony-version: [7.0.*]
include:
- php: '8.1'
symfony-version: 5.4.*
stability: prefer-lowest
- php: '8.1'
symfony-version: 5.4.*
stability: prefer-stable
- php: '8.1'
symfony-version: 6.4.*
stability: prefer-stable
- php: '8.2'
symfony-version: 6.4.*
stability: prefer-stable
- php: '8.3'
symfony-version: 6.4.*
stability: prefer-stable
- php: '8.3'
symfony-version: 7.0.*
stability: prefer-stable
Expand Down Expand Up @@ -61,5 +46,5 @@ jobs:
- name: Execute tests
env:
SYMFONY_DEPRECATIONS_HELPER: 'weak'
SYMFONY_DEPRECATIONS_HELPER: weak
run: vendor/bin/phpunit
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/build/
/vendor/
.DS_Store
.php_cs.cache
.phpunit.result.cache
composer.lock
.phpunit.cache

# phpunit
/build/
.phpunit.result.cache

# php-cs-fixer
.php-cs-fixer.cache
27 changes: 27 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,

'@PSR1' => true,
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,

'php_unit_internal_class' => false,
'php_unit_test_class_requires_covers' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude([
'vendor',
])
)
;
68 changes: 0 additions & 68 deletions .php_cs.dist

This file was deleted.

13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
all: install test

install:
composer install

test:
vendor/bin/phpunit

lint_php:
vendor/bin/php-cs-fixer fix --ansi -v

lint_php_dry:
vendor/bin/php-cs-fixer fix --ansi -v --dry-run
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Check the existence of the file `config/routes/calendar.yaml` or create it
```yaml
# config/routes/calendar.yaml
calendar:
resource: "@CalendarBundle/Resources/config/routing.yaml"
resource: '@CalendarBundle/Resources/config/routing.yaml'
```
#### 2. Create the subscriber
Expand All @@ -66,34 +66,34 @@ namespace App\EventSubscriber;

use CalendarBundle\CalendarEvents;
use CalendarBundle\Entity\Event;
use CalendarBundle\Event\CalendarEvent;
use CalendarBundle\Event\SetDataEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class CalendarSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
CalendarEvents::SET_DATA => 'onCalendarSetData',
SetDataEvent::class => 'onCalendarSetData',
];
}

public function onCalendarSetData(CalendarEvent $calendar)
public function onCalendarSetData(SetDataEvent $event)
{
$start = $calendar->getStart();
$end = $calendar->getEnd();
$filters = $calendar->getFilters();
$start = $event->getStart();
$end = $event->getEnd();
$filters = $event->getFilters();

// You may want to make a custom query from your database to fill the calendar

$calendar->addEvent(new Event(
$event->addEvent(new Event(
'Event 1',
new \DateTime('Tuesday this week'),
new \DateTime('Wednesdays this week')
));

// If the end date is null or not defined, it creates a all day event
$calendar->addEvent(new Event(
$event->addEvent(new Event(
'All day event',
new \DateTime('Friday this week')
));
Expand All @@ -115,14 +115,14 @@ Add styles and js. Click [here](https://fullcalendar.io/download) to see other c

```twig
{% block javascripts %}
<script src="https://cdn.jsdelivr.net/npm/[email protected].5/index.global.min.js" integrity="sha256-dHUNnePy81fXq4D/wfu7cPsEIP7zl6MvLb84jtZf+UY=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected].11/index.global.min.js"></script>
{% endblock %}
```

### Basic functionalities

You will probably want to customize the Calendar javascript to fit the needs of your application.
To do this, you can copy the following settings and modify them by consulting the [fullcalendar.js documentation](https://fullcalendar.io/docs). You can also look at the [options.ts](https://github.com/fullcalendar/fullcalendar/blob/master/src/core/options.ts) file as an option reference.
To do this, you can copy the following settings and modify them by consulting the [fullcalendar.js documentation](https://fullcalendar.io/docs).
```js
document.addEventListener('DOMContentLoaded', () => {
var calendarEl = document.getElementById('calendar-holder');
Expand All @@ -132,13 +132,13 @@ document.addEventListener('DOMContentLoaded', () => {
editable: true,
eventSources: [
{
url: "/fc-load-events",
method: "POST",
url: '/fc-load-events',
method: 'POST',
extraParams: {
filters: JSON.stringify({})
},
failure: () => {
// alert("There was an error while fetching FullCalendar!");
// alert('There was an error while fetching FullCalendar!');
},
},
],
Expand Down
24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tattali/calendar-bundle",
"type": "symfony-bundle",
"description": "Provides event calendar for your Symfony 5+ project. Compatible with Doctrine ORM & ODM, and API like Google Calendar.",
"description": "Provides event calendar for your Symfony 5+ project. Compatible with API like Google Calendar.",
"keywords": [
"fullcalendar",
"calendar",
Expand All @@ -18,19 +18,18 @@
}
],
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-json": "*",
"symfony/dependency-injection": "^5.4 || ^6.3 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.3 || ^7.0",
"symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0"
"symfony/dependency-injection": "^7.0",
"symfony/event-dispatcher": "^7.0",
"symfony/framework-bundle": "^7.0"
},
"require-dev": {
"phpspec/prophecy": "^1.8",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^10.5.11 || ^11.0.4",
"symfony/dotenv": "^5.4 || ^6.3 || ^7.0",
"phpunit/phpunit": "^11.0",
"symfony/dotenv": "^7.0",
"symfony/phpunit-bridge": "^7.0",
"symfony/yaml": "^5.4 || ^6.3 || ^7.0"
"symfony/yaml": "^7.0",
"friendsofphp/php-cs-fixer": "^3.54"
},
"suggest": {
"symfony/orm-pack": "To support Doctrine ORM and Migration.",
Expand All @@ -45,5 +44,10 @@
"psr-4": {
"CalendarBundle\\Tests\\": "tests/"
}
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
}
}
25 changes: 0 additions & 25 deletions phpcs.xml.dist

This file was deleted.

Loading

0 comments on commit 044a84f

Please sign in to comment.