2017 © Pedro Peláez
 

library entity-helper

Symfony Entity Helper

image

tangoman/entity-helper

Symfony Entity Helper

  • Monday, April 9, 2018
  • by Tangoman
  • Repository
  • 0 Watchers
  • 1 Stars
  • 140 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 12 Versions
  • 1 % Grown

The README.md

TangoMan Entity Helper

TangoMan Entity Helper provides a collection of traits for common properties to use in your project entities., (*1)

Features

  • Included asserts with custom messages (french) for property validation.
  • Fluent setters for all properties, allowing chaining.
  • Magic JsonSerialisable.

Installation

Step 1: Download the Helper

Open a command console, enter your project directory and execute the following command to download the latest stable version of this helper:, (*2)

$ composer require tangoman/entity-helper

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable VichUploader

Since TangoMan Entity Helper requires VichUploaderBundle, if you plan to use UploadableDocument, or UploadableImage traits, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    // ...

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Vich\UploaderBundle\VichUploaderBundle(),
        );

        // ...
    }
}

Step 3: Implement your entities

Add "use" statements inside your entities for desired traits. See below for full list of availlable traits., (*5)

Step 4: Update your database schema

Open a command console, enter your project directory and execute the following command to update your database schema:, (*6)

$ php bin/console schema:update

Usage

Inside your entity class: Some traits will require your entity class to use Symfony\Component\Validator\Constraints for validation. UploadableDocument and UploadableImage traits will require your entity class to use Vich\UploaderBundle\Mapping\Annotation as Vich annotation., (*7)

src\AppBundle\Entity\FooBar.php, (*8)

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

// ...

use TangoMan\EntityHelper\Traits\Categorized;
use TangoMan\EntityHelper\Traits\Embeddable;
use TangoMan\EntityHelper\Traits\Featurable;
use TangoMan\EntityHelper\Traits\HasAddress;
use TangoMan\EntityHelper\Traits\HasBirthDate;
use TangoMan\EntityHelper\Traits\HasClickDate;
use TangoMan\EntityHelper\Traits\HasEmail;
use TangoMan\EntityHelper\Traits\HasFirstAndLastName;
use TangoMan\EntityHelper\Traits\HasFontAwesomeIcon;
use TangoMan\EntityHelper\Traits\HasGender;
use TangoMan\EntityHelper\Traits\HasGlyphicon;
use TangoMan\EntityHelper\Traits\HasIcon;
use TangoMan\EntityHelper\Traits\HasLabel;
use TangoMan\EntityHelper\Traits\HasMobile;
use TangoMan\EntityHelper\Traits\HasName;
use TangoMan\EntityHelper\Traits\HasPhone;
use TangoMan\EntityHelper\Traits\HasRoles;
use TangoMan\EntityHelper\Traits\HasSummary;
use TangoMan\EntityHelper\Traits\HasText;
use TangoMan\EntityHelper\Traits\HasTimePeriod;
use TangoMan\EntityHelper\Traits\HasTitle;
use TangoMan\EntityHelper\Traits\HasType;
use TangoMan\EntityHelper\Traits\HasViews;
use TangoMan\EntityHelper\Traits\HasWebsite;
use TangoMan\EntityHelper\Traits\HasWork;
use TangoMan\EntityHelper\Traits\Illustrable;
use TangoMan\EntityHelper\Traits\JsonSerializable;
use TangoMan\EntityHelper\Traits\Privatable;
use TangoMan\EntityHelper\Traits\Publishable;
use TangoMan\EntityHelper\Traits\Sluggable;
use TangoMan\EntityHelper\Traits\Slugify;
use TangoMan\EntityHelper\Traits\Timestampable;
use TangoMan\EntityHelper\Traits\UploadableDocument;
use TangoMan\EntityHelper\Traits\UploadableImage;

/**
 * Class Foobar
 *
 * @package AppBundle\Entity
 */
class Foobar
{
    use Categorized;
    use Embeddable;
    use Featurable;
    use HasAddress;
    use HasBirthDate;
    use HasClickDate;
    use HasEmail;
    use HasFirstAndLastName;
    use HasFontAwesomeIcon;
    use HasGender;
    use HasGlyphicon;
    use HasIcon;
    use HasLabel;
    use HasMobile;
    use HasName;
    use HasPhone;
    use HasRoles;
    use HasSummary;
    use HasText;
    use HasTimePeriod;
    use HasTitle;
    use HasType;
    use HasViews;
    use HasWebsite;
    use HasWork;
    use Illustrable;
    use JsonSerializable;
    use Privatable;
    use Publishable;
    use Sluggable;
    use Slugify;
    use Timestampable;
    use UploadableDocument;
    use UploadableImage;

    // ...
}

Trait JsonSerializable

Magic method to make your entities jsonserializable. Allows to use php json_encode() function on your object., (*9)

$fooBar = new FooBar;
$json = json_encode($fooBar, JSON_PRETTY_PRINT);
echo $json;

In order to use php JsonSerializable interface on your object your class must implement \JsonSerializable src\AppBundle\Entity\FooBar.php, (*10)

namespace AppBundle\Entity;

use TangoMan\EntityHelper\Traits\JsonSerializable;

class FooBar implements \JsonSerializable {
    use JsonSerializable;

    // ...

Note

If you find any bug please report here : Issues, (*11)

License

Copyright (c) 2018 Matthias Morin, (*12)

License Distributed under the MIT license., (*13)

If you like TangoMan Entity Helper please star! And follow me on GitHub: TangoMan75 ... And check my other cool projects., (*14)

Matthias Morin | LinkedIn, (*15)

The Versions

09/04 2018

dev-master

9999999-dev

Symfony Entity Helper

  Sources   Download

MIT GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony traits tangoman

09/04 2018

2.1.2

2.1.2.0

Symfony Entity Helper

  Sources   Download

MIT

The Requires

 

by Matthias Morin

helper entity symfony traits tangoman

08/04 2018

2.1.1

2.1.1.0

Symfony Entity Helper

  Sources   Download

MIT

The Requires

 

by Matthias Morin

helper entity symfony traits tangoman

20/11 2017

2.1.0

2.1.0.0

Symfony Entity Helper

  Sources   Download

MIT

The Requires

 

by Matthias Morin

helper entity symfony traits tangoman

10/11 2017

2.0.0

2.0.0.0

Symfony Entity Helper

  Sources   Download

MIT

The Requires

 

by Matthias Morin

helper entity symfony traits tangoman

13/09 2017

1.2.5

1.2.5.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman

12/09 2017

1.2.4

1.2.4.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman

12/09 2017

1.2.3

1.2.3.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman

24/08 2017

1.2.2

1.2.2.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman

23/08 2017

1.2.1

1.2.1.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman

22/08 2017

1.1.0

1.1.0.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman

21/08 2017

1.0.0

1.0.0.0

Symfony Entity Helper

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

helper trait entity symfony tangoman