Skip to content

Commit d91bb35

Browse files
committed
Fixed fallback support for plugins, closes #25
1 parent 507883a commit d91bb35

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Prolet and other ExpressionEngine Control Panel URLs were using old admin route
88
- Channel Entries tag support for random ordering
99
- An issue preventing the Comment Form Tag from rendering
10+
- Fallback support for plugins which do not require a method name
1011

1112
## [2.0.0] - 2025-01-14
1213

src/Core.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function runGlobal()
8686
$headers = $this->getRestrictedProperty($response, 'headers');
8787

8888
if ($body == '') {
89-
return (new Response)->fromOutput($status);
89+
return (new Response)->fromOutput($status, $headers);
9090
}
9191

9292
return new \Illuminate\Http\Response($body, $status, $headers);

src/Response.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class Response
99
* This code is taken from EE_Output::_display() with some modifications
1010
*
1111
* @param int $status
12+
* @param array $headers
1213
* @return Illuminate\Http\Response
1314
*/
14-
public function fromOutput($status = 200)
15+
public function fromOutput($status = 200, $headers = [])
1516
{
1617
$output = ee()->output->final_output;
1718
$response = ee('Response') ?: new \ExpressionEngine\Core\Response;
@@ -36,7 +37,6 @@ public function fromOutput($status = 200)
3637

3738
// Content Type Headers
3839
// Also need to do some extra work for feeds
39-
4040
switch (ee()->output->out_type) {
4141
case 'webpage':
4242
if (! $response->hasHeader('Content-Type')) {
@@ -258,7 +258,7 @@ public function fromOutput($status = 200)
258258

259259
// Transform headers that have already been set on the request
260260
// to the correct format ["header_name" => "value"]
261-
$headers = array_reduce(headers_list(), function ($carry, $header) use ($exclude, $duplicates) {
261+
$headers = array_merge($headers, array_reduce(headers_list(), function ($carry, $header) use ($exclude, $duplicates) {
262262
$header = $this->parseHeader($header);
263263

264264
if (! in_array(strtolower($header->name), $exclude)) {
@@ -271,7 +271,7 @@ public function fromOutput($status = 200)
271271
}
272272

273273
return $carry;
274-
}, []);
274+
}, []));
275275

276276
// Transform and set headers that have been assigned to the Output class
277277
// but not yet set on the request to be ["header_name" => "value"]

src/TemplateOutput.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public function value($value)
2626
if (is_array($value) || $value instanceof Arrayable) {
2727
$this->array(is_array($value) ? $value : $value->toArray());
2828
} else {
29-
$this->string(is_string($value) ? $value : (string) $value);
29+
try {
30+
$this->string(is_string($value) ? $value : (string) $value);
31+
} catch (\Throwable $e) {
32+
}
3033
}
3134

3235
return $this;

src/View/Exp.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static function boot()
2929
})->all();
3030

3131
$plugins = Addon\Plugin::get()->keyBy(function ($plugin) {
32-
return strtolower($plugin->plugin_name);
32+
return strtolower($plugin->plugin_package);
3333
})->all();
3434

3535
static::$addons = array_merge($plugins, $modules);
@@ -148,6 +148,19 @@ public function __get($key)
148148
return $fallback;
149149
}
150150

151+
public function __call($method, $arguments)
152+
{
153+
static::boot();
154+
155+
if ($this->__isset($method)) {
156+
$tag = $this->$method;
157+
158+
if ($tag && $tag instanceof Tag) {
159+
return $tag(...$arguments);
160+
}
161+
}
162+
}
163+
151164
public function __isset($key)
152165
{
153166
static::boot();

src/View/LegacyTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function run()
3535
}, []);
3636

3737
return Coilpack::isolateTemplateLibrary(function ($template) {
38-
$output = $this->getInstanceClass()->{$this->method}();
38+
$output = $this->method ? $this->getInstanceClass()->{$this->method}() : $this->getInstanceClass();
3939
$templateData = $template->get_data();
4040
$templateOutput = \Expressionengine\Coilpack\TemplateOutput::make();
4141

0 commit comments

Comments
 (0)