Open bnomei opened 5 years ago
NOPE. i am getting an error on composer install
Fatal error: Class 'Kirby\Editor\Block' not found in /%%USER%%/kirby3-srcset/classes/Kirby/Editor/SrcsetBlock.php on line 9 PHP Fatal error: Class 'Kirby\Editor\Block' not found in /%%USER%%/kirby3-srcset/classes/Kirby/Editor/SrcsetBlock.php on line 9 Script composer install handling the kirby event returned with error code 255
i added the %%USER%%
part. :)
solved that in adding a faux class. composer runs now.
<?php
namespace Kirby\Editor;
use Throwable;
if (!class_exists('Kirby\Editor\Block')) {
class Block { }
}
final class SrcsetBlock extends Block
{
this made me pass unittests
<?php
namespace Kirby\Editor;
use Throwable;
if (!class_exists('Kirby\Editor\Block')) {
load([
'kirby\editor\block' => __DIR__ . '/../../../tests/site/plugins/editor/lib/Block.php',
'kirby\editor\blocks' => __DIR__ . '/../../../tests/site/plugins/editor/lib/Blocks.php',
]);
}
final class SrcsetBlock extends Block
{
//...
@bastianallgeier my fix broke recently. it seems that since my srcsetblock depends inherits from you block class loading order is important but not guaranteed in composer setups (for reasons unclear to me). https://github.com/bnomei/kirby3-srcset/issues/15
i solved this by duplicating your block and blocks classes to my project but i think its a horrible idea. https://github.com/bnomei/kirby3-srcset/blob/aeafd2a71ac39dd9f4c472205d8c151bda612391/classes/Kirby/Editor/SrcsetBlock.php#L20
maybe we could solve this inheritance problem better?
in my plugin i have a class extending the editor. https://github.com/bnomei/kirby3-srcset/blob/2ed1d7e38c131c6545f793d74b236ae2844ef489/classes/Kirby/Editor/SrcsetBlock.php#L9
but the complete plugin consists of more then the editor block. will it break if the editor is not installed? my guess is not since the class will never be called?
i am loading the class with composer https://github.com/bnomei/kirby3-srcset/issues/12
but that should not matter either until my class is called? which it will not when the editor is not installed/used?