PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.4.3
Kubio AI Page Builder v2.4.3
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 4 years ago Props 1 year ago BlockStyleRender.php 4 years ago DynamicStyles.php 3 years ago GlobalStyleRender.php 2 years ago MainAttribute.php 4 years ago ParserUtils.php 2 years ago StyleManager.php 2 years ago StyleParser.php 2 years ago StyleRender.php 2 years ago Utils.php 4 years ago
BlockStyleRender.php
71 lines
1 <?php
2
3 namespace Kubio\Core\StyleManager;
4
5 use Kubio\Config;
6 use Kubio\Core\Blocks\BlockBase;
7 use Kubio\Core\LodashBasic;
8
9 class BlockStyleRender extends StyleRender {
10 protected $block;
11 private $styleRef;
12
13
14 private static $rendererRefs = array();
15
16 protected $parentBlock = null;
17 protected $parentStyleRenderer = null;
18
19 public static function normalizeBlockData( $mainAttr, $blockType ) {
20 $supports = $blockType->supports;
21 $styledElementsByName = LodashBasic::get( $supports, array( Config::$mainAttributeKey, Config::$elementsKey ), array() );
22 $styledElementsEnum = LodashBasic::get( $supports, array( Config::$mainAttributeKey, Config::$elementsEnum ), array() );
23
24 return self::normalizeData( $mainAttr, $styledElementsByName, $styledElementsEnum );
25 }
26
27
28 public function setFlags() {
29
30 }
31
32
33 public function __construct( $block, $parent_block = null ) {
34 $this->block = $block;
35 $this->parentBlock = $parent_block;
36 $this->parentStyleRenderer = $parent_block ? new BlockStyleRender( $parent_block ) : null;
37 $mainAttr = $block->getMergedMainAttribute();
38 $this->styleRef = LodashBasic::get( $mainAttr, 'styleRef', null );
39
40 // check if the same style was already rendered and skip new renders
41 if ( $this->styleRef && in_array( $this->styleRef, BlockStyleRender::$rendererRefs, true ) ) {
42 $this->skipSharedStyleRender = true;
43 }
44
45 BlockStyleRender::$rendererRefs[] = $this->styleRef;
46
47 $normalized = self::normalizeBlockData( array_merge( $mainAttr, array( 'id' => $this->block->localId() ) ), $block->block_type );
48 $this->model = (object) LodashBasic::get( $normalized, 'model', array() );
49
50 $prefixParents = array();
51 $useParentPrefix = $this->block->getBlockSupport( 'useParentPrefix' );
52 if ( $this->parentBlock ) {
53 $prefixParents[] = '.' . $this->parentStyleRenderer->componentInstanceClass( $this->parentBlock->getWrapperElementName(), 'shared' );
54 }
55
56 parent::__construct(
57 array(
58 'styledElementsByName' => LodashBasic::get( $normalized, 'styledElementsByName', array() ),
59 'styledElementsEnum' => LodashBasic::get( $normalized, 'styledElementsEnum', array() ),
60 'wrapperElement' => $block->getWrapperElementName(),
61 'prefixParents' => $prefixParents,
62 'useParentPrefix' => $useParentPrefix,
63 )
64 );
65 }
66
67 public function export( $dynamicStyle = null ) {
68 return parent::export( $dynamicStyle );
69 }
70 }
71