Skip to content

Commit

Permalink
The need for MobileTwigModule has decreased, so we will make it an op…
Browse files Browse the repository at this point in the history
…tional install.

See https://github.com/madapaja/Madapaja.TwigModule/releases/tag/2.6.0

In order to use the MobileTwigModule, it is necessary to install mobiledetect/mobiledetectlib. Relocate `mobiledetect/mobiledetectlib` to "require-dev" in composer.json and implement a runtime check that throws an exception if the dependency is missing in MobileTwigModule. Additionally, add getInput method to ErrorPagerRenderer to handle input values from resource objects.
  • Loading branch information
koriym committed Nov 23, 2024
1 parent 0df8a84 commit 49977cc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"symbol-whitelist" : [
"Mobile_Detect"
"Mobile_Detect", "Detection\\MobileDetect"
],
"php-core-extensions" : [
"Core",
Expand All @@ -15,4 +15,4 @@
"standard"
],
"scan-files" : []
}
}
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"bear/sunday": "^1.7",
"bear/app-meta": "^1.8",
"twig/twig": "^v3.15",
"mobiledetect/mobiledetectlib": "^3.74.3",
"ray/di": "^2.17",
"ray/aop": "^2.17",
"psr/log": "^3.0.2"
},
"require-dev": {
"mobiledetect/mobiledetectlib": "^3.74.3",
"phpunit/phpunit": "^9.6.21",
"doctrine/annotations": "^1.14.4 || ^2.0",
"bamarni/composer-bin-plugin": "^1.8.2"
Expand Down Expand Up @@ -66,5 +66,8 @@
"bin-links": true,
"forward-command": true
}
},
"suggest": {
"mobiledetect/mobiledetectlib": "MobileTwigModule"
}
}
13 changes: 13 additions & 0 deletions src/MobileTwigModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

namespace Madapaja\TwigModule;

use Detection\MobileDetect;
use Ray\Di\AbstractModule;
use RuntimeException;

use function class_exists;

/**
* Provides TemplateFinderInterface and derived bindings
Expand All @@ -17,6 +21,15 @@
*/
class MobileTwigModule extends AbstractModule
{
public function __construct(AbstractModule $module)
{
if (! class_exists(MobileDetect::class)) {
throw new RuntimeException('mobiledetect/mobiledetectlib is required for MobileTwigModule, please install it via composer. (composer require mobiledetect/mobiledetectlib)'); // @codeCoverageIgnore
}

parent::__construct($module);
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 49977cc

Please sign in to comment.