<?php
namespace Website\Widgets\Facebook; use Moto; class PagePluginWidget extends Moto\System\Widgets\AbstractWidget { protected $_name = 'facebook_page_plugin'; protected static $_defaultProperties = array( 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), 'visible_on' => 'mobile-v', 'align' => array( 'desktop' => 'center', 'tablet' => '', 'mobile-v' => '', 'mobile-h' => '', ), 'title' => '', 'params' => array( 'href' => '', 'width' => 500, 'height' => 500, 'hide_cover' => false, 'show_facepile' => true, 'show_posts' => true, 'hide_cta' => false, 'small_header' => true, 'adapt_container_width' => true, ), ); protected $_widgetId = true; public function getTemplatePath($preset = 'default') { return '@websiteWidgets/facebook/templates/page_plugin.twig.html'; } public function getHref() { $facebookUrlPattern = '/^(http[s]?:\/\/)?((www\.)?facebook\.com\/)(.+)$/i'; if (preg_match($facebookUrlPattern, $this->getPropertyValue('params.href', ''))) { return $this->getPropertyValue('params.href'); } else { return ''; } } } 