Completed
Push — master ( 4c54c0...a40619 )
by Fabien
10:04
created
Classes/Converter/Property.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -17,102 +17,102 @@
 block discarded – undo
17 17
 class Property
18 18
 {
19 19
 
20
-    /**
21
-     * @var string
22
-     */
23
-    static protected $currentProperty;
24
-
25
-    /**
26
-     * @var string
27
-     */
28
-    static protected $currentTable;
29
-
30
-    /**
31
-     * @var array
32
-     */
33
-    protected $storage = array();
34
-
35
-    /**
36
-     * @param string $propertyName
37
-     * @return $this
38
-     * @throws \InvalidArgumentException
39
-     */
40
-    static public 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
-    /**
61
-     * @return string
62
-     */
63
-    public function toFieldName()
64
-    {
65
-
66
-        $propertyName = $this->getPropertyName();
67
-        $tableName = $this->getTableName();
68
-
69
-        if (empty($this->storage[$tableName][$propertyName])) {
70
-            if ($this->storage[$tableName]) {
71
-                $this->storage[$tableName] = array();
72
-            }
73
-
74
-            // Default case
75
-            $fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
76
-
77
-            // Special case in case the field name does not follow the conventions "field_name" => "fieldName"
78
-            // There is the chance to make some mapping
79
-            if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'])) {
80
-                $key = array_search($propertyName, $GLOBALS['TCA'][$tableName]['vidi']['mappings']);
81
-                if ($key !== FALSE) {
82
-                    $fieldName = $key;
83
-                }
84
-            }
85
-
86
-            $this->storage[$tableName][$propertyName] = $fieldName;
87
-        }
88
-
89
-        return $this->storage[$tableName][$propertyName];
90
-    }
91
-
92
-    /**
93
-     * @return string
94
-     * @throws \RuntimeException
95
-     */
96
-    protected function getPropertyName()
97
-    {
98
-        $propertyName = self::$currentProperty;
99
-        if (empty($propertyName)) {
100
-            throw new \RuntimeException('I could not find a field name value.', 1403203290);
101
-        }
102
-        return $propertyName;
103
-    }
104
-
105
-    /**
106
-     * @return string
107
-     * @throws \RuntimeException
108
-     */
109
-    protected function getTableName()
110
-    {
111
-        $tableName = self::$currentTable;
112
-        if (empty($tableName)) {
113
-            throw new \RuntimeException('I could not find a table name value.', 1403203291);
114
-        }
115
-        return $tableName;
116
-    }
20
+	/**
21
+	 * @var string
22
+	 */
23
+	static protected $currentProperty;
24
+
25
+	/**
26
+	 * @var string
27
+	 */
28
+	static protected $currentTable;
29
+
30
+	/**
31
+	 * @var array
32
+	 */
33
+	protected $storage = array();
34
+
35
+	/**
36
+	 * @param string $propertyName
37
+	 * @return $this
38
+	 * @throws \InvalidArgumentException
39
+	 */
40
+	static public 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
+	/**
61
+	 * @return string
62
+	 */
63
+	public function toFieldName()
64
+	{
65
+
66
+		$propertyName = $this->getPropertyName();
67
+		$tableName = $this->getTableName();
68
+
69
+		if (empty($this->storage[$tableName][$propertyName])) {
70
+			if ($this->storage[$tableName]) {
71
+				$this->storage[$tableName] = array();
72
+			}
73
+
74
+			// Default case
75
+			$fieldName = GeneralUtility::camelCaseToLowerCaseUnderscored($propertyName);
76
+
77
+			// Special case in case the field name does not follow the conventions "field_name" => "fieldName"
78
+			// There is the chance to make some mapping
79
+			if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'])) {
80
+				$key = array_search($propertyName, $GLOBALS['TCA'][$tableName]['vidi']['mappings']);
81
+				if ($key !== FALSE) {
82
+					$fieldName = $key;
83
+				}
84
+			}
85
+
86
+			$this->storage[$tableName][$propertyName] = $fieldName;
87
+		}
88
+
89
+		return $this->storage[$tableName][$propertyName];
90
+	}
91
+
92
+	/**
93
+	 * @return string
94
+	 * @throws \RuntimeException
95
+	 */
96
+	protected function getPropertyName()
97
+	{
98
+		$propertyName = self::$currentProperty;
99
+		if (empty($propertyName)) {
100
+			throw new \RuntimeException('I could not find a field name value.', 1403203290);
101
+		}
102
+		return $propertyName;
103
+	}
104
+
105
+	/**
106
+	 * @return string
107
+	 * @throws \RuntimeException
108
+	 */
109
+	protected function getTableName()
110
+	{
111
+		$tableName = self::$currentTable;
112
+		if (empty($tableName)) {
113
+			throw new \RuntimeException('I could not find a table name value.', 1403203291);
114
+		}
115
+		return $tableName;
116
+	}
117 117
 
118 118
 }
Please login to merge, or discard this patch.
Classes/Converter/Field.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -18,98 +18,98 @@
 block discarded – undo
18 18
 class Field implements SingletonInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    static protected $currentField;
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    static protected $currentTable;
30
-
31
-    /**
32
-     * @var array
33
-     */
34
-    protected $storage = array();
35
-
36
-    /**
37
-     * @param string $fieldName
38
-     * @return $this
39
-     * @throws \InvalidArgumentException
40
-     */
41
-    static public function name($fieldName)
42
-    {
43
-        self::$currentField = $fieldName;
44
-        self::$currentTable = ''; // reset the table name value.
45
-        return GeneralUtility::makeInstance(self::class);
46
-    }
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
-    }
60
-
61
-    /**
62
-     * @return string
63
-     * @throws \RuntimeException
64
-     */
65
-    public function toPropertyName()
66
-    {
67
-
68
-        $fieldName = $this->getFieldName();
69
-        $tableName = $this->getTableName();
70
-
71
-        if (empty($this->storage[$tableName][$fieldName])) {
72
-            if ($this->storage[$tableName]) {
73
-                $this->storage[$tableName] = array();
74
-            }
75
-
76
-            // Special case when the field name does not follow the conventions "field_name" => "fieldName".
77
-            // Rely on mapping for those cases.
78
-            if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName])) {
79
-                $propertyName = $GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName];
80
-            } else {
81
-                $propertyName = GeneralUtility::underscoredToLowerCamelCase($fieldName);
82
-            }
83
-
84
-            $this->storage[$tableName][$fieldName] = $propertyName;
85
-        }
86
-
87
-        return $this->storage[$tableName][$fieldName];
88
-    }
89
-
90
-    /**
91
-     * @return string
92
-     * @throws \RuntimeException
93
-     */
94
-    protected function getFieldName()
95
-    {
96
-        $fieldName = self::$currentField;
97
-        if (empty($fieldName)) {
98
-            throw new \RuntimeException('I could not find a field name value.', 1403203290);
99
-        }
100
-        return $fieldName;
101
-    }
102
-
103
-    /**
104
-     * @return string
105
-     */
106
-    protected function getTableName()
107
-    {
108
-        $tableName = self::$currentTable;
109
-        if (empty($tableName)) {
110
-            throw new \RuntimeException('I could not find a table name value.', 1403203291);
111
-        }
112
-        return $tableName;
113
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	static protected $currentField;
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	static protected $currentTable;
30
+
31
+	/**
32
+	 * @var array
33
+	 */
34
+	protected $storage = array();
35
+
36
+	/**
37
+	 * @param string $fieldName
38
+	 * @return $this
39
+	 * @throws \InvalidArgumentException
40
+	 */
41
+	static public function name($fieldName)
42
+	{
43
+		self::$currentField = $fieldName;
44
+		self::$currentTable = ''; // reset the table name value.
45
+		return GeneralUtility::makeInstance(self::class);
46
+	}
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
+	}
60
+
61
+	/**
62
+	 * @return string
63
+	 * @throws \RuntimeException
64
+	 */
65
+	public function toPropertyName()
66
+	{
67
+
68
+		$fieldName = $this->getFieldName();
69
+		$tableName = $this->getTableName();
70
+
71
+		if (empty($this->storage[$tableName][$fieldName])) {
72
+			if ($this->storage[$tableName]) {
73
+				$this->storage[$tableName] = array();
74
+			}
75
+
76
+			// Special case when the field name does not follow the conventions "field_name" => "fieldName".
77
+			// Rely on mapping for those cases.
78
+			if (!empty($GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName])) {
79
+				$propertyName = $GLOBALS['TCA'][$tableName]['vidi']['mappings'][$fieldName];
80
+			} else {
81
+				$propertyName = GeneralUtility::underscoredToLowerCamelCase($fieldName);
82
+			}
83
+
84
+			$this->storage[$tableName][$fieldName] = $propertyName;
85
+		}
86
+
87
+		return $this->storage[$tableName][$fieldName];
88
+	}
89
+
90
+	/**
91
+	 * @return string
92
+	 * @throws \RuntimeException
93
+	 */
94
+	protected function getFieldName()
95
+	{
96
+		$fieldName = self::$currentField;
97
+		if (empty($fieldName)) {
98
+			throw new \RuntimeException('I could not find a field name value.', 1403203290);
99
+		}
100
+		return $fieldName;
101
+	}
102
+
103
+	/**
104
+	 * @return string
105
+	 */
106
+	protected function getTableName()
107
+	{
108
+		$tableName = self::$currentTable;
109
+		if (empty($tableName)) {
110
+			throw new \RuntimeException('I could not find a table name value.', 1403203291);
111
+		}
112
+		return $tableName;
113
+	}
114 114
 
115 115
 }
Please login to merge, or discard this patch.