Skip to content

Commit e6ee6ec

Browse files
committed
MC-15763: Introduce critical CSS scope loaded through head
- Stabilization
1 parent 19a39ad commit e6ee6ec

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

app/code/Magento/Theme/Block/Html/Header/CriticalCss.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Framework\View\Asset\File\NotFoundException;
1616

1717
/**
18-
* This ViewModel will add inline critical css in case dev/css/use_css_critical_path is enabled
18+
* This ViewModel will add inline critical css in case dev/css/use_css_critical_path is enabled.
1919
*/
2020
class CriticalCss implements ArgumentInterface
2121
{
@@ -30,10 +30,8 @@ class CriticalCss implements ArgumentInterface
3030
private $filePath;
3131

3232
/**
33-
* @param Template\Context $context
3433
* @param Repository $assetRepo
3534
* @param string $filePath
36-
* @param array $data
3735
*/
3836
public function __construct(
3937
Repository $assetRepo,
@@ -54,8 +52,11 @@ public function getCriticalCssData()
5452
try {
5553
$asset = $this->assetRepo->createAsset($this->filePath, ['_secure' => 'false']);
5654
$content = $asset->getContent();
57-
} catch (LocalizedException | NotFoundException $e) {
58-
throw new LocalizedException(__("Cannot get critical css file data: ", $e->getMessage()));
55+
} catch (NotFoundException $e) {
56+
throw new LocalizedException(__(
57+
'Cannot get critical css file data: "%1"',
58+
$e->getMessage()
59+
));
5960
};
6061

6162
return $content;

lib/internal/Magento/Framework/View/Asset/Repository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\Filesystem\DirectoryList;
1111
use Magento\Framework\App\ObjectManager;
1212
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
13+
use Magento\Framework\Exception\LocalizedException;
1314

1415
/**
1516
* A repository service for view assets
@@ -201,9 +202,10 @@ private function getDefaultParameter($name)
201202
/**
202203
* Create a file asset that's subject of fallback system
203204
*
204-
* @param string $fileId
205+
* @param $fileId
205206
* @param array $params
206207
* @return File
208+
* @throws LocalizedException
207209
*/
208210
public function createAsset($fileId, array $params = [])
209211
{

lib/internal/Magento/Framework/View/Layout/etc/head.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<xs:element name="script" type="scriptType" minOccurs="0" maxOccurs="unbounded"/>
6868
<xs:element name="remove" type="srcRemoveType" minOccurs="0" maxOccurs="unbounded"/>
6969
<xs:element name="attribute" type="headAttributeType" minOccurs="0" maxOccurs="unbounded"/>
70+
<xs:element name="font" type="linkType" minOccurs="0" maxOccurs="unbounded"/>app/code/Magento/Theme/Block/Html/Header/CriticalCss.php
7071
</xs:sequence>
7172
</xs:complexType>
7273
</xs:schema>

lib/internal/Magento/Framework/View/Page/Config/Reader/Head.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class Head implements Layout\ReaderInterface
3535

3636
/**
3737
* {@inheritdoc}
38-
*
39-
* @return string[]
4038
*/
4139
public function getSupportedNodes()
4240
{
@@ -66,10 +64,6 @@ protected function addContentTypeByNodeName(Layout\Element $node)
6664

6765
/**
6866
* {@inheritdoc}
69-
*
70-
* @param Layout\Reader\Context $readerContext
71-
* @param Layout\Element $headElement
72-
* @return $this
7367
*/
7468
public function interpret(
7569
Layout\Reader\Context $readerContext,

0 commit comments

Comments
 (0)