Skip to content

Commit 212ed5a

Browse files
committed
AC-9831: Block template render enhancement
* fixed review comments
1 parent fe6cc2a commit 212ed5a

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lib/internal/Magento/Framework/View/Element/AbstractBlock.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Cache\LockGuardedCacheLoader;
1313
use Magento\Framework\Config\ConfigOptionsListConstants;
1414
use Magento\Framework\DataObject\IdentityInterface;
15+
use Magento\Framework\Exception\RuntimeException;
1516

1617
/**
1718
* Base class for all blocks.
@@ -1043,17 +1044,13 @@ public function getCacheKeyInfo()
10431044
* Get Key for caching block content
10441045
*
10451046
* @return string
1046-
* @throws \Magento\Framework\Exception\LocalizedException
1047+
* @throws RuntimeException
10471048
*/
10481049
public function getCacheKey()
10491050
{
10501051
if ($this->hasData('cache_key')) {
10511052
if (preg_match('/[^a-z0-9\-\_]/i', $this->getData('cache_key'))) {
1052-
throw new \Magento\Framework\Exception\LocalizedException(
1053-
__(
1054-
'Please enter cache key with only alphanumeric or hash string.'
1055-
)
1056-
);
1053+
throw new RuntimeException(__('Please enter cache key with only alphanumeric or hash string.'));
10571054
}
10581055

10591056
return static::CUSTOM_CACHE_KEY_PREFIX . $this->getData('cache_key');

lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Framework\Config\View;
1616
use Magento\Framework\Escaper;
1717
use Magento\Framework\Event\ManagerInterface as EventManagerInterface;
18-
use Magento\Framework\Exception\LocalizedException;
18+
use Magento\Framework\Exception\RuntimeException;
1919
use Magento\Framework\ObjectManagerInterface;
2020
use Magento\Framework\Session\SessionManagerInterface;
2121
use Magento\Framework\Session\SidResolverInterface;
@@ -246,13 +246,13 @@ public function testGetCacheKey()
246246
/**
247247
* Test for invalid cacheKey name
248248
* @return void
249-
* @throws LocalizedException
249+
* @throws RuntimeException
250250
*/
251251
public function testGetCacheKeyFail(): void
252252
{
253253
$cacheKey = "test&''Key";
254254
$this->block->setData('cache_key', $cacheKey);
255-
$this->expectException(LocalizedException::class);
255+
$this->expectException(RuntimeException::class);
256256
$this->expectExceptionMessage((string)__('Please enter cache key with only alphanumeric or hash string.'));
257257
$this->block->getCacheKey();
258258
}

0 commit comments

Comments
 (0)