<?php
namespace Website\Widgets\Accordion; use Moto; class Widget extends Moto\System\Widgets\AbstractContainerWidget { protected $_name = 'accordion'; protected static $_defaultProperties = array( 'preset' => 'default', 'animation' => '', 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), 'closeOthers' => true, 'expandedFirstItem' => false, 'showCollapseIcon' => true, 'collapseIconAlign' => 'right', 'visible_on' => 'mobile-v', ); protected $_templateType = 'templates'; protected $_templatePath = '@websiteWidgets/accordion/templates/default.twig.html'; protected $_widgetId = true; public function init() { if (isset($this->properties['items'])) { $this->_migrateItems(); unset($this->properties['items']); } parent::init(); } protected function _migrateItems() { foreach ($this->properties['items'] as $item) { $this->children[] = array( 'name' => 'accordion.item', 'properties' => array( 'header' => $item['header'], ), 'children' => $item['body']['content'] ); } } } 