nligo / material-bundle
appcoachs 广告材料包
dev-master / 2.5.x-dev
2017-03-29 11:02 UTC
Requires
- php: >=5.3.3
- symfony/framework-bundle: ~2.3|~3.0
Requires (Dev)
- symfony/expression-language: ~2.4|~3.0
This package is not auto-updated.
Last update: 2024-09-20 20:21:13 UTC
README
请使用 MaterialBundle 代替
MaterialBundle,Appcoachs 的材料
需求
- Symfony (2.1 (master 分支) 或更高版本)
安装
使用 composer 需求项目
composer require nligo/material-bundle "dev-master"
在您的 AppKernel
中注册包
$bundles = array(
new Appcoachs\Bundle\MaterialBundle\AppcoachsMaterialBundle(),
...
);
使用 MaterialBundle
,我只需要在您的 app/config/sonata.yml
中进行少量配置。加入以下配置可以
sonata_admin:
dashboard:
groups:
sonata.admin.group.,material:
label: Video Private Auction
item_adds:
- appcoachs.admin.material.creative
roles: [ ROLE_ADMIN, ROLE_ADVERTISER, ROLE_OPERATOR ]
sonata.admin.group.,admin:
label: Admin Setting
item_adds:
- appcoachs.admin.material.mediamanagement
roles: [ ROLE_ADMIN]
在 app/config/routing.yml
路由文件中引入
appcoachs_material:
resource: "@AppcoachsMaterialBundle/Resources/config/routing.yml"
prefix: /
在 Appcoachs/Bundle/ManageBundle/Document/Creative.php
中添加新字段并生成 get set 方法
/**
* Creative Campaign
*
* @MongoDB\ReferenceOne(targetDocument="Appcoachs\Bundle\ManageBundle\Document\Campaign")
*/
protected $campaign;
/**
* Get campaign
*
* @return Appcoachs\Bundle\ManageBundle\Document\Campaign $campaign
*/
public function getCampaign()
{
return $this->campaign;
}
/**
* Creative ReviewStatus
*
* @MongoDB\String
*/
protected $reviewStatus;
/**
* Creative Adid
*
* @MongoDB\String
*/
protected $adid;
/**
* Set campaign
* @param Appcoachs\Bundle\ManageBundle\Document\Campaign $campaign
* @return self
*/
public function setCampaign($campaign)
{
$this->campaign = $campaign;
}
public function __construct()
{
$this->setReviewStatus('Ready');
}
/**
* Set reviewStatus
*
* @param string $reviewStatus
* @return self
*/
public function setReviewStatus($reviewStatus)
{
$this->reviewStatus = $reviewStatus;
return $this;
}
/**
* Get reviewStatus
*
* @return string $reviewStatus
*/
public function getReviewStatus()
{
return $this->reviewStatus;
}
/**
* Set mediaManagement
*
* @param \Appcoachs\Bundle\MaterialBundle\Document\MediaMangement $mediaManagement
* @return self
*/
public function setMediaManagement($mediaManagement)
{
$this->mediaManagement = $mediaManagement;
}
/**
* Get MediaManagement
*
* @return \Appcoachs\Bundle\MaterialBundle\Document\MediaMangement $mediaManagement
*/
public function getMediaManagement()
{
return $this->mediaManagement;
}
使用 MaterialBundle
,我只需要在您的 Appcoachs/Bundle/ManageBundle/Admin/AdgroupAdmin.php
中进行少量配置。替换以下方法
public function preUpdate($object)
{
if ($object->getReview() == 'approved') {
$object->setWeight(1);
}
if ($object->getReview() == 'rejected') {
$object->setWeight(2);
}
$owner = $this->getConfigurationPool()->getContainer()->get('security.token_storage')->getToken()->getUser();
$object->setOwner($owner);
if ($object->getCreatives()) {
foreach ($object->getCreatives() as $creative) {
if ($creative->getName() && $creative->getMedia()) {
$creative->setOwner($owner);
$creative->setCampaign($object->getCampaign());
$creative->setAdgroup($object);
} else {
$object->removeCreative($creative);
}
}
}
if ($object->getVideos()) {
foreach ($object->getVideos() as $videoad) {
if ($videoad->getStart() && $videoad->getComplete() && $videoad->getVideo()) {
$videoad->setAdgroup($object);
} else {
$object->removeVideo($videoad);
}
}
}
parent::preUpdate($object);
}