2017 © Pedro Peláez
 

symfony-bundle role-bundle

Symfony Role Bundle

image

tangoman/role-bundle

Symfony Role Bundle

  • Sunday, April 8, 2018
  • by Tangoman
  • Repository
  • 0 Watchers
  • 2 Stars
  • 91 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 2 % Grown

The README.md

TangoMan Role Bundle

TangoMan Role Bundle provides basis for user roles / privileges management., (*1)

Installation

Step 1: Download the Bundle

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

$ composer require tangoman/role-bundle

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

Step 2: Enable the Bundle

Then, 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 TangoMan\RoleBundle\TangoManRoleBundle(),
        );

        // ...
    }
}

Usage

Step 1: Create Role entity

Your Role entity must extends TangoMan\RoleBundle\Model\Role., (*5)

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use TangoMan\RoleBundle\Model\Role as TangoManRole;

/**
 * Class Role
 * @ORM\Entity(repositoryClass="AppBundle\Repository\RoleRepository")
 * @ORM\Table(name="role")
 */
class Role extends TangoManRole
{
}

Step 2: Create Privilege entity

Your Privilege entity must extends TangoMan\RoleBundle\Model\Privilege., (*6)

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use TangoMan\RoleBundle\Model\Privilege as TangoManPrivilege;

/**
 * Class Privilege
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PrivilegeRepository")
 * @ORM\Table(name="privilege")
 */
class Privilege extends TangoManPrivilege
{
}

Step 3: Create Role and Privilege repository

<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Class RoleRepository
 *
 * @package AppBundle\Repository
 */
class RoleRepository extends EntityRepository
{
    // ...
}
<?php

namespace AppBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Class PrivilegeRepository
 *
 * @package AppBundle\Repository
 */
class PrivilegeRepository extends EntityRepository
{
    // ...
}

Step 4: Inside User entity

Your User entity must extends TangoMan\RoleBundle\Model\User., (*7)

<?php

namespace AppBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use TangoMan\UserBundle\Model\User as TangoManUser;
use TangoMan\RoleBundle\Relationships\UsersHavePrivileges;
use TangoMan\RoleBundle\Relationships\UsersHaveRoles;

/**
 * Class User
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
 * @ORM\Table(name="user")
 */
class User extends TangoManUser
{
    use UsersHavePrivileges;
    use UsersHaveRoles;
    // ...

    public function __construct()
    {
        parent::__construct();
        $this->roles = new ArrayCollection();
        $this->privileges = new ArrayCollection();
        // ...
    }
}

Step 5: Update database schema

From your project folder :, (*8)

$ php bin/console doctrine:schema:update --force

Step 6: Load default roles and privileges

$ php bin/console tangoman:roles
$ php bin/console tangoman:privileges

Deprecation Warning

For Symfony 3.4 and Symfony 4 users :, (*9)

User Deprecated: The "TangoMan\RoleBundle\Model\Role" class implements "Symfony\Component\Security\Core\Role\RoleInterface" that is deprecated The RoleInterface is deprecated since version 3.3 and will be removed in 4.0. Extend the Symfony\Component\Security\Core\Role\Role class instead., (*10)

Note

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

License

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

![License-MIT] Distributed under the MIT license., (*13)

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

Matthias Morin | LinkedIn, (*15)

The Versions

08/04 2018

dev-master

9999999-dev

Symfony Role Bundle

  Sources   Download

MIT GPL-3.0

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

08/04 2018

2.0.2

2.0.2.0

Symfony Role Bundle

  Sources   Download

MIT

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

08/04 2018

2.0.1

2.0.1.0

Symfony Role Bundle

  Sources   Download

MIT

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

21/02 2018

2.0.0

2.0.0.0

Symfony Role Bundle

  Sources   Download

MIT

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

21/02 2018

1.0.4

1.0.4.0

Symfony Role Bundle

  Sources   Download

MIT

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

21/02 2018

1.0.3

1.0.3.0

Symfony Role Bundle

  Sources   Download

MIT

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

08/11 2017

1.0.2

1.0.2.0

Symfony Role Bundle

  Sources   Download

MIT

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

05/09 2017

1.0.1

1.0.1.0

Symfony Role Bundle

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman

21/08 2017

1.0.0

1.0.0.0

Symfony Role Bundle

  Sources   Download

GPL-3.0

The Requires

 

by Matthias Morin

bundle symfony privilege role tangoman