2017 © Pedro PelĂĄez
 

library publishable

A library base for publishable Entities for PositibeLabs Project

image

positibe/publishable

A library base for publishable Entities for PositibeLabs Project

  • Wednesday, March 29, 2017
  • by pcabreus
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Positibe Publishable Component

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., (*1)

PublishableTrait

This trait has the default mapping for a Entity that implement TranslatableInterface., (*2)

[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., (*3)

[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., (*4)

[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., (*5)

Caution: To use the trait system you need to use PHP > 5.4., (*6)

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., (*7)

The Versions

29/03 2017

dev-master

9999999-dev http://positibelabs.blogspot.com/component/publishable

A library base for publishable Entities for PositibeLabs Project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

positibelabs positibe publishable time period

29/03 2017

0.2.0.0

0.2.0.0 http://positibelabs.blogspot.com/component/publishable

A library base for publishable Entities for PositibeLabs Project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

positibelabs positibe publishable time period