1
0
mirror of https://github.com/flarum/core.git synced 2025-07-31 13:40:20 +02:00

feat: allow replacing of blade template namespaces via extender (#3167)

* feat: allow replacing of blade template namespaces

* wip: add `prependNamespace` support

* test: add replace namespace test

* Apply fixes from StyleCI

[ci skip] [skip ci]

* fix: add missing property

* test: add prepend test

* fix: add view namespaces before resolving

Allows `replaceNamespace()` extender to actually remove old routes.

* test: make replace test ensure that replaced view does not exist

* docs: update docblock

* Apply fixes from StyleCI

[ci skip] [skip ci]

* fix: missing `\` before class

* fix: change test view namespace

* chore: simplify test

* Remove replace namespace code

We only really need prepend.

* chore: rename extender

* ci: add override test

* Apply fixes from StyleCI

[ci skip] [skip ci]

* fix(tests): add `trim` call

* revert: 3d46ead14b

Co-authored-by: luceos <luceos@users.noreply.github.com>
This commit is contained in:
David Wheatley
2021-12-20 09:56:48 +01:00
committed by GitHub
parent c8febb6199
commit fbaf936e7e
3 changed files with 59 additions and 3 deletions

View File

@@ -0,0 +1 @@
<html><body>We have overridden the core app view.</body></html>

View File

@@ -36,4 +36,34 @@ class ViewTest extends TestCase
$this->assertEquals('<html><body>Hello World!</body></html>', trim($this->app()->getContainer()->make(Factory::class)->make('integration.test::test')->render()));
}
/**
* @test
*/
public function can_add_view_to_namespace_by_prepend_extender()
{
$this->extend(
(new Extend\View)
->extendNamespace('flarum', dirname(__FILE__, 3).'/fixtures/views')
);
$this->assertEquals('<html><body>Hello World!</body></html>', trim($this->app()->getContainer()->make(Factory::class)->make('flarum::test')->render()));
}
/**
* @test
*/
public function can_override_view_in_namespace_by_prepend_extender()
{
$this->extend(
(new Extend\View)
->extendNamespace('flarum', dirname(__FILE__, 3).'/fixtures/views/override')
);
$response = $this->send(
$this->request('GET', '/')
);
$this->assertEquals('<html><body>We have overridden the core app view.</body></html>', trim($response->getBody()->getContents()));
}
}