s25/promo
最新稳定版本:1.0.1
Composer 安装命令:
composer require s25/promo
包简介
package for connecting promo to the project
README 文档
README
Package for connecting promotion to the project.
Install
composer require s25/promo
Usage
- Create the PromotionClient extended from base class
use S25\Promo; class PromotionClient extends BasePromotionsClient { public function getHeaderPlace(): PromoPlace|null { return $this->getPlace('header'); } public function getCategoryPlace(array $conditions = []): PromoPlace|null { return $this->getPlace('header', $conditions); } }
- Create the promo client facade
use S25\Promo; class PromotionClientFacade { private static PromotionsClient|null $instance; private static bool $isSet = false; public static function getInstance(): PromotionsClient|null { if (!self::$isSet) { try{ self::$isSet = true; $options = new PromotionsClientOptions('host', 'project', 'ru'); self::$instance = new PromotionsClient(new \GuzzleHttp\Client(), $options); } catch (Exception) { self::$instance = null; } } return self::$instance; } }
- Create template
<?php $promotionPlace = PromotionClientFacade::getInstance()?->getHeaderPlace() ?> <?php if($promotionPlace !== null): ?> <div [data-location-name="<?= $promotionPlace->getName() ?>" class="<?= $promotionPlace->getClasses() ?>" style="<?= $promotionPlace->getStyle() ?>" > <iframe src="<?= $promotionPlace->getIframeSrc()?>"></iframe> </div> <?php endif; ?>
- Javascript
npm i @shop25/banners-client
import { PromotionClient } from '@shop25/banners-client' import '@shop25/banners-client/dist/style.css' const element = document.querySelector('[my-selector]') const location = client.createLocation('header') location.mount(element).then(() => console.log('mounted')) // if need destroy location.destroy()
统计信息
- 总下载量: 7.72k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2022-09-01