cisse/symfony-traits-bundle

Symfony Useful Traits

8.0.0 2021-10-07 08:47 UTC

This package is auto-updated.

Last update: 2024-11-07 17:00:06 UTC


README

Symfony Traits is useful trait that will help you easily create your Symfony entities

Installation

Symfony traits uses Composer.

composer require cisse/symfony-traits-bundle

Usage

<?php

require __DIR__.'/vendor/autoload.php';

use Cisse\Bundle\TraitsBundle\Entity\Annotation\NoUnique\Nullable\Text\AddressTrait;
use Cisse\Bundle\TraitsBundle\Entity\Annotation\NoUnique\Nullable\Json\RolesTrait;

class Foo{
    use AddressTrait;
    // Declaration
    
    use RolesTrait {
        RolesTrait::__construct as private __constructRoles;
    }
    // Declaration with constructor alias

    public function __construct()
    {
        $this->__constructRoles();
        // Calling constructor from withing trait
    }
}

$foo = new Foo();

$foo->setAddress('your address'); // Return $foo.
$foo->getAddress(); // Return address

Notes

This component is a work in progress, and it is target for my own usages. But if you like it feel free to use it ;)

Versions

1.0.10