Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache refactor #452

Open
wants to merge 13 commits into
base: release/10.0.0
Choose a base branch
from
Prev Previous commit
updating cache and helpers
  • Loading branch information
iruzevic committed Feb 21, 2025
commit dfcf982f76dc68eaa23aa138420d702d26ee04ad
11 changes: 6 additions & 5 deletions src/Helpers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ public static function render(
$componentName = \explode(\DIRECTORY_SEPARATOR, $renderPrefixPath)[0] ?? '';

if ($componentName) {
$renderPath = Helpers::getProjectPaths('blocksRoot', [$renderPathName, $renderPrefixPath, "{$renderName}.php"]);
$renderPath = Helpers::getProjectPaths('components', [$renderPrefixPath, "{$renderName}.php"]);
$manifest = Helpers::getComponent($componentName);
} else {
$renderPath = Helpers::getProjectPaths('blocksRoot', [$renderPathName, $renderPrefixPath, $renderName, "{$renderName}.php"]);
$renderPath = Helpers::getProjectPaths('components', [$renderPrefixPath, $renderName, "{$renderName}.php"]);
$manifest = Helpers::getComponent($renderName);
}

Expand All @@ -139,16 +139,16 @@ public static function render(
break;
case 'wrapper':
$manifest = Helpers::getWrapper();
$renderPath = Helpers::getProjectPaths('blocksRoot', [$renderPathName, "{$renderName}.php"]);
$renderPath = Helpers::getProjectPaths('wrapper', ["{$renderName}.php"]);
break;
case 'blocks':
$blockName = \explode(\DIRECTORY_SEPARATOR, $renderPrefixPath)[0] ?? '';

if ($blockName) {
$renderPath = Helpers::getProjectPaths('blocksRoot', [$renderPathName, $renderPrefixPath, "{$renderName}.php"]);
$renderPath = Helpers::getProjectPaths('blocks', [$renderPrefixPath, "{$renderName}.php"]);
$manifest = Helpers::getBlock($blockName);
} else {
$renderPath = Helpers::getProjectPaths('blocksRoot', [$renderPathName, $renderPrefixPath, $renderName, "{$renderName}.php"]);
$renderPath = Helpers::getProjectPaths('blocks', [$renderPrefixPath, $renderName, "{$renderName}.php"]);
$manifest = Helpers::getBlock($renderName);
}

Expand Down Expand Up @@ -199,6 +199,7 @@ public static function render(
return \trim((string) \ob_get_clean());
}


/**
* Internal helper for getting all project paths for easy mocking in tests.
*
Expand Down