dukt /
facebook
| 1 | <?php |
||
| 2 | namespace dukt\facebook\widgets; |
||
| 3 | |||
| 4 | use Craft; |
||
| 5 | use dukt\facebook\Plugin as Facebook; |
||
| 6 | use dukt\facebook\web\assets\insightswidget\InsightsWidgetAsset; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * InsightsWidget represents an Insights dashboard widget. |
||
| 10 | * |
||
| 11 | * @author Dukt <[email protected]> |
||
| 12 | * @since 2.0 |
||
| 13 | */ |
||
| 14 | class InsightsWidget extends \craft\base\Widget |
||
| 15 | { |
||
| 16 | // Public Methods |
||
| 17 | // ========================================================================= |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @inheritdoc |
||
| 21 | */ |
||
| 22 | public static function displayName(): string |
||
| 23 | { |
||
| 24 | return Craft::t('facebook', 'Facebook Insights'); |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @inheritdoc |
||
| 29 | */ |
||
| 30 | public static function icon() |
||
| 31 | { |
||
| 32 | return Craft::getAlias('@dukt/facebook/icons/like.svg'); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @inheritdoc |
||
| 37 | */ |
||
| 38 | public function getBodyHtml() |
||
| 39 | { |
||
| 40 | $facebookInsightsObjectId = Facebook::$plugin->getSettings()->facebookInsightsObjectId; |
||
| 41 | |||
| 42 | if (Facebook::$plugin->isConfigured() && $facebookInsightsObjectId) { |
||
| 43 | Craft::$app->getView()->registerAssetBundle(InsightsWidgetAsset::class); |
||
| 44 | Craft::$app->getView()->registerJs('new Craft.FacebookInsightsWidget("widget'.$this->id.'");'); |
||
| 45 | |||
| 46 | return Craft::$app->getView()->renderTemplate('facebook/_components/widgets/Insights/body'); |
||
| 47 | } |
||
| 48 | |||
| 49 | return Craft::$app->getView()->renderTemplate('facebook/_components/widgets/Insights/not-configured'); |
||
| 50 | } |
||
| 51 | } |