Purpose: To enable A user to manage multiple stores, for example, A user A is granted the management permissions of stores with store ID 1 and store ID 2. Then, you can manage the background when accessing the store on the ^ shop1 and ^ shop2 paths. When he accesses the ^ shop3 store, he does not have the background purpose:
To allow a user to manage multiple stores
Example:
There is A user A who is granted the management permissions of the store with store IDs of 1 and 2.
Then, you can manage the background when accessing the shops in the ^/shop/1 and ^/shop/2 paths. When he accesses the ^/shop/3 store, he does not have the background access function.
- How can this function be implemented?
- If you have any relevant information in English, just connect to me.
- Or I recommend several English search keywords.
Thank you.
Reply content:
Purpose:
To allow a user to manage multiple stores
Example:
There is A user A who is granted the management permissions of the store with store IDs of 1 and 2.
Then, you can manage the background when accessing the shops in the ^/shop/1 and ^/shop/2 paths. When he accesses the ^/shop/3 store, he does not have the background access function.
- How can this function be implemented?
- If you have any relevant information in English, just connect to me.
- Or I recommend several English search keywords.
Thank you.
Key words: ParamConverter ACL
Set: Your store uses a Doctrine Entity, such
namespace YourBundle\Entity;class Store{ // ...}
Code:
// In your Controller, first introduce your Store class: use YourBundle \ Entity \ Store; // then introduce the ParamConverter annotation of SensioFrameworkExtraBundle (which is included by Symfony 2 by default: use Sensio \ Bundle \ FrameworkExtraBundle \ Configuration \ ParamConverter; // introduce the SecureParam Annotation of fuse (which is included by Symfony 2 by default): use JMS \ SecurityExtraBundle \ Annotation \ SecureParam; class YourController {/*** uses ParamConverter to set the id (or other placeholder) in the router. Note that the default value is id) value is instantiated as the primary key as a Store object * @ ParamConverter ("store", class = "YourBundle: Store", options = {"id" = "id "}) * The current user is required to have the OWNER permission for the $ store parameter * @ SecureParam (name = "store", permissions = "OWNER") */public function someAction (Store $ store) {//...}}
See http://symfony.com/doc/current/cookbook/security/acl.html for how to give users OWNER permissions on $ store objects