index.php
45 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Kubio\Blocks; |
| 4 | |
| 5 | use Kubio\Core\Blocks\BlockBase; |
| 6 | use Kubio\Core\Registry; |
| 7 | |
| 8 | class DividerBlock extends BlockBase { |
| 9 | |
| 10 | const OUTER = 'outer'; |
| 11 | const LINE = 'line'; |
| 12 | const INNER = 'inner'; |
| 13 | |
| 14 | public function computed() { |
| 15 | $iconEnabled = false; |
| 16 | if ( $this->getProp( 'type' ) === 'icon' ) { |
| 17 | $iconEnabled = true; |
| 18 | } |
| 19 | return array( |
| 20 | 'iconEnabled' => $iconEnabled, |
| 21 | ); |
| 22 | } |
| 23 | |
| 24 | public function mapPropsToElements() { |
| 25 | if ( $this->getProp( 'type' ) === 'icon' ) { |
| 26 | if ( ! $this->getAttribute( 'iconName' ) ) { |
| 27 | $icon = ''; |
| 28 | } else { |
| 29 | $icon = $this->getAttribute( 'iconName' ); |
| 30 | } |
| 31 | } else { |
| 32 | $icon = null; |
| 33 | } |
| 34 | return array( |
| 35 | self::INNER => array( 'name' => $icon ), |
| 36 | ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | |
| 41 | Registry::registerBlock( |
| 42 | __DIR__, |
| 43 | DividerBlock::class |
| 44 | ); |
| 45 |