PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.0
Kubio AI Page Builder v2.8.0
2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / src / Core / StyleManager / BlockStyleRender.php
kubio / lib / src / Core / StyleManager Last commit date
Generics 1 year ago Props 1 month ago BlockStyleRender.php 1 year ago DynamicStyles.php 1 year ago GlobalStyleRender.php 1 year ago MainAttribute.php 4 years ago ParserUtils.php 1 year ago StyleManager.php 2 years ago StyleParser.php 1 year ago StyleRender.php 1 year ago Utils.php 1 year ago
BlockStyleRender.php
69 lines
1 <?php
2
3 namespace Kubio\Core\StyleManager;
4
5 use Kubio\Config;
6 use Kubio\Core\LodashBasic;
7
8 class BlockStyleRender extends StyleRender {
9 protected $block;
10 private $styleRef;
11
12
13 private static $rendererRefs = array();
14
15 protected $parentBlock = null;
16 protected $parentStyleRenderer = null;
17
18 public static function normalizeBlockData( $mainAttr, $blockType ) {
19 $supports = $blockType->supports;
20 $styledElementsByName = LodashBasic::get( $supports, array( Config::$mainAttributeKey, Config::$elementsKey ), array() );
21 $styledElementsEnum = LodashBasic::get( $supports, array( Config::$mainAttributeKey, Config::$elementsEnum ), array() );
22
23 return self::normalizeData( $mainAttr, $styledElementsByName, $styledElementsEnum );
24 }
25
26
27 public function setFlags() {
28 }
29
30
31 public function __construct( $block, $parent_block = null ) {
32 $this->block = $block;
33 $this->parentBlock = $parent_block;
34 $this->parentStyleRenderer = $parent_block ? new BlockStyleRender( $parent_block ) : null;
35 $mainAttr = $block->getMergedMainAttribute();
36 $this->styleRef = LodashBasic::get( $mainAttr, 'styleRef', null );
37
38 // check if the same style was already rendered and skip new renders
39 if ( $this->styleRef && in_array( $this->styleRef, BlockStyleRender::$rendererRefs, true ) ) {
40 $this->skipSharedStyleRender = true;
41 }
42
43 BlockStyleRender::$rendererRefs[] = $this->styleRef;
44
45 $normalized = self::normalizeBlockData( array_merge( $mainAttr, array( 'id' => $this->block->localId() ) ), $block->block_type );
46 $this->model = (object) LodashBasic::get( $normalized, 'model', array() );
47
48 $prefixParents = array();
49 $useParentPrefix = $this->block->getBlockSupport( 'useParentPrefix' );
50 if ( $this->parentBlock ) {
51 $prefixParents[] = '.' . $this->parentStyleRenderer->componentInstanceClass( $this->parentBlock->getWrapperElementName(), 'shared' );
52 }
53
54 parent::__construct(
55 array(
56 'styledElementsByName' => LodashBasic::get( $normalized, 'styledElementsByName', array() ),
57 'styledElementsEnum' => LodashBasic::get( $normalized, 'styledElementsEnum', array() ),
58 'wrapperElement' => $block->getWrapperElementName(),
59 'prefixParents' => $prefixParents,
60 'useParentPrefix' => $useParentPrefix,
61 )
62 );
63 }
64
65 public function export( $dynamicStyle = null ) {
66 return parent::export( $dynamicStyle );
67 }
68 }
69