[~TASK] Extbase (Domain): Changed property usergroups to usergroup (FrontendUser...
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Domain / Model / FrontendUser.php
index 9dae178..b08a63e 100644 (file)
@@ -44,7 +44,7 @@ class Tx_Extbase_Domain_Model_FrontendUser extends Tx_Extbase_DomainObject_Abstr
        protected $password;
 
        /**
-        * @var Tx_Extbase_Domain_Model_FrontendUserGroup
+        * @var Tx_Extbase_Persistence_ObjectStorage<Tx_Extbase_Domain_Model_FrontendUserGroup>
         */
        protected $usergroup;
 
@@ -131,6 +131,7 @@ class Tx_Extbase_Domain_Model_FrontendUser extends Tx_Extbase_DomainObject_Abstr
        public function __construct($username = '', $password = '') {
                $this->username = $username;
                $this->password = $password;
+               $this->usergroup = new Tx_Extbase_Persistence_ObjectStorage();
        }
 
        /**
@@ -176,23 +177,47 @@ class Tx_Extbase_Domain_Model_FrontendUser extends Tx_Extbase_DomainObject_Abstr
        }
 
        /**
-        * Sets the usergroup value
+        * Sets the usergroups. Keep in mind that the property is called "usergroup"
+        * although it can hold several usergroups.
         *
-        * @param Tx_Extbase_Domain_Model_FrontendUserGroup $usergroup
+        * @param Tx_Extbase_Persistence_ObjectStorage<Tx_Extbase_Domain_Model_FrontendUserGroup> $usergroup An object storage containing the usergroups to add
         * @return void
         * @api
         */
-       public function setUsergroup(Tx_Extbase_Domain_Model_FrontendUserGroup $usergroup) {
+       public function setUsergroup(Tx_Extbase_Persistence_ObjectStorage $usergroup) {
                $this->usergroup = $usergroup;
        }
 
        /**
-        * Returns the usergroup value
+        * Adds a usergroup to the frontend user
+        *
+        * @param Tx_Extbase_Domain_Model_FrontendUserGroup $usergroup
+        * @return void
+        * @api
+        */
+       public function addUsergroup(Tx_Extbase_Domain_Model_FrontendUserGroup $usergroup) {
+               $this->usergroup->attach($usergroup);
+       }
+
+       /**
+        * Removes a usergroup from the frontend user
+        *
+        * @param Tx_Extbase_Domain_Model_FrontendUserGroup $usergroup
+        * @return void
+        * @api
+        */
+       public function removeUsergroup(Tx_Extbase_Domain_Model_FrontendUserGroup $usergroup) {
+               $this->usergroup->detach($usergroup);
+       }
+
+       /**
+        * Returns the usergroups. Keep in mind that the property is called "usergroup"
+        * although it can hold several usergroups.
         *
-        * @return Tx_Extbase_Domain_Model_FrontendUserGroup
+        * @return Tx_Extbase_Persistence_ObjectStorage An object storage containing the usergroup
         * @api
         */
-       public function getUsergroup() {
+       public function getUsergroups() {
                return $this->usergroup;
        }