Skip to content

Commit

Permalink
Retrofit for Drupal
Browse files Browse the repository at this point in the history
  • Loading branch information
mglaman committed Jun 5, 2023
0 parents commit 593b5db
Show file tree
Hide file tree
Showing 80 changed files with 7,743 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[composer.{json,lock}]
indent_size = 4

[*.neon]
indent_style = tab
indent_size = 4
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/phpstan-baseline.neon export-ignore
/tests/ export-ignore
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: mglaman
ko_fi: mglaman
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI
on:
push:
branches: [ main ]
paths-ignore:
- '**.md'
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: gd
coverage: none
tools: composer:v2

- name: Install dependencies
run: composer install --no-progress --prefer-dist
- name: Composer validate
run: composer validate --strict
- name: Composer normalize
run: composer normalize --dry-run
- name: PHPCS
run: php vendor/bin/phpcs
static:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: gd
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-progress --prefer-dist
- name: PHPStan
run: php vendor/bin/phpstan analyze
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: gd
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-progress --prefer-dist
- name: phpunit
run: php vendor/bin/phpunit
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/.phpunit.cache
/.phpunit.result.cache

/composer.lock
/vendor

/.idea

/phpcs.xml
/phpunit.xml
/phpstan.neon
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Matt Glaman

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Retrofit for Drupal

The Retrofit provides compatibility layers for legacy Drupal code to allow run on any version of Drupal.

## Installation

```shell
composer require mglaman/retrofit-drupal
```

And that's it! 🎉

## How it works

This library registers a service provider to integrate with Drupal automatically.

## Usage

Currently, the compatibility layers are drop-in replacements. This means you can use them in your code without any
changes. Some functions are namespaced for compatibility.

You must modify your Drupal 7 modules `.info` file to `info.yml`.

* Add `type: module`
* Add `core_version_requirement: >= 10`

### Namespaced functions

* `module_load_include` is now `Retrofit\Drupal\module_load_include`

### Fixing placeholders in `t()`

The `!` placeholder is no longer valid. Placeholders using `!` in `t()` need to be manually changed to `@` or `:`.
7 changes: 7 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

use Retrofit\Drupal\Provider;

$GLOBALS['conf']['container_service_providers']['retrofit'] = Provider::class;
50 changes: 50 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "mglaman/retrofit-drupal",
"description": "Retrofit provides compatibility layers to run legacy Drupal code.",
"license": "MIT",
"type": "library",
"authors": [
{
"name": "Matt Glaman",
"email": "[email protected]"
}
],
"require": {
"php": "^8.1",
"drupal/core": "^10"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.31",
"mglaman/drupal-test-helpers": "^1.0",
"mikey179/vfsstream": "^1.6",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3.7",
"symfony/css-selector": "^6.3",
"symfony/phpunit-bridge": "^6.2"
},
"autoload": {
"psr-4": {
"Retrofit\\Drupal\\": "src"
},
"files": [
"src/constants.php",
"src/functions.php",
"bootstrap.php"
]
},
"autoload-dev": {
"psr-4": {
"Retrofit\\Drupal\\Tests\\": "tests/src"
}
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true,
"ergebnis/composer-normalize": true
}
}
}
17 changes: 17 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<ruleset name="drupal-memory-kernel">
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="utf-8"/>
<arg name="tab-width" value="4"/>
<arg value="sp"/>

<file>src</file>
<file>tests</file>

<rule ref="PSR12">
<!-- Already checked with the sniff Squiz.WhiteSpace.SemicolonSpacing.Incorrect -->
<exclude name="PSR12.Files.DeclareStatement.SpaceFoundBeforeSemicolon"/>
</rule>

</ruleset>
Loading

0 comments on commit 593b5db

Please sign in to comment.