happyr/user-project-bundle

If you have multiple users that will share access to one or more objects.

0.3.1 2016-06-15 10:08 UTC

This package is auto-updated.

Last update: 2024-09-25 06:01:12 UTC


README

If you have multiple users that will share access to one or more objects.

Installation

Step 1: Using Composer

Install it with Composer!

// composer.json
{
    // ...
    require: {
        // ...
        "happyr/user-project-bundle": "dev-master",
    }
}

Then, you can install the new dependencies by running Composer's update command from the directory where your composer.json file is located:

$ php composer.phar update

Step 2: Register the bundle

To register the bundles with your kernel:

<?php

// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Happyr\UserProjectBundle\HappyrUserProjectBundle(),
    // ...
);

Step 3: Init ACL

If you have not done it before, it is time to init the ACL. If you like, you could read about access control lists or you could just run this command:

php app/console init:acl

Step 4: Configure the bundle

# app/config/config.yml

#happyr_user_project:
  #no config at this point

Requirements

Your User object must implement Happyr\UserProjectBundle\Model\ProjectMemberInterface. Your other object that is in the project must implement Happyr\UserProjectBundle\Model\ProjectObjectInterface.

http://symfony.com/doc/current/cookbook/doctrine/resolve_target_entity.html

use Happyr\UserProjectBundle\Model\ProjectObjectInterface;
use Happyr\UserProjectBundle\Entity\Project;

class MyObject implements ProjectObjectInterface
{
    /**
     * @var \Happyr\UserProjectBundle\Entity\Project project
     *
     * @ORM\ManyToOne(targetEntity="Happyr\UserProjectBundle\Entity\Project", inversedBy="objects", cascade={"persist"})
     *
     */
    protected $project;

    public function getId()
    {
        return $this->id
    }

    public function getProject()
    {
        $this->project;
    }

    /**
     *
     * @param Project $project
     *
     */
    public function setProject(Project $project)
    {
        $this->project=$project;
    }
}

Routing

# app/config/routing.yml
happyr_user_project:
    resource: "@HappyrUserProjectBundle/Resources/config/routing.yml"
    prefix:   /