[FEATURE] File mount model and repository
authorMarkus Günther <mail@markus-guenther.de>
Thu, 2 Aug 2012 20:41:39 +0000 (22:41 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 14 Aug 2012 20:20:32 +0000 (22:20 +0200)
Actually we have a backend user model in extbase and a backend usergroup
is in progress. For these models we need a seperate file mount model.

This patch includes the model and the repository with the typoscript
mapping on the datebase table.

Change-Id: Id0b4a1ad168ba189940282222bf4e08b6441a3bf
Resolves: #39323
Releases: 6.0
Reviewed-on: http://review.typo3.org/13429
Reviewed-by: Ingo Pfennigstorf
Tested-by: Ingo Pfennigstorf
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/extbase/Classes/Domain/Model/FileMount.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Domain/Repository/FileMountRepository.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Domain/Model/FileMountTest.php [new file with mode: 0755]
typo3/sysext/extbase/Tests/Unit/Domain/Repository/FileMountRepositoryTest.php [new file with mode: 0644]
typo3/sysext/extbase/ext_typoscript_setup.txt

diff --git a/typo3/sysext/extbase/Classes/Domain/Model/FileMount.php b/typo3/sysext/extbase/Classes/Domain/Model/FileMount.php
new file mode 100644 (file)
index 0000000..280a484
--- /dev/null
@@ -0,0 +1,124 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Markus Günther <mail@markus-guenther.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * This model represents a file mount.
+ *
+ * @author Markus Günther <mail@markus-guenther.de>
+ *
+ * @package Extbase
+ *
+ * @scope prototype
+ * @entity
+ * @api
+ */
+class Tx_Extbase_Domain_Model_FileMount extends Tx_Extbase_DomainObject_AbstractEntity {
+
+       /**
+        * Title of the file mount.
+        *
+        * @var string
+        * @validate notEmpty
+        */
+       protected $title = '';
+
+       /**
+        * Path of the file mount.
+        *
+        * @var string
+        * @validate notEmpty
+        */
+       protected $path = '';
+
+       /**
+        * Determines whether the value of the path field is to be recognized as an absolute
+        * path on the server or a path relative to the fileadmin/ subfolder to the website.
+        *
+        * If the value is true the path is an absolute one, otherwise the path is relative
+        * the fileadmin.
+        *
+        * @var boolean
+        */
+       protected $isAbsolutePath = FALSE;
+
+       /**
+        * Getter for the title of the file mount.
+        *
+        * @return string
+        */
+       public function getTitle() {
+               return $this->title;
+       }
+
+       /**
+        * Setter for the title of the file mount.
+        *
+        * @param string $value
+        * @return void
+        */
+       public function setTitle($value) {
+               $this->title = $value;
+       }
+
+       /**
+        * Getter for the path of the file mount.
+        *
+        * @return string
+        */
+       public function getPath() {
+               return $this->path;
+       }
+
+       /**
+        * Setter for the path of the file mount.
+        *
+        * @param string $value
+        * @return void
+        */
+       public function setPath($value) {
+               $this->path = $value;
+       }
+
+       /**
+        * Getter for the is absolute path of the file mount.
+        *
+        * @return boolean
+        */
+       public function getIsAbsolutePath() {
+               return $this->isAbsolutePath;
+       }
+
+       /**
+        * Setter for is absolute path of the file mount.
+        *
+        * @param boolean $value
+        * @return void
+        */
+       public function setIsAbsolutePath($value) {
+               $this->isAbsolutePath = $value;
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Domain/Repository/FileMountRepository.php b/typo3/sysext/extbase/Classes/Domain/Repository/FileMountRepository.php
new file mode 100644 (file)
index 0000000..6dc8145
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Markus Günther <mail@markus-guenther.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Repository for Tx_Extbase_Domain_Model_FileMount.
+ *
+ * @author Markus Günther <mail@markus-guenther.de>
+ *
+ * @package Extbase
+ * @api
+ */
+class Tx_Extbase_Domain_Repository_FileMountRepository extends Tx_Extbase_Persistence_Repository {
+       /**
+        * Initializes the repository.
+        *
+        * @return void
+        */
+       public function initializeObject() {
+               /** @var $querySettings Tx_Extbase_Persistence_Typo3QuerySettings */
+               $querySettings = $this->objectManager->create('Tx_Extbase_Persistence_Typo3QuerySettings');
+               $querySettings->setRespectStoragePage(FALSE);
+               $this->setDefaultQuerySettings($querySettings);
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Unit/Domain/Model/FileMountTest.php b/typo3/sysext/extbase/Tests/Unit/Domain/Model/FileMountTest.php
new file mode 100755 (executable)
index 0000000..89269cd
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Markus Günther <mail@markus-guenther.de>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for Tx_Extbase_Domain_Model_FileMount.
+ *
+ * @author Markus Günther <mail@markus-guenther.de>
+ *
+ * @package Extbase
+ *
+ * @scope prototype
+ * @entity
+ * @api
+ */
+class Tx_Extbase_Tests_Unit_Domain_Model_FileMountTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
+
+       /**
+        * @var Tx_Extbase_Domain_Model_FileMount
+        */
+       protected $fixture = NULL;
+
+       public function setUp() {
+               $this->fixture = new Tx_Extbase_Domain_Model_FileMount();
+       }
+
+       public function tearDown() {
+               unset($this->fixture);
+       }
+
+       /**
+        * @test
+        */
+       public function getTitleInitiallyReturnsEmptyString() {
+               $this->assertSame(
+                       '',
+                       $this->fixture->getTitle()
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function setTitleSetsTitle() {
+               $title = 'foobar mount';
+               $this->fixture->setTitle($title);
+
+               $this->assertSame(
+                       $title,
+                       $this->fixture->getTitle()
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function getPathInitiallyReturnsEmptyString() {
+               $this->assertSame(
+                       '',
+                       $this->fixture->getPath()
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function setPathSetsPath() {
+               $path = 'foo/bar/';
+               $this->fixture->setPath($path);
+
+               $this->assertSame(
+                       $path,
+                       $this->fixture->getPath()
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function getIsAbsolutePathInitiallyReturnsFalse() {
+               $this->assertFalse(
+                       $this->fixture->getIsAbsolutePath()
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function setIsAbsolutePathCanSetBaseIsAbsolutePathToTrue() {
+               $this->fixture->setIsAbsolutePath(TRUE);
+
+               $this->assertTrue(
+                       $this->fixture->getIsAbsolutePath()
+               );
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Unit/Domain/Repository/FileMountRepositoryTest.php b/typo3/sysext/extbase/Tests/Unit/Domain/Repository/FileMountRepositoryTest.php
new file mode 100644 (file)
index 0000000..26f3f08
--- /dev/null
@@ -0,0 +1,64 @@
+<?php
+/***************************************************************
+ * Copyright notice
+ *
+ * (c) 2012 Markus Günther <mail@markus-guenther.de>
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Testcase for the Tx_Extbase_Domain_Repository_FileMountRepository class.
+ *
+ * @package Extbase
+ *
+ * @author Markus Günther <mail@markus-guenther.de>
+ */
+class Tx_Extbase_Domain_Repository_FileMountRepositoryTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
+       /**
+        * @var Tx_Extbase_Domain_Repository_FileMountRepository
+        */
+       private $fixture = NULL;
+
+       protected function setUp() {
+               $this->fixture = new Tx_Extbase_Domain_Repository_FileMountRepository(
+                       $this->getMock('Tx_Extbase_Object_ObjectManagerInterface')
+               );
+       }
+
+       protected function tearDown() {
+               unset($this->fixture);
+       }
+
+       /**
+        * @test
+        */
+       public function initializeObjectSetsRespectStoragePidToFalse() {
+               /** @var $objectManager Tx_Extbase_Object_ObjectManagerInterface */
+               $objectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface');
+               $fixture = new Tx_Extbase_Domain_Repository_FileMountRepository($objectManager);
+
+               $querySettings = $this->getMock('Tx_Extbase_Persistence_Typo3QuerySettings');
+               $querySettings->expects($this->once())->method('setRespectStoragePage')->with(FALSE);
+               $objectManager->expects($this->once())->method('create')
+                       ->with('Tx_Extbase_Persistence_Typo3QuerySettings')->will($this->returnValue($querySettings));
+
+               $fixture->initializeObject();
+       }
+}
+?>
\ No newline at end of file
index 2512c50..f3c181b 100644 (file)
@@ -19,6 +19,16 @@ config.tx_extbase {
                enableAutomaticCacheClearing = 1
                updateReferenceIndex = 0
                classes {
+                       Tx_Extbase_Domain_Model_FileMount {
+                               mapping {
+                                       tableName = sys_filemounts
+                                       columns {
+                                               title.mapOnProperty = title
+                                               path.mapOnProperty = path
+                                               base.mapOnProperty = isAbsolutePath
+                                       }
+                               }
+                       }
                        Tx_Extbase_Domain_Model_BackendUser {
                                mapping {
                                        tableName = be_users
@@ -62,4 +72,4 @@ config.tx_extbase {
                # if set to 1, the enable fields are ignored in BE context
                ignoreAllEnableFieldsInBe = 0
        }
-}
\ No newline at end of file
+}