[FEATURE] Add filemount property to backend users
authorMarkus Günther <mail@markus-guenther.de>
Fri, 17 Aug 2012 23:49:12 +0000 (01:49 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 8 Jan 2013 19:18:10 +0000 (20:18 +0100)
This patch set adds the new extbase filemount model as property to the
backend user model.

Change-Id: I8ed292fa4c38794a13ca62ee85f7767e16dc80e5
Resolves: #39324
Releases: 6.1
Reviewed-on: https://review.typo3.org/13880
Reviewed-by: Tymoteusz Motylewski
Tested-by: Tymoteusz Motylewski
Reviewed-by: Oliver Klee
Reviewed-by: Markus Günther
Tested-by: Markus Günther
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Domain/Model/BackendUser.php
typo3/sysext/extbase/Tests/Unit/Domain/Model/BackendUserTest.php
typo3/sysext/extbase/ext_typoscript_setup.txt

index 038b99c..c21ca5f 100644 (file)
@@ -76,11 +76,32 @@ class BackendUser extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
        protected $lastLoginDateAndTime;
 
        /**
+        * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileMount>
+        */
+       protected $fileMounts = NULL;
+
+       /**
         * @var boolean
         */
        protected $ipLockIsDisabled = FALSE;
 
        /**
+        * Constructs this backend user
+        */
+       public function __construct() {
+               $this->fileMounts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
+       }
+
+       /**
+        * Initialize object
+        *
+        * @return void
+        */
+       public function initializeObject() {
+               $this->fileMounts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
+       }
+
+       /**
         * Gets the user name.
         *
         * @return string the user name, will not be empty
@@ -286,6 +307,54 @@ class BackendUser extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
        public function setLastLoginDateAndTime(\DateTime $dateAndTime = NULL) {
                $this->lastLoginDateAndTime = $dateAndTime;
        }
+
+       /**
+        * Setter for the file mounts
+        *
+        * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $fileMounts
+        * @return void
+        */
+       public function setFileMounts(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $fileMounts) {
+               $this->fileMounts = $fileMounts;
+       }
+
+       /**
+        * Adds a file mount to this backend user
+        *
+        * @param \TYPO3\CMS\Extbase\Domain\Model\FileMount $fileMount
+        * @return void
+        */
+       public function addFileMount(\TYPO3\CMS\Extbase\Domain\Model\FileMount $fileMount) {
+               $this->fileMounts->attach($fileMount);
+       }
+
+       /**
+        * Removes file mount from this backend user
+        *
+        * @param \TYPO3\CMS\Extbase\Domain\Model\FileMount $fileMount
+        * @return void
+        */
+       public function removeFileMount(\TYPO3\CMS\Extbase\Domain\Model\FileMount $fileMount) {
+               $this->fileMounts->detach($fileMount);
+       }
+
+       /**
+        * Remove all file mounts from this backend user
+        *
+        * @return void
+        */
+       public function removeAllFileMounts() {
+               $this->fileMounts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
+       }
+
+       /**
+        * Getter of file mounts
+        *
+        * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
+        */
+       public function getFileMounts() {
+               return $this->fileMounts;
+       }
 }
 
 ?>
\ No newline at end of file
index cb9c080..5655f73 100644 (file)
@@ -269,6 +269,62 @@ class BackendUserTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
                $this->fixture->setLastLoginDateAndTime($date);
                $this->assertSame($date, $this->fixture->getLastLoginDateAndTime());
        }
+
+       /**
+        * @test
+        */
+       public function getFileMountsInitiallyReturnsEmpty() {
+               $this->assertSame(0, $this->fixture->getFileMounts()->count());
+       }
+
+       /**
+        * @test
+        */
+       public function setFileMountsSetsFileMounts() {
+               $fileMounts = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
+               $this->fixture->setFileMounts($fileMounts);
+
+               $this->assertSame(
+                       $fileMounts,
+                       $this->fixture->getFileMounts()
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function addFileMountAddsFileMount() {
+               $fileMount = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
+
+               $this->fixture->addFileMount($fileMount);
+               $this->assertTrue($this->fixture->getFileMounts()->contains($fileMount));
+       }
+
+       /**
+        * @test
+        */
+       public function removeFileMountRemovesFileMount() {
+               $fileMount = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
+
+               $this->fixture->addFileMount($fileMount);
+               $this->fixture->removeFileMount($fileMount);
+               $this->assertFalse($this->fixture->getFileMounts()->contains($fileMount));
+       }
+
+       /**
+        * @test
+        */
+       public function removeAllFileMountsRemovesAllFileMounts() {
+               $fileMount = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
+               $fileMount2 = new \TYPO3\CMS\Extbase\Domain\Model\FileMount();
+
+               $this->fixture->addFileMount($fileMount);
+               $this->fixture->addFileMount($fileMount2);
+               $this->fixture->removeAllFileMounts();
+
+               $this->assertFalse($this->fixture->getFileMounts()->contains($fileMount));
+               $this->assertFalse($this->fixture->getFileMounts()->contains($fileMount2));
+       }
 }
 
 ?>
\ No newline at end of file
index fe4cab2..993e38d 100644 (file)
@@ -50,6 +50,7 @@ config.tx_extbase {
                                                endtime.mapOnProperty = endDateAndTime
                                                disableIPlock.mapOnProperty = ipLockIsDisabled
                                                lastlogin.mapOnProperty = lastLoginDateAndTime
+                                               file_mountpoints.mapOnProperty = fileMounts
                                        }
                                }
                        }