Reputation: 1016
I am new with Symfony. I would like to use LifeCycle callbacks. I've spent a lot of time to get it to work, but without success. I read documentation and much more sources and made several times that is written there.
I have definition in yml. Then I create entities by orm:generate... This process create for me even empty setUpdateTimestamp() function. I modify this function, but then when I do update, i don't see change.
BaseBundle\Entity\Person:
type: entity
table: people
fields:
id:
id: true
type: integer
nullable: false
generator:
strategy: IDENTITY
first_name:
type: string
length: 32
nullable: true
last_name:
type: string
length: 32
nullable: true
updatedAt:
type: datetime
nullable: false
lifecycleCallbacks:
preUpdate: [ setUpdateTimestamp ]
and
/**
* Person
*
* @ORM\Table(name="people")
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class Person extends BaseBundle\Entity\Base\BaseEntity
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=false)
*/
protected $updatedAt;
...........
/**
* @ORM\PreUpdate
*/
public function setUpdateTimestamp()
{
$this->setUpdatedAt(new \DateTime());
}
Where is my problem? Do I something wrong?
EDIT: I use for create entities and for create migration file.
php app/console orm:generate-super-entities --generate-annotations=1 --regenerate-entities=1 --extend="BaseBundle\Entity\Base\BaseEntity" --super-dest-path="src" --super-dest-namespace="Generated" src
php app/console doctrine:migrations:diff --configuration src/BaseBundle/Resources/config/doctrine-migrations-config.yml $@
Upvotes: 0
Views: 1498
Reputation: 1016
I didn't realize that in apc cache it can be something also. After restart apache2 service it started to work.
Upvotes: 2