2017 © Pedro Peláez
 

library entity-before-save

EntityBeforeSave module for zend framework 3

image

vim/entity-before-save

EntityBeforeSave module for zend framework 3

  • Saturday, January 20, 2018
  • by vanvas
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

entity-before-save

Module for Zend Framework 3., (*1)

Installation

Installation of this module uses composer. For composer documentation, please refer to getcomposer.org., (*2)

composer require vim/entity-before-save

Register Vim\EntityBeforeSave in config/modules.config.php:, (*3)

<?php
return [
    'Vim\EntityBeforeSave',
];

Example

<?php
namespace Application\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="article")
 * @ORM\Entity
 */
class ArticleEntity implements \Vim\EntityBeforeSave\Entity\BeforeSaveAwareInterface
{
    /**
     * @var integer
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $identity;

    /**
     * @var \DateTime
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
     */
    private $createdAt;

    /**
     * @var \DateTime
     * @ORM\Column(name="updated_at", type="datetime", nullable=true)
     */
    private $updatedAt;

    /**
     * Method is called before saving the entity
     * @param array $changedData
     */
    public function onBeforeSave(array $changedData): void
    {
        $currentDate = new \DateTime();
        $this->updatedAt = $currentDate;

        if (!$this->identity) {
            $this->createdAt = $currentDate;
        }
    }
}

The Versions

20/01 2018

dev-master

9999999-dev https://github.com/vanvas/entity-before-save.git

EntityBeforeSave module for zend framework 3

  Sources   Download

The Requires

 

php zend framework zf2 module zf3 module entity before save

20/01 2018

1.0.0

1.0.0.0 https://github.com/vanvas/entity-before-save.git

EntityBeforeSave module for zend framework 3

  Sources   Download

The Requires

 

php zend framework zf2 module zf3 module entity before save