承接 positibe/publishable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

positibe/publishable

Composer 安装命令:

composer require positibe/publishable

包简介

A library base for publishable Entities for PositibeLabs Project

README 文档

README

This library provide you some traits to be used in doctrine entities that implement Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface and Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface.

PublishableTrait

This trait has the default mapping for a Entity that implement TranslatableInterface.

[php]
namespace Positibe\Component\Publishable\Entity;

trait PublishableTrait
{
    /**
     * @var boolean
     *
     * @ORM\Column(name="publishable", type="boolean")
     */
    protected $publishable = true;

    public function isPublishable()
    {
        return $this->publishable;
    }

    public function setPublishable($boolean)
    {
        $this->publishable = $boolean;
    }
}

PublishTimePeriodTrait

This trait has the default mapping for a Entity that implement PublishTimePeriodInterface.

[php]
namespace Positibe\Component\Publishable\Entity;

trait PublishTimePeriodTrait
{
    /**
     * @var \DateTime
     *
     * @ORM\Column(name="publish_start_date", type="datetime", nullable=TRUE)
     */
    protected $publishStartDate;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="publish_end_date", type="datetime", nullable=TRUE)
     */
    protected $publishEndDate;

    public function setPublishStartDate(\DateTime $startDate = null)
    {
        $this->publishStartDate = $startDate;
    }

    public function getPublishStartDate()
    {
        return $this->publishStartDate;
    }

    public function setPublishEndDate(\DateTime $endDate = null)
    {
        $this->publishEndDate = $endDate;
    }

    public function getPublishEndDate()
    {
        return $this->publishEndDate;
    }
}

Using php trait

These are simple php traits so you can use it like that.

[php]
namespace Blog\Entity;

use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface;
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface;
use Positibe\Component\Publishable\Entity\PublishableTrait;
use Positibe\Component\Publishable\Entity\PublishTimePeriodTrait;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table()
 * @ORM\Entity
 */
class Post implement PublishableInterface, PublishTimePeriodInterface
{
    use PublishableTrait;
    use PublishTimePeriodTrait;
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
}

Note how you don't need to create anything to implement those interfaces.

Caution: To use the trait system you need to use PHP > 5.4.

Important: This library has not direct dependency of symfony-cmf/core-bundle, so you can use it without this one and need to be installed to use the interfaces.

统计信息

  • 总下载量: 30
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固