Re-add syntax highlighting to daily emails and

...ATDC lessons
This commit is contained in:
Oliver Davies 2024-02-18 01:35:59 +00:00
parent 0d9bb37503
commit 5fbf48d9ac
48 changed files with 186 additions and 165 deletions

View file

@ -8,7 +8,7 @@ tags: [php]
Here's a snippet of some Drupal code that I wrote last week. It's responsible for converting an array of nodes into a Collection of one of it's field values.
```php
```language-php
return Collection::make($stationNodes)
->map(fn (NodeInterface $station): string => $station->get('field_station_code')->getString())
->values();
@ -28,7 +28,7 @@ It accepts the original node but checks to ensure that the node is the correct t
I've added a helper method to get the field value, encapsulating that logic in a reusable function whilst making the code easier to read and its intent clearer.
```php
```language-php
namespace Drupal\mymodule\ValueObject;
use Drupal\node\NodeInterface;
@ -60,7 +60,7 @@ final class Station implements StationInterface {
This is what my code now looks like:
```php
```language-php
return Collection::make($stationNodes)
->map(fn (NodeInterface $node): StationInterface => Station::fromNode($node))
->map(fn (StationInterface $station): string => $station->getStationCode())