ytko/doctrine-uploadable

Doctrine2 behavior uploadable trait

dev-master 2013-03-04 20:20 UTC

This package is not auto-updated.

Last update: 2024-11-09 15:22:52 UTC


README

This php 5.4+ library provides file uploading trait for Doctrine2 entities.

This library needs Doctrine listener to be activated.

Listeners

Symfony2:

    # app/config/config.yml
    imports:
        - { resource: ../../vendor/ytko/doctrine-uploadable/config/orm-services.yml }

Or Doctrine2 api:

<?php

$em->getEventManager()->addEventSubscriber(new \Ytko\DoctrineBehaviors\ORM\UploadableListener);

Usage

Define a Doctrine2 entity and use traits:

<?php

use Doctrine\ORM\Mapping as ORM;
use Ytko\DoctrineBehaviors\Model\Uploadable;

/**
 * @ORM\Entity
 */
class Category
{
    use Uploadable;

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="NONE")
     */
    protected $id;
}

Inspired by KnpLabs/DoctrineBehaviors.