init() public static method

Create a singleton instance of WPDKUserRoles class
public static init ( ) : WPDKUserRoles
return WPDKUserRoles
Esempio n. 1
0
 /**
  * Create an instance of WPDKUserCapability class
  *
  * @brief Construct
  *
  * @param string $id          Unique id of capability
  * @param string $description Optional. Capability description
  * @param string $owner       Optional. Capability owner, who create this capabilty
  *
  * @return WPDKUserCapability
  */
 public function __construct($id, $description = '', $owner = '')
 {
     $this->id = $id;
     $this->description = $description;
     $this->owner = $owner;
     // Cap already exists ? Then get the data
     if (WPDKUserCapabilities::init()->capabilityExists($id)) {
         // Get extends data
         $extend_data = WPDKUserCapabilities::init()->get_extended_data($id);
         if (!empty($extend_data)) {
             list($id, $description, $owner) = $extend_data;
             // Population
             $this->description = $description;
             $this->owner = $owner;
         }
         // Get the users id list with this cap
         $this->users = WPDKUserCapabilities::init()->usersWithCaps($id);
         // Get the roles id list with this cap
         $this->roles = WPDKUserRoles::init()->rolesWithCaps($id);
     }
 }