Skip to content

Commit

Permalink
Adds version restriction to ^0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vassyli committed Apr 5, 2019
1 parent f6efde1 commit c431262
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 30 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"lotgd/core": "dev-feature/admin-commands as 0.5.1",
"lotgd/core": "^0.5.0",
"sensio/framework-extra-bundle": "^5.2",
"symfony/asset": "4.2.*",
"symfony/console": "4.2.*",
Expand All @@ -33,12 +33,14 @@
"symfony/twig-bundle": "4.2.*",
"symfony/validator": "4.2.*",
"symfony/web-link": "4.2.*",
"symfony/yaml": "4.2.*"
"symfony/yaml": "4.2.*",
"twig/extensions": "^1.5"
},
"require-dev": {
"lotgd/module-forest": ">0.4",
"lotgd/module-gender": ">0.4",
"lotgd/module-new-day": ">0.4",
"lotgd/module-res-charstats": "dev-master",
"lotgd/module-res-fight": ">0.4",
"lotgd/module-scene-bundle": ">0.4",
"lotgd/module-village": ">0.4",
Expand Down
144 changes: 118 additions & 26 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions config/packages/twig_extensions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
_defaults:
public: false
autowire: true
autoconfigure: true

# Uncomment any lines below to activate that Twig extension
#Twig\Extensions\ArrayExtension: ~
#Twig\Extensions\DateExtension: ~
#Twig\Extensions\IntlExtension: ~
#Twig\Extensions\TextExtension: ~
2 changes: 2 additions & 0 deletions src/Controller/CharacterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


use LotGD\Core\Exceptions\ActionNotFoundException;
use LotGD\Core\Models\CharacterStats;
use LotGD\Crate\WWW\Service\GameService;
use LotGD\Crate\WWW\Service\Realm;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down Expand Up @@ -58,6 +59,7 @@ public function sceneRender(
"realm" => $realm,
"user" => $security->getUser(),
"character" => $game->getCharacter(),
"character_stats" => new CharacterStats($game, $game->getCharacter()),
"viewpoint" => $game->getViewpoint(),
"viewpoint_error" => $viewpoint_error??null,
]);
Expand Down
51 changes: 51 additions & 0 deletions src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
declare(strict_types=1);


namespace LotGD\Crate\WWW\Twig;


use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigTest;

/**
* Adds custom filters.
* @package LotGD\Crate\WWW\Twig
*/
class AppExtension extends AbstractExtension
{
public function getTests()
{
return [
new TwigTest("instanceOf", [$this, "_instanceOf"]),
];
}

public function getFilters()
{
return [
new TwigFilter("viewpoint_format", [$this, "formatContent"]),
];
}

public function _instanceOf($object, $class)
{
if (!is_object($object)) {
return false;
}

if ($object instanceof $class) {
return true;
}

return false;
}

public function formatContent($text)
{
$text = explode("\n\n", $text);
$text = implode("</p><p>", $text);
return "<p>{$text}</p>";
}
}
15 changes: 15 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@
"lotgd/module-new-day": {
"version": "v0.4.0-alpha"
},
"lotgd/module-res-charstats": {
"version": "dev-master"
},
"lotgd/module-res-fight": {
"version": "v0.4.0"
},
Expand Down Expand Up @@ -461,6 +464,18 @@
"symfony/yaml": {
"version": "v4.2.2"
},
"twig/extensions": {
"version": "1.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "master",
"version": "1.0",
"ref": "ddb2e0a77773b7fd75d8d649545f174e664500ab"
},
"files": [
"config/packages/twig_extensions.yaml"
]
},
"twig/twig": {
"version": "v2.6.2"
},
Expand Down
Loading

0 comments on commit c431262

Please sign in to comment.