diff --git a/composer.json b/composer.json index 1d5c2542..cba133e1 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,8 @@ { "require": { - "sculpin/sculpin": "^3.2", - "opdavies/sculpin-twig-markdown-bundle": "^0.2.0" + "illuminate/collections": "^11.6", + "opdavies/sculpin-twig-markdown-bundle": "^0.2.0", + "sculpin/sculpin": "^3.2" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index a8c9f653..369b716c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b02a47aa3f7b8cb842ee39beec85b6b1", + "content-hash": "910019ed15f62fccc7241d065627ac72", "packages": [ { "name": "dflydev/ant-path-matcher", @@ -562,6 +562,201 @@ }, "time": "2020-11-24T22:02:12+00:00" }, + { + "name": "illuminate/collections", + "version": "v11.6.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/collections.git", + "reference": "19c6554c7eba0efabc3f8aa4c434815b7f6b4b7d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/collections/zipball/19c6554c7eba0efabc3f8aa4c434815b7f6b4b7d", + "reference": "19c6554c7eba0efabc3f8aa4c434815b7f6b4b7d", + "shasum": "" + }, + "require": { + "illuminate/conditionable": "^11.0", + "illuminate/contracts": "^11.0", + "illuminate/macroable": "^11.0", + "php": "^8.2" + }, + "suggest": { + "symfony/var-dumper": "Required to use the dump method (^7.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "files": [ + "helpers.php" + ], + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Collections package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2024-04-15T15:26:05+00:00" + }, + { + "name": "illuminate/conditionable", + "version": "v11.6.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/conditionable.git", + "reference": "8a558fec063b6a63da1c3af1d219c0f998edffeb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/8a558fec063b6a63da1c3af1d219c0f998edffeb", + "reference": "8a558fec063b6a63da1c3af1d219c0f998edffeb", + "shasum": "" + }, + "require": { + "php": "^8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Conditionable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2024-04-04T17:36:49+00:00" + }, + { + "name": "illuminate/contracts", + "version": "v11.6.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "8782f75e80ab3e6036842d24dbeead34a16f3a79" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/8782f75e80ab3e6036842d24dbeead34a16f3a79", + "reference": "8782f75e80ab3e6036842d24dbeead34a16f3a79", + "shasum": "" + }, + "require": { + "php": "^8.2", + "psr/container": "^1.1.1|^2.0.1", + "psr/simple-cache": "^1.0|^2.0|^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2024-04-17T14:09:55+00:00" + }, + { + "name": "illuminate/macroable", + "version": "v11.6.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/macroable.git", + "reference": "e1be58f9b2af73f242dc6a9add1f376b3ec89eef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/e1be58f9b2af73f242dc6a9add1f376b3ec89eef", + "reference": "e1be58f9b2af73f242dc6a9add1f376b3ec89eef", + "shasum": "" + }, + "require": { + "php": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Macroable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2023-06-08T14:08:27+00:00" + }, { "name": "michelf/php-markdown", "version": "1.9.1", @@ -873,6 +1068,57 @@ }, "time": "2021-07-14T16:41:46+00:00" }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, { "name": "react/cache", "version": "v1.2.0", diff --git a/source/_pages/talks.md b/source/_pages/talks.md index 1b1f9795..cb962ef5 100644 --- a/source/_pages/talks.md +++ b/source/_pages/talks.md @@ -10,7 +10,7 @@ use: [talks] {% endfor %} {% endfor %} -Since September 2012, I have given {{ talkCount }} public presentations and workshops at various conferences and meetups, in-person and remotely, on topics including PHP, Drupal, automated testing, Git, CSS, and systems administration. +Since September 2012, I have given {{ get_past_talk_count(data.talks) }} public presentations and workshops at various conferences and meetups, in-person and remotely, on topics including PHP, Drupal, automated testing, Git, CSS, and systems administration. {% for talk in data.talks|sort((a, b) => a.events|first.date|date('U') > b.events|first.date|date('U') ? -1 : 1) %}
diff --git a/source/_talks/introduction-to-mob-programming.md b/source/_talks/introduction-to-mob-programming.md index 96c6535b..4595d227 100644 --- a/source/_talks/introduction-to-mob-programming.md +++ b/source/_talks/introduction-to-mob-programming.md @@ -10,7 +10,7 @@ events: - name: PHP South Wales location: Cardiff, Wales - date: '2022-09-28' + date: 2022-09-28 url: https://www.meetup.com/php-south-wales/events/288359737 --- diff --git a/src/Opdavies/TwigExtension/OpdaviesTwigExtension.php b/src/Opdavies/TwigExtension/OpdaviesTwigExtension.php index f86d8752..9c9fc41d 100644 --- a/src/Opdavies/TwigExtension/OpdaviesTwigExtension.php +++ b/src/Opdavies/TwigExtension/OpdaviesTwigExtension.php @@ -2,6 +2,7 @@ namespace App\Opdavies\TwigExtension; +use Sculpin\Contrib\ProxySourceCollection\ProxySourceItem; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; @@ -10,6 +11,7 @@ class OpdaviesTwigExtension extends AbstractExtension public function getFunctions(): array { return [ + new TwigFunction('get_past_talk_count', [$this, 'getPastTalkCount']), new TwigFunction('get_years_of_experience', [$this, 'getYearsOfExperience']), ]; } @@ -19,6 +21,22 @@ class OpdaviesTwigExtension extends AbstractExtension return 'app.opdavies_twig_extension'; } + public function getPastTalkCount(array $talks): int + { + $today = (new \DateTime())->getTimestamp(); + + return collect($talks) + ->flatMap(fn (ProxySourceItem $talk) => $talk->data()->get('events')) + ->filter( + function (array $event) use ($today): bool { + assert(array_key_exists(array: $event, key: 'date')); + + return $event['date'] < $today; + } + ) + ->count(); + } + public function getYearsOfExperience(): int { return (new \DateTimeImmutable())->format('Y') - 2007;