PHP code example of soft-passio / user-bundle

1. Go to this page and download the library: Download soft-passio/user-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

soft-passio / user-bundle example snippets


// ./src/AppBundle/Controller/DefaultController.php

...
use SoftPassio\UserBundle\Annotation\AVSecurity;
...

    /**
     * ...
     * @AVSecurity(allow={"ROLE_ADMIN"}, disallow={"ROLE_X"}, name="list", group="default")
     */
    public function listAction()
    {
        return $this->render('@App/controller/user/list.html.twig');
    }
    

// ./src/AppBundle/Security/CustomAccessResolver.php

...
use SoftPassio\UserBundle\Security\AccessResolverInterface;
...

class SimpleAccessResolver implements AccessResolverInterface
{
    public function resolve(RoleableInterface $user, $action): bool
    {
    // your own logic
    }
}


namespace AppBundle\Entity;

use SoftPassio\UserBundle\Entity\User as AbstractUser;
use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
 */
class User extends AbstractUser implements EntityInterface
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;