Completed
Push — master ( 5794c5...08c98b )
by Fabien
53:00
created
Classes/Service/ContentService.php 1 patch
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -22,121 +22,121 @@
 block discarded – undo
22 22
  */
23 23
 class ContentService
24 24
 {
25
-    /**
26
-     * @var string
27
-     */
28
-    protected $dataType;
29
-
30
-    /**
31
-     * @var Content[]
32
-     */
33
-    protected $objects = [];
34
-
35
-    /**
36
-     * @var int
37
-     */
38
-    protected $numberOfObjects = 0;
39
-
40
-    /**
41
-     * Constructor
42
-     *
43
-     * @param string $dataType
44
-     */
45
-    public function __construct($dataType = '')
46
-    {
47
-        if (empty($dataType)) {
48
-            $dataType = $this->getModuleLoader()->getDataType();
49
-        }
50
-        $this->dataType = $dataType;
51
-    }
52
-
53
-    /**
54
-     * Fetch the files given an object assuming
55
-     *
56
-     * @param Matcher $matcher
57
-     * @param Order $order The order
58
-     * @param int $limit
59
-     * @param int $offset
60
-     * @return $this
61
-     */
62
-    public function findBy(Matcher $matcher, Order $order = null, $limit = null, $offset = null)
63
-    {
64
-        // Query the repository.
65
-        $objects = ContentRepositoryFactory::getInstance($this->dataType)->findBy($matcher, $order, $limit, $offset);
66
-        $signalResult = $this->emitAfterFindContentObjectsSignal($objects, $matcher, $order, $limit, $offset);
67
-
68
-        // Reset objects variable after possible signal / slot processing.
69
-        $this->objects = $signalResult->getContentObjects();
70
-
71
-        // Count number of content objects.
72
-        if ($signalResult->getHasBeenProcessed()) {
73
-            $this->numberOfObjects = $signalResult->getNumberOfObjects();
74
-        } else {
75
-            $this->numberOfObjects = ContentRepositoryFactory::getInstance($this->dataType)->countBy($matcher);
76
-        }
77
-
78
-        return $this;
79
-    }
80
-
81
-    /**
82
-     * Signal that is called after the content objects have been found.
83
-     *
84
-     * @param array $contentObjects
85
-     * @param Matcher $matcher
86
-     * @param Order $order
87
-     * @param int $limit
88
-     * @param int $offset
89
-     * @return AfterFindContentObjectsSignalArguments
90
-     */
91
-    protected function emitAfterFindContentObjectsSignal($contentObjects, Matcher $matcher, Order $order = null, $limit = 0, $offset = 0)
92
-    {
93
-        /** @var AfterFindContentObjectsSignalArguments $signalArguments */
94
-        $signalArguments = GeneralUtility::makeInstance(AfterFindContentObjectsSignalArguments::class);
95
-        $signalArguments->setDataType($this->dataType)
96
-            ->setContentObjects($contentObjects)
97
-            ->setMatcher($matcher)
98
-            ->setOrder($order)
99
-            ->setLimit($limit)
100
-            ->setOffset($offset)
101
-            ->setHasBeenProcessed(false);
102
-
103
-        $signalResult = $this->getSignalSlotDispatcher()->dispatch(ContentService::class, 'afterFindContentObjects', array($signalArguments));
104
-        return $signalResult[0];
105
-    }
106
-
107
-    /**
108
-     * Get the Vidi Module Loader.
109
-     *
110
-     * @return ModuleLoader|object
111
-     */
112
-    protected function getModuleLoader()
113
-    {
114
-        return GeneralUtility::makeInstance(ModuleLoader::class);
115
-    }
116
-
117
-    /**
118
-     * Get the SignalSlot dispatcher.
119
-     *
120
-     * @return Dispatcher|object
121
-     */
122
-    protected function getSignalSlotDispatcher()
123
-    {
124
-        return GeneralUtility::makeInstance(Dispatcher::class);
125
-    }
126
-
127
-    /**
128
-     * @return Content[]
129
-     */
130
-    public function getObjects()
131
-    {
132
-        return $this->objects;
133
-    }
134
-
135
-    /**
136
-     * @return int
137
-     */
138
-    public function getNumberOfObjects()
139
-    {
140
-        return $this->numberOfObjects;
141
-    }
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected $dataType;
29
+
30
+	/**
31
+	 * @var Content[]
32
+	 */
33
+	protected $objects = [];
34
+
35
+	/**
36
+	 * @var int
37
+	 */
38
+	protected $numberOfObjects = 0;
39
+
40
+	/**
41
+	 * Constructor
42
+	 *
43
+	 * @param string $dataType
44
+	 */
45
+	public function __construct($dataType = '')
46
+	{
47
+		if (empty($dataType)) {
48
+			$dataType = $this->getModuleLoader()->getDataType();
49
+		}
50
+		$this->dataType = $dataType;
51
+	}
52
+
53
+	/**
54
+	 * Fetch the files given an object assuming
55
+	 *
56
+	 * @param Matcher $matcher
57
+	 * @param Order $order The order
58
+	 * @param int $limit
59
+	 * @param int $offset
60
+	 * @return $this
61
+	 */
62
+	public function findBy(Matcher $matcher, Order $order = null, $limit = null, $offset = null)
63
+	{
64
+		// Query the repository.
65
+		$objects = ContentRepositoryFactory::getInstance($this->dataType)->findBy($matcher, $order, $limit, $offset);
66
+		$signalResult = $this->emitAfterFindContentObjectsSignal($objects, $matcher, $order, $limit, $offset);
67
+
68
+		// Reset objects variable after possible signal / slot processing.
69
+		$this->objects = $signalResult->getContentObjects();
70
+
71
+		// Count number of content objects.
72
+		if ($signalResult->getHasBeenProcessed()) {
73
+			$this->numberOfObjects = $signalResult->getNumberOfObjects();
74
+		} else {
75
+			$this->numberOfObjects = ContentRepositoryFactory::getInstance($this->dataType)->countBy($matcher);
76
+		}
77
+
78
+		return $this;
79
+	}
80
+
81
+	/**
82
+	 * Signal that is called after the content objects have been found.
83
+	 *
84
+	 * @param array $contentObjects
85
+	 * @param Matcher $matcher
86
+	 * @param Order $order
87
+	 * @param int $limit
88
+	 * @param int $offset
89
+	 * @return AfterFindContentObjectsSignalArguments
90
+	 */
91
+	protected function emitAfterFindContentObjectsSignal($contentObjects, Matcher $matcher, Order $order = null, $limit = 0, $offset = 0)
92
+	{
93
+		/** @var AfterFindContentObjectsSignalArguments $signalArguments */
94
+		$signalArguments = GeneralUtility::makeInstance(AfterFindContentObjectsSignalArguments::class);
95
+		$signalArguments->setDataType($this->dataType)
96
+			->setContentObjects($contentObjects)
97
+			->setMatcher($matcher)
98
+			->setOrder($order)
99
+			->setLimit($limit)
100
+			->setOffset($offset)
101
+			->setHasBeenProcessed(false);
102
+
103
+		$signalResult = $this->getSignalSlotDispatcher()->dispatch(ContentService::class, 'afterFindContentObjects', array($signalArguments));
104
+		return $signalResult[0];
105
+	}
106
+
107
+	/**
108
+	 * Get the Vidi Module Loader.
109
+	 *
110
+	 * @return ModuleLoader|object
111
+	 */
112
+	protected function getModuleLoader()
113
+	{
114
+		return GeneralUtility::makeInstance(ModuleLoader::class);
115
+	}
116
+
117
+	/**
118
+	 * Get the SignalSlot dispatcher.
119
+	 *
120
+	 * @return Dispatcher|object
121
+	 */
122
+	protected function getSignalSlotDispatcher()
123
+	{
124
+		return GeneralUtility::makeInstance(Dispatcher::class);
125
+	}
126
+
127
+	/**
128
+	 * @return Content[]
129
+	 */
130
+	public function getObjects()
131
+	{
132
+		return $this->objects;
133
+	}
134
+
135
+	/**
136
+	 * @return int
137
+	 */
138
+	public function getNumberOfObjects()
139
+	{
140
+		return $this->numberOfObjects;
141
+	}
142 142
 }
Please login to merge, or discard this patch.
Classes/Service/SpreadSheetService.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -21,145 +21,145 @@
 block discarded – undo
21 21
  */
22 22
 class SpreadSheetService
23 23
 {
24
-    public const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">";
25
-    public const XmlFooter = "</Workbook>";
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $encoding = 'UTF-8'; // encoding type to specify in file.
31
-    // Note that you're on your own for making sure your data is actually encoded to this encoding
32
-
33
-    /**
34
-     * @var string
35
-     */
36
-    protected $title = 'Sheet1'; // title for Worksheet
37
-
38
-    /**
39
-     * @var string
40
-     */
41
-    protected $buffer = '';
42
-
43
-
44
-    /**
45
-     * Constructor
46
-     */
47
-    public function __construct()
48
-    {
49
-        $this->addToBuffer($this->generateHeader());
50
-    }
51
-
52
-    /**
53
-     * @param array $row
54
-     */
55
-    public function addRow($row)
56
-    {
57
-        $this->addToBuffer($this->generateRow($row));
58
-    }
59
-
60
-    /**
61
-     * @return mixed
62
-     */
63
-    public function toString()
64
-    {
65
-        $this->addToBuffer($this->generateFooter());
66
-        return $this->buffer;
67
-    }
68
-
69
-    /**
70
-     * @param $data
71
-     */
72
-    protected function addToBuffer($data)
73
-    {
74
-        $this->buffer .= $data;
75
-    }
76
-
77
-    /**
78
-     * @return string
79
-     */
80
-    protected function generateHeader()
81
-    {
82
-        // workbook header
83
-        $output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";
84
-
85
-        // Set up styles
86
-        $output .= "<Styles>\n";
87
-        $output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n";
88
-        $output .= "</Styles>\n";
89
-
90
-        // worksheet header
91
-        $output .= sprintf("<Worksheet ss:Name=\"%s\">\n    <Table>\n", htmlentities($this->title));
92
-
93
-        return $output;
94
-    }
95
-
96
-    protected function generateFooter()
97
-    {
98
-        $output = '';
99
-
100
-        // worksheet footer
101
-        $output .= "    </Table>\n</Worksheet>\n";
102
-
103
-        // workbook footer
104
-        $output .= self::XmlFooter;
105
-
106
-        return $output;
107
-    }
108
-
109
-    /**
110
-     * @param $row
111
-     * @return string
112
-     */
113
-    protected function generateRow($row)
114
-    {
115
-        $output = '';
116
-        $output .= "        <Row>\n";
117
-        foreach ($row as $v) {
118
-            $output .= $this->generateCell($v);
119
-        }
120
-        $output .= "        </Row>\n";
121
-        return $output;
122
-    }
123
-
124
-    /**
125
-     * @param $item
126
-     * @return string
127
-     */
128
-    protected function generateCell($item)
129
-    {
130
-        $output = '';
131
-        $style = '';
132
-
133
-        // Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep
134
-        // as text if number is longer than that.
135
-        if (preg_match("/^-?\d+(?:[.,]\d+)?$/", $item) && (strlen($item) < 15)) {
136
-            $type = 'Number';
137
-        }
138
-        // Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can
139
-        // also have an optional time after the date.
140
-        //
141
-        // Note we want to be very strict in what we consider a date. There is the possibility
142
-        // of really screwing up the data if we try to reformat a string that was not actually
143
-        // intended to represent a date.
144
-        elseif (preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/", $item) &&
145
-            ($timestamp = strtotime($item)) &&
146
-            ($timestamp > 0) &&
147
-            ($timestamp < strtotime('+500 years'))
148
-        ) {
149
-            $type = 'DateTime';
150
-            $item = strftime("%Y-%m-%dT%H:%M:%S", $timestamp);
151
-            $style = 'sDT'; // defined in header; tells excel to format date for display
152
-        } else {
153
-            $type = 'String';
154
-        }
155
-
156
-        $item = str_replace('&#039;', '&apos;', htmlspecialchars($item, ENT_QUOTES));
157
-        $item = str_replace("\n", '&#13;', $item);
158
-        $output .= "            ";
159
-        $output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>";
160
-        $output .= sprintf("<Data ss:Type=\"%s\">%s</Data>", $type, $item);
161
-        $output .= "</Cell>\n";
162
-
163
-        return $output;
164
-    }
24
+	public const XmlHeader = "<?xml version=\"1.0\" encoding=\"%s\"?\>\n<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:html=\"http://www.w3.org/TR/REC-html40\">";
25
+	public const XmlFooter = "</Workbook>";
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $encoding = 'UTF-8'; // encoding type to specify in file.
31
+	// Note that you're on your own for making sure your data is actually encoded to this encoding
32
+
33
+	/**
34
+	 * @var string
35
+	 */
36
+	protected $title = 'Sheet1'; // title for Worksheet
37
+
38
+	/**
39
+	 * @var string
40
+	 */
41
+	protected $buffer = '';
42
+
43
+
44
+	/**
45
+	 * Constructor
46
+	 */
47
+	public function __construct()
48
+	{
49
+		$this->addToBuffer($this->generateHeader());
50
+	}
51
+
52
+	/**
53
+	 * @param array $row
54
+	 */
55
+	public function addRow($row)
56
+	{
57
+		$this->addToBuffer($this->generateRow($row));
58
+	}
59
+
60
+	/**
61
+	 * @return mixed
62
+	 */
63
+	public function toString()
64
+	{
65
+		$this->addToBuffer($this->generateFooter());
66
+		return $this->buffer;
67
+	}
68
+
69
+	/**
70
+	 * @param $data
71
+	 */
72
+	protected function addToBuffer($data)
73
+	{
74
+		$this->buffer .= $data;
75
+	}
76
+
77
+	/**
78
+	 * @return string
79
+	 */
80
+	protected function generateHeader()
81
+	{
82
+		// workbook header
83
+		$output = stripslashes(sprintf(self::XmlHeader, $this->encoding)) . "\n";
84
+
85
+		// Set up styles
86
+		$output .= "<Styles>\n";
87
+		$output .= "<Style ss:ID=\"sDT\"><NumberFormat ss:Format=\"Short Date\"/></Style>\n";
88
+		$output .= "</Styles>\n";
89
+
90
+		// worksheet header
91
+		$output .= sprintf("<Worksheet ss:Name=\"%s\">\n    <Table>\n", htmlentities($this->title));
92
+
93
+		return $output;
94
+	}
95
+
96
+	protected function generateFooter()
97
+	{
98
+		$output = '';
99
+
100
+		// worksheet footer
101
+		$output .= "    </Table>\n</Worksheet>\n";
102
+
103
+		// workbook footer
104
+		$output .= self::XmlFooter;
105
+
106
+		return $output;
107
+	}
108
+
109
+	/**
110
+	 * @param $row
111
+	 * @return string
112
+	 */
113
+	protected function generateRow($row)
114
+	{
115
+		$output = '';
116
+		$output .= "        <Row>\n";
117
+		foreach ($row as $v) {
118
+			$output .= $this->generateCell($v);
119
+		}
120
+		$output .= "        </Row>\n";
121
+		return $output;
122
+	}
123
+
124
+	/**
125
+	 * @param $item
126
+	 * @return string
127
+	 */
128
+	protected function generateCell($item)
129
+	{
130
+		$output = '';
131
+		$style = '';
132
+
133
+		// Tell Excel to treat as a number. Note that Excel only stores roughly 15 digits, so keep
134
+		// as text if number is longer than that.
135
+		if (preg_match("/^-?\d+(?:[.,]\d+)?$/", $item) && (strlen($item) < 15)) {
136
+			$type = 'Number';
137
+		}
138
+		// Sniff for valid dates; should look something like 2010-07-14 or 7/14/2010 etc. Can
139
+		// also have an optional time after the date.
140
+		//
141
+		// Note we want to be very strict in what we consider a date. There is the possibility
142
+		// of really screwing up the data if we try to reformat a string that was not actually
143
+		// intended to represent a date.
144
+		elseif (preg_match("/^(\d{1,2}|\d{4})[\/\-]\d{1,2}[\/\-](\d{1,2}|\d{4})([^\d].+)?$/", $item) &&
145
+			($timestamp = strtotime($item)) &&
146
+			($timestamp > 0) &&
147
+			($timestamp < strtotime('+500 years'))
148
+		) {
149
+			$type = 'DateTime';
150
+			$item = strftime("%Y-%m-%dT%H:%M:%S", $timestamp);
151
+			$style = 'sDT'; // defined in header; tells excel to format date for display
152
+		} else {
153
+			$type = 'String';
154
+		}
155
+
156
+		$item = str_replace('&#039;', '&apos;', htmlspecialchars($item, ENT_QUOTES));
157
+		$item = str_replace("\n", '&#13;', $item);
158
+		$output .= "            ";
159
+		$output .= $style ? "<Cell ss:StyleID=\"$style\">" : "<Cell>";
160
+		$output .= sprintf("<Data ss:Type=\"%s\">%s</Data>", $type, $item);
161
+		$output .= "</Cell>\n";
162
+
163
+		return $output;
164
+	}
165 165
 }
Please login to merge, or discard this patch.
Classes/Service/ClipboardService.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -19,83 +19,83 @@
 block discarded – undo
19 19
  */
20 20
 class ClipboardService implements SingletonInterface
21 21
 {
22
-    /**
23
-     * Get the Matcher object of the clipboard.
24
-     *
25
-     * @return Matcher
26
-     */
27
-    public function getMatcher()
28
-    {
29
-        $matcher = $this->getBackendUser()->getModuleData($this->getDataKey());
30
-        if (!$matcher) {
31
-            /** @var $matcher Matcher */
32
-            $matcher = GeneralUtility::makeInstance(Matcher::class);
33
-        }
34
-        return $matcher;
35
-    }
22
+	/**
23
+	 * Get the Matcher object of the clipboard.
24
+	 *
25
+	 * @return Matcher
26
+	 */
27
+	public function getMatcher()
28
+	{
29
+		$matcher = $this->getBackendUser()->getModuleData($this->getDataKey());
30
+		if (!$matcher) {
31
+			/** @var $matcher Matcher */
32
+			$matcher = GeneralUtility::makeInstance(Matcher::class);
33
+		}
34
+		return $matcher;
35
+	}
36 36
 
37
-    /**
38
-     * Tell whether the clipboard has items or not.
39
-     *
40
-     * @return bool
41
-     */
42
-    public function hasItems()
43
-    {
44
-        $matcher = $this->getMatcher();
37
+	/**
38
+	 * Tell whether the clipboard has items or not.
39
+	 *
40
+	 * @return bool
41
+	 */
42
+	public function hasItems()
43
+	{
44
+		$matcher = $this->getMatcher();
45 45
 
46
-        $inCriteria = $matcher->getIn();
47
-        $likeCriteria = $matcher->getLike();
48
-        $searchTerm = $matcher->getSearchTerm();
46
+		$inCriteria = $matcher->getIn();
47
+		$likeCriteria = $matcher->getLike();
48
+		$searchTerm = $matcher->getSearchTerm();
49 49
 
50
-        $hasItems = !empty($inCriteria) || !empty($likeCriteria) || !empty($searchTerm);
51
-        return $hasItems;
52
-    }
50
+		$hasItems = !empty($inCriteria) || !empty($likeCriteria) || !empty($searchTerm);
51
+		return $hasItems;
52
+	}
53 53
 
54
-    /**
55
-     * Save data into the clipboard.
56
-     *
57
-     * @param Matcher $matches
58
-     */
59
-    public function save(Matcher $matches)
60
-    {
61
-        $this->getBackendUser()->pushModuleData($this->getDataKey(), $matches);
62
-    }
54
+	/**
55
+	 * Save data into the clipboard.
56
+	 *
57
+	 * @param Matcher $matches
58
+	 */
59
+	public function save(Matcher $matches)
60
+	{
61
+		$this->getBackendUser()->pushModuleData($this->getDataKey(), $matches);
62
+	}
63 63
 
64
-    /**
65
-     * Completely empty the clipboard for a data type.
66
-     *
67
-     * @return void
68
-     */
69
-    public function flush()
70
-    {
71
-        $this->getBackendUser()->pushModuleData($this->getDataKey(), null);
72
-    }
64
+	/**
65
+	 * Completely empty the clipboard for a data type.
66
+	 *
67
+	 * @return void
68
+	 */
69
+	public function flush()
70
+	{
71
+		$this->getBackendUser()->pushModuleData($this->getDataKey(), null);
72
+	}
73 73
 
74
-    /**
75
-     * @return string
76
-     */
77
-    protected function getDataKey()
78
-    {
79
-        return 'vidi_clipboard_' . $this->getModuleLoader()->getDataType();
80
-    }
74
+	/**
75
+	 * @return string
76
+	 */
77
+	protected function getDataKey()
78
+	{
79
+		return 'vidi_clipboard_' . $this->getModuleLoader()->getDataType();
80
+	}
81 81
 
82
-    /**
83
-     * Get the Vidi Module Loader.
84
-     *
85
-     * @return ModuleLoader|object
86
-     */
87
-    protected function getModuleLoader()
88
-    {
89
-        return GeneralUtility::makeInstance(ModuleLoader::class);
90
-    }
82
+	/**
83
+	 * Get the Vidi Module Loader.
84
+	 *
85
+	 * @return ModuleLoader|object
86
+	 */
87
+	protected function getModuleLoader()
88
+	{
89
+		return GeneralUtility::makeInstance(ModuleLoader::class);
90
+	}
91 91
 
92
-    /**
93
-     * Returns an instance of the current Backend User.
94
-     *
95
-     * @return BackendUserAuthentication
96
-     */
97
-    protected function getBackendUser()
98
-    {
99
-        return $GLOBALS['BE_USER'];
100
-    }
92
+	/**
93
+	 * Returns an instance of the current Backend User.
94
+	 *
95
+	 * @return BackendUserAuthentication
96
+	 */
97
+	protected function getBackendUser()
98
+	{
99
+		return $GLOBALS['BE_USER'];
100
+	}
101 101
 }
Please login to merge, or discard this patch.
Classes/Converter/Field.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -18,92 +18,92 @@
 block discarded – undo
18 18
  */
19 19
 class Field implements SingletonInterface
20 20
 {
21
-    /**
22
-     * @var string
23
-     */
24
-    protected static $currentField;
21
+	/**
22
+	 * @var string
23
+	 */
24
+	protected static $currentField;
25 25
 
26
-    /**
27
-     * @var string
28
-     */
29
-    protected static $currentTable;
26
+	/**
27
+	 * @var string
28
+	 */
29
+	protected static $currentTable;
30 30
 
31
-    /**
32
-     * @var array
33
-     */
34
-    protected $storage = [];
31
+	/**
32
+	 * @var array
33
+	 */
34
+	protected $storage = [];
35 35
 
36
-    /**
37
-     * @param string $fieldName
38
-     * @return $this
39
-     * @throws \InvalidArgumentException
40
-     */
41
-    public static function name($fieldName)
42
-    {
43
-        self::$currentField = $fieldName;
44
-        self::$currentTable = ''; // reset the table name value.
45
-        return GeneralUtility::makeInstance(self::class);
46
-    }
36
+	/**
37
+	 * @param string $fieldName
38
+	 * @return $this
39
+	 * @throws \InvalidArgumentException
40
+	 */
41
+	public static function name($fieldName)
42
+	{
43
+		self::$currentField = $fieldName;
44
+		self::$currentTable = ''; // reset the table name value.
45
+		return GeneralUtility::makeInstance(self::class);
46
+	}
47 47
 
48
-    /**
49
-     * @param string|Content $tableNameOrContentObject
50
-     * @return $this
51
-     */
52
-    public function of($tableNameOrContentObject)
53
-    {
54
-        // Resolve the table name.
55
-        self::$currentTable = $tableNameOrContentObject instanceof Content ?
56
-            $tableNameOrContentObject->getDataType() :
57
-            $tableNameOrContentObject;
58
-        return $this;
59
-    }
48
+	/**
49
+	 * @param string|Content $tableNameOrContentObject
50
+	 * @return $this
51
+	 */
52
+	public function of($tableNameOrContentObject)
53
+	{
54
+		// Resolve the table name.
55
+		self::$currentTable = $tableNameOrContentObject instanceof Content ?
56
+			$tableNameOrContentObject->getDataType() :
57
+			$tableNameOrContentObject;
58
+		return $this;
59
+	}
60 60
 
61
-    public function toPropertyName()
62
-    {
63
-        $fieldName = $this->getFieldName();
64
-        $tableName = $this->getTableName();
61
+	public function toPropertyName()
62
+	{
63
+		$fieldName = $this->getFieldName();
64
+		$tableName = $this->getTableName();
65 65
 
66
-        if (empty($this->storage[$tableName][$fieldName])) {
67
-            if (!array_key_exists($tableName, $this->storage)) {
68
-                $this->storage[$tableName] = [];
69
-            }
66
+		if (empty($this->storage[$tableName][$fieldName])) {
67
+			if (!array_key_exists($tableName, $this->storage)) {
68
+				$this->storage[$tableName] = [];
69
+			}
70 70
 
71
-            // Special case when the field name does not follow the conventions "field_name" => "fieldName".
72
-            // Rely on mapping for those cases.
73
-            if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName])) {
74
-                $propertyName = $GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName];
75
-            } else {
76
-                $propertyName = GeneralUtility::underscoredToLowerCamelCase($fieldName);
77
-            }
71
+			// Special case when the field name does not follow the conventions "field_name" => "fieldName".
72
+			// Rely on mapping for those cases.
73
+			if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName])) {
74
+				$propertyName = $GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName];
75
+			} else {
76
+				$propertyName = GeneralUtility::underscoredToLowerCamelCase($fieldName);
77
+			}
78 78
 
79
-            $this->storage[$tableName][$fieldName] = $propertyName;
80
-        }
79
+			$this->storage[$tableName][$fieldName] = $propertyName;
80
+		}
81 81
 
82
-        return $this->storage[$tableName][$fieldName];
83
-    }
82
+		return $this->storage[$tableName][$fieldName];
83
+	}
84 84
 
85
-    /**
86
-     * @return string
87
-     * @throws \RuntimeException
88
-     */
89
-    protected function getFieldName()
90
-    {
91
-        $fieldName = self::$currentField;
92
-        if (empty($fieldName)) {
93
-            throw new \RuntimeException('I could not find a field name value.', 1403203290);
94
-        }
95
-        return $fieldName;
96
-    }
85
+	/**
86
+	 * @return string
87
+	 * @throws \RuntimeException
88
+	 */
89
+	protected function getFieldName()
90
+	{
91
+		$fieldName = self::$currentField;
92
+		if (empty($fieldName)) {
93
+			throw new \RuntimeException('I could not find a field name value.', 1403203290);
94
+		}
95
+		return $fieldName;
96
+	}
97 97
 
98
-    /**
99
-     * @return string
100
-     */
101
-    protected function getTableName()
102
-    {
103
-        $tableName = self::$currentTable;
104
-        if (empty($tableName)) {
105
-            throw new \RuntimeException('I could not find a table name value.', 1403203291);
106
-        }
107
-        return $tableName;
108
-    }
98
+	/**
99
+	 * @return string
100
+	 */
101
+	protected function getTableName()
102
+	{
103
+		$tableName = self::$currentTable;
104
+		if (empty($tableName)) {
105
+			throw new \RuntimeException('I could not find a table name value.', 1403203291);
106
+		}
107
+		return $tableName;
108
+	}
109 109
 }
Please login to merge, or discard this patch.
Classes/Converter/Property.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -17,97 +17,97 @@
 block discarded – undo
17 17
  */
18 18
 class Property
19 19
 {
20
-    /**
21
-     * @var string
22
-     */
23
-    protected static $currentProperty;
24
-
25
-    /**
26
-     * @var string
27
-     */
28
-    protected static $currentTable;
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    protected $storage = [];
34
-
35
-    /**
36
-     * @param string $propertyName
37
-     * @return $this
38
-     * @throws \InvalidArgumentException
39
-     */
40
-    public static function name($propertyName)
41
-    {
42
-        self::$currentProperty = $propertyName;
43
-        self::$currentTable = ''; // reset the table name value.
44
-        return GeneralUtility::makeInstance(self::class);
45
-    }
46
-
47
-    /**
48
-     * @param string|Content $tableNameOrContentObject
49
-     * @return $this
50
-     */
51
-    public function of($tableNameOrContentObject)
52
-    {
53
-        // Resolve the table name.
54
-        self::$currentTable = $tableNameOrContentObject instanceof Content ?
55
-            $tableNameOrContentObject->getDataType() :
56
-            $tableNameOrContentObject;
57
-        return $this;
58
-    }
59
-
60
-    public function toFieldName()
61
-    {
62
-        $propertyName = $this->getPropertyName();
63
-        $tableName = $this->getTableName();
64
-
65
-        if (empty($this->storage[$tableName][$propertyName])) {
66
-            if (!array_key_exists($tableName, $this->storage)) {
67
-                $this->storage[$tableName] = [];
68
-            }
69
-
70
-            // Default case
71
-            $fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
72
-
73
-            // Special case in case the field name does not follow the conventions "field_name" => "fieldName"
74
-            // There is the chance to make some mapping
75
-            if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'])) {
76
-                $key = array_search($propertyName, $GLOBALS['TCA'][$tableName]['vidi']['mappings']);
77
-                if ($key !== false) {
78
-                    $fieldName = $key;
79
-                }
80
-            }
81
-
82
-            $this->storage[$tableName][$propertyName] = $fieldName;
83
-        }
84
-
85
-        return $this->storage[$tableName][$propertyName];
86
-    }
87
-
88
-    /**
89
-     * @return string
90
-     * @throws \RuntimeException
91
-     */
92
-    protected function getPropertyName()
93
-    {
94
-        $propertyName = self::$currentProperty;
95
-        if (empty($propertyName)) {
96
-            throw new \RuntimeException('I could not find a field name value.', 1403203290);
97
-        }
98
-        return $propertyName;
99
-    }
100
-
101
-    /**
102
-     * @return string
103
-     * @throws \RuntimeException
104
-     */
105
-    protected function getTableName()
106
-    {
107
-        $tableName = self::$currentTable;
108
-        if (empty($tableName)) {
109
-            throw new \RuntimeException('I could not find a table name value.', 1403203291);
110
-        }
111
-        return $tableName;
112
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	protected static $currentProperty;
24
+
25
+	/**
26
+	 * @var string
27
+	 */
28
+	protected static $currentTable;
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	protected $storage = [];
34
+
35
+	/**
36
+	 * @param string $propertyName
37
+	 * @return $this
38
+	 * @throws \InvalidArgumentException
39
+	 */
40
+	public static function name($propertyName)
41
+	{
42
+		self::$currentProperty = $propertyName;
43
+		self::$currentTable = ''; // reset the table name value.
44
+		return GeneralUtility::makeInstance(self::class);
45
+	}
46
+
47
+	/**
48
+	 * @param string|Content $tableNameOrContentObject
49
+	 * @return $this
50
+	 */
51
+	public function of($tableNameOrContentObject)
52
+	{
53
+		// Resolve the table name.
54
+		self::$currentTable = $tableNameOrContentObject instanceof Content ?
55
+			$tableNameOrContentObject->getDataType() :
56
+			$tableNameOrContentObject;
57
+		return $this;
58
+	}
59
+
60
+	public function toFieldName()
61
+	{
62
+		$propertyName = $this->getPropertyName();
63
+		$tableName = $this->getTableName();
64
+
65
+		if (empty($this->storage[$tableName][$propertyName])) {
66
+			if (!array_key_exists($tableName, $this->storage)) {
67
+				$this->storage[$tableName] = [];
68
+			}
69
+
70
+			// Default case
71
+			$fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
72
+
73
+			// Special case in case the field name does not follow the conventions "field_name" => "fieldName"
74
+			// There is the chance to make some mapping
75
+			if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'])) {
76
+				$key = array_search($propertyName, $GLOBALS['TCA'][$tableName]['vidi']['mappings']);
77
+				if ($key !== false) {
78
+					$fieldName = $key;
79
+				}
80
+			}
81
+
82
+			$this->storage[$tableName][$propertyName] = $fieldName;
83
+		}
84
+
85
+		return $this->storage[$tableName][$propertyName];
86
+	}
87
+
88
+	/**
89
+	 * @return string
90
+	 * @throws \RuntimeException
91
+	 */
92
+	protected function getPropertyName()
93
+	{
94
+		$propertyName = self::$currentProperty;
95
+		if (empty($propertyName)) {
96
+			throw new \RuntimeException('I could not find a field name value.', 1403203290);
97
+		}
98
+		return $propertyName;
99
+	}
100
+
101
+	/**
102
+	 * @return string
103
+	 * @throws \RuntimeException
104
+	 */
105
+	protected function getTableName()
106
+	{
107
+		$tableName = self::$currentTable;
108
+		if (empty($tableName)) {
109
+			throw new \RuntimeException('I could not find a table name value.', 1403203291);
110
+		}
111
+		return $tableName;
112
+	}
113 113
 }
Please login to merge, or discard this patch.
Classes/Persistence/OrderObjectFactory.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -18,42 +18,42 @@
 block discarded – undo
18 18
  */
19 19
 class OrderObjectFactory implements SingletonInterface
20 20
 {
21
-    /**
22
-     * Gets a singleton instance of this class.
23
-     *
24
-     * @return \Fab\Vidi\Persistence\OrderObjectFactory|object
25
-     */
26
-    public static function getInstance()
27
-    {
28
-        return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\OrderObjectFactory::class);
29
-    }
30
-
31
-    /**
32
-     * Returns an order object.
33
-     *
34
-     * @param string $dataType
35
-     * @return Order|object
36
-     */
37
-    public function getOrder($dataType = '')
38
-    {
39
-        // Default ordering
40
-        $order = Tca::table($dataType)->getDefaultOrderings();
41
-
42
-        // Retrieve a possible id of the column from the request
43
-        $orderings = GeneralUtility::_GP('order');
44
-
45
-        if (is_array($orderings) && isset($orderings[0])) {
46
-            $columnPosition = $orderings[0]['column'];
47
-            $direction = $orderings[0]['dir'];
48
-
49
-            if ($columnPosition > 0) {
50
-                $field = Tca::grid()->getFieldNameByPosition($columnPosition);
51
-
52
-                $order = array(
53
-                    $field => strtoupper($direction)
54
-                );
55
-            }
56
-        }
57
-        return GeneralUtility::makeInstance(Order::class, $order);
58
-    }
21
+	/**
22
+	 * Gets a singleton instance of this class.
23
+	 *
24
+	 * @return \Fab\Vidi\Persistence\OrderObjectFactory|object
25
+	 */
26
+	public static function getInstance()
27
+	{
28
+		return GeneralUtility::makeInstance(\Fab\Vidi\Persistence\OrderObjectFactory::class);
29
+	}
30
+
31
+	/**
32
+	 * Returns an order object.
33
+	 *
34
+	 * @param string $dataType
35
+	 * @return Order|object
36
+	 */
37
+	public function getOrder($dataType = '')
38
+	{
39
+		// Default ordering
40
+		$order = Tca::table($dataType)->getDefaultOrderings();
41
+
42
+		// Retrieve a possible id of the column from the request
43
+		$orderings = GeneralUtility::_GP('order');
44
+
45
+		if (is_array($orderings) && isset($orderings[0])) {
46
+			$columnPosition = $orderings[0]['column'];
47
+			$direction = $orderings[0]['dir'];
48
+
49
+			if ($columnPosition > 0) {
50
+				$field = Tca::grid()->getFieldNameByPosition($columnPosition);
51
+
52
+				$order = array(
53
+					$field => strtoupper($direction)
54
+				);
55
+			}
56
+		}
57
+		return GeneralUtility::makeInstance(Order::class, $order);
58
+	}
59 59
 }
Please login to merge, or discard this patch.
Classes/Persistence/Matcher.php 1 patch
Indentation   +495 added lines, -495 removed lines patch added patch discarded remove patch
@@ -14,499 +14,499 @@
 block discarded – undo
14 14
  */
15 15
 class Matcher
16 16
 {
17
-    /**
18
-     * The logical OR
19
-     */
20
-    public const LOGICAL_OR = 'logicalOr';
21
-
22
-    /**
23
-     * The logical AND
24
-     */
25
-    public const LOGICAL_AND = 'logicalAnd';
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    protected $dataType = '';
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    protected $searchTerm = '';
36
-
37
-    /**
38
-     * @var array
39
-     */
40
-    protected $supportedOperators = [
41
-        '=' => 'equals',
42
-        '!=' => 'notEquals',
43
-        'in' => 'in',
44
-        'like' => 'like',
45
-        '>' => 'greaterThan',
46
-        '>=' => 'greaterThanOrEqual',
47
-        '<' => 'lessThan',
48
-        '<=' => 'lessThanOrEqual',
49
-    ];
50
-
51
-    /**
52
-     * @var array
53
-     */
54
-    protected $equals = [];
55
-
56
-    /**
57
-     * @var array
58
-     */
59
-    protected $notEquals = [];
60
-
61
-    /**
62
-     * @var array
63
-     */
64
-    protected $greaterThan = [];
65
-
66
-    /**
67
-     * @var array
68
-     */
69
-    protected $greaterThanOrEqual = [];
70
-
71
-    /**
72
-     * @var array
73
-     */
74
-    protected $lessThan = [];
75
-
76
-    /**
77
-     * @var array
78
-     */
79
-    protected $lessThanOrEqual = [];
80
-
81
-    /**
82
-     * @var array
83
-     */
84
-    protected $in = [];
85
-
86
-    /**
87
-     * @var array
88
-     */
89
-    protected $like = [];
90
-
91
-    /**
92
-     * @var array
93
-     */
94
-    protected $matches = [];
95
-
96
-    /**
97
-     * @var string
98
-     */
99
-    protected $defaultLogicalSeparator = self::LOGICAL_AND;
100
-
101
-    /**
102
-     * @var string
103
-     */
104
-    protected $logicalSeparatorForEquals = self::LOGICAL_AND;
105
-
106
-    /**
107
-     * @var string
108
-     */
109
-    protected $logicalSeparatorForGreaterThan = self::LOGICAL_AND;
110
-
111
-    /**
112
-     * @var string
113
-     */
114
-    protected $logicalSeparatorForGreaterThanOrEqual = self::LOGICAL_AND;
115
-
116
-    /**
117
-     * @var string
118
-     */
119
-    protected $logicalSeparatorForLessThan = self::LOGICAL_AND;
120
-
121
-    /**
122
-     * @var string
123
-     */
124
-    protected $logicalSeparatorForLessThanOrEqual = self::LOGICAL_AND;
125
-
126
-    /**
127
-     * @var string
128
-     */
129
-    protected $logicalSeparatorForIn = self::LOGICAL_AND;
130
-
131
-    /**
132
-     * @var string
133
-     */
134
-    protected $logicalSeparatorForLike = self::LOGICAL_AND;
135
-
136
-    /**
137
-     * @var string
138
-     */
139
-    protected $logicalSeparatorForSearchTerm = self::LOGICAL_OR;
140
-
141
-    /**
142
-     * Constructs a new Matcher
143
-     *
144
-     * @param array $matches associative [$field => $value]
145
-     * @param string $dataType which corresponds to an entry of the TCA (table name).
146
-     */
147
-    public function __construct($matches = [], $dataType = '')
148
-    {
149
-        $this->dataType = $dataType;
150
-        $this->matches = $matches;
151
-    }
152
-
153
-    /**
154
-     * @param string $searchTerm
155
-     * @return \Fab\Vidi\Persistence\Matcher
156
-     */
157
-    public function setSearchTerm($searchTerm): Matcher
158
-    {
159
-        $this->searchTerm = $searchTerm;
160
-        return $this;
161
-    }
162
-
163
-    /**
164
-     * @return string
165
-     */
166
-    public function getSearchTerm(): string
167
-    {
168
-        return $this->searchTerm;
169
-    }
170
-
171
-    /**
172
-     * @return array
173
-     */
174
-    public function getEquals(): array
175
-    {
176
-        return $this->equals;
177
-    }
178
-
179
-    /**
180
-     * @param $fieldNameAndPath
181
-     * @param $operand
182
-     * @return $this
183
-     */
184
-    public function equals($fieldNameAndPath, $operand): self
185
-    {
186
-        $this->equals[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
187
-        return $this;
188
-    }
189
-
190
-    /**
191
-     * @return array
192
-     */
193
-    public function getNotEquals(): array
194
-    {
195
-        return $this->notEquals;
196
-    }
197
-
198
-    /**
199
-     * @param $fieldNameAndPath
200
-     * @param $operand
201
-     * @return $this
202
-     */
203
-    public function notEquals($fieldNameAndPath, $operand): self
204
-    {
205
-        $this->notEquals[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
206
-        return $this;
207
-    }
208
-
209
-    /**
210
-     * @return array
211
-     */
212
-    public function getGreaterThan(): array
213
-    {
214
-        return $this->greaterThan;
215
-    }
216
-
217
-    /**
218
-     * @param $fieldNameAndPath
219
-     * @param $operand
220
-     * @return $this
221
-     */
222
-    public function greaterThan($fieldNameAndPath, $operand): self
223
-    {
224
-        $this->greaterThan[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
225
-        return $this;
226
-    }
227
-
228
-    /**
229
-     * @return array
230
-     */
231
-    public function getGreaterThanOrEqual(): array
232
-    {
233
-        return $this->greaterThanOrEqual;
234
-    }
235
-
236
-    /**
237
-     * @param $fieldNameAndPath
238
-     * @param $operand
239
-     * @return $this
240
-     */
241
-    public function greaterThanOrEqual($fieldNameAndPath, $operand): self
242
-    {
243
-        $this->greaterThanOrEqual[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
244
-        return $this;
245
-    }
246
-
247
-    /**
248
-     * @return array
249
-     */
250
-    public function getLessThan(): array
251
-    {
252
-        return $this->lessThan;
253
-    }
254
-
255
-    /**
256
-     * @param $fieldNameAndPath
257
-     * @param $operand
258
-     * @return $this
259
-     */
260
-    public function lessThan($fieldNameAndPath, $operand): self
261
-    {
262
-        $this->lessThan[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
263
-        return $this;
264
-    }
265
-
266
-    /**
267
-     * @return array
268
-     */
269
-    public function getLessThanOrEqual(): array
270
-    {
271
-        return $this->lessThanOrEqual;
272
-    }
273
-
274
-    /**
275
-     * @param $fieldNameAndPath
276
-     * @param $operand
277
-     * @return $this
278
-     */
279
-    public function lessThanOrEqual($fieldNameAndPath, $operand): self
280
-    {
281
-        $this->lessThanOrEqual[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
282
-        return $this;
283
-    }
284
-
285
-    /**
286
-     * @return array
287
-     */
288
-    public function getLike(): array
289
-    {
290
-        return $this->like;
291
-    }
292
-
293
-    /**
294
-     * @param $fieldNameAndPath
295
-     * @param $operand
296
-     * @return $this
297
-     */
298
-    public function in($fieldNameAndPath, $operand): self
299
-    {
300
-        $this->in[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
301
-        return $this;
302
-    }
303
-
304
-    /**
305
-     * @return array
306
-     */
307
-    public function getIn(): array
308
-    {
309
-        return $this->in;
310
-    }
311
-
312
-    /**
313
-     * @param $fieldNameAndPath
314
-     * @param $operand
315
-     * @param bool $addWildCard
316
-     * @return $this
317
-     */
318
-    public function like($fieldNameAndPath, $operand, $addWildCard = true): self
319
-    {
320
-        $wildCardSymbol = $addWildCard ? '%' : '';
321
-        $this->like[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $wildCardSymbol . $operand . $wildCardSymbol];
322
-        return $this;
323
-    }
324
-
325
-    /**
326
-     * @return string
327
-     */
328
-    public function getDefaultLogicalSeparator(): string
329
-    {
330
-        return $this->defaultLogicalSeparator;
331
-    }
332
-
333
-    /**
334
-     * @param string $defaultLogicalSeparator
335
-     * @return $this
336
-     */
337
-    public function setDefaultLogicalSeparator($defaultLogicalSeparator): self
338
-    {
339
-        $this->defaultLogicalSeparator = $defaultLogicalSeparator;
340
-        return $this;
341
-    }
342
-
343
-    /**
344
-     * @return string
345
-     */
346
-    public function getLogicalSeparatorForEquals(): string
347
-    {
348
-        return $this->logicalSeparatorForEquals;
349
-    }
350
-
351
-    /**
352
-     * @param string $logicalSeparatorForEquals
353
-     * @return $this
354
-     */
355
-    public function setLogicalSeparatorForEquals($logicalSeparatorForEquals): self
356
-    {
357
-        $this->logicalSeparatorForEquals = $logicalSeparatorForEquals;
358
-        return $this;
359
-    }
360
-
361
-    /**
362
-     * @return string
363
-     */
364
-    public function getLogicalSeparatorForGreaterThan(): string
365
-    {
366
-        return $this->logicalSeparatorForGreaterThan;
367
-    }
368
-
369
-    /**
370
-     * @param string $logicalSeparatorForGreaterThan
371
-     * @return $this
372
-     */
373
-    public function setLogicalSeparatorForGreaterThan($logicalSeparatorForGreaterThan): self
374
-    {
375
-        $this->logicalSeparatorForGreaterThan = $logicalSeparatorForGreaterThan;
376
-        return $this;
377
-    }
378
-
379
-    /**
380
-     * @return string
381
-     */
382
-    public function getLogicalSeparatorForGreaterThanOrEqual(): string
383
-    {
384
-        return $this->logicalSeparatorForGreaterThanOrEqual;
385
-    }
386
-
387
-    /**
388
-     * @param string $logicalSeparatorForGreaterThanOrEqual
389
-     * @return $this
390
-     */
391
-    public function setLogicalSeparatorForGreaterThanOrEqual($logicalSeparatorForGreaterThanOrEqual): self
392
-    {
393
-        $this->logicalSeparatorForGreaterThanOrEqual = $logicalSeparatorForGreaterThanOrEqual;
394
-        return $this;
395
-    }
396
-
397
-    /**
398
-     * @return string
399
-     */
400
-    public function getLogicalSeparatorForLessThan(): string
401
-    {
402
-        return $this->logicalSeparatorForLessThan;
403
-    }
404
-
405
-    /**
406
-     * @param string $logicalSeparatorForLessThan
407
-     * @return $this
408
-     */
409
-    public function setLogicalSeparatorForLessThan($logicalSeparatorForLessThan): self
410
-    {
411
-        $this->logicalSeparatorForLessThan = $logicalSeparatorForLessThan;
412
-        return $this;
413
-    }
414
-
415
-    /**
416
-     * @return string
417
-     */
418
-    public function getLogicalSeparatorForLessThanOrEqual(): string
419
-    {
420
-        return $this->logicalSeparatorForLessThanOrEqual;
421
-    }
422
-
423
-    /**
424
-     * @param string $logicalSeparatorForLessThanOrEqual
425
-     * @return $this
426
-     */
427
-    public function setLogicalSeparatorForLessThanOrEqual($logicalSeparatorForLessThanOrEqual): self
428
-    {
429
-        $this->logicalSeparatorForLessThanOrEqual = $logicalSeparatorForLessThanOrEqual;
430
-        return $this;
431
-    }
432
-
433
-    /**
434
-     * @return string
435
-     */
436
-    public function getLogicalSeparatorForIn(): string
437
-    {
438
-        return $this->logicalSeparatorForIn;
439
-    }
440
-
441
-    /**
442
-     * @param string $logicalSeparatorForIn
443
-     * @return $this
444
-     */
445
-    public function setLogicalSeparatorForIn($logicalSeparatorForIn): self
446
-    {
447
-        $this->logicalSeparatorForIn = $logicalSeparatorForIn;
448
-        return $this;
449
-    }
450
-
451
-    /**
452
-     * @return string
453
-     */
454
-    public function getLogicalSeparatorForLike(): string
455
-    {
456
-        return $this->logicalSeparatorForLike;
457
-    }
458
-
459
-    /**
460
-     * @param string $logicalSeparatorForLike
461
-     * @return $this
462
-     */
463
-    public function setLogicalSeparatorForLike($logicalSeparatorForLike): self
464
-    {
465
-        $this->logicalSeparatorForLike = $logicalSeparatorForLike;
466
-        return $this;
467
-    }
468
-
469
-    /**
470
-     * @return string
471
-     */
472
-    public function getLogicalSeparatorForSearchTerm(): string
473
-    {
474
-        return $this->logicalSeparatorForSearchTerm;
475
-    }
476
-
477
-    /**
478
-     * @param string $logicalSeparatorForSearchTerm
479
-     * @return $this
480
-     */
481
-    public function setLogicalSeparatorForSearchTerm($logicalSeparatorForSearchTerm): self
482
-    {
483
-        $this->logicalSeparatorForSearchTerm = $logicalSeparatorForSearchTerm;
484
-        return $this;
485
-    }
486
-
487
-    /**
488
-     * @return array
489
-     */
490
-    public function getSupportedOperators(): array
491
-    {
492
-        return $this->supportedOperators;
493
-    }
494
-
495
-    /**
496
-     * @return string
497
-     */
498
-    public function getDataType(): string
499
-    {
500
-        return $this->dataType;
501
-    }
502
-
503
-    /**
504
-     * @param string $dataType
505
-     * @return $this
506
-     */
507
-    public function setDataType($dataType): self
508
-    {
509
-        $this->dataType = $dataType;
510
-        return $this;
511
-    }
17
+	/**
18
+	 * The logical OR
19
+	 */
20
+	public const LOGICAL_OR = 'logicalOr';
21
+
22
+	/**
23
+	 * The logical AND
24
+	 */
25
+	public const LOGICAL_AND = 'logicalAnd';
26
+
27
+	/**
28
+	 * @var string
29
+	 */
30
+	protected $dataType = '';
31
+
32
+	/**
33
+	 * @var string
34
+	 */
35
+	protected $searchTerm = '';
36
+
37
+	/**
38
+	 * @var array
39
+	 */
40
+	protected $supportedOperators = [
41
+		'=' => 'equals',
42
+		'!=' => 'notEquals',
43
+		'in' => 'in',
44
+		'like' => 'like',
45
+		'>' => 'greaterThan',
46
+		'>=' => 'greaterThanOrEqual',
47
+		'<' => 'lessThan',
48
+		'<=' => 'lessThanOrEqual',
49
+	];
50
+
51
+	/**
52
+	 * @var array
53
+	 */
54
+	protected $equals = [];
55
+
56
+	/**
57
+	 * @var array
58
+	 */
59
+	protected $notEquals = [];
60
+
61
+	/**
62
+	 * @var array
63
+	 */
64
+	protected $greaterThan = [];
65
+
66
+	/**
67
+	 * @var array
68
+	 */
69
+	protected $greaterThanOrEqual = [];
70
+
71
+	/**
72
+	 * @var array
73
+	 */
74
+	protected $lessThan = [];
75
+
76
+	/**
77
+	 * @var array
78
+	 */
79
+	protected $lessThanOrEqual = [];
80
+
81
+	/**
82
+	 * @var array
83
+	 */
84
+	protected $in = [];
85
+
86
+	/**
87
+	 * @var array
88
+	 */
89
+	protected $like = [];
90
+
91
+	/**
92
+	 * @var array
93
+	 */
94
+	protected $matches = [];
95
+
96
+	/**
97
+	 * @var string
98
+	 */
99
+	protected $defaultLogicalSeparator = self::LOGICAL_AND;
100
+
101
+	/**
102
+	 * @var string
103
+	 */
104
+	protected $logicalSeparatorForEquals = self::LOGICAL_AND;
105
+
106
+	/**
107
+	 * @var string
108
+	 */
109
+	protected $logicalSeparatorForGreaterThan = self::LOGICAL_AND;
110
+
111
+	/**
112
+	 * @var string
113
+	 */
114
+	protected $logicalSeparatorForGreaterThanOrEqual = self::LOGICAL_AND;
115
+
116
+	/**
117
+	 * @var string
118
+	 */
119
+	protected $logicalSeparatorForLessThan = self::LOGICAL_AND;
120
+
121
+	/**
122
+	 * @var string
123
+	 */
124
+	protected $logicalSeparatorForLessThanOrEqual = self::LOGICAL_AND;
125
+
126
+	/**
127
+	 * @var string
128
+	 */
129
+	protected $logicalSeparatorForIn = self::LOGICAL_AND;
130
+
131
+	/**
132
+	 * @var string
133
+	 */
134
+	protected $logicalSeparatorForLike = self::LOGICAL_AND;
135
+
136
+	/**
137
+	 * @var string
138
+	 */
139
+	protected $logicalSeparatorForSearchTerm = self::LOGICAL_OR;
140
+
141
+	/**
142
+	 * Constructs a new Matcher
143
+	 *
144
+	 * @param array $matches associative [$field => $value]
145
+	 * @param string $dataType which corresponds to an entry of the TCA (table name).
146
+	 */
147
+	public function __construct($matches = [], $dataType = '')
148
+	{
149
+		$this->dataType = $dataType;
150
+		$this->matches = $matches;
151
+	}
152
+
153
+	/**
154
+	 * @param string $searchTerm
155
+	 * @return \Fab\Vidi\Persistence\Matcher
156
+	 */
157
+	public function setSearchTerm($searchTerm): Matcher
158
+	{
159
+		$this->searchTerm = $searchTerm;
160
+		return $this;
161
+	}
162
+
163
+	/**
164
+	 * @return string
165
+	 */
166
+	public function getSearchTerm(): string
167
+	{
168
+		return $this->searchTerm;
169
+	}
170
+
171
+	/**
172
+	 * @return array
173
+	 */
174
+	public function getEquals(): array
175
+	{
176
+		return $this->equals;
177
+	}
178
+
179
+	/**
180
+	 * @param $fieldNameAndPath
181
+	 * @param $operand
182
+	 * @return $this
183
+	 */
184
+	public function equals($fieldNameAndPath, $operand): self
185
+	{
186
+		$this->equals[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
187
+		return $this;
188
+	}
189
+
190
+	/**
191
+	 * @return array
192
+	 */
193
+	public function getNotEquals(): array
194
+	{
195
+		return $this->notEquals;
196
+	}
197
+
198
+	/**
199
+	 * @param $fieldNameAndPath
200
+	 * @param $operand
201
+	 * @return $this
202
+	 */
203
+	public function notEquals($fieldNameAndPath, $operand): self
204
+	{
205
+		$this->notEquals[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
206
+		return $this;
207
+	}
208
+
209
+	/**
210
+	 * @return array
211
+	 */
212
+	public function getGreaterThan(): array
213
+	{
214
+		return $this->greaterThan;
215
+	}
216
+
217
+	/**
218
+	 * @param $fieldNameAndPath
219
+	 * @param $operand
220
+	 * @return $this
221
+	 */
222
+	public function greaterThan($fieldNameAndPath, $operand): self
223
+	{
224
+		$this->greaterThan[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
225
+		return $this;
226
+	}
227
+
228
+	/**
229
+	 * @return array
230
+	 */
231
+	public function getGreaterThanOrEqual(): array
232
+	{
233
+		return $this->greaterThanOrEqual;
234
+	}
235
+
236
+	/**
237
+	 * @param $fieldNameAndPath
238
+	 * @param $operand
239
+	 * @return $this
240
+	 */
241
+	public function greaterThanOrEqual($fieldNameAndPath, $operand): self
242
+	{
243
+		$this->greaterThanOrEqual[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
244
+		return $this;
245
+	}
246
+
247
+	/**
248
+	 * @return array
249
+	 */
250
+	public function getLessThan(): array
251
+	{
252
+		return $this->lessThan;
253
+	}
254
+
255
+	/**
256
+	 * @param $fieldNameAndPath
257
+	 * @param $operand
258
+	 * @return $this
259
+	 */
260
+	public function lessThan($fieldNameAndPath, $operand): self
261
+	{
262
+		$this->lessThan[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
263
+		return $this;
264
+	}
265
+
266
+	/**
267
+	 * @return array
268
+	 */
269
+	public function getLessThanOrEqual(): array
270
+	{
271
+		return $this->lessThanOrEqual;
272
+	}
273
+
274
+	/**
275
+	 * @param $fieldNameAndPath
276
+	 * @param $operand
277
+	 * @return $this
278
+	 */
279
+	public function lessThanOrEqual($fieldNameAndPath, $operand): self
280
+	{
281
+		$this->lessThanOrEqual[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
282
+		return $this;
283
+	}
284
+
285
+	/**
286
+	 * @return array
287
+	 */
288
+	public function getLike(): array
289
+	{
290
+		return $this->like;
291
+	}
292
+
293
+	/**
294
+	 * @param $fieldNameAndPath
295
+	 * @param $operand
296
+	 * @return $this
297
+	 */
298
+	public function in($fieldNameAndPath, $operand): self
299
+	{
300
+		$this->in[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $operand];
301
+		return $this;
302
+	}
303
+
304
+	/**
305
+	 * @return array
306
+	 */
307
+	public function getIn(): array
308
+	{
309
+		return $this->in;
310
+	}
311
+
312
+	/**
313
+	 * @param $fieldNameAndPath
314
+	 * @param $operand
315
+	 * @param bool $addWildCard
316
+	 * @return $this
317
+	 */
318
+	public function like($fieldNameAndPath, $operand, $addWildCard = true): self
319
+	{
320
+		$wildCardSymbol = $addWildCard ? '%' : '';
321
+		$this->like[] = ['fieldNameAndPath' => $fieldNameAndPath, 'operand' => $wildCardSymbol . $operand . $wildCardSymbol];
322
+		return $this;
323
+	}
324
+
325
+	/**
326
+	 * @return string
327
+	 */
328
+	public function getDefaultLogicalSeparator(): string
329
+	{
330
+		return $this->defaultLogicalSeparator;
331
+	}
332
+
333
+	/**
334
+	 * @param string $defaultLogicalSeparator
335
+	 * @return $this
336
+	 */
337
+	public function setDefaultLogicalSeparator($defaultLogicalSeparator): self
338
+	{
339
+		$this->defaultLogicalSeparator = $defaultLogicalSeparator;
340
+		return $this;
341
+	}
342
+
343
+	/**
344
+	 * @return string
345
+	 */
346
+	public function getLogicalSeparatorForEquals(): string
347
+	{
348
+		return $this->logicalSeparatorForEquals;
349
+	}
350
+
351
+	/**
352
+	 * @param string $logicalSeparatorForEquals
353
+	 * @return $this
354
+	 */
355
+	public function setLogicalSeparatorForEquals($logicalSeparatorForEquals): self
356
+	{
357
+		$this->logicalSeparatorForEquals = $logicalSeparatorForEquals;
358
+		return $this;
359
+	}
360
+
361
+	/**
362
+	 * @return string
363
+	 */
364
+	public function getLogicalSeparatorForGreaterThan(): string
365
+	{
366
+		return $this->logicalSeparatorForGreaterThan;
367
+	}
368
+
369
+	/**
370
+	 * @param string $logicalSeparatorForGreaterThan
371
+	 * @return $this
372
+	 */
373
+	public function setLogicalSeparatorForGreaterThan($logicalSeparatorForGreaterThan): self
374
+	{
375
+		$this->logicalSeparatorForGreaterThan = $logicalSeparatorForGreaterThan;
376
+		return $this;
377
+	}
378
+
379
+	/**
380
+	 * @return string
381
+	 */
382
+	public function getLogicalSeparatorForGreaterThanOrEqual(): string
383
+	{
384
+		return $this->logicalSeparatorForGreaterThanOrEqual;
385
+	}
386
+
387
+	/**
388
+	 * @param string $logicalSeparatorForGreaterThanOrEqual
389
+	 * @return $this
390
+	 */
391
+	public function setLogicalSeparatorForGreaterThanOrEqual($logicalSeparatorForGreaterThanOrEqual): self
392
+	{
393
+		$this->logicalSeparatorForGreaterThanOrEqual = $logicalSeparatorForGreaterThanOrEqual;
394
+		return $this;
395
+	}
396
+
397
+	/**
398
+	 * @return string
399
+	 */
400
+	public function getLogicalSeparatorForLessThan(): string
401
+	{
402
+		return $this->logicalSeparatorForLessThan;
403
+	}
404
+
405
+	/**
406
+	 * @param string $logicalSeparatorForLessThan
407
+	 * @return $this
408
+	 */
409
+	public function setLogicalSeparatorForLessThan($logicalSeparatorForLessThan): self
410
+	{
411
+		$this->logicalSeparatorForLessThan = $logicalSeparatorForLessThan;
412
+		return $this;
413
+	}
414
+
415
+	/**
416
+	 * @return string
417
+	 */
418
+	public function getLogicalSeparatorForLessThanOrEqual(): string
419
+	{
420
+		return $this->logicalSeparatorForLessThanOrEqual;
421
+	}
422
+
423
+	/**
424
+	 * @param string $logicalSeparatorForLessThanOrEqual
425
+	 * @return $this
426
+	 */
427
+	public function setLogicalSeparatorForLessThanOrEqual($logicalSeparatorForLessThanOrEqual): self
428
+	{
429
+		$this->logicalSeparatorForLessThanOrEqual = $logicalSeparatorForLessThanOrEqual;
430
+		return $this;
431
+	}
432
+
433
+	/**
434
+	 * @return string
435
+	 */
436
+	public function getLogicalSeparatorForIn(): string
437
+	{
438
+		return $this->logicalSeparatorForIn;
439
+	}
440
+
441
+	/**
442
+	 * @param string $logicalSeparatorForIn
443
+	 * @return $this
444
+	 */
445
+	public function setLogicalSeparatorForIn($logicalSeparatorForIn): self
446
+	{
447
+		$this->logicalSeparatorForIn = $logicalSeparatorForIn;
448
+		return $this;
449
+	}
450
+
451
+	/**
452
+	 * @return string
453
+	 */
454
+	public function getLogicalSeparatorForLike(): string
455
+	{
456
+		return $this->logicalSeparatorForLike;
457
+	}
458
+
459
+	/**
460
+	 * @param string $logicalSeparatorForLike
461
+	 * @return $this
462
+	 */
463
+	public function setLogicalSeparatorForLike($logicalSeparatorForLike): self
464
+	{
465
+		$this->logicalSeparatorForLike = $logicalSeparatorForLike;
466
+		return $this;
467
+	}
468
+
469
+	/**
470
+	 * @return string
471
+	 */
472
+	public function getLogicalSeparatorForSearchTerm(): string
473
+	{
474
+		return $this->logicalSeparatorForSearchTerm;
475
+	}
476
+
477
+	/**
478
+	 * @param string $logicalSeparatorForSearchTerm
479
+	 * @return $this
480
+	 */
481
+	public function setLogicalSeparatorForSearchTerm($logicalSeparatorForSearchTerm): self
482
+	{
483
+		$this->logicalSeparatorForSearchTerm = $logicalSeparatorForSearchTerm;
484
+		return $this;
485
+	}
486
+
487
+	/**
488
+	 * @return array
489
+	 */
490
+	public function getSupportedOperators(): array
491
+	{
492
+		return $this->supportedOperators;
493
+	}
494
+
495
+	/**
496
+	 * @return string
497
+	 */
498
+	public function getDataType(): string
499
+	{
500
+		return $this->dataType;
501
+	}
502
+
503
+	/**
504
+	 * @param string $dataType
505
+	 * @return $this
506
+	 */
507
+	public function setDataType($dataType): self
508
+	{
509
+		$this->dataType = $dataType;
510
+		return $this;
511
+	}
512 512
 }
Please login to merge, or discard this patch.
Classes/Persistence/Pager.php 1 patch
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -16,168 +16,168 @@
 block discarded – undo
16 16
  */
17 17
 class Pager
18 18
 {
19
-    /**
20
-     * Total amount of entries
21
-     *
22
-     * @var integer
23
-     */
24
-    protected $count;
25
-
26
-    /**
27
-     * Current offset
28
-     *
29
-     * @var integer
30
-     */
31
-    protected $offset;
32
-
33
-    /**
34
-     * Current page index
35
-     *
36
-     * @var integer
37
-     */
38
-    protected $page;
39
-
40
-    /**
41
-     * Number of items per page
42
-     *
43
-     * @var integer
44
-     */
45
-    protected $limit = 10;
46
-
47
-    /**
48
-     * Constructs a new Pager
49
-     */
50
-    public function __construct()
51
-    {
52
-        $this->page = 1;
53
-    }
54
-
55
-    /**
56
-     * Returns the total amount of entries
57
-     *
58
-     * @return int
59
-     */
60
-    public function getCount()
61
-    {
62
-        return $this->count;
63
-    }
64
-
65
-    /**
66
-     * Sets the total amount of entries
67
-     *
68
-     * @param int $count
69
-     */
70
-    public function setCount($count)
71
-    {
72
-        $this->count = $count;
73
-    }
74
-
75
-    /**
76
-     * Returns the current page index
77
-     *
78
-     * @return int
79
-     */
80
-    public function getPage()
81
-    {
82
-        return $this->page;
83
-    }
84
-
85
-    /**
86
-     * Sets the current page index
87
-     *
88
-     * @param int $page
89
-     */
90
-    public function setPage($page)
91
-    {
92
-        $this->page = $page;
93
-    }
94
-
95
-    /**
96
-     * Returns the current limit index
97
-     *
98
-     * @return int
99
-     */
100
-    public function getLimit()
101
-    {
102
-        return $this->limit;
103
-    }
104
-
105
-    /**
106
-     * Sets the current limit index
107
-     *
108
-     * @param int $limit
109
-     */
110
-    public function setLimit($limit)
111
-    {
112
-        $this->limit = $limit;
113
-    }
114
-
115
-    /**
116
-     * @return Array Items to display
117
-     */
118
-    public function getDisplayItems()
119
-    {
120
-        $last = $this->getLastPage();
121
-        if ($last == 1) {
122
-            return null;
123
-        }
124
-        $values = array();
125
-        for ($i = 1; $i <= $last; $i++) {
126
-            $values[] = array('key' => $i, 'value' => $i);
127
-        }
128
-        return $values;
129
-    }
130
-
131
-    /**
132
-     * @return int The last page index
133
-     */
134
-    public function getLastPage()
135
-    {
136
-        $last = intval($this->count / $this->limit);
137
-        if ($this->count % $this->limit > 0) {
138
-            $last++;
139
-        }
140
-        return $last;
141
-    }
142
-
143
-    /**
144
-     * @return int The previous page index. Minimum value is 1
145
-     */
146
-    public function getPreviousPage()
147
-    {
148
-        $prev = $this->page - 1;
149
-        if ($prev < 1) {
150
-            $prev = 1;
151
-        }
152
-        return $prev;
153
-    }
154
-
155
-    /**
156
-     * @return int The next page index. Maximum valus is the last page
157
-     */
158
-    public function getNextPage()
159
-    {
160
-        $next = $this->page + 1;
161
-        $last = $this->getLastPage();
162
-        if ($next > $last) {
163
-            $next = $last;
164
-        }
165
-        return $next;
166
-    }
167
-
168
-    /**
169
-     * @return int
170
-     */
171
-    public function getOffset()
172
-    {
173
-        return $this->offset;
174
-    }
175
-
176
-    /**
177
-     * @param int $offset
178
-     */
179
-    public function setOffset($offset)
180
-    {
181
-        $this->offset = $offset;
182
-    }
19
+	/**
20
+	 * Total amount of entries
21
+	 *
22
+	 * @var integer
23
+	 */
24
+	protected $count;
25
+
26
+	/**
27
+	 * Current offset
28
+	 *
29
+	 * @var integer
30
+	 */
31
+	protected $offset;
32
+
33
+	/**
34
+	 * Current page index
35
+	 *
36
+	 * @var integer
37
+	 */
38
+	protected $page;
39
+
40
+	/**
41
+	 * Number of items per page
42
+	 *
43
+	 * @var integer
44
+	 */
45
+	protected $limit = 10;
46
+
47
+	/**
48
+	 * Constructs a new Pager
49
+	 */
50
+	public function __construct()
51
+	{
52
+		$this->page = 1;
53
+	}
54
+
55
+	/**
56
+	 * Returns the total amount of entries
57
+	 *
58
+	 * @return int
59
+	 */
60
+	public function getCount()
61
+	{
62
+		return $this->count;
63
+	}
64
+
65
+	/**
66
+	 * Sets the total amount of entries
67
+	 *
68
+	 * @param int $count
69
+	 */
70
+	public function setCount($count)
71
+	{
72
+		$this->count = $count;
73
+	}
74
+
75
+	/**
76
+	 * Returns the current page index
77
+	 *
78
+	 * @return int
79
+	 */
80
+	public function getPage()
81
+	{
82
+		return $this->page;
83
+	}
84
+
85
+	/**
86
+	 * Sets the current page index
87
+	 *
88
+	 * @param int $page
89
+	 */
90
+	public function setPage($page)
91
+	{
92
+		$this->page = $page;
93
+	}
94
+
95
+	/**
96
+	 * Returns the current limit index
97
+	 *
98
+	 * @return int
99
+	 */
100
+	public function getLimit()
101
+	{
102
+		return $this->limit;
103
+	}
104
+
105
+	/**
106
+	 * Sets the current limit index
107
+	 *
108
+	 * @param int $limit
109
+	 */
110
+	public function setLimit($limit)
111
+	{
112
+		$this->limit = $limit;
113
+	}
114
+
115
+	/**
116
+	 * @return Array Items to display
117
+	 */
118
+	public function getDisplayItems()
119
+	{
120
+		$last = $this->getLastPage();
121
+		if ($last == 1) {
122
+			return null;
123
+		}
124
+		$values = array();
125
+		for ($i = 1; $i <= $last; $i++) {
126
+			$values[] = array('key' => $i, 'value' => $i);
127
+		}
128
+		return $values;
129
+	}
130
+
131
+	/**
132
+	 * @return int The last page index
133
+	 */
134
+	public function getLastPage()
135
+	{
136
+		$last = intval($this->count / $this->limit);
137
+		if ($this->count % $this->limit > 0) {
138
+			$last++;
139
+		}
140
+		return $last;
141
+	}
142
+
143
+	/**
144
+	 * @return int The previous page index. Minimum value is 1
145
+	 */
146
+	public function getPreviousPage()
147
+	{
148
+		$prev = $this->page - 1;
149
+		if ($prev < 1) {
150
+			$prev = 1;
151
+		}
152
+		return $prev;
153
+	}
154
+
155
+	/**
156
+	 * @return int The next page index. Maximum valus is the last page
157
+	 */
158
+	public function getNextPage()
159
+	{
160
+		$next = $this->page + 1;
161
+		$last = $this->getLastPage();
162
+		if ($next > $last) {
163
+			$next = $last;
164
+		}
165
+		return $next;
166
+	}
167
+
168
+	/**
169
+	 * @return int
170
+	 */
171
+	public function getOffset()
172
+	{
173
+		return $this->offset;
174
+	}
175
+
176
+	/**
177
+	 * @param int $offset
178
+	 */
179
+	public function setOffset($offset)
180
+	{
181
+		$this->offset = $offset;
182
+	}
183 183
 }
Please login to merge, or discard this patch.
Classes/Persistence/Order.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,45 +14,45 @@
 block discarded – undo
14 14
  */
15 15
 class Order
16 16
 {
17
-    /**
18
-     * The orderings
19
-     *
20
-     * @var array
21
-     */
22
-    protected $orderings = [];
17
+	/**
18
+	 * The orderings
19
+	 *
20
+	 * @var array
21
+	 */
22
+	protected $orderings = [];
23 23
 
24
-    /**
25
-     * Constructs a new Order
26
-     *
27
-     * @para array $orders
28
-     * @param array $orders
29
-     */
30
-    public function __construct($orders = array())
31
-    {
32
-        foreach ($orders as $order => $direction) {
33
-            $this->addOrdering($order, $direction);
34
-        }
35
-    }
24
+	/**
25
+	 * Constructs a new Order
26
+	 *
27
+	 * @para array $orders
28
+	 * @param array $orders
29
+	 */
30
+	public function __construct($orders = array())
31
+	{
32
+		foreach ($orders as $order => $direction) {
33
+			$this->addOrdering($order, $direction);
34
+		}
35
+	}
36 36
 
37
-    /**
38
-     * Add ordering
39
-     *
40
-     * @param string $order The order
41
-     * @param string $direction ASC / DESC
42
-     * @return void
43
-     */
44
-    public function addOrdering($order, $direction)
45
-    {
46
-        $this->orderings[$order] = $direction;
47
-    }
37
+	/**
38
+	 * Add ordering
39
+	 *
40
+	 * @param string $order The order
41
+	 * @param string $direction ASC / DESC
42
+	 * @return void
43
+	 */
44
+	public function addOrdering($order, $direction)
45
+	{
46
+		$this->orderings[$order] = $direction;
47
+	}
48 48
 
49
-    /**
50
-     * Returns the order
51
-     *
52
-     * @return array The order
53
-     */
54
-    public function getOrderings()
55
-    {
56
-        return $this->orderings;
57
-    }
49
+	/**
50
+	 * Returns the order
51
+	 *
52
+	 * @return array The order
53
+	 */
54
+	public function getOrderings()
55
+	{
56
+		return $this->orderings;
57
+	}
58 58
 }
Please login to merge, or discard this patch.