Skip to content

Commit

Permalink
add logger function to block assests load
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriipavlov committed Jul 24, 2024
1 parent d5099d5 commit 4de9077
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion blocks/PricingTable/Block.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Block extends BlockAbstract
'editor_style' => [
'file' => 'editor.css',
'dependencies' => [],
]
],
'style' => [
'file' => 'style.css',
Expand Down
14 changes: 10 additions & 4 deletions src/Handlers/Blocks/BlockAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use RuntimeException;
use StarterKit\App;
use StarterKit\Handlers\Errors\ErrorHandler;
use StarterKit\Helper\Config;
use StarterKit\Helper\NotFoundException;
Expand Down Expand Up @@ -90,13 +92,16 @@ public function registerBlock(): void
* @param string $file
* @param array $data
* @param string|null $base
* @param bool $echo
*
* @return string
*
* @throws ContainerExceptionInterface
* @throws NotFoundException
* @throws NotFoundExceptionInterface
* @throws Throwable
*/
public function loadBlockView(string $file = '', array $data = [], string $base = null, $echo = false): string
public function loadBlockView(string $file = '', array $data = [], string $base = null, bool $echo = false): string
{
if ($base === null) {
$base = Config::get('blocksDir') . $this->blockName . '/' . Config::get('blocksViewDir');
Expand Down Expand Up @@ -215,7 +220,7 @@ public function registerBlockAssets(): void
/**
* Filter block asset dependencies
*/
$deps = apply_filters(
$deps = apply_filters(
Config::get('hooksPrefix') . '/block_asset_dependencies',
$asset['dependencies'],
$this->blockName,
Expand Down Expand Up @@ -254,8 +259,9 @@ public function registerBlockAssets(): void
}

if (!in_array($type, ['editor_script', 'editor_style', 'script', 'view_script', 'style', 'view_style'])) {
// ToDo vvv add correct error logging
error_log("Unsupported asset type or context: $type");
/** @var LoggerInterface $logger */
$logger = App::container()->get(LoggerInterface::class);
$logger->warning("Unsupported asset type or context: $type");
}
}
}
Expand Down

0 comments on commit 4de9077

Please sign in to comment.